Changeset 7378 for trunk/src/includes/common/widgets.php
- Timestamp:
- 11/22/2025 06:05:25 AM (7 months ago)
- File:
-
- 1 edited
-
trunk/src/includes/common/widgets.php (modified) (28 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/common/widgets.php
r7374 r7378 30 30 */ 31 31 public function __construct() { 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 ) ); 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 ); 37 40 38 41 parent::__construct( false, esc_html__( '(bbPress) Login Widget', 'bbpress' ), $widget_ops ); … … 153 156 public function update( $new_instance, $old_instance ) { 154 157 $instance = $old_instance; 155 $instance['title'] = strip_tags( $new_instance['title'] );158 $instance['title'] = wp_strip_all_tags( $new_instance['title'] ); 156 159 $instance['register'] = esc_url_raw( $new_instance['register'] ); 157 160 $instance['lostpass'] = esc_url_raw( $new_instance['lostpass'] ); … … 198 201 */ 199 202 public function parse_settings( $instance = array() ) { 200 return bbp_parse_args( $instance, array( 201 'title' => '', 202 'register' => '', 203 'lostpass' => '' 204 ), 'login_widget_settings' ); 203 return bbp_parse_args( 204 $instance, 205 array( 206 'title' => '', 207 'register' => '', 208 'lostpass' => '' 209 ), 210 'login_widget_settings' 211 ); 205 212 } 206 213 } … … 223 230 */ 224 231 public function __construct() { 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 ) ); 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 ); 230 240 231 241 parent::__construct( false, esc_html__( '(bbPress) Topic Views List', 'bbpress' ), $widget_ops ); … … 300 310 public function update( $new_instance = array(), $old_instance = array() ) { 301 311 $instance = $old_instance; 302 $instance['title'] = strip_tags( $new_instance['title'] );312 $instance['title'] = wp_strip_all_tags( $new_instance['title'] ); 303 313 304 314 return $instance; … … 334 344 */ 335 345 public function parse_settings( $instance = array() ) { 336 return bbp_parse_args( $instance, array( 337 'title' => '' 338 ), 'view_widget_settings' ); 346 return bbp_parse_args( 347 $instance, 348 array( 349 'title' => '' 350 ), 351 'view_widget_settings' 352 ); 339 353 } 340 354 } … … 357 371 */ 358 372 public function __construct() { 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 ) ); 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 ); 364 381 365 382 parent::__construct( false, esc_html__( '(bbPress) Forum Search Form', 'bbpress' ), $widget_ops ); … … 417 434 public function update( $new_instance, $old_instance ) { 418 435 $instance = $old_instance; 419 $instance['title'] = strip_tags( $new_instance['title'] );436 $instance['title'] = wp_strip_all_tags( $new_instance['title'] ); 420 437 421 438 return $instance; … … 451 468 */ 452 469 public function parse_settings( $instance = array() ) { 453 return bbp_parse_args( $instance, array( 454 'title' => esc_html__( 'Search Forums', 'bbpress' ) 455 ), 'search_widget_settings' ); 470 return bbp_parse_args( 471 $instance, 472 array( 473 'title' => esc_html__( 'Search Forums', 'bbpress' ) 474 ), 475 'search_widget_settings' 476 ); 456 477 } 457 478 } … … 474 495 */ 475 496 public function __construct() { 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 ) ); 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 ); 481 505 482 506 parent::__construct( false, esc_html__( '(bbPress) Forums List', 'bbpress' ), $widget_ops ); … … 513 537 // Note: private and hidden forums will be excluded via the 514 538 // bbp_pre_get_posts_normalize_forum_visibility action and function. 515 $widget_query = new WP_Query( array( 516 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 ), 522 523 // Order 524 'orderby' => 'menu_order title', 525 'order' => 'ASC', 526 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 ) ); 539 $widget_query = new WP_Query( 540 array( 541 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 ), 547 548 // Order 549 'orderby' => 'menu_order title', 550 'order' => 'ASC', 551 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 ); 533 559 534 560 // Bail if no posts … … 573 599 public function update( $new_instance, $old_instance ) { 574 600 $instance = $old_instance; 575 $instance['title'] = strip_tags( $new_instance['title'] );601 $instance['title'] = wp_strip_all_tags( $new_instance['title'] ); 576 602 $instance['parent_forum'] = sanitize_text_field( $new_instance['parent_forum'] ); 577 603 … … 623 649 */ 624 650 public function parse_settings( $instance = array() ) { 625 return bbp_parse_args( $instance, array( 626 'title' => esc_html__( 'Forums', 'bbpress' ), 627 'parent_forum' => 0 628 ), 'forum_widget_settings' ); 651 return bbp_parse_args( 652 $instance, 653 array( 654 'title' => esc_html__( 'Forums', 'bbpress' ), 655 'parent_forum' => 0 656 ), 657 'forum_widget_settings' 658 ); 629 659 } 630 660 } … … 647 677 */ 648 678 public function __construct() { 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 ) ); 679 $widget_ops = apply_filters( 680 'bbp_topics_widget_options', 681 array( 682 'classname' => 'widget_display_topics', 683 'description' => esc_html__( 'A list of recent topics, sorted by: newness, popularity, or recent replies.', 'bbpress' ), 684 'customize_selective_refresh' => true 685 ) 686 ); 654 687 655 688 parent::__construct( false, esc_html__( '(bbPress) Recent Topics', 'bbpress' ), $widget_ops ); … … 696 729 'post_parent' => $settings['parent_forum'], 697 730 'posts_per_page' => (int) $settings['max_shown'], 698 'meta_query' => array( 731 'meta_query' => array( 699 732 array( 700 733 'key' => '_bbp_last_active_time', 701 734 'type' => 'DATETIME' 702 ) 735 ) 703 736 ), 704 737 … … 724 757 'post_parent' => $settings['parent_forum'], 725 758 'posts_per_page' => (int) $settings['max_shown'], 726 'meta_query' => array( 759 'meta_query' => array( 727 760 array( 728 761 'key' => '_bbp_reply_count', 729 762 'type' => 'NUMERIC' 730 ) 763 ) 731 764 ), 732 765 … … 795 828 // Maybe get the topic author 796 829 if ( ! empty( $settings['show_user'] ) ) : 797 $author_link = bbp_get_topic_author_link( array( 798 'post_id' => $topic_id, 799 'type' => 'both', 800 'size' => 14 801 ) ); 830 $author_link = bbp_get_topic_author_link( 831 array( 832 'post_id' => $topic_id, 833 'type' => 'both', 834 'size' => 14 835 ) 836 ); 802 837 endif; ?> 803 838 … … 807 842 <?php if ( ! empty( $author_link ) ) : ?> 808 843 809 <?php 810 printf( 844 <?php 845 printf( 811 846 /* translators: %1$s: Topic author link wrapped in span tag */ 812 esc_html_x( 'by %1$s', 'widgets', 'bbpress' ), '<span class="topic-author">' . $author_link . '</span>' 813 ); 847 esc_html_x( 'by %1$s', 'widgets', 'bbpress' ), 848 '<span class="topic-author">' . $author_link . '</span>' 849 ); 814 850 ?> 815 851 … … 847 883 public function update( $new_instance = array(), $old_instance = array() ) { 848 884 $instance = $old_instance; 849 $instance['title'] = strip_tags( $new_instance['title'] );850 $instance['order_by'] = strip_tags( $new_instance['order_by'] );885 $instance['title'] = wp_strip_all_tags( $new_instance['title'] ); 886 $instance['order_by'] = wp_strip_all_tags( $new_instance['order_by'] ); 851 887 $instance['parent_forum'] = sanitize_text_field( $new_instance['parent_forum'] ); 852 888 $instance['max_shown'] = (int) $new_instance['max_shown']; … … 918 954 */ 919 955 public function parse_settings( $instance = array() ) { 920 return bbp_parse_args( $instance, array( 921 'title' => esc_html__( 'Recent Topics', 'bbpress' ), 922 'max_shown' => 5, 923 'show_date' => false, 924 'show_user' => false, 925 'parent_forum' => 'any', 926 'order_by' => false 927 ), 'topic_widget_settings' ); 956 return bbp_parse_args( 957 $instance, 958 array( 959 'title' => esc_html__( 'Recent Topics', 'bbpress' ), 960 'max_shown' => 5, 961 'show_date' => false, 962 'show_user' => false, 963 'parent_forum' => 'any', 964 'order_by' => false 965 ), 966 'topic_widget_settings' 967 ); 928 968 } 929 969 } … … 946 986 */ 947 987 public function __construct() { 948 $widget_ops = apply_filters( 'bbp_stats_widget_options', array( 949 'classname' => 'widget_display_stats', 950 'description' => esc_html__( 'Some statistics from your forum.', 'bbpress' ), 951 'customize_selective_refresh' => true 952 ) ); 988 $widget_ops = apply_filters( 989 'bbp_stats_widget_options', 990 array( 991 'classname' => 'widget_display_stats', 992 'description' => esc_html__( 'Some statistics from your forum.', 'bbpress' ), 993 'customize_selective_refresh' => true 994 ) 995 ); 953 996 954 997 parent::__construct( false, esc_html__( '(bbPress) Statistics', 'bbpress' ), $widget_ops ); … … 1006 1049 public function update( $new_instance, $old_instance ) { 1007 1050 $instance = $old_instance; 1008 $instance['title'] = strip_tags( $new_instance['title'] );1051 $instance['title'] = wp_strip_all_tags( $new_instance['title'] ); 1009 1052 1010 1053 return $instance; … … 1042 1085 */ 1043 1086 public function parse_settings( $instance = array() ) { 1044 return bbp_parse_args( $instance, array( 1045 'title' => esc_html__( 'Forum Statistics', 'bbpress' ) 1046 ), 'stats_widget_settings' ); 1087 return bbp_parse_args( 1088 $instance, 1089 array( 1090 'title' => esc_html__( 'Forum Statistics', 'bbpress' ) 1091 ), 1092 'stats_widget_settings' 1093 ); 1047 1094 } 1048 1095 } … … 1065 1112 */ 1066 1113 public function __construct() { 1067 $widget_ops = apply_filters( 'bbp_replies_widget_options', array( 1068 'classname' => 'widget_display_replies', 1069 'description' => esc_html__( 'A list of the most recent replies.', 'bbpress' ), 1070 'customize_selective_refresh' => true 1071 ) ); 1114 $widget_ops = apply_filters( 1115 'bbp_replies_widget_options', 1116 array( 1117 'classname' => 'widget_display_replies', 1118 'description' => esc_html__( 'A list of the most recent replies.', 'bbpress' ), 1119 'customize_selective_refresh' => true 1120 ) 1121 ); 1072 1122 1073 1123 parent::__construct( false, esc_html__( '(bbPress) Recent Replies', 'bbpress' ), $widget_ops ); … … 1104 1154 // Note: private and hidden forums will be excluded via the 1105 1155 // bbp_pre_get_posts_normalize_forum_visibility action and function. 1106 $widget_query = new WP_Query( array( 1107 1108 // What and when 1109 'post_type' => bbp_get_reply_post_type(), 1110 'post_status' => bbp_get_public_reply_statuses(), 1111 'posts_per_page' => (int) $settings['max_shown'], 1112 1113 // Performance 1114 'ignore_sticky_posts' => true, 1115 'no_found_rows' => true, 1116 'update_post_term_cache' => false, 1117 'update_post_meta_cache' => false 1118 ) ); 1156 $widget_query = new WP_Query( 1157 array( 1158 1159 // What and when 1160 'post_type' => bbp_get_reply_post_type(), 1161 'post_status' => bbp_get_public_reply_statuses(), 1162 'posts_per_page' => (int) $settings['max_shown'], 1163 1164 // Performance 1165 'ignore_sticky_posts' => true, 1166 'no_found_rows' => true, 1167 'update_post_term_cache' => false, 1168 'update_post_meta_cache' => false 1169 ) 1170 ); 1119 1171 1120 1172 // Bail if no replies … … 1148 1200 // Only query user if showing them 1149 1201 if ( ! empty( $settings['show_user'] ) ) : 1150 $author_link = bbp_get_reply_author_link( array( 1151 'post_id' => $reply_id, 1152 'type' => 'both', 1153 'size' => 14 1154 ) ); 1202 $author_link = bbp_get_reply_author_link( 1203 array( 1204 'post_id' => $reply_id, 1205 'type' => 'both', 1206 'size' => 14 1207 ) 1208 ); 1155 1209 else : 1156 1210 $author_link = false; … … 1205 1259 public function update( $new_instance = array(), $old_instance = array() ) { 1206 1260 $instance = $old_instance; 1207 $instance['title'] = strip_tags( $new_instance['title'] );1261 $instance['title'] = wp_strip_all_tags( $new_instance['title'] ); 1208 1262 $instance['max_shown'] = (int) $new_instance['max_shown']; 1209 1263 … … 1249 1303 */ 1250 1304 public function parse_settings( $instance = array() ) { 1251 return bbp_parse_args( $instance, array( 1252 'title' => esc_html__( 'Recent Replies', 'bbpress' ), 1253 'max_shown' => 5, 1254 'show_date' => false, 1255 'show_user' => false 1256 ), 'replies_widget_settings' ); 1305 return bbp_parse_args( 1306 $instance, 1307 array( 1308 'title' => esc_html__( 'Recent Replies', 'bbpress' ), 1309 'max_shown' => 5, 1310 'show_date' => false, 1311 'show_user' => false 1312 ), 1313 'replies_widget_settings' 1314 ); 1257 1315 } 1258 1316 }
Note: See TracChangeset
for help on using the changeset viewer.