Tag searching from jhodgdon. see #5684

git-svn-id: http://svn.automattic.com/wordpress/trunk@6670 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-01-28 17:21:14 +00:00
parent 80643d6ed9
commit bd3b74e729
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 = '';