Blog

Getting the Current Full URL of any page in Pods 1.9.6

Pods 1.9.6 isn’t out yet, we’re waiting on the fully working TinyMCE API to be ready, but once it is, we’ve added a new function called get_current_url()

You can use get_current_url() to get the full URL including the protocol, current hostname, and URI. This differs from just using $_SERVER[‘REQUEST_URI’] because it’s absolute. You can use this on your Pod Pages or when needing the real URL of a page. This function works both inside WP and outside WP (if WP is init via an include) and it gets the current HTTP_HOST which could possibly differ from a normal get_bloginfo(‘wpurl’)

function get_current_url () {
    $url = 'http';
    if (isset($_SERVER['HTTPS']) && 'off' != $_SERVER['HTTPS'] && 0 != $_SERVER['HTTPS'])
        $url = 'https';
    $url .= '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
    return apply_filters('get_current_url', $url);
}