Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display an admin notice if neither Jetpack transport is available for WCPay #394

Merged
merged 4 commits into from
Feb 4, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions includes/class-wc-payments.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,21 @@ public static function check_plugin_dependencies( $silent ) {
return true;
}

// TODO - Remove/update when Jetpack Connection package is all we need.
if ( ! self::check_for_jetpack_layer() ) {
if ( ! $silent ) {
$message = sprintf(
/* translators: %1: WooCommerce Payments version */
__( 'WooCommerce Payments %1$s requires Jetpack. Please install, activate, and connect Jetpack. This dependency will change in an upcoming release.', 'woocommerce-payments' ),
WCPAY_VERSION_NUMBER
);

self::display_admin_error( $message );
}

return false;
};

$plugin_headers = self::get_plugin_headers();

$wc_version = $plugin_headers['WCRequires'];
Expand Down Expand Up @@ -230,6 +245,22 @@ public static function check_plugin_dependencies( $silent ) {
return true;
}

/**
* Checks whether either Jetpack transport is available and displays an admin error message if not.
*
* @return bool true if either Jetpack transport is available, false otherwise.
*/
public static function check_for_jetpack_layer() {
dechov marked this conversation as resolved.
Show resolved Hide resolved
if ( class_exists( 'Automattic\Jetpack\Connection\Client' ) ) {
return true;
}
if ( class_exists( 'Jetpack_Client' ) ) {
return true;
}

return false;
}

/**
* Checks whether Woo Multi-Currency is disabled and displays admin error message if enabled.
* TODO: Once Multi-Currency support is implemented, remove this check.
Expand Down