Make WordPress Core

Ticket #5684: tagsearch.diff

File tagsearch.diff, 2.1 KB (added by jhodgdon, 17 years ago)

Patch that adds search to the tag screen

  • E:/EclipseWorkWeb/WordPressDev/wp-admin/includes/template.php

     
    261261// Outputs appropriate rows for the Nth page of the Tag Management screen,
    262262// assuming M tags displayed at a time on the page
    263263// Returns the number of tags displayed
    264 function tag_rows( $page = 0, $pagesize = 20 ) {
     264function tag_rows( $page = 0, $pagesize = 20, $searchterms = '' ) {
    265265       
    266266        // Get a page worth of tags
    267267        $start = $page * $pagesize;
    268         $tags = get_terms( 'post_tag', "offset=$start&number=$pagesize&hide_empty=0"  );
    269268       
     269        $search = '';
     270        if( strlen( $searchterms )) {
     271                $searchterms = attribute_escape( $searchterms );
     272                $search = "&name__like=%$searchterms";
     273        }
     274       
     275        $tags = get_terms( 'post_tag', "offset=$start&number=$pagesize&hide_empty=0$search"  );
     276       
    270277        // convert it to table rows
    271278        $out = '';
    272279        $class = '';
  • E:/EclipseWorkWeb/WordPressDev/wp-admin/edit-tags.php

     
    8686<?php else : ?>
    8787        <h2><?php _e('Tags') ?> </h2>
    8888<?php endif; ?>
     89
     90<form name="searchform" id="searchform" action="" method="get">
     91        <fieldset><legend><?php _e('Tag contains&hellip;'); ?></legend>
     92                <input type="text" name="s" id="s" value="<?php echo stripslashes( $_GET[ 's' ]); ?>" size="17" />
     93        </fieldset>
     94
     95        <input type="submit" id="post-query-submit" value="<?php _e('Filter &#187;'); ?>" class="button" />
     96</form>
     97<br style="clear:both;" />
     98
     99
    89100<table class="widefat">
    90101        <thead>
    91102        <tr>
     
    101112if( !$tagsperpage || $tagsperpage < 0 ) {
    102113        $tagsperpage = 20;
    103114}
    104 $count = tag_rows( $pagenum, $tagsperpage );
     115$searchterms = trim( $_GET['s'] );
     116
     117$count = tag_rows( $pagenum, $tagsperpage, $searchterms );
    105118?>
    106119        </tbody>
    107120</table>