How to Call Specific .PHP file on add_submenu_page selection in Plugin Development?
Question
I want to structure my Plugin folder & file system in a way, where in add_submenu_page when I will click on my sub menu link it will call separate .php file where i will car specific function which will do their job.
This is my Code.
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
/* Adding Plugin Menu to WordPress Dashboard */
add_action('admin_menu', 'myfunction_admin_menu');
/** Admin Menu **/
function myfunction_admin_menu()
{
// Double check user capabilities
if ( !current_user_can('manage_options') ) {
return;
}
// Adding main menu in administrative area.
add_menu_page('Digital', 'Menu', 'manage_options', 'myfunction', 'myfunction_settings_page', plugins_url('digisol/assets/images/myfunction.png'), 100 );
add_submenu_page('myfunction', 'Option 1', 'Option 1', 'manage_options', 'mydifferentfile.php');
}
function myfunction_settings_page()
{
// Double check user capabilities
if ( !current_user_can('manage_options') ) {
return;
}
?>
<div class="wrap">
<h1><?php esc_html_e( get_admin_page_title() ); ?></h1>
<p><?php esc_html_e( 'Some content.', 'myfunction' ); ?></p>
</div>
<?php
}
Where my submenu myfunction will call mydifferentfile.php file from plugin’s includes folder.
In that file I want Store Some information (Insert/Update/Delete/Display) Operations in specific table of database.
So How can I implement it.?
Thank you.
0
8 months
2022-06-09T08:33:53-05:00
2022-06-09T08:33:53-05:00 0 Answers
0 views
0
Leave an answer