Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



sync_category_tag_slugs ›

Seit3.0.0
Veraltetn/v
sync_category_tag_slugs ( $term, $taxonomy )
Parameter: (2)
  • (object) $term The term.
    Erforderlich: Ja
  • (string) $taxonomy 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.
    Erforderlich: Ja
Gibt zurück:
  • (object|array) Returns `$term`, after filtering the 'slug' field with sanitize_title() if $taxonomy is 'category' or 'post_tag'.
Definiert in:
Codex:

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



Quellcode

function sync_category_tag_slugs( $term, $taxonomy ) {
	if ( global_terms_enabled() && ( $taxonomy == 'category' || $taxonomy == 'post_tag' ) ) {
		if ( is_object( $term ) ) {
			$term->slug = sanitize_title( $term->name );
		} else {
			$term['slug'] = sanitize_title( $term['name'] );
		}
	}
	return $term;
}