-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', "default=$default");
-}
-
-function wp_insert_category($catarr, $wp_error = false) {
- $cat_defaults = array('cat_ID' => 0, 'cat_name' => '', 'category_description' => '', 'category_nicename' => '', 'category_parent' => '');
- $cat_arr = wp_parse_args($cat_arr, $cat_defaults);
- extract($catarr, EXTR_SKIP);
-
- if ( trim( $cat_name ) == '' ) {
- if ( ! $wp_error )
+/**
+ * Updates an existing Category or creates a new Category.
+ *
+ * @since 2.0.0
+ * @since 2.5.0 $wp_error parameter was added.
+ * @since 3.0.0 The 'taxonomy' argument was added.
+ *
+ * @param array $catarr {
+ * Array of arguments for inserting a new category.
+ *
+ * @type int $cat_ID Categoriy ID. A non-zero value updates an existing category.
+ * Default 0.
+ * @type string $taxonomy Taxonomy slug. Defualt 'category'.
+ * @type string $cat_nam Category name. Default empty.
+ * @type string $category_description Category description. Default empty.
+ * @type string $category_nicename Category nice (display) name. Default empty.
+ * @type int|string $category_parent Category parent ID. Default empty.
+ * }
+ * @param bool $wp_error Optional. Default false.
+ * @return int|object The ID number of the new or updated Category on success. Zero or a WP_Error on failure,
+ * depending on param $wp_error.
+ */
+function wp_insert_category( $catarr, $wp_error = false ) {
+ $cat_defaults = array( 'cat_ID' => 0, 'taxonomy' => 'category', 'cat_name' => '', 'category_description' => '', 'category_nicename' => '', 'category_parent' => '' );
+ $catarr = wp_parse_args( $catarr, $cat_defaults );
+
+ if ( trim( $catarr['cat_name'] ) == '' ) {
+ if ( ! $wp_error ) {