PluginProbe ʕ •ᴥ•ʔ
Independent Analytics – WordPress Analytics Plugin / 1.20.0
Independent Analytics – WordPress Analytics Plugin v1.20.0
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-bootstrap.php
independent-analytics Last commit date
IAWP 3 years ago dist 3 years ago freemius 3 years ago img 3 years ago languages 3 years ago sql 3 years ago templates 3 years ago vendor 3 years ago iawp-bootstrap.php 3 years ago iawp.php 3 years ago readme.txt 3 years ago
iawp-bootstrap.php
171 lines
1 <?php
2
3 namespace IAWP_SCOPED;
4
5 use IAWP_SCOPED\IAWP\Geo_Database ;
6 use IAWP_SCOPED\IAWP\Independent_Analytics ;
7 use IAWP_SCOPED\IAWP\Migrations ;
8 use IAWP_SCOPED\IAWP\Utils\Request ;
9 use IAWP_SCOPED\IAWP\WP_Option_Cache_Bust ;
10 \define( 'IAWP_DIRECTORY', \rtrim( \plugin_dir_path( __FILE__ ), \DIRECTORY_SEPARATOR ) );
11 \define( 'IAWP_URL', \rtrim( \plugin_dir_url( __FILE__ ), '/' ) );
12 \define( 'IAWP_VERSION', '1.20.0' );
13 \define( 'IAWP_LANGUAGES_DIRECTORY', \dirname( \plugin_basename( __FILE__ ) ) . '/languages' );
14
15 if ( \file_exists( \IAWP_SCOPED\iawp_path_to( 'vendor/scoper-autoload.php' ) ) ) {
16 require_once \IAWP_SCOPED\iawp_path_to( 'vendor/scoper-autoload.php' );
17 } else {
18 require_once \IAWP_SCOPED\iawp_path_to( 'vendor/autoload.php' );
19 }
20
21 /**
22 * @param $log
23 *
24 * @return void
25 */
26 function iawp_log( $log ) : void
27 {
28 if ( \WP_DEBUG === \true && \WP_DEBUG_LOG === \true ) {
29
30 if ( \is_array( $log ) || \is_object( $log ) ) {
31 \error_log( \print_r( $log, \true ) );
32 } else {
33 \error_log( $log );
34 }
35
36 }
37 }
38
39 /**
40 * @param $path
41 *
42 * @return string
43 */
44 function iawp_path_to( $path ) : string
45 {
46 $path = \trim( $path, \DIRECTORY_SEPARATOR );
47 return \implode( \DIRECTORY_SEPARATOR, [ \IAWP_DIRECTORY, $path ] );
48 }
49
50 /**
51 * @param $path
52 *
53 * @return string
54 */
55 function iawp_url_to( $path ) : string
56 {
57 $path = \trim( $path, '/' );
58 return \implode( '/', [ \IAWP_URL, $path ] );
59 }
60
61 /**
62 * Provide defaults for arguments provided as an associated array
63 *
64 * @param array $args
65 * @param array $defaults
66 *
67 * @return array
68 */
69 function iawp_default_args( array $args = array(), array $defaults = array() ) : array
70 {
71 $args = \array_filter( $args, function ( $value ) {
72 // Remove key/value pairs where value is null
73 return $value !== null;
74 } );
75 $args = \array_intersect_key( $args, $defaults );
76 return \array_replace( $defaults, $args );
77 }
78
79 /**
80 * Determines if the user is running a licensed pro version
81 *
82 * @return bool
83 */
84 function iawp_is_pro() : bool
85 {
86 return \false;
87 }
88
89 /**
90 * Determines if the user is running a free version or an unlicensed pro version
91 * @return bool
92 */
93 function iawp_is_free() : bool
94 {
95 return !\IAWP_SCOPED\iawp_is_pro();
96 }
97
98 /**
99 * Determines if a pro user has WooCommerce activated
100 * @return bool
101 */
102 function iawp_using_woocommerce() : bool
103 {
104 global $wpdb ;
105 if ( \IAWP_SCOPED\iawp_is_free() ) {
106 return \false;
107 }
108 $class_missing = \class_exists( '\\WooCommerce' ) === \false;
109 if ( $class_missing ) {
110 return \false;
111 }
112 $table_name = $wpdb->prefix . 'wc_order_stats';
113 $order_stats_table = $wpdb->get_row( $wpdb->prepare( '
114 SELECT * FROM INFORMATION_SCHEMA.TABLES
115 WHERE TABLE_SCHEMA = %s AND TABLE_NAME = %s
116 ', $wpdb->dbname, $table_name ) );
117 if ( \is_null( $order_stats_table ) ) {
118 return \false;
119 }
120 return \true;
121 }
122
123 function iawp()
124 {
125 return Independent_Analytics::getInstance();
126 }
127
128 \IAWP_SCOPED\iawp();
129 WP_Option_Cache_Bust::register( 'iawp_is_migrating' );
130 WP_Option_Cache_Bust::register( 'iawp_is_database_downloading' );
131 WP_Option_Cache_Bust::register( 'iawp_db_version' );
132 WP_Option_Cache_Bust::register( 'iawp_geo_database_version' );
133 \register_activation_hook( __DIR__ . '/iawp.php', function () {
134
135 if ( \get_option( 'iawp_db_version', '0' ) === '0' ) {
136 // If there is no database installed, run migration on current process
137 Migrations\Migration::create_or_migrate();
138 } else {
139 // If there is a database, run migration in a background process
140 Migrations\Migration_Job::maybe_dispatch();
141 }
142
143 $geo_database = new Geo_Database();
144 $geo_database->maybe_dispatch_download_job();
145 \update_option( 'iawp_need_clear_cache', \true );
146 if ( \IAWP_SCOPED\iawp_is_pro() ) {
147 \IAWP_SCOPED\iawp()->email_reports->schedule_email_report();
148 }
149 } );
150 \register_deactivation_hook( __DIR__ . '/iawp.php', function () {
151 if ( \IAWP_SCOPED\iawp_is_pro() ) {
152 \IAWP_SCOPED\iawp()->email_reports->unschedule_email_report();
153 }
154 } );
155 /*
156 * The admin_init hook will fire when the dashboard is loaded or an admin ajax request is made
157 */
158 \add_action( 'admin_init', function () {
159 new Migrations\Migration_Job();
160
161 if ( \get_option( 'iawp_db_version', '0' ) === '0' ) {
162 // If there is no database installed, run migration on current process
163 Migrations\Migration::create_or_migrate();
164 } else {
165 // If there is a database, run migration in a background process
166 Migrations\Migration_Job::maybe_dispatch();
167 }
168
169 $geo_database = new Geo_Database();
170 $geo_database->maybe_dispatch_download_job();
171 } );