函数
menu_page_url ( $menu_slug, $display = true )
- 参数
-
-
(string)
$menu_slug
The slug name to refer to this menu by (should be unique for this menu).- Required: 是
-
(bool)
$display
Optional. Whether or not to display the URL. Default true.- Required: 否
- Default: true
-
(string)
- 返回值
-
- (string) The menu page URL.
- 定义位置
-
-
wp-admin/includes/plugin.php
, line 1837
-
wp-admin/includes/plugin.php
- 引入
- 3.0.0
- 弃用
- –
Gets 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.
function menu_page_url( $menu_slug, $display = 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 ( $display ) { echo $url; } return $url; }
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。