access.php
4 years ago
advanced_settings.php
4 years ago
exclusion_settings.php
4 years ago
geolocation_settings.php
4 years ago
get_started.php
4 years ago
import_wp_statistics.php
4 years ago
info.php
4 years ago
info_bug_report.php
4 years ago
info_help.php
4 years ago
info_high_traffic.php
4 years ago
info_multisite.php
4 years ago
info_newsletter.php
4 years ago
info_shared.php
4 years ago
marketplace.php
4 years ago
privacy_gdpr.php
4 years ago
settings.php
4 years ago
settings_errors.php
4 years ago
summary.php
4 years ago
systemreport.php
3 years ago
tracking.php
3 years ago
update_notice_clear_cache.php
5 years ago
summary.php
173 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Matomo - free/libre analytics platform |
| 4 | * |
| 5 | * @link https://matomo.org |
| 6 | * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later |
| 7 | * @package matomo |
| 8 | */ |
| 9 | /** |
| 10 | * phpcs considers all of our variables as global and want them prefixed with matomo |
| 11 | * phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound |
| 12 | */ |
| 13 | use WpMatomo\Admin\Dashboard; |
| 14 | use WpMatomo\Admin\Menu; |
| 15 | use WpMatomo\Admin\Summary; |
| 16 | use WpMatomo\Report\Dates; |
| 17 | |
| 18 | if ( ! defined( 'ABSPATH' ) ) { |
| 19 | exit; |
| 20 | } |
| 21 | |
| 22 | /** @var array $report_metadata */ |
| 23 | /** @var array $report_dates */ |
| 24 | /** @var array $reports_to_show */ |
| 25 | /** @var string $report_date */ |
| 26 | /** @var string $report_period_selected */ |
| 27 | /** @var string $report_date_selected */ |
| 28 | /** @var bool $matomo_pinned */ |
| 29 | /** @var bool $is_tracking */ |
| 30 | /** @var bool $matomo_is_version_pre55 */ |
| 31 | /** @var Dashboard $matomo_dashboard */ |
| 32 | global $wp; |
| 33 | |
| 34 | $matomo_dashboard_nonce = wp_create_nonce( Summary::NONCE_DASHBOARD ); |
| 35 | ?> |
| 36 | <?php |
| 37 | if ( $matomo_pinned ) { |
| 38 | echo '<div class="notice notice-success"><p>' . esc_html__( 'Dashboard updated.', 'matomo' ) . '</p></div>'; |
| 39 | } |
| 40 | if ( $matomo_is_version_pre55 ) { |
| 41 | echo '<style type="text/css">.handle-actions { position: absolute; right: 0;top: 0;}</style>'; |
| 42 | } |
| 43 | ?> |
| 44 | <?php if ( ! $is_tracking ) { ?> |
| 45 | <div class="notice notice-warning"> |
| 46 | <p><?php esc_html_e( 'Matomo Tracking is not enabled. If you have added the Matomo tracking code in a different way, for example using a consent plugin, then you can ignore this message.', 'matomo' ); ?></p> |
| 47 | </div> |
| 48 | <?php } ?> |
| 49 | <div class="wrap"> |
| 50 | <div id="icon-plugins" class="icon32"></div> |
| 51 | <h1><?php matomo_header_icon(); ?><?php esc_html_e( 'Summary', 'matomo' ); ?></h1> |
| 52 | <?php |
| 53 | if ( Dates::TODAY === $report_date ) { |
| 54 | echo '<div class="notice notice-info" style="padding:8px;">' . esc_html__( 'Reports for today are only refreshed approximately every hour through the WordPress cronjob.', 'matomo' ) . '</div>'; |
| 55 | } |
| 56 | ?> |
| 57 | <p><?php esc_html_e( 'Looking for all reports and advanced features like segmentation, real time reports, and more?', 'matomo' ); ?> |
| 58 | <a href="<?php echo esc_url( add_query_arg( [ 'report_date' => $report_date ], menu_page_url( Menu::SLUG_REPORTING, false ) ) ); ?>" |
| 59 | ><?php esc_html_e( 'View full reporting', 'matomo' ); ?></a> |
| 60 | <br/><br/> |
| 61 | <?php esc_html_e( 'Change date:', 'matomo' ); ?> |
| 62 | <?php |
| 63 | foreach ( $report_dates as $matomo_report_date_key => $matomo_report_name ) { |
| 64 | $matomo_button_class = 'button'; |
| 65 | if ( $report_date === $matomo_report_date_key ) { |
| 66 | $matomo_button_class = 'button-primary'; |
| 67 | } |
| 68 | echo '<a href="' . esc_url( add_query_arg( [ 'report_date' => $matomo_report_date_key ], menu_page_url( Menu::SLUG_REPORT_SUMMARY, false ) ) ) . '" class="' . esc_attr( $matomo_button_class ) . '">' . esc_html( $matomo_report_name ) . '</a> '; |
| 69 | } |
| 70 | ?> |
| 71 | |
| 72 | <div id="dashboard-widgets" class="metabox-holder has-right-sidebar matomo-dashboard-container"> |
| 73 | <?php |
| 74 | $matomo_columns = [ 1, 0 ]; |
| 75 | foreach ( $matomo_columns as $matomo_column_index => $matomo_column_modulo ) { |
| 76 | ?> |
| 77 | <div id="postbox-container-<?php echo ( esc_html( $matomo_column_index + 1 ) ); ?>" class="postbox-container"> |
| 78 | <div id="normal-sortables" class="meta-box-sortables ui-sortable"> |
| 79 | <?php |
| 80 | foreach ( $reports_to_show as $matomo_index => $matomo_report_meta ) { |
| 81 | if ( $matomo_index % 2 === $matomo_column_modulo ) { |
| 82 | continue; |
| 83 | } |
| 84 | $shortcode = sprintf( '[matomo_report unique_id=%s report_date=%s limit=10]', $matomo_report_meta['uniqueId'], $report_date ); |
| 85 | ?> |
| 86 | <div class="postbox "> |
| 87 | <div class="postbox-header"> |
| 88 | <h2 class="hndle ui-sortable-handle" |
| 89 | style="cursor: help;" |
| 90 | title="<?php echo ! empty( $matomo_report_meta['documentation'] ) ? ( esc_html( wp_strip_all_tags( $matomo_report_meta['documentation'] ) . ' ' ) ) : null; ?><?php esc_html_e( 'You can embed this report on any page using the shortcode:', 'matomo' ); ?> <?php echo esc_attr( $shortcode ); ?>"> |
| 91 | <?php echo esc_html( $matomo_report_meta['name'] ); ?></h2> |
| 92 | <div class="handle-actions hide-if-no-js"> |
| 93 | <?php if ( ! empty( $matomo_report_meta['page'] ) ) { ?> |
| 94 | <button type="button" class="handlediv" aria-expanded="true" |
| 95 | title="<?php esc_html_e( 'Click to view the report in detail', 'matomo' ); ?>"> |
| 96 | <a |
| 97 | href=" |
| 98 | <?php |
| 99 | |
| 100 | echo esc_url( |
| 101 | Menu::get_matomo_reporting_url( |
| 102 | $matomo_report_meta['page']['category'], |
| 103 | $matomo_report_meta['page']['subcategory'], |
| 104 | [ |
| 105 | 'period' => $report_period_selected, |
| 106 | 'date' => $report_date_selected, |
| 107 | ] |
| 108 | ) |
| 109 | ); |
| 110 | ?> |
| 111 | " style="color: inherit;text-decoration: none;" target="_blank" |
| 112 | rel="noreferrer noopener" |
| 113 | class="dashicons-before dashicons-external" aria-hidden="true"></a> |
| 114 | </button> |
| 115 | <?php } ?> |
| 116 | |
| 117 | <?php $matomo_is_dashboard_widget = $matomo_dashboard->has_widget( $matomo_report_meta['uniqueId'], $report_date ); ?> |
| 118 | <?php // phpcs:ignore Squiz.PHP.EmbeddedPhp.ContentBeforeOpen ?> |
| 119 | <button type="button" class="handlediv" aria-expanded="true" title="<?php |
| 120 | if ( $matomo_is_dashboard_widget ) { |
| 121 | esc_html_e( 'Click to remove this report from the WordPress admin dashboard', 'matomo' ); |
| 122 | } else { |
| 123 | esc_html_e( 'Click to add this report to the WordPress admin dashboard', 'matomo' ); |
| 124 | } |
| 125 | // phpcs:ignore Squiz.PHP.EmbeddedPhp.ContentAfterEnd |
| 126 | ?>"><a |
| 127 | href=" |
| 128 | <?php |
| 129 | echo esc_url( |
| 130 | add_query_arg( |
| 131 | [ |
| 132 | 'pin' => true, |
| 133 | '_wpnonce' => $matomo_dashboard_nonce, |
| 134 | 'report_uniqueid' => $matomo_report_meta['uniqueId'], |
| 135 | 'report_date' => $report_date, |
| 136 | ], |
| 137 | menu_page_url( Menu::SLUG_REPORT_SUMMARY, false ) |
| 138 | ) |
| 139 | ); |
| 140 | ?> |
| 141 | " style="color: inherit;text-decoration: none; |
| 142 | <?php |
| 143 | if ( $matomo_is_dashboard_widget ) { |
| 144 | echo 'opacity: 0.4 !important'; |
| 145 | } |
| 146 | ?> |
| 147 | " |
| 148 | class="dashicons-before dashicons-admin-post" aria-hidden="true"></a> |
| 149 | </button> |
| 150 | |
| 151 | </div> |
| 152 | </div> |
| 153 | <div> |
| 154 | <?php echo do_shortcode( $shortcode ); ?> |
| 155 | </div> |
| 156 | </div> |
| 157 | <?php |
| 158 | } |
| 159 | ?> |
| 160 | </div> |
| 161 | </div> |
| 162 | <?php |
| 163 | } |
| 164 | ?> |
| 165 | </div> |
| 166 | |
| 167 | <p style="clear:both;"> |
| 168 | <?php esc_html_e( 'Did you know? You can embed any report into any page or post using a shortcode. Simply hover the title to find the correct shortcode.', 'matomo' ); ?> |
| 169 | <?php esc_html_e( 'Only users with view access will be able to view the content of the report.', 'matomo' ); ?> |
| 170 | <?php esc_html_e( 'Note: Embedding report data can be tricky if you are using caching plugins that cache the entire HTML of your page or post. In case you are using such a plugin, we recommend you disable the caching for these pages.', 'matomo' ); ?> |
| 171 | </p> |
| 172 | </div> |
| 173 |