WordPress.org

Make WordPress Core

Ticket #15355: clear_search.15355.patch

File clear_search.15355.patch, 10.3 KB (added by ocean90, 5 years ago)

First pass

  • 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 ) ); ?> 
     350if ( !empty( $usersearch ) ) 
     351        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( $usersearch ), admin_url( 'users.php' ) ); ?> 
    352352</h2> 
    353353 
    354354<?php $wp_list_table->views(); ?> 
  • wp-admin/edit-comments.php

     
    128128<?php screen_icon(); ?> 
    129129<h2><?php echo esc_html( $title ); 
    130130if ( 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>' ); ?> 
     131        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>', wp_html_excerpt( esc_html( stripslashes( $_REQUEST['s'] ) ), 50 ), admin_url( 'edit-comments.php' ) ); ?> 
    132132</h2> 
    133133 
    134134<?php 
  • 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']) ) ); ?> 
     215if ( isset($_REQUEST['s']) && $_REQUEST['s'] ) 
     216        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']) ), admin_url( "edit-tags.php?taxonomy=$taxonomy" ) ); ?> 
    217217</h2> 
    218218 
    219219<?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() ); ?> 
     155if ( isset($_REQUEST['s']) && $_REQUEST['s'] ) 
     156        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>', get_search_query(), admin_url( 'upload.php' ) ); ?> 
    157157</h2> 
    158158 
    159159<?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          
     73 
    7474        if ( !empty( $usersearch ) ) 
    75         printf( '<span class="subtitle">' . __( 'Search results for &#8220;%s&#8221;' ) . '</span>', esc_html( $usersearch ) ); 
     75                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( $usersearch ), network_admin_url( 'users.php' ) ); ?> 
    7676        ?> 
    7777        </h2> 
    7878 
  • wp-admin/network/sites.php

     
    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> 
    9797<?php endif; ?> 
    9898 
    99 <?php if ( isset( $_REQUEST['s'] ) && $_REQUEST['s'] ) { 
    100         printf( '<span class="subtitle">' . __( 'Search results for &#8220;%s&#8221;' ) . '</span>', esc_html( $s ) ); 
    101 } ?> 
     99<?php if ( isset($_REQUEST['s']) && $_REQUEST['s'] ) 
     100        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']) ), network_admin_url( 'sites.php' ) ); ?> 
    102101</h2> 
    103102 
    104103<form action="" method="get" id="ms-search"> 
  • wp-admin/edit.php

     
    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 
    173173if ( isset($_REQUEST['s']) && $_REQUEST['s'] ) 
    174         printf( '<span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', get_search_query() ); ?> 
     174        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>', get_search_query(), admin_url( "edit.php?post_type=$post_type" ) ); ?> 
    175175</h2> 
    176176 
    177177<?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']) ) ); ?> 
     61if ( isset($_REQUEST['s']) && $_REQUEST['s'] ) 
     62        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']) ), admin_url( 'link-manager.php' ) ); ?> 
    6363</h2> 
    6464 
    6565<?php