WordPress dashboard hacks for developers and freelancers

by Jean. 22 Comments -

The dashboard is an essential part of WordPress, as it is the place where you write posts and install plugins. But as a developer and/or freelancer, you have to be careful about what your clients are doing on the dashboard of their WordPress powered websites. Today, I have compiled 10 super useful hacks to customize, modify or enhance WordPress dashboard.

Remove menu items from WordPress admin bar

Here is a super useful code snippet for developers who wants to prevent their clients to access some dashboard menus, such as “Plugins” or “Settings”. Paste this code into your theme functions.php file to remove menus from the admin bar.

function wps_admin_bar() {
    global $wp_admin_bar;
    $wp_admin_bar->remove_menu('wp-logo');
    $wp_admin_bar->remove_menu('about');
    $wp_admin_bar->remove_menu('wporg');
    $wp_admin_bar->remove_menu('documentation');
    $wp_admin_bar->remove_menu('support-forums');
    $wp_admin_bar->remove_menu('feedback');
    $wp_admin_bar->remove_menu('view-site');
}
add_action( 'wp_before_admin_bar_render', 'wps_admin_bar' );

Source: http://wpsnipp.com/index.php/functions-php/remove-menu…

Remove the screen options tab with screen_options hook

Don’t need the “Screen Options” button? Here is a simple hack to remove it. Paste the code below into your functions.php file, save it, and you’re done.

function remove_screen_options(){
    return false;
}
add_filter('screen_options_show_screen', 'remove_screen_options');

Source: http://wpsnipp.com/index.php/functions-php/chnage-default…

Change default “Enter title here” text within post title input field

If for some reason you need to replace the “Enter title here” text within post title input field by a custom text, here is an easy way to do it. Define a new text on line 2, then paste the code into your functions.php file.

function title_text_input( $title ){
     return $title = 'Enter new title';
}
add_filter( 'enter_title_here', 'title_text_input' );

Source: http://wpsnipp.com/index.php/functions-php/chnage-default…

Change dashboard footer text

Changing the dashboard footer text is pretty easy as well. Update the code below with your custom text on line 2, then include the snippet into your functions.php file.

function remove_footer_admin () {
    echo "Your own text";
} 

add_filter('admin_footer_text', 'remove_footer_admin'); 

Source: http://www.wprecipes.com/wordpress-tip-how-to-change-the-dashboard-footer-text

Disable the “please update now” message in WP dashboard

Security is indeed a crucial aspect of a website and you should always update all blogs you manage to prevent any risk of hacking. But when working with clients, sometimes you may want to hide the “please update now” message generated by WordPress when a new version is available.

Simply add this code to your functions.php file to hide the message.

if ( !current_user_can( 'edit_users' ) ) {
  add_action( 'init', create_function( '$a', "remove_action( 'init', 'wp_version_check' );" ), 2 );
  add_filter( 'pre_option_update_core', create_function( '$a', "return null;" ) );
}

Source: http://www.wprecipes.com/how-to-disable-the-please-update-now-message…

Custom login form with full screen background

Here is a super cool code snippet that your clients will definitely love: a custom login form with a full screen background. Click here for a demo. Once again, the code goes to your functions.php file.

Please note that I left the CSS code “as it” so you can have a look at it, but on a production site you should definitely use an external stylesheet instead.

