-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Try generating styles for classic themes by filtering theme.json
data
#44268
Closed
+61
−35
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
lib/compat/wordpress-6.1/hook-theme-json-for-classic-themes.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
|
||
function theme_json_current_theme_has_support( ){ | ||
return WP_Theme_JSON_Resolver_Gutenberg::theme_has_support(); | ||
} | ||
|
||
function theme_json_default_filter_for_classic_themes( $theme_json_data ) { | ||
if ( ! theme_json_current_theme_has_support() ) { | ||
$new_data = array( | ||
'version' => 2, | ||
'settings' => array( | ||
/* | ||
* We should be able to remove this. | ||
* Without it, it breaks. | ||
*/ | ||
"spacing" => array( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Something breaks if I create a |
||
"spacingScale" => array( | ||
"operator" => "*", | ||
"increment" => 1.5, | ||
"steps" => 7, | ||
"mediumStep" => 1.5, | ||
"unit" => "rem" | ||
), | ||
), | ||
), | ||
'styles' => array( | ||
'elements' => array( | ||
'button' => array( | ||
'color' => array( | ||
'text' => '#fff', | ||
'background' => '#32373c', | ||
), | ||
'spacing' => array( | ||
'padding' =>'calc(0.667em + 2px) calc(1.333em + 2px)', | ||
), | ||
'typography' => array( | ||
'fontSize' => 'inherit', | ||
'fontFamily' => 'inherit', | ||
'lineHeight' => 'inherit', | ||
'textDecoration' => 'none', | ||
), | ||
'border' => array( | ||
'width' => '0', | ||
), | ||
), | ||
), | ||
), | ||
); | ||
$theme_json_data->create_with( $new_data ); | ||
} | ||
|
||
return $theme_json_data; | ||
} | ||
add_filter( 'theme_json_default', 'theme_json_default_filter_for_classic_themes'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turns out we don't have a great way to clear existing data through the
merge
process if it's not overwrite it. This creates a new object from scratch. May need to revisit the ability to clear data but this works for now.