sync_category_tag_slugs()
sync_category_tag_slugs( WP_Term|array $term, string $t…
sync_category_tag_slugs( WP_Term|array $term, string $taxonomy )
启用全局术语时同步类别和后标记段。
Synchronizes category and post tag slugs when global terms are enabled.
目录锚点:#参数#源码
参数(Parameters)
| 参数 | 类型 | 说明 |
|---|---|---|
| $term | (WP_Term | array) | 术语。 |
| $taxonomy | (string) | $term的分类法。应该是“category”或“post_tag”,因为这是此函数处理的唯一分类法;其他任何分类都将原封不动地返回。 |
源码(Source)
/**
* Synchronize category and post tag slugs when global terms are enabled.
*
* @since 3.0.0
*
* @param object $term The term.
* @param 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.
* @return object|array Returns `$term`, after filtering the 'slug' field with {@see sanitize_title()}
* if $taxonomy is 'category' or 'post_tag'.
*/
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;
}| 更新版本 | 源码位置 | 使用 | 被使用 |
|---|---|---|---|
| 3.0.0 | wp-admin/includes/ms.php | 1 | 13 |
类别:WordPress 函数手册、
本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。

还没有任何评论,赶紧来占个楼吧!