Ticket #11331: 11331.b.diff
| File 11331.b.diff, 3.5 KB (added by , 16 years ago) |
|---|
-
wp-includes/post-template.php
371 371 372 372 $classes = array(); 373 373 374 if ( 'rtl' == get_bloginfo( 'text_direction') )374 if ( 'rtl' == get_bloginfo( 'text_direction' ) ) 375 375 $classes[] = 'rtl'; 376 376 377 377 if ( is_front_page() ) … … 393 393 394 394 if ( is_single() ) { 395 395 $wp_query->post = $wp_query->posts[0]; 396 setup_postdata( $wp_query->post);396 setup_postdata( $wp_query->post ); 397 397 398 398 $postID = $wp_query->post->ID; 399 399 $classes[] = 'single postid-' . $postID; … … 402 402 $mime_type = get_post_mime_type(); 403 403 $mime_prefix = array( 'application/', 'image/', 'text/', 'audio/', 'video/', 'music/' ); 404 404 $classes[] = 'attachmentid-' . $postID; 405 $classes[] = 'attachment-' . str_replace( $mime_prefix, '', $mime_type);405 $classes[] = 'attachment-' . str_replace( $mime_prefix, '', $mime_type ); 406 406 } 407 407 } elseif ( is_archive() ) { 408 408 if ( is_author() ) { 409 409 $author = $wp_query->get_queried_object(); 410 410 $classes[] = 'author'; 411 $classes[] = 'author-' . sanitize_html_class( $author->user_nicename , $author->ID);411 $classes[] = 'author-' . sanitize_html_class( $author->user_nicename , $author->ID ); 412 412 } elseif ( is_category() ) { 413 413 $cat = $wp_query->get_queried_object(); 414 414 $classes[] = 'category'; 415 $classes[] = 'category-' . sanitize_html_class( $cat->slug, $cat->cat_ID);415 $classes[] = 'category-' . sanitize_html_class( $cat->slug, $cat->cat_ID ); 416 416 } elseif ( is_tag() ) { 417 417 $tags = $wp_query->get_queried_object(); 418 418 $classes[] = 'tag'; 419 $classes[] = 'tag-' . sanitize_html_class( $tags->slug, $tags->term_id);419 $classes[] = 'tag-' . sanitize_html_class( $tags->slug, $tags->term_id ); 420 420 } 421 421 } elseif ( is_page() ) { 422 422 $classes[] = 'page'; 423 423 424 424 $wp_query->post = $wp_query->posts[0]; 425 setup_postdata( $wp_query->post);425 setup_postdata( $wp_query->post ); 426 426 427 427 $pageID = $wp_query->post->ID; 428 428 429 429 $classes[] = 'page-id-' . $pageID; 430 $classes[] = 'page-slug-' . sanitize_html_class( $wp_query->post->post_name, '' ); 430 431 431 432 if ( $wpdb->get_var( $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' LIMIT 1", $pageID) ) ) 432 433 $classes[] = 'page-parent'; … … 440 441 $classes[] = 'page-template-' . sanitize_html_class( str_replace( '.', '-', get_post_meta( $pageID, '_wp_page_template', true ) ), '' ); 441 442 } 442 443 } elseif ( is_search() ) { 443 if ( !empty( $wp_query->posts) )444 if ( !empty( $wp_query->posts ) ) 444 445 $classes[] = 'search-results'; 445 446 else 446 447 $classes[] = 'search-no-results'; … … 449 450 if ( is_user_logged_in() ) 450 451 $classes[] = 'logged-in'; 451 452 452 $page = $wp_query->get( 'page');453 $page = $wp_query->get( 'page' ); 453 454 454 455 if ( !$page || $page < 2) 455 $page = $wp_query->get( 'paged');456 $page = $wp_query->get( 'paged' ); 456 457 457 458 if ( $page && $page > 1 ) { 458 459 $classes[] = 'paged-' . $page; … … 473 474 $classes[] = 'search-paged-' . $page; 474 475 } 475 476 476 if ( !empty( $class) ) {477 if ( !empty( $class ) ) { 477 478 if ( !is_array( $class ) ) 478 $class = preg_split( '#\s+#', $class);479 $classes = array_merge( $classes, $class);479 $class = preg_split( '#\s+#', $class ); 480 $classes = array_merge( $classes, $class ); 480 481 } 481 482 482 $classes = array_map( 'esc_attr', $classes);483 $classes = array_map( 'esc_attr', $classes ); 483 484 484 return apply_filters( 'body_class', $classes, $class);485 return apply_filters( 'body_class', $classes, $class ); 485 486 } 486 487 487 488 /**