Check if add_menu_page exists or not

You can use the fourth parameter of add_menu_page(), the my_unique_slug, to check if the page exists:

if ( empty ( $GLOBALS['admin_page_hooks']['my_unique_slug'] ) )
    add_menu_page(
        'Page Title',
        'Top Menu Title',
        'manage_options',
        'my_unique_slug',
        'my_magic_function'
    );

$GLOBALS['admin_page_hooks'] is the list of registered pages.

Leave a Comment