1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
<?php
defined( 'ABSPATH' ) || exit();
class WC_Braintree_Install {
public static function init() {
add_filter( 'plugin_action_links_' . WC_BRAINTREE_PLUGIN_NAME, array( __CLASS__, 'plugin_action_links' ) );
register_activation_hook( WC_BRAINTREE_PLUGIN_NAME, array( __CLASS__, 'install' ) );
}
public static function plugin_action_links( $links ) {
$action_links = array(
'settings' => sprintf( '<a href="%1$s">%2$s</a>', admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=braintree_api' ), esc_html__( 'Settings', 'woo-payment-gateway' ) ),
'docs' => sprintf( '<a target="_blank" href="https://docs.paymentplugins.com/wc-braintree/config">%s</a>', __( 'Documentation', 'woo-payment-gateway' ) ),
);
return array_merge( $action_links, $links );
}
public static function install() {
if ( get_option( 'braintree_wc_version', false ) !== false ) {
return;
}
if ( is_plugin_active( 'woocommerce-gateway-paypal-powered-by-braintree/woocommerce-gateway-paypal-powered-by-braintree.php' ) ) {
throw new Exception( 'Please deactivate all other Braintree plugins to proceed with installation' );
}
update_option( 'woocommerce_queue_flush_rewrite_rules', 'yes' );
update_option( 'braintree_wc_version', braintree()->version );
}
}
WC_Braintree_Install::init();