GC_Block_Type_Registry::unregister()

最后更新于:2021-11-26 11:25:08

GC_Block_Type_Registry::unregister( string|GC_Block_Type$name)

Unregisters a block type.

参数

$name

(string|GC_Block_Type) (Required) Block type name including namespace, or alternatively a complete GC_Block_Type instance.

响应

(GC_Block_Type|false) The unregistered block type on success, or false on failure.

源文件

文件: gc-includes/class-gc-block-type-registry.php

	public function unregister( $name ) {
		if ( $name instanceof GC_Block_Type ) {
			$name = $name->name;
		}

		if ( ! $this->is_registered( $name ) ) {
			_doing_it_wrong(
				__METHOD__,
				/* translators: %s: Block name. */
				sprintf( __( 'Block type "%s" is not registered.' ), $name ),
				'5.0.0'
			);
			return false;
		}

		$unregistered_block_type = $this->registered_block_types[ $name ];
		unset( $this->registered_block_types[ $name ] );

		return $unregistered_block_type;
	}