Advertisements

menu_page_url

Definition:
function menu_page_url($menu_slug, $echo = true) {}

Get the url to access a particular menu page based on the slug it was registered with.
If the slug hasn’t been registered properly no url will be returned

Parameters

  • string $menu_slug: The slug name to refer to this menu by (should be unique for this menu)
  • bool $echo: Whether or not to echo the url – default is true

Return values

returns:the url

Source code

function menu_page_url($menu_slug, $echo = true) {

	global $_parent_pages;



	if ( isset( $_parent_pages[$menu_slug] ) ) {

		$parent_slug = $_parent_pages[$menu_slug];

		if ( $parent_slug && ! isset( $_parent_pages[$parent_slug] ) ) {

			$url = admin_url( add_query_arg( 'page', $menu_slug, $parent_slug ) );

		} else {

			$url = admin_url( 'admin.php?page=' . $menu_slug );

		}

	} else {

		$url = '';

	}



	$url = esc_url($url);



	if ( $echo )

		echo $url;



	return $url;

}

2397

Advertisements

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: