Skip to:
Content

bbPress.org

Changeset 6506


Ignore:
Timestamp:
06/09/2017 04:45:11 AM (9 years ago)
Author:
johnjamesjacoby
Message:

Widgets: Audit all widget classes:

  • Use escaping GetText functions
  • Fix typos
  • Use more efficient queries for forum/topic/reply meta-boxes

Needs testing. See #3070.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/common/widgets.php

    r6384 r6506  
    3737                $widget_ops = apply_filters( 'bbp_login_widget_options', array(
    3838                        'classname'   => 'bbp_widget_login',
    39                         'description' => __( 'A simple login form with optional links to sign-up and lost password pages.', 'bbpress' )
     39                        'description' => esc_html__( 'A simple login form with optional links to sign-up and lost password pages.', 'bbpress' )
    4040                ) );
    4141
    42                 parent::__construct( false, __( '(bbPress) Login Widget', 'bbpress' ), $widget_ops );
     42                parent::__construct( false, esc_html__( '(bbPress) Login Widget', 'bbpress' ), $widget_ops );
    4343        }
    4444
     
    8787                        <form method="post" action="<?php bbp_wp_login_action( array( 'context' => 'login_post' ) ); ?>" class="bbp-login-form">
    8888                                <fieldset>
    89                                         <legend><?php _e( 'Log In', 'bbpress' ); ?></legend>
     89                                        <legend><?php esc_html_e( 'Log In', 'bbpress' ); ?></legend>
    9090
    9191                                        <div class="bbp-username">
    92                                                 <label for="user_login"><?php _e( 'Username', 'bbpress' ); ?>: </label>
     92                                                <label for="user_login"><?php esc_html_e( 'Username', 'bbpress' ); ?>: </label>
    9393                                                <input type="text" name="log" value="<?php bbp_sanitize_val( 'user_login', 'text' ); ?>" size="20" id="user_login" />
    9494                                        </div>
    9595
    9696                                        <div class="bbp-password">
    97                                                 <label for="user_pass"><?php _e( 'Password', 'bbpress' ); ?>: </label>
     97                                                <label for="user_pass"><?php esc_html_e( 'Password', 'bbpress' ); ?>: </label>
    9898                                                <input type="password" name="pwd" value="<?php bbp_sanitize_val( 'user_pass', 'password' ); ?>" size="20" id="user_pass" autocomplete="off" />
    9999                                        </div>
     
    101101                                        <div class="bbp-remember-me">
    102102                                                <input type="checkbox" name="rememberme" value="forever" <?php checked( bbp_get_sanitize_val( 'rememberme', 'checkbox' ), true, true ); ?> id="rememberme" />
    103                                                 <label for="rememberme"><?php _e( 'Remember Me', 'bbpress' ); ?></label>
     103                                                <label for="rememberme"><?php esc_html_e( 'Remember Me', 'bbpress' ); ?></label>
    104104                                        </div>
    105105
     
    108108                                                <?php do_action( 'login_form' ); ?>
    109109
    110                                                 <button type="submit" name="user-submit" id="user-submit" class="button submit user-submit"><?php _e( 'Log In', 'bbpress' ); ?></button>
     110                                                <button type="submit" name="user-submit" id="user-submit" class="button submit user-submit"><?php esc_html_e( 'Log In', 'bbpress' ); ?></button>
    111111
    112112                                                <?php bbp_user_login_fields(); ?>
     
    120120                                                        <?php if ( ! empty( $settings['register'] ) ) : ?>
    121121
    122                                                                 <a href="<?php echo esc_url( $settings['register'] ); ?>" title="<?php esc_attr_e( 'Register', 'bbpress' ); ?>" class="bbp-register-link"><?php _e( 'Register', 'bbpress' ); ?></a>
     122                                                                <a href="<?php echo esc_url( $settings['register'] ); ?>" title="<?php esc_attr_e( 'Register', 'bbpress' ); ?>" class="bbp-register-link"><?php esc_html_e( 'Register', 'bbpress' ); ?></a>
    123123
    124124                                                        <?php endif; ?>
     
    126126                                                        <?php if ( ! empty( $settings['lostpass'] ) ) : ?>
    127127
    128                                                                 <a href="<?php echo esc_url( $settings['lostpass'] ); ?>" title="<?php esc_attr_e( 'Lost Password', 'bbpress' ); ?>" class="bbp-lostpass-link"><?php _e( 'Lost Password', 'bbpress' ); ?></a>
     128                                                                <a href="<?php echo esc_url( $settings['lostpass'] ); ?>" title="<?php esc_attr_e( 'Lost Password', 'bbpress' ); ?>" class="bbp-lostpass-link"><?php esc_html_e( 'Lost Password', 'bbpress' ); ?></a>
    129129
    130130                                                        <?php endif; ?>
     
    183183
    184184                <p>
    185                         <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'bbpress' ); ?>
     185                        <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php esc_html_e( 'Title:', 'bbpress' ); ?>
    186186                        <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $settings['title'] ); ?>" /></label>
    187187                </p>
    188188
    189189                <p>
    190                         <label for="<?php echo $this->get_field_id( 'register' ); ?>"><?php _e( 'Register URI:', 'bbpress' ); ?>
     190                        <label for="<?php echo $this->get_field_id( 'register' ); ?>"><?php esc_html_e( 'Register URI:', 'bbpress' ); ?>
    191191                        <input class="widefat" id="<?php echo $this->get_field_id( 'register' ); ?>" name="<?php echo $this->get_field_name( 'register' ); ?>" type="text" value="<?php echo esc_url( $settings['register'] ); ?>" /></label>
    192192                </p>
    193193
    194194                <p>
    195                         <label for="<?php echo $this->get_field_id( 'lostpass' ); ?>"><?php _e( 'Lost Password URI:', 'bbpress' ); ?>
     195                        <label for="<?php echo $this->get_field_id( 'lostpass' ); ?>"><?php esc_html_e( 'Lost Password URI:', 'bbpress' ); ?>
    196196                        <input class="widefat" id="<?php echo $this->get_field_id( 'lostpass' ); ?>" name="<?php echo $this->get_field_name( 'lostpass' ); ?>" type="text" value="<?php echo esc_url( $settings['lostpass'] ); ?>" /></label>
    197197                </p>
     
    241241                $widget_ops = apply_filters( 'bbp_views_widget_options', array(
    242242                        'classname'   => 'widget_display_views',
    243                         'description' => __( 'A list of registered optional topic views.', 'bbpress' )
     243                        'description' => esc_html__( 'A list of registered optional topic views.', 'bbpress' )
    244244                ) );
    245245
    246                 parent::__construct( false, __( '(bbPress) Topic Views List', 'bbpress' ), $widget_ops );
     246                parent::__construct( false, esc_html__( '(bbPress) Topic Views List', 'bbpress' ), $widget_ops );
    247247        }
    248248
     
    286286                $settings['title'] = apply_filters( 'bbp_view_widget_title', $settings['title'], $instance, $this->id_base );
    287287
     288                // Start an output buffer
     289                ob_start();
     290
    288291                echo $args['before_widget'];
    289292
     
    292295                } ?>
    293296
    294                 <ul>
     297                <ul class="bbp-views-widget">
    295298
    296299                        <?php foreach ( array_keys( bbp_get_views() ) as $view ) : ?>
     
    303306
    304307                <?php echo $args['after_widget'];
     308
     309                // Output the current buffer
     310                echo ob_get_clean();
    305311        }
    306312
     
    335341
    336342                <p>
    337                         <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'bbpress' ); ?>
     343                        <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php esc_html_e( 'Title:', 'bbpress' ); ?>
    338344                                <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $settings['title'] ); ?>" />
    339345                        </label>
     
    382388                $widget_ops = apply_filters( 'bbp_search_widget_options', array(
    383389                        'classname'   => 'widget_display_search',
    384                         'description' => __( 'The bbPress forum search form.', 'bbpress' )
     390                        'description' => esc_html__( 'The bbPress forum search form.', 'bbpress' )
    385391                ) );
    386392
    387                 parent::__construct( false, __( '(bbPress) Forum Search Form', 'bbpress' ), $widget_ops );
     393                parent::__construct( false, esc_html__( '(bbPress) Forum Search Form', 'bbpress' ), $widget_ops );
    388394        }
    389395
     
    464470
    465471                <p>
    466                         <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'bbpress' ); ?>
     472                        <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php esc_html_e( 'Title:', 'bbpress' ); ?>
    467473                                <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $settings['title'] ); ?>" />
    468474                        </label>
     
    482488        public function parse_settings( $instance = array() ) {
    483489                return bbp_parse_args( $instance, array(
    484                         'title' => __( 'Search Forums', 'bbpress' )
     490                        'title' => esc_html__( 'Search Forums', 'bbpress' )
    485491                ), 'search_widget_settings' );
    486492        }
     
    511517                $widget_ops = apply_filters( 'bbp_forums_widget_options', array(
    512518                        'classname'   => 'widget_display_forums',
    513                         'description' => __( 'A list of forums with an option to set the parent.', 'bbpress' )
     519                        'description' => esc_html__( 'A list of forums with an option to set the parent.', 'bbpress' )
    514520                ) );
    515521
    516                 parent::__construct( false, __( '(bbPress) Forums List', 'bbpress' ), $widget_ops );
     522                parent::__construct( false, esc_html__( '(bbPress) Forums List', 'bbpress' ), $widget_ops );
    517523        }
    518524
     
    560566                // bbp_pre_get_posts_normalize_forum_visibility action and function.
    561567                $widget_query = new WP_Query( array(
    562                         'post_type'           => bbp_get_forum_post_type(),
    563                         'post_parent'         => $settings['parent_forum'],
    564                         'post_status'         => bbp_get_public_status_id(),
    565                         'posts_per_page'      => get_option( '_bbp_forums_per_page', 50 ),
    566                         'ignore_sticky_posts' => true,
    567                         'no_found_rows'       => true,
    568                         'orderby'             => 'menu_order title',
    569                         'order'               => 'ASC'
     568
     569                        // What and how
     570                        'post_type'      => bbp_get_forum_post_type(),
     571                        'post_status'    => bbp_get_public_status_id(),
     572                        'post_parent'    => $settings['parent_forum'],
     573                        'posts_per_page' => (int) get_option( '_bbp_forums_per_page', 50 ),
     574
     575                        // Order
     576                        'orderby' => 'menu_order title',
     577                        'order'   => 'DESC',
     578
     579                        // Performance
     580                        'ignore_sticky_posts'    => true,
     581                        'no_found_rows'          => true,
     582                        'nopaging'               => true,
     583                        'update_post_term_cache' => false,
     584                        'update_post_meta_cache' => false
    570585                ) );
    571586
     
    581596                } ?>
    582597
    583                 <ul>
     598                <ul class="bbp-forums-widget">
    584599
    585600                        <?php while ( $widget_query->have_posts() ) : $widget_query->the_post(); ?>
     
    637652
    638653                <p>
    639                         <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'bbpress' ); ?>
     654                        <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php esc_html_e( 'Title:', 'bbpress' ); ?>
    640655                                <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $settings['title'] ); ?>" />
    641656                        </label>
     
    643658
    644659                <p>
    645                         <label for="<?php echo $this->get_field_id( 'parent_forum' ); ?>"><?php _e( 'Parent Forum ID:', 'bbpress' ); ?>
     660                        <label for="<?php echo $this->get_field_id( 'parent_forum' ); ?>"><?php esc_html_e( 'Parent Forum ID:', 'bbpress' ); ?>
    646661                                <input class="widefat" id="<?php echo $this->get_field_id( 'parent_forum' ); ?>" name="<?php echo $this->get_field_name( 'parent_forum' ); ?>" type="text" value="<?php echo esc_attr( $settings['parent_forum'] ); ?>" />
    647662                        </label>
     
    649664                        <br />
    650665
    651                         <small><?php _e( '"0" to show only root - "any" to show all', 'bbpress' ); ?></small>
     666                        <small><?php esc_html_e( '"0" to show only root - "any" to show all', 'bbpress' ); ?></small>
    652667                </p>
    653668
     
    665680        public function parse_settings( $instance = array() ) {
    666681                return bbp_parse_args( $instance, array(
    667                         'title'        => __( 'Forums', 'bbpress' ),
     682                        'title'        => esc_html__( 'Forums', 'bbpress' ),
    668683                        'parent_forum' => 0
    669684                ), 'forum_widget_settings' );
     
    695710                $widget_ops = apply_filters( 'bbp_topics_widget_options', array(
    696711                        'classname'   => 'widget_display_topics',
    697                         'description' => __( 'A list of recent topics, sorted by: newness, popularity, or recent replies.', 'bbpress' )
     712                        'description' => esc_html__( 'A list of recent topics, sorted by: newness, popularity, or recent replies.', 'bbpress' )
    698713                ) );
    699714
    700                 parent::__construct( false, __( '(bbPress) Recent Topics', 'bbpress' ), $widget_ops );
     715                parent::__construct( false, esc_html__( '(bbPress) Recent Topics', 'bbpress' ), $widget_ops );
    701716        }
    702717
     
    743758                        case 'freshness' :
    744759                                $topics_query = array(
    745                                         'post_type'           => bbp_get_topic_post_type(),
    746                                         'post_parent'         => $settings['parent_forum'],
    747                                         'posts_per_page'      => (int) $settings['max_shown'],
    748                                         'post_status'         => bbp_get_public_topic_statuses(),
    749                                         'ignore_sticky_posts' => true,
    750                                         'no_found_rows'       => true,
    751                                         'meta_key'            => '_bbp_last_active_time',
    752                                         'meta_type'           => 'DATETIME',
    753                                         'orderby'             => 'meta_value',
    754                                         'order'               => 'DESC',
     760
     761                                        // What and how
     762                                        'post_type'      => bbp_get_topic_post_type(),
     763                                        'post_status'    => bbp_get_public_topic_statuses(),
     764                                        'post_parent'    => $settings['parent_forum'],
     765                                        'posts_per_page' => (int) $settings['max_shown'],
     766                                        'meta_query'     => array( array(
     767                                                'key'  => '_bbp_last_active_time',
     768                                                'type' => 'DATETIME'
     769                                        ) ),
     770
     771                                        // Ordering
     772                                        'orderby' => 'meta_value',
     773                                        'order'   => 'DESC',
     774
     775                                        // Performance
     776                                        'ignore_sticky_posts'    => true,
     777                                        'no_found_rows'          => true,
     778                                        'nopaging'               => true,
     779                                        'update_post_term_cache' => false,
     780                                        'update_post_meta_cache' => false
    755781                                );
    756782                                break;
     
    759785                        case 'popular' :
    760786                                $topics_query = array(
    761                                         'post_type'           => bbp_get_topic_post_type(),
    762                                         'post_parent'         => $settings['parent_forum'],
    763                                         'posts_per_page'      => (int) $settings['max_shown'],
    764                                         'post_status'         => bbp_get_public_topic_statuses(),
    765                                         'ignore_sticky_posts' => true,
    766                                         'no_found_rows'       => true,
    767                                         'meta_key'            => '_bbp_reply_count',
    768                                         'meta_type'           => 'NUMERIC',
    769                                         'orderby'             => 'meta_value_num',
    770                                         'order'               => 'DESC'
     787
     788                                        // What and how
     789                                        'post_type'      => bbp_get_topic_post_type(),
     790                                        'post_status'    => bbp_get_public_topic_statuses(),
     791                                        'post_parent'    => $settings['parent_forum'],
     792                                        'posts_per_page' => (int) $settings['max_shown'],
     793                                        'meta_query'     => array( array(
     794                                                'key'  => '_bbp_reply_count',
     795                                                'type' => 'NUMERIC'
     796                                        ) ),
     797
     798                                        // Ordering
     799                                        'orderby' => 'meta_value_num',
     800                                        'order'   => 'DESC',
     801
     802                                        // Performance
     803                                        'ignore_sticky_posts'    => true,
     804                                        'no_found_rows'          => true,
     805                                        'nopaging'               => true,
     806                                        'update_post_term_cache' => false,
     807                                        'update_post_meta_cache' => false
    771808                                );
    772809                                break;
     
    776813                        default :
    777814                                $topics_query = array(
    778                                         'post_type'           => bbp_get_topic_post_type(),
    779                                         'post_parent'         => $settings['parent_forum'],
    780                                         'posts_per_page'      => (int) $settings['max_shown'],
    781                                         'post_status'         => bbp_get_public_topic_statuses(),
    782                                         'ignore_sticky_posts' => true,
    783                                         'no_found_rows'       => true,
    784                                         'order'               => 'DESC'
     815
     816                                        // What and how
     817                                        'post_type'      => bbp_get_topic_post_type(),
     818                                        'post_status'    => bbp_get_public_topic_statuses(),
     819                                        'post_parent'    => $settings['parent_forum'],
     820                                        'posts_per_page' => (int) $settings['max_shown'],
     821
     822                                        // Ordering
     823                                        'orderby' => 'date',
     824                                        'order'   => 'DESC',
     825
     826                                        // Performance
     827                                        'ignore_sticky_posts'    => true,
     828                                        'no_found_rows'          => true,
     829                                        'nopaging'               => true,
     830                                        'update_post_term_cache' => false,
     831                                        'update_post_meta_cache' => false
    785832                                );
    786833                                break;
     
    796843                }
    797844
     845                // Start an output buffer
     846                ob_start();
     847
    798848                echo $args['before_widget'];
    799849
     
    802852                } ?>
    803853
    804                 <ul>
     854                <ul class="bbp-topics-widget <?php echo esc_attr( $settings['order_by'] ); ?>">
    805855
    806856                        <?php while ( $widget_query->have_posts() ) :
     
    820870                                        <?php if ( ! empty( $author_link ) ) : ?>
    821871
    822                                                 <?php printf( _x( 'by %1$s', 'widgets', 'bbpress' ), '<span class="topic-author">' . $author_link . '</span>' ); ?>
     872                                                <?php printf( esc_html_x( 'by %1$s', 'widgets', 'bbpress' ), '<span class="topic-author">' . $author_link . '</span>' ); ?>
    823873
    824874                                        <?php endif; ?>
     
    840890                // Reset the $post global
    841891                wp_reset_postdata();
     892
     893                // Output the current buffer
     894                echo ob_get_clean();
    842895        }
    843896
     
    881934                $settings = $this->parse_settings( $instance ); ?>
    882935
    883                 <p><label for="<?php echo $this->get_field_id( 'title'     ); ?>"><?php _e( 'Title:',                  'bbpress' ); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'title'     ); ?>" name="<?php echo $this->get_field_name( 'title'     ); ?>" type="text" value="<?php echo esc_attr( $settings['title']     ); ?>" /></label></p>
    884                 <p><label for="<?php echo $this->get_field_id( 'max_shown' ); ?>"><?php _e( 'Maximum topics to show:', 'bbpress' ); ?> <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 esc_attr( $settings['max_shown'] ); ?>" /></label></p>
     936                <p><label for="<?php echo $this->get_field_id( 'title'     ); ?>"><?php esc_html_e( 'Title:',                  'bbpress' ); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'title'     ); ?>" name="<?php echo $this->get_field_name( 'title'     ); ?>" type="text" value="<?php echo esc_attr( $settings['title']     ); ?>" /></label></p>
     937                <p><label for="<?php echo $this->get_field_id( 'max_shown' ); ?>"><?php esc_html_e( 'Maximum topics to show:', 'bbpress' ); ?> <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 esc_attr( $settings['max_shown'] ); ?>" /></label></p>
    885938
    886939                <p>
    887                         <label for="<?php echo $this->get_field_id( 'parent_forum' ); ?>"><?php _e( 'Parent Forum ID:', 'bbpress' ); ?>
     940                        <label for="<?php echo $this->get_field_id( 'parent_forum' ); ?>"><?php esc_html_e( 'Parent Forum ID:', 'bbpress' ); ?>
    888941                                <input class="widefat" id="<?php echo $this->get_field_id( 'parent_forum' ); ?>" name="<?php echo $this->get_field_name( 'parent_forum' ); ?>" type="text" value="<?php echo esc_attr( $settings['parent_forum'] ); ?>" />
    889942                        </label>
     
    891944                        <br />
    892945
    893                         <small><?php _e( '"0" to show only root - "any" to show all', 'bbpress' ); ?></small>
     946                        <small><?php esc_html_e( '"0" to show only root - "any" to show all', 'bbpress' ); ?></small>
    894947                </p>
    895948
    896                 <p><label for="<?php echo $this->get_field_id( 'show_date' ); ?>"><?php _e( 'Show post date:',    'bbpress' ); ?> <input type="checkbox" id="<?php echo $this->get_field_id( 'show_date' ); ?>" name="<?php echo $this->get_field_name( 'show_date' ); ?>" <?php checked( true, $settings['show_date'] ); ?> value="1" /></label></p>
    897                 <p><label for="<?php echo $this->get_field_id( 'show_user' ); ?>"><?php _e( 'Show topic author:', 'bbpress' ); ?> <input type="checkbox" id="<?php echo $this->get_field_id( 'show_user' ); ?>" name="<?php echo $this->get_field_name( 'show_user' ); ?>" <?php checked( true, $settings['show_user'] ); ?> value="1" /></label></p>
     949                <p><label for="<?php echo $this->get_field_id( 'show_date' ); ?>"><?php esc_html_e( 'Show post date:',    'bbpress' ); ?> <input type="checkbox" id="<?php echo $this->get_field_id( 'show_date' ); ?>" name="<?php echo $this->get_field_name( 'show_date' ); ?>" <?php checked( true, $settings['show_date'] ); ?> value="1" /></label></p>
     950                <p><label for="<?php echo $this->get_field_id( 'show_user' ); ?>"><?php esc_html_e( 'Show topic author:', 'bbpress' ); ?> <input type="checkbox" id="<?php echo $this->get_field_id( 'show_user' ); ?>" name="<?php echo $this->get_field_name( 'show_user' ); ?>" <?php checked( true, $settings['show_user'] ); ?> value="1" /></label></p>
    898951
    899952                <p>
    900                         <label for="<?php echo $this->get_field_id( 'order_by' ); ?>"><?php _e( 'Order By:', 'bbpress' ); ?></label>
     953                        <label for="<?php echo $this->get_field_id( 'order_by' ); ?>"><?php esc_html_e( 'Order By:', 'bbpress' ); ?></label>
    901954                        <select name="<?php echo $this->get_field_name( 'order_by' ); ?>" id="<?php echo $this->get_field_id( 'order_by' ); ?>">
    902                                 <option <?php selected( $settings['order_by'], 'newness' );   ?> value="newness"><?php _e( 'Newest Topics',                'bbpress' ); ?></option>
    903                                 <option <?php selected( $settings['order_by'], 'popular' );   ?> value="popular"><?php _e( 'Popular Topics',               'bbpress' ); ?></option>
    904                                 <option <?php selected( $settings['order_by'], 'freshness' ); ?> value="freshness"><?php _e( 'Topics With Recent Replies', 'bbpress' ); ?></option>
     955                                <option <?php selected( $settings['order_by'], 'newness'   ); ?> value="newness"><?php esc_html_e( 'Newest Topics',                'bbpress' ); ?></option>
     956                                <option <?php selected( $settings['order_by'], 'popular'   ); ?> value="popular"><?php esc_html_e( 'Popular Topics',               'bbpress' ); ?></option>
     957                                <option <?php selected( $settings['order_by'], 'freshness' ); ?> value="freshness"><?php esc_html_e( 'Topics With Recent Replies', 'bbpress' ); ?></option>
    905958                        </select>
    906959                </p>
     
    919972        public function parse_settings( $instance = array() ) {
    920973                return bbp_parse_args( $instance, array(
    921                         'title'        => __( 'Recent Topics', 'bbpress' ),
     974                        'title'        => esc_html__( 'Recent Topics', 'bbpress' ),
    922975                        'max_shown'    => 5,
    923976                        'show_date'    => false,
     
    930983
    931984/**
    932  * bbPress Stats Widget
     985 * bbPress Statistics Widget
    933986 *
    934987 * Adds a widget which displays the forum statistics
     
    941994
    942995        /**
    943          * bbPress Stats Widget
    944          *
    945          * Registers the stats widget
     996         * bbPress Statistics Widget
     997         *
     998         * Registers the statistics widget
    946999         *
    9471000         * @since 2.3.0 bbPress (r4509)
     
    9531006                $widget_ops = apply_filters( 'bbp_stats_widget_options', array(
    9541007                        'classname'   => 'widget_display_stats',
    955                         'description' => __( 'Some statistics from your forum.', 'bbpress' )
     1008                        'description' => esc_html__( 'Some statistics from your forum.', 'bbpress' )
    9561009                ) );
    9571010
    958                 parent::__construct( false, __( '(bbPress) Statistics', 'bbpress' ), $widget_ops );
     1011                parent::__construct( false, esc_html__( '(bbPress) Statistics', 'bbpress' ), $widget_ops );
    9591012        }
    9601013
     
    10041057
    10051058        /**
    1006          * Update the stats widget options
     1059         * Update the statistics widget options
    10071060         *
    10081061         * @since 2.3.0 bbPress (r4509)
     
    10211074
    10221075        /**
    1023          * Output the stats widget options form
     1076         * Output the statistics widget options form
    10241077         *
    10251078         * @since 2.3.0 bbPress (r4509)
     
    10351088
    10361089                <p>
    1037                         <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'bbpress' ); ?>
     1090                        <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php esc_html_e( 'Title:', 'bbpress' ); ?>
    10381091                                <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $settings['title'] ); ?>"/>
    10391092                        </label>
     
    10531106        public function parse_settings( $instance = array() ) {
    10541107                return bbp_parse_args( $instance, array(
    1055                         'title' => __( 'Forum Statistics', 'bbpress' )
    1056                 ),
    1057                 'stats_widget_settings' );
     1108                        'title' => esc_html__( 'Forum Statistics', 'bbpress' )
     1109                ), 'stats_widget_settings' );
    10581110        }
    10591111}
     
    10831135                $widget_ops = apply_filters( 'bbp_replies_widget_options', array(
    10841136                        'classname'   => 'widget_display_replies',
    1085                         'description' => __( 'A list of the most recent replies.', 'bbpress' )
     1137                        'description' => esc_html__( 'A list of the most recent replies.', 'bbpress' )
    10861138                ) );
    10871139
    1088                 parent::__construct( false, __( '(bbPress) Recent Replies', 'bbpress' ), $widget_ops );
     1140                parent::__construct( false, esc_html__( '(bbPress) Recent Replies', 'bbpress' ), $widget_ops );
    10891141        }
    10901142
     
    11301182                // bbp_pre_get_posts_normalize_forum_visibility action and function.
    11311183                $widget_query = new WP_Query( array(
    1132                         'post_type'           => bbp_get_reply_post_type(),
    1133                         'post_status'         => bbp_get_public_topic_statuses(),
    1134                         'posts_per_page'      => (int) $settings['max_shown'],
    1135                         'ignore_sticky_posts' => true,
    1136                         'no_found_rows'       => true,
     1184
     1185                        // What and when
     1186                        'post_type'      => bbp_get_reply_post_type(),
     1187                        'post_status'    => bbp_get_public_topic_statuses(),
     1188                        'posts_per_page' => (int) $settings['max_shown'],
     1189
     1190                        // Performance
     1191                        'ignore_sticky_posts'    => true,
     1192                        'no_found_rows'          => true,
     1193                        'nopaging'               => true,
     1194                        'update_post_term_cache' => false,
     1195                        'update_post_meta_cache' => false
    11371196                ) );
    11381197
     
    11421201                }
    11431202
     1203                // Start an output buffer
     1204                ob_start();
     1205
    11441206                echo $args['before_widget'];
    11451207
     
    11481210                } ?>
    11491211
    1150                 <ul>
     1212                <ul class="bbp-replies-widget">
    11511213
    11521214                        <?php while ( $widget_query->have_posts() ) : $widget_query->the_post(); ?>
     
    11711233
    11721234                                                // translators: 1: reply author, 2: reply link, 3: reply timestamp
    1173                                                 printf( _x( '%1$s on %2$s %3$s', 'widgets', 'bbpress' ), $author_link, $reply_link, '<div>' . bbp_get_time_since( get_the_time( 'U' ) ) . '</div>' );
     1235                                                printf( esc_html_x( '%1$s on %2$s %3$s', 'widgets', 'bbpress' ), $author_link, $reply_link, '<div>' . bbp_get_time_since( get_the_time( 'U' ) ) . '</div>' );
    11741236
    11751237                                        // Reply link and timestamp
     
    11771239
    11781240                                                // translators: 1: reply link, 2: reply timestamp
    1179                                                 printf( _x( '%1$s %2$s',         'widgets', 'bbpress' ), $reply_link,  '<div>' . bbp_get_time_since( get_the_time( 'U' ) ) . '</div>'              );
     1241                                                printf( esc_html_x( '%1$s %2$s',         'widgets', 'bbpress' ), $reply_link,  '<div>' . bbp_get_time_since( get_the_time( 'U' ) ) . '</div>'              );
    11801242
    11811243                                        // Reply author and title
     
    11831245
    11841246                                                // translators: 1: reply author, 2: reply link
    1185                                                 printf( _x( '%1$s on %2$s',      'widgets', 'bbpress' ), $author_link, $reply_link                                                                 );
     1247                                                printf( esc_html_x( '%1$s on %2$s',      'widgets', 'bbpress' ), $author_link, $reply_link                                                                 );
    11861248
    11871249                                        // Only the reply title
     
    11891251
    11901252                                                // translators: 1: reply link
    1191                                                 printf( _x( '%1$s',              'widgets', 'bbpress' ), $reply_link                                                                               );
     1253                                                printf( esc_html_x( '%1$s',              'widgets', 'bbpress' ), $reply_link                                                                               );
    11921254
    11931255                                        endif;
     
    12051267                // Reset the $post global
    12061268                wp_reset_postdata();
     1269
     1270                // Output the current buffer
     1271                echo ob_get_clean();
    12071272        }
    12081273
     
    12391304                $settings = $this->parse_settings( $instance ); ?>
    12401305
    1241                 <p><label for="<?php echo $this->get_field_id( 'title'     ); ?>"><?php _e( 'Title:',                   'bbpress' ); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'title'     ); ?>" name="<?php echo $this->get_field_name( 'title'     ); ?>" type="text" value="<?php echo esc_attr( $settings['title']     ); ?>" /></label></p>
    1242                 <p><label for="<?php echo $this->get_field_id( 'max_shown' ); ?>"><?php _e( 'Maximum replies to show:', 'bbpress' ); ?> <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 esc_attr( $settings['max_shown'] ); ?>" /></label></p>
    1243                 <p><label for="<?php echo $this->get_field_id( 'show_date' ); ?>"><?php _e( 'Show post date:',          'bbpress' ); ?> <input type="checkbox" id="<?php echo $this->get_field_id( 'show_date' ); ?>" name="<?php echo $this->get_field_name( 'show_date' ); ?>" <?php checked( true, $settings['show_date'] ); ?> value="1" /></label></p>
    1244                 <p><label for="<?php echo $this->get_field_id( 'show_user' ); ?>"><?php _e( 'Show reply author:',       'bbpress' ); ?> <input type="checkbox" id="<?php echo $this->get_field_id( 'show_user' ); ?>" name="<?php echo $this->get_field_name( 'show_user' ); ?>" <?php checked( true, $settings['show_user'] ); ?> value="1" /></label></p>
     1306                <p><label for="<?php echo $this->get_field_id( 'title'     ); ?>"><?php esc_html_e( 'Title:',                   'bbpress' ); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'title'     ); ?>" name="<?php echo $this->get_field_name( 'title'     ); ?>" type="text" value="<?php echo esc_attr( $settings['title']     ); ?>" /></label></p>
     1307                <p><label for="<?php echo $this->get_field_id( 'max_shown' ); ?>"><?php esc_html_e( 'Maximum replies to show:', 'bbpress' ); ?> <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 esc_attr( $settings['max_shown'] ); ?>" /></label></p>
     1308                <p><label for="<?php echo $this->get_field_id( 'show_date' ); ?>"><?php esc_html_e( 'Show post date:',          'bbpress' ); ?> <input type="checkbox" id="<?php echo $this->get_field_id( 'show_date' ); ?>" name="<?php echo $this->get_field_name( 'show_date' ); ?>" <?php checked( true, $settings['show_date'] ); ?> value="1" /></label></p>
     1309                <p><label for="<?php echo $this->get_field_id( 'show_user' ); ?>"><?php esc_html_e( 'Show reply author:',       'bbpress' ); ?> <input type="checkbox" id="<?php echo $this->get_field_id( 'show_user' ); ?>" name="<?php echo $this->get_field_name( 'show_user' ); ?>" <?php checked( true, $settings['show_user'] ); ?> value="1" /></label></p>
    12451310
    12461311                <?php
     
    12571322        public function parse_settings( $instance = array() ) {
    12581323                return bbp_parse_args( $instance, array(
    1259                         'title'     => __( 'Recent Replies', 'bbpress' ),
     1324                        'title'     => esc_html__( 'Recent Replies', 'bbpress' ),
    12601325                        'max_shown' => 5,
    12611326                        'show_date' => false,
    12621327                        'show_user' => false
    1263                 ),
    1264                 'replies_widget_settings' );
     1328                ), 'replies_widget_settings' );
    12651329        }
    12661330}
Note: See TracChangeset for help on using the changeset viewer.