WordPress.org

Make WordPress Core

Changeset 12942


Ignore:
Timestamp:
02/04/2010 11:01:07 AM (11 years ago)
Author:
dd32
Message:

Remove redundant Category forms/code/ajax. See #11838

Location:
trunk/wp-admin
Files:
2 deleted
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/admin-ajax.php

    r12859 r12942  
    313313    die( '0' );
    314314    break;
    315 case 'delete-cat' :
    316     check_ajax_referer( "delete-category_$id" );
    317     if ( !current_user_can( 'manage_categories' ) )
    318         die('-1');
    319 
    320     $cat = get_category( $id );
    321     if ( !$cat || is_wp_error( $cat ) )
    322         die('1');
    323 
    324     if ( wp_delete_category( $id ) )
    325         die('1');
    326     else
    327         die('0');
    328     break;
    329315case 'delete-tag' :
    330316    $tag_id = (int) $_POST['tag_ID'];
     
    510496        ) );
    511497    }
    512     $x->send();
    513     break;
    514 case 'add-cat' : // From Manage->Categories
    515     check_ajax_referer( 'add-category' );
    516     if ( !current_user_can( 'manage_categories' ) )
    517         die('-1');
    518 
    519     if ( '' === trim($_POST['cat_name']) ) {
    520         $x = new WP_Ajax_Response( array(
    521             'what' => 'cat',
    522             'id' => new WP_Error( 'cat_name', __('You did not enter a category name.') )
    523         ) );
    524         $x->send();
    525     }
    526 
    527     if ( is_term( trim( $_POST['cat_name'] ), $_POST['taxonomy'], $_POST['category_parent'] ) ) {
    528         $x = new WP_Ajax_Response( array(
    529             'what' => 'cat',
    530             'id' => new WP_Error( 'cat_exists', __('The category you are trying to create already exists.'), array( 'form-field' => 'cat_name' ) ),
    531         ) );
    532         $x->send();
    533     }
    534 
    535     $cat = wp_insert_category( $_POST, true );
    536 
    537     if ( is_wp_error($cat) ) {
    538         $x = new WP_Ajax_Response( array(
    539             'what' => 'cat',
    540             'id' => $cat
    541         ) );
    542         $x->send();
    543     }
    544 
    545     if ( !$cat || (!$cat = get_term( $cat, $_POST['taxonomy'] ) ) )
    546         die('0');
    547 
    548     $level = 0;
    549     $cat_full_name = $cat->name;
    550     $_cat = $cat;
    551     while ( $_cat->parent ) {
    552         $_cat = get_category( $_cat->parent );
    553         $cat_full_name = $_cat->name . ' — ' . $cat_full_name;
    554         $level++;
    555     }
    556     $cat_full_name = esc_attr($cat_full_name);
    557 
    558     $x = new WP_Ajax_Response( array(
    559         'what' => 'cat',
    560         'id' => $cat->term_id,
    561         'position' => -1,
    562         'data' => _cat_row( $cat, $level, $cat_full_name ),
    563         'supplemental' => array('name' => $cat_full_name, 'show-link' => sprintf(__( 'Category <a href="#%s">%s</a> added' ), "cat-$cat->term_id", $cat_full_name))
    564     ) );
    565498    $x->send();
    566499    break;
Note: See TracChangeset for help on using the changeset viewer.