<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[13262] trunk: Rename file.</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/13262">13262</a></dd>
<dt>Author</dt> <dd>ryan</dd>
<dt>Date</dt> <dd>2010-02-20 23:18:57 +0000 (Sat, 20 Feb 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>Rename file. see <a href="http://trac.wordpress.org/ticket/11817">#11817</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadmincustomnavigationphp">trunk/wp-admin/custom-navigation.php</a></li>
<li><a href="#trunkwpincludesgeneraltemplatephp">trunk/wp-includes/general-template.php</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkwpincludescustomnavigationphp">trunk/wp-includes/custom-navigation.php</a></li>
</ul>

<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkwpincludescustomnavigationfunctionsphp">trunk/wp-includes/custom-navigation-functions.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadmincustomnavigationphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/custom-navigation.php (13261 => 13262)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/custom-navigation.php        2010-02-20 22:44:24 UTC (rev 13261)
+++ trunk/wp-admin/custom-navigation.php        2010-02-20 23:18:57 UTC (rev 13262)
</span><span class="lines">@@ -22,7 +22,7 @@
</span><span class="cx"> wp_enqueue_script( 'jquery-ui-dialog' );
</span><span class="cx"> 
</span><span class="cx"> require_once('admin-header.php');
</span><del>-require_once (ABSPATH . WPINC . '/custom-navigation-functions.php');
</del><ins>+require_once (ABSPATH . WPINC . '/custom-navigation.php');
</ins><span class="cx"> 
</span><span class="cx"> wp_custom_navigation();
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkwpincludescustomnavigationfunctionsphp"></a>
<div class="delfile"><h4>Deleted: trunk/wp-includes/custom-navigation-functions.php (13261 => 13262)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/custom-navigation-functions.php        2010-02-20 22:44:24 UTC (rev 13261)
+++ trunk/wp-includes/custom-navigation-functions.php        2010-02-20 23:18:57 UTC (rev 13262)
</span><span class="lines">@@ -1,993 +0,0 @@
</span><del>-&lt;?php
-/**
- * WordPress Administration Custom Navigation
- * General Functions
- *
- * @author Jeffikus &lt;pearce.jp@gmail.com&gt;
- * @version 1.1.0
- *
- * @package WordPress
- * @subpackage Administration
- */
-
-function wp_custom_navigation_get_menu_items( $menu_objects, $key = 'ID' ) {
-        $menu_items = array();
-        if ( !empty( $menu_objects ) &amp;&amp; !empty( $key ) ) {
-                $args = array( 'orderby' =&gt; 'menu_order', 'post_type' =&gt; 'menu_item', 'post_status' =&gt; 'menu-category,menu-page,menu-custom' );
-                if ( count( $menu_objects ) &gt; 1 )
-                        $args['include'] = implode( ',', $menu_objects );
-                else
-                        $args['include'] = $menu_objects[0];
-                $posts = new WP_Query( $args );
-                if ( ! empty( $posts-&gt;posts ) ) {
-                        foreach( $posts-&gt;posts as $post ) {
-                                $menu_items[ $post-&gt;$key ] = $post;
-                        }
-                }
-                unset( $posts );
-                ksort( $menu_items );
-        }
-        return $menu_items;
-}
-function wp_custom_navigation_setup($override = false) {
-        
-        $nav_version = '1.1.0';
-        //Custom Navigation Menu Setup
-        
-        //Check for Upgrades
-        if (get_option('wp_settings_custom_nav_version') &lt;&gt; '') {
-                $nav_version_in_db = get_option('wp_settings_custom_nav_version');
-        }
-        else {
-                $nav_version_in_db = '0';
-        }
-        
-        //Override for menu descriptions
-        update_option('wp_settings_custom_nav_advanced_options','yes');
-                        
-        if(($nav_version_in_db &lt;&gt; $nav_version) || ($override)) 
-                update_option('wp_settings_custom_nav_version',$nav_version);
-
-        $custom_menus = get_terms( 'menu', array( 'hide_empty' =&gt; false ) );
-         if ( !empty( $custom_menus ) ) {
-                foreach( $custom_menus as $menu ) {
-                        $menu_objects = get_objects_in_term( $menu-&gt;term_id, 'menu' );
-                        if ( !empty( $menu_objects ) ) {
-                                foreach( $menu_objects as $item )
-                                        wp_delete_post( $item );
-                        }
-                        wp_delete_term( $menu-&gt;term_id, 'menu' );
-                }
-        }
-
-}
-
-/*-----------------------------------------------------------------------------------*/
-/* Custom Navigation Functions */
-/* wp_custom_navigation_output() displays the menu in the back/frontend
-/* wp_custom_navigation_sub_items() is a recursive sub menu item function
-/* wp_custom_nav_get_pages()
-/* wp_custom_nav_get_categories()
-/* wp_custom_navigation_default_sub_items() is a recursive sub menu item function
-/*-----------------------------------------------------------------------------------*/
-
-/*-----------------------------------------------------------------------------------*/
-/* Main Output Function
-/* args list
-/* type - frontend or backend
-/* name - name of your menu
-/* id - id of menu in db
-/* desc - 1 = show descriptions, 2 = dont show descriptions
-/* before_title - html before title is outputted in &lt;a&gt; tag
-/* after_title - html after title is outputted in &lt;a&gt; tag
-/*-----------------------------------------------------------------------------------*/
-
-function wp_custom_navigation_output($args = array()) {
-                
-                //DEFAULT ARGS
-                $type = 'frontend';
-                $name = 'Menu 1'; 
-                $id = 0;
-                $desc = 2;
-                $before_title = '';
-                $after_title = '';
-                
-                if (isset($args)) {
-                
-                        if ( !is_array($args) ) 
-                        parse_str( $args, $args );
-        
-                        extract($args);
-                }
-
-                $menu_objects = get_objects_in_term( $id, 'menu' );
-                $menu_items = wp_custom_navigation_get_menu_items( $menu_objects, 'menu_order' );
-                //Override for menu descriptions
-                $advanced_option_descriptions = get_option('wp_settings_custom_nav_advanced_options');
-                if ($advanced_option_descriptions == 'no')
-                {
-                        $desc = 2;
-                }
-                
-                $queried_id = 0;
-                global $wp_query;
-                if ( is_page() )
-                        $queried_id = $wp_query-&gt;post-&gt;ID;
-                elseif ( is_category() )
-                        $queried_id = $wp_query-&gt;query_vars['cat'];
-            //DISPLAY Loop
-                foreach ($menu_items as $menu_item) {
-
-                        //PREPARE Menu Data
-                        //Page Menu Item
-                        switch ( $menu_item-&gt;post_status ) {
-                                case 'menu-page':
-                                        if ($menu_item-&gt;guid == '')
-                                                $link = get_permalink( $menu_item-&gt;post_parent );
-                                        else
-                                                $link = $menu_item-&gt;guid;
-
-                                        if ( $menu_item-&gt;post_title == '' )
-                                                $title = htmlentities( get_the_title( $menu_item-&gt;post_parent ) );
-                                        else
-                                                $title = htmlentities( $menu_item-&gt;post_title );
-
-                                        if ( $menu_item-&gt;post_content == '' )
-                                                $description = htmlentities( get_post_meta( $menu_item-&gt;ID, 'page-description', true ) );
-                                        else
-                                                $description = htmlentities( $menu_item-&gt;post_content );
-                                        $target = '';
-                                break;
-                        //Category Menu Item
-                                case 'menu-category':
-                                        if ($menu_item-&gt;guid == '')
-                                                $link = get_category_link( $menu_item-&gt;post_parent );
-                                        else
-                                                $link = $menu_item-&gt;guid;
-                                
-                                        if ( $menu_item-&gt;post_title == '' ) {
-                                                $title_raw = get_categories( 'include='.$menu_item-&gt;post_parent );
-                                                $title =  htmlentities($title_raw[0]-&gt;cat_name);        
-                                        } else {
-                                                $title = htmlentities( $menu_item-&gt;post_title );
-                                        }
-                                
-                                        if ( $menu_item-&gt;post_content == '' )
-                                                $description = htmlentities( strip_tags( category_description( $menu_item-&gt;post_parent ) ) );
-                                        else
-                                                $description = htmlentities( $menu_item-&gt;post_content );
-                                        $target = '';
-                                break;
-                                default:
-                        //Custom Menu Item
-                                        $link = $menu_item-&gt;guid;
-                                        $title =  htmlentities( $menu_item-&gt;post_title );
-                                        $description = htmlentities( $menu_item-&gt;post_content );
-                                        $target = 'target=&quot;_blank&quot;';
-                                break;
-                        }
-/* @todo: update to use tax/post data
-
-                        //SET anchor title
-                        if (isset($wp_custom_nav_menu_items-&gt;custom_anchor_title)) {
-                                $anchor_title = htmlentities($wp_custom_nav_menu_items-&gt;custom_anchor_title);
-                        }
-                        else {
-                                $anchor_title = $title;
-                        }
-                        
-                        if ($queried_id == $wp_custom_nav_menu_items-&gt;post_id) {
-                                $li_class = 'class=&quot;current_page_item&quot;';
-                        }
-                        else {
-                                $li_class = '';
-                        }
-                        
-                        if (isset($wp_custom_nav_menu_items-&gt;new_window)) {
-                                if ($wp_custom_nav_menu_items-&gt;new_window &gt; 0) {
-                                        $target = 'target=&quot;_blank&quot;';
-                                }
-                                else {
-                                        $target = '';
-                                }
-                        }
-*/                        
-                        //List Items
-                        ?&gt;&lt;li id=&quot;menu-&lt;?php echo $menu_item-&gt;ID; ?&gt;&quot; value=&quot;&lt;?php echo $menu_item-&gt;ID; ?&gt;&quot; &lt;?php echo $li_class; ?&gt;&gt;&lt;?php
-                                        //@todo: update front end to use post data
-                                        //FRONTEND Link
-                                        if ($type == &quot;frontend&quot;)
-                                        {                
-                                                ?&gt;&lt;a title=&quot;&lt;?php echo $anchor_title; ?&gt;&quot; href=&quot;&lt;?php echo $link; ?&gt;&quot; &lt;?php echo $target; ?&gt;&gt;&lt;?php echo $before_title.$title.$after_title; ?&gt;&lt;?php 
-                                                
-                                                        if ( $advanced_option_descriptions == 'no' ) 
-                                                        { 
-                                                                // 2 widget override do NOT display descriptions
-                                                                // 1 widget override display descriptions
-                                                                // 0 widget override not set
-                                                                if (($desc == 1) || ($desc == 0) )
-                                                                {
-                                                                        ?&gt;&lt;span class=&quot;nav-description&quot;&gt;&lt;?php echo $description; ?&gt;&lt;/span&gt;&lt;?php
-                                                                } 
-                                                                elseif ($desc == 2)
-                                                                { }
-                                                                else
-                                                                { }
-                                                        } 
-                                                        else 
-                                                        {
-                                                                // 2 widget override do NOT display descriptions
-                                                                // 1 widget override display descriptions
-                                                                // 0 widget override not set
-                                                                if ($desc == 1)
-                                                                {
-                                                                        ?&gt;&lt;span class=&quot;nav-description&quot;&gt;&lt;?php echo $description; ?&gt;&lt;/span&gt;&lt;?php
-                                                                } 
-                                                                elseif (($desc == 2) || ($desc == 0))
-                                                                { }
-                                                                else 
-                                                                { }
-                                                        }
-                                                        
-                                                ?&gt;&lt;/a&gt;&lt;?php 
-                                        }
-                                        //BACKEND draggable and droppable elements
-                                        elseif ($type == &quot;backend&quot;)
-                                                $link_type = substr( $menu_item-&gt;post_status, 5 );
-                                        {
-                                                ?&gt;
-                                                
-                                                &lt;dl&gt;
-                                                        &lt;dt&gt;
-                                                                &lt;span class=&quot;title&quot;&gt;&lt;?php echo $title; ?&gt;&lt;/span&gt;
-                                                                &lt;span class=&quot;controls&quot;&gt;
-                                                                &lt;span class=&quot;type&quot;&gt;&lt;?php echo $link_type; ?&gt;&lt;/span&gt;
-                                                                &lt;a id=&quot;edit&lt;?php echo $menu_item-&gt;menu_order; ?&gt;&quot; onclick=&quot;edititem(&lt;?php echo $menu_item-&gt;menu_order; ?&gt;)&quot; value=&quot;&lt;?php echo $menu_item-&gt;menu_order; ?&gt;&quot;&gt;&lt;img class=&quot;edit&quot; alt=&quot;Edit Menu Item&quot; title=&quot;Edit Menu Item&quot; src=&quot;&lt;?php echo get_bloginfo('url'); ?&gt;/wp-admin/images/ico-edit.png&quot; /&gt;&lt;/a&gt;
-                                                                &lt;a id=&quot;remove&lt;?php echo $menu_item-&gt;menu_order; ?&gt;&quot; onclick=&quot;removeitem(&lt;?php echo $menu_item-&gt;menu_order; ?&gt;)&quot; value=&quot;&lt;?php echo $menu_item-&gt;menu_order; ?&gt;&quot;&gt;&lt;img class=&quot;remove&quot; alt=&quot;Remove from Custom Menu&quot; title=&quot;Remove from Custom Menu&quot; src=&quot;&lt;?php echo get_bloginfo('url'); ?&gt;/wp-admin/images/ico-close.png&quot; /&gt;&lt;/a&gt;
-                                                                &lt;a id=&quot;view&lt;?php echo $menu_item-&gt;menu_order; ?&gt;&quot; target=&quot;_blank&quot; href=&quot;&lt;?php echo $link; ?&gt;&quot;&gt;&lt;img alt=&quot;View Page&quot; title=&quot;View Page&quot; src=&quot;&lt;?php echo get_bloginfo('url'); ?&gt;/wp-admin/images/ico-viewpage.png&quot; /&gt;&lt;/a&gt;
-                                                                &lt;/span&gt;
-                                                        &lt;/dt&gt;
-                                                &lt;/dl&gt;
-                                                
-                                                &lt;a&gt;&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;/a&gt;
-                                                &lt;input type=&quot;hidden&quot; name=&quot;dbid&lt;?php echo $menu_item-&gt;menu_order; ?&gt;&quot; id=&quot;dbid&lt;?php echo $menu_item-&gt;menu_order; ?&gt;&quot; value=&quot;&lt;?php echo $menu_item-&gt;ID; ?&gt;&quot; /&gt;
-                                                &lt;input type=&quot;hidden&quot; name=&quot;postmenu&lt;?php echo $menu_item-&gt;menu_order; ?&gt;&quot; id=&quot;postmenu&lt;?php echo $menu_item-&gt;menu_order; ?&gt;&quot; value=&quot;&lt;?php echo $id; ?&gt;&quot; /&gt;
-                                                &lt;input type=&quot;hidden&quot; name=&quot;parent&lt;?php echo $menu_item-&gt;menu_order; ?&gt;&quot; id=&quot;parent&lt;?php echo $menu_item-&gt;menu_order; ?&gt;&quot; value=&quot;&lt;?php echo $menu_item-&gt;post_parent; ?&gt;&quot; /&gt;
-                                                &lt;input type=&quot;hidden&quot; name=&quot;title&lt;?php echo $menu_item-&gt;menu_order; ?&gt;&quot; id=&quot;title&lt;?php echo $menu_item-&gt;menu_order; ?&gt;&quot; value=&quot;&lt;?php echo $title; ?&gt;&quot; /&gt;
-                                                &lt;input type=&quot;hidden&quot; name=&quot;linkurl&lt;?php echo $menu_item-&gt;menu_order; ?&gt;&quot; id=&quot;linkurl&lt;?php echo $menu_item-&gt;menu_order; ?&gt;&quot; value=&quot;&lt;?php echo $link; ?&gt;&quot; /&gt;
-                                                &lt;input type=&quot;hidden&quot; name=&quot;description&lt;?php echo $menu_item-&gt;menu_order; ?&gt;&quot; id=&quot;description&lt;?php echo $menu_item-&gt;menu_order; ?&gt;&quot; value=&quot;&lt;?php echo $description; ?&gt;&quot; /&gt;
-                                                &lt;input type=&quot;hidden&quot; name=&quot;icon&lt;?php echo $menu_item-&gt;menu_order; ?&gt;&quot; id=&quot;icon&lt;?php echo $menu_item-&gt;menu_order; ?&gt;&quot; value=&quot;0&quot; /&gt;
-                                                &lt;input type=&quot;hidden&quot; name=&quot;position&lt;?php echo $menu_item-&gt;menu_order; ?&gt;&quot; id=&quot;position&lt;?php echo $menu_item-&gt;menu_order; ?&gt;&quot; value=&quot;&lt;?php echo $menu_item-&gt;menu_order; ?&gt;&quot; /&gt;
-                                                &lt;input type=&quot;hidden&quot; name=&quot;linktype&lt;?php echo $menu_item-&gt;menu_order; ?&gt;&quot; id=&quot;linktype&lt;?php echo $menu_item-&gt;menu_order; ?&gt;&quot; value=&quot;&lt;?php echo $link_type; ?&gt;&quot; /&gt;
-                                                &lt;input type=&quot;hidden&quot; name=&quot;anchortitle&lt;?php echo $menu_item-&gt;menu_order; ?&gt;&quot; id=&quot;anchortitle&lt;?php echo $menu_item-&gt;menu_order; ?&gt;&quot; value=&quot;&lt;?php echo esc_html( $menu_item-&gt;post_excerpt ); ?&gt;&quot; /&gt;
-                                                &lt;input type=&quot;hidden&quot; name=&quot;newwindow&lt;?php echo $menu_item-&gt;menu_order; ?&gt;&quot; id=&quot;newwindow&lt;?php echo $menu_item-&gt;menu_order; ?&gt;&quot; value=&quot;&lt;?php echo ( '' == $menu_item-&gt;post_content_filtered ? '0' : '1' ); ?&gt;&quot; /&gt;
-                                                
-                                                &lt;?php 
-                                        }
-
-                                        //@todo: implement menu heirarchy
-/*                                        //DISPLAY menu sub items
-                                        if ($wp_custom_nav_menu_items-&gt;parent_id == 0) 
-                                        {
-                                                //FRONTEND
-                                                if ($type == 'frontend') 
-                                                {
-                                                        //Recursive function
-                                                        $intj = wp_custom_navigation_sub_items($wp_custom_nav_menu_items-&gt;id,$wp_custom_nav_menu_items-&gt;link_type,$table_name,$type,$wp_custom_nav_menu_id);
-                                                }
-                                                //BACKEND
-                                                else 
-                                                {
-                                                        //Recursive function
-                                                        $intj = wp_custom_navigation_sub_items($wp_custom_nav_menu_items-&gt;id,$wp_custom_nav_menu_items-&gt;link_type,$table_name,$type,$id);
-                                                }
-                                        }
-*/                        ?&gt;&lt;/li&gt;
-                        &lt;?php 
-                }
-}
-//@todo: implement menu heirarchy
-//RECURSIVE Sub Menu Items
-function wp_custom_navigation_sub_items($post_id,$type,$table_name,$output_type,$menu_id = 0) {
-        
-        $parent_id = 0;
-        global $wpdb;
-        
-        //GET sub menu items
-        $wp_custom_nav_menu = $wpdb-&gt;get_results(&quot;SELECT id,post_id,parent_id,position,custom_title,custom_link,custom_description,menu_icon,link_type,custom_anchor_title,new_window FROM &quot;.$table_name.&quot; WHERE parent_id = '&quot;.$post_id.&quot;' AND menu_id='&quot;.$menu_id.&quot;' ORDER BY position ASC&quot;);
-        
-        if (empty($wp_custom_nav_menu))
-        {
-        
-        }
-        else
-        {
-                ?&gt;&lt;ul id=&quot;sub-custom-nav&quot;&gt;
-                &lt;?php
-            $queried_id = 0;
-                global $wp_query;
-        if (is_page()) {
-                    $queried_id = $wp_query-&gt;post-&gt;ID;
-            }
-            elseif (is_category()) {
-                    $queried_id = $wp_query-&gt;query_vars['cat'];
-            }
-            else {
-
-            }
-            //DISPLAY Loop
-                foreach ($wp_custom_nav_menu as $sub_item) 
-                {
-                        //Figure out where the menu item sits
-                        $counter=$sub_item-&gt;position;
-                        
-                        //Prepare Menu Data
-                        //Category Menu Item
-                        if ($sub_item-&gt;link_type == 'category') 
-                        {
-                                
-                                $parent_id = $sub_item-&gt;parent_id;
-                                $post_id = $sub_item-&gt;post_id;
-                                
-                                if ($sub_item-&gt;custom_link == '') {
-                                        $link = get_category_link($sub_item-&gt;post_id);
-                                }
-                                else {
-                                        $link = $sub_item-&gt;custom_link;
-                                }
-                                
-                                if ($sub_item-&gt;custom_title == '') {
-                                        $title_raw = get_categories('include='.$sub_item-&gt;post_id);
-                                        $title =  htmlentities($title_raw[0]-&gt;cat_name);
-                                }
-                                else {
-                                        $title = htmlentities($sub_item-&gt;custom_title);
-                                }
-                                
-                                if ($sub_item-&gt;custom_description == '') {
-                                        $description = strip_tags(category_description($sub_item-&gt;post_id));
-                                }
-                                else {
-                                        $description = $sub_item-&gt;custom_description;
-                                }
-                                $target = '';
-                        }
-                        //Page Menu Item
-                        elseif ($sub_item-&gt;link_type == 'page')
-                        {
-                                
-                                $parent_id = $sub_item-&gt;parent_id;
-                                $post_id = $sub_item-&gt;post_id;
-                                
-                                if ($sub_item-&gt;custom_link == '') {
-                                        $link = get_permalink($sub_item-&gt;post_id);
-                                }
-                                else {
-                                        $link = $sub_item-&gt;custom_link;
-                                }
-
-                                if ($sub_item-&gt;custom_title == '') {
-                                        $title = htmlentities(get_the_title($sub_item-&gt;post_id));
-                                }
-                                else {
-                                        $title = htmlentities($sub_item-&gt;custom_title);
-                                }
-                                
-                                if ($sub_item-&gt;custom_description == '') {
-                                        $description = get_post_meta($sub_item-&gt;post_id, 'page-description', true);
-                                }
-                                else {
-                                        $description = $sub_item-&gt;custom_description;
-                                }
-                                $target = '';
-                                
-                        }
-                        //Custom Menu Item
-                        else
-                        {
-                                $link = $sub_item-&gt;custom_link;
-                                $title = htmlentities($sub_item-&gt;custom_title);
-                                $parent_id = $sub_item-&gt;parent_id;
-                                $post_id = $sub_item-&gt;post_id;
-                                $description = $sub_item-&gt;custom_description;
-                                $target = 'target=&quot;_blank&quot;';
-                        }
-                        if ($queried_id == $sub_item-&gt;post_id) {
-                                $li_class = 'class=&quot;current_page_item&quot;';
-                        }
-                        else {
-                                $li_class = '';
-                        }
-                        
-                        //SET anchor title
-                        if (isset($sub_item-&gt;custom_anchor_title)) {
-                                $anchor_title = htmlentities($sub_item-&gt;custom_anchor_title);
-                        }
-                        else {
-                                $anchor_title = $title;
-                        }
-                        
-                        if (isset($sub_item-&gt;new_window)) {
-                                if ($sub_item-&gt;new_window &gt; 0) {
-                                        $target = 'target=&quot;_blank&quot;';
-                                }
-                        }
-                        
-                        //List Items
-                        ?&gt;&lt;li id=&quot;menu-&lt;?php echo $counter; ?&gt;&quot; value=&quot;&lt;?php echo $counter; ?&gt;&quot; &lt;?php echo $li_class; ?&gt;&gt;&lt;?php 
-                                                //FRONTEND
-                                                if ($output_type == &quot;frontend&quot;)
-                                                {
-                                                        ?&gt;&lt;a title=&quot;&lt;?php echo $anchor_title; ?&gt;&quot; href=&quot;&lt;?php echo $link; ?&gt;&quot; &lt;?php echo $target; ?&gt;&gt;&lt;?php echo $title; ?&gt;&lt;/a&gt;&lt;?php 
-                                                }
-                                                //BACKEND
-                                                elseif ($output_type == &quot;backend&quot;)
-                                                {
-                                                        ?&gt;
-                                                        &lt;dl&gt;
-                                                        &lt;dt&gt;
-                                                                &lt;span class=&quot;title&quot;&gt;&lt;?php echo $title; ?&gt;&lt;/span&gt;
-                                                                &lt;span class=&quot;controls&quot;&gt;
-                                                                &lt;span class=&quot;type&quot;&gt;&lt;?php echo $sub_item-&gt;link_type; ?&gt;&lt;/span&gt;
-                                                                &lt;a id=&quot;edit&lt;?php echo $counter; ?&gt;&quot; onclick=&quot;edititem(&lt;?php echo $counter; ?&gt;)&quot; value=&quot;&lt;?php echo $counter; ?&gt;&quot;&gt;&lt;img class=&quot;edit&quot; alt=&quot;Edit Menu Item&quot; title=&quot;Edit Menu Item&quot; src=&quot;&lt;?php echo get_bloginfo('url'); ?&gt;/wp-admin/images/ico-edit.png&quot; /&gt;&lt;/a&gt; 
-                                                                &lt;a id=&quot;remove&lt;?php echo $counter; ?&gt;&quot; onclick=&quot;removeitem(&lt;?php echo $counter; ?&gt;)&quot; value=&quot;&lt;?php echo $counter; ?&gt;&quot;&gt;&lt;img class=&quot;remove&quot; alt=&quot;Remove from Custom Menu&quot; title=&quot;Remove from Custom Menu&quot; src=&quot;&lt;?php echo get_bloginfo('url'); ?&gt;/wp-admin/images/ico-close.png&quot; /&gt;&lt;/a&gt;
-                                                                &lt;a id=&quot;view&lt;?php echo $counter; ?&gt;&quot; target=&quot;_blank&quot; href=&quot;&lt;?php echo $link; ?&gt;&quot;&gt;&lt;img alt=&quot;View Page&quot; title=&quot;View Page&quot; src=&quot;&lt;?php echo get_bloginfo('url'); ?&gt;/wp-admin/images/ico-viewpage.png&quot; /&gt;&lt;/a&gt;
-                                                                &lt;/span&gt;
-                                                        &lt;/dt&gt;
-                                                        &lt;/dl&gt;
-                                                        &lt;a class=&quot;hide&quot; href=&quot;&lt;?php echo $link; ?&gt;&quot;&gt;&lt;?php echo $title; ?&gt;&lt;/a&gt;
-                                                        &lt;input type=&quot;hidden&quot; name=&quot;dbid&lt;?php echo $counter; ?&gt;&quot; id=&quot;dbid&lt;?php echo $counter; ?&gt;&quot; value=&quot;&lt;?php echo $sub_item-&gt;id; ?&gt;&quot; /&gt;
-                                                        &lt;input type=&quot;hidden&quot; name=&quot;postmenu&lt;?php echo $counter; ?&gt;&quot; id=&quot;postmenu&lt;?php echo $counter; ?&gt;&quot; value=&quot;&lt;?php echo $post_id; ?&gt;&quot; /&gt;
-                                                        &lt;input type=&quot;hidden&quot; name=&quot;parent&lt;?php echo $counter; ?&gt;&quot; id=&quot;parent&lt;?php echo $counter; ?&gt;&quot; value=&quot;&lt;?php echo $parent_id; ?&gt;&quot; /&gt;
-                                                        &lt;input type=&quot;hidden&quot; name=&quot;title&lt;?php echo $counter; ?&gt;&quot; id=&quot;title&lt;?php echo $counter; ?&gt;&quot; value=&quot;&lt;?php echo $title; ?&gt;&quot; /&gt;
-                                                        &lt;input type=&quot;hidden&quot; name=&quot;linkurl&lt;?php echo $counter; ?&gt;&quot; id=&quot;linkurl&lt;?php echo $counter; ?&gt;&quot; value=&quot;&lt;?php echo $link; ?&gt;&quot; /&gt;
-                                                        &lt;input type=&quot;hidden&quot; name=&quot;description&lt;?php echo $counter; ?&gt;&quot; id=&quot;description&lt;?php echo $counter; ?&gt;&quot; value=&quot;&lt;?php echo $description; ?&gt;&quot; /&gt;
-                                                        &lt;input type=&quot;hidden&quot; name=&quot;icon&lt;?php echo $counter; ?&gt;&quot; id=&quot;icon&lt;?php echo $counter; ?&gt;&quot; value=&quot;0&quot; /&gt;
-                                                        &lt;input type=&quot;hidden&quot; name=&quot;position&lt;?php echo $counter; ?&gt;&quot; id=&quot;position&lt;?php echo $counter; ?&gt;&quot; value=&quot;&lt;?php echo $counter; ?&gt;&quot; /&gt;
-                                                        &lt;input type=&quot;hidden&quot; name=&quot;linktype&lt;?php echo $counter; ?&gt;&quot; id=&quot;linktype&lt;?php echo $counter; ?&gt;&quot; value=&quot;&lt;?php echo $sub_item-&gt;link_type; ?&gt;&quot; /&gt;
-                                                        &lt;input type=&quot;hidden&quot; name=&quot;anchortitle&lt;?php echo $counter; ?&gt;&quot; id=&quot;anchortitle&lt;?php echo $counter; ?&gt;&quot; value=&quot;&lt;?php echo $anchor_title; ?&gt;&quot; /&gt;
-                                                        &lt;input type=&quot;hidden&quot; name=&quot;newwindow&lt;?php echo $counter; ?&gt;&quot; id=&quot;newwindow&lt;?php echo $counter; ?&gt;&quot; value=&quot;&lt;?php echo $sub_item-&gt;new_window; ?&gt;&quot; /&gt;
-                                                        &lt;?php 
-                                                }
-                                                
-                                                //Do recursion
-                                                wp_custom_navigation_sub_items($sub_item-&gt;id,$sub_item-&gt;link_type,$table_name,$output_type,$menu_id); 
-                        ?&gt;&lt;/li&gt;
-                        &lt;?php 
-        
-                } 
-        
-        ?&gt;&lt;/ul&gt;
-        &lt;?php 
-        
-        } 
-        
-        return $parent_id;

-}
-
-
-//Outputs All Pages and Sub Items
-function wp_custom_nav_get_pages($counter,$type) {
-
-        $pages_args = array(
-                    'child_of' =&gt; 0,
-                        'sort_order' =&gt; 'ASC',
-                        'sort_column' =&gt; 'post_title',
-                        'hierarchical' =&gt; 1,
-                        'exclude' =&gt; '',
-                        'include' =&gt; '',
-                        'meta_key' =&gt; '',
-                        'meta_value' =&gt; '',
-                        'authors' =&gt; '',
-                        'parent' =&gt; -1,
-                        'exclude_tree' =&gt; '',
-                        'number' =&gt; '',
-                        'offset' =&gt; 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-&gt;post_parent == 0)
-                        {
-                                //Custom Menu
-                                if ($type == 'menu')
-                                {
-                                        $description = get_post_meta($post-&gt;ID, 'page-description', true);
-                                        ?&gt;
-                                        
-                                        &lt;li id=&quot;menu-&lt;?php echo $intCounter; ?&gt;&quot; value=&quot;&lt;?php echo $intCounter; ?&gt;&quot;&gt;
-                                
-                                                &lt;dl&gt;
-                                                &lt;dt&gt;
-                                                &lt;span class=&quot;title&quot;&gt;&lt;?php echo $post-&gt;post_title; ?&gt;&lt;/span&gt;
-                                                &lt;span class=&quot;controls&quot;&gt;
-                                                        &lt;span class=&quot;type&quot;&gt;page&lt;/span&gt;
-                                                        &lt;a id=&quot;edit&lt;?php echo $intCounter; ?&gt;&quot; onclick=&quot;edititem(&lt;?php echo $intCounter; ?&gt;)&quot; value=&quot;&lt;?php echo $intCounter; ?&gt;&quot;&gt;&lt;img class=&quot;edit&quot; alt=&quot;Edit Menu Item&quot; title=&quot;Edit Menu Item&quot; src=&quot;&lt;?php echo get_bloginfo('url'); ?&gt;/wp-admin/images/ico-edit.png&quot; /&gt;&lt;/a&gt; 
-                                                        &lt;a id=&quot;remove&lt;?php echo $intCounter; ?&gt;&quot; onclick=&quot;removeitem(&lt;?php echo $intCounter; ?&gt;)&quot; value=&quot;&lt;?php echo $intCounter; ?&gt;&quot;&gt;
-                                                                &lt;img class=&quot;remove&quot; alt=&quot;Remove from Custom Menu&quot; title=&quot;Remove from Custom Menu&quot; src=&quot;&lt;?php echo get_bloginfo('url'); ?&gt;/wp-admin/images/ico-close.png&quot; /&gt;
-                                                        &lt;/a&gt;
-                                                        &lt;a target=&quot;_blank&quot; href=&quot;&lt;?php echo get_permalink($post-&gt;ID); ?&gt;&quot;&gt;
-                                                                &lt;img alt=&quot;View Page&quot; title=&quot;View Page&quot; src=&quot;&lt;?php echo get_bloginfo('url'); ?&gt;/wp-admin/images/ico-viewpage.png&quot; /&gt;
-                                                        &lt;/a&gt;
-                                                &lt;/span&gt;
-                                                
-                                                &lt;/dt&gt;
-                                                &lt;/dl&gt;
-                                                &lt;a class=&quot;hide&quot; href=&quot;&lt;?php echo get_permalink($post-&gt;ID); ?&gt;&quot;&gt;&lt;span class=&quot;title&quot;&gt;&lt;?php echo $post-&gt;post_title; ?&gt;&lt;/span&gt;
-                                        &lt;/a&gt;
-                                        &lt;input type=&quot;hidden&quot; name=&quot;postmenu&lt;?php echo $intCounter; ?&gt;&quot; id=&quot;postmenu&lt;?php echo $intCounter; ?&gt;&quot; value=&quot;&lt;?php echo $post-&gt;ID; ?&gt;&quot; /&gt;
-                                                &lt;input type=&quot;hidden&quot; name=&quot;parent&lt;?php echo $intCounter; ?&gt;&quot; id=&quot;parent&lt;?php echo $intCounter; ?&gt;&quot; value=&quot;0&quot; /&gt;
-                                                &lt;input type=&quot;hidden&quot; name=&quot;title&lt;?php echo $intCounter; ?&gt;&quot; id=&quot;title&lt;?php echo $intCounter; ?&gt;&quot; value=&quot;&lt;?php echo htmlentities($post-&gt;post_title); ?&gt;&quot; /&gt;
-                                                &lt;input type=&quot;hidden&quot; name=&quot;linkurl&lt;?php echo $intCounter; ?&gt;&quot; id=&quot;linkurl&lt;?php echo $intCounter; ?&gt;&quot; value=&quot;&lt;?php echo get_permalink($post-&gt;ID); ?&gt;&quot; /&gt;
-                                                &lt;input type=&quot;hidden&quot; name=&quot;description&lt;?php echo $intCounter; ?&gt;&quot; id=&quot;description&lt;?php echo $intCounter; ?&gt;&quot; value=&quot;&lt;?php echo $description; ?&gt;&quot; /&gt;
-                                                &lt;input type=&quot;hidden&quot; name=&quot;icon&lt;?php echo $intCounter; ?&gt;&quot; id=&quot;icon&lt;?php echo $intCounter; ?&gt;&quot; value=&quot;0&quot; /&gt;
-                                                &lt;input type=&quot;hidden&quot; name=&quot;position&lt;?php echo $intCounter; ?&gt;&quot; id=&quot;position&lt;?php echo $intCounter; ?&gt;&quot; value=&quot;&lt;?php echo $intCounter; ?&gt;&quot; /&gt;
-                                                &lt;input type=&quot;hidden&quot; name=&quot;linktype&lt;?php echo $intCounter; ?&gt;&quot; id=&quot;linktype&lt;?php echo $intCounter; ?&gt;&quot; value=&quot;page&quot; /&gt;
-                                                &lt;input type=&quot;hidden&quot; name=&quot;anchortitle&lt;?php echo $intCounter; ?&gt;&quot; id=&quot;anchortitle&lt;?php echo $intCounter; ?&gt;&quot; value=&quot;&lt;?php echo htmlentities($post-&gt;post_title); ?&gt;&quot; /&gt;
-                                                &lt;input type=&quot;hidden&quot; name=&quot;newwindow&lt;?php echo $intCounter; ?&gt;&quot; id=&quot;newwindow&lt;?php echo $intCounter; ?&gt;&quot; value=&quot;0&quot; /&gt;
-                                                
-                                                &lt;?php $parentli = $post-&gt;ID; ?&gt;
-                                                &lt;?php $intCounter++; ?&gt;                                        
-                                                &lt;?php
-                                                
-                                                        //Recursive function
-                                                        $intCounter = wp_custom_navigation_default_sub_items($post-&gt;ID, $intCounter, $parentli, 'pages', 'menu');
-                                                
-                                                ?&gt;
-                                        
-                                        &lt;/li&gt;
-                                        
-                                        &lt;?php 
-                                        
-                                }
-                                //Sidebar Menu
-                                elseif ($type == 'default')
-                                {
-                                        ?&gt;
-                                         
-                                         &lt;li&gt;
-                                        &lt;dl&gt;
-                                        &lt;dt&gt;
-                                        &lt;?php
-                                                $post_text = htmlentities($post-&gt;post_title);
-                                                $post_url = get_permalink($post-&gt;ID);
-                                                $post_id = $post-&gt;ID;
-                                                $post_parent_id = $post-&gt;post_parent;
-                                                
-                                                        $description = htmlentities(get_post_meta($post_id, 'page-description', true));
-                                                        
-                                        ?&gt;
-                                        &lt;?php $templatedir = get_bloginfo('url'); ?&gt;
-                                        
-                                        &lt;span class=&quot;title&quot;&gt;&lt;?php echo $post-&gt;post_title; ?&gt;&lt;/span&gt; &lt;a onclick=&quot;appendToList('&lt;?php echo $templatedir; ?&gt;','Page','&lt;?php echo $post_text; ?&gt;','&lt;?php echo $post_url; ?&gt;','&lt;?php echo $post_id; ?&gt;','&lt;?php echo $post_parent_id ?&gt;','&lt;?php echo $description; ?&gt;')&quot; name=&quot;&lt;?php echo $post_text; ?&gt;&quot; value=&quot;&lt;?php echo get_permalink($post-&gt;ID); ?&gt;&quot;&gt;&lt;img alt=&quot;Add to Custom Menu&quot; title=&quot;Add to Custom Menu&quot; src=&quot;&lt;?php echo get_bloginfo('url'); ?&gt;/wp-admin/images/ico-add.png&quot; /&gt;&lt;/a&gt;&lt;/dt&gt;
-                                        &lt;/dl&gt;
-                                        &lt;?php $parentli = $post-&gt;ID; ?&gt;
-                                                &lt;?php $intCounter++; ?&gt;                            
-                                        &lt;?php
-                                                
-                                                        //Recursive function
-                                                        $intCounter = wp_custom_navigation_default_sub_items($post_id, $intCounter, $parentli, 'pages', 'default');
-                                                
-                                                 ?&gt;
-                                                
-                                        &lt;/li&gt;
-        
-                                        &lt;?php 
-                                
-                                }
-                                else
-                                {
-                                
-                                }        
-                        } 
-                } 
-        }
-        else 
-        {
-                echo 'Not Found';
-        }
-
-        return $intCounter;
-}
-
-//Outputs All Categories and Sub Items
-function wp_custom_nav_get_categories($counter, $type) {
-
-        $category_args = array(
-                        'type'                     =&gt; 'post',
-                        'child_of'                 =&gt; 0,
-                        'orderby'                  =&gt; 'name',
-                        'order'                    =&gt; 'ASC',
-                        'hide_empty'               =&gt; false,
-                        'include_last_update_time' =&gt; false,
-                        'hierarchical'             =&gt; 1,
-                        'exclude'                  =&gt; '',
-                        'include'                  =&gt; '',
-                        'number'                   =&gt; '',
-                        'pad_counts'               =&gt; 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-&gt;parent == 0)
-                        {
-                                //Custom Menu
-                                if ($type == 'menu')
-                                {
-                                        ?&gt;
-            
-                                    &lt;li id=&quot;menu-&lt;?php echo $intCounter; ?&gt;&quot; value=&quot;&lt;?php echo $intCounter; ?&gt;&quot;&gt;
-                                            &lt;dl&gt;
-                                    &lt;dt&gt;
-                                            &lt;span class=&quot;title&quot;&gt;&lt;?php echo $cat_item-&gt;cat_name; ?&gt;&lt;/span&gt;
-                                                        &lt;span class=&quot;controls&quot;&gt;
-                                                        &lt;span class=&quot;type&quot;&gt;category&lt;/span&gt;
-                                                        &lt;a id=&quot;edit&lt;?php echo $intCounter; ?&gt;&quot; onclick=&quot;edititem(&lt;?php echo $intCounter; ?&gt;)&quot; value=&quot;&lt;?php echo $intCounter; ?&gt;&quot;&gt;&lt;img class=&quot;edit&quot; alt=&quot;Edit Menu Item&quot; title=&quot;Edit Menu Item&quot; src=&quot;&lt;?php echo get_bloginfo('url'); ?&gt;/wp-admin/images/ico-edit.png&quot; /&gt;&lt;/a&gt; 
-                                                        &lt;a id=&quot;remove&lt;?php echo $intCounter; ?&gt;&quot; onclick=&quot;removeitem(&lt;?php echo $intCounter; ?&gt;)&quot; value=&quot;&lt;?php echo $intCounter; ?&gt;&quot;&gt;
-                                                                &lt;img class=&quot;remove&quot; alt=&quot;Remove from Custom Menu&quot; title=&quot;Remove from Custom Menu&quot; src=&quot;&lt;?php echo get_bloginfo('url'); ?&gt;/wp-admin/images/ico-close.png&quot; /&gt;
-                                                        &lt;/a&gt;
-                                                        &lt;a target=&quot;_blank&quot; href=&quot;&lt;?php echo get_category_link($cat_item-&gt;cat_ID); ?&gt;&quot;&gt;
-                                                                &lt;img alt=&quot;View Page&quot; title=&quot;View Page&quot; src=&quot;&lt;?php echo get_bloginfo('url'); ?&gt;/wp-admin/images/ico-viewpage.png&quot; /&gt;
-                                                        &lt;/a&gt;
-                                                        &lt;/span&gt;
-                                        
-                                    &lt;/dt&gt;
-                                    &lt;/dl&gt;
-                                    &lt;a class=&quot;hide&quot; href=&quot;&lt;?php echo get_category_link($cat_item-&gt;cat_ID); ?&gt;&quot;&gt;&lt;span class=&quot;title&quot;&gt;&lt;?php echo $cat_item-&gt;cat_name; ?&gt;&lt;/span&gt;
-                                    &lt;?php 
-                                    $use_cats_raw = get_option('wp_settings_custom_nav_descriptions');
-                                                   $use_cats = strtolower($use_cats_raw);
-                                                   if ($use_cats == 'yes') { ?&gt;
-                                    &lt;br/&gt; &lt;span&gt;&lt;?php echo $cat_item-&gt;category_description; ?&gt;&lt;/span&gt;
-                                    &lt;?php } ?&gt;
-                                                    &lt;/a&gt;
-                                    &lt;input type=&quot;hidden&quot; name=&quot;postmenu&lt;?php echo $intCounter; ?&gt;&quot; id=&quot;postmenu&lt;?php echo $intCounter; ?&gt;&quot; value=&quot;&lt;?php echo $cat_item-&gt;cat_ID; ?&gt;&quot; /&gt;
-                                    &lt;input type=&quot;hidden&quot; name=&quot;parent&lt;?php echo $intCounter; ?&gt;&quot; id=&quot;parent&lt;?php echo $intCounter; ?&gt;&quot; value=&quot;0&quot; /&gt;
-                                    &lt;input type=&quot;hidden&quot; name=&quot;title&lt;?php echo $intCounter; ?&gt;&quot; id=&quot;title&lt;?php echo $intCounter; ?&gt;&quot; value=&quot;&lt;?php echo htmlentities($cat_item-&gt;cat_name); ?&gt;&quot; /&gt;
-                                                &lt;input type=&quot;hidden&quot; name=&quot;linkurl&lt;?php echo $intCounter; ?&gt;&quot; id=&quot;linkurl&lt;?php echo $intCounter; ?&gt;&quot; value=&quot;&lt;?php echo get_category_link($cat_item-&gt;cat_ID); ?&gt;&quot; /&gt;
-                                                &lt;input type=&quot;hidden&quot; name=&quot;description&lt;?php echo $intCounter; ?&gt;&quot; id=&quot;description&lt;?php echo $intCounter; ?&gt;&quot; value=&quot;&lt;?php echo htmlentities($cat_item-&gt;category_description); ?&gt;&quot; /&gt;
-                                                &lt;input type=&quot;hidden&quot; name=&quot;icon&lt;?php echo $intCounter; ?&gt;&quot; id=&quot;icon&lt;?php echo $intCounter; ?&gt;&quot; value=&quot;0&quot; /&gt;
-                                                &lt;input type=&quot;hidden&quot; name=&quot;position&lt;?php echo $intCounter; ?&gt;&quot; id=&quot;position&lt;?php echo $intCounter; ?&gt;&quot; value=&quot;&lt;?php echo $intCounter; ?&gt;&quot; /&gt;
-                                                &lt;input type=&quot;hidden&quot; name=&quot;linktype&lt;?php echo $intCounter; ?&gt;&quot; id=&quot;linktype&lt;?php echo $intCounter; ?&gt;&quot; value=&quot;category&quot; /&gt;
-                                                &lt;input type=&quot;hidden&quot; name=&quot;anchortitle&lt;?php echo $intCounter; ?&gt;&quot; id=&quot;anchortitle&lt;?php echo $intCounter; ?&gt;&quot; value=&quot;&lt;?php echo htmlentities($cat_item-&gt;cat_name); ?&gt;&quot; /&gt;
-                                                &lt;input type=&quot;hidden&quot; name=&quot;newwindow&lt;?php echo $intCounter; ?&gt;&quot; id=&quot;newwindow&lt;?php echo $intCounter; ?&gt;&quot; value=&quot;0&quot; /&gt;
-                                                
-                                    &lt;?php $parentli = $cat_item-&gt;cat_ID; ?&gt;
-                                    &lt;?php $intCounter++; ?&gt;                                        
-                                           &lt;?php
-                                                
-                                                        //Recursive function
-                                                        $intCounter = wp_custom_navigation_default_sub_items($cat_item-&gt;cat_ID, $intCounter, $parentli, 'categories','menu');
-                                                        
-                                                ?&gt;
-                                    
-                                    &lt;/li&gt;
-                                    
-                                    &lt;?php 
-                            }
-                            //Sidebar Menu
-                            elseif ($type == 'default')
-                            {
-                                    ?&gt;
-                                    &lt;li&gt;
-                                                &lt;dl&gt;
-                                                &lt;dt&gt;
-                                                &lt;?php
-                                        $post_text = htmlentities($cat_item-&gt;cat_name);
-                                        $post_url = get_category_link($cat_item-&gt;cat_ID);
-                                        $post_id = $cat_item-&gt;cat_ID;
-                                        $post_parent_id = $cat_item-&gt;parent;
-                                        $description = htmlentities(strip_tags($cat_item-&gt;description));
-                                        ?&gt;
-                                        &lt;?php $templatedir = get_bloginfo('url'); ?&gt;
-                                                &lt;span class=&quot;title&quot;&gt;&lt;?php echo $cat_item-&gt;cat_name; ?&gt;&lt;/span&gt; &lt;a onclick=&quot;appendToList('&lt;?php echo $templatedir; ?&gt;','Category','&lt;?php echo $post_text; ?&gt;','&lt;?php echo $post_url; ?&gt;','&lt;?php echo $post_id; ?&gt;','&lt;?php echo $post_parent_id ?&gt;','&lt;?php echo $description; ?&gt;')&quot; name=&quot;&lt;?php echo $post_text; ?&gt;&quot; value=&quot;&lt;?php echo $post_url;  ?&gt;&quot;&gt;&lt;img alt=&quot;Add to Custom Menu&quot; title=&quot;Add to Custom Menu&quot;  src=&quot;&lt;?php echo get_bloginfo('url'); ?&gt;/wp-admin/images/ico-add.png&quot; /&gt;&lt;/a&gt; &lt;/dt&gt;
-                                                &lt;/dl&gt;
-                                                &lt;?php $parentli = $cat_item-&gt;cat_ID; ?&gt;
-                                    &lt;?php $intCounter++; ?&gt;                
-                                                &lt;?php 
-                                                        //Recursive function
-                                                        $intCounter = wp_custom_navigation_default_sub_items($cat_item-&gt;cat_ID, $intCounter, $parentli, 'categories','default');
-                                                ?&gt;
-                                                
-                                        &lt;/li&gt;
-                                        
-                                        &lt;?php 
-                            }        
-                        } 
-                }
-        }
-        else 
-        {
-                echo 'Not Found';
-        }
-        
-        return $intCounter;
-}
-
-//RECURSIVE Sub Menu Items of default categories and pages
-function wp_custom_navigation_default_sub_items($childof, $intCounter, $parentli, $type, $output_type) {
-
-        $counter = $intCounter;
-        
-        //Custom Menu
-        if ($output_type == 'menu') 
-        {
-                $sub_args = array(
-                'child_of' =&gt; $childof,
-                'hide_empty' =&gt; false,
-                'parent' =&gt; $childof);
-        }
-        //Sidebar Menu
-        elseif ($output_type == 'default') 
-        {
-                $sub_args = array(
-                'child_of' =&gt; $childof,
-                'hide_empty' =&gt; false,
-                'parent' =&gt; $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)
-        {
-                ?&gt;
-                
-                &lt;ul id=&quot;sub-custom-nav-&lt;?php echo $type ?&gt;&quot;&gt;
-                
-                &lt;?php
-                //DISPLAY Loop
-                foreach ($sub_array as $sub_item)
-                {
-                        //Prepare Menu Data
-                        //Category Menu Item
-                        if ($type == 'categories') 
-                        {
-                                $link = get_category_link($sub_item-&gt;cat_ID);
-                                $title = htmlentities($sub_item-&gt;cat_name);
-                                $parent_id = $sub_item-&gt;cat_ID;
-                                $itemid = $sub_item-&gt;cat_ID;
-                                $linktype = 'category';
-                                $appendtype = 'Category';
-                                $description = htmlentities(strip_tags($sub_item-&gt;description));                                
-                        }
-                        //Page Menu Item
-                        elseif ($type == 'pages')
-                        {
-                                $link = get_permalink($sub_item-&gt;ID);
-                                $title = htmlentities($sub_item-&gt;post_title);
-                                $parent_id = $sub_item-&gt;ID;
-                                $linktype = 'page';
-                                $itemid = $sub_item-&gt;ID;
-                                $appendtype = 'Page';
-                                $description = htmlentities(get_post_meta($itemid, 'page-description', true));
-                        }
-                        //Custom Menu Item
-                        else 
-                        {
-                                $title = '';
-                                $linktype = 'custom';
-                                $appendtype= 'Custom';
-                        }
-                        
-                        //Custom Menu
-                        if ($output_type == 'menu')
-                        {
-                                ?&gt;
-                                &lt;li id=&quot;menu-&lt;?php echo $counter; ?&gt;&quot; value=&quot;&lt;?php echo $counter; ?&gt;&quot;&gt;
-                                        &lt;dl&gt;
-                                        &lt;dt&gt;
-                                                &lt;span class=&quot;title&quot;&gt;&lt;?php echo $title; ?&gt;&lt;/span&gt;
-                                                        &lt;span class=&quot;controls&quot;&gt;
-                                                        &lt;span class=&quot;type&quot;&gt;&lt;?php echo $linktype; ?&gt;&lt;/span&gt;
-                                                        &lt;a id=&quot;edit&lt;?php echo $counter; ?&gt;&quot; onclick=&quot;edititem(&lt;?php echo $counter; ?&gt;)&quot; value=&quot;&lt;?php echo $counter; ?&gt;&quot;&gt;&lt;img class=&quot;edit&quot; alt=&quot;Edit Menu Item&quot; title=&quot;Edit Menu Item&quot; src=&quot;&lt;?php echo get_bloginfo('url'); ?&gt;/wp-admin/images/ico-edit.png&quot; /&gt;&lt;/a&gt; 
-                                                                &lt;a id=&quot;remove&lt;?php echo $counter; ?&gt;&quot; onclick=&quot;removeitem(&lt;?php echo $counter; ?&gt;)&quot; value=&quot;&lt;?php echo $counter; ?&gt;&quot;&gt;
-                                                                        &lt;img class=&quot;remove&quot; alt=&quot;Remove from Custom Menu&quot; title=&quot;Remove from Custom Menu&quot; src=&quot;&lt;?php echo get_bloginfo('url'); ?&gt;/wp-admin/images/ico-close.png&quot; /&gt;
-                                                                &lt;/a&gt;
-                                                                &lt;a target=&quot;_blank&quot; href=&quot;&lt;?php echo $link; ?&gt;&quot;&gt;
-                                                                        &lt;img alt=&quot;View Page&quot; title=&quot;View Page&quot; src=&quot;&lt;?php echo get_bloginfo('url'); ?&gt;/wp-admin/images/ico-viewpage.png&quot; /&gt;
-                                                                &lt;/a&gt;
-                                                &lt;/span&gt;
-                        
-                                        &lt;/dt&gt;
-                                        &lt;/dl&gt;
-                                        &lt;a class=&quot;hide&quot; href=&quot;&lt;?php echo $link; ?&gt;&quot;&gt;&lt;?php echo $title; ?&gt;&lt;/a&gt;
-                                        &lt;input type=&quot;hidden&quot; name=&quot;dbid&lt;?php echo $counter; ?&gt;&quot; id=&quot;dbid&lt;?php echo $counter; ?&gt;&quot; value=&quot;&lt;?php echo $sub_item-&gt;id; ?&gt;&quot; /&gt;
-                                        &lt;input type=&quot;hidden&quot; name=&quot;postmenu&lt;?php echo $counter; ?&gt;&quot; id=&quot;postmenu&lt;?php echo $counter; ?&gt;&quot; value=&quot;&lt;?php echo $parent_id; ?&gt;&quot; /&gt;
-                                        &lt;input type=&quot;hidden&quot; name=&quot;parent&lt;?php echo $counter; ?&gt;&quot; id=&quot;parent&lt;?php echo $counter; ?&gt;&quot; value=&quot;&lt;?php echo $parentli; ?&gt;&quot; /&gt;
-                                        &lt;input type=&quot;hidden&quot; name=&quot;title&lt;?php echo $counter; ?&gt;&quot; id=&quot;title&lt;?php echo $counter; ?&gt;&quot; value=&quot;&lt;?php echo $title; ?&gt;&quot; /&gt;
-                                        &lt;input type=&quot;hidden&quot; name=&quot;linkurl&lt;?php echo $counter; ?&gt;&quot; id=&quot;linkurl&lt;?php echo $counter; ?&gt;&quot; value=&quot;&lt;?php echo $link; ?&gt;&quot; /&gt;
-                                        &lt;input type=&quot;hidden&quot; name=&quot;description&lt;?php echo $counter; ?&gt;&quot; id=&quot;description&lt;?php echo $counter; ?&gt;&quot; value=&quot;&lt;?php echo $description; ?&gt;&quot; /&gt;
-                                        &lt;input type=&quot;hidden&quot; name=&quot;icon&lt;?php echo $counter; ?&gt;&quot; id=&quot;icon&lt;?php echo $counter; ?&gt;&quot; value=&quot;0&quot; /&gt;
-                                        &lt;input type=&quot;hidden&quot; name=&quot;position&lt;?php echo $counter; ?&gt;&quot; id=&quot;position&lt;?php echo $counter; ?&gt;&quot; value=&quot;&lt;?php echo $counter; ?&gt;&quot; /&gt;
-                                        &lt;input type=&quot;hidden&quot; name=&quot;linktype&lt;?php echo $counter; ?&gt;&quot; id=&quot;linktype&lt;?php echo $counter; ?&gt;&quot; value=&quot;&lt;?php echo $linktype; ?&gt;&quot; /&gt;
-                                        &lt;input type=&quot;hidden&quot; name=&quot;anchortitle&lt;?php echo $counter; ?&gt;&quot; id=&quot;anchortitle&lt;?php echo $counter; ?&gt;&quot; value=&quot;&lt;?php echo $title; ?&gt;&quot; /&gt;
-                                        &lt;input type=&quot;hidden&quot; name=&quot;newwindow&lt;?php echo $counter; ?&gt;&quot; id=&quot;newwindow&lt;?php echo $counter; ?&gt;&quot; value=&quot;0&quot; /&gt;
-                                        
-                                        &lt;?php $counter++; ?&gt;
-                                        &lt;?php 
-                                                
-                                                //Do recursion
-                                                $counter = wp_custom_navigation_default_sub_items($parent_id, $counter, $parent_id, $type, 'menu'); 
-                                                
-                                        ?&gt;
-                                        
-                                &lt;/li&gt;
-                                &lt;?php 
-                        }
-                        //Sidebar Menu
-                        elseif ($output_type == 'default')
-                        {
-                                        
-                                ?&gt;
-                                &lt;li&gt;
-                                        &lt;dl&gt;
-                                        &lt;dt&gt;
-                                        
-                                        &lt;?php $templatedir = get_bloginfo('url'); ?&gt;
-                                        &lt;span class=&quot;title&quot;&gt;&lt;?php echo $title; ?&gt;&lt;/span&gt; &lt;a onclick=&quot;appendToList('&lt;?php echo $templatedir; ?&gt;','&lt;?php echo $appendtype; ?&gt;','&lt;?php echo $title; ?&gt;','&lt;?php echo $link; ?&gt;','&lt;?php echo $itemid; ?&gt;','&lt;?php echo $parent_id ?&gt;','&lt;?php echo $description; ?&gt;')&quot; name=&quot;&lt;?php echo $title; ?&gt;&quot; value=&quot;&lt;?php echo $link; ?&gt;&quot;&gt;&lt;img alt=&quot;Add to Custom Menu&quot; title=&quot;Add to Custom Menu&quot; src=&quot;&lt;?php echo get_bloginfo('url'); ?&gt;/wp-admin/images/ico-add.png&quot; /&gt;&lt;/a&gt; &lt;/dt&gt;
-                                        &lt;/dl&gt;
-                                        &lt;?php 
-                                        
-                                                //Do recursion
-                                                $counter = wp_custom_navigation_default_sub_items($itemid, $counter, $parent_id, $type, 'default');
-                                                
-                                        ?&gt;
-                                &lt;/li&gt;
-                                          
-                                &lt;?php 
-                        }
-                        
-                }
-                ?&gt;
-                
-                &lt;/ul&gt;
-                
-        &lt;?php 
-        }
-        
-        return $counter;
-
-}
-
-/*-----------------------------------------------------------------------------------*/
-/* Recursive get children */
-/*-----------------------------------------------------------------------------------*/
-
-function get_children_menu_elements($childof, $intCounter, $parentli, $type, $menu_id, $table_name) {
-
-        $counter = $intCounter;
-        
-        global $wpdb;
-        
-        
-        
-        //Get Sub Category Items                        
-        if ($type == 'categories')
-        {
-                $sub_args = array(
-                        'child_of' =&gt; $childof,
-                        'hide_empty'  =&gt; false,
-                        'parent' =&gt; $childof);
-                $sub_array = get_categories($sub_args);        
-        }
-        //Get Sub Page Items
-        elseif ($type == 'pages')
-        {
-                $sub_args = array(
-                        'child_of' =&gt; $childof,
-                        'parent' =&gt; $childof);
-        
-                $sub_array = get_pages($sub_args);
-                
-        }
-        else {
-        
-        }
-        
-        if ($sub_array)
-        {
-                //DISPLAY Loop
-                foreach ($sub_array as $sub_item)
-                {
-                        if (isset($sub_item-&gt;parent)) {
-                                $sub_item_parent = $sub_item-&gt;parent;
-                        }
-                        elseif (isset($sub_item-&gt;post_parent)) {
-                                $sub_item_parent = $sub_item-&gt;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-&gt;cat_ID);
-                                        $title = htmlentities($sub_item-&gt;cat_name);
-                                        $parent_id = $sub_item-&gt;category_parent;
-                                        $itemid = $sub_item-&gt;cat_ID;
-                                        $linktype = 'category';
-                                        $appendtype= 'Category';
-                                }
-                                //Page Menu Item
-                                elseif ($type == 'pages')
-                                {
-                                        $link = get_permalink($sub_item-&gt;ID);
-                                        $title = htmlentities($sub_item-&gt;post_title);
-                                        $parent_id = $sub_item-&gt;post_parent;
-                                        $linktype = 'page';
-                                        $itemid = $sub_item-&gt;ID;
-                                        $appendtype= 'Page';
-                                }
-                                //Custom Menu Item
-                                else 
-                                {
-                                        $title = '';
-                                        $linktype = 'custom';
-                                        $appendtype= 'Custom';
-                                }
-                                
-                                //CHECK for existing parent records
-                                //echo $parent_id;
-                                $wp_result = $wpdb-&gt;get_results(&quot;SELECT id FROM &quot;.$table_name.&quot; WHERE post_id='&quot;.$parent_id.&quot;' AND link_type='&quot;.$linktype.&quot;' AND menu_id='&quot;.$menu_id.&quot;'&quot;);
-                                if ($wp_result &gt; 0 &amp;&amp; isset($wp_result[0]-&gt;id)) {
-                                        $parent_id = $wp_result[0]-&gt;id;
-                                }
-                                else {
-                                        //$parent_id = 0;
-                                }
-                                
-                                //INSERT item
-                                $insert = &quot;INSERT INTO &quot;.$table_name.&quot; (position,post_id,parent_id,custom_title,custom_link,custom_description,menu_icon,link_type,menu_id,custom_anchor_title) &quot;.&quot;VALUES ('&quot;.$counter.&quot;','&quot;.$itemid.&quot;','&quot;.$parent_id.&quot;','&quot;.$title.&quot;','&quot;.$link.&quot;','','','&quot;.$linktype.&quot;','&quot;.$menu_id.&quot;','&quot;.$title.&quot;')&quot;;
-                                  $results = $wpdb-&gt;query( $insert );
-         
-                                  $counter++;
-                                  $counter = get_children_menu_elements($itemid, $counter, $parent_id, $type, $menu_id, $table_name);
-                        }        
-                        //Do nothing
-                        else {
-                        
-                        }
-                }
-        }
-        return $counter;
-}
-
-
-?&gt;
</del></span></pre></div>
<a id="trunkwpincludescustomnavigationphpfromrev13257trunkwpincludescustomnavigationfunctionsphp"></a>
<div class="copfile"><h4>Copied: trunk/wp-includes/custom-navigation.php (from rev 13257, trunk/wp-includes/custom-navigation-functions.php) (0 => 13262)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/custom-navigation.php                                (rev 0)
+++ trunk/wp-includes/custom-navigation.php        2010-02-20 23:18:57 UTC (rev 13262)
</span><span class="lines">@@ -0,0 +1,993 @@
</span><ins>+&lt;?php
+/**
+ * WordPress Administration Custom Navigation
+ * General Functions
+ *
+ * @author Jeffikus &lt;pearce.jp@gmail.com&gt;
+ * @version 1.1.0
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+function wp_custom_navigation_get_menu_items( $menu_objects, $key = 'ID' ) {
+        $menu_items = array();
+        if ( !empty( $menu_objects ) &amp;&amp; !empty( $key ) ) {
+                $args = array( 'orderby' =&gt; 'menu_order', 'post_type' =&gt; 'menu_item', 'post_status' =&gt; 'menu-category,menu-page,menu-custom' );
+                if ( count( $menu_objects ) &gt; 1 )
+                        $args['include'] = implode( ',', $menu_objects );
+                else
+                        $args['include'] = $menu_objects[0];
+                $posts = new WP_Query( $args );
+                if ( ! empty( $posts-&gt;posts ) ) {
+                        foreach( $posts-&gt;posts as $post ) {
+                                $menu_items[ $post-&gt;$key ] = $post;
+                        }
+                }
+                unset( $posts );
+                ksort( $menu_items );
+        }
+        return $menu_items;
+}
+function wp_custom_navigation_setup($override = false) {
+        
+        $nav_version = '1.1.0';
+        //Custom Navigation Menu Setup
+        
+        //Check for Upgrades
+        if (get_option('wp_settings_custom_nav_version') &lt;&gt; '') {
+                $nav_version_in_db = get_option('wp_settings_custom_nav_version');
+        }
+        else {
+                $nav_version_in_db = '0';
+        }
+        
+        //Override for menu descriptions
+        update_option('wp_settings_custom_nav_advanced_options','yes');
+                        
+        if(($nav_version_in_db &lt;&gt; $nav_version) || ($override)) 
+                update_option('wp_settings_custom_nav_version',$nav_version);
+
+        $custom_menus = get_terms( 'menu', array( 'hide_empty' =&gt; false ) );
+         if ( !empty( $custom_menus ) ) {
+                foreach( $custom_menus as $menu ) {
+                        $menu_objects = get_objects_in_term( $menu-&gt;term_id, 'menu' );
+                        if ( !empty( $menu_objects ) ) {
+                                foreach( $menu_objects as $item )
+                                        wp_delete_post( $item );
+                        }
+                        wp_delete_term( $menu-&gt;term_id, 'menu' );
+                }
+        }
+
+}
+
+/*-----------------------------------------------------------------------------------*/
+/* Custom Navigation Functions */
+/* wp_custom_navigation_output() displays the menu in the back/frontend
+/* wp_custom_navigation_sub_items() is a recursive sub menu item function
+/* wp_custom_nav_get_pages()
+/* wp_custom_nav_get_categories()
+/* wp_custom_navigation_default_sub_items() is a recursive sub menu item function
+/*-----------------------------------------------------------------------------------*/
+
+/*-----------------------------------------------------------------------------------*/
+/* Main Output Function
+/* args list
+/* type - frontend or backend
+/* name - name of your menu
+/* id - id of menu in db
+/* desc - 1 = show descriptions, 2 = dont show descriptions
+/* before_title - html before title is outputted in &lt;a&gt; tag
+/* after_title - html after title is outputted in &lt;a&gt; tag
+/*-----------------------------------------------------------------------------------*/
+
+function wp_custom_navigation_output($args = array()) {
+                
+                //DEFAULT ARGS
+                $type = 'frontend';
+                $name = 'Menu 1'; 
+                $id = 0;
+                $desc = 2;
+                $before_title = '';
+                $after_title = '';
+                
+                if (isset($args)) {
+                
+                        if ( !is_array($args) ) 
+                        parse_str( $args, $args );
+        
+                        extract($args);
+                }
+
+                $menu_objects = get_objects_in_term( $id, 'menu' );
+                $menu_items = wp_custom_navigation_get_menu_items( $menu_objects, 'menu_order' );
+                //Override for menu descriptions
+                $advanced_option_descriptions = get_option('wp_settings_custom_nav_advanced_options');
+                if ($advanced_option_descriptions == 'no')
+                {
+                        $desc = 2;
+                }
+                
+                $queried_id = 0;
+                global $wp_query;
+                if ( is_page() )
+                        $queried_id = $wp_query-&gt;post-&gt;ID;
+                elseif ( is_category() )
+                        $queried_id = $wp_query-&gt;query_vars['cat'];
+            //DISPLAY Loop
+                foreach ($menu_items as $menu_item) {
+
+                        //PREPARE Menu Data
+                        //Page Menu Item
+                        switch ( $menu_item-&gt;post_status ) {
+                                case 'menu-page':
+                                        if ($menu_item-&gt;guid == '')
+                                                $link = get_permalink( $menu_item-&gt;post_parent );
+                                        else
+                                                $link = $menu_item-&gt;guid;
+
+                                        if ( $menu_item-&gt;post_title == '' )
+                                                $title = htmlentities( get_the_title( $menu_item-&gt;post_parent ) );
+                                        else
+                                                $title = htmlentities( $menu_item-&gt;post_title );
+
+                                        if ( $menu_item-&gt;post_content == '' )
+                                                $description = htmlentities( get_post_meta( $menu_item-&gt;ID, 'page-description', true ) );
+                                        else
+                                                $description = htmlentities( $menu_item-&gt;post_content );
+                                        $target = '';
+                                break;
+                        //Category Menu Item
+                                case 'menu-category':
+                                        if ($menu_item-&gt;guid == '')
+                                                $link = get_category_link( $menu_item-&gt;post_parent );
+                                        else
+                                                $link = $menu_item-&gt;guid;
+                                
+                                        if ( $menu_item-&gt;post_title == '' ) {
+                                                $title_raw = get_categories( 'include='.$menu_item-&gt;post_parent );
+                                                $title =  htmlentities($title_raw[0]-&gt;cat_name);        
+                                        } else {
+                                                $title = htmlentities( $menu_item-&gt;post_title );
+                                        }
+                                
+                                        if ( $menu_item-&gt;post_content == '' )
+                                                $description = htmlentities( strip_tags( category_description( $menu_item-&gt;post_parent ) ) );
+                                        else
+                                                $description = htmlentities( $menu_item-&gt;post_content );
+                                        $target = '';
+                                break;
+                                default:
+                        //Custom Menu Item
+                                        $link = $menu_item-&gt;guid;
+                                        $title =  htmlentities( $menu_item-&gt;post_title );
+                                        $description = htmlentities( $menu_item-&gt;post_content );
+                                        $target = 'target=&quot;_blank&quot;';
+                                break;
+                        }
+/* @todo: update to use tax/post data
+
+                        //SET anchor title
+                        if (isset($wp_custom_nav_menu_items-&gt;custom_anchor_title)) {
+                                $anchor_title = htmlentities($wp_custom_nav_menu_items-&gt;custom_anchor_title);
+                        }
+                        else {
+                                $anchor_title = $title;
+                        }
+                        
+                        if ($queried_id == $wp_custom_nav_menu_items-&gt;post_id) {
+                                $li_class = 'class=&quot;current_page_item&quot;';
+                        }
+                        else {
+                                $li_class = '';
+                        }
+                        
+                        if (isset($wp_custom_nav_menu_items-&gt;new_window)) {
+                                if ($wp_custom_nav_menu_items-&gt;new_window &gt; 0) {
+                                        $target = 'target=&quot;_blank&quot;';
+                                }
+                                else {
+                                        $target = '';
+                                }
+                        }
+*/                        
+                        //List Items
+                        ?&gt;&lt;li id=&quot;menu-&lt;?php echo $menu_item-&gt;ID; ?&gt;&quot; value=&quot;&lt;?php echo $menu_item-&gt;ID; ?&gt;&quot; &lt;?php echo $li_class; ?&gt;&gt;&lt;?php
+                                        //@todo: update front end to use post data
+                                        //FRONTEND Link
+                                        if ($type == &quot;frontend&quot;)
+                                        {                
+                                                ?&gt;&lt;a title=&quot;&lt;?php echo $anchor_title; ?&gt;&quot; href=&quot;&lt;?php echo $link; ?&gt;&quot; &lt;?php echo $target; ?&gt;&gt;&lt;?php echo $before_title.$title.$after_title; ?&gt;&lt;?php 
+                                                
+                                                        if ( $advanced_option_descriptions == 'no' ) 
+                                                        { 
+                                                                // 2 widget override do NOT display descriptions
+                                                                // 1 widget override display descriptions
+                                                                // 0 widget override not set
+                                                                if (($desc == 1) || ($desc == 0) )
+                                                                {
+                                                                        ?&gt;&lt;span class=&quot;nav-description&quot;&gt;&lt;?php echo $description; ?&gt;&lt;/span&gt;&lt;?php
+                                                                } 
+                                                                elseif ($desc == 2)
+                                                                { }
+                                                                else
+                                                                { }
+                                                        } 
+                                                        else 
+                                                        {
+                                                                // 2 widget override do NOT display descriptions
+                                                                // 1 widget override display descriptions
+                                                                // 0 widget override not set
+                                                                if ($desc == 1)
+                                                                {
+                                                                        ?&gt;&lt;span class=&quot;nav-description&quot;&gt;&lt;?php echo $description; ?&gt;&lt;/span&gt;&lt;?php
+                                                                } 
+                                                                elseif (($desc == 2) || ($desc == 0))
+                                                                { }
+                                                                else 
+                                                                { }
+                                                        }
+                                                        
+                                                ?&gt;&lt;/a&gt;&lt;?php 
+                                        }
+                                        //BACKEND draggable and droppable elements
+                                        elseif ($type == &quot;backend&quot;)
+                                                $link_type = substr( $menu_item-&gt;post_status, 5 );
+                                        {
+                                                ?&gt;
+                                                
+                                                &lt;dl&gt;
+                                                        &lt;dt&gt;
+                                                                &lt;span class=&quot;title&quot;&gt;&lt;?php echo $title; ?&gt;&lt;/span&gt;
+                                                                &lt;span class=&quot;controls&quot;&gt;
+                                                                &lt;span class=&quot;type&quot;&gt;&lt;?php echo $link_type; ?&gt;&lt;/span&gt;
+                                                                &lt;a id=&quot;edit&lt;?php echo $menu_item-&gt;menu_order; ?&gt;&quot; onclick=&quot;edititem(&lt;?php echo $menu_item-&gt;menu_order; ?&gt;)&quot; value=&quot;&lt;?php echo $menu_item-&gt;menu_order; ?&gt;&quot;&gt;&lt;img class=&quot;edit&quot; alt=&quot;Edit Menu Item&quot; title=&quot;Edit Menu Item&quot; src=&quot;&lt;?php echo get_bloginfo('url'); ?&gt;/wp-admin/images/ico-edit.png&quot; /&gt;&lt;/a&gt;
+                                                                &lt;a id=&quot;remove&lt;?php echo $menu_item-&gt;menu_order; ?&gt;&quot; onclick=&quot;removeitem(&lt;?php echo $menu_item-&gt;menu_order; ?&gt;)&quot; value=&quot;&lt;?php echo $menu_item-&gt;menu_order; ?&gt;&quot;&gt;&lt;img class=&quot;remove&quot; alt=&quot;Remove from Custom Menu&quot; title=&quot;Remove from Custom Menu&quot; src=&quot;&lt;?php echo get_bloginfo('url'); ?&gt;/wp-admin/images/ico-close.png&quot; /&gt;&lt;/a&gt;
+                                                                &lt;a id=&quot;view&lt;?php echo $menu_item-&gt;menu_order; ?&gt;&quot; target=&quot;_blank&quot; href=&quot;&lt;?php echo $link; ?&gt;&quot;&gt;&lt;img alt=&quot;View Page&quot; title=&quot;View Page&quot; src=&quot;&lt;?php echo get_bloginfo('url'); ?&gt;/wp-admin/images/ico-viewpage.png&quot; /&gt;&lt;/a&gt;
+                                                                &lt;/span&gt;
+                                                        &lt;/dt&gt;
+                                                &lt;/dl&gt;
+                                                
+                                                &lt;a&gt;&lt;span class=&quot;&quot;&gt;&lt;/span&gt;&lt;/a&gt;
+                                                &lt;input type=&quot;hidden&quot; name=&quot;dbid&lt;?php echo $menu_item-&gt;menu_order; ?&gt;&quot; id=&quot;dbid&lt;?php echo $menu_item-&gt;menu_order; ?&gt;&quot; value=&quot;&lt;?php echo $menu_item-&gt;ID; ?&gt;&quot; /&gt;
+                                                &lt;input type=&quot;hidden&quot; name=&quot;postmenu&lt;?php echo $menu_item-&gt;menu_order; ?&gt;&quot; id=&quot;postmenu&lt;?php echo $menu_item-&gt;menu_order; ?&gt;&quot; value=&quot;&lt;?php echo $id; ?&gt;&quot; /&gt;
+                                                &lt;input type=&quot;hidden&quot; name=&quot;parent&lt;?php echo $menu_item-&gt;menu_order; ?&gt;&quot; id=&quot;parent&lt;?php echo $menu_item-&gt;menu_order; ?&gt;&quot; value=&quot;&lt;?php echo $menu_item-&gt;post_parent; ?&gt;&quot; /&gt;
+                                                &lt;input type=&quot;hidden&quot; name=&quot;title&lt;?php echo $menu_item-&gt;menu_order; ?&gt;&quot; id=&quot;title&lt;?php echo $menu_item-&gt;menu_order; ?&gt;&quot; value=&quot;&lt;?php echo $title; ?&gt;&quot; /&gt;
+                                                &lt;input type=&quot;hidden&quot; name=&quot;linkurl&lt;?php echo $menu_item-&gt;menu_order; ?&gt;&quot; id=&quot;linkurl&lt;?php echo $menu_item-&gt;menu_order; ?&gt;&quot; value=&quot;&lt;?php echo $link; ?&gt;&quot; /&gt;
+                                                &lt;input type=&quot;hidden&quot; name=&quot;description&lt;?php echo $menu_item-&gt;menu_order; ?&gt;&quot; id=&quot;description&lt;?php echo $menu_item-&gt;menu_order; ?&gt;&quot; value=&quot;&lt;?php echo $description; ?&gt;&quot; /&gt;
+                                                &lt;input type=&quot;hidden&quot; name=&quot;icon&lt;?php echo $menu_item-&gt;menu_order; ?&gt;&quot; id=&quot;icon&lt;?php echo $menu_item-&gt;menu_order; ?&gt;&quot; value=&quot;0&quot; /&gt;
+                                                &lt;input type=&quot;hidden&quot; name=&quot;position&lt;?php echo $menu_item-&gt;menu_order; ?&gt;&quot; id=&quot;position&lt;?php echo $menu_item-&gt;menu_order; ?&gt;&quot; value=&quot;&lt;?php echo $menu_item-&gt;menu_order; ?&gt;&quot; /&gt;
+                                                &lt;input type=&quot;hidden&quot; name=&quot;linktype&lt;?php echo $menu_item-&gt;menu_order; ?&gt;&quot; id=&quot;linktype&lt;?php echo $menu_item-&gt;menu_order; ?&gt;&quot; value=&quot;&lt;?php echo $link_type; ?&gt;&quot; /&gt;
+                                                &lt;input type=&quot;hidden&quot; name=&quot;anchortitle&lt;?php echo $menu_item-&gt;menu_order; ?&gt;&quot; id=&quot;anchortitle&lt;?php echo $menu_item-&gt;menu_order; ?&gt;&quot; value=&quot;&lt;?php echo esc_html( $menu_item-&gt;post_excerpt ); ?&gt;&quot; /&gt;
+                                                &lt;input type=&quot;hidden&quot; name=&quot;newwindow&lt;?php echo $menu_item-&gt;menu_order; ?&gt;&quot; id=&quot;newwindow&lt;?php echo $menu_item-&gt;menu_order; ?&gt;&quot; value=&quot;&lt;?php echo ( '' == $menu_item-&gt;post_content_filtered ? '0' : '1' ); ?&gt;&quot; /&gt;
+                                                
+                                                &lt;?php 
+                                        }
+
+                                        //@todo: implement menu heirarchy
+/*                                        //DISPLAY menu sub items
+                                        if ($wp_custom_nav_menu_items-&gt;parent_id == 0) 
+                                        {
+                                                //FRONTEND
+                                                if ($type == 'frontend') 
+                                                {
+                                                        //Recursive function
+                                                        $intj = wp_custom_navigation_sub_items($wp_custom_nav_menu_items-&gt;id,$wp_custom_nav_menu_items-&gt;link_type,$table_name,$type,$wp_custom_nav_menu_id);
+                                                }
+                                                //BACKEND
+                                                else 
+                                                {
+                                                        //Recursive function
+                                                        $intj = wp_custom_navigation_sub_items($wp_custom_nav_menu_items-&gt;id,$wp_custom_nav_menu_items-&gt;link_type,$table_name,$type,$id);
+                                                }
+                                        }
+*/                        ?&gt;&lt;/li&gt;
+                        &lt;?php 
+                }
+}
+//@todo: implement menu heirarchy
+//RECURSIVE Sub Menu Items
+function wp_custom_navigation_sub_items($post_id,$type,$table_name,$output_type,$menu_id = 0) {
+        
+        $parent_id = 0;
+        global $wpdb;
+        
+        //GET sub menu items
+        $wp_custom_nav_menu = $wpdb-&gt;get_results(&quot;SELECT id,post_id,parent_id,position,custom_title,custom_link,custom_description,menu_icon,link_type,custom_anchor_title,new_window FROM &quot;.$table_name.&quot; WHERE parent_id = '&quot;.$post_id.&quot;' AND menu_id='&quot;.$menu_id.&quot;' ORDER BY position ASC&quot;);
+        
+        if (empty($wp_custom_nav_menu))
+        {
+        
+        }
+        else
+        {
+                ?&gt;&lt;ul id=&quot;sub-custom-nav&quot;&gt;
+                &lt;?php
+            $queried_id = 0;
+                global $wp_query;
+        if (is_page()) {
+                    $queried_id = $wp_query-&gt;post-&gt;ID;
+            }
+            elseif (is_category()) {
+                    $queried_id = $wp_query-&gt;query_vars['cat'];
+            }
+            else {
+
+            }
+            //DISPLAY Loop
+                foreach ($wp_custom_nav_menu as $sub_item) 
+                {
+                        //Figure out where the menu item sits
+                        $counter=$sub_item-&gt;position;
+                        
+                        //Prepare Menu Data
+                        //Category Menu Item
+                        if ($sub_item-&gt;link_type == 'category') 
+                        {
+                                
+                                $parent_id = $sub_item-&gt;parent_id;
+                                $post_id = $sub_item-&gt;post_id;
+                                
+                                if ($sub_item-&gt;custom_link == '') {
+                                        $link = get_category_link($sub_item-&gt;post_id);
+                                }
+                                else {
+                                        $link = $sub_item-&gt;custom_link;
+                                }
+                                
+                                if ($sub_item-&gt;custom_title == '') {
+                                        $title_raw = get_categories('include='.$sub_item-&gt;post_id);
+                                        $title =  htmlentities($title_raw[0]-&gt;cat_name);
+                                }
+                                else {
+                                        $title = htmlentities($sub_item-&gt;custom_title);
+                                }
+                                
+                                if ($sub_item-&gt;custom_description == '') {
+                                        $description = strip_tags(category_description($sub_item-&gt;post_id));
+                                }
+                                else {
+                                        $description = $sub_item-&gt;custom_description;
+                                }
+                                $target = '';
+                        }
+                        //Page Menu Item
+                        elseif ($sub_item-&gt;link_type == 'page')
+                        {
+                                
+                                $parent_id = $sub_item-&gt;parent_id;
+                                $post_id = $sub_item-&gt;post_id;
+                                
+                                if ($sub_item-&gt;custom_link == '') {
+                                        $link = get_permalink($sub_item-&gt;post_id);
+                                }
+                                else {
+                                        $link = $sub_item-&gt;custom_link;
+                                }
+
+                                if ($sub_item-&gt;custom_title == '') {
+                                        $title = htmlentities(get_the_title($sub_item-&gt;post_id));
+                                }
+                                else {
+                                        $title = htmlentities($sub_item-&gt;custom_title);
+                                }
+                                
+                                if ($sub_item-&gt;custom_description == '') {
+                                        $description = get_post_meta($sub_item-&gt;post_id, 'page-description', true);
+                                }
+                                else {
+                                        $description = $sub_item-&gt;custom_description;
+                                }
+                                $target = '';
+                                
+                        }
+                        //Custom Menu Item
+                        else
+                        {
+                                $link = $sub_item-&gt;custom_link;
+                                $title = htmlentities($sub_item-&gt;custom_title);
+                                $parent_id = $sub_item-&gt;parent_id;
+                                $post_id = $sub_item-&gt;post_id;
+                                $description = $sub_item-&gt;custom_description;
+                                $target = 'target=&quot;_blank&quot;';
+                        }
+                        if ($queried_id == $sub_item-&gt;post_id) {
+                                $li_class = 'class=&quot;current_page_item&quot;';
+                        }
+                        else {
+                                $li_class = '';
+                        }
+                        
+                        //SET anchor title
+                        if (isset($sub_item-&gt;custom_anchor_title)) {
+                                $anchor_title = htmlentities($sub_item-&gt;custom_anchor_title);
+                        }
+                        else {
+                                $anchor_title = $title;
+                        }
+                        
+                        if (isset($sub_item-&gt;new_window)) {
+                                if ($sub_item-&gt;new_window &gt; 0) {
+                                        $target = 'target=&quot;_blank&quot;';
+                                }
+                        }
+                        
+                        //List Items
+                        ?&gt;&lt;li id=&quot;menu-&lt;?php echo $counter; ?&gt;&quot; value=&quot;&lt;?php echo $counter; ?&gt;&quot; &lt;?php echo $li_class; ?&gt;&gt;&lt;?php 
+                                                //FRONTEND
+                                                if ($output_type == &quot;frontend&quot;)
+                                                {
+                                                        ?&gt;&lt;a title=&quot;&lt;?php echo $anchor_title; ?&gt;&quot; href=&quot;&lt;?php echo $link; ?&gt;&quot; &lt;?php echo $target; ?&gt;&gt;&lt;?php echo $title; ?&gt;&lt;/a&gt;&lt;?php 
+                                                }
+                                                //BACKEND
+                                                elseif ($output_type == &quot;backend&quot;)
+                                                {
+                                                        ?&gt;
+                                                        &lt;dl&gt;
+                                                        &lt;dt&gt;
+                                                                &lt;span class=&quot;title&quot;&gt;&lt;?php echo $title; ?&gt;&lt;/span&gt;
+                                                                &lt;span class=&quot;controls&quot;&gt;
+                                                                &lt;span class=&quot;type&quot;&gt;&lt;?php echo $sub_item-&gt;link_type; ?&gt;&lt;/span&gt;
+                                                                &lt;a id=&quot;edit&lt;?php echo $counter; ?&gt;&quot; onclick=&quot;edititem(&lt;?php echo $counter; ?&gt;)&quot; value=&quot;&lt;?php echo $counter; ?&gt;&quot;&gt;&lt;img class=&quot;edit&quot; alt=&quot;Edit Menu Item&quot; title=&quot;Edit Menu Item&quot; src=&quot;&lt;?php echo get_bloginfo('url'); ?&gt;/wp-admin/images/ico-edit.png&quot; /&gt;&lt;/a&gt; 
+                                                                &lt;a id=&quot;remove&lt;?php echo $counter; ?&gt;&quot; onclick=&quot;removeitem(&lt;?php echo $counter; ?&gt;)&quot; value=&quot;&lt;?php echo $counter; ?&gt;&quot;&gt;&lt;img class=&quot;remove&quot; alt=&quot;Remove from Custom Menu&quot; title=&quot;Remove from Custom Menu&quot; src=&quot;&lt;?php echo get_bloginfo('url'); ?&gt;/wp-admin/images/ico-close.png&quot; /&gt;&lt;/a&gt;
+                                                                &lt;a id=&quot;view&lt;?php echo $counter; ?&gt;&quot; target=&quot;_blank&quot; href=&quot;&lt;?php echo $link; ?&gt;&quot;&gt;&lt;img alt=&quot;View Page&quot; title=&quot;View Page&quot; src=&quot;&lt;?php echo get_bloginfo('url'); ?&gt;/wp-admin/images/ico-viewpage.png&quot; /&gt;&lt;/a&gt;
+                                                                &lt;/span&gt;
+                                                        &lt;/dt&gt;
+                                                        &lt;/dl&gt;
+                                                        &lt;a class=&quot;hide&quot; href=&quot;&lt;?php echo $link; ?&gt;&quot;&gt;&lt;?php echo $title; ?&gt;&lt;/a&gt;
+                                                        &lt;input type=&quot;hidden&quot; name=&quot;dbid&lt;?php echo $counter; ?&gt;&quot; id=&quot;dbid&lt;?php echo $counter; ?&gt;&quot; value=&quot;&lt;?php echo $sub_item-&gt;id; ?&gt;&quot; /&gt;
+                                                        &lt;input type=&quot;hidden&quot; name=&quot;postmenu&lt;?php echo $counter; ?&gt;&quot; id=&quot;postmenu&lt;?php echo $counter; ?&gt;&quot; value=&quot;&lt;?php echo $post_id; ?&gt;&quot; /&gt;
+                                                        &lt;input type=&quot;hidden&quot; name=&quot;parent&lt;?php echo $counter; ?&gt;&quot; id=&quot;parent&lt;?php echo $counter; ?&gt;&quot; value=&quot;&lt;?php echo $parent_id; ?&gt;&quot; /&gt;
+                                                        &lt;input type=&quot;hidden&quot; name=&quot;title&lt;?php echo $counter; ?&gt;&quot; id=&quot;title&lt;?php echo $counter; ?&gt;&quot; value=&quot;&lt;?php echo $title; ?&gt;&quot; /&gt;
+                                                        &lt;input type=&quot;hidden&quot; name=&quot;linkurl&lt;?php echo $counter; ?&gt;&quot; id=&quot;linkurl&lt;?php echo $counter; ?&gt;&quot; value=&quot;&lt;?php echo $link; ?&gt;&quot; /&gt;
+                                                        &lt;input type=&quot;hidden&quot; name=&quot;description&lt;?php echo $counter; ?&gt;&quot; id=&quot;description&lt;?php echo $counter; ?&gt;&quot; value=&quot;&lt;?php echo $description; ?&gt;&quot; /&gt;
+                                                        &lt;input type=&quot;hidden&quot; name=&quot;icon&lt;?php echo $counter; ?&gt;&quot; id=&quot;icon&lt;?php echo $counter; ?&gt;&quot; value=&quot;0&quot; /&gt;
+                                                        &lt;input type=&quot;hidden&quot; name=&quot;position&lt;?php echo $counter; ?&gt;&quot; id=&quot;position&lt;?php echo $counter; ?&gt;&quot; value=&quot;&lt;?php echo $counter; ?&gt;&quot; /&gt;
+                                                        &lt;input type=&quot;hidden&quot; name=&quot;linktype&lt;?php echo $counter; ?&gt;&quot; id=&quot;linktype&lt;?php echo $counter; ?&gt;&quot; value=&quot;&lt;?php echo $sub_item-&gt;link_type; ?&gt;&quot; /&gt;
+                                                        &lt;input type=&quot;hidden&quot; name=&quot;anchortitle&lt;?php echo $counter; ?&gt;&quot; id=&quot;anchortitle&lt;?php echo $counter; ?&gt;&quot; value=&quot;&lt;?php echo $anchor_title; ?&gt;&quot; /&gt;
+                                                        &lt;input type=&quot;hidden&quot; name=&quot;newwindow&lt;?php echo $counter; ?&gt;&quot; id=&quot;newwindow&lt;?php echo $counter; ?&gt;&quot; value=&quot;&lt;?php echo $sub_item-&gt;new_window; ?&gt;&quot; /&gt;
+                                                        &lt;?php 
+                                                }
+                                                
+                                                //Do recursion
+                                                wp_custom_navigation_sub_items($sub_item-&gt;id,$sub_item-&gt;link_type,$table_name,$output_type,$menu_id); 
+                        ?&gt;&lt;/li&gt;
+                        &lt;?php 
+        
+                } 
+        
+        ?&gt;&lt;/ul&gt;
+        &lt;?php 
+        
+        } 
+        
+        return $parent_id;

+}
+
+
+//Outputs All Pages and Sub Items
+function wp_custom_nav_get_pages($counter,$type) {
+
+        $pages_args = array(
+                    'child_of' =&gt; 0,
+                        'sort_order' =&gt; 'ASC',
+                        'sort_column' =&gt; 'post_title',
+                        'hierarchical' =&gt; 1,
+                        'exclude' =&gt; '',
+                        'include' =&gt; '',
+                        'meta_key' =&gt; '',
+                        'meta_value' =&gt; '',
+                        'authors' =&gt; '',
+                        'parent' =&gt; -1,
+                        'exclude_tree' =&gt; '',
+                        'number' =&gt; '',
+                        'offset' =&gt; 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-&gt;post_parent == 0)
+                        {
+                                //Custom Menu
+                                if ($type == 'menu')
+                                {
+                                        $description = get_post_meta($post-&gt;ID, 'page-description', true);
+                                        ?&gt;
+                                        
+                                        &lt;li id=&quot;menu-&lt;?php echo $intCounter; ?&gt;&quot; value=&quot;&lt;?php echo $intCounter; ?&gt;&quot;&gt;
+                                
+                                                &lt;dl&gt;
+                                                &lt;dt&gt;
+                                                &lt;span class=&quot;title&quot;&gt;&lt;?php echo $post-&gt;post_title; ?&gt;&lt;/span&gt;
+                                                &lt;span class=&quot;controls&quot;&gt;
+                                                        &lt;span class=&quot;type&quot;&gt;page&lt;/span&gt;
+                                                        &lt;a id=&quot;edit&lt;?php echo $intCounter; ?&gt;&quot; onclick=&quot;edititem(&lt;?php echo $intCounter; ?&gt;)&quot; value=&quot;&lt;?php echo $intCounter; ?&gt;&quot;&gt;&lt;img class=&quot;edit&quot; alt=&quot;Edit Menu Item&quot; title=&quot;Edit Menu Item&quot; src=&quot;&lt;?php echo get_bloginfo('url'); ?&gt;/wp-admin/images/ico-edit.png&quot; /&gt;&lt;/a&gt; 
+                                                        &lt;a id=&quot;remove&lt;?php echo $intCounter; ?&gt;&quot; onclick=&quot;removeitem(&lt;?php echo $intCounter; ?&gt;)&quot; value=&quot;&lt;?php echo $intCounter; ?&gt;&quot;&gt;
+                                                                &lt;img class=&quot;remove&quot; alt=&quot;Remove from Custom Menu&quot; title=&quot;Remove from Custom Menu&quot; src=&quot;&lt;?php echo get_bloginfo('url'); ?&gt;/wp-admin/images/ico-close.png&quot; /&gt;
+                                                        &lt;/a&gt;
+                                                        &lt;a target=&quot;_blank&quot; href=&quot;&lt;?php echo get_permalink($post-&gt;ID); ?&gt;&quot;&gt;
+                                                                &lt;img alt=&quot;View Page&quot; title=&quot;View Page&quot; src=&quot;&lt;?php echo get_bloginfo('url'); ?&gt;/wp-admin/images/ico-viewpage.png&quot; /&gt;
+                                                        &lt;/a&gt;
+                                                &lt;/span&gt;
+                                                
+                                                &lt;/dt&gt;
+                                                &lt;/dl&gt;
+                                                &lt;a class=&quot;hide&quot; href=&quot;&lt;?php echo get_permalink($post-&gt;ID); ?&gt;&quot;&gt;&lt;span class=&quot;title&quot;&gt;&lt;?php echo $post-&gt;post_title; ?&gt;&lt;/span&gt;
+                                        &lt;/a&gt;
+                                        &lt;input type=&quot;hidden&quot; name=&quot;postmenu&lt;?php echo $intCounter; ?&gt;&quot; id=&quot;postmenu&lt;?php echo $intCounter; ?&gt;&quot; value=&quot;&lt;?php echo $post-&gt;ID; ?&gt;&quot; /&gt;
+                                                &lt;input type=&quot;hidden&quot; name=&quot;parent&lt;?php echo $intCounter; ?&gt;&quot; id=&quot;parent&lt;?php echo $intCounter; ?&gt;&quot; value=&quot;0&quot; /&gt;
+                                                &lt;input type=&quot;hidden&quot; name=&quot;title&lt;?php echo $intCounter; ?&gt;&quot; id=&quot;title&lt;?php echo $intCounter; ?&gt;&quot; value=&quot;&lt;?php echo htmlentities($post-&gt;post_title); ?&gt;&quot; /&gt;
+                                                &lt;input type=&quot;hidden&quot; name=&quot;linkurl&lt;?php echo $intCounter; ?&gt;&quot; id=&quot;linkurl&lt;?php echo $intCounter; ?&gt;&quot; value=&quot;&lt;?php echo get_permalink($post-&gt;ID); ?&gt;&quot; /&gt;
+                                                &lt;input type=&quot;hidden&quot; name=&quot;description&lt;?php echo $intCounter; ?&gt;&quot; id=&quot;description&lt;?php echo $intCounter; ?&gt;&quot; value=&quot;&lt;?php echo $description; ?&gt;&quot; /&gt;
+                                                &lt;input type=&quot;hidden&quot; name=&quot;icon&lt;?php echo $intCounter; ?&gt;&quot; id=&quot;icon&lt;?php echo $intCounter; ?&gt;&quot; value=&quot;0&quot; /&gt;
+                                                &lt;input type=&quot;hidden&quot; name=&quot;position&lt;?php echo $intCounter; ?&gt;&quot; id=&quot;position&lt;?php echo $intCounter; ?&gt;&quot; value=&quot;&lt;?php echo $intCounter; ?&gt;&quot; /&gt;
+                                                &lt;input type=&quot;hidden&quot; name=&quot;linktype&lt;?php echo $intCounter; ?&gt;&quot; id=&quot;linktype&lt;?php echo $intCounter; ?&gt;&quot; value=&quot;page&quot; /&gt;
+                                                &lt;input type=&quot;hidden&quot; name=&quot;anchortitle&lt;?php echo $intCounter; ?&gt;&quot; id=&quot;anchortitle&lt;?php echo $intCounter; ?&gt;&quot; value=&quot;&lt;?php echo htmlentities($post-&gt;post_title); ?&gt;&quot; /&gt;
+                                                &lt;input type=&quot;hidden&quot; name=&quot;newwindow&lt;?php echo $intCounter; ?&gt;&quot; id=&quot;newwindow&lt;?php echo $intCounter; ?&gt;&quot; value=&quot;0&quot; /&gt;
+                                                
+                                                &lt;?php $parentli = $post-&gt;ID; ?&gt;
+                                                &lt;?php $intCounter++; ?&gt;                                        
+                                                &lt;?php
+                                                
+                                                        //Recursive function
+                                                        $intCounter = wp_custom_navigation_default_sub_items($post-&gt;ID, $intCounter, $parentli, 'pages', 'menu');
+                                                
+                                                ?&gt;
+                                        
+                                        &lt;/li&gt;
+                                        
+                                        &lt;?php 
+                                        
+                                }
+                                //Sidebar Menu
+                                elseif ($type == 'default')
+                                {
+                                        ?&gt;
+                                         
+                                         &lt;li&gt;
+                                        &lt;dl&gt;
+                                        &lt;dt&gt;
+                                        &lt;?php
+                                                $post_text = htmlentities($post-&gt;post_title);
+                                                $post_url = get_permalink($post-&gt;ID);
+                                                $post_id = $post-&gt;ID;
+                                                $post_parent_id = $post-&gt;post_parent;
+                                                
+                                                        $description = htmlentities(get_post_meta($post_id, 'page-description', true));
+                                                        
+                                        ?&gt;
+                                        &lt;?php $templatedir = get_bloginfo('url'); ?&gt;
+                                        
+                                        &lt;span class=&quot;title&quot;&gt;&lt;?php echo $post-&gt;post_title; ?&gt;&lt;/span&gt; &lt;a onclick=&quot;appendToList('&lt;?php echo $templatedir; ?&gt;','Page','&lt;?php echo $post_text; ?&gt;','&lt;?php echo $post_url; ?&gt;','&lt;?php echo $post_id; ?&gt;','&lt;?php echo $post_parent_id ?&gt;','&lt;?php echo $description; ?&gt;')&quot; name=&quot;&lt;?php echo $post_text; ?&gt;&quot; value=&quot;&lt;?php echo get_permalink($post-&gt;ID); ?&gt;&quot;&gt;&lt;img alt=&quot;Add to Custom Menu&quot; title=&quot;Add to Custom Menu&quot; src=&quot;&lt;?php echo get_bloginfo('url'); ?&gt;/wp-admin/images/ico-add.png&quot; /&gt;&lt;/a&gt;&lt;/dt&gt;
+                                        &lt;/dl&gt;
+                                        &lt;?php $parentli = $post-&gt;ID; ?&gt;
+                                                &lt;?php $intCounter++; ?&gt;                            
+                                        &lt;?php
+                                                
+                                                        //Recursive function
+                                                        $intCounter = wp_custom_navigation_default_sub_items($post_id, $intCounter, $parentli, 'pages', 'default');
+                                                
+                                                 ?&gt;
+                                                
+                                        &lt;/li&gt;
+        
+                                        &lt;?php 
+                                
+                                }
+                                else
+                                {
+                                
+                                }        
+                        } 
+                } 
+        }
+        else 
+        {
+                echo 'Not Found';
+        }
+
+        return $intCounter;
+}
+
+//Outputs All Categories and Sub Items
+function wp_custom_nav_get_categories($counter, $type) {
+
+        $category_args = array(
+                        'type'                     =&gt; 'post',
+                        'child_of'                 =&gt; 0,
+                        'orderby'                  =&gt; 'name',
+                        'order'                    =&gt; 'ASC',
+                        'hide_empty'               =&gt; false,
+                        'include_last_update_time' =&gt; false,
+                        'hierarchical'             =&gt; 1,
+                        'exclude'                  =&gt; '',
+                        'include'                  =&gt; '',
+                        'number'                   =&gt; '',
+                        'pad_counts'               =&gt; 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-&gt;parent == 0)
+                        {
+                                //Custom Menu
+                                if ($type == 'menu')
+                                {
+                                        ?&gt;
+            
+                                    &lt;li id=&quot;menu-&lt;?php echo $intCounter; ?&gt;&quot; value=&quot;&lt;?php echo $intCounter; ?&gt;&quot;&gt;
+                                            &lt;dl&gt;
+                                    &lt;dt&gt;
+                                            &lt;span class=&quot;title&quot;&gt;&lt;?php echo $cat_item-&gt;cat_name; ?&gt;&lt;/span&gt;
+                                                        &lt;span class=&quot;controls&quot;&gt;
+                                                        &lt;span class=&quot;type&quot;&gt;category&lt;/span&gt;
+                                                        &lt;a id=&quot;edit&lt;?php echo $intCounter; ?&gt;&quot; onclick=&quot;edititem(&lt;?php echo $intCounter; ?&gt;)&quot; value=&quot;&lt;?php echo $intCounter; ?&gt;&quot;&gt;&lt;img class=&quot;edit&quot; alt=&quot;Edit Menu Item&quot; title=&quot;Edit Menu Item&quot; src=&quot;&lt;?php echo get_bloginfo('url'); ?&gt;/wp-admin/images/ico-edit.png&quot; /&gt;&lt;/a&gt; 
+                                                        &lt;a id=&quot;remove&lt;?php echo $intCounter; ?&gt;&quot; onclick=&quot;removeitem(&lt;?php echo $intCounter; ?&gt;)&quot; value=&quot;&lt;?php echo $intCounter; ?&gt;&quot;&gt;
+                                                                &lt;img class=&quot;remove&quot; alt=&quot;Remove from Custom Menu&quot; title=&quot;Remove from Custom Menu&quot; src=&quot;&lt;?php echo get_bloginfo('url'); ?&gt;/wp-admin/images/ico-close.png&quot; /&gt;
+                                                        &lt;/a&gt;
+                                                        &lt;a target=&quot;_blank&quot; href=&quot;&lt;?php echo get_category_link($cat_item-&gt;cat_ID); ?&gt;&quot;&gt;
+                                                                &lt;img alt=&quot;View Page&quot; title=&quot;View Page&quot; src=&quot;&lt;?php echo get_bloginfo('url'); ?&gt;/wp-admin/images/ico-viewpage.png&quot; /&gt;
+                                                        &lt;/a&gt;
+                                                        &lt;/span&gt;
+                                        
+                                    &lt;/dt&gt;
+                                    &lt;/dl&gt;
+                                    &lt;a class=&quot;hide&quot; href=&quot;&lt;?php echo get_category_link($cat_item-&gt;cat_ID); ?&gt;&quot;&gt;&lt;span class=&quot;title&quot;&gt;&lt;?php echo $cat_item-&gt;cat_name; ?&gt;&lt;/span&gt;
+                                    &lt;?php 
+                                    $use_cats_raw = get_option('wp_settings_custom_nav_descriptions');
+                                                   $use_cats = strtolower($use_cats_raw);
+                                                   if ($use_cats == 'yes') { ?&gt;
+                                    &lt;br/&gt; &lt;span&gt;&lt;?php echo $cat_item-&gt;category_description; ?&gt;&lt;/span&gt;
+                                    &lt;?php } ?&gt;
+                                                    &lt;/a&gt;
+                                    &lt;input type=&quot;hidden&quot; name=&quot;postmenu&lt;?php echo $intCounter; ?&gt;&quot; id=&quot;postmenu&lt;?php echo $intCounter; ?&gt;&quot; value=&quot;&lt;?php echo $cat_item-&gt;cat_ID; ?&gt;&quot; /&gt;
+                                    &lt;input type=&quot;hidden&quot; name=&quot;parent&lt;?php echo $intCounter; ?&gt;&quot; id=&quot;parent&lt;?php echo $intCounter; ?&gt;&quot; value=&quot;0&quot; /&gt;
+                                    &lt;input type=&quot;hidden&quot; name=&quot;title&lt;?php echo $intCounter; ?&gt;&quot; id=&quot;title&lt;?php echo $intCounter; ?&gt;&quot; value=&quot;&lt;?php echo htmlentities($cat_item-&gt;cat_name); ?&gt;&quot; /&gt;
+                                                &lt;input type=&quot;hidden&quot; name=&quot;linkurl&lt;?php echo $intCounter; ?&gt;&quot; id=&quot;linkurl&lt;?php echo $intCounter; ?&gt;&quot; value=&quot;&lt;?php echo get_category_link($cat_item-&gt;cat_ID); ?&gt;&quot; /&gt;
+                                                &lt;input type=&quot;hidden&quot; name=&quot;description&lt;?php echo $intCounter; ?&gt;&quot; id=&quot;description&lt;?php echo $intCounter; ?&gt;&quot; value=&quot;&lt;?php echo htmlentities($cat_item-&gt;category_description); ?&gt;&quot; /&gt;
+                                                &lt;input type=&quot;hidden&quot; name=&quot;icon&lt;?php echo $intCounter; ?&gt;&quot; id=&quot;icon&lt;?php echo $intCounter; ?&gt;&quot; value=&quot;0&quot; /&gt;
+                                                &lt;input type=&quot;hidden&quot; name=&quot;position&lt;?php echo $intCounter; ?&gt;&quot; id=&quot;position&lt;?php echo $intCounter; ?&gt;&quot; value=&quot;&lt;?php echo $intCounter; ?&gt;&quot; /&gt;
+                                                &lt;input type=&quot;hidden&quot; name=&quot;linktype&lt;?php echo $intCounter; ?&gt;&quot; id=&quot;linktype&lt;?php echo $intCounter; ?&gt;&quot; value=&quot;category&quot; /&gt;
+                                                &lt;input type=&quot;hidden&quot; name=&quot;anchortitle&lt;?php echo $intCounter; ?&gt;&quot; id=&quot;anchortitle&lt;?php echo $intCounter; ?&gt;&quot; value=&quot;&lt;?php echo htmlentities($cat_item-&gt;cat_name); ?&gt;&quot; /&gt;
+                                                &lt;input type=&quot;hidden&quot; name=&quot;newwindow&lt;?php echo $intCounter; ?&gt;&quot; id=&quot;newwindow&lt;?php echo $intCounter; ?&gt;&quot; value=&quot;0&quot; /&gt;
+                                                
+                                    &lt;?php $parentli = $cat_item-&gt;cat_ID; ?&gt;
+                                    &lt;?php $intCounter++; ?&gt;                                        
+                                           &lt;?php
+                                                
+                                                        //Recursive function
+                                                        $intCounter = wp_custom_navigation_default_sub_items($cat_item-&gt;cat_ID, $intCounter, $parentli, 'categories','menu');
+                                                        
+                                                ?&gt;
+                                    
+                                    &lt;/li&gt;
+                                    
+                                    &lt;?php 
+                            }
+                            //Sidebar Menu
+                            elseif ($type == 'default')
+                            {
+                                    ?&gt;
+                                    &lt;li&gt;
+                                                &lt;dl&gt;
+                                                &lt;dt&gt;
+                                                &lt;?php
+                                        $post_text = htmlentities($cat_item-&gt;cat_name);
+                                        $post_url = get_category_link($cat_item-&gt;cat_ID);
+                                        $post_id = $cat_item-&gt;cat_ID;
+                                        $post_parent_id = $cat_item-&gt;parent;
+                                        $description = htmlentities(strip_tags($cat_item-&gt;description));
+                                        ?&gt;
+                                        &lt;?php $templatedir = get_bloginfo('url'); ?&gt;
+                                                &lt;span class=&quot;title&quot;&gt;&lt;?php echo $cat_item-&gt;cat_name; ?&gt;&lt;/span&gt; &lt;a onclick=&quot;appendToList('&lt;?php echo $templatedir; ?&gt;','Category','&lt;?php echo $post_text; ?&gt;','&lt;?php echo $post_url; ?&gt;','&lt;?php echo $post_id; ?&gt;','&lt;?php echo $post_parent_id ?&gt;','&lt;?php echo $description; ?&gt;')&quot; name=&quot;&lt;?php echo $post_text; ?&gt;&quot; value=&quot;&lt;?php echo $post_url;  ?&gt;&quot;&gt;&lt;img alt=&quot;Add to Custom Menu&quot; title=&quot;Add to Custom Menu&quot;  src=&quot;&lt;?php echo get_bloginfo('url'); ?&gt;/wp-admin/images/ico-add.png&quot; /&gt;&lt;/a&gt; &lt;/dt&gt;
+                                                &lt;/dl&gt;
+                                                &lt;?php $parentli = $cat_item-&gt;cat_ID; ?&gt;
+                                    &lt;?php $intCounter++; ?&gt;                
+                                                &lt;?php 
+                                                        //Recursive function
+                                                        $intCounter = wp_custom_navigation_default_sub_items($cat_item-&gt;cat_ID, $intCounter, $parentli, 'categories','default');
+                                                ?&gt;
+                                                
+                                        &lt;/li&gt;
+                                        
+                                        &lt;?php 
+                            }        
+                        } 
+                }
+        }
+        else 
+        {
+                echo 'Not Found';
+        }
+        
+        return $intCounter;
+}
+
+//RECURSIVE Sub Menu Items of default categories and pages
+function wp_custom_navigation_default_sub_items($childof, $intCounter, $parentli, $type, $output_type) {
+
+        $counter = $intCounter;
+        
+        //Custom Menu
+        if ($output_type == 'menu') 
+        {
+                $sub_args = array(
+                'child_of' =&gt; $childof,
+                'hide_empty' =&gt; false,
+                'parent' =&gt; $childof);
+        }
+        //Sidebar Menu
+        elseif ($output_type == 'default') 
+        {
+                $sub_args = array(
+                'child_of' =&gt; $childof,
+                'hide_empty' =&gt; false,
+                'parent' =&gt; $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)
+        {
+                ?&gt;
+                
+                &lt;ul id=&quot;sub-custom-nav-&lt;?php echo $type ?&gt;&quot;&gt;
+                
+                &lt;?php
+                //DISPLAY Loop
+                foreach ($sub_array as $sub_item)
+                {
+                        //Prepare Menu Data
+                        //Category Menu Item
+                        if ($type == 'categories') 
+                        {
+                                $link = get_category_link($sub_item-&gt;cat_ID);
+                                $title = htmlentities($sub_item-&gt;cat_name);
+                                $parent_id = $sub_item-&gt;cat_ID;
+                                $itemid = $sub_item-&gt;cat_ID;
+                                $linktype = 'category';
+                                $appendtype = 'Category';
+                                $description = htmlentities(strip_tags($sub_item-&gt;description));                                
+                        }
+                        //Page Menu Item
+                        elseif ($type == 'pages')
+                        {
+                                $link = get_permalink($sub_item-&gt;ID);
+                                $title = htmlentities($sub_item-&gt;post_title);
+                                $parent_id = $sub_item-&gt;ID;
+                                $linktype = 'page';
+                                $itemid = $sub_item-&gt;ID;
+                                $appendtype = 'Page';
+                                $description = htmlentities(get_post_meta($itemid, 'page-description', true));
+                        }
+                        //Custom Menu Item
+                        else 
+                        {
+                                $title = '';
+                                $linktype = 'custom';
+                                $appendtype= 'Custom';
+                        }
+                        
+                        //Custom Menu
+                        if ($output_type == 'menu')
+                        {
+                                ?&gt;
+                                &lt;li id=&quot;menu-&lt;?php echo $counter; ?&gt;&quot; value=&quot;&lt;?php echo $counter; ?&gt;&quot;&gt;
+                                        &lt;dl&gt;
+                                        &lt;dt&gt;
+                                                &lt;span class=&quot;title&quot;&gt;&lt;?php echo $title; ?&gt;&lt;/span&gt;
+                                                        &lt;span class=&quot;controls&quot;&gt;
+                                                        &lt;span class=&quot;type&quot;&gt;&lt;?php echo $linktype; ?&gt;&lt;/span&gt;
+                                                        &lt;a id=&quot;edit&lt;?php echo $counter; ?&gt;&quot; onclick=&quot;edititem(&lt;?php echo $counter; ?&gt;)&quot; value=&quot;&lt;?php echo $counter; ?&gt;&quot;&gt;&lt;img class=&quot;edit&quot; alt=&quot;Edit Menu Item&quot; title=&quot;Edit Menu Item&quot; src=&quot;&lt;?php echo get_bloginfo('url'); ?&gt;/wp-admin/images/ico-edit.png&quot; /&gt;&lt;/a&gt; 
+                                                                &lt;a id=&quot;remove&lt;?php echo $counter; ?&gt;&quot; onclick=&quot;removeitem(&lt;?php echo $counter; ?&gt;)&quot; value=&quot;&lt;?php echo $counter; ?&gt;&quot;&gt;
+                                                                        &lt;img class=&quot;remove&quot; alt=&quot;Remove from Custom Menu&quot; title=&quot;Remove from Custom Menu&quot; src=&quot;&lt;?php echo get_bloginfo('url'); ?&gt;/wp-admin/images/ico-close.png&quot; /&gt;
+                                                                &lt;/a&gt;
+                                                                &lt;a target=&quot;_blank&quot; href=&quot;&lt;?php echo $link; ?&gt;&quot;&gt;
+                                                                        &lt;img alt=&quot;View Page&quot; title=&quot;View Page&quot; src=&quot;&lt;?php echo get_bloginfo('url'); ?&gt;/wp-admin/images/ico-viewpage.png&quot; /&gt;
+                                                                &lt;/a&gt;
+                                                &lt;/span&gt;
+                        
+                                        &lt;/dt&gt;
+                                        &lt;/dl&gt;
+                                        &lt;a class=&quot;hide&quot; href=&quot;&lt;?php echo $link; ?&gt;&quot;&gt;&lt;?php echo $title; ?&gt;&lt;/a&gt;
+                                        &lt;input type=&quot;hidden&quot; name=&quot;dbid&lt;?php echo $counter; ?&gt;&quot; id=&quot;dbid&lt;?php echo $counter; ?&gt;&quot; value=&quot;&lt;?php echo $sub_item-&gt;id; ?&gt;&quot; /&gt;
+                                        &lt;input type=&quot;hidden&quot; name=&quot;postmenu&lt;?php echo $counter; ?&gt;&quot; id=&quot;postmenu&lt;?php echo $counter; ?&gt;&quot; value=&quot;&lt;?php echo $parent_id; ?&gt;&quot; /&gt;
+                                        &lt;input type=&quot;hidden&quot; name=&quot;parent&lt;?php echo $counter; ?&gt;&quot; id=&quot;parent&lt;?php echo $counter; ?&gt;&quot; value=&quot;&lt;?php echo $parentli; ?&gt;&quot; /&gt;
+                                        &lt;input type=&quot;hidden&quot; name=&quot;title&lt;?php echo $counter; ?&gt;&quot; id=&quot;title&lt;?php echo $counter; ?&gt;&quot; value=&quot;&lt;?php echo $title; ?&gt;&quot; /&gt;
+                                        &lt;input type=&quot;hidden&quot; name=&quot;linkurl&lt;?php echo $counter; ?&gt;&quot; id=&quot;linkurl&lt;?php echo $counter; ?&gt;&quot; value=&quot;&lt;?php echo $link; ?&gt;&quot; /&gt;
+                                        &lt;input type=&quot;hidden&quot; name=&quot;description&lt;?php echo $counter; ?&gt;&quot; id=&quot;description&lt;?php echo $counter; ?&gt;&quot; value=&quot;&lt;?php echo $description; ?&gt;&quot; /&gt;
+                                        &lt;input type=&quot;hidden&quot; name=&quot;icon&lt;?php echo $counter; ?&gt;&quot; id=&quot;icon&lt;?php echo $counter; ?&gt;&quot; value=&quot;0&quot; /&gt;
+                                        &lt;input type=&quot;hidden&quot; name=&quot;position&lt;?php echo $counter; ?&gt;&quot; id=&quot;position&lt;?php echo $counter; ?&gt;&quot; value=&quot;&lt;?php echo $counter; ?&gt;&quot; /&gt;
+                                        &lt;input type=&quot;hidden&quot; name=&quot;linktype&lt;?php echo $counter; ?&gt;&quot; id=&quot;linktype&lt;?php echo $counter; ?&gt;&quot; value=&quot;&lt;?php echo $linktype; ?&gt;&quot; /&gt;
+                                        &lt;input type=&quot;hidden&quot; name=&quot;anchortitle&lt;?php echo $counter; ?&gt;&quot; id=&quot;anchortitle&lt;?php echo $counter; ?&gt;&quot; value=&quot;&lt;?php echo $title; ?&gt;&quot; /&gt;
+                                        &lt;input type=&quot;hidden&quot; name=&quot;newwindow&lt;?php echo $counter; ?&gt;&quot; id=&quot;newwindow&lt;?php echo $counter; ?&gt;&quot; value=&quot;0&quot; /&gt;
+                                        
+                                        &lt;?php $counter++; ?&gt;
+                                        &lt;?php 
+                                                
+                                                //Do recursion
+                                                $counter = wp_custom_navigation_default_sub_items($parent_id, $counter, $parent_id, $type, 'menu'); 
+                                                
+                                        ?&gt;
+                                        
+                                &lt;/li&gt;
+                                &lt;?php 
+                        }
+                        //Sidebar Menu
+                        elseif ($output_type == 'default')
+                        {
+                                        
+                                ?&gt;
+                                &lt;li&gt;
+                                        &lt;dl&gt;
+                                        &lt;dt&gt;
+                                        
+                                        &lt;?php $templatedir = get_bloginfo('url'); ?&gt;
+                                        &lt;span class=&quot;title&quot;&gt;&lt;?php echo $title; ?&gt;&lt;/span&gt; &lt;a onclick=&quot;appendToList('&lt;?php echo $templatedir; ?&gt;','&lt;?php echo $appendtype; ?&gt;','&lt;?php echo $title; ?&gt;','&lt;?php echo $link; ?&gt;','&lt;?php echo $itemid; ?&gt;','&lt;?php echo $parent_id ?&gt;','&lt;?php echo $description; ?&gt;')&quot; name=&quot;&lt;?php echo $title; ?&gt;&quot; value=&quot;&lt;?php echo $link; ?&gt;&quot;&gt;&lt;img alt=&quot;Add to Custom Menu&quot; title=&quot;Add to Custom Menu&quot; src=&quot;&lt;?php echo get_bloginfo('url'); ?&gt;/wp-admin/images/ico-add.png&quot; /&gt;&lt;/a&gt; &lt;/dt&gt;
+                                        &lt;/dl&gt;
+                                        &lt;?php 
+                                        
+                                                //Do recursion
+                                                $counter = wp_custom_navigation_default_sub_items($itemid, $counter, $parent_id, $type, 'default');
+                                                
+                                        ?&gt;
+                                &lt;/li&gt;
+                                          
+                                &lt;?php 
+                        }
+                        
+                }
+                ?&gt;
+                
+                &lt;/ul&gt;
+                
+        &lt;?php 
+        }
+        
+        return $counter;
+
+}
+
+/*-----------------------------------------------------------------------------------*/
+/* Recursive get children */
+/*-----------------------------------------------------------------------------------*/
+
+function get_children_menu_elements($childof, $intCounter, $parentli, $type, $menu_id, $table_name) {
+
+        $counter = $intCounter;
+        
+        global $wpdb;
+        
+        
+        
+        //Get Sub Category Items                        
+        if ($type == 'categories')
+        {
+                $sub_args = array(
+                        'child_of' =&gt; $childof,
+                        'hide_empty'  =&gt; false,
+                        'parent' =&gt; $childof);
+                $sub_array = get_categories($sub_args);        
+        }
+        //Get Sub Page Items
+        elseif ($type == 'pages')
+        {
+                $sub_args = array(
+                        'child_of' =&gt; $childof,
+                        'parent' =&gt; $childof);
+        
+                $sub_array = get_pages($sub_args);
+                
+        }
+        else {
+        
+        }
+        
+        if ($sub_array)
+        {
+                //DISPLAY Loop
+                foreach ($sub_array as $sub_item)
+                {
+                        if (isset($sub_item-&gt;parent)) {
+                                $sub_item_parent = $sub_item-&gt;parent;
+                        }
+                        elseif (isset($sub_item-&gt;post_parent)) {
+                                $sub_item_parent = $sub_item-&gt;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-&gt;cat_ID);
+                                        $title = htmlentities($sub_item-&gt;cat_name);
+                                        $parent_id = $sub_item-&gt;category_parent;
+                                        $itemid = $sub_item-&gt;cat_ID;
+                                        $linktype = 'category';
+                                        $appendtype= 'Category';
+                                }
+                                //Page Menu Item
+                                elseif ($type == 'pages')
+                                {
+                                        $link = get_permalink($sub_item-&gt;ID);
+                                        $title = htmlentities($sub_item-&gt;post_title);
+                                        $parent_id = $sub_item-&gt;post_parent;
+                                        $linktype = 'page';
+                                        $itemid = $sub_item-&gt;ID;
+                                        $appendtype= 'Page';
+                                }
+                                //Custom Menu Item
+                                else 
+                                {
+                                        $title = '';
+                                        $linktype = 'custom';
+                                        $appendtype= 'Custom';
+                                }
+                                
+                                //CHECK for existing parent records
+                                //echo $parent_id;
+                                $wp_result = $wpdb-&gt;get_results(&quot;SELECT id FROM &quot;.$table_name.&quot; WHERE post_id='&quot;.$parent_id.&quot;' AND link_type='&quot;.$linktype.&quot;' AND menu_id='&quot;.$menu_id.&quot;'&quot;);
+                                if ($wp_result &gt; 0 &amp;&amp; isset($wp_result[0]-&gt;id)) {
+                                        $parent_id = $wp_result[0]-&gt;id;
+                                }
+                                else {
+                                        //$parent_id = 0;
+                                }
+                                
+                                //INSERT item
+                                $insert = &quot;INSERT INTO &quot;.$table_name.&quot; (position,post_id,parent_id,custom_title,custom_link,custom_description,menu_icon,link_type,menu_id,custom_anchor_title) &quot;.&quot;VALUES ('&quot;.$counter.&quot;','&quot;.$itemid.&quot;','&quot;.$parent_id.&quot;','&quot;.$title.&quot;','&quot;.$link.&quot;','','','&quot;.$linktype.&quot;','&quot;.$menu_id.&quot;','&quot;.$title.&quot;')&quot;;
+                                  $results = $wpdb-&gt;query( $insert );
+         
+                                  $counter++;
+                                  $counter = get_children_menu_elements($itemid, $counter, $parent_id, $type, $menu_id, $table_name);
+                        }        
+                        //Do nothing
+                        else {
+                        
+                        }
+                }
+        }
+        return $counter;
+}
+
+
+?&gt;
</ins></span></pre></div>
<a id="trunkwpincludescustomnavigationphp"></a>
<div class="propset"><h4>Property changes: trunk/wp-includes/custom-navigation.php</h4>
<pre class="diff"><span>
<span class="cx">Name: svn:eol-style
</span><span class="cx">   + native
</span></span></pre></div>
<a id="trunkwpincludesgeneraltemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/general-template.php (13261 => 13262)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/general-template.php        2010-02-20 22:44:24 UTC (rev 13261)
+++ trunk/wp-includes/general-template.php        2010-02-20 23:18:57 UTC (rev 13262)
</span><span class="lines">@@ -2221,7 +2221,7 @@
</span><span class="cx">  * @since 3.0.0
</span><span class="cx">  */
</span><span class="cx"> function custom_nav($args = array()) {
</span><del>-        require_once (ABSPATH . WPINC . '/custom-navigation-functions.php');
</del><ins>+        require_once (ABSPATH . WPINC . '/custom-navigation.php');
</ins><span class="cx">         wp_custom_navigation_output($args);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>