Skip to content

Instantly share code, notes, and snippets.

@bmarshall511
Last active April 4, 2017 19:12
Show Gist options
  • Save bmarshall511/3681c04a7d1bf14907b49cf7be507e8f to your computer and use it in GitHub Desktop.
Save bmarshall511/3681c04a7d1bf14907b49cf7be507e8f to your computer and use it in GitHub Desktop.
Load a WordPress plugin template.
<?php
/**
* Get template.
*
* Search for the template and include the file.
*
* @since 1.0.0
*
* @see PLUGIN_locate_template()
*
* @param string $template_name Template to load.
* @param array $args Args passed for the template file.
* @param string $string $template_path Path to templates.
* @param string $default_path Default path to template files.
*/
function PLUGIN_get_template( $template_name, $args = array(), $tempate_path = '', $default_path = '' ) {
if ( is_array( $args ) && isset( $args ) ) :
extract( $args );
endif;
$template_file = contests_locate_template( $template_name, $tempate_path, $default_path );
if ( ! file_exists( $template_file ) ) :
_doing_it_wrong( __FUNCTION__, sprintf( '<code>%s</code> does not exist.', $template_file ), '1.0.0' );
return;
endif;
include $template_file;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment