mirror of
https://github.com/WordPress/WordPress.git
synced 2025-02-17 03:56:07 +00:00
Fix assignment of links to the default category when a category is deleted. Props scohoust. fixes #7316 for trunk
git-svn-id: http://svn.automattic.com/wordpress/trunk@8388 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
e13c015e92
commit
2749db26de
@ -10,12 +10,13 @@ if ( isset($_GET['deleteit']) && isset($_GET['delete']) ) {
|
|||||||
|
|
||||||
foreach( (array) $_GET['delete'] as $cat_ID ) {
|
foreach( (array) $_GET['delete'] as $cat_ID ) {
|
||||||
$cat_name = get_term_field('name', $cat_ID, 'link_category');
|
$cat_name = get_term_field('name', $cat_ID, 'link_category');
|
||||||
|
$default_cat_id = get_option('default_link_category');
|
||||||
|
|
||||||
// Don't delete the default cats.
|
// Don't delete the default cats.
|
||||||
if ( $cat_ID == get_option('default_link_category') )
|
if ( $cat_ID == $default_cat_id )
|
||||||
wp_die(sprintf(__("Can’t delete the <strong>%s</strong> category: this is the default one"), $cat_name));
|
wp_die(sprintf(__("Can’t delete the <strong>%s</strong> category: this is the default one"), $cat_name));
|
||||||
|
|
||||||
wp_delete_term($cat_ID, 'link_category');
|
wp_delete_term($cat_ID, 'link_category', array('default' => $default_cat_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
$location = 'edit-link-categories.php';
|
$location = 'edit-link-categories.php';
|
||||||
|
@ -28,12 +28,13 @@ case 'delete':
|
|||||||
wp_die(__('Cheatin’ uh?'));
|
wp_die(__('Cheatin’ uh?'));
|
||||||
|
|
||||||
$cat_name = get_term_field('name', $cat_ID, 'link_category');
|
$cat_name = get_term_field('name', $cat_ID, 'link_category');
|
||||||
|
$default_cat_id = get_option('default_link_category');
|
||||||
|
|
||||||
// Don't delete the default cats.
|
// Don't delete the default cats.
|
||||||
if ( $cat_ID == get_option('default_link_category') )
|
if ( $cat_ID == $default_cat_id )
|
||||||
wp_die(sprintf(__("Can’t delete the <strong>%s</strong> category: this is the default one"), $cat_name));
|
wp_die(sprintf(__("Can’t delete the <strong>%s</strong> category: this is the default one"), $cat_name));
|
||||||
|
|
||||||
wp_delete_term($cat_ID, 'link_category');
|
wp_delete_term($cat_ID, 'link_category', array('default' => $default_cat_id));
|
||||||
|
|
||||||
$location = 'edit-link-categories.php';
|
$location = 'edit-link-categories.php';
|
||||||
if ( $referer = wp_get_original_referer() ) {
|
if ( $referer = wp_get_original_referer() ) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user