-
Notifications
You must be signed in to change notification settings - Fork 219
Check if WordPress version is higher than 6.2.2 to make Products block compatible with Gutenberg 16+ #10360
Conversation
…k compatible with Gutenberg 16+
The release ZIP for this PR is accessible via:
Script Dependencies ReportThe
This comment was automatically generated by the TypeScript Errors Report
🎉 🎉 This PR does not introduce new TS errors. |
src/BlockTypes/ProductQuery.php
Outdated
@@ -91,6 +91,14 @@ protected function initialize() { | |||
protected function enqueue_data( array $attributes = [] ) { | |||
parent::enqueue_data( $attributes ); | |||
|
|||
if ( version_compare( $GLOBALS['wp_version'], '6.2.2', '>' ) ) { |
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.
NIT: Should we put both logic in a dedicated function and add a comment? (it would be great just the link to this PR)
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.
NIT: Should we put both logic in a dedicated function and add a comment? (it would be great just the link to this PR)
Good idea! I extracted the logic to separate function, do you mind taking a look one more time?
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 noticed that we should fix the check for the WP version :D
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.
LGTM! I added a comment, but feel free to merge as it is! Thanks for tacking care of this! 🚀
Size Change: -18.1 kB (-1%) Total Size: 1.34 MB
ℹ️ View Unchanged
|
… toi separate function
src/BlockTypes/ProductQuery.php
Outdated
* - https://github.com/woocommerce/woocommerce-blocks/pull/10360 | ||
*/ | ||
private function check_if_post_template_has_support_for_grid_view() { | ||
if ( version_compare( $GLOBALS['wp_version'], '6.2.2', '>' ) ) { |
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.
Are you sure that this check is correct? Should be
if ( version_compare( $GLOBALS['wp_version'], '6.2.2', '>' ) ) { | |
if ( version_compare( $GLOBALS['wp_version'], '6.3.0', '>=' ) ) { |
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.
version_compare
consider versions with suffix as lower, for example, 6.3.0 is higher than 6.3.0-RC2. That means the fix won't be applied to the RC version.
But you're right, I cannot compare to 6.2.2, because there may be another 6.2.x release and there will be incorrect behaviour.
I'll try to use this custom function wp_version_compare
which I belive was written for exactly this case or I'll think of something custom.
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.
version_compare consider versions with suffix as lower, for example, 6.3.0 is higher than 6.3.0-RC2. That means the fix won't be applied to the RC version.
TIL
version_compare consider versions with suffix as lower, for example, 6.3.0 is higher than 6.3.0-RC2. That means the fix won't be applied to the RC version.
Thanks!
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.
OK, code updated! And I updated testing steps to cover cases with higher and lower than WP 6.3 + Gutenberg 16 enabled and disabled.
…ion compare function
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.
LGTM! Thanks for your work!
…ck compatible with Gutenberg 16+ (#10360) * Check if WordPress version is higher than 6.2.2 to make Products block compatible with Gutenberg 16+ * Extract the logic of checking the post template support for grid view toi separate function * Change the versions comparison and improve description of custom version compare function
* Fix: WooCommerce Blocks causing malfunction of the navigation block on WordPress 6.3 (#10388) * Make sure the revert button is registered and enqueued for usage exclusively in the site editor. * Register and enqueue the styles for the revert button. * Rename the files. * Revert "Rename the file renames." This reverts commit c0330ce. * Add plugin-proposal-optional-chaining to the WebPack plugins config. * Rename the files. * Remove unnecessary dependencies as those are already provided via : more specifically, get_script_data. * Address CR. * Cart and Checkout Page Migration: Inherit Page template and fix rendering (#10375) * Change shortcode block render callback * Inherit template from original "page" template * Check if WordPress version is higher than 6.2.2 to make Products block compatible with Gutenberg 16+ (#10360) * Check if WordPress version is higher than 6.2.2 to make Products block compatible with Gutenberg 16+ * Extract the logic of checking the post template support for grid view toi separate function * Change the versions comparison and improve description of custom version compare function * Render Checkout/Cart containing pages without template overriding (#10359) * Render Checkout/Cart containing pages without template overriding * Fix checkout typo --------- Co-authored-by: Mike Jolley <mike.jolley@me.com> * Add to cart form: Fix fatal error when missing `product` param in add_to_cart_redirect_filter (#10316) * Transform product param optional in add_to_cart_redirect_filter method * Remove unnecessary argument from add_to_cart_redirect_filter * Remove mocked filter call * Remove unnecessary argument from function docs * Remove opinionated styles from Product Hero pattern (#10255) * Mini Cart: Remove deprecated print_inline_script() (#10165) * Mini Cart: Replace the deprecated print_inline_script() with supported get_inline_script_data(). Fixes #10004 * Mini Cart: Add version check for the new get_inline_script_data() function * Update the variable names and fix a typo * Mini Cart: Add regex to check for the WP version * Abstract the WP version comparison regex to a separate Utils class * Call wc_setup_product_data if the global product variable is not an instance of WC_Product. (#10128) * Empty commit for release pull request * add testing instructions * Per block stylesheets (#9831) * Clean up blank lines * Update Webpack config * Update PHP logic to load block styles * Style fixes * Style fixes (II) * Style fixes (III) * Style fixes (IV) * Fix missing stylesheets in the Site Editor * Fix wrong return values in some PHP method docs * Fix missing ProductPrice stylesheet causing 404 in tests * Fix missing ProductGallery stylesheet causing 404 in tests * update testing instructions * add zip link * update version * update zip link * remove screenshot * remove testing instructions * Register Legacy block for all taxonomy-product_ template (#10382) * WIP * improve logic * improve unit test * $post validation on Cart and Checkout template (#10410) Co-authored-by: Luigi Teschio <gigitux@gmail.com> * Update zip --------- Co-authored-by: Patricia Hillebrandt <patriciahillebrandt@gmail.com> Co-authored-by: Mike Jolley <mike.jolley@me.com> Co-authored-by: Karol Manijak <20098064+kmanijak@users.noreply.github.com> Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com> Co-authored-by: Alexandre Lara <allexandrelara@gmail.com> Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com> Co-authored-by: Daniel Dudzic <daniel.dudzic@automattic.com> Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: Luigi <gigitux@gmail.com>
In Gutenberg 16+ the layout attributes of Query block has been moved from
core/query
tocore/post-template
. Products (Beta) and Product Template blocks are variations of the mentioned blocks, hence we had to adjust to this logic (issue: #9884).In #9916 we fixed this, but the change is applied based on the Gutenberg version. When Gutenberg was not installed or disabled we didn't apply the adjusting logic.
However, Gutenberg 16+ is included in WordPress 6.3, so we have to apply the fix also in the case of WordPress 6.3+.
Fixes #10367
Screenshots
Testing
User Facing Testing
Check below steps in following configurations:
WooCommerce Visibility
Changelog