Create a free scripts and styles template within a plugin

Let me explain what Im trying to do. Im creating a plugin that will have a main page like a dashboard that will be used to manage the public facing side of the plugin. Just think like a separate app inside a normal WordPress site.

That page needs to be completely separate from user theme as will be totally custom. Admin bar will be used, nothing else.

My first thought was to create a page with a custom template (already done that) and second step would be to remove all actions from wp_header + wp_footer and remove all scripts and styles that are not WordPress core.

So currently Im stuck on step 2 and before going forward Im wondering if there is another way to do this that Im missing.

Solutions Collecting From Web of "Create a free scripts and styles template within a plugin"

It seems a little odd to only offer the admin bar for a page, but the easiest solution I can think of would be to use conditional functions to deregister scripts/styles and create custom template files for this specific page.
Unfortunately, you’ll have to figure out all the styles/scripts that are loaded

add_action('init', 'remove_all_the_things');

function remove_all_the_things() {

  if (is_page(123)) {
    // etc
    // remove other actions/filters as well

and you can create a custom header/footer with

header-empty.php & footer-empty.php

calling get_header('empty'); & get_footer('empty'); in your page template


This is what I´ve done so far, I won’t mark as correct answer yet in case there is a better approach that Im not aware.

add_action('wp_enqueue_scripts',array( $this, 'remove_all_actions'), 99);
public function remove_all_actions(){
        if( 'custom-template.php' != get_page_template_slug( get_queried_object_id() ))
        global $wp_scripts, $wp_styles;

        $exceptions = array(

        foreach( $wp_scripts->queue as $handle ){
            if( in_array($handle, $exceptions))

        foreach( $wp_styles->queue as $handle ){
            if( in_array($handle, $exceptions) )

        // Now remove actions
        $action_exceptions = array(


        // No core action in header

        global $wp_filter;
        foreach( $wp_filter['wp_footer'] as $priority => $handle ){

            if( in_array( key($handle), $action_exceptions ) )
            unset( $wp_filter['wp_footer'][$priority] );