函数文档

unregister_block_pattern_category()

💡 云策文档标注

概述

unregister_block_pattern_category() 函数用于注销一个区块模式分类,通过调用 WP_Block_Pattern_Categories_Registry 实例的 unregister 方法实现。

关键要点

  • 参数 $category_name 为字符串类型,必需,指定要注销的区块模式分类名称,需包含命名空间。
  • 返回值为布尔类型,成功注销时返回 true,否则返回 false。
  • 该函数在 WordPress 5.5.0 版本中引入。

代码示例

function unregister_block_pattern_category( $category_name ) {
    return WP_Block_Pattern_Categories_Registry::get_instance()->unregister( $category_name );
}

注意事项

相关函数 WP_Block_Pattern_Categories_Registry::get_instance() 用于获取类的主实例,位于 wp-includes/class-wp-block-pattern-categories-registry.php 文件中。


📄 原文内容

Unregisters a pattern category.

Parameters

$category_namestringrequired
Pattern category name including namespace.

Return

bool True if the pattern category was unregistered with success and false otherwise.

Source

function unregister_block_pattern_category( $category_name ) {
	return WP_Block_Pattern_Categories_Registry::get_instance()->unregister( $category_name );
}

Changelog

Version Description
5.5.0 Introduced.