'') { $nav_version_in_db = get_option( 'woo_settings_custom_nav_version' ); } else { $nav_version_in_db = '0'; } //Override for menu descriptions update_option( 'woo_settings_custom_nav_advanced_options','yes' ); if (isset($_GET['page'])) { $page_var = $_GET['page']; } else { $page_var = ''; } if ($page_var == 'custom_navigation') { //CREATE Custom Menu tables global $wpdb; $table_name = $wpdb->prefix . "woo_custom_nav_records"; $charset_collate = ''; if ( ! empty($wpdb->charset) ) { $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset"; } if ( ! empty($wpdb->collate) ) { $charset_collate .= " COLLATE $wpdb->collate"; } if(($wpdb->get_var( "show tables like '$table_name'") != $table_name) || ($nav_version_in_db <> $nav_version)) { $sql = "CREATE TABLE " . $table_name . " ( id mediumint(9) NOT NULL AUTO_INCREMENT, position bigint(11) NOT NULL, post_id bigint(11) NOT NULL, parent_id bigint(11) NOT NULL, custom_title text NOT NULL, custom_link text NOT NULL, custom_description text NOT NULL, menu_icon text NOT NULL, link_type varchar(55) NOT NULL default 'custom', menu_id bigint(11) NOT NULL, custom_anchor_title text NOT NULL, new_window bigint(11) NOT NULL default 0, UNIQUE KEY id (id) ) ".$charset_collate.";"; require_once(ABSPATH . 'wp-admin/includes/upgrade.php' ); dbDelta($sql); update_option( 'woo_settings_custom_nav_version',$nav_version); } $table_name_menus = $wpdb->prefix . "woo_custom_nav_menus"; if(($wpdb->get_var( "show tables like '$table_name_menus'") != $table_name_menus) || ($nav_version_in_db <> $nav_version)) { $data_insert = false; //CHECK if tables exist if ($wpdb->get_var( "show tables like '$table_name_menus'") != $table_name_menus) { $data_insert = true; } $sql = "CREATE TABLE " . $table_name_menus . " ( id mediumint(9) NOT NULL AUTO_INCREMENT, menu_name text NOT NULL, UNIQUE KEY id (id) ) ".$charset_collate.";"; require_once(ABSPATH . 'wp-admin/includes/upgrade.php' ); dbDelta($sql); //ADD data to tables if ($data_insert) { //POPULATE with first menu $insert = "INSERT INTO ".$table_name_menus." (menu_name) "."VALUES ( 'Woo Menu 1')"; $results = $wpdb->query( $insert ); //POPULATE with first menu content //Pages $table_name = $wpdb->prefix . "woo_custom_nav_records"; //GET all current pages $pages_args = array( 'child_of' => 0, 'sort_order' => 'ASC', 'sort_column' => 'post_title', 'hierarchical' => 1, 'exclude' => '', 'include' => '', 'meta_key' => '', 'meta_value' => '', 'authors' => '', 'parent' => 0, 'exclude_tree' => '', 'number' => '', 'offset' => 0 ); $pages_array = get_pages($pages_args); $counter = 1; //INSERT Loop foreach ($pages_array as $post) { //CHECK if is top level element if ($post->post_parent == 0) { //CHECK for existing page records $table_name_parent = $wpdb->prefix . "woo_custom_nav_records"; $woo_result = $wpdb->get_results( "SELECT id FROM ".$table_name_parent." WHERE post_id='".$post->post_parent."' AND link_type='page' AND menu_id='1'" ); if ($woo_result > 0 && isset($woo_result[0]->id)) { $parent_id = $woo_result[0]->id; } else { $parent_id = 0; } //INSERT page //Convert string to UTF-8 $str_converted = stripslashes($post->post_title); //$insert_title = htmlspecialchars($str_converted, ENT_QUOTES, 'UTF-8' ); //$insert = "INSERT INTO ".$table_name." (position,post_id,parent_id,custom_title,custom_link,custom_description,menu_icon,link_type,menu_id,custom_anchor_title) "."VALUES ( '".$counter."','".$post->ID."','".$parent_id."','".$insert_title."','".get_permalink($post->ID)."','','','page','1','".$insert_title."')"; //$results = $wpdb->query( $insert ); $results = $wpdb->insert( $table_name, array( 'position' => $counter, 'post_id' => $post->ID, 'parent_id' => $parent_id, 'custom_title' => $str_converted, 'custom_link' => get_permalink($post->ID), 'custom_description' => '', 'menu_icon' => '', 'link_type' => 'page', 'menu_id' => '1', 'custom_anchor_title' => $str_converted )); $counter++; //$counter = get_children_menu_elements($post->ID, $counter, $post->ID, 'pages',1,$table_name); $counter = get_children_menu_elements($post->ID, $counter, $post->post_parent, 'pages',1,$table_name); } //Do nothing else { } } //GET all current categories $category_args = array( 'type' => 'post', 'child_of' => 0, 'orderby' => 'name', 'order' => 'ASC', 'hide_empty' => false, 'include_last_update_time' => false, 'hierarchical' => 0, 'parent' => 0, 'depth' => 1, 'exclude' => '', 'include' => '', 'number' => '', 'pad_counts' => false ); $categories_array = get_categories($category_args); //POPULATE with second menu $insert = "INSERT INTO ".$table_name_menus." (menu_name) "."VALUES ( 'Woo Menu 2')"; $results = $wpdb->query( $insert ); //POPULATE with second menu content //GET all current pages $counter = 1; //GET all current categories //INSERT Loop foreach ($categories_array as $cat_item) { //CHECK if is top level element if ($cat_item->parent == 0) { //CHECK for existing category records $table_name_parent = $wpdb->prefix . "woo_custom_nav_records"; $woo_result = $wpdb->get_results( "SELECT id FROM ".$table_name_parent." WHERE post_id='".$cat_item->parent."' AND link_type='category' AND menu_id='2'" ); if ($woo_result > 0 && isset($woo_result[0]->id)) { $parent_id = $woo_result[0]->id; } else { $parent_id = 0; } //INSERT category //Convert string to UTF-8 $str_converted = stripslashes($cat_item->cat_name); //$insert_title = htmlspecialchars($str_converted, ENT_QUOTES, 'UTF-8' ); //$insert = "INSERT INTO ".$table_name." (position,post_id,parent_id,custom_title,custom_link,custom_description,menu_icon,link_type,menu_id) "."VALUES ( '".$counter."','".$cat_item->cat_ID."','".$parent_id."','".$insert_title."','".get_category_link($cat_item->cat_ID)."','','','category','2')"; //$results = $wpdb->query( $insert ); $results = $wpdb->insert( $table_name, array( 'position' => $counter, 'post_id' => $cat_item->cat_ID, 'parent_id' => $parent_id, 'custom_title' => $str_converted, 'custom_link' => get_category_link($cat_item->cat_ID), 'custom_description' => '', 'menu_icon' => '', 'link_type' => 'category', 'menu_id' => '2', 'custom_anchor_title' => $str_converted )); $counter++; $counter = get_children_menu_elements($cat_item->cat_ID, $counter, $cat_item->parent, 'categories',2,$table_name); } //Do nothing else { } } } } } } function woo_custom_nav_reset() { global $wpdb; $table_name = $wpdb->prefix . "woo_custom_nav_records"; //DROP existing tables $wpdb->query( "DROP TABLE ".$table_name); $table_name_menus = $wpdb->prefix . "woo_custom_nav_menus"; //DELETE existing menus $wpdb->query( "DROP TABLE ".$table_name_menus); woo_custom_navigation_setup(); return true; } function woo_custom_navigation_menu() { //Woothemes Custom Navigation Menu $woopage = add_submenu_page( 'woothemes', 'Custom Navigation', 'Custom Navigation', 8, 'custom_navigation', 'woo_custom_navigation' ); add_action( "admin_print_scripts-$woopage", 'woo_custom_nav_scripts' ); } function woo_custom_nav_scripts() { //STYLES AND JAVASCRIPT wp_enqueue_script( 'jquery' ); wp_enqueue_script( 'jquery-ui-core' ); wp_enqueue_script( 'jquery-ui-draggable' ); wp_enqueue_script( 'jquery-ui-droppable' ); wp_enqueue_script( 'jquery-ui-sortable' ); wp_enqueue_script( 'jquery-ui-dialog' ); wp_register_script( 'woo-nav-dynamic', get_template_directory_uri() . '/functions/js/custom_menu_dynamic_items.js', array( 'jquery-ui-dialog' )); wp_enqueue_script( 'woo-nav-dynamic' ); wp_register_script( 'woo-nav-initial', get_template_directory_uri() . '/functions/js/custom_menu_initial_items.js', array( 'jquery-ui-dialog' )); wp_enqueue_script( 'woo-nav-initial' ); wp_register_script( 'woo-nav-autocomplete', get_template_directory_uri() . '/functions/js/jquery.autocomplete.js', array( 'jquery' )); wp_enqueue_script( 'woo-nav-autocomplete' ); //Default Style echo ''; } /*-----------------------------------------------------------------------------------*/ /* Woothemes Custom Navigation Menu Interface /* woo_custom_navigation() is the main function for the Custom Navigation /* See functions in admin-functions.php /*-----------------------------------------------------------------------------------*/ function woo_custom_navigation() { global $wpdb; ?>

