Add Admin menus or submenus depending on conditions

I managed to find a solution: File 1: //Count the number of active plugins whose Author is “My Brand”, and store the number in a global variable. $GLOBALS[‘mybrand_active_plugins’]=0; if (!function_exists(‘get_plugins’)){require_once ABSPATH.’wp-admin/includes/plugin.php’;} $plugins=get_plugins(); $activated_plugins=get_option(‘active_plugins’); foreach ($activated_plugins as $p){ if( (isset($plugins[$p])) AND ($plugins[$p][‘Author’]==’My Brand’)){ $GLOBALS[‘mybrand_active_plugins’]++; } } // Add menus on sidebar if($GLOBALS[‘mybrand_active_plugins’]<2) { function sub1_setup_menu() { … Read more

Adding Meta Box to Specific Submenu Page

I think for this you want to go with WordPress Setting API. If you prefer meta box. You have to add a do_action in your function which render the page (view_tasks_submenu_page_callback). do_action( ‘add_meta_boxes’, $hook_id ); And add do_meta_boxes($hook_id, $context, null) where you want your meta boxes appear. replace $hook_id by the fourth parameter of add_meta_box … Read more

How to keep the plugin submenu open on viewing a custom version of users.php?

You must use a different parent slug (first parameter) to keep the user menu as you want. An example, add_action(‘admin_menu’, ‘register_subscriber_submenu_page’); function wpdocs_register_subscriber_submenu_page() { add_submenu_page( ‘users.php’, ‘Subscribers’, ‘Subscribers’, ‘manage_options’, ‘custom-submenu-page’, ‘custom_callback_function’ ); } Try to prefix your plugin page slug, you can have conflict with such a name : ‘subscribers’ -> your-plugin-subscribers . You will … Read more

Create an administation subpage containing posts in a certain category

See my answer here on a similar question https://wordpress.stackexchange.com/posts/comments/401940?noredirect=1 that discusses a plugin I did that might start to meet your needs. The plugin is called Multisite Post Reader, and can be found here: https://wordpress.stackexchange.com/posts/comments/401940?noredirect=1 Comments about additional features can be posted in the plugin support page. If the plugin is not exactly what you … Read more

Admin submenu does not call function to load the page

I found my solution. Problem of hrefs when the wordpress core did not find the function callback or it’s empty for the functions add_menu_page() and add_submenu_page() the href wil be generated like this : http(s)://my-site.org/wp-admin/my-slug-page, otherwise the href is in this format : http(s)://my-site.org/wp-admin/admin.php?page=my-slug-page So In my case, I had to be sure the functions … Read more