<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[17006] trunk/wp-admin: Introduce WP_List_Table::search_box().</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/17006">17006</a></dd>
<dt>Author</dt> <dd>scribu</dd>
<dt>Date</dt> <dd>2010-12-16 20:45:10 +0000 (Thu, 16 Dec 2010)</dd>
</dl>
<h3>Log Message</h3>
<pre>Introduce WP_List_Table::search_box(). See <a href="http://trac.wordpress.org/ticket/15353">#15353</a></pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadmineditcommentsphp">trunk/wp-admin/edit-comments.php</a></li>
<li><a href="#trunkwpadminedittagsphp">trunk/wp-admin/edit-tags.php</a></li>
<li><a href="#trunkwpadmineditphp">trunk/wp-admin/edit.php</a></li>
<li><a href="#trunkwpadminincludesclasswplisttablephp">trunk/wp-admin/includes/class-wp-list-table.php</a></li>
<li><a href="#trunkwpadminlinkmanagerphp">trunk/wp-admin/link-manager.php</a></li>
<li><a href="#trunkwpadminnetworksitethemesphp">trunk/wp-admin/network/site-themes.php</a></li>
<li><a href="#trunkwpadminnetworksiteusersphp">trunk/wp-admin/network/site-users.php</a></li>
<li><a href="#trunkwpadminnetworksitesphp">trunk/wp-admin/network/sites.php</a></li>
<li><a href="#trunkwpadminnetworkthemesphp">trunk/wp-admin/network/themes.php</a></li>
<li><a href="#trunkwpadminnetworkusersphp">trunk/wp-admin/network/users.php</a></li>
<li><a href="#trunkwpadminpluginsphp">trunk/wp-admin/plugins.php</a></li>
<li><a href="#trunkwpadminthemesphp">trunk/wp-admin/themes.php</a></li>
<li><a href="#trunkwpadminuploadphp">trunk/wp-admin/upload.php</a></li>
<li><a href="#trunkwpadminusersphp">trunk/wp-admin/users.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadmineditcommentsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/edit-comments.php (17005 => 17006)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/edit-comments.php        2010-12-16 19:48:00 UTC (rev 17005)
+++ trunk/wp-admin/edit-comments.php        2010-12-16 20:45:10 UTC (rev 17006)
</span><span class="lines">@@ -220,16 +220,8 @@
</span><span class="cx">
</span><span class="cx"> <form id="comments-form" action="" method="post">
</span><span class="cx">
</span><del>-<?php if ( $wp_list_table->has_items() ) : ?>
</del><ins>+<?php $wp_list_table->search_box( __( 'Search Comments' ), 'comment' ); ?>
</ins><span class="cx">
</span><del>-<p class="search-box">
-        <label class="screen-reader-text" for="comment-search-input"><?php _e( 'Search Comments' ); ?>:</label>
-        <input type="text" id="comment-search-input" name="s" value="<?php _admin_search_query(); ?>" />
-        <?php submit_button( __( 'Search Comments' ), 'button', 'submit', false ); ?>
-</p>
-
-<?php endif; ?>
-
</del><span class="cx"> <?php if ( $post_id ) : ?>
</span><span class="cx"> <input type="hidden" name="p" value="<?php echo esc_attr( intval( $post_id ) ); ?>" />
</span><span class="cx"> <?php endif; ?>
</span></span></pre></div>
<a id="trunkwpadminedittagsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/edit-tags.php (17005 => 17006)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/edit-tags.php        2010-12-16 19:48:00 UTC (rev 17005)
+++ trunk/wp-admin/edit-tags.php        2010-12-16 20:45:10 UTC (rev 17006)
</span><span class="lines">@@ -237,11 +237,9 @@
</span><span class="cx"> <form class="search-form" action="" method="get">
</span><span class="cx"> <input type="hidden" name="taxonomy" value="<?php echo esc_attr($taxonomy); ?>" />
</span><span class="cx"> <input type="hidden" name="post_type" value="<?php echo esc_attr($post_type); ?>" />
</span><del>-<p class="search-box">
-        <label class="screen-reader-text" for="tag-search-input"><?php echo $tax->labels->search_items; ?>:</label>
-        <input type="text" id="tag-search-input" name="s" value="<?php _admin_search_query(); ?>" />
-        <?php submit_button( $tax->labels->search_items, 'button', 'search-items', false ); ?>
-</p>
</del><ins>+
+<?php $wp_list_table->search_box( $tax->labels->search_items, 'tag' ); ?>
+
</ins><span class="cx"> </form>
</span><span class="cx"> <br class="clear" />
</span><span class="cx">
</span></span></pre></div>
<a id="trunkwpadmineditphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/edit.php (17005 => 17006)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/edit.php        2010-12-16 19:48:00 UTC (rev 17005)
+++ trunk/wp-admin/edit.php        2010-12-16 20:45:10 UTC (rev 17006)
</span><span class="lines">@@ -242,16 +242,8 @@
</span><span class="cx">
</span><span class="cx"> <form id="posts-filter" action="" method="get">
</span><span class="cx">
</span><del>-<?php if ( $wp_list_table->has_items() ) : ?>
</del><ins>+<?php $wp_list_table->search_box( $post_type_object->labels->search_items, 'post' ); ?>
</ins><span class="cx">
</span><del>-<p class="search-box">
-        <label class="screen-reader-text" for="post-search-input"><?php echo $post_type_object->labels->search_items; ?>:</label>
-        <input type="text" id="post-search-input" name="s" value="<?php the_search_query(); ?>" />
-        <?php submit_button( $post_type_object->labels->search_items, 'button', 'submit', false ); ?>
-</p>
-
-<?php endif; ?>
-
</del><span class="cx"> <input type="hidden" name="post_status" class="post_status_page" value="<?php echo !empty($_REQUEST['post_status']) ? esc_attr($_REQUEST['post_status']) : 'all'; ?>" />
</span><span class="cx"> <input type="hidden" name="post_type" class="post_type_page" value="<?php echo $post_type; ?>" />
</span><span class="cx">
</span></span></pre></div>
<a id="trunkwpadminincludesclasswplisttablephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/class-wp-list-table.php (17005 => 17006)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/class-wp-list-table.php        2010-12-16 19:48:00 UTC (rev 17005)
+++ trunk/wp-admin/includes/class-wp-list-table.php        2010-12-16 20:45:10 UTC (rev 17006)
</span><span class="lines">@@ -179,6 +179,30 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         /**
</span><ins>+         * Display the search box.
+         *
+         * @since 3.1.0
+         * @access public
+         *
+         * @param string $text The search button text
+         * @param string $input_id The search input id
+         */
+        function search_box( $text, $input_id ) {
+                if ( empty( $_REQUEST['s'] ) && !$this->has_items() )
+                        return;
+
+                $input_id = $input_id . '-search-input';
+
+?>
+<p class="search-box">
+        <label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label>
+        <input type="text" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>" />
+        <?php submit_button( $text, 'button', 'submit', false ); ?>
+</p>
+<?php
+        }
+
+        /**
</ins><span class="cx">          * Get an associative array ( id => link ) with the list
</span><span class="cx">          * of views available on this table.
</span><span class="cx">          *
</span></span></pre></div>
<a id="trunkwpadminlinkmanagerphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/link-manager.php (17005 => 17006)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/link-manager.php        2010-12-16 19:48:00 UTC (rev 17005)
+++ trunk/wp-admin/link-manager.php        2010-12-16 20:45:10 UTC (rev 17006)
</span><span class="lines">@@ -76,16 +76,8 @@
</span><span class="cx">
</span><span class="cx"> <form id="posts-filter" action="" method="post">
</span><span class="cx">
</span><del>-<?php if ( $wp_list_table->has_items() ) : ?>
</del><ins>+<?php $wp_list_table->search_box( __( 'Search Links' ), 'link' ); ?>
</ins><span class="cx">
</span><del>-<p class="search-box">
-        <label class="screen-reader-text" for="link-search-input"><?php _e( 'Search Links' ); ?>:</label>
-        <input type="text" id="link-search-input" name="s" value="<?php _admin_search_query(); ?>" />
-        <?php submit_button( __( 'Search Links' ), 'button', '', false ); ?>
-</p>
-
-<?php endif; ?>
-
</del><span class="cx"> <?php $wp_list_table->display(); ?>
</span><span class="cx">
</span><span class="cx"> <div id="ajax-response"></div>
</span></span></pre></div>
<a id="trunkwpadminnetworksitethemesphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/network/site-themes.php (17005 => 17006)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/network/site-themes.php        2010-12-16 19:48:00 UTC (rev 17005)
+++ trunk/wp-admin/network/site-themes.php        2010-12-16 20:45:10 UTC (rev 17006)
</span><span class="lines">@@ -152,11 +152,7 @@
</span><span class="cx"> <p><?php _e( 'Network enabled themes are not shown on this screen.' ) ?></p>
</span><span class="cx">
</span><span class="cx"> <form method="get" action="">
</span><del>-<p class="search-box">
-        <label class="screen-reader-text" for="theme-search-input"><?php _e( 'Search Themes' ); ?>:</label>
-        <input type="text" id="theme-search-input" name="s" value="<?php _admin_search_query(); ?>" />
-        <?php submit_button( __( 'Search Installed Themes' ), 'button', '', false ); ?>
-</p>
</del><ins>+<?php $wp_list_table->search_box( __( 'Search Installed Themes' ), 'theme' ); ?>
</ins><span class="cx"> </form>
</span><span class="cx">
</span><span class="cx"> <?php $wp_list_table->views(); ?>
</span><span class="lines">@@ -170,4 +166,4 @@
</span><span class="cx"> </form>
</span><span class="cx">
</span><span class="cx"> </div>
</span><del>-<?php include(ABSPATH . 'wp-admin/admin-footer.php'); ?>
</del><span class="cx">\ No newline at end of file
</span><ins>+<?php include(ABSPATH . 'wp-admin/admin-footer.php'); ?>
</ins></span></pre></div>
<a id="trunkwpadminnetworksiteusersphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/network/site-users.php (17005 => 17006)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/network/site-users.php        2010-12-16 19:48:00 UTC (rev 17005)
+++ trunk/wp-admin/network/site-users.php        2010-12-16 20:45:10 UTC (rev 17006)
</span><span class="lines">@@ -211,11 +211,7 @@
</span><span class="cx"> endif; ?>
</span><span class="cx">
</span><span class="cx"> <form class="search-form" action="" method="get">
</span><del>-<p class="search-box">
-        <label class="screen-reader-text" for="user-search-input"><?php _e( 'Search Users' ); ?>:</label>
-        <input type="text" id="user-search-input" name="s" value="<?php echo esc_attr($usersearch); ?>" />
-        <?php submit_button( __( 'Search Users' ), 'button', 'submit', false ); ?>
-</p>
</del><ins>+<?php $wp_list_table->search_box( __( 'Search Users' ), 'user' ); ?>
</ins><span class="cx"> </form>
</span><span class="cx">
</span><span class="cx"> <?php $wp_list_table->views(); ?>
</span><span class="lines">@@ -301,4 +297,4 @@
</span><span class="cx"> <?php endif; ?>
</span><span class="cx"> </div>
</span><span class="cx"> <?php
</span><del>-require('../admin-footer.php');
</del><span class="cx">\ No newline at end of file
</span><ins>+require('../admin-footer.php');
</ins></span></pre></div>
<a id="trunkwpadminnetworksitesphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/network/sites.php (17005 => 17006)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/network/sites.php        2010-12-16 19:48:00 UTC (rev 17005)
+++ trunk/wp-admin/network/sites.php        2010-12-16 20:45:10 UTC (rev 17006)
</span><span class="lines">@@ -104,11 +104,8 @@
</span><span class="cx"> </h2>
</span><span class="cx">
</span><span class="cx"> <form action="" method="get" id="ms-search">
</span><del>-<p class="search-box">
</del><ins>+<?php $wp_list_table->search_box( __( 'Search Sites' ), 'site' ); ?>
</ins><span class="cx"> <input type="hidden" name="action" value="blogs" />
</span><del>-<input type="text" name="s" value="<?php echo esc_attr( $s ); ?>" />
-<?php submit_button( __( 'Search Sites' ), 'button', 'submit', false ); ?>
-</p>
</del><span class="cx"> </form>
</span><span class="cx">
</span><span class="cx"> <form id="form-site-list" action="edit.php?action=allblogs" method="post">
</span></span></pre></div>
<a id="trunkwpadminnetworkthemesphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/network/themes.php (17005 => 17006)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/network/themes.php        2010-12-16 19:48:00 UTC (rev 17005)
+++ trunk/wp-admin/network/themes.php        2010-12-16 20:45:10 UTC (rev 17006)
</span><span class="lines">@@ -94,11 +94,7 @@
</span><span class="cx"> <h2><?php echo esc_html( $title ); if ( current_user_can('install_themes') ) { ?> <a href="theme-install.php" class="button add-new-h2"><?php echo esc_html_x('Add New', 'theme'); ?></a><?php } ?></h2>
</span><span class="cx">
</span><span class="cx"> <form method="get" action="">
</span><del>-<p class="search-box">
-        <label class="screen-reader-text" for="theme-search-input"><?php _e( 'Search Themes' ); ?>:</label>
-        <input type="text" id="theme-search-input" name="s" value="<?php _admin_search_query(); ?>" />
-        <?php submit_button( __( 'Search Installed Themes' ), 'button', '', false ); ?>
-</p>
</del><ins>+<?php $wp_list_table->search_box( __( 'Search Installed Themes' ), 'theme' ); ?>
</ins><span class="cx"> </form>
</span><span class="cx">
</span><span class="cx"> <?php $wp_list_table->views(); ?>
</span><span class="lines">@@ -113,4 +109,4 @@
</span><span class="cx"> </div>
</span><span class="cx">
</span><span class="cx"> <?php
</span><del>-include(ABSPATH . 'wp-admin/admin-footer.php');
</del><span class="cx">\ No newline at end of file
</span><ins>+include(ABSPATH . 'wp-admin/admin-footer.php');
</ins></span></pre></div>
<a id="trunkwpadminnetworkusersphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/network/users.php (17005 => 17006)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/network/users.php        2010-12-16 19:48:00 UTC (rev 17005)
+++ trunk/wp-admin/network/users.php        2010-12-16 20:45:10 UTC (rev 17006)
</span><span class="lines">@@ -79,10 +79,7 @@
</span><span class="cx">         <?php $wp_list_table->views(); ?>
</span><span class="cx">
</span><span class="cx">         <form action="" method="get" class="search-form">
</span><del>-                <p class="search-box">
-                <input type="text" name="s" value="<?php echo esc_attr( $usersearch ); ?>" class="search-input" id="user-search-input" />
-                <?php submit_button( __( 'Search Users' ), 'button', 'post-query-submit', false ); ?>
-                </p>
</del><ins>+                <?php $wp_list_table->search_box( __( 'Search Users' ), 'user' ); ?>
</ins><span class="cx">         </form>
</span><span class="cx">
</span><span class="cx">         <form id="form-user-list" action='edit.php?action=allusers' method='post'>
</span><span class="lines">@@ -90,4 +87,4 @@
</span><span class="cx">         </form>
</span><span class="cx"> </div>
</span><span class="cx">
</span><del>-<?php require_once( '../admin-footer.php' ); ?>
</del><span class="cx">\ No newline at end of file
</span><ins>+<?php require_once( '../admin-footer.php' ); ?>
</ins></span></pre></div>
<a id="trunkwpadminpluginsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/plugins.php (17005 => 17006)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/plugins.php        2010-12-16 19:48:00 UTC (rev 17005)
+++ trunk/wp-admin/plugins.php        2010-12-16 20:45:10 UTC (rev 17006)
</span><span class="lines">@@ -377,16 +377,8 @@
</span><span class="cx">
</span><span class="cx"> <form method="post" action="">
</span><span class="cx">
</span><del>-<?php if ( $wp_list_table->has_items() ) : ?>
</del><ins>+<?php $wp_list_table->search_box( __( 'Search Plugins' ), 'plugin' ); ?>
</ins><span class="cx">
</span><del>-<p class="search-box">
-        <label class="screen-reader-text" for="plugin-search-input"><?php _e( 'Search Plugins' ); ?>:</label>
-        <input type="text" id="plugin-search-input" name="s" value="<?php _admin_search_query(); ?>" />
-        <?php submit_button( __( 'Search Installed Plugins' ), 'button', '', false ); ?>
-</p>
-
-<?php endif; ?>
-
</del><span class="cx"> <input type="hidden" name="plugin_status" value="<?php echo esc_attr($status) ?>" />
</span><span class="cx"> <input type="hidden" name="paged" value="<?php echo esc_attr($page) ?>" />
</span><span class="cx">
</span></span></pre></div>
<a id="trunkwpadminthemesphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/themes.php (17005 => 17006)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/themes.php        2010-12-16 19:48:00 UTC (rev 17005)
+++ trunk/wp-admin/themes.php        2010-12-16 20:45:10 UTC (rev 17006)
</span><span class="lines">@@ -146,7 +146,7 @@
</span><span class="cx">
</span><span class="cx"> <h3><?php _e('Available Themes'); ?></h3>
</span><span class="cx">
</span><del>-<?php if ( $wp_list_table->has_items() ) : ?>
</del><ins>+<?php if ( !empty( $_REQUEST['s'] ) || $wp_list_table->has_items() ) : ?>
</ins><span class="cx">
</span><span class="cx"> <form class="search-form filter-form" action="" method="get">
</span><span class="cx">
</span></span></pre></div>
<a id="trunkwpadminuploadphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/upload.php (17005 => 17006)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/upload.php        2010-12-16 19:48:00 UTC (rev 17005)
+++ trunk/wp-admin/upload.php        2010-12-16 20:45:10 UTC (rev 17006)
</span><span class="lines">@@ -206,16 +206,8 @@
</span><span class="cx">
</span><span class="cx"> <form id="posts-filter" action="" method="post">
</span><span class="cx">
</span><del>-<?php if ( $wp_list_table->has_items() ) : ?>
</del><ins>+<?php $wp_list_table->search_box( __( 'Search Media' ), 'media' ); ?>
</ins><span class="cx">
</span><del>-<p class="search-box">
-        <label class="screen-reader-text" for="media-search-input"><?php _e( 'Search Media' ); ?>:</label>
-        <input type="text" id="media-search-input" name="s" value="<?php the_search_query(); ?>" />
-        <?php submit_button( __( 'Search Media' ), 'button', 'submit', false ); ?>
-</p>
-
-<?php endif; ?>
-
</del><span class="cx"> <?php $wp_list_table->display(); ?>
</span><span class="cx">
</span><span class="cx"> <div id="ajax-response"></div>
</span></span></pre></div>
<a id="trunkwpadminusersphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/users.php (17005 => 17006)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/users.php        2010-12-16 19:48:00 UTC (rev 17005)
+++ trunk/wp-admin/users.php        2010-12-16 20:45:10 UTC (rev 17006)
</span><span class="lines">@@ -357,16 +357,8 @@
</span><span class="cx">
</span><span class="cx"> <form action="" method="post">
</span><span class="cx">
</span><del>-<?php if ( $wp_list_table->has_items() ) : ?>
</del><ins>+<?php $wp_list_table->search_box( __( 'Search Users' ), 'user' ); ?>
</ins><span class="cx">
</span><del>-<p class="search-box">
-        <label class="screen-reader-text" for="user-search-input"><?php _e( 'Search Users' ); ?>:</label>
-        <input type="text" id="user-search-input" name="s" value="<?php echo esc_attr($usersearch); ?>" />
-        <?php submit_button( __( 'Search Users' ), 'button', 'submit', false ); ?>
-</p>
-
-<?php endif; ?>
-
</del><span class="cx"> <?php $wp_list_table->display(); ?>
</span><span class="cx"> </form>
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>