Add StatTraq to your WordPress Dashboard

StatTraq is one of the better statistics for WordPress blogs. Unfortunately Randy Peterman is no longer maintaining it, but Adsworth have patched a version which will run under WordPress v1.5 and 2.0 as well as fixing a couple of bugs.

I often forget the url to view my StatTraq statistics so I wanted to add a link to it in the WordPress Dashboard page. UrbanGiraffe shows one method of adding a link as a menu item. I adapted this slightly to add the link as a submenu under the Dashboard, along with a link to Webalizer which comes with my webhosting service.

To add the links, edit wp-admin\menu.php and add the following lines right after the $menu[45]=… line.

// Add StatTraq to Dashboard submenu
$submenu['index.php'][5] = array(__('Dashboard'), 'read', 'index.php');
$submenu['index.php'][10] = array(__('StatTraq'), 'read', '../wp-stattraq/statistics.php');
$submenu['index.php'][15] = array(__('Webalizer'), 'edit_posts', '../webalizer/');

2008/1/6 Update – A Better Menu
The above solution works to some extent, but your changes to the menu.php file disappear every time you upgrade WordPress. A much more satisfactory method is to create your own plugin. Add the following to a file called my_menu.php and save it in your wp-content/plugins folder. Enable your new My Menus plugin then you should find a brand new set of links to your statistics pages under your Dashboard.

<?php 
/* 
Plugin Name: My Menus 
Plugin URI: http://mortell.blogdns.com/2006/10/22/wordpress-statistics-plugins/ 
Description: Add your own items to the WordPress menus 
Author: D. Mortell 
Author URI: http://www.dmortell.com 
*/ 

add_action('admin_menu', 'mymenu_add_page'); 

function mymenu_add_page() 
{ 
   # Add sub-menus to the "Dashboard" page. 
   add_submenu_page('index.php', 'StatTraq', 'StatTraq', 1, '../wp-stattraq/statistics.php'); 
   add_submenu_page('index.php', 'Webalizer', 'Webalizer', 1, '../webalizer/'); 
} 
?> 
Tags: No tags

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.