Tag searching from jhodgdon. see #5684

git-svn-id: https://develop.svn.wordpress.org/trunk@6670 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2008-01-28 17:21:14 +00:00
parent a8eb580138
commit 6bfc62a22b
2 changed files with 19 additions and 3 deletions

View File

@ -86,6 +86,14 @@ $messages[5] = __('Tag not updated.');
<?php else : ?>
<h2><?php _e('Tags') ?> </h2>
<?php endif; ?>
<form name="searchform" id="searchform" action="" method="get">
<input type="text" name="s" id="s" value="<?php echo attribute_escape( stripslashes( $_GET[ 's' ]) ); ?>" size="17" />
<input type="submit" id="post-query-submit" value="<?php _e('Search Tags'); ?>" class="button" />
</form>
<br style="clear:both;" />
<table class="widefat">
<thead>
<tr>
@ -101,7 +109,9 @@ $pagenum = absint( $_GET['pagenum'] );
if( !$tagsperpage || $tagsperpage < 0 ) {
$tagsperpage = 20;
}
$count = tag_rows( $pagenum, $tagsperpage );
$searchterms = trim( $_GET['s'] );
$count = tag_rows( $pagenum, $tagsperpage, $searchterms );
?>
</tbody>
</table>

View File

@ -261,11 +261,17 @@ function _tag_row( $tag, $class = '' ) {
// Outputs appropriate rows for the Nth page of the Tag Management screen,
// assuming M tags displayed at a time on the page
// Returns the number of tags displayed
function tag_rows( $page = 0, $pagesize = 20 ) {
function tag_rows( $page = 0, $pagesize = 20, $searchterms = '' ) {
// Get a page worth of tags
$start = $page * $pagesize;
$tags = get_terms( 'post_tag', "offset=$start&number=$pagesize&hide_empty=0" );
$args = array('offset' => $start, 'number' => $pagesize, 'hide_empty' => 0);
if ( !empty( $searchterms ) )
$args['name__like'] = $searchterms;
$tags = get_terms( 'post_tag', $args );
// convert it to table rows
$out = '';