WooCommerce Code Reference

WC_Settings_General extends WC_Settings_Page
in package

WC_Admin_Settings_General.

Table of Contents

$id  : string
Setting page id.
$label  : string
Setting page label.
__construct()  : mixed
Constructor.
add_settings_page()  : mixed
Add this page to settings.
color_picker()  : mixed
Output a color picker input box.
get_id()  : string
Get settings page ID.
get_label()  : string
Get settings page label.
get_sections()  : array<string|int, mixed>
Get all sections for this page, both the own ones and the ones defined via filters.
get_settings()  : array<string|int, mixed>
Get settings array for the default section.
get_settings_for_section()  : array<string|int, mixed>
Get settings array.
output()  : mixed
Output the HTML for the settings.
output_sections()  : mixed
Output sections.
save()  : mixed
Save settings and trigger the 'woocommerce_update_options_'.id action.
do_update_options_action()  : mixed
Trigger the 'woocommerce_update_options_'.id action.
get_own_sections()  : array<string|int, mixed>
Get own sections for this page.
get_settings_for_default_section()  : array<string|int, mixed>
Get settings or the default section.
get_settings_for_section_core()  : array<string|int, mixed>
Get the settings for a given section.
save_settings_for_current_section()  : mixed
Save settings for current section.

Properties

Methods

add_settings_page()

Add this page to settings.

public add_settings_page(array<string|int, mixed> $pages) : mixed
Parameters
$pages : array<string|int, mixed>

The settings array where we'll add ourselves.

Return values
mixed

color_picker()

Output a color picker input box.

public color_picker(mixed $name, string $id, mixed $value[, string $desc = '' ]) : mixed
Parameters
$name : mixed

Name of input.

$id : string

ID of input.

$value : mixed

Value of input.

$desc : string = ''

(default: '') Description for input.

Return values
mixed

get_settings()

Get settings array for the default section.

public get_settings() : array<string|int, mixed>

External settings classes (registered via 'woocommerce_get_settings_pages' filter) might have redefined this method as "get_settings($section_id='')", thus we need to use this method internally instead of 'get_settings_for_section' to register settings and render settings pages.

But we can't just redefine the method as "get_settings($section_id='')" here, since this will break on PHP 8 if any external setting class have it as 'get_settings()'.

Thus we leave the method signature as is and use 'func_get_arg' to get the setting id if it's supplied, and we use this method internally; but it's deprecated and should otherwise never be used.

Tags
deprecated
5.4.0

Use 'get_settings_for_section' (passing an empty string for default section)

Return values
array<string|int, mixed>Settings array, each item being an associative array representing a setting.

get_settings_for_section()

Get settings array.

public final get_settings_for_section(string $section_id) : array<string|int, mixed>

The strategy for getting the settings is as follows:

  • If a method named 'get_settings_for_{section_id}_section' exists in the class it will be invoked (for the default '' section, the method name is 'get_settings_for_default_section'). Derived classes can implement these methods as required.

  • Otherwise, 'get_settings_for_section_core' will be invoked. Derived classes can override it as an alternative to implementing 'get_settings_for_{section_id}_section' methods.

Parameters
$section_id : string

The id of the section to return settings for, an empty string for the default section.

Return values
array<string|int, mixed>Settings array, each item being an associative array representing a setting.

do_update_options_action()

Trigger the 'woocommerce_update_options_'.id action.

protected do_update_options_action([string $section_id = null ]) : mixed
Parameters
$section_id : string = null

Section to trigger the action for, or null for current section.

Return values
mixed

get_own_sections()

Get own sections for this page.

protected get_own_sections() : array<string|int, mixed>

Derived classes should override this method if they define sections. There should always be one default section with an empty string as identifier.

Example: return array( '' => __( 'General', 'woocommerce' ), 'foobars' => __( 'Foos & Bars', 'woocommerce' ), );

Return values
array<string|int, mixed>An associative array where keys are section identifiers and the values are translated section names.

get_settings_for_section_core()

Get the settings for a given section.

protected get_settings_for_section_core(string $section_id) : array<string|int, mixed>

This method is invoked from 'get_settings_for_section' when no 'get_settings_for_{current_section}_section' method exists in the class.

When overriding, note that the 'woocommerce_get_settings_' filter must NOT be triggered, as this is already done by 'get_settings_for_section'.

Parameters
$section_id : string

The section name to get the settings for.

Return values
array<string|int, mixed>Settings array, each item being an associative array representing a setting.