Skip to:
Content

bbPress.org

Ticket #1402: topic-widget-errors.diff

File topic-widget-errors.diff, 3.4 KB (added by GautamGupta, 16 years ago)

Also contains some whitespace fixes

  • bbp-widgets.php

     
    3838
    3939                if ( bbp_has_forums( $default ) ) :
    4040                        echo "<ul>";
    41                         while ( bbp_forums ( ) ) : bbp_the_forum();
     41                        while ( bbp_forums() ) : bbp_the_forum();
    4242?>
    4343
    4444                                <li><a class="bbp-forum-title" href="<?php bbp_forum_permalink(); ?>" title="<?php bbp_forum_title(); ?>"><?php bbp_forum_title(); ?></a></li>
     
    101101                echo $before_widget;
    102102                echo $before_title . $title . $after_title;
    103103
    104                 if ( ($pop_check < $max_shown) && bbp_has_topics( $default ) ) :
     104                if ( $pop_check < $max_shown && bbp_has_topics( $default ) ) :
    105105                        echo "<ul>";
    106                         while ( bbp_topics ( ) ) : bbp_the_topic();
     106                        while ( bbp_topics() ) : bbp_the_topic();
    107107?>
    108108                                <li><a class="bbp-forum-title" href="<?php bbp_topic_permalink(); ?>" title="<?php bbp_topic_title(); ?>"><?php bbp_topic_title(); ?></a><?php if ( $show_date == 'on' )
    109109                                        _e( ', ' . bbp_get_topic_last_active() . ' ago' ); ?></li>
     
    112112                        echo "</ul>";
    113113                endif;
    114114
    115                 if ( ($pop_check >= $max_shown) && bbp_has_topics( $default ) ) :
     115                if ( $pop_check >= $max_shown && bbp_has_topics( $default ) ) :
    116116                        echo "<ul>";
    117117                        while ( bbp_topics ( ) ) : bbp_the_topic();
    118118                                $topics[bbp_get_topic_id()] = bbp_get_topic_reply_count();
     
    144144        }
    145145
    146146        function form( $instance ) {
    147                 $title     = esc_attr( $instance['title'] );
    148                 $max_shown = esc_attr( $instance['max_shown'] );
    149                 $show_date = esc_attr( $instance['show_date'] );
    150                 $pop_check = esc_attr( $instance['pop_check'] );
     147                $title     = !empty( $instance['title'] )     ? esc_attr( $instance['title'] )     : '';
     148                $max_shown = !empty( $instance['max_shown'] ) ? esc_attr( $instance['max_shown'] ) : '';
     149                $show_date = !empty( $instance['show_date'] ) ? esc_attr( $instance['show_date'] ) : '';
     150                $pop_check = !empty( $instance['pop_check'] ) ? esc_attr( $instance['pop_check'] ) : '';
    151151?>
    152152                <p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo $title; ?>" /></label></p>
    153153                <p><label for="<?php echo $this->get_field_id( 'max_shown' ); ?>"><?php _e( 'Maximum topics to show:' ); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'max_shown' ); ?>" name="<?php echo $this->get_field_name( 'max_shown' ); ?>" type="text" value="<?php echo $max_shown; ?>" /></label></p>
     
    191191                if ( bbp_has_replies( $default ) ) :
    192192                        echo "<ul>";
    193193
    194                         while ( bbp_replies ( ) ) : bbp_the_reply();
     194                        while ( bbp_replies() ) : bbp_the_reply();
    195195?>
    196196                                <li>
    197197                                        <a class="bbp-forum-title" href="<?php bbp_reply_permalink(); ?>" title="<?php bbp_reply_title(); ?>"><?php bbp_reply_title(); ?></a>
     
    229229
    230230}
    231231
    232 add_action( 'widgets_init', create_function( '', 'return register_widget("BBP_Forums_Widget");' ) );
    233 add_action( 'widgets_init', create_function( '', 'return register_widget("BBP_Topics_Widget");' ) );
     232add_action( 'widgets_init', create_function( '', 'return register_widget("BBP_Forums_Widget");'  ) );
     233add_action( 'widgets_init', create_function( '', 'return register_widget("BBP_Topics_Widget");'  ) );
    234234add_action( 'widgets_init', create_function( '', 'return register_widget("BBP_Replies_Widget");' ) );
    235235
    236236?>