diff --git a/src/wp-admin/includes/ajax-actions.php b/src/wp-admin/includes/ajax-actions.php
index 1df84f204e..259e14d5db 100644
|
a
|
b
|
function wp_ajax_search_plugins() { |
| 4829 | 4829 | network_admin_url( 'plugins.php', 'relative' ) |
| 4830 | 4830 | ); |
| 4831 | 4831 | |
| 4832 | | $GLOBALS['s'] = wp_unslash( $_POST['s'] ); |
| | 4832 | $GLOBALS['search_term'] = wp_unslash( $_POST['s'] ); |
| 4833 | 4833 | |
| 4834 | 4834 | $wp_list_table->prepare_items(); |
| 4835 | 4835 | |
diff --git a/src/wp-admin/includes/class-wp-links-list-table.php b/src/wp-admin/includes/class-wp-links-list-table.php
index b038f79a76..d60f4dddef 100644
|
a
|
b
|
class WP_Links_List_Table extends WP_List_Table { |
| 48 | 48 | * @global string $order |
| 49 | 49 | */ |
| 50 | 50 | public function prepare_items() { |
| 51 | | global $cat_id, $s, $orderby, $order; |
| | 51 | global $cat_id, $search_term, $orderby, $order; |
| 52 | 52 | |
| 53 | | $cat_id = ! empty( $_REQUEST['cat_id'] ) ? absint( $_REQUEST['cat_id'] ) : 0; |
| 54 | | $orderby = ! empty( $_REQUEST['orderby'] ) ? sanitize_text_field( $_REQUEST['orderby'] ) : ''; |
| 55 | | $order = ! empty( $_REQUEST['order'] ) ? sanitize_text_field( $_REQUEST['order'] ) : ''; |
| 56 | | $s = ! empty( $_REQUEST['s'] ) ? sanitize_text_field( $_REQUEST['s'] ) : ''; |
| | 53 | $cat_id = ! empty( $_REQUEST['cat_id'] ) ? absint( $_REQUEST['cat_id'] ) : 0; |
| | 54 | $orderby = ! empty( $_REQUEST['orderby'] ) ? sanitize_text_field( $_REQUEST['orderby'] ) : ''; |
| | 55 | $order = ! empty( $_REQUEST['order'] ) ? sanitize_text_field( $_REQUEST['order'] ) : ''; |
| | 56 | $search_term = ! empty( $_REQUEST['s'] ) ? sanitize_text_field( $_REQUEST['s'] ) : ''; |
| 57 | 57 | |
| 58 | 58 | $args = array( |
| 59 | 59 | 'hide_invisible' => 0, |
| … |
… |
class WP_Links_List_Table extends WP_List_Table { |
| 63 | 63 | if ( 'all' !== $cat_id ) { |
| 64 | 64 | $args['category'] = $cat_id; |
| 65 | 65 | } |
| 66 | | if ( ! empty( $s ) ) { |
| 67 | | $args['search'] = $s; |
| | 66 | if ( ! empty( $search_term ) ) { |
| | 67 | $args['search'] = $search_term; |
| 68 | 68 | } |
| 69 | 69 | if ( ! empty( $orderby ) ) { |
| 70 | 70 | $args['orderby'] = $orderby; |
diff --git a/src/wp-admin/includes/class-wp-ms-sites-list-table.php b/src/wp-admin/includes/class-wp-ms-sites-list-table.php
index 6097f5e13e..48962e2ee3 100644
|
a
|
b
|
class WP_MS_Sites_List_Table extends WP_List_Table { |
| 66 | 66 | * @global wpdb $wpdb WordPress database abstraction object. |
| 67 | 67 | */ |
| 68 | 68 | public function prepare_items() { |
| 69 | | global $mode, $s, $wpdb; |
| | 69 | global $mode, $search_term, $wpdb; |
| 70 | 70 | |
| 71 | 71 | if ( ! empty( $_REQUEST['mode'] ) ) { |
| 72 | 72 | $mode = 'excerpt' === $_REQUEST['mode'] ? 'excerpt' : 'list'; |
| … |
… |
class WP_MS_Sites_List_Table extends WP_List_Table { |
| 79 | 79 | |
| 80 | 80 | $pagenum = $this->get_pagenum(); |
| 81 | 81 | |
| 82 | | $s = isset( $_REQUEST['s'] ) ? wp_unslash( trim( $_REQUEST['s'] ) ) : ''; |
| 83 | | $wild = ''; |
| 84 | | if ( str_contains( $s, '*' ) ) { |
| 85 | | $wild = '*'; |
| 86 | | $s = trim( $s, '*' ); |
| | 82 | $search_term = isset( $_REQUEST['s'] ) ? wp_unslash( trim( $_REQUEST['s'] ) ) : ''; |
| | 83 | $wild = ''; |
| | 84 | if ( str_contains( $search_term, '*' ) ) { |
| | 85 | $wild = '*'; |
| | 86 | $search_term = trim( $search_term, '*' ); |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | /* |
| 90 | 90 | * If the network is large and a search is not being performed, show only |
| 91 | 91 | * the latest sites with no paging in order to avoid expensive count queries. |
| 92 | 92 | */ |
| 93 | | if ( ! $s && wp_is_large_network() ) { |
| | 93 | if ( ! $search_term && wp_is_large_network() ) { |
| 94 | 94 | if ( ! isset( $_REQUEST['orderby'] ) ) { |
| 95 | 95 | $_GET['orderby'] = ''; |
| 96 | 96 | $_REQUEST['orderby'] = ''; |
| … |
… |
class WP_MS_Sites_List_Table extends WP_List_Table { |
| 107 | 107 | 'network_id' => get_current_network_id(), |
| 108 | 108 | ); |
| 109 | 109 | |
| 110 | | if ( empty( $s ) ) { |
| | 110 | if ( empty( $search_term ) ) { |
| 111 | 111 | // Nothing to do. |
| 112 | | } elseif ( preg_match( '/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/', $s ) |
| 113 | | || preg_match( '/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.?$/', $s ) |
| 114 | | || preg_match( '/^[0-9]{1,3}\.[0-9]{1,3}\.?$/', $s ) |
| 115 | | || preg_match( '/^[0-9]{1,3}\.$/', $s ) |
| | 112 | } elseif ( preg_match( '/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/', $search_term ) |
| | 113 | || preg_match( '/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.?$/', $search_term ) |
| | 114 | || preg_match( '/^[0-9]{1,3}\.[0-9]{1,3}\.?$/', $search_term ) |
| | 115 | || preg_match( '/^[0-9]{1,3}\.$/', $search_term ) |
| 116 | 116 | ) { |
| 117 | 117 | // IPv4 address. |
| 118 | 118 | $reg_blog_ids = $wpdb->get_col( |
| 119 | 119 | $wpdb->prepare( |
| 120 | 120 | "SELECT blog_id FROM {$wpdb->registration_log} WHERE {$wpdb->registration_log}.IP LIKE %s", |
| 121 | | $wpdb->esc_like( $s ) . ( ! empty( $wild ) ? '%' : '' ) |
| | 121 | $wpdb->esc_like( $search_term ) . ( ! empty( $wild ) ? '%' : '' ) |
| 122 | 122 | ) |
| 123 | 123 | ); |
| 124 | 124 | |
| 125 | 125 | if ( $reg_blog_ids ) { |
| 126 | 126 | $args['site__in'] = $reg_blog_ids; |
| 127 | 127 | } |
| 128 | | } elseif ( is_numeric( $s ) && empty( $wild ) ) { |
| 129 | | $args['ID'] = $s; |
| | 128 | } elseif ( is_numeric( $search_term ) && empty( $wild ) ) { |
| | 129 | $args['ID'] = $search_term; |
| 130 | 130 | } else { |
| 131 | | $args['search'] = $s; |
| | 131 | $args['search'] = $search_term; |
| 132 | 132 | |
| 133 | 133 | if ( ! is_subdomain_install() ) { |
| 134 | 134 | $args['search_columns'] = array( 'path' ); |
diff --git a/src/wp-admin/includes/class-wp-ms-themes-list-table.php b/src/wp-admin/includes/class-wp-ms-themes-list-table.php
index 70187f44d4..a3fb02e960 100644
|
a
|
b
|
class WP_MS_Themes_List_Table extends WP_List_Table { |
| 97 | 97 | * @global string $s |
| 98 | 98 | */ |
| 99 | 99 | public function prepare_items() { |
| 100 | | global $status, $totals, $page, $orderby, $order, $s; |
| | 100 | global $status, $totals, $page, $orderby, $order, $search_term; |
| 101 | 101 | |
| 102 | | $orderby = ! empty( $_REQUEST['orderby'] ) ? sanitize_text_field( $_REQUEST['orderby'] ) : ''; |
| 103 | | $order = ! empty( $_REQUEST['order'] ) ? sanitize_text_field( $_REQUEST['order'] ) : ''; |
| 104 | | $s = ! empty( $_REQUEST['s'] ) ? sanitize_text_field( $_REQUEST['s'] ) : ''; |
| | 102 | $orderby = ! empty( $_REQUEST['orderby'] ) ? sanitize_text_field( $_REQUEST['orderby'] ) : ''; |
| | 103 | $order = ! empty( $_REQUEST['order'] ) ? sanitize_text_field( $_REQUEST['order'] ) : ''; |
| | 104 | $search_term = ! empty( $_REQUEST['s'] ) ? sanitize_text_field( $_REQUEST['s'] ) : ''; |
| 105 | 105 | |
| 106 | 106 | $themes = array( |
| 107 | 107 | /** |
| … |
… |
class WP_MS_Themes_List_Table extends WP_List_Table { |
| 202 | 202 | } |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | | if ( $s ) { |
| | 205 | if ( $search_term ) { |
| 206 | 206 | $status = 'search'; |
| 207 | 207 | $themes['search'] = array_filter( array_merge( $themes['all'], $themes['broken'] ), array( $this, '_search_callback' ) ); |
| 208 | 208 | } |
| … |
… |
class WP_MS_Themes_List_Table extends WP_List_Table { |
| 545 | 545 | * @param WP_Theme $theme The current WP_Theme object. |
| 546 | 546 | */ |
| 547 | 547 | public function column_name( $theme ) { |
| 548 | | global $status, $page, $s; |
| | 548 | global $status, $page, $search_term; |
| 549 | 549 | |
| 550 | 550 | $context = $status; |
| 551 | 551 | |
| … |
… |
class WP_MS_Themes_List_Table extends WP_List_Table { |
| 574 | 574 | 'action' => 'enable', |
| 575 | 575 | 'theme' => $theme_key, |
| 576 | 576 | 'paged' => $page, |
| 577 | | 's' => $s, |
| | 577 | 's' => $search_term, |
| 578 | 578 | ), |
| 579 | 579 | $url |
| 580 | 580 | ); |
| … |
… |
class WP_MS_Themes_List_Table extends WP_List_Table { |
| 600 | 600 | 'action' => 'disable', |
| 601 | 601 | 'theme' => $theme_key, |
| 602 | 602 | 'paged' => $page, |
| 603 | | 's' => $s, |
| | 603 | 's' => $search_term, |
| 604 | 604 | ), |
| 605 | 605 | $url |
| 606 | 606 | ); |
| … |
… |
class WP_MS_Themes_List_Table extends WP_List_Table { |
| 632 | 632 | 'checked[]' => $theme_key, |
| 633 | 633 | 'theme_status' => $context, |
| 634 | 634 | 'paged' => $page, |
| 635 | | 's' => $s, |
| | 635 | 's' => $search_term, |
| 636 | 636 | ), |
| 637 | 637 | 'themes.php' |
| 638 | 638 | ); |
diff --git a/src/wp-admin/includes/class-wp-plugins-list-table.php b/src/wp-admin/includes/class-wp-plugins-list-table.php
index 897e46cda2..f4286af2e8 100644
|
a
|
b
|
class WP_Plugins_List_Table extends WP_List_Table { |
| 88 | 88 | * @global string $s |
| 89 | 89 | */ |
| 90 | 90 | public function prepare_items() { |
| 91 | | global $status, $plugins, $totals, $page, $orderby, $order, $s; |
| | 91 | global $status, $plugins, $totals, $page, $orderby, $order, $search_term; |
| 92 | 92 | |
| 93 | 93 | $orderby = ! empty( $_REQUEST['orderby'] ) ? sanitize_text_field( $_REQUEST['orderby'] ) : ''; |
| 94 | 94 | $order = ! empty( $_REQUEST['order'] ) ? sanitize_text_field( $_REQUEST['order'] ) : ''; |
| … |
… |
class WP_Plugins_List_Table extends WP_List_Table { |
| 294 | 294 | } |
| 295 | 295 | } |
| 296 | 296 | |
| 297 | | if ( strlen( $s ) ) { |
| | 297 | if ( strlen( $search_term ) ) { |
| 298 | 298 | $status = 'search'; |
| 299 | 299 | $plugins['search'] = array_filter( $plugins['all'], array( $this, '_search_callback' ) ); |
| 300 | 300 | } |
| … |
… |
class WP_Plugins_List_Table extends WP_List_Table { |
| 372 | 372 | * @return bool |
| 373 | 373 | */ |
| 374 | 374 | public function _search_callback( $plugin ) { |
| 375 | | global $s; |
| | 375 | global $search_term; |
| 376 | 376 | |
| 377 | 377 | foreach ( $plugin as $value ) { |
| 378 | | if ( is_string( $value ) && false !== stripos( strip_tags( $value ), urldecode( $s ) ) ) { |
| | 378 | if ( is_string( $value ) && false !== stripos( strip_tags( $value ), urldecode( $search_term ) ) ) { |
| 379 | 379 | return true; |
| 380 | 380 | } |
| 381 | 381 | } |
| … |
… |
class WP_Plugins_List_Table extends WP_List_Table { |
| 721 | 721 | * @param array $item |
| 722 | 722 | */ |
| 723 | 723 | public function single_row( $item ) { |
| 724 | | global $status, $page, $s, $totals; |
| | 724 | global $status, $page, $search_term, $totals; |
| 725 | 725 | static $plugin_id_attrs = array(); |
| 726 | 726 | |
| 727 | 727 | list( $plugin_file, $plugin_data ) = $item; |
| … |
… |
class WP_Plugins_List_Table extends WP_List_Table { |
| 817 | 817 | '&plugin=' . urlencode( $plugin_file ) . |
| 818 | 818 | '&plugin_status=' . $context . |
| 819 | 819 | '&paged=' . $page . |
| 820 | | '&s=' . $s; |
| | 820 | '&s=' . $search_term; |
| 821 | 821 | |
| 822 | 822 | $actions['deactivate'] = sprintf( |
| 823 | 823 | '<a href="%s" id="deactivate-%s" aria-label="%s">%s</a>', |
| … |
… |
class WP_Plugins_List_Table extends WP_List_Table { |
| 842 | 842 | '&plugin=' . urlencode( $plugin_file ) . |
| 843 | 843 | '&plugin_status=' . $context . |
| 844 | 844 | '&paged=' . $page . |
| 845 | | '&s=' . $s; |
| | 845 | '&s=' . $search_term; |
| 846 | 846 | |
| 847 | 847 | $actions['activate'] = sprintf( |
| 848 | 848 | '<a href="%s" id="activate-%s" class="edit" aria-label="%s">%s</a>', |
| … |
… |
class WP_Plugins_List_Table extends WP_List_Table { |
| 872 | 872 | '&checked[]=' . urlencode( $plugin_file ) . |
| 873 | 873 | '&plugin_status=' . $context . |
| 874 | 874 | '&paged=' . $page . |
| 875 | | '&s=' . $s; |
| | 875 | '&s=' . $search_term; |
| 876 | 876 | |
| 877 | 877 | $actions['delete'] = sprintf( |
| 878 | 878 | '<a href="%s" id="delete-%s" class="delete" aria-label="%s">%s</a>', |
| … |
… |
class WP_Plugins_List_Table extends WP_List_Table { |
| 906 | 906 | '&plugin=' . urlencode( $plugin_file ) . |
| 907 | 907 | '&plugin_status=' . $context . |
| 908 | 908 | '&paged=' . $page . |
| 909 | | '&s=' . $s; |
| | 909 | '&s=' . $search_term; |
| 910 | 910 | |
| 911 | 911 | $actions['deactivate'] = sprintf( |
| 912 | 912 | '<a href="%s" id="deactivate-%s" aria-label="%s">%s</a>', |
| … |
… |
class WP_Plugins_List_Table extends WP_List_Table { |
| 924 | 924 | '&plugin=' . urlencode( $plugin_file ) . |
| 925 | 925 | '&plugin_status=' . $context . |
| 926 | 926 | '&paged=' . $page . |
| 927 | | '&s=' . $s; |
| | 927 | '&s=' . $search_term; |
| 928 | 928 | |
| 929 | 929 | $actions['resume'] = sprintf( |
| 930 | 930 | '<a href="%s" id="resume-%s" class="resume-link" aria-label="%s">%s</a>', |
| … |
… |
class WP_Plugins_List_Table extends WP_List_Table { |
| 948 | 948 | '&plugin=' . urlencode( $plugin_file ) . |
| 949 | 949 | '&plugin_status=' . $context . |
| 950 | 950 | '&paged=' . $page . |
| 951 | | '&s=' . $s; |
| | 951 | '&s=' . $search_term; |
| 952 | 952 | |
| 953 | 953 | $actions['activate'] = sprintf( |
| 954 | 954 | '<a href="%s" id="activate-%s" class="edit" aria-label="%s">%s</a>', |
| … |
… |
class WP_Plugins_List_Table extends WP_List_Table { |
| 978 | 978 | '&checked[]=' . urlencode( $plugin_file ) . |
| 979 | 979 | '&plugin_status=' . $context . |
| 980 | 980 | '&paged=' . $page . |
| 981 | | '&s=' . $s; |
| | 981 | '&s=' . $search_term; |
| 982 | 982 | |
| 983 | 983 | $actions['delete'] = sprintf( |
| 984 | 984 | '<a href="%s" id="delete-%s" class="delete" aria-label="%s">%s</a>', |
diff --git a/src/wp-admin/network/sites.php b/src/wp-admin/network/sites.php
index 17a072287d..208ef37c51 100644
|
a
|
b
|
if ( isset( $_REQUEST['s'] ) && strlen( $_REQUEST['s'] ) ) { |
| 411 | 411 | printf( |
| 412 | 412 | /* translators: %s: Search query. */ |
| 413 | 413 | __( 'Search results for: %s' ), |
| 414 | | '<strong>' . esc_html( $s ) . '</strong>' |
| | 414 | '<strong>' . esc_html( $search_term ) . '</strong>' |
| 415 | 415 | ); |
| 416 | 416 | echo '</span>'; |
| 417 | 417 | } |
diff --git a/src/wp-admin/network/themes.php b/src/wp-admin/network/themes.php
index 9794c08f8f..1a5e7180db 100644
|
a
|
b
|
$pagenum = $wp_list_table->get_pagenum(); |
| 19 | 19 | |
| 20 | 20 | $action = $wp_list_table->current_action(); |
| 21 | 21 | |
| 22 | | $s = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : ''; |
| | 22 | $search_term = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : ''; |
| 23 | 23 | |
| 24 | 24 | // Clean up request URI from temporary args for screen options/paging uri's to work as expected. |
| 25 | 25 | $temp_args = array( |
| … |
… |
if ( $action ) { |
| 226 | 226 | array( |
| 227 | 227 | 'deleted' => count( $themes ), |
| 228 | 228 | 'paged' => $paged, |
| 229 | | 's' => $s, |
| | 229 | 's' => $search_term, |
| 230 | 230 | ), |
| 231 | 231 | network_admin_url( 'themes.php' ) |
| 232 | 232 | ) |
| … |
… |
if ( isset( $_REQUEST['s'] ) && strlen( $_REQUEST['s'] ) ) { |
| 372 | 372 | printf( |
| 373 | 373 | /* translators: %s: Search query. */ |
| 374 | 374 | __( 'Search results for: %s' ), |
| 375 | | '<strong>' . esc_html( $s ) . '</strong>' |
| | 375 | '<strong>' . esc_html( $search_term ) . '</strong>' |
| 376 | 376 | ); |
| 377 | 377 | echo '</span>'; |
| 378 | 378 | } |
diff --git a/tests/phpunit/tests/admin/wpPluginsListTable.php b/tests/phpunit/tests/admin/wpPluginsListTable.php
index e75a473e2b..aec3ebf536 100644
|
a
|
b
|
class Tests_Admin_wpPluginsListTable extends WP_UnitTestCase { |
| 48 | 48 | * Creates an admin user before any tests run and backs up the `$s` global. |
| 49 | 49 | */ |
| 50 | 50 | public static function set_up_before_class() { |
| 51 | | global $s; |
| | 51 | global $search_term; |
| 52 | 52 | |
| 53 | 53 | parent::set_up_before_class(); |
| 54 | 54 | |
| … |
… |
class Tests_Admin_wpPluginsListTable extends WP_UnitTestCase { |
| 60 | 60 | 'user_email' => 'testadmin@example.com', |
| 61 | 61 | ) |
| 62 | 62 | ); |
| 63 | | self::$original_s = $s; |
| | 63 | self::$original_s = $search_term; |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | public function set_up() { |
| … |
… |
class Tests_Admin_wpPluginsListTable extends WP_UnitTestCase { |
| 72 | 72 | * Restores the `$s` global after each test. |
| 73 | 73 | */ |
| 74 | 74 | public function tear_down() { |
| 75 | | global $s; |
| | 75 | global $search_term; |
| 76 | 76 | |
| 77 | | $s = self::$original_s; |
| | 77 | $search_term = self::$original_s; |
| 78 | 78 | |
| 79 | 79 | parent::tear_down(); |
| 80 | 80 | } |
| … |
… |
class Tests_Admin_wpPluginsListTable extends WP_UnitTestCase { |
| 307 | 307 | * @covers WP_Plugins_List_Table::prepare_items |
| 308 | 308 | */ |
| 309 | 309 | public function test_plugins_list_filter() { |
| 310 | | global $status, $s; |
| | 310 | global $status, $search_term; |
| 311 | 311 | |
| 312 | | $old_status = $status; |
| 313 | | $status = 'mustuse'; |
| 314 | | $s = ''; |
| | 312 | $old_status = $status; |
| | 313 | $status = 'mustuse'; |
| | 314 | $search_term = ''; |
| 315 | 315 | |
| 316 | 316 | add_filter( 'plugins_list', array( $this, 'plugins_list_filter' ), 10, 1 ); |
| 317 | 317 | $this->table->prepare_items(); |