Skip to content

Instantly share code, notes, and snippets.

@danielbachhuber
Created July 26, 2011 13:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save danielbachhuber/1106704 to your computer and use it in GitHub Desktop.
Save danielbachhuber/1106704 to your computer and use it in GitHub Desktop.
WordPress admin improvements
<?php
/**
* Random set of improvements
*/
/**
* Tidy up the admin and remove options we don't need
*/
function db_clean_up_admin() {
// Remove the unneccessary plugins menus
remove_submenu_page( 'plugins.php', 'plugin-install.php' );
remove_submenu_page( 'plugins.php', 'plugin-editor.php' );
// Remove unnecessary theme menus
remove_submenu_page( 'themes.php', 'theme-editor.php' );
}
add_action( 'admin_init', 'db_clean_up_admin' );
/**
* Add and remove links from the admin bar
*/
function db_admin_bar_modifications() {
if ( is_admin_bar_showing() ) {
global $wp_admin_bar;
// Add a "Edit CSS" link to the appearance dropdown if user can edit
if ( current_user_can( 'manage_options' ) ) {
$args = array(
'title' => 'Edit CSS',
'href' => admin_url( 'themes.php?page=editcss' ),
'parent' => 'appearance',
);
$wp_admin_bar->add_menu( $args );
}
// Remove the "Add Plugins" and "Add Themes" options
$wp_admin_bar->remove_menu( 'new-plugin' );
$wp_admin_bar->remove_menu( 'new-theme' );
}
}
add_action( 'admin_bar_menu', 'db_admin_bar_modifications', 150 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment