Changeset 58951
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 ) ) { -
trunk/src/wp-includes/deprecated.php
r58703 r58951 6388 6388 } 6389 6389 } 6390 6391 /** 6392 * Generate block style variation instance name. 6393 * 6394 * @since 6.6.0 6395 * @deprecated 6.7.0 Use `wp_unique_id( $variation . '--' )` instead. 6396 * 6397 * @access private 6398 * 6399 * @param array $block Block object. 6400 * @param string $variation Slug for the block style variation. 6401 * 6402 * @return string The unique variation name. 6403 */ 6404 function wp_create_block_style_variation_instance_name( $block, $variation ) { 6405 _deprecated_function( __FUNCTION__, '6.7.0', 'wp_unique_id' ); 6406 return $variation . '--' . md5( serialize( $block ) ); 6407 } -
trunk/tests/phpunit/tests/block-supports/wpCreateBlockStyleVariationInstanceName.php
r58264 r58951 14 14 * 15 15 * @covers ::wp_create_block_style_variation_instance_name 16 * 17 * @expectedDeprecated wp_create_block_style_variation_instance_name 16 18 */ 17 19 public function test_block_style_variation_instance_name_generation() {
Note: See TracChangeset
for help on using the changeset viewer.