sync_category_tag_slugs

Advertisement

Summery Summery

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

Syntax Syntax

sync_category_tag_slugs( WP_Term|array $term, string $taxonomy )

Parameters Parameters

$term

(WP_Term|array) (Required) The term.

$taxonomy

(string) (Required) 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.

Return Return

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

Source Source

File: wp-admin/includes/ms.php

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

Advertisement

Changelog Changelog

Changelog
Version Description
3.0.0 Introduced.

Advertisement

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.