Skip to content

Commit 398a548

Browse files
committed
Editor: Add support for text inputs to theme.json.
Adds support for text input elements to theme.json so that theme builders and extenders can be style text input elements consistently. Text input elements are `textarea`, and `input` with type `email`, `number`, `password`, `search`, `text`, `tel` and `url`. We are targeting the HTML elements directly rather than adding a CSS class, as we do for other elements that theme.json supports. This commit adds no extra styling unless a theme opts in to use this and the specificity of any generated CSS with the element is 0. See original Gutenberg PR: WordPress/gutenberg#70378. Example usage: {{{ "elements": { "textInput": { "border": { "radius": "0", "style": "solid", "width": "1px", "color": "red" }, "color": { "text": "var(--wp--preset--color--theme-2)" }, "typography": { "fontFamily": "var(--wp--preset--font-family--inter)" } } } }}} Reviewed by mukesh27, scruffian. Merges [9600] to the 6.9 branch. Props onemaggie, mukesh27, sabernhardt, joen, get_dave, wildworks, ocean90, mikachan, poena. Fixes #63878. See #63555. Built from https://develop.svn.wordpress.org/trunk@61023 git-svn-id: https://core.svn.wordpress.org/trunk@60359 1a063a9b-81f0-0310-95a4-ce76da25c4cd
1 parent bd521a6 commit 398a548

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

wp-includes/class-wp-theme-json.php

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -613,22 +613,24 @@ class WP_Theme_JSON {
613613
*
614614
* @since 5.8.0
615615
* @since 6.1.0 Added `heading`, `button`, and `caption` elements.
616+
* @since 6.9.0 Added `textInput` elements.
616617
* @var string[]
617618
*/
618619
const ELEMENTS = array(
619-
'link' => 'a:where(:not(.wp-element-button))', // The `where` is needed to lower the specificity.
620-
'heading' => 'h1, h2, h3, h4, h5, h6',
621-
'h1' => 'h1',
622-
'h2' => 'h2',
623-
'h3' => 'h3',
624-
'h4' => 'h4',
625-
'h5' => 'h5',
626-
'h6' => 'h6',
620+
'link' => 'a:where(:not(.wp-element-button))', // The `where` is needed to lower the specificity.
621+
'heading' => 'h1, h2, h3, h4, h5, h6',
622+
'h1' => 'h1',
623+
'h2' => 'h2',
624+
'h3' => 'h3',
625+
'h4' => 'h4',
626+
'h5' => 'h5',
627+
'h6' => 'h6',
627628
// We have the .wp-block-button__link class so that this will target older buttons that have been serialized.
628-
'button' => '.wp-element-button, .wp-block-button__link',
629+
'button' => '.wp-element-button, .wp-block-button__link',
629630
// The block classes are necessary to target older content that won't use the new class names.
630-
'caption' => '.wp-element-caption, .wp-block-audio figcaption, .wp-block-embed figcaption, .wp-block-gallery figcaption, .wp-block-image figcaption, .wp-block-table figcaption, .wp-block-video figcaption',
631-
'cite' => 'cite',
631+
'caption' => '.wp-element-caption, .wp-block-audio figcaption, .wp-block-embed figcaption, .wp-block-gallery figcaption, .wp-block-image figcaption, .wp-block-table figcaption, .wp-block-video figcaption',
632+
'cite' => 'cite',
633+
'textInput' => 'textarea, input:where([type=email],[type=number],[type=password],[type=search],[type=text],[type=tel],[type=url])',
632634
);
633635

634636
const __EXPERIMENTAL_ELEMENT_CLASS_NAMES = array(

wp-includes/version.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*
1717
* @global string $wp_version
1818
*/
19-
$wp_version = '6.9-alpha-61022';
19+
$wp_version = '6.9-alpha-61023';
2020

2121
/**
2222
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.

0 commit comments

Comments
 (0)