id = 'payment_gateways'; $this->label = __( 'Gateways', 'woocommerce' ); add_filter( 'woocommerce_settings_tabs_array', array( $this, 'add_settings_page' ), 20 ); add_action( 'woocommerce_sections_' . $this->id, array( $this, 'output_sections' ) ); add_action( 'woocommerce_settings_' . $this->id, array( $this, 'output' ) ); add_action( 'woocommerce_admin_field_payment_gateways', array( $this, 'payment_gateways_setting' ) ); add_action( 'woocommerce_settings_save_' . $this->id, array( $this, 'save' ) ); } /** * Get sections * * @return array */ public function get_sections() { $sections = array( '' => __( 'Payment Gateways', 'woocommerce' ) ); // Load shipping methods so we can show any global options they may have $payment_gateways = WC()->payment_gateways->payment_gateways(); foreach ( $payment_gateways as $gateway ) { $title = empty( $gateway->method_title ) ? ucwords( $gateway->id ) : ucwords( $gateway->method_title ); $sections[ strtolower( get_class( $gateway ) ) ] = esc_html( $title ); } return $sections; } /** * Get settings array * * @return array */ public function get_settings() { return apply_filters( 'woocommerce_payment_gateways_settings', array( array( 'title' => __( 'Payment Gateways', 'woocommerce' ), 'desc' => __( 'Installed payment gateways are displayed below. Drag and drop payment gateways to control their display order on the checkout.', 'woocommerce' ), 'type' => 'title', 'id' => 'payment_gateways_options' ), array( 'type' => 'payment_gateways', ), array( 'type' => 'sectionend', 'id' => 'payment_gateways_options' ), )); // End payment_gateway settings } /** * Output the settings */ public function output() { global $current_section; // Load shipping methods so we can show any global options they may have $payment_gateways = WC()->payment_gateways->payment_gateways(); if ( $current_section ) { foreach ( $payment_gateways as $gateway ) { if ( strtolower( get_class( $gateway ) ) == strtolower( $current_section ) ) { $gateway->admin_options(); break; } } } else { $settings = $this->get_settings(); WC_Admin_Settings::output_fields( $settings ); } } /** * Output payment gateway settings. * * @access public * @return void */ public function payment_gateways_setting() { ?> __( 'Default', 'woocommerce' ), 'gateway' => __( 'Gateway', 'woocommerce' ), 'status' => __( 'Status', 'woocommerce' ) ) ); foreach ( $columns as $key => $column ) { echo ''; } ?> payment_gateways->payment_gateways() as $gateway ) { echo ''; foreach ( $columns as $key => $column ) { switch ( $key ) { case 'default' : echo ''; break; case 'gateway' : echo ''; break; case 'status' : echo ''; break; default : do_action( 'woocommerce_payment_gateways_setting_column_' . $key, $gateway ); break; } } echo ''; } ?>
' . esc_html( $column ) . '
id ), false ) . ' />

' . $gateway->get_title() . '
' . __( 'Gateway ID', 'woocommerce' ) . ': ' . esc_html( $gateway->id ) . '

'; if ( $gateway->enabled == 'yes' ) echo '' . __ ( 'Enabled', 'woocommerce' ) . ''; echo '
get_settings(); WC_Admin_Settings::save_fields( $settings ); WC()->payment_gateways->process_admin_options(); } elseif ( class_exists( $current_section ) ) { $current_section_class = new $current_section(); do_action( 'woocommerce_update_options_' . $this->id . '_' . $current_section_class->id ); WC()->payment_gateways()->init(); } } } endif; return new WC_Settings_Payment_Gateways();