wp_ajax_delete_tag

Ajax handler for deleting a tag.

Description

wp_ajax_delete_tag(); 

Usage

  1. if ( !function_exists( 'wp_ajax_delete_tag' ) ) { 
  2. require_once ABSPATH . '/wp-admin/includes/ajax-actions.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = wp_ajax_delete_tag(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/wp-admin/includes/ajax-actions.php  
  1. function wp_ajax_delete_tag() { 
  2. $tag_id = (int) $_POST['tag_ID']; 
  3. check_ajax_referer( "delete-tag_$tag_id" ); 
  4.  
  5. if ( ! current_user_can( 'delete_term', $tag_id ) ) { 
  6. wp_die( -1 ); 
  7.  
  8. $taxonomy = !empty($_POST['taxonomy']) ? $_POST['taxonomy'] : 'post_tag'; 
  9. $tag = get_term( $tag_id, $taxonomy ); 
  10. if ( !$tag || is_wp_error( $tag ) ) 
  11. wp_die( 1 ); 
  12.  
  13. if ( wp_delete_term($tag_id, $taxonomy)) 
  14. wp_die( 1 ); 
  15. else 
  16. wp_die( 0 );