Created
June 10, 2014 22:28
-
-
Save drrobotnik/e5567b37e2c403d59207 to your computer and use it in GitHub Desktop.
plugin template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Get template part (for templates like the shop-loop). | |
* | |
* @access public | |
* @param mixed $slug | |
* @param string $name (default: '') | |
* @return void | |
*/ | |
function wc_get_template_part( $slug, $name = '' ) { | |
$template = ''; | |
// Look in yourtheme/slug-name.php and yourtheme/woocommerce/slug-name.php | |
if ( $name ) { | |
$template = locate_template( array( "{$slug}-{$name}.php", WC()->template_path() . "{$slug}-{$name}.php" ) ); | |
} | |
// Get default slug-name.php | |
if ( ! $template && $name && file_exists( WC()->plugin_path() . "/templates/{$slug}-{$name}.php" ) ) { | |
$template = WC()->plugin_path() . "/templates/{$slug}-{$name}.php"; | |
} | |
// If template file doesn't exist, look in yourtheme/slug.php and yourtheme/woocommerce/slug.php | |
if ( ! $template ) { | |
$template = locate_template( array( "{$slug}.php", WC()->template_path() . "{$slug}.php" ) ); | |
} | |
// Allow 3rd party plugin filter template file from their plugin | |
$template = apply_filters( 'wc_get_template_part', $template, $slug, $name ); | |
if ( $template ) { | |
load_template( $template, false ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment