Changeset 6299 for trunk/wp-admin/admin-ajax.php
- Timestamp:
- 10/31/2007 03:53:32 AM (19 years ago)
- File:
-
- 1 edited
-
trunk/wp-admin/admin-ajax.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/admin-ajax.php
r6287 r6299 52 52 die('1'); 53 53 else die('0'); 54 break; 55 case 'delete-link-cat' : 56 check_ajax_referer( "delete-link-category_$id" ); 57 if ( !current_user_can( 'manage_categories' ) ) 58 die('-1'); 59 60 $cat_name = get_term_field('name', $id, 'link_category'); 61 62 // Don't delete the default cats. 63 if ( $id == get_option('default_link_category') ) { 64 $x = new WP_AJAX_Response( array( 65 'what' => 'link-cat', 66 'id' => $id, 67 'data' => new WP_Error( 'default-link-cat', sprintf(__("Can’t delete the <strong>%s</strong> category: this is the default one"), $cat_name) ) 68 ) ); 69 $x->send(); 70 } 71 72 $r = wp_delete_term($id, 'link_category'); 73 if ( !$r ) 74 die('0'); 75 if ( is_wp_error($r) ) { 76 $x = new WP_AJAX_Response( array( 77 'what' => 'link-cat', 78 'id' => $id, 79 'data' => $r 80 ) ); 81 $x->send(); 82 } 83 die('1'); 54 84 break; 55 85 case 'delete-link' : … … 179 209 'data' => _cat_row( $cat, $level, $cat_full_name ), 180 210 'supplemental' => array('name' => $cat_full_name, 'show-link' => sprintf(__( 'Category <a href="#%s">%s</a> added' ), "cat-$cat->term_id", $cat_full_name)) 211 ) ); 212 $x->send(); 213 break; 214 case 'add-link-cat' : // From Blogroll -> Categories 215 check_ajax_referer( 'add-link-category' ); 216 if ( !current_user_can( 'manage_categories' ) ) 217 die('-1'); 218 219 $r = wp_insert_term($_POST['name'], 'link_category', $_POST ); 220 if ( is_wp_error( $r ) ) { 221 $x = new WP_AJAX_Response( array( 222 'what' => 'link-cat', 223 'id' => $r 224 ) ); 225 $x->send(); 226 } 227 228 extract($r, EXTR_SKIP); 229 230 if ( !$link_cat = link_cat_row( $term_id ) ) 231 die('0'); 232 233 $x = new WP_Ajax_Response( array( 234 'what' => 'link-cat', 235 'id' => $term_id, 236 'data' => $link_cat 181 237 ) ); 182 238 $x->send();
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)