Using WordPress Settings API tutorial I created a new custom menu and corresponding sub menus. Each of my menus have a page of its own. I used add_menu_page()
and add_submenu_page()
for that. (Here is the Complete Code)
Admin——–
» Special Admin
» Price Quotation
Now I’m trying to make a Plugin for some additional purposes. I want to integrate my plugin with the custom menu, I created earlier.
I placed a checkbox saying “Activate Price Quotation” in the “Special Admin” page. When the user Activates the Price Quotation the plugin will come into action. Then plugin will be available in the “Price Quotation” submenu_page.
There I’ll make some tabbed pages under the Price Quotation page with some certain functionalities.
I tried with a basic plugin with add_plugins_page()
:
<?php
/*
* Plugin Name: Price Quotation
* Plugin URI: http://www.example.com
* Author: Mayeenul Islam
* Author URI: http://www.example.com
* Version: 1.0.0
*/
?>
<?php
function add_a_menu(){
add_plugins_page(
'Price Factor',
'Price Factor',
'edit_posts',
'edit_private_posts',
'price_factor_callback'
);
}
add_action('admin_menu', 'add_a_menu');
function price_factor_callback(){
echo "This is Price Quotation Page";
}
?>
But this admin_menu
filter added the menu under the default “Plugins” menu by default. How can I manage to call the menu or menus where I decided them to?
Use add_submenu_page instead.
$parent_slug
should be one of the followingExample: