Documentation

SettingsPage extends Engine
in package

Class to initialise all defined page layouts.

Tags
since
1.5.0
since
2.8.0

Rename class from Settings to SettingsPage.

see
Engine

Table of Contents

$plugin_name  : string
The ID of this plugin.
$sections  : array<string|int, mixed>
Stores all Sections for the child sub-page.
$settings  : Settings
The plugin settings object.
$sub_page_hook  : string|null
Stores the Hook connection string for the child sub-page.
__construct()  : mixed
Initialize the class and set its properties.
add_settings_fields()  : void
add_settings_sections()  : void
Registers all sections for a sub-page.
description()  : void
Output the description of a section. May be overwritten in any section.
display_content()  : void
Displays the content of specific sub-page.
donate()  : void
Displays all Donate button to support the developers.
get_priority()  : int
Returns a priority index.
help()  : void
Displays a short introduction to the plugin.
register_sub_page()  : void
Registers a sub-page.
setting_field_callback()  : void
add_input_checkbox()  : void
Constructs the HTML for a checkbox 'input' element.
add_input_color()  : void
Constructs the HTML for a color 'input' element.
add_input_number()  : void
Constructs the HTML for a numeric 'input' element.
add_input_text()  : void
Constructs the HTML for a text 'input' element.
add_label()  : string
Returns the HTML tag for a 'label' element.
add_meta_box()  : array<string|int, mixed>
Returns an array describing a meta box.
add_section()  : array<string|int, mixed>
Returns an array describing a sub-page section.
add_select()  : void
Constructs the HTML for a 'select' element.
add_text()  : string
Returns a simple text inside a 'span' element.
add_textarea()  : void
Constructs the HTML for a 'textarea' element.
get_meta_boxes()  : array<string|int, array<string|int, mixed>>
Returns an array of all registered meta boxes for each section of the sub-page.
get_sections()  : array<string|int, array<string|int, mixed>>
Returns an array of all registered sections for the sub-page.
get_sub_page_slug()  : string
Returns the unique slug of the sub-page.
get_sub_page_title()  : string
Returns the title of the sub-page.
load_setting()  : array<string|int, mixed>
Loads a specified setting.
append_scripts()  : void
Append JavaScript and CSS files for specific sub-page.
register_meta_boxes()  : void
Registers all Meta boxes for a sub-page.
save_settings()  : bool
Save plugin settings.

Properties

$plugin_name

The ID of this plugin.

protected string $plugin_name

The ID of this plugin.

Tags
access

private

since
2.8.0

$sections

Stores all Sections for the child sub-page.

protected array<string|int, mixed> $sections = array()
Tags
access

protected

since
1.5.0

$sub_page_hook

Stores the Hook connection string for the child sub-page.

protected string|null $sub_page_hook = null
Tags
access

protected

since
1.5.0

Methods

__construct()

Initialize the class and set its properties.

public __construct(string $plugin_name, Settings $settings) : mixed
Parameters
$plugin_name : string
$settings : Settings
Tags
since
2.8.0
Return values
mixed

add_settings_sections()

Registers all sections for a sub-page.

public add_settings_sections() : void
Tags
since
1.5.0
Return values
void

description()

Output the description of a section. May be overwritten in any section.

public description() : void
Tags
since
1.5.0
todo

Required? Should be abstract?

Return values
void

display_content()

Displays the content of specific sub-page.

public display_content() : void
Tags
since
1.5.0
todo

Review nonce verification.

Return values
void

donate()

Displays all Donate button to support the developers.

public donate() : void
Tags
since
1.5.0
Return values
void

get_priority()

Returns a priority index.

public get_priority() : int

Lower numbers have a higher priority.

Tags
since
1.5.0
Return values
int

help()

Displays a short introduction to the plugin.

public help() : void
Tags
since
1.5.0
todo

Review in light of admin/public split.

Return values
void

register_sub_page()

Registers a sub-page.

public register_sub_page() : void
Tags
since
1.5.0
Return values
void

setting_field_callback()

public setting_field_callback(array<string|int, mixed> $args) : void
Parameters
$args : array<string|int, mixed>
Return values
void

add_input_checkbox()

Constructs the HTML for a checkbox 'input' element.

protected add_input_checkbox(array<string|int, mixed> $args) : void
Parameters
$args : array<string|int, mixed>

Input arguments. @see {Setting::get_setting_field_args()}.

Tags
access

protected

since
1.5.0
since
2.8.0

Rename function from 'add_checkbox' to 'add_input_checkbox'. Replace 'p_str_setting_name' argument with 'args' array.

Return values
void

add_input_color()

Constructs the HTML for a color 'input' element.

protected add_input_color(array<string|int, mixed> $args) : void
Parameters
$args : array<string|int, mixed>

Input arguments. @see {Setting::get_setting_field_args()}.

Tags
access

protected

since
1.5.6
since
2.8.0

Rename function from 'add_color_selection' to 'add_input_color'. Replace 'p_str_setting_name' argument with 'args' array.

Return values
void

add_input_number()

Constructs the HTML for a numeric 'input' element.

protected add_input_number(array<string|int, mixed> $args) : void
Parameters
$args : array<string|int, mixed>

Input arguments. @see {Setting::get_setting_field_args()}.

Tags
access

protected

since
1.5.0
since
2.1.4

Add step argument and 'number_format()' to allow decimals

since
2.8.0

