-
Notifications
You must be signed in to change notification settings - Fork 384
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
Always provide polyfill for dependencies if WP or Gutenberg plugin is not supported; ensure onboarding wizard works on < WP 5.6 #6225
Always provide polyfill for dependencies if WP or Gutenberg plugin is not supported; ensure onboarding wizard works on < WP 5.6 #6225
Conversation
Plugin builds for 303a4a3 are ready 🛎️!
|
if ( version_compare( get_bloginfo( 'version' ), '4.9', '<' ) ) { | ||
$this->markTestSkipped( 'The WP version is less than 4.9, so Gutenberg did not init.' ); | ||
if ( version_compare( get_bloginfo( 'version' ), '5.0', '<' ) ) { | ||
$this->markTestSkipped( 'Gutenberg for WP < 5.0 is not supported.' ); |
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.
Is this change and the latter correct since in WP 4.9 the 4.9.0 version of Gutenberg is installed?
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 meant 'not supported' in the sense that the do_blocks
hook occurs at priority 7 instead of 9 in GB 4.9.0, so the functionality being tested here would fail.
Todo: Onboarding Wizard should work on WP<5.6 if the AMP Settings screen is also supposed to work. |
Done in f0962b1. The onboarding wizard should be operable as far back as WP 4.9. |
…-active # Conflicts: # includes/admin/functions.php
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 code, specifically the JS/Gutenberg-related part, looks good to me.
I've tested out the update on WordPress 4.9.8 with Gutenberg 4.9.0 activated and can confirm that both the Settings page and the Wizard work well now.
@@ -160,7 +160,7 @@ const customizer = { | |||
|
|||
const WORDPRESS_NAMESPACE = '@wordpress/'; | |||
const BABEL_NAMESPACE = '@babel/'; | |||
const gutenbergPackages = [ '@babel/polyfill', '@wordpress/dom-ready', '@wordpress/i18n', '@wordpress/hooks', '@wordpress/url' ].map( | |||
const gutenbergPackages = [ '@babel/polyfill', '@wordpress/dom-ready', '@wordpress/i18n', '@wordpress/hooks', '@wordpress/html-entities', '@wordpress/url' ].map( |
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.
@pierlon The @wordpress/html-entities
is a new dependency that we use which needs to be polyfilled or else an error occurs?
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.
It's needed for the onboarding wizard to load in WP 4.9.
@westonruter can you confirm if 98e259c fixes the AMP Enabled link in the classic editor? |
I think we should replace that line with a notice to ask the user to upgrade. |
With d2b79c1, users of unsupported versions of WordPress will see: |
@@ -163,6 +163,11 @@ public function enqueue_admin_assets() { | |||
|
|||
wp_styles()->add_data( self::ASSETS_HANDLE, 'rtl', 'replace' ); | |||
|
|||
// Abort if version of WordPress is too old. | |||
if ( ! Services::get( 'dependency_support' )->has_support_from_core() ) { |
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 chose to go with checking for core support here rather than support in general because I figure it would be a bad idea to try to amp_register_polyfills
on the edit post screen, not knowing what possible conflicts could result.
Co-authored-by: Weston Ruter <[email protected]>
'my-gb-post-type', | ||
[ | ||
'public' => true, | ||
'show_in_rest' => true, | ||
'supports' => [ 'editor' ], | ||
] | ||
); | ||
|
||
set_current_screen( 'edit.php' ); | ||
$post = $this->factory()->post->create( [ 'post_type' => 'my-gutenberg-post-type' ] ); |
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.
This test is failing, at least because my-gb-post-type
is the post type defined but my-gutenberg-post-type
is the post type created, but neither of these are among the AMP_Post_Type_Support::get_eligible_post_types()
.
Fixing test… |
See test cases in the description on #6194. |
… not supported; ensure onboarding wizard works on < WP 5.6 (#6225) Co-authored-by: Pierre Gordon <[email protected]>
Summary
Fixes #6194.
This PR ensures that the polyfilled dependencies are always registered if WP or the active Gutenberg plugin is known to have outdated dependencies, which can sometimes cause some plugin screens to not work as intended.
Also, polyfills are now provided for the onboarding wizard so that it is operable on WP < 5.6.
Checklist