Have wp_delete_category wrap wp_delete_term. Move wp_delete_category into wp-includes scope for consistency. fixes #15008, props blepoxp.

git-svn-id: http://svn.automattic.com/wordpress/trunk@15690 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
nacin 2010-10-03 07:29:44 +00:00
parent 054e18cb05
commit c6ff4fbaa9
3 changed files with 10 additions and 22 deletions

View File

@ -79,25 +79,6 @@ function wp_create_categories($categories, $post_id = '') {
return $cat_ids;
}
/**
* Deletes one existing category.
*
* @since 2.0.0
*
* @param int $cat_ID
* @return mixed Returns true if completes delete action; false if term doesnt exist; Zero on attempted deletion of default Category; WP_Error object is also a possibility.
*/
function wp_delete_category($cat_ID) {
$cat_ID = (int) $cat_ID;
$default = get_option('default_category');
// Don't delete the default cat
if ( $cat_ID == $default )
return 0;
return wp_delete_term($cat_ID, 'category', array('default' => $default));
}
/**
* Updates an existing Category or creates a new Category.
*

View File

@ -859,7 +859,7 @@ class wp_xmlrpc_server extends IXR_Server {
* @since 2.5.0
*
* @param array $args Method parameters.
* @return mixed See {@link wp_delete_category()} for return info.
* @return mixed See {@link wp_delete_term()} for return info.
*/
function wp_deleteCategory($args) {
$this->escape($args);
@ -877,7 +877,7 @@ class wp_xmlrpc_server extends IXR_Server {
if ( !current_user_can("manage_categories") )
return new IXR_Error( 401, __( "Sorry, you do not have the right to delete a category." ) );
return wp_delete_category( $category_id );
return wp_delete_term( $category_id, 'category' );
}
/**

View File

@ -1455,6 +1455,13 @@ function wp_delete_term( $term, $taxonomy, $args = array() ) {
$tt_id = $ids['term_taxonomy_id'];
$defaults = array();
if ( 'category' == $taxonomy ) {
$defaults['default'] = get_option( 'default_category' );
if ( $defaults['default'] == $term )
return 0; // Don't delete the default category
}
$args = wp_parse_args($args, $defaults);
extract($args, EXTR_SKIP);