rest_url() WordPress Function
The rest_url() function is used to retrieve the URL of the REST API. This function is useful for making REST API calls from JavaScript or other programming languages. The URL returned by this function can be used to access the WordPress REST API.
rest_url( string $path = '', string $scheme = 'rest' ) #
Retrieves the URL to a REST endpoint.
Description
Note: The returned URL is NOT escaped.
Parameters
- $path
(string)(Optional) REST route.
Default value: ''
- $scheme
(string)(Optional) Sanitization scheme.
Default value: 'rest'
Return
(string) Full URL to the endpoint.
Source
File: wp-includes/rest-api.php
function rest_url( $path = '', $scheme = 'rest' ) { return get_rest_url( null, $path, $scheme ); }
Expand full source codeCollapse full source codeView on TracView on GitHub
Related
Uses
Uses | Description |
---|---|
wp-includes/rest-api.php:get_rest_url() | Retrieves the URL to a REST endpoint on a site. |
Used By
Used By | Description |
---|---|
wp-includes/rest-api/class-wp-rest-server.php:WP_REST_Server::add_image_to_index() | Exposes an image through the WordPress REST API. |
wp-includes/rest-api/endpoints/class-wp-rest-menu-items-controller.php:WP_REST_Menu_Items_Controller::prepare_links() | Prepares links for the request. |
wp-includes/rest-api/endpoints/class-wp-rest-menu-items-controller.php:WP_REST_Menu_Items_Controller::get_schema_links() | Retrieve Link Description Objects that should be added to the Schema for the posts collection. |
wp-includes/rest-api/endpoints/class-wp-rest-menu-items-controller.php:WP_REST_Menu_Items_Controller::create_item() | Creates a single post. |
wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php:WP_REST_Global_Styles_Controller::get_theme_item() | Returns the given theme global styles config. |
wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php:WP_REST_Global_Styles_Controller::prepare_links() | Prepares links for the request. |
wp-includes/rest-api/endpoints/class-wp-rest-menus-controller.php:WP_REST_Menus_Controller::prepare_links() | Prepares links for the request. |
wp-includes/rest-api/endpoints/class-wp-rest-menus-controller.php:WP_REST_Menus_Controller::create_item() | Creates a single term in a taxonomy. |
wp-includes/rest-api/endpoints/class-wp-rest-menu-locations-controller.php:WP_REST_Menu_Locations_Controller::prepare_links() | Prepares links for the request. |
wp-includes/rest-api/endpoints/class-wp-rest-widgets-controller.php:WP_REST_Widgets_Controller::prepare_links() | Prepares links for the widget. |
wp-includes/rest-api/endpoints/class-wp-rest-sidebars-controller.php:WP_REST_Sidebars_Controller::prepare_links() | Prepares links for the sidebar. |
wp-includes/rest-api/endpoints/class-wp-rest-templates-controller.php:WP_REST_Templates_Controller::prepare_links() | Prepares links for the request. |
wp-includes/rest-api/endpoints/class-wp-rest-templates-controller.php:WP_REST_Templates_Controller::create_item() | Creates a single template. |
wp-includes/rest-api/endpoints/class-wp-rest-widget-types-controller.php:WP_REST_Widget_Types_Controller::prepare_links() | Prepares links for the widget type. |
wp-includes/rest-api/class-wp-rest-server.php:WP_REST_Server::add_active_theme_link_to_index() | Adds a link to the active theme for users who have proper permissions. |
wp-includes/rest-api/endpoints/class-wp-rest-themes-controller.php:WP_REST_Themes_Controller::prepare_links() | Prepares links for the request. |
wp-includes/rest-api/endpoints/class-wp-rest-application-passwords-controller.php:WP_REST_Application_Passwords_Controller::prepare_links() | Prepares links for the request. |
wp-includes/rest-api/search/class-wp-rest-term-search-handler.php:WP_REST_Term_Search_Handler::prepare_item_links() | Prepares links for the search result of a given ID. |
wp-includes/rest-api/endpoints/class-wp-rest-block-directory-controller.php:WP_REST_Block_Directory_Controller::prepare_links() | Generates a list of links to include in the response for the plugin. |
wp-includes/rest-api/endpoints/class-wp-rest-plugins-controller.php:WP_REST_Plugins_Controller::prepare_links() | Prepares links for the request. |
wp-includes/rest-api/endpoints/class-wp-rest-plugins-controller.php:WP_REST_Plugins_Controller::create_item() | Uploads a plugin and optionally activates it. |
wp-includes/rest-api/endpoints/class-wp-rest-block-types-controller.php:WP_REST_Block_Types_Controller::prepare_links() | Prepares links for the request. |
wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php:WP_REST_Attachments_Controller::edit_media_item() | Applies edits to a media item and creates a new attachment record. |
wp-admin/includes/class-wp-site-health.php:WP_Site_Health::get_test_rest_availability() | Test if the REST API is accessible. |
wp-admin/includes/class-wp-site-health.php:WP_Site_Health::get_tests() | Return a set of tests that belong to the site status page. |
wp-includes/rest-api/endpoints/class-wp-rest-search-controller.php:WP_REST_Search_Controller::get_items() | Retrieves a collection of search results. |
wp-includes/rest-api/endpoints/class-wp-rest-search-controller.php:WP_REST_Search_Controller::prepare_item_for_response() | Prepares a single search result for response. |
wp-includes/rest-api/endpoints/class-wp-rest-themes-controller.php:WP_REST_Themes_Controller::prepare_item_for_response() | Prepares a single theme output for response. |
wp-includes/rest-api/search/class-wp-rest-post-search-handler.php:WP_REST_Post_Search_Handler::prepare_item_links() | Prepares links for the search result of a given ID. |
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php:WP_REST_Posts_Controller::get_schema_links() | Retrieve Link Description Objects that should be added to the Schema for the posts collection. |
wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php:WP_REST_Users_Controller::prepare_links() | Prepares links for the user request. |
wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php:WP_REST_Users_Controller::create_item() | Creates a single user. |
wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php:WP_REST_Users_Controller::get_items() | Retrieves all users. |
wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php:WP_REST_Revisions_Controller::prepare_item_for_response() | Prepares the revision for the REST response. |
wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php:WP_REST_Revisions_Controller::get_items() | Gets a collection of revisions. |
wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php:WP_REST_Attachments_Controller::create_item() | Creates a single attachment. |
wp-includes/rest-api/endpoints/class-wp-rest-post-statuses-controller.php:WP_REST_Post_Statuses_Controller::prepare_item_for_response() | Prepares a post status object for serialization. |
wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php:WP_REST_Terms_Controller::prepare_links() | Prepares links for the request. |
wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php:WP_REST_Terms_Controller::create_item() | Creates a single term in a taxonomy. |
wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php:WP_REST_Terms_Controller::get_items() | Retrieves terms associated with a taxonomy. |
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php:WP_REST_Posts_Controller::prepare_links() | Prepares links for the request. |
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php:WP_REST_Posts_Controller::create_item() | Creates a single post. |
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php:WP_REST_Posts_Controller::get_items() | Retrieves a collection of posts. |
wp-includes/rest-api/endpoints/class-wp-rest-taxonomies-controller.php:WP_REST_Taxonomies_Controller::prepare_item_for_response() | Prepares a taxonomy object for serialization. |
wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php:WP_REST_Post_Types_Controller::prepare_item_for_response() | Prepares a post type object for serialization. |
wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php:WP_REST_Comments_Controller::prepare_links() | Prepares links for the request. |
wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php:WP_REST_Comments_Controller::create_item() | Creates a comment. |
wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php:WP_REST_Comments_Controller::get_items() | Retrieves a list of comment items. |
wp-includes/rest-api/class-wp-rest-request.php:WP_REST_Request::from_url() | Retrieves a WP_REST_Request object from a full URL. |
wp-includes/rest-api.php:rest_output_link_wp_head() | Outputs the REST API link tag into page header. |
wp-includes/rest-api.php:rest_output_link_header() | Sends a Link header for the REST API. |
wp-includes/embed.php:get_oembed_endpoint_url() | Retrieves the oEmbed endpoint URL for a given permalink. |
wp-includes/rest-api/class-wp-rest-server.php:WP_REST_Server::get_data_for_route() | Retrieves publicly-visible data for the route. |
wp-includes/rest-api/class-wp-rest-server.php:WP_REST_Server::get_namespace_index() | Retrieves the index for a namespace. |
wp-includes/media.php:wp_enqueue_media() | Enqueues all scripts, styles, settings, and templates necessary to use all media JS APIs. |
Changelog
Version | Description |
---|---|
4.4.0 | Introduced. |