WooCommerce Code Reference

WC_Settings_Emails extends WC_Settings_Page
in package

WC_Settings_Emails.

Table of Contents

TYPE_CHECKBOX  = 'checkbox'
TYPE_COLOR  = 'color'
TYPE_DATE  = 'date'
TYPE_DATETIME  = 'datetime'
TYPE_DATETIME_LOCAL  = 'datetime-local'
TYPE_EMAIL  = 'email'
TYPE_IMAGE_WIDTH  = 'image_width'
TYPE_INFO  = 'info'
TYPE_MONTH  = 'month'
TYPE_MULTI_SELECT_COUNTRIES  = 'multi_select_countries'
TYPE_MULTISELECT  = 'multiselect'
TYPE_NUMBER  = 'number'
TYPE_PASSWORD  = 'password'
TYPE_RADIO  = 'radio'
TYPE_RELATIVE_DATE_SELECTOR  = 'relative_date_selector'
TYPE_SECTIONEND  = 'sectionend'
TYPE_SELECT  = 'select'
TYPE_SINGLE_SELECT_COUNTRY  = 'single_select_country'
TYPE_SINGLE_SELECT_PAGE  = 'single_select_page'
TYPE_SINGLE_SELECT_PAGE_WITH_SEARCH  = 'single_select_page_with_search'
TYPE_SLOTFILL_PLACEHOLDER  = 'slotfill_placeholder'
TYPE_TEL  = 'tel'
TYPE_TEXT  = 'text'
TYPE_TEXTAREA  = 'textarea'
TYPE_TIME  = 'time'
TYPE_TITLE  = 'title'
Setting field types.
TYPE_URL  = 'url'
TYPE_WEEK  = 'week'
$icon  : string
Setting page icon.
$id  : string
Setting page id.
$label  : string
Setting page label.
__construct()  : mixed
Constructor.
add_settings_page()  : mixed
Add this page to settings.
add_settings_slot()  : mixed
Creates the React mount point for settings slot.
add_settings_ui_body_class()  : string
Add a body class for settings pages rendered through the settings UI.
append_feature_email_improvements_to_tracks()  : array<string|int, mixed>
Append email improvements prop to Tracks globally.
email_color_palette()  : mixed
Creates the React mount point for the email color palette title.
email_font_family()  : mixed
Creates the email font family field with custom font family applied to each option.
email_image_url()  : mixed
Creates the React mount point for the email image url.
email_improvements_button()  : void
Show a button to revert or enable email improvements.
email_notification_setting()  : mixed
Output email notification settings.
email_notification_setting_block_emails()  : mixed
Creates the React mount point for listing of block based emails.
email_preview()  : mixed
Creates the React mount point for the email preview.
email_preview_single()  : mixed
Creates the React mount point for the single email preview.
enable_email_improvements_when_trying_new_templates()  : mixed
When the email settings are saved, if the user is trying out the new email templates, enable the email improvements feature.
get_custom_fonts()  : mixed
Get custom fonts for emails.
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.
get_settings_ui_page()  : SettingsUIPageInterface|null
Get the settings UI page adapter for this settings page.
output()  : mixed
Output the settings.
output_sections()  : mixed
Output sections.
previewing_new_templates()  : void
Show a notice to the user when they are trying out the new email templates.
sanitize_email_header_image()  : string
Sanitize email image URL.
save()  : mixed
Save settings.
track_email_improvements_feature_change()  : mixed
Track email improvements feature change.
do_update_options_action()  : mixed
Trigger the 'woocommerce_update_options_'.id action.
get_own_sections()  : array<string|int, mixed>
Get own sections.
get_settings_for_default_section()  : array<string|int, mixed>
Get settings array.
get_settings_for_section_core()  : array<string|int, mixed>
Get the settings for a given section.
run_email_admin_options()  : mixed
Run the 'admin_options' method on a given email.
save_settings_for_current_section()  : mixed
Save settings for current section.
delete_transient_email_settings()  : mixed
Deletes transient with email settings used for live preview. This is to prevent conflicts where the preview would show values from previous session.
get_email_improvements_enabled()  : bool
Get "email improvements" feature status or force it when enabled via URL parameter.
is_trying_new_templates()  : bool
Check if the user is trying out the new email templates.
log_settings_ui_fallback()  : void
Log a developer-facing notice when settings UI rendering falls back to the legacy renderer.

