From 34b9ef9b93a88a99520212bd1056e75239453583 Mon Sep 17 00:00:00 2001 From: lucasstark Date: Tue, 6 Mar 2012 08:26:10 -0500 Subject: [PATCH] Locate Template Filters and Actions --- woocommerce-core-functions.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/woocommerce-core-functions.php b/woocommerce-core-functions.php index fcec0495933..12d823cec32 100644 --- a/woocommerce-core-functions.php +++ b/woocommerce-core-functions.php @@ -151,30 +151,35 @@ function woocommerce_get_template_part( $slug, $name = '' ) { /** * Get other templates (e.g. product attributes) passing attributes and including the file */ -function woocommerce_get_template($template_name, $args = array()) { +function woocommerce_get_template($template_name, $args = array(), $template_path='') { global $woocommerce; if ( $args && is_array($args) ) extract( $args ); - include( woocommerce_locate_template( $template_name ) ); + $located = woocommerce_locate_template( $template_name, $template_path ); + do_action('woocommerce_before_template_part', $template_name, $template_path, $located); + include( $located ); + do_action('woocommerce_after_template_part', $template_name, $template_path, $located); + } /** * Locate a template and return the path for inclusion */ -function woocommerce_locate_template( $template_name ) { +function woocommerce_locate_template( $template_name, $template_path='' ) { global $woocommerce; + if (!empty($template_path)) $template = locate_template( array( $template_path . $template_name , $template_name ) ); + // Look in yourtheme/woocommerce/template-name and yourtheme/template-name - $template = locate_template( array( $woocommerce->template_url . $template_name , $template_name ) ); + if (!$template) $template = locate_template( array( $woocommerce->template_url . $template_name , $template_name ) ); // Get default template if (!$template) $template = $woocommerce->plugin_path() . '/templates/' . $template_name; - return $template; + return apply_filters('woocommerce_locate_template', $template, $template_name, $template_path); } - /** * Currency **/