WP_Customize_Widgets::tally_sidebars_via_dynamic_sidebar_calls() WordPress Method

The WP_Customize_Widgets::tally_sidebars_via_dynamic_sidebar_calls() method is used to tally the number of sidebars that are currently active on a WordPress site. This method is called automatically by the WordPress Customizer when the user first loads the Customizer interface.

WP_Customize_Widgets::tally_sidebars_via_dynamic_sidebar_calls( bool $has_widgets, string $sidebar_id ) #

Tallies the sidebars rendered via dynamic_sidebar().


Description

Keep track of the times that dynamic_sidebar() is called in the template, and assume this means the sidebar would be rendered on the template if there were widgets populating it.


Top ↑

Parameters

$has_widgets

(bool)(Required)Whether the current sidebar has widgets.

$sidebar_id

(string)(Required)Sidebar ID.


Top ↑

Return

(bool) Whether the current sidebar has widgets.


Top ↑

Source

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

	public function tally_sidebars_via_dynamic_sidebar_calls( $has_widgets, $sidebar_id ) {
		if ( is_registered_sidebar( $sidebar_id ) ) {
			$this->rendered_sidebars[ $sidebar_id ] = true;
		}

		/*
		 * We may need to force this to true, and also force-true the value
		 * for 'is_active_sidebar' if we want to ensure there is an area to
		 * drop widgets into, if the sidebar is empty.
		 */
		return $has_widgets;
	}


Top ↑

Changelog

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