Retrieves the URL to a REST endpoint.
Description
Note: The returned URL is NOT escaped.
Parameters
$path
stringoptional- REST route.
Default:
''
$scheme
stringoptional- Sanitization scheme. Default
'rest'
.Default:
'rest'
Return
string Full URL to the endpoint.Source
function rest_url( $path = '', $scheme = 'rest' ) {
return get_rest_url( null, $path, $scheme );
}
Related
Uses | Description |
---|---|
get_rest_url()wp-includes/rest-api.php | Retrieves the URL to a REST endpoint on a site. |
Used by | Description |
---|---|
WP_REST_Font_Faces_Controller::prepare_links()wp-includes/rest-api/endpoints/class-wp-rest-font-faces-controller.php | Prepares links for the request. |
WP_REST_Font_Families_Controller::prepare_font_face_links()wp-includes/rest-api/endpoints/class-wp-rest-font-families-controller.php | Prepares child font face links for the request. |
WP_REST_Font_Collections_Controller::prepare_links()wp-includes/rest-api/endpoints/class-wp-rest-font-collections-controller.php | Prepares links for the request. |
WP_REST_Font_Collections_Controller::get_items()wp-includes/rest-api/endpoints/class-wp-rest-font-collections-controller.php | Gets the font collections available. |
WP_REST_Template_Autosaves_Controller::prepare_links()wp-includes/rest-api/endpoints/class-wp-rest-template-autosaves-controller.php | Prepares links for the request. |
WP_REST_Template_Revisions_Controller::prepare_links()wp-includes/rest-api/endpoints/class-wp-rest-template-revisions-controller.php | Prepares links for the request. |
WP_REST_Navigation_Fallback_Controller::prepare_links()wp-includes/rest-api/endpoints/class-wp-rest-navigation-fallback-controller.php | Prepares the links for the request. |
WP_REST_Global_Styles_Revisions_Controller::get_items()wp-includes/rest-api/endpoints/class-wp-rest-global-styles-revisions-controller.php | Returns paginated revisions of the given global styles config custom post type. |
WP_REST_Post_Types_Controller::prepare_links()wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php | Prepares links for the request. |
WP_REST_Taxonomies_Controller::prepare_links()wp-includes/rest-api/endpoints/class-wp-rest-taxonomies-controller.php | Prepares links for the request. |
WP_REST_Server::add_image_to_index()wp-includes/rest-api/class-wp-rest-server.php | Exposes an image through the WordPress REST API. |
WP_REST_Menu_Items_Controller::prepare_links()wp-includes/rest-api/endpoints/class-wp-rest-menu-items-controller.php | Prepares links for the request. |
WP_REST_Menu_Items_Controller::get_schema_links()wp-includes/rest-api/endpoints/class-wp-rest-menu-items-controller.php | Retrieves Link Description Objects that should be added to the Schema for the nav menu items collection. |
WP_REST_Menu_Items_Controller::create_item()wp-includes/rest-api/endpoints/class-wp-rest-menu-items-controller.php | Creates a single nav menu item. |
WP_REST_Global_Styles_Controller::get_theme_item()wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php | Returns the given theme global styles config. |
WP_REST_Global_Styles_Controller::prepare_links()wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php | Prepares links for the request. |
WP_REST_Menus_Controller::prepare_links()wp-includes/rest-api/endpoints/class-wp-rest-menus-controller.php | Prepares links for the request. |
WP_REST_Menus_Controller::create_item()wp-includes/rest-api/endpoints/class-wp-rest-menus-controller.php | Creates a single term in a taxonomy. |
WP_REST_Menu_Locations_Controller::prepare_links()wp-includes/rest-api/endpoints/class-wp-rest-menu-locations-controller.php | Prepares links for the request. |
WP_REST_Widgets_Controller::prepare_links()wp-includes/rest-api/endpoints/class-wp-rest-widgets-controller.php | Prepares links for the widget. |
WP_REST_Sidebars_Controller::prepare_links()wp-includes/rest-api/endpoints/class-wp-rest-sidebars-controller.php | Prepares links for the sidebar. |
WP_REST_Templates_Controller::prepare_links()wp-includes/rest-api/endpoints/class-wp-rest-templates-controller.php | Prepares links for the request. |
WP_REST_Templates_Controller::create_item()wp-includes/rest-api/endpoints/class-wp-rest-templates-controller.php | Creates a single template. |
WP_REST_Widget_Types_Controller::prepare_links()wp-includes/rest-api/endpoints/class-wp-rest-widget-types-controller.php | Prepares links for the widget type. |
WP_REST_Server::add_active_theme_link_to_index()wp-includes/rest-api/class-wp-rest-server.php | Adds a link to the active theme for users who have proper permissions. |
WP_REST_Themes_Controller::prepare_links()wp-includes/rest-api/endpoints/class-wp-rest-themes-controller.php | Prepares links for the request. |
WP_REST_Application_Passwords_Controller::prepare_links()wp-includes/rest-api/endpoints/class-wp-rest-application-passwords-controller.php | Prepares links for the request. |
WP_REST_Term_Search_Handler::prepare_item_links()wp-includes/rest-api/search/class-wp-rest-term-search-handler.php | Prepares links for the search result of a given ID. |
WP_REST_Block_Directory_Controller::prepare_links()wp-includes/rest-api/endpoints/class-wp-rest-block-directory-controller.php | Generates a list of links to include in the response for the plugin. |
WP_REST_Plugins_Controller::prepare_links()wp-includes/rest-api/endpoints/class-wp-rest-plugins-controller.php | Prepares links for the request. |
WP_REST_Plugins_Controller::create_item()wp-includes/rest-api/endpoints/class-wp-rest-plugins-controller.php | Uploads a plugin and optionally activates it. |
WP_REST_Block_Types_Controller::prepare_links()wp-includes/rest-api/endpoints/class-wp-rest-block-types-controller.php | Prepares links for the request. |
WP_REST_Attachments_Controller::edit_media_item()wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php | Applies edits to a media item and creates a new attachment record. |
WP_Site_Health::get_test_rest_availability()wp-admin/includes/class-wp-site-health.php | Tests if the REST API is accessible. |
WP_Site_Health::get_tests()wp-admin/includes/class-wp-site-health.php | Returns a set of tests that belong to the site status page. |
WP_REST_Search_Controller::get_items()wp-includes/rest-api/endpoints/class-wp-rest-search-controller.php | Retrieves a collection of search results. |
WP_REST_Search_Controller::prepare_item_for_response()wp-includes/rest-api/endpoints/class-wp-rest-search-controller.php | Prepares a single search result for response. |
WP_REST_Post_Search_Handler::prepare_item_links()wp-includes/rest-api/search/class-wp-rest-post-search-handler.php | Prepares links for the search result of a given ID. |
WP_REST_Posts_Controller::get_schema_links()wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php | Retrieves Link Description Objects that should be added to the Schema for the posts collection. |
WP_REST_Users_Controller::prepare_links()wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php | Prepares links for the user request. |
WP_REST_Users_Controller::create_item()wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php | Creates a single user. |
WP_REST_Users_Controller::get_items()wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php | Retrieves all users. |
WP_REST_Revisions_Controller::prepare_item_for_response()wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php | Prepares the revision for the REST response. |
WP_REST_Revisions_Controller::get_items()wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php | Gets a collection of revisions. |
WP_REST_Attachments_Controller::create_item()wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php | Creates a single attachment. |
WP_REST_Post_Statuses_Controller::prepare_item_for_response()wp-includes/rest-api/endpoints/class-wp-rest-post-statuses-controller.php | Prepares a post status object for serialization. |
WP_REST_Terms_Controller::prepare_links()wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php | Prepares links for the request. |
WP_REST_Terms_Controller::create_item()wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php | Creates a single term in a taxonomy. |
WP_REST_Terms_Controller::get_items()wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php | Retrieves terms associated with a taxonomy. |
WP_REST_Posts_Controller::prepare_links()wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php | Prepares links for the request. |
WP_REST_Posts_Controller::create_item()wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php | Creates a single post. |
WP_REST_Posts_Controller::get_items()wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php | Retrieves a collection of posts. |
WP_REST_Comments_Controller::prepare_links()wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php | Prepares links for the request. |
WP_REST_Comments_Controller::create_item()wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php | Creates a comment. |
WP_REST_Comments_Controller::get_items()wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php | Retrieves a list of comment items. |
WP_REST_Request::from_url()wp-includes/rest-api/class-wp-rest-request.php | Retrieves a WP_REST_Request object from a full URL. |
rest_output_link_wp_head()wp-includes/rest-api.php | Outputs the REST API link tag into page header. |
rest_output_link_header()wp-includes/rest-api.php | Sends a Link header for the REST API. |
get_oembed_endpoint_url()wp-includes/embed.php | Retrieves the oEmbed endpoint URL for a given permalink. |
WP_REST_Server::get_data_for_route()wp-includes/rest-api/class-wp-rest-server.php | Retrieves publicly-visible data for the route. |
WP_REST_Server::get_namespace_index()wp-includes/rest-api/class-wp-rest-server.php | Retrieves the index for a namespace. |
Changelog
Version | Description |
---|---|
4.4.0 | Introduced. |
As an example, to get the rest endpoint for a given post: