wp_maybe_load_widgets() WordPress Function

The wp_maybe_load_widgets() function is used to determine whether a sidebar is active and if so, load the corresponding widgets. This function is called when the sidebar is first initialized.

wp_maybe_load_widgets() #

Determines if Widgets library should be loaded.


Description

Checks to make sure that the widgets library hasn’t already been loaded. If it hasn’t, then it will load the widgets library and run an action hook.


Top ↑

Source

File: wp-includes/functions.php

function wp_maybe_load_widgets() {
	/**
	 * Filters whether to load the Widgets library.
	 *
	 * Returning a falsey value from the filter will effectively short-circuit
	 * the Widgets library from loading.
	 *
	 * @since 2.8.0
	 *
	 * @param bool $wp_maybe_load_widgets Whether to load the Widgets library.
	 *                                    Default true.
	 */
	if ( ! apply_filters( 'load_default_widgets', true ) ) {
		return;
	}

	require_once ABSPATH . WPINC . '/default-widgets.php';

	add_action( '_admin_menu', 'wp_widgets_add_menu' );
}


Top ↑

Changelog

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

Show More
Show More