AJAX for link category add and delete. Props mdawaffe. fixes #5291
git-svn-id: http://svn.automattic.com/wordpress/trunk@6299 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -4,7 +4,7 @@ require_once('admin.php');
|
||||
$title = __('Categories');
|
||||
$parent_file = 'link-manager.php';
|
||||
|
||||
//wp_enqueue_script( 'admin-categories' ); TODO: Fix AJAX
|
||||
wp_enqueue_script( 'admin-categories' );
|
||||
require_once ('admin-header.php');
|
||||
|
||||
$messages[1] = __('Category added.');
|
||||
@@ -13,35 +13,8 @@ $messages[3] = __('Category updated.');
|
||||
$messages[4] = __('Category not added.');
|
||||
$messages[5] = __('Category not updated.');
|
||||
|
||||
function link_cat_row($category) {
|
||||
global $class;
|
||||
if (isset($_GET['message'])) : ?>
|
||||
|
||||
if ( current_user_can( 'manage_categories' ) ) {
|
||||
$edit = "<a href='link-category.php?action=edit&cat_ID=$category->term_id' class='edit'>".__( 'Edit' )."</a></td>";
|
||||
$default_cat_id = (int) get_option( 'default_link_category' );
|
||||
|
||||
if ( $category->term_id != $default_cat_id )
|
||||
$edit .= "<td><a href='" . wp_nonce_url( "link-category.php?action=delete&cat_ID=$category->term_id", 'delete-link-category_' . $category->term_id ) . "' onclick=\"return deleteSomething( 'cat', $category->term_id, '" . js_escape(sprintf( __("You are about to delete the category '%s'.\nAll links that were only assigned to this category will be assigned to the '%s' category.\n'OK' to delete, 'Cancel' to stop." ), $category->name, get_term_field( 'name', $default_cat_id, 'link_category' ))) . "' );\" class='delete'>".__( 'Delete' )."</a>";
|
||||
else
|
||||
$edit .= "<td style='text-align:center'>".__( "Default" );
|
||||
} else {
|
||||
$edit = '';
|
||||
}
|
||||
|
||||
$class = ( ( defined( 'DOING_AJAX' ) && DOING_AJAX ) || " class='alternate'" == $class ) ? '' : " class='alternate'";
|
||||
|
||||
$category->count = number_format_i18n( $category->count );
|
||||
$count = ( $category->count > 0 ) ? "<a href='link-manager.php?cat_id=$category->term_id'>$category->count</a>" : $category->count;
|
||||
return "<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>
|
||||
<td>$category->description</td>
|
||||
<td align='center'>$count</td>
|
||||
<td>$edit</td>\n\t</tr>\n";
|
||||
}
|
||||
?>
|
||||
|
||||
<?php if (isset($_GET['message'])) : ?>
|
||||
<div id="message" class="updated fade"><p><?php echo $messages[$_GET['message']]; ?></p></div>
|
||||
<?php endif; ?>
|
||||
|
||||
@@ -61,7 +34,7 @@ function link_cat_row($category) {
|
||||
<th colspan="2" style="text-align: center"><?php _e('Action') ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="the-list">
|
||||
<tbody id="the-list" class="list:link-cat">
|
||||
<?php
|
||||
$categories = get_terms( 'link_category', 'hide_empty=0' );
|
||||
if ( $categories ) {
|
||||
|
||||
Reference in New Issue
Block a user