Fix up some comments and add uninstalling code.
This commit is contained in:
parent
c0b74296ff
commit
75f2e6b85c
|
@ -109,8 +109,17 @@ abstract class WC_Payment_Gateway extends WC_Settings_API {
|
||||||
*/
|
*/
|
||||||
public $new_method_label = '';
|
public $new_method_label = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains a users saved tokens for this gateway.
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
protected $tokens = array();
|
protected $tokens = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a users saved tokens for this gateway.
|
||||||
|
* @since 2.6.0
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function get_tokens() {
|
public function get_tokens() {
|
||||||
if ( sizeof( $this->tokens ) > 0 ) {
|
if ( sizeof( $this->tokens ) > 0 ) {
|
||||||
return $this->tokens;
|
return $this->tokens;
|
||||||
|
@ -332,7 +341,7 @@ abstract class WC_Payment_Gateway extends WC_Settings_API {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $this->supports( 'default_credit_card_form' ) ) {
|
if ( $this->supports( 'default_credit_card_form' ) ) {
|
||||||
$this->credit_card_form();
|
$this->credit_card_form(); // Deprecated, will be removed in a future version.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -350,7 +359,11 @@ abstract class WC_Payment_Gateway extends WC_Settings_API {
|
||||||
return apply_filters( 'woocommerce_payment_gateway_supports', in_array( $feature, $this->supports ) ? true : false, $feature, $this );
|
return apply_filters( 'woocommerce_payment_gateway_supports', in_array( $feature, $this->supports ) ? true : false, $feature, $this );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function payment_gateway_script() {
|
/**
|
||||||
|
* Enqueues our tokenization script to handle some of the new form options.
|
||||||
|
* @since 2.6.0
|
||||||
|
*/
|
||||||
|
public function tokenization_script() {
|
||||||
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
||||||
wp_enqueue_script(
|
wp_enqueue_script(
|
||||||
'woocommerce-payment-gateway-form',
|
'woocommerce-payment-gateway-form',
|
||||||
|
@ -369,7 +382,7 @@ abstract class WC_Payment_Gateway extends WC_Settings_API {
|
||||||
* @since 2.6.0
|
* @since 2.6.0
|
||||||
*/
|
*/
|
||||||
public function saved_payment_methods() {
|
public function saved_payment_methods() {
|
||||||
$this->payment_gateway_script();
|
$this->tokenization_script();
|
||||||
$html = '<p>';
|
$html = '<p>';
|
||||||
foreach ( $this->get_tokens() as $token ) {
|
foreach ( $this->get_tokens() as $token ) {
|
||||||
$html .= $this->saved_payment_method( $token );
|
$html .= $this->saved_payment_method( $token );
|
||||||
|
@ -432,7 +445,7 @@ abstract class WC_Payment_Gateway extends WC_Settings_API {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Outputs a checkbox for saving a new payment method.
|
* Outputs a checkbox for saving a new payment method to the database.
|
||||||
* @since 2.6.0
|
* @since 2.6.0
|
||||||
*/
|
*/
|
||||||
public function save_payment_method_checkbox() {
|
public function save_payment_method_checkbox() {
|
||||||
|
@ -453,9 +466,13 @@ abstract class WC_Payment_Gateway extends WC_Settings_API {
|
||||||
echo $html;
|
echo $html;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Displays a radio button for entering a new payment method (new CC details) instead of using a saved method.
|
||||||
|
* Only displayed when a gateway supports tokenization.
|
||||||
|
* @since 2.6.0
|
||||||
|
*/
|
||||||
public function use_new_payment_method_checkbox() {
|
public function use_new_payment_method_checkbox() {
|
||||||
$label = ( ! empty( $this->new_method_label ) ? esc_html( $this->new_method_label ) : esc_html__( 'Use a new payment method', 'woocommerce' ) );
|
$label = ( ! empty( $this->new_method_label ) ? esc_html( $this->new_method_label ) : esc_html__( 'Use a new payment method', 'woocommerce' ) );
|
||||||
|
|
||||||
$html = '<input type="radio" id="wc-' . esc_attr( $this->id ). '-new" name="wc-' . esc_attr( $this->id ) . '-payment-token" value="new" style="width:auto;">';
|
$html = '<input type="radio" id="wc-' . esc_attr( $this->id ). '-new" name="wc-' . esc_attr( $this->id ) . '-payment-token" value="new" style="width:auto;">';
|
||||||
$html .= '<label class="wc-' . esc_attr( $this->id ) . '-payment-form-new-checkbox wc-gateway-payment-token-label" for="wc-' . esc_attr( $this->id ) . '-new">';
|
$html .= '<label class="wc-' . esc_attr( $this->id ) . '-payment-form-new-checkbox wc-gateway-payment-token-label" for="wc-' . esc_attr( $this->id ) . '-new">';
|
||||||
$html .= apply_filters( 'woocommerce_payment_gateway_form_new_method_label', $label, $this );
|
$html .= apply_filters( 'woocommerce_payment_gateway_form_new_method_label', $label, $this );
|
||||||
|
@ -464,8 +481,7 @@ abstract class WC_Payment_Gateway extends WC_Settings_API {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Core credit card form which gateways can used if needed.
|
* Core credit card form which gateways can used if needed. Deprecated - inheirt WC_Payment_Gateway_CC instead.
|
||||||
*
|
|
||||||
* @param array $args
|
* @param array $args
|
||||||
* @param array $fields
|
* @param array $fields
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -12,6 +12,11 @@ if ( ! defined( 'ABSPATH' ) ) {
|
||||||
*/
|
*/
|
||||||
class WC_Payment_Gateway_CC extends WC_Payment_Gateway {
|
class WC_Payment_Gateway_CC extends WC_Payment_Gateway {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builds our payment fields area - including tokenization fields and the actualy payment fields.
|
||||||
|
* If tokenization is displayed, just the fields will be displayed.
|
||||||
|
* @since 2.6.0
|
||||||
|
*/
|
||||||
public function payment_fields() {
|
public function payment_fields() {
|
||||||
$display_tokenization = $this->supports( 'tokenization' ) && is_checkout();
|
$display_tokenization = $this->supports( 'tokenization' ) && is_checkout();
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,11 @@ if ( ! defined( 'ABSPATH' ) ) {
|
||||||
*/
|
*/
|
||||||
class WC_Payment_Gateway_eCheck extends WC_Payment_Gateway {
|
class WC_Payment_Gateway_eCheck extends WC_Payment_Gateway {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builds our payment fields area - including tokenization fields and the actualy payment fields.
|
||||||
|
* If tokenization is displayed, just the fields will be displayed.
|
||||||
|
* @since 2.6.0
|
||||||
|
*/
|
||||||
public function payment_fields() {
|
public function payment_fields() {
|
||||||
$display_tokenization = $this->supports( 'tokenization' ) && is_checkout();
|
$display_tokenization = $this->supports( 'tokenization' ) && is_checkout();
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,8 @@ if ( ! empty( $status_options['uninstall_data'] ) ) {
|
||||||
$wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}woocommerce_shipping_zone_locations" );
|
$wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}woocommerce_shipping_zone_locations" );
|
||||||
$wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}woocommerce_shipping_zones" );
|
$wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}woocommerce_shipping_zones" );
|
||||||
$wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}woocommerce_sessions" );
|
$wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}woocommerce_sessions" );
|
||||||
|
$wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}woocommerce_payment_tokens" );
|
||||||
|
$wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}woocommerce_payment_tokenmeta" );
|
||||||
|
|
||||||
// Delete options.
|
// Delete options.
|
||||||
$wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE 'woocommerce\_%';");
|
$wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE 'woocommerce\_%';");
|
||||||
|
|
Loading…
Reference in New Issue