PluginProbe ʕ •ᴥ•ʔ
Independent Analytics – WordPress Analytics Plugin / 2.11.4
Independent Analytics – WordPress Analytics Plugin v2.11.4
2.15.5 2.15.4 2.15.3 2.15.2 2.15.1 2.15.0 2.14.10 trunk 1.1 1.10 1.10.1 1.11 1.12 1.13 1.14 1.15 1.16 1.17 1.17.1 1.17.2 1.17.3 1.17.4 1.18 1.18.1 1.19.0 1.19.1 1.2 1.20.0 1.21.0 1.22.0 1.22.1 1.23.0 1.23.1 1.24.0 1.24.1 1.25.0 1.25.1 1.26.0 1.27.0 1.28.0 1.28.1 1.28.2 1.28.3 1.29.0 1.3 1.30.0 1.30.1 1.4 1.5 1.6 1.7 1.8 1.9 2.0.0 2.0.1 2.1.4 2.1.5 2.1.6 2.10.0 2.10.1 2.10.2 2.10.3 2.10.4 2.11.0 2.11.1 2.11.10 2.11.2 2.11.3 2.11.4 2.11.5 2.11.6 2.11.7 2.11.8 2.11.9 2.12.0 2.12.1 2.12.2 2.13.1 2.13.2 2.13.5 2.13.6 2.14.0 2.14.1 2.14.2 2.14.4 2.14.6 2.14.7 2.14.8 2.14.9 2.2.0 2.2.1 2.3.1 2.3.2 2.4.2 2.4.3 2.5.0 2.5.1 2.6.0 2.6.1 2.6.2 2.6.3 2.6.4 2.7.0 2.7.1 2.7.2 2.7.3 2.8.2 2.8.3 2.8.4 2.8.5 2.8.6 2.8.7 2.8.8 2.8.9 2.9.2 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7
independent-analytics / IAWP / Admin_Page / Analytics_Page.php
independent-analytics / IAWP / Admin_Page Last commit date
Admin_Page.php 1 year ago Analytics_Page.php 1 year ago Campaign_Builder_Page.php 2 years ago Click_Tracking_Page.php 1 year ago Settings_Page.php 2 years ago Support_Page.php 1 year ago Updates_Page.php 1 year ago
Analytics_Page.php
205 lines
1 <?php
2
3 namespace IAWP\Admin_Page;
4
5 use IAWP\Capability_Manager;
6 use IAWP\Chart;
7 use IAWP\Dashboard_Options;
8 use IAWP\Database;
9 use IAWP\Env;
10 use IAWP\Map;
11 use IAWP\Map_Data;
12 use IAWP\Overview\Overview;
13 use IAWP\Plugin_Conflict_Detector;
14 use IAWP\Quick_Stats;
15 use IAWP\Real_Time;
16 use IAWP\Report;
17 use IAWP\Report_Finder;
18 use IAWP\Tables\Table;
19 use IAWP\Tables\Table_Campaigns;
20 use IAWP\Tables\Table_Clicks;
21 use IAWP\Tables\Table_Devices;
22 use IAWP\Tables\Table_Geo;
23 use IAWP\Tables\Table_Pages;
24 use IAWP\Tables\Table_Referrers;
25 use IAWP\Utils\Security;
26 /** @internal */
27 class Analytics_Page extends \IAWP\Admin_Page\Admin_Page
28 {
29 protected function render_page()
30 {
31 $options = Dashboard_Options::getInstance();
32 $date_rage = $options->get_date_range();
33 $tab = (new Env())->get_tab();
34 $report = Report_Finder::new()->fetch_current_report();
35 $is_showing_skeleton_ui = $report instanceof Report && $report->has_filters();
36 if ($tab === 'views') {
37 $table = new Table_Pages();
38 $statistics_class = $table->group()->statistics_class();
39 $statistics = new $statistics_class($date_rage, null, $options->chart_interval());
40 $stats = new Quick_Stats($statistics, \false, $is_showing_skeleton_ui);
41 $chart = new Chart($statistics, \false, $is_showing_skeleton_ui);
42 $this->interface($table, $stats, $chart);
43 } elseif ($tab === 'referrers') {
44 $table = new Table_Referrers();
45 $statistics_class = $table->group()->statistics_class();
46 $statistics = new $statistics_class($date_rage, null, $options->chart_interval());
47 $stats = new Quick_Stats($statistics, \false, $is_showing_skeleton_ui);
48 $chart = new Chart($statistics, \false, $is_showing_skeleton_ui);
49 $this->interface($table, $stats, $chart);
50 } elseif ($tab === 'geo') {
51 $table = new Table_Geo($options->group());
52 $statistics_class = $table->group()->statistics_class();
53 $statistics = new $statistics_class($date_rage, null, $options->chart_interval());
54 $stats = new Quick_Stats($statistics, \false, $is_showing_skeleton_ui);
55 $table_data_class = $table->group()->rows_class();
56 $geo_data = new $table_data_class($date_rage);
57 $map_data = new Map_Data($geo_data->rows());
58 $chart = new Map($map_data->get_country_data(), null, $is_showing_skeleton_ui);
59 $this->interface($table, $stats, $chart);
60 } elseif ($tab === 'campaigns') {
61 $table = new Table_Campaigns();
62 $statistics_class = $table->group()->statistics_class();
63 $statistics = new $statistics_class($date_rage, null, $options->chart_interval());
64 $stats = new Quick_Stats($statistics, \false, $is_showing_skeleton_ui);
65 $chart = new Chart($statistics, \false, $is_showing_skeleton_ui);
66 $this->interface($table, $stats, $chart);
67 } elseif ($tab === 'clicks') {
68 $table = new Table_Clicks($options->group());
69 $statistics_class = $table->group()->statistics_class();
70 $statistics = new $statistics_class($date_rage, null, $options->chart_interval());
71 $stats = new Quick_Stats($statistics, \false, $is_showing_skeleton_ui);
72 $chart = new Chart($statistics, \false, $is_showing_skeleton_ui);
73 $this->interface($table, $stats, $chart);
74 } elseif ($tab === 'devices') {
75 $table = new Table_Devices($options->group());
76 $statistics_class = $table->group()->statistics_class();
77 $statistics = new $statistics_class($date_rage, null, $options->chart_interval());
78 $stats = new Quick_Stats($statistics, \false, $is_showing_skeleton_ui);
79 $chart = new Chart($statistics, \false, $is_showing_skeleton_ui);
80 $this->interface($table, $stats, $chart);
81 } elseif ($tab === 'real-time') {
82 (new Real_Time())->render_real_time_analytics();
83 } elseif ($tab === 'overview') {
84 echo (new Overview())->get_report_html();
85 $this->notices();
86 }
87 }
88 private function interface(Table $table, $stats, $chart)
89 {
90 $options = Dashboard_Options::getInstance();
91 $sort_configuration = $table->sanitize_sort_parameters($options->sort_column(), $options->sort_direction());
92 ?>
93 <div data-controller="report"
94 data-report-name-value="<?php
95 echo Security::string($options->report_name());
96 ?>"
97 data-report-relative-range-id-value="<?php
98 echo Security::attr($options->relative_range_id());
99 ?>"
100 data-report-exact-start-value="<?php
101 echo Security::attr($options->start());
102 ?>"
103 data-report-exact-end-value="<?php
104 echo Security::attr($options->end());
105 ?>"
106 data-report-group-value="<?php
107 echo Security::attr($options->group());
108 ?>"
109 data-report-filters-value="<?php
110 echo \esc_attr(Security::json_encode($options->filters()));
111 ?>"
112 data-report-chart-interval-value="<?php
113 echo Security::attr($options->chart_interval()->id());
114 ?>"
115 data-report-sort-column-value="<?php
116 echo Security::attr($sort_configuration->column());
117 ?>"
118 data-report-sort-direction-value="<?php
119 echo Security::attr($sort_configuration->direction());
120 ?>"
121 data-report-columns-value="<?php
122 echo \esc_attr(Security::json_encode($table->visible_column_ids()));
123 ?>"
124 data-report-quick-stats-value="<?php
125 echo \esc_attr(Security::json_encode($options->visible_quick_stats()));
126 ?>"
127 data-report-primary-chart-metric-id-value="<?php
128 echo \esc_attr($options->primary_chart_metric_id());
129 ?>"
130 data-report-secondary-chart-metric-id-value="<?php
131 echo \esc_attr($options->secondary_chart_metric_id());
132 ?>"
133 >
134 <div id="report-header-container" class="report-header-container">
135 <?php
136 echo \IAWPSCOPED\iawp_blade()->run('partials.report-header', ['report' => Report_Finder::new()->fetch_current_report(), 'can_edit' => Capability_Manager::can_edit()]);
137 ?>
138 <?php
139 $table->output_report_toolbar();
140 ?>
141 <div class="modal-background"></div>
142 </div>
143 <?php
144 echo $stats->get_html();
145 ?>
146 <?php
147 echo $chart->get_html();
148 ?>
149 <?php
150 echo $table->get_table_toolbar_markup();
151 ?>
152 <?php
153 echo $table->get_table_markup($sort_configuration->column(), $sort_configuration->direction());
154 ?>
155 </div>
156 <?php
157 if (Env::get_tab() === 'geo') {
158 echo '<div class="geo-ip-attribution">';
159 echo \esc_html_x('Geolocation data powered by', 'Following text is a noun: DB-IP', 'independent-analytics') . ' ' . '<a href="https://db-ip.com" target="_blank">DB-IP</a>.';
160 echo '</div>';
161 }
162 $this->notices();
163 }
164 private function notices()
165 {
166 $plugin_conflict_detector = new Plugin_Conflict_Detector();
167 $requires_logged_in_tracking = $plugin_conflict_detector->plugin_requiring_logged_in_tracking();
168 $show_logged_in_tracking_notice = $requires_logged_in_tracking && !\get_option('iawp_track_authenticated_users') && !\get_option('iawp_need_clear_cache') && !\get_option('iawp_logged_in_tracking_notice');
169 ?><div class="iawp-notices"><?php
170 if (Capability_Manager::can_edit()) {
171 if ($plugin_conflict_detector->has_conflict()) {
172 echo \IAWPSCOPED\iawp_blade()->run('notices.notice', ['notice_text' => $plugin_conflict_detector->get_error(), 'button_text' => \false, 'id' => 'plugin-conflict', 'notice' => 'iawp-error', 'plugin' => $plugin_conflict_detector->get_plugin(), 'url' => 'https://independentwp.com/knowledgebase/tracking/secure-rest-api/']);
173 } elseif (\IAWPSCOPED\iawp_is_pro() && \is_plugin_active('better-wp-security/better-wp-security.php')) {
174 $settings = \get_option('itsec-storage');
175 if (\array_key_exists('system-tweaks', $settings)) {
176 if (\array_key_exists('plugins_php', $settings['system-tweaks'])) {
177 if ($settings['system-tweaks']['plugins_php']) {
178 echo \IAWPSCOPED\iawp_blade()->run('notices.notice', ['notice_text' => \__('The "Solid Security" plugin is disabling PHP execution in the plugins folder, and this is preventing click tracking from working. Please visit the Security > Settings page, click on the Advanced section, click on System Tweaks Settings, uncheck the "Disable PHP Plugins" option, and then save.', 'independent-analytics'), 'button_text' => \false, 'id' => 'plugin-conflict', 'notice' => 'iawp-error', 'url' => 'https://independentwp.com/knowledgebase/click-tracking/allow-php-execution-plugins-folder/']);
179 }
180 }
181 }
182 }
183 if (\get_option('iawp_need_clear_cache')) {
184 echo \IAWPSCOPED\iawp_blade()->run('notices.notice', ['notice_text' => \__('Please clear your cache to ensure tracking works properly.', 'independent-analytics'), 'button_text' => \__('I\'ve cleared the cache', 'independent-analytics'), 'id' => 'iawp_need_clear_cache', 'notice' => 'iawp-warning', 'url' => 'https://independentwp.com/knowledgebase/common-questions/views-not-recording/']);
185 }
186 if ($show_logged_in_tracking_notice) {
187 echo \IAWPSCOPED\iawp_blade()->run('notices.notice', ['notice_text' => '<strong>' . \sprintf(\_x('%s compatibility:', 'Variable is the name of a plugin', 'independent-analytics'), $requires_logged_in_tracking) . '</strong> ' . \__('We recommend you enable tracking for logged-in visitors.', 'independent-analytics'), 'button_text' => \__('Dismiss', 'independent-analytics'), 'id' => 'enable-logged-in-tracking', 'notice' => 'iawp-warning', 'url' => 'https://independentwp.com/knowledgebase/tracking/how-to-track-logged-in-visitors/']);
188 }
189 if (\IAWPSCOPED\iawp_db_version() > 0 && !Database::has_correct_database_privileges()) {
190 echo \IAWPSCOPED\iawp_blade()->run('notices.notice', ['notice_text' => \__('Your site is missing the following critical database permissions:', 'independent-analytics') . ' ' . \implode(', ', Database::missing_database_privileges()) . '. ' . \__('There is no issue at this time, but you will need to enable the missing permissions before updating the plugin to a newer version to ensure an error is avoided. Please click this link to read our tutorial:', 'independent-analytics'), 'button_text' => \false, 'id' => 'missing-permissions', 'notice' => 'iawp-error', 'url' => 'https://independentwp.com/knowledgebase/common-questions/missing-database-permissions/']);
191 }
192 if (Env::get_tab() === 'clicks') {
193 if (!\get_option('iawp_clicks_sync_notice')) {
194 echo \IAWPSCOPED\iawp_blade()->run('notices.notice', ['notice_text' => \__('Click data syncs every 60 seconds. Please allow for this delay when testing clicks on new links.', 'independent-analytics'), 'button_text' => \__('Dismiss', 'independent-analytics'), 'id' => 'iawp_clicks_sync_notice', 'notice' => 'iawp-warning', 'url' => 'https://independentwp.com/knowledgebase/click-tracking/click-tracking-update-process/']);
195 }
196 }
197 }
198 ?>
199 </div><?php
200 if (\get_option('iawp_show_gsg') === '1' && !\get_option('iawp_need_clear_cache') && !$show_logged_in_tracking_notice && !$plugin_conflict_detector->has_conflict() && (Env::get_tab() !== 'clicks' || Env::get_tab() === 'clicks' && \get_option('iawp_clicks_sync_notice'))) {
201 echo \IAWPSCOPED\iawp_blade()->run('notices.getting-started');
202 }
203 }
204 }
205