Introduce WP_List_Table::search_box(). See #15353

git-svn-id: http://svn.automattic.com/wordpress/trunk@17006 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
scribu 2010-12-16 20:45:10 +00:00
parent 4e7270ab6a
commit cfe09b99e5
14 changed files with 43 additions and 87 deletions

View File

@ -220,15 +220,7 @@ if ( isset($_REQUEST['approved']) || isset($_REQUEST['deleted']) || isset($_REQU
<form id="comments-form" action="" method="post">
<?php if ( $wp_list_table->has_items() ) : ?>
<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; ?>
<?php $wp_list_table->search_box( __( 'Search Comments' ), 'comment' ); ?>
<?php if ( $post_id ) : ?>
<input type="hidden" name="p" value="<?php echo esc_attr( intval( $post_id ) ); ?>" />

View File

@ -237,11 +237,9 @@ endif; ?>
<form class="search-form" action="" method="get">
<input type="hidden" name="taxonomy" value="<?php echo esc_attr($taxonomy); ?>" />
<input type="hidden" name="post_type" value="<?php echo esc_attr($post_type); ?>" />
<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>
<?php $wp_list_table->search_box( $tax->labels->search_items, 'tag' ); ?>
</form>
<br class="clear" />

View File

@ -242,15 +242,7 @@ $_SERVER['REQUEST_URI'] = remove_query_arg( array('locked', 'skipped', 'updated'
<form id="posts-filter" action="" method="get">
<?php if ( $wp_list_table->has_items() ) : ?>
<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; ?>
<?php $wp_list_table->search_box( $post_type_object->labels->search_items, 'post' ); ?>
<input type="hidden" name="post_status" class="post_status_page" value="<?php echo !empty($_REQUEST['post_status']) ? esc_attr($_REQUEST['post_status']) : 'all'; ?>" />
<input type="hidden" name="post_type" class="post_type_page" value="<?php echo $post_type; ?>" />

View File

@ -178,6 +178,30 @@ class WP_List_Table {
_e( 'No items found.' );
}
/**
* 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
}
/**
* Get an associative array ( id => link ) with the list
* of views available on this table.

View File

@ -76,15 +76,7 @@ if ( isset($_REQUEST['deleted']) ) {
<form id="posts-filter" action="" method="post">
<?php if ( $wp_list_table->has_items() ) : ?>
<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; ?>
<?php $wp_list_table->search_box( __( 'Search Links' ), 'link' ); ?>
<?php $wp_list_table->display(); ?>

View File

@ -152,11 +152,7 @@ if ( isset( $_GET['update'] ) ) {
<p><?php _e( 'Network enabled themes are not shown on this screen.' ) ?></p>
<form method="get" action="">
<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>
<?php $wp_list_table->search_box( __( 'Search Installed Themes' ), 'theme' ); ?>
</form>
<?php $wp_list_table->views(); ?>
@ -170,4 +166,4 @@ if ( isset( $_GET['update'] ) ) {
</form>
</div>
<?php include(ABSPATH . 'wp-admin/admin-footer.php'); ?>
<?php include(ABSPATH . 'wp-admin/admin-footer.php'); ?>

View File

@ -211,11 +211,7 @@ if ( isset($_GET['update']) ) :
endif; ?>
<form class="search-form" action="" method="get">
<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 $wp_list_table->search_box( __( 'Search Users' ), 'user' ); ?>
</form>
<?php $wp_list_table->views(); ?>
@ -301,4 +297,4 @@ endif; ?>
<?php endif; ?>
</div>
<?php
require('../admin-footer.php');
require('../admin-footer.php');

View File

@ -104,11 +104,8 @@ require_once( '../admin-header.php' );
</h2>
<form action="" method="get" id="ms-search">
<p class="search-box">
<?php $wp_list_table->search_box( __( 'Search Sites' ), 'site' ); ?>
<input type="hidden" name="action" value="blogs" />
<input type="text" name="s" value="<?php echo esc_attr( $s ); ?>" />
<?php submit_button( __( 'Search Sites' ), 'button', 'submit', false ); ?>
</p>
</form>
<form id="form-site-list" action="edit.php?action=allblogs" method="post">

View File

@ -94,11 +94,7 @@ require_once(ABSPATH . 'wp-admin/admin-header.php');
<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>
<form method="get" action="">
<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>
<?php $wp_list_table->search_box( __( 'Search Installed Themes' ), 'theme' ); ?>
</form>
<?php $wp_list_table->views(); ?>
@ -113,4 +109,4 @@ require_once(ABSPATH . 'wp-admin/admin-header.php');
</div>
<?php
include(ABSPATH . 'wp-admin/admin-footer.php');
include(ABSPATH . 'wp-admin/admin-footer.php');

View File

@ -79,10 +79,7 @@ if ( isset( $_REQUEST['updated'] ) && $_REQUEST['updated'] == 'true' && ! empty(
<?php $wp_list_table->views(); ?>
<form action="" method="get" class="search-form">
<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>
<?php $wp_list_table->search_box( __( 'Search Users' ), 'user' ); ?>
</form>
<form id="form-user-list" action='edit.php?action=allusers' method='post'>
@ -90,4 +87,4 @@ if ( isset( $_REQUEST['updated'] ) && $_REQUEST['updated'] == 'true' && ! empty(
</form>
</div>
<?php require_once( '../admin-footer.php' ); ?>
<?php require_once( '../admin-footer.php' ); ?>

View File

@ -377,15 +377,7 @@ if ( ( ! is_multisite() || is_network_admin() ) && current_user_can('install_plu
<form method="post" action="">
<?php if ( $wp_list_table->has_items() ) : ?>
<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; ?>
<?php $wp_list_table->search_box( __( 'Search Plugins' ), 'plugin' ); ?>
<input type="hidden" name="plugin_status" value="<?php echo esc_attr($status) ?>" />
<input type="hidden" name="paged" value="<?php echo esc_attr($page) ?>" />

View File

@ -146,7 +146,7 @@ if ( ! current_user_can( 'switch_themes' ) ) {
<h3><?php _e('Available Themes'); ?></h3>
<?php if ( $wp_list_table->has_items() ) : ?>
<?php if ( !empty( $_REQUEST['s'] ) || $wp_list_table->has_items() ) : ?>
<form class="search-form filter-form" action="" method="get">

View File

@ -206,15 +206,7 @@ if ( !empty($message) ) { ?>
<form id="posts-filter" action="" method="post">
<?php if ( $wp_list_table->has_items() ) : ?>
<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; ?>
<?php $wp_list_table->search_box( __( 'Search Media' ), 'media' ); ?>
<?php $wp_list_table->display(); ?>

View File

@ -357,15 +357,7 @@ if ( $usersearch )
<form action="" method="post">
<?php if ( $wp_list_table->has_items() ) : ?>
<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; ?>
<?php $wp_list_table->search_box( __( 'Search Users' ), 'user' ); ?>
<?php $wp_list_table->display(); ?>
</form>