确定是否应加载Widgets库。

原型

wp_maybe_load_widgets()

描述

检查以确保尚未加载窗口小部件库。如果没有,那么它将加载小部件库并运行一个动作钩子。

源文件

路径:wp-includes/functions.php

<?php
...
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' );
}
...
?>

其他

英文文档:https://developer.wordpress.org/reference/functions/wp_maybe_load_widgets/