From c61e6f6bbddf595fbb3c87d94b3d61966842634a Mon Sep 17 00:00:00 2001 From: Peter Westwood Date: Sun, 18 Oct 2009 11:50:59 +0000 Subject: [PATCH] Remove duplicated create_function calls an use a private _search_terms_tidy function instead for tidying up the post/page searching when looking to attach orphans to a parent post or page. git-svn-id: https://develop.svn.wordpress.org/trunk@12052 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/admin-ajax.php | 2 +- wp-includes/functions.php | 9 +++++++++ wp-includes/query.php | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/wp-admin/admin-ajax.php b/wp-admin/admin-ajax.php index 6b6ca5f127..6445979b7c 100644 --- a/wp-admin/admin-ajax.php +++ b/wp-admin/admin-ajax.php @@ -1197,7 +1197,7 @@ case 'find_posts': $what = isset($_POST['pages']) ? 'page' : 'post'; $s = stripslashes($_POST['ps']); preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches); - $search_terms = array_map(create_function('$a', 'return trim($a, "\\"\'\\n\\r ");'), $matches[0]); + $search_terms = array_map('_search_terms_tidy', $matches[0]); $searchand = $search = ''; foreach( (array) $search_terms as $term) { diff --git a/wp-includes/functions.php b/wp-includes/functions.php index c0437d2909..1f5086f0fe 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -3479,4 +3479,13 @@ function get_file_data( $file, $default_headers, $context = '' ) { return $file_data; } +/* + * Used internally to tidy up the search terms + * + * @private + * @since 2.9.0 + */ +function _search_terms_tidy($t) { + return trim($t, "\"\'\n\r "); +} ?> \ No newline at end of file diff --git a/wp-includes/query.php b/wp-includes/query.php index 6f2d7b3d37..0ce4b89f33 100644 --- a/wp-includes/query.php +++ b/wp-includes/query.php @@ -1747,7 +1747,7 @@ class WP_Query { $q['search_terms'] = array($q['s']); } else { preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $q['s'], $matches); - $q['search_terms'] = array_map(create_function('$a', 'return trim($a, "\\"\'\\n\\r ");'), $matches[0]); + $q['search_terms'] = array_map('_search_terms_tidy', $matches[0]); } $n = !empty($q['exact']) ? '' : '%'; $searchand = '';