Changes in trunk/wp-includes/post-template.php [15264:17292]
- File:
-
- 1 edited
-
trunk/wp-includes/post-template.php (modified) (17 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/post-template.php
r15264 r17292 13 13 * 14 14 * @since 0.71 15 * @uses $id16 15 */ 17 16 function the_ID() { 18 global $id; 19 echo $id; 17 echo get_the_ID(); 20 18 } 21 19 … … 24 22 * 25 23 * @since 2.1.0 26 * @uses $ id27 * 28 * @return unknown24 * @uses $post 25 * 26 * @return int 29 27 */ 30 28 function get_the_ID() { 31 global $ id;32 return $ id;29 global $post; 30 return $post->ID; 33 31 } 34 32 … … 182 180 */ 183 181 function get_the_content($more_link_text = null, $stripteaser = 0) { 184 global $ id, $post, $more, $page, $pages, $multipage, $preview;182 global $post, $more, $page, $pages, $multipage, $preview; 185 183 186 184 if ( null === $more_link_text ) … … 217 215 if ( count($content) > 1 ) { 218 216 if ( $more ) { 219 $output .= '<span id="more-' . $ id. '"></span>' . $content[1];217 $output .= '<span id="more-' . $post->ID . '"></span>' . $content[1]; 220 218 } else { 221 219 if ( ! empty($more_link_text) ) 222 $output .= apply_filters( 'the_content_more_link', ' <a href="' . get_permalink() . "#more- $id\" class=\"more-link\">$more_link_text</a>", $more_link_text );220 $output .= apply_filters( 'the_content_more_link', ' <a href="' . get_permalink() . "#more-{$post->ID}\" class=\"more-link\">$more_link_text</a>", $more_link_text ); 223 221 $output = force_balance_tags($output); 224 222 } … … 226 224 } 227 225 if ( $preview ) // preview fix for javascript bug with foreign languages 228 $output = preg_replace_callback('/\%u([0-9A-F]{4})/', create_function('$match', 'return "&#" . base_convert($match[1], 16, 10) . ";";'), $output);226 $output = preg_replace_callback('/\%u([0-9A-F]{4})/', '_convert_urlencoded_to_entities', $output); 229 227 230 228 return $output; 229 } 230 231 /** 232 * Preview fix for javascript bug with foreign languages 233 * 234 * @since 3.1.0 235 * @access private 236 * @param array $match Match array from preg_replace_callback 237 * @returns string 238 */ 239 function _convert_urlencoded_to_entities( $match ) { 240 return '&#' . base_convert( $match[1], 16, 10 ) . ';'; 231 241 } 232 242 … … 317 327 $classes[] = $post->post_type; 318 328 $classes[] = 'type-' . $post->post_type; 329 $classes[] = 'status-' . $post->post_status; 330 331 // Post Format 332 $post_format = get_post_format( $post->ID ); 333 334 if ( post_type_supports( $post->post_type, 'post-formats' ) ) { 335 if ( $post_format && !is_wp_error($post_format) ) 336 $classes[] = 'format-' . sanitize_html_class( $post_format ); 337 else 338 $classes[] = 'format-standard'; 339 } 340 341 // post requires password 342 if ( post_password_required($post->ID) ) 343 $classes[] = 'post-password-required'; 319 344 320 345 // sticky for Sticky Posts … … 322 347 $classes[] = 'sticky'; 323 348 324 // hentry for hAtom complia ce349 // hentry for hAtom compliance 325 350 $classes[] = 'hentry'; 326 351 327 352 // Categories 328 foreach ( (array) get_the_category($post->ID) as $cat ) { 329 if ( empty($cat->slug ) ) 330 continue; 331 $classes[] = 'category-' . sanitize_html_class($cat->slug, $cat->cat_ID); 353 if ( is_object_in_taxonomy( $post->post_type, 'category' ) ) { 354 foreach ( (array) get_the_category($post->ID) as $cat ) { 355 if ( empty($cat->slug ) ) 356 continue; 357 $classes[] = 'category-' . sanitize_html_class($cat->slug, $cat->term_id); 358 } 332 359 } 333 360 334 361 // Tags 335 foreach ( (array) get_the_tags($post->ID) as $tag ) { 336 if ( empty($tag->slug ) ) 337 continue; 338 $classes[] = 'tag-' . sanitize_html_class($tag->slug, $tag->term_id); 362 if ( is_object_in_taxonomy( $post->post_type, 'post_tag' ) ) { 363 foreach ( (array) get_the_tags($post->ID) as $tag ) { 364 if ( empty($tag->slug ) ) 365 continue; 366 $classes[] = 'tag-' . sanitize_html_class($tag->slug, $tag->term_id); 367 } 339 368 } 340 369 … … 403 432 $classes[] = 'postid-' . $post_id; 404 433 434 // Post Format 435 $post_format = get_post_format( $post->ID ); 436 437 if ( $post_format && !is_wp_error($post_format) ) 438 $classes[] = 'single-format-' . sanitize_html_class( $post_format ); 439 else 440 $classes[] = 'single-format-standard'; 441 405 442 if ( is_attachment() ) { 406 443 $mime_type = get_post_mime_type($post_id); … … 410 447 } 411 448 } elseif ( is_archive() ) { 412 if ( is_author() ) { 449 if ( is_post_type_archive() ) { 450 $classes[] = 'post-type-archive'; 451 $classes[] = 'post-type-archive-' . sanitize_html_class( get_query_var( 'post_type' ) ); 452 } else if ( is_author() ) { 413 453 $author = $wp_query->get_queried_object(); 414 454 $classes[] = 'author'; 415 455 $classes[] = 'author-' . sanitize_html_class( $author->user_nicename , $author->ID ); 456 $classes[] = 'author-' . $author->ID; 416 457 } elseif ( is_category() ) { 417 458 $cat = $wp_query->get_queried_object(); 418 459 $classes[] = 'category'; 419 $classes[] = 'category-' . sanitize_html_class( $cat->slug, $cat->cat_ID ); 460 $classes[] = 'category-' . sanitize_html_class( $cat->slug, $cat->term_id ); 461 $classes[] = 'category-' . $cat->term_id; 420 462 } elseif ( is_tag() ) { 421 463 $tags = $wp_query->get_queried_object(); 422 464 $classes[] = 'tag'; 423 465 $classes[] = 'tag-' . sanitize_html_class( $tags->slug, $tags->term_id ); 466 $classes[] = 'tag-' . $tags->term_id; 467 } elseif ( is_tax() ) { 468 $term = $wp_query->get_queried_object(); 469 $classes[] = 'tax-' . sanitize_html_class( $term->taxonomy ); 470 $classes[] = 'term-' . sanitize_html_class( $term->slug, $term->term_id ); 471 $classes[] = 'term-' . $term->term_id; 424 472 } 425 473 } elseif ( is_page() ) { … … 452 500 if ( is_user_logged_in() ) 453 501 $classes[] = 'logged-in'; 502 503 if ( is_admin_bar_showing() ) 504 $classes[] = 'admin-bar'; 454 505 455 506 $page = $wp_query->get( 'page' ); … … 475 526 elseif ( is_search() ) 476 527 $classes[] = 'search-paged-' . $page; 528 elseif ( is_post_type_archive() ) 529 $classes[] = 'post-type-paged-' . $page; 477 530 } 478 531 … … 578 631 extract( $r, EXTR_SKIP ); 579 632 580 global $p ost, $page, $numpages, $multipage, $more, $pagenow;633 global $page, $numpages, $multipage, $more, $pagenow; 581 634 582 635 $output = ''; … … 588 641 $output .= ' '; 589 642 if ( ($i != $page) || ((!$more) && ($page==1)) ) { 590 if ( 1 == $i ) { 591 $output .= '<a href="' . get_permalink() . '">'; 592 } else { 593 if ( '' == get_option('permalink_structure') || in_array($post->post_status, array('draft', 'pending')) ) 594 $output .= '<a href="' . add_query_arg('page', $i, get_permalink()) . '">'; 595 elseif ( 'page' == get_option('show_on_front') && get_option('page_on_front') == $post->ID ) 596 $output .= '<a href="' . trailingslashit(get_permalink()) . user_trailingslashit('page/' . $i, 'single_paged'). '">'; 597 else 598 $output .= '<a href="' . trailingslashit(get_permalink()) . user_trailingslashit($i, 'single_paged') . '">'; 599 } 600 643 $output .= _wp_link_page($i); 601 644 } 602 $output .= $link_before; 603 $output .= $j; 604 $output .= $link_after; 645 $output .= $link_before . $j . $link_after; 605 646 if ( ($i != $page) || ((!$more) && ($page==1)) ) 606 647 $output .= '</a>'; … … 612 653 $i = $page - 1; 613 654 if ( $i && $more ) { 614 if ( 1 == $i ) { 615 $output .= '<a href="' . get_permalink() . '">'; 616 } else { 617 if ( '' == get_option('permalink_structure') || in_array($post->post_status, array('draft', 'pending')) ) 618 $output .= '<a href="' . add_query_arg('page', $i, get_permalink()) . '">'; 619 elseif ( 'page' == get_option('show_on_front') && get_option('page_on_front') == $post->ID ) 620 $output .= '<a href="' . trailingslashit(get_permalink()) . user_trailingslashit('page/' . $i, 'single_paged'). '">'; 621 else 622 $output .= '<a href="' . trailingslashit(get_permalink()) . user_trailingslashit($i, 'single_paged') . '">'; 623 } 655 $output .= _wp_link_page($i); 624 656 $output .= $link_before. $previouspagelink . $link_after . '</a>'; 625 657 } 626 658 $i = $page + 1; 627 659 if ( $i <= $numpages && $more ) { 628 if ( 1 == $i ) { 629 $output .= '<a href="' . get_permalink() . '">'; 630 } else { 631 if ( '' == get_option('permalink_structure') || in_array($post->post_status, array('draft', 'pending')) ) 632 $output .= '<a href="' . add_query_arg('page', $i, get_permalink()) . '">'; 633 elseif ( 'page' == get_option('show_on_front') && get_option('page_on_front') == $post->ID ) 634 $output .= '<a href="' . trailingslashit(get_permalink()) . user_trailingslashit('page/' . $i, 'single_paged'). '">'; 635 else 636 $output .= '<a href="' . trailingslashit(get_permalink()) . user_trailingslashit($i, 'single_paged') . '">'; 637 } 660 $output .= _wp_link_page($i); 638 661 $output .= $link_before. $nextpagelink . $link_after . '</a>'; 639 662 } … … 649 672 } 650 673 674 /** 675 * Helper function for wp_link_pages(). 676 * 677 * @since 3.1.0 678 * @access private 679 * 680 * @param int $i Page number. 681 * @return string Link. 682 */ 683 function _wp_link_page( $i ) { 684 global $post, $wp_rewrite; 685 686 if ( 1 == $i ) { 687 $url = get_permalink(); 688 } else { 689 if ( '' == get_option('permalink_structure') || in_array($post->post_status, array('draft', 'pending')) ) 690 $url = add_query_arg( 'page', $i, get_permalink() ); 691 elseif ( 'page' == get_option('show_on_front') && get_option('page_on_front') == $post->ID ) 692 $url = trailingslashit(get_permalink()) . user_trailingslashit("$wp_rewrite->pagination_base/" . $i, 'single_paged'); 693 else 694 $url = trailingslashit(get_permalink()) . user_trailingslashit($i, 'single_paged'); 695 } 696 697 return '<a href="' . esc_url( $url ) . '">'; 698 } 651 699 652 700 // … … 685 733 foreach ( (array) $keys as $key ) { 686 734 $keyt = trim($key); 687 if ( '_' == $keyt {0})735 if ( '_' == $keyt[0] ) 688 736 continue; 689 737 $values = array_map('trim', get_post_custom_values($key)); … … 908 956 } 909 957 958 /** 959 * Create HTML list of pages. 960 * 961 * @package WordPress 962 * @since 2.1.0 963 * @uses Walker 964 */ 965 class Walker_Page extends Walker { 966 /** 967 * @see Walker::$tree_type 968 * @since 2.1.0 969 * @var string 970 */ 971 var $tree_type = 'page'; 972 973 /** 974 * @see Walker::$db_fields 975 * @since 2.1.0 976 * @todo Decouple this. 977 * @var array 978 */ 979 var $db_fields = array ('parent' => 'post_parent', 'id' => 'ID'); 980 981 /** 982 * @see Walker::start_lvl() 983 * @since 2.1.0 984 * 985 * @param string $output Passed by reference. Used to append additional content. 986 * @param int $depth Depth of page. Used for padding. 987 */ 988 function start_lvl(&$output, $depth) { 989 $indent = str_repeat("\t", $depth); 990 $output .= "\n$indent<ul class='children'>\n"; 991 } 992 993 /** 994 * @see Walker::end_lvl() 995 * @since 2.1.0 996 * 997 * @param string $output Passed by reference. Used to append additional content. 998 * @param int $depth Depth of page. Used for padding. 999 */ 1000 function end_lvl(&$output, $depth) { 1001 $indent = str_repeat("\t", $depth); 1002 $output .= "$indent</ul>\n"; 1003 } 1004 1005 /** 1006 * @see Walker::start_el() 1007 * @since 2.1.0 1008 * 1009 * @param string $output Passed by reference. Used to append additional content. 1010 * @param object $page Page data object. 1011 * @param int $depth Depth of page. Used for padding. 1012 * @param int $current_page Page ID. 1013 * @param array $args 1014 */ 1015 function start_el(&$output, $page, $depth, $args, $current_page) { 1016 if ( $depth ) 1017 $indent = str_repeat("\t", $depth); 1018 else 1019 $indent = ''; 1020 1021 extract($args, EXTR_SKIP); 1022 $css_class = array('page_item', 'page-item-'.$page->ID); 1023 if ( !empty($current_page) ) { 1024 $_current_page = get_page( $current_page ); 1025 _get_post_ancestors($_current_page); 1026 if ( isset($_current_page->ancestors) && in_array($page->ID, (array) $_current_page->ancestors) ) 1027 $css_class[] = 'current_page_ancestor'; 1028 if ( $page->ID == $current_page ) 1029 $css_class[] = 'current_page_item'; 1030 elseif ( $_current_page && $page->ID == $_current_page->post_parent ) 1031 $css_class[] = 'current_page_parent'; 1032 } elseif ( $page->ID == get_option('page_for_posts') ) { 1033 $css_class[] = 'current_page_parent'; 1034 } 1035 1036 $css_class = implode(' ', apply_filters('page_css_class', $css_class, $page)); 1037 1038 $output .= $indent . '<li class="' . $css_class . '"><a href="' . get_permalink($page->ID) . '" title="' . esc_attr( wp_strip_all_tags( apply_filters( 'the_title', $page->post_title, $page->ID ) ) ) . '">' . $link_before . apply_filters( 'the_title', $page->post_title, $page->ID ) . $link_after . '</a>'; 1039 1040 if ( !empty($show_date) ) { 1041 if ( 'modified' == $show_date ) 1042 $time = $page->post_modified; 1043 else 1044 $time = $page->post_date; 1045 1046 $output .= " " . mysql2date($date_format, $time); 1047 } 1048 } 1049 1050 /** 1051 * @see Walker::end_el() 1052 * @since 2.1.0 1053 * 1054 * @param string $output Passed by reference. Used to append additional content. 1055 * @param object $page Page data object. Not used. 1056 * @param int $depth Depth of page. Not Used. 1057 */ 1058 function end_el(&$output, $page, $depth) { 1059 $output .= "</li>\n"; 1060 } 1061 1062 } 1063 1064 /** 1065 * Create HTML dropdown list of pages. 1066 * 1067 * @package WordPress 1068 * @since 2.1.0 1069 * @uses Walker 1070 */ 1071 class Walker_PageDropdown extends Walker { 1072 /** 1073 * @see Walker::$tree_type 1074 * @since 2.1.0 1075 * @var string 1076 */ 1077 var $tree_type = 'page'; 1078 1079 /** 1080 * @see Walker::$db_fields 1081 * @since 2.1.0 1082 * @todo Decouple this 1083 * @var array 1084 */ 1085 var $db_fields = array ('parent' => 'post_parent', 'id' => 'ID'); 1086 1087 /** 1088 * @see Walker::start_el() 1089 * @since 2.1.0 1090 * 1091 * @param string $output Passed by reference. Used to append additional content. 1092 * @param object $page Page data object. 1093 * @param int $depth Depth of page in reference to parent pages. Used for padding. 1094 * @param array $args Uses 'selected' argument for selected page to set selected HTML attribute for option element. 1095 */ 1096 function start_el(&$output, $page, $depth, $args) { 1097 $pad = str_repeat(' ', $depth * 3); 1098 1099 $output .= "\t<option class=\"level-$depth\" value=\"$page->ID\""; 1100 if ( $page->ID == $args['selected'] ) 1101 $output .= ' selected="selected"'; 1102 $output .= '>'; 1103 $title = esc_html($page->post_title); 1104 $title = apply_filters( 'list_pages', $page->post_title ); 1105 $output .= "$pad$title"; 1106 $output .= "</option>\n"; 1107 } 1108 } 1109 910 1110 // 911 1111 // Attachments
Note: See TracChangeset
for help on using the changeset viewer.