-
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
Global Styles: Add a const for the latest schema version of Global Styles #40811
Closed
Closed
Changes from all commits
Commits
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 |
---|---|---|
|
@@ -13,16 +13,37 @@ import { | |
__EXPERIMENTAL_PATHS_WITH_MERGE as PATHS_WITH_MERGE, | ||
__EXPERIMENTAL_STYLE_PROPERTY as STYLE_PROPERTY, | ||
} from '@wordpress/blocks'; | ||
import { useSelect } from '@wordpress/data'; | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import { store as editSiteStore } from '../../store'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { getValueFromVariable, getPresetVariableFromValue } from './utils'; | ||
import { | ||
getValueFromVariable, | ||
getPresetVariableFromValue, | ||
LATEST_SCHEMA, | ||
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. Don't need this line anymore |
||
} from './utils'; | ||
import { GlobalStylesContext } from './context'; | ||
|
||
const EMPTY_CONFIG = { isGlobalStylesUserThemeJSON: true, version: 1 }; | ||
const EMPTY_CONFIG = { | ||
isGlobalStylesUserThemeJSON: true, | ||
}; | ||
|
||
export const useGlobalStylesReset = () => { | ||
const { __unstableThemeJSONLatestSchema } = useSelect( ( select ) => { | ||
return { | ||
__unstableThemeJSONLatestSchema: select( | ||
editSiteStore | ||
).getSettings()?.__unstableThemeJSONLatestSchema, | ||
}; | ||
}, [] ); | ||
|
||
EMPTY_CONFIG.version = __unstableThemeJSONLatestSchema; | ||
|
||
const { user: config, setUserConfig } = useContext( GlobalStylesContext ); | ||
const canReset = !! config && ! isEqual( config, EMPTY_CONFIG ); | ||
return [ | ||
|
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.
Should this change live in a 6.1 compat file?
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'd defer to @adamziel on that one. I am behind with how all this is supposed to work. Id love to see some docs on it if there is somewhere I can reference.
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.
Docs would be awesome, I am getting confused here all the time! The basic idea is:
lib/compat
.In this case, you want:
It seems like this file is loaded in all these releases:
gutenberg/lib/load.php
Line 99 in d5b0656
It also seems like this code has a counterpart in wordpress-develop:
https://github.com/WordPress/wordpress-develop/blob/04e9728701b3dde0260c7cdebfd726edbe62ac97/src/wp-admin/site-editor.php#L63-L70
So I'm confused, does this mean that Gutenberg plugin always replaces that entire page with a custom one? If yes, then updating
lib/compat/wordpress-5.9
+ a backport to wordpress-develop would likely be sufficient. You could even move that entire function tolib/compat/wordpress-6.1
to make it clear to 6.1 release leads that there were relevant changes hereThere 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.
@scruffian I've played a bit with a version matrix and I think this is what we're after here:
❌ – fix not included
✅ – fix included
Which means two things need to happen:
This makes me think you could move this entire function to
lib/compat/wordpress-6.1
, apply your patch there, and make sure it does something reasonable on all the supported WordPress versions. Two downsides:lib/compat/wordpress-6.1
would be relevant for all the prior versions as wellTo that second point, these compat directories are notoriously confusing. Actually most of the files are always loaded regardless of the WordPress version. I think we need a better process here.