From 6267650ddd008de07fa1332a74bdc7b69c56c916 Mon Sep 17 00:00:00 2001 From: scribu Date: Sat, 13 Nov 2010 18:18:45 +0000 Subject: [PATCH] Split get_search_sql(). See #15170. See #15032 git-svn-id: http://svn.automattic.com/wordpress/trunk@16351 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-object-query.php | 26 -------------------------- wp-includes/comment.php | 20 ++++++++++++++++++++ wp-includes/user.php | 26 ++++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 26 deletions(-) diff --git a/wp-includes/class-wp-object-query.php b/wp-includes/class-wp-object-query.php index 5d4dd025a5..67524bb006 100644 --- a/wp-includes/class-wp-object-query.php +++ b/wp-includes/class-wp-object-query.php @@ -70,32 +70,6 @@ class WP_Object_Query { $qv['meta_query'] = $meta_query; } - - /* - * Used internally to generate an SQL string for searching across multiple columns - * - * @access protected - * @since 3.1.0 - * - * @param string $string - * @param array $cols - * @param bool $wild Whether to allow trailing wildcard searches. Default is false. - * @return string - */ - function get_search_sql( $string, $cols, $wild = false ) { - $string = esc_sql( $string ); - - $searches = array(); - $wild_char = ( $wild ) ? '%' : ''; - foreach ( $cols as $col ) { - if ( 'ID' == $col ) - $searches[] = "$col = '$string'"; - else - $searches[] = "$col LIKE '$string$wild_char'"; - } - - return ' AND (' . implode(' OR ', $searches) . ')'; - } } ?> diff --git a/wp-includes/comment.php b/wp-includes/comment.php index 071a3faf85..3980ab1e98 100644 --- a/wp-includes/comment.php +++ b/wp-includes/comment.php @@ -341,6 +341,26 @@ class WP_Comment_Query extends WP_Object_Query { return $comments; } + + /* + * Used internally to generate an SQL string for searching across multiple columns + * + * @access protected + * @since 3.1.0 + * + * @param string $string + * @param array $cols + * @return string + */ + function get_search_sql( $string, $cols ) { + $string = esc_sql( $string ); + + $searches = array(); + foreach ( $cols as $col ) + $searches[] = "$col LIKE '%$string%'"; + + return ' AND (' . implode(' OR ', $searches) . ')'; + } } /** diff --git a/wp-includes/user.php b/wp-includes/user.php index fc6913ba40..22bc85b08a 100644 --- a/wp-includes/user.php +++ b/wp-includes/user.php @@ -526,6 +526,32 @@ class WP_User_Query extends WP_Object_Query { } } + /* + * Used internally to generate an SQL string for searching across multiple columns + * + * @access protected + * @since 3.1.0 + * + * @param string $string + * @param array $cols + * @param bool $wild Whether to allow trailing wildcard searches. Default is false. + * @return string + */ + function get_search_sql( $string, $cols, $wild = false ) { + $string = esc_sql( $string ); + + $searches = array(); + $wild_char = ( $wild ) ? '%' : ''; + foreach ( $cols as $col ) { + if ( 'ID' == $col ) + $searches[] = "$col = '$string'"; + else + $searches[] = "$col LIKE '$string$wild_char'"; + } + + return ' AND (' . implode(' OR ', $searches) . ')'; + } + /** * Return the list of users *