PluginProbe
bbPress / 2.6.6
bbPress v2.6.6
2.6.17 trunk 2.0 2.0-beta-1 2.0-beta-2b 2.0-beta-3 2.0-beta-3b 2.0-rc-2 2.0-rc-3 2.0-rc-4 2.0-rc-5 2.0.1 2.0.2 2.0.3 2.1 2.1-beta-1 2.1-rc1 2.1-rc2 2.1-rc3 2.1-rc4 2.1.1 2.1.2 2.1.3 2.2 2.2.1 All 72 releases
← All changes | includes/common/widgets.php +208 -287 trunk2.6.6 View file →
@@ -1,8 +1,8 @@
1 1 <?php
2 2
3 3 /**
4 - * bbPress Widgets.
4 + * bbPress Widgets
5 5 *
6 6 * Contains the forum list, topic list, reply list and login form widgets.
7 7 *
8 8 * @package bbPress
@@ -12,11 +12,11 @@
12 12 // Exit if accessed directly
13 13 defined( 'ABSPATH' ) || exit;
14 14
15 15 /**
16 - * bbPress Login Widget.
16 + * bbPress Login Widget
17 17 *
18 - * Adds a widget which displays the login form.
18 + * Adds a widget which displays the login form
19 19 *
20 20 * @since 2.0.0 bbPress (r2827)
21 21 */
22 22 class BBP_Login_Widget extends WP_Widget {
@@ -21,29 +21,26 @@
21 21 */
22 22 class BBP_Login_Widget extends WP_Widget {
23 23
24 24 /**
25 - * bbPress Login Widget.
25 + * bbPress Login Widget
26 26 *
27 - * Registers the login widget.
27 + * Registers the login widget
28 28 *
29 29 * @since 2.0.0 bbPress (r2827)
30 30 */
31 31 public function __construct() {
32 - $widget_ops = apply_filters(
33 - 'bbp_login_widget_options',
34 - array(
35 - 'classname' => 'bbp_widget_login',
36 - 'description' => esc_html__( 'A simple login form with optional links to sign-up and lost password pages.', 'bbpress' ),
37 - 'customize_selective_refresh' => true
38 - )
39 - );
32 + $widget_ops = apply_filters( 'bbp_login_widget_options', array(
33 + 'classname' => 'bbp_widget_login',
34 + 'description' => esc_html__( 'A simple login form with optional links to sign-up and lost password pages.', 'bbpress' ),
35 + 'customize_selective_refresh' => true
36 + ) );
40 37
41 38 parent::__construct( false, esc_html__( '(bbPress) Login Widget', 'bbpress' ), $widget_ops );
42 39 }
43 40
44 41 /**
45 - * Register the widget.
42 + * Register the widget
46 43 *
47 44 * @since 2.0.0 bbPress (r3389)
48 45 */
49 46 public static function register_widget() {
@@ -50,14 +47,14 @@
50 47 register_widget( 'BBP_Login_Widget' );
51 48 }
52 49
53 50 /**
54 - * Displays the output, the login form.
51 + * Displays the output, the login form
55 52 *
56 53 * @since 2.0.0 bbPress (r2827)
57 54 *
58 - * @param array $args Arguments.
59 - * @param array $instance Instance.
55 + * @param array $args Arguments
56 + * @param array $instance Instance
60 57 */
61 58 public function widget( $args = array(), $instance = array() ) {
62 59
63 60 // Get widget settings
@@ -145,18 +142,18 @@
145 142 echo $args['after_widget'];
146 143 }
147 144
148 145 /**
149 - * Update the login widget options.
146 + * Update the login widget options
150 147 *
151 148 * @since 2.0.0 bbPress (r2827)
152 149 *
153 - * @param array $new_instance The new instance options.
154 - * @param array $old_instance The old instance options.
150 + * @param array $new_instance The new instance options
151 + * @param array $old_instance The old instance options
155 152 */
156 153 public function update( $new_instance, $old_instance ) {
157 154 $instance = $old_instance;
158 - $instance['title'] = wp_strip_all_tags( $new_instance['title'] );
155 + $instance['title'] = strip_tags( $new_instance['title'] );
159 156 $instance['register'] = esc_url_raw( $new_instance['register'] );
160 157 $instance['lostpass'] = esc_url_raw( $new_instance['lostpass'] );
161 158
162 159 return $instance;
@@ -162,13 +159,13 @@
162 159 return $instance;
163 160 }
164 161
165 162 /**
166 - * Output the login widget options form.
163 + * Output the login widget options form
167 164 *
168 165 * @since 2.0.0 bbPress (r2827)
169 166 *
170 - * @param $instance Instance.
167 + * @param $instance Instance
171 168 */
172 169 public function form( $instance = array() ) {
173 170
174 171 // Get widget settings
@@ -196,27 +193,23 @@
196 193 * Merge the widget settings into defaults array.
197 194 *
198 195 * @since 2.3.0 bbPress (r4802)
199 196 *
200 - * @param $instance Instance.
197 + * @param $instance Instance
201 198 */
202 199 public function parse_settings( $instance = array() ) {
203 - return bbp_parse_args(
204 - $instance,
205 - array(
206 - 'title' => '',
207 - 'register' => '',
208 - 'lostpass' => ''
209 - ),
210 - 'login_widget_settings'
211 - );
200 + return bbp_parse_args( $instance, array(
201 + 'title' => '',
202 + 'register' => '',
203 + 'lostpass' => ''
204 + ), 'login_widget_settings' );
212 205 }
213 206 }
214 207
215 208 /**
216 - * bbPress Views Widget.
209 + * bbPress Views Widget
217 210 *
218 - * Adds a widget which displays the view list.
211 + * Adds a widget which displays the view list
219 212 *
220 213 * @since 2.0.0 bbPress (r3020)
221 214 */
222 215 class BBP_Views_Widget extends WP_Widget {
@@ -221,29 +214,26 @@
221 214 */
222 215 class BBP_Views_Widget extends WP_Widget {
223 216
224 217 /**
225 - * bbPress View Widget.
218 + * bbPress View Widget
226 219 *
227 - * Registers the view widget.
220 + * Registers the view widget
228 221 *
229 222 * @since 2.0.0 bbPress (r3020)
230 223 */
231 224 public function __construct() {
232 - $widget_ops = apply_filters(
233 - 'bbp_views_widget_options',
234 - array(
235 - 'classname' => 'widget_display_views',
236 - 'description' => esc_html__( 'A list of registered optional topic views.', 'bbpress' ),
237 - 'customize_selective_refresh' => true
238 - )
239 - );
225 + $widget_ops = apply_filters( 'bbp_views_widget_options', array(
226 + 'classname' => 'widget_display_views',
227 + 'description' => esc_html__( 'A list of registered optional topic views.', 'bbpress' ),
228 + 'customize_selective_refresh' => true
229 + ) );
240 230
241 231 parent::__construct( false, esc_html__( '(bbPress) Topic Views List', 'bbpress' ), $widget_ops );
242 232 }
243 233
244 234 /**
245 - * Register the widget.
235 + * Register the widget
246 236 *
247 237 * @since 2.0.0 bbPress (r3389)
248 238 */
249 239 public static function register_widget() {
@@ -250,14 +240,14 @@
250 240 register_widget( 'BBP_Views_Widget' );
251 241 }
252 242
253 243 /**
254 - * Displays the output, the view list.
244 + * Displays the output, the view list
255 245 *
256 246 * @since 2.0.0 bbPress (r3020)
257 247 *
258 - * @param array $args Arguments.
259 - * @param array $instance Instance.
248 + * @param array $args Arguments
249 + * @param array $instance Instance
260 250 */
261 251 public function widget( $args = array(), $instance = array() ) {
262 252
263 253 // Only output widget contents if views exist
@@ -299,28 +289,28 @@
299 289 echo ob_get_clean();
300 290 }
301 291
302 292 /**
303 - * Update the view widget options.
293 + * Update the view widget options
304 294 *
305 295 * @since 2.0.0 bbPress (r3020)
306 296 *
307 - * @param array $new_instance The new instance options.
308 - * @param array $old_instance The old instance options.
297 + * @param array $new_instance The new instance options
298 + * @param array $old_instance The old instance options
309 299 */
310 300 public function update( $new_instance = array(), $old_instance = array() ) {
311 301 $instance = $old_instance;
312 - $instance['title'] = wp_strip_all_tags( $new_instance['title'] );
302 + $instance['title'] = strip_tags( $new_instance['title'] );
313 303
314 304 return $instance;
315 305 }
316 306
317 307 /**
318 - * Output the view widget options form.
308 + * Output the view widget options form
319 309 *
320 310 * @since 2.0.0 bbPress (r3020)
321 311 *
322 - * @param $instance Instance.
312 + * @param $instance Instance
323 313 */
324 314 public function form( $instance = array() ) {
325 315
326 316 // Get widget settings
@@ -339,25 +329,21 @@
339 329 * Merge the widget settings into defaults array.
340 330 *
341 331 * @since 2.3.0 bbPress (r4802)
342 332 *
343 - * @param $instance Instance.
333 + * @param $instance Instance
344 334 */
345 335 public function parse_settings( $instance = array() ) {
346 - return bbp_parse_args(
347 - $instance,
348 - array(
349 - 'title' => ''
350 - ),
351 - 'view_widget_settings'
352 - );
336 + return bbp_parse_args( $instance, array(
337 + 'title' => ''
338 + ), 'view_widget_settings' );
353 339 }
354 340 }
355 341
356 342 /**
357 - * bbPress Search Widget.
343 + * bbPress Search Widget
358 344 *
359 - * Adds a widget which displays the forum search form.
345 + * Adds a widget which displays the forum search form
360 346 *
361 347 * @since 2.3.0 bbPress (r4579)
362 348 */
363 349 class BBP_Search_Widget extends WP_Widget {
@@ -362,29 +348,26 @@
362 348 */
363 349 class BBP_Search_Widget extends WP_Widget {
364 350
365 351 /**
366 - * bbPress Search Widget.
352 + * bbPress Search Widget
367 353 *
368 - * Registers the search widget.
354 + * Registers the search widget
369 355 *
370 356 * @since 2.3.0 bbPress (r4579)
371 357 */
372 358 public function __construct() {
373 - $widget_ops = apply_filters(
374 - 'bbp_search_widget_options',
375 - array(
376 - 'classname' => 'widget_display_search',
377 - 'description' => esc_html__( 'The bbPress forum search form.', 'bbpress' ),
378 - 'customize_selective_refresh' => true
379 - )
380 - );
359 + $widget_ops = apply_filters( 'bbp_search_widget_options', array(
360 + 'classname' => 'widget_display_search',
361 + 'description' => esc_html__( 'The bbPress forum search form.', 'bbpress' ),
362 + 'customize_selective_refresh' => true
363 + ) );
381 364
382 365 parent::__construct( false, esc_html__( '(bbPress) Forum Search Form', 'bbpress' ), $widget_ops );
383 366 }
384 367
385 368 /**
386 - * Register the widget.
369 + * Register the widget
387 370 *
388 371 * @since 2.3.0 bbPress (r4579)
389 372 */
390 373 public static function register_widget() {
@@ -391,9 +374,9 @@
391 374 register_widget( 'BBP_Search_Widget' );
392 375 }
393 376
394 377 /**
395 - * Displays the output, the search form.
378 + * Displays the output, the search form
396 379 *
397 380 * @since 2.3.0 bbPress (r4579)
398 381 */
399 382 public function widget( $args, $instance ) {
@@ -423,28 +406,28 @@
423 406 echo $args['after_widget'];
424 407 }
425 408
426 409 /**
427 - * Update the widget options.
410 + * Update the widget options
428 411 *
429 412 * @since 2.3.0 bbPress (r4579)
430 413 *
431 - * @param array $new_instance The new instance options.
432 - * @param array $old_instance The old instance options.
414 + * @param array $new_instance The new instance options
415 + * @param array $old_instance The old instance options
433 416 */
434 417 public function update( $new_instance, $old_instance ) {
435 418 $instance = $old_instance;
436 - $instance['title'] = wp_strip_all_tags( $new_instance['title'] );
419 + $instance['title'] = strip_tags( $new_instance['title'] );
437 420
438 421 return $instance;
439 422 }
440 423
441 424 /**
442 - * Output the search widget options form.
425 + * Output the search widget options form
443 426 *
444 427 * @since 2.3.0 bbPress (r4579)
445 428 *
446 - * @param $instance Instance.
429 + * @param $instance Instance
447 430 */
448 431 public function form( $instance ) {
449 432
450 433 // Get widget settings
@@ -463,25 +446,21 @@
463 446 * Merge the widget settings into defaults array.
464 447 *
465 448 * @since 2.3.0 bbPress (r4802)
466 449 *
467 - * @param $instance Instance.
450 + * @param $instance Instance
468 451 */
469 452 public function parse_settings( $instance = array() ) {
470 - return bbp_parse_args(
471 - $instance,
472 - array(
473 - 'title' => esc_html__( 'Search Forums', 'bbpress' )
474 - ),
475 - 'search_widget_settings'
476 - );
453 + return bbp_parse_args( $instance, array(
454 + 'title' => esc_html__( 'Search Forums', 'bbpress' )
455 + ), 'search_widget_settings' );
477 456 }
478 457 }
479 458
480 459 /**
481 - * bbPress Forum Widget.
460 + * bbPress Forum Widget
482 461 *
483 - * Adds a widget which displays the forum list.
462 + * Adds a widget which displays the forum list
484 463 *
485 464 * @since 2.0.0 bbPress (r2653)
486 465 */
487 466 class BBP_Forums_Widget extends WP_Widget {
@@ -486,29 +465,26 @@
486 465 */
487 466 class BBP_Forums_Widget extends WP_Widget {
488 467
489 468 /**
490 - * bbPress Forum Widget.
469 + * bbPress Forum Widget
491 470 *
492 - * Registers the forum widget.
471 + * Registers the forum widget
493 472 *
494 473 * @since 2.0.0 bbPress (r2653)
495 474 */
496 475 public function __construct() {
497 - $widget_ops = apply_filters(
498 - 'bbp_forums_widget_options',
499 - array(
500 - 'classname' => 'widget_display_forums',
501 - 'description' => esc_html__( 'A list of forums with an option to set the parent.', 'bbpress' ),
502 - 'customize_selective_refresh' => true
503 - )
504 - );
476 + $widget_ops = apply_filters( 'bbp_forums_widget_options', array(
477 + 'classname' => 'widget_display_forums',
478 + 'description' => esc_html__( 'A list of forums with an option to set the parent.', 'bbpress' ),
479 + 'customize_selective_refresh' => true
480 + ) );
505 481
506 482 parent::__construct( false, esc_html__( '(bbPress) Forums List', 'bbpress' ), $widget_ops );
507 483 }
508 484
509 485 /**
510 - * Register the widget.
486 + * Register the widget
511 487 *
512 488 * @since 2.0.0 bbPress (r3389)
513 489 */
514 490 public static function register_widget() {
@@ -515,14 +491,14 @@
515 491 register_widget( 'BBP_Forums_Widget' );
516 492 }
517 493
518 494 /**
519 - * Displays the output, the forum list.
495 + * Displays the output, the forum list
520 496 *
521 497 * @since 2.0.0 bbPress (r2653)
522 498 *
523 - * @param array $args Arguments.
524 - * @param array $instance Instance.
499 + * @param array $args Arguments
500 + * @param array $instance Instance
525 501 */
526 502 public function widget( $args, $instance ) {
527 503
528 504 // Get widget settings
@@ -535,28 +511,26 @@
535 511 $settings['title'] = apply_filters( 'bbp_forum_widget_title', $settings['title'], $instance, $this->id_base );
536 512
537 513 // Note: private and hidden forums will be excluded via the
538 514 // bbp_pre_get_posts_normalize_forum_visibility action and function.
539 - $widget_query = new WP_Query(
540 - array(
515 + $widget_query = new WP_Query( array(
541 516
542 - // What and how
543 - 'post_type' => bbp_get_forum_post_type(),
544 - 'post_status' => bbp_get_public_status_id(),
545 - 'post_parent' => $settings['parent_forum'],
546 - 'posts_per_page' => (int) get_option( '_bbp_forums_per_page', 50 ),
517 + // What and how
518 + 'post_type' => bbp_get_forum_post_type(),
519 + 'post_status' => bbp_get_public_status_id(),
520 + 'post_parent' => $settings['parent_forum'],
521 + 'posts_per_page' => (int) get_option( '_bbp_forums_per_page', 50 ),
547 522
548 - // Order
549 - 'orderby' => 'menu_order title',
550 - 'order' => 'ASC',
523 + // Order
524 + 'orderby' => 'menu_order title',
525 + 'order' => 'ASC',
551 526
552 - // Performance
553 - 'ignore_sticky_posts' => true,
554 - 'no_found_rows' => true,
555 - 'update_post_term_cache' => false,
556 - 'update_post_meta_cache' => false
557 - )
558 - );
527 + // Performance
528 + 'ignore_sticky_posts' => true,
529 + 'no_found_rows' => true,
530 + 'update_post_term_cache' => false,
531 + 'update_post_meta_cache' => false
532 + ) );
559 533
560 534 // Bail if no posts
561 535 if ( ! $widget_query->have_posts() ) {
562 536 return;
@@ -569,12 +543,10 @@
569 543 } ?>
570 544
571 545 <ul class="bbp-forums-widget">
572 546
573 - <?php while ( $widget_query->have_posts() ) :
547 + <?php while ( $widget_query->have_posts() ) : $widget_query->the_post(); ?>
574 548
575 - $widget_query->the_post(); ?>
576 -
577 549 <li <?php echo ( bbp_get_forum_id() === $widget_query->post->ID ? ' class="bbp-forum-widget-current-forum"' : '' ); ?>>
578 550 <a class="bbp-forum-title" href="<?php bbp_forum_permalink( $widget_query->post->ID ); ?>">
579 551 <?php bbp_forum_title( $widget_query->post->ID ); ?>
580 552 </a>
@@ -590,18 +562,18 @@
590 562 wp_reset_postdata();
591 563 }
592 564
593 565 /**
594 - * Update the forum widget options.
566 + * Update the forum widget options
595 567 *
596 568 * @since 2.0.0 bbPress (r2653)
597 569 *
598 - * @param array $new_instance The new instance options.
599 - * @param array $old_instance The old instance options.
570 + * @param array $new_instance The new instance options
571 + * @param array $old_instance The old instance options
600 572 */
601 573 public function update( $new_instance, $old_instance ) {
602 574 $instance = $old_instance;
603 - $instance['title'] = wp_strip_all_tags( $new_instance['title'] );
575 + $instance['title'] = strip_tags( $new_instance['title'] );
604 576 $instance['parent_forum'] = sanitize_text_field( $new_instance['parent_forum'] );
605 577
606 578 // Force to any
607 579 if ( ! empty( $instance['parent_forum'] ) && ! is_numeric( $instance['parent_forum'] ) ) {
@@ -611,13 +583,13 @@
611 583 return $instance;
612 584 }
613 585
614 586 /**
615 - * Output the forum widget options form.
587 + * Output the forum widget options form
616 588 *
617 589 * @since 2.0.0 bbPress (r2653)
618 590 *
619 - * @param $instance Instance.
591 + * @param $instance Instance
620 592 */
621 593 public function form( $instance ) {
622 594
623 595 // Get widget settings
@@ -646,26 +618,22 @@
646 618 * Merge the widget settings into defaults array.
647 619 *
648 620 * @since 2.3.0 bbPress (r4802)
649 621 *
650 - * @param $instance Instance.
622 + * @param $instance Instance
651 623 */
652 624 public function parse_settings( $instance = array() ) {
653 - return bbp_parse_args(
654 - $instance,
655 - array(
656 - 'title' => esc_html__( 'Forums', 'bbpress' ),
657 - 'parent_forum' => 0
658 - ),
659 - 'forum_widget_settings'
660 - );
625 + return bbp_parse_args( $instance, array(
626 + 'title' => esc_html__( 'Forums', 'bbpress' ),
627 + 'parent_forum' => 0
628 + ), 'forum_widget_settings' );
661 629 }
662 630 }
663 631
664 632 /**
665 - * bbPress Topic Widget.
633 + * bbPress Topic Widget
666 634 *
667 - * Adds a widget which displays the topic list.
635 + * Adds a widget which displays the topic list
668 636 *
669 637 * @since 2.0.0 bbPress (r2653)
670 638 */
671 639 class BBP_Topics_Widget extends WP_Widget {
@@ -670,29 +638,26 @@
670 638 */
671 639 class BBP_Topics_Widget extends WP_Widget {
672 640
673 641 /**
674 - * bbPress Topic Widget.
642 + * bbPress Topic Widget
675 643 *
676 - * Registers the topic widget.
644 + * Registers the topic widget
677 645 *
678 646 * @since 2.0.0 bbPress (r2653)
679 647 */
680 648 public function __construct() {
681 - $widget_ops = apply_filters(
682 - 'bbp_topics_widget_options',
683 - array(
684 - 'classname' => 'widget_display_topics',
685 - 'description' => esc_html__( 'A list of recent topics, sorted by: newness, popularity, or recent replies.', 'bbpress' ),
686 - 'customize_selective_refresh' => true
687 - )
688 - );
649 + $widget_ops = apply_filters( 'bbp_topics_widget_options', array(
650 + 'classname' => 'widget_display_topics',
651 + 'description' => esc_html__( 'A list of recent topics, sorted by: newness, popularity, or recent replies.', 'bbpress' ),
652 + 'customize_selective_refresh' => true
653 + ) );
689 654
690 655 parent::__construct( false, esc_html__( '(bbPress) Recent Topics', 'bbpress' ), $widget_ops );
691 656 }
692 657
693 658 /**
694 - * Register the widget.
659 + * Register the widget
695 660 *
696 661 * @since 2.0.0 bbPress (r3389)
697 662 */
698 663 public static function register_widget() {
@@ -699,9 +664,9 @@
699 664 register_widget( 'BBP_Topics_Widget' );
700 665 }
701 666
702 667 /**
703 - * Displays the output, the topic list.
668 + * Displays the output, the topic list
704 669 *
705 670 * @since 2.0.0 bbPress (r2653)
706 671 *
707 672 * @param array $args
@@ -729,14 +694,12 @@
729 694 'post_type' => bbp_get_topic_post_type(),
730 695 'post_status' => bbp_get_public_topic_statuses(),
731 696 'post_parent' => $settings['parent_forum'],
732 697 'posts_per_page' => (int) $settings['max_shown'],
733 - 'meta_query' => array(
734 - array(
735 - 'key' => '_bbp_last_active_time',
736 - 'type' => 'DATETIME'
737 - )
738 - ),
698 + 'meta_query' => array( array(
699 + 'key' => '_bbp_last_active_time',
700 + 'type' => 'DATETIME'
701 + ) ),
739 702
740 703 // Ordering
741 704 'orderby' => 'meta_value',
742 705 'order' => 'DESC',
@@ -757,14 +720,12 @@
757 720 'post_type' => bbp_get_topic_post_type(),
758 721 'post_status' => bbp_get_public_topic_statuses(),
759 722 'post_parent' => $settings['parent_forum'],
760 723 'posts_per_page' => (int) $settings['max_shown'],
761 - 'meta_query' => array(
762 - array(
763 - 'key' => '_bbp_reply_count',
764 - 'type' => 'NUMERIC'
765 - )
766 - ),
724 + 'meta_query' => array( array(
725 + 'key' => '_bbp_reply_count',
726 + 'type' => 'NUMERIC'
727 + ) ),
767 728
768 729 // Ordering
769 730 'orderby' => 'meta_value_num',
770 731 'order' => 'DESC',
@@ -828,15 +789,9 @@
828 789 $author_link = '';
829 790
830 791 // Maybe get the topic author
831 792 if ( ! empty( $settings['show_user'] ) ) :
832 - $author_link = bbp_get_topic_author_link(
833 - array(
834 - 'post_id' => $topic_id,
835 - 'type' => 'both',
836 - 'size' => 14
837 - )
838 - );
793 + $author_link = bbp_get_topic_author_link( array( 'post_id' => $topic_id, 'type' => 'both', 'size' => 14 ) );
839 794 endif; ?>
840 795
841 796 <li>
842 797 <a class="bbp-forum-title" href="<?php bbp_topic_permalink( $topic_id ); ?>"><?php bbp_topic_title( $topic_id ); ?></a>
@@ -842,15 +797,9 @@
842 797 <a class="bbp-forum-title" href="<?php bbp_topic_permalink( $topic_id ); ?>"><?php bbp_topic_title( $topic_id ); ?></a>
843 798
844 799 <?php if ( ! empty( $author_link ) ) : ?>
845 800
846 - <?php
847 - printf(
848 - /* translators: %1$s: Topic author link wrapped in span tag */
849 - esc_html_x( 'by %1$s', 'widgets', 'bbpress' ),
850 - '<span class="topic-author">' . $author_link . '</span>'
851 - );
852 - ?>
801 + <?php printf( esc_html_x( 'by %1$s', 'widgets', 'bbpress' ), '<span class="topic-author">' . $author_link . '</span>' ); ?>
853 802
854 803 <?php endif; ?>
855 804
856 805 <?php if ( ! empty( $settings['show_date'] ) ) : ?>
@@ -874,19 +823,19 @@
874 823 echo ob_get_clean();
875 824 }
876 825
877 826 /**
878 - * Update the topic widget options.
827 + * Update the topic widget options
879 828 *
880 829 * @since 2.0.0 bbPress (r2653)
881 830 *
882 - * @param array $new_instance The new instance options.
883 - * @param array $old_instance The old instance options.
831 + * @param array $new_instance The new instance options
832 + * @param array $old_instance The old instance options
884 833 */
885 834 public function update( $new_instance = array(), $old_instance = array() ) {
886 835 $instance = $old_instance;
887 - $instance['title'] = wp_strip_all_tags( $new_instance['title'] );
888 - $instance['order_by'] = wp_strip_all_tags( $new_instance['order_by'] );
836 + $instance['title'] = strip_tags( $new_instance['title'] );
837 + $instance['order_by'] = strip_tags( $new_instance['order_by'] );
889 838 $instance['parent_forum'] = sanitize_text_field( $new_instance['parent_forum'] );
890 839 $instance['max_shown'] = (int) $new_instance['max_shown'];
891 840
892 841 // Date
@@ -907,13 +856,13 @@
907 856 return $instance;
908 857 }
909 858
910 859 /**
911 - * Output the topic widget options form.
860 + * Output the topic widget options form
912 861 *
913 862 * @since 2.0.0 bbPress (r2653)
914 863 *
915 - * @param $instance Instance.
864 + * @param $instance Instance
916 865 */
917 866 public function form( $instance = array() ) {
918 867
919 868 // Get widget settings
@@ -951,30 +900,26 @@
951 900 * Merge the widget settings into defaults array.
952 901 *
953 902 * @since 2.3.0 bbPress (r4802)
954 903 *
955 - * @param $instance Instance.
904 + * @param $instance Instance
956 905 */
957 906 public function parse_settings( $instance = array() ) {
958 - return bbp_parse_args(
959 - $instance,
960 - array(
961 - 'title' => esc_html__( 'Recent Topics', 'bbpress' ),
962 - 'max_shown' => 5,
963 - 'show_date' => false,
964 - 'show_user' => false,
965 - 'parent_forum' => 'any',
966 - 'order_by' => false
967 - ),
968 - 'topic_widget_settings'
969 - );
907 + return bbp_parse_args( $instance, array(
908 + 'title' => esc_html__( 'Recent Topics', 'bbpress' ),
909 + 'max_shown' => 5,
910 + 'show_date' => false,
911 + 'show_user' => false,
912 + 'parent_forum' => 'any',
913 + 'order_by' => false
914 + ), 'topic_widget_settings' );
970 915 }
971 916 }
972 917
973 918 /**
974 - * bbPress Statistics Widget.
919 + * bbPress Statistics Widget
975 920 *
976 - * Adds a widget which displays the forum statistics.
921 + * Adds a widget which displays the forum statistics
977 922 *
978 923 * @since 2.3.0 bbPress (r4509)
979 924 */
980 925 class BBP_Stats_Widget extends WP_Widget {
@@ -979,29 +924,26 @@
979 924 */
980 925 class BBP_Stats_Widget extends WP_Widget {
981 926
982 927 /**
983 - * bbPress Statistics Widget.
928 + * bbPress Statistics Widget
984 929 *
985 - * Registers the statistics widget.
930 + * Registers the statistics widget
986 931 *
987 932 * @since 2.3.0 bbPress (r4509)
988 933 */
989 934 public function __construct() {
990 - $widget_ops = apply_filters(
991 - 'bbp_stats_widget_options',
992 - array(
993 - 'classname' => 'widget_display_stats',
994 - 'description' => esc_html__( 'Some statistics from your forum.', 'bbpress' ),
995 - 'customize_selective_refresh' => true
996 - )
997 - );
935 + $widget_ops = apply_filters( 'bbp_stats_widget_options', array(
936 + 'classname' => 'widget_display_stats',
937 + 'description' => esc_html__( 'Some statistics from your forum.', 'bbpress' ),
938 + 'customize_selective_refresh' => true
939 + ) );
998 940
999 941 parent::__construct( false, esc_html__( '(bbPress) Statistics', 'bbpress' ), $widget_ops );
1000 942 }
1001 943
1002 944 /**
1003 - * Register the widget.
945 + * Register the widget
1004 946 *
1005 947 * @since 2.3.0 bbPress (r4509)
1006 948 */
1007 949 public static function register_widget() {
@@ -1008,14 +950,14 @@
1008 950 register_widget( 'BBP_Stats_Widget' );
1009 951 }
1010 952
1011 953 /**
1012 - * Displays the output, the statistics.
954 + * Displays the output, the statistics
1013 955 *
1014 956 * @since 2.3.0 bbPress (r4509)
1015 957 *
1016 - * @param array $args Arguments.
1017 - * @param array $instance Instance.
958 + * @param array $args Arguments
959 + * @param array $instance Instance
1018 960 */
1019 961 public function widget( $args = array(), $instance = array() ) {
1020 962
1021 963 // Get widget settings
@@ -1038,26 +980,26 @@
1038 980 echo $args['after_widget'];
1039 981 }
1040 982
1041 983 /**
1042 - * Update the statistics widget options.
984 + * Update the statistics widget options
1043 985 *
1044 986 * @since 2.3.0 bbPress (r4509)
1045 987 *
1046 - * @param array $new_instance The new instance options.
1047 - * @param array $old_instance The old instance options.
988 + * @param array $new_instance The new instance options
989 + * @param array $old_instance The old instance options
1048 990 *
1049 991 * @return array
1050 992 */
1051 993 public function update( $new_instance, $old_instance ) {
1052 994 $instance = $old_instance;
1053 - $instance['title'] = wp_strip_all_tags( $new_instance['title'] );
995 + $instance['title'] = strip_tags( $new_instance['title'] );
1054 996
1055 997 return $instance;
1056 998 }
1057 999
1058 1000 /**
1059 - * Output the statistics widget options form.
1001 + * Output the statistics widget options form
1060 1002 *
1061 1003 * @since 2.3.0 bbPress (r4509)
1062 1004 *
1063 1005 * @param $instance
@@ -1082,25 +1024,21 @@
1082 1024 * Merge the widget settings into defaults array.
1083 1025 *
1084 1026 * @since 2.3.0 bbPress (r4802)
1085 1027 *
1086 - * @param $instance Instance.
1028 + * @param $instance Instance
1087 1029 */
1088 1030 public function parse_settings( $instance = array() ) {
1089 - return bbp_parse_args(
1090 - $instance,
1091 - array(
1092 - 'title' => esc_html__( 'Forum Statistics', 'bbpress' )
1093 - ),
1094 - 'stats_widget_settings'
1095 - );
1031 + return bbp_parse_args( $instance, array(
1032 + 'title' => esc_html__( 'Forum Statistics', 'bbpress' )
1033 + ), 'stats_widget_settings' );
1096 1034 }
1097 1035 }
1098 1036
1099 1037 /**
1100 - * bbPress Replies Widget.
1038 + * bbPress Replies Widget
1101 1039 *
1102 - * Adds a widget which displays the replies list.
1040 + * Adds a widget which displays the replies list
1103 1041 *
1104 1042 * @since 2.0.0 bbPress (r2653)
1105 1043 */
1106 1044 class BBP_Replies_Widget extends WP_Widget {
@@ -1105,29 +1043,26 @@
1105 1043 */
1106 1044 class BBP_Replies_Widget extends WP_Widget {
1107 1045
1108 1046 /**
1109 - * bbPress Replies Widget.
1047 + * bbPress Replies Widget
1110 1048 *
1111 - * Registers the replies widget.
1049 + * Registers the replies widget
1112 1050 *
1113 1051 * @since 2.0.0 bbPress (r2653)
1114 1052 */
1115 1053 public function __construct() {
1116 - $widget_ops = apply_filters(
1117 - 'bbp_replies_widget_options',
1118 - array(
1119 - 'classname' => 'widget_display_replies',
1120 - 'description' => esc_html__( 'A list of the most recent replies.', 'bbpress' ),
1121 - 'customize_selective_refresh' => true
1122 - )
1123 - );
1054 + $widget_ops = apply_filters( 'bbp_replies_widget_options', array(
1055 + 'classname' => 'widget_display_replies',
1056 + 'description' => esc_html__( 'A list of the most recent replies.', 'bbpress' ),
1057 + 'customize_selective_refresh' => true
1058 + ) );
1124 1059
1125 1060 parent::__construct( false, esc_html__( '(bbPress) Recent Replies', 'bbpress' ), $widget_ops );
1126 1061 }
1127 1062
1128 1063 /**
1129 - * Register the widget.
1064 + * Register the widget
1130 1065 *
1131 1066 * @since 2.0.0 bbPress (r3389)
1132 1067 */
1133 1068 public static function register_widget() {
@@ -1134,9 +1069,9 @@
1134 1069 register_widget( 'BBP_Replies_Widget' );
1135 1070 }
1136 1071
1137 1072 /**
1138 - * Displays the output, the replies list.
1073 + * Displays the output, the replies list
1139 1074 *
1140 1075 * @since 2.0.0 bbPress (r2653)
1141 1076 *
1142 1077 * @param array $args
@@ -1154,23 +1089,21 @@
1154 1089 $settings['title'] = apply_filters( 'bbp_replies_widget_title', $settings['title'], $instance, $this->id_base );
1155 1090
1156 1091 // Note: private and hidden forums will be excluded via the
1157 1092 // bbp_pre_get_posts_normalize_forum_visibility action and function.
1158 - $widget_query = new WP_Query(
1159 - array(
1093 + $widget_query = new WP_Query( array(
1160 1094
1161 - // What and when
1162 - 'post_type' => bbp_get_reply_post_type(),
1163 - 'post_status' => bbp_get_public_reply_statuses(),
1164 - 'posts_per_page' => (int) $settings['max_shown'],
1095 + // What and when
1096 + 'post_type' => bbp_get_reply_post_type(),
1097 + 'post_status' => bbp_get_public_reply_statuses(),
1098 + 'posts_per_page' => (int) $settings['max_shown'],
1165 1099
1166 - // Performance
1167 - 'ignore_sticky_posts' => true,
1168 - 'no_found_rows' => true,
1169 - 'update_post_term_cache' => false,
1170 - 'update_post_meta_cache' => false
1171 - )
1172 - );
1100 + // Performance
1101 + 'ignore_sticky_posts' => true,
1102 + 'no_found_rows' => true,
1103 + 'update_post_term_cache' => false,
1104 + 'update_post_meta_cache' => false
1105 + ) );
1173 1106
1174 1107 // Bail if no replies
1175 1108 if ( ! $widget_query->have_posts() ) {
1176 1109 return;
@@ -1186,12 +1119,10 @@
1186 1119 } ?>
1187 1120
1188 1121 <ul class="bbp-replies-widget">
1189 1122
1190 - <?php while ( $widget_query->have_posts() ) :
1123 + <?php while ( $widget_query->have_posts() ) : $widget_query->the_post(); ?>
1191 1124
1192 - $widget_query->the_post(); ?>
1193 -
1194 1125 <li>
1195 1126
1196 1127 <?php
1197 1128
@@ -1202,15 +1133,9 @@
1202 1133 $show_date = '<time datetime="' . gmdate( 'Y-m-d H:i:s', $time ) . '">' . esc_html( bbp_get_time_since( $time ) ) . '</time>';
1203 1134
1204 1135 // Only query user if showing them
1205 1136 if ( ! empty( $settings['show_user'] ) ) :
1206 - $author_link = bbp_get_reply_author_link(
1207 - array(
1208 - 'post_id' => $reply_id,
1209 - 'type' => 'both',
1210 - 'size' => 14
1211 - )
1212 - );
1137 + $author_link = bbp_get_reply_author_link( array( 'post_id' => $reply_id, 'type' => 'both', 'size' => 14 ) );
1213 1138 else :
1214 1139 $author_link = false;
1215 1140 endif;
1216 1141
@@ -1216,9 +1141,9 @@
1216 1141
1217 1142 // Reply author, link, and timestamp
1218 1143 if ( ! empty( $settings['show_date'] ) && ! empty( $author_link ) ) :
1219 1144
1220 - /* translators: 1: reply author, 2: reply link, 3: reply timestamp */
1145 + // translators: 1: reply author, 2: reply link, 3: reply timestamp
1221 1146 printf( esc_html_x( '%1$s on %2$s %3$s', 'widgets', 'bbpress' ), $author_link, $reply_link, $show_date );
1222 1147
1223 1148 // Reply link and timestamp
1224 1149 elseif ( ! empty( $settings['show_date'] ) ) :
@@ -1226,9 +1151,9 @@
1226 1151
1227 1152 // Reply author and title
1228 1153 elseif ( ! empty( $author_link ) ) :
1229 1154
1230 - /* translators: 1: reply author, 2: reply link */
1155 + // translators: 1: reply author, 2: reply link
1231 1156 printf( esc_html_x( '%1$s on %2$s', 'widgets', 'bbpress' ), $author_link, $reply_link );
1232 1157
1233 1158 // Only the reply title
1234 1159 else :
@@ -1252,18 +1177,18 @@
1252 1177 echo ob_get_clean();
1253 1178 }
1254 1179
1255 1180 /**
1256 - * Update the reply widget options.
1181 + * Update the reply widget options
1257 1182 *
1258 1183 * @since 2.0.0 bbPress (r2653)
1259 1184 *
1260 - * @param array $new_instance The new instance options.
1261 - * @param array $old_instance The old instance options.
1185 + * @param array $new_instance The new instance options
1186 + * @param array $old_instance The old instance options
1262 1187 */
1263 1188 public function update( $new_instance = array(), $old_instance = array() ) {
1264 1189 $instance = $old_instance;
1265 - $instance['title'] = wp_strip_all_tags( $new_instance['title'] );
1190 + $instance['title'] = strip_tags( $new_instance['title'] );
1266 1191 $instance['max_shown'] = (int) $new_instance['max_shown'];
1267 1192
1268 1193 // Date
1269 1194 $instance['show_date'] = isset( $new_instance['show_date'] )
@@ -1278,13 +1203,13 @@
1278 1203 return $instance;
1279 1204 }
1280 1205
1281 1206 /**
1282 - * Output the reply widget options form.
1207 + * Output the reply widget options form
1283 1208 *
1284 1209 * @since 2.0.0 bbPress (r2653)
1285 1210 *
1286 - * @param $instance Instance.
1211 + * @param $instance Instance
1287 1212 */
1288 1213 public function form( $instance = array() ) {
1289 1214
1290 1215 // Get widget settings
@@ -1302,19 +1227,15 @@
1302 1227 * Merge the widget settings into defaults array.
1303 1228 *
1304 1229 * @since 2.3.0 bbPress (r4802)
1305 1230 *
1306 - * @param $instance Instance.
1231 + * @param $instance Instance
1307 1232 */
1308 1233 public function parse_settings( $instance = array() ) {
1309 - return bbp_parse_args(
1310 - $instance,
1311 - array(
1312 - 'title' => esc_html__( 'Recent Replies', 'bbpress' ),
1313 - 'max_shown' => 5,
1314 - 'show_date' => false,
1315 - 'show_user' => false
1316 - ),
1317 - 'replies_widget_settings'
1318 - );
1234 + return bbp_parse_args( $instance, array(
1235 + 'title' => esc_html__( 'Recent Replies', 'bbpress' ),
1236 + 'max_shown' => 5,
1237 + 'show_date' => false,
1238 + 'show_user' => false
1239 + ), 'replies_widget_settings' );
1319 1240 }
1320 1241 }