cptui_delete_post_type

Delete our custom post type from the array of post types.

Description

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

Returns (bool|string)

False on failure, string on success.

Parameters (1)

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

Usage

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

Defined (1)

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

/inc/post-types.php  
  1. function cptui_delete_post_type( $data = array() ) { 
  2.  
  3. // Pass double data into last function despite matching values. 
  4. if ( is_string( $data ) && cptui_get_post_type_exists( $data, $data ) ) { 
  5. $data = array( 
  6. 'cpt_custom_post_type' => array( 
  7. 'name' => $data,  
  8. ),  
  9. ); 
  10.  
  11. if ( empty( $data['cpt_custom_post_type']['name'] ) ) { 
  12. return cptui_admin_notices( error, '', false, __( 'Please provide a post type to delete', 'custom-post-type-ui' ) ); 
  13.  
  14. /** 
  15. * Fires before a post type is deleted from our saved options. 
  16. * @since 1.0.0 
  17. * @param array $data Array of post type data we are deleting. 
  18. */ 
  19. do_action( 'cptui_before_delete_post_type', $data ); 
  20.  
  21. $post_types = cptui_get_post_type_data(); 
  22.  
  23. if ( array_key_exists( strtolower( $data['cpt_custom_post_type']['name'] ), $post_types ) ) { 
  24.  
  25. unset( $post_types[ $data['cpt_custom_post_type']['name'] ] ); 
  26.  
  27. /** 
  28. * Filters whether or not 3rd party options were saved successfully within post type deletion. 
  29. * @since 1.3.0 
  30. * @param bool $value Whether or not someone else saved successfully. Default false. 
  31. * @param array $post_types Array of our updated post types data. 
  32. * @param array $data Array of submitted post type to update. 
  33. */ 
  34. if ( false === ( $success = apply_filters( 'cptui_post_type_delete_type', false, $post_types, $data ) ) ) { 
  35. $success = update_option( 'cptui_post_types', $post_types ); 
  36.  
  37. /** 
  38. * Fires after a post type is deleted from our saved options. 
  39. * @since 1.0.0 
  40. * @param array $data Array of post type data that was deleted. 
  41. */ 
  42. do_action( 'cptui_after_delete_post_type', $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';