mc4wp_get_current_url ()

Retrieves the URL of the current WordPress page

Return: (string) The current URL (escaped)

Source file: functions.php

View source


Used by

Uses


Source

function mc4wp_get_current_url() {

	global $wp;

	// get requested url from global $wp object
	$site_request_uri = $wp->request;

	// fix for IIS servers using index.php in the URL
	if( false !== stripos( $_SERVER['REQUEST_URI'], '/index.php/' . $site_request_uri ) ) {
		$site_request_uri = 'index.php/' . $site_request_uri;
	}

	// concatenate request url to home url
	$url = home_url( $site_request_uri );
	$url = trailingslashit( $url );

	return esc_url( $url );
}


Changelog

  • Since: WordPress 2.0

User Contributed Notes

You must log in before being able to contribute a note.