WC_REST_Payment_Gateways_V2_Controller::get_settings() public WC 1.0
Return settings associated with this payment gateway.
{} It's a method of the class: WC_REST_Payment_Gateways_V2_Controller{}
No Hooks.
Return
Array.
Usage
$WC_REST_Payment_Gateways_V2_Controller = new WC_REST_Payment_Gateways_V2_Controller(); $WC_REST_Payment_Gateways_V2_Controller->get_settings( $gateway );
- $gateway(WC_Payment_Gateway) (required)
- Gateway data.
Code of WC_REST_Payment_Gateways_V2_Controller::get_settings() WC REST Payment Gateways V2 Controller::get settings WC 5.0.0
public function get_settings( $gateway ) {
$settings = array();
$gateway->init_form_fields();
foreach ( $gateway->form_fields as $id => $field ) {
// Make sure we at least have a title and type.
if ( empty( $field['title'] ) || empty( $field['type'] ) ) {
continue;
}
// Ignore 'title' settings/fields -- they are UI only.
if ( 'title' === $field['type'] ) {
continue;
}
// Ignore 'enabled' and 'description' which get included elsewhere.
if ( in_array( $id, array( 'enabled', 'description' ), true ) ) {
continue;
}
$data = array(
'id' => $id,
'label' => empty( $field['label'] ) ? $field['title'] : $field['label'],
'description' => empty( $field['description'] ) ? '' : $field['description'],
'type' => $field['type'],
'value' => empty( $gateway->settings[ $id ] ) ? '' : $gateway->settings[ $id ],
'default' => empty( $field['default'] ) ? '' : $field['default'],
'tip' => empty( $field['description'] ) ? '' : $field['description'],
'placeholder' => empty( $field['placeholder'] ) ? '' : $field['placeholder'],
);
if ( ! empty( $field['options'] ) ) {
$data['options'] = $field['options'];
}
$settings[ $id ] = $data;
}
return $settings;
}