Skip to content

Commit

Permalink
Add link color theme support (#51775)
Browse files Browse the repository at this point in the history
  • Loading branch information
carolinan authored Jun 28, 2023
1 parent 42cd04a commit d8e8c28
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/how-to-guides/themes/theme-json.md
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,8 @@ To retain backward compatibility, the existing `add_theme_support` declarations
| `editor-color-palette` | Provide the list of colors via `color.palette`. |
| `editor-font-sizes` | Provide the list of font size via `typography.fontSizes`. |
| `editor-gradient-presets` | Provide the list of gradients via `color.gradients`. |
| `experimental-link-color` | Set `color.link` to `true`. `experimental-link-color` will be removed when the plugin requires WordPress 5.9 as the minimum version. |
| `appearance-tools` | Set `appearanceTools` to `true`. |
| `link-color ` | Set `color.link` to `true`. |

#### Presets

Expand Down
8 changes: 8 additions & 0 deletions docs/how-to-guides/themes/theme-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,14 @@ Use this setting to enable the following Global Styles settings:
add_theme_support( 'appearance-tools' );
```

## Link color

Use this to enable the link color setting:

```php
add_theme_support( 'link-color' );
```

## Block Based Template Parts

Block Based Template parts allow administrators to edit parts of the site using blocks. This is off by default, and requires the theme to opt in by declaring support:
Expand Down
12 changes: 12 additions & 0 deletions lib/class-wp-theme-json-resolver-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,18 @@ public static function get_theme_data( $deprecated = array(), $options = array()
// Classic themes without a theme.json don't support global duotone.
$theme_support_data['settings']['color']['defaultDuotone'] = false;

// Allow themes to enable link colors via theme_support.
if ( current_theme_supports( 'link-color' ) ) {
$theme_support_data['settings']['color']['link'] = true;
}
if ( current_theme_supports( 'experimental-link-color' ) ) {
_doing_it_wrong(
current_theme_supports( 'experimental-link-color' ),
__( '`experimental-link-color` is no longer supported. Use `link-color` instead.', 'gutenberg' ),
'6.3.0'
);
}

// BEGIN EXPERIMENTAL.
// Allow themes to enable appearance tools via theme_support.
// This feature was backported for WordPress 6.2 as of https://core.trac.wordpress.org/ticket/56487
Expand Down
4 changes: 4 additions & 0 deletions packages/core-data/src/entity-types/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ declare module './base-entity-records' {
* Post formats supported.
*/
formats: PostFormat[];
/**
* Whether link colors are enabled.
*/
'link-color': boolean;
/**
* The post types that support thumbnails or true if all post types are supported.
*/
Expand Down

0 comments on commit d8e8c28

Please sign in to comment.