PluginProbe
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder / 2.13.1
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder v2.13.1
2.13.0 2.13.1 2.12.0 2.11.1 2.11.0 2.10.0 2.9.0 2.7.4 2.7.5 2.7.6 2.7.7 2.8.0 2.8.1 2.9.1 trunk 1.0 1.0-beta1 1.0-beta2 1.0-beta3 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 All 80 releases
← All changes | includes/api/search-controller.php +6 -2 2.10.02.13.1 View file →
@@ -49,10 +49,12 @@
49 49 'required' => true,
50 50 'type' => 'string',
51 51 'description' => 'Post type to search.',
52 52 'sanitize_callback' => 'sanitize_key',
53 + // Public route: only a post type visitors can already
54 + // see may be searched, never an internal one.
53 55 'validate_callback' => function( $param ) {
54 - return $param === 'any' || post_type_exists( $param );
56 + return 'any' === $param || is_post_type_viewable( (string) $param );
55 57 },
56 58 ),
57 59 ),
58 60 )
@@ -66,9 +68,11 @@
66 68 $current_page_id = $request->get_param( 'current_page_id' );
67 69
68 70 $args = array(
69 71 's' => $searchQuery,
70 - 'posts_per_page' => -1,
72 + // A public, repeatable request must not render every matching post.
73 + 'posts_per_page' => max( 1, (int) apply_filters( 'ablocks/search/max_results', 20, $source ) ),
74 + 'no_found_rows' => true,
71 75 'post_type' => $source,
72 76 'post_status' => 'publish',
73 77 );
74 78