PluginProbe ʕ •ᴥ•ʔ
Independent Analytics – WordPress Analytics Plugin / 2.1.4
Independent Analytics – WordPress Analytics Plugin v2.1.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 / Independent_Analytics.php
independent-analytics / IAWP Last commit date
AJAX 2 years ago Date_Range 2 years ago Interval 3 years ago Menu_Bar_Stats 2 years ago Migrations 2 years ago Models 2 years ago Public_API 2 years ago Rows 2 years ago Statistics 2 years ago Tables 2 years ago Utils 2 years ago Campaign_Builder.php 2 years ago Capability_Manager.php 3 years ago Chart.php 2 years ago Chart_Geo.php 2 years ago Cron_Manager.php 2 years ago Current_Traffic_Finder.php 2 years ago Dashboard_Options.php 2 years ago Dashboard_Widget.php 2 years ago Database_Manager.php 2 years ago Email_Chart.php 2 years ago Email_Reports.php 2 years ago Empty_Report_Option.php 2 years ago Env.php 2 years ago Filters.php 3 years ago Geo_Database_Background_Job.php 2 years ago Geo_Database_Manager.php 2 years ago Geoposition.php 2 years ago Icon_Directory.php 2 years ago Icon_Directory_Factory.php 2 years ago Illuminate_Builder.php 2 years ago Independent_Analytics.php 2 years ago Interrupt.php 2 years ago Known_Referrers.php 2 years ago Plugin_Conflict_Detector.php 2 years ago Query.php 2 years ago Quick_Stats.php 2 years ago REST_API.php 2 years ago Real_Time.php 2 years ago Report.php 2 years ago Report_Finder.php 2 years ago Report_Options_Parser.php 2 years ago Resource_Identifier.php 3 years ago Settings.php 2 years ago Sort_Configuration.php 2 years ago Track_Resource_Changes.php 2 years ago View.php 2 years ago View_Counter.php 2 years ago Visitors_Over_Time_Finder.php 2 years ago WP_Option_Cache_Bust.php 2 years ago WooCommerce_Order.php 2 years ago WooCommerce_Referrer_Meta_Box.php 2 years ago
Independent_Analytics.php
436 lines
1 <?php
2
3 namespace IAWP_SCOPED\IAWP;
4
5 use IAWP_SCOPED\IAWP\AJAX\AJAX_Manager;
6 use IAWP_SCOPED\IAWP\Menu_Bar_Stats\Menu_Bar_Stats;
7 use IAWP_SCOPED\IAWP\Migrations\Migrations;
8 use IAWP_SCOPED\IAWP\Tables\Table;
9 use IAWP_SCOPED\IAWP\Tables\Table_Campaigns;
10 use IAWP_SCOPED\IAWP\Tables\Table_Devices;
11 use IAWP_SCOPED\IAWP\Tables\Table_Geo;
12 use IAWP_SCOPED\IAWP\Tables\Table_Pages;
13 use IAWP_SCOPED\IAWP\Tables\Table_Referrers;
14 use IAWP_SCOPED\IAWP\Utils\Security;
15 use IAWP_SCOPED\IAWP\Utils\Singleton;
16 class Independent_Analytics
17 {
18 use Singleton;
19 public $settings;
20 public $email_reports;
21 public $cron_manager;
22 // This is where we attach functions to WP hooks
23 private function __construct()
24 {
25 $this->settings = new Settings();
26 new REST_API();
27 new Dashboard_Widget();
28 new View_Counter();
29 AJAX_Manager::getInstance();
30 if (!Migrations::is_migrating()) {
31 new Track_Resource_Changes();
32 Menu_Bar_Stats::register();
33 WooCommerce_Order::initialize_order_tracker();
34 }
35 $this->cron_manager = new Cron_Manager();
36 if (\IAWP_SCOPED\iawp_is_pro()) {
37 $this->email_reports = new Email_Reports();
38 new Campaign_Builder();
39 new WooCommerce_Referrer_Meta_Box();
40 }
41 \add_filter('admin_body_class', function ($classes) {
42 if (\get_option('iawp_dark_mode')) {
43 $classes .= ' iawp-dark-mode ';
44 }
45 return $classes;
46 });
47 \add_action('admin_menu', [$this, 'add_admin_menu_pages']);
48 \add_action('admin_enqueue_scripts', [$this, 'enqueue_admin_scripts']);
49 \add_action('wp_enqueue_scripts', [$this, 'enqueue_scripts']);
50 \add_filter('plugin_action_links_independent-analytics/iawp.php', [$this, 'plugin_action_links']);
51 \add_filter('admin_footer_text', [$this, 'ip_db_attribution'], 1, 1);
52 \add_filter('admin_head', [$this, 'style_premium_menu_item']);
53 \add_action('init', [$this, 'polylang_translations']);
54 \add_action('init', [$this, 'load_textdomain']);
55 IAWP_FS()->add_filter('connect_message_on_update', [$this, 'filter_connect_message_on_update'], 10, 6);
56 IAWP_FS()->add_filter('connect_message', [$this, 'filter_connect_message_on_update'], 10, 6);
57 IAWP_FS()->add_filter('is_submenu_visible', [$this, 'hide_freemius_sub_menus'], 10, 2);
58 IAWP_FS()->add_filter('pricing_url', [$this, 'change_freemius_pricing_url'], 10);
59 IAWP_FS()->add_filter('show_deactivation_feedback_form', function () {
60 return \false;
61 });
62 \add_action('admin_init', [$this, 'maybe_create_mu_plugin']);
63 }
64 public function load_textdomain()
65 {
66 \load_plugin_textdomain('independent-analytics', \false, \IAWP_LANGUAGES_DIRECTORY);
67 }
68 public function polylang_translations()
69 {
70 if (\function_exists('IAWP_SCOPED\\pll_register_string')) {
71 pll_register_string('view_counter', 'Views:', 'Independent Analytics');
72 }
73 }
74 // Settings page where the analytics will appear
75 public function add_admin_menu_pages()
76 {
77 $title = Capability_Manager::white_labeled() ? \esc_html__('Analytics', 'independent-analytics') : 'Independent Analytics';
78 \add_menu_page($title, \esc_html__('Analytics', 'independent-analytics'), Capability_Manager::can_view_string(), 'independent-analytics', [$this, 'render_analytics_page'], 'dashicons-analytics', 3);
79 if (!Capability_Manager::white_labeled()) {
80 \add_submenu_page('independent-analytics', \esc_html__('Feedback', 'independent-analytics'), \esc_html__('Feedback', 'independent-analytics'), Capability_Manager::can_view_string(), \esc_url('https://feedback.independentwp.com/boards/feature-requests'));
81 }
82 if (\IAWP_SCOPED\iawp_is_free() && !Capability_Manager::white_labeled()) {
83 \add_submenu_page('independent-analytics', \esc_html__('Upgrade to Pro &rarr;', 'independent-analytics'), \esc_html__('Upgrade to Pro &rarr;', 'independent-analytics'), 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'));
84 }
85 }
86 public function hide_freemius_sub_menus($is_visible, $menu_id)
87 {
88 if ('pricing' == $menu_id) {
89 return \false;
90 } elseif ('support' == $menu_id && Capability_Manager::white_labeled()) {
91 return \false;
92 } else {
93 return \true;
94 }
95 }
96 public function change_freemius_pricing_url()
97 {
98 return 'https://independentwp.com/pricing/?utm_source=User+Dashboard&utm_medium=WP+Admin&utm_campaign=Upgrade+to+Pro&utm_content=Account';
99 }
100 // The submenu item needs to be styled on all admin pages, and we only load stylesheets on our page
101 public function style_premium_menu_item()
102 {
103 if (\IAWP_SCOPED\iawp_is_free()) {
104 echo '<style>#toplevel_page_independent-analytics .wp-submenu li:nth-child(4) a { color: #F69D0A; }</style>';
105 }
106 }
107 public function render_analytics_page()
108 {
109 if (!Capability_Manager::can_view()) {
110 return;
111 }
112 if (Migrations::is_migrating()) {
113 echo \IAWP_SCOPED\iawp_blade()->run('interrupt.migration-is-running');
114 return;
115 }
116 $options = new Dashboard_Options();
117 $tab = $this->get_current_tab();
118 ?>
119 <div id="iawp-parent" class="iawp-parent <?php
120 \esc_attr_e($tab);
121 ?>">
122 <div id="iawp-layout" class="iawp-layout <?php
123 echo $options->is_sidebar_collapsed() ? 'collapsed' : '';
124 ?>">
125 <?php
126 echo \IAWP_SCOPED\iawp_blade()->run('partials.sidebar', ['favorite_report' => Report_Finder::get_favorite(), 'report_finder' => new Report_Finder(), 'is_white_labeled' => Capability_Manager::white_labeled(), 'can_edit_settings' => Capability_Manager::can_edit(), 'is_dark_mode' => \get_option('iawp_dark_mode')]);
127 ?>
128 <div class="iawp-layout-main">
129 <div class="iawp-tab-content"><?php
130 $date_rage = $options->get_date_range();
131 $date_label = $date_rage->label();
132 $columns = $options->columns();
133 if ($tab == 'views') {
134 $table = new Table_Pages($columns);
135 $statistics_class = $table->group()->statistics_class();
136 $statistics = new $statistics_class($date_rage, null, $options->chart_interval());
137 $stats = new Quick_Stats(null, $statistics);
138 $chart = new Chart($statistics, $date_label);
139 $this->interface($table, $stats, $chart);
140 } elseif ($tab == 'referrers') {
141 $table = new Table_Referrers($columns);
142 $statistics_class = $table->group()->statistics_class();
143 $statistics = new $statistics_class($date_rage, null, $options->chart_interval());
144 $stats = new Quick_Stats(null, $statistics);
145 $chart = new Chart($statistics, $date_label);
146 $this->interface($table, $stats, $chart);
147 } elseif ($tab == 'geo') {
148 $table = new Table_Geo($columns, $options->group());
149 $statistics_class = $table->group()->statistics_class();
150 $statistics = new $statistics_class($date_rage, null, $options->chart_interval());
151 $stats = new Quick_Stats(null, $statistics);
152 $table_data_class = $table->group()->rows_class();
153 $geo_data = new $table_data_class($date_rage);
154 $chart = new Chart_Geo($geo_data->rows(), $date_label);
155 $this->interface($table, $stats, $chart);
156 } elseif ($tab === 'campaigns') {
157 $table = new Table_Campaigns($columns);
158 $statistics_class = $table->group()->statistics_class();
159 $statistics = new $statistics_class($date_rage, null, $options->chart_interval());
160 $stats = new Quick_Stats(null, $statistics);
161 $chart = new Chart($statistics, $date_label);
162 $this->interface($table, $stats, $chart);
163 } elseif ($tab == 'campaign-builder') {
164 (new Campaign_Builder())->render_campaign_builder();
165 } elseif ($tab == 'devices') {
166 $table = new Table_Devices($columns, $options->group());
167 $statistics_class = $table->group()->statistics_class();
168 $statistics = new $statistics_class($date_rage, null, $options->chart_interval());
169 $stats = new Quick_Stats(null, $statistics);
170 $chart = new Chart($statistics, $date_label);
171 $this->interface($table, $stats, $chart);
172 } elseif ($tab === 'real-time') {
173 (new Real_Time())->render_real_time_analytics();
174 } elseif ($tab == 'settings') {
175 echo '<div id="iawp-dashboard" class="iawp-dashboard">';
176 if (Capability_Manager::can_edit()) {
177 $this->settings->render_settings();
178 } else {
179 echo '<p class="permission-blocked">' . \esc_html__('You do not have permission to edit the settings.', 'independent-analytics') . '</p>';
180 }
181 echo '</div>';
182 } elseif ($tab == 'learn') {
183 echo '<div id="iawp-dashboard" class="iawp-dashboard">';
184 echo \IAWP_SCOPED\iawp_blade()->run('learn.learn');
185 echo '</div>';
186 }
187 ?>
188 </div>
189 <div id="loading-icon" class="loading-icon"><img
190 src="<?php
191 echo \esc_url(\IAWP_SCOPED\iawp_url_to('img/loading.svg'));
192 ?>"/>
193 </div>
194 <button id="scroll-to-top" class="scroll-to-top"><span
195 class="dashicons dashicons-arrow-up-alt"></span>
196 </button>
197 </div>
198 </div>
199 </div>
200 <?php
201 }
202 public function interface(Table $table, $stats, $chart)
203 {
204 $options = new Dashboard_Options();
205 // Todo - Silly that I use table to get the params just to pass them back into table
206 $sort_configuration = $table->sanitize_sort_parameters($options->sort_column(), $options->sort_direction());
207 ?>
208 <div id="iawp-dashboard"
209 class="iawp-dashboard"
210 data-controller="report"
211 data-report-relative-range-id-value="<?php
212 echo Security::attr($options->relative_range_id());
213 ?>"
214 data-report-exact-start-value="<?php
215 echo Security::attr($options->start());
216 ?>"
217 data-report-exact-end-value="<?php
218 echo Security::attr($options->end());
219 ?>"
220 data-report-group-value="<?php
221 echo Security::attr($options->group());
222 ?>"
223 data-report-filters-value="<?php
224 \esc_attr_e(Security::json_encode($options->filters()));
225 ?>"
226 data-report-chart-interval-value="<?php
227 echo Security::attr($options->chart_interval()->id());
228 ?>"
229 data-report-sort-column-value="<?php
230 echo Security::attr($options->sort_column());
231 ?>"
232 data-report-sort-direction-value="<?php
233 echo Security::attr($options->sort_direction());
234 ?>"
235 data-report-columns-value="<?php
236 \esc_attr_e(Security::json_encode($table->visible_column_ids()));
237 ?>"
238 data-report-visible-datasets-value="<?php
239 \esc_attr_e(Security::json_encode($options->visible_datasets()));
240 ?>"
241 >
242 <div class="report-header-container">
243 <?php
244 echo \IAWP_SCOPED\iawp_blade()->run('partials.report-header', ['report' => (new Report_Finder())->current(), 'can_edit' => Capability_Manager::can_edit()]);
245 ?>
246 <?php
247 $table->output_toolbar();
248 ?>
249 </div>
250 <?php
251 echo $stats->get_html();
252 ?>
253 <?php
254 echo $chart->get_html($options->visible_datasets());
255 ?>
256 <?php
257 echo $table->get_table_markup($sort_configuration->column(), $sort_configuration->direction());
258 ?>
259 </div>
260 <div class="iawp-notices"><?php
261 $plugin_conflict_detector = new Plugin_Conflict_Detector();
262 if (!$plugin_conflict_detector->has_conflict()) {
263 echo \IAWP_SCOPED\iawp_blade()->run('settings.notice', ['notice_text' => $plugin_conflict_detector->get_error(), 'button_text' => \false, 'notice' => 'iawp-error', 'url' => 'https://independentwp.com/knowledgebase/common-questions/views-not-recording/']);
264 }
265 if (\get_option('iawp_need_clear_cache')) {
266 echo \IAWP_SCOPED\iawp_blade()->run('settings.notice', ['notice_text' => \__('Please clear your cache to ensure tracking works properly.', 'independent-analytics'), 'button_text' => \__('I\'ve cleared the cache', 'independent-analytics'), 'notice' => 'iawp-warning', 'url' => 'https://independentwp.com/knowledgebase/common-questions/views-not-recording/']);
267 }
268 ?>
269 </div><?php
270 }
271 public function enqueue_admin_scripts($hook)
272 {
273 $this->enqueue_translations();
274 $this->enqueue_nonces();
275 if ($hook == 'toplevel_page_independent-analytics') {
276 $tab = $this->get_current_tab();
277 $this->dequeue_other_plugin_styles();
278 \wp_register_style('iawp-style', \IAWP_SCOPED\iawp_url_to('dist/styles/style.css'), [], \IAWP_VERSION);
279 \wp_enqueue_style('iawp-style');
280 \wp_register_script('iawp-js', \IAWP_SCOPED\iawp_url_to('dist/js/index.js'), [], \IAWP_VERSION);
281 \wp_enqueue_script('iawp-js');
282 if ($tab === 'views' || $tab === 'referrers' || $tab === 'geo' || $tab === 'campaigns' || $tab === 'campaign-builder' || $tab === 'devices' || $tab === 'real-time') {
283 \wp_register_script('iawp-data-table', \IAWP_SCOPED\iawp_url_to('dist/js/data-table.js'), [], \IAWP_VERSION);
284 \wp_enqueue_script('iawp-data-table');
285 } elseif ($tab == 'settings') {
286 \wp_enqueue_style('wp-color-picker');
287 \wp_register_script('iawp-settings', \IAWP_SCOPED\iawp_url_to('dist/js/settings.js'), ['wp-color-picker'], \IAWP_VERSION);
288 \wp_enqueue_script('iawp-settings');
289 } elseif ($tab == 'learn') {
290 \wp_register_script('iawp-learn', \IAWP_SCOPED\iawp_url_to('dist/js/learn.js'), [], \IAWP_VERSION);
291 \wp_enqueue_script('iawp-learn');
292 }
293 } elseif ($hook == 'index.php') {
294 \wp_register_script('iawp-dashboard-widget', \IAWP_SCOPED\iawp_url_to('dist/js/dashboard_widget.js'), [], \IAWP_VERSION);
295 \wp_enqueue_script('iawp-dashboard-widget');
296 \wp_register_style('iawp-dashboard-widget-css', \IAWP_SCOPED\iawp_url_to('dist/styles/dashboard_widget.css'), [], \IAWP_VERSION);
297 \wp_enqueue_style('iawp-dashboard-widget-css');
298 }
299 $this->maybe_enqueue_menu_bar_stats_styles();
300 \wp_register_style('iawp-freemius-notice-styles', \IAWP_SCOPED\iawp_url_to('dist/styles/freemius_notice_styles.css'), [], \IAWP_VERSION);
301 \wp_enqueue_style('iawp-freemius-notice-styles');
302 }
303 public function enqueue_scripts($hook)
304 {
305 $this->maybe_enqueue_menu_bar_stats_styles();
306 }
307 public function enqueue_translations()
308 {
309 \wp_register_script('iawp-translations', '');
310 \wp_enqueue_script('iawp-translations');
311 \wp_add_inline_script('iawp-translations', 'const iawpText = ' . \json_encode(['visitors' => \__('Visitors', 'independent-analytics'), 'views' => \__('Views', 'independent-analytics'), 'sessions' => \__('Sessions', 'independent-analytics'), 'orders' => \__('Orders', 'independent-analytics'), 'netSales' => \__('Net Sales', 'independent-analytics'), 'country' => \__('country', 'independent-analytics'), 'exactDates' => \__('Apply Exact Dates', 'independent-analytics'), 'relativeDates' => \__('Apply Relative Dates', 'independent-analytics'), 'copied' => \esc_html__('Copied', 'independent-analytics'), 'exportingPages' => \esc_html__('Exporting Pages...', 'independent-analytics'), 'exportPages' => \esc_html__('Export Pages', 'independent-analytics'), 'exportingReferrers' => \esc_html__('Exporting Referrers...', 'independent-analytics'), 'exportReferrers' => \esc_html__('Export Referrers', 'independent-analytics'), 'exportingGeolocations' => \esc_html__('Exporting Geolocations...', 'independent-analytics'), 'exportGeolocations' => \esc_html__('Export Geolocations', 'independent-analytics'), 'exportingDevices' => \esc_html__('Exporting Devices...', 'independent-analytics'), 'exportDevices' => \esc_html__('Export Devices', 'independent-analytics'), 'exportingCampaigns' => \esc_html__('Exporting Campaigns...', 'independent-analytics'), 'exportCampaigns' => \esc_html__('Export Campaigns', 'independent-analytics'), 'invalidReportArchive' => \esc_html__('This report archive is invalid. Please export your reports and try again.', 'independent-analytics'), 'openMobileMenu' => \esc_html__('Open menu', 'independent-analytics'), 'closeMobileMenu' => \esc_html__('Close menu', 'independent-analytics')]), 'before');
312 }
313 public function enqueue_nonces()
314 {
315 \wp_register_script('iawp-nonces', '');
316 \wp_enqueue_script('iawp-nonces');
317 \wp_add_inline_script('iawp-nonces', 'const iawpActions = ' . \json_encode(AJAX_Manager::getInstance()->get_action_signatures()), 'before');
318 }
319 public function maybe_enqueue_menu_bar_stats_styles()
320 {
321 if (Menu_Bar_Stats::is_option_enabled()) {
322 \wp_register_style('iawp-front-end-css', \IAWP_SCOPED\iawp_url_to('dist/styles/menu_bar_stats.css'), [], \IAWP_VERSION);
323 \wp_enqueue_style('iawp-front-end-css');
324 }
325 }
326 // Remove errant CSS from other plugins affecting our styles
327 public function dequeue_other_plugin_styles()
328 {
329 // https://wordpress.org/plugins/comment-link-remove/
330 \wp_dequeue_style('qc_clr_admin_style_css');
331 }
332 public function maybe_create_mu_plugin()
333 {
334 if (\defined('IAWP_MUST_USE_PLUGIN_EXISTS') || \get_option('iawp_must_use_directory_not_writable')) {
335 return;
336 }
337 $header_options = [['Plugin Name', 'Independent Analytics Performance Booster'], ['Plugin URI', 'https://independentwp.com'], ['Description', 'This MU plugin is added upon activating the Independent Analytics plugin, and automatically deleted when deactivating it. It speeds up the REST API request that IA makes by preventing any other plugins from getting loaded during that request.'], ['Version', '1.0'], ['Author', 'Independent Analytics'], ['Author URI', 'https://independentwp.com']];
338 $header_string = \PHP_EOL;
339 foreach ($header_options as $option) {
340 $header_string .= ' * ';
341 $header_string .= $option[0];
342 $header_string .= ': ';
343 $header_string .= $option[1];
344 $header_string .= \PHP_EOL;
345 }
346 $code = \file_get_contents(\IAWP_SCOPED\iawp_path_to('must-use/iawp-must-use-plugin.php'));
347 $code = \str_replace('MUST_USE_PLUGIN_HEADER', $header_string, $code);
348 if (!\is_writable(\WPMU_PLUGIN_DIR)) {
349 \wp_mkdir_p(\trailingslashit(\WPMU_PLUGIN_DIR));
350 }
351 if ($code !== \false && \is_writable(\WPMU_PLUGIN_DIR)) {
352 \file_put_contents(\trailingslashit(\WPMU_PLUGIN_DIR) . 'iawp-performance-boost.php', $code);
353 } else {
354 \update_option('iawp_must_use_directory_not_writable', \true);
355 }
356 }
357 public function get_option($name, $default)
358 {
359 $option = \get_option($name, $default);
360 return $option === '' ? $default : $option;
361 }
362 public function get_authors()
363 {
364 $roles = [];
365 foreach (\wp_roles()->roles as $role_name => $role_obj) {
366 if (!empty($role_obj['capabilities']['edit_posts'])) {
367 $roles[] = $role_name;
368 }
369 }
370 $users = \get_users(['role__in' => $roles]);
371 return $users;
372 }
373 public function get_custom_types(bool $tax = \false)
374 {
375 $args = ['public' => \true, '_builtin' => \false];
376 if ($tax) {
377 return \get_taxonomies($args);
378 } else {
379 return \get_post_types($args);
380 }
381 }
382 public function filter_connect_message_on_update($message, $user_first_name, $product_title, $user_login, $site_link, $freemius_link)
383 {
384 // Add the heading HTML.
385 $plugin_name = 'Independent Analytics';
386 $title = '<h3>' . \sprintf(\esc_html__('We hope you love %1$s', 'independent-analytics'), $plugin_name) . '</h3>';
387 $html = '';
388 // Add the introduction HTML.
389 $html .= '<p>';
390 $html .= \sprintf(\esc_html__('Hi, %1$s! This is an invitation to help the %2$s community.', 'independent-analytics'), $user_first_name, $plugin_name);
391 $html .= '<strong>';
392 $html .= \sprintf(\esc_html__('If you opt-in, some data about your usage of %2$s will be shared with us', 'independent-analytics'), $user_first_name, $plugin_name);
393 $html .= '</strong>';
394 $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.', 'independent-analytics'), $user_first_name, $plugin_name);
395 $html .= '</p>';
396 $html .= '<p>';
397 $html .= \sprintf(\esc_html__('And if you skip this, that\'s okay! %1$s will still work just fine.', 'independent-analytics'), $plugin_name);
398 $html .= '</p>';
399 return $title . $html;
400 }
401 public function plugin_action_links($links)
402 {
403 // Create the link
404 $settings_link = '<a class="calendar-link" href="' . \esc_url(\IAWP_SCOPED\iawp_dashboard_url()) . '">' . \esc_html__('Analytics Dashboard', 'independent-analytics') . '</a>';
405 // Add the link to the start of the array
406 \array_unshift($links, $settings_link);
407 return $links;
408 }
409 public function ip_db_attribution($text)
410 {
411 if ($this->get_current_tab() === 'geo') {
412 $text = $text . ' ' . \esc_html_x('Geolocation data powered by', 'Following text is a noun: DB-IP', 'independent-analytics') . ' ' . '<a href="https://db-ip.com" class="geo-message" target="_blank">DB-IP</a>.';
413 }
414 return $text;
415 }
416 public function pagination_page_size()
417 {
418 return 50;
419 }
420 public function get_current_tab() : string
421 {
422 if (\IAWP_SCOPED\iawp_is_pro()) {
423 $valid_tabs = ['views', 'referrers', 'geo', 'devices', 'campaigns', 'campaign-builder', 'real-time', 'settings', 'learn'];
424 } else {
425 $valid_tabs = ['views', 'referrers', 'geo', 'devices', 'settings', 'learn'];
426 }
427 $default_tab = $valid_tabs[0];
428 $tab = \array_key_exists('tab', $_GET) ? \sanitize_text_field($_GET['tab']) : \false;
429 $is_valid = \array_search($tab, $valid_tabs) != \false;
430 if (!$tab || !$is_valid) {
431 $tab = $default_tab;
432 }
433 return $tab;
434 }
435 }
436