PluginProbe
bbPress / 2.6.6
bbPress v2.6.6
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 2.2.2 All 71 releases
← All changes | includes/admin/tools/common.php +83 -124 trunk2.6.6 View file →
@@ -1,8 +1,8 @@
1 1 <?php
2 2
3 3 /**
4 - * bbPress Admin Tools Common.
4 + * bbPress Admin Tools Common
5 5 *
6 6 * @package bbPress
7 7 * @subpackage Administration
8 8 */
@@ -10,9 +10,9 @@
10 10 // Exit if accessed directly
11 11 defined( 'ABSPATH' ) || exit;
12 12
13 13 /**
14 - * Return the current admin repair tool page.
14 + * Return the current admin repair tool page
15 15 *
16 16 * @since 2.6.0 bbPress (r6894)
17 17 *
18 18 * @return string
@@ -21,9 +21,9 @@
21 21 return sanitize_key( $_GET['page'] );
22 22 }
23 23
24 24 /**
25 - * Return the current admin repair tool page ID.
25 + * Return the current admin repair tool page ID
26 26 *
27 27 * @since 2.6.0 bbPress (r6894)
28 28 *
29 29 * @return string
@@ -43,9 +43,9 @@
43 43 return $page;
44 44 }
45 45
46 46 /**
47 - * Return a URL to the repair tool page.
47 + * Return a URL to the repair tool page
48 48 *
49 49 * @since 2.6.0 bbPress (r6894)
50 50 *
51 51 * @param array $args
@@ -54,20 +54,17 @@
54 54 */
55 55 function bbp_get_admin_repair_tool_page_url( $args = array() ) {
56 56
57 57 // Parse arguments
58 - $r = wp_parse_args(
59 - $args,
60 - array(
61 - 'page' => bbp_get_admin_repair_tool_page()
62 - )
63 - );
58 + $r = wp_parse_args( $args, array(
59 + 'page' => bbp_get_admin_repair_tool_page()
60 + ) );
64 61
65 62 return add_query_arg( $r, admin_url( 'tools.php' ) );
66 63 }
67 64
68 65 /**
69 - * Output the URL to run a specific repair tool.
66 + * Output the URL to run a specific repair tool
70 67 *
71 68 * @since 2.6.0 bbPress (r5885)
72 69 *
73 70 * @param string $component
@@ -75,38 +72,38 @@
75 72 function bbp_admin_repair_tool_run_url( $component = array() ) {
76 73 echo esc_url( bbp_get_admin_repair_tool_run_url( $component ) );
77 74 }
78 75
79 -/**
80 - * Return the URL to run a specific repair tool.
81 - *
82 - * @since 2.6.0 bbPress (r5885)
83 - *
84 - * @param string $component
85 - */
86 -function bbp_get_admin_repair_tool_run_url( $component = array() ) {
76 + /**
77 + * Return the URL to run a specific repair tool
78 + *
79 + * @since 2.6.0 bbPress (r5885)
80 + *
81 + * @param string $component
82 + */
83 + function bbp_get_admin_repair_tool_run_url( $component = array() ) {
87 84
88 - // Page
89 - $page = ( 'repair' === $component['type'] )
90 - ? 'bbp-repair'
91 - : 'bbp-upgrade';
85 + // Page
86 + $page = ( 'repair' === $component['type'] )
87 + ? 'bbp-repair'
88 + : 'bbp-upgrade';
92 89
93 - // Arguments
94 - $args = array(
95 - 'page' => $page,
96 - 'action' => 'run',
97 - 'checked' => array( $component['id'] )
98 - );
90 + // Arguments
91 + $args = array(
92 + 'page' => $page,
93 + 'action' => 'run',
94 + 'checked' => array( $component['id'] )
95 + );
99 96
100 - // Url
101 - $nonced = wp_nonce_url( bbp_get_admin_repair_tool_page_url( $args ), 'bbpress-do-counts' );
97 + // Url
98 + $nonced = wp_nonce_url( bbp_get_admin_repair_tool_page_url( $args ), 'bbpress-do-counts' );
102 99
103 - // Filter & return
104 - return apply_filters( 'bbp_get_admin_repair_tool_run_url', $nonced, $component );
105 -}
100 + // Filter & return
101 + return apply_filters( 'bbp_get_admin_repair_tool_run_url', $nonced, $component );
102 + }
106 103
107 104 /**
108 - * Assemble the admin notices.
105 + * Assemble the admin notices
109 106 *
110 107 * @since 2.0.0 bbPress (r2613)
111 108 *
112 109 * @param string|WP_Error $message A message to be displayed or {@link WP_Error}
@@ -119,9 +116,9 @@
119 116 return bbp_admin()->add_notice( $message, $class, $is_dismissible );
120 117 }
121 118
122 119 /**
123 - * Handle the processing and feedback of the admin tools page.
120 + * Handle the processing and feedback of the admin tools page
124 121 *
125 122 * @since 2.0.0 bbPress (r2613)
126 123 *
127 124 */
@@ -185,9 +182,9 @@
185 182 wp_cache_flush();
186 183 }
187 184
188 185 /**
189 - * Get the array of available repair tools.
186 + * Get the array of available repair tools
190 187 *
191 188 * @since 2.6.0 bbPress (r5885)
192 189 *
193 190 * @param string $type repair|upgrade The type of tools to get. Default empty for all tools.
@@ -209,9 +206,9 @@
209 206 return (array) apply_filters( 'bbp_get_admin_repair_tools', $tools, $type );
210 207 }
211 208
212 209 /**
213 - * Return array of components from the array of registered tools.
210 + * Return array of components from the array of registered tools
214 211 *
215 212 * @since 2.5.0 bbPress (r5885)
216 213 *
217 214 * @return array
@@ -221,9 +218,9 @@
221 218 // Default return value
222 219 $retval = array();
223 220
224 221 // Get tools
225 - $tools = bbp_get_admin_repair_tools( bbp_get_admin_repair_tool_page_id() );
222 + $tools = bbp_get_admin_repair_tools( bbp_get_admin_repair_tool_page_id() );
226 223
227 224 // Loop through tools
228 225 if ( ! empty( $tools ) ) {
229 226 $plucked = wp_list_pluck( $tools, 'components' );
@@ -249,14 +246,14 @@
249 246 return (array) apply_filters( 'bbp_get_admin_repair_tool_registered_components', $retval );
250 247 }
251 248
252 249 /**
253 - * Output the repair list search form.
250 + * Output the repair list search form
254 251 *
255 252 * @since 2.6.0 bbPress (r5885)
256 253 */
257 254 function bbp_admin_repair_list_search_form() {
258 -?>
255 + ?>
259 256
260 257 <p class="search-box">
261 258 <label class="screen-reader-text" for="bbp-repair-search-input"><?php esc_html_e( 'Search Tools:', 'bbpress' ); ?></label>
262 259 <input type="search" id="bbp-repair-search-input" name="s" value="<?php _admin_search_query(); ?>">
@@ -266,9 +263,9 @@
266 263 <?php
267 264 }
268 265
269 266 /**
270 - * Output a select drop-down of components to filter by.
267 + * Output a select drop-down of components to filter by
271 268 *
272 269 * @since 2.5.0 bbPress (r5885)
273 270 */
274 271 function bbp_admin_repair_list_components_filter() {
@@ -301,9 +298,9 @@
301 298 <?php
302 299 }
303 300
304 301 /**
305 - * Return array of versions from the array of registered tools.
302 + * Return array of versions from the array of registered tools
306 303 *
307 304 * @since 2.6.0 bbPress (r6894)
308 305 *
309 306 * @return array
@@ -313,9 +310,9 @@
313 310 // Default return value
314 311 $retval = array();
315 312
316 313 // Get tools
317 - $tools = bbp_get_admin_repair_tools( bbp_get_admin_repair_tool_page_id() );
314 + $tools = bbp_get_admin_repair_tools( bbp_get_admin_repair_tool_page_id() );
318 315
319 316 // Loop through tools
320 317 if ( ! empty( $tools ) ) {
321 318 $plucked = wp_list_pluck( $tools, 'version' );
@@ -352,9 +349,9 @@
352 349 return (array) apply_filters( 'bbp_get_admin_repair_tool_registered_versions', $retval );
353 350 }
354 351
355 352 /**
356 - * Output a select drop-down of versions to filter by.
353 + * Output a select drop-down of versions to filter by
357 354 *
358 355 * @since 2.5.0 bbPress (r6894)
359 356 */
360 357 function bbp_admin_repair_list_versions_filter() {
@@ -389,9 +386,9 @@
389 386
390 387 /** Translations **************************************************************/
391 388
392 389 /**
393 - * Maybe translate a repair tool overhead name.
390 + * Maybe translate a repair tool overhead name
394 391 *
395 392 * @since 2.6.0 bbPress (r6177)
396 393 *
397 394 * @param string $overhead
@@ -418,9 +415,9 @@
418 415 return $name;
419 416 }
420 417
421 418 /**
422 - * Maybe translate a repair tool component name.
419 + * Maybe translate a repair tool component name
423 420 *
424 421 * @since 2.6.0 bbPress (r5885)
425 422 *
426 423 * @param string $component
@@ -465,9 +462,9 @@
465 462 return $name;
466 463 }
467 464
468 465 /**
469 - * Maybe translate a repair tool overhead name.
466 + * Maybe translate a repair tool overhead name
470 467 *
471 468 * @since 2.6.0 bbPress (r6894)
472 469 *
473 470 * @param string $version
@@ -502,9 +499,9 @@
502 499 * set of tools.
503 500 *
504 501 * @since 2.0.0 bbPress (r2613)
505 502 *
506 - * @return array Repair list of options.
503 + * @return array Repair list of options
507 504 */
508 505 function bbp_admin_repair_list( $type = 'repair' ) {
509 506
510 507 // Define empty array
@@ -526,9 +523,9 @@
526 523 ? sanitize_key( $_GET['status'] )
527 524 : '';
528 525
529 526 // Overhead
530 - $overhead = ! empty( $_GET['overhead'] )
527 + $overhead = ! empty( $_GET['overhead'] )
531 528 ? sanitize_key( $_GET['overhead'] )
532 529 : '';
533 530
534 531 // Component
@@ -611,9 +608,9 @@
611 608 return (array) apply_filters( 'bbp_repair_list', $retval );
612 609 }
613 610
614 611 /**
615 - * Get filter links for components for a specific admin repair tool.
612 + * Get filter links for components for a specific admin repair tool
616 613 *
617 614 * @since 2.6.0 bbPress (r5885)
618 615 *
619 616 * @param array $item
@@ -648,9 +645,9 @@
648 645 return (array) apply_filters( 'bbp_get_admin_repair_tool_components', $links, $item );
649 646 }
650 647
651 648 /**
652 - * Get filter links for versions for a specific admin repair tool.
649 + * Get filter links for versions for a specific admin repair tool
653 650 *
654 651 * @since 2.6.0 bbPress (r6894)
655 652 *
656 653 * @param array $item
@@ -685,9 +682,9 @@
685 682 return (array) apply_filters( 'bbp_get_admin_repair_tool_version', $links, $item );
686 683 }
687 684
688 685 /**
689 - * Get filter links for overhead for a specific admin repair tool.
686 + * Get filter links for overhead for a specific admin repair tool
690 687 *
691 688 * @since 2.6.0 bbPress (r5885)
692 689 *
693 690 * @param array $item
@@ -724,9 +721,9 @@
724 721
725 722 /** Overhead ******************************************************************/
726 723
727 724 /**
728 - * Output filter links for overheads for a specific admin repair tool.
725 + * Output filter links for overheads for a specific admin repair tool
729 726 *
730 727 * @since 2.6.0 bbPress (r5885)
731 728 *
732 729 * @param array $args
@@ -735,9 +732,9 @@
735 732 echo bbp_get_admin_repair_tool_overhead_filters( $args );
736 733 }
737 734
738 735 /**
739 - * Get filter links for overheads for a specific admin repair tool.
736 + * Get filter links for overheads for a specific admin repair tool
740 737 *
741 738 * @since 2.6.0 bbPress (r5885)
742 739 *
743 740 * @param array $args
@@ -745,24 +742,20 @@
745 742 */
746 743 function bbp_get_admin_repair_tool_overhead_filters( $args = array() ) {
747 744
748 745 // Parse args
749 - $r = bbp_parse_args(
750 - $args,
751 - array(
752 - 'before' => '<ul class="subsubsub">',
753 - 'after' => '</ul>',
754 - 'link_before' => '<li>',
755 - 'link_after' => '</li>',
756 - 'count_before' => ' <span class="count">(',
757 - 'count_after' => ')</span>',
758 - 'sep' => ' | ',
746 + $r = bbp_parse_args( $args, array(
747 + 'before' => '<ul class="subsubsub">',
748 + 'after' => '</ul>',
749 + 'link_before' => '<li>',
750 + 'link_after' => '</li>',
751 + 'count_before' => ' <span class="count">(',
752 + 'count_after' => ')</span>',
753 + 'sep' => ' | ',
759 754
760 - // Retired, use 'sep' instead
761 - 'separator' => false
762 - ),
763 - 'get_admin_repair_tool_overhead_filters'
764 - );
755 + // Retired, use 'sep' instead
756 + 'separator' => false
757 + ), 'get_admin_repair_tool_overhead_filters' );
765 758
766 759 /**
767 760 * Necessary for backwards compatibility
768 761 * @see https://bbpress.trac.wordpress.org/ticket/2900
@@ -792,9 +785,9 @@
792 785 $overheads[ $overhead ] = 0;
793 786 }
794 787
795 788 // Bump the overhead count
796 - ++$overheads[ $overhead ];
789 + $overheads[ $overhead ]++;
797 790 }
798 791 }
799 792
800 793 // Get the current overhead, if any
@@ -803,24 +796,10 @@
803 796 : '';
804 797
805 798 // Create the "All" link
806 799 $current = empty( $selected ) ? 'current' : '';
800 + $links[] = $r['link_before'] . '<a href="' . esc_url( $tools_url ) . '" class="' . esc_attr( $current ) . '">' . sprintf( esc_html__( 'All %s', 'bbpress' ), $r['count_before'] . count( $tools ) . $r['count_after'] ) . '</a>' . $r['link_after'];
807 801
808 - $all_text = sprintf(
809 - /* translators: %s: Number of items */
810 - esc_html__( 'All %s', 'bbpress' ),
811 - $r['count_before'] . count( $tools ) . $r['count_after']
812 - );
813 -
814 - $links[] = sprintf(
815 - '%1$s<a href="%2$s" class="%3$s">%4$s</a>%5$s',
816 - $r['link_before'],
817 - esc_url( $tools_url ),
818 - esc_attr( $current ),
819 - $all_text,
820 - $r['link_after']
821 - );
822 -
823 802 // Loop through overheads and created links
824 803 if ( count( $overheads ) ) {
825 804
826 805 // Sort
@@ -858,9 +837,9 @@
858 837
859 838 /** Pending ******************************************************************/
860 839
861 840 /**
862 - * Output filter links for statuses.
841 + * Output filter links for statuses
863 842 *
864 843 * @since 2.6.0 bbPress (r6925)
865 844 *
866 845 * @param array $args
@@ -869,9 +848,9 @@
869 848 echo bbp_get_admin_repair_tool_status_filters( $args );
870 849 }
871 850
872 851 /**
873 - * Get filter links for statuses.
852 + * Get filter links for statuses
874 853 *
875 854 * @since 2.6.0 bbPress (r5885)
876 855 *
877 856 * @param array $args
@@ -879,24 +858,20 @@
879 858 */
880 859 function bbp_get_admin_repair_tool_status_filters( $args = array() ) {
881 860
882 861 // Parse args
883 - $r = bbp_parse_args(
884 - $args,
885 - array(
886 - 'before' => '<ul class="subsubsub">',
887 - 'after' => '</ul>',
888 - 'link_before' => '<li>',
889 - 'link_after' => '</li>',
890 - 'count_before' => ' <span class="count">(',
891 - 'count_after' => ')</span>',
892 - 'sep' => ' | ',
862 + $r = bbp_parse_args( $args, array(
863 + 'before' => '<ul class="subsubsub">',
864 + 'after' => '</ul>',
865 + 'link_before' => '<li>',
866 + 'link_after' => '</li>',
867 + 'count_before' => ' <span class="count">(',
868 + 'count_after' => ')</span>',
869 + 'sep' => ' | ',
893 870
894 - // Retired, use 'sep' instead
895 - 'separator' => false
896 - ),
897 - 'get_admin_repair_tool_status_filters'
898 - );
871 + // Retired, use 'sep' instead
872 + 'separator' => false
873 + ), 'get_admin_repair_tool_status_filters' );
899 874
900 875 /**
901 876 * Necessary for backwards compatibility
902 877 * @see https://bbpress.trac.wordpress.org/ticket/2900
@@ -935,14 +910,11 @@
935 910 // Sort
936 911 ksort( $pending );
937 912
938 913 // Build the filter URL
939 - $filter_url = add_query_arg(
940 - array(
941 - 'status' => 'pending'
942 - ),
943 - $tools_url
944 - );
914 + $filter_url = add_query_arg( array(
915 + 'status' => 'pending'
916 + ), $tools_url );
945 917
946 918 // Count HTML
947 919 $all_count = $r['count_before'] . count( $tools ) . $r['count_after'];
948 920 $pending_count = $r['count_before'] . count( $pending ) . $r['count_after'];
@@ -948,23 +920,10 @@
948 920 $pending_count = $r['count_before'] . count( $pending ) . $r['count_after'];
949 921
950 922 // Define links
951 923 $links = array(
952 - $r['link_before'] . '<a href="' . esc_url( $tools_url ) . '" class="' . esc_attr( $all_current ) . '">' .
953 - sprintf(
954 - /* translators: %s: Number of items */
955 - esc_html__( 'All %s', 'bbpress' ),
956 - $all_count
957 - ) .
958 - '</a>' . $r['link_after'],
959 -
960 - $r['link_before'] . '<a href="' . esc_url( $filter_url ) . '" class="' . esc_attr( $pending_current ) . '">' .
961 - sprintf(
962 - /* translators: %s: Number of pending items */
963 - esc_html__( 'Pending %s', 'bbpress' ),
964 - $pending_count
965 - ) .
966 - '</a>' . $r['link_after']
924 + $r['link_before'] . '<a href="' . esc_url( $tools_url ) . '" class="' . esc_attr( $all_current ) . '">' . sprintf( esc_html__( 'All %s', 'bbpress' ), $all_count ) . '</a>' . $r['link_after'],
925 + $r['link_before'] . '<a href="' . esc_url( $filter_url ) . '" class="' . esc_attr( $pending_current ) . '">' . sprintf( esc_html__( 'Pending %s', 'bbpress' ), $pending_count ) . '</a>' . $r['link_after']
967 926 );
968 927
969 928 // Surround output with before & after strings
970 929 $output = $r['before'] . implode( $r['sep'], $links ) . $r['after'];