id, array( 'plugins', 'plugins-network' ), true ) || ! current_user_can( 'activate_plugins' ) ) { return; } $woocommerce = 'woocommerce/woocommerce.php'; $installed = file_exists( WP_PLUGIN_DIR . '/' . $woocommerce ); $button = ''; $url = ''; if ( $installed ) { $message = __( 'Brickmoat is switched on, but WooCommerce is not active on this site, so there is no checkout to protect yet. Activate WooCommerce and Brickmoat starts working by itself.', 'brickmoat' ); if ( current_user_can( 'activate_plugin', $woocommerce ) ) { $button = __( 'Activate WooCommerce', 'brickmoat' ); $url = wp_nonce_url( self_admin_url( 'plugins.php?action=activate&plugin=' . rawurlencode( $woocommerce ) ), 'activate-plugin_' . $woocommerce ); } } else { $message = __( 'Brickmoat is switched on, but WooCommerce is not installed on this site, so there is no checkout to protect yet. Install and activate WooCommerce and Brickmoat starts working by itself.', 'brickmoat' ); if ( current_user_can( 'install_plugins' ) ) { $button = __( 'Install WooCommerce', 'brickmoat' ); $path = 'update.php?action=install-plugin&plugin=woocommerce'; $url = wp_nonce_url( is_multisite() ? network_admin_url( $path ) : admin_url( $path ), 'install-plugin_woocommerce' ); } } echo '

' . esc_html__( 'Brickmoat needs WooCommerce.', 'brickmoat' ) . ' ' . esc_html( $message ) . '

'; if ( '' !== $url ) { echo '

' . esc_html( $button ) . '

'; } echo '
'; } /** * Decides one payment attempt: allow, challenge or block. Every route that can create an * order or charge a card calls this before the payment gateway is contacted. It never * throws: if anything inside it fails, the attempt is allowed and the error is logged. * * @param array $context What is known about the attempt; see \Brickmoat\Context::build(). * At least `route`: checkout_classic, checkout_block, order_pay, * add_payment_method or gateway_ajax. * @return array{decision:string,score:int,reasons:string[],signals:array,message:string,code:string,ms:float} */ function brickmoat_decide( $context = array() ) { return \Brickmoat\Decider::decide( $context ); }