In `get_attachment_template()`, pass an array of templates to `get_query_template( 'attachment', $templates )`, instead of bailing on the first found template.
Props willnorris, jfarthing84, SergeyBiryukov, DrewAPicture, wonderboymusic. Fixes #15337. Built from https://develop.svn.wordpress.org/trunk@32804 git-svn-id: http://core.svn.wordpress.org/trunk@32775 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
0cc29d8bb7
commit
a1bd091d65
|
@ -391,7 +391,7 @@ function get_single_template() {
|
||||||
* 'attachment.php' is checked and returned.
|
* 'attachment.php' is checked and returned.
|
||||||
*
|
*
|
||||||
* Some examples for the 'text/plain' mime type are 'text.php', 'plain.php', and
|
* Some examples for the 'text/plain' mime type are 'text.php', 'plain.php', and
|
||||||
* finally 'text_plain.php'.
|
* finally 'text-plain.php'.
|
||||||
*
|
*
|
||||||
* The template path is filterable via the 'attachment_template' hook.
|
* The template path is filterable via the 'attachment_template' hook.
|
||||||
*
|
*
|
||||||
|
@ -404,24 +404,26 @@ function get_single_template() {
|
||||||
* @return string Full path to attachment template file.
|
* @return string Full path to attachment template file.
|
||||||
*/
|
*/
|
||||||
function get_attachment_template() {
|
function get_attachment_template() {
|
||||||
global $posts;
|
$attachment = get_queried_object();
|
||||||
|
|
||||||
if ( ! empty( $posts ) && isset( $posts[0]->post_mime_type ) ) {
|
$templates = array();
|
||||||
$type = explode( '/', $posts[0]->post_mime_type );
|
|
||||||
|
|
||||||
if ( ! empty( $type ) ) {
|
if ( $attachment ) {
|
||||||
if ( $template = get_query_template( $type[0] ) )
|
if ( false !== strpos( $attachment->post_mime_type, '/' ) ) {
|
||||||
return $template;
|
list( $type, $subtype ) = explode( '/', $attachment->post_mime_type );
|
||||||
elseif ( ! empty( $type[1] ) ) {
|
} else {
|
||||||
if ( $template = get_query_template( $type[1] ) )
|
list( $type, $subtype ) = array( $attachment->post_mime_type, '' );
|
||||||
return $template;
|
|
||||||
elseif ( $template = get_query_template( "$type[0]_$type[1]" ) )
|
|
||||||
return $template;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return get_query_template( 'attachment' );
|
if ( ! empty( $subtype ) ) {
|
||||||
|
$templates[] = "{$type}-{$subtype}.php";
|
||||||
|
$templates[] = "{$subtype}.php";
|
||||||
|
}
|
||||||
|
$templates[] = "{$type}.php";
|
||||||
|
}
|
||||||
|
$templates[] = 'attachment.php';
|
||||||
|
|
||||||
|
return get_query_template( 'attachment', $templates );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.3-alpha-32803';
|
$wp_version = '4.3-alpha-32804';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue