includes(); $this->init(); add_action( 'admin_init', array( $this , 'awca_compat_checker' )); } /*loads other support classes*/ private function includes(){ /* Settings class. */ require_once AWCA_DIR . 'main/class-awca-settings.php'; /* Include core class. */ require_once AWCA_DIR . 'main/class-awca-main.php'; /* Include admin class. */ require_once AWCA_DIR . 'main/class-awca-admin.php'; /* Include auth class. */ require_once AWCA_DIR . 'main/class-awca-auth.php'; } /* init support classes*/ private function init(){ $this->settings = new AWCA_Settings(); $this->main = new AWCA_Main(); $this->admin = new AWCA_Admin(); $this->auth = new AWCA_Auth(); } /* returning setting class object */ public function settings(){ return $this->settings; } /* returning main class object */ public function main(){ return $this->main; } /* returning admin class object */ public function admin(){ return $this->admin; } /* returning auth class object */ public function auth(){ return $this->auth; } /* checking compatibility for plugin to get activated and working */ public function awca_compat_checker(){ global $wp_version ; $error = ''; $nwpv = implode( '.', array_slice( explode( '.', $wp_version ), 0, 2 ) ); #getiing wp version upto 2 decimal points # php version requirements if ( version_compare( PHP_VERSION, '7.0', '<' ) ) { $error = 'Advance Woocommerce Analytics requires PHP 7.0 or higher. You’re still on ' . PHP_VERSION; } # wp version requirements if ( $nwpv < '5.0' ) { $error = 'Advance Woocommerce Analytics requires WP 5.0 or higher. You’re still on ' . $wp_version; } # wc version requirements if ( class_exists( 'WooCommerce' ) ) { global $woocommerce; if ( version_compare( $woocommerce->version, '3.7', "<" ) ) { $error = 'Advance Woocommerce Analytics requires Woocommerce 3.7 or higher. You’re still on ' . $woocommerce->version; } } else{ $error = 'Advance Woocommerce Analytics requires WooCommerce 3.7 or higher for proper working'; } # disabling plugin on error if ( is_plugin_active( plugin_basename( __FILE__ ) ) && !empty($error) || !empty($error) ) { if ( isset( $_GET['activate'] ) ) { unset( $_GET['activate'] ); } deactivate_plugins( plugin_basename( __FILE__ ) ); add_action( 'admin_notices', function () use( $error ) { echo '
' . $error . '