Changeset 13483 for trunk/wp-includes/link-template.php
- Timestamp:
- 02/28/2010 04:15:02 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/link-template.php
r13475 r13483 657 657 658 658 /** 659 * Retrieve permalink for search. 660 * 661 * @since 3.0.0 662 * @param string $query Optional. The query string to use. If empty the current query is used. 663 * @return string 664 */ 665 function get_search_link( $query = '' ) { 666 global $wp_rewrite; 667 668 if ( empty($query) ) 669 $search = get_search_query(); 670 else 671 $search = stripslashes($query); 672 673 $permastruct = $wp_rewrite->get_search_permastruct(); 674 675 if ( empty( $permastruct ) ) { 676 $link = home_url('?s=' . urlencode($search) ); 677 } else { 678 $search = urlencode($search); 679 $search = str_replace('%2F', '/', $search); // %2F(/) is not valid within a URL, send it unencoded. 680 $link = str_replace( '%search%', $search, $permastruct ); 681 $link = home_url( user_trailingslashit( $link, 'search' ) ); 682 } 683 684 return apply_filters( 'search_link', $link, $search ); 685 } 686 687 /** 659 688 * Retrieve the permalink for the feed of the search results. 660 689 * … … 666 695 */ 667 696 function get_search_feed_link($search_query = '', $feed = '') { 668 if ( empty($search_query) ) 669 $search = esc_attr( urlencode(get_search_query()) ); 670 else 671 $search = esc_attr( urlencode(stripslashes($search_query)) ); 697 global $wp_rewrite; 698 $link = get_search_link($search_query); 672 699 673 700 if ( empty($feed) ) 674 701 $feed = get_default_feed(); 675 702 676 $link = home_url("?s=$search&feed=$feed"); 677 678 $link = apply_filters('search_feed_link', $link); 703 $permastruct = $wp_rewrite->get_search_permastruct(); 704 705 if ( empty($permastruct) ) { 706 $link = add_query_arg('feed', $feed, $link); 707 } else { 708 $link = trailingslashit($link); 709 $link .= "feed/$feed/"; 710 } 711 712 $link = apply_filters('search_feed_link', $link, $feed, 'posts'); 679 713 680 714 return $link; … … 691 725 */ 692 726 function get_search_comments_feed_link($search_query = '', $feed = '') { 693 if ( empty($search_query) ) 694 $search = esc_attr( urlencode(get_search_query()) ); 695 else 696 $search = esc_attr( urlencode(stripslashes($search_query)) ); 727 global $wp_rewrite; 697 728 698 729 if ( empty($feed) ) 699 730 $feed = get_default_feed(); 700 731 701 $link = home_url("?s=$search&feed=comments-$feed"); 702 703 $link = apply_filters('search_feed_link', $link); 732 $link = get_search_feed_link($search_query, $feed); 733 734 $permastruct = $wp_rewrite->get_search_permastruct(); 735 736 if ( empty($permastruct) ) 737 $link = add_query_arg('feed', 'comments-' . $feed, $link); 738 else 739 $link = add_query_arg('withcomments', 1, $link); 740 741 $link = apply_filters('search_feed_link', $link, $feed, 'comments'); 704 742 705 743 return $link;
Note: See TracChangeset
for help on using the changeset viewer.