/** * if this callback of the hook that mean you not link specific menu to wp_nav_menu * @hook filter 'wp_nav_menu_args' * @param $args */ public function _modify_nav_menu_args($args) { //get current menu name $menu = self::get_menu_name($args); /** * get menu skin * first entry for through out menu filters */ $skin = HW_NavMenu_Metabox_settings::get_menu_setting('skin', $menu); $enable_skin = HW_NavMenu_Metabox_settings::get_menu_setting('enable_skin', $menu); $enable_filter_menu = HW_NavMenu_Metabox_settings::get_menu_setting('enable_filter_menu', $menu); //add other menu setting to menu args $addition_menu_args = array('show_searchbox', 'remove_ul_wrap', 'only_anchor_tag_nav_menu', 'show_home_menu', 'allow_tags_nav_menu', 'show_icon'); foreach ($addition_menu_args as $option) { $args[$option] = HW_NavMenu_Metabox_settings::get_menu_setting($option, $menu); } if ($enable_filter_menu && $enable_skin && $skin) { //parse SKIN object $this->skin = APF_hw_skin_Selector_hwskin::resume_hwskin_instance($skin); //parse into HW_SKIN object & saved as property $this->skin->file = $this->skin->instance->get_skin_file($this->skin->hash_skin); $options_config = $this->skin->instance->get_file_skin_options($this->skin->hash_skin); //theme options configuration $theme_setting = $this->skin->instance->get_file_skin_setting(); //theme setting file //register twig loader if (class_exists('HW_Twig_Template')) { //Twig_Autoloader::register(); //$loader = new Twig_Loader_Filesystem($this->skin->instance->get_file_skin_resource('tpl')); $this->twig = HW_Twig_Template::create($this->skin->instance->get_file_skin_resource('tpl')); #$this->twig = new Twig_Environment($loader); $args['twig'] = $this->twig->get(); //reference twig object } if (file_exists($this->skin->file)) { $theme = array(); $theme['styles'] = array(); //init $theme['scripts'] = array(); $theme['filters'] = array(); //allow filters //keep this info (ex: menu) with filter that bind to callback to compare from current filter args $theme['menu'] = $menu; $user_options = array(); //skin options if (file_exists($theme_setting)) { include $theme_setting; } //theme setting if (file_exists($options_config)) { include $options_config; } //options file if (isset($theme_options)) { //$theme_options variable already exists in skin options //$skin_options_config = hwskin_parse_theme_options($theme_options); //get addition skin options value $skin_options = isset($skin['skin_options']) ? $skin['skin_options'] : array(); if (empty($skin_options)) { $skin_options = array(); } //please go menu setting page & press on save button $exclude_options = array('menu'); foreach ($exclude_options as $opt) { if (isset($skin_options[$opt])) { unset($skin_options[$opt]); } } $user_options = HW_SKIN::get_skin_options($skin_options, $theme['args'], $theme_options); $args = array_merge($args, $user_options); //sync skin options with $args //hope $args share to all remain menu filters in order to render final output menu to user /*foreach($skin_options as $arg => $value){ $field_setting = $skin_options_config[$arg]; if(!isset($args[$arg])) $args[$arg] = ''; //set menu args from skin //append if exists setting if(isset($field_setting['method']) && $field_setting['method'] == 'append' && !empty($value)){ if(!in_array($value, preg_split('#[\s]+#',$args[$arg]))){ $args[$arg] .= (!empty($args[$arg])? ' ':'').trim($value); } } //override setting if not exists if(isset($field_setting['method']) && $field_setting['method'] == 'override' && !empty($value)){ $args[$arg] = $value; } }*/ } //make sure have no ouput at here HW_SKIN::include_skin_file($this->skin->file); //extract wp_nav_menu_args from skin file /*if(isset($theme['args']) && is_array($theme['args'])){ //$args = array_merge($args, $theme['args']); foreach($theme['args'] as $arg => $val){ if(isset($args[$arg])) $args[$arg] .= (!empty($args[$arg])? ' ':'').$val; //append else $args[$arg] = $val; //create if not exists } }*/ $this->skin->instance->do_filters($theme['filters'], array($theme, $user_options)); //do filters & actions that defined in skin //$this->skin->instance->enqueue_files_from_skin(null/*$theme['styles']*/, $theme['scripts']); //put stuff from skin (note: css enqueue before) //new way for enqueue stuff from skin HW_SKIN::enqueue_skin_assets(array('instance' => $this->skin->instance, 'hash_skin' => $this->skin->hash_skin, 'skin_file' => $this->skin->file, 'theme_settings' => $theme, 'theme_options' => $args)); //languages selector on the website $show_langs_switcher = HW_NavMenu_Metabox_settings::get_menu_setting('show_langs_switcher', $menu); //show search form in nav menu if ($show_langs_switcher) { //get langs switcher output $args['langs_switcher'] = hw_get_qtrans_switcher(); } #$args = array_merge($args, $skin_options); //filtered values in above //if(isset($args['show_items_separator'])) ; } $args['walker'] = new HW_Nav_Menu_Walker(); } $this->menu_args = (object) $args; //save current menu args /*if( 'primary' == $args['theme_location'] ) { $args['depth'] = -1; $args['container_id'] = 'my_primary_menu'; } if('menu1' == $args['menu']){ #maybe old wp version $args['walker'] = new custom_walker(); } //for custom menu widget if(isset($args['menu']) && isset($args['menu']->name) && $args['menu']->name == 'menu-header') { }*/ return $args; }