cptui_check_existing_taxonomy_slugs

Checks if we are trying to register an already registered taxonomy slug.

Description

cptui_check_existing_taxonomy_slugs( (constant) $slug_exists = false, (string) $taxonomy_slug = '', (array) $taxonomies = array() ); 

Parameters (3)

0. $slug_exists — Optional. (constant) => false
Whether or not the post type slug exists. Optional. Default false.
1. $taxonomy_slug — Optional. (string) => ''
The post type slug being saved. Optional. Default empty string.
2. $taxonomies — Optional. (array) => array()
Array of CPTUI-registered post types. Optional.

Usage

  1. if ( !function_exists( 'cptui_check_existing_taxonomy_slugs' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'custom-post-type-ui/inc/taxonomies.php'; 
  3.  
  4. // Whether or not the post type slug exists. Optional. Default false. 
  5. $slug_exists = false; 
  6.  
  7. // The post type slug being saved. Optional. Default empty string. 
  8. $taxonomy_slug = ''; 
  9.  
  10. // Array of CPTUI-registered post types. Optional. 
  11. $taxonomies = array(); 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = cptui_check_existing_taxonomy_slugs($slug_exists, $taxonomy_slug, $taxonomies); 
  15.  

Defined (1)

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

/inc/taxonomies.php  
  1. function cptui_check_existing_taxonomy_slugs( $slug_exists = false, $taxonomy_slug = '', $taxonomies = array() ) { 
  2.  
  3. // If true, then we'll already have a conflict, let's not re-process. 
  4. if ( true === $slug_exists ) { 
  5. return $slug_exists; 
  6.  
  7. // Check if CPTUI has already registered this slug. 
  8. if ( array_key_exists( strtolower( $taxonomy_slug ), $taxonomies ) ) { 
  9. return true; 
  10.  
  11. // Check if we're registering a reserved post type slug. 
  12. if ( in_array( $taxonomy_slug, cptui_reserved_taxonomies() ) ) { 
  13. return true; 
  14.  
  15. // Check if other plugins have registered this same slug. 
  16. $registered_taxonomies = get_post_types( array( '_builtin' => false, 'public' => false ) ); 
  17. if ( in_array( $taxonomy_slug, $registered_taxonomies ) ) { 
  18. return true; 
  19.  
  20. // If we're this far, it's false. 
  21. return $slug_exists;