Make WordPress Core

Ticket #22400: 22400.taxonomy.php.diff

File 22400.taxonomy.php.diff, 2.3 KB (added by MikeHansenMe, 11 years ago)

Updated to remove debug.

  • wp-admin/includes/taxonomy.php

     
    9090 */
    9191function wp_insert_category($catarr, $wp_error = false) {
    9292        $cat_defaults = array('cat_ID' => 0, 'taxonomy' => 'category', 'cat_name' => '', 'category_description' => '', 'category_nicename' => '', 'category_parent' => '');
    93         $catarr = wp_parse_args($catarr, $cat_defaults);
    94         extract($catarr, EXTR_SKIP);
     93        $catarr = wp_parse_args( $catarr, $cat_defaults );
    9594
    96         if ( trim( $cat_name ) == '' ) {
     95        if ( trim( $catarr['cat_name'] ) == '' ) {
    9796                if ( ! $wp_error )
    9897                        return 0;
    9998                else
    10099                        return new WP_Error( 'cat_name', __('You did not enter a category name.') );
    101100        }
    102101
    103         $cat_ID = (int) $cat_ID;
     102        $catarr['cat_ID'] = (int) $catarr['cat_ID'];
    104103
    105104        // Are we updating or creating?
    106         if ( !empty ($cat_ID) )
     105        if ( !empty ( $catarr['cat_ID'] ) )
    107106                $update = true;
    108107        else
    109108                $update = false;
    110109
    111         $name = $cat_name;
    112         $description = $category_description;
    113         $slug = $category_nicename;
    114         $parent = $category_parent;
     110        $name = $catarr['cat_name'];
     111        $description = $catarr['category_description'];
     112        $slug = $catarr['category_nicename'];
     113        $parent = $catarr['category_parent'];
    115114
    116115        $parent = (int) $parent;
    117116        if ( $parent < 0 )
    118117                $parent = 0;
    119118
    120         if ( empty( $parent ) || ! term_exists( $parent, $taxonomy ) || ( $cat_ID && term_is_ancestor_of( $cat_ID, $parent, $taxonomy ) ) )
     119        if ( empty( $parent ) || ! term_exists( $parent, $taxonomy ) || ( $catarr['cat_ID'] && term_is_ancestor_of( $catarr['cat_ID'], $parent, $catarr['taxonomy'] ) ) )
    121120                $parent = 0;
    122121
    123122        $args = compact('name', 'slug', 'parent', 'description');
    124123
    125124        if ( $update )
    126                 $cat_ID = wp_update_term($cat_ID, $taxonomy, $args);
     125                $catarr['cat_ID'] = wp_update_term( $catarr['cat_ID'], $catarr['taxonomy'], $args);
    127126        else
    128                 $cat_ID = wp_insert_term($cat_name, $taxonomy, $args);
     127                $catarr['cat_ID'] = wp_insert_term( $catarr['cat_name'], $catarr['taxonomy'], $args);
    129128
    130         if ( is_wp_error($cat_ID) ) {
     129        if ( is_wp_error( $catarr['cat_ID'] ) ) {
    131130                if ( $wp_error )
    132                         return $cat_ID;
     131                        return $catarr['cat_ID'];
    133132                else
    134133                        return 0;
    135134        }
    136 
    137         return $cat_ID['term_id'];
     135        return $catarr['cat_ID']['term_id'];
    138136}
    139137
    140138/**