PHP 클래스 WC_Settings_API

파일 보기 프로젝트 열기: woocommerce/woocommerce 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$errors Validation errors.
$form_fields array Form option fields.
$id string ID of the class extending the settings API. Used in option names.
$plugin_id string The plugin ID. Used for option names.
$settings array Setting values.

보호된 프로퍼티들

프로퍼티 타입 설명
$data array The posted settings data. When empty, $_POST data will be used.

공개 메소드들

메소드 설명
add_error ( string $error ) Add an error message for display in admin on save.
admin_options ( ) Output the admin options table.
display_errors ( ) Display admin error messages.
format_settings ( array $value ) : array Format settings if needed.
generate_checkbox_html ( mixed $key, mixed $data ) : string Generate Checkbox HTML.
generate_color_html ( mixed $key, mixed $data ) : string Generate Color Picker Input HTML.
generate_decimal_html ( mixed $key, mixed $data ) : string Generate Decimal Input HTML.
generate_multiselect_html ( mixed $key, mixed $data ) : string Generate Multiselect HTML.
generate_password_html ( mixed $key, mixed $data ) : string Generate Password Input HTML.
generate_price_html ( mixed $key, mixed $data ) : string Generate Price Input HTML.
generate_select_html ( mixed $key, mixed $data ) : string Generate Select HTML.
generate_settings_html ( array $form_fields = [], $echo = true ) : string Generate Settings HTML.
generate_text_html ( mixed $key, mixed $data ) : string Generate Text Input HTML.
generate_textarea_html ( mixed $key, mixed $data ) : string Generate Textarea HTML.
generate_title_html ( mixed $key, mixed $data ) : string Generate Title HTML.
get_custom_attribute_html ( array $data ) : string Get custom attributes.
get_description_html ( array $data ) : string Get HTML for descriptions.
get_errors ( ) Get admin error messages.
get_field_default ( array $field ) : string Get a fields default value. Defaults to "" if not set.
get_field_key ( mixed $key ) : string Prefix key for settings.
get_field_type ( array $field ) : string Get a fields type. Defaults to "text" if not set.
get_field_value ( string $key, array $field, array $post_data = [] ) : string Get a field's posted and validated value.
get_form_fields ( ) : array Get the form fields after they are initialized.
get_option ( string $key, mixed $empty_value = null ) : string get_option function.
get_option_key ( ) : string Return the name of the option in the WP DB.
get_post_data ( ) : array Returns the POSTed data, to be used to save the settings.
get_tooltip_html ( array $data ) : string Get HTML for tooltips.
init_form_fields ( ) : string Initialise settings form fields.
init_settings ( ) Initialise Settings.
process_admin_options ( ) : boolean Processes and saves options.
set_post_data ( $data = [] ) Sets the POSTed data. This method can be used to set specific data, instead of taking it from the $_POST array.
validate_checkbox_field ( string $key, string | null $value ) : string Validate Checkbox Field.
validate_decimal_field ( string $key, string | null $value ) : string Validate Decimal Field.
validate_multiselect_field ( string $key, string $value ) : string Validate Multiselect Field.
validate_password_field ( string $key, string | null $value ) : string Validate Password Field. No input sanitization is used to avoid corrupting passwords.
validate_price_field ( string $key, string | null $value ) : string Validate Price Field.
validate_select_field ( string $key, string $value ) : string Validate Select Field.
validate_settings_fields ( $form_fields = [] ) Validate the data on the "Settings" form.
validate_text_field ( string $key, string | null $value ) : string Validate Text Field.
validate_textarea_field ( string $key, string | null $value ) : string Validate Textarea Field.

보호된 메소드들

메소드 설명
set_defaults ( $field ) Set default required properties for each field.

메소드 상세

add_error() 공개 메소드

Add an error message for display in admin on save.
public add_error ( string $error )
$error string

admin_options() 공개 메소드

Output the admin options table.
public admin_options ( )

display_errors() 공개 메소드

Display admin error messages.
public display_errors ( )

format_settings() 공개 메소드

Format settings if needed.
사용 중단: 2.6.0 Unused
public format_settings ( array $value ) : array
$value array
리턴 array

generate_checkbox_html() 공개 메소드

Generate Checkbox HTML.
부터: 1.0.0
public generate_checkbox_html ( mixed $key, mixed $data ) : string
$key mixed
$data mixed
리턴 string

generate_color_html() 공개 메소드

Generate Color Picker Input HTML.
부터: 1.0.0
public generate_color_html ( mixed $key, mixed $data ) : string
$key mixed
$data mixed
리턴 string

generate_decimal_html() 공개 메소드

Generate Decimal Input HTML.
부터: 1.0.0
public generate_decimal_html ( mixed $key, mixed $data ) : string
$key mixed
$data mixed
리턴 string

generate_multiselect_html() 공개 메소드

Generate Multiselect HTML.
부터: 1.0.0
public generate_multiselect_html ( mixed $key, mixed $data ) : string
$key mixed
$data mixed
리턴 string

generate_password_html() 공개 메소드

Generate Password Input HTML.
부터: 1.0.0
public generate_password_html ( mixed $key, mixed $data ) : string
$key mixed
$data mixed
리턴 string

generate_price_html() 공개 메소드

Generate Price Input HTML.
부터: 1.0.0
public generate_price_html ( mixed $key, mixed $data ) : string
$key mixed
$data mixed
리턴 string

generate_select_html() 공개 메소드

Generate Select HTML.
부터: 1.0.0
public generate_select_html ( mixed $key, mixed $data ) : string
$key mixed
$data mixed
리턴 string

generate_settings_html() 공개 메소드

