_wp_multiple_block_styles

The timeline below displays how wordpress function _wp_multiple_block_styles has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.1

/**
 * Allows multiple block styles.
 *
 * @since 5.9.0
 * @deprecated 6.1.0
 *
 * @param array $metadata Metadata for registering a block type.
 * @return array Metadata for registering a block type.
 */
function _wp_multiple_block_styles($metadata)
{
    _deprecated_function(__FUNCTION__, '6.1.0');
    return $metadata;
}

WordPress Version: 5.9

/**
 * Allow multiple block styles.
 *
 * @since 5.9.0
 *
 * @param array $metadata Metadata for registering a block type.
 * @return array Metadata for registering a block type.
 */
function _wp_multiple_block_styles($metadata)
{
    foreach (array('style', 'editorStyle') as $key) {
        if (!empty($metadata[$key]) && is_array($metadata[$key])) {
            $default_style = array_shift($metadata[$key]);
            foreach ($metadata[$key] as $handle) {
                $args = array('handle' => $handle);
                if (0 === strpos($handle, 'file:') && isset($metadata['file'])) {
                    $style_path = remove_block_asset_path_prefix($handle);
                    $args = array('handle' => sanitize_key("{$metadata['name']}-{$style_path}"), 'src' => plugins_url($style_path, $metadata['file']));
                }
                wp_enqueue_block_style($metadata['name'], $args);
            }
            // Only return the 1st item in the array.
            $metadata[$key] = $default_style;
        }
    }
    return $metadata;
}