Skip to content

Instantly share code, notes, and snippets.

@jessestu
Last active October 27, 2023 14:40
Show Gist options
  • Save jessestu/3ac7c2148a1df3ac6d6ae6bfecb5f609 to your computer and use it in GitHub Desktop.
Save jessestu/3ac7c2148a1df3ac6d6ae6bfecb5f609 to your computer and use it in GitHub Desktop.

Disable WordPress.com admin bar

This walkthrough disables the WordPress.com admin bar when needed to reveal the default WordPress admin bar on WordPress.com sites using the Business plan.

What to do next:

  1. Install Code Snippets on your site: https://wordpress.com/plugins/code-snippets
  2. Activate code snippets either on that installation page or by going to My Site → WP-Admin → Plugins
  3. Go to My Site → WP-Admin → Snippets → Add New.
  4. Create a new snippet and name it Disable WordPress.com admin bar or something similar.
  5. Copy and paste the PHP code in the window below into the Code textarea.
  6. Choose "Run snippet everywhere."
  7. Save the changes.

Congratulations! You should now have the default WordPress admin bar on your WordPress.com site.

function disable_wpcomtoolbar ( $modules ) {
if ( isset( $modules['masterbar'] ) ) {
unset( $modules['masterbar'] );
}
return $modules;
}
add_filter( 'jetpack_get_available_modules', 'disable_wpcomtoolbar' );
@neoswf
Copy link

neoswf commented Aug 1, 2023

Why to install a code snippers plugin, when you can create a micro plugin and run it by yourself?

<?php
/**
 * Plugin Name: Disable Jetpack Admin-bar
 * Plugin URI: https://your_url.com
 * Description: Bring back self hosted admin-bar, and all its buttons
 * Version: 1.0.0
 * Author: Jess
 */

function disable_wpcomtoolbar ( $modules ) {
    if ( isset( $modules['masterbar'] ) ) {
      unset( $modules['masterbar'] );
    }
    return $modules;
}
add_filter( 'jetpack_get_available_modules', 'disable_wpcomtoolbar' );
?>

@jessestu
Copy link
Author

jessestu commented Aug 2, 2023

That's a great solution, too, @neoswf! Thanks for adding!

@neoswf
Copy link

neoswf commented Oct 27, 2023

You welcome @jessestu. I add all my codes using this technique. Creating tiny plugins, enabling/disabling them, and like that I control my codebase and the app's health. Like that I exclude the need for another plugin on my site, another potential vulnerability problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment