Skip to content

Commit

Permalink
Global Styles: Add support for heading elements (#41981)
Browse files Browse the repository at this point in the history
* Global Styles: Add support for heading elements

* Collect element style nodes in the order they're defined in ELEMENTS and not in theme.json

Co-authored-by: Adam Zieliński <[email protected]>
  • Loading branch information
scruffian and adamziel authored Jul 4, 2022
1 parent 9df5714 commit 2ac16f4
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/compat/wordpress-6.1/class-wp-theme-json-6-1.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class WP_Theme_JSON_6_1 extends WP_Theme_JSON_6_0 {
*/
const ELEMENTS = array(
'link' => 'a:not(.wp-element-button)',
'heading' => 'h1, h2, h3, h4, h5, h6',
'h1' => 'h1',
'h2' => 'h2',
'h3' => 'h3',
Expand Down Expand Up @@ -342,8 +343,10 @@ protected static function get_style_nodes( $theme_json, $selectors = array() ) {
);

if ( isset( $theme_json['styles']['elements'] ) ) {

foreach ( $theme_json['styles']['elements'] as $element => $node ) {
foreach ( self::ELEMENTS as $element => $selector ) {
if ( ! isset( $theme_json['styles']['elements'][ $element ] ) ) {
continue;
}

// Handle element defaults.
$nodes[] = array(
Expand Down

0 comments on commit 2ac16f4

Please sign in to comment.