Changeset 32804
- Timestamp:
- 06/16/2015 08:49:44 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/template.php
r32628 r32804 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. … … 405 405 */ 406 406 function get_attachment_template() { 407 global $posts; 408 409 if ( ! empty( $posts ) && isset( $posts[0]->post_mime_type ) ) { 410 $type = explode( '/', $posts[0]->post_mime_type ); 411 412 if ( ! empty( $type ) ) { 413 if ( $template = get_query_template( $type[0] ) ) 414 return $template; 415 elseif ( ! empty( $type[1] ) ) { 416 if ( $template = get_query_template( $type[1] ) ) 417 return $template; 418 elseif ( $template = get_query_template( "$type[0]_$type[1]" ) ) 419 return $template; 420 } 407 $attachment = get_queried_object(); 408 409 $templates = array(); 410 411 if ( $attachment ) { 412 if ( false !== strpos( $attachment->post_mime_type, '/' ) ) { 413 list( $type, $subtype ) = explode( '/', $attachment->post_mime_type ); 414 } else { 415 list( $type, $subtype ) = array( $attachment->post_mime_type, '' ); 421 416 } 422 } 423 424 return get_query_template( 'attachment' ); 417 418 if ( ! empty( $subtype ) ) { 419 $templates[] = "{$type}-{$subtype}.php"; 420 $templates[] = "{$subtype}.php"; 421 } 422 $templates[] = "{$type}.php"; 423 } 424 $templates[] = 'attachment.php'; 425 426 return get_query_template( 'attachment', $templates ); 425 427 } 426 428
Note: See TracChangeset
for help on using the changeset viewer.