Changeset 11676 for trunk/wp-admin/admin-ajax.php
- Timestamp:
- 07/01/2009 08:12:39 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/admin-ajax.php
r11660 r11676 214 214 break; 215 215 case 'delete-tag' : 216 check_ajax_referer( "delete-tag_$id" ); 216 $tag_id = (int) $_POST['tag_ID']; 217 check_ajax_referer( "delete-tag_$tag_id" ); 217 218 if ( !current_user_can( 'manage_categories' ) ) 218 219 die('-1'); 219 220 220 if ( !empty($_POST['taxonomy']) ) 221 $taxonomy = $_POST['taxonomy']; 222 else 223 $taxonomy = 'post_tag'; 224 225 $tag = get_term( $id, $taxonomy ); 221 $taxonomy = !empty($_POST['taxonomy']) ? $_POST['taxonomy'] : 'post_tag'; 222 223 $tag = get_term( $tag_id, $taxonomy ); 226 224 if ( !$tag || is_wp_error( $tag ) ) 227 225 die('1'); 228 226 229 if ( wp_delete_term($ id, $taxonomy))227 if ( wp_delete_term($tag_id, $taxonomy)) 230 228 die('1'); 231 229 else … … 528 526 die('-1'); 529 527 530 if ( '' === trim($_POST['name']) ) { 531 $x = new WP_Ajax_Response( array( 532 'what' => 'tag', 533 'id' => new WP_Error( 'name', __('You did not enter a tag name.') ) 534 ) ); 535 $x->send(); 536 } 537 538 if ( !empty($_POST['taxonomy']) ) 539 $taxonomy = $_POST['taxonomy']; 540 else 541 $taxonomy = 'post_tag'; 542 543 $tag = wp_insert_term($_POST['name'], $taxonomy, $_POST ); 544 545 if ( is_wp_error($tag) ) { 546 $x = new WP_Ajax_Response( array( 547 'what' => 'tag', 548 'id' => $tag 549 ) ); 550 $x->send(); 551 } 552 553 if ( !$tag || (!$tag = get_term( $tag['term_id'], $taxonomy )) ) 554 die('0'); 555 556 $tag_full_name = $tag->name; 557 $tag_full_name = esc_attr($tag_full_name); 558 559 $x = new WP_Ajax_Response( array( 560 'what' => 'tag', 561 'id' => $tag->term_id, 562 'position' => '-1', 563 'data' => _tag_row( $tag, '', $taxonomy ), 564 'supplemental' => array('name' => $tag_full_name, 'show-link' => sprintf(__( 'Tag <a href="#%s">%s</a> added' ), "tag-$tag->term_id", $tag_full_name)) 565 ) ); 566 $x->send(); 528 $taxonomy = !empty($_POST['taxonomy']) ? $_POST['taxonomy'] : 'post_tag'; 529 $tag = wp_insert_term($_POST['tag-name'], $taxonomy, $_POST ); 530 531 if ( !$tag || is_wp_error($tag) || (!$tag = get_term( $tag['term_id'], $taxonomy )) ) { 532 echo '<div class="error"><p>' . __('An error has occured. Please reload the page and try again.') . '</p></div>'; 533 exit; 534 } 535 536 echo _tag_row( $tag, '', $taxonomy ); 537 exit; 567 538 break; 568 539 case 'get-tagcloud' : … … 1149 1120 break; 1150 1121 case 'tag' : 1151 if ( !empty($_POST['taxonomy']) ) 1152 $taxonomy = $_POST['taxonomy']; 1153 else 1154 $taxonomy = 'post_tag'; 1122 $taxonomy = !empty($_POST['taxonomy']) ? $_POST['taxonomy'] : 'post_tag'; 1155 1123 1156 1124 $tag = get_term( $id, $taxonomy ); … … 1163 1131 die( __('Tag not updated.') ); 1164 1132 1165 echo _tag_row($tag );1133 echo _tag_row($tag, '', $taxonomy); 1166 1134 } else { 1167 1135 die( __('Tag not updated.') );
Note: See TracChangeset
for help on using the changeset viewer.