PluginProbe ʕ •ᴥ•ʔ
Independent Analytics – WordPress Analytics Plugin / 2.6.3
Independent Analytics – WordPress Analytics Plugin v2.6.3
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 Admin_Page 2 years ago Custom_WordPress_Columns 2 years ago Date_Range 2 years ago Email_Reports 2 years ago Filter_Lists 2 years ago Form_Submissions 2 years ago Interval 2 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 2 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.php 2 years ago Database_Manager.php 2 years ago Empty_Report_Option.php 2 years ago Env.php 2 years ago Filters.php 2 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 Patch.php 2 years ago Plugin_Conflict_Detector.php 2 years ago Plugin_Group.php 2 years ago Plugin_Group_Option.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 2 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
292 lines
1 <?php
2
3 namespace IAWP;
4
5 use IAWP\Admin_Page\Analytics_Page;
6 use IAWP\Admin_Page\Campaign_Builder_Page;
7 use IAWP\Admin_Page\Settings_Page;
8 use IAWP\Admin_Page\Support_Page;
9 use IAWP\Admin_Page\Updates_Page;
10 use IAWP\AJAX\AJAX_Manager;
11 use IAWP\Email_Reports\Email_Reports;
12 use IAWP\Form_Submissions\Submission_Listener;
13 use IAWP\Menu_Bar_Stats\Menu_Bar_Stats;
14 use IAWP\Migrations\Migrations;
15 use IAWP\Utils\Singleton;
16 /** @internal */
17 class Independent_Analytics
18 {
19 use Singleton;
20 public $settings;
21 public $email_reports;
22 public $cron_manager;
23 // This is where we attach functions to WP hooks
24 private function __construct()
25 {
26 $this->settings = new \IAWP\Settings();
27 new \IAWP\REST_API();
28 new \IAWP\Dashboard_Widget();
29 new \IAWP\View_Counter();
30 new Submission_Listener();
31 AJAX_Manager::getInstance();
32 if (!Migrations::is_migrating()) {
33 new \IAWP\Track_Resource_Changes();
34 Menu_Bar_Stats::register();
35 \IAWP\WooCommerce_Order::initialize_order_tracker();
36 }
37 $this->cron_manager = new \IAWP\Cron_Manager();
38 if (\IAWPSCOPED\iawp_is_pro()) {
39 $this->email_reports = new Email_Reports();
40 new \IAWP\Campaign_Builder();
41 new \IAWP\WooCommerce_Referrer_Meta_Box();
42 }
43 \add_filter('admin_body_class', function ($classes) {
44 if (\get_option('iawp_dark_mode')) {
45 $classes .= ' iawp-dark-mode ';
46 }
47 return $classes;
48 });
49 \add_action('admin_enqueue_scripts', [$this, 'enqueue_scripts_and_styles'], 110);
50 // Called at 110 to dequeue other scripts
51 \add_action('wp_enqueue_scripts', [$this, 'enqueue_scripts_and_styles_front_end']);
52 \add_action('admin_menu', [$this, 'add_admin_menu_pages']);
53 \add_action('admin_init', [$this, 'remove_freemius_pricing_menu']);
54 \add_filter('plugin_action_links_independent-analytics/iawp.php', [$this, 'plugin_action_links']);
55 \add_filter('admin_footer_text', [$this, 'ip_db_attribution'], 1, 1);
56 \add_action('init', [$this, 'polylang_translations']);
57 \add_action('init', [$this, 'load_textdomain']);
58 \IAWP_FS()->add_filter('connect_message_on_update', [$this, 'filter_connect_message_on_update'], 10, 6);
59 \IAWP_FS()->add_filter('connect_message', [$this, 'filter_connect_message_on_update'], 10, 6);
60 \IAWP_FS()->add_filter('pricing_url', [$this, 'change_freemius_pricing_url'], 10);
61 \IAWP_FS()->add_filter('show_deactivation_feedback_form', function () {
62 return \false;
63 });
64 \add_action('admin_init', [$this, 'maybe_delete_mu_plugin']);
65 }
66 /**
67 * At one point in time, there was a must-use plugin that was created. The plugin file and the
68 * option need to get cleaned up.
69 * @return void
70 */
71 public function maybe_delete_mu_plugin()
72 {
73 $already_attempted = \get_option('iawp_attempted_to_delete_mu_plugin', '0');
74 if ($already_attempted === '1') {
75 return;
76 }
77 if (\get_option('iawp_must_use_directory_not_writable', '0') === '1') {
78 \delete_option('iawp_must_use_directory_not_writable');
79 }
80 $mu_plugin_file = \trailingslashit(\WPMU_PLUGIN_DIR) . 'iawp-performance-boost.php';
81 if (\file_exists($mu_plugin_file)) {
82 \unlink($mu_plugin_file);
83 }
84 \update_option('iawp_attempted_to_delete_mu_plugin', '1');
85 }
86 public function load_textdomain()
87 {
88 \load_plugin_textdomain('independent-analytics', \false, \IAWP_LANGUAGES_DIRECTORY);
89 }
90 public function polylang_translations()
91 {
92 if (\function_exists('IAWPSCOPED\\pll_register_string')) {
93 pll_register_string('view_counter', 'Views:', 'Independent Analytics');
94 }
95 }
96 // Changes the URL for the "Upgrade" tab in the Account menu
97 public function change_freemius_pricing_url()
98 {
99 return 'https://independentwp.com/pricing/?utm_source=User+Dashboard&utm_medium=WP+Admin&utm_campaign=Upgrade+to+Pro&utm_content=Account';
100 }
101 public function add_admin_menu_pages()
102 {
103 $title = \IAWP\Capability_Manager::white_labeled() ? \esc_html__('Analytics', 'independent-analytics') : 'Independent Analytics';
104 \add_menu_page($title, \esc_html__('Analytics', 'independent-analytics'), \IAWP\Capability_Manager::can_view_string(), 'independent-analytics', function () {
105 $analytics_page = new Analytics_Page();
106 $analytics_page->render();
107 }, 'dashicons-analytics', 3);
108 if (\IAWP\Capability_Manager::can_edit()) {
109 \add_submenu_page('independent-analytics', \esc_html__('Settings', 'independent-analytics'), \esc_html__('Settings', 'independent-analytics'), \IAWP\Capability_Manager::can_view_string(), 'independent-analytics-settings', function () {
110 $settings_page = new Settings_Page();
111 $settings_page->render(\false);
112 });
113 }
114 if (\IAWPSCOPED\iawp_is_pro()) {
115 \add_submenu_page('independent-analytics', \esc_html__('Campaign Builder', 'independent-analytics'), \esc_html__('Campaign Builder', 'independent-analytics'), \IAWP\Capability_Manager::can_view_string(), 'independent-analytics-campaign-builder', function () {
116 $campaign_builder_page = new Campaign_Builder_Page();
117 $campaign_builder_page->render(\false);
118 });
119 }
120 if (!\IAWP\Capability_Manager::white_labeled()) {
121 \add_submenu_page('independent-analytics', \esc_html__('Help & Support', 'independent-analytics'), \esc_html__('Help & Support', 'independent-analytics'), \IAWP\Capability_Manager::can_view_string(), 'independent-analytics-support-center', function () {
122 $support_page = new Support_Page();
123 $support_page->render(\false);
124 });
125 }
126 if (!\IAWP\Capability_Manager::white_labeled()) {
127 $menu_html = '<span class="menu-name">' . \esc_html__('Changelog', 'independent-analytics') . '</span>';
128 $menu_html = $this->changelog_viewed_since_update() ? $menu_html . ' <span class="menu-counter">' . \esc_html__('New', 'independent-analytics') . '</span>' : $menu_html;
129 \add_submenu_page('independent-analytics', \esc_html__('Changelog', 'independent-analytics'), $menu_html, \IAWP\Capability_Manager::can_view_string(), 'independent-analytics-updates', function () {
130 $updates_page = new Updates_Page();
131 $updates_page->render(\false);
132 });
133 }
134 if (\IAWPSCOPED\iawp_is_free() && !\IAWP\Capability_Manager::white_labeled()) {
135 \add_submenu_page('independent-analytics', \esc_html__('Upgrade to Pro &rarr;', 'independent-analytics'), '<span style="color: #F69D0A;">' . \esc_html__('Upgrade to Pro &rarr;', 'independent-analytics') . '</span>', \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'));
136 }
137 }
138 // The menu link is removed in the SDK setup, but this makes it completely inaccessible
139 public function remove_freemius_pricing_menu()
140 {
141 \remove_submenu_page('independent-analytics', 'independent-analytics-pricing');
142 }
143 public function register_scripts_and_styles() : void
144 {
145 \wp_register_style('iawp-styles', \IAWPSCOPED\iawp_url_to('dist/styles/style.css'), [], \IAWP_VERSION);
146 \wp_register_style('iawp-dashboard-widget-styles', \IAWPSCOPED\iawp_url_to('dist/styles/dashboard_widget.css'), [], \IAWP_VERSION);
147 \wp_register_style('iawp-freemius-notice-styles', \IAWPSCOPED\iawp_url_to('dist/styles/freemius_notice_styles.css'), [], \IAWP_VERSION);
148 \wp_register_style('iawp-posts-menu-styles', \IAWPSCOPED\iawp_url_to('dist/styles/posts_menu.css'), [], \IAWP_VERSION);
149 \wp_register_script('iawp-javascript', \IAWPSCOPED\iawp_url_to('dist/js/index.js'), [], \IAWP_VERSION);
150 \wp_register_script('iawp-dashboard-widget-javascript', \IAWPSCOPED\iawp_url_to('dist/js/dashboard_widget.js'), [], \IAWP_VERSION);
151 \wp_register_script('iawp-layout-javascript', \IAWPSCOPED\iawp_url_to('dist/js/layout.js'), [], \IAWP_VERSION);
152 \wp_register_script('iawp-settings-javascript', \IAWPSCOPED\iawp_url_to('dist/js/settings.js'), ['wp-color-picker'], \IAWP_VERSION);
153 if (Menu_Bar_Stats::is_option_enabled()) {
154 \wp_register_style('iawp-front-end-styles', \IAWPSCOPED\iawp_url_to('dist/styles/menu_bar_stats.css'), [], \IAWP_VERSION);
155 }
156 if (\is_rtl()) {
157 \wp_register_style('iawp-styles-rtl', \IAWPSCOPED\iawp_url_to('dist/styles/rtl.css'), [], \IAWP_VERSION);
158 }
159 }
160 public function register_scripts_and_styles_front_end() : void
161 {
162 if (Menu_Bar_Stats::is_option_enabled()) {
163 \wp_register_style('iawp-front-end-styles', \IAWPSCOPED\iawp_url_to('dist/styles/menu_bar_stats.css'), [], \IAWP_VERSION);
164 }
165 }
166 public function enqueue_scripts_and_styles($hook)
167 {
168 $this->register_scripts_and_styles();
169 $page = \IAWP\Env::get_page();
170 $this->enqueue_translations();
171 $this->enqueue_nonces();
172 \wp_enqueue_style('iawp-freemius-notice-styles');
173 if (\is_string($page)) {
174 \wp_enqueue_style('iawp-styles');
175 \wp_enqueue_script('iawp-javascript');
176 \wp_enqueue_script('iawp-layout-javascript');
177 $this->dequeue_bad_actors();
178 $this->maybe_override_adminify_styles();
179 if (\is_rtl()) {
180 \wp_enqueue_style('iawp-styles-rtl');
181 }
182 }
183 if ($page === 'independent-analytics-settings') {
184 \wp_enqueue_style('wp-color-picker');
185 \wp_enqueue_script('iawp-settings-javascript');
186 } elseif ($hook === 'index.php') {
187 \wp_enqueue_script('iawp-dashboard-widget-javascript');
188 \wp_enqueue_style('iawp-dashboard-widget-styles');
189 } elseif ($hook === 'edit.php') {
190 \wp_enqueue_style('iawp-posts-menu-styles');
191 }
192 if (Menu_Bar_Stats::is_option_enabled()) {
193 \wp_enqueue_style('iawp-front-end-styles');
194 }
195 }
196 public function enqueue_scripts_and_styles_front_end()
197 {
198 if (Menu_Bar_Stats::is_option_enabled()) {
199 $this->register_scripts_and_styles_front_end();
200 \wp_enqueue_style('iawp-front-end-styles');
201 }
202 }
203 public function enqueue_translations()
204 {
205 \wp_register_script('iawp-translations', '');
206 \wp_enqueue_script('iawp-translations');
207 \wp_add_inline_script('iawp-translations', 'const iawpText = ' . \json_encode(['views' => \__('Views', 'independent-analytics'), 'exactDates' => \__('Apply Exact Dates', 'independent-analytics'), 'relativeDates' => \__('Apply Relative Dates', 'independent-analytics'), 'copied' => \__('Copied', 'independent-analytics'), 'exportingPages' => \__('Exporting Pages...', 'independent-analytics'), 'exportPages' => \__('Export Pages', 'independent-analytics'), 'exportingReferrers' => \__('Exporting Referrers...', 'independent-analytics'), 'exportReferrers' => \__('Export Referrers', 'independent-analytics'), 'exportingGeolocations' => \__('Exporting Geolocations...', 'independent-analytics'), 'exportGeolocations' => \__('Export Geolocations', 'independent-analytics'), 'exportingDevices' => \__('Exporting Devices...', 'independent-analytics'), 'exportDevices' => \__('Export Devices', 'independent-analytics'), 'exportingCampaigns' => \__('Exporting Campaigns...', 'independent-analytics'), 'exportCampaigns' => \__('Export Campaigns', 'independent-analytics'), 'invalidReportArchive' => \__('This report archive is invalid. Please export your reports and try again.', 'independent-analytics'), 'openMobileMenu' => \__('Open menu', 'independent-analytics'), 'closeMobileMenu' => \__('Close menu', 'independent-analytics')]), 'before');
208 }
209 public function enqueue_nonces()
210 {
211 \wp_register_script('iawp-nonces', '');
212 \wp_enqueue_script('iawp-nonces');
213 \wp_add_inline_script('iawp-nonces', 'const iawpActions = ' . \json_encode(AJAX_Manager::getInstance()->get_action_signatures()), 'before');
214 }
215 public function get_option($name, $default)
216 {
217 $option = \get_option($name, $default);
218 return $option === '' ? $default : $option;
219 }
220 public function filter_connect_message_on_update($message, $user_first_name, $product_title, $user_login, $site_link, $freemius_link)
221 {
222 // Add the heading HTML.
223 $plugin_name = 'Independent Analytics';
224 $title = '<h3>' . \sprintf(\esc_html__('We hope you love %1$s', 'independent-analytics'), $plugin_name) . '</h3>';
225 $html = '';
226 // Add the introduction HTML.
227 $html .= '<p>';
228 $html .= \sprintf(\esc_html__('Hi, %1$s! This is an invitation to help the %2$s community.', 'independent-analytics'), $user_first_name, $plugin_name);
229 $html .= '<strong>';
230 $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);
231 $html .= '</strong>';
232 $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);
233 $html .= '</p>';
234 $html .= '<p>';
235 $html .= \sprintf(\esc_html__('And if you skip this, that\'s okay! %1$s will still work just fine.', 'independent-analytics'), $plugin_name);
236 $html .= '</p>';
237 return $title . $html;
238 }
239 public function plugin_action_links($links)
240 {
241 // Create the link
242 $settings_link = '<a class="calendar-link" href="' . \esc_url(\IAWPSCOPED\iawp_dashboard_url()) . '">' . \esc_html__('Analytics Dashboard', 'independent-analytics') . '</a>';
243 // Add the link to the start of the array
244 \array_unshift($links, $settings_link);
245 return $links;
246 }
247 public function ip_db_attribution($text)
248 {
249 if (\IAWP\Env::get_tab() === 'geo') {
250 $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>.';
251 }
252 return $text;
253 }
254 public function pagination_page_size()
255 {
256 return 50;
257 }
258 public function dequeue_bad_actors()
259 {
260 // https://wordpress.org/plugins/comment-link-remove/
261 \wp_dequeue_style('qc_clr_admin_style_css');
262 // https://wordpress.org/plugins/webappick-pdf-invoice-for-woocommerce/
263 \wp_dequeue_style('woo-invoice');
264 // https://wordpress.org/plugins/wp-media-files-name-rename/
265 \wp_dequeue_style('wpcmp_bootstrap_css');
266 // https://wordpress.org/plugins/morepuzzles/
267 \wp_dequeue_style('bscss');
268 \wp_dequeue_style('mypluginstyle');
269 }
270 public function maybe_override_adminify_styles()
271 {
272 if (\in_array('adminify/adminify.php', \get_option('active_plugins'))) {
273 $settings = \get_option('_wpadminify');
274 if ($settings) {
275 if (\array_key_exists('admin_ui', $settings)) {
276 if ($settings['admin_ui']) {
277 \wp_register_style('iawp-adminify-styles', \IAWPSCOPED\iawp_url_to('dist/styles/adminify.css'), [], \IAWP_VERSION);
278 \wp_enqueue_style('iawp-adminify-styles');
279 }
280 }
281 }
282 }
283 }
284 public function changelog_viewed_since_update() : bool
285 {
286 if (\number_format(\floatval(\IAWP_VERSION), 1) > \floatval($this->get_option('iawp_last_update_viewed', '0'))) {
287 return \true;
288 }
289 return \false;
290 }
291 }
292