'') { $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; ?>
'.$themename.'\'s Custom Menu has been updated!
'.$insert_menu_name.' Menu has already created - please try another name
'.$insert_menu_name.' Menu has been created!
Please enter a valid Menu name
'.$themename.'\'s Custom Menu has been RESET!
'.$themename.'\'s Custom Menu could not be RESET. Please try again.
'.$themename.'\'s Custom Menu has been updated!
'.$themename.'\'s Custom Menu has been RESET!
'.$themename.'\'s Custom Menu could not be RESET. Please try again.
Custom NavigationThe Custom Menu has not been Enabled yet. Please enable it in order to use it -------->
You have WordPress 3.0.x installed!
We suggest that you use the WordPress Menu Management system instead of the Custom Navigation.
; ?>/functions/images/ico-add.png)
/>
/>
/>
/>
/>
/>
style="display:none;">
/>
/>