diff --git a/functions.php b/functions.php index 643262ab..9132beea 100644 --- a/functions.php +++ b/functions.php @@ -42,9 +42,9 @@ if ( storefront_is_woocommerce_activated() ) { require 'inc/woocommerce/class-storefront-woocommerce-adjacent-products.php'; - require 'inc/woocommerce/storefront-woocommerce-template-hooks.php'; - require 'inc/woocommerce/storefront-woocommerce-template-functions.php'; require 'inc/woocommerce/storefront-woocommerce-functions.php'; + require 'inc/woocommerce/storefront-woocommerce-template-functions.php'; + require 'inc/woocommerce/storefront-woocommerce-template-hooks.php'; } if ( is_admin() ) { diff --git a/inc/woocommerce/storefront-woocommerce-functions.php b/inc/woocommerce/storefront-woocommerce-functions.php index 40f7dd31..ba648661 100644 --- a/inc/woocommerce/storefront-woocommerce-functions.php +++ b/inc/woocommerce/storefront-woocommerce-functions.php @@ -47,3 +47,32 @@ function storefront_get_next_product( $in_same_term = false, $excluded_terms = ' $product = new Storefront_WooCommerce_Adjacent_Products( $in_same_term, $excluded_terms, $taxonomy ); return $product->get_product(); } + +/** + * Retrieves the homepage sections to diplay. + * + * @since 2.5.1 + * + * @return array Array of homepage section to add. + */ +function storefront_get_homepage_sections() { + + $sections = array( + 20 => 'product_categories', + 30 => 'recent_products', + 40 => 'featured_products', + 50 => 'popular_products', + 60 => 'on_sale_products', + 70 => 'best_selling_products' + + ); + + /** + * Filter homepage sections. + * + * @since 2.5.1 + * + * @param array $sections + */ + return apply_filters( 'woocommerce_storefront_homepage_sections', $sections ); +} diff --git a/inc/woocommerce/storefront-woocommerce-template-hooks.php b/inc/woocommerce/storefront-woocommerce-template-hooks.php index 7f40c5be..e653f94b 100644 --- a/inc/woocommerce/storefront-woocommerce-template-hooks.php +++ b/inc/woocommerce/storefront-woocommerce-template-hooks.php @@ -8,6 +8,7 @@ /** * Homepage * + * @see storefront_get_homepage_sections() * @see storefront_product_categories() * @see storefront_recent_products() * @see storefront_featured_products() @@ -15,12 +16,9 @@ * @see storefront_on_sale_products() * @see storefront_best_selling_products() */ -add_action( 'homepage', 'storefront_product_categories', 20 ); -add_action( 'homepage', 'storefront_recent_products', 30 ); -add_action( 'homepage', 'storefront_featured_products', 40 ); -add_action( 'homepage', 'storefront_popular_products', 50 ); -add_action( 'homepage', 'storefront_on_sale_products', 60 ); -add_action( 'homepage', 'storefront_best_selling_products', 70 ); +foreach ( storefront_get_homepage_sections() as $priority => $section ) { + add_action( 'homepage', 'storefront_' . $section, $priority ); +} /** * Layout