Ejemplo n.º 1
0
 public function prepare_items()
 {
     $current_page = $this->get_pagenum();
     $per_page = 10;
     global $blog_id;
     global $wpdb;
     global $pagenow;
     if (is_plugin_active_for_network('wp-piwik/wp-piwik.php')) {
         $total_items = $wpdb->get_var('SELECT COUNT(*) FROM ' . $wpdb->blogs);
         $blogs = \WP_Piwik\Settings::getBlogList($per_page, $current_page);
         foreach ($blogs as $blog) {
             $blogDetails = get_blog_details($blog['blog_id'], true);
             $this->data[] = array('name' => $blogDetails->blogname, 'id' => $blogDetails->blog_id, 'siteurl' => $blogDetails->siteurl, 'piwikid' => $this->wpPiwik->getPiwikSiteId($blogDetails->blog_id));
         }
     } else {
         $blogDetails = get_bloginfo();
         $this->data[] = array('name' => get_bloginfo('name'), 'id' => '-', 'siteurl' => get_bloginfo('url'), 'piwikid' => $this->wpPiwik->getPiwikSiteId());
         $total_items = 1;
     }
     $columns = $this->get_columns();
     $hidden = array();
     $sortable = array();
     $this->_column_headers = array($columns, $hidden, $sortable);
     $this->set_pagination_args(array('total_items' => $total_items, 'per_page' => $per_page));
     foreach ($this->data as $key => $dataset) {
         if (empty($dataset['piwikid']) || $dataset['piwikid'] == 'n/a') {
             $this->data[$key]['piwikid'] = __('Site not created yet.', 'wp-piwik');
         }
         if ($this->wpPiwik->isNetworkMode()) {
             $this->data[$key]['name'] = '<a href="index.php?page=wp-piwik_stats&wpmu_show_stats=' . $dataset['id'] . '">' . $dataset['name'] . '</a>';
         }
     }
     $this->items = $this->data;
     return count($this->items);
 }
Ejemplo n.º 2
0
 /**
  * Clear cache and reset settings
  *
  * @param boolean $clearSettings set to true to reset settings (default: false)
  */
 private function clear($clearSettings = false)
 {
     if ($clearSettings) {
         self::$settings->resetSettings();
         $this->showBox('updated', 'yes', __('Settings cleared (except connection settings).'));
     }
     global $wpdb;
     if (self::$settings->checkNetworkActivation()) {
         $aryBlogs = \WP_Piwik\Settings::getBlogList();
         if (is_array($aryBlogs)) {
             foreach ($aryBlogs as $aryBlog) {
                 switch_to_blog($aryBlog['blog_id']);
                 $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_wp-piwik_%'");
                 $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_timeout_wp-piwik_%'");
                 restore_current_blog();
             }
         }
     } else {
         $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_wp-piwik_%'");
         $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_timeout_wp-piwik_%'");
     }
     $this->showBox('updated', 'yes', __('Cache cleared.'));
 }
Ejemplo n.º 3
0
<?php

// Get & delete old version's options
if (self::$settings->checkNetworkActivation()) {
    $oldGlobalOptions = get_site_option('wp-piwik_global-settings', array());
    delete_site_option('wp-piwik_global-settings');
} else {
    $oldGlobalOptions = get_option('wp-piwik_global-settings', array());
    delete_option('wp-piwik_global-settings');
}
$oldOptions = get_option('wp-piwik_settings', array());
delete_option('wp-piwik_settings');
if (self::$settings->checkNetworkActivation()) {
    global $wpdb;
    $aryBlogs = \WP_Piwik\Settings::getBlogList();
    if (is_array($aryBlogs)) {
        foreach ($aryBlogs as $aryBlog) {
            $oldOptions = get_blog_option($aryBlog['blog_id'], 'wp-piwik_settings', array());
            if (!$this->isConfigured()) {
                foreach ($oldOptions as $key => $value) {
                    self::$settings->setOption($key, $value, $aryBlog['blog_id']);
                }
            }
            delete_blog_option($aryBlog['blog_id'], 'wp-piwik_settings');
        }
    }
}
if (!$this->isConfigured()) {
    if (!$oldGlobalOptions['add_tracking_code']) {
        $oldGlobalOptions['track_mode'] = 'disabled';
    } elseif (!$oldGlobalOptions['track_mode']) {