sync_category_tag_slugs

Synchronize category and post tag slugs when global terms are enabled.

Description

(object|array) sync_category_tag_slugs( (object) $term, (string) $taxonomy ); 

Returns (object|array)

Returns `$term`, after filtering the 'slug' field with sanitize_title() if $taxonomy is 'category' or 'post_tag'.

Parameters (2)

0. $term (object)
The term.
1. $taxonomy (string)
The taxonomy for $term.. Should be category or post_tag,, as these are the only taxonomies which are processed by this function; anything else will be returned untouched.

Usage

  1. if ( !function_exists( 'sync_category_tag_slugs' ) ) { 
  2. require_once ABSPATH . '/wp-admin/includes/ms.php'; 
  3.  
  4. // The term. 
  5. $term = null; 
  6. $taxonomy = ''; 
  7.  
  8. // NOTICE! Understand what this does before running. 
  9. $result = sync_category_tag_slugs($term, $taxonomy); 
  10.  

Defined (1)

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

/wp-admin/includes/ms.php  
  1. function sync_category_tag_slugs( $term, $taxonomy ) { 
  2. if ( global_terms_enabled() && ( $taxonomy == 'category' || $taxonomy == 'post_tag' ) ) { 
  3. if ( is_object( $term ) ) { 
  4. $term->slug = sanitize_title( $term->name ); 
  5. } else { 
  6. $term['slug'] = sanitize_title( $term['name'] ); 
  7. return $term;