function login_enqueue_scripts(){
	echo '
		<div class="background-cover"></div>
		<style type="text/css" media="screen">
			.background-cover{
				background:url('.get_bloginfo('template_directory').'/images/background) no-repeat center center fixed; 
				-webkit-background-size: cover; 
				-moz-background-size: cover; 
				-o-background-size: cover; 
				background-size: cover; 
				position:fixed; 
				top:0; 
				left:0; 
				z-index:10; 
				overflow: hidden; 
				width: 100%; 
				height:100%;
			} 
			#login{ z-index:9999; position:relative; }
			.login form { box-shadow: 0px 0px 0px 0px !important; }
			.login h1 a { background:url('.get_bloginfo('template_directory').'/images/logo.png) no-repeat center top !important; } 
			input.button-primary, button.button-primary, a.button-primary{ 
				border-radius: 3px !important; 						background:url('.get_bloginfo('template_directory').'/images/button.jpg); 
					border:none !important;
					font-weight:normal !important;
					text-shadow:none !important;
				}
				.button:active, .submit input:active, .button-secondary:active {
					background:#96C800 !important; 
					text-shadow: none !important;
				}
				.login #nav a, .login #backtoblog a {
					color:#fff !important;
					text-shadow: none !important;
				}
				.login #nav a:hover, .login #backtoblog a:hover{
					color:#96C800 !important;
					text-shadow: none !important;
				}
				.login #nav, .login #backtoblog{
					text-shadow: none !important;
				}
			</style>
		';
	}
add_action( 'login_enqueue_scripts', 'login_enqueue_scripts' );

Source: http://www.catswhocode.com/blog/snippets/custom-wp-login…

Disable theme switching

The best way to prevent your clients from switching theme is definitely by disabling theme switching. Paste the following code into functions.php and your clients will not be able to switch themes anymore.

add_action('admin_init', 'slt_lock_theme');
function slt_lock_theme() {
	global $submenu, $userdata;
	get_currentuserinfo();
	if ($userdata->ID != 1) {
		unset($submenu['themes.php'][5]);
		unset($submenu['themes.php'][15]);
	}
}

Source: http://www.wprecipes.com/how-to-easily-disable-theme-changing

Change WordPress dashboard colors

If you ever wanted to be able to change WordPress dashboard colors (as well as font or even display) without having to edit WordPress core files, you’ll like this hack for sure.
The following example features a basic style change (grey header is replaced by a blue one) but you can easily add as many styles as you wish within the <style> and </style> tags.

function custom_colors() {
   echo '<style type="text/css">#wphead{background:#069}</style>';
}

add_action('admin_head', 'custom_colors');

Create custom help messages

If you’re building a site for a client and they have some problems with some parts of the dashboard, a good idea is to provide contextual help to the client.
The following hack will allow you to add a custom help messages for the blog admin. As usual, you only have to paste the code into your functions.php file.

function my_admin_help($text, $screen) {
	// Check we're only on my Settings page
	if (strcmp($screen, MY_PAGEHOOK) == 0 ) {

		$text = 'Here is some very useful information to help you use this plugin...';
		return $text;
	}
	// Let the default WP Dashboard help stuff through on other Admin pages
	return $text;
}

add_action( 'contextual_help', 'my_admin_help' );

Source: http://www.studiograsshopper.ch/code-snippets/wordpress-action-hook-contextual-help/

Change WordPress default FROM email address

If you want to change WordPress default FROM email adress, simply paste the following snippet into your functions.php file. Don’t forget to put the desired email adress on line 5 and desired name on line 8.

add_filter('wp_mail_from', 'new_mail_from');
add_filter('wp_mail_from_name', 'new_mail_from_name');

function new_mail_from($old) {
 return 'admin@yourdomain.com';
}
function new_mail_from_name($old) {
 return 'Your Blog Name';
}

Source: http://www.wprecipes.com/how-to-change-wordpress-default-from…

