id = 'checkout'; // @todo In future versions this may make more sense as 'payment' however to avoid breakage lets leave this alone until we refactor settings APIs in general. $this->label = _x( 'Payments', 'Settings tab label', 'woocommerce' ); add_action( 'woocommerce_admin_field_payment_gateways', array( $this, 'payment_gateways_setting' ) ); parent::__construct(); } /** * Get sections. * * @return array */ public function get_sections() { $sections = array( '' => __( 'Payment methods', 'woocommerce' ), ); return apply_filters( 'woocommerce_get_sections_' . $this->id, $sections ); } /** * Get settings array. * * @param string $current_section Section being shown. * @return array */ public function get_settings( $current_section = '' ) { $settings = array(); if ( '' === $current_section ) { $settings = apply_filters( 'woocommerce_payment_gateways_settings', array( array( 'title' => __( 'Payment methods', 'woocommerce' ), 'desc' => __( 'Installed payment methods are listed below and can be sorted to control their display order on the frontend.', 'woocommerce' ), 'type' => 'title', 'id' => 'payment_gateways_options', ), array( 'type' => 'payment_gateways', ), array( 'type' => 'sectionend', 'id' => 'payment_gateways_options', ), ) ); } return apply_filters( 'woocommerce_get_settings_' . $this->id, $settings, $current_section ); } /** * Output the settings. */ public function output() { global $current_section; // Load gateways 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 ( in_array( $current_section, array( $gateway->id, sanitize_title( get_class( $gateway ) ) ), true ) ) { if ( isset( $_GET['toggle_enabled'] ) ) { // WPCS: input var ok, CSRF ok. $enabled = $gateway->get_option( 'enabled' ); if ( $enabled ) { $gateway->settings['enabled'] = wc_string_to_bool( $enabled ) ? 'no' : 'yes'; } } $gateway->admin_options(); break; } } } $settings = $this->get_settings( $current_section ); WC_Admin_Settings::output_fields( $settings ); } /** * Output payment gateway settings. */ public function payment_gateways_setting() { ?>
' . esc_html( $column ) . ' | '; } ?>
---|
';
switch ( $key ) {
case 'sort':
?>
| ';
}
echo '