wp_get_sidebars_widgets

Retrieve full list of sidebars and their widget instance IDs.

Description

(array) wp_get_sidebars_widgets( (bool) $deprecated = true ); 

Will upgrade sidebar widget list, if needed. Will also save updated list, if needed.

Returns (array)

Upgraded list of widgets to version 3 array format when called from the admin.

Parameters (1)

0. $deprecated — Optional. (bool) => true
Not used (argument deprecated).

Usage

  1. if ( !function_exists( 'wp_get_sidebars_widgets' ) ) { 
  2. require_once ABSPATH . WPINC . '/widgets.php'; 
  3.  
  4. // Not used (argument deprecated). 
  5. $deprecated = true; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wp_get_sidebars_widgets($deprecated); 
  9.  

Defined (1)

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

/wp-includes/widgets.php  
  1. function wp_get_sidebars_widgets( $deprecated = true ) { 
  2. if ( $deprecated !== true ) 
  3. _deprecated_argument( __FUNCTION__, '2.8.1' ); 
  4.  
  5. global $_wp_sidebars_widgets, $sidebars_widgets; 
  6.  
  7. // If loading from front page, consult $_wp_sidebars_widgets rather than options 
  8. // to see if wp_convert_widget_settings() has made manipulations in memory. 
  9. if ( !is_admin() ) { 
  10. if ( empty($_wp_sidebars_widgets) ) 
  11. $_wp_sidebars_widgets = get_option('sidebars_widgets', array()); 
  12.  
  13. $sidebars_widgets = $_wp_sidebars_widgets; 
  14. } else { 
  15. $sidebars_widgets = get_option('sidebars_widgets', array()); 
  16.  
  17. if ( is_array( $sidebars_widgets ) && isset($sidebars_widgets['array_version']) ) 
  18. unset($sidebars_widgets['array_version']); 
  19.  
  20. /** 
  21. * Filters the list of sidebars and their widgets. 
  22. * @since 2.7.0 
  23. * @param array $sidebars_widgets An associative array of sidebars and their widgets. 
  24. */ 
  25. return apply_filters( 'sidebars_widgets', $sidebars_widgets );