Constructor.
Will populate object properties from the provided arguments.
$block_typestringrequired
$argsarray|stringoptional
api_version stringtitle stringcategory string|nullparent string[]|nullancestor string[]|nullallowed_blocks string[]|nullicon string|nulldescription stringkeywords string[]textdomain string|nullstyles array[]variations array[]selectors arraysupports array|nullexample array|nullrender_callback callable|nullvariation_callback callable|nullattributes array|nulluses_context string[]provides_context string[]|nullblock_hooks string[]editor_script_handles string[]script_handles string[]view_script_handles string[]editor_style_handles string[]style_handles string[]view_style_handles string[]Default:array()
public function __construct( $block_type, $args = array() ) {
$this->name = $block_type;
$this->set_props( $args );
}
| Version | Description |
|---|---|
| 6.5.0 | Added the allowed_blocks, variation_callback, and view_style_handles properties. |
| 6.4.0 | Added the block_hooks property. |
| 6.3.0 | Added the selectors property. |
| 6.1.0 | Added the editor_script_handles, script_handles, view_script_handles, editor_style_handles, and style_handles properties.Deprecated the editor_script, script, view_script, editor_style, and style properties. |
| 6.0.0 | Added the ancestor property. |
| 5.9.0 | Added the view_script property. |
| 5.8.0 | Added the variations property. |
| 5.6.0 | Added the api_version property. |
| 5.5.0 | Added the title, category, parent, icon, description, keywords, textdomain, styles, supports, example, uses_context, and provides_context properties. |
| 5.0.0 | Introduced. |
© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_block_type/__construct