function hpy_fdv_woocommerce_locate_template($template, $template_name, $template_path) { global $woocommerce; $_template = $template; if (!$template_path) { $template_path = $woocommerce->template_url; } $plugin_path = myplugin_plugin_path() . '/woocommerce/'; if (file_exists($plugin_path . $template_name)) { $template = $plugin_path . $template_name; } if (!$template) { $template = locate_template(array($template_path . $template_name, $template_name)); } // Use default template if (!$template) { $template = $_template; } // Return what we found return $template; }
function myplugin_woocommerce_locate_template($template, $template_name, $template_path) { global $woocommerce; $_template = $template; if (!$template_path) { $template_path = $woocommerce->template_url; } $plugin_path = myplugin_plugin_path() . '/woocommerce/templates'; // Look within passed path within the theme - this is priority $template = locate_template(array($template_path . $template_name, $template_name)); // Modification: Get the template from this plugin, if it exists if (!$template && file_exists($plugin_path . $template_name)) { $template = $plugin_path . $template_name; } // Use default template if (!$template) { $template = $_template; } // Return what we found return $template; }