failures = array(); if ( version_compare( PHP_VERSION, AKSMB_MIN_PHP, '<' ) ) { $this->failures[] = sprintf( /* translators: 1: required PHP, 2: current PHP */ __( 'MarginBeacon requires PHP %1$s or higher. You are running %2$s.', 'marginbeacon' ), AKSMB_MIN_PHP, PHP_VERSION ); } global $wp_version; if ( isset( $wp_version ) && version_compare( $wp_version, AKSMB_MIN_WP, '<' ) ) { $this->failures[] = sprintf( /* translators: 1: required WP, 2: current WP */ __( 'MarginBeacon requires WordPress %1$s or higher. You are running %2$s.', 'marginbeacon' ), AKSMB_MIN_WP, $wp_version ); } if ( ! $this->is_woocommerce_active() ) { $this->failures[] = __( 'MarginBeacon requires WooCommerce to be installed and active.', 'marginbeacon' ); } elseif ( defined( 'WC_VERSION' ) && version_compare( WC_VERSION, AKSMB_MIN_WC, '<' ) ) { $this->failures[] = sprintf( /* translators: 1: required WC, 2: current WC */ __( 'MarginBeacon requires WooCommerce %1$s or higher. You are running %2$s.', 'marginbeacon' ), AKSMB_MIN_WC, WC_VERSION ); } if ( ! extension_loaded( 'bcmath' ) ) { $this->failures[] = __( 'MarginBeacon requires the PHP BCMath extension for exact money calculations.', 'marginbeacon' ); } return empty( $this->failures ); } /** * @return string[] */ public function failures() { return $this->failures; } /** * @return bool */ private function is_woocommerce_active() { if ( class_exists( 'WooCommerce' ) ) { return true; } if ( ! function_exists( 'is_plugin_active' ) ) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; } return function_exists( 'is_plugin_active' ) && is_plugin_active( 'woocommerce/woocommerce.php' ); } }