Plugin Directory

Changeset 421895


Ignore:
Timestamp:
08/10/2011 10:25:47 PM (15 years ago)
Author:
Braekling
Message:

0.8.9 - WP 3.2 compatible

Location:
wp-piwik/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • wp-piwik/trunk/dashboard/overview.php

    r402225 r421895  
    5959    echo '<tr><td>'.__('Bounce count', 'wp-piwik').':</td><td>'.$aryConf['data']['bounce_count'].' ('.$aryConf['data']['bounce_rate'].')</td></tr>';
    6060    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>';
    6262
    6363/***************************************************************************/ ?>
  • wp-piwik/trunk/dashboard/visitors.php

    r371267 r421895  
    2222        $aryConf['params']['limit']
    2323    ); 
    24     $aryConf['title'] = __('Visitors', 'wp-piwik');
    2524   
    2625    if (!isset($aryConf['inline']) || $aryConf['inline'] != true)
     
    4847/***************************************************************************/ ?>
    4948<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>
    5150</div>
    5251<?php if (!isset($aryConf['inline']) || $aryConf['inline'] != true) { ?>
     
    6665        $aryTmp = array_reverse($aryConf['data']['Visitors']);
    6766        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">'.
    6968                $intValue.'</td><td class="n">'.
    7069                $aryConf['data']['Unique'][$strDate].
  • wp-piwik/trunk/readme.txt

    r402225 r421895  
    22
    33Contributors: Braekling
    4 Requires at least: 3.1
    5 Tested up to: 3.1.3
    6 Stable tag: 0.8.8
     4Requires at least: 3.2
     5Tested up to: 3.2.1
     6Stable tag: 0.8.9
    77Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=6046779
    88Tags: statistics, stats, analytics, piwik, wpmu
     
    4848
    4949* 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).
    5051* Albanian [sq] language file by [Besnik Bleta](http://blogu.programeshqip.org/).
    5152* Azerbaijani [az_AZ] language file by [Galina Miklosic](http://www.webhostinggeeks.com).
     
    7879
    7980== Changelog ==
     81
     82= 0.8.9 =
     83* WP 3.2 compatible, metabox support
    8084
    8185= 0.8.8 =
  • wp-piwik/trunk/wp-piwik.php

    r415623 r421895  
    77Description: Adds Piwik stats to your dashboard menu and Piwik code to your wordpress footer.
    88
    9 Version: 0.8.8
     9Version: 0.8.9
    1010Author: Andr&eacute; Br&auml;kling
    1111Author URI: http://www.braekling.de
     
    2828*******************************************************************************************/
    2929
    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 */
    3233if (!function_exists ('add_action')) {
    3334    header('Status: 403 Forbidden');
     
    4243
    4344    private static
    44         $intRevisionId = 80800,
    45         $strVersion = '0.8.8',
    46         $intDashboardID = 20,
     45        $intRevisionId = 80900,
     46        $strVersion = '0.8.9',
     47        $intDashboardID = 30,
    4748        $bolWPMU = false,
    4849        $bolOverall = false,
     
    128129        register_activation_hook(__FILE__, array($this, 'install'));
    129130        // 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);
    131132        // Add tracking code to footer if enabled
    132133        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);
    133136        // 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'));
    135140        // Add dashboard widget if enabled
    136141        if (self::$aryGlobalSettings['dashboard_widget'] || self::$aryGlobalSettings['dashboard_chart'])
     
    147152     */
    148153    function install() {
    149        
    150154        // Update: Translate options
    151155        if (self::$aryGlobalSettings['revision'] < 80403) {
     
    185189                'piwik_shortcut'    => get_option('wp-piwik_piwiklink',false),
    186190            );
    187 
    188191            $this->installSite(false);
    189            
    190192            // Remove deprecated option values
    191193            $aryRemoveOptions = array(
     
    212214        self::$aryGlobalSettings['revision'] = self::$intRevisionId;
    213215        self::$aryGlobalSettings['last_settings_update'] = time();
    214        
    215216        // Save upgraded or default settings
    216217        self::saveSettings();
     
    303304     * Add pages to admin menu
    304305     */
    305     function build_menu() {     
     306    function buildAdminMenu() {     
    306307        // Show stats dashboard page if WP-Piwik is configured
    307308        if (!empty(self::$aryGlobalSettings['piwik_token']) && !empty(self::$aryGlobalSettings['piwik_url'])) {
     
    312313                (!self::$bolWPMU?'wp-piwik_read_stats':'administrator'),
    313314                '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            );
    320317            // Add required scripts
    321318            add_action('admin_print_scripts-'.$this->intStatsPage, array($this, 'load_scripts'));
     
    325322            add_action('admin_head-'.$this->intStatsPage, array($this, 'add_admin_header'));
    326323            // Stats page onload callback
    327             add_action('load-'.$this->intStatsPage, array(&$this, 'onload_stats_page'));
     324            add_action('load-'.$this->intStatsPage, array(&$this, 'onloadStatsPage'));
    328325        }
    329326        // Add options page if not multi-user
     
    354351
    355352    /* 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;
    363358        return $aryColumns;
    364359    }
     
    393388                'wp-piwik_stats-dashboard-overview',
    394389                __('WP-Piwik', 'wp-piwik').' - '.__(self::$aryGlobalSettings['dashboard_widget'], 'wp-piwik'),
    395                 array(&$this, 'create_dashboard_widget'),
     390                array(&$this, 'createDashboardWidget'),
    396391                'dashboard',
    397392                'side',
     
    417412                'wp-piwik_stats-dashboard-chart',
    418413                __('WP-Piwik', 'wp-piwik').' - '.__('Visitors', 'wp-piwik'),
    419                 array(&$this, 'create_dashboard_widget'),
     414                array(&$this, 'createDashboardWidget'),
    420415                'dashboard',
    421416                'side',
     
    430425     * @see http://wpengineer.com/1295/meta-links-for-wordpress-plugins/
    431426     */
    432     function set_plugin_meta($strLinks, $strFile) {
     427    function setPluginMeta($strLinks, $strFile) {
    433428        // Get plugin basename
    434429        $strPlugin = plugin_basename(__FILE__);
     
    450445    function load_scripts() {
    451446        // 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);
    453448        // Load jqPlot
    454449        wp_enqueue_script('wp-piwik-jqplot',$this->get_plugin_url().'js/jqplot/wp-piwik.jqplot.js',array('jquery'));
     
    567562    }
    568563
    569     function create_dashboard_widget($objPost, $aryMetabox) {
     564    function createDashboardWidget($objPost, $aryMetabox) {
    570565        $strDesc = $strID = '';
    571566        $aryConfig = $aryMetabox['args']['aryConfig'];
     
    594589    }
    595590
    596     function onload_stats_page() {
    597         wp_enqueue_script('common');
     591    function onloadStatsPage() {
     592    wp_enqueue_script('common');
    598593        wp_enqueue_script('wp-lists');
    599594        wp_enqueue_script('postbox');
    600595        $strToken = self::$aryGlobalSettings['piwik_token'];
    601596        $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();
    605597        $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(
    624617                        'params' => array(
     618                            'title'  => (isset($aryParams[0])?$aryParams[0]:$strFile),
    625619                            'period' => (isset($aryParams[1])?$aryParams[1]:''),
    626620                            'date'   => (isset($aryParams[2])?$aryParams[2]:''),
    627621                            'limit'  => (isset($aryParams[3])?$aryParams[3]:'')
    628                         ),
    629                         'closed' => (in_array($strParams, $aryClosed))
     622                        )
    630623                    );
    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'];
    635628            }
    636629        }
     
    640633            add_meta_box(
    641634                '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'),
    644637                $this->intStatsPage,
    645638                'side',
     
    652645            add_meta_box(
    653646                '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'),
    656649                $this->intStatsPage,
    657650                'normal',
     
    662655    }
    663656       
    664     function show_stats() {
     657    function showStats() {
    665658        //we need the global screen column value to be able to have a sidebar in WordPress 2.8
    666659        global $screen_layout_columns;     
     
    692685        <?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false ); ?>
    693686        <?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>
    699692            <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">
    701694                    <?php $meta_boxes = do_meta_boxes($this->intStatsPage, 'normal', $data); ?>
    702                     <?php $meta_boxes = do_meta_boxes($this->intStatsPage, 'additional', $data); ?>
    703695                </div>
    704696            </div>
     
    723715    }
    724716
    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() {
    727721        //user permission check
    728722        if ( !current_user_can('manage_options') )
    729723            wp_die( __('Cheatin&#8217; uh?') );         
    730724        //cross check the given referer
    731         check_admin_referer('wp-piwik_stats-general');
    732        
     725        check_admin_referer('wp-piwik_stats');
    733726        //process here your on $_POST validation and / or option saving
    734        
    735727        //lets redirect the post request into get request (you may add additional params at the url, if you need to show save results
    736728        wp_redirect($_POST['_wp_http_referer']);       
     
    10341026        <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>
    10351027        <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>
    10361029        <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>
    10371030        <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.