PluginProbe ʕ •ᴥ•ʔ
Independent Analytics – WordPress Analytics Plugin / 1.23.1
Independent Analytics – WordPress Analytics Plugin v1.23.1
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 / Independent_Analytics.php
independent-analytics / IAWP Last commit date
AJAX 3 years ago Date_Range 3 years ago Interval 3 years ago Migrations 3 years ago Models 3 years ago Queries 3 years ago Statistics 3 years ago Tables 3 years ago Utils 3 years ago Campaign_Builder.php 3 years ago Capability_Manager.php 3 years ago Chart.php 3 years ago Chart_Geo.php 3 years ago Chart_SVG.php 3 years ago Current_Resource.php 3 years ago Dashboard_Options.php 3 years ago Dashboard_Widget.php 3 years ago Email_Reports.php 3 years ago Filters.php 3 years ago Geo_Database.php 3 years ago Geo_Database_Download_Job.php 3 years ago Health_Check.php 3 years ago Illuminate_Builder.php 3 years ago Independent_Analytics.php 3 years ago Known_Referrers.php 3 years ago PDF.php 3 years ago Query.php 3 years ago Quick_Stats.php 3 years ago REST_API.php 3 years ago Real_Time.php 3 years ago Reset_Database.php 3 years ago Settings.php 3 years ago Track_Resource_Changes.php 3 years ago View.php 3 years ago View_Counter.php 3 years ago WP_Option_Cache_Bust.php 3 years ago WooCommerce_Order.php 3 years ago
Independent_Analytics.php
584 lines
1 <?php
2
3 namespace IAWP_SCOPED\IAWP;
4
5 use IAWP_SCOPED\IAWP\AJAX\Cleared_Cache_AJAX;
6 use IAWP_SCOPED\IAWP\AJAX\Create_Campaign_AJAX;
7 use IAWP_SCOPED\IAWP\AJAX\Delete_Data_AJAX;
8 use IAWP_SCOPED\IAWP\AJAX\Export_Campaigns_AJAX;
9 use IAWP_SCOPED\IAWP\AJAX\Export_Geo_AJAX;
10 use IAWP_SCOPED\IAWP\AJAX\Export_Referrers_AJAX;
11 use IAWP_SCOPED\IAWP\AJAX\Export_Views_AJAX;
12 use IAWP_SCOPED\IAWP\AJAX\Filters_AJAX;
13 use IAWP_SCOPED\IAWP\AJAX\Migration_Status_AJAX;
14 use IAWP_SCOPED\IAWP\AJAX\Real_Time_AJAX;
15 use IAWP_SCOPED\IAWP\AJAX\Test_Email_AJAX;
16 use IAWP_SCOPED\IAWP\AJAX\Update_Capabilities_AJAX;
17 use IAWP_SCOPED\IAWP\Queries\Country_Statistics;
18 use IAWP_SCOPED\IAWP\Statistics\Campaign_Statistics;
19 use IAWP_SCOPED\IAWP\Statistics\Geo_Statistics;
20 use IAWP_SCOPED\IAWP\Statistics\Page_Statistics;
21 use IAWP_SCOPED\IAWP\Statistics\Referrer_Statistics;
22 use IAWP_SCOPED\IAWP\Tables\Table_Campaigns;
23 use IAWP_SCOPED\IAWP\Tables\Table_Geo;
24 use IAWP_SCOPED\IAWP\Tables\Table_Referrers;
25 use IAWP_SCOPED\IAWP\Tables\Table_Pages;
26 use IAWP_SCOPED\IAWP\Utils\Security;
27 use IAWP_SCOPED\IAWP\Utils\Singleton;
28 class Independent_Analytics
29 {
30 use Singleton;
31 public $settings;
32 public $email_reports;
33 // This is where we attach functions to WP hooks
34 private function __construct()
35 {
36 $this->settings = new Settings();
37 new REST_API();
38 new Dashboard_Widget();
39 new View_Counter();
40 new Delete_Data_AJAX();
41 new Filters_AJAX();
42 new Export_Geo_AJAX();
43 new Export_Referrers_AJAX();
44 new Export_Views_AJAX();
45 new Migration_Status_AJAX();
46 new Update_Capabilities_AJAX();
47 new Cleared_Cache_AJAX();
48 new Track_Resource_Changes();
49 WooCommerce_Order::initialize_order_tracker();
50 if (\IAWP_SCOPED\iawp_is_pro()) {
51 $this->email_reports = new Email_Reports();
52 new Export_Campaigns_AJAX();
53 new Create_Campaign_AJAX();
54 new Campaign_Builder();
55 new Real_Time_AJAX();
56 new Test_Email_AJAX();
57 }
58 \add_filter('admin_body_class', function ($classes) {
59 if (\get_option('iawp_dark_mode')) {
60 $classes .= ' iawp-dark-mode ';
61 }
62 return $classes;
63 });
64 \add_action('admin_menu', [$this, 'add_settings_page']);
65 \add_action('admin_enqueue_scripts', [$this, 'enqueue_scripts']);
66 \add_filter('plugin_action_links_independent-analytics/iawp.php', [$this, 'plugin_action_links']);
67 \add_filter('admin_footer_text', [$this, 'ip_db_attribution'], 1, 1);
68 \add_filter('admin_head', [$this, 'style_premium_menu_item']);
69 \add_action('init', [$this, 'load_textdomain']);
70 \add_action('init', [$this, 'polylang_translations']);
71 IAWP_FS()->add_filter('connect_message_on_update', [$this, 'filter_connect_message_on_update'], 10, 6);
72 IAWP_FS()->add_filter('connect_message', [$this, 'filter_connect_message_on_update'], 10, 6);
73 IAWP_FS()->add_filter('is_submenu_visible', [$this, 'hide_freemius_sub_menus'], 10, 2);
74 IAWP_FS()->add_filter('pricing_url', [$this, 'change_freemius_pricing_url'], 10);
75 }
76 // Text domain is used for i18n
77 public function load_textdomain()
78 {
79 \load_plugin_textdomain('iawp', \false, \IAWP_LANGUAGES_DIRECTORY);
80 }
81 public function polylang_translations()
82 {
83 if (\function_exists('IAWP_SCOPED\\pll_register_string')) {
84 pll_register_string('view_counter', 'Views:', 'Independent Analytics');
85 }
86 }
87 // Settings page where the analytics will appear
88 public function add_settings_page()
89 {
90 \add_menu_page('Independent Analytics', \esc_html__('Analytics', 'iawp'), Capability_Manager::can_view_string(), 'independent-analytics', [$this, 'settings_page_markup'], 'dashicons-analytics', 3);
91 if (!Capability_Manager::white_labeled()) {
92 \add_submenu_page('independent-analytics', \esc_html__('Feedback', 'iawp'), \esc_html__('Feedback', 'iawp'), Capability_Manager::can_view_string(), \esc_url('https://feedback.independentwp.com/boards/feature-requests'));
93 }
94 if (\IAWP_SCOPED\iawp_is_free() && !Capability_Manager::white_labeled()) {
95 \add_submenu_page('independent-analytics', \esc_html__('Upgrade to Pro &rarr;', 'iawp'), \esc_html__('Upgrade to Pro &rarr;', 'iawp'), Capability_Manager::can_view_string(), \esc_url('https://independentwp.com/pricing/?utm_source=User+Dashboard&utm_medium=WP+Admin&utm_campaign=Upgrade+to+Pro&utm_content=Sidebar'));
96 }
97 }
98 public function hide_freemius_sub_menus($is_visible, $menu_id)
99 {
100 if ('pricing' == $menu_id) {
101 return \false;
102 } elseif ('support' == $menu_id && Capability_Manager::white_labeled()) {
103 return \false;
104 } else {
105 return \true;
106 }
107 }
108 public function change_freemius_pricing_url()
109 {
110 return 'https://independentwp.com/pricing/?utm_source=User+Dashboard&utm_medium=WP+Admin&utm_campaign=Upgrade+to+Pro&utm_content=Account';
111 }
112 // The submenu item needs to be styled on all admin pages, and we only load stylesheets on our page
113 public function style_premium_menu_item()
114 {
115 if (\IAWP_SCOPED\iawp_is_free()) {
116 echo '<style>#toplevel_page_independent-analytics .wp-submenu li:nth-child(4) a { color: #F69D0A; }</style>';
117 }
118 }
119 private function get_current_tab()
120 {
121 if (\IAWP_SCOPED\iawp_is_pro()) {
122 $valid_tabs = ['views', 'referrers', 'geo', 'campaigns', 'campaign-builder', 'real-time', 'settings', 'learn'];
123 } else {
124 $valid_tabs = ['views', 'referrers', 'geo', 'settings', 'learn'];
125 }
126 $default_tab = $valid_tabs[0];
127 $tab = \array_key_exists('tab', $_GET) ? \sanitize_text_field($_GET['tab']) : \false;
128 $is_valid = \array_search($tab, $valid_tabs) != \false;
129 if (!$tab || !$is_valid) {
130 $tab = $default_tab;
131 }
132 return $tab;
133 }
134 public function settings_page_markup()
135 {
136 if (!Capability_Manager::can_view()) {
137 return;
138 }
139 // ray(Migrations\Migration::has_newer_database_version());
140 if (Migrations\Migration::has_newer_database_version()) {
141 ?>
142 <div id="iawp-parent" class="iawp-parent">
143 <?php
144 echo \IAWP_SCOPED\iawp()->templates()->render('layout/header', ['show_review' => \false]);
145 ?>
146 <?php
147 echo \IAWP_SCOPED\iawp()->templates()->render('newer_database');
148 ?>
149 </div>
150 <?php
151 return;
152 } elseif (Migrations\Migration::is_migrating()) {
153 ?>
154 <div id="iawp-parent" class="iawp-parent">
155 <?php
156 echo \IAWP_SCOPED\iawp()->templates()->render('layout/header', ['show_review' => \false]);
157 ?>
158 <?php
159 echo \IAWP_SCOPED\iawp()->templates()->render('migration_running');
160 ?>
161 </div>
162 <?php
163 return;
164 }
165 $tab = $this->get_current_tab();
166 ?>
167 <div id="iawp-parent" class="iawp-parent">
168 <?php
169 if (!Capability_Manager::white_labeled()) {
170 echo \IAWP_SCOPED\iawp()->templates()->render('layout/header');
171 }
172 ?>
173 <nav class="nav">
174 <ul class="menu">
175 <li class="menu-item">
176 <a href="?page=independent-analytics"
177 data-controller="track-date-range"
178 data-test-menu="views"
179 class="menu-link link-dark <?php
180 if ($tab === 'views') {
181 ?>active<?php
182 }
183 ?>">
184 <?php
185 \esc_html_e('Pages', 'iawp');
186 ?>
187 </a>
188 </li>
189 <li class="menu-item">
190 <a href="?page=independent-analytics&tab=referrers"
191 data-controller="track-date-range"
192 data-test-menu="referrers"
193 class="menu-link link-dark <?php
194 if ($tab === 'referrers') {
195 ?>active<?php
196 }
197 ?>">
198 <?php
199 \esc_html_e('Referrers', 'iawp');
200 ?>
201 </a>
202 </li>
203 <li class="menu-item">
204 <a href="?page=independent-analytics&tab=geo"
205 data-controller="track-date-range"
206 data-test-menu="geo"
207 class="menu-link link-dark <?php
208 if ($tab === 'geo') {
209 ?>active<?php
210 }
211 ?>">
212 <?php
213 \esc_html_e('Geographic', 'iawp');
214 ?>
215 </a>
216 </li>
217 <?php
218 if (\IAWP_SCOPED\iawp_is_pro()) {
219 ?>
220 <li class="menu-item">
221 <a href="?page=independent-analytics&tab=campaigns"
222 data-controller="track-date-range"
223 data-test-menu="campaigns"
224 class="menu-link link-dark <?php
225 if ($tab === 'campaigns' || $tab === 'campaign-builder') {
226 ?>active<?php
227 }
228 ?>">
229 <?php
230 \esc_html_e('Campaigns', 'iawp');
231 ?>
232 </a>
233 <div class="sub-menu">
234 <ul>
235 <li class="menu-item">
236 <a href="?page=independent-analytics&tab=campaign-builder"
237 class="menu-link link-dark">
238 <?php
239 \esc_html_e('Campaign Builder', 'iawp');
240 ?>
241 </a>
242 </li>
243 </ul>
244 </div>
245 </li>
246 <li class="menu-item">
247 <a href="?page=independent-analytics&tab=real-time"
248 data-test-menu="real-time"
249 class="menu-link link-dark <?php
250 if ($tab === 'real-time') {
251 ?>active<?php
252 }
253 ?>">
254 <?php
255 \esc_html_e('Real-time', 'iawp');
256 ?>
257 </a>
258 </li>
259 <?php
260 }
261 ?>
262 <?php
263 if (Capability_Manager::can_edit()) {
264 ?>
265 <li class="menu-item">
266 <a href="?page=independent-analytics&tab=settings"
267 data-test-menu="settings"
268 class="menu-link link-dark <?php
269 if ($tab === 'settings') {
270 ?>active<?php
271 }
272 ?>">
273 <?php
274 \esc_html_e('Settings', 'iawp');
275 ?>
276 </a>
277 </li>
278 <?php
279 }
280 ?>
281 <?php
282 if (!Capability_Manager::white_labeled()) {
283 ?>
284 <li class="menu-item">
285 <a href="?page=independent-analytics&tab=learn"
286 data-test-menu="learn"
287 class="menu-link link-dark <?php
288 if ($tab === 'learn') {
289 ?>active<?php
290 }
291 ?>">
292 <?php
293 \esc_html_e('Learn', 'iawp');
294 ?>
295 </a>
296 </li>
297 <?php
298 }
299 ?>
300 <?php
301 if (!Capability_Manager::white_labeled() && \IAWP_SCOPED\iawp_is_free()) {
302 ?>
303 <li class="menu-item upgrade first" data-controller="modal">
304 <a href="#"
305 data-test-menu="campaigns"
306 data-action="modal#toggleModal"
307 data-modal-target="modalButton"
308 class="menu-link link-dark">
309 <?php
310 \esc_html_e('Campaigns', 'iawp');
311 ?>
312 </a>
313 <div class="upgrade-popup"
314 data-modal-target="modal"
315 >
316 <div class="title">
317 <span class="name"><?php
318 \esc_html_e('Campaigns', 'iawp');
319 ?></span>
320 <span class="iawp-label"><?php
321 \esc_html_e('PRO', 'iawp');
322 ?></span>
323 </div>
324 <div class="description">
325 <p><?php
326 \esc_html_e("Campaigns let you track visits from individual links you share online, whether that's a Tweet, ad, or guest post.", 'iawp');
327 ?></p>
328 <a class="iawp-button purple" target="_blank"
329 href="https://independentwp.com/features/campaigns/?utm_source=User+Dashboard&utm_medium=WP+Admin&utm_campaign=Campaigns+menu+item&utm_content=Menu+item"><?php
330 \esc_html_e('Upgrade', 'iawp');
331 ?></a>
332 </div>
333 </div>
334 </li>
335 <li class="menu-item upgrade" data-controller="modal">
336 <a href="#"
337 data-test-menu="real-time"
338 data-action="modal#toggleModal"
339 data-modal-target="modalButton"
340 class="menu-link link-dark">
341 <?php
342 \esc_html_e('Real-time', 'iawp');
343 ?>
344 </a>
345 <div class="upgrade-popup"
346 data-modal-target="modal"
347 >
348 <div class="title">
349 <span class="name"><?php
350 \esc_html_e('Real-time analytics', 'iawp');
351 ?></span>
352 <span class="iawp-label"><?php
353 \esc_html_e('PRO', 'iawp');
354 ?></span>
355 </div>
356 <div class="description">
357 <p><?php
358 \esc_html_e("Real-time analytics let you see how many people are on your site right now, what pages they're viewing, and where they came from.", 'iawp');
359 ?></p>
360 <a class="iawp-button purple" target="_blank"
361 href="https://independentwp.com/features/real-time/?utm_source=User+Dashboard&utm_medium=WP+Admin&utm_campaign=Real-time+menu+item&utm_content=Menu+item"><?php
362 \esc_html_e('Upgrade', 'iawp');
363 ?></a>
364 </div>
365 </div>
366 </li>
367 <?php
368 }
369 ?>
370 </ul>
371 </nav>
372 <div class="iawp-tab-content"><?php
373 $options = new Dashboard_Options();
374 $date_rage = $options->get_date_range();
375 $date_label = $date_rage->label();
376 $columns = $options->columns();
377 if ($tab == 'views') {
378 $table = new Table_Pages($columns);
379 $statistics = new Page_Statistics($date_rage);
380 $stats = new Quick_Stats($statistics, null);
381 $chart = new Chart($statistics, $date_label);
382 $this->interface($table, $stats, $chart);
383 } elseif ($tab == 'referrers') {
384 $table = new Table_Referrers($columns);
385 $statistics = new Referrer_Statistics($date_rage);
386 $stats = new Quick_Stats($statistics, null);
387 $chart = new Chart($statistics, $date_label);
388 $this->interface($table, $stats, $chart);
389 } elseif ($tab == 'geo') {
390 $table = new Table_Geo($columns);
391 $statistics = new Geo_Statistics($date_rage);
392 $stats = new Quick_Stats($statistics, null);
393 $country_statistics = new Country_Statistics($date_rage);
394 $chart = new Chart_Geo($country_statistics->fetch(), $date_label);
395 $this->interface($table, $stats, $chart);
396 } elseif ($tab === 'campaigns') {
397 $table = new Table_Campaigns($columns);
398 $statistics = new Campaign_Statistics($date_rage);
399 $stats = new Quick_Stats($statistics, null);
400 $chart = new Chart($statistics, $date_label);
401 $this->interface($table, $stats, $chart);
402 } elseif ($tab == 'campaign-builder') {
403 (new Campaign_Builder())->render_campaign_builder();
404 } elseif ($tab === 'real-time') {
405 (new Real_Time())->render_real_time_analytics();
406 } elseif ($tab == 'settings') {
407 echo '<div id="iawp-dashboard" class="iawp-dashboard">';
408 if (Capability_Manager::can_edit()) {
409 $this->settings->render_settings();
410 } else {
411 echo '<p class="permission-blocked">' . \esc_html__('You do not have permission to edit the settings.', 'iawp') . '</p>';
412 }
413 echo '</div>';
414 } elseif ($tab == 'learn') {
415 echo '<div id="iawp-dashboard" class="iawp-dashboard">';
416 echo \IAWP_SCOPED\iawp()->templates()->render('learn/index');
417 echo '</div>';
418 }
419 ?>
420 </div>
421 <div id="loading-icon" class="loading-icon"><img
422 src="<?php
423 echo \esc_url(\IAWP_SCOPED\iawp_url_to('img/loading.svg'));
424 ?>"/>
425 </div>
426 <button id="scroll-to-top" class="scroll-to-top"><span
427 class="dashicons dashicons-arrow-up-alt"></span>
428 </button>
429 </div>
430 <?php
431 }
432 public function interface($table, $stats, $chart)
433 {
434 $opts = new Dashboard_Options();
435 ?>
436 <div id="iawp-dashboard"
437 class="iawp-dashboard"
438 data-controller="report"
439 data-report-relative-range-id-value="<?php
440 echo Security::attr($opts->relative_range_id());
441 ?>"
442 data-report-exact-start-value="<?php
443 echo Security::attr($opts->start());
444 ?>"
445 data-report-exact-end-value="<?php
446 echo Security::attr($opts->end());
447 ?>"
448 data-report-columns-value="<?php
449 \esc_attr_e(Security::json_encode($table->visible_column_ids()));
450 ?>"
451 >
452 <?php
453 $table->output_toolbar();
454 ?>
455 <?php
456 echo $stats->get_html();
457 ?>
458 <?php
459 echo $chart->get_html();
460 ?>
461 <?php
462 echo $table->get_table_markup();
463 ?>
464 </div>
465 <div class="iawp-notices"><?php
466 $health_check = new Health_Check();
467 if (!$health_check->healthy()) {
468 echo \IAWP_SCOPED\iawp()->templates()->render('settings/notice', ['notice_text' => $health_check->error(), 'button_text' => \false, 'notice' => 'iawp-error', 'url' => 'https://independentwp.com/knowledgebase/common-questions/views-not-recording/']);
469 }
470 if (\get_option('iawp_need_clear_cache')) {
471 echo \IAWP_SCOPED\iawp()->templates()->render('settings/notice', ['notice_text' => \__('Please clear your cache to ensure tracking works properly.', 'iawp'), 'button_text' => \__('I\'ve cleared the cache', 'iawp'), 'notice' => 'iawp-warning', 'url' => 'https://independentwp.com/knowledgebase/common-questions/views-not-recording/']);
472 }
473 ?>
474 </div><?php
475 }
476 public function enqueue_scripts($hook)
477 {
478 if ($hook == 'toplevel_page_independent-analytics') {
479 $tab = $this->get_current_tab();
480 \wp_register_style('iawp-style', \IAWP_SCOPED\iawp_url_to('dist/styles/style.css'), [], \IAWP_VERSION);
481 \wp_enqueue_style('iawp-style');
482 \wp_register_script('iawp-js', \IAWP_SCOPED\iawp_url_to('dist/js/index.js'), [], \IAWP_VERSION);
483 \wp_enqueue_script('iawp-js');
484 \wp_add_inline_script('iawp-js', 'const IAWP_DELETE_DATA_NONCE = ' . \json_encode(\wp_create_nonce('iawp_delete_data')), 'before');
485 if ($tab === 'views' || $tab === 'referrers' || $tab === 'geo' || $tab === 'campaigns' || $tab === 'campaign-builder') {
486 \wp_register_script('iawp-data-table', \IAWP_SCOPED\iawp_url_to('dist/js/data-table.js'), [], \IAWP_VERSION);
487 \wp_enqueue_script('iawp-data-table');
488 \wp_add_inline_script('iawp-data-table', 'const IAWP_AJAX = ' . \json_encode(['filter_nonce' => \wp_create_nonce('iawp_filter'), 'create_campaign_nonce' => \wp_create_nonce('iawp_create_campaign'), 'copied_text' => \esc_html__('Copied!', 'iawp'), 'iawp_need_clear_cache_nonce' => \wp_create_nonce('iawp_need_clear_cache')]), 'before');
489 } elseif ($tab == 'settings') {
490 \wp_register_script('iawp-settings', \IAWP_SCOPED\iawp_url_to('dist/js/settings.js'), [], \IAWP_VERSION);
491 \wp_enqueue_script('iawp-settings');
492 \wp_add_inline_script('iawp-settings', 'const IAWP_AJAX = ' . \json_encode(['export_views_nonce' => \wp_create_nonce('iawp_export_views'), 'export_referrers_nonce' => \wp_create_nonce('iawp_export_referrers'), 'export_geo_nonce' => \wp_create_nonce('iawp_export_geo'), 'export_campaigns_nonce' => \wp_create_nonce('iawp_export_campaigns'), 'iawp_capabilities_nonce' => \wp_create_nonce('iawp_capabilities'), 'iawp_test_email_nonce' => \wp_create_nonce('iawp_test_email'), 'exporting_views_text' => \esc_html__('Exporting Pages...', 'iawp'), 'export_views_text' => \esc_html__('Export Pages', 'iawp'), 'exporting_referrers_text' => \esc_html__('Exporting Referrers...', 'iawp'), 'export_referrers_text' => \esc_html__('Export Referrers', 'iawp'), 'exporting_geo_text' => \esc_html__('Exporting Geolocations...', 'iawp'), 'export_geo_text' => \esc_html__('Export Geolocations', 'iawp'), 'exporting_campaigns_text' => \esc_html__('Exporting Campaigns...', 'iawp'), 'export_campaigns_text' => \esc_html__('Export Campaigns', 'iawp')]), 'before');
493 } elseif ($tab == 'learn') {
494 \wp_register_script('iawp-learn', \IAWP_SCOPED\iawp_url_to('dist/js/learn.js'), [], \IAWP_VERSION);
495 \wp_enqueue_script('iawp-learn');
496 }
497 } elseif ($hook == 'index.php') {
498 \wp_register_script('iawp-dashboard-widget', \IAWP_SCOPED\iawp_url_to('dist/js/dashboard_widget.js'), [], \IAWP_VERSION);
499 \wp_enqueue_script('iawp-dashboard-widget');
500 \wp_register_style('iawp-dashboard-widget-css', \IAWP_SCOPED\iawp_url_to('dist/styles/dashboard_widget.css'), [], \IAWP_VERSION);
501 \wp_enqueue_style('iawp-dashboard-widget-css');
502 }
503 }
504 /* WP uses $default when get_option() is empty, but it also saves empty fields
505 ** as empty strings, meaning the return value can be "" instead of the default. This is
506 ** a defensive function that guarantees we get the proper default when the setting is empty. */
507 public function get_option($name, $default)
508 {
509 $option = \get_option($name, $default);
510 return $option === '' ? $default : $option;
511 }
512 public function templates()
513 {
514 return new \IAWP_SCOPED\League\Plates\Engine(\IAWP_SCOPED\iawp_path_to('templates'));
515 }
516 public function get_users_can_write()
517 {
518 $roles = [];
519 foreach (\wp_roles()->roles as $role_name => $role_obj) {
520 if (!empty($role_obj['capabilities']['edit_posts'])) {
521 $roles[] = $role_name;
522 }
523 }
524 $users = \get_users(['role__in' => $roles]);
525 return $users;
526 }
527 public function get_custom_types(bool $tax = \false)
528 {
529 $args = ['public' => \true, '_builtin' => \false];
530 if ($tax) {
531 return \get_taxonomies($args);
532 } else {
533 return \get_post_types($args);
534 }
535 }
536 public function filter_connect_message_on_update($message, $user_first_name, $product_title, $user_login, $site_link, $freemius_link)
537 {
538 // Add the heading HTML.
539 $plugin_name = 'Independent Analytics';
540 $title = '<h3>' . \sprintf(\esc_html__('We hope you love %1$s', 'iawp'), $plugin_name) . '</h3>';
541 $html = '';
542 // Add the introduction HTML.
543 $html .= '<p>';
544 $html .= \sprintf(\esc_html__('Hi, %1$s! This is an invitation to help the %2$s community. ', 'iawp'), $user_first_name, $plugin_name);
545 $html .= '<strong>';
546 $html .= \sprintf(\esc_html__('If you opt-in, some data about your usage of %2$s will be shared with us', 'iawp'), $user_first_name, $plugin_name);
547 $html .= '</strong>';
548 $html .= \sprintf(\esc_html__(' so we can improve %2$s. We will also share some helpful info on using the plugin so you can get the most out of your sites analytics.', 'iawp'), $user_first_name, $plugin_name);
549 $html .= '</p>';
550 $html .= '<p>';
551 $html .= \sprintf(\esc_html__('And if you skip this, that\'s okay! %1$s will still work just fine.', 'iawp'), $plugin_name);
552 $html .= '</p>';
553 return $title . $html;
554 }
555 public function plugin_action_links($links)
556 {
557 // Build the URL
558 $url = \add_query_arg('page', 'independent-analytics', \admin_url('admin.php'));
559 // Create the link
560 $settings_link = '<a class="calendar-link" href="' . \esc_url($url) . '">' . \esc_html__('Analytics Dashboard', 'iawp') . '</a>';
561 // Add the link to the start of the array
562 \array_unshift($links, $settings_link);
563 return $links;
564 }
565 public function set_time_limit($limit = 0)
566 {
567 if (!\function_exists('set_time_limit') && \false !== \strpos(\ini_get('disable_functions'), 'set_time_limit') && \ini_get('safe_mode')) {
568 return \false;
569 }
570 return @\set_time_limit($limit);
571 }
572 public function ip_db_attribution($text)
573 {
574 if ($this->get_current_tab() === 'geo') {
575 $text = $text . ' ' . \esc_html_x('Geolocation data powered by', 'Following text is a noun: DB-IP', 'iawp') . ' ' . '<a href="https://db-ip.com" class="geo-message" target="_blank">DB-IP</a>.';
576 }
577 return $text;
578 }
579 public function pagination_page_size()
580 {
581 return 50;
582 }
583 }
584