Skip to content

Commit

Permalink
Enable appearance tools via theme_support (#43337)
Browse files Browse the repository at this point in the history
* Enable appearance tools via theme_support
Co-authored-by: Jeff Ong <jonger4@gmail.com>
  • Loading branch information
pbking authored Aug 22, 2022
1 parent c4b2ca7 commit f695d8c
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/how-to-guides/themes/theme-json.md
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ To retain backward compatibility, the existing `add_theme_support` declarations
| `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`. |

#### Presets

Expand Down
13 changes: 13 additions & 0 deletions docs/how-to-guides/themes/theme-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -463,3 +463,16 @@ where
- `<link-color>` is either `var(--wp--preset--color--slug)` (if the user selected a preset value) or a raw color value (if the user selected a custom value)

The block will get attached the class `.wp-elements-<uuid>`.

## Appearance Tools

Use this setting to enable the following Global Styles settings:

- border: color, radius, style, width
- color: link
- spacing: blockGap, margin, padding
- typography: lineHeight

```php
add_theme_support( 'appearance-tools' );
```
5 changes: 5 additions & 0 deletions lib/experimental/class-wp-theme-json-resolver-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ public static function get_theme_data( $deprecated = array(), $settings = array(

// Classic themes without a theme.json don't support global duotone.
$theme_support_data['settings']['color']['defaultDuotone'] = false;

// Allow themes to enable appearance tools via theme_support.
if ( current_theme_supports( 'appearance-tools' ) ) {
$theme_support_data['settings']['appearanceTools'] = true;
}
}
$with_theme_supports = new WP_Theme_JSON_Gutenberg( $theme_support_data );
$with_theme_supports->merge( static::$theme );
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 @@ -78,6 +78,10 @@ declare module './base-entity-records' {
* Whether theme opts in to wide alignment CSS class.
*/
'align-wide': boolean;
/**
* Whether appearanceTools are enabled in Global Styles.
*/
'appearance-tools': boolean;
/**
* Whether posts and comments RSS feed links are added to head.
*/
Expand Down

0 comments on commit f695d8c

Please sign in to comment.