You do not have JavaScript enabled in your browser. Please enabled it to access the Custom Menu functionality.

prefix . "woo_custom_nav_menus"; $woo_result = $wpdb->get_results( "SELECT id FROM ".$table_name_menus." ORDER BY id ASC LIMIT 1" ); if ($woo_result > 0 && isset($woo_result[0]->id)) { $menu_selected_id = $woo_result[0]->id; } else { $menu_selected_id = 1; } //CHECK which menu is selected and if menu is in edit already if (isset($_POST['switch_menu'])) { //echo $_POST['menu_select']; $menu_selected_id = $_POST['menu_select']; } elseif (isset($_POST['menu_id_in_edit'])){ $menu_selected_id = $_POST['menu_id_in_edit']; } else { } if (isset($_POST['set_woo_menu'])) { update_option( 'woo_custom_nav_menu', $_POST['enable_woo_menu']); $messagesdiv = '

'.$themename.'\'s Custom Menu has been updated!

'; } //CHECK for existing woo custom menu $table_name = $wpdb->prefix . "woo_custom_nav_records"; $custom_nav_exists = $wpdb->query( "SELECT id FROM ".$table_name." WHERE menu_id='".$menu_selected_id."'" ); if (isset($_POST['licount'])) { $postCounter = $_POST['licount']; } else { $postCounter = 0; } if (isset($_POST['add_menu'])) { $table_name_custom_menu = $wpdb->prefix . "woo_custom_nav_menus"; $insert_menu_name = $_POST['add_menu_name']; //CHECK for existing woo custom menu $existing_records = $wpdb->query( "SELECT id FROM ".$table_name_custom_menu." WHERE menu_name='".$insert_menu_name."'" ); if ($insert_menu_name <> '') { if ($existing_records > 0) { $messagesdiv = '

