\DevOwl\CustomizeAbstractCustomizePanel

An abstract implementation of a panel in WP customize.

The main purpose of this abstract class is the following layer:

  • It creates a main panel
  • That panel can contain multiple sections
  • A section contains multiple controls
  • A control holds a single setting

If you need a more specific setting override the customize_register method!

Summary

Methods
Properties
Constants
__construct()
resolveSections()
getSections()
customize_register()
enableOptionsAutoload()
localizeIds()
localizeValues()
localizeDefaultValues()
getUrl()
getSetting()
getPanel()
getName()
getManager()
gotUpdated()
sanitize_checkbox()
No public properties found
WEB_SAFE_FONT_FAMILY
getPanelArgs()
registerSections()
getSkipControlClasses()
sectionDefaults()
controlDefaults()
settingDefaults()
No protected properties found
N/A
No private methods found
$panel
$name
$manager
$sections
N/A

Constants

WEB_SAFE_FONT_FAMILY

WEB_SAFE_FONT_FAMILY =array('Georgia, serif', '"Palatino Linotype", "Book Antiqua", Palatino, serif', '"Times New Roman", Times, serif', 'Arial, Helvetica, sans-serif', '"Arial Black", Gadget, sans-serif', '"Comic Sans MS", cursive, sans-serif', 'Impact, Charcoal, sans-serif', '"Lucida Sans Unicode", "Lucida Grande", sans-serif', 'Tahoma, Geneva, sans-serif', '"Trebuchet MS", Helvetica, sans-serif', 'Verdana, Geneva, sans-serif', '"Courier New", Courier, monospace', '"Lucida Console", Monaco, monospace')

Cross-browser compatible font families.

Properties

$panel

$panel :string

The main panel ID.

Type

string

$name

$name :string

The name of this panel.

Type

string

$manager

$manager :\WP_Customize_Manager

The manager received through customize_register.

Type

\WP_Customize_Manager

$sections

$sections :array

Cached sections definition.

Type

array

Methods

__construct()

__construct(string  $panel,string  $name)

C'tor.

Parameters

string $panel

The main panel ID.

string $name

The name of this panel, e. g. "banner". This is needed for frontend localization

resolveSections()

resolveSections(): array

Return sections for this panel. Do not directly use this, use `getSections` instead.

Returns

array —

Documentation follows soon, in the meantime have a look at Real Cookie Banner implementation

getSections()

getSections(boolean  $force = false)

Return sections for this panel with caching mechanism.

Parameters

boolean $force

customize_register()

customize_register(\WP_Customize_Manager  $wp_customize)

Add cookie banner section. If you need a more granular customization you can safely override this method!

Parameters

\WP_Customize_Manager $wp_customize

enableOptionsAutoload()

enableOptionsAutoload()

Write defaults to database via `add_option` to avoid performance issues with `get_option` (autoload).

localizeIds()

localizeIds()

Localize for frontend (registered panel, section and setting IDs).

localizeValues()

localizeValues(string  $skipControlClasses = array())

Localize for frontend (customize values)

Parameters

string $skipControlClasses

localizeDefaultValues()

localizeDefaultValues(string  $skipControlClasses = array())

Localize for frontend (customize defaults so they can be resetted)

Parameters

string $skipControlClasses

getUrl()

getUrl()

Get the live preview url with autofocus.

getSetting()

getSetting(string  $id,boolean  $resolve = true)

Get value of a setting. Unfortunately, getting the managers' settings does not work as expected because they are only available in customize, and not in frontend. We need to reconstruct the #value method.

Parameters

string $id

The unique ID of the setting

boolean $resolve

If false, it returns always the default values

Throws

\Exception

When no setting with the given ID was found

getPanel()

getPanel()

Get main panel id.

getName()

getName()

Get name.

getManager()

getManager()

Get manager.

gotUpdated()

gotUpdated(array  $response,string  $prefix)

Check depending on the `$response` of `customize_save_response` hook if a specific prefix got changed.

Parameters

array $response
string $prefix

sanitize_checkbox()

sanitize_checkbox(boolean  $checked): boolean

Sanitize boolean for checkbox. Note: We need to sanitize the value to "y" or "n".

Parameters

boolean $checked

Whether or not a box is checked.

Returns

boolean

getPanelArgs()

getPanelArgs(): array

Return main arguments for this panel.

Returns

array

registerSections()

registerSections(array  $sections)

Register sections from the dynamic array.

Parameters

array $sections

Result of getSections

getSkipControlClasses()

getSkipControlClasses(): array<mixed,string>

Override this for default overrides arguments.

Returns

array<mixed,string>

sectionDefaults()

sectionDefaults(): array

Override this for default section arguments.

Returns

array

controlDefaults()

controlDefaults(): array

Override this for default control arguments.

Returns

array

settingDefaults()

settingDefaults(): array

Override this for default setting arguments.

Returns

array