mirror of
https://github.com/WordPress/WordPress.git
synced 2025-01-03 06:57:35 +01:00
Sanity checks in get_body_class() to ensure we are operating on the type of queried object that we expect. props wonderboymusic. fixes #17662.
git-svn-id: http://core.svn.wordpress.org/trunk@22451 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
f85592021d
commit
9beec00613
@ -429,6 +429,7 @@ function get_body_class( $class = '' ) {
|
||||
$post = $wp_query->get_queried_object();
|
||||
|
||||
$classes[] = 'single';
|
||||
if ( isset( $post->post_type ) ) {
|
||||
$classes[] = 'single-' . sanitize_html_class($post->post_type, $post_id);
|
||||
$classes[] = 'postid-' . $post_id;
|
||||
|
||||
@ -441,6 +442,7 @@ function get_body_class( $class = '' ) {
|
||||
else
|
||||
$classes[] = 'single-format-standard';
|
||||
}
|
||||
}
|
||||
|
||||
if ( is_attachment() ) {
|
||||
$mime_type = get_post_mime_type($post_id);
|
||||
@ -455,24 +457,32 @@ function get_body_class( $class = '' ) {
|
||||
} else if ( is_author() ) {
|
||||
$author = $wp_query->get_queried_object();
|
||||
$classes[] = 'author';
|
||||
if ( isset( $author->user_nicename ) ) {
|
||||
$classes[] = 'author-' . sanitize_html_class( $author->user_nicename, $author->ID );
|
||||
$classes[] = 'author-' . $author->ID;
|
||||
}
|
||||
} elseif ( is_category() ) {
|
||||
$cat = $wp_query->get_queried_object();
|
||||
$classes[] = 'category';
|
||||
if ( isset( $cat->term_id ) ) {
|
||||
$classes[] = 'category-' . sanitize_html_class( $cat->slug, $cat->term_id );
|
||||
$classes[] = 'category-' . $cat->term_id;
|
||||
}
|
||||
} elseif ( is_tag() ) {
|
||||
$tags = $wp_query->get_queried_object();
|
||||
$classes[] = 'tag';
|
||||
if ( isset( $tags->term_id ) ) {
|
||||
$classes[] = 'tag-' . sanitize_html_class( $tags->slug, $tags->term_id );
|
||||
$classes[] = 'tag-' . $tags->term_id;
|
||||
}
|
||||
} elseif ( is_tax() ) {
|
||||
$term = $wp_query->get_queried_object();
|
||||
if ( isset( $term->term_id ) ) {
|
||||
$classes[] = 'tax-' . sanitize_html_class( $term->taxonomy );
|
||||
$classes[] = 'term-' . sanitize_html_class( $term->slug, $term->term_id );
|
||||
$classes[] = 'term-' . $term->term_id;
|
||||
}
|
||||
}
|
||||
} elseif ( is_page() ) {
|
||||
$classes[] = 'page';
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user