rest_url

Retrieves the URL to a REST endpoint.

Description

(string) rest_url( (string) $path = '', (string) $scheme = 'json' ); 

Note: The returned URL is NOT escaped.

Returns (string)

Full URL to the endpoint.

Parameters (2)

0. $path — Optional. (string) => ''
REST route. Default empty.
1. $scheme — Optional. (string) => 'json'
Sanitization scheme. Default json..

Usage

  1. if ( !function_exists( 'rest_url' ) ) { 
  2. require_once ABSPATH . WPINC . '/rest-api.php'; 
  3.  
  4. // Optional. REST route. Default empty. 
  5. $path = ''; 
  6.  
  7. // Optional. Sanitization scheme. Default 'json'. 
  8. $scheme = 'json'; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = rest_url($path, $scheme); 
  12.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/rest-api.php  
  1. function rest_url( $path = '', $scheme = 'json' ) { 
  2. return get_rest_url( null, $path, $scheme );