I’ve managed to add my own menu to the admin bar. I want the first menu item to link to my theme’s options page.
For example, is this 100% bulletproof or is there a direct method?
echo '<a href="'.get_admin_url().'admin.php?page=functions.php">Theme Options</a>';
Assuming the installation will never have a plugin register a page with that same name it should be safe, i’d suggest giving your registered page a uniquely prefixed name, and secondly if the page name refers to your theme’s functions file wouldn’t it then be calling the file directly(you shouldn’t ever be calling the theme functions file directly).
You can actually pass
get_admin_url
and alsoadmin_url
the path to append, to use it like this..or similarly..
No need for concatenation, and of course add the link html back as appropriate(left that out for brevity).
Another suggestion would be to not use the file name as the page value you registered, i keep seeing plugin’s do it, and it’s always driven me nuts, it makes more sense to just pass the page registration code a unique string, and not a filename(usually done using
__FILE__
which i personally find ugly and hacky).That would be my initial observations, ideally i’d like to see the code that registers the page and know where that registration code sits, ie. what file.
How about this:
Codex for admin_url.
Btw, are you adding a menu/submenu page for your custom theme options? You can use its slug here.