| 622 | * Display the orignal source link for the currently displayed feed. |
| 623 | * |
| 624 | * Generate a correct link for the <link> element. |
| 625 | * |
| 626 | * @since 4.4.0 |
| 627 | */ |
| 628 | function source_link_rss() { |
| 629 | global $wp_query; |
| 630 | $queried_object = get_queried_object(); |
| 631 | |
| 632 | // Posts and Custom Post Types |
| 633 | if( $wp_query->is_singular() ) { |
| 634 | $source_link = the_permalink_rss(); |
| 635 | } |
| 636 | // Pages |
| 637 | else if( $wp_query->is_page() && isset( $wp_query->query['pagename'] ) ) { |
| 638 | $page = get_page_by_path( $wp_query->query['pagename'] ); |
| 639 | $source_link = get_page_link( $page->ID ); |
| 640 | } |
| 641 | // Taxonomy Archive Pages |
| 642 | else if( ( $wp_query->is_category() || $wp_query->is_tag() || $wp_query->is_taxonomy() ) && isset( $queried_object->term_id ) && ! empty( $queried_object->term_id ) ) { |
| 643 | $source_link = get_term_link( $queried_object->term_id ); |
| 644 | } |
| 645 | // Date Archive Pages |
| 646 | else if( $wp_query->is_date() ) { |
| 647 | if( $wp_query->is_day() ) { |
| 648 | $source_link = get_day_link( $wp_query->query_vars['year'], $wp_query->query_vars['monthnum'], $wp_query->query_vars['day'] ); |
| 649 | } else if( $wp_query->is_month() ) { |
| 650 | $source_link = get_month_link( $wp_query->query['year'], $wp_query->query['monthnum'] ); |
| 651 | } |
| 652 | } |
| 653 | // Custom Post Type Archive Pages |
| 654 | else if( $wp_query->is_post_type_archive() && isset( $wp_query->query['post_type'] ) && ! empty( $wp_query->query['post_type'] ) ) { |
| 655 | $post_type = $wp_query->query['post_type']; |
| 656 | $source_link = get_post_type_archive_link( $post_type ); |
| 657 | } |
| 658 | // Search Result Pages |
| 659 | else if( $wp_query->is_search() && isset( $wp_query->query['s'] ) && ! empty( $wp_query->query['s'] ) ) { |
| 660 | $source_link = get_search_link( $wp_query->query['s'] ); |
| 661 | } |
| 662 | // Fallback |
| 663 | else { |
| 664 | $source_link = bloginfo_rss('url'); |
| 665 | } |
| 666 | |
| 667 | /** |
| 668 | * Filter the original HTML source link URL for use in RSS feeds. |
| 669 | * |
| 670 | * @since 4.4.0 |
| 671 | * |
| 672 | * |
| 673 | * @param string $source_link The link to the orignal HTML source the feed represents. |
| 674 | */ |
| 675 | echo esc_url( apply_filters( 'source_link_rss', $source_link ) ); |
| 676 | } |
| 677 | |
| 678 | /** |