PluginProbe
Elementor Website Builder – more than just a page builder / 4.2.4
Elementor Website Builder – more than just a page builder v4.2.4
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 4.1.0-beta1 4.1.0-dev1 All 452 releases
← All changes | modules/wp-rest/classes/post-query.php +17 -18 4.2.0-beta14.2.4 View file →
@@ -56,17 +56,8 @@
56 56 protected function get( \WP_REST_Request $request ) {
57 57 $params = $request->get_params();
58 58 $term = trim( $params[ self::SEARCH_TERM_KEY ] ?? '' );
59 59
60 - if ( empty( $term ) ) {
61 - return new \WP_REST_Response( [
62 - 'success' => true,
63 - 'data' => [
64 - 'value' => [],
65 - ],
66 - ], 200 );
67 - }
68 -
69 60 $keys_format_map = $this->filter_keys_conversion_map(
70 61 $params[ self::KEYS_CONVERSION_MAP_KEY ] ?? self::ALLOWED_KEYS_CONVERSION_MAP,
71 62 self::ALLOWED_KEYS_CONVERSION_MAP
72 63 );
@@ -76,18 +67,26 @@
76 67 $is_public_only = $params[ self::IS_PUBLIC_KEY ] ?? true;
77 68 $post_types = $this->get_post_types_from_params( $request );
78 69
79 70 $query_args = [
80 - 'post_type' => array_keys( $post_types ),
81 - 'numberposts' => $post_count,
82 - 'suppress_filters' => false,
83 - 'custom_search' => true,
84 - 'search_term' => $term,
85 - self::SEARCH_IN_CONTENT_KEY => $params[ self::SEARCH_IN_CONTENT_KEY ] ?? false,
86 - 'post_status' => $is_public_only ? 'publish' : 'any',
87 - 'orderby' => 'ID',
88 - 'order' => 'ASC',
71 + 'post_type' => array_keys( $post_types ),
72 + 'numberposts' => $post_count,
73 + 'suppress_filters' => false,
74 + 'custom_search' => true,
75 + 'post_status' => $is_public_only ? 'publish' : 'any',
76 + 'orderby' => 'modified',
77 + 'order' => 'DESC',
89 78 ];
79 +
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 + }
90 89
91 90 if ( ! empty( $params[ self::META_QUERY_KEY ] ) && is_array( $params[ self::META_QUERY_KEY ] ) ) {
92 91 $query_args['meta_query'] = $params[ self::META_QUERY_KEY ];
93 92 }