Ticket #17662: validate-body-class-vars.diff
| File validate-body-class-vars.diff, 3.0 KB (added by , 13 years ago) |
|---|
-
wp-includes/post-template.php
428 428 $post = $wp_query->get_queried_object(); 429 429 430 430 $classes[] = 'single'; 431 $classes[] = 'single-' . sanitize_html_class($post->post_type, $post_id); 432 $classes[] = 'postid-' . $post_id; 431 if ( isset( $post->post_type ) ) { 432 $classes[] = 'single-' . sanitize_html_class($post->post_type, $post_id); 433 $classes[] = 'postid-' . $post_id; 433 434 434 // Post Format435 if ( post_type_supports( $post->post_type, 'post-formats' ) ) {436 $post_format = get_post_format( $post->ID );435 // Post Format 436 if ( post_type_supports( $post->post_type, 'post-formats' ) ) { 437 $post_format = get_post_format( $post->ID ); 437 438 438 if ( $post_format && !is_wp_error($post_format) ) 439 $classes[] = 'single-format-' . sanitize_html_class( $post_format ); 440 else 441 $classes[] = 'single-format-standard'; 439 if ( $post_format && !is_wp_error($post_format) ) 440 $classes[] = 'single-format-' . sanitize_html_class( $post_format ); 441 else 442 $classes[] = 'single-format-standard'; 443 } 442 444 } 443 445 444 446 if ( is_attachment() ) { … … 454 456 } else if ( is_author() ) { 455 457 $author = $wp_query->get_queried_object(); 456 458 $classes[] = 'author'; 457 $classes[] = 'author-' . sanitize_html_class( $author->user_nicename , $author->ID ); 458 $classes[] = 'author-' . $author->ID; 459 if ( isset( $author->user_nicename ) ) { 460 $classes[] = 'author-' . sanitize_html_class( $author->user_nicename, $author->ID ); 461 $classes[] = 'author-' . $author->ID; 462 } 459 463 } elseif ( is_category() ) { 460 464 $cat = $wp_query->get_queried_object(); 461 465 $classes[] = 'category'; 462 $classes[] = 'category-' . sanitize_html_class( $cat->slug, $cat->term_id ); 463 $classes[] = 'category-' . $cat->term_id; 466 if ( isset( $cat->term_id ) ) { 467 $classes[] = 'category-' . sanitize_html_class( $cat->slug, $cat->term_id ); 468 $classes[] = 'category-' . $cat->term_id; 469 } 464 470 } elseif ( is_tag() ) { 465 471 $tags = $wp_query->get_queried_object(); 466 472 $classes[] = 'tag'; 467 $classes[] = 'tag-' . sanitize_html_class( $tags->slug, $tags->term_id ); 468 $classes[] = 'tag-' . $tags->term_id; 473 if ( isset( $tags->term_id ) ) { 474 $classes[] = 'tag-' . sanitize_html_class( $tags->slug, $tags->term_id ); 475 $classes[] = 'tag-' . $tags->term_id; 476 } 469 477 } elseif ( is_tax() ) { 470 478 $term = $wp_query->get_queried_object(); 471 $classes[] = 'tax-' . sanitize_html_class( $term->taxonomy ); 472 $classes[] = 'term-' . sanitize_html_class( $term->slug, $term->term_id ); 473 $classes[] = 'term-' . $term->term_id; 479 if ( isset( $term->term_id ) ) { 480 $classes[] = 'tax-' . sanitize_html_class( $term->taxonomy ); 481 $classes[] = 'term-' . sanitize_html_class( $term->slug, $term->term_id ); 482 $classes[] = 'term-' . $term->term_id; 483 } 474 484 } 475 485 } elseif ( is_page() ) { 476 486 $classes[] = 'page';