ginfuru
10/11/2012 - 1:48 PM

Wordpress: Admin Improvements

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 );