- Timestamp:
- 08/29/2024 05:39:22 AM (15 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/block-supports/block-style-variations.php
r58850 r58951 7 7 * @since 6.6.0 8 8 */ 9 10 /**11 * Generate block style variation instance name.12 *13 * @since 6.6.014 * @access private15 *16 * @param array $block Block object.17 * @param string $variation Slug for the block style variation.18 *19 * @return string The unique variation name.20 */21 function wp_create_block_style_variation_instance_name( $block, $variation ) {22 return $variation . '--' . md5( serialize( $block ) );23 }24 9 25 10 /** … … 125 110 wp_resolve_block_style_variation_ref_values( $variation_data, $theme_json ); 126 111 127 $variation_instance = wp_ create_block_style_variation_instance_name( $parsed_block, $variation);112 $variation_instance = wp_unique_id( $variation . '--' ); 128 113 $class_name = "is-style-$variation_instance"; 129 114 $updated_class_name = $parsed_block['attrs']['className'] . " $class_name"; … … 231 216 /* 232 217 * Matches a class prefixed by `is-style`, followed by the 233 * variation slug, then `--`, and finally a hash. 234 * 235 * See `wp_create_block_style_variation_instance_name` for class generation. 236 */ 237 preg_match( '/\bis-style-(\S+?--\w+)\b/', $block['attrs']['className'], $matches ); 218 * variation slug, then `--`, and finally an instance number. 219 */ 220 preg_match( '/\bis-style-(\S+?--\d+)\b/', $block['attrs']['className'], $matches ); 238 221 239 222 if ( empty( $matches ) ) {
Note: See TracChangeset
for help on using the changeset viewer.