Make WordPress Core

Ticket #15337: 15337.patch

File 15337.patch, 1.1 KB (added by SergeyBiryukov, 12 years ago)
  • wp-includes/template.php

     
    313313 * @return string
    314314 */
    315315function get_attachment_template() {
    316         global $posts;
     316        $attachment = get_queried_object();
    317317
    318         if ( ! empty( $posts ) && isset( $posts[0]->post_mime_type ) ) {
    319                 $type = explode( '/', $posts[0]->post_mime_type );
     318        $templates = array();
    320319
     320        if ( $attachment ) {
     321                $type = explode( '/', $attachment->post_mime_type );
     322
    321323                if ( ! empty( $type ) ) {
    322                         if ( $template = get_query_template( $type[0] ) )
    323                                 return $template;
    324                         elseif ( $template = get_query_template( $type[1] ) )
    325                                 return $template;
    326                         elseif ( $template = get_query_template( "$type[0]_$type[1]" ) )
    327                                 return $template;
     324                        $templates[] = "{$type[0]}.php";
     325                        $templates[] = "{$type[1]}.php";
     326                        $templates[] = "{$type[0]}_{$type[1]}.php";
    328327                }
    329328        }
     329        $templates[] = 'attachment.php';
    330330
    331         return get_query_template( 'attachment' );
     331        return get_query_template( 'attachment', $templates );
    332332}
    333333
    334334/**