unregister_taxonomy
函数
unregister_taxonomy ( $taxonomy )
- 参数
-
-
(string)
$taxonomy
Taxonomy name.- Required: 是
-
(string)
- 返回值
-
- (true|WP_Error) True on success, WP_Error on failure or if the taxonomy doesn’t exist.
- 定义位置
-
-
wp-includes/taxonomy.php
, line 567
-
wp-includes/taxonomy.php
- 引入
- 4.5.0
- 弃用
- –
取消注册一个分类法。
不能用于取消注册内置分类法。
function unregister_taxonomy( $taxonomy ) { if ( ! taxonomy_exists( $taxonomy ) ) { return new WP_Error( 'invalid_taxonomy', __( 'Invalid taxonomy.' ) ); } $taxonomy_object = get_taxonomy( $taxonomy ); // Do not allow unregistering internal taxonomies. if ( $taxonomy_object->_builtin ) { return new WP_Error( 'invalid_taxonomy', __( 'Unregistering a built-in taxonomy is not allowed.' ) ); } global $wp_taxonomies; $taxonomy_object->remove_rewrite_rules(); $taxonomy_object->remove_hooks(); // Remove the taxonomy. unset( $wp_taxonomies[ $taxonomy ] ); /** * Fires after a taxonomy is unregistered. * * @since 4.5.0 * * @param string $taxonomy Taxonomy name. */ do_action( 'unregistered_taxonomy', $taxonomy ); return true; }
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。