Make WordPress Core


Ignore:
Timestamp:
03/02/2012 06:56:54 PM (13 years ago)
Author:
nacin
Message:

Introduce get_page_template_slug( $id = null ) to return a page's template (like "showcase.php"). Returns false if post ID is not a page, and an empty string for the default page template. Use the function across core. props billerickson for initial patch. fixes #18750.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/template.php

    r20002 r20075  
    226226function get_page_template() {
    227227    $id = get_queried_object_id();
    228     $template = get_post_meta($id, '_wp_page_template', true);
     228    $template = get_page_template_slug();
    229229    $pagename = get_query_var('pagename');
    230230
    231     if ( !$pagename && $id > 0 ) {
     231    if ( ! $pagename && $id ) {
    232232        // If a static page is set as the front page, $pagename will not be set. Retrieve it from the queried object
    233233        $post = get_queried_object();
     
    235235    }
    236236
    237     if ( 'default' == $template )
    238         $template = '';
    239 
    240     $templates = array();
    241     if ( !empty($template) && !validate_file($template) )
     237    $templates = array();
     238    if ( $template && 0 === validate_file( $template ) )
    242239        $templates[] = $template;
    243240    if ( $pagename )
Note: See TracChangeset for help on using the changeset viewer.