'.$insert_menu_name.' Menu has already created - please try another name

'; //GET reset menu id $table_name_menus = $wpdb->prefix . "woo_custom_nav_menus"; $woo_result = $wpdb->get_results( "SELECT id FROM ".$table_name_menus." ORDER BY id ASC LIMIT 1" ); if ($woo_result > 0) { $menu_selected_id = $woo_result[0]->id; $menu_id_in_edit = $menu_selected_id; } else { $menu_selected_id = 0; $menu_selected_id = 0; } } else { $wpdb->insert( $table_name_custom_menu, array( 'menu_name' => $insert_menu_name )); $menu_selected_id = $wpdb->insert_id; $menu_id_in_edit = $menu_selected_id; $messagesdiv = '

'.$insert_menu_name.' Menu has been created!

'; $custom_nav_exists = $wpdb->query( "SELECT id FROM ".$table_name." WHERE menu_id='".$menu_selected_id."'" ); $postCounter = 0; } } else { $messagesdiv = '

Please enter a valid Menu name

'; } } if ($postCounter > 0) { if (isset($_POST['switch_menu'])) { } elseif (isset($_POST['add_menu'])) { } elseif (isset($_POST['reset_woo_menu'])) { $success = woo_custom_nav_reset(); if ($success) { //DISPLAY SUCCESS MESSAGE IF Menu Reset Correctly $messagesdiv = '

'.$themename.'\'s Custom Menu has been RESET!

