0

In the WP Admin panel, I have a plugin that does certain calculations based on input from a form. I need it to print pretty, so I am attempting to render the plugin page without the admin menu etc.

I thought that remove_action( 'wp_footer', 'wp_admin_bar_render', 10000 ); would accomplish this, but it seems to not be working as it still renders the admin panel, and not just a blank white page.

Here's what I have:

public function cpui_setup()
{
    add_submenu_page( NULL, __( 'WooCommerce Print Order Recipe', 'woocommerce' ),  __( 'Print Recipe', 'woocommerce' ) , 'manage_woocommerce', 'cpui_print_recipe', array( $this, 'print_recipe_page' ) );
}

public function print_recipe_page()
{
    remove_action( 'wp_footer', 'wp_admin_bar_render', 1000 );
    require_once( 'admin/print_recipe.php' );
}
...

What am I overlooking?

1

2 Answers 2

2

In modern WordPress toolbar is considered mandatory part of admin. That is WordPress is explicitly opinionated about not letting you to disable it. While you still can kind of hack it out, it's unnecessary struggle.

If you need a blank page there is no reason to struggle with blanking admin interface for it. You could simply use wp-admin/admin-post.php to handle your form. Ajax endpoint would work just as well, or maybe even custom "pretty" URL endpoint.

1
  • This answer seems to be correct: All other solutions don't seem to work, and the only way to "hide" the admin bar seems to be with CSS. Thanks for the insight.
    – visevo
    May 5, 2015 at 0:10
0

If you will disable the admin bar for all users on this page, use this

wp_deregister_script( 'admin-bar' );
        wp_deregister_style( 'admin-bar' );
        remove_action( 'init', '_wp_admin_bar_init' );  
    remove_action( 'wp_footer', 'wp_admin_bar_render', 1000 );  
    remove_action( 'admin_footer', 'wp_admin_bar_render', 1000 ); 

in a function, where you check for your plugin page, like with get_current_sreen(). The codex have all information and examples.

2
  • show_admin_bar() no longer allows to disable toolbar in admin, WP will just ignore it.
    – Rarst
    May 1, 2015 at 20:21
  • You have right, update the answer. Also it is a wrong goal in my eyes, to remove the admin bar only on one page.
    – bueltge
    May 1, 2015 at 20:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.