wp_maybe_load_widgets

The timeline below displays how wordpress function wp_maybe_load_widgets has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 5.5

/**
 * Determines if Widgets library should be loaded.
 *
 * 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.
 *
 * @since 2.2.0
 */
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');
}

WordPress Version: 4.6

/**
 * Determines if Widgets library should be loaded.
 *
 * 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.
 *
 * @since 2.2.0
 */
function wp_maybe_load_widgets()
{
    /**
     * Filters whether to load the Widgets library.
     *
     * Passing a falsey value to 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');
}

WordPress Version: 4.0

/**
 * Determines if Widgets library should be loaded.
 *
 * 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.
 *
 * @since 2.2.0
 */
function wp_maybe_load_widgets()
{
    /**
     * Filter whether to load the Widgets library.
     *
     * Passing a falsey value to 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');
}

WordPress Version: 3.9

/**
 * Determines if Widgets library should be loaded.
 *
 * 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.
 *
 * @since 2.2.0
 * @uses add_action() Calls '_admin_menu' hook with 'wp_widgets_add_menu' value.
 */
function wp_maybe_load_widgets()
{
    /**
     * Filter whether to load the Widgets library.
     *
     * @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');
}

WordPress Version: 3.7

/**
 * Determines if Widgets library should be loaded.
 *
 * 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.
 *
 * @since 2.2.0
 * @uses add_action() Calls '_admin_menu' hook with 'wp_widgets_add_menu' value.
 */
function wp_maybe_load_widgets()
{
    if (!apply_filters('load_default_widgets', true)) {
        return;
    }
    require_once ABSPATH . WPINC . '/default-widgets.php';
    add_action('_admin_menu', 'wp_widgets_add_menu');
}