Ticket #9510: 9510-v2.patch
| File 9510-v2.patch, 20.2 KB (added by , 17 years ago) |
|---|
-
feed-atom.php
14 14 xmlns="http://www.w3.org/2005/Atom" 15 15 xmlns:thr="http://purl.org/syndication/thread/1.0" 16 16 xml:lang="<?php echo get_option('rss_language'); ?>" 17 xml:base="<?php bloginfo_rss(' home') ?>/wp-atom.php"17 xml:base="<?php bloginfo_rss('url') ?>/wp-atom.php" 18 18 <?php do_action('atom_ns'); ?> 19 19 > 20 20 <title type="text"><?php bloginfo_rss('name'); wp_title_rss(); ?></title> 21 <subtitle type="text"><?php bloginfo_rss("description") ?></subtitle> 22 23 <updated><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_lastpostmodified('GMT')); ?></updated> 21 <?php atom_header();?> 24 22 <?php the_generator( 'atom' ); ?> 25 26 <link rel="alternate" type="text/html" href="<?php bloginfo_rss('home') ?>" />27 <id><?php bloginfo('atom_url'); ?></id>28 <link rel="self" type="application/atom+xml" href="<?php self_link(); ?>" />29 30 23 <?php do_action('atom_head'); ?> 24 <updated><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_lastpostmodified('GMT')); ?></updated> 31 25 <?php while (have_posts()) : the_post(); ?> 32 26 <entry> 33 27 <author> … … 53 47 <thr:total><?php echo get_comments_number()?></thr:total> 54 48 </entry> 55 49 <?php endwhile ; ?> 56 </feed> 50 </feed> 51 No newline at end of file -
feed.php
558 558 559 559 return $feed; 560 560 } 561 562 function echo_atom_feed_id($feed_id) { 563 echo "<id>$feed_id</id>\n"; 564 } 565 function echo_atom_feed_subtitle($feed_subtitle) { 566 if(!empty($feed_subtitle)) { 567 echo '<subtitle type="text">'.$feed_subtitle.'</subtitle>'."\n"; 568 } 569 } 570 function echo_atom_feed_links($self_link,$alternate_link,$replies_link) { 571 echo '<link rel="self" type="application/atom+xml" href="'.$self_link.'" />'."\n".'<link rel="alternate" type="'.get_option('html_type').'" href="'.$alternate_link.'" />'."\n".'<link rel="replies" type="application/atom+xml" href="'.$replies_link.'" />'."\n"; 572 } 573 function atom_header() { 574 $feed_type="atom"; 575 if(is_category()) { 576 $cat_id=get_query_object_id(); 577 echo_atom_feed_id(get_category_feed_link($cat_id,$feed_type,true)); 578 echo_atom_feed_links(get_category_feed_link($cat_id,$feed_type),get_category_link($cat_id),get_category_comments_feed_link($cat_id,$feed_type)); 579 } 580 elseif(is_tag()) { 581 $tag_atom_id=get_query_object_id(); 582 echo_atom_feed_id(get_tag_feed_link($tag_id,$feed_type,true)); 583 echo_atom_feed_links(get_tag_feed_link($tag_id,$feed_type),get_tag_link($tag_id),get_tag_comments_feed_link($tag_id,$feed_type)); 584 } 585 elseif(is_author()) { 586 $author_id=get_query_object_id(); 587 echo_atom_feed_id(get_author_feed_link($author_id,$feed_type,true)); 588 echo_atom_feed_links(get_author_feed_link($author_id,$feed_type),get_author_posts_url($author_id),get_author_comments_feed_link($author_id,$feed_type)); 589 } 590 elseif(is_date()) { 591 $year=$month=$day=$hour=$minute=$second=$canonical_feed_link=$alternate_link=$comments_feed_link=null; 592 $year_string=get_query_var('year'); 593 $month_string=get_query_var('monthnum'); 594 $day_string=get_query_var('day'); 595 $hour_string=get_query_var('hour'); 596 $minute_string=get_query_var('minute'); 597 $second_string=get_query_var('second'); 598 $m=get_query_var('m'); 599 $week=get_query_var('w'); 600 if(!empty($week)) { 601 if(!empty($year_string)) { 602 $year=$year_string; 603 } 604 elseif(!empty($m)&&strlen($m)>=4) { 605 $year=substr($m,0,4); 606 } 607 $canonical_feed_link=get_week_feed_link($year,$week,$feed_type); 608 $alternate_link=get_week_link($year,$week); 609 $comments_feed_link=get_week_comments_feed_link($year,$week,$feed_type); 610 } 611 elseif(empty($m)) { 612 if(!empty($year_string)) { 613 $year=$year_string; 614 } 615 if(!empty($month_string)) { 616 $month=$month_string; 617 } 618 if(!empty($day_string)) { 619 $day=$day_string; 620 } 621 if(!empty($hour_string)) { 622 $hour=$hour_string; 623 } 624 if(!empty($minute_string)) { 625 $minute=$minute_string; 626 } 627 if(!empty($second_string)) { 628 $second=$second_string; 629 } 630 } 631 else { 632 $m_length=strlen($m); 633 switch($m_length) { 634 case 14: 635 $second=substr($m,12,2); 636 case 12: 637 $minute=substr($m,10,2); 638 case 10: 639 $hour=substr($m,8,2); 640 case 8: 641 $day=substr($m,6,2); 642 case 6: 643 $month=substr($m,4,2); 644 case 4: 645 $year=substr($m,0,4); 646 break; 647 default: 648 return false; 649 } 650 } 651 if($canonical_feed_link===null) { 652 $canonical_feed_link=get_archive_feed_link($year,$month,$day,$hour,$minute,$second,$feed_type); 653 } 654 if($alternate_link===null) { 655 $alternate_link=get_archive_link($year,$month,$day,$hour,$minute,$second); 656 } 657 if($comments_feed_link===null) { 658 $comments_feed_link=get_archive_comments_feed_link($year,$month,$day,$hour,$minute,$second,$feed_type); 659 } 660 echo_atom_feed_id($canonical_feed_link); 661 echo_atom_feed_links($canonical_feed_link,$alternate_link,$comments_feed_link); 662 } 663 else if(is_search()) { 664 $search_query=get_search_query(); 665 $canonical_feed_link=get_search_feed_link($search_query,$feed_type); 666 echo_atom_feed_id($canonical_feed_link); 667 echo_atom_feed_links($canonical_feed_link,get_search_link($search_query),get_search_comments_feed_link($search_query,$feed_type)); 668 } 669 else { 670 echo_atom_feed_subtitle(get_bloginfo_rss("description")); 671 echo_atom_feed_id(get_feed_link('atom',true)); 672 echo_atom_feed_links(get_bloginfo('atom_url'),user_trailingslashit(get_bloginfo_rss('url')),get_bloginfo_rss('comments_atom_url')); 673 } 674 } 675 No newline at end of file -
link-template.php
154 154 $permalink = user_trailingslashit($permalink, 'single'); 155 155 return apply_filters('post_link', $permalink, $post, $leavename); 156 156 } else { // if they're not using the fancy permalink option 157 $permalink = get_option('home') . '/?p=' . $post->ID;157 $permalink = trailingslashit(get_option('home')) . '?p=' . $post->ID; 158 158 return apply_filters('post_link', $permalink, $post, $leavename); 159 159 } 160 160 } … … 225 225 if ( '' != $pagestruct && ( ( isset($post->post_status) && 'draft' != $post->post_status ) || $sample ) ) { 226 226 $link = get_page_uri($id); 227 227 $link = ( $leavename ) ? $pagestruct : str_replace('%pagename%', $link, $pagestruct); 228 $link = get_option('home') . "/$link";228 $link = trailingslashit(get_option('home')) . "$link"; 229 229 $link = user_trailingslashit($link, 'page'); 230 230 } else { 231 $link = get_option('home') . "/?page_id=$id";231 $link = trailingslashit(get_option('home')) . "?page_id=$id"; 232 232 } 233 233 234 234 return apply_filters( '_get_page_link', $link, $id ); … … 269 269 } 270 270 271 271 if (! $link ) { 272 $link = get_bloginfo('url') . "/?attachment_id=$id";272 $link = trailingslashit(get_bloginfo('url')) . "?attachment_id=$id"; 273 273 } 274 274 275 275 return apply_filters('attachment_link', $link, $id); … … 292 292 $yearlink = str_replace('%year%', $year, $yearlink); 293 293 return apply_filters('year_link', get_option('home') . user_trailingslashit($yearlink, 'year'), $year); 294 294 } else { 295 return apply_filters('year_link', get_option('home') . '/?m=' . $year, $year);295 return apply_filters('year_link', trailingslashit(get_option('home')) . '?m=' . $year, $year); 296 296 } 297 297 } 298 298 … … 317 317 $monthlink = str_replace('%monthnum%', zeroise(intval($month), 2), $monthlink); 318 318 return apply_filters('month_link', get_option('home') . user_trailingslashit($monthlink, 'month'), $year, $month); 319 319 } else { 320 return apply_filters('month_link', get_option('home') . '/?m=' . $year . zeroise($month, 2), $year, $month);320 return apply_filters('month_link', trailingslashit(get_option('home')) . '?m=' . $year . zeroise($month, 2), $year, $month); 321 321 } 322 322 } 323 323 … … 347 347 $daylink = str_replace('%day%', zeroise(intval($day), 2), $daylink); 348 348 return apply_filters('day_link', get_option('home') . user_trailingslashit($daylink, 'day'), $year, $month, $day); 349 349 } else { 350 return apply_filters('day_link', get_option('home') . '/?m=' . $year . zeroise($month, 2) . zeroise($day, 2), $year, $month, $day);350 return apply_filters('day_link', trailingslashit(get_option('home')) . '?m=' . $year . zeroise($month, 2) . zeroise($day, 2), $year, $month, $day); 351 351 } 352 352 } 353 353 … … 359 359 * @param string $feed Optional, defaults to default feed. Feed type. 360 360 * @return string 361 361 */ 362 function get_feed_link($feed = '' ) {362 function get_feed_link($feed = '', $return_canonical_form=false) { 363 363 global $wp_rewrite; 364 364 365 365 $permalink = $wp_rewrite->get_feed_permastruct(); 366 if ( '' != $permalink ) { 366 if ($return_canonical_form==true||empty($permalink)) { 367 if ( empty($feed) ) 368 $feed = get_default_feed(); 369 370 if ( false !== strpos($feed, 'comments_') ) 371 $feed = str_replace('comments_', 'comments-', $feed); 372 373 $output = trailingslashit(get_option('home')) . "?feed={$feed}"; 374 } 375 else { 367 376 if ( false !== strpos($feed, 'comments_') ) { 368 377 $feed = str_replace('comments_', '', $feed); 369 378 $permalink = $wp_rewrite->get_comment_feed_permastruct(); … … 375 384 $permalink = str_replace('%feed%', $feed, $permalink); 376 385 $permalink = preg_replace('#/+#', '/', "/$permalink"); 377 386 $output = get_option('home') . user_trailingslashit($permalink, 'feed'); 378 } else {379 if ( empty($feed) )380 $feed = get_default_feed();381 382 if ( false !== strpos($feed, 'comments_') )383 $feed = str_replace('comments_', 'comments-', $feed);384 385 $output = get_option('home') . "/?feed={$feed}";386 387 } 387 388 388 389 return apply_filters('feed_link', $output, $feed); … … 397 398 * @param string $feed Optional. Feed type. 398 399 * @return string 399 400 */ 400 function get_post_comments_feed_link($post_id = '', $feed = '' ) {401 function get_post_comments_feed_link($post_id = '', $feed = '', $return_canonical_form=false) { 401 402 global $id; 402 403 403 404 if ( empty($post_id) ) … … 406 407 if ( empty($feed) ) 407 408 $feed = get_default_feed(); 408 409 409 if ( '' != get_option('permalink_structure') ) { 410 if ($return_canonical_form==true||empty($permalink)) { 411 $type = get_post_field('post_type', $post_id); 412 if ( 'page' == $type ) 413 $url = trailingslashit(get_option('home')) . "?feed=$feed&page_id=$post_id"; 414 else 415 $url = trailingslashit(get_option('home')) . "?feed=$feed&p=$post_id"; 416 } 417 else { 410 418 $url = trailingslashit( get_permalink($post_id) ) . 'feed'; 411 419 if ( $feed != get_default_feed() ) 412 420 $url .= "/$feed"; 413 421 $url = user_trailingslashit($url, 'single_feed'); 414 } else {415 $type = get_post_field('post_type', $post_id);416 if ( 'page' == $type )417 $url = get_option('home') . "/?feed=$feed&page_id=$post_id";418 else419 $url = get_option('home') . "/?feed=$feed&p=$post_id";420 422 } 421 423 422 424 return apply_filters('post_comments_feed_link', $url); … … 460 462 * @param string $feed Optional. Feed type. 461 463 * @return string Link to the feed for the author specified by $author_id. 462 464 */ 463 function get_author_feed_link( $author_id, $feed = '' ) {465 function get_author_feed_link( $author_id, $feed = '', $return_canonical_form=false) { 464 466 $author_id = (int) $author_id; 465 467 $permalink_structure = get_option('permalink_structure'); 466 468 467 469 if ( empty($feed) ) 468 470 $feed = get_default_feed(); 469 471 470 if ( '' == $permalink_structure) {471 $link = get_option('home') . "?feed=$feed&author=" . $author_id;472 if ($return_canonical_form==true||empty($permalink_structure)) { 473 $link = trailingslashit(get_option('home')) . "?feed=$feed&author=" . $author_id; 472 474 } else { 473 475 $link = get_author_posts_url($author_id); 474 476 if ( $feed == get_default_feed() ) … … 483 485 484 486 return $link; 485 487 } 488 function get_author_comments_feed_link($author_id, $feed = '', $return_canonical_form=false) { 489 $author_id = (int) $author_id; 490 $permalink_structure = get_option('permalink_structure'); 486 491 492 if ( empty($feed) ) 493 $feed = get_default_feed(); 494 495 if ($return_canonical_form==true||empty($permalink_structure)) { 496 $link = get_option('home') . "/?feed=comments-$feed&author=" . $author_id; 497 } else { 498 $link = get_author_posts_url($author_id); 499 if ( $feed == get_default_feed() ) 500 $feed_link = 'comments/feed'; 501 else 502 $feed_link = "comments/feed/$feed"; 503 504 $link = trailingslashit($link) . user_trailingslashit($feed_link, 'feed'); 505 } 506 507 $link = apply_filters('author_comments_feed_link', $link, $feed); 508 509 return $link; 510 } 487 511 /** 488 512 * Retrieve the feed link for a category. 489 513 * … … 498 522 * @param string $feed Optional. Feed type. 499 523 * @return string Link to the feed for the category specified by $cat_id. 500 524 */ 501 function get_category_feed_link($cat_id, $feed = '' ) {525 function get_category_feed_link($cat_id, $feed = '', $return_canonical_form=false) { 502 526 $cat_id = (int) $cat_id; 503 527 504 528 $category = get_category($cat_id); … … 511 535 512 536 $permalink_structure = get_option('permalink_structure'); 513 537 514 if ( '' == $permalink_structure) {515 $link = trailingslashit( get_option('home')) . "?feed=$feed&cat=" . $cat_id;538 if ($return_canonical_form==true||empty($permalink_structure)) { 539 $link = trailingslashit(get_option('home')) . "?feed=$feed&cat=" . $cat_id; 516 540 } else { 517 541 $link = get_category_link($cat_id); 518 542 if( $feed == get_default_feed() ) … … 527 551 528 552 return $link; 529 553 } 554 function get_category_comments_feed_link($cat_id, $feed = '', $return_canonical_form=false) { 555 $cat_id = (int) $cat_id; 530 556 557 $category = get_category($cat_id); 558 559 if ( empty($category) || is_wp_error($category) ) 560 return false; 561 562 if ( empty($feed) ) 563 $feed = get_default_feed(); 564 565 $permalink_structure = get_option('permalink_structure'); 566 567 if ($return_canonical_form==true||empty($permalink_structure)) { 568 $link = trailingslashit(get_option('home')) . "?feed=comments-$feed&cat=" . $cat_id; 569 } else { 570 $link = get_category_link($cat_id); 571 if( $feed == get_default_feed() ) 572 $feed_link = 'comments/feed'; 573 else 574 $feed_link = "comments/feed/$feed"; 575 576 $link = trailingslashit($link) . user_trailingslashit($feed_link, 'feed'); 577 } 578 579 $link = apply_filters('category_comments_feed_link', $link, $feed); 580 581 return $link; 582 } 583 531 584 /** 532 585 * Retrieve permalink for feed of tag. 533 586 * … … 537 590 * @param string $feed Optional. Feed type. 538 591 * @return string 539 592 */ 540 function get_tag_feed_link($tag_id, $feed = '' ) {593 function get_tag_feed_link($tag_id, $feed = '', $return_canonical_form=false) { 541 594 $tag_id = (int) $tag_id; 542 595 543 596 $tag = get_tag($tag_id); … … 550 603 if ( empty($feed) ) 551 604 $feed = get_default_feed(); 552 605 553 if ( '' == $permalink_structure ) { 554 $link = get_option('home') . "?feed=$feed&tag=" . $tag->slug; 555 } else { 606 if ($return_canonical_form==true||empty($permalink_structure)) { 607 $link = trailingslashit(get_option('home')) . "?feed=$feed&tag=" . $tag->slug; 608 } 609 else { 556 610 $link = get_tag_link($tag->term_id); 557 611 if ( $feed == get_default_feed() ) 558 612 $feed_link = 'feed'; … … 565 619 566 620 return $link; 567 621 } 622 function get_tag_comments_feed_link($tag_id, $feed = '', $return_canonical_form=false) { 623 $tag_id = (int) $tag_id; 568 624 625 $tag = get_tag($tag_id); 626 627 if ( empty($tag) || is_wp_error($tag) ) 628 return false; 629 630 $permalink_structure = get_option('permalink_structure'); 631 632 if ( empty($feed) ) 633 $feed = get_default_feed(); 634 635 if ($return_canonical_form==true||empty($permalink_structure)) { 636 $link = get_option('home') . "/?feed=comments-$feed&tag=" . $tag->slug; 637 } else { 638 $link = get_tag_link($tag->term_id); 639 if ( $feed == get_default_feed() ) 640 $feed_link = 'comments/feed'; 641 else 642 $feed_link = "comments/feed/$feed"; 643 $link = trailingslashit($link) . user_trailingslashit($feed_link, 'feed'); 644 } 645 646 $link = apply_filters('tag_comments_feed_link', $link, $feed); 647 648 return $link; 649 } 569 650 /** 570 651 * Retrieve edit tag link. 571 652 * … … 608 689 echo $before . apply_filters( 'edit_tag_link', $link, $tag->term_id ) . $after; 609 690 } 610 691 692 function get_search_link($search_query) { 693 if (empty($search_query)) { 694 $search=attribute_escape(get_search_query()); 695 } 696 else { 697 $search=attribute_escape(stripslashes($search_query)); 698 } 699 $link=trailingslashit(get_option('home'))."?s=$search"; 700 $link=apply_filters('search_link',$link); 701 return $link; 702 } 611 703 /** 612 704 * Retrieve the permalink for the feed of the search results. 613 705 * … … 626 718 if ( empty($feed) ) 627 719 $feed = get_default_feed(); 628 720 629 $link = get_option('home') . "?s=$search&feed=$feed";721 $link = trailingslashit(get_option('home')) . "?s=$search&feed=$feed"; 630 722 631 723 $link = apply_filters('search_feed_link', $link); 632 724 … … 651 743 if ( empty($feed) ) 652 744 $feed = get_default_feed(); 653 745 654 $link = get_option('home') . "?s=$search&feed=comments-$feed";746 $link = trailingslashit(get_option('home')) . "?s=$search&feed=comments-$feed"; 655 747 656 748 $link = apply_filters('search_feed_link', $link); 657 749 658 750 return $link; 659 751 } 660 752 753 function _archive_array_to_link($array) { 754 $link=$array[0]; 755 $array_length=count($array); 756 if($array_length>1) { 757 $link.="?$array[1]"; 758 if($array_length>2) { 759 for($i=2;$i<$array_length;$i++) { 760 $link.="&$array[$i]"; 761 } 762 } 763 } 764 return $link; 765 } 766 function get_archive_link($year,$month=null,$day=null,$hour=null,$minute=null,$second=null,$return_array=false) { 767 $array=array(trailingslashit(get_option('home'))); 768 if($year!==null) { 769 $year=(int)$year; 770 if($year<=0) { 771 return false; 772 } 773 $array[]="year=$year"; 774 } 775 if($month!==null) { 776 $month=(int)$month; 777 if($month<1||$month>12) { 778 return false; 779 } 780 $array[]="monthnum=$month"; 781 } 782 if($day!==null) { 783 $day=(int)$day; 784 if($day<1||$day>31) { 785 return false; 786 } 787 $array[]="day=$day"; 788 } 789 if($hour!==null) { 790 $hour=(int)$hour; 791 if($hour<0||$hour>23) { 792 return false; 793 } 794 $array[]="hour=$hour"; 795 } 796 if($minute!==null) { 797 $minute=(int)$minute; 798 if($minute<0||$minute>60) { 799 return false; 800 } 801 $array[]="minute=$minute"; 802 } 803 if($second!==null) { 804 $second=(int)$second; 805 if($second<0||$second>60) { 806 return false; 807 } 808 $array[]="second=$second"; 809 } 810 if($return_array==true) { 811 return $array; 812 } 813 else { 814 return apply_filters('archive_link',_archive_array_to_link($array)); 815 } 816 } 817 function get_archive_feed_link($year,$month=null,$day=null,$hour=null,$minute=null,$second=null,$feed='') { 818 $array=get_archive_link($year,$month,$day,$hour,$minute,$second,true); 819 if($array===false) { 820 return false; 821 } 822 if(empty($feed)) { 823 $feed=get_default_feed(); 824 } 825 $array[]="feed=$feed"; 826 return apply_filters('archive_feed_link',_archive_array_to_link($array),$feed); 827 } 828 function get_archive_comments_feed_link($year,$month=null,$day=null,$hour=null,$minute=null,$second=null,$feed='') { 829 $array=get_archive_link($year,$month,$day,$hour,$minute,$second,true); 830 if($array===false) { 831 return false; 832 } 833 if(empty($feed)) { 834 $feed=get_default_feed(); 835 } 836 $array[]="feed=comments-$feed"; 837 return apply_filters('archive_comments_feed_link',_archive_array_to_link($array),$feed); 838 } 839 function get_week_link($year,$week,$return_array=false) { 840 $array=get_archive_link($year,null,null,null,null,null,true); 841 $week=(int)$week; 842 if($array===false||$week<0||$week>53) { 843 return false; 844 } 845 $array[]="w=$week"; 846 if($return_array==true) { 847 return $array; 848 } 849 else { 850 return apply_filters('week_link',_archive_array_to_link($array)); 851 } 852 } 853 function get_week_feed_link($year,$week,$feed='') { 854 $array=get_week_link($year,$week,true); 855 if($array===false) { 856 return false; 857 } 858 if(empty($feed)) { 859 $feed=get_default_feed(); 860 } 861 $array[]="feed=$feed"; 862 return apply_filters('week_feed_link',_archive_array_to_link($array),$feed); 863 } 864 function get_week_comments_feed_link($year,$week,$feed='') { 865 $array=get_week_link($year,$week,true); 866 if($array===false) { 867 return false; 868 } 869 if(empty($feed)) { 870 $feed=get_default_feed(); 871 } 872 $array[]="feed=comments-$feed"; 873 return apply_filters('week_comments_feed_link',_archive_array_to_link($array),$feed); 874 } 875 661 876 /** 662 877 * Retrieve edit posts link for post. 663 878 * -
query.php
11 11 * @subpackage Query 12 12 */ 13 13 14 function get_query_object_id() { 15 global $wp_query; 16 return $wp_query->get_queried_object_id(); 17 } 18 14 19 /** 15 20 * Retrieve variable in the WP_Query class. 16 21 *
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)