Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Retrieve the name of the highest priority template file that exists.
- *
- * Searches in the STYLESHEETPATH before TEMPLATEPATH so that themes which
- * inherit from a parent theme can just overload one file.
- *
- * @since 2.7.0
- *
- * @param string|array $template_names Template file(s) to search for, in order.
- * @param bool $load If true the template file will be loaded if it is found.
- * @param bool $require_once Whether to require_once or require. Default true. Has no effect if $load is false.
- * @return string The template filename if one is located.
- */
- function locate_template($template_names, $load = false, $require_once = true, $args = array() ) {
- $located = '';
- foreach ( (array) $template_names as $template_name ) {
- if ( !$template_name )
- continue;
- if ( file_exists(STYLESHEETPATH . '/' . $template_name)) {
- $located = STYLESHEETPATH . '/' . $template_name;
- break;
- } else if ( file_exists(TEMPLATEPATH . '/' . $template_name) ) {
- $located = TEMPLATEPATH . '/' . $template_name;
- break;
- }
- }
- if ( $load && '' != $located )
- load_template( $located, $require_once, $args );
- return $located;
- }
- /**
- * Require the template file with WordPress environment.
- *
- * The globals are set up for the template file to ensure that the WordPress
- * environment is available from within the function. The query variables are
- * also available.
- *
- * @since 1.5.0
- *
- * @param string $_template_file Path to template file.
- * @param bool $require_once Whether to require_once or require. Default true.
- */
- function load_template( $_template_file, $require_once = true, $args = array() ) {
- global $posts, $post, $wp_did_header, $wp_query, $wp_rewrite, $wpdb, $wp_version, $wp, $id, $comment, $user_ID;
- if ( is_array( $wp_query->query_vars ) )
- extract( $wp_query->query_vars, EXTR_SKIP );
- if ( is_array( $args ) )
- extract( $args );
- echo $foo;
- if ( $require_once )
- require_once( $_template_file );
- else
- require( $_template_file );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement