Class: Section

wp.customize. Section


new Section(id, options)

Parameters:
Name Type Description
id string The ID for the section.
options object Options.
Properties
Name Type Argument Default Description
title string Title shown when section is collapsed and expanded.
description string <optional>
Description shown at the top of the section.
priority number <optional>
100 The sort priority for the section.
type string <optional>
default The type of the section. See wp.customize.sectionConstructor.
content string <optional>
The markup to be used for the section container. If empty, a JS template is used.
active boolean <optional>
true Whether the section is active or not.
panel string The ID for the panel this section is associated with.
customizeAction string <optional>
Additional context information shown before the section title when expanded.
params object <optional>
Deprecated wrapper for the above properties.
Since:
  • 4.1.0
Source:

Extends

Methods


<private> _animateChangeExpanded(completeCallback)

Animate container state change if transitions are supported by the browser.
Parameters:
Name Type Description
completeCallback function Function to be called after transition is completed.
Since:
  • 4.7.0
Inherited From:
Source:
Returns:
Type
void

_children(parentType, childType)

Get the child models associated with this parent, sorting them by their priority Value.
Parameters:
Name Type Description
parentType String
childType String
Since:
  • 4.1.0
Inherited From:
Source:
Returns:
Type
Array

_toggleActive(active [, params])

Parameters:
Name Type Argument Description
active Boolean
params Object <optional>
Since:
  • 4.1.0
Inherited From:
Source:
Returns:
False if state already applied.
Type
Boolean

_toggleExpanded(expanded [, params])

Handle the toggle logic for expand/collapse.
Parameters:
Name Type Argument Description
expanded Boolean The new state to apply.
params Object <optional>
Object containing options for expand/collapse.
Properties
Name Type Argument Description
completeCallback function <optional>
Function to call when expansion/collapse is complete.
Inherited From:
Source:
Returns:
False if state already applied or active state is false.
Type
Boolean

activate( [params])

Parameters:
Name Type Argument Description
params Object <optional>
Inherited From:
Source:
Returns:
False if already active.
Type
Boolean

attachEvents()

Add behaviors for the accordion section.
Since:
  • 4.1.0
Source:

collapse( [params])

Parameters:
Name Type Argument Description
params Object <optional>
Inherited From:
Source:
Returns:
False if already collapsed.
Type
Boolean

controls()

Get the controls that are associated with this section, sorted by their priority Value.
Since:
  • 4.1.0
Source:
Returns:
Type
Array

deactivate( [params])

Parameters:
Name Type Argument Description
params Object <optional>
Inherited From:
Source:
Returns:
False if already inactive.
Type
Boolean

embed()

Embed the container in the DOM when any parent panel is ready.
Since:
  • 4.1.0
Source:

expand( [params])

Parameters:
Name Type Argument Description
params Object <optional>
Inherited From:
Source:
Returns:
False if already expanded or if inactive.
Type
Boolean

getContainer()

Return the container html, generated from its JS template, if it exists.
Since:
  • 4.3.0
Inherited From:
Source:

getContent()

Find content element which is displayed when the section is expanded. After a construct is initialized, the return value will be available via the `contentContainer` property. By default the element will be related it to the parent container with `aria-owns` and detached. Custom panels and sections (such as the `NewMenuSection`) that do not have a sliding pane should just return the content element without needing to add the `aria-owns` element or detach it from the container. Such non-sliding pane custom sections also need to override the `onChangeExpanded` method to handle animating the panel/section into and out of view.
Since:
  • 4.7.0
Inherited From:
Source:
Returns:
Detached content element.
Type
jQuery

getNotificationsContainerElement()

Get the element that will contain the notifications.
Since:
  • 4.9.0
Inherited From:
Source:
Returns:
Notification container element.
Type
jQuery

isContextuallyActive()

Return whether this section has any active controls.
Since:
  • 4.1.0
Overrides:
Source:
Returns:
Type
Boolean

onChangeActive(active [, args])

Active state change handler. Shows the container if it is active, hides it if not. To override by subclass, update the container's UI to reflect the provided active state.
Parameters:
Name Type Argument Description
active boolean The active state to transiution to.
args Object <optional>
Args.
Properties
Name Type Argument Description
duration Object <optional>
The duration for the slideUp/slideDown animation.
unchanged boolean <optional>
Whether the state is already known to not be changed, and so short-circuit with calling completeCallback early.
completeCallback function <optional>
Function to call when the slideUp/slideDown has completed.
Since:
  • 4.1.0
Inherited From:
Source:

onChangeExpanded(expanded, args)

Update UI to reflect expanded state.
Parameters:
Name Type Description
expanded Boolean
args Object
Since:
  • 4.1.0
Overrides:
Source:

<abstract> ready()

Since:
  • 4.1.0
Inherited From:
Source:

setupNotifications()

Set up notifications.
Since:
  • 4.9.0
Inherited From:
Source:
Returns:
Type
void