-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Fix default duotone preset SVG and style generation #38681
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
01d593e
Fix spacing
51d2bc5
Add defaultDuotone to disable default SVGs
9072348
Disable duotone css vars too
ccb65ac
Add defaultDuotone to JSON schema
93f23af
Fix phpcs
7b4e11c
Update docs
795de03
Add defaultDuotone to prevent override
3cda90b
Try refactoring override path and bool to not be inverse
68cdf4e
Use multi-origin duotone presets
fe1c37a
Try refactor should_override_preset
6b65616
Prevent generating other default presets
ece841d
Fix conditional hook
d47041e
Add example for get_metadata_boolean
bb55054
Fix phpcs
e6ceb4b
Override core duotone rendering in plugin
67dbd4b
Use protected/static instead of private/self
10e3e26
Fix toolbar items for duotone
159afc3
Disable duotone generation in classic themes while keeping the defaul…
9de2494
Update schema description for defaultDuotone
1410ae1
Add comment about overriding
6bdf5d0
Fix comment style
77b04c7
Revert extra check in theme.json resolver
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
Try refactor should_override_preset
- Loading branch information
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -1487,7 +1487,7 @@ public function merge( $incoming ) { | |
|
|
||
| // Replace the presets. | ||
| foreach ( static::PRESETS_METADATA as $preset ) { | ||
| $override_preset = static::should_override_preset( $this->theme_json, $node['path'], $preset['prevent_override'] ); | ||
| $override_preset = ! static::get_metadata_boolean( $this->theme_json['settings'], $preset['prevent_override'], true ); | ||
|
|
||
| foreach ( static::VALID_ORIGINS as $origin ) { | ||
| $base_path = array_merge( $node['path'], $preset['path'] ); | ||
|
|
@@ -1560,32 +1560,25 @@ public function get_svg_filters( $origins ) { | |
| } | ||
|
|
||
| /** | ||
| * Returns whether a presets should be overridden or not. | ||
| * For metadata values that can either be booleans or paths to booleans, gets the value. | ||
| * | ||
| * @param array $theme_json The theme.json like structure to inspect. | ||
| * @param array $path Path to inspect. | ||
| * @param bool|array $prevent_override Data to compute whether to prevent override of the preset. | ||
| * @param array $data The data to inspect. | ||
| * @param bool|array $path Boolean or path to a boolean. | ||
| * @return boolean | ||
| */ | ||
| protected static function should_override_preset( $theme_json, $path, $prevent_override ) { | ||
| if ( is_bool( $prevent_override ) ) { | ||
| return ! $prevent_override; | ||
| protected static function get_metadata_boolean( $data, $path, $default = false ) { | ||
| if ( is_bool( $path ) ) { | ||
| return $path; | ||
| } | ||
|
|
||
| if ( is_array( $prevent_override ) ) { | ||
| $value = _wp_array_get( $theme_json, array_merge( $path, $prevent_override ) ); | ||
| if ( is_array( $path ) ) { | ||
| $value = _wp_array_get( $data, $path ); | ||
| if ( isset( $value ) ) { | ||
| return ! $value; | ||
| return $value; | ||
|
Member
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. this does seem like a very nice improvement over |
||
| } | ||
|
|
||
| // Search the top-level key if none was found for this node. | ||
| $value = _wp_array_get( $theme_json, array_merge( array( 'settings' ), $prevent_override ) ); | ||
| if ( isset( $value ) ) { | ||
| return ! $value; | ||
| } | ||
|
|
||
| return false; | ||
| } | ||
|
|
||
| return $default; | ||
| } | ||
|
|
||
| /** | ||
|
|
||
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.
here's an example of the confusion:
$override_presetreads to me like a directive, such as "you should override the preset" whileprevent_overridesounds more like an allowance, "you may or may not override the preset."two changes that may not be ideal but which would remove the confusion from this line would be to: