Changes in trunk/wp-includes/post-template.php [17292:15264]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/post-template.php
r17292 r15264 13 13 * 14 14 * @since 0.71 15 * @uses $id 15 16 */ 16 17 function the_ID() { 17 echo get_the_ID(); 18 global $id; 19 echo $id; 18 20 } 19 21 … … 22 24 * 23 25 * @since 2.1.0 24 * @uses $ post25 * 26 * @return int26 * @uses $id 27 * 28 * @return unknown 27 29 */ 28 30 function get_the_ID() { 29 global $ post;30 return $ post->ID;31 global $id; 32 return $id; 31 33 } 32 34 … … 180 182 */ 181 183 function get_the_content($more_link_text = null, $stripteaser = 0) { 182 global $ post, $more, $page, $pages, $multipage, $preview;184 global $id, $post, $more, $page, $pages, $multipage, $preview; 183 185 184 186 if ( null === $more_link_text ) … … 215 217 if ( count($content) > 1 ) { 216 218 if ( $more ) { 217 $output .= '<span id="more-' . $ post->ID. '"></span>' . $content[1];219 $output .= '<span id="more-' . $id . '"></span>' . $content[1]; 218 220 } else { 219 221 if ( ! empty($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 );222 $output .= apply_filters( 'the_content_more_link', ' <a href="' . get_permalink() . "#more-$id\" class=\"more-link\">$more_link_text</a>", $more_link_text ); 221 223 $output = force_balance_tags($output); 222 224 } … … 224 226 } 225 227 if ( $preview ) // preview fix for javascript bug with foreign languages 226 $output = preg_replace_callback('/\%u([0-9A-F]{4})/', '_convert_urlencoded_to_entities', $output);228 $output = preg_replace_callback('/\%u([0-9A-F]{4})/', create_function('$match', 'return "&#" . base_convert($match[1], 16, 10) . ";";'), $output); 227 229 228 230 return $output; 229 }230 231 /**232 * Preview fix for javascript bug with foreign languages233 *234 * @since 3.1.0235 * @access private236 * @param array $match Match array from preg_replace_callback237 * @returns string238 */239 function _convert_urlencoded_to_entities( $match ) {240 return '&#' . base_convert( $match[1], 16, 10 ) . ';';241 231 } 242 232 … … 327 317 $classes[] = $post->post_type; 328 318 $classes[] = 'type-' . $post->post_type; 329 $classes[] = 'status-' . $post->post_status;330 331 // Post Format332 $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 else338 $classes[] = 'format-standard';339 }340 341 // post requires password342 if ( post_password_required($post->ID) )343 $classes[] = 'post-password-required';344 319 345 320 // sticky for Sticky Posts … … 347 322 $classes[] = 'sticky'; 348 323 349 // hentry for hAtom complia nce324 // hentry for hAtom compliace 350 325 $classes[] = 'hentry'; 351 326 352 327 // Categories 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 } 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); 359 332 } 360 333 361 334 // Tags 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 } 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); 368 339 } 369 340 … … 432 403 $classes[] = 'postid-' . $post_id; 433 404 434 // Post Format435 $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 else440 $classes[] = 'single-format-standard';441 442 405 if ( is_attachment() ) { 443 406 $mime_type = get_post_mime_type($post_id); … … 447 410 } 448 411 } elseif ( is_archive() ) { 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() ) { 412 if ( is_author() ) { 453 413 $author = $wp_query->get_queried_object(); 454 414 $classes[] = 'author'; 455 415 $classes[] = 'author-' . sanitize_html_class( $author->user_nicename , $author->ID ); 456 $classes[] = 'author-' . $author->ID;457 416 } elseif ( is_category() ) { 458 417 $cat = $wp_query->get_queried_object(); 459 418 $classes[] = 'category'; 460 $classes[] = 'category-' . sanitize_html_class( $cat->slug, $cat->term_id ); 461 $classes[] = 'category-' . $cat->term_id; 419 $classes[] = 'category-' . sanitize_html_class( $cat->slug, $cat->cat_ID ); 462 420 } elseif ( is_tag() ) { 463 421 $tags = $wp_query->get_queried_object(); 464 422 $classes[] = 'tag'; 465 423 $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;472 424 } 473 425 } elseif ( is_page() ) { … … 500 452 if ( is_user_logged_in() ) 501 453 $classes[] = 'logged-in'; 502 503 if ( is_admin_bar_showing() )504 $classes[] = 'admin-bar';505 454 506 455 $page = $wp_query->get( 'page' ); … … 526 475 elseif ( is_search() ) 527 476 $classes[] = 'search-paged-' . $page; 528 elseif ( is_post_type_archive() )529 $classes[] = 'post-type-paged-' . $page;530 477 } 531 478 … … 631 578 extract( $r, EXTR_SKIP ); 632 579 633 global $p age, $numpages, $multipage, $more, $pagenow;580 global $post, $page, $numpages, $multipage, $more, $pagenow; 634 581 635 582 $output = ''; … … 641 588 $output .= ' '; 642 589 if ( ($i != $page) || ((!$more) && ($page==1)) ) { 643 $output .= _wp_link_page($i); 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 644 601 } 645 $output .= $link_before . $j . $link_after; 602 $output .= $link_before; 603 $output .= $j; 604 $output .= $link_after; 646 605 if ( ($i != $page) || ((!$more) && ($page==1)) ) 647 606 $output .= '</a>'; … … 653 612 $i = $page - 1; 654 613 if ( $i && $more ) { 655 $output .= _wp_link_page($i); 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 } 656 624 $output .= $link_before. $previouspagelink . $link_after . '</a>'; 657 625 } 658 626 $i = $page + 1; 659 627 if ( $i <= $numpages && $more ) { 660 $output .= _wp_link_page($i); 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 } 661 638 $output .= $link_before. $nextpagelink . $link_after . '</a>'; 662 639 } … … 672 649 } 673 650 674 /**675 * Helper function for wp_link_pages().676 *677 * @since 3.1.0678 * @access private679 *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 else694 $url = trailingslashit(get_permalink()) . user_trailingslashit($i, 'single_paged');695 }696 697 return '<a href="' . esc_url( $url ) . '">';698 }699 651 700 652 // … … 733 685 foreach ( (array) $keys as $key ) { 734 686 $keyt = trim($key); 735 if ( '_' == $keyt [0])687 if ( '_' == $keyt{0} ) 736 688 continue; 737 689 $values = array_map('trim', get_post_custom_values($key)); … … 956 908 } 957 909 958 /**959 * Create HTML list of pages.960 *961 * @package WordPress962 * @since 2.1.0963 * @uses Walker964 */965 class Walker_Page extends Walker {966 /**967 * @see Walker::$tree_type968 * @since 2.1.0969 * @var string970 */971 var $tree_type = 'page';972 973 /**974 * @see Walker::$db_fields975 * @since 2.1.0976 * @todo Decouple this.977 * @var array978 */979 var $db_fields = array ('parent' => 'post_parent', 'id' => 'ID');980 981 /**982 * @see Walker::start_lvl()983 * @since 2.1.0984 *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.0996 *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.01008 *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 $args1014 */1015 function start_el(&$output, $page, $depth, $args, $current_page) {1016 if ( $depth )1017 $indent = str_repeat("\t", $depth);1018 else1019 $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 else1044 $time = $page->post_date;1045 1046 $output .= " " . mysql2date($date_format, $time);1047 }1048 }1049 1050 /**1051 * @see Walker::end_el()1052 * @since 2.1.01053 *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 WordPress1068 * @since 2.1.01069 * @uses Walker1070 */1071 class Walker_PageDropdown extends Walker {1072 /**1073 * @see Walker::$tree_type1074 * @since 2.1.01075 * @var string1076 */1077 var $tree_type = 'page';1078 1079 /**1080 * @see Walker::$db_fields1081 * @since 2.1.01082 * @todo Decouple this1083 * @var array1084 */1085 var $db_fields = array ('parent' => 'post_parent', 'id' => 'ID');1086 1087 /**1088 * @see Walker::start_el()1089 * @since 2.1.01090 *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 1110 910 // 1111 911 // Attachments
Note: See TracChangeset
for help on using the changeset viewer.