errors = array(); if ( version_compare( PHP_VERSION, PROFIT_ENGINE_MIN_PHP, '<' ) ) { $this->errors[] = sprintf( /* translators: 1: required PHP version, 2: current PHP version. */ __( 'ProfitEngine requires PHP %1$s or higher. You are running %2$s.', 'profit-engine' ), PROFIT_ENGINE_MIN_PHP, PHP_VERSION ); } global $wp_version; if ( isset( $wp_version ) && version_compare( $wp_version, PROFIT_ENGINE_MIN_WP, '<' ) ) { $this->errors[] = sprintf( /* translators: 1: required WordPress version, 2: current WordPress version. */ __( 'ProfitEngine requires WordPress %1$s or higher. You are running %2$s.', 'profit-engine' ), PROFIT_ENGINE_MIN_WP, $wp_version ); } if ( ! $this->is_woocommerce_active() ) { $this->errors[] = __( 'ProfitEngine requires WooCommerce to be installed and active.', 'profit-engine' ); } elseif ( defined( 'WC_VERSION' ) && version_compare( WC_VERSION, PROFIT_ENGINE_MIN_WC, '<' ) ) { $this->errors[] = sprintf( /* translators: 1: required WooCommerce version, 2: current WooCommerce version. */ __( 'ProfitEngine requires WooCommerce %1$s or higher. You are running %2$s.', 'profit-engine' ), PROFIT_ENGINE_MIN_WC, WC_VERSION ); } return array() === $this->errors; } /** * Detect an active WooCommerce install without relying on load order. */ private function is_woocommerce_active(): bool { if ( class_exists( \WooCommerce::class ) ) { return true; } $active_plugins = (array) get_option( 'active_plugins', array() ); if ( is_multisite() ) { $active_plugins = array_merge( $active_plugins, array_keys( (array) get_site_option( 'active_sitewide_plugins', array() ) ) ); } return in_array( 'woocommerce/woocommerce.php', $active_plugins, true ); } /** * Render an admin notice describing why the plugin did not boot. */ public function render_notice(): void { if ( array() === $this->errors ) { return; } echo '

' . esc_html__( 'ProfitEngine', 'profit-engine' ) . '

'; } }