Add doc blocks to Products shortcode hooks (#51061)

* Add doc blocks to products shortcode woocommerce_before_shop_loop hooks

* Improved comments

* Add changelog
This commit is contained in:
Tom Cafferkey 2024-08-30 12:24:34 +01:00 committed by GitHub
parent 5999ea6716
commit 44b5f54d08
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 2 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: dev
Added doc blocks to conditionally fired hooks to better explain nuanced behavior

View File

@ -641,8 +641,13 @@ class WC_Shortcode_Products {
do_action( "woocommerce_shortcode_before_{$this->type}_loop", $this->attributes );
// Fire standard shop loop hooks when paginating results so we can show result counts and so on.
if ( wc_string_to_bool( $this->attributes['paginate'] ) ) {
/**
* Fire the standard shop hooks when paginating so we can display result counts etc.
* If the pagination is not enabled, this hook will not be fired.
*
* @since 3.3.1
*/
do_action( 'woocommerce_before_shop_loop' );
}
@ -667,8 +672,13 @@ class WC_Shortcode_Products {
$GLOBALS['post'] = $original_post; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
woocommerce_product_loop_end();
// Fire standard shop loop hooks when paginating results so we can show result counts and so on.
if ( wc_string_to_bool( $this->attributes['paginate'] ) ) {
/**
* Fire the standard shop hooks when paginating so we can display the pagination.
* If the pagination is not enabled, this hook will not be fired.
*
* @since 3.3.1
*/
do_action( 'woocommerce_after_shop_loop' );
}