diff --git src/wp-admin/edit-comments.php src/wp-admin/edit-comments.php
index 3aac00b..218b5b8 100644
|
|
if ( $post_id ) |
186 | 186 | else |
187 | 187 | _e( 'Comments' ); |
188 | 188 | |
189 | | if ( isset($_REQUEST['s']) && $_REQUEST['s'] ) |
190 | | echo '<span class="subtitle">' . sprintf( __( 'Search results for “%s”' ), wp_html_excerpt( esc_html( wp_unslash( $_REQUEST['s'] ) ), 50, '…' ) ) . '</span>'; ?> |
| 189 | if ( isset( $_REQUEST['s'] ) && '' !== $_REQUEST['s'] ) { |
| 190 | echo '<span class="subtitle">' . sprintf( __( 'Search results for “%s”' ), wp_html_excerpt( esc_html( wp_unslash( $_REQUEST['s'] ) ), 50, '…' ) ) . '</span>'; |
| 191 | } |
| 192 | ?> |
191 | 193 | </h1> |
192 | 194 | |
193 | 195 | <?php |
diff --git src/wp-admin/edit-tags.php src/wp-admin/edit-tags.php
index 748ae17..80595a6 100644
|
|
if ( is_plugin_active( 'wpcat2tag-importer/wpcat2tag-importer.php' ) ) { |
307 | 307 | |
308 | 308 | <div class="wrap nosubsub"> |
309 | 309 | <h1><?php echo esc_html( $title ); |
310 | | if ( !empty($_REQUEST['s']) ) |
311 | | printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', esc_html( wp_unslash($_REQUEST['s']) ) ); ?> |
| 310 | if ( isset( $_REQUEST['s'] ) && '' !== $_REQUEST['s'] ) { |
| 311 | printf( '<span class="subtitle">' . __( 'Search results for “%s”' ) . '</span>', esc_html( wp_unslash( $_REQUEST['s'] ) ) ); |
| 312 | } |
| 313 | ?> |
312 | 314 | </h1> |
313 | 315 | |
314 | 316 | <?php if ( $message ) : ?> |
diff --git src/wp-admin/edit.php src/wp-admin/edit.php
index fa4a7b6..b46d1d0 100644
|
|
require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
303 | 303 | echo esc_html( $post_type_object->labels->name ); |
304 | 304 | if ( current_user_can( $post_type_object->cap->create_posts ) ) |
305 | 305 | echo ' <a href="' . esc_url( admin_url( $post_new_file ) ) . '" class="page-title-action">' . esc_html( $post_type_object->labels->add_new ) . '</a>'; |
306 | | if ( ! empty( $_REQUEST['s'] ) ) |
307 | | printf( ' <span class="subtitle">' . __('Search results for “%s”') . '</span>', get_search_query() ); |
| 306 | |
| 307 | if ( isset( $_REQUEST['s'] ) && '' !== $_REQUEST['s'] ) { |
| 308 | printf( ' <span class="subtitle">' . __( 'Search results for “%s”' ) . '</span>', get_search_query() ); |
| 309 | } |
308 | 310 | ?></h1> |
309 | 311 | |
310 | 312 | <?php |
diff --git src/wp-admin/link-manager.php src/wp-admin/link-manager.php
index 5cf80cd..d6bb18d 100644
|
|
if ( ! current_user_can('manage_links') ) |
74 | 74 | |
75 | 75 | <div class="wrap nosubsub"> |
76 | 76 | <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 |
77 | | if ( !empty($_REQUEST['s']) ) |
78 | | printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', esc_html( wp_unslash($_REQUEST['s']) ) ); ?> |
| 77 | if ( isset( $_REQUEST['s'] ) && '' !== $_REQUEST['s'] ) { |
| 78 | printf( '<span class="subtitle">' . __( 'Search results for “%s”' ) . '</span>', esc_html( wp_unslash( $_REQUEST['s'] ) ) ); |
| 79 | } |
| 80 | ?> |
79 | 81 | </h1> |
80 | 82 | |
81 | 83 | <?php |
diff --git src/wp-admin/network/sites.php src/wp-admin/network/sites.php
index e0e7e1e..1ec328c 100644
|
|
require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
284 | 284 | <a href="<?php echo network_admin_url('site-new.php'); ?>" class="page-title-action"><?php echo esc_html_x( 'Add New', 'site' ); ?></a> |
285 | 285 | <?php endif; ?> |
286 | 286 | |
287 | | <?php if ( isset( $_REQUEST['s'] ) && $_REQUEST['s'] ) { |
| 287 | <?php |
| 288 | if ( isset( $_REQUEST['s'] ) && '' !== $_REQUEST['s'] ) { |
288 | 289 | printf( '<span class="subtitle">' . __( 'Search results for “%s”' ) . '</span>', esc_html( $s ) ); |
289 | 290 | } ?> |
290 | 291 | </h1> |
diff --git src/wp-admin/network/themes.php src/wp-admin/network/themes.php
index 958bd7e..057dd1e 100644
|
|
require_once(ABSPATH . 'wp-admin/admin-header.php'); |
268 | 268 | |
269 | 269 | <div class="wrap"> |
270 | 270 | <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 } |
271 | | if ( $s ) |
272 | | printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', esc_html( $s ) ); ?> |
| 271 | if ( isset( $_REQUEST['s'] ) && '' !== $_REQUEST['s'] ) { |
| 272 | printf( '<span class="subtitle">' . __( 'Search results for “%s”' ) . '</span>', esc_html( $s ) ); |
| 273 | } |
| 274 | ?> |
273 | 275 | </h1> |
274 | 276 | |
275 | 277 | <?php |
diff --git src/wp-admin/network/users.php src/wp-admin/network/users.php
index f55ea6c..36094eb 100644
|
|
if ( isset( $_REQUEST['updated'] ) && $_REQUEST['updated'] == 'true' && ! empty( |
212 | 212 | <a href="<?php echo network_admin_url('user-new.php'); ?>" class="page-title-action"><?php echo esc_html_x( 'Add New', 'user' ); ?></a><?php |
213 | 213 | endif; |
214 | 214 | |
215 | | if ( !empty( $usersearch ) ) |
216 | | printf( '<span class="subtitle">' . __( 'Search results for “%s”' ) . '</span>', esc_html( $usersearch ) ); |
| 215 | if ( '' !== $usersearch ) { |
| 216 | printf( '<span class="subtitle">' . __( 'Search results for “%s”' ) . '</span>', esc_html( $usersearch ) ); |
| 217 | } |
217 | 218 | ?> |
218 | 219 | </h1> |
219 | 220 | |
diff --git src/wp-admin/plugins.php src/wp-admin/plugins.php
index 93aec79..24728af 100644
|
|
if ( ! empty( $invalid ) ) { |
510 | 510 | <h1><?php echo esc_html( $title ); |
511 | 511 | if ( ( ! is_multisite() || is_network_admin() ) && current_user_can('install_plugins') ) { ?> |
512 | 512 | <a href="<?php echo self_admin_url( 'plugin-install.php' ); ?>" class="page-title-action"><?php echo esc_html_x('Add New', 'plugin'); ?></a> |
513 | | <?php } |
514 | | if ( $s ) |
515 | | printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', esc_html( $s ) ); ?> |
| 513 | <?php |
| 514 | } |
| 515 | |
| 516 | if ( isset( $_REQUEST['s'] ) && '' !== $_REQUEST['s'] ) { |
| 517 | printf( '<span class="subtitle">' . __( 'Search results for “%s”' ) . '</span>', esc_html( $s ) ); |
| 518 | } |
| 519 | ?> |
516 | 520 | </h1> |
517 | 521 | |
518 | 522 | <?php |
diff --git src/wp-admin/upload.php src/wp-admin/upload.php
index 65bb790..524432d 100644
|
|
echo esc_html( $title ); |
220 | 220 | if ( current_user_can( 'upload_files' ) ) { ?> |
221 | 221 | <a href="media-new.php" class="page-title-action"><?php echo esc_html_x('Add New', 'file'); ?></a><?php |
222 | 222 | } |
223 | | if ( ! empty( $_REQUEST['s'] ) ) |
224 | | printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', get_search_query() ); ?> |
| 223 | if ( isset( $_REQUEST['s'] ) && '' !== $_REQUEST['s'] ) { |
| 224 | printf( '<span class="subtitle">' . __( 'Search results for “%s”' ) . '</span>', get_search_query() ); |
| 225 | } |
| 226 | ?> |
225 | 227 | </h1> |
226 | 228 | |
227 | 229 | <?php |
diff --git src/wp-admin/users.php src/wp-admin/users.php
index a541baf..359f1db 100644
|
|
if ( current_user_can( 'create_users' ) ) { ?> |
475 | 475 | <a href="user-new.php" class="page-title-action"><?php echo esc_html_x( 'Add Existing', 'user' ); ?></a> |
476 | 476 | <?php } |
477 | 477 | |
478 | | if ( $usersearch ) |
479 | | printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', esc_html( $usersearch ) ); ?> |
| 478 | if ( '' !== $usersearch ) { |
| 479 | printf( '<span class="subtitle">' . __( 'Search results for “%s”' ) . '</span>', esc_html( $usersearch ) ); |
| 480 | } |
| 481 | ?> |
480 | 482 | </h1> |
481 | 483 | |
482 | 484 | <?php $wp_list_table->views(); ?> |
diff --git src/wp-includes/query.php src/wp-includes/query.php
index 84eda07..a874151 100644
|
|
class WP_Query { |
2793 | 2793 | } |
2794 | 2794 | |
2795 | 2795 | // If a search pattern is specified, load the posts that match. |
2796 | | if ( ! empty( $q['s'] ) ) { |
| 2796 | if ( isset( $q['s'] ) ) { |
2797 | 2797 | $search = $this->parse_search( $q ); |
2798 | 2798 | } |
2799 | 2799 | |
diff --git tests/phpunit/tests/query/search.php tests/phpunit/tests/query/search.php
index b81bef3..f49d023 100644
|
|
class Tests_Query_Search extends WP_UnitTestCase { |
125 | 125 | |
126 | 126 | $this->assertEqualSets( array( $p3 ), $q->posts ); |
127 | 127 | } |
| 128 | |
| 129 | /** |
| 130 | * @ticket 31025 |
| 131 | */ |
| 132 | public function test_s_zero() { |
| 133 | $p = $this->factory->post->create( array( |
| 134 | 'post_status' => 'publish', |
| 135 | 'post_title' => '0', |
| 136 | ) ); |
| 137 | |
| 138 | $q = new WP_Query( array( |
| 139 | 's' => '0', |
| 140 | 'fields' => 'ids', |
| 141 | ) ); |
| 142 | |
| 143 | $this->assertEqualSets( array( $p ), $q->posts ); |
| 144 | } |
128 | 145 | } |