Make WordPress Core


Ignore:
Timestamp:
06/26/2023 01:13:56 AM (2 years ago)
Author:
isabel_brison
Message:

Editor: add support for block-level link hover colors.

Adds the ability to set link hover colors for individual blocks from the block inspector color panel.

Props @youknowriad, @peterwilsoncc, @kebbet.
Fixes #58575.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/block-supports/elements.php

    r55235 r56028  
    4747    }
    4848
     49    $hover_link_color = null;
     50    if ( ! empty( $block['attrs'] ) ) {
     51        $hover_link_color = _wp_array_get( $block['attrs'], array( 'style', 'elements', 'link', ':hover', 'color', 'text' ), null );
     52    }
     53
    4954    /*
    50      * For now we only care about link color.
     55     * For now we only care about link colors.
    5156     * This code in the future when we have a public API
    5257     * should take advantage of WP_Theme_JSON::compute_style_properties
    5358     * and work for any element and style.
    5459     */
    55     if ( null === $link_color ) {
     60    if ( null === $link_color && null === $hover_link_color ) {
    5661        return $block_content;
    5762    }
     
    105110    );
    106111
     112    if ( isset( $link_block_styles[':hover'] ) ) {
     113        wp_style_engine_get_styles(
     114            $link_block_styles[':hover'],
     115            array(
     116                'selector' => ".$class_name a:hover",
     117                'context'  => 'block-supports',
     118            )
     119        );
     120    }
     121
    107122    return null;
    108123}
Note: See TracChangeset for help on using the changeset viewer.