WP_Block_Type::__construct()publicWP 5.0.0


Will populate object properties from the provided arguments.

Метод класса: WP_Block_Type{}

Хуков нет.


null. Ничего (null).


$WP_Block_Type = new WP_Block_Type();
$WP_Block_Type->__construct( $block_type, $args );
$block_type(строка) (обязательный)
Block type name including namespace.

Array or string of arguments for registering a block type. Any arguments may be defined, however the ones described below are supported by default.

По умолчанию: empty array

  • api_version(строка)
    Block API version.

  • title(строка)
    Human-readable block type label.

  • category(строка|null)
    Block type category classification, used in search interfaces to arrange block types by category.

  • parent(string[]|null)
    Setting parent lets a block require that it is only available when nested within the specified blocks.

  • ancestor(string[]|null)
    Setting ancestor makes a block available only inside the specified block types at any position of the ancestor's block subtree.

  • icon(строка|null)
    Block type icon.

  • description(строка)
    A detailed block type description.

  • keywords(string[])
    Additional keywords to produce block type as result in search interfaces.

  • textdomain(строка|null)
    The translation textdomain.

  • styles(array[])
    Alternative block styles.

  • variations(array[])
    Block variations.

  • selectors(массив)
    Custom CSS selectors for theme.json style generation.

  • supports(массив|null)
    Supported features.

  • example(массив|null)
    Structured data for the block preview.

  • render_callback(callable|null)
    Block type render callback.

  • attributes(массив|null)
    Block type attributes property schemas.

  • uses_context(string[])
    Context values inherited by blocks of this type.

  • provides_context(string[]|null)
    Context provided by blocks of this type.

  • block_hooks(array[])
    Block hooks.

  • editor_script_handles(string[])
    Block type editor only script handles.

  • script_handles(string[])
    Block type front end and editor script handles.

  • view_script_handles(string[])
    Block type front end only script handles.

  • editor_style_handles(string[])
    Block type editor only style handles.

  • style_handles(string[])
    Block type front end and editor style handles.


Список изменений

С версии 5.0.0 Введена.
С версии 5.5.0 Added the title, category, parent, icon, description, keywords, textdomain, styles, supports, example, uses_context, and provides_context properties.
С версии 5.6.0 Added the api_version property.
С версии 5.8.0 Added the variations property.
С версии 5.9.0 Added the view_script property.
С версии 6.0.0 Added the ancestor property.
С версии 6.1.0 Added the editor_script_handles, script_handles, view_script_handles,editor_style_handles, andstyle_handlesproperties. Deprecated theeditor_script,script,view_script,editor_style, andstyle` properties.
С версии 6.3.0 Added the selectors property.
С версии 6.4.0 Added the block_hooks property.

Код WP_Block_Type::__construct() WP 6.4.3

public function __construct( $block_type, $args = array() ) {
	$this->name = $block_type;

	$this->set_props( $args );