wp/wp-includes/class-wp-block-type.php
changeset 16 a86126ab1dd4
parent 9 177826044cd9
child 18 be944660c56a
--- a/wp/wp-includes/class-wp-block-type.php	Tue Oct 22 16:11:46 2019 +0200
+++ b/wp/wp-includes/class-wp-block-type.php	Tue Dec 15 13:49:49 2020 +0100
@@ -15,6 +15,7 @@
  * @see register_block_type()
  */
 class WP_Block_Type {
+
 	/**
 	 * Block type key.
 	 *
@@ -24,52 +25,128 @@
 	public $name;
 
 	/**
+	 * @since 5.5.0
+	 * @var string
+	 */
+	public $title = '';
+
+	/**
+	 * @since 5.5.0
+	 * @var string|null
+	 */
+	public $category = null;
+
+	/**
+	 * @since 5.5.0
+	 * @var array|null
+	 */
+	public $parent = null;
+
+	/**
+	 * @since 5.5.0
+	 * @var string|null
+	 */
+	public $icon = null;
+
+	/**
+	 * @since 5.5.0
+	 * @var string
+	 */
+	public $description = '';
+
+	/**
+	 * @since 5.5.0
+	 * @var array
+	 */
+	public $keywords = array();
+
+	/**
+	 * @since 5.5.0
+	 * @var string|null
+	 */
+	public $textdomain = null;
+
+	/**
+	 * @since 5.5.0
+	 * @var array
+	 */
+	public $styles = array();
+
+	/**
+	 * @since 5.5.0
+	 * @var array|null
+	 */
+	public $supports = null;
+
+	/**
+	 * @since 5.5.0
+	 * @var array|null
+	 */
+	public $example = null;
+
+	/**
 	 * Block type render callback.
 	 *
 	 * @since 5.0.0
 	 * @var callable
 	 */
-	public $render_callback;
+	public $render_callback = null;
 
 	/**
 	 * Block type attributes property schemas.
 	 *
 	 * @since 5.0.0
+	 * @var array|null
+	 */
+	public $attributes = null;
+
+	/**
+	 * Context values inherited by blocks of this type.
+	 *
+	 * @since 5.5.0
 	 * @var array
 	 */
-	public $attributes;
+	public $uses_context = array();
+
+	/**
+	 * Context provided by blocks of this type.
+	 *
+	 * @since 5.5.0
+	 * @var array|null
+	 */
+	public $provides_context = null;
 
 	/**
 	 * Block type editor script handle.
 	 *
 	 * @since 5.0.0
-	 * @var string
+	 * @var string|null
 	 */
-	public $editor_script;
+	public $editor_script = null;
 
 	/**
 	 * Block type front end script handle.
 	 *
 	 * @since 5.0.0
-	 * @var string
+	 * @var string|null
 	 */
-	public $script;
+	public $script = null;
 
 	/**
 	 * Block type editor style handle.
 	 *
 	 * @since 5.0.0
-	 * @var string
+	 * @var string|null
 	 */
-	public $editor_style;
+	public $editor_style = null;
 
 	/**
 	 * Block type front end style handle.
 	 *
 	 * @since 5.0.0
-	 * @var string
+	 * @var string|null
 	 */
-	public $style;
+	public $style = null;
 
 	/**
 	 * Constructor.
@@ -127,8 +204,8 @@
 	 *
 	 * @since 5.0.0
 	 *
-	 * @param  array $attributes Original block attributes.
-	 * @return array             Prepared block attributes.
+	 * @param array $attributes Original block attributes.
+	 * @return array Prepared block attributes.
 	 */
 	public function prepare_attributes_for_render( $attributes ) {
 		// If there are no attribute definitions for the block type, skip
@@ -185,6 +262,16 @@
 
 		$args['name'] = $this->name;
 
+		/**
+		 * 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;
 		}
@@ -199,18 +286,7 @@
 	 */
 	public function get_attributes() {
 		return is_array( $this->attributes ) ?
-			array_merge(
-				$this->attributes,
-				array(
-					'layout' => array(
-						'type' => 'string',
-					),
-				)
-			) :
-			array(
-				'layout' => array(
-					'type' => 'string',
-				),
-			);
+			$this->attributes :
+			array();
 	}
 }