| @@ 256-274 (lines=19) @@ | ||
| 253 | /** |
|
| 254 | * Output the settings. |
|
| 255 | */ |
|
| 256 | public function output() { |
|
| 257 | global $current_section; |
|
| 258 | ||
| 259 | // Load shipping methods so we can show any global options they may have. |
|
| 260 | $payment_gateways = WC()->payment_gateways->payment_gateways(); |
|
| 261 | ||
| 262 | if ( $current_section ) { |
|
| 263 | foreach ( $payment_gateways as $gateway ) { |
|
| 264 | if ( in_array( $current_section, array( $gateway->id, sanitize_title( get_class( $gateway ) ) ) ) ) { |
|
| 265 | $gateway->admin_options(); |
|
| 266 | break; |
|
| 267 | } |
|
| 268 | } |
|
| 269 | } else { |
|
| 270 | $settings = $this->get_settings(); |
|
| 271 | ||
| 272 | WC_Admin_Settings::output_fields( $settings ); |
|
| 273 | } |
|
| 274 | } |
|
| 275 | ||
| 276 | /** |
|
| 277 | * Output payment gateway settings. |
|
| @@ 358-375 (lines=18) @@ | ||
| 355 | /** |
|
| 356 | * Save settings. |
|
| 357 | */ |
|
| 358 | public function save() { |
|
| 359 | global $current_section; |
|
| 360 | ||
| 361 | $wc_payment_gateways = WC_Payment_Gateways::instance(); |
|
| 362 | ||
| 363 | if ( ! $current_section ) { |
|
| 364 | WC_Admin_Settings::save_fields( $this->get_settings() ); |
|
| 365 | $wc_payment_gateways->process_admin_options(); |
|
| 366 | ||
| 367 | } else { |
|
| 368 | foreach ( $wc_payment_gateways->payment_gateways() as $gateway ) { |
|
| 369 | if ( in_array( $current_section, array( $gateway->id, sanitize_title( get_class( $gateway ) ) ) ) ) { |
|
| 370 | do_action( 'woocommerce_update_options_payment_gateways_' . $gateway->id ); |
|
| 371 | $wc_payment_gateways->init(); |
|
| 372 | } |
|
| 373 | } |
|
| 374 | } |
|
| 375 | } |
|
| 376 | } |
|
| 377 | ||
| 378 | endif; |
|