A fast and easy solution is to fetch the slug with $_GET['page']
. Don’t forget to do some safety checks on the query after getting it.
Also, while i’m on it, to make the submenu items show up below your top level you need to change the first property of add_submenu_page
to your top level slug.
add_action( 'admin_menu', 'MyPlugin_AddAdminMenus' );
function MyPlugin_AddAdminMenus()
{
add_menu_page('General settings', 'MyPlugin', 'manage_options', 'my-plugin-General', 'render_generic_settings_page');
add_submenu_page('my-plugin-General', 'General settings', 'General settings', 'manage_options', 'my-plugin-General');
add_submenu_page('my-plugin-General', 'Lead capturing', 'Lead capturing', 'manage_options', 'my-plugin-SubPage1', 'render_generic_settings_page');
add_submenu_page('my-plugin-General', 'Toggle features', 'Toggle features', 'manage_options', 'my-plugin-SubPage2', 'render_generic_settings_page');
}
Related Posts:
- Hook if somebody saves plugin options?
- Where can I find a schema of wordpress plugin core architecture?
- How to Loop Plugin Option Field Set?
- Save and retrieve custom plugin options value
- How should I use register_setting, add_settings_section, & add_settings_field in my plugin’s options page?
- Using tabs for wordpress plugin
- How to handel multiple checkbox field in the admin settings page with Settings API
- Custom plugin settings: clicking “save changes” does not display success message
- How can I include a setting that has a variable number of values in a settings page using register_setting?
- Saving Plugin settings to the database
- check for the current screen
- Plugin set default setting value when it activated
- Stop the form of beign submitted on “Save changes” custom option page
- Add a Custom Permalink option in the Permalink Admin Screen?
- Settings API – input always updates over validation
- Wp die causing 500 Internal Server Error?
- redirect on theme switch – WordPress
- Can’t get plugin settings page to save data
- Why this global array is returning NULL from a callback function
- How to get specific setting by settings_fields()?
- Most efficient way to use classes to create admin pages using Settings API
- Show admin notice on incorrect value on form field
- Cannot display settings field
- Checkbox conflict in my custom plugin admin page
- Bulk update all posts from plugin settings screen
- Change the display of Settings API (do_settings_sections)
- Settings API saved values not getting shown in the dropdownbox
- Can I use register_settings and unregister_setting once the settings page has loaded?
- Update WP option by plugin
- How to save plugin custom settings page fields
- How to change php variable value using wp setting api
- Settings API Message Error is global
- 500 error when updating plugin option
- How to make sure settings are not lost when plugin is updated?
- Editable select options in quick edit OR in plugin settings
- How to save Setting pages data to the database?
- update_option_{$option} not working (do function after options are saved)
- How do I render content from a wp_editor in a plugin setting field?
- Settings Fields not showing up in Submenu Page
- How to save the option’s new values plus old value without overwrite old one
- WordPress Boilerplate Plugin doesn’t see callback functions for add_settings_field and add_settings_section
- How do I add a textarea (multirow) option to my WordPress plugin?
- WordPress Settings – Custom Button actions
- Option page not updating multiple records in settings api
- WordPress 4.1 plugin only save 1 field to database
- Creating a register settings class that supports extended classes
- Unable to Retrieve Setting Value for my Plugin
- Validating values using Settings API?
- Extend my plugin settings with hooks
- How can I save a setting field with multiple checkbox options generated by a foreach loop on a custom wordpress admin page?
- move setting data from wordpress api to codestar freamwork
- Making plugin unique to not conflict with plugins with the same name
- How to store ACF custom fields data in a custom table
- How to get posts by content?
- Trying to disable plugins doens’t work
- Plugins won’t update when WordPress says they’re updated
- Correct way to use register_activation_hook
- Have plugin require two other plugins
- How to include plugin without activation?
- How can I create a plugin installation link?
- CMB2 installation – cannot get it to work
- Plugin shortcodes not working in custom theme
- Best approach to fetch data from wp options to js file or php file
- Is there any W3C compatible Share & Follow plugin?
- What plugin should I use for booking events and receiving payments? [closed]
- Creating an online questionnaire form – by Importing the questions from a spreadsheet?
- The Events Calendar and Easy Digital Downloads adding customer notes to Attendee export
- Modifying a .js Function for Print [QZ Tray, WooCommerce POS]
- How does task scheduler plugin implements cron that is not dependent on page load request? [closed]
- Enabling WP_USE_EXT_MYSQL to support old plugin
- Can I load the textdomain before a plugin is activated?
- How can I position ShareThis buttons manually when using the plug-in? [closed]
- wordpress add_action() issue in ajax call
- Turning on output buffering in a wordpress plugin
- Is there a plugin for uploading files such as PDF files?
- Location dependent rendering of locations? [closed]
- get_comments_number() giving wrong results! What are alternatives?
- $pages = get_pages(‘child_of=’.$post->ID); Why arguments are concatenated?
- Disable variations on woo commerce if out of stock
- Add wordpress user database on android app
- Help with a function in a widget
- Is wp_deregister_script the best way to deal with unneeded plugins in a page?
- Error: Can´t access facebook comment plugin admin page
- Deregistering and registering javascript breaks plugin
- how to convert XML from URL to HTML
- [Plugin: WordPress.com Stats] Javascript not being added to footer
- Strange Cached File in Super Cache
- Fail on admin_enqueue_scripts when I try it to upload a CSS file to my WordPress Plugin
- Can we hide a certain user in WP?
- Block plugin update possibilities (but not by hiding notifications)
- Execute function activate/deactivate plugin in specific pages
- Why can I not deregister my style and script on custom post type?
- Using multi-dimensional array with filter
- database – multiple wordpress installations using same database – can they share plugin settings?
- How change menu for each user in plugin?
- Synch Custom Post Types (and Custom Fields, Cats, etc.) Between WordPress Sites
- Modifying lightbox plugin to allow for quoting, Does this exist? [closed]
- How to escape html code?
- A way to upload old html pages with all its assets via WordPress admin and to add a fixed menu on top of those (a la Wayback Machine)
- admin_enqueue_scripts using hook_suffix vs GET page