Skip to content

Instantly share code, notes, and snippets.

@swashcap
Created May 6, 2014 04:51
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save swashcap/864b93d2445b86a427a8 to your computer and use it in GitHub Desktop.
Save swashcap/864b93d2445b86a427a8 to your computer and use it in GitHub Desktop.
Easily remove the “Themes” and “Editor” submenus from the WordPress admin area.

According to a WordPress.org support thread, it’s very easy to remove the Themes and Editor sub-pages entirely, making it (nearly) impossible to change themes. Drop this in your functions.php file:

/**
 * Remove the 'Themes' submenu page.
 *
 * @link http://codex.wordpress.org/Function_Reference/remove_submenu_page
 *
 * @return void
 */
function remove_theme_submenu() {
  remove_submenu_page('themes.php', 'themes.php');
  remove_submenu_page('themes.php', 'theme-editor.php');
}
add_action('admin_init', 'remove_theme_submenu', 100);

If you want to remove the Themes sub-page for everyone except you, place this in your functions.php file (replace admin with your username):

/**
 * Remove the 'Themes' submenu page for everyone but the 'admin'.
 *
 * @link https://codex.wordpress.org/Function_Reference/wp_get_current_user
 * @link http://codex.wordpress.org/Function_Reference/remove_submenu_page
 *
 *
 * @return void
 */
function remove_theme_submenu_except_admin() {
  $current_user = wp_get_current_user();

  if ($current_user->user_login !== 'admin') {
    remove_submenu_page('themes.php', 'themes.php');
    remove_submenu_page('themes.php', 'theme-editor.php');
  }
}
add_action('admin_init', 'remove_theme_submenu_except_admin', 100);
@swashcap
Copy link
Author

swashcap commented May 6, 2014

I should mention that I tested this against WordPress 3.9. Works like a charm.

@charliewilco
Copy link

cory you're a freaking genius.

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