Ticket #15337: 15337.4.patch
File 15337.4.patch, 1.7 KB (added by , 11 years ago) |
---|
-
src/wp-includes/template.php
391 391 * 'attachment.php' is checked and returned. 392 392 * 393 393 * Some examples for the 'text/plain' mime type are 'text.php', 'plain.php', and 394 * finally 'text _plain.php'.394 * finally 'text-plain.php'. 395 395 * 396 396 * The template path is filterable via the 'attachment_template' hook. 397 397 * … … 402 402 * @return string Full path to attachment template file. 403 403 */ 404 404 function get_attachment_template() { 405 global $posts;405 $attachment = get_queried_object(); 406 406 407 if ( ! empty( $posts ) && isset( $posts[0]->post_mime_type ) ) { 408 $type = explode( '/', $posts[0]->post_mime_type ); 407 $templates = array(); 409 408 410 if ( ! empty( $type ) ) { 411 if ( $template = get_query_template( $type[0] ) ) 412 return $template; 413 elseif ( ! empty( $type[1] ) ) { 414 if ( $template = get_query_template( $type[1] ) ) 415 return $template; 416 elseif ( $template = get_query_template( "$type[0]_$type[1]" ) ) 417 return $template; 418 } 409 if ( $attachment ) { 410 if ( false !== strpos( $attachment->post_mime_type, '/' ) ) { 411 list( $type, $subtype ) = explode( '/', $attachment->post_mime_type ); 412 } else { 413 list( $type, $subtype ) = array( $attachment->post_mime_type, '' ); 419 414 } 415 416 if ( ! empty( $subtype ) ) { 417 $templates[] = "{$type}-{$subtype}.php"; 418 $templates[] = "{$subtype}.php"; 419 } else { 420 $templates[] = "{$type}.php"; 421 } 420 422 } 423 $templates[] = 'attachment.php'; 421 424 422 return get_query_template( 'attachment' );425 return get_query_template( 'attachment', $templates ); 423 426 } 424 427 425 428 /**