PluginProbe
Gutenberg / 9.8.0
Gutenberg v9.8.0
24.0.0 23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 All 403 releases
← All changes | lib/rest-api.php +37 -67 12.6.09.8.0 View file →
@@ -9,23 +9,11 @@
9 9 if ( ! defined( 'ABSPATH' ) ) {
10 10 die( 'Silence is golden.' );
11 11 }
12 12
13 -
14 13 /**
15 - * Registers the REST API routes for URL Details.
16 - *
17 - * @since 5.0.0
14 + * Registers the menu locations area REST API routes.
18 15 */
19 -function gutenberg_register_url_details_routes() {
20 - $url_details_controller = new WP_REST_URL_Details_Controller();
21 - $url_details_controller->register_routes();
22 -}
23 -add_action( 'rest_api_init', 'gutenberg_register_url_details_routes' );
24 -
25 -/**
26 - * Registers the menu locations REST API routes.
27 - */
28 16 function gutenberg_register_rest_menu_location() {
29 17 $nav_menu_location = new WP_REST_Menu_Locations_Controller();
30 18 $nav_menu_location->register_routes();
31 19 }
@@ -31,33 +19,38 @@
31 19 }
32 20 add_action( 'rest_api_init', 'gutenberg_register_rest_menu_location' );
33 21
34 22 /**
35 - * Registers the navigation areas REST API routes.
23 + * Registers the menu locations area REST API routes.
36 24 */
37 -function gutenberg_register_rest_navigation_areas() {
38 - $navigation_areas = new WP_REST_Block_Navigation_Areas_Controller();
39 - $navigation_areas->register_routes();
25 +function gutenberg_register_rest_customizer_nonces() {
26 + $nav_menu_location = new WP_Rest_Customizer_Nonces();
27 + $nav_menu_location->register_routes();
40 28 }
41 -add_action( 'rest_api_init', 'gutenberg_register_rest_navigation_areas' );
29 +add_action( 'rest_api_init', 'gutenberg_register_rest_customizer_nonces' );
42 30
43 31 /**
44 - * Registers the customizer nonces REST API routes.
32 + * Registers the Sidebars & Widgets REST API routes.
45 33 */
46 -function gutenberg_register_rest_customizer_nonces() {
47 - $customizer_nonces = new WP_Rest_Customizer_Nonces();
48 - $customizer_nonces->register_routes();
34 +function gutenberg_register_sidebars_and_widgets_endpoint() {
35 + $sidebars = new WP_REST_Sidebars_Controller();
36 + $sidebars->register_routes();
37 +
38 + $widget_types = new WP_REST_Widget_Types_Controller();
39 + $widget_types->register_routes();
40 + $widgets = new WP_REST_Widgets_Controller();
41 + $widgets->register_routes();
49 42 }
50 -add_action( 'rest_api_init', 'gutenberg_register_rest_customizer_nonces' );
43 +add_action( 'rest_api_init', 'gutenberg_register_sidebars_and_widgets_endpoint' );
51 44
52 45 /**
53 - * Registers the Block editor settings REST API routes.
46 + * Registers the Batch REST API routes.
54 47 */
55 -function gutenberg_register_block_editor_settings() {
56 - $editor_settings = new WP_REST_Block_Editor_Settings_Controller();
57 - $editor_settings->register_routes();
48 +function gutenberg_register_batch_endpoint() {
49 + $batch = new WP_REST_Batch_Controller();
50 + $batch->register_routes();
58 51 }
59 -add_action( 'rest_api_init', 'gutenberg_register_block_editor_settings' );
52 +add_action( 'rest_api_init', 'gutenberg_register_batch_endpoint' );
60 53
61 54 /**
62 55 * Hook in to the nav menu item post type and enable a post type rest endpoint.
63 56 *
@@ -169,54 +162,31 @@
169 162 }
170 163 add_filter( 'get_sample_permalink', 'gutenberg_auto_draft_get_sample_permalink', 10, 5 );
171 164
172 165 /**
173 - * Filters WP_User_Query arguments when querying users via the REST API.
166 + * Registers the post format search handler.
174 167 *
175 - * Allow using the has_published_post argument.
168 + * @param string $search_handlers Title list of current handlers.
176 169 *
177 - * @param array $prepared_args Array of arguments for WP_User_Query.
178 - * @param WP_REST_Request $request The REST API request.
179 - *
180 - * @return array Returns modified $prepared_args.
170 + * @return array Title updated list of handlers.
181 171 */
182 -function gutenberg_rest_user_query_has_published_posts( $prepared_args, $request ) {
183 - if ( ! empty( $request['has_published_posts'] ) ) {
184 - $prepared_args['has_published_posts'] = ( true === $request['has_published_posts'] )
185 - ? get_post_types( array( 'show_in_rest' => true ), 'names' )
186 - : (array) $request['has_published_posts'];
172 +function gutenberg_post_format_search_handler( $search_handlers ) {
173 + if ( current_theme_supports( 'post-formats' ) ) {
174 + $search_handlers[] = new WP_REST_Post_Format_Search_Handler();
187 175 }
188 - return $prepared_args;
176 +
177 + return $search_handlers;
189 178 }
190 -add_filter( 'rest_user_query', 'gutenberg_rest_user_query_has_published_posts', 10, 2 );
179 +add_filter( 'wp_rest_search_handlers', 'gutenberg_post_format_search_handler', 10, 5 );
191 180
192 -
193 181 /**
194 - * Filters REST API collection parameters for the users controller.
182 + * Registers the terms search handler.
195 183 *
196 - * @param array $query_params JSON Schema-formatted collection parameters.
184 + * @param string $search_handlers Title list of current handlers.
197 185 *
198 - * @return array Returns the $query_params with "has_published_posts".
186 + * @return array Title updated list of handlers.
199 187 */
200 -function gutenberg_rest_user_collection_params_has_published_posts( $query_params ) {
201 - $query_params['has_published_posts'] = array(
202 - 'description' => __( 'Limit result set to users who have published posts.', 'gutenberg' ),
203 - 'type' => array( 'boolean', 'array' ),
204 - 'items' => array(
205 - 'type' => 'string',
206 - 'enum' => get_post_types( array( 'show_in_rest' => true ), 'names' ),
207 - ),
208 - );
209 - return $query_params;
188 +function gutenberg_term_search_handler( $search_handlers ) {
189 + $search_handlers[] = new WP_REST_Term_Search_Handler();
190 + return $search_handlers;
210 191 }
211 -add_filter( 'rest_user_collection_params', 'gutenberg_rest_user_collection_params_has_published_posts' );
212 -
213 -/**
214 - * Registers the Edit Site's Export REST API routes.
215 - *
216 - * @return void
217 - */
218 -function gutenberg_register_edit_site_export_endpoint() {
219 - $editor_settings = new WP_REST_Edit_Site_Export_Controller();
220 - $editor_settings->register_routes();
221 -}
222 -add_action( 'rest_api_init', 'gutenberg_register_edit_site_export_endpoint' );
192 +add_filter( 'wp_rest_search_handlers', 'gutenberg_term_search_handler', 10, 5 );