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 ) ) == $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() { ?>
' . esc_html( $column ) . ' | '; } ?>||
---|---|---|
id ), false ) . ' /> | '; break; case 'gateway' : echo '
' . $gateway->get_title() . ' | ';
break;
case 'status' :
echo ''; if ( $gateway->enabled == 'yes' ) echo '' . __ ( 'Enabled', 'woocommerce' ) . ''; echo ' | '; break; default : do_action( 'woocommerce_payment_gateways_setting_column_' . $key, $gateway ); break; } } echo '