errors[] = sprintf( /* translators: 1: required WordPress version, 2: current WordPress version. */ __( 'Stock Alibi requires WordPress %1$s or newer. This site runs WordPress %2$s.', 'stock-alibi' ), STOCK_ALIBI_MIN_WP, $wp_version ); } if ( null === $wc_version ) { $this->errors[] = __( 'Stock Alibi requires WooCommerce to be installed and active.', 'stock-alibi' ); } elseif ( version_compare( $wc_version, STOCK_ALIBI_MIN_WC, '<' ) ) { $this->errors[] = sprintf( /* translators: 1: required WooCommerce version, 2: current WooCommerce version. */ __( 'Stock Alibi requires WooCommerce %1$s or newer. This site runs WooCommerce %2$s.', 'stock-alibi' ), STOCK_ALIBI_MIN_WC, $wc_version ); } } /** * Builds the checks from the running environment. */ public static function from_environment(): self { $wc_version = defined( 'WC_VERSION' ) ? (string) WC_VERSION : null; return new self( (string) get_bloginfo( 'version' ), $wc_version ); } /** * Whether every requirement is met. */ public function are_met(): bool { return array() === $this->errors; } /** * Messages of the failed checks. * * @return string[] */ public function errors(): array { return $this->errors; } /** * Prints the failed checks as an admin notice. Hooked to `admin_notices`. */ public function render_notice(): void { if ( $this->are_met() || ! current_user_can( 'activate_plugins' ) ) { return; } echo '
'; foreach ( $this->errors as $error ) { echo '

' . esc_html( $error ) . ' ' . esc_html__( 'The plugin is not recording changes.', 'stock-alibi' ) . '

'; } echo '
'; } }