public function generate_files($menu_object = NULL, $js = true) { global $wpdb; #MAIN MENU OBJECT $get = new hmenu_class_get($this->plugin_dir); $this->menu_object = $menu_object != NULL ? $menu_object : $get->get_main_menu_object(intval($_POST['menu_id']), false); $menu = $this->menu_object['menu']; #CREATE OBJECT $test_object = array('stuff' => array()); #MENU HTML DIRECTORY $menu_id = $menu['menuId']; $menu_directory = '_menu_' . $menu_id . '/'; #CHECK IF DIRECTORY EXISTS if (!is_dir($this->plugin_dir . $this->frontend_directory . $menu_directory)) { #CREATE FILES DIRECTORY if (!is_dir($this->plugin_dir . $this->frontend_directory)) { mkdir($this->plugin_dir . $this->frontend_directory); } #CREATE SUB FOLDERS $this->create_sub_folders($this->frontend_directory, $menu_directory); } else { //LOOP THORUGH DIRECTORY AND REMOVE OLD FILES if ($handle = opendir($this->plugin_dir . $this->frontend_directory . $menu_directory)) { while (false !== ($file = readdir($handle))) { if ('.' === $file) { continue; } if ('..' === $file) { continue; } $test_object['stuff'][] = array('file' => $file); #REMOVE DIRECTORY $this->remove_directory($file, $menu_directory); } #CLOSE DIRECTORY closedir($handle); #CREATE SUB FOLDERS $this->create_sub_folders($this->frontend_directory, $menu_directory); } } if ($js) { echo json_encode(true); exit; } else { return true; } }
public function return_menu_html($menu_id, $current_url, $current_id) { #GLOBALS global $wpdb; $result = $wpdb->get_results("SELECT * FROM " . $wpdb->base_prefix . "hmenu_menu WHERE menuId = " . $menu_id . " AND deleted = '0' ORDER BY created DESC"); if ($result) { $get = new hmenu_class_get($this->plugin_dir); $generate = new hmenu_class_generate($this->plugin_dir); $menu_object = $get->get_main_menu_object(intval($menu_id), false); #GOOGLE FONTS $main_font = $menu_object['main_styles'][0]['fontFamily']; $standard_font = $menu_object['dropdown_styles'][0]['fontFamily']; $mega_font_0 = $menu_object['mega_font_styles'][0]['fontFamily']; $mega_font_1 = $menu_object['mega_font_styles'][1]['fontFamily']; $mega_font_2 = $menu_object['mega_font_styles'][2]['fontFamily']; $mega_font_3 = $menu_object['mega_font_styles'][3]['fontFamily']; $search_font = $menu_object['search_styles'][0]['fontFamily']; $font_array = array($main_font, $standard_font, $mega_font_0, $mega_font_1, $mega_font_2, $mega_font_3, $search_font); $font_array = array_unique($font_array); $the_font_string = ''; foreach ($font_array as $font) { $the_font_string .= $font . '|'; } $final_font_string = rtrim($the_font_string, '|'); $the_html = ''; #FONT LINK $the_html .= '<link href="https://fonts.googleapis.com/css?family=' . $final_font_string . '" rel="stylesheet" type="text/css">'; #MENU HTML HOLDER $the_html .= '<div id="hmenu_load_' . $menu_id . '" style="display:none" class="hmenu_load_menu" data-menu-id="' . $menu_id . '">'; $the_html .= $generate->frontend_call($menu_object, $current_url, $current_id); $the_html .= '</div>'; } else { $the_html = 'Sorry, that menu does not exist.'; } return $the_html; }
public function process_generate() { #GLOBALS global $wpdb; $result = $wpdb->get_results("SELECT * FROM " . $wpdb->base_prefix . "hmenu_menu WHERE deleted = '0' ORDER BY created DESC"); if ($result) { $backend = new hmenu_backend($this->plugin_dir); $get = new hmenu_class_get($this->plugin_dir); $generate = new hmenu_class_generate($this->plugin_dir); foreach ($result as $menu) { $menu_object = $get->get_main_menu_object(intval($menu->menuId), false); $backend->get_fonts('icons', false); $generate->generate_files($menu_object, false); } } return true; }