register_block_type

函数


register_block_type ( $block_type, $args = array() )
参数
  • (string|WP_Block_Type)
    $block_type
    Block type name including namespace, or alternatively a path to the JSON file with metadata definition for the block, or a path to the folder where the `block.json` file is located, or a complete WP_Block_Type instance. In case a WP_Block_Type is provided, the $args parameter will be ignored.
    Required:
  • (array)
    $args
    Optional. Array of block type arguments. Accepts any public property of `WP_Block_Type`. See WP_Block_Type::__construct() for information on accepted arguments. Default empty array.
    Required:
    Default: array()
返回值
  • (WP_Block_Type|false) The registered block type on success, or false on failure.
定义位置
  • wp-includes/blocks.php
    , line 531
引入
5.0.0
弃用

Registers a block type. The recommended way is to register a block type using
the metadata stored in the `block.json` file.

function register_block_type( $block_type, $args = array() ) {
	if ( is_string( $block_type ) && file_exists( $block_type ) ) {
		return register_block_type_from_metadata( $block_type, $args );
	}

	return WP_Block_Type_Registry::get_instance()->register( $block_type, $args );
}
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。