--- a/wp/wp-includes/class-wp-block-type.php Tue Dec 15 15:52:01 2020 +0100
+++ b/wp/wp-includes/class-wp-block-type.php Wed Sep 21 18:19:35 2022 +0200
@@ -17,6 +17,14 @@
class WP_Block_Type {
/**
+ * Block API version.
+ *
+ * @since 5.6.0
+ * @var int
+ */
+ public $api_version = 1;
+
+ /**
* Block type key.
*
* @since 5.0.0
@@ -25,60 +33,91 @@
public $name;
/**
+ * Human-readable block type label.
+ *
* @since 5.5.0
* @var string
*/
public $title = '';
/**
+ * Block type category classification, used in search interfaces
+ * to arrange block types by category.
+ *
* @since 5.5.0
* @var string|null
*/
public $category = null;
/**
+ * Setting parent lets a block require that it is only available
+ * when nested within the specified blocks.
+ *
* @since 5.5.0
* @var array|null
*/
public $parent = null;
/**
+ * Block type icon.
+ *
* @since 5.5.0
* @var string|null
*/
public $icon = null;
/**
+ * A detailed block type description.
+ *
* @since 5.5.0
* @var string
*/
public $description = '';
/**
+ * Additional keywords to produce block type as result
+ * in search interfaces.
+ *
* @since 5.5.0
* @var array
*/
public $keywords = array();
/**
+ * The translation textdomain.
+ *
* @since 5.5.0
* @var string|null
*/
public $textdomain = null;
/**
+ * Alternative block styles.
+ *
* @since 5.5.0
* @var array
*/
public $styles = array();
/**
+ * Block variations.
+ *
+ * @since 5.8.0
+ * @var array
+ */
+ public $variations = array();
+
+ /**
+ * Supported features.
+ *
* @since 5.5.0
* @var array|null
*/
public $supports = null;
/**
+ * Structured data for the block preview.
+ *
* @since 5.5.0
* @var array|null
*/
@@ -154,12 +193,43 @@
* Will populate object properties from the provided arguments.
*
* @since 5.0.0
+ * @since 5.5.0 Added the `title`, `category`, `parent`, `icon`, `description`,
+ * `keywords`, `textdomain`, `styles`, `supports`, `example`,
+ * `uses_context`, and `provides_context` properties.
+ * @since 5.6.0 Added the `api_version` property.
+ * @since 5.8.0 Added the `variations` property.
*
* @see register_block_type()
*
* @param string $block_type Block type name including namespace.
- * @param array|string $args Optional. Array or string of arguments for registering a block type.
- * Default empty array.
+ * @param array|string $args {
+ * Optional. Array or string of arguments for registering a block type. Any arguments may be defined,
+ * however the ones described below are supported by default. Default empty array.
+ *
+ * @type string $api_version Block API version.
+ * @type string $title Human-readable block type label.
+ * @type string|null $category Block type category classification, used in
+ * search interfaces to arrange block types by category.
+ * @type array|null $parent Setting parent lets a block require that it is only
+ * available when nested within the specified blocks.
+ * @type string|null $icon Block type icon.
+ * @type string $description A detailed block type description.
+ * @type array $keywords Additional keywords to produce block type as
+ * result in search interfaces.
+ * @type string|null $textdomain The translation textdomain.
+ * @type array $styles Alternative block styles.
+ * @type array $variations Block variations.
+ * @type array|null $supports Supported features.
+ * @type array|null $example Structured data for the block preview.
+ * @type callable|null $render_callback Block type render callback.
+ * @type array|null $attributes Block type attributes property schemas.
+ * @type array $uses_context Context values inherited by blocks of this type.
+ * @type array|null $provides_context Context provided by blocks of this type.
+ * @type string|null $editor_script Block type editor script handle.
+ * @type string|null $script Block type front end script handle.
+ * @type string|null $editor_style Block type editor style handle.
+ * @type string|null $style Block type front end style handle.
+ * }
*/
public function __construct( $block_type, $args = array() ) {
$this->name = $block_type;
@@ -192,7 +262,7 @@
*
* @since 5.0.0
*
- * @return boolean Whether block type is dynamic.
+ * @return bool Whether block type is dynamic.
*/
public function is_dynamic() {
return is_callable( $this->render_callback );
@@ -209,7 +279,7 @@
*/
public function prepare_attributes_for_render( $attributes ) {
// If there are no attribute definitions for the block type, skip
- // processing and return vebatim.
+ // processing and return verbatim.
if ( ! isset( $this->attributes ) ) {
return $attributes;
}
@@ -227,7 +297,7 @@
// its default, if one exists. This occurs by virtue of the missing
// attributes loop immediately following. If there is not a default
// assigned, the attribute value should remain unset.
- $is_valid = rest_validate_value_from_schema( $value, $schema );
+ $is_valid = rest_validate_value_from_schema( $value, $schema, $attribute_name );
if ( is_wp_error( $is_valid ) ) {
unset( $attributes[ $attribute_name ] );
}
@@ -251,6 +321,7 @@
* @since 5.0.0
*
* @param array|string $args Array or string of arguments for registering a block type.
+ * See WP_Block_Type::__construct() for information on accepted arguments.
*/
public function set_props( $args ) {
$args = wp_parse_args(