WP_Customize_Panel::active() WordPress Method

The WP_Customize_Panel::active() method is used to determine whether a panel is currently active in the Customizer. This is useful when you need to know whether a particular panel is the one currently being edited by the user. For example, you might want to hide or show certain controls based on whether the panel is active. The active() method returns a boolean value, so you can use it like this: if ( $panel->active() ) { // do something } else { // do something else }

WP_Customize_Panel::active() #

Check whether panel is active to current Customizer preview.


Return

(bool) Whether the panel is active to the current preview.


Top ↑

Source

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

	final public function active() {
		$panel  = $this;
		$active = call_user_func( $this->active_callback, $this );

		/**
		 * Filters response of WP_Customize_Panel::active().
		 *
		 * @since 4.1.0
		 *
		 * @param bool               $active Whether the Customizer panel is active.
		 * @param WP_Customize_Panel $panel  WP_Customize_Panel instance.
		 */
		$active = apply_filters( 'customize_panel_active', $active, $panel );

		return $active;
	}


Top ↑

Changelog

Changelog
VersionDescription
4.1.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.