Make WordPress Core

Changeset 56028


Ignore:
Timestamp:
06/26/2023 01:13:56 AM (19 months 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.

Location:
trunk
Files:
4 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}
  • trunk/src/wp-includes/class-wp-theme-json.php

    r55987 r56028  
    361361            'gradients'        => null,
    362362            'link'             => null,
     363            'heading'          => null,
     364            'button'           => null,
     365            'caption'          => null,
    363366            'palette'          => null,
    364367            'text'             => null,
     
    563566        array( 'border', 'width' ),
    564567        array( 'color', 'link' ),
     568        array( 'color', 'heading' ),
     569        array( 'color', 'button' ),
     570        array( 'color', 'caption' ),
    565571        array( 'dimensions', 'minHeight' ),
    566572        array( 'position', 'sticky' ),
  • trunk/src/wp-includes/theme.json

    r55975 r56028  
    1212        "color": {
    1313            "background": true,
     14            "button": true,
     15            "caption": true,
    1416            "custom": true,
    1517            "customDuotone": true,
     
    122124                }
    123125            ],
     126            "heading": true,
    124127            "link": false,
    125128            "palette": [
  • trunk/tests/phpunit/tests/theme/wpThemeJson.php

    r55986 r56028  
    270270            ),
    271271            'color'      => array(
    272                 'link' => true,
     272                'link'    => true,
     273                'heading' => true,
     274                'button'  => true,
     275                'caption' => true,
    273276            ),
    274277            'dimensions' => array(
     
    300303                    ),
    301304                    'color'      => array(
    302                         'link' => true,
     305                        'link'    => true,
     306                        'heading' => true,
     307                        'button'  => true,
     308                        'caption' => true,
    303309                    ),
    304310                    'dimensions' => array(
Note: See TracChangeset for help on using the changeset viewer.