Changeset 45292
- Timestamp:
- 05/11/08 19:20:29 (2 months ago)
- Files:
-
- immerstat/trunk/COPYING (added)
- immerstat/trunk/immerstat.php (modified) (3 diffs, 1 prop)
- immerstat/trunk/readme.txt (added)
- immerstat/trunk/screenshot1.jpg (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
immerstat/trunk/immerstat.php
- Property svn:keywords set to Id
r45215 r45292 3 3 Plugin Name: ImmerStat 4 4 Plugin URI: http://scompt.com/projects/immerstat 5 Description: Replaces the Flash-based WordPress.com stats display on the dashboard with an ever-present .PNG in the top-right corner.5 Description: ImmerStat places a .PNG in the top-right corner of your admin screen with your current WordPress.com pageview statistics. 6 6 Author: Edward Dale 7 7 Author URI: http://scompt.com/ … … 9 9 */ 10 10 11 /** 12 * ImmerStat places a .PNG in the top-right corner of your admin screen with 13 * your current WordPress.com pageview statistics. 14 * 15 * LICENSE 16 * This file is part of ImmerStat. 17 * 18 * ImmerStat is free software; you can redistribute it and/or 19 * modify it under the terms of the GNU General Public License 20 * as published by the Free Software Foundation; either version 2 21 * of the License, or (at your option) any later version. 22 * 23 * This program is distributed in the hope that it will be useful, 24 * but WITHOUT ANY WARRANTY; without even the implied warranty of 25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 26 * GNU General Public License for more details. 27 * 28 * You should have received a copy of the GNU General Public License 29 * along with this program; if not, write to the Free Software 30 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 31 * 32 * @package ImmerStat 33 * @author Edward Dale <scompt@scompt.com> 34 * @copyright Copyright 2008 Edward Dale 35 * @license http://www.gnu.org/licenses/gpl.txt GPL 2.0 36 * @version $Id:$ 37 * @link http://www.scompt.com/projects/immerstat 38 * @since 0.5 39 */ 11 40 class ImmerStat { 41 42 // Whether to regenerate stats 43 var $do_load = False; 44 12 45 /** 13 46 * Make sure we've got all we need to run and the run. … … 18 51 } 19 52 } 53 54 /** 55 * A filter hook used to pick up on whether new stats were downloaded. 56 */ 57 function enable_load($ret) { 58 $this->do_load = True; 59 return $ret; 60 } 20 61 21 62 /** 22 63 * Gets the view count from the WordPress.com Stats plugin and saves it 23 64 * in a form that we can use later in the footer. 24 *25 * TODO: If the stats haven't changed, don't do all this stuff.26 65 */ 27 66 function load() { 28 67 $num_days = apply_filters('immerstat_days', 30); 68 69 // Use this filter to determine when new stats were actually retrieved 70 add_filter('update_option_stats_cache', array(&$this, 'enable_load')); 29 71 $from_wp = stats_get_csv('views', array('days'=>$num_days, 'limit'=>$num_days, 'summarize'=>false)); 72 remove_filter('update_option_stats_cache', array(&$this, 'enable_load')); 73 30 74 $data = array(); 31 75 $max = $min = $from_wp[0]['views']; 32 foreach( $from_wp as $day ) { 33 if( $max<$day['views'] ) $max=$day['views']; 34 if( $min>$day['views'] ) $min=$day['views']; 35 $data []= $day['views']; 76 77 if( $this->do_load ) { 78 foreach( $from_wp as $day ) { 79 if( $max<$day['views'] ) $max=$day['views']; 80 if( $min>$day['views'] ) $min=$day['views']; 81 $data []= $day['views']; 82 } 83 84 $stats = array('data'=>implode($data, ','), 'min'=>$min, 'max'=>$max, 'days'=>$num_days, 'current'=>$data[count($data)-1]); 85 update_option('immerstat_data', $stats); 36 86 } 37 38 $stats = array('data'=>implode($data, ','), 'min'=>$min, 'max'=>$max, 'days'=>$num_days, 'current'=>$data[count($data)-1]);39 update_option('immerstat_data', $stats);40 87 41 88 add_action('admin_footer', array(&$this, 'footer'));
