Add sanity checks to get_*_template()
functions to ensure that the return value of get_queried_object()
is compatible with the assumed context.
Fixes #25291. See #25282. git-svn-id: https://develop.svn.wordpress.org/trunk@25386 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
66aa532da5
commit
c5c88eb85b
@ -83,7 +83,7 @@ function get_post_type_archive_template() {
|
||||
$post_type = get_query_var( 'post_type' );
|
||||
if ( is_array( $post_type ) )
|
||||
$post_type = reset( $post_type );
|
||||
|
||||
|
||||
$obj = get_post_type_object( $post_type );
|
||||
if ( ! $obj->has_archive )
|
||||
return '';
|
||||
@ -103,7 +103,7 @@ function get_author_template() {
|
||||
|
||||
$templates = array();
|
||||
|
||||
if ( $author ) {
|
||||
if ( is_a( $author, 'WP_User' ) ) {
|
||||
$templates[] = "author-{$author->user_nicename}.php";
|
||||
$templates[] = "author-{$author->ID}.php";
|
||||
}
|
||||
@ -129,7 +129,7 @@ function get_category_template() {
|
||||
|
||||
$templates = array();
|
||||
|
||||
if ( $category ) {
|
||||
if ( ! empty( $category->slug ) ) {
|
||||
$templates[] = "category-{$category->slug}.php";
|
||||
$templates[] = "category-{$category->term_id}.php";
|
||||
}
|
||||
@ -155,7 +155,7 @@ function get_tag_template() {
|
||||
|
||||
$templates = array();
|
||||
|
||||
if ( $tag ) {
|
||||
if ( ! empty( $tag->slug ) ) {
|
||||
$templates[] = "tag-{$tag->slug}.php";
|
||||
$templates[] = "tag-{$tag->term_id}.php";
|
||||
}
|
||||
@ -186,7 +186,7 @@ function get_taxonomy_template() {
|
||||
|
||||
$templates = array();
|
||||
|
||||
if ( $term ) {
|
||||
if ( ! empty( $term->slug ) ) {
|
||||
$taxonomy = $term->taxonomy;
|
||||
$templates[] = "taxonomy-$taxonomy-{$term->slug}.php";
|
||||
$templates[] = "taxonomy-$taxonomy.php";
|
||||
@ -310,7 +310,7 @@ function get_single_template() {
|
||||
|
||||
$templates = array();
|
||||
|
||||
if ( $object )
|
||||
if ( ! empty( $object->post_type ) )
|
||||
$templates[] = "single-{$object->post_type}.php";
|
||||
$templates[] = "single.php";
|
||||
|
||||
@ -341,10 +341,12 @@ function get_attachment_template() {
|
||||
if ( ! empty( $type ) ) {
|
||||
if ( $template = get_query_template( $type[0] ) )
|
||||
return $template;
|
||||
elseif ( $template = get_query_template( $type[1] ) )
|
||||
return $template;
|
||||
elseif ( $template = get_query_template( "$type[0]_$type[1]" ) )
|
||||
return $template;
|
||||
elseif ( ! empty( $type[1] ) ) {
|
||||
if ( $template = get_query_template( $type[1] ) )
|
||||
return $template;
|
||||
elseif ( $template = get_query_template( "$type[0]_$type[1]" ) )
|
||||
return $template;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user