Have you tried including the file?..
You can’t call a function from a file that’s not been loaded, so try an include first, then see if your function call works..
Hi,
Thanks for your reply.
I don’t think including the file is going to work there seems to be far to many includes that I will need.
I’ve been looking further into the code and what I actually want to use is the $menu and $submenu arrays that are used to build the admin menu in te dashboard.
Do you know if there is a way of accessing these from within a plugin?
Regards
Pete
include( 'wp-admin/menu.php' );
$menu and $submenu are defined there, include it and you’ll have access to the vars..
Also, if preferred, you hook an action onto..
_admin_menu
..instead of the include..
You you will likely need to globalise the $menu and $submenu vars when using the action hook..
add_action( '_admin_menu' , 'example' );
function example() {
global $menu, $submenu;
..
😉
Hi,
Thanks for your reply.
When I try and include the menu.php file I get the following error:
Warning: Invalid argument supplied for foreach() in /mnt/local/home/pjharrison/peterjharrison.me/wp-admin/menu.php on line 38
I think it has something to do with the $wp_taxonomies array, any ideas?
Regards
Pete
It’s because when you include the file, there’s no $wp_taxonomies var for it to loop over… where as when the file is usually included that var is present…
What do you think you should do ? … it’s your code … i can’t tell you how to write it .. 😉
Hi
Thanks for your help.
I guess I’ll have to try and find out what populates the $wp_taxonomies array and see if it will effect what im trying to do if I push it through as blank.
Regards
Pete