[wp-trac] [WordPress Trac] #10552: Add get_search_link()
WordPress Trac
wp-trac at lists.automattic.com
Wed Aug 5 21:22:24 UTC 2009
#10552: Add get_search_link()
-------------------------+--------------------------------------------------
Reporter: sirzooro | Owner: ryan
Type: enhancement | Status: new
Priority: normal | Milestone: 2.9
Component: Permalinks | Version: 2.8.3
Severity: normal | Keywords: has-patch needs-testing
-------------------------+--------------------------------------------------
WP_Rewrite class provides get_search_permastruct() method, but it is not
used. It will be good to add get_search_link() function for completness. I
am not sure where it should go (which file), so I post it here:
{{{
function get_search_link( $query = null ) {
global $wp_rewrite;
$searchlink = $wp_rewrite->get_search_permastruct();
if ( is_null( $query ) )
$query = get_search_query();
$query = rawurlencode( $query );
if ( empty( $searchlink ) ) {
$file = trailingslashit( get_option( 'home' ) );
$searchlink = $file . '?s=' . $query;
} else {
$searchlink = str_replace( '%search%', $query, $searchlink
);
$searchlink = trailingslashit( get_option( 'home' ) ) .
user_trailingslashit( $searchlink, 'category' );
}
return apply_filters( 'search_link', $searchlink, $query );
}
}}}
--
Ticket URL: <http://core.trac.wordpress.org/ticket/10552>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list