updated plugin Connect Matomo version 1.1.5
This commit is contained in:
@ -1,19 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace WP_Piwik\Admin;
|
||||
namespace WP_Piwik\Admin;
|
||||
|
||||
class Network extends \WP_Piwik\Admin\Statistics {
|
||||
class Network extends \WP_Piwik\Admin\Statistics {
|
||||
|
||||
public function show() {
|
||||
parent::show();
|
||||
}
|
||||
|
||||
public function printAdminScripts() {
|
||||
wp_enqueue_script('wp-piwik', self::$wpPiwik->getPluginURL().'js/wp-piwik.js', array(), self::$wpPiwik->getPluginVersion(), true);
|
||||
wp_enqueue_script ( 'wp-piwik-chartjs', self::$wpPiwik->getPluginURL() . 'js/chartjs/chart.min.js', "3.4.1" );
|
||||
}
|
||||
|
||||
public function onLoad() {
|
||||
self::$wpPiwik->onloadStatsPage(self::$pageID);
|
||||
}
|
||||
}
|
||||
public function print_admin_scripts() {
|
||||
$version = self::$wp_piwik->get_plugin_version();
|
||||
wp_enqueue_script( 'wp-piwik', self::$wp_piwik->get_plugin_url() . 'js/wp-piwik.js', array(), $version, true );
|
||||
wp_enqueue_script( 'wp-piwik-chartjs', self::$wp_piwik->get_plugin_url() . 'js/chartjs/chart.min.js', array(), $version, false );
|
||||
}
|
||||
|
||||
public function on_load() {
|
||||
self::$wp_piwik->onload_stats_page();
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,112 +1,132 @@
|
||||
<?php
|
||||
|
||||
namespace WP_Piwik\Admin;
|
||||
|
||||
if (! class_exists ( 'WP_List_Table' ))
|
||||
require_once (ABSPATH . 'wp-admin/includes/class-wp-list-table.php');
|
||||
|
||||
class Sitebrowser extends \WP_List_Table {
|
||||
|
||||
private $data = array (), $wpPiwik;
|
||||
|
||||
public function __construct($wpPiwik) {
|
||||
$this->wpPiwik = $wpPiwik;
|
||||
if( isset($_POST['s']) ){
|
||||
$cnt = $this->prepare_items ($_POST['s']);
|
||||
} else {
|
||||
$cnt = $this->prepare_items ();
|
||||
}
|
||||
global $status, $page;
|
||||
$this->showSearchForm();
|
||||
parent::__construct ( array (
|
||||
'singular' => __ ( 'site', 'wp-piwik' ),
|
||||
'plural' => __ ( 'sites', 'wp-piwik' ),
|
||||
'ajax' => false
|
||||
) );
|
||||
if ($cnt > 0)
|
||||
$this->display ();
|
||||
else
|
||||
echo '<p>' . __ ( 'No site configured yet.', 'wp-piwik' ) . '</p>';
|
||||
}
|
||||
|
||||
public function get_columns() {
|
||||
$columns = array (
|
||||
'id' => __ ( 'Blog ID', 'wp-piwik' ),
|
||||
'name' => __ ( 'Title', 'wp-piwik' ),
|
||||
'siteurl' => __ ( 'URL', 'wp-piwik' ),
|
||||
'piwikid' => __ ( 'Site ID (Piwik)', 'wp-piwik' )
|
||||
);
|
||||
return $columns;
|
||||
}
|
||||
|
||||
public function prepare_items($search = '') {
|
||||
$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 ( $wpdb->prepare('SELECT COUNT(*) FROM ' . $wpdb->blogs . ' WHERE CONCAT(domain, path) LIKE "%%%s%%" AND spam = 0 AND deleted = 0', $search));
|
||||
$blogs = \WP_Piwik\Settings::getBlogList($per_page, $current_page, $search);
|
||||
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 );
|
||||
}
|
||||
|
||||
public function column_default($item, $column_name) {
|
||||
switch ($column_name) {
|
||||
case 'id' :
|
||||
case 'name' :
|
||||
case 'siteurl' :
|
||||
case 'piwikid' :
|
||||
return $item [$column_name];
|
||||
default :
|
||||
return print_r ( $item, true );
|
||||
}
|
||||
}
|
||||
|
||||
private function showSearchForm() {
|
||||
?>
|
||||
<form method="post">
|
||||
<input type="hidden" name="page" value="<?php echo filter_var($_REQUEST['page'], FILTER_SANITIZE_STRING) ?>" />
|
||||
<?php $this->search_box('Search domain and path', 'wpPiwikSiteSearch'); ?>
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace WP_Piwik\Admin;
|
||||
|
||||
if ( ! class_exists( 'WP_List_Table' ) ) {
|
||||
require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery
|
||||
* phpcs:disable WordPress.DB.DirectDatabaseQuery.NoCaching
|
||||
*/
|
||||
class Sitebrowser extends \WP_List_Table {
|
||||
|
||||
private $data = array();
|
||||
|
||||
/**
|
||||
* @var \WP_Piwik
|
||||
*/
|
||||
private $wp_piwik;
|
||||
|
||||
public function __construct( $wp_piwik ) {
|
||||
$this->wp_piwik = $wp_piwik;
|
||||
if ( isset( $_REQUEST['s'] ) ) {
|
||||
$cnt = $this->prepare_items( sanitize_text_field( wp_unslash( $_REQUEST['s'] ) ) );
|
||||
} else {
|
||||
$cnt = $this->prepare_items();
|
||||
}
|
||||
$this->show_search_form();
|
||||
parent::__construct(
|
||||
array(
|
||||
'singular' => __( 'site', 'wp-piwik' ),
|
||||
'plural' => __( 'sites', 'wp-piwik' ),
|
||||
'ajax' => false,
|
||||
)
|
||||
);
|
||||
if ( $cnt > 0 ) {
|
||||
$this->display();
|
||||
} else {
|
||||
echo '<p>' . esc_html__( 'No site configured yet.', 'wp-piwik' ) . '</p>';
|
||||
}
|
||||
}
|
||||
|
||||
public function get_columns() {
|
||||
$columns = array(
|
||||
'id' => __( 'Blog ID', 'wp-piwik' ),
|
||||
'name' => __( 'Title', 'wp-piwik' ),
|
||||
'siteurl' => __( 'URL', 'wp-piwik' ),
|
||||
'piwikid' => __( 'Site ID (Piwik)', 'wp-piwik' ),
|
||||
);
|
||||
return $columns;
|
||||
}
|
||||
|
||||
public function prepare_items( $search = '' ) {
|
||||
global $blog_id;
|
||||
global $wpdb;
|
||||
global $pagenow;
|
||||
|
||||
$current_page = $this->get_pagenum();
|
||||
$per_page = 10;
|
||||
|
||||
if ( is_plugin_active_for_network( 'wp-piwik/wp-piwik.php' ) ) {
|
||||
$search = '%' . $wpdb->esc_like( $search ) . '%';
|
||||
$total_items = $wpdb->get_var( $wpdb->prepare( 'SELECT COUNT(*) FROM %s WHERE CONCAT(domain, path) LIKE %s AND spam = 0 AND deleted = 0', $wpdb->blogs, $search ) );
|
||||
$blogs = \WP_Piwik\Settings::get_blog_list( $per_page, $current_page, $search );
|
||||
foreach ( $blogs as $blog ) {
|
||||
$blog_details = get_blog_details( $blog['blog_id'], true );
|
||||
$this->data [] = array(
|
||||
'name' => $blog_details->blogname,
|
||||
'id' => $blog_details->blog_id,
|
||||
'siteurl' => $blog_details->siteurl,
|
||||
'piwikid' => $this->wp_piwik->get_piwik_site_id( $blog_details->blog_id ),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$blog_details = get_bloginfo();
|
||||
$this->data [] = array(
|
||||
'name' => get_bloginfo( 'name' ),
|
||||
'id' => '-',
|
||||
'siteurl' => get_bloginfo( 'url' ),
|
||||
'piwikid' => $this->wp_piwik->get_piwik_site_id(),
|
||||
);
|
||||
$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'] ) || 'n/a' === $dataset['piwikid'] ) {
|
||||
$this->data [ $key ] ['piwikid'] = __( 'Site not created yet.', 'wp-piwik' );
|
||||
}
|
||||
if ( $this->wp_piwik->is_network_mode() ) {
|
||||
$this->data [ $key ] ['name'] = '<a href="index.php?page=wp-piwik_stats&wpmu_show_stats=' . esc_attr( rawurlencode( $dataset['id'] ) ) . '">' . esc_html( $dataset['name'] ) . '</a>';
|
||||
}
|
||||
}
|
||||
$this->items = $this->data;
|
||||
return count( $this->items );
|
||||
}
|
||||
|
||||
public function column_default( $item, $column_name ) {
|
||||
switch ( $column_name ) {
|
||||
case 'id':
|
||||
case 'name':
|
||||
case 'siteurl':
|
||||
case 'piwikid':
|
||||
return $item [ $column_name ];
|
||||
default:
|
||||
return print_r( $item, true );
|
||||
}
|
||||
}
|
||||
|
||||
private function show_search_form() {
|
||||
$page = isset( $_REQUEST['page'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['page'] ) ) : '';
|
||||
?>
|
||||
<form method="post">
|
||||
<input type="hidden" name="page" value="<?php echo esc_attr( $page ); ?>" />
|
||||
<?php $this->search_box( 'Search domain and path', 'wpPiwikSiteSearch' ); ?>
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,47 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace WP_Piwik\Admin;
|
||||
|
||||
class Statistics extends \WP_Piwik\Admin {
|
||||
namespace WP_Piwik\Admin;
|
||||
|
||||
public function show() {
|
||||
global $screen_layout_columns;
|
||||
if (empty($screen_layout_columns)) $screen_layout_columns = 2;
|
||||
if (self::$settings->getGlobalOption('disable_timelimit')) set_time_limit(0);
|
||||
echo '<div id="wp-piwik-stats-general" class="wrap">';
|
||||
echo '<h2>'.(self::$settings->getGlobalOption('plugin_display_name') == 'WP-Piwik'?'Piwik '.__('Statistics', 'wp-piwik'):self::$settings->getGlobalOption('plugin_display_name')).'</h2>';
|
||||
if (self::$settings->checkNetworkActivation() && function_exists('is_super_admin') && is_super_admin()) {
|
||||
class Statistics extends \WP_Piwik\Admin {
|
||||
|
||||
if (isset($_GET['wpmu_show_stats'])) {
|
||||
switch_to_blog((int) $_GET['wpmu_show_stats']);
|
||||
} elseif ((isset($_GET['overview']) && $_GET['overview']) || (function_exists('is_network_admin') && is_network_admin())) {
|
||||
new \WP_Piwik\Admin\Sitebrowser(self::$wpPiwik);
|
||||
return;
|
||||
}
|
||||
echo '<p>'.__('Currently shown stats:').' <a href="'.get_bloginfo('url').'">'.get_bloginfo('name').'</a>.'.' <a href="?page=wp-piwik_stats&overview=1">Show site overview</a>.</p>';
|
||||
}
|
||||
echo '<form action="admin-post.php" method="post"><input type="hidden" name="action" value="save_wp-piwik_stats_general" /><div id="dashboard-widgets" class="metabox-holder columns-'.$screen_layout_columns.(2 <= $screen_layout_columns?' has-right-sidebar':'').'">';
|
||||
wp_nonce_field('wp-piwik_stats-general');
|
||||
wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
|
||||
wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
|
||||
$columns = array('normal', 'side', 'column3');
|
||||
for ($i = 0; $i < 3; $i++) {
|
||||
echo '<div id="postbox-container-'.($i+1).'" class="postbox-container">';
|
||||
do_meta_boxes(self::$wpPiwik->statsPageId, $columns[$i], null);
|
||||
echo '</div>';
|
||||
}
|
||||
echo '</div></form></div>';
|
||||
echo '<script>//<![CDATA['."\n";
|
||||
echo 'jQuery(document).ready(function($) {$(".if-js-closed").removeClass("if-js-closed").addClass("closed"); postboxes.add_postbox_toggles("'.self::$wpPiwik->statsPageId.'");});'."\n";
|
||||
echo '//]]></script>'."\n";
|
||||
if (self::$settings->checkNetworkActivation() && function_exists('is_super_admin') && is_super_admin()) {
|
||||
restore_current_blog();
|
||||
}
|
||||
/**
|
||||
* @return void
|
||||
* @phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound
|
||||
*/
|
||||
public function show() {
|
||||
global $screen_layout_columns;
|
||||
if ( empty( $screen_layout_columns ) ) {
|
||||
$screen_layout_columns = 2;
|
||||
}
|
||||
|
||||
public function printAdminScripts() {
|
||||
wp_enqueue_script('wp-piwik', self::$wpPiwik->getPluginURL().'js/wp-piwik.js', array(), self::$wpPiwik->getPluginVersion(), true);
|
||||
wp_enqueue_script ( 'wp-piwik-chartjs', self::$wpPiwik->getPluginURL () . 'js/chartjs/chart.min.js', "3.4.1" );
|
||||
if ( self::$settings->get_global_option( 'disable_timelimit' ) ) {
|
||||
set_time_limit( 0 );
|
||||
}
|
||||
echo '<div id="wp-piwik-stats-general" class="wrap">';
|
||||
echo '<h2>' . esc_html( 'WP-Piwik' === self::$settings->get_global_option( 'plugin_display_name' ) ? 'Piwik ' . esc_html__( 'Statistics', 'wp-piwik' ) : self::$settings->get_global_option( 'plugin_display_name' ) ) . '</h2>';
|
||||
if ( self::$settings->check_network_activation() && function_exists( 'is_super_admin' ) && is_super_admin() ) {
|
||||
if ( isset( $_GET['wpmu_show_stats'] ) ) {
|
||||
switch_to_blog( (int) $_GET['wpmu_show_stats'] );
|
||||
} elseif ( ! empty( $_GET['overview'] ) || ( function_exists( 'is_network_admin' ) && is_network_admin() ) ) {
|
||||
new \WP_Piwik\Admin\Sitebrowser( self::$wp_piwik );
|
||||
return;
|
||||
}
|
||||
echo '<p>' . esc_html__( 'Currently shown stats:', 'wp-piwik' ) . ' <a href="' . esc_attr( get_bloginfo( 'url' ) ) . '">' . esc_html( get_bloginfo( 'name' ) ) . '</a>. <a href="?page=wp-piwik_stats&overview=1">Show site overview</a>.</p>';
|
||||
}
|
||||
echo '<form action="admin-post.php" method="post"><input type="hidden" name="action" value="save_wp-piwik_stats_general" /><div id="dashboard-widgets" class="metabox-holder columns-' . esc_attr( $screen_layout_columns ) . esc_attr( 2 <= $screen_layout_columns ? ' has-right-sidebar' : '' ) . '">';
|
||||
wp_nonce_field( 'wp-piwik_stats-general' );
|
||||
wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
|
||||
wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
|
||||
$columns = array( 'normal', 'side', 'column3' );
|
||||
for ( $i = 0; $i < 3; $i++ ) {
|
||||
// @phpstan-ignore-next-line
|
||||
echo '<div id="postbox-container-' . esc_attr( $i + 1 ) . '" class="postbox-container">';
|
||||
do_meta_boxes( self::$wp_piwik->stats_page_id, $columns[ $i ], null );
|
||||
echo '</div>';
|
||||
}
|
||||
echo '</div></form></div>';
|
||||
echo '<script>//<![CDATA[' . "\n";
|
||||
echo 'jQuery(document).ready(function($) {$(".if-js-closed").removeClass("if-js-closed").addClass("closed"); postboxes.add_postbox_toggles(' . wp_json_encode( self::$wp_piwik->stats_page_id ) . ');});' . "\n";
|
||||
echo '//]]></script>' . "\n";
|
||||
if ( self::$settings->check_network_activation() && function_exists( 'is_super_admin' ) && is_super_admin() ) {
|
||||
restore_current_blog();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public function print_admin_scripts() {
|
||||
$version = self::$wp_piwik->get_plugin_version();
|
||||
wp_enqueue_script( 'wp-piwik', self::$wp_piwik->get_plugin_url() . 'js/wp-piwik.js', array(), $version, true );
|
||||
wp_enqueue_script( 'wp-piwik-chartjs', self::$wp_piwik->get_plugin_url() . 'js/chartjs/chart.min.js', array(), $version, false );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user