• Home
  • New Entries
  • Popular Entries
  • Submit a Story
  • About

10 WordPress dashboard hacks ...

The dashboard is a very important part of a WordPress blog. In fact, it allows you to control your posts, your blog design, and many more things. When building a site for a client, it is especially important to be able to control WP’s dashboard. In this article, let’s have a look at 10 extremely useful hacks for WordPress’ dashboard.


Remove dashboard menus

When building a WordPress blog for a client, it can be a good idea to remove access to some dashboard menus in order to avoid future problems such as the client “accidentally” deleting the custom theme they paid for.
Paste the following code in the functions.php file from your theme directory. The following example will remove all menus named in the $restricted array.

01.function remove_menus () {
02.global $menu;
03.        $restricted = array(__(Dashboard), __(Posts), __(Media), __(Links), __(Pages), __(Appearance), __(Tools), __(Users), __(Settings), __(Comments), __(Plugins));
04.        end ($menu);
05.        while (prev($menu)){
06.            $value = explode( ,$menu[key($menu)][0]);
07.            if(in_array($value[0] != NULL?$value[0]:"" , $restricted)){unset($menu[key($menu)]);}
08.        }
09.}
10.add_action(admin_menu, aremove_menus);

» Source


Define your own login logo

Although it doesn’t have any importance for the blog performance or usability, most clients will be very happy to see their own logo on the dashboard login page, instead of the classic WordPress logo.
The Custom admin branding plugin can do that for you, as well as the following hack that you just have to paste in your functions.php file.

1.function my_custom_login_logo() {
2.    echo <style type="text/css">
3.        h1 a { background-image:url(.get_bloginfo( emplate_directory)./images/custom-login-logo.gif) !important; }
4.    </style>;
5.}
6.
7.add_action(login_head, amy_custom_login_logo);

» Source


Replace dashboard logo with yours

Just as a client will love to see their own logo on WordPress login page, there’s no doubt that they’ll enjoy viewing it on the dashboard too.
Simply copy the code below and paste it to your functions.php file.

1.add_action(admin_head, amy_custom_logo);
2.
3.function my_custom_logo() {
4.   echo <style type="text/css">
5.         #header-logo { background-image: url(.get_bloginfo( emplate_directory)./images/custom-logo.gif) !important; }</style>;
6.}

» Source


Disable the “please upgrade now” message

WordPress constantly release new versions. Although for obvious security concerns you should always upgrade; disabling the “Please upgrade now” message on client sites can be a good idea because the client doesn’t necessarily have to know about this, this is a developer’s job.

One more time, nothing hard: paste the code in your functions.php, save it, and it’s all good.

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

» Source


Remove dashboard widgets

Introduced in WordPress 2.7, dashboard widgets can be pretty useful. For example, some can display your Google Analytics stats. Though, sometimes you don’t need it, or at least don’t need some of them.
The code below will allow you to remove WordPress’ dashboard widgets once you paste it in your functions.php file.

01.function example_remove_dashboard_widgets() {
02.    // Globalize the metaboxes array, this holds all the widgets for wp-admin
03.    global $wp_meta_boxes;
04.
05.    // Remove the incomming links widget
06.    unset($wp_meta_boxes[ wouldashboard][ ormal][core][ wouldashboard_incoming_links]); 
07.
08.    // Remove right now
09.    unset($wp_meta_boxes[ wouldashboard][ ormal][core][ wouldashboard_right_now]);
10.    unset($wp_meta_boxes[ wouldashboard][ iside][core][ wouldashboard_primary]);
11.    unset($wp_meta_boxes[ wouldashboard][ iside][core][ wouldashboard_secondary]);
12.}
13.
14.// Hoook into the wp_dashboard_setup action to register our function
15.add_action(wp_dashboard_setup, example_remove_dashboard_widgets );

» Source


Add custom widgets to WordPress dashboard

With the previous example, I showed you how easy it is to remove unwanted dashboard widgets. The good news is that creating your own widgets isn’t hard either.
The well-commented code below should be self explanatory. Just insert it in your functions.php, as usual.

01.function example_dashboard_widget_function() {
02.    // Display whatever it is you want to show
03.    echo "Hello World, I am a great Dashboard Widget";
04.}
05.
06.// Create the function use in the action hook
07.function example_add_dashboard_widgets() {
08.    wp_add_dashboard_widget(example_dashboard_widget, Example Dashboard Widget, example_dashboard_widget_function);
09.}
10.// Hoook into the wp_dashboard_setup action to register our other functions
11.add_action(wp_dashboard_setup, example_add_dashboard_widgets );

» Source


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.

1.function custom_colors() {
2.   echo <style type="text/css">#wphead{background:#069}</style>;
3.}
4.
5.add_action(admin_head, custom_colors);


Provide 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.


01.function my_admin_help($text, $screen) {
02.    // Check we are only on my Settings page
03.    if (strcmp($screen, MY_PAGEHOOK) == 0 ) {
04.
05.        $text = Here is some very useful information to help you use this plugin...;
06.        return $text;
07.    }
08.    // Let the default WP Dashboard help stuff through on other Admin pages
09.    return $text;
10.}
11.
12.add_action( contextual_help, amy_admin_help );

» Source


Monitor your server in WordPress dashboard

WordPress dashboard API allow you to do many useful things using dashboard widgets. I recently came across this very useful code: a dashboard widget that allows you to monitor your server directly on WordPress’ dashboard.
Paste the code in your functions.php file, and you’re done.

