WordPress.org

Make WordPress Core

Changeset 11306


Ignore:
Timestamp:
05/12/2009 05:11:57 PM (13 years ago)
Author:
ryan
Message:

Use IDs instead of slugs in CSS classes ro avoid invalid class names. Props hakre. fixes #8446

Location:
trunk/wp-includes
Files:
2 edited

Legend:

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

    r11249 r11306  
    295295        // For all registered users, 'byuser'
    296296        $classes[] = 'byuser';
    297         $classes[] = 'comment-author-' . $user->user_nicename;
     297        $classes[] = 'comment-author-' . $user->user_id;
    298298        // For comment authors who are the author of the post
    299299        if ( $post = get_post($post_id) ) {
  • trunk/wp-includes/post-template.php

    r11300 r11306  
    312312
    313313    $classes = array();
    314 
     314   
     315    $classes[] = 'post-' . $post->ID;
    315316    $classes[] = $post->post_type;
    316317
     
    324325    // Categories
    325326    foreach ( (array) get_the_category($post->ID) as $cat ) {
    326         if ( empty($cat->slug ) )
     327        if ( empty($cat->cat_ID ) )
    327328            continue;
    328         $classes[] = 'category-' . $cat->slug;
     329        $classes[] = 'category-' . $cat->cat_ID;
    329330    }
    330331
    331332    // Tags
    332333    foreach ( (array) get_the_tags($post->ID) as $tag ) {
    333         if ( empty($tag->slug ) )
     334        if ( empty($tag->term_id ) )
    334335            continue;
    335         $classes[] = 'tag-' . $tag->slug;
     336        $classes[] = 'tag-' . $tag->term_id;
    336337    }
    337338
     
    400401            $mime_type = get_post_mime_type();
    401402            $mime_prefix = array( 'application/', 'image/', 'text/', 'audio/', 'video/', 'music/' );
    402             $classes[] = 'attachmentid-' . $postID . ' attachment-' . str_replace( $mime_prefix, "", "$mime_type" );
     403            $classes[] = 'attachmentid-' . $postID;
     404            $classes[] = 'attachment-' . str_replace($mime_prefix, '', $mime_type);
    403405        }
    404406    } elseif ( is_archive() ) {
     
    406408            $author = $wp_query->get_queried_object();
    407409            $classes[] = 'author';
    408             $classes[] = 'author-' . $author->user_nicename;
     410            $classes[] = 'author-' . $author->user_id;
    409411        } elseif ( is_category() ) {
    410412            $cat = $wp_query->get_queried_object();
    411413            $classes[] = 'category';
    412             $classes[] = 'category-' . $cat->slug;
     414            $classes[] = 'category-' . $cat->cat_ID;
    413415        } elseif ( is_tag() ) {
    414416            $tags = $wp_query->get_queried_object();
    415417            $classes[] = 'tag';
    416             $classes[] = 'tag-' . $tags->slug;
     418            $classes[] = 'tag-' . $tags->term_id;
    417419        }
    418420    } elseif ( is_page() ) {
     
    430432
    431433        if ( $wp_query->post->post_parent )
    432             $classes[] = 'page-child parent-pageid-' . $wp_query->post->post_parent;
     434            $classes[] = 'page-child';
     435            $classes[] = 'parent-pageid-' . $wp_query->post->post_parent;
    433436
    434437        if ( is_page_template() )
    435             $classes[] = 'page-template page-template-' . str_replace( '.php', '-php', get_post_meta( $pageID, '_wp_page_template', true ) );
     438            $classes[] = 'page-template';
     439            $classes[] = 'page-template-' . str_replace( '.php', '-php', get_post_meta( $pageID, '_wp_page_template', true ) );
    436440    } elseif ( is_search() ) {
    437441        if ( !empty($wp_query->posts) )
Note: See TracChangeset for help on using the changeset viewer.