cptui_delete_taxonomy

Delete our custom taxonomy from the array of taxonomies.

Description

(bool|string) cptui_delete_taxonomy( (array) $data = array() ); 

Returns (bool|string)

False on failure, string on success.

Parameters (1)

0. $data — Optional. (array) => array()
The $_POST values. Optional.

Usage

  1. if ( !function_exists( 'cptui_delete_taxonomy' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'custom-post-type-ui/inc/taxonomies.php'; 
  3.  
  4. // The $_POST values. Optional. 
  5. $data = array(); 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = cptui_delete_taxonomy($data); 
  9.  

Defined (1)

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

/inc/taxonomies.php  
  1. function cptui_delete_taxonomy( $data = array() ) { 
  2.  
  3. if ( is_string( $data ) && taxonomy_exists( $data ) ) { 
  4. $data = array( 
  5. 'cpt_custom_tax' => array( 
  6. 'name' => $data,  
  7. ),  
  8. ); 
  9.  
  10. // Check if they selected one to delete. 
  11. if ( empty( $data['cpt_custom_tax']['name'] ) ) { 
  12. return cptui_admin_notices( error, '', false, esc_html__( 'Please provide a taxonomy to delete', 'custom-post-type-ui' ) ); 
  13.  
  14. /** 
  15. * Fires before a taxonomy is deleted from our saved options. 
  16. * @since 1.0.0 
  17. * @param array $data Array of taxonomy data we are deleting. 
  18. */ 
  19. do_action( 'cptui_before_delete_taxonomy', $data ); 
  20.  
  21. $taxonomies = cptui_get_taxonomy_data(); 
  22.  
  23. if ( array_key_exists( strtolower( $data['cpt_custom_tax']['name'] ), $taxonomies ) ) { 
  24.  
  25. unset( $taxonomies[ $data['cpt_custom_tax']['name'] ] ); 
  26.  
  27. /** 
  28. * Filters whether or not 3rd party options were saved successfully within taxonomy deletion. 
  29. * @since 1.3.0 
  30. * @param bool $value Whether or not someone else saved successfully. Default false. 
  31. * @param array $taxonomies Array of our updated taxonomies data. 
  32. * @param array $data Array of submitted taxonomy to update. 
  33. */ 
  34. if ( false === ( $success = apply_filters( 'cptui_taxonomy_delete_tax', false, $taxonomies, $data ) ) ) { 
  35. $success = update_option( 'cptui_taxonomies', $taxonomies ); 
  36.  
  37. /** 
  38. * Fires after a taxonomy is deleted from our saved options. 
  39. * @since 1.0.0 
  40. * @param array $data Array of taxonomy data that was deleted. 
  41. */ 
  42. do_action( 'cptui_after_delete_taxonomy', $data ); 
  43.  
  44. // Used to help flush rewrite rules on init. 
  45. set_transient( 'cptui_flush_rewrite_rules', 'true', 5 * 60 ); 
  46.  
  47. if ( isset( $success ) ) { 
  48. return 'delete_success'; 
  49. return 'delete_fail';