WordPress.org

Make WordPress Core

Ticket #3799: duplicate-category-protection.diff

File duplicate-category-protection.diff, 652 bytes (added by westi, 10 years ago)

Updated patch for trunk

  • C:/xampp/htdocs/wordpress/trunk/wp-admin/admin-ajax.php

     
    246246                $x->send();
    247247        }
    248248
     249        if ( category_exists( trim( $_POST['cat_name'] ) ) ) {
     250                $x = new WP_Ajax_Response( array(
     251                        'what' => 'cat',
     252                        'id' => new WP_Error( 'cat_exists', __('The category you are trying to create already exists.') )
     253                ) );
     254                $x->send();
     255        }
     256       
    249257        $cat = wp_insert_category( $_POST, true );
    250258
    251259        if ( is_wp_error($cat) ) {