mirror of
git://develop.git.wordpress.org/
synced 2025-03-15 01:19:51 +01:00
like_escape() from nbachiyski. see #5684
git-svn-id: https://develop.svn.wordpress.org/trunk@6680 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
7707124027
commit
222e9ca396
@ -268,8 +268,9 @@ function tag_rows( $page = 0, $pagesize = 20, $searchterms = '' ) {
|
|||||||
|
|
||||||
$args = array('offset' => $start, 'number' => $pagesize, 'hide_empty' => 0);
|
$args = array('offset' => $start, 'number' => $pagesize, 'hide_empty' => 0);
|
||||||
|
|
||||||
if ( !empty( $searchterms ) )
|
if ( !empty( $searchterms ) ) {
|
||||||
$args['name__like'] = '%' . $searchterms;
|
$args['name__like'] = '%' . like_escape( $searchterms );
|
||||||
|
}
|
||||||
|
|
||||||
$tags = get_terms( 'post_tag', $args );
|
$tags = get_terms( 'post_tag', $args );
|
||||||
|
|
||||||
|
@ -1164,6 +1164,15 @@ function attribute_escape($text) {
|
|||||||
$safe_text = wp_specialchars($text, true);
|
$safe_text = wp_specialchars($text, true);
|
||||||
return apply_filters('attribute_escape', $safe_text, $text);
|
return apply_filters('attribute_escape', $safe_text, $text);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Escapes text for SQL LIKE special characters % and _
|
||||||
|
*
|
||||||
|
* @param string text the text to be escaped
|
||||||
|
* @return string text, safe for inclusion in LIKE query
|
||||||
|
*/
|
||||||
|
function like_escape($text) {
|
||||||
|
return str_replace(array("%", "_"), array("\\%", "\\_"), $text);
|
||||||
|
}
|
||||||
|
|
||||||
function wp_make_link_relative( $link ) {
|
function wp_make_link_relative( $link ) {
|
||||||
return preg_replace('|https?://[^/]+(/.*)|i', '$1', $link );
|
return preg_replace('|https?://[^/]+(/.*)|i', '$1', $link );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user