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