Archive Old post. Originally published 4 November 2011 on the WordPress version of this site. Preserved here for the search engines and the curious. Old me had opinions.
Developer 3 min read

Super Useful WordPress Admin Customisations

I’ve recently been working on a big corporate theme and wanted to limit and customise the WordPress core much more than I have done in the past. A few handy lines inside your themes functions.php can easily achieve this a few examples are below.

Changing the Login Page Logo

Super easy just change the image path to match where you have put your logo!

//Custom Login Logo
function my_login_logo() {
    echo '<style type="text/css">
        h1 a { background-image:url('.get_stylesheet_directory_uri(). '/images/logo.png) !important; }
    </style>';
}

add_action('login_head', 'my_login_logo');

Changing the admin logo

That little Favicon style logo next to your site name in the admin area, easily changed!

//Change Admin Logo
function my_custom_logo() {
	echo '<style type="text/css">
		#header-logo { background-image: url(' . get_bloginfo('template_directory') . '/images/admin_logo.png) !important; }
		
		</style>';
}

add_action('admin_head', 'my_custom_logo');

Want your own default Avatar?

This code will allow you to specify your own custom avatar, you can select it from the Settings->Discussion Menu

//Custom Default Avatar
add_filter('avatar_defaults', 'vt_gravatar');  

function vmy_gravatar ($avatar_defaults) {
     $myavatar = get_bloginfo('template_directory') . '/images/avatar.jpg';
     $avatar_defaults[$myavatar] = "My super cool default avatar!";
     return $avatar_defaults;
}

Tidy your admin dashboard, for everyone, easily!

Those stupid dashboard things that you never look at and clients just have no clue about them? Hide them!

//Tidy Dashboard
function remove_dashboard_widgets(){ //get rid of stupid default dashboard stuff
  global$wp_meta_boxes;
  unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']);
  unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']);
  unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']);
  unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']); 
}

add_action('wp_dashboard_setup', 'remove_dashboard_widgets');

Get rid of scary editor buttons

Scared of someone messing with your code, take away the options. Simple.

//Get Rid of Editor Button under themes and Plugins menu
function remove_editor_menu() {
  remove_action('admin_menu', '_add_themes_utility_last', 101);
}

add_action('_admin_menu', 'remove_editor_menu', 1);

Change the Admin Footer Text
Want to add a special message, brag, whatever. This will alter the admin area footer text for you.

//change admin area footer
function modify_footer_admin () {   
 	echo 'Developed and managed by <a href="mailto:me@mydomain.com?subject=Admin Footer Email Link">Super Cool Developer Person</a>. ';
  	echo 'Powered by <a href="http://WordPress.org">WordPress</a> and lots of coffee!';
}

add_filter('admin_footer_text', 'modify_footer_admin');

Login Page Logo Link

So it points to wordpress.org, but maybe you want it to go somewhere else?

//set login page URL
add_filter( 'login_headerurl', 'my_custom_login_url' );

function my_custom_login_url($url) {
	return 'http://www.mydomain.com';
}

Custom Login Title?

Basically changes the hover text over your new custom logo

//Change Login Title
function custom_login_title($title) { 
	return bloginfo('description');;
}
add_filter( 'login_headertitle', 'custom_login_title' );

Hide the WordPress version and generator info
I like to hide the generator tag and WordPress version just to try and stop script kiddies having a go!

//Hide Wordpress Generator Tag for Security Purpose
remove_action('wp_head', 'wp_generator'); // !IMPORTANT FOR SECURITY

And Finally…those stupid extra 10px that WordPress puts around captioned images!
It’s annoying and messes with my themes, go away!

//Remove Stupid 10xp from around the Caption Images
class fixImageMargins{
    public $xs = 0; //change this to change the amount of extra spacing

    public function __construct(){
        add_filter('img_caption_shortcode', array(&$this, 'fixme'), 10, 3);
    }
    public function fixme($x=null, $attr, $content){

        extract(shortcode_atts(array(
                'id'    => '',
                'align'    => 'alignnone',
                'width'    => '',
                'caption' => ''
            ), $attr));

        if ( 1 > (int) $width || empty($caption) ) {
            return $content;
        }

        if ( $id ) $id = 'id="' . $id . '" ';

    return '<div ' . $id . 'class="wp-caption ' . $align . '" style="width: ' . ((int) $width + $this->xs) . 'px">'
    . $content . '<p class="wp-caption-text">' . $caption . '</p></div>';
    }
}
$fixImageMargins = new fixImageMargins();

Filed under Developer. No comments, on purpose.