wp_ajax_inline_save_tax

Ajax handler for quick edit saving for a term.

Description

wp_ajax_inline_save_tax(); 

Usage

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

Defined (1)

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

/wp-admin/includes/ajax-actions.php  
  1. function wp_ajax_inline_save_tax() { 
  2. check_ajax_referer( 'taxinlineeditnonce', '_inline_edit' ); 
  3.  
  4. $taxonomy = sanitize_key( $_POST['taxonomy'] ); 
  5. $tax = get_taxonomy( $taxonomy ); 
  6. if ( ! $tax ) 
  7. wp_die( 0 ); 
  8.  
  9. if ( ! isset( $_POST['tax_ID'] ) || ! ( $id = (int) $_POST['tax_ID'] ) ) { 
  10. wp_die( -1 ); 
  11.  
  12. if ( ! current_user_can( 'edit_term', $id ) ) { 
  13. wp_die( -1 ); 
  14.  
  15. $wp_list_table = _get_list_table( 'WP_Terms_List_Table', array( 'screen' => 'edit-' . $taxonomy ) ); 
  16.  
  17. $tag = get_term( $id, $taxonomy ); 
  18. $_POST['description'] = $tag->description; 
  19.  
  20. $updated = wp_update_term($id, $taxonomy, $_POST); 
  21. if ( $updated && !is_wp_error($updated) ) { 
  22. $tag = get_term( $updated['term_id'], $taxonomy ); 
  23. if ( !$tag || is_wp_error( $tag ) ) { 
  24. if ( is_wp_error($tag) && $tag->get_error_message() ) 
  25. wp_die( $tag->get_error_message() ); 
  26. wp_die( __( 'Item not updated.' ) ); 
  27. } else { 
  28. if ( is_wp_error($updated) && $updated->get_error_message() ) 
  29. wp_die( $updated->get_error_message() ); 
  30. wp_die( __( 'Item not updated.' ) ); 
  31. $level = 0; 
  32. $parent = $tag->parent; 
  33. while ( $parent > 0 ) { 
  34. $parent_tag = get_term( $parent, $taxonomy ); 
  35. $parent = $parent_tag->parent; 
  36. $level++; 
  37. $wp_list_table->single_row( $tag, $level ); 
  38. wp_die();