diff --git a/wp-admin/admin-ajax.php b/wp-admin/admin-ajax.php index 7218be8e49..3bac0582e1 100644 --- a/wp-admin/admin-ajax.php +++ b/wp-admin/admin-ajax.php @@ -134,7 +134,7 @@ case 'add-link-category' : // On the Fly $cat_name = trim($cat_name); if ( !$slug = sanitize_title($cat_name) ) die('0'); - if ( !$cat_id = category_exists( $cat_name ) ) { + if ( !$cat_id = is_term( $cat_name, 'link_category' ) ) { $cat_id = wp_insert_term( $cat_name, 'link_category' ); $cat_id = $cat_id['term_id']; } diff --git a/wp-admin/categories.php b/wp-admin/categories.php index 41caea2255..6fc07889b0 100644 --- a/wp-admin/categories.php +++ b/wp-admin/categories.php @@ -36,9 +36,6 @@ case 'delete': if ( $cat_ID == get_option('default_category') ) wp_die(sprintf(__("Can’t delete the %s category: this is the default one"), $cat_name)); - if ( $cat_ID == get_option('default_link_category') ) - wp_die(sprintf(__("Can’t delete the %s category: this is the default one for links"), $cat_name)); - wp_delete_category($cat_ID); wp_redirect('categories.php?message=2'); @@ -113,7 +110,7 @@ cat_rows();
-

Note:
Deleting a category does not delete the posts and links in that category. Instead, posts that were only assigned to the deleted category are set to the category %s and links that were only assigned to the deleted category are set to %s.'), apply_filters('the_category', get_catname(get_option('default_category'))), apply_filters('the_category', get_catname(get_option('default_link_category')))) ?>

+

Note:
Deleting a category does not delete the posts in that category. Instead, posts that were only assigned to the deleted category are set to the category %s.'), apply_filters('the_category', get_catname(get_option('default_category')))) ?>

diff --git a/wp-admin/edit-link-categories.php b/wp-admin/edit-link-categories.php new file mode 100644 index 0000000000..3e05f5a88c --- /dev/null +++ b/wp-admin/edit-link-categories.php @@ -0,0 +1,93 @@ +term_id' class='edit'>".__( 'Edit' ).""; + $default_cat_id = (int) get_option( 'default_link_category' ); + + if ( $category->term_id != $default_cat_id ) + $edit .= "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' ).""; + else + $edit .= "".__( "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 ) ? "$category->count" : $category->count; + return " + $category->term_id + " . ( $name_override ? $name_override : $pad . ' ' . $category->name ) . " + $category->description + $count + $edit\n\t\n"; +} +?> + + +

+ + +
+ +

add new)'), '#addcat') ?>

+ +

+ + + + + + + + + + + + + + +
+ +
+ + +
+

Note:
Deleting a category does not delete the links in that category. Instead, links that were only assigned to the deleted category are set to the category %s.'), get_term_field('name', get_option('default_link_category'), 'link_category')) ?>

+
+ + + + + + diff --git a/wp-admin/edit-link-category-form.php b/wp-admin/edit-link-category-form.php new file mode 100644 index 0000000000..f31a7729e8 --- /dev/null +++ b/wp-admin/edit-link-category-form.php @@ -0,0 +1,49 @@ +'; + $action = 'editedcat'; + $nonce_action = 'update-link-category_' . $cat_ID; + do_action('edit_link_category_form_pre', $category); +} else { + $heading = __('Add Category'); + $submit_text = __('Add Category »'); + $form = '
'; + $action = 'addcat'; + $nonce_action = 'add-link-category'; + do_action('add_link_category_form_pre', $category); +} +?> + +
+

+
+ + + + + + + + + + + + + + + + + + + + + +
+ parent . '&hierarchical=1&show_option_none=' . __('None')); ?> +
+

+ + +
diff --git a/wp-admin/link-category.php b/wp-admin/link-category.php new file mode 100644 index 0000000000..51723f7cb1 --- /dev/null +++ b/wp-admin/link-category.php @@ -0,0 +1,71 @@ +%s category: this is the default one"), $cat_name)); + + wp_delete_term($cat_ID, 'link_category'); + + wp_redirect('edit-link-categories.php?message=2'); + exit; + +break; + +case 'edit': + $title = __('Categories'); + $parent_file = 'link-manager.php'; + $submenu_file = 'edit-link-categories.php'; + require_once ('admin-header.php'); + $cat_ID = (int) $_GET['cat_ID']; + $category = get_term_to_edit($cat_ID, 'link_category'); + include('edit-link-category-form.php'); + include('admin-footer.php'); + exit; +break; + +case 'editedcat': + $cat_ID = (int) $_POST['cat_ID']; + check_admin_referer('update-link-category_' . $cat_ID); + + if ( !current_user_can('manage_categories') ) + wp_die(__('Cheatin’ uh?')); + + if ( wp_update_term($cat_ID, 'link_category', $_POST) ) + wp_redirect('edit-link-categories.php?message=3'); + else + wp_redirect('edit-link-categories.php?message=5'); + + exit; +break; +} + +?> diff --git a/wp-admin/menu.php b/wp-admin/menu.php index 7bd8bc9435..4ae1e18775 100644 --- a/wp-admin/menu.php +++ b/wp-admin/menu.php @@ -46,6 +46,7 @@ $submenu['edit.php'][40] = array(__('Export'), 'import', 'export.php'); $submenu['link-manager.php'][5] = array(__('Manage Blogroll'), 'manage_links', 'link-manager.php'); $submenu['link-manager.php'][10] = array(__('Add Link'), 'manage_links', 'link-add.php'); $submenu['link-manager.php'][20] = array(__('Import Links'), 'manage_links', 'link-import.php'); +$submenu['link-manager.php'][30] = array(__('Categories'), 'manage_links', 'edit-link-categories.php'); if ( current_user_can('edit_users') ) { $_wp_real_parent_file['profile.php'] = 'users.php'; // Back-compat for plugins adding submenus to profile.php.