'; //GET reset menu id $table_name_menus = $wpdb->prefix . "woo_custom_nav_menus"; $woo_result = $wpdb->get_results( "SELECT id FROM ".$table_name_menus." ORDER BY id ASC LIMIT 1" ); if ($woo_result > 0 && isset($woo_result[0]->id)) { $menu_selected_id = $woo_result[0]->id; } else { $menu_selected_id = 0; } } else { //DISPLAY SUCCESS MESSAGE IF Menu Reset Correctly $messagesdiv = '

'.$themename.'\'s Custom Menu could not be RESET. Please try again.

'; } } else { $menu_id_in_edit = $_POST['menu_id_in_edit']; //After POST delete existing records in prep for Insert $wpdb->query( "DELETE FROM ".$table_name." WHERE menu_id='".$menu_id_in_edit."'" ); //Loop through all POST variables for ($k = 1;$k<= $postCounter; $k++) { if (isset($_POST['dbid'.$k])) { $db_id = $_POST['dbid'.$k]; } else { $db_id = 0; } if (isset($_POST['postmenu'.$k])) { $post_id = $_POST['postmenu'.$k]; } else { $post_id = 0; } if (isset($_POST['parent'.$k])) { $parent_id = $_POST['parent'.$k]; } else { $parent_id = 0; } if (isset($_POST['title'.$k])) { $custom_title = stripslashes($_POST['title'.$k]); } else { $custom_title = ''; } if (isset($_POST['linkurl'.$k])) { $custom_linkurl = $_POST['linkurl'.$k]; } else { $custom_linkurl = ''; } if (isset($_POST['description'.$k])) { $custom_description = stripslashes($_POST['description'.$k]); } else { $custom_description = ''; } if (isset($_POST['icon'.$k])) { $icon = $_POST['icon'.$k]; } else { $icon = 0; } if (isset($_POST['position'.$k])) { $position = $_POST['position'.$k]; } else { $position = 0; } if (isset($_POST['linktype'.$k])) { $linktype = $_POST['linktype'.$k]; } else { $linktype = 'custom'; } if (isset($_POST['anchortitle'.$k])) { $custom_anchor_title = stripslashes($_POST['anchortitle'.$k]); } else { $custom_anchor_title = $custom_title; } if (isset($_POST['newwindow'.$k])) { $new_window = $_POST['newwindow'.$k]; } else { $new_window = 0; } if ($linktype == '') { } else { //If top level menu item if ($parent_id == 0) { //INSERT menu item record $wpdb->insert( $table_name, array( 'position' => $position, 'post_id' => $post_id, 'parent_id' => $parent_id, 'custom_title' => $custom_title, 'custom_link' => $custom_linkurl, 'custom_description' => $custom_description, 'menu_icon' => $icon, 'link_type' => $linktype, 'menu_id' => $menu_id_in_edit, 'custom_anchor_title' => $custom_anchor_title, 'new_window' => $new_window )); } //If not top level menu item else { //INSERT menu item record $wpdb->insert( $table_name, array( 'position' => $position, 'post_id' => $post_id, 'parent_id' => '8000', 'custom_title' => $custom_title, 'custom_link' => $custom_linkurl, 'custom_description' => $custom_description, 'menu_icon' => $icon, 'link_type' => $linktype, 'menu_id' => $menu_id_in_edit, 'custom_anchor_title' => $custom_anchor_title, 'new_window' => $new_window )); $lastid = $wpdb->insert_id; //GET the correct parent record $parentrecords = $wpdb->get_results( "SELECT id FROM ".$table_name." WHERE position='".($parent_id)."' AND menu_id='".$menu_id_in_edit."'" ); if ($parentrecords > 0) { foreach ($parentrecords as $parentrecord) { $parent_id_update = $parentrecord->id; } } //UPDATE menu item record with correct parent $wpdb->update( $table_name, array( 'parent_id' => $parent_id_update ), array( 'id' => $lastid, 'menu_id' => $menu_id_in_edit )); } } } //DISPLAY SUCCESS MESSAGE IF POST CORRECT $messagesdiv = '

'.$themename.'\'s Custom Menu has been updated!

'; } } else { if (isset($_POST['reset_woo_menu'])) { $success = woo_custom_nav_reset(); if ($success) { //DISPLAY SUCCESS MESSAGE IF Menu Reset Correctly $messagesdiv = '

'.$themename.'\'s Custom Menu has been RESET!

