Make WordPress Core


Ignore:
Timestamp:
08/29/2024 05:39:22 AM (15 months ago)
Author:
ramonopoly
Message:

Block Styles: Ensure unique classname generation for variations

This commit simplifies block style variation class name generation to ensure unique class names by replacing the hashing of block attributes in the block style variation class names with a call to wp_unique_id.

Doing so avoids potential for non-unique class names and conflicting styles when exact copies of a block are inserted via a repeated pattern.

Props aaronrobertshaw, martinkrcho, mukesh27, peterwilsoncc, ramonopoly.

Fixes #61877.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/deprecated.php

    r58703 r58951  
    63886388    }
    63896389}
     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 */
     6404function 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}
Note: See TracChangeset for help on using the changeset viewer.