Changeset 126622
- Timestamp:
- 06/17/2009 12:58:28 AM (17 years ago)
- Location:
- immerstat/tags/0.5
- Files:
-
- 1 added
- 1 deleted
- 2 edited
-
immerstat.php (modified) (8 diffs)
-
readme.txt (modified) (4 diffs)
-
screenshot-1.jpg (deleted)
-
screenshot-1.png (added)
Legend:
- Unmodified
- Added
- Removed
-
immerstat/tags/0.5/immerstat.php
r45292 r126622 3 3 Plugin Name: ImmerStat 4 4 Plugin URI: http://scompt.com/projects/immerstat 5 Description: ImmerStat places a .PNG in the top-right corner of your admin screen with your current WordPress.com pageview statistics. 5 Description: ImmerStat places an image in the header of your admin screen with 6 your current WordPress.com pageview statistics. 6 7 Author: Edward Dale 7 8 Author URI: http://scompt.com/ 8 Version: 0. 59 Version: 0.6 9 10 */ 10 11 11 12 /** 12 * ImmerStat places a .PNG in the top-right corner of your admin screen with13 * ImmerStat places an image in the header of your admin screen with 13 14 * your current WordPress.com pageview statistics. 14 15 * … … 34 35 * @copyright Copyright 2008 Edward Dale 35 36 * @license http://www.gnu.org/licenses/gpl.txt GPL 2.0 36 * @version $Id :$37 * @version $Id$ 37 38 * @link http://www.scompt.com/projects/immerstat 38 39 * @since 0.5 … … 47 48 */ 48 49 function ImmerStat() { 50 add_settings_section('immerstat_setting_section', 'ImmerStat', 51 array(&$this, 'settings_section'), 'misc'); 52 add_settings_field('immerstat_days', 'Number of Days', 53 array(&$this, 'settings_field'), 54 'misc', 'immerstat_setting_section'); 55 register_setting('misc', 'immerstat_days'); 56 add_option('immerstat_days', 30); 57 49 58 if( function_exists('stats_get_csv') && current_user_can( 'manage_options' ) ) { 50 59 $this->load(); 51 60 } 52 61 } 62 63 /** 64 * There's not much to say at the top of the ImmerStats section. 65 */ 66 function settings_section() { 67 // NOOP 68 } 69 70 /** 71 * Shows the input field for the number of days. 72 */ 73 function settings_field() { 74 $days = get_option('immerstat_days'); 75 76 echo "<input name='immerstat_days' id='immerstat_days' type='text' 77 value='".$days."' class='code' />"; 78 } 53 79 54 80 /** … … 65 91 */ 66 92 function load() { 67 $num_days = apply_filters('immerstat_days', 30); 93 $num_days = get_option('immerstat_days'); 94 $old_data = get_option('immerstat_data'); 68 95 69 96 // Use this filter to determine when new stats were actually retrieved 70 97 add_filter('update_option_stats_cache', array(&$this, 'enable_load')); 71 $from_wp = stats_get_csv('views', array('days'=>$num_days, 'limit'=>$num_days, 'summarize'=>false)); 98 $from_wp = stats_get_csv('views', array( 'days'=>$num_days, 99 'limit'=>$num_days, 100 'summarize'=>false)); 72 101 remove_filter('update_option_stats_cache', array(&$this, 'enable_load')); 73 102 … … 75 104 $max = $min = $from_wp[0]['views']; 76 105 77 if( $this->do_load ) { 106 if( $this->do_load || (isset($old_data['days']) && 107 $old_data['days'] != $num_days) ) { 78 108 foreach( $from_wp as $day ) { 79 109 if( $max<$day['views'] ) $max=$day['views']; … … 82 112 } 83 113 84 $stats = array('data'=>implode($data, ','), 'min'=>$min, 'max'=>$max, 'days'=>$num_days, 'current'=>$data[count($data)-1]); 114 $stats = array('data'=>implode($data, ','), 'min'=>$min, 115 'max'=>$max, 'days'=>$num_days, 116 'current'=>$data[count($data)-1]); 85 117 update_option('immerstat_data', $stats); 86 118 } 87 119 88 add_action('admin_footer', array(&$this, 'footer')); 89 add_filter( 'wp_dashboard_widgets', array(&$this,'remove_dashboard_widget'), 11, 1); 90 } 91 92 /** 93 * Removes the WordPress.com Stats widget from the dashboard. 94 */ 95 function remove_dashboard_widget($widgets) { 96 array_splice($widgets, array_search( "dashboard_stats", $widgets), 1 ); 97 return $widgets; 120 // This filter gets called at a convenient place in the header 121 add_filter('favorite_actions', array(&$this, 'show_graph')); 98 122 } 99 123 … … 102 126 * and echo it all out. 103 127 */ 104 function footer() {128 function show_graph($ret) { 105 129 global $_wp_admin_css_colors; 106 130 107 131 // Figure out a good color scheme to use. 108 132 $scheme_name = get_user_option('admin_color'); 109 if ( empty($scheme_name) || !isset($_wp_admin_css_colors[$scheme_name]) || $scheme_name =='fresh' ) { 110 $colors = array('bg'=>'E4F2FD', 'under'=>'2583AD', 'line'=>'D54E21'); 111 } else if( $scheme_name == 'classic' ) { 112 $colors = array('bg'=>'14568A', 'under'=>'CFEBF6', 'line'=>'D54E21'); 133 134 if ( empty($scheme_name) || !isset($_wp_admin_css_colors[$scheme_name]) ) { 135 if( $scheme_name == 'fresh' ) { 136 $colors = array('bg'=>'E4F2FD', 'under'=>'2583AD', 'line'=>'D54E21'); 137 } else { // if( $scheme_name == 'classic' ) { 138 $colors = array('bg'=>'14568A', 'under'=>'CFEBF6', 'line'=>'D54E21'); 139 } 113 140 } else { 114 141 $colors = array('bg'=>'FF0000', 'under'=>'00FF00', 'line'=>'0000FF'); 115 142 $scheme = $_wp_admin_css_colors[$scheme_name]; 116 for( $i=0; $i<3; $i++ ) { 117 if( isset( $scheme->colors[$i])) $colors[$i] = substr($scheme->colors[$i],1); 118 } 143 144 if( count($scheme->colors)>3 ) { 145 $colors['bg'] = substr($scheme->colors[0],1); 146 $colors['under'] = substr($scheme->colors[1],1); 147 $colors['line'] = substr($scheme->colors[2],1); 148 } 119 149 } 120 150 $colors = apply_filters('immerstat_colors', $colors); 121 151 122 152 $stats = get_option('immerstat_data'); 123 $current_ratio = (float)(($stats['current']-$stats['min'])/($stats['max']-$stats['min'])); 153 154 if( $stats['max']==$stats['min']) { 155 $current_ratio=0; 156 } else { 157 $current_ratio = (float)(($stats['current']-$stats['min'])/($stats['max']-$stats['min'])); 158 } 124 159 $width = $stats['days']*4; 125 160 … … 133 168 134 169 $link_args = apply_filters('immerstat_img_link_args', $link_args); 135 $link = add_query_arg($link_args, 'http://chart.apis.google.com/chart?') 136 ?> 137 <script type="text/javascript"> 138 var img = jQuery('<a href="index.php?page=stats"><img title="<?php echo $stats['current'] ?>" alt="<?php echo $stats['current'] ?>" style="position:absolute;top:35px;right:20px;" height="60" width="<?php echo $width ?>" src="<?php echo $link ?>" /></a>'); 139 jQuery('#wphead').append(img); 140 </script> 141 <?php 170 $link = add_query_arg($link_args, 'http://chart.apis.google.com/chart?'); 171 172 ?><div id="immerstat" style="float:left"> 173 <a href="index.php?page=stats"> 174 <img title="<?php echo $stats['current'] ?>" 175 alt="<?php echo $stats['current'] ?>" 176 height="46" width="<?php echo $width ?>" 177 src="<?php echo $link ?>" /> 178 </a></div><?php 179 180 // Don't break the filter 181 return $ret; 142 182 } 143 183 } -
immerstat/tags/0.5/readme.txt
r45294 r126622 3 3 Donate link: http://scompt.com/projects/immerstat 4 4 Tags: stats, wordpress, admin 5 Requires at least: 2. 26 Tested up to: 2. 57 Stable tag: 0. 55 Requires at least: 2.7 6 Tested up to: 2.8 7 Stable tag: 0.6 8 8 9 ImmerStat places a .PNG in the top-right corner of your admin screen with your current WordPress.com pageview statistics.9 ImmerStat places an image in the header of your admin screen with your current WordPress.com pageview statistics. 10 10 11 11 == Description == 12 12 13 ImmerStat places a .PNG in the top-right corner of your admin screen with your current WordPress.com pageview statistics. You must also have the [WordPress.com Stats plugin](http://wordpress.org/extend/plugins/stats/) installed and configured. The graphic is provided using the [Google Charts API](http://code.google.com/apis/chart/). 14 15 It also removes the WordPress.com Stats panel from the dashboard. If you want to see all the information that WordPress.com Stats provides, you can still go to that subpage. Your dashboard no longer has any Flash elements on it! 16 17 ImmerStat has been tested in WordPress 2.5. It should work in versions 2.3 and 2.2, but it hasn't been tested there. Please let [me](mailto:[email protected]) know if there are any problems. 13 ImmerStat places an image in the header of your admin screen with your current WordPress.com pageview statistics. You must also have the [WordPress.com Stats plugin](http://wordpress.org/extend/plugins/stats/) installed and configured. The graphic is provided using the [Google Charts API](http://code.google.com/apis/chart/). 18 14 19 15 == Installation == … … 24 20 == Configuration == 25 21 26 There's no Options/Settings panel for ImmerStat. Instead, a number of filter hooks are provided to change the default behavior. Here's what they are. 27 28 = immerstat_days = 29 30 This is the number of days that should be displayed. The default value is `30`. 22 The number of days displayed in the image is controlled in the Miscellaneous Settings page. The default value is 30. The rest of the options can be controlled using the following filter hooks: 31 23 32 24 = immerstat_colors = … … 46 38 == Screenshots == 47 39 48 1. ImmerStat adds a small .PNG to the top-right corner of your admin screen.40 1. ImmerStat adds a small image to the header of your admin screen. 49 41 50 42 == Future Plans == … … 54 46 == Version History == 55 47 48 = Version 0.6 = 49 50 * Updated for WordPress 2.7/2.8 51 * Now shows an image that fits into the empty space in the middle of the admin header 52 * Moved days setting to Settings page 53 * Won't show warning if there's no data 54 56 55 = Version 0.5 = 57 56
Note: See TracChangeset
for help on using the changeset viewer.