is_woocommerce_active() ) { add_action( 'admin_notices', array( $this, 'woocommerce_missing_notice' ) ); return; } // Check for OpenSSL extension (required for JWT signing). if ( ! extension_loaded( 'openssl' ) ) { add_action( 'admin_notices', array( $this, 'openssl_missing_notice' ) ); return; } // Load plugin classes. $this->includes(); // Initialize plugin. $this->init(); // Register hooks. $this->register_hooks(); } /** * Check if WooCommerce is active. * * @return bool */ private function is_woocommerce_active() { return in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ), true ) || ( is_multisite() && array_key_exists( 'woocommerce/woocommerce.php', get_site_option( 'active_sitewide_plugins', array() ) ) ); } /** * WooCommerce missing notice. */ public function woocommerce_missing_notice() { ?>

logger = new Informatiq_SP_Logger(); $this->price_updater = new Informatiq_SP_Price_Updater( $this->logger ); $this->admin = new Informatiq_SP_Admin( $this->logger, $this->price_updater ); // Initialize scheduler. new Informatiq_SP_Scheduler( $this->price_updater ); } /** * Register hooks. */ private function register_hooks() { register_activation_hook( INFORMATIQ_SP_PLUGIN_FILE, array( $this, 'activate' ) ); register_deactivation_hook( INFORMATIQ_SP_PLUGIN_FILE, array( $this, 'deactivate' ) ); add_action( 'plugins_loaded', array( $this, 'load_textdomain' ) ); } /** * Plugin activation. */ public function activate() { // Schedule daily cron event. if ( ! wp_next_scheduled( 'informatiq_sp_daily_price_update' ) ) { wp_schedule_event( time(), 'daily', 'informatiq_sp_daily_price_update' ); } // Create log table if needed. $this->logger->create_log_table(); } /** * Plugin deactivation. */ public function deactivate() { // Clear scheduled cron event. $timestamp = wp_next_scheduled( 'informatiq_sp_daily_price_update' ); if ( $timestamp ) { wp_unschedule_event( $timestamp, 'informatiq_sp_daily_price_update' ); } } /** * Load text domain. */ public function load_textdomain() { load_plugin_textdomain( 'informatiq-smart-pricing', false, dirname( INFORMATIQ_SP_PLUGIN_BASENAME ) . '/languages' ); } } /** * Get main instance. * * @return Informatiq_Smart_Google_Pricing */ function informatiq_sp() { return Informatiq_Smart_Google_Pricing::instance(); } /** * Initialize plugin after all plugins are loaded. * This ensures WooCommerce functions are available. */ function informatiq_sp_init() { informatiq_sp(); } add_action( 'plugins_loaded', 'informatiq_sp_init', 20 );