WordPress.org

Make WordPress Core

Ticket #10552: link-template.diff

File link-template.diff, 1.0 KB (added by jshreve, 8 years ago)
  • link-template.php

     
    656656}
    657657
    658658/**
     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*/
     665function get_search_link( $query = '' ) {
     666        global $wp_rewrite;
     667       
     668        if ( empty($query) )
     669                $search = esc_attr( urlencode(get_search_query()) );
     670        else
     671                $search = esc_attr( urlencode(stripslashes($query)) );
     672               
     673        $permalink = $wp_rewrite->get_search_permastruct();
     674       
     675        if( empty( $permalink ) )
     676                $permalink = home_url("?s=$search");
     677        else {
     678                $permalink = str_replace( '%search%', $search, $permalink );
     679                $permalink = home_url( user_trailingslashit( $permalink, 'category' ) );
     680        }
     681       
     682        return apply_filters( 'search_link', $permalink, $search );
     683}
     684
     685/**
    659686 * Retrieve the permalink for the feed of the search results.
    660687 *
    661688 * @since 2.5.0