Changeset 421895
- Timestamp:
- 08/10/2011 10:25:47 PM (15 years ago)
- Location:
- wp-piwik/trunk
- Files:
-
- 4 edited
-
dashboard/overview.php (modified) (1 diff)
-
dashboard/visitors.php (modified) (3 diffs)
-
readme.txt (modified) (3 diffs)
-
wp-piwik.php (modified) (23 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-piwik/trunk/dashboard/overview.php
r402225 r421895 59 59 echo '<tr><td>'.__('Bounce count', 'wp-piwik').':</td><td>'.$aryConf['data']['bounce_count'].' ('.$aryConf['data']['bounce_rate'].')</td></tr>'; 60 60 if (self::$aryGlobalSettings['piwik_shortcut']) 61 echo '<tr><td>'.__('Shortcut', 'wp-piwik').':</td><td><a href="'.self::$aryGlobalSettings['piwik_url'].'">Piwik</a>'.(isset($aryConf['inline']) && $aryConf['inline']?' - <a href="?page=wp-piwik /wp-piwik.php">WP-Piwik</a>':'').'</td></tr>';61 echo '<tr><td>'.__('Shortcut', 'wp-piwik').':</td><td><a href="'.self::$aryGlobalSettings['piwik_url'].'">Piwik</a>'.(isset($aryConf['inline']) && $aryConf['inline']?' - <a href="?page=wp-piwik_stats">WP-Piwik</a>':'').'</td></tr>'; 62 62 63 63 /***************************************************************************/ ?> -
wp-piwik/trunk/dashboard/visitors.php
r371267 r421895 22 22 $aryConf['params']['limit'] 23 23 ); 24 $aryConf['title'] = __('Visitors', 'wp-piwik');25 24 26 25 if (!isset($aryConf['inline']) || $aryConf['inline'] != true) … … 48 47 /***************************************************************************/ ?> 49 48 <div class="wp-piwik-graph-wide"> 50 <div id="wp-piwik_stats_vistors_graph" style="height:220px;width: 100%"></div>49 <div id="wp-piwik_stats_vistors_graph" style="height:220px;width:490px;"></div> 51 50 </div> 52 51 <?php if (!isset($aryConf['inline']) || $aryConf['inline'] != true) { ?> … … 66 65 $aryTmp = array_reverse($aryConf['data']['Visitors']); 67 66 foreach ($aryTmp as $strDate => $intValue) 68 echo '<tr onclick="javascript:datelink(\''.urlencode( self::$strPluginBasename).'\',\''.str_replace('-', '', $strDate).'\');"><td>'.$strDate.'</td><td class="n">'.67 echo '<tr onclick="javascript:datelink(\''.urlencode('wp-piwik_stats').'\',\''.str_replace('-', '', $strDate).'\');"><td>'.$strDate.'</td><td class="n">'. 69 68 $intValue.'</td><td class="n">'. 70 69 $aryConf['data']['Unique'][$strDate]. -
wp-piwik/trunk/readme.txt
r402225 r421895 2 2 3 3 Contributors: Braekling 4 Requires at least: 3. 15 Tested up to: 3. 1.36 Stable tag: 0.8. 84 Requires at least: 3.2 5 Tested up to: 3.2.1 6 Stable tag: 0.8.9 7 7 Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=6046779 8 8 Tags: statistics, stats, analytics, piwik, wpmu … … 48 48 49 49 * Graphs powered by [jqPlot](http://www.jqplot.com/), an open source project by Chris Leonello. Give it a try! (GPL 2.0 and MIT) 50 * Metabox support inspired by [Heiko Rabe's metabox demo plugin](http://www.code-styling.de/english/how-to-use-wordpress-metaboxes-at-own-plugins). 50 51 * Albanian [sq] language file by [Besnik Bleta](http://blogu.programeshqip.org/). 51 52 * Azerbaijani [az_AZ] language file by [Galina Miklosic](http://www.webhostinggeeks.com). … … 78 79 79 80 == Changelog == 81 82 = 0.8.9 = 83 * WP 3.2 compatible, metabox support 80 84 81 85 = 0.8.8 = -
wp-piwik/trunk/wp-piwik.php
r415623 r421895 7 7 Description: Adds Piwik stats to your dashboard menu and Piwik code to your wordpress footer. 8 8 9 Version: 0.8. 89 Version: 0.8.9 10 10 Author: André Bräkling 11 11 Author URI: http://www.braekling.de … … 28 28 *******************************************************************************************/ 29 29 30 /* Avoid direct calls to this file where wp core files not present 31 seen in Heiko Rabe's metabox demo plugin http://tinyurl.com/5r5vnzs */ 30 /* Avoid direct calls to this file if wp core files not present 31 seen (as some other parts) in Heiko Rabe's metabox demo plugin 32 http://tinyurl.com/5r5vnzs */ 32 33 if (!function_exists ('add_action')) { 33 34 header('Status: 403 Forbidden'); … … 42 43 43 44 private static 44 $intRevisionId = 80 800,45 $strVersion = '0.8. 8',46 $intDashboardID = 20,45 $intRevisionId = 80900, 46 $strVersion = '0.8.9', 47 $intDashboardID = 30, 47 48 $bolWPMU = false, 48 49 $bolOverall = false, … … 128 129 register_activation_hook(__FILE__, array($this, 'install')); 129 130 // Add meta links to plugin details 130 if (!self::$bolWPMU) add_filter('plugin_row_meta', array($this, 'set _plugin_meta'), 10, 2);131 if (!self::$bolWPMU) add_filter('plugin_row_meta', array($this, 'setPluginMeta'), 10, 2); 131 132 // Add tracking code to footer if enabled 132 133 if (self::$aryGlobalSettings['add_tracking_code']) add_action('wp_footer', array($this, 'footer')); 134 // Register columns 135 //add_filter('screen_layout_columns', array(&$this, 'onScreenLayoutColumns'), 10, 2); 133 136 // Add admin menu 134 add_action('admin_menu', array($this, 'build_menu')); 137 add_action('admin_menu', array($this, 'buildAdminMenu')); 138 // Register the callback been used if options of page been submitted and needs to be processed 139 add_action('admin_post_save_wp-piwik_stats', array(&$this, 'onStatsPageSaveChanges')); 135 140 // Add dashboard widget if enabled 136 141 if (self::$aryGlobalSettings['dashboard_widget'] || self::$aryGlobalSettings['dashboard_chart']) … … 147 152 */ 148 153 function install() { 149 150 154 // Update: Translate options 151 155 if (self::$aryGlobalSettings['revision'] < 80403) { … … 185 189 'piwik_shortcut' => get_option('wp-piwik_piwiklink',false), 186 190 ); 187 188 191 $this->installSite(false); 189 190 192 // Remove deprecated option values 191 193 $aryRemoveOptions = array( … … 212 214 self::$aryGlobalSettings['revision'] = self::$intRevisionId; 213 215 self::$aryGlobalSettings['last_settings_update'] = time(); 214 215 216 // Save upgraded or default settings 216 217 self::saveSettings(); … … 303 304 * Add pages to admin menu 304 305 */ 305 function build _menu() {306 function buildAdminMenu() { 306 307 // Show stats dashboard page if WP-Piwik is configured 307 308 if (!empty(self::$aryGlobalSettings['piwik_token']) && !empty(self::$aryGlobalSettings['piwik_url'])) { … … 312 313 (!self::$bolWPMU?'wp-piwik_read_stats':'administrator'), 313 314 'wp-piwik_stats', 314 array($this, 'show_stats') 315 ); 316 // Register columns 317 add_filter('screen_layout_columns', array(&$this, 'on_screen_layout_columns'), 10, 2); 318 // Register the callback been used if options of page been submitted and needs to be processed 319 add_action('admin_post_save_wp-piwik_stats', array(&$this, 'on_stats_page_save_changes')); 315 array($this, 'showStats') 316 ); 320 317 // Add required scripts 321 318 add_action('admin_print_scripts-'.$this->intStatsPage, array($this, 'load_scripts')); … … 325 322 add_action('admin_head-'.$this->intStatsPage, array($this, 'add_admin_header')); 326 323 // Stats page onload callback 327 add_action('load-'.$this->intStatsPage, array(&$this, 'onload _stats_page'));324 add_action('load-'.$this->intStatsPage, array(&$this, 'onloadStatsPage')); 328 325 } 329 326 // Add options page if not multi-user … … 354 351 355 352 /* Support two columns 356 seen in Heiko Rabe's metabox demo plugin http://tinyurl.com/5r5vnzs */ 357 function on_screen_layout_columns($aryColumns, $strScreen) { 358 //if (!defined( 'WP_NETWORK_ADMIN' ) && !defined( 'WP_USER_ADMIN' )) { 359 if ($strScreen == $this->intStatsPage) { 360 $aryColumns[$this->intStatsPage] = 2; 361 } 362 //} 353 seen in Heiko Rabe's metabox demo plugin 354 http://tinyurl.com/5r5vnzs */ 355 function onScreenLayoutColumns($aryColumns, $strScreen) { 356 if ($strScreen == $this->intStatsPage) 357 $aryColumns[$this->intStatsPage] = 4; 363 358 return $aryColumns; 364 359 } … … 393 388 'wp-piwik_stats-dashboard-overview', 394 389 __('WP-Piwik', 'wp-piwik').' - '.__(self::$aryGlobalSettings['dashboard_widget'], 'wp-piwik'), 395 array(&$this, 'create _dashboard_widget'),390 array(&$this, 'createDashboardWidget'), 396 391 'dashboard', 397 392 'side', … … 417 412 'wp-piwik_stats-dashboard-chart', 418 413 __('WP-Piwik', 'wp-piwik').' - '.__('Visitors', 'wp-piwik'), 419 array(&$this, 'create _dashboard_widget'),414 array(&$this, 'createDashboardWidget'), 420 415 'dashboard', 421 416 'side', … … 430 425 * @see http://wpengineer.com/1295/meta-links-for-wordpress-plugins/ 431 426 */ 432 function set _plugin_meta($strLinks, $strFile) {427 function setPluginMeta($strLinks, $strFile) { 433 428 // Get plugin basename 434 429 $strPlugin = plugin_basename(__FILE__); … … 450 445 function load_scripts() { 451 446 // Load WP-Piwik script 452 wp_enqueue_script('wp-piwik', $this->get_plugin_url().'js/wp-piwik.js', array( 'jquery', 'admin-comments', 'dashboard','thickbox'), self::$strVersion, true);447 wp_enqueue_script('wp-piwik', $this->get_plugin_url().'js/wp-piwik.js', array(), self::$strVersion, true); 453 448 // Load jqPlot 454 449 wp_enqueue_script('wp-piwik-jqplot',$this->get_plugin_url().'js/jqplot/wp-piwik.jqplot.js',array('jquery')); … … 567 562 } 568 563 569 function create _dashboard_widget($objPost, $aryMetabox) {564 function createDashboardWidget($objPost, $aryMetabox) { 570 565 $strDesc = $strID = ''; 571 566 $aryConfig = $aryMetabox['args']['aryConfig']; … … 594 589 } 595 590 596 function onload _stats_page() {597 wp_enqueue_script('common');591 function onloadStatsPage() { 592 wp_enqueue_script('common'); 598 593 wp_enqueue_script('wp-lists'); 599 594 wp_enqueue_script('postbox'); 600 595 $strToken = self::$aryGlobalSettings['piwik_token']; 601 596 $strPiwikURL = self::$aryGlobalSettings['piwik_url']; 602 $arySortOrder = get_user_option('meta-box-order_wppiwik');603 $aryClosed = get_user_option('closedpostboxes_wppiwik');604 if (empty($aryClosed)) $aryClosed = array();605 597 $aryDashboard = array(); 606 $intCurrentDashboard = self::$arySettings['dashboard_revision']; 607 if (!$arySortOrder || $intCurrentDashboard < 20) { 608 // Set default configuration 609 $arySortOrder = array( 610 'side' => 'overview_day_yesterday,pages_day_yesterday,keywords_day_yesterday_10,websites_day_yesterday_10,plugins_day_yesterday', 611 'normal' => 'visitors_day_last30,browsers_day_yesterday,screens_day_yesterday,systems_day_yesterday' 612 ); 613 global $current_user; 614 get_currentuserinfo(); 615 update_user_option($current_user->ID, 'meta-box-order_wppiwik', $arySortOrder); 616 self::$arySettings['dashboard_revision'] = self::$intDashboardID; 617 self::saveSettings(); 618 } 619 foreach ($arySortOrder as $strCol => $strWidgets) { 620 $aryWidgets = explode(',', $strWidgets); 621 if (is_array($aryWidgets)) foreach ($aryWidgets as $strParams) { 622 $aryParams = explode('_', $strParams); 623 $aryDashboard[$strCol][$aryParams[0]] = array( 598 // Set default configuration 599 $arySortOrder = array( 600 'side' => array( 601 'overview' => array(__('Overview', 'wp-piwik'), 'day', 'yesterday'), 602 'pages' => array(__('Pages', 'wp-piwik'), 'day', 'yesterday'), 603 'keywords' => array(__('Keywords', 'wp-piwik'), 'day', 'yesterday', 10), 604 'websites' => array(__('Websites', 'wp-piwik'), 'day', 'yesterday', 10), 605 'plugins' => array(__('Plugins', 'wp-piwik'), 'day', 'yesterday') 606 ), 607 'normal' => array( 608 'visitors' => array(__('Visitors', 'wp-piwik'), 'day', 'last30'), 609 'browsers' => array(__('Browser', 'wp-piwik'), 'day', 'yesterday'), 610 'screens' => array(__('Resolution', 'wp-piwik'), 'day', 'yesterday'), 611 'systems' => array(__('Operating System', 'wp-piwik'), 'day', 'yesterday') 612 ) 613 ); 614 foreach ($arySortOrder as $strCol => $aryWidgets) { 615 if (is_array($aryWidgets)) foreach ($aryWidgets as $strFile => $aryParams) { 616 $aryDashboard[$strCol][$strFile] = array( 624 617 'params' => array( 618 'title' => (isset($aryParams[0])?$aryParams[0]:$strFile), 625 619 'period' => (isset($aryParams[1])?$aryParams[1]:''), 626 620 'date' => (isset($aryParams[2])?$aryParams[2]:''), 627 621 'limit' => (isset($aryParams[3])?$aryParams[3]:'') 628 ), 629 'closed' => (in_array($strParams, $aryClosed)) 622 ) 630 623 ); 631 if (isset($_GET['date']) && preg_match('/^[0-9]{8}$/', $_GET['date']) && $ aryParams[0]!= 'visitors')632 $aryDashboard[$strCol][$ aryParams[0]]['params']['date'] = $_GET['date'];633 elseif ($ aryParams[0]!= 'visitors')634 $aryDashboard[$strCol][$ aryParams[0]]['params']['date'] = self::$aryGlobalSettings['default_date'];624 if (isset($_GET['date']) && preg_match('/^[0-9]{8}$/', $_GET['date']) && $strFile != 'visitors') 625 $aryDashboard[$strCol][$strFile]['params']['date'] = $_GET['date']; 626 elseif ($strFile != 'visitors') 627 $aryDashboard[$strCol][$strFile]['params']['date'] = self::$aryGlobalSettings['default_date']; 635 628 } 636 629 } … … 640 633 add_meta_box( 641 634 'wp-piwik_stats-sidebox-'.$intSideBoxCnt, 642 $ strFile.' '.$aryConfig['params']['date'],643 array(&$this, 'create _dashboard_widget'),635 $aryConfig['params']['title'].' '.$aryConfig['params']['date'], 636 array(&$this, 'createDashboardWidget'), 644 637 $this->intStatsPage, 645 638 'side', … … 652 645 add_meta_box( 653 646 'wp-piwik_stats-contentbox-'.$intContentBox, 654 $ strFile.' '.$aryConfig['params']['date'],655 array(&$this, 'create _dashboard_widget'),647 $aryConfig['params']['title'].' '.$aryConfig['params']['date'], 648 array(&$this, 'createDashboardWidget'), 656 649 $this->intStatsPage, 657 650 'normal', … … 662 655 } 663 656 664 function show _stats() {657 function showStats() { 665 658 //we need the global screen column value to be able to have a sidebar in WordPress 2.8 666 659 global $screen_layout_columns; … … 692 685 <?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false ); ?> 693 686 <?php wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false ); ?> 694 <input type="hidden" name="action" value="save_wp-piwik_stats_general" /> 695 <div id="poststuff" class="metabox-holder has-right-sidebar" >696 <div id="side-info-column" class="inner-sidebar">697 <?php $meta_boxes =do_meta_boxes($this->intStatsPage, 'side', $data); ?>698 </div>687 <input type="hidden" name="action" value="save_wp-piwik_stats_general" /> 688 <div id="poststuff" class="metabox-holder has-right-sidebar" style="width:<?php echo 528+281; ?>px;"> 689 <div id="side-info-column" class="inner-sidebar wp-piwik-side"> 690 <?php do_meta_boxes($this->intStatsPage, 'side', $data); ?> 691 </div> 699 692 <div id="post-body" class="has-sidebar"> 700 <div id="post-body-content" class="has-sidebar-content">693 <div id="post-body-content" class="postbox-container has-sidebar-content"> 701 694 <?php $meta_boxes = do_meta_boxes($this->intStatsPage, 'normal', $data); ?> 702 <?php $meta_boxes = do_meta_boxes($this->intStatsPage, 'additional', $data); ?>703 695 </div> 704 696 </div> … … 723 715 } 724 716 725 //executed if the post arrives initiated by pressing the submit button of form 726 function on_stats_page_save_changes() { 717 /* Stats page changes by POST submit 718 seen in Heiko Rabe's metabox demo plugin 719 http://tinyurl.com/5r5vnzs */ 720 function onStatsPageSaveChanges() { 727 721 //user permission check 728 722 if ( !current_user_can('manage_options') ) 729 723 wp_die( __('Cheatin’ uh?') ); 730 724 //cross check the given referer 731 check_admin_referer('wp-piwik_stats-general'); 732 725 check_admin_referer('wp-piwik_stats'); 733 726 //process here your on $_POST validation and / or option saving 734 735 727 //lets redirect the post request into get request (you may add additional params at the url, if you need to show save results 736 728 wp_redirect($_POST['_wp_http_referer']); … … 1034 1026 <p><strong><?php _e('Thank you very much for your donation', 'wp-piwik'); ?>:</strong> Marco L., Rolf W., Tobias U., Lars K., Donna F. <?php _e('and all people flattering this','wp-piwik'); ?>!</p> 1035 1027 <p><?php _e('Graphs powered by <a href="http://www.jqplot.com/">jqPlot</a>, an open source project by Chris Leonello. Give it a try! (License: GPL 2.0 and MIT)','wp-piwik'); ?></p> 1028 <p><?php _e('Metabox support inspired by <a href="http://www.code-styling.de/english/how-to-use-wordpress-metaboxes-at-own-plugins">Heiko Rabe\'s metabox demo plugin</a>.')?></p> 1036 1029 <p><?php _e('Thank you very much','wp-piwik'); ?>, <a href="http://blogu.programeshqip.org/">Besnik Bleta</a>, <a href="http://www.fatcow.com/">FatCow</a>, <a href="http://www.pamukkaleturkey.com/">Rene</a>, Fab, <a href="http://ezbizniz.com/">EzBizNiz</a>, Gormer, Natalya, <a href="www.aggeliopolis.gr">AggelioPolis</a><?php _e(', and', 'wp-piwik'); ?> <a href="http://wwww.webhostinggeeks.com">Galina Miklosic</a> <?php _e('for your translation work','wp-piwik'); ?>!</p> 1037 1030 <p><?php _e('Thank you very much, all users who send me mails containing criticism, commendation, feature requests and bug reports! You help me to make WP-Piwik much better.','wp-piwik'); ?></p>
Note: See TracChangeset
for help on using the changeset viewer.