Making WordPress.org

Changeset 12025


Ignore:
Timestamp:
08/19/2022 07:35:59 PM (20 months ago)
Author:
ryelle
Message:

Pattern Directory: Sync with git WordPress/pattern-directory@4d558c36f05355aa63e6e72a8af604cf6887f9e8

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns/includes/inline-styles.php

    r11766 r12025  
    179179    }
    180180
     181    $colors          = $block['attrs']['style']['color']['duotone'];
     182    $filter_key      = is_array( $colors ) ? implode( '-', $colors ) : $colors;
    181183    $filter_preset   = array(
    182         'slug'   => wp_unique_id( sanitize_key( implode( '-', $block['attrs']['style']['color']['duotone'] ) . '-' ) ),
    183         'colors' => $block['attrs']['style']['color']['duotone'],
     184        'slug'   => wp_unique_id( sanitize_key( $filter_key . '-' ) ),
     185        'colors' => $colors,
    184186    );
    185187    $filter_property = wp_get_duotone_filter_property( $filter_preset );
    186188    $filter_id       = wp_get_duotone_filter_id( $filter_preset );
    187     $filter_svg      = wp_get_duotone_filter_svg( $filter_preset );
    188189
    189190    $scope     = '.' . $filter_id;
     
    201202        : $selector . '{filter:' . $filter_property . ' !important;}';
    202203
    203     // Like the layout hook, this assumes the hook only applies to blocks with a single wrapper.
     204    wp_register_style( $filter_id, false, array(), true, true );
     205    wp_add_inline_style( $filter_id, $filter_style );
     206    wp_enqueue_style( $filter_id );
     207
    204208    $content = preg_replace(
    205209        '/' . preg_quote( 'class="', '/' ) . '/',
     
    209213    );
    210214
     215    $filter_svg = '';
     216    if ( 'unset' !== $colors ) {
     217        $filter_svg = wp_get_duotone_filter_svg( $filter_preset );
     218    }
     219
    211220    // Output the style first, to fix the Safari bug.
    212     // See https://github.com/WordPress/gutenberg/blob/a9b29acd0a058644ef28523c00fbe633272d6c0c/lib/block-supports/duotone.php#L467.
     221    // See https://github.com/WordPress/gutenberg/blob/330f1f4a19603529130dbd831be824c07d50d8e8/lib/block-supports/duotone.php#L431.
    213222    return '<style>' . $filter_style . '</style>' . $filter_svg . $content;
    214223}
Note: See TracChangeset for help on using the changeset viewer.