create_initial_rest_routes()
Registers default REST API routes.
Description Description
Source Source
File: wp-includes/rest-api.php
function create_initial_rest_routes() { foreach ( get_post_types( array( 'show_in_rest' => true ), 'objects' ) as $post_type ) { $controller = $post_type->get_rest_controller(); if ( ! $controller ) { continue; } $controller->register_routes(); if ( post_type_supports( $post_type->name, 'revisions' ) ) { $revisions_controller = new WP_REST_Revisions_Controller( $post_type->name ); $revisions_controller->register_routes(); } if ( 'attachment' !== $post_type->name ) { $autosaves_controller = new WP_REST_Autosaves_Controller( $post_type->name ); $autosaves_controller->register_routes(); } } // Post types. $controller = new WP_REST_Post_Types_Controller; $controller->register_routes(); // Post statuses. $controller = new WP_REST_Post_Statuses_Controller; $controller->register_routes(); // Taxonomies. $controller = new WP_REST_Taxonomies_Controller; $controller->register_routes(); // Terms. foreach ( get_taxonomies( array( 'show_in_rest' => true ), 'object' ) as $taxonomy ) { $class = ! empty( $taxonomy->rest_controller_class ) ? $taxonomy->rest_controller_class : 'WP_REST_Terms_Controller'; if ( ! class_exists( $class ) ) { continue; } $controller = new $class( $taxonomy->name ); if ( ! is_subclass_of( $controller, 'WP_REST_Controller' ) ) { continue; } $controller->register_routes(); } // Users. $controller = new WP_REST_Users_Controller; $controller->register_routes(); // Comments. $controller = new WP_REST_Comments_Controller; $controller->register_routes(); /** * Filters the search handlers to use in the REST search controller. * * @since 5.0.0 * * @param array $search_handlers List of search handlers to use in the controller. Each search * handler instance must extend the `WP_REST_Search_Handler` class. * Default is only a handler for posts. */ $search_handlers = apply_filters( 'wp_rest_search_handlers', array( new WP_REST_Post_Search_Handler() ) ); $controller = new WP_REST_Search_Controller( $search_handlers ); $controller->register_routes(); // Block Renderer. $controller = new WP_REST_Block_Renderer_Controller; $controller->register_routes(); // Settings. $controller = new WP_REST_Settings_Controller; $controller->register_routes(); // Themes. $controller = new WP_REST_Themes_Controller; $controller->register_routes(); }
Expand full source code Collapse full source code View on Trac
Changelog Changelog
Version | Description |
---|---|
4.7.0 | Introduced. |