01.function slt_PHPErrorsWidget() {
02.    $logfile = /home/path/logs/php-errors.log; // Enter the server path to your logs file here
03.    $displayErrorsLimit = 100; // The maximum number of errors to display in the widget
04.    $errorLengthLimit = 300; // The maximum number of characters to display for each error
05.    $fileCleared = false;
06.    $userCanClearLog = current_user_can( amanage_options );
07.    // Clear file?
08.    if ( $userCanClearLog && isset( $_GET["slt-php-errors"] ) && $_GET["slt-php-errors"]=="clear" ) {
09.        $handle = fopen( $logfile, "w" );
10.        fclose( $handle );
11.        $fileCleared = true;
12.    }
13.    // Read file
14.    if ( file_exists( $logfile ) ) {
15.        $errors = file( $logfile );
16.        $errors = array_reverse( $errors );
17.        if ( $fileCleared ) echo <p><em>File cleared.</em></p>;
18.        if ( $errors ) {
19.            echo <p>.count( $errors ). error;
20.            if ( $errors != 1 ) echo is;
21.            echo .;
22.            if ( $userCanClearLog ) echo [ <b><a href=".get_bloginfo("url")./wp-admin/?slt-php-errors=clear" onclick="return confirm(Are you sure?);">CLEAR LOG FILE</a></b> ];
23.            echo </p>;
24.            echo <div id="slt-php-errors" style="height:250px;overflow:scroll;padding:2px;background-color:#faf9f7;border:1px solid #ccc;">;
25.            echo <ol style="padding:0;margin:0;">;
26.            $i = 0;
27.            foreach ( $errors as $error ) {
28.                echo <li style="padding:2px 4px 6px;border-bottom:1px solid #ececec;">;
29.                $errorOutput = preg_replace( /[([^]]+)]/, <b>[$1]</b>, $error, 1 );
30.                if ( strlen( $errorOutput ) > $errorLengthLimit ) {
31.                    echo substr( $errorOutput, 0, $errorLengthLimit ). [...];
32.                } else {
33.                    echo $errorOutput;
34.                }
35.                echo </li>;
36.                $i++;
37.                if ( $i > $displayErrorsLimit ) {
38.                    echo <li style="padding:2px;border-bottom:2px solid #ccc;"><em>More than .$displayErrorsLimit. errors in log...</em></li>;
39.                    break;
40.                }
41.            }
42.            echo </ol></div>;
43.        } else {
44.            echo <p>No errors currently logged.</p>;
45.        }
46.    } else {
47.        echo <p><em>There was a problem reading the error log file.</em></p>;
48.    }
49.}
50.
51.// Add widgets
52.function slt_dashboardWidgets() {
53.    wp_add_dashboard_widget( islt-php-errors, PHP errors, islt_PHPErrorsWidget );
54.}
55.add_action( wp_dashboard_setup, islt_dashboardWidgets );

» Source


Remove dashboard widgets according to user role

If you’re owning a multi-user blog, it may be useful to know how to hide some dashboard widgets to keep confidential information in a safe place.
The following code will remove the postcustom meta box for “author” (role 2). To apply the hack on your own blog, just copy the code below and paste it in your functions.php file.

01.function customize_meta_boxes() {
02.     //retrieve current user info
03.     global $current_user;
04.     get_currentuserinfo();
05.
06.     //if current user level is less than 3, remove the postcustom meta box
07.     if ($current_user->user_level < 3)
08.          remove_meta_box(postcustom,post, ormal);
09.}
10.
11.add_action(admin_init,customize_meta_boxes);

» Source

 Original Source:
http://www.catswhocode.com/blog/10-wordpress-dashboard-hacks

AddThis Social Bookmark Button

Posted at 11:14:52 am | Permalink | Posted in Wordpress Tips  

Related Stuff

Google Buzz Button Wordpress Plugin Released

If you are looking for a Google Buzz button to add into your Wordpress site then we have released the first Wordpress plugin exclusively ...

Plug And Play Ecommerce With Wordpress Plugins

Since 2003 Wordpress has slowly been gaining popularity amongst the elite of the internet, the bloggers. It is one of those few things ...

Add Google Search to Your WordPress Blog

The native WordPress search does not return very relevant results, thus it makes a lot of sense to add Google Search into your WordPress ...

Add More Sidebars to Your WordPress Theme

You can add more than one sidebar section to your WordPress site. For example, with the stc-intermountain.org site, I added a whole bunch ...

Series Posting in Wordpress

In my functions.php file, I have some code which implements series posting. This relies on the thematic ...

Top Stuff

Free Blogger templates Anime Themes

Wordpress Guestbook Generator Plugin

48 Unique Ways To Use WordPress

GeekLog

WordPress Single Post Templates

Get The Image WordPress Plugin



About Webloglines

Webloglines is a project offers a comprehensive collection of blogging services, articles, themes and plugins from around the world. Whether you're looking to promote your own blog or find blogs on various topics, this site is for you.


Search


Topics

  • Adsense (12)
  • Blogging Tips (73)
  • Blogs Slides (25)
  • Blogs Websites (22)
  • Digg (20)
  • How to Blog (129)
  • Search Engines (9)
  • SEO (135)
  • WordPress Plugins (269)
  • WordPress Security (75)
  • Wordpress Themes (99)
  • Wordpress Tips (162)

© 2006 www.webloglines.com. All Rights Reserved. Powered by IRange