Todo List Plugin: Patch to display todo in Dashboard

Abstract Dimension has written an excellent Todo List plugin for each author to manage a personal todo list.

After using it, I thought it would be nice to have my todo appeared on the Dashboard Latest Activity box as the screenshot below:

Screenshot: Todo List displays in Dashboard

So, here’s a patch that does the job. To apply, simply copy and append the code below to the end of the plugin script, admin_todo.php.

The only thing the patch does is to retrieve the first ten todo items (sorted by priority) and display them on the Dashboard. No changes to database, it’s pretty safe to patch.

Welcome to submit bug reports through comments.

The patch source code, tested on Todo List Plugin version 1.2 :

/*
 Patch-To    : Todo List Plugin version 1.2
 Description : To display the first 10 todo items sorted by priority on Dashboard.
 Installation: Append the entire code to the end of admin_todo.php file.
 Author      : Wordpress By Examples
 Author URL  : http://wordpress.byexamples.com
 License     : GPL Version 2
*/
/*
 List top 10 todo in Dashboard Lastest Activity
*/
function atd_todo_in_activity_box() {

  global $table_prefix, $wpdb, $userdata;
  get_currentuserinfo();
  $table_name = $table_prefix . 'todolist';

  echo '<div><h3>'.__('Todo List').
       ' <a href="edit.php?page=admin_todo.php">'.
       __('&raquo;').'</a></h3>';

  $sql = "SELECT id, todotext FROM $table_name ".
         "WHERE status = 0 AND author = $userdata->ID ".
         'ORDER BY priority LIMIT 10';

  $results = $wpdb->get_results($sql);
  if ($results) {
    echo '<ol>';
    foreach ($results as $result) {
      echo "<li>$result->todotext <small>".
           '(<a href="edit.php?page=admin_todo.php&action=edittd&id='.
           $result->id . '&noheader&message=3">'.
           __('Edit')  . '</a>)</small></li>';
    }
    echo '</ol>';
  }
  else  {
    echo '<p>'.__('nothing to do...').'</p>';
  }
  echo '<p style="text-align:right">'.
       '<a href="edit.php?page=admin_todo.php#addtd">'.
       __('New Todo &raquo;').'</a></p></div>';
}

/*
 Wordpress hooks
 */
if (function_exists('add_action')) {
  add_action('activity_box_end', 'atd_todo_in_activity_box');
}
No tags for this post.

One Response to “Todo List Plugin: Patch to display todo in Dashboard”

  1. WordPress Plugins Database » Plugin Details » Todo List Plugin Says:

    [...] Visit [...]

Leave a Reply

It sounds like SK2 has recently been updated on this blog. But not fully configured. You MUST visit Spam Karma's admin page at least once before letting it filter your comments (chaos may ensue otherwise).