无法在WordPress中获取url插件设置页面

时间:2014-12-15 05:27:41

标签: php wordpress plugins

我试图获取插件的插件设置网址,如下所示:

$settings_page_url = menu_page_url( 'zrdn-settings', false );

我已按如下方式添加了菜单页:

add_action('admin_menu', 'zrdn_menu_pages' );

// Adds module to left sidebar in wp-admin for ZLRecipe
function zrdn_menu_pages() {
    // Add the top-level admin menu
    $page_title = 'Zip Recipes Plugin Settings';
    $menu_title = 'Zip Recipes Plugin';
    $capability = 'manage_options';
    $menu_slug = 'zrdn-settings';
    $function = 'zrdn_settings';
    add_menu_page($page_title, $menu_title, $capability, $menu_slug, $function, 'dashicons-carrot');

    // Add submenu page with same slug as parent to ensure no duplicates
    $settings_title = 'Settings';
    add_submenu_page($menu_slug, $page_title, $settings_title, $capability, $menu_slug, $function);
}

$settings_page_url最终成为一个空字符串。

1 个答案:

答案 0 :(得分:0)

您可以使用

获取网址

$url = admin_url() . 'admin.php?page=' . $_GET['page']