Class WC_Settings_API

Admin Settings API used by Shipping Methods and Payment Gateways

Direct known subclasses

WC_Email, WC_Integration, WC_Payment_Gateway, WC_Shipping_Method

Indirect known subclasses

WC_Email_Customer_Completed_Order, WC_Email_Customer_Invoice, WC_Shipping_Local_Delivery, WC_Shipping_Local_Pickup, WC_Email_Customer_New_Account, WC_Email_Customer_Note, WC_Email_Customer_Processing_Order, WC_Email_Customer_Reset_Password, WC_Email_New_Order, WC_Shipping_Flat_Rate, WC_Shipping_Free_Shipping, WC_Shipping_International_Delivery

Abstract
Package: WooCommerce\Abstracts
Category: Abstract Class
Author: WooThemes
Version: 2.1.0
Class: WC_Settings_API
Located at includes/abstracts/abstract-wc-settings-api.php

Methods summary

public
# admin_options( )

Admin Options

Admin Options

Setup the gateway settings screen. Override this in your gateway.

Since

1.0.0
public string
# init_form_fields( )

Initialise Settings Form Fields

Initialise Settings Form Fields

Add an array of fields to be displayed on the gateway's settings screen.

Returns

string

Since

1.0.0
public array
# get_form_fields( )

Get the form fields after they are initialized

Get the form fields after they are initialized

Returns

array
of options
public boolean
# process_admin_options( )

Admin Panel Options Processing

  • Saves the options to the DB

Admin Panel Options Processing

  • Saves the options to the DB

Returns

boolean

Since

1.0.0
public
# display_errors( )

Display admin error messages.

Display admin error messages.

Since

1.0.0
public
# init_settings( )

Initialise Gateway Settings

Initialise Gateway Settings

Store all settings in a single database entry and make sure the $settings array is either the default or the settings stored in the database.

Since

1.0.0

Uses

get_option(), add_option()
public string
# get_option( string $key, mixed $empty_value = null )

get_option function.

get_option function.

Gets and option from the settings API, using defaults if necessary to prevent undefined notices.

Parameters

$key
string
$key
$empty_value
mixed
$empty_value

Returns

string
The value specified for the option or a default value for the option
public array
# format_settings( mixed $value )

Decode values for settings.

Decode values for settings.

Parameters

$value
mixed
$value

Returns

array
public string
# generate_settings_html( boolean $form_fields = false )

Generate Settings HTML.

Generate Settings HTML.

Generate the HTML for the fields on the "settings" screen.

Parameters

$form_fields
boolean
$form_fields (default: false)

Returns

string
the html for the settings

Since

1.0.0

Uses

method_exists()
public string
# get_tooltip_html( array $data )

Get HTML for tooltips

Get HTML for tooltips

Parameters

$data
array
$data

Returns

string
public string
# get_description_html( array $data )

Get HTML for descriptions

Get HTML for descriptions

Parameters

$data
array
$data

Returns

string
public string
# get_custom_attribute_html( array $data )

Get custom attributes

Get custom attributes

Parameters

$data
array
$data

Returns

string
public string
# generate_text_html( mixed $key, mixed $data )

Generate Text Input HTML.

Generate Text Input HTML.

Parameters

$key
mixed
$key
$data
mixed
$data

Returns

string

Since

1.0.0
public string
# generate_price_html( mixed $key, mixed $data )

Generate Password Input HTML.

Generate Password Input HTML.

Parameters

$key
mixed
$key
$data
mixed
$data

Returns

string

Since

1.0.0
public string
# generate_decimal_html( mixed $key, mixed $data )

Generate Password Input HTML.

Generate Password Input HTML.

Parameters

$key
mixed
$key
$data
mixed
$data

Returns

string

Since

1.0.0
public string
# generate_password_html( mixed $key, mixed $data )

Generate Password Input HTML.

Generate Password Input HTML.

Parameters

$key
mixed
$key
$data
mixed
$data

Returns

string

Since

1.0.0
public string
# generate_textarea_html( mixed $key, mixed $data )

Generate Textarea HTML.

Generate Textarea HTML.

Parameters

$key
mixed
$key
$data
mixed
$data

Returns

string

Since

1.0.0
public string
# generate_checkbox_html( mixed $key, mixed $data )

Generate Checkbox HTML.

Generate Checkbox HTML.

Parameters

$key
mixed
$key
$data
mixed
$data

Returns

string

Since

1.0.0
public string
# generate_select_html( mixed $key, mixed $data )

Generate Select HTML.

Generate Select HTML.

Parameters

$key
mixed
$key
$data
mixed
$data

Returns

string

Since

1.0.0
public string
# generate_multiselect_html( mixed $key, mixed $data )

Generate Multiselect HTML.

Generate Multiselect HTML.

Parameters

$key
mixed
$key
$data
mixed
$data

Returns

string

Since

1.0.0
public string
# generate_title_html( mixed $key, mixed $data )

Generate Title HTML.

Generate Title HTML.

Parameters

$key
mixed
$key
$data
mixed
$data

Returns

string

Since

1.6.2
public
# validate_settings_fields( boolean $form_fields = false )

Validate Settings Field Data.

Validate Settings Field Data.

Validate the data on the "Settings" form.

Parameters

$form_fields
boolean
$form_fields (default: false)

Since

1.0.0

Uses

method_exists()
public string
# validate_checkbox_field( mixed $key )

Validate Checkbox Field.

Validate Checkbox Field.

If not set, return "no", otherwise return "yes".

Parameters

$key
mixed
$key

Returns

string

Since

1.0.0
public string
# validate_text_field( mixed $key )

Validate Text Field.

Validate Text Field.

Parameters

$key
mixed
$key

Returns

string
public string
# validate_price_field( mixed $key )

Validate Price Field.

Validate Price Field.

Parameters

$key
mixed
$key

Returns

string
public string
# validate_decimal_field( mixed $key )

Validate Price Field.

Validate Price Field.

Parameters

$key
mixed
$key

Returns

string
public string
# validate_password_field( mixed $key )

Validate Password Field.

Validate Password Field.

Make sure the data is escaped correctly, etc.

Parameters

$key
mixed
$key

Returns

string

Since

1.0.0
public string
# validate_textarea_field( mixed $key )

Validate Textarea Field.

Validate Textarea Field.

Make sure the data is escaped correctly, etc.

Parameters

$key
mixed
$key

Returns

string

Since

1.0.0
public string
# validate_select_field( mixed $key )

Validate Select Field.

Validate Select Field.

Make sure the data is escaped correctly, etc.

Parameters

$key
mixed
$key

Returns

string

Since

1.0.0
public string
# validate_multiselect_field( mixed $key )

Validate Multiselect Field.

Validate Multiselect Field.

Make sure the data is escaped correctly, etc.

Parameters

$key
mixed
$key

Returns

string

Since

1.0.0

Magic methods summary

Properties summary

public string $plugin_id
#

The plugin ID. Used for option names.

The plugin ID. Used for option names.

public array $settings
#

Array of setting values.

Array of setting values.

public array $form_fields
#

Array of form option fields.

Array of form option fields.

public array $errors
#

Array of validation errors.

Array of validation errors.

public array $sanitized_fields
#

Sanitized fields after validation.

Sanitized fields after validation.

WooCommerce API documentation generated by ApiGen 2.8.0