WP_Customize_Section::__construct() WordPress Method

The WP_Customize_Section::__construct() method is used to create a new section object. A section is a container for controls.

WP_Customize_Section::__construct( WP_Customize_Manager $manager, string $id, array $args = array() ) #

Constructor.


Description

Any supplied $args override class property defaults.


Top ↑

Parameters

$manager

(WP_Customize_Manager)(Required)Customizer bootstrap instance.

$id

(string)(Required)A specific ID of the section.

$args

(array)(Optional)Array of properties for the new Section object.

  • 'priority'
    (int) Priority of the section, defining the display order of panels and sections. Default 160.
  • 'panel'
    (string) The panel this section belongs to (if any).
  • 'capability'
    (string) Capability required for the section. Default 'edit_theme_options'
  • 'theme_supports'
    (string|string[]) Theme features required to support the section.
  • 'title'
    (string) Title of the section to show in UI.
  • 'description'
    (string) Description to show in the UI.
  • 'type'
    (string) Type of the section.
  • 'active_callback'
    (callable) Active callback.
  • 'description_hidden'
    (bool) Hide the description behind a help icon, instead of inline above the first control. Default false.

Default value: array()


Top ↑

Source

File: wp-includes/class-wp-customize-section.php

	public function __construct( $manager, $id, $args = array() ) {
		$keys = array_keys( get_object_vars( $this ) );
		foreach ( $keys as $key ) {
			if ( isset( $args[ $key ] ) ) {
				$this->$key = $args[ $key ];
			}
		}

		$this->manager = $manager;
		$this->id      = $id;
		if ( empty( $this->active_callback ) ) {
			$this->active_callback = array( $this, 'active_callback' );
		}
		self::$instance_count += 1;
		$this->instance_number = self::$instance_count;

		$this->controls = array(); // Users cannot customize the $controls array.
	}


Top ↑

Changelog

Changelog
VersionDescription
3.4.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.