Manage categories redesign. Add categories search.
git-svn-id: http://svn.automattic.com/wordpress/trunk@6799 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
1bd097fff0
commit
8bd0691aa3
|
@ -84,19 +84,39 @@ $messages[5] = __('Category not updated.');
|
|||
<?php endif; ?>
|
||||
|
||||
<div class="wrap">
|
||||
<form id="posts-filter" action="" method="get">
|
||||
<?php if ( current_user_can('manage_categories') ) : ?>
|
||||
<h2><?php printf(__('Categories (<a href="%s">add new</a>)'), '#addcat') ?> </h2>
|
||||
<h2><?php printf(__('Manage Categories (<a href="%s">add new</a>)'), '#addcat') ?> </h2>
|
||||
<?php else : ?>
|
||||
<h2><?php _e('Categories') ?> </h2>
|
||||
<h2><?php _e('Manage Categories') ?> </h2>
|
||||
<?php endif; ?>
|
||||
|
||||
<p id="post-search">
|
||||
<input type="text" id="post-search-input" name="s" value="<?php echo attribute_escape(stripslashes($_GET['s'])); ?>" />
|
||||
<input type="submit" value="<?php _e( 'Search Categories' ); ?>" />
|
||||
</p>
|
||||
|
||||
<br style="clear:both;" />
|
||||
|
||||
<div class="tablenav">
|
||||
|
||||
<div style="float: left">
|
||||
<input type="button" value="<?php _e('Delete'); ?>" name="deleteit" />
|
||||
</div>
|
||||
|
||||
<br style="clear:both;" />
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<br style="clear:both;" />
|
||||
|
||||
<table class="widefat">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col" style="text-align: center"><?php _e('ID') ?></th>
|
||||
<th scope="col"><div style="text-align: center"><input type="checkbox" name="TODO" /></div></th>
|
||||
<th scope="col"><?php _e('Name') ?></th>
|
||||
<th scope="col"><?php _e('Description') ?></th>
|
||||
<th scope="col" width="90" style="text-align: center"><?php _e('Posts') ?></th>
|
||||
<th colspan="2" style="text-align: center"><?php _e('Action') ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="the-list" class="list:cat">
|
||||
|
|
|
@ -6,8 +6,12 @@
|
|||
|
||||
// Dandy new recursive multiple category stuff.
|
||||
function cat_rows( $parent = 0, $level = 0, $categories = 0 ) {
|
||||
if ( !$categories )
|
||||
$categories = get_categories( 'hide_empty=0' );
|
||||
if ( !$categories ) {
|
||||
$args = array('hide_empty' => 0);
|
||||
if ( !empty($_GET['s']) )
|
||||
$args['search'] = $_GET['s'];
|
||||
$categories = get_categories( $args );
|
||||
}
|
||||
|
||||
$children = _get_term_hierarchy('category');
|
||||
|
||||
|
@ -38,26 +42,21 @@ function _cat_row( $category, $level, $name_override = false ) {
|
|||
|
||||
$pad = str_repeat( '— ', $level );
|
||||
if ( current_user_can( 'manage_categories' ) ) {
|
||||
$edit = "<a href='categories.php?action=edit&cat_ID=$category->term_id' class='edit'>".__( 'Edit' )."</a></td>";
|
||||
$edit = "<a href='categories.php?action=edit&cat_ID=$category->term_id'>". ( $name_override ? $name_override : $pad . ' ' . $category->name ) ."</a>";
|
||||
$default_cat_id = (int) get_option( 'default_category' );
|
||||
|
||||
if ( $category->term_id != $default_cat_id )
|
||||
$edit .= "<td><a href='" . wp_nonce_url( "categories.php?action=delete&cat_ID=$category->term_id", 'delete-category_' . $category->term_id ) . "' class='delete:the-list:cat-$category->term_id delete'>".__( 'Delete' )."</a>";
|
||||
else
|
||||
$edit .= "<td style='text-align:center'>".__( "Default" );
|
||||
} else
|
||||
$edit = '';
|
||||
} else {
|
||||
$edit = ( $name_override ? $name_override : $pad . ' ' . $category->name );
|
||||
}
|
||||
|
||||
$class = " class='alternate'" == $class ? '' : " class='alternate'";
|
||||
|
||||
$category->count = number_format_i18n( $category->count );
|
||||
$posts_count = ( $category->count > 0 ) ? "<a href='edit.php?cat=$category->term_id'>$category->count</a>" : $category->count;
|
||||
$output = "<tr id='cat-$category->term_id'$class>
|
||||
<th scope='row' style='text-align: center'>$category->term_id</th>
|
||||
<td>" . ( $name_override ? $name_override : $pad . ' ' . $category->name ) . "</td>
|
||||
<th scope='row' style='text-align: center'><input type='checkbox' name='delete[]' value='$category->term_id' /></th>
|
||||
<td>$edit</td>
|
||||
<td>$category->description</td>
|
||||
<td align='center'>$posts_count</td>
|
||||
<td>$edit</td>\n\t</tr>\n";
|
||||
<td align='center'>$posts_count</td>\n\t</tr>\n";
|
||||
|
||||
return apply_filters('cat_row', $output);
|
||||
}
|
||||
|
|
|
@ -117,7 +117,7 @@ $link_columns = apply_filters('manage_link_columns', $link_columns);
|
|||
if ( 'all' == $cat_id )
|
||||
$cat_id = '';
|
||||
$args = array('category' => $cat_id, 'hide_invisible' => 0, 'orderby' => $sqlorderby, 'hide_empty' => 0);
|
||||
if ( $_GET['s'] )
|
||||
if ( !empty($_GET['s']) )
|
||||
$args['search'] = $_GET['s'];
|
||||
$links = get_bookmarks( $args );
|
||||
if ( $links ) {
|
||||
|
|
|
@ -525,7 +525,7 @@ function &get_terms($taxonomies, $args = '') {
|
|||
'hide_empty' => true, 'exclude' => '', 'include' => '',
|
||||
'number' => '', 'fields' => 'all', 'slug' => '', 'parent' => '',
|
||||
'hierarchical' => true, 'child_of' => 0, 'get' => '', 'name__like' => '',
|
||||
'pad_counts' => false, 'offset' => '');
|
||||
'pad_counts' => false, 'offset' => '', 'search' => '');
|
||||
$args = wp_parse_args( $args, $defaults );
|
||||
$args['number'] = absint( $args['number'] );
|
||||
$args['offset'] = absint( $args['offset'] );
|
||||
|
@ -635,6 +635,11 @@ function &get_terms($taxonomies, $args = '') {
|
|||
} else
|
||||
$number = '';
|
||||
|
||||
if ( !empty($search) ) {
|
||||
$search = like_escape($search);
|
||||
$where .= " AND (t.name LIKE '%$search%')";
|
||||
}
|
||||
|
||||
if ( 'all' == $fields )
|
||||
$select_this = 't.*, tt.*';
|
||||
else if ( 'ids' == $fields )
|
||||
|
|
Loading…
Reference in New Issue