Allow searching for `0` throughout the admin.

Fixes #31025.

git-svn-id: https://develop.svn.wordpress.org/trunk@36302 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Pascal Birchler 2016-01-14 20:05:06 +00:00
parent 5209de6052
commit cc6fe1179d
11 changed files with 52 additions and 26 deletions

View File

@ -191,7 +191,7 @@ if ( $post_id ) {
_e( 'Comments' );
}
if ( isset($_REQUEST['s']) && $_REQUEST['s'] ) {
if ( isset($_REQUEST['s']) && strlen( $_REQUEST['s'] ) ) {
echo '<span class="subtitle">';
/* translators: %s: search keywords */
printf( __( 'Search results for &#8220;%s&#8221;' ),

View File

@ -311,8 +311,11 @@ if ( is_plugin_active( 'wpcat2tag-importer/wpcat2tag-importer.php' ) ) {
<div class="wrap nosubsub">
<h1><?php echo esc_html( $title );
if ( !empty($_REQUEST['s']) )
printf( '<span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', esc_html( wp_unslash($_REQUEST['s']) ) ); ?>
if ( isset( $_REQUEST['s'] ) && strlen( $_REQUEST['s'] ) ) {
/* translators: %s: search keywords */
printf( '<span class="subtitle">' . __( 'Search results for &#8220;%s&#8221;' ) . '</span>', esc_html( wp_unslash( $_REQUEST['s'] ) ) );
}
?>
</h1>
<?php if ( $message ) : ?>

View File

@ -303,8 +303,11 @@ require_once( ABSPATH . 'wp-admin/admin-header.php' );
echo esc_html( $post_type_object->labels->name );
if ( current_user_can( $post_type_object->cap->create_posts ) )
echo ' <a href="' . esc_url( admin_url( $post_new_file ) ) . '" class="page-title-action">' . esc_html( $post_type_object->labels->add_new ) . '</a>';
if ( ! empty( $_REQUEST['s'] ) )
printf( ' <span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', get_search_query() );
if ( isset( $_REQUEST['s'] ) && strlen( $_REQUEST['s'] ) ) {
/* translators: %s: search keywords */
printf( ' <span class="subtitle">' . __( 'Search results for &#8220;%s&#8221;' ) . '</span>', get_search_query() );
}
?></h1>
<?php

View File

@ -75,7 +75,7 @@ class WP_Plugins_List_Table extends WP_List_Table {
public function prepare_items() {
global $status, $plugins, $totals, $page, $orderby, $order, $s;
wp_reset_vars( array( 'orderby', 'order', 's' ) );
wp_reset_vars( array( 'orderby', 'order' ) );
/**
* Filter the full array of plugins to list in the Plugins list table.
@ -224,7 +224,7 @@ class WP_Plugins_List_Table extends WP_List_Table {
}
}
if ( $s ) {
if ( strlen( $s ) ) {
$status = 'search';
$plugins['search'] = array_filter( $plugins['all'], array( $this, '_search_callback' ) );
}
@ -268,17 +268,16 @@ class WP_Plugins_List_Table extends WP_List_Table {
}
/**
* @staticvar string $term
* @global string $s
*
* @param array $plugin
* @return bool
*/
public function _search_callback( $plugin ) {
static $term = null;
if ( is_null( $term ) )
$term = wp_unslash( $_REQUEST['s'] );
global $s;
foreach ( $plugin as $value ) {
if ( is_string( $value ) && false !== stripos( strip_tags( $value ), $term ) ) {
if ( is_string( $value ) && false !== stripos( strip_tags( $value ), $s ) ) {
return true;
}
}

View File

@ -74,8 +74,11 @@ if ( ! current_user_can('manage_links') )
<div class="wrap nosubsub">
<h1><?php echo esc_html( $title ); ?> <a href="link-add.php" class="page-title-action"><?php echo esc_html_x('Add New', 'link'); ?></a> <?php
if ( !empty($_REQUEST['s']) )
printf( '<span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', esc_html( wp_unslash($_REQUEST['s']) ) ); ?>
if ( isset( $_REQUEST['s'] ) && strlen( $_REQUEST['s'] ) ) {
/* translators: %s: search keywords */
printf( '<span class="subtitle">' . __( 'Search results for &#8220;%s&#8221;' ) . '</span>', esc_html( wp_unslash( $_REQUEST['s'] ) ) );
}
?>
</h1>
<?php

View File

@ -288,7 +288,9 @@ require_once( ABSPATH . 'wp-admin/admin-header.php' );
<a href="<?php echo network_admin_url('site-new.php'); ?>" class="page-title-action"><?php echo esc_html_x( 'Add New', 'site' ); ?></a>
<?php endif; ?>
<?php if ( isset( $_REQUEST['s'] ) && $_REQUEST['s'] ) {
<?php
if ( isset( $_REQUEST['s'] ) && strlen( $_REQUEST['s'] ) ) {
/* translators: %s: search keywords */
printf( '<span class="subtitle">' . __( 'Search results for &#8220;%s&#8221;' ) . '</span>', esc_html( $s ) );
} ?>
</h1>

View File

@ -239,8 +239,11 @@ require_once(ABSPATH . 'wp-admin/admin-header.php');
<div class="wrap">
<h1><?php echo esc_html( $title ); if ( current_user_can('install_themes') ) { ?> <a href="theme-install.php" class="page-title-action"><?php echo esc_html_x('Add New', 'theme'); ?></a><?php }
if ( $s )
printf( '<span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', esc_html( $s ) ); ?>
if ( isset( $_REQUEST['s'] ) && strlen( $_REQUEST['s'] ) ) {
/* translators: %s: search keywords */
printf( '<span class="subtitle">' . __( 'Search results for &#8220;%s&#8221;' ) . '</span>', esc_html( $s ) );
}
?>
</h1>
<?php

View File

@ -212,8 +212,10 @@ if ( isset( $_REQUEST['updated'] ) && $_REQUEST['updated'] == 'true' && ! empty(
<a href="<?php echo network_admin_url('user-new.php'); ?>" class="page-title-action"><?php echo esc_html_x( 'Add New', 'user' ); ?></a><?php
endif;
if ( !empty( $usersearch ) )
printf( '<span class="subtitle">' . __( 'Search results for &#8220;%s&#8221;' ) . '</span>', esc_html( $usersearch ) );
if ( strlen( $usersearch ) ) {
/* translators: %s: search keywords */
printf( '<span class="subtitle">' . __( 'Search results for &#8220;%s&#8221;' ) . '</span>', esc_html( $usersearch ) );
}
?>
</h1>

View File

@ -481,9 +481,14 @@ if ( ! empty( $invalid ) ) {
<h1><?php echo esc_html( $title );
if ( ( ! is_multisite() || is_network_admin() ) && current_user_can('install_plugins') ) { ?>
<a href="<?php echo self_admin_url( 'plugin-install.php' ); ?>" class="page-title-action"><?php echo esc_html_x('Add New', 'plugin'); ?></a>
<?php }
if ( $s )
printf( '<span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', esc_html( $s ) ); ?>
<?php
}
if ( strlen( $s ) ) {
/* translators: %s: search keywords */
printf( '<span class="subtitle">' . __( 'Search results for &#8220;%s&#8221;' ) . '</span>', esc_html( $s ) );
}
?>
</h1>
<?php

View File

@ -220,8 +220,11 @@ echo esc_html( $title );
if ( current_user_can( 'upload_files' ) ) { ?>
<a href="media-new.php" class="page-title-action"><?php echo esc_html_x('Add New', 'file'); ?></a><?php
}
if ( ! empty( $_REQUEST['s'] ) )
printf( '<span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', get_search_query() ); ?>
if ( isset( $_REQUEST['s'] ) && strlen( $_REQUEST['s'] ) ) {
/* translators: %s: search keywords */
printf( '<span class="subtitle">' . __( 'Search results for &#8220;%s&#8221;' ) . '</span>', get_search_query() );
}
?>
</h1>
<?php

View File

@ -481,8 +481,11 @@ if ( current_user_can( 'create_users' ) ) { ?>
<a href="user-new.php" class="page-title-action"><?php echo esc_html_x( 'Add Existing', 'user' ); ?></a>
<?php }
if ( $usersearch )
printf( '<span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', esc_html( $usersearch ) ); ?>
if ( strlen( $usersearch ) ) {
/* translators: %s: search keywords */
printf( '<span class="subtitle">' . __( 'Search results for &#8220;%s&#8221;' ) . '</span>', esc_html( $usersearch ) );
}
?>
</h1>
<?php $wp_list_table->views(); ?>