Skip to Content
Menu

requested_url()

Get the full URL.

PHP July 8, 2017

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”.

Request or provide clarification »

Was this page helpful? Yes No


    A feedback message is required to submit this form.


    Please check that you have entered a valid email address.

    Enter your email address if you would like a response.

    Thank you for your feedback!

    Source File

    Located in /libs/Utilities/Utilities.php on line 430.

    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;}
    
                $protocol = ( is_ssl() )? 'https' : 'http';
                $full_url = $protocol . '://' . $this->super->server["$host"] . $this->super->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');