I am creating a wordpress plugin that has it’s own UI. It looks like a standard web application, so everything that is done within the plugin is handled in this UI instead of integrating it with the WP admin area. My issue seems to be that I can’t get it to load as a separate page, I can only get it to load in a page created in the admin area with the UI embedded in the content block. When I add it to the menu like this:
// Add plugin UI submenu item
add_submenu_page(
'myPlugin', 'myPlugin WP', __('myPlugin UI', 'myPlugin'),
$capability, 'myPlugin-ui', 'myPlugin_router'
);
And have it accessing the page as such:
function myPlugin_router() {
// Get current screen details
$screen = get_current_screen();
if(strpos($screen->base, 'myPlugin-ui') !== false) {
include(DS_ROOT_PATH.'/views/myPlugin-ui.php');
}
}
Is this because I am using “include” to add it, so it is loading it as a template?
I am also planning on using this UI the same way wordpress admin does, and load separate pages inside of the content area of the UI, exactly the way WP is doing it to my UI. So it uses templates. Would I just use include like above to do so?
I’ll preface this by saying I think it’s a really bad idea, but you could circumvent the admin UI by hooking an action that happens after things are initialized, but before any output occurs: