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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
<?php
defined( 'ABSPATH' ) || exit();
class WC_Stripe_Admin_Settings {
public static function init() {
add_action( 'woocommerce_settings_checkout', array( __CLASS__, 'output' ) );
add_filter( 'wc_stripe_settings_nav_tabs', array( __CLASS__, 'admin_settings_tabs' ), 20 );
add_action( 'woocommerce_update_options_checkout', array( __CLASS__, 'save' ) );
}
public static function output() {
global $current_section;
do_action( 'woocommerce_stripe_settings_checkout_' . $current_section );
}
public static function output_advanced_settings() {
self::output_custom_section( '' );
}
public static function output_local_gateways() {
self::output_custom_section( 'stripe_ideal' );
}
public static function output_custom_section( $sub_section = '' ) {
global $current_section, $wc_stripe_subsection;
$wc_stripe_subsection = isset( $_GET['stripe_sub_section'] ) ? sanitize_title( $_GET['stripe_sub_section'] ) : $sub_section;
do_action( 'woocommerce_stripe_settings_checkout_' . $current_section . '_' . $wc_stripe_subsection );
}
public static function save_local_gateway() {
self::save_custom_section( 'stripe_ideal' );
}
public static function save_custom_section( $sub_section = '' ) {
global $current_section, $wc_stripe_subsection;
$wc_stripe_subsection = isset( $_GET['stripe_sub_section'] ) ? sanitize_title( $_GET['stripe_sub_section'] ) : $sub_section;
do_action( 'woocommerce_update_options_checkout_' . $current_section . '_' . $wc_stripe_subsection );
}
public static function save() {
global $current_section;
if ( $current_section && ! did_action( 'woocommerce_update_options_checkout_' . $current_section ) ) {
do_action( 'woocommerce_update_options_checkout_' . $current_section );
}
}
public static function admin_settings_tabs( $tabs ) {
$tabs['stripe_afterpay'] = __( 'Local Gateways', 'woo-stripe-payment' );
return $tabs;
}
public static function before_options() {
global $current_section, $wc_stripe_subsection;
do_action( 'wc_stripe_settings_before_options_' . $current_section . '_' . $wc_stripe_subsection );
}
public static function get_email_settings( $settings, $section_id = '' ) {
if ( ! $section_id ) {
$settings[] = array(
'type' => 'title',
'title' => __( 'Stripe Email Options', 'woo-stripe-payment' ),
);
$settings[] = array(
'type' => 'checkbox',
'title' => __( 'Email Receipt', 'woo-stripe-payment' ),
'id' => 'woocommerce_stripe_email_receipt',
'autoload' => false,
'desc' => __( 'If enabled, an email receipt will be sent to the customer by Stripe when the order is processed.',
'woo-stripe-payment' ),
);
$settings[] = array(
'type' => 'sectionend',
'id' => 'stripe_email',
);
}
return $settings;
}
}
WC_Stripe_Admin_Settings::init();