WordPress dashboard hacks for developers and freelancers

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 '[email protected]';
}
function new_mail_from_name($old) {
 return 'Your Blog Name';
}

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

Leave a Reply

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