Generate the HTML for the fields on the "settings" screen.
부터: 1.0.0
public generate_settings_html ( array $form_fields = [], $echo = true ) : string
$form_fields array (default: array())
리턴 string the html for the settings

generate_text_html() 공개 메소드

Generate Text Input HTML.
부터: 1.0.0
public generate_text_html ( mixed $key, mixed $data ) : string
$key mixed
$data mixed
리턴 string

generate_textarea_html() 공개 메소드

Generate Textarea HTML.
부터: 1.0.0
public generate_textarea_html ( mixed $key, mixed $data ) : string
$key mixed
$data mixed
리턴 string

generate_title_html() 공개 메소드

Generate Title HTML.
부터: 1.0.0
public generate_title_html ( mixed $key, mixed $data ) : string
$key mixed
$data mixed
리턴 string

get_custom_attribute_html() 공개 메소드

Get custom attributes.
public get_custom_attribute_html ( array $data ) : string
$data array
리턴 string

get_description_html() 공개 메소드

Get HTML for descriptions.
public get_description_html ( array $data ) : string
$data array
리턴 string

get_errors() 공개 메소드

Get admin error messages.
public get_errors ( )

get_field_default() 공개 메소드

Get a fields default value. Defaults to "" if not set.
public get_field_default ( array $field ) : string
$field array
리턴 string

get_field_key() 공개 메소드

Prefix key for settings.
public get_field_key ( mixed $key ) : string
$key mixed
리턴 string

get_field_type() 공개 메소드

Get a fields type. Defaults to "text" if not set.
public get_field_type ( array $field ) : string
$field array
리턴 string

get_field_value() 공개 메소드

Get a field's posted and validated value.
public get_field_value ( string $key, array $field, array $post_data = [] ) : string
$key string
$field array
$post_data array
리턴 string

get_form_fields() 공개 메소드

Get the form fields after they are initialized.
public get_form_fields ( ) : array
리턴 array of options

get_option() 공개 메소드

Gets an option from the settings API, using defaults if necessary to prevent undefined notices.
public get_option ( string $key, mixed $empty_value = null ) : string
$key string
$empty_value mixed
리턴 string The value specified for the option or a default value for the option.

get_option_key() 공개 메소드

Return the name of the option in the WP DB.
부터: 2.6.0
public get_option_key ( ) : string
리턴 string

get_post_data() 공개 메소드

Returns the POSTed data, to be used to save the settings.
public get_post_data ( ) : array
리턴 array

get_tooltip_html() 공개 메소드

Get HTML for tooltips.
public get_tooltip_html ( array $data ) : string
$data array
리턴 string

init_form_fields() 공개 메소드

Add an array of fields to be displayed on the gateway's settings screen.
부터: 1.0.0
public init_form_fields ( ) : string
리턴 string

init_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.
부터: 1.0.0
public init_settings ( )

process_admin_options() 공개 메소드

If there is an error thrown, will continue to save and validate fields, but will leave the erroring field out.
public process_admin_options ( ) : boolean
리턴 boolean was anything saved?

set_defaults() 보호된 메소드

Set default required properties for each field.
protected set_defaults ( $field )

set_post_data() 공개 메소드

Sets the POSTed data. This method can be used to set specific data, instead of taking it from the $_POST array.
public set_post_data ( $data = [] )

validate_checkbox_field() 공개 메소드

If not set, return "no", otherwise return "yes".
public validate_checkbox_field ( string $key, string | null $value ) : string
$key string
$value string | null Posted Value
리턴 string

validate_decimal_field() 공개 메소드

Make sure the data is escaped correctly, etc.
public validate_decimal_field ( string $key, string | null $value ) : string
$key string
$value string | null Posted Value
리턴 string

validate_multiselect_field() 공개 메소드

Validate Multiselect Field.
public validate_multiselect_field ( string $key, string $value ) : string
$key string
$value string Posted Value
리턴 string

validate_password_field() 공개 메소드

Validate Password Field. No input sanitization is used to avoid corrupting passwords.
public validate_password_field ( string $key, string | null $value ) : string
$key string
$value string | null Posted Value
리턴 string

validate_price_field() 공개 메소드

Make sure the data is escaped correctly, etc.
public validate_price_field ( string $key, string | null $value ) : string
$key string
$value string | null Posted Value
리턴 string

validate_select_field() 공개 메소드

Validate Select Field.
public validate_select_field ( string $key, string $value ) : string
$key string
$value string Posted Value
리턴 string

validate_settings_fields() 공개 메소드

Validate the data on the "Settings" form.
사용 중단: 2.6.0 No longer used
public validate_settings_fields ( $form_fields = [] )

validate_text_field() 공개 메소드

Make sure the data is escaped correctly, etc.
public validate_text_field ( string $key, string | null $value ) : string
$key string Field key
$value string | null Posted Value
리턴 string

validate_textarea_field() 공개 메소드

Validate Textarea Field.
public validate_textarea_field ( string $key, string | null $value ) : string
$key string
$value string | null Posted Value
리턴 string

프로퍼티 상세

$data 보호되어 있는 프로퍼티

The posted settings data. When empty, $_POST data will be used.
protected array $data
리턴 array

$errors 공개적으로 프로퍼티

Validation errors.
public $errors

$form_fields 공개적으로 프로퍼티

Form option fields.
public array $form_fields
리턴 array

$id 공개적으로 프로퍼티

ID of the class extending the settings API. Used in option names.
public string $id
리턴 string

$plugin_id 공개적으로 프로퍼티

The plugin ID. Used for option names.
public string $plugin_id
리턴 string

$settings 공개적으로 프로퍼티

Setting values.
public array $settings
리턴 array