updated plugin Connect Matomo version 1.1.5

This commit is contained in:
2026-06-03 21:28:54 +00:00
committed by Gitium
parent 6e8ffa6f66
commit 1f3438440f
78 changed files with 13800 additions and 5314 deletions

View File

@ -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 );
}
}