Filter hook 'rest_url'

in WP Core File wp-includes/rest-api.php at line 556

View Source

rest_url

Filter Hook
Description
Filters the REST URL. Use this filter to adjust the url returned by the get_rest_url() function.

Hook Information

File Location wp-includes/rest-api.php View on GitHub
Hook Type Filter
Line Number 556

Hook Parameters

Type Name Description
string $url REST URL.
string $path REST route.
int|null $blog_id Blog ID.
string $scheme Sanitization scheme.

Usage Examples

Basic Usage
<?php
// Hook into rest_url
add_filter('rest_url', 'my_custom_filter', 10, 4);

function my_custom_filter($url, $path, $blog_id, $scheme) {
    // Your custom filtering logic here
    return $url;
}

Source Code Context

wp-includes/rest-api.php:556 - How this hook is used in WordPress core
<?php
 551  	 * @param string   $url     REST URL.
 552  	 * @param string   $path    REST route.
 553  	 * @param int|null $blog_id Blog ID.
 554  	 * @param string   $scheme  Sanitization scheme.
 555  	 */
 556  	return apply_filters( 'rest_url', $url, $path, $blog_id, $scheme );
 557  }
 558  
 559  /**
 560   * Retrieves the URL to a REST endpoint.
 561   *

PHP Documentation

<?php
/**
	 * Filters the REST URL.
	 *
	 * Use this filter to adjust the url returned by the get_rest_url() function.
	 *
	 * @since 4.4.0
	 *
	 * @param string   $url     REST URL.
	 * @param string   $path    REST route.
	 * @param int|null $blog_id Blog ID.
	 * @param string   $scheme  Sanitization scheme.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 4
  • File: wp-includes/rest-api.php
Related Hooks

Related hooks will be displayed here in future updates.