WordPress.org

Make WordPress Core

Changeset 24191


Ignore:
Timestamp:
05/07/13 18:44:22 (12 months ago)
Author:
SergeyBiryukov
Message:

Avoid a PHP notice in get_page_template_slug() if the page does not exist. props tollmanz. fixes #24250.

File:
1 edited

Legend:

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

    r24175 r24191  
    12761276 * @since 3.4.0 
    12771277 * 
    1278  * @param int $post_id The page ID to check. Defaults to the current post, when used in the loop. 
     1278 * @param int $post_id Optional. The page ID to check. Defaults to the current post, when used in the loop. 
    12791279 * @return string|bool Page template filename. Returns an empty string when the default page template 
    12801280 *  is in use. Returns false if the post is not a page. 
     
    12821282function get_page_template_slug( $post_id = null ) { 
    12831283    $post = get_post( $post_id ); 
    1284     if ( 'page' != $post->post_type ) 
     1284    if ( ! $post || 'page' != $post->post_type ) 
    12851285        return false; 
    12861286    $template = get_post_meta( $post->ID, '_wp_page_template', true ); 
Note: See TracChangeset for help on using the changeset viewer.