menu_page_url() - WordPress 函数参考中文文档

返回介绍

menu_page_url()

发布于 2017-09-11 字数1805 浏览 867 评论 0

menu_page_url( string $menu_slug,  bool $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


参数

$menu_slug

(string)
(Required)
The slug name to refer to this menu by (should be unique for this menu)

$echo

(bool)
(Optional)
Whether or not to echo the url – default is true

Default value: true


返回值

(string) the url


源代码

File: wp-admin/includes/plugin.php

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;
}

更新日志

Version 描述
3.0.0 Introduced.

相关函数

Uses

  • wp-includes/formatting.php:
    esc_url()
  • wp-includes/functions.php:
    add_query_arg()
  • wp-includes/link-template.php:
    admin_url()

User Contributed Notes

上一篇:media_upload_video()

下一篇:metadata_exists()

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!