mirrored from git://develop.git.wordpress.org/
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Backport global styles custom css changes #3896
Closed
glendaviesnz
wants to merge
24
commits into
WordPress:trunk
from
glendaviesnz:backport/global-styles-custom-css
Closed
Changes from 14 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
baa9ab4
Add initial backports
glendaviesnz b314cf3
Test that invalid CSS is rejected
glendaviesnz f0a244b
Add tests for global styles custom CSS
glendaviesnz cecd9ca
fix function name
glendaviesnz 5a11f8a
Fix class naming issue
glendaviesnz bd7fe93
Fix linting issue
glendaviesnz 76d3f99
Add tests for global custom CSS
glendaviesnz c446376
add debugging to unit test
glendaviesnz 8f7afa8
check for array or object
glendaviesnz 1f74f52
Remove debugging
glendaviesnz 6787594
Add in check for edit-css capabilities
glendaviesnz e4d53a2
Add tests for custom CSS user capabilities
glendaviesnz 400d437
Fix permissions issue on multisite test
glendaviesnz eec32b6
Put permissions assignment in the right place!
glendaviesnz c9fcd81
Set permissions in tests instead of setup to prevent changing permiss…
glendaviesnz 7450db9
Fixes from code review
glendaviesnz d6c6e65
Remove unnecessary description
glendaviesnz 20442c9
But make user definition that was removed by mistake
glendaviesnz d055fa5
Change ordering of $request[styles] assignment to $config[styles]
glendaviesnz d37e7f2
Change cache key and add doc comments
glendaviesnz d71a7fe
match cache key to method name
glendaviesnz b658684
Move check for theme.json to top of function
glendaviesnz 6a986eb
Merge branch 'trunk' into backport/global-styles-custom-css
felixarntz 7261356
Update inline comment.
felixarntz 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
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -425,6 +425,7 @@ class WP_Theme_JSON { | |||||
'textDecoration' => null, | ||||||
'textTransform' => null, | ||||||
), | ||||||
'css' => null, | ||||||
); | ||||||
|
||||||
/** | ||||||
|
@@ -1005,6 +1006,31 @@ public function get_stylesheet( $types = array( 'variables', 'styles', 'presets' | |||||
return $stylesheet; | ||||||
} | ||||||
|
||||||
/** | ||||||
* Returns the global styles custom css. | ||||||
* | ||||||
* @since 6.2.0 | ||||||
* | ||||||
* @return string | ||||||
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.
Suggested change
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. @hellofromtonya Addressed this as part of follow up 2cf1b08. |
||||||
*/ | ||||||
public function get_custom_css() { | ||||||
// Add the global styles root CSS. | ||||||
$stylesheet = _wp_array_get( $this->theme_json, array( 'styles', 'css' ), '' ); | ||||||
|
||||||
// Add the global styles block CSS. | ||||||
if ( isset( $this->theme_json['styles']['blocks'] ) ) { | ||||||
foreach ( $this->theme_json['styles']['blocks'] as $name => $node ) { | ||||||
$custom_block_css = _wp_array_get( $this->theme_json, array( 'styles', 'blocks', $name, 'css' ) ); | ||||||
if ( $custom_block_css ) { | ||||||
$selector = static::$blocks_metadata[ $name ]['selector']; | ||||||
$stylesheet .= $this->process_blocks_custom_css( $custom_block_css, $selector ); | ||||||
} | ||||||
} | ||||||
} | ||||||
|
||||||
return $stylesheet; | ||||||
} | ||||||
|
||||||
/** | ||||||
* Returns the page templates of the active theme. | ||||||
* | ||||||
|
@@ -2740,7 +2766,12 @@ public static function remove_insecure_properties( $theme_json ) { | |||||
continue; | ||||||
} | ||||||
|
||||||
$output = static::remove_insecure_styles( $input ); | ||||||
// The global styles custom CSS is not sanitized, but can only be edited by users with 'edit_css' capability. | ||||||
if ( isset( $input['css'] ) && current_user_can( 'edit_css' ) ) { | ||||||
$output = $input; | ||||||
} else { | ||||||
$output = static::remove_insecure_styles( $input ); | ||||||
} | ||||||
|
||||||
/* | ||||||
* Get a reference to element name from path. | ||||||
|
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
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
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
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.
The comment is too long on one line.
Helps to improve readability.
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.
Two things:
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.
I can take care of committing this and address this feedback prior to the commit.