cptui_import_types_taxes_settings

Import the posted JSON data from a separate export.

Description

cptui_import_types_taxes_settings( (array) $postdata = array() ); 

Parameters (1)

0. $postdata — Optional. (array) => array()
$_POST data as json. Optional.

Usage

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

Defined (1)

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

/inc/tools.php  
  1. function cptui_import_types_taxes_settings( $postdata = array() ) { 
  2. if ( ! isset( $postdata['cptui_post_import'] ) && ! isset( $postdata['cptui_tax_import'] ) ) { 
  3. return false; 
  4.  
  5. $status = 'import_fail'; 
  6. $success = false; 
  7.  
  8. /** 
  9. * Filters the post type data to import. 
  10. * Allows third parties to provide their own data dump and import instead of going through our UI. 
  11. * @since 1.2.0 
  12. * @param bool $value Default to no data. 
  13. */ 
  14. $third_party_post_type_data = apply_filters( 'cptui_third_party_post_type_import', false ); 
  15.  
  16. /** 
  17. * Filters the taxonomy data to import. 
  18. * Allows third parties to provide their own data dump and import instead of going through our UI. 
  19. * @since 1.2.0 
  20. * @param bool $value Default to no data. 
  21. */ 
  22. $third_party_taxonomy_data = apply_filters( 'cptui_third_party_taxonomy_import', false ); 
  23.  
  24. if ( false !== $third_party_post_type_data ) { 
  25. $postdata['cptui_post_import'] = $third_party_post_type_data; 
  26.  
  27. if ( false !== $third_party_taxonomy_data ) { 
  28. $postdata['cptui_tax_import'] = $third_party_taxonomy_data; 
  29.  
  30. if ( ! empty( $postdata['cptui_post_import'] ) ) { 
  31. $cpt_data = stripslashes_deep( trim( $postdata['cptui_post_import'] ) ); 
  32. $settings = json_decode( $cpt_data, true ); 
  33.  
  34. // Add support to delete settings outright, without accessing database. 
  35. // Doing double check to protect. 
  36. if ( is_null( $settings ) && '{""}' === $cpt_data ) { 
  37.  
  38. /** 
  39. * Filters whether or not 3rd party options were deleted successfully within post type import. 
  40. * @since 1.3.0 
  41. * @param bool $value Whether or not someone else deleted successfully. Default false. 
  42. * @param array $postdata Post type data. 
  43. */ 
  44. if ( false === ( $success = apply_filters( 'cptui_post_type_import_delete_save', false, $postdata ) ) ) { 
  45. $success = delete_option( 'cptui_post_types' ); 
  46.  
  47. if ( $settings ) { 
  48. if ( false !== cptui_get_post_type_data() ) { 
  49. /** This filter is documented in /inc/import-export.php */ 
  50. if ( false === ( $success = apply_filters( 'cptui_post_type_import_delete_save', false, $postdata ) ) ) { 
  51. delete_option( 'cptui_post_types' ); 
  52.  
  53. /** 
  54. * Filters whether or not 3rd party options were updated successfully within the post type import. 
  55. * @since 1.3.0 
  56. * @param bool $value Whether or not someone else updated successfully. Default false. 
  57. * @param array $postdata Post type data. 
  58. */ 
  59. if ( false === ( $success = apply_filters( 'cptui_post_type_import_update_save', false, $postdata ) ) ) { 
  60. $success = update_option( 'cptui_post_types', $settings ); 
  61. // Used to help flush rewrite rules on init. 
  62. set_transient( 'cptui_flush_rewrite_rules', 'true', 5 * 60 ); 
  63.  
  64. if ( $success ) { 
  65. $status = 'import_success'; 
  66. } elseif ( ! empty( $postdata['cptui_tax_import'] ) ) { 
  67. $tax_data = stripslashes_deep( trim( $postdata['cptui_tax_import'] ) ); 
  68. $settings = json_decode( $tax_data, true ); 
  69.  
  70. // Add support to delete settings outright, without accessing database. 
  71. // Doing double check to protect. 
  72. if ( is_null( $settings ) && '{""}' === $tax_data ) { 
  73.  
  74. /** 
  75. * Filters whether or not 3rd party options were deleted successfully within taxonomy import. 
  76. * @since 1.3.0 
  77. * @param bool $value Whether or not someone else deleted successfully. Default false. 
  78. * @param array $postdata Taxonomy data 
  79. */ 
  80. if ( false === ( $success = apply_filters( 'cptui_taxonomy_import_delete_save', false, $postdata ) ) ) { 
  81. $success = delete_option( 'cptui_taxonomies' ); 
  82.  
  83. if ( $settings ) { 
  84. if ( false !== cptui_get_taxonomy_data() ) { 
  85. /** This filter is documented in /inc/import-export.php */ 
  86. if ( false === ( $success = apply_filters( 'cptui_taxonomy_import_delete_save', false, $postdata ) ) ) { 
  87. delete_option( 'cptui_taxonomies' ); 
  88. /** 
  89. * Filters whether or not 3rd party options were updated successfully within the taxonomy import. 
  90. * @since 1.3.0 
  91. * @param bool $value Whether or not someone else updated successfully. Default false. 
  92. * @param array $postdata Taxonomy data. 
  93. */ 
  94. if ( false === ( $success = apply_filters( 'cptui_taxonomy_import_update_save', false, $postdata ) ) ) { 
  95. $success = update_option( 'cptui_taxonomies', $settings ); 
  96. // Used to help flush rewrite rules on init. 
  97. set_transient( 'cptui_flush_rewrite_rules', 'true', 5 * 60 ); 
  98. if ( $success ) { 
  99. $status = 'import_success'; 
  100.  
  101. return $status;