Skip to content

Commit

Permalink
Make link color control opt-in (#23049)
Browse files Browse the repository at this point in the history
  • Loading branch information
nosolosw authored Jun 10, 2020
1 parent 7567111 commit f6e4673
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
15 changes: 15 additions & 0 deletions lib/client-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,21 @@ function gutenberg_extend_settings_custom_spacing( $settings ) {
}
add_filter( 'block_editor_settings', 'gutenberg_extend_settings_custom_spacing' );


/**
* Extends block editor settings to determine whether to use custom spacing controls.
* Currently experimental.
*
* @param array $settings Default editor settings.
*
* @return array Filtered editor settings.
*/
function gutenberg_extend_settings_link_color( $settings ) {
$settings['__experimentalEnableLinkColor'] = get_theme_support( 'experimental-link-color' );
return $settings;
}
add_filter( 'block_editor_settings', 'gutenberg_extend_settings_link_color' );

/*
* Register default patterns if not registered in Core already.
*/
Expand Down
13 changes: 9 additions & 4 deletions packages/block-editor/src/hooks/color.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,13 @@ const getLinkColorFromAttributeValue = ( colors, value ) => {
*/
export function ColorEdit( props ) {
const { name: blockName, attributes } = props;
const { colors, gradients } = useSelect( ( select ) => {
return select( 'core/block-editor' ).getSettings();
}, [] );
const { colors, gradients, __experimentalEnableLinkColor } = useSelect(
( select ) => {
return select( 'core/block-editor' ).getSettings();
},
[]
);

// Shouldn't be needed but right now the ColorGradientsPanel
// can trigger both onChangeColor and onChangeBackground
// synchronously causing our two callbacks to override changes
Expand Down Expand Up @@ -310,7 +314,8 @@ export function ColorEdit( props ) {
? onChangeGradient
: undefined,
},
...( hasLinkColorSupport( blockName )
...( __experimentalEnableLinkColor &&
hasLinkColorSupport( blockName )
? [
{
label: __( 'Link Color' ),
Expand Down
1 change: 1 addition & 0 deletions packages/editor/src/components/provider/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ class EditorProvider extends Component {
'__experimentalDisableCustomLineHeight',
'__experimentalEnableCustomSpacing',
'__experimentalEnableLegacyWidgetBlock',
'__experimentalEnableLinkColor',
'__experimentalEnableFullSiteEditing',
'__experimentalEnableFullSiteEditingDemo',
'__experimentalFeatures',
Expand Down

0 comments on commit f6e4673

Please sign in to comment.