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