Comments (22) - Leave yours

  1. Simon said:

    It is worth noting that the contextual_help function has been deprecated and replaced with a new function: http://codex.wordpress.org/Function_Reference/add_help_tab which can be used from 3.3 onwards and allows the use of tabs within the help drop down :)

  2. Piet said:

    Great list, small typo with the first one though. First line should be function wp_admin_bar(), not function wps_admin_bar()

  3. adam collins said:

    Cheers for this really interesting and useful blog post on developer hacks for wordpress, this is definitely a useful blog post for me, and i look forward to actioning some of these different hacks onto my future wordpress projects. Custom login form with full screen background is definitely my favourite, i will be implementing this onto all of my wordpress sites.

  4. Luis Perales said:

    Thanks for these usefull codes. I just was searching how to change the background screen on the login form. One question, do you know how to change the WordPress avatar in navbar for custom avatar in WordPress 3.4 ?? I’ve seen hacks for previous versions, that don’t work now.

    Thanks
    (sorry my bad english)

  5. Jasmine said:

    I like the custom login with full screen background hack. I think this personalized screen will be cool and great for branding. Anyway, will a WordPress update overwrites these hacks?

  6. valeriy said:

    Jean, this is amazing. All of these widgets are useful for everyday developers. i think i will honestly use the first 5 100% every time from now on. A custom login screen will go a long way ;)

  7. Jamie said:

    This site is certainly one of the best helpful blogs that I have found. WordPress plugins are helpful to help me manipulate my WP blog

  8. Jamie said:

    Getting these tips on how to customize the admin file on WP is certainly a good help for people like me who are into the developing business. Keep posting!

  9. Torbjorn said:

    Thanks for the great tips. Some of them were new to me. Please add functions to remove dashboard metaboxes(widgets). Working code below. An as a followup. Does anybody know how to remove the bbPress widget “Right Now in Forums”

    /Greetings from Sweden ;-)

    `
    /********* REMOVE ALL DASHBOARD WIDGETS FOR A CERTAN ROLE **********/

    // disable default dashboard widgets
    function disable_default_dashboard_widgets() {

    // Right Now Widget
    remove_meta_box(‘dashboard_right_now’, ‘dashboard’, ‘core’);
    // Comments Widget
    remove_meta_box(‘dashboard_recent_comments’, ‘dashboard’, ‘core’);
    // Incoming Links Widget
    remove_meta_box(‘dashboard_incoming_links’, ‘dashboard’, ‘core’);
    // Plugins Widget
    remove_meta_box(‘dashboard_plugins’, ‘dashboard’, ‘core’);
    // Quick Press Widget
    remove_meta_box(‘dashboard_quick_press’, ‘dashboard’, ‘core’);
    // Recent Drafts Widget
    remove_meta_box(‘dashboard_recent_drafts’, ‘dashboard’, ‘core’);
    // WordPress Blog Feed
    remove_meta_box(‘dashboard_primary’, ‘dashboard’, ‘side’);
    // Other WordPress News
    remove_meta_box(‘dashboard_secondary’, ‘dashboard’, ‘side’);

    // bbPress widget ‘Right Now in Forums’bbp-dashboard-right-now
    // *******Does not work right now *******//
    remove_meta_box(‘bbp_dashboard_right_now’, ‘dashboard’, ‘core’);

    }
    //Set the capability to target users
    // If NOT users can edit_posts then hide all widgets.
    if (!current_user_can(‘manage_options’)) {
    add_action(‘wp_dashboard_setup’, ‘disable_default_dashboard_widgets’);
    }
    `

  10. Amber said:

    Hello :)

    I was wondering how I can remove the ‘Customize’ and ‘OPTIONS:’ links under my Current Theme information on my Manage Themes tab. (phew that’s a mouthful)

    Any suggestions would be awesome.

    • WhiteCoder said:

      Crap admin delete my first 2 replies please I cant use any tags I guess lol. This is my hack fix to remove the Customize link from the Manage Themes page. I have been using it for a while with no problems. It goes in your functions.php file.

      //open php tag

      add_action( ‘admin_menu’, ‘remove_customize_theme_options’ );
      function remove_customize_theme_options() {
      //if the logged in user has access to edit theme options (the admin)
      if(current_user_can(‘edit_theme_options’)) {

      //close php tag

      //open style type tag
      /* this is the id for the a href link that generates the word Customize on manage themes */
      #customize-current-theme-link {
      display:none;
      }
      //close style type tag

      //open php tag

      }
      }

      //close php tag

  11. شات بنات مصر said:

    I was wondering how I can remove the ‘Customize’ and ‘OPTIONS:’ links under my Current Theme information on my Manage Themes tab. (phew that’s a mouthful)

    Any suggestions would be awesome

Leave a Reply

Your email address will not be published. Required fields are marked *

Please respect the following rules: No advertising, no spam, no keyword in name field. Thank you!