From 44b5f54d08cf6b2f7c34568464d543e4a26d6174 Mon Sep 17 00:00:00 2001 From: Tom Cafferkey Date: Fri, 30 Aug 2024 12:24:34 +0100 Subject: [PATCH] Add doc blocks to Products shortcode hooks (#51061) * Add doc blocks to products shortcode woocommerce_before_shop_loop hooks * Improved comments * Add changelog --- .../add-docblocks-to-products-shortcode-hooks | 4 ++++ .../shortcodes/class-wc-shortcode-products.php | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 plugins/woocommerce/changelog/add-docblocks-to-products-shortcode-hooks diff --git a/plugins/woocommerce/changelog/add-docblocks-to-products-shortcode-hooks b/plugins/woocommerce/changelog/add-docblocks-to-products-shortcode-hooks new file mode 100644 index 00000000000..0c79db17c86 --- /dev/null +++ b/plugins/woocommerce/changelog/add-docblocks-to-products-shortcode-hooks @@ -0,0 +1,4 @@ +Significance: patch +Type: dev + +Added doc blocks to conditionally fired hooks to better explain nuanced behavior diff --git a/plugins/woocommerce/includes/shortcodes/class-wc-shortcode-products.php b/plugins/woocommerce/includes/shortcodes/class-wc-shortcode-products.php index 9b551b3f2e0..51eed9c2753 100644 --- a/plugins/woocommerce/includes/shortcodes/class-wc-shortcode-products.php +++ b/plugins/woocommerce/includes/shortcodes/class-wc-shortcode-products.php @@ -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' ); }