Usage
PHP
nebula()->requested_url($host)
Parameters
$host
(Optional) (String) Which $_SERVER variable to use
Default: "HTTP_HOST"
Parameter Notes
$host could either be “HTTP_HOST” (default) or “SERVER_NAME”.
Source File
Located in /libs/Utilities/Utilities.php on line 662.
1 Hook
Find these filters and actions in the source code below to hook into them. Use do_action() and add_filter() in your functions file or plugin.
Filters
"pre_nebula_requested_url"Need a new filter hook? Request one here.
Actions
This function has no action hooks available. Request one?
PHP
public function requested_url($host="HTTP_HOST"){ //Can use "SERVER_NAME" as an alternative to "HTTP_HOST"
$override = apply_filters('pre_nebula_requested_url', null, $host);
if ( isset($override) ){
return $override;
}
//Bail early if CLI or no REQUEST_URI
if ( $this->is_cli() || empty($this->super->server['REQUEST_URI']) ){
return null;
}
//Check if host key exists
$server = $this->super->server;
if ( !isset($server[$host]) || empty($server[$host]) ){
//Fall back to SERVER_NAME or return null
if ( !empty($server['SERVER_NAME']) ){
$server[$host] = $server['SERVER_NAME'];
} else {
return null;
}
}
$protocol = is_ssl() ? 'https' : 'http';
$full_url = $protocol . '://' . $server[$host] . $server['REQUEST_URI'];
return esc_url($full_url);
}
Override
To override this PHP function, use this hook in your child theme or plugin ("my_custom" can be changed):
PHP
add_filter('pre_nebula_requested_url', 'my_custom_requested_url', 10, 2); //The last integer must be 1 more than the actual parameters
function my_custom_requested_url($null, $host){ //$null is required, but can be ignored
//Write your own code here
return true; //Return true to prevent the original function from running afterwords
}
You can completely disable this PHP function with a single line actions:
PHP
add_filter('pre_nebula_requested_url', '__return_false');