admin管理员组

文章数量:1122846

I'm creating a plugin with custom pages on wp-admin side. I have the main level page, which is actually just the menu and then child pages, which opens different pages. So far it's working as expected. I can load the data I need and display it on the page as expected. This is my code so far:

add_action('admin_menu', function() {
  $icon = '<svg>...</svg>';
 
  add_menu_page('Financial', 'Financial', 'manage_options', 'myplugin-finance', 'render_page_base', 'data:image/svg+xml;base64,'.base64_encode($icon));
 
  // Add child pages
  add_submenu_page('myplugin-finance', 'Overview', 'Overview', 'manage_options', 'overview', 'render_page_overview');
  add_submenu_page('myplugin-finance', 'Transactions', 'Transactions', 'manage_options', 'transactions', 'render_page_transactions');
  add_submenu_page('myplugin-finance', 'Customers', 'Customers', 'manage_options', 'customers', 'render_page_customers');
  add_submenu_page('myplugin-finance', 'Transfers', 'Transfers', 'manage_options', 'transfers', 'render_page_transfers');
 
  // Remove parent from child menu list
  remove_submenu_page('myplugin-finance','myplugin-finance');
});

I tried to create the page details like this:

add_submenu_page('transactions', 'Transaction details', 'Transaction details', 'manage_options', 'transactions-details', 'render_page_transactions_details');

I can open this page, but the menu isn't opened and/or selected on the correct menu item. Is there a way to achieve this? Woocommerce product does what I want to do. If you select the list of products, the Woocommerce menu stay opened with Products selected. If you then select one product to edit its details, the menu stays the same. Forminator is also another plugin I use that does this, but I was not able to identify how they do that.

This is my desired result:

本文标签: plugin developmentCreate child of child custom page in wpadmin