Make WordPress Core


Ignore:
Timestamp:
02/08/2010 10:05:05 PM (13 years ago)
Author:
ryan
Message:

Look for single-.php templates. Add single- class to get_body_class(). Props ptahdunbar. see #12105

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/post-template.php

    r13025 r13032  
    393393
    394394    if ( is_single() ) {
    395         $postID = $wp_query->get_queried_object_id();
    396 
    397         $classes[] = 'single postid-' . $postID;
     395        $post_id = $wp_query->get_queried_object_id();
     396        $post = $wp_query->get_queried_object();
     397
     398        $classes[] = 'single';
     399        $classes[] = 'single-' . sanitize_html_class($post->post_type, $post_id);
     400        $classes[] = 'postid-' . $post_id;
    398401
    399402        if ( is_attachment() ) {
    400             $mime_type = get_post_mime_type($postID);
     403            $mime_type = get_post_mime_type($post_id);
    401404            $mime_prefix = array( 'application/', 'image/', 'text/', 'audio/', 'video/', 'music/' );
    402             $classes[] = 'attachmentid-' . $postID;
     405            $classes[] = 'attachmentid-' . $post_id;
    403406            $classes[] = 'attachment-' . str_replace($mime_prefix, '', $mime_type);
    404407        }
     
    420423        $classes[] = 'page';
    421424
    422         $pageID = $wp_query->get_queried_object_id();
    423 
    424         $post = get_page($pageID);
    425 
    426         $classes[] = 'page-id-' . $pageID;
    427 
    428         if ( $wpdb->get_var( $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' AND post_status = 'publish' LIMIT 1", $pageID) ) )
     425        $page_id = $wp_query->get_queried_object_id();
     426
     427        $post = get_page($page_id);
     428
     429        $classes[] = 'page-id-' . $page_id;
     430
     431        if ( $wpdb->get_var( $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' AND post_status = 'publish' LIMIT 1", $page_id) ) )
    429432            $classes[] = 'page-parent';
    430433
     
    435438        if ( is_page_template() ) {
    436439            $classes[] = 'page-template';
    437             $classes[] = 'page-template-' . sanitize_html_class( str_replace( '.', '-', get_post_meta( $pageID, '_wp_page_template', true ) ), '' );
     440            $classes[] = 'page-template-' . sanitize_html_class( str_replace( '.', '-', get_post_meta( $page_id, '_wp_page_template', true ) ), '' );
    438441        }
    439442    } elseif ( is_search() ) {
Note: See TracChangeset for help on using the changeset viewer.