-
Notifications
You must be signed in to change notification settings - Fork 800
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
Consolidate Jetpack initial state #38430
Conversation
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available. Once your PR is ready for review, check one last time that all required checks appearing at the bottom of this PR are passing or skipped. Jetpack plugin: The Jetpack plugin has different release cadences depending on the platform:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. Backup plugin:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. Boost plugin:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. Search plugin:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. Social plugin:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. Starter Plugin plugin:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. Protect plugin:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. Videopress plugin:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. Migration plugin:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. Mu Wpcom plugin:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. Inspect plugin:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. Wpcomsh plugin:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. Automattic For agencies client plugin:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. Classic Theme helper plugin plugin:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. |
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
30ee33f
to
d8f5928
Compare
d8f5928
to
18026f2
Compare
|
||
wp_add_inline_script( | ||
self::SCRIPT_HANDLE, | ||
sprintf( 'var JETPACK_INITIAL_STATE = %s;', $initial_state ), |
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 wonder what the merits are of setting this global versus setting a property on the window.JetpackInitialState
object.
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 am not sure which is better:
One benefit of window.JetpackInitialState
is that it can be check in if()
condition but it can also be deleted
.
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.
Since we're already using window.JetpackInitialState
in both types and utils, can we use it here as well? I don't think there's a downside to it, is there?
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.
Just wanted to mention that a huge benefit of using window.JetpackInitialState
has been that I can directly type JetpackInitialState
in the console on simple sites where the editor parts are rendered in iframes and the variable is still attached to the window
. Otherise, for the variables declared with var
, I had to search the DOM to find the data being rendered inside iframes because it would not be globally available.
Thanks.
d34ff98
to
bb90514
Compare
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'm going to ask Vulcan to finish up the review on this, since they know a lot more about how Connection and such works than I do.
@anomiex any idea why the build for It works fine locally. |
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.
Looks good!
This is the first attempt to consolidate initial state in Jetpack - pdWQjU-KI-p2
#38606 serves as the basic working example of the usage of the initial state (script data) added in this PR.
Proposed changes:
script-data
which provides some basic JS utility functions. Suggestions are welcome.script-data
package viapackages/assets
, i.e.assets
package will contain the build output fromscript-data
js package.jetpack-script-data
as a dependency to its JS script handle when registering/enqueueing it.Other information:
Jetpack product discussion
pdWQjU-KI-p2
Does this pull request change what data or activity we track or use?
Testing instructions:
This PR does not change anything, for any package/plugin. It just adds the support for initial state which can be used in subsequent PR. As mentioned above, #38606 serves as the basic working example of the usage of this PR.