-
Notifications
You must be signed in to change notification settings - Fork 1
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
Feature/check dependencies #40
base: release/next-release
Are you sure you want to change the base?
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,14 +7,48 @@ | |
* Requires PHP: 7.1 | ||
* WC tested up to: 7.2.2 | ||
* Author: Global Payments | ||
*/ | ||
*/ | ||
|
||
defined( 'ABSPATH' ) || exit; | ||
|
||
if ( version_compare( PHP_VERSION, '7.1', '<' ) ) { | ||
add_action( 'admin_notices', function () { | ||
$message = sprintf( __( 'Your PHP version is %s but GlobalPayments For WooCommerce requires version 7.1+.', 'globalpayments-gateway-provider-for-woocommerce' ), PHP_VERSION ); | ||
echo '<div class="notice notice-error"><p>' . $message . '</p></div>'; | ||
} ); | ||
|
||
return; | ||
} | ||
|
||
register_activation_hook( __FILE__, 'plugin_activation' ); | ||
|
||
function plugin_activation() { | ||
$requiredExtensions = [ 'curl', 'dom', 'openssl', 'json', 'zlib', 'intl', 'mbstring', 'xml' ]; | ||
foreach ( $requiredExtensions as $ext ) { | ||
if ( ! extension_loaded( $ext ) ) { | ||
$notices = get_option( 'plugin_deferred_admin_notices', array() ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please prefix the option name with "globalpayments_" instead of "plugin_" to avoid name collision with other plugins. |
||
$notices[] = sprintf( __( 'The GlobalPayments WooCommerce plugin requires the %s extension.', 'globalpayments-gateway-provider-for-woocommerce' ), $ext ); | ||
update_option( 'plugin_deferred_admin_notices', $notices ); | ||
} | ||
} | ||
} | ||
|
||
add_action( 'admin_notices', 'plugin_admin_notices' ); | ||
function plugin_admin_notices() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please prefix the function name with "globalpayments_" to avoid name collision with other plugins. |
||
if ( $notices = get_option( 'plugin_deferred_admin_notices' ) ) { | ||
foreach ( $notices as $notice ) { | ||
echo "<div class='notice notice-error'><p>$notice</p></div>"; | ||
} | ||
delete_option( 'plugin_deferred_admin_notices' ); | ||
deactivate_plugins( __FILE__ ); | ||
} | ||
} | ||
|
||
register_deactivation_hook( __FILE__, 'plugin_deactivation' ); | ||
function plugin_deactivation() { | ||
delete_option( 'plugin_deferred_admin_notices' ); | ||
} | ||
|
||
/** | ||
* Autoload SDK. | ||
*/ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please prefix the function name with "globalpayments_" to avoid name collision with other plugins.