/** * returns all the widgets * @param bool $only_names, returns only an array with the widgets names, if not array with widgets instances * @return array */ public static function get_widgets($only_names = FALSE) { $widgets = array(); Widgets::$default_widgets = self::get_installed_widgets(); //merge the possible widgets of the theme $list = array_unique(array_merge(widgets::$default_widgets, widgets::$theme_widgets)); if ($only_names) { return $list; } //creating an instance of each widget foreach ($list as $widget_name) { if (class_exists($widget_name)) { $widgets[] = new $widget_name(); } } return $widgets; }