wp/wp-includes/class-wp-block-supports.php
changeset 21 48c4eec2b7e6
parent 19 3d72ae0968f4
child 22 8c2e4d02f4ef
--- a/wp/wp-includes/class-wp-block-supports.php	Thu Sep 29 08:06:27 2022 +0200
+++ b/wp/wp-includes/class-wp-block-supports.php	Fri Sep 05 18:40:08 2025 +0200
@@ -14,6 +14,7 @@
  *
  * @access private
  */
+#[AllowDynamicProperties]
 class WP_Block_Supports {
 
 	/**
@@ -72,6 +73,8 @@
 	 *
 	 * @since 5.6.0
 	 *
+	 * @link https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/
+	 *
 	 * @param string $block_support_name   Block support name.
 	 * @param array  $block_support_config Array containing the properties of the block support.
 	 */
@@ -88,11 +91,10 @@
 	 *
 	 * @since 5.6.0
 	 *
-	 * @return string[] Array of HTML attributes.
+	 * @return string[] Array of HTML attribute values keyed by their name.
 	 */
 	public function apply_block_supports() {
-		$block_attributes = self::$block_to_render['attrs'];
-		$block_type       = WP_Block_Type_Registry::get_instance()->get_registered(
+		$block_type = WP_Block_Type_Registry::get_instance()->get_registered(
 			self::$block_to_render['blockName']
 		);
 
@@ -101,6 +103,10 @@
 			return array();
 		}
 
+		$block_attributes = array_key_exists( 'attrs', self::$block_to_render ) && is_array( self::$block_to_render['attrs'] )
+			? self::$block_to_render['attrs']
+			: array();
+
 		$output = array();
 		foreach ( $this->block_supports as $block_support_config ) {
 			if ( ! isset( $block_support_config['apply'] ) ) {
@@ -136,7 +142,7 @@
 		$block_registry         = WP_Block_Type_Registry::get_instance();
 		$registered_block_types = $block_registry->get_all_registered();
 		foreach ( $registered_block_types as $block_type ) {
-			if ( ! property_exists( $block_type, 'supports' ) ) {
+			if ( ! ( $block_type instanceof WP_Block_Type ) ) {
 				continue;
 			}
 			if ( ! $block_type->attributes ) {
@@ -175,7 +181,7 @@
 
 	// This is hardcoded on purpose.
 	// We only support a fixed list of attributes.
-	$attributes_to_merge = array( 'style', 'class' );
+	$attributes_to_merge = array( 'style', 'class', 'id' );
 	$attributes          = array();
 	foreach ( $attributes_to_merge as $attribute_name ) {
 		if ( empty( $new_attributes[ $attribute_name ] ) && empty( $extra_attributes[ $attribute_name ] ) ) {