Prevent hooks from being attached to empty content #10453
Prevent hooks from being attached to empty content #10453
Conversation
The release ZIP for this PR is accessible via:
Script Dependencies ReportThere is no changed script dependency between this branch and trunk. This comment was automatically generated by the TypeScript Errors Report
🎉 🎉 This PR does not introduce new TS errors. |
Size Change: 0 B Total Size: 1.34 MB ℹ️ View Unchanged
|
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 works as expected!
I'd modify the testing steps in the following way:
- The
functions.php
code is missing some closing brackets:
add_action( 'woocommerce_before_shop_loop' , function () {
echo 'Hook: woocommerce_before_shop_loop';
});
add_action( 'woocommerce_after_shop_loop' , function () {
echo 'Hook: woocommerce_after_shop_loop';
});
add_action( 'woocommerce_no_products_found' , function () {
echo 'Hook: woocommerce_no_products_found';
});
-
Since the testing requires code changes I'd check the
Do not include in the Testing Notes
checkbox. -
I think this qualifies for the
skip-changelog
so the changelog is unnecessary.
Since the requested changes only are relating to the PR description I am approving.
Thanks @danieldudzic! I applied the changes you mentioned except for
I think in general we communicate fixes in changelog so I'd stick with the changelog 🤔 |
Hooks were attached also to the blocks that has empty content which is unexpected. As an example the
woocommerce_before_shop_loop_item
andwoocommerce_after_shop_loop_item
where rendered "around" the empty Products (Beta) block. This issue fixes the problem.Fixes #10452
Screenshots
Testing
Automated Tests
Issue found during writing E2E test for Compatibility Layer so it will be covered.
User Facing Testing
Expected: Only
woocommerce_no_products_found
should be firedWooCommerce Visibility
Performance Impact
Changelog