Constants

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

add_settings_ui_body_class()

Add a body class for settings pages rendered through the settings UI.

public add_settings_ui_body_class(string $classes) : string
Parameters
$classes : string

The existing body classes for the admin area.

Tags
since
10.9.0
Return values
stringThe modified body classes for the admin area.

append_feature_email_improvements_to_tracks()

Append email improvements prop to Tracks globally.

public append_feature_email_improvements_to_tracks(array<string|int, mixed> $event_properties) : array<string|int, mixed>
Parameters
$event_properties : array<string|int, mixed>

Event properties array.

Return values
array<string|int, mixed>

email_color_palette()

Creates the React mount point for the email color palette title.

public email_color_palette(array<string|int, mixed> $value) : mixed
Parameters
$value : array<string|int, mixed>

Field value array.

Return values
mixed

email_font_family()

Creates the email font family field with custom font family applied to each option.

public email_font_family(array<string|int, mixed> $value) : mixed
Parameters
$value : array<string|int, mixed>

Field value array.

Return values
mixed

email_image_url()

Creates the React mount point for the email image url.

public email_image_url(array<string|int, mixed> $value) : mixed
Parameters
$value : array<string|int, mixed>

Field value array.

Return values
mixed

email_preview_single()

Creates the React mount point for the single email preview.

public email_preview_single(object $email) : mixed
Parameters
$email : object

The email object to run the method on.

Return values
mixed

enable_email_improvements_when_trying_new_templates()

When the email settings are saved, if the user is trying out the new email templates, enable the email improvements feature.

public enable_email_improvements_when_trying_new_templates() : mixed
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.

get_settings_ui_page()

Get the settings UI page adapter for this settings page.

public get_settings_ui_page() : SettingsUIPageInterface|null

Settings pages can override this to opt in to the settings UI renderer while retaining the classic WooCommerce settings page route and save flow.

Tags
since
10.9.0
Return values
SettingsUIPageInterface|null

sanitize_email_header_image()

Sanitize email image URL.

public sanitize_email_header_image(string $value, array<string|int, mixed> $option, string $raw_value) : string
Parameters
$value : string

Option value.

$option : array<string|int, mixed>

Option name.

$raw_value : string

Raw value.

Return values
string

track_email_improvements_feature_change()

Track email improvements feature change.

public track_email_improvements_feature_change(string $feature_id, bool $enabled) : mixed
Parameters
$feature_id : string

The feature ID.

$enabled : bool

True if the feature is enabled, false if it is disabled.

Return values
mixed

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_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.

run_email_admin_options()

Run the 'admin_options' method on a given email.

protected run_email_admin_options(object $email) : mixed

This method exists to easy unit testing.

Parameters
$email : object

The email object to run the method on.

Return values
mixed

delete_transient_email_settings()

Deletes transient with email settings used for live preview. This is to prevent conflicts where the preview would show values from previous session.

private delete_transient_email_settings() : mixed
Return values
mixed

get_email_improvements_enabled()

Get "email improvements" feature status or force it when enabled via URL parameter.

private get_email_improvements_enabled() : bool

Transient is used to force the email improvements feature in email preview, which is rendered in iframe.

Return values
bool

log_settings_ui_fallback()

Log a developer-facing notice when settings UI rendering falls back to the legacy renderer.

private log_settings_ui_fallback(SettingsUIPageInterface $settings_ui_page, string $section_id, string $reason) : void
Parameters
$settings_ui_page : SettingsUIPageInterface

Settings UI page adapter.

$section_id : string

Section id.

$reason : string

Fallback reason.

Tags
since
10.9.0
Return values
void