Ticket #9510: 9510-v4.patch
| File 9510-v4.patch, 48.6 KB (added by peaceablewhale, 4 years ago) |
|---|
-
feed-atom.php
4 4 * 5 5 * @package WordPress 6 6 */ 7 8 header('Content-Type: ' . feed_content_type('atom') . '; charset=' . get_option('blog_charset'), true); 7 8 $feed_type='atom'; 9 header('Content-Type: ' . feed_content_type($feed_type) . '; charset=' . get_option('blog_charset'), true); 9 10 $more = 1; 10 11 11 12 echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?> 12 <feed13 xmlns="http://www.w3.org/2005/Atom"14 xmlns:thr="http://purl.org/syndication/thread/1.0"15 xml:lang="<?php echo get_option('rss_language'); ?>"16 xml:base="<?php bloginfo_rss('home') ?>/wp-atom.php"17 <?php do_action('atom_ns'); ?>18 >19 <title type="text"><?php bloginfo_rss('name'); wp_title_rss(); ?></title>20 <subtitle type="text"><?php bloginfo_rss("description") ?></subtitle>21 13 22 <updated><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_lastpostmodified('GMT'), false); ?></updated> 23 <?php the_generator( 'atom' ); ?> 24 25 <link rel="alternate" type="text/html" href="<?php bloginfo_rss('home') ?>" /> 26 <id><?php bloginfo('atom_url'); ?></id> 27 <link rel="self" type="application/atom+xml" href="<?php self_link(); ?>" /> 28 29 <?php do_action('atom_head'); ?> 30 <?php while (have_posts()) : the_post(); ?> 31 <entry> 32 <author> 33 <name><?php the_author() ?></name> 34 <?php $author_url = get_the_author_meta('url'); if ( !empty($author_url) ) : ?> 35 <uri><?php the_author_meta('url')?></uri> 36 <?php endif; ?> 37 </author> 38 <title type="<?php html_type_rss(); ?>"><![CDATA[<?php the_title_rss() ?>]]></title> 39 <link rel="alternate" type="text/html" href="<?php the_permalink_rss() ?>" /> 40 <id><?php the_guid(); ?></id> 41 <updated><?php echo get_post_modified_time('Y-m-d\TH:i:s\Z', true); ?></updated> 42 <published><?php echo get_post_time('Y-m-d\TH:i:s\Z', true); ?></published> 43 <?php the_category_rss('atom') ?> 44 <summary type="<?php html_type_rss(); ?>"><![CDATA[<?php the_excerpt_rss(); ?>]]></summary> 45 <?php if ( !get_option('rss_use_excerpt') ) : ?> 46 <content type="<?php html_type_rss(); ?>" xml:base="<?php the_permalink_rss() ?>"><![CDATA[<?php the_content_feed('atom') ?>]]></content> 47 <?php endif; ?> 48 <?php atom_enclosure(); ?> 49 <?php do_action('atom_entry'); ?> 50 <link rel="replies" type="text/html" href="<?php the_permalink_rss() ?>#comments" thr:count="<?php echo get_comments_number()?>"/> 51 <link rel="replies" type="application/atom+xml" href="<?php echo get_post_comments_feed_link(0,'atom') ?>" thr:count="<?php echo get_comments_number()?>"/> 52 <thr:total><?php echo get_comments_number()?></thr:total> 53 </entry> 54 <?php endwhile ; ?> 55 </feed> 14 <feed xmlns="http://www.w3.org/2005/Atom" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xml:lang="<?php echo get_option('rss_language'); ?>" xml:base="<?php bloginfo_rss('url') ?>/wp-atom.php" <?php do_action('atom_ns'); ?>> 15 <?php 16 feed_headers($feed_type); 17 while (have_posts()) { 18 the_post(); 19 feed_entry($feed_type, 'entry', apply_filters('feed_entry_element_preceding', "\t"), apply_filters('feed_entry_element_trailing', "\n")); 20 } 21 ?> 22 </feed> 23 No newline at end of file -
feed-rss2.php
5 5 * @package WordPress 6 6 */ 7 7 8 $feed_type='rss2'; 8 9 header('Content-Type: ' . feed_content_type('rss-http') . '; charset=' . get_option('blog_charset'), true); 9 10 $more = 1; 10 11 11 12 echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?> 12 13 13 <rss version="2.0" 14 xmlns:content="http://purl.org/rss/1.0/modules/content/" 15 xmlns:wfw="http://wellformedweb.org/CommentAPI/" 16 xmlns:dc="http://purl.org/dc/elements/1.1/" 17 xmlns:atom="http://www.w3.org/2005/Atom" 18 xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" 19 xmlns:slash="http://purl.org/rss/1.0/modules/slash/" 20 <?php do_action('rss2_ns'); ?> 21 > 22 14 <rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" <?php do_action('rss2_ns'); ?>> 23 15 <channel> 24 <title><?php bloginfo_rss('name'); wp_title_rss(); ?></title>25 <atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />26 <link><?php bloginfo_rss('url') ?></link>27 <description><?php bloginfo_rss("description") ?></description>28 <lastBuildDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false); ?></lastBuildDate>29 <?php the_generator( 'rss2' ); ?>30 16 <language><?php echo get_option('rss_language'); ?></language> 31 <sy:updatePeriod><?php echo apply_filters( 'rss_update_period', 'hourly' ); ?></sy:updatePeriod> 32 <sy:updateFrequency><?php echo apply_filters( 'rss_update_frequency', '1' ); ?></sy:updateFrequency> 33 <?php do_action('rss2_head'); ?> 34 <?php while( have_posts()) : the_post(); ?> 35 <item> 36 <title><?php the_title_rss() ?></title> 37 <link><?php the_permalink_rss() ?></link> 38 <comments><?php comments_link(); ?></comments> 39 <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false); ?></pubDate> 40 <dc:creator><?php the_author() ?></dc:creator> 41 <?php the_category_rss() ?> 42 43 <guid isPermaLink="false"><?php the_guid(); ?></guid> 44 <?php if (get_option('rss_use_excerpt')) : ?> 45 <description><![CDATA[<?php the_excerpt_rss() ?>]]></description> 46 <?php else : ?> 47 <description><![CDATA[<?php the_excerpt_rss() ?>]]></description> 48 <?php if ( strlen( $post->post_content ) > 0 ) : ?> 49 <content:encoded><![CDATA[<?php the_content_feed('rss2') ?>]]></content:encoded> 50 <?php else : ?> 51 <content:encoded><![CDATA[<?php the_excerpt_rss() ?>]]></content:encoded> 52 <?php endif; ?> 53 <?php endif; ?> 54 <wfw:commentRss><?php echo get_post_comments_feed_link(null, 'rss2'); ?></wfw:commentRss> 55 <slash:comments><?php echo get_comments_number(); ?></slash:comments> 56 <?php rss_enclosure(); ?> 57 <?php do_action('rss2_item'); ?> 58 </item> 59 <?php endwhile; ?> 17 <?php 18 feed_headers($feed_type); 19 while (have_posts()) { 20 the_post(); 21 feed_entry($feed_type, 'item', apply_filters('feed_entry_element_preceding', "\t"), apply_filters('feed_entry_element_trailing', "\n")); 22 } 23 ?> 60 24 </channel> 61 </rss> 25 </rss> 26 No newline at end of file -
feed.php
183 183 * @package WordPress 184 184 * @subpackage Feed 185 185 * @since 2.3.0 186 * @ uses apply_filters() Call 'the_permalink_rss' on the post permalink186 * @return get_the_permalink_rss() 187 187 */ 188 188 function the_permalink_rss() { 189 echo apply_filters('the_permalink_rss', get_permalink());189 echo get_the_permalink_rss(); 190 190 } 191 191 192 192 /** 193 * Retrieve the permalink to the post for use in feeds. 194 * 195 * @since 2.9 196 * @uses apply_filters() Call 'the_permalink_rss' on the post permalink 197 */ 198 function get_the_permalink_rss() { 199 return apply_filters('the_permalink_rss', get_permalink()); 200 } 201 202 /** 193 203 * Display the feed GUID for the current comment. 194 204 * 195 205 * @package WordPress … … 276 286 * 277 287 * All of the categories for the current post in the feed loop, will be 278 288 * retrieved and have feed markup added, so that they can easily be added to the 279 * RSS2, Atom, or RSS1 and RSS0.91 RDFfeeds.289 * feeds. 280 290 * 281 291 * @package WordPress 282 292 * @subpackage Feed 283 293 * @since 2.1.0 284 294 * @uses apply_filters() 295 * @uses feed_entry_category() 285 296 * 286 297 * @param string $type Optional, default is 'rss'. Either 'rss', 'atom', or 'rdf'. 287 298 * @return string All of the post categories for displaying in the feed. 288 299 */ 289 300 function get_the_category_rss($type = 'rss') { 290 $categories = get_the_category(); 291 $tags = get_the_tags(); 301 $categories = (array)get_the_category(); 302 $tags = (array)get_the_tags(); 303 $base_scheme = untrailingslashit(get_bloginfo_rss('url')); 304 $category_scheme = "$base_scheme/category/"; 305 $tag_scheme = "$base_scheme/tag/"; 292 306 $the_list = ''; 293 $cat_names = array(); 294 295 $filter = 'rss'; 296 if ( 'atom' == $type ) 297 $filter = 'raw'; 298 299 if ( !empty($categories) ) foreach ( (array) $categories as $category ) { 300 $cat_names[] = sanitize_term_field('name', $category->name, $category->term_id, 'category', $filter); 307 foreach ($categories as $category) { 308 if (!empty($category->slug)) { 309 $the_list .= feed_entry_category($type, $category->name, $category->slug, $category_scheme); 310 } 301 311 } 302 303 if ( !empty($tags) ) foreach ( (array) $tags as $tag ) { 304 $cat_names[] = sanitize_term_field('name', $tag->name, $tag->term_id, 'post_tag', $filter); 312 foreach ($tags as $tag) { 313 if (!empty($tag->slug)) { 314 $the_list .= feed_entry_category($type, $tag->name, $tag->slug, $tag_scheme); 315 } 305 316 } 306 307 $cat_names = array_unique($cat_names);308 309 foreach ( $cat_names as $cat_name ) {310 if ( 'rdf' == $type )311 $the_list .= "\t\t<dc:subject><![CDATA[$cat_name]]></dc:subject>\n";312 elseif ( 'atom' == $type )313 $the_list .= sprintf( '<category scheme="%1$s" term="%2$s" />', esc_attr( apply_filters( 'get_bloginfo_rss', get_bloginfo( 'url' ) ) ), esc_attr( $cat_name ) );314 else315 $the_list .= "\t\t<category><![CDATA[" . @html_entity_decode( $cat_name, ENT_COMPAT, get_option('blog_charset') ) . "]]></category>\n";316 }317 318 317 return apply_filters('the_category_rss', $the_list, $type); 319 318 } 320 319 … … 531 530 532 531 return $feed; 533 532 } 533 534 /** 535 * Feed ID Template 536 * 537 * @since 2.9 538 * 539 * @param string $feed_type : Feed Type 540 * @param string $id : Feed ID 541 * @param string $preceding Optional : Whitespaces before the element 542 * @param string $trailing Optional : Whitespaces after the element 543 * @uses apply_filters() Calls 'feed_id' 544 * @return XML string 545 */ 546 function feed_id($feed_type, $id, $preceding = "\t", $trailing = "\n") { 547 $prefix = ($feed_type == 'atom' ? '' : 'atom:'); 548 return apply_filters('feed_id', "$preceding<{$prefix}id>$id</{$prefix}id>$trailing", $feed_type, $id, $preceding, $trailing); 549 } 550 551 /** 552 * Feed Title Template 553 * 554 * @since 2.9 555 * 556 * @param string $feed_type : Feed Type 557 * @param string $text : Text of the feed title 558 * @param string $preceding Optional : Whitespaces before the element 559 * @param string $trailing Optional : Whitespaces after the element 560 * @uses apply_filters() Calls 'feed_title' 561 * @return XML string 562 */ 563 function feed_title($feed_type, $text, $preceding = "\t", $trailing = "\n") { 564 return apply_filters('feed_title', "$preceding<title>$text</title>$trailing", $feed_type, $text, $preceding, $trailing); 565 } 566 567 /** 568 * Feed Subtitle Template 569 * 570 * @since 2.9 571 * 572 * @param string $feed_type : Feed Type 573 * @param string $text : Text of the feed subtitle/description 574 * @param string $preceding Optional : Whitespaces before the element 575 * @param string $trailing Optional : Whitespaces after the element 576 * @uses apply_filters() Calls 'feed_subtitle' 577 * @return XML string 578 */ 579 function feed_subtitle($feed_type, $text, $preceding = "\t", $trailing = "\n") { 580 if ($feed_type == 'atom' && !empty($text)) { 581 $subtitle = "$preceding<subtitle>$text</subtitle>$trailing"; 582 } 583 elseif ($feed_type == 'rss2') { 584 if (empty($text)) { 585 $subtitle = "$preceding<description />$trailing"; 586 } 587 else { 588 $subtitle = "$preceding<description>$text</description>$trailing"; 589 } 590 } 591 else { 592 $subtitle = ''; 593 } 594 return apply_filters('feed_subtitle', $subtitle, $feed_type, $text, $preceding, $trailing); 595 } 596 597 /** 598 * Feed Self Link Template 599 * 600 * @since 2.9 601 * 602 * @param string $feed_type : Feed Type 603 * @param string $href : The self link of the feed 604 * @param string $preceding Optional : Whitespaces before the element 605 * @param string $trailing Optional : Whitespaces after the element 606 * @uses apply_filters() Calls 'feed_self_link' 607 * @return XML string 608 */ 609 function feed_self_link($feed_type, $href, $preceding = "\t", $trailing = "\n") { 610 $prefix = ($feed_type == 'atom' ? '' : 'atom:'); 611 $self_link = "$preceding<{$prefix}link rel=\"self\" type=\"" . feed_content_type($feed_type) . "\" href=\"$href\" />$trailing"; 612 return apply_filters('feed_self_link', $self_link, $feed_type, $href, $preceding, $trailing); 613 } 614 615 /** 616 * Feed Link Template 617 * 618 * @since 2.9 619 * 620 * @param string $feed_type : Feed Type 621 * @param bool $is_entry : if the link is entry link 622 * @param string $href : The link of the feed 623 * @param string $href_type : The content type of the link 624 * @param string $preceding Optional : Whitespaces before the element 625 * @param string $trailing Optional : Whitespaces after the element 626 * @uses apply_filters() Calls 'feed_link' or 'feed_entry_link' depending on $is_entry 627 * @return XML string 628 */ 629 function feed_link($feed_type, $is_entry, $href, $href_type = null, $preceding = "\t", $trailing = "\n") { 630 switch ($feed_type) { 631 case 'atom': 632 $link = '<link rel="alternate"'; 633 if (!empty($href_type)) { 634 $link .= " type=\"$href_type\""; 635 } 636 $link .= " href=\"$href\" />"; 637 break; 638 case 'rss2': 639 $link = "<link>$href</link>"; 640 break; 641 } 642 $link = $preceding . $link . $trailing; 643 return apply_filters(($is_entry == true ? 'feed_entry_link' : 'feed_link'), $link, $feed_type, $href, $href_type, $preceding, $trailing); 644 } 645 646 /** 647 * Feed Replies Link Template 648 * 649 * @since 2.9 650 * 651 * @param string $feed_type : Feed Type 652 * @param string $href : The location of the replies to the feed 653 * @param string $href_type : The content type of the link 654 * @param string $preceding Optional : Whitespaces before the element 655 * @param string $trailing Optional : Whitespaces after the element 656 * @uses apply_filters() Calls 'feed_replies_link' 657 * @return XML string 658 */ 659 function feed_replies_link($feed_type, $href, $href_type = null, $preceding = "\t", $trailing = "\n") { 660 $prefix = ($feed_type == 'atom' ? '' : 'atom:'); 661 $replies_link = "$preceding<{$prefix}link rel=\"replies\""; 662 if (!empty($href_type)) { 663 $replies_link .= " type=\"$href_type\""; 664 } 665 $replies_link .= " href=\"$href\" />$trailing"; 666 return apply_filters('feed_replies_link', $replies_link, $feed_type, $href, $href_type, $preceding, $trailing); 667 } 668 669 /** 670 * Feed Last-Updated Timestamp Template 671 * 672 * @since 2.9 673 * 674 * @param string $feed_type : Feed Type 675 * @param int $updated_time: The last-updated timestamp of the feed 676 * @param string $preceding Optional : Whitespaces before the element 677 * @param string $trailing Optional : Whitespaces after the element 678 * @uses apply_filters() Calls 'feed_updated' 679 * @return XML string 680 */ 681 function feed_updated($feed_type, $updated_time, $preceding="\t", $trailing="\n") { 682 switch ($feed_type) { 683 case 'atom': 684 $updated = '<updated>' . gmdate('Y-m-d\TH:i:s\Z', $updated_time).'</updated>'; 685 break; 686 case 'rss2': 687 $updated = '<lastBuildDate>' . gmdate('D, d M Y H:i:s +0000', $updated_time). '</lastBuildDate>'; 688 break; 689 } 690 $updated = $preceding . $updated . $trailing; 691 return apply_filters('feed_updated', $updated, $feed_type, $updated_time, $preceding, $trailing); 692 } 693 694 /** 695 * Feed Update Limit Template 696 * 697 * @since 2.9 698 * 699 * @param string $feed_type : Feed Type 700 * @param string $period: Feed update period: 'hourly' | 'daily' | 'weekly' | 'monthly' | 'yearly' 701 * @param int $frequency: Feed update frequency, relative to $period 702 * @param string $preceding Optional : Whitespaces before the element 703 * @param string $trailing Optional : Whitespaces after the element 704 * @uses apply_filters() Calls 'feed_update_limit' 705 * @return XML string 706 */ 707 function feed_update_limit($feed_type, $period, $frequency, $preceding = "\t", $trailing = "\n") { 708 $update_limit = $preceding . "<sy:updatePeriod>$period</sy:updatePeriod>" . $trailing . 709 $preceding . "<sy:updateFrequency>$frequency</sy:updateFrequency>" . $trailing; 710 return apply_filters('feed_update_limit', $update_limit, $feed_type, $period, $frequency, $preceding, $trailing); 711 } 712 713 /** 714 * Feed Entry ID Template 715 * 716 * @since 2.9 717 * 718 * @param string $feed_type : Feed Type 719 * @param string $id: The entry id 720 * @param string $preceding Optional : Whitespaces before the element 721 * @param string $trailing Optional : Whitespaces after the element 722 * @uses apply_filters() Calls 'feed_entry_id' 723 * @return XML string 724 */ 725 function feed_entry_id($feed_type, $id, $preceding = "\t\t", $trailing = "\n") { 726 switch ($feed_type) { 727 case 'atom': 728 $entry_id = "<id>$id</id>"; 729 break; 730 case 'rss2': 731 $entry_id = "<guid isPermaLink=\"false\">$id</guid>"; 732 break; 733 } 734 $entry_id = $preceding . $entry_id . $trailing; 735 return apply_filters('feed_entry_id', $entry_id, $feed_type, $id, $preceding, $trailing); 736 } 737 738 /** 739 * Feed Entry Title Template 740 * 741 * @since 2.9 742 * 743 * @param string $feed_type : Feed Type 744 * @param string $text: The text of the entry title 745 * @param string $preceding Optional : Whitespaces before the element 746 * @param string $trailing Optional : Whitespaces after the element 747 * @uses apply_filters() Calls 'feed_entry_title' 748 * @return XML string 749 */ 750 function feed_entry_title($feed_type, $text, $preceding = "\t\t", $trailing = "\n") { 751 return apply_filters('feed_entry_title', "$preceding<title>$text</title>$trailing", $feed_type, $text, $preceding, $trailing); 752 } 753 754 /** 755 * Feed Entry Category Template 756 * 757 * @since 2.9 758 * 759 * @param string $feed_type : Feed Type 760 * @param string $category_label: The display name of the category 761 * @param string $category_term Optional : The slug of the category 762 * @param string $category_scheme Optional : The scheme of the category 763 * @param string $preceding Optional : Whitespaces before the element 764 * @param string $trailing Optional : Whitespaces after the element 765 * @uses apply_filters() Calls 'feed_entry_category' 766 * @return XML string 767 */ 768 function feed_entry_category($feed_type, $category_label, $category_term = null, $category_scheme = null, $preceding = "\t\t", $trailing = "\n") { 769 if (empty($category_term)) { 770 $category_term = $category_label; 771 } 772 switch ($feed_type) { 773 case 'atom': 774 $entry_category = '<category'; 775 if (!empty($category_scheme)) { 776 $entry_category .= " scheme=\"$category_scheme\""; 777 } 778 $entry_category .= " term=\"$category_term\" label=\"$category_label\" />"; 779 break; 780 case 'rss2': 781 $entry_category = '<category'; 782 if (!empty($category_scheme)) { 783 $entry_category .= " domain=\"$category_scheme\""; 784 } 785 $entry_category .= ">$category_label</category>"; 786 break; 787 } 788 $entry_category = $preceding . $entry_category . $trailing; 789 return apply_filters('feed_entry_category', $entry_category, $feed_type, $category_label, $category_term, $category_scheme, $preceding, $trailing); 790 } 791 792 /** 793 * Feed Entry Author Template 794 * 795 * @since 2.9 796 * 797 * @param string $feed_type : Feed Type 798 * @param string $author_name: The author's display name 799 * @param string $author_email Optional : The author's email address 800 * @param string $author_uri Optional : The author's URI 801 * @param string $preceding Optional : Whitespaces before the element 802 * @param string $trailing Optional : Whitespaces after the element 803 * @uses apply_filters() Calls 'feed_entry_author' 804 * @return XML string 805 */ 806 function feed_entry_author($feed_type, $author_name, $author_email = null, $author_uri = null, $preceding = "\t\t", $trailing = "\n") { 807 $feed_display_author_email = apply_filters('feed_display_author_email', false); 808 switch ($feed_type) { 809 case 'atom': 810 $entry_author = "<author><name>$author_name</name>"; 811 if ($feed_display_author_email == true && !empty($author_email)) { 812 $entry_author .= "<email>$author_email</email>"; 813 } 814 if (!empty($author_uri)) { 815 $entry_author .= "<uri>$author_uri</uri>"; 816 } 817 $entry_author .= "</author>"; 818 break; 819 case 'rss2': 820 if ($feed_display_author_email == true && !empty($author_email)) { 821 $entry_author = "<author>$author_email ($author_name)</author>"; 822 } 823 else { 824 $entry_author = "<dc:creator>$author_name</dc:creator>"; 825 } 826 break; 827 } 828 $entry_author = $preceding . $entry_author . $trailing; 829 return apply_filters('feed_entry_author', $entry_author, $feed_type, $author_name, $author_email, $author_uri, $preceding, $trailing); 830 } 831 832 /** 833 * Feed Entry Summary Template 834 * 835 * @since 2.9 836 * 837 * @param string $feed_type : Feed Type 838 * @param string $summary: The feed entry's summary 839 * @param string $preceding Optional : Whitespaces before the element 840 * @param string $trailing Optional : Whitespaces after the element 841 * @uses apply_filters() Calls 'feed_entry_summary' 842 * @return XML string 843 */ 844 function feed_entry_summary($feed_type, $summary, $preceding = "\t\t", $trailing = "\n") { 845 switch ($feed_type) { 846 case 'atom': 847 $entry_summary = "<summary type=\"text\">$summary</summary>"; 848 break; 849 case 'rss2': 850 $entry_summary = "<description><![CDATA[$summary]]></description>"; 851 break; 852 } 853 $entry_summary = $preceding . $entry_summary . $trailing; 854 return apply_filters('feed_entry_summary', $entry_summary, $feed_type, $summary, $preceding, $trailing); 855 } 856 857 /** 858 * Feed Entry Content Template 859 * 860 * @since 2.9 861 * 862 * @param string $feed_type : Feed Type 863 * @param string $content: The feed entry's content 864 * @param string $content_type Optional: content type: null | 'text' | 'html' | 'xhtml' 865 * @param string $content_base_url Optional: The base url of the content 866 * @param string $preceding Optional : Whitespaces before the element 867 * @param string $trailing Optional : Whitespaces after the element 868 * @uses apply_filters() Calls 'feed_entry_content' 869 * @return XML string 870 */ 871 function feed_entry_content($feed_type, $content, $content_type = null, $content_base_url = null, $preceding = "\t\t", $trailing = "\n") { 872 if (empty($content_type)) { 873 $content_type = (strpos(get_bloginfo('html_type'), 'xhtml') !== false ? 'xhtml' : 'html'); 874 } 875 if (!empty($content)) { 876 switch ($feed_type) { 877 case 'atom': 878 $entry_content = "<content type=\"$content_type\""; 879 if (!empty($content_base_url)) { 880 $entry_content .= " xml:base=\"$content_base_url\""; 881 } 882 $entry_content .= '>'; 883 switch ($content_type) { 884 case 'xhtml': 885 $entry_content .= "<div xmlns=\"http://www.w3.org/1999/xhtml\">$content</div>"; 886 break; 887 case 'html': 888 $entry_content .= "<![CDATA[$content]]>"; 889 break; 890 default: 891 $entry_content .= $content; 892 break; 893 } 894 $entry_content .= '</content>'; 895 break; 896 case 'rss2': 897 $entry_content = "<content:encoded><![CDATA[$content]]></content:encoded>"; 898 break; 899 } 900 $entry_content = $preceding . $entry_content . $trailing; 901 } 902 else { 903 $entry_content = ''; 904 } 905 return apply_filters('feed_entry_content', $entry_content, $feed_type, $content, $content_type, $content_base_url, $preceding, $trailing); 906 } 907 908 /** 909 * Feed Entry Comment Information Template 910 * 911 * @since 2.9 912 * 913 * @param string $feed_type : Feed Type 914 * @param string $blog_comment_link: The link to the feed entry's comment part 915 * @param string $feed_comment_link: The link to the feed entry's comment feed 916 * @param int $comment_number: Number of comments 917 * @param string $preceding Optional : Whitespaces before the element 918 * @param string $trailing Optional : Whitespaces after the element 919 * @uses apply_filters() Calls 'feed_entry_comment_info' 920 * @return XML string 921 */ 922 function feed_entry_comment_info($feed_type, $blog_comment_link, $feed_comment_link, $comment_number, $preceding = "\t\t", $trailing = "\n") { 923 switch ($feed_type) { 924 case 'atom': 925 $entry_comment_info= 926 $preceding . '<link rel="replies" type="' . get_bloginfo('html_type') . "\" href=\"$blog_comment_link\" thr:count=\"$comment_number\" />" . $trailing . 927 $preceding . '<link rel="replies" type="' . feed_content_type($feed_type) . "\" href=\"$feed_comment_link\" thr:count=\"$comment_number\" />" . $trailing . 928 $preceding . "<thr:total>$comment_number</thr:total>" . $trailing; 929 break; 930 case 'rss2': 931 $entry_comment_info= 932 $preceding . "<comments>$blog_comment_link</comments>" . $trailing . 933 $preceding . "<wfw:commentRss>$feed_comment_link</wfw:commentRss>" . $trailing . 934 $preceding . "<slash:comments>$comment_number</slash:comments>" . $trailing; 935 break; 936 } 937 return apply_filters('feed_entry_comment_info', $entry_comment_info, $feed_type, $blog_comment_link, $feed_comment_link, $comment_number, $preceding, $trailing); 938 } 939 940 /** 941 * Feed Entry Published TimeStamp Template 942 * 943 * @since 2.9 944 * 945 * @param string $feed_type : Feed Type 946 * @param int $published_time: The published time of the feed entry 947 * @param string $preceding Optional : Whitespaces before the element 948 * @param string $trailing Optional : Whitespaces after the element 949 * @uses apply_filters() Calls 'feed_entry_published' 950 * @return XML string 951 */ 952 function feed_entry_published($feed_type, $published_time, $preceding = "\t\t", $trailing = "\n") { 953 switch ($feed_type) { 954 case 'atom': 955 $entry_published = '<published>' . gmdate('Y-m-d\TH:i:s\Z',$published_time) . '</published>'; 956 break; 957 case 'rss2': 958 $entry_published = '<pubDate>' . gmdate('D, d M Y H:i:s +0000',$published_time) . '</pubDate>'; 959 break; 960 } 961 $entry_published = $preceding . $entry_published . $trailing; 962 return apply_filters('feed_entry_published', $entry_published, $feed_type, $published_time, $preceding, $trailing); 963 } 964 965 /** 966 * Feed Entry Updated TimeStamp Template 967 * 968 * @since 2.9 969 * 970 * @param string $feed_type : Feed Type 971 * @param int $updated_time: The updated time of the feed entry 972 * @param string $preceding Optional : Whitespaces before the element 973 * @param string $trailing Optional : Whitespaces after the element 974 * @uses apply_filters() Calls 'feed_entry_updated' 975 * @return XML string 976 */ 977 function feed_entry_updated($feed_type, $updated_time, $preceding = "\t\t", $trailing = "\n") { 978 if ($feed_type == 'atom') { 979 $entry_updated = $preceding . '<updated>' . gmdate('Y-m-d\TH:i:s\Z', $updated_time) . '</updated>' . $trailing; 980 } 981 else { 982 $entry_updated = ''; 983 } 984 return apply_filters('feed_entry_updated', $entry_updated, $feed_type, $updated_time, $preceding, $trailing); 985 } 986 987 /** 988 * Feed Headers Generator 989 * 990 * @since 2.9 991 * 992 * @param string $feed_type : Feed Type 993 */ 994 function feed_headers($feed_type) { 995 global $wp_query; 996 if (is_category()) { 997 $cat_id = $wp_query->get_queried_object_id(); 998 $id = get_category_feed_link($cat_id, $feed_type, true); 999 $subtitle = trim(strip_tags(category_description($cat_id))); 1000 $self_link = get_category_feed_link($cat_id, $feed_type); 1001 $feed_link = get_category_link($cat_id); 1002 $replies_link = get_category_comments_feed_link($cat_id, $feed_type); 1003 } 1004 elseif (is_tag()) { 1005 $tag_atom_id = $wp_query->get_queried_object_id(); 1006 $id = get_tag_feed_link($tag_id, $feed_type, true); 1007 $subtitle = trim(strip_tags(tag_description($cat_id))); 1008 $self_link = get_tag_feed_link($tag_id, $feed_type); 1009 $feed_link = get_tag_link($tag_id); 1010 $replies_link = get_tag_comments_feed_link($tag_id, $feed_type); 1011 } 1012 elseif (is_author()) { 1013 $author_id = $wp_query->get_queried_object_id(); 1014 $id = get_author_feed_link($author_id, $feed_type, true); 1015 $subtitle = null; 1016 $self_link = get_author_feed_link($author_id, $feed_type); 1017 $feed_link = get_author_posts_url($author_id); 1018 $replies_link = get_author_comments_feed_link($author_id, $feed_type); 1019 } 1020 elseif (is_date()) { 1021 $year = $month = $day = $hour = $minute = $second = $canonical_feed_link = $alternate_link = $comments_feed_link = null; 1022 $year_string = get_query_var('year'); 1023 $month_string = get_query_var('monthnum'); 1024 $day_string = get_query_var('day'); 1025 $hour_string = get_query_var('hour'); 1026 $minute_string = get_query_var('minute'); 1027 $second_string = get_query_var('second'); 1028 $m = get_query_var('m'); 1029 $week = get_query_var('w'); 1030 if (!empty($week)) { 1031 if (!empty($year_string)) { 1032 $year = $year_string; 1033 } 1034 elseif (!empty($m) && strlen($m) >= 4) { 1035 $year = substr($m, 0, 4); 1036 } 1037 $canonical_feed_link = get_week_feed_link($year, $week, $feed_type); 1038 $alternate_link = get_week_link($year, $week); 1039 $comments_feed_link = get_week_comments_feed_link($year, $week, $feed_type); 1040 } 1041 elseif (empty($m)) { 1042 if (!empty($year_string)) { 1043 $year = $year_string; 1044 } 1045 if (!empty($month_string)) { 1046 $month = $month_string; 1047 } 1048 if (!empty($day_string)) { 1049 $day = $day_string; 1050 } 1051 if (!empty($hour_string)) { 1052 $hour = $hour_string; 1053 } 1054 if (!empty($minute_string)) { 1055 $minute = $minute_string; 1056 } 1057 if (!empty($second_string)) { 1058 $second = $second_string; 1059 } 1060 } 1061 else { 1062 $m_length = strlen($m); 1063 switch ($m_length) { 1064 case 14: 1065 $second = substr($m, 12, 2); 1066 case 12: 1067 $minute = substr($m, 10, 2); 1068 case 10: 1069 $hour = substr($m, 8, 2); 1070 case 8: 1071 $day = substr($m, 6, 2); 1072 case 6: 1073 $month = substr($m, 4, 2); 1074 case 4: 1075 $year = substr($m, 0, 4); 1076 break; 1077 default: 1078 return false; 1079 } 1080 } 1081 if ($canonical_feed_link === null) { 1082 $canonical_feed_link = get_archive_feed_link($year, $month, $day, $hour, $minute, $second, $feed_type); 1083 } 1084 if ($alternate_link === null) { 1085 $alternate_link = get_archive_link($year, $month, $day, $hour, $minute, $second); 1086 } 1087 if ($comments_feed_link === null) { 1088 $comments_feed_link = get_archive_comments_feed_link($year, $month, $day, $hour, $minute, $second, $feed_type); 1089 } 1090 $subtitle = null; 1091 $id=$self_link = $canonical_feed_link; 1092 $feed_link = $alternate_link; 1093 $replies_link = $comments_feed_link; 1094 } 1095 elseif (is_search()) { 1096 $search_query = get_search_query(); 1097 $subtitle = null; 1098 $id = $self_link = get_search_feed_link($search_query, $feed_type); 1099 $feed_link = get_search_link($search_query); 1100 $replies_link = get_search_comments_feed_link($search_query, $feed_type); 1101 } 1102 else { 1103 $id = get_feed_link($feed_type, true); 1104 $subtitle = get_bloginfo_rss('description'); 1105 $self_link = get_bloginfo("{$feed_type}_url"); 1106 $feed_link = trailingslashit(get_bloginfo_rss('url')); 1107 $replies_link = get_bloginfo_rss("comments_{$feed_type}_url"); 1108 } 1109 echo feed_id($feed_type, $id); 1110 echo feed_title($feed_type, get_bloginfo_rss('name') . get_wp_title_rss()); 1111 echo feed_subtitle($feed_type, $subtitle); 1112 echo feed_self_link($feed_type, $self_link); 1113 echo feed_link($feed_type, false, $feed_link, get_bloginfo('html_type')); 1114 echo feed_replies_link($feed_type, $replies_link, feed_content_type($feed_type)); 1115 echo "\t"; 1116 the_generator($feed_type); 1117 if (apply_filters('feed_set_update_limit', true) == true) { 1118 echo feed_update_limit($feed_type, apply_filters('rss_update_period', 'hourly'), apply_filters('rss_update_frequency', 1)); 1119 } 1120 do_action("{$feed_type}_head"); 1121 echo feed_updated($feed_type, strtotime(get_lastpostmodified('GMT'))); 1122 } 1123 1124 /** 1125 * Feed Entry Generator 1126 * 1127 * @since 2.9 1128 * 1129 * @param string $feed_type : Feed Type 1130 * @param string $entry_element_name : Name of the entry element 1131 * @param string $preceding Optional : Whitespaces before the element 1132 * @param string $trailing Optional : Whitespaces after the element 1133 */ 1134 function feed_entry($feed_type, $entry_element_name, $preceding = "\t", $trailing = "\n") { 1135 echo $preceding . "<$entry_element_name>" . $trailing; 1136 echo feed_entry_id($feed_type, get_the_guid()); 1137 echo feed_entry_title($feed_type, get_the_title_rss()); 1138 echo get_the_category_rss($feed_type); 1139 echo feed_entry_author($feed_type, get_the_author(), get_the_author_meta('user_email'), get_the_author_meta('user_url')); 1140 echo feed_entry_summary($feed_type, trim(get_the_excerpt())); 1141 $feed_entry_link = get_the_permalink_rss(); 1142 if (get_option('rss_use_excerpt') == false) { 1143 echo feed_entry_content($feed_type, trim(get_the_content_feed($feed_type)), null, $feed_entry_link); 1144 } 1145 echo feed_link($feed_type, true, $feed_entry_link, get_bloginfo('html_type'), "\t\t"); 1146 echo feed_entry_comment_info($feed_type, $feed_entry_link . '#comments', get_post_comments_feed_link(null, $feed_type), get_comments_number()); 1147 switch ($feed_type) { 1148 case 'atom': 1149 atom_enclosure(); 1150 do_action('atom_entry'); 1151 break; 1152 case 'rss2': 1153 rss_enclosure(); 1154 do_action('rss2_item'); 1155 break; 1156 } 1157 echo feed_entry_published($feed_type, get_post_time('U', true)); 1158 echo feed_entry_updated($feed_type, get_post_modified_time('U', true)); 1159 echo $preceding . "</$entry_element_name>" . $trailing; 1160 } 1161 No newline at end of file -
link-template.php
357 357 * @since 1.5.0 358 358 * 359 359 * @param string $feed Optional, defaults to default feed. Feed type. 360 * @param bool $return_canonical_form Optional. Whether the function should generate a link that will not change even when the permalink format changes (since 2.9) 360 361 * @return string 361 362 */ 362 function get_feed_link($feed = '' ) {363 function get_feed_link($feed = '', $return_canonical_form = false) { 363 364 global $wp_rewrite; 364 365 365 366 $permalink = $wp_rewrite->get_feed_permastruct(); 366 if ( '' != $permalink ) { 367 if ($return_canonical_form==true||empty($permalink)) { 368 if ( empty($feed) ) 369 $feed = get_default_feed(); 370 371 if ( false !== strpos($feed, 'comments_') ) 372 $feed = str_replace('comments_', 'comments-', $feed); 373 374 $output = trailingslashit(get_option('home')) . "?feed={$feed}"; 375 } 376 else { 367 377 if ( false !== strpos($feed, 'comments_') ) { 368 378 $feed = str_replace('comments_', '', $feed); 369 379 $permalink = $wp_rewrite->get_comment_feed_permastruct(); … … 375 385 $permalink = str_replace('%feed%', $feed, $permalink); 376 386 $permalink = preg_replace('#/+#', '/', "/$permalink"); 377 387 $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 = trailingslashit(get_option('home')) . "?feed={$feed}";386 388 } 387 389 388 390 return apply_filters('feed_link', $output, $feed); 389 391 } 390 392 … … 395 397 * 396 398 * @param int $post_id Optional. Post ID. 397 399 * @param string $feed Optional. Feed type. 400 * @param bool $return_canonical_form Optional. Whether the function should generate a link that will not change even when the permalink format changes (since 2.9) 398 401 * @return string 399 402 */ 400 function get_post_comments_feed_link($post_id = '', $feed = '' ) {403 function get_post_comments_feed_link($post_id = '', $feed = '', $return_canonical_form = false) { 401 404 global $id; 402 405 403 406 if ( empty($post_id) ) … … 406 409 if ( empty($feed) ) 407 410 $feed = get_default_feed(); 408 411 409 if ( '' != get_option('permalink_structure') ) { 410 $url = trailingslashit( get_permalink($post_id) ) . 'feed'; 411 if ( $feed != get_default_feed() ) 412 $url .= "/$feed"; 413 $url = user_trailingslashit($url, 'single_feed'); 414 } else { 412 if ($return_canonical_form==true||empty($permalink)) { 415 413 $type = get_post_field('post_type', $post_id); 416 414 if ( 'page' == $type ) 417 415 $url = trailingslashit(get_option('home')) . "?feed=$feed&page_id=$post_id"; 418 416 else 419 417 $url = trailingslashit(get_option('home')) . "?feed=$feed&p=$post_id"; 420 418 } 421 419 else { 420 $url = trailingslashit( get_permalink($post_id) ) . 'feed'; 421 if ( $feed != get_default_feed() ) 422 $url .= "/$feed"; 423 $url = user_trailingslashit($url, 'single_feed'); 424 } 425 422 426 return apply_filters('post_comments_feed_link', $url); 423 427 } 424 428 … … 436 440 * @param string $link_text Descriptive text. 437 441 * @param int $post_id Optional post ID. Default to current post. 438 442 * @param string $feed Optional. Feed format. 443 * @param bool $return_canonical_form Optional. Whether the function should generate a link that will not change even when the permalink format changes (since 2.9) 439 444 * @return string Link to the comment feed for the current post. 440 445 */ 441 function post_comments_feed_link( $link_text = '', $post_id = '', $feed = '' ) {442 $url = get_post_comments_feed_link($post_id, $feed );446 function post_comments_feed_link( $link_text = '', $post_id = '', $feed = '', $return_canonical_form = false) { 447 $url = get_post_comments_feed_link($post_id, $feed, $return_canonical_form); 443 448 if ( empty($link_text) ) 444 449 $link_text = __('Comments Feed'); 445 450 … … 458 463 * 459 464 * @param int $author_id ID of an author. 460 465 * @param string $feed Optional. Feed type. 466 * @param bool $return_canonical_form Optional. Whether the function should generate a link that will not change even when the permalink format changes (since 2.9) 461 467 * @return string Link to the feed for the author specified by $author_id. 462 468 */ 463 function get_author_feed_link( $author_id, $feed = '' ) {469 function get_author_feed_link( $author_id, $feed = '', $return_canonical_form = false) { 464 470 $author_id = (int) $author_id; 465 471 $permalink_structure = get_option('permalink_structure'); 466 472 467 473 if ( empty($feed) ) 468 474 $feed = get_default_feed(); 469 475 470 if ( '' == $permalink_structure) {476 if ($return_canonical_form==true||empty($permalink_structure)) { 471 477 $link = trailingslashit(get_option('home')) . "?feed=$feed&author=" . $author_id; 472 } else { 478 } 479 else { 473 480 $link = get_author_posts_url($author_id); 474 481 if ( $feed == get_default_feed() ) 475 482 $feed_link = 'feed'; … … 485 492 } 486 493 487 494 /** 495 * Retrieve the comments feed link for a given author. 496 * 497 * @since 2.9 498 * 499 * @param int $author_id ID of an author. 500 * @param string $feed Optional. Feed type. 501 * @param bool $return_canonical_form Optional. Whether the function should generate a link that will not change even when the permalink format changes 502 * @return string Link to the comments feed for the author specified by $author_id. 503 */ 504 function get_author_comments_feed_link($author_id, $feed = '', $return_canonical_form = false) { 505 $author_id = (int) $author_id; 506 $permalink_structure = get_option('permalink_structure'); 507 508 if ( empty($feed) ) 509 $feed = get_default_feed(); 510 511 if ($return_canonical_form==true||empty($permalink_structure)) { 512 $link = trailingslashit(get_option('home')) . "?feed=comments-$feed&author=" . $author_id; 513 } 514 else { 515 $link = get_author_posts_url($author_id); 516 if ( $feed == get_default_feed() ) 517 $feed_link = 'comments/feed'; 518 else 519 $feed_link = "comments/feed/$feed"; 520 521 $link = trailingslashit($link) . user_trailingslashit($feed_link, 'feed'); 522 } 523 524 $link = apply_filters('author_comments_feed_link', $link, $feed); 525 526 return $link; 527 } 528 529 /** 488 530 * Retrieve the feed link for a category. 489 531 * 490 532 * Returns a link to the feed for all post in a given category. A specific feed … … 496 538 * 497 539 * @param int $cat_id ID of a category. 498 540 * @param string $feed Optional. Feed type. 541 * @param bool $return_canonical_form Optional. Whether the function should generate a link that will not change even when the permalink format changes (since 2.9) 499 542 * @return string Link to the feed for the category specified by $cat_id. 500 543 */ 501 function get_category_feed_link($cat_id, $feed = '' ) {544 function get_category_feed_link($cat_id, $feed = '', $return_canonical_form = false) { 502 545 $cat_id = (int) $cat_id; 503 546 504 547 $category = get_category($cat_id); … … 511 554 512 555 $permalink_structure = get_option('permalink_structure'); 513 556 514 if ( '' == $permalink_structure) {557 if ($return_canonical_form==true||empty($permalink_structure)) { 515 558 $link = trailingslashit(get_option('home')) . "?feed=$feed&cat=" . $cat_id; 516 } else { 559 } 560 else { 517 561 $link = get_category_link($cat_id); 518 562 if( $feed == get_default_feed() ) 519 563 $feed_link = 'feed'; … … 529 573 } 530 574 531 575 /** 576 * Retrieve the comments feed link for a category. 577 * 578 * @since 2.9 579 * 580 * @param int $cat_id ID of a category. 581 * @param string $feed Optional. Feed type. 582 * @param bool $return_canonical_form Optional. Whether the function should generate a link that will not change even when the permalink format changes 583 * @return string Link to the comments feed for the category specified by $cat_id. 584 */ 585 function get_category_comments_feed_link($cat_id, $feed = '', $return_canonical_form = false) { 586 $cat_id = (int) $cat_id; 587 588 $category = get_category($cat_id); 589 590 if ( empty($category) || is_wp_error($category) ) 591 return false; 592 593 if ( empty($feed) ) 594 $feed = get_default_feed(); 595 596 $permalink_structure = get_option('permalink_structure'); 597 598 if ($return_canonical_form==true||empty($permalink_structure)) { 599 $link = trailingslashit(get_option('home')) . "?feed=comments-$feed&cat=" . $cat_id; 600 } 601 else { 602 $link = get_category_link($cat_id); 603 if( $feed == get_default_feed() ) 604 $feed_link = 'comments/feed'; 605 else 606 $feed_link = "comments/feed/$feed"; 607 608 $link = trailingslashit($link) . user_trailingslashit($feed_link, 'feed'); 609 } 610 611 $link = apply_filters('category_comments_feed_link', $link, $feed); 612 613 return $link; 614 } 615 616 /** 532 617 * Retrieve permalink for feed of tag. 533 618 * 534 619 * @since 2.3.0 535 620 * 536 621 * @param int $tag_id Tag ID. 537 622 * @param string $feed Optional. Feed type. 623 * @param bool $return_canonical_form Optional. Whether the function should generate a link that will not change even when the permalink format changes (since 2.9) 538 624 * @return string 539 625 */ 540 function get_tag_feed_link($tag_id, $feed = '' ) {626 function get_tag_feed_link($tag_id, $feed = '', $return_canonical_form = false) { 541 627 $tag_id = (int) $tag_id; 542 628 543 629 $tag = get_tag($tag_id); … … 550 636 if ( empty($feed) ) 551 637 $feed = get_default_feed(); 552 638 553 if ( '' == $permalink_structure) {639 if ($return_canonical_form==true||empty($permalink_structure)) { 554 640 $link = trailingslashit(get_option('home')) . "?feed=$feed&tag=" . $tag->slug; 555 } else { 641 } 642 else { 556 643 $link = get_tag_link($tag->term_id); 557 644 if ( $feed == get_default_feed() ) 558 645 $feed_link = 'feed'; … … 567 654 } 568 655 569 656 /** 657 * Retrieve permalink for the comments feed of tag. 658 * 659 * @since 2.9 660 * 661 * @param int $tag_id Tag ID. 662 * @param string $feed Optional. Feed type. 663 * @param bool $return_canonical_form Optional. Whether the function should generate a link that will not change even when the permalink format changes 664 * @return string 665 */ 666 function get_tag_comments_feed_link($tag_id, $feed = '', $return_canonical_form = false) { 667 $tag_id = (int) $tag_id; 668 669 $tag = get_tag($tag_id); 670 671 if ( empty($tag) || is_wp_error($tag) ) 672 return false; 673 674 $permalink_structure = get_option('permalink_structure'); 675 676 if ( empty($feed) ) 677 $feed = get_default_feed(); 678 679 if ($return_canonical_form==true||empty($permalink_structure)) { 680 $link = trailingslashit(get_option('home')) . "?feed=comments-$feed&tag=" . $tag->slug; 681 } 682 else { 683 $link = get_tag_link($tag->term_id); 684 if ( $feed == get_default_feed() ) 685 $feed_link = 'comments/feed'; 686 else 687 $feed_link = "comments/feed/$feed"; 688 $link = trailingslashit($link) . user_trailingslashit($feed_link, 'feed'); 689 } 690 691 $link = apply_filters('tag_comments_feed_link', $link, $feed); 692 693 return $link; 694 } 695 696 /** 570 697 * Retrieve edit tag link. 571 698 * 572 699 * @since 2.7.0 … … 609 736 } 610 737 611 738 /** 739 * Retrieve the permalink for the search results. 740 * 741 * @since 2.9 742 * 743 * @param string $search_query Optional. Search query. 744 * @return string 745 */ 746 function get_search_link($search_query = '') { 747 if(empty($search_query)) { 748 $search=esc_attr(get_search_query()); 749 } 750 else { 751 $search=esc_attr(stripslashes($search_query)); 752 } 753 $link=trailingslashit(get_option('home'))."?s=$search"; 754 $link=apply_filters('search_link',$link); 755 return $link; 756 } 757 758 /** 612 759 * Retrieve the permalink for the feed of the search results. 613 760 * 614 761 * @since 2.5.0 … … 659 806 } 660 807 661 808 /** 809 * Convert link array to link string. For internal use only. 810 * 811 * @since 2.9 812 * 813 * @param array $array The link array 814 * @return string 815 */ 816 function _archive_array_to_link($array) { 817 $link = $array[0]; 818 $array_length = count($array); 819 if ($array_length > 1) { 820 $link .= "?$array[1]"; 821 if ($array_length > 2) { 822 for ($i = 2; $i < $array_length ; $i++) { 823 $link .= "&$array[$i]"; 824 } 825 } 826 } 827 return $link; 828 } 829 830 /** 831 * Retrieve the archive link of a specific time 832 * 833 * @since 2.9 834 * 835 * @param int $year 836 * @param int $month Optional 837 * @param int $day Optional 838 * @param int $hour Optional 839 * @param int $minute Optional 840 * @param int $second Optional 841 * @param bool $return_array Optional 842 * @return array or string depending on $return_array 843 */ 844 function get_archive_link($year, $month = null, $day = null, $hour = null, $minute = null, $second = null, $return_array = false) { 845 $array = array(trailingslashit(get_option('home'))); 846 if ($year !== null) { 847 $year = (int)$year; 848 if ($year <= 0) { 849 return false; 850 } 851 $array[] = "year=$year"; 852 } 853 if ($month!==null) { 854 $month = (int)$month; 855 if ($month < 1 || $month > 12) { 856 return false; 857 } 858 $array[] = "monthnum=$month"; 859 } 860 if ($day !== null) { 861 $day = (int)$day; 862 if ($day < 1 || $day > 31) { 863 return false; 864 } 865 $array[] = "day=$day"; 866 } 867 if ($hour !== null) { 868 $hour = (int)$hour; 869 if ($hour < 0 || $hour > 23) { 870 return false; 871 } 872 $array[] = "hour=$hour"; 873 } 874 if ($minute !== null) { 875 $minute = (int)$minute; 876 if($minute < 0 || $minute > 60) { 877 return false; 878 } 879 $array[] = "minute=$minute"; 880 } 881 if ($second !== null) { 882 $second = (int)$second; 883 if($second < 0 || $second > 60) { 884 return false; 885 } 886 $array[] = "second=$second"; 887 } 888 if ($return_array == true) { 889 return $array; 890 } 891 else { 892 return apply_filters('archive_link', _archive_array_to_link($array), $year, $month, $day, $hour, $minute, $second); 893 } 894 } 895 896 /** 897 * Retrieve the feed link of a specific time 898 * 899 * @since 2.9 900 * 901 * @param int $year 902 * @param int $month Optional 903 * @param int $day Optional 904 * @param int $hour Optional 905 * @param int $minute Optional 906 * @param int $second Optional 907 * @param string $feed Optional. Feed Type 908 * @return string 909 */ 910 function get_archive_feed_link($year, $month = null, $day = null, $hour = null, $minute = null, $second = null, $feed = '') { 911 $array = get_archive_link($year, $month, $day, $hour, $minute, $second, true); 912 if ($array === false) { 913 return false; 914 } 915 if (empty($feed)) { 916 $feed = get_default_feed(); 917 } 918 $array[] = "feed=$feed"; 919 return apply_filters('archive_feed_link', _archive_array_to_link($array), $year, $month, $day, $hour, $minute, $second, $feed); 920 } 921 922 /** 923 * Retrieve the comments feed link of a specific time 924 * 925 * @since 2.9 926 * 927 * @param int $year 928 * @param int $month Optional 929 * @param int $day Optional 930 * @param int $hour Optional 931 * @param int $minute Optional 932 * @param int $second Optional 933 * @param string $feed Optional. Feed Type 934 * @return string 935 */ 936 function get_archive_comments_feed_link($year, $month = null, $day = null, $hour = null, $minute = null, $second = null, $feed = '') { 937 $array = get_archive_link($year, $month, $day, $hour, $minute, $second, true); 938 if ($array === false) { 939 return false; 940 } 941 if (empty($feed)) { 942 $feed = get_default_feed(); 943 } 944 $array[] = "feed=comments-$feed"; 945 return apply_filters('archive_comments_feed_link', _archive_array_to_link($array), $year, $month, $day, $hour, $minute, $second, $feed); 946 } 947 948 /** 949 * Retrieve the archive link of a specific week 950 * 951 * @since 2.9 952 * 953 * @param int $year 954 * @param int $week 955 * @param bool $return_array Optional 956 * @return array or string depending on $return_array 957 */ 958 function get_week_link($year, $week, $return_array = false) { 959 $array = get_archive_link($year, null, null, null, null, null, true); 960 $week = (int)$week; 961 if ($array === false || $week < 0 || $week > 53) { 962 return false; 963 } 964 $array[] = "w=$week"; 965 if ($return_array == true) { 966 return $array; 967 } 968 else { 969 return apply_filters('week_link', _archive_array_to_link($array)); 970 } 971 } 972 973 /** 974 * Retrieve the feed link of a specific week 975 * 976 * @since 2.9 977 * 978 * @param int $year 979 * @param int $week 980 * @param string $feed Optional. Feed Type 981 * @return string 982 */ 983 function get_week_feed_link($year, $week, $feed = '') { 984 $array = get_week_link($year, $week, true); 985 if ($array === false) { 986 return false; 987 } 988 if (empty($feed)) { 989 $feed = get_default_feed(); 990 } 991 $array[] = "feed=$feed"; 992 return apply_filters('week_feed_link', _archive_array_to_link($array), $feed); 993 } 994 995 /** 996 * Retrieve the comments feed link of a specific week 997 * 998 * @since 2.9 999 * 1000 * @param int $year 1001 * @param int $week 1002 * @param string $feed Optional. Feed Type 1003 * @return string 1004 */ 1005 function get_week_comments_feed_link($year, $week, $feed = '') { 1006 $array = get_week_link($year, $week, true); 1007 if ($array === false) { 1008 return false; 1009 } 1010 if (empty($feed)) { 1011 $feed = get_default_feed(); 1012 } 1013 $array[] = "feed=comments-$feed"; 1014 return apply_filters('week_comments_feed_link', _archive_array_to_link($array), $feed); 1015 } 1016 1017 /** 662 1018 * Retrieve edit posts link for post. 663 1019 * 664 1020 * Can be used within the WordPress loop or outside of it. Can be used with