Skip to content

Instantly share code, notes, and snippets.

@stas
Created June 14, 2011 20:01
Show Gist options
  • Select an option

  • Save stas/1025741 to your computer and use it in GitHub Desktop.

Select an option

Save stas/1025741 to your computer and use it in GitHub Desktop.
Checks if current theme has the template file for this post type
/**
* check_template()
*
* Checks if current theme has the template file for this post type
*/
function check_template() {
$template_name = 'single-event.php';
$source_template_file = dirname( __FILE__ ) .'/templates/' . $template_name;
$theme_folder = get_stylesheet_directory();
if( !file_exists( $theme_folder . '/' . $template_name ) )
copy( $source_template_file, $theme_folder . '/' . $template_name );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment