- Timestamp:
- 07/09/2024 10:22:10 AM (5 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/block-supports/block-style-variations.php
r58466 r58691 41 41 } 42 42 43 /** 44 * Recursively resolves any `ref` values within a block style variation's data. 45 * 46 * @since 6.6.0 47 * @access private 48 * 49 * @param array $variation_data Reference to the variation data being processed. 50 * @param array $theme_json Theme.json data to retrieve referenced values from. 51 */ 52 function wp_resolve_block_style_variation_ref_values( &$variation_data, $theme_json ) { 53 foreach ( $variation_data as $key => &$value ) { 54 // Only need to potentially process arrays. 55 if ( is_array( $value ) ) { 56 // If ref value is set, attempt to find its matching value and update it. 57 if ( array_key_exists( 'ref', $value ) ) { 58 // Clean up any invalid ref value. 59 if ( empty( $value['ref'] ) || ! is_string( $value['ref'] ) ) { 60 unset( $variation_data[ $key ] ); 61 } 62 63 $value_path = explode( '.', $value['ref'] ?? '' ); 64 $ref_value = _wp_array_get( $theme_json, $value_path ); 65 66 // Only update the current value if the referenced path matched a value. 67 if ( null === $ref_value ) { 68 unset( $variation_data[ $key ] ); 69 } else { 70 $value = $ref_value; 71 } 72 } else { 73 // Recursively look for ref instances. 74 wp_resolve_block_style_variation_ref_values( $value, $theme_json ); 75 } 76 } 77 } 78 } 43 79 /** 44 80 * Render the block style variation's styles. … … 82 118 return $parsed_block; 83 119 } 120 121 /* 122 * Recursively resolve any ref values with the appropriate value within the 123 * theme_json data. 124 */ 125 wp_resolve_block_style_variation_ref_values( $variation_data, $theme_json ); 84 126 85 127 $variation_instance = wp_create_block_style_variation_instance_name( $parsed_block, $variation );
Note: See TracChangeset
for help on using the changeset viewer.