Make WordPress Core

Changeset 40031


Ignore:
Timestamp:
01/30/2017 07:31:25 PM (8 years ago)
Author:
boonebgorges
Message:

Avoid PHP notices in get_post_type_archive_template().

The function should fail more gracefully when called in the context
where get_query_var( 'post_type' ) doesn't represent an actual post
type.

Props technopolitica, dlh.
Fixes #38374.

File:
1 edited

Legend:

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

    r39884 r40031  
    136136
    137137    $obj = get_post_type_object( $post_type );
    138     if ( ! $obj->has_archive )
     138    if ( ! ( $obj instanceof WP_Post_Type ) || ! $obj->has_archive ) {
    139139        return '';
     140    }
    140141
    141142    return get_archive_template();
Note: See TracChangeset for help on using the changeset viewer.