diff --git a/lib/block-supports/elements.php b/lib/block-supports/elements.php index 9230fd48b1c10..8307b92803a9c 100644 --- a/lib/block-supports/elements.php +++ b/lib/block-supports/elements.php @@ -15,6 +15,8 @@ function gutenberg_get_elements_class_name( $block ) { return 'wp-elements-' . md5( serialize( $block ) ); } + + /** * Update the block content with elements class names. * @@ -29,8 +31,9 @@ function gutenberg_render_elements_support( $block_content, $block ) { $block_type = WP_Block_Type_Registry::get_instance()->get_registered( $block['blockName'] ); $skip_link_color_serialization = gutenberg_should_skip_block_supports_serialization( $block_type, 'color', 'link' ); + $skip_link_hover_color_serialization = gutenberg_should_skip_block_supports_serialization( $block_type, 'color', 'link:hover' ); - if ( $skip_link_color_serialization ) { + if ( $skip_link_color_serialization && $skip_link_hover_color_serialization ) { return $block_content; } @@ -38,14 +41,19 @@ function gutenberg_render_elements_support( $block_content, $block ) { if ( ! empty( $block['attrs'] ) ) { $link_color = _wp_array_get( $block['attrs'], array( 'style', 'elements', 'link', 'color', 'text' ), null ); } + + $link_hover_color = null; + if ( ! empty( $block['attrs'] ) ) { + $link_hover_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 color and link hover color. * This code in the future when we have a public API * should take advantage of WP_Theme_JSON_Gutenberg::compute_style_properties * and work for any element and style. */ - if ( null === $link_color ) { + if ( null === $link_color && null === $link_hover_color ) { return $block_content; } @@ -75,7 +83,11 @@ function gutenberg_render_elements_support( $block_content, $block ) { } /** - * Render the elements stylesheet. + * Renders the elements stylesheet for a given block type. + * + * Each block may have styles for it's child HTML elements (currently only a limited subset are supported). + * Render an inline