Changeset 13032
- Timestamp:
- 02/08/2010 10:05:05 PM (15 years ago)
- Location:
- trunk/wp-includes
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/post-template.php
r13025 r13032 393 393 394 394 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; 398 401 399 402 if ( is_attachment() ) { 400 $mime_type = get_post_mime_type($post ID);403 $mime_type = get_post_mime_type($post_id); 401 404 $mime_prefix = array( 'application/', 'image/', 'text/', 'audio/', 'video/', 'music/' ); 402 $classes[] = 'attachmentid-' . $post ID;405 $classes[] = 'attachmentid-' . $post_id; 403 406 $classes[] = 'attachment-' . str_replace($mime_prefix, '', $mime_type); 404 407 } … … 420 423 $classes[] = 'page'; 421 424 422 $page ID= $wp_query->get_queried_object_id();423 424 $post = get_page($page ID);425 426 $classes[] = 'page-id-' . $page ID;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", $page ID) ) )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) ) ) 429 432 $classes[] = 'page-parent'; 430 433 … … 435 438 if ( is_page_template() ) { 436 439 $classes[] = 'page-template'; 437 $classes[] = 'page-template-' . sanitize_html_class( str_replace( '.', '-', get_post_meta( $page ID, '_wp_page_template', true ) ), '' );440 $classes[] = 'page-template-' . sanitize_html_class( str_replace( '.', '-', get_post_meta( $page_id, '_wp_page_template', true ) ), '' ); 438 441 } 439 442 } elseif ( is_search() ) { -
trunk/wp-includes/query.php
r12995 r13032 2550 2550 */ 2551 2551 function get_queried_object() { 2552 if ( isset($this->queried_object)) {2552 if ( isset($this->queried_object) ) 2553 2553 return $this->queried_object; 2554 }2555 2554 2556 2555 $this->queried_object = NULL; 2557 2556 $this->queried_object_id = 0; 2558 2557 2559 if ( $this->is_category) {2558 if ( $this->is_category ) { 2560 2559 $cat = $this->get('cat'); 2561 2560 $category = &get_category($cat); … … 2564 2563 $this->queried_object = &$category; 2565 2564 $this->queried_object_id = (int) $cat; 2566 } else if ($this->is_tag) {2565 } elseif ( $this->is_tag ) { 2567 2566 $tag_id = $this->get('tag_id'); 2568 2567 $tag = &get_term($tag_id, 'post_tag'); … … 2571 2570 $this->queried_object = &$tag; 2572 2571 $this->queried_object_id = (int) $tag_id; 2573 } else if ($this->is_tax) {2572 } elseif ( $this->is_tax ) { 2574 2573 $tax = $this->get('taxonomy'); 2575 2574 $slug = $this->get('term'); … … 2580 2579 $this->queried_object = $term; 2581 2580 $this->queried_object_id = $term->term_id; 2582 } else if ($this->is_posts_page) {2581 } elseif ( $this->is_posts_page ) { 2583 2582 $this->queried_object = & get_page(get_option('page_for_posts')); 2584 2583 $this->queried_object_id = (int) $this->queried_object->ID; 2585 } else if ($this->is_single) {2584 } elseif ( $this->is_single ) { 2586 2585 $this->queried_object = $this->post; 2587 2586 $this->queried_object_id = (int) $this->post->ID; 2588 } else if ($this->is_page) {2587 } elseif ( $this->is_page ) { 2589 2588 $this->queried_object = $this->post; 2590 2589 $this->queried_object_id = (int) $this->post->ID; 2591 } else if ($this->is_author) {2590 } elseif ( $this->is_author ) { 2592 2591 $author_id = (int) $this->get('author'); 2593 2592 $author = get_userdata($author_id); -
trunk/wp-includes/theme.php
r13020 r13032 861 861 global $wp_query; 862 862 863 $id = (int) $wp_query-> post->ID;863 $id = (int) $wp_query->get_queried_object_id(); 864 864 $template = get_post_meta($id, '_wp_page_template', true); 865 865 $pagename = get_query_var('pagename'); … … 910 910 */ 911 911 function get_single_template() { 912 return get_query_template('single'); 912 global $wp_query; 913 914 $object = $wp_query->get_queried_object(); 915 $templates = array('single-' . $object->post_type . '.php', 'single.php'); 916 return apply_filters('single_template', locate_template($templates)); 913 917 } 914 918 … … 975 979 */ 976 980 function locate_template($template_names, $load = false) { 977 if ( !is_array($template_names))981 if ( !is_array($template_names) ) 978 982 return ''; 979 983 980 984 $located = ''; 981 foreach ($template_names as $template_name) {985 foreach ( $template_names as $template_name ) { 982 986 if ( file_exists(STYLESHEETPATH . '/' . $template_name)) { 983 987 $located = STYLESHEETPATH . '/' . $template_name; … … 989 993 } 990 994 991 if ( $load && '' != $located)995 if ( $load && '' != $located ) 992 996 load_template($located); 993 997
Note: See TracChangeset
for help on using the changeset viewer.