/** * add export widgets for the module */ public function add_export_widgets() { $theme_config = HW__Template::get_theme_config(); if ($theme_config && $theme_config->item('sidebars')) { foreach ($theme_config->item('sidebars') as $sidebar => $item) { if (isset($item['widgets'])) { foreach ($item['widgets'] as $widget) { $this->load_widgets($widget); //init widget $wxr_widget = $this->widgets->get($widget); if (!$wxr_widget) { continue; } //widget not exists $wxr_widget->get()->setAttribute('sidebar', $sidebar); //add widget to sidebar if ($this->widgets->get($widget)) { $this->add_export($wxr_widget->get()); } } } } } }
/** * prepare hook * @hook after_setup_theme */ public function _setup_theme() { //no, because this trigger before init if (empty($this->theme_config)) { $this->theme_config = HW__Template::get_theme_config(); } }