PluginProbe ʕ •ᴥ•ʔ
Independent Analytics – WordPress Analytics Plugin / 1.14
Independent Analytics – WordPress Analytics Plugin v1.14
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 / index.php
independent-analytics Last commit date
dist 3 years ago freemius 3 years ago img 3 years ago inc 3 years ago languages 3 years ago templates 3 years ago vendor 3 years ago iawp.php 3 years ago index.php 3 years ago readme.txt 3 years ago
index.php
182 lines
1 <?php
2
3 namespace IAWP;
4
5 define('IAWP_DIRECTORY', rtrim(plugin_dir_path(__FILE__), DIRECTORY_SEPARATOR));
6 define('IAWP_URL', rtrim(plugin_dir_url(__FILE__), '/'));
7 define('IAWP_VERSION', '1.14');
8 define('IAWP_LANGUAGES_DIRECTORY', dirname(plugin_basename(__FILE__)) . '/languages');
9
10 function path_to($path)
11 {
12 $path = trim($path, DIRECTORY_SEPARATOR);
13
14 return implode(DIRECTORY_SEPARATOR, [IAWP_DIRECTORY, $path]);
15 }
16
17 function url_to($path)
18 {
19 $path = trim($path, '/');
20
21 return implode('/', [IAWP_URL, $path]);
22 }
23
24 // Load scoped composer autoloader
25 require_once path_to('vendor/scoper-autoload.php');
26 // Load class utilities needed for other require calls to work
27 require_once path_to('inc/utils/singleton.php');
28 // Load utils
29 require_once path_to('inc/utils/array_to_csv.php');
30 require_once path_to('inc/utils/date_format.php');
31 require_once path_to('inc/utils/exact_range.php');
32 require_once path_to('inc/models/visitor.php');
33 require_once path_to('inc/utils/request.php');
34 require_once path_to('inc/utils/salt.php');
35 require_once path_to('inc/utils/security.php');
36 require_once path_to('inc/utils/string.php');
37 require_once path_to('inc/utils/timezone.php');
38 require_once path_to('inc/utils/relative_range.php');
39 require_once path_to('inc/utils/url.php');
40 require_once path_to('inc/utils/wp-async-request.php');
41 // Load ajax
42 require_once path_to('inc/ajax/ajax.php');
43 require_once path_to('inc/ajax/create_campaign_ajax.php');
44 require_once path_to('inc/ajax/delete_data_ajax.php');
45 require_once path_to('inc/ajax/export_campaigns_ajax.php');
46 require_once path_to('inc/ajax/export_geo_ajax.php');
47 require_once path_to('inc/ajax/export_referrers_ajax.php');
48 require_once path_to('inc/ajax/export_views_ajax.php');
49 require_once path_to('inc/ajax/filters_ajax.php');
50 require_once path_to('inc/ajax/migration_status_ajax.php');
51 require_once path_to('inc/ajax/update_capabilities_ajax.php');
52 // Load migrations
53 require_once path_to('inc/migrations/migration.php');
54 require_once path_to('inc/migrations/migration_job.php');
55 require_once path_to('inc/migrations/versions/migration_1_0.php');
56 require_once path_to('inc/migrations/versions/migration_1_6.php');
57 require_once path_to('inc/migrations/versions/migration_1_8.php');
58 require_once path_to('inc/migrations/versions/migration_1_9.php');
59 require_once path_to('inc/migrations/versions/migration_2.php');
60 require_once path_to('inc/migrations/versions/migration_3.php');
61 require_once path_to('inc/migrations/versions/migration_4.php');
62 require_once path_to('inc/migrations/versions/migration_5.php');
63 // Load models
64 require_once path_to('inc/models/page.php');
65 require_once path_to('inc/models/page_author_archive.php');
66 require_once path_to('inc/models/page_date_archive.php');
67 require_once path_to('inc/models/page_home.php');
68 require_once path_to('inc/models/page_not_found.php');
69 require_once path_to('inc/models/page_post_type_archive.php');
70 require_once path_to('inc/models/page_search.php');
71 require_once path_to('inc/models/page_singular.php');
72 require_once path_to('inc/models/page_term_archive.php');
73 require_once path_to('inc/models/campaign.php');
74 require_once path_to('inc/models/geo.php');
75 require_once path_to('inc/models/referrer.php');
76 // Load queries
77 require_once path_to('inc/queries/range_query.php');
78 require_once path_to('inc/queries/campaigns.php');
79 require_once path_to('inc/queries/geos.php');
80 require_once path_to('inc/queries/referrers.php');
81 require_once path_to('inc/queries/resources.php');
82 require_once path_to('inc/queries/views.php');
83 // Load root files
84 require_once path_to('inc/campaign_builder.php');
85 require_once path_to('inc/capability_manager.php');
86 require_once path_to('inc/chart.php');
87 require_once path_to('inc/chart_geo.php');
88 require_once path_to('inc/dashboard_options.php');
89 require_once path_to('inc/dashboard_widget.php');
90 require_once path_to('inc/db.php');
91 require_once path_to('inc/filters.php');
92 require_once path_to('inc/geo_database.php');
93 require_once path_to('inc/geo_database_download_job.php');
94 require_once path_to('inc/independent_analytics.php');
95 require_once path_to('inc/known_referrers.php');
96 require_once path_to('inc/quick_stats.php');
97 require_once path_to('inc/rest_api.php');
98 require_once path_to('inc/settings.php');
99 require_once path_to('inc/tables/table.php');
100 require_once path_to('inc/tables/table_campaigns.php');
101 require_once path_to('inc/tables/table_geo.php');
102 require_once path_to('inc/tables/table_referrers.php');
103 require_once path_to('inc/tables/table_views.php');
104 require_once path_to('inc/track_resource_changes.php');
105 require_once path_to('inc/view_counter.php');
106
107 // Initialize independent analytics
108 function IAWP()
109 {
110 return Independent_Analytics::getInstance();
111 }
112
113 IAWP();
114
115 add_filter('pre_option_iawp_is_migrating', function ($default) {
116 global $wpdb;
117 $row = $wpdb->get_row($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", 'iawp_is_migrating'));
118
119 if (is_object($row)) {
120 $value = $row->option_value;
121 } else {
122 $value = $default;
123 }
124
125 return apply_filters('option_iawp_is_migrating', maybe_unserialize($value), 'iawp_is_migrating');
126 });
127
128 add_filter('pre_option_iawp_is_database_downloading', function ($default) {
129 global $wpdb;
130 $row = $wpdb->get_row($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", 'iawp_is_database_downloading'));
131
132 if (is_object($row)) {
133 $value = $row->option_value;
134 } else {
135 $value = $default;
136 }
137
138 return apply_filters('option_iawp_is_migrating', maybe_unserialize($value), 'iawp_is_migrating');
139 });
140
141 add_filter('pre_option_iawp_db_version', function ($default) {
142 global $wpdb;
143 $row = $wpdb->get_row($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", 'iawp_db_version'));
144
145 if (is_object($row)) {
146 $value = $row->option_value;
147 } else {
148 $value = $default;
149 }
150
151 return apply_filters('option_iawp_db_version', maybe_unserialize($value), 'iawp_db_version');
152 });
153
154 register_activation_hook(__FILE__, function () {
155 if (get_option('iawp_db_version', '0') === '0') {
156 // If there is no database installed, run migration on current process
157 Migration::create_or_migrate();
158 } else {
159 // If there is a database, run migration in a background process
160 Migration_Job::maybe_dispatch();
161 }
162 $geo_database = new Geo_Database();
163 $geo_database->maybe_download();
164 });
165
166 /*
167 * The admin_init hook will fire when the dashboard is loaded or an admin ajax request is made
168 */
169 add_action('admin_init', function () {
170 new Migration_Job();
171
172 if (get_option('iawp_db_version', '0') === '0') {
173 // If there is no database installed, run migration on current process
174 Migration::create_or_migrate();
175 } else {
176 // If there is a database, run migration in a background process
177 Migration_Job::maybe_dispatch();
178 }
179 $geo_database = new Geo_Database();
180 $geo_database->maybe_download();
181 });
182