wp_maybe_load_widgets

Determines if Widgets library should be loaded.

Description

wp_maybe_load_widgets(); 

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.


Usage

  1. if ( !function_exists( 'wp_maybe_load_widgets' ) ) { 
  2. require_once ABSPATH . WPINC . '/functions.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = wp_maybe_load_widgets(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/functions.php  
  1. function wp_maybe_load_widgets() { 
  2. /** 
  3. * Filters whether to load the Widgets library. 
  4. * Passing a falsey value to the filter will effectively short-circuit 
  5. * the Widgets library from loading. 
  6. * @since 2.8.0 
  7. * @param bool $wp_maybe_load_widgets Whether to load the Widgets library. 
  8. * Default true. 
  9. */ 
  10. if ( ! apply_filters( 'load_default_widgets', true ) ) { 
  11. return; 
  12.  
  13. require_once( ABSPATH . WPINC . '/default-widgets.php' ); 
  14.