Ticket #15355: clear_search.2.15355.patch

File clear_search.2.15355.patch, 13.0 KB (added by ocean90, 3 years ago)

With _search_results_subtitle()

  • wp-includes/script-loader.php

     
    372372                $scripts->localize( 'list-table', 'listTableL10n', array( 
    373373                        'loading' => __('Loading...'), 
    374374                        'error' => __('An error has occurred while loading the items.'), 
    375                         'search' => __('Search results for “%s”') 
     375                        'search' => __('Search results for “%s”'), 
     376                        'clear_search' => __('Clear search results') 
    376377                ) ); 
    377378 
    378379                $scripts->add( 'inline-edit-post', "/wp-admin/js/inline-edit-post$suffix.js", array( 'jquery', 'suggest' ), '20100707' ); 
  • wp-admin/users.php

     
    347347<div class="wrap"> 
    348348<?php screen_icon(); ?> 
    349349<h2><?php echo esc_html( $title ); if ( current_user_can( 'create_users' ) || current_user_can( 'promote_users' ) ) { ?>  <a href="user-new.php" class="button add-new-h2"><?php echo esc_html_x('Add New', 'user'); ?></a><?php } 
    350 if ( $usersearch ) 
    351         printf( '<span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', esc_html( $usersearch ) ); ?> 
     350_search_results_subtitle( admin_url( 'users.php' ) ); ?> 
    352351</h2> 
    353352 
    354353<?php $wp_list_table->views(); ?> 
     
    356355<form class="search-form" action="" method="get"> 
    357356<p class="search-box"> 
    358357        <label class="screen-reader-text" for="user-search-input"><?php _e( 'Search Users' ); ?>:</label> 
    359         <input type="text" id="user-search-input" name="usersearch" value="<?php echo esc_attr($usersearch); ?>" /> 
     358        <input type="text" id="user-search-input" name="s" value="<?php _admin_search_query(); ?>" /> 
    360359        <?php submit_button( __( 'Search Users' ), 'button', 'submit', false ); ?> 
    361360</p> 
    362361</form> 
  • wp-admin/edit-comments.php

     
    127127<div class="wrap"> 
    128128<?php screen_icon(); ?> 
    129129<h2><?php echo esc_html( $title ); 
    130 if ( isset($_REQUEST['s']) && $_REQUEST['s'] ) 
    131         printf( '<span class="subtitle">' . sprintf( __( 'Search results for &#8220;%s&#8221;' ), wp_html_excerpt( esc_html( stripslashes( $_REQUEST['s'] ) ), 50 ) ) . '</span>' ); ?> 
     130_search_results_subtitle( admin_url( 'edit-comments.php' ) ); ?> 
    132131</h2> 
    133132 
    134133<?php 
     
    200199 
    201200<?php $wp_list_table->views(); ?> 
    202201 
    203 <form id="comments-form" action="" method="post"> 
     202<form id="comments-form" action="" method="get"> 
    204203<p class="search-box"> 
    205204        <label class="screen-reader-text" for="comment-search-input"><?php _e( 'Search Comments' ); ?>:</label> 
    206205        <input type="text" id="comment-search-input" name="s" value="<?php _admin_search_query(); ?>" /> 
  • wp-admin/includes/class-wp-users-list-table.php

     
    1414        } 
    1515 
    1616        function prepare_items() { 
    17                 global $role, $usersearch; 
     17                global $role, $search; 
    1818 
    19                 $usersearch = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : ''; 
     19                $search = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : ''; 
    2020 
    2121                $role = isset( $_REQUEST['role'] ) ? $_REQUEST['role'] : ''; 
    2222 
     
    2828                        'number' => $users_per_page, 
    2929                        'offset' => ( $paged-1 ) * $users_per_page, 
    3030                        'role' => $role, 
    31                         'search' => $usersearch 
     31                        'search' => $search 
    3232                ); 
    3333 
    3434                if ( isset( $_REQUEST['orderby'] ) ) 
  • wp-admin/includes/class-wp-ms-users-list-table.php

     
    2323        } 
    2424 
    2525        function prepare_items() { 
    26                 global $usersearch, $role, $wpdb; 
     26                global $search, $role, $wpdb; 
    2727 
    28                 $usersearch = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : ''; 
     28                $search = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : ''; 
    2929 
    3030                $users_per_page = $this->get_items_per_page( 'users_network_per_page' ); 
    3131 
     
    3636                $args = array( 
    3737                        'number' => $users_per_page, 
    3838                        'offset' => ( $paged-1 ) * $users_per_page, 
    39                         'search' => $usersearch, 
     39                        'search' => $search, 
    4040                        'blog_id' => 0 
    4141                ); 
    4242 
     
    4747 
    4848                // If the network is large and a search is not being performed, show only the latest users with no paging in order 
    4949                // to avoid expensive count queries. 
    50                 if ( !$usersearch && ( get_blog_count() >= 10000 ) ) { 
     50                if ( !$search && ( get_blog_count() >= 10000 ) ) { 
    5151                        if ( !isset($_REQUEST['orderby']) ) 
    5252                                $_GET['orderby'] = $_REQUEST['orderby'] = 'id'; 
    5353                        if ( !isset($_REQUEST['order']) ) 
  • wp-admin/includes/template.php

     
    21652165        return $button; 
    21662166} 
    21672167 
     2168/** 
     2169 * Print the search results sentence as a subtitle 
     2170 * 
     2171 * @since 3.1.0 
     2172 * 
     2173 * uses esc_html 
     2174 * 
     2175 * @param string $url The URL of the search page 
     2176 */ 
     2177function _search_results_subtitle( $url ) { 
     2178        if ( !empty( $_REQUEST['s']) && !empty( $url ) ) 
     2179                printf( '<span class="subtitle">' . __( 'Search results for &#8220;%s&#8221;' ) . '<a id="clear-search" href="%s" class="ntdelbutton" title="' . __( 'Clear search results' ) . '">X</a></span>', esc_html( stripslashes( $_REQUEST['s'] ) ), $url ); 
     2180        return null; 
     2181} 
  • wp-admin/edit-tags.php

     
    212212<div class="wrap nosubsub"> 
    213213<?php screen_icon(); ?> 
    214214<h2><?php echo esc_html( $title ); 
    215 if ( !empty($_REQUEST['s']) ) 
    216         printf( '<span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', esc_html( stripslashes($_REQUEST['s']) ) ); ?> 
     215_search_results_subtitle( admin_url( "edit-tags.php?taxonomy=$taxonomy" ) ); ?> 
    217216</h2> 
    218217 
    219218<?php if ( isset($_REQUEST['message']) && ( $msg = (int) $_REQUEST['message'] ) ) : ?> 
  • wp-admin/js/list-table.dev.js

     
    220220                listTable.update_rows(data, true, function() { 
    221221                        $('h2 .subtitle').remove(); 
    222222 
    223                         if ( data.s ) 
    224                                 $('h2').append($('<span class="subtitle">').html( 
    225                                         listTableL10n.search.replace('%s', this.htmlencode(data.s)) 
    226                                 )); 
     223                        if ( data.s ) { 
     224                                $('h2').append( $('<span class="subtitle">').html( 
     225                                        listTableL10n.search.replace('%s', this.htmlencode(data.s)) + 
     226                                        '<a id="clear-search" class="ntdelbutton" title="' + 
     227                                        listTableL10n.clear_search + 
     228                                        '">X</a></span>' 
     229                                ) ); 
     230                        } 
     231                                 
    227232                }); 
    228233        } 
     234 
     235        function clear_search() { 
     236                listTable.update_rows({'s': ''}, true, function() { 
     237                        $('h2 .subtitle').remove(); 
     238                        $('.search-box input[type="text"]').val(''); 
     239                }); 
     240 
     241                return false; 
     242        }; 
     243 
    229244        $('.search-box :submit').click(change_search); 
    230245        $('.search-box :text').keypress(change_search); 
     246        $('#clear-search').live('click', clear_search) 
    231247 
    232248        // tablenav dropdowns 
    233249        $('#post-query-submit').click(function() { 
  • wp-admin/upload.php

     
    152152<div class="wrap"> 
    153153<?php screen_icon(); ?> 
    154154<h2><?php echo esc_html( $title ); ?> <a href="media-new.php" class="button add-new-h2"><?php echo esc_html_x('Add New', 'file'); ?></a> <?php 
    155 if ( isset($_GET['s']) && $_GET['s'] ) 
    156         printf( '<span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', get_search_query() ); ?> 
     155_search_results_subtitle( admin_url( 'upload.php' ) ); ?> 
    157156</h2> 
    158157 
    159158<?php 
  • wp-admin/network/users.php

     
    7070        if ( current_user_can( 'create_users') ) : ?> 
    7171                <a href="<?php echo network_admin_url('user-new.php'); ?>" class="button add-new-h2"><?php echo esc_html_x( 'Add New', 'users' ); ?></a><?php 
    7272        endif; 
    73          
    74         if ( !empty( $usersearch ) ) 
    75         printf( '<span class="subtitle">' . __( 'Search results for &#8220;%s&#8221;' ) . '</span>', esc_html( $usersearch ) ); 
    76         ?> 
     73        _search_results_subtitle( network_admin_url( 'users.php' ) ); ?> 
    7774        </h2> 
    7875 
    7976        <?php $wp_list_table->views(); ?> 
    8077 
    8178        <form action="" method="get" class="search-form"> 
    8279                <p class="search-box"> 
    83                 <input type="text" name="s" value="<?php echo esc_attr( $usersearch ); ?>" class="search-input" id="user-search-input" /> 
     80                <input type="text" name="s" value="<?php echo esc_attr( $search ); ?>" class="search-input" id="user-search-input" /> 
    8481                <?php submit_button( __( 'Search Users' ), 'button', 'post-query-submit', false ); ?> 
    8582                </p> 
    8683        </form> 
  • wp-admin/network/sites.php

     
    9494<?php echo $msg; ?> 
    9595<?php if ( current_user_can( 'create_sites') ) : ?> 
    9696        <a href="<?php echo network_admin_url('site-new.php'); ?>" class="button add-new-h2"><?php echo esc_html_x( 'Add New', 'sites' ); ?></a> 
    97 <?php endif; ?> 
    98  
    99 <?php if ( isset( $_REQUEST['s'] ) && $_REQUEST['s'] ) { 
    100         printf( '<span class="subtitle">' . __( 'Search results for &#8220;%s&#8221;' ) . '</span>', esc_html( $s ) ); 
    101 } ?> 
     97<?php endif; 
     98_search_results_subtitle( network_admin_url( 'sites.php' ) ); ?> 
    10299</h2> 
    103100 
    104101<form action="" method="get" id="ms-search"> 
    105102<p class="search-box"> 
    106103<input type="hidden" name="action" value="blogs" /> 
    107 <input type="text" name="s" value="<?php echo esc_attr( $s ); ?>" /> 
     104<input type="text" name="s" value="<?php _admin_search_query(); ?>" /> 
    108105<?php submit_button( __( 'Search Sites' ), 'button', 'submit', false ); ?> 
    109106</p> 
    110107</form> 
  • wp-admin/edit.php

     
    170170<div class="wrap"> 
    171171<?php screen_icon(); ?> 
    172172<h2><?php echo esc_html( $post_type_object->labels->name ); ?> <a href="<?php echo $post_new_file ?>" class="button add-new-h2"><?php echo esc_html($post_type_object->labels->add_new); ?></a> <?php 
    173 if ( isset($_REQUEST['s']) && $_REQUEST['s'] ) 
    174         printf( '<span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', get_search_query() ); ?> 
     173_search_results_subtitle( admin_url( "edit.php?post_type=$post_type" ) ); ?> 
    175174</h2> 
    176175 
    177176<?php 
  • wp-admin/css/colors-classic.dev.css

     
    684684} 
    685685 
    686686.tagchecklist span a, 
    687 #bulk-titles div a { 
     687#bulk-titles div a, 
     688a#clear-search { 
    688689        background: url(../images/xit.gif) no-repeat; 
    689690} 
    690691 
    691692.tagchecklist span a:hover, 
    692 #bulk-titles div a:hover { 
     693#bulk-titles div a:hover, 
     694a#clear-search:hover { 
    693695        background: url(../images/xit.gif) no-repeat -10px 0; 
    694696} 
    695697 
  • wp-admin/css/colors-fresh.dev.css

     
    684684} 
    685685 
    686686.tagchecklist span a, 
    687 #bulk-titles div a { 
     687#bulk-titles div a, 
     688a#clear-search { 
    688689        background: url(../images/xit.gif) no-repeat; 
    689690} 
    690691 
    691692.tagchecklist span a:hover, 
    692 #bulk-titles div a:hover { 
     693#bulk-titles div a:hover, 
     694a#clear-search:hover { 
    693695        background: url(../images/xit.gif) no-repeat -10px 0; 
    694696} 
    695697 
  • wp-admin/css/wp-admin.dev.css

     
    284284        margin: -5px 0 0; 
    285285} 
    286286 
     287a#clear-search { 
     288        display: inline-block; 
     289        cursor: pointer; 
     290        height: 10px; 
     291        margin: 3px 5px 0; 
     292        overflow: hidden; 
     293        text-indent: -9999px; 
     294        width: 10px; 
     295} 
    287296 
    288297/*------------------------------------------------------------------------------ 
    289298  3.0 - Actions 
  • wp-admin/link-manager.php

     
    5858<div class="wrap nosubsub"> 
    5959<?php screen_icon(); ?> 
    6060<h2><?php echo esc_html( $title ); ?> <a href="link-add.php" class="button add-new-h2"><?php echo esc_html_x('Add New', 'link'); ?></a> <?php 
    61 if ( !empty($_REQUEST['s']) ) 
    62         printf( '<span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', esc_html( stripslashes($_REQUEST['s']) ) ); ?> 
     61_search_results_subtitle( admin_url( 'link-manager.php' ) ); ?> 
    6362</h2> 
    6463 
    6564<?php