WooCommerce Code Reference

Init
in package

Contains backend logic for the Settings feature.

Table of Contents

$instance  : Init
Class instance.
__construct()  : mixed
Hook into WooCommerce.
add_component_settings()  : array<string|int, mixed>
Add the necessary data to initially load the WooCommerce Settings pages.
enqueue_settings_editor_scripts()  : mixed
Enqueue scripts for the settings editor.
enqueue_settings_editor_styles()  : mixed
Enqueue styles for the settings editor.
get_instance()  : mixed
Get class instance.
get_page_data()  : array<string|int, mixed>
Get the page data for the settings editor.
is_settings_page()  : bool
Check if the current screen is the WooCommerce settings page.
get_script_urls()  : array<string|int, mixed>
Retrieve the script URLs from the provided script handles.

Properties

Methods

add_component_settings()

Add the necessary data to initially load the WooCommerce Settings pages.

public static add_component_settings(array<string|int, mixed> $settings) : array<string|int, mixed>
Parameters
$settings : array<string|int, mixed>

Array of component settings.

Return values
array<string|int, mixed>Array of component settings.

enqueue_settings_editor_scripts()

Enqueue scripts for the settings editor.

public enqueue_settings_editor_scripts() : mixed
Return values
mixed

enqueue_settings_editor_styles()

Enqueue styles for the settings editor.

public enqueue_settings_editor_styles() : mixed
Return values
mixed

get_page_data()

Get the page data for the settings editor.

public static get_page_data(array<string|int, mixed> $settings, array<string|int, mixed> $setting_pages) : array<string|int, mixed>
Parameters
$settings : array<string|int, mixed>

The settings array.

$setting_pages : array<string|int, mixed>

The setting pages.

Return values
array<string|int, mixed>The settings array.

is_settings_page()

Check if the current screen is the WooCommerce settings page.

public is_settings_page() : bool
Return values
bool

get_script_urls()

Retrieve the script URLs from the provided script handles.

private static get_script_urls(array<string|int, mixed> $script_handles) : array<string|int, mixed>

This will also filter out scripts from WordPress core since they only need to be loaded once.

Parameters
$script_handles : array<string|int, mixed>

Array of script handles.

Return values
array<string|int, mixed>Array of script URLs.