'; //GET reset menu id $table_name_menus = $wpdb->prefix . "woo_custom_nav_menus"; $woo_result = $wpdb->get_results( "SELECT id FROM ".$table_name_menus." ORDER BY id ASC LIMIT 1" ); if ($woo_result > 0 && isset($woo_result[0]->id)) { $menu_selected_id = $woo_result[0]->id; } else { $menu_selected_id = 0; } } else { //DISPLAY SUCCESS MESSAGE IF Menu Reset Correctly $messagesdiv = '

'.$themename.'\'s Custom Menu could not be RESET. Please try again.

'; } } } //DISPLAY Custom Navigation ?>

Custom Navigation

The Custom Menu has not been Enabled yet. Please enable it in order to use it -------->

'; } //Notify users that they can use 3.0 Menus instead if ( function_exists( 'wp_nav_menu') ) { echo '

You have WordPress 3.0.x installed!

We suggest that you use the WordPress Menu Management system instead of the Custom Navigation.

'; } ?>




style="display:none;" />
tag /* after_title - html after title is outputted in tag /*-----------------------------------------------------------------------------------*/ function woo_custom_navigation_output($args = array()) { //DEFAULT ARGS $type = 'frontend'; $name = 'Woo Menu 1'; $id = 0; $desc = 2; $before_title = ''; $after_title = ''; $depth = 0; if (isset($args)) { if ( !is_array($args) ) parse_str( $args, $args ); extract($args); } global $wpdb; $woo_custom_nav_menu_id = 0; $table_name = $wpdb->prefix . "woo_custom_nav_records"; //Override for menu descriptions $advanced_option_descriptions = get_option( 'woo_settings_custom_nav_advanced_options' ); if ($advanced_option_descriptions == 'no') { $desc = 2; } //GET Menu Items //FRONTEND if ($type == "frontend") { $table_name_menus = $wpdb->prefix . "woo_custom_nav_menus"; if ($id > 0) { $woo_custom_nav_menu_id = $id; } else { $woo_result = $wpdb->get_results( "SELECT id FROM ".$table_name_menus." WHERE menu_name='".$name."'" ); $woo_custom_nav_menu_id = $woo_result[0]->id; } $woo_custom_nav_menu = $wpdb->get_results( "SELECT id,post_id,parent_id,position,custom_title,custom_link,custom_description,menu_icon,link_type,custom_anchor_title,new_window FROM ".$table_name." WHERE parent_id = '0' AND menu_id='".$woo_custom_nav_menu_id."' ORDER BY position ASC" ); } //BACKEND else { $woo_custom_nav_menu = $wpdb->get_results( "SELECT id,post_id,parent_id,position,custom_title,custom_link,custom_description,menu_icon,link_type,custom_anchor_title,new_window FROM ".$table_name." WHERE parent_id = '0' AND menu_id='".$id."' ORDER BY position ASC" ); } $queried_id = 0; $type_settings = 'custom'; global $wp_query; if (is_page()) { $queried_id = $wp_query->post->ID; $type_settings = 'page'; } elseif (is_category()) { $queried_id = $wp_query->query_vars['cat']; $type_settings = 'category'; } else { } //DISPLAY Loop foreach ($woo_custom_nav_menu as $woo_custom_nav_menu_items) { //PREPARE Menu Data //Page Menu Item if ($woo_custom_nav_menu_items->link_type == 'page') { if ($woo_custom_nav_menu_items->custom_link == '') { $link = get_permalink($woo_custom_nav_menu_items->post_id); } else { $link = $woo_custom_nav_menu_items->custom_link; } if ($woo_custom_nav_menu_items->custom_title == '') { //Convert string to UTF-8 $str_converted = woo_encoding_convert(get_the_title($woo_custom_nav_menu_items->post_id)); $title = htmlspecialchars($str_converted, ENT_QUOTES, 'UTF-8' ); } else { //Convert string to UTF-8 $str_converted = woo_encoding_convert($woo_custom_nav_menu_items->custom_title); $title = htmlspecialchars($str_converted, ENT_QUOTES, 'UTF-8' ); } if ($woo_custom_nav_menu_items->custom_description == '') { //Convert string to UTF-8 $str_converted = woo_encoding_convert(get_post_meta($woo_custom_nav_menu_items->post_id, 'page-description', true)); $description = htmlspecialchars(trim($str_converted), ENT_QUOTES, 'UTF-8' ); } else { //Convert string to UTF-8 $str_converted = woo_encoding_convert($woo_custom_nav_menu_items->custom_description); $description = htmlspecialchars(trim($str_converted), ENT_QUOTES, 'UTF-8' ); } $target = ''; } //Category Menu Item elseif ($woo_custom_nav_menu_items->link_type == 'category') { if ($woo_custom_nav_menu_items->custom_link == '') { $link = get_category_link($woo_custom_nav_menu_items->post_id); } else { $link = $woo_custom_nav_menu_items->custom_link; } if ($woo_custom_nav_menu_items->custom_title == '') { $title_raw = get_categories( 'include='.$woo_custom_nav_menu_items->post_id); //Convert string to UTF-8 $str_converted = woo_encoding_convert($title_raw[0]->cat_name); $title = htmlspecialchars($str_converted, ENT_QUOTES, 'UTF-8' ); } else { //Convert string to UTF-8 $str_converted = woo_encoding_convert($woo_custom_nav_menu_items->custom_title); $title = htmlspecialchars($str_converted, ENT_QUOTES, 'UTF-8' ); } if ($woo_custom_nav_menu_items->custom_description == '') { //Convert string to UTF-8 $str_converted = woo_encoding_convert(category_description($woo_custom_nav_menu_items->post_id)); $description = htmlspecialchars(strip_tags(trim($str_converted)), ENT_QUOTES, 'UTF-8' ); } else { //Convert string to UTF-8 $str_converted = woo_encoding_convert($woo_custom_nav_menu_items->custom_description); $description = htmlspecialchars(trim($str_converted), ENT_QUOTES, 'UTF-8' ); } $target = ''; } //Custom Menu Item else { $link = $woo_custom_nav_menu_items->custom_link; //Convert string to UTF-8 $str_converted = woo_encoding_convert($woo_custom_nav_menu_items->custom_title); $title = htmlspecialchars($str_converted, ENT_QUOTES, 'UTF-8' ); //Convert string to UTF-8 $str_converted = woo_encoding_convert($woo_custom_nav_menu_items->custom_description); $description = htmlspecialchars(trim($str_converted), ENT_QUOTES, 'UTF-8' ); $target = 'target="_blank"'; } //SET anchor title if (isset($woo_custom_nav_menu_items->custom_anchor_title)) { //Convert string to UTF-8 $str_converted = woo_encoding_convert($woo_custom_nav_menu_items->custom_anchor_title); $anchor_title = htmlspecialchars($str_converted, ENT_QUOTES, 'UTF-8' ); } else { $anchor_title = $title; } //SET URL protocol if (isset($_SERVER['HTTPS'])) { if ($_SERVER['HTTPS'] == 'on') { $protocol = 'https'; } else { $protocol = 'http'; } } else { $protocol = 'http'; } $full_web_address = $protocol.'://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; if (($queried_id == $woo_custom_nav_menu_items->post_id) && ($queried_id != 0) && ($type_settings == $woo_custom_nav_menu_items->link_type) ) { $li_class = 'class="current_page_item"'; } else if (($woo_custom_nav_menu_items->custom_link == $full_web_address) && ($queried_id == 0) && ($type_settings == $woo_custom_nav_menu_items->link_type) ) { $li_class = 'class="current_page_item"'; } else if (woo_child_is_current($woo_custom_nav_menu_items->id, $woo_custom_nav_menu_id, $table_name, $queried_id, $type_settings, $full_web_address)) { $li_class = 'class="current_page_parent"'; } else { $li_class = ''; } if (isset($woo_custom_nav_menu_items->new_window)) { if ($woo_custom_nav_menu_items->new_window > 0) { $target = 'target="_blank"'; } else { $target = ''; } } //List Items ?>
  • >>
  • get_results( "SELECT id,post_id,parent_id,position,custom_title,custom_link,custom_description,menu_icon,link_type,custom_anchor_title,new_window FROM ".$table_name." WHERE parent_id = '".$post_id."' AND menu_id='".$menu_id."' ORDER BY position ASC" ); if (empty($woo_custom_nav_menu)) { } else { ?> get_results( "SELECT id,post_id,parent_id,position,custom_title,custom_link,custom_description,menu_icon,link_type,custom_anchor_title,new_window FROM ".$table_name." WHERE parent_id = '".$parent_id."' AND menu_id='".$menu_id."' ORDER BY position ASC" ); //If more than 0 child elements if (empty($woo_parent_children)) { } else { //Children Loop foreach ($woo_parent_children as $woo_parent_child) { //Check if meets criteria if (($queried_id == $woo_parent_child->post_id) && ($queried_id != 0) && ($type_settings == $woo_parent_child->link_type) ) { $success = true; } else if (($woo_parent_child->custom_link == $full_web_address) && ($queried_id == 0) && ($type_settings == $woo_parent_child->link_type) ) { $success = true; } } } return $success; } //Outputs All Pages and Sub Items function woo_get_pages($counter,$type) { $pages_args = array( 'child_of' => 0, 'sort_order' => 'ASC', 'sort_column' => 'post_title', 'hierarchical' => 1, 'exclude' => '', 'include' => '', 'meta_key' => '', 'meta_value' => '', 'authors' => '', 'parent' => -1, 'exclude_tree' => '', 'number' => '', 'offset' => 0 ); //GET all pages $pages_array = get_pages($pages_args); $intCounter = $counter; $parentli = $intCounter; if ($pages_array) { //DISPLAY Loop foreach ($pages_array as $post) { if ($post->post_parent == 0) { //Custom Menu if ($type == 'menu') { $description = trim(get_post_meta($post->ID, 'page-description', true)); ?>
  • post_title); $post_text = htmlspecialchars($str_converted, ENT_QUOTES, 'UTF-8' ); $post_url = get_permalink($post->ID); $post_id = $post->ID; $post_parent_id = $post->post_parent; //Convert string to UTF-8 $str_converted = woo_encoding_convert(get_post_meta($post_id, 'page-description', true)); $description = htmlspecialchars(trim($str_converted), ENT_QUOTES, 'UTF-8' ); ?> post_title; ?> Add to Custom Menu
    ID; ?>
  • 'post', 'child_of' => 0, 'orderby' => 'name', 'order' => 'ASC', 'hide_empty' => false, 'include_last_update_time' => false, 'hierarchical' => 1, 'exclude' => '', 'include' => '', 'number' => '', 'pad_counts' => false ); $intCounter = $counter; //GET all categories $categories_array = get_categories($category_args); if ($categories_array) { //DISPLAY Loop foreach ($categories_array as $cat_item) { if ($cat_item->parent == 0) { //Custom Menu if ($type == 'menu') { ?>
  • cat_name); $post_text = htmlspecialchars(addslashes($str_converted), ENT_QUOTES, 'UTF-8' ); $post_url = get_category_link($cat_item->cat_ID); $post_id = $cat_item->cat_ID; $post_parent_id = $cat_item->parent; //Convert string to UTF-8 $str_converted = woo_encoding_convert($cat_item->description); $description = htmlspecialchars(addslashes(strip_tags(trim($str_converted))), ENT_QUOTES, 'UTF-8' ); ?> cat_name; ?> Add to Custom Menu
    cat_ID; ?> cat_ID, $intCounter, $parentli, 'categories','default' ); ?>
  • $childof, 'hide_empty' => false, 'parent' => $childof); } //Sidebar Menu elseif ($output_type == 'default') { $sub_args = array( 'child_of' => $childof, 'hide_empty' => false, 'parent' => $childof); } else { } //Get Sub Category Items if ($type == 'categories') { $sub_array = get_categories($sub_args); } //Get Sub Page Items elseif ($type == 'pages') { $sub_array = get_pages($sub_args); } if ($sub_array) { ?> $childof, 'hide_empty' => false, 'parent' => $childof); $sub_array = get_categories($sub_args); } //Get Sub Page Items elseif ($type == 'pages') { $sub_args = array( 'child_of' => $childof, 'parent' => $childof); $sub_array = get_pages($sub_args); } else { } if ($sub_array) { //DISPLAY Loop foreach ($sub_array as $sub_item) { if (isset($sub_item->parent)) { $sub_item_parent = $sub_item->parent; } elseif (isset($sub_item->post_parent)) { $sub_item_parent = $sub_item->post_parent; } else { } //Is child if ($sub_item_parent == $childof) { //Prepare Menu Data //Category Menu Item if ($type == 'categories') { $link = get_category_link($sub_item->cat_ID); //Convert string to UTF-8 //$str_converted = woo_encoding_convert($sub_item->cat_name); //$title = htmlspecialchars($str_converted, ENT_QUOTES, 'UTF-8' ); $title = $sub_item->cat_name; $parent_id = $sub_item->category_parent; $itemid = $sub_item->cat_ID; $linktype = 'category'; $appendtype= 'Category'; } //Page Menu Item elseif ($type == 'pages') { $link = get_permalink($sub_item->ID); //Convert string to UTF-8 //$str_converted = woo_encoding_convert($sub_item->post_title); //$title = htmlspecialchars($str_converted, ENT_QUOTES, 'UTF-8' ); $title = $sub_item->post_title; $parent_id = $sub_item->post_parent; $linktype = 'page'; $itemid = $sub_item->ID; $appendtype= 'Page'; } //Custom Menu Item else { $title = ''; $linktype = 'custom'; $appendtype= 'Custom'; } //CHECK for existing parent records //echo $parent_id; $woo_result = $wpdb->get_results( "SELECT id FROM ".$table_name." WHERE post_id='".$parent_id."' AND link_type='".$linktype."' AND menu_id='".$menu_id."'" ); if ($woo_result > 0 && isset($woo_result[0]->id)) { $parent_id = $woo_result[0]->id; } else { //$parent_id = 0; } //INSERT item //Convert string to UTF-8 $str_converted = stripslashes($title); //$insert_title = htmlspecialchars($str_converted, ENT_QUOTES, 'UTF-8' ); //$insert = "INSERT INTO ".$table_name." (position,post_id,parent_id,custom_title,custom_link,custom_description,menu_icon,link_type,menu_id,custom_anchor_title) "."VALUES ( '".$counter."','".$itemid."','".$parent_id."','".$title."','".$link."','','','".$linktype."','".$menu_id."','".$title."')"; //$results = $wpdb->query( $insert ); $results = $wpdb->insert( $table_name, array( 'position' => $counter, 'post_id' => $itemid, 'parent_id' => $parent_id, 'custom_title' => $str_converted, 'custom_link' => $link, 'custom_description' => '', 'menu_icon' => '', 'link_type' => $linktype, 'menu_id' => $menu_id, 'custom_anchor_title' => $str_converted )); $counter++; $counter = get_children_menu_elements($itemid, $counter, $parent_id, $type, $menu_id, $table_name); } //Do nothing else { } } } return $counter; } /*---------------------------------------------------------------------------------*/ /* Woothemes Custom Navigation Menu Widget */ /*---------------------------------------------------------------------------------*/ class Woo_NavWidget extends WP_Widget { function Woo_NavWidget() { $widget_ops = array( 'description' => 'Use this widget to add one of your Woo Custom Navigation Menus as a widget.' ); parent::WP_Widget(false, __( 'Woo - Custom Nav Menu', 'woothemes' ),$widget_ops); } function widget($args, $instance) { $navmenu = $instance['navmenu']; $navtitle = $instance['navtitle']; $navdeveloper = strtolower($instance['navdeveloper']); if (isset($instance['navdiv'])) { $navdiv = strtolower($instance['navdiv']); } else { $navdiv = 'no';} if (isset($instance['navul'])) { $navul = strtolower($instance['navul']); } else { $navul = 'no';} if (isset($instance['navwidgetdescription'])) { $navwidgetdescription = strtolower($instance['navwidgetdescription']); } else { $navwidgetdescription = '2';} $menuexists = false; global $wpdb; //GET menu name if ($navmenu > 0) { $table_name_menus = $wpdb->prefix . "woo_custom_nav_menus"; $woo_result = $wpdb->get_results( "SELECT menu_name FROM ".$table_name_menus." WHERE id='".$navmenu."'" ); $woo_custom_nav_menu_name = $woo_result[0]->menu_name; $menuexists = true; } //Do nothing else { $menuexists = false; } ?>

    prefix . "woo_custom_nav_menus"; $custom_menu_records = $wpdb->get_results( "SELECT id,menu_name FROM ".$table_name_custom_menus); //CHECK if menus exist if ($custom_menu_records > 0) { ?>


    /> />


    /> />


    /> />

    style="display:none;">
    /> />