PluginProbe
Elementor Website Builder – more than just a page builder / 4.1.4
Elementor Website Builder – more than just a page builder v4.1.4
4.3.1 4.3.0 4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 All 454 releases
← All changes | modules/wp-rest/classes/post-query.php +16 -28 4.3.14.1.4 View file →
@@ -30,15 +30,10 @@
30 30 $is_custom_search = $wp_query->get( 'custom_search' ) ?? false;
31 31
32 32 if ( $is_custom_search && ! empty( $term ) ) {
33 33 $escaped = esc_sql( $term );
34 - $search_in_content = $wp_query->get( self::SEARCH_IN_CONTENT_KEY ) ?? false;
35 34 $search_term .= ' AND (';
36 35 $search_term .= "post_title LIKE '%{$escaped}%'";
37 - if ( $search_in_content ) {
38 - $search_term .= " OR post_content LIKE '%{$escaped}%'";
39 - $search_term .= " OR post_excerpt LIKE '%{$escaped}%'";
40 - }
41 36 if ( ctype_digit( $term ) ) {
42 37 $search_term .= ' OR ID = ' . intval( $term );
43 38 } else {
44 39 $search_term .= " OR ID LIKE '%{$escaped}%'";
@@ -56,8 +51,17 @@
56 51 protected function get( \WP_REST_Request $request ) {
57 52 $params = $request->get_params();
58 53 $term = trim( $params[ self::SEARCH_TERM_KEY ] ?? '' );
59 54
55 + if ( empty( $term ) ) {
56 + return new \WP_REST_Response( [
57 + 'success' => true,
58 + 'data' => [
59 + 'value' => [],
60 + ],
61 + ], 200 );
62 + }
63 +
60 64 $keys_format_map = $this->filter_keys_conversion_map(
61 65 $params[ self::KEYS_CONVERSION_MAP_KEY ] ?? self::ALLOWED_KEYS_CONVERSION_MAP,
62 66 self::ALLOWED_KEYS_CONVERSION_MAP
63 67 );
@@ -67,27 +71,18 @@
67 71 $is_public_only = $params[ self::IS_PUBLIC_KEY ] ?? true;
68 72 $post_types = $this->get_post_types_from_params( $request );
69 73
70 74 $query_args = [
71 - 'post_type' => array_keys( $post_types ),
72 - 'numberposts' => $post_count,
75 + 'post_type' => array_keys( $post_types ),
76 + 'numberposts' => $post_count,
73 77 'suppress_filters' => false,
74 - 'custom_search' => true,
75 - 'post_status' => $is_public_only ? 'publish' : 'any',
76 - 'orderby' => 'modified',
77 - 'order' => 'DESC',
78 + 'custom_search' => true,
79 + 'search_term' => $term,
80 + 'post_status' => $is_public_only ? 'publish' : 'any',
81 + 'orderby' => 'ID',
82 + 'order' => 'ASC',
78 83 ];
79 84
80 - // for non-admins (contributors), filter by author for private posts
81 - if ( ! $is_public_only && ! current_user_can( 'read_private_posts' ) ) {
82 - $query_args['author'] = get_current_user_id();
83 - }
84 -
85 - if ( ! empty( $term ) ) {
86 - $query_args['search_term'] = $term;
87 - $query_args[ self::SEARCH_IN_CONTENT_KEY ] = $params[ self::SEARCH_IN_CONTENT_KEY ] ?? false;
88 - }
89 -
90 85 if ( ! empty( $params[ self::META_QUERY_KEY ] ) && is_array( $params[ self::META_QUERY_KEY ] ) ) {
91 86 $query_args['meta_query'] = $params[ self::META_QUERY_KEY ];
92 87 }
93 88
@@ -215,14 +210,8 @@
215 210 'required' => false,
216 211 'default' => null,
217 212 'sanitize_callback' => fn ( ...$args ) => self::sanitize_string_array( ...$args ),
218 213 ],
219 - self::SEARCH_IN_CONTENT_KEY => [
220 - 'description' => 'Whether to search within post content and excerpt in addition to title',
221 - 'type' => 'boolean',
222 - 'required' => false,
223 - 'default' => false,
224 - ],
225 214 ];
226 215 }
227 216
228 217 protected static function get_allowed_param_keys(): array {
@@ -233,9 +222,8 @@
233 222 self::META_QUERY_KEY,
234 223 self::TAX_QUERY_KEY,
235 224 self::IS_PUBLIC_KEY,
236 225 self::ITEMS_COUNT_KEY,
237 - self::SEARCH_IN_CONTENT_KEY,
238 226 ];
239 227 }
240 228
241 229 protected static function get_keys_to_encode(): array {