mirror of
https://github.com/WordPress/WordPress.git
synced 2024-06-26 06:45:07 +02:00
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. Built from https://develop.svn.wordpress.org/trunk@56028 git-svn-id: http://core.svn.wordpress.org/trunk@55540 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
c4a22d5a34
commit
2fbd7aeb8f
|
@ -46,13 +46,18 @@ function wp_render_elements_support( $block_content, $block ) {
|
||||||
$link_color = _wp_array_get( $block['attrs'], array( 'style', 'elements', 'link', 'color', 'text' ), null );
|
$link_color = _wp_array_get( $block['attrs'], array( 'style', 'elements', 'link', 'color', 'text' ), null );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$hover_link_color = null;
|
||||||
|
if ( ! empty( $block['attrs'] ) ) {
|
||||||
|
$hover_link_color = _wp_array_get( $block['attrs'], array( 'style', 'elements', 'link', ':hover', 'color', 'text' ), null );
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* For now we only care about link color.
|
* For now we only care about link colors.
|
||||||
* This code in the future when we have a public API
|
* This code in the future when we have a public API
|
||||||
* should take advantage of WP_Theme_JSON::compute_style_properties
|
* should take advantage of WP_Theme_JSON::compute_style_properties
|
||||||
* and work for any element and style.
|
* and work for any element and style.
|
||||||
*/
|
*/
|
||||||
if ( null === $link_color ) {
|
if ( null === $link_color && null === $hover_link_color ) {
|
||||||
return $block_content;
|
return $block_content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,6 +109,16 @@ function wp_render_elements_support_styles( $pre_render, $block ) {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if ( isset( $link_block_styles[':hover'] ) ) {
|
||||||
|
wp_style_engine_get_styles(
|
||||||
|
$link_block_styles[':hover'],
|
||||||
|
array(
|
||||||
|
'selector' => ".$class_name a:hover",
|
||||||
|
'context' => 'block-supports',
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -360,6 +360,9 @@ class WP_Theme_JSON {
|
||||||
'duotone' => null,
|
'duotone' => null,
|
||||||
'gradients' => null,
|
'gradients' => null,
|
||||||
'link' => null,
|
'link' => null,
|
||||||
|
'heading' => null,
|
||||||
|
'button' => null,
|
||||||
|
'caption' => null,
|
||||||
'palette' => null,
|
'palette' => null,
|
||||||
'text' => null,
|
'text' => null,
|
||||||
),
|
),
|
||||||
|
@ -562,6 +565,9 @@ class WP_Theme_JSON {
|
||||||
array( 'border', 'style' ),
|
array( 'border', 'style' ),
|
||||||
array( 'border', 'width' ),
|
array( 'border', 'width' ),
|
||||||
array( 'color', 'link' ),
|
array( 'color', 'link' ),
|
||||||
|
array( 'color', 'heading' ),
|
||||||
|
array( 'color', 'button' ),
|
||||||
|
array( 'color', 'caption' ),
|
||||||
array( 'dimensions', 'minHeight' ),
|
array( 'dimensions', 'minHeight' ),
|
||||||
array( 'position', 'sticky' ),
|
array( 'position', 'sticky' ),
|
||||||
array( 'spacing', 'blockGap' ),
|
array( 'spacing', 'blockGap' ),
|
||||||
|
|
|
@ -11,6 +11,8 @@
|
||||||
},
|
},
|
||||||
"color": {
|
"color": {
|
||||||
"background": true,
|
"background": true,
|
||||||
|
"button": true,
|
||||||
|
"caption": true,
|
||||||
"custom": true,
|
"custom": true,
|
||||||
"customDuotone": true,
|
"customDuotone": true,
|
||||||
"customGradient": true,
|
"customGradient": true,
|
||||||
|
@ -121,6 +123,7 @@
|
||||||
"slug": "midnight"
|
"slug": "midnight"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"heading": true,
|
||||||
"link": false,
|
"link": false,
|
||||||
"palette": [
|
"palette": [
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '6.3-alpha-56027';
|
$wp_version = '6.3-alpha-56028';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user