WP_Block_Type::set_props( array|string $args )
Sets block type properties.
Parameters
-
$args
array|string Required -
Array or string of arguments for registering a block type.
See WP_Block_Type::__construct() for information on accepted arguments.More Arguments from WP_Block_Type::__construct( ... $args )
Array or string of arguments for registering a block type. Any arguments may be defined, however the ones described below are supported by default.
api_version
stringBlock API version.title
stringHuman-readable block type label.category
string|nullBlock type category classification, used in search interfaces to arrange block types by category.parent
string[]|nullSetting parent lets a block require that it is only available when nested within the specified blocks.ancestor
string[]|nullSetting ancestor makes a block available only inside the specified block types at any position of the ancestor's block subtree.icon
string|nullBlock type icon.description
stringA detailed block type description.keywords
string[]Additional keywords to produce block type as result in search interfaces.textdomain
string|nullThe translation textdomain.styles
array[]Alternative block styles.variations
array[]Block variations.supports
array|nullSupported features.example
array|nullStructured data for the block preview.render_callback
callable|nullBlock type render callback.attributes
array|nullBlock type attributes property schemas.uses_context
string[]Context values inherited by blocks of this type.provides_context
string[]|nullContext provided by blocks of this type.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.
Source
File: wp-includes/class-wp-block-type.php
.
View all references
public function set_props( $args ) {
$args = wp_parse_args(
$args,
array(
'render_callback' => null,
)
);
$args['name'] = $this->name;
// Setup attributes if needed.
if ( ! isset( $args['attributes'] ) || ! is_array( $args['attributes'] ) ) {
$args['attributes'] = array();
}
// Register core attributes.
foreach ( static::GLOBAL_ATTRIBUTES as $attr_key => $attr_schema ) {
if ( ! array_key_exists( $attr_key, $args['attributes'] ) ) {
$args['attributes'][ $attr_key ] = $attr_schema;
}
}
/**
* Filters the arguments for registering a block type.
*
* @since 5.5.0
*
* @param array $args Array of arguments for registering a block type.
* @param string $block_type Block type name including namespace.
*/
$args = apply_filters( 'register_block_type_args', $args, $this->name );
foreach ( $args as $property_name => $property_value ) {
$this->$property_name = $property_value;
}
}
Hooks
-
apply_filters( 'register_block_type_args',
array $args ,string $block_type ) -
Filters the arguments for registering a block type.
Changelog
Version | Description |
---|---|
5.0.0 | Introduced. |