wp_list_widgets

Display list of the available widgets.

Description

wp_list_widgets(); 

Usage

  1. if ( !function_exists( 'wp_list_widgets' ) ) { 
  2. require_once ABSPATH . '/wp-admin/includes/widgets.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = wp_list_widgets(); 
  7.  

Defined (1)

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

/wp-admin/includes/widgets.php  
  1. function wp_list_widgets() { 
  2. global $wp_registered_widgets, $wp_registered_widget_controls; 
  3.  
  4. $sort = $wp_registered_widgets; 
  5. usort( $sort, '_sort_name_callback' ); 
  6. $done = array(); 
  7.  
  8. foreach ( $sort as $widget ) { 
  9. if ( in_array( $widget['callback'], $done, true ) ) // We already showed this multi-widget 
  10. continue; 
  11.  
  12. $sidebar = is_active_widget( $widget['callback'], $widget['id'], false, false ); 
  13. $done[] = $widget['callback']; 
  14.  
  15. if ( ! isset( $widget['params'][0] ) ) 
  16. $widget['params'][0] = array(); 
  17.  
  18. $args = array( 'widget_id' => $widget['id'], 'widget_name' => $widget['name'], '_display' => 'template' ); 
  19.  
  20. if ( isset($wp_registered_widget_controls[$widget['id']]['id_base']) && isset($widget['params'][0]['number']) ) { 
  21. $id_base = $wp_registered_widget_controls[$widget['id']]['id_base']; 
  22. $args['_temp_id'] = "$id_base-__i__"; 
  23. $args['_multi_num'] = next_widget_id_number($id_base); 
  24. $args['_add'] = 'multi'; 
  25. } else { 
  26. $args['_add'] = 'single'; 
  27. if ( $sidebar ) 
  28. $args['_hide'] = '1'; 
  29.  
  30. $args = wp_list_widget_controls_dynamic_sidebar( array( 0 => $args, 1 => $widget['params'][0] ) ); 
  31. call_user_func_array( 'wp_widget_control', $args );