Пример #1
0
    public function get_menu_html($menu_id)
    {
        #ACCESS GLOBALS
        global $wpdb, $hmenu_helper, $woocommerce, $wp;
        #CREATE INSTANCE
        $backend = new hmenu_backend($this->plugin_dir);
        $get = new hmenu_class_get($this->plugin_dir);
        $unique_id = str_replace('-', '', $hmenu_helper->genGUID());
        //////////////////////////////////////////////////////////
        $result = $wpdb->get_results("\n\t\t\t\tSELECT\n\t\t\t\t\t" . $get->prefixed_table_fields_wildcard($wpdb->base_prefix . 'hmenu_menu', 'm') . ",\n\t\t\t\t\t" . $get->prefixed_table_fields_wildcard($wpdb->base_prefix . 'hmenu_nav_items', 'ni') . ",\n\t\t\t\t\t" . $get->prefixed_table_fields_wildcard($wpdb->base_prefix . 'hmenu_mega_menu', 'mega') . ",\n\t\t\t\t\t" . $get->prefixed_table_fields_wildcard($wpdb->base_prefix . 'hmenu_mega_contact', 'mega_tact') . ",\n\t\t\t\t\t" . $get->prefixed_table_fields_wildcard($wpdb->base_prefix . 'hmenu_mega_map', 'mega_map') . "\n\t\t\t\tFROM\n\t\t\t\t\t`" . $wpdb->base_prefix . "hmenu_menu` AS `m`\n\t\t\t\t\tLEFT JOIN `" . $wpdb->base_prefix . "hmenu_nav_items` AS `ni` ON(`ni`.`menuId` = `m`.`menuId` AND `ni`.`deleted` = '0')\n\t\t\t\t\tLEFT JOIN `" . $wpdb->base_prefix . "hmenu_mega_menu` AS `mega` ON(`mega`.`navItemId` = `ni`.`navItemId` AND `mega`.`deleted` = '0')\n\t\t\t\t\tLEFT JOIN `" . $wpdb->base_prefix . "hmenu_mega_contact` AS `mega_tact` ON(`mega_tact`.`megaMenuId` = `mega`.`megaMenuId` AND `mega_tact`.`deleted` = '0')\n\t\t\t\t\tLEFT JOIN `" . $wpdb->base_prefix . "hmenu_mega_map` AS `mega_map` ON(`mega_map`.`megaMenuId` = `mega`.`megaMenuId` AND `mega_map`.`deleted` = '0')\n\t\t\t\tWHERE\n\t\t\t\t\t`m`.`menuId` = " . $menu_id . "\n\t\t\t\tAND\n\t\t\t\t\t`m`.`deleted` = 0\n\t\t\t\tORDER BY\n\t\t\t\t\t`m`.`menuId` ASC;\n\t\t\t");
        #CREATE OBJECT
        $menu_object = array('menu' => array());
        //////////////////////////////////////////////////////////
        if ($result) {
            $menu_object['menu'] = array('id' => $result[0]->m_menuId);
        }
        #GET CURRENT URL AND SEND IT TO JQUERY TO DO MAGIC
        $category = get_the_category();
        $current_id = get_the_ID();
        if (isset($category[0]) && is_category($category[0]->slug)) {
            $current_url = get_category_link($category[0]->term_id);
        } else {
            if (is_page()) {
                $current_url = get_the_permalink($current_id);
            } else {
                $current_url = home_url(add_query_arg(array(), $wp->request)) . '/';
            }
        }
        $menu = '
				<script type="text/javascript">
					jQuery(function(){
						hmenu_activate_menu(\'' . $menu_id . '\',\'' . $current_url . '\');
					});					
				</script>				
			';
        if ($this->count == 0) {
            $backend = new hmenu_backend($this->plugin_dir);
            if ($backend->get_frontend_fonts()) {
                foreach ($backend->get_frontend_fonts() as $font) {
                    $menu .= '<link rel="stylesheet" property="stylesheet" id="hmenu-' . $font->fontName . '" href="' . $this->plugin_url . '/_fonts/' . $font->fontName . '.css" type="text/css" media="all">';
                }
            }
        }
        #CHECK ADMIN BAR
        if (is_admin_bar_showing()) {
            $menu .= " <style type='text/css'> .hmenu_is_sticky { margin-top:32px !important; } /* This adds the padding for the admin bar when active. */ </style> ";
        }
        $menu .= '<link rel="stylesheet" property="stylesheet" id="hmenu-' . $menu_id . '-general-css" href="' . $this->plugin_url . '/_frontend_files/_menu_' . $menu_id . '/_css/hero_menu_styles.css" type="text/css" media="all">';
        #ATTACH MENU HTML
        $menu .= $this->return_menu_html($menu_id, $current_url, $current_id);
        $this->count++;
        #RETURN MENU
        return $menu;
    }
 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;
 }