Rename function from 'add_num_box' to 'add_input_number'. Replace multiple arguments with single 'args' array.

Return values
void

add_input_text()

Constructs the HTML for a text 'input' element.

protected add_input_text(array<string|int, mixed> $args) : void
Parameters
$args : array<string|int, mixed>

Input arguments. @see {Setting::get_setting_field_args()}.

Tags
access

protected

since
1.5.0
since
2.8.0

Rename function from 'add_text_box' to 'add_input_text'. Replace multiple arguments with single 'args' array.

Return values
void

add_label()

Returns the HTML tag for a 'label' element.

protected add_label(string $setting_name, string $caption) : string
Parameters
$setting_name : string

Settings key.

$caption : string

Label caption.

Tags
access

protected

since
1.5.0
todo

Refactor HTML generation.

Return values
string

add_meta_box()

Returns an array describing a meta box.

protected add_meta_box(string $section_id, string $id, string $title, string $callback_function_name) : array<string|int, mixed>
Parameters
$section_id : string

Parent section ID.

$id : string

Unique ID suffix.

$title : string

Title for the meta box.

$callback_function_name : string

Class method name for callback.

Tags
access

protected

since
1.5.0
todo

Refactor meta boxes into their own class?

todo

Pass actual functions rather than strings?

Return values
array<string|int, mixed>

{ A dashboard meta box.

@type  string  $parent  Parent section ID.
@type  string  $id  Meta box ID.
@type  string  $title  Meta box title.
@type  string  $callback  Meta box callback function.

}

add_section()

Returns an array describing a sub-page section.

protected add_section(string $id, string $title, int $settings_container_index[, bool $has_submit_button = true ]) : array<string|int, mixed>
Parameters
$id : string

Unique ID suffix.

$title : string

Title of the section.

$settings_container_index : int

Settings Container index.

$has_submit_button : bool = true

Whether a ‘Submit’ button should be displayed for this section. Default true.

Tags
access

protected

since
1.5.0
todo

Refactor sections into their own class?

Return values
array<string|int, mixed>

{ A dashboard section.

@type  string  $id  Section ID.
@type  string  $title  Section title.
@type  bool  $submit  Whether the section has a submit button or not.
@type  int  $container  Settings Container index.

}

add_select()

Constructs the HTML for a 'select' element.

protected add_select(array<string|int, mixed> $args) : void
Parameters
$args : array<string|int, mixed>

Input arguments. @see {Setting::get_setting_field_args()}.

Tags
access

protected

since
1.5.0
since
2.8.0

Rename function from 'add_select_box' to 'add_select'. Replace multiple arguments with single 'args' array.

Return values
void

add_text()

Returns a simple text inside a 'span' element.

protected add_text(string $text) : string
Parameters
$text : string

Message to be surrounded with <span> tags.

Tags
access

protected

since
1.5.0
todo

Refactor HTML generation.

Return values
string

add_textarea()

Constructs the HTML for a 'textarea' element.

protected add_textarea(array<string|int, mixed> $args) : void
Parameters
$args : array<string|int, mixed>

Input arguments. @see {Setting::get_setting_field_args()}.

Tags
access

protected

since
1.5.0
since
2.8.0

Replace 'p_str_setting_name' argument with 'args' array.

Return values
void

get_meta_boxes()

Returns an array of all registered meta boxes for each section of the sub-page.

protected get_meta_boxes() : array<string|int, array<string|int, mixed>>
Tags
see
Engine::add_meta_box()

For more information on the meta box array format.

since
1.5.0
since
2.2.0

Re-order and rename tabs.

Return values
array<string|int, array<string|int, mixed>>

All of the registered meta boxes.

get_sections()

Returns an array of all registered sections for the sub-page.

protected get_sections() : array<string|int, array<string|int, mixed>>
Tags
see
Engine::add_section()

For more information on the section array format.

since
1.5.0
since
2.1.6

Remove conditional rendering of ‘Expert’ tab.

Return values
array<string|int, array<string|int, mixed>>

All of the registered sections.

get_sub_page_slug()

Returns the unique slug of the sub-page.

protected get_sub_page_slug() : string
Tags
since
1.5.0
Return values
string

get_sub_page_title()

Returns the title of the sub-page.

protected get_sub_page_title() : string
Tags
since
1.5.0
Return values
string

load_setting()

Loads a specified setting.

protected load_setting(string $setting_key_name) : array<string|int, mixed>
Parameters
$setting_key_name : string

Setting key.

Tags
access

protected

since
1.5.0
since
2.5.11

Broken due to accidental removal of esc_attr() call.

since
2.6.1

Restore esc_attr() call.

Return values
array<string|int, mixed>

{ A configurable setting.

@type  string  $id  Setting key.
@type  string  $name  Setting name.
@type  string  $value  Setting value.

}

append_scripts()

Append JavaScript and CSS files for specific sub-page.

private append_scripts() : void
Tags
access

private

since
1.5.0
todo

Move to Admin.

Return values
void

register_meta_boxes()

Registers all Meta boxes for a sub-page.

private register_meta_boxes(string $parent_id) : void
Parameters
$parent_id : string

Parent section unique ID.

Tags
access

private

since
1.5.0
Return values
void

save_settings()

Save plugin settings.

private save_settings() : bool
Tags
access

private

since
1.5.0
todo

Review nonce verification.

todo

New settings require a page refresh to render correctly. Fix.

Return values
bool

true on save success, else false.

Search results