<!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>[13317] trunk/wp-includes/custom-navigation.php: Formatting cleanups.</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/13317">13317</a></dd>
<dt>Author</dt> <dd>ryan</dd>
<dt>Date</dt> <dd>2010-02-22 23:14:03 +0000 (Mon, 22 Feb 2010)</dd>
</dl>

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

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

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpincludescustomnavigationphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/custom-navigation.php (13316 => 13317)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/custom-navigation.php        2010-02-22 23:12:48 UTC (rev 13316)
+++ trunk/wp-includes/custom-navigation.php        2010-02-22 23:14:03 UTC (rev 13317)
</span><span class="lines">@@ -32,35 +32,23 @@
</span><span class="cx"> 
</span><span class="cx"> function wp_custom_navigation_setup($override = false) {
</span><span class="cx"> 
</span><del>-        $nav_version = '1.1.0';
-        //Custom Navigation Menu Setup
</del><ins>+        // Custom Navigation Menu Setup
</ins><span class="cx"> 
</span><del>-        //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';
-        }
</del><ins>+        // Override for menu descriptions
+        update_option('wp_settings_custom_nav_advanced_options', 'yes');
</ins><span class="cx"> 
</span><del>-        //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);
-
</del><span class="cx">         $custom_menus = get_terms( 'nav_menu', array( 'hide_empty' =&gt; false ) );
</span><span class="cx">          if ( !empty( $custom_menus ) ) {
</span><del>-                foreach( $custom_menus as $menu ) {
</del><ins>+                foreach ( $custom_menus as $menu ) {
</ins><span class="cx">                         $menu_objects = get_objects_in_term( $menu-&gt;term_id, 'nav_menu' );
</span><span class="cx">                         if ( !empty( $menu_objects ) ) {
</span><del>-                                foreach( $menu_objects as $item )
</del><ins>+                                foreach ( $menu_objects as $item ) {
</ins><span class="cx">                                         wp_delete_post( $item );
</span><ins>+                                }
</ins><span class="cx">                         }
</span><span class="cx">                         wp_delete_term( $menu-&gt;term_id, 'nav_menu' );
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /*-----------------------------------------------------------------------------------*/
</span><span class="lines">@@ -83,27 +71,17 @@
</span><span class="cx"> /* after_title - html after title is outputted in &lt;a&gt; tag
</span><span class="cx"> /*-----------------------------------------------------------------------------------*/
</span><span class="cx"> 
</span><del>-function wp_custom_navigation_output($args = array()) {
</del><ins>+function wp_custom_navigation_output( $args = array() ) {
</ins><span class="cx"> 
</span><del>-                //DEFAULT ARGS
-                $type = 'frontend';
-                $name = 'Menu 1';
-                $id = 0;
-                $desc = 2;
-                $before_title = '';
-                $after_title = '';
</del><ins>+                // Defaults
+                $defaults = array( 'type' =&gt; 'frontend', 'name' =&gt; 'Menu 1', 'id' =&gt; 0, 'desc' =&gt; 2, 'before_title' =&gt; '', 'after_title' =&gt; '');
</ins><span class="cx"> 
</span><del>-                if (isset($args)) {
</del><ins>+                $args = wp_parse_args($args, $defaults);
+                extract($args, EXTR_SKIP);
</ins><span class="cx"> 
</span><del>-                        if ( !is_array($args) )
-                        parse_str( $args, $args );
-
-                        extract($args);
-                }
-
</del><span class="cx">                 $menu_objects = get_objects_in_term( $id, 'nav_menu' );
</span><span class="cx">                 $menu_items = wp_custom_navigation_get_menu_items( $menu_objects, 'menu_order' );
</span><del>-                //Override for menu descriptions
</del><ins>+                //O verride for menu descriptions
</ins><span class="cx">                 $advanced_option_descriptions = get_option('wp_settings_custom_nav_advanced_options');
</span><span class="cx">                 if ( $advanced_option_descriptions == 'no' )
</span><span class="cx">                         $desc = 2;
</span><span class="lines">@@ -211,14 +189,9 @@
</span><span class="cx">                                                                 // 2 widget override do NOT display descriptions
</span><span class="cx">                                                                 // 1 widget override display descriptions
</span><span class="cx">                                                                 // 0 widget override not set
</span><del>-                                                                if (($desc == 1) || ($desc == 0) )
-                                                                {
</del><ins>+                                                                if ( ($desc == 1) || ($desc == 0) ) {
</ins><span class="cx">                                                                         ?&gt;&lt;span class=&quot;nav-description&quot;&gt;&lt;?php echo $description; ?&gt;&lt;/span&gt;&lt;?php
</span><span class="cx">                                                                 }
</span><del>-                                                                elseif ($desc == 2)
-                                                                { }
-                                                                else
-                                                                { }
</del><span class="cx">                                                         } else {
</span><span class="cx">                                                                 // 2 widget override do NOT display descriptions
</span><span class="cx">                                                                 // 1 widget override display descriptions
</span><span class="lines">@@ -226,10 +199,6 @@
</span><span class="cx">                                                                 if ( $desc == 1 ) {
</span><span class="cx">                                                                         ?&gt;&lt;span class=&quot;nav-description&quot;&gt;&lt;?php echo $description; ?&gt;&lt;/span&gt;&lt;?php
</span><span class="cx">                                                                 }
</span><del>-                                                                elseif (($desc == 2) || ($desc == 0))
-                                                                { }
-                                                                else
-                                                                { }
</del><span class="cx">                                                         }
</span><span class="cx"> 
</span><span class="cx">                                                 ?&gt;&lt;/a&gt;&lt;?php
</span><span class="lines">@@ -287,7 +256,7 @@
</span><span class="cx"> }
</span><span class="cx"> //@todo: implement menu heirarchy
</span><span class="cx"> //RECURSIVE Sub Menu Items
</span><del>-function wp_custom_navigation_sub_items($post_id,$type,$table_name,$output_type,$menu_id = 0) {
</del><ins>+function wp_custom_navigation_sub_items($post_id, $type, $table_name, $output_type, $menu_id = 0) {
</ins><span class="cx"> 
</span><span class="cx">         $parent_id = 0;
</span><span class="cx">         global $wpdb;
</span><span class="lines">@@ -466,8 +435,8 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-//Outputs All Pages and Sub Items
-function wp_custom_nav_get_pages($counter,$type) {
</del><ins>+// Outputs All Pages and Sub Items
+function wp_custom_nav_get_pages($counter, $type) {
</ins><span class="cx"> 
</span><span class="cx">         $pages_args = array(
</span><span class="cx">                     'child_of' =&gt; 0,
</span><span class="lines">@@ -490,111 +459,99 @@
</span><span class="cx">         $intCounter = $counter;
</span><span class="cx">         $parentli = $intCounter;
</span><span class="cx"> 
</span><del>-        if ($pages_array)
-        {
-                //DISPLAY Loop
-                foreach ($pages_array as $post)
-                {
</del><ins>+        if ( !$pages_array ) {
+                echo 'Not Found';
+                return $intCounter;
+        }
</ins><span class="cx"> 
</span><del>-                        if ($post-&gt;post_parent == 0)
-                        {
-                                //Custom Menu
-                                if ($type == 'menu')
-                                {
-                                        $description = get_post_meta($post-&gt;ID, 'page-description', true);
-                                        ?&gt;
</del><ins>+        // 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;
</ins><span class="cx"> 
</span><del>-                                        &lt;li id=&quot;menu-&lt;?php echo $intCounter; ?&gt;&quot; value=&quot;&lt;?php echo $intCounter; ?&gt;&quot;&gt;
</del><ins>+                                &lt;li id=&quot;menu-&lt;?php echo $intCounter; ?&gt;&quot; value=&quot;&lt;?php echo $intCounter; ?&gt;&quot;&gt;
</ins><span class="cx"> 
</span><del>-                                                &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;
</del><ins>+                                        &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;
</ins><span class="cx"> 
</span><del>-                                                &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;
</del><ins>+                                        &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;
</ins><span class="cx"> 
</span><del>-                                                &lt;?php $parentli = $post-&gt;ID; ?&gt;
-                                                &lt;?php $intCounter++; ?&gt;
-                                                &lt;?php
</del><ins>+                                        &lt;?php $parentli = $post-&gt;ID; ?&gt;
+                                        &lt;?php $intCounter++; ?&gt;
+                                        &lt;?php
</ins><span class="cx"> 
</span><del>-                                                        //Recursive function
-                                                        $intCounter = wp_custom_navigation_default_sub_items($post-&gt;ID, $intCounter, $parentli, 'pages', 'menu');
</del><ins>+                                                //Recursive function
+                                                $intCounter = wp_custom_navigation_default_sub_items($post-&gt;ID, $intCounter, $parentli, 'pages', 'menu');
</ins><span class="cx"> 
</span><del>-                                                ?&gt;
</del><ins>+                                        ?&gt;
</ins><span class="cx"> 
</span><del>-                                        &lt;/li&gt;
</del><ins>+                                &lt;/li&gt;
</ins><span class="cx"> 
</span><del>-                                        &lt;?php
</del><ins>+                                &lt;?php
</ins><span class="cx"> 
</span><del>-                                }
-                                //Sidebar Menu
-                                elseif ($type == 'default')
-                                {
-                                        ?&gt;
</del><ins>+                        } elseif ( $type == 'default' ) {
+                                // Sidebar Menu
+                                ?&gt;
</ins><span class="cx"> 
</span><del>-                                         &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;
</del><ins>+                                 &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;
</ins><span class="cx"> 
</span><del>-                                                        $description = htmlentities(get_post_meta($post_id, 'page-description', true));
</del><ins>+                                                $description = htmlentities(get_post_meta($post_id, 'page-description', true));
</ins><span class="cx"> 
</span><del>-                                        ?&gt;
-                                        &lt;?php $templatedir = get_bloginfo('url'); ?&gt;
</del><ins>+                                        ?&gt;
+                                        &lt;?php $templatedir = get_bloginfo('url'); ?&gt;
</ins><span class="cx"> 
</span><del>-                                        &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
</del><ins>+                                        &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
</ins><span class="cx"> 
</span><del>-                                                        //Recursive function
-                                                        $intCounter = wp_custom_navigation_default_sub_items($post_id, $intCounter, $parentli, 'pages', 'default');
</del><ins>+                                                //Recursive function
+                                                $intCounter = wp_custom_navigation_default_sub_items($post_id, $intCounter, $parentli, 'pages', 'default');
</ins><span class="cx"> 
</span><del>-                                                 ?&gt;
</del><ins>+                                         ?&gt;
</ins><span class="cx"> 
</span><del>-                                        &lt;/li&gt;
</del><ins>+                                &lt;/li&gt;
</ins><span class="cx"> 
</span><del>-                                        &lt;?php
</del><ins>+                                &lt;?php
</ins><span class="cx"> 
</span><del>-                                }
-                                else
-                                {
-
-                                }
</del><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        else
-        {
-                echo 'Not Found';
-        }
</del><span class="cx"> 
</span><span class="cx">         return $intCounter;
</span><span class="cx"> }
</span><span class="lines">@@ -615,110 +572,101 @@
</span><span class="cx">                         'number'                   =&gt; '',
</span><span class="cx">                         'pad_counts'               =&gt; false );
</span><span class="cx"> 
</span><del>-
-
</del><span class="cx">         $intCounter = $counter;
</span><span class="cx"> 
</span><del>-        //GET all categories
</del><ins>+        // Get all categories
</ins><span class="cx">         $categories_array = get_categories($category_args);
</span><span class="cx"> 
</span><del>-        if ($categories_array)
-        {
-                //DISPLAY Loop
-                foreach ($categories_array as $cat_item)
-                {
</del><ins>+        if ( !$categories_array ) {
+                echo 'Not Found';
+                return $intCounter;
+        }
</ins><span class="cx"> 
</span><del>-                        if ($cat_item-&gt;parent == 0)
-                        {
-                                //Custom Menu
-                                if ($type == 'menu')
-                                {
-                                        ?&gt;
</del><ins>+        // Display Loop
+        foreach ( $categories_array as $cat_item ) {
</ins><span class="cx"> 
</span><del>-                                    &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;
</del><ins>+                if ( $cat_item-&gt;parent == 0 ) {
+                        // Custom Menu
+                        if ( $type == 'menu' ) {
+                                ?&gt;
</ins><span class="cx"> 
</span><del>-                                    &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;
</del><ins>+                                &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;
</ins><span class="cx"> 
</span><del>-                                    &lt;?php $parentli = $cat_item-&gt;cat_ID; ?&gt;
-                                    &lt;?php $intCounter++; ?&gt;
-                                           &lt;?php
</del><ins>+                                        &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;
</ins><span class="cx"> 
</span><del>-                                                        //Recursive function
-                                                        $intCounter = wp_custom_navigation_default_sub_items($cat_item-&gt;cat_ID, $intCounter, $parentli, 'categories','menu');
</del><ins>+                                        &lt;?php $parentli = $cat_item-&gt;cat_ID; ?&gt;
+                                        &lt;?php $intCounter++; ?&gt;
+                                        &lt;?php
</ins><span class="cx"> 
</span><del>-                                                ?&gt;
</del><ins>+                                                //Recursive function
+                                                $intCounter = wp_custom_navigation_default_sub_items($cat_item-&gt;cat_ID, $intCounter, $parentli, 'categories','menu');
</ins><span class="cx"> 
</span><del>-                                    &lt;/li&gt;
</del><ins>+                                        ?&gt;
</ins><span class="cx"> 
</span><del>-                                    &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;
</del><ins>+                                &lt;/li&gt;
</ins><span class="cx"> 
</span><del>-                                        &lt;/li&gt;
-
</del><ins>+                                &lt;?php
+                        } elseif ($type == 'default') {
+                                // Sidebar Menu
+                                ?&gt;
+                                &lt;li&gt;
+                                        &lt;dl&gt;
+                                        &lt;dt&gt;
</ins><span class="cx">                                         &lt;?php
</span><del>-                            }
</del><ins>+                                        $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
</ins><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        else
-        {
-                echo 'Not Found';
-        }
</del><span class="cx"> 
</span><span class="cx">         return $intCounter;
</span><span class="cx"> }
</span><span class="lines">@@ -728,53 +676,42 @@
</span><span class="cx"> 
</span><span class="cx">         $counter = $intCounter;
</span><span class="cx"> 
</span><del>-        //Custom Menu
-        if ($output_type == 'menu')
-        {
</del><ins>+        // Custom Menu
+        if ($output_type == 'menu') {
</ins><span class="cx">                 $sub_args = array(
</span><span class="cx">                 'child_of' =&gt; $childof,
</span><span class="cx">                 'hide_empty' =&gt; false,
</span><span class="cx">                 'parent' =&gt; $childof);
</span><del>-        }
-        //Sidebar Menu
-        elseif ($output_type == 'default')
-        {
</del><ins>+        } elseif ($output_type == 'default') {
+                // Sidebar Menu
</ins><span class="cx">                 $sub_args = array(
</span><span class="cx">                 'child_of' =&gt; $childof,
</span><span class="cx">                 'hide_empty' =&gt; false,
</span><span class="cx">                 'parent' =&gt; $childof);
</span><span class="cx">         }
</span><del>-        else
-        {
</del><span class="cx"> 
</span><del>-        }
-
-        //Get Sub Category Items
-        if ($type == 'categories')
-        {
</del><ins>+        if ( $type == 'categories' ) {
+                // Get Sub Category Items
</ins><span class="cx">                 $sub_array = get_categories($sub_args);
</span><del>-        }
-        //Get Sub Page Items
-        elseif ($type == 'pages')
-        {
</del><ins>+        } elseif ($type == 'pages') {
+                // Get Sub Page Items
</ins><span class="cx">                 $sub_array = get_pages($sub_args);
</span><ins>+        } else {
+                $sub_array = array();
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-        if ($sub_array)
-        {
</del><ins>+        if ( $sub_array ) {
</ins><span class="cx">                 ?&gt;
</span><span class="cx"> 
</span><span class="cx">                 &lt;ul id=&quot;sub-custom-nav-&lt;?php echo $type ?&gt;&quot;&gt;
</span><span class="cx"> 
</span><span class="cx">                 &lt;?php
</span><del>-                //DISPLAY Loop
-                foreach ($sub_array as $sub_item)
-                {
</del><ins>+                // Display Loop
+                foreach ( $sub_array as $sub_item ) {
</ins><span class="cx">                         //Prepare Menu Data
</span><span class="cx">                         //Category Menu Item
</span><del>-                        if ($type == 'categories')
-                        {
</del><ins>+                        if ( $type == 'categories' ) {
</ins><span class="cx">                                 $link = get_category_link($sub_item-&gt;cat_ID);
</span><span class="cx">                                 $title = htmlentities($sub_item-&gt;cat_name);
</span><span class="cx">                                 $parent_id = $sub_item-&gt;cat_ID;
</span><span class="lines">@@ -782,10 +719,8 @@
</span><span class="cx">                                 $linktype = 'category';
</span><span class="cx">                                 $appendtype = 'Category';
</span><span class="cx">                                 $description = htmlentities(strip_tags($sub_item-&gt;description));
</span><del>-                        }
-                        //Page Menu Item
-                        elseif ($type == 'pages')
-                        {
</del><ins>+                        } elseif ( $type == 'pages' ) {
+                                //Page Menu Item
</ins><span class="cx">                                 $link = get_permalink($sub_item-&gt;ID);
</span><span class="cx">                                 $title = htmlentities($sub_item-&gt;post_title);
</span><span class="cx">                                 $parent_id = $sub_item-&gt;ID;
</span><span class="lines">@@ -793,18 +728,15 @@
</span><span class="cx">                                 $itemid = $sub_item-&gt;ID;
</span><span class="cx">                                 $appendtype = 'Page';
</span><span class="cx">                                 $description = htmlentities(get_post_meta($itemid, 'page-description', true));
</span><del>-                        }
-                        //Custom Menu Item
-                        else
-                        {
</del><ins>+                        } else {
+                                // Custom Menu Item
</ins><span class="cx">                                 $title = '';
</span><span class="cx">                                 $linktype = 'custom';
</span><span class="cx">                                 $appendtype= 'Custom';
</span><span class="cx">                         }
</span><span class="cx"> 
</span><del>-                        //Custom Menu
-                        if ($output_type == 'menu')
-                        {
</del><ins>+                        // Custom Menu
+                        if ( $output_type == 'menu' ) {
</ins><span class="cx">                                 ?&gt;
</span><span class="cx">                                 &lt;li id=&quot;menu-&lt;?php echo $counter; ?&gt;&quot; value=&quot;&lt;?php echo $counter; ?&gt;&quot;&gt;
</span><span class="cx">                                         &lt;dl&gt;
</span><span class="lines">@@ -846,11 +778,8 @@
</span><span class="cx"> 
</span><span class="cx">                                 &lt;/li&gt;
</span><span class="cx">                                 &lt;?php
</span><del>-                        }
-                        //Sidebar Menu
-                        elseif ($output_type == 'default')
-                        {
-
</del><ins>+                        } elseif ($output_type == 'default') {
+                                // Sidebar Menu
</ins><span class="cx">                                 ?&gt;
</span><span class="cx">                                 &lt;li&gt;
</span><span class="cx">                                         &lt;dl&gt;
</span><span class="lines">@@ -879,7 +808,6 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         return $counter;
</span><del>-
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /*-----------------------------------------------------------------------------------*/
</span><span class="lines">@@ -887,16 +815,12 @@
</span><span class="cx"> /*-----------------------------------------------------------------------------------*/
</span><span class="cx"> 
</span><span class="cx"> function get_children_menu_elements($childof, $intCounter, $parentli, $type, $menu_id, $table_name) {
</span><ins>+        global $wpdb;
</ins><span class="cx"> 
</span><span class="cx">         $counter = $intCounter;
</span><span class="cx"> 
</span><del>-        global $wpdb;
-
-
-
</del><span class="cx">         //Get Sub Category Items
</span><del>-        if ($type == 'categories')
-        {
</del><ins>+        if ( $type == 'categories' ) {
</ins><span class="cx">                 $sub_args = array(
</span><span class="cx">                         'child_of' =&gt; $childof,
</span><span class="cx">                         'hide_empty'  =&gt; false,
</span><span class="lines">@@ -912,31 +836,24 @@
</span><span class="cx"> 
</span><span class="cx">                 $sub_array = get_pages($sub_args);
</span><span class="cx"> 
</span><ins>+        } else {
+                $sub_array = array();
</ins><span class="cx">         }
</span><del>-        else {
</del><span class="cx"> 
</span><del>-        }
-
-        if ($sub_array)
-        {
</del><ins>+        if ( $sub_array ) {
</ins><span class="cx">                 //DISPLAY Loop
</span><del>-                foreach ($sub_array as $sub_item)
-                {
-                        if (isset($sub_item-&gt;parent)) {
</del><ins>+                foreach ( $sub_array as $sub_item ) {
+                        if ( isset($sub_item-&gt;parent) ) {
</ins><span class="cx">                                 $sub_item_parent = $sub_item-&gt;parent;
</span><del>-                        }
-                        elseif (isset($sub_item-&gt;post_parent)) {
</del><ins>+                        } elseif (isset($sub_item-&gt;post_parent)) {
</ins><span class="cx">                                 $sub_item_parent = $sub_item-&gt;post_parent;
</span><span class="cx">                         }
</span><del>-                        else {
-                        }
-                        //Is child
-                        if ($sub_item_parent == $childof)
-                        {
</del><ins>+
+                        // Is child
+                        if ( $sub_item_parent == $childof ) {
</ins><span class="cx">                                 //Prepare Menu Data
</span><span class="cx">                                 //Category Menu Item
</span><del>-                                if ($type == 'categories')
-                                {
</del><ins>+                                if ( $type == 'categories' ) {
</ins><span class="cx">                                         $link = get_category_link($sub_item-&gt;cat_ID);
</span><span class="cx">                                         $title = htmlentities($sub_item-&gt;cat_name);
</span><span class="cx">                                         $parent_id = $sub_item-&gt;category_parent;
</span><span class="lines">@@ -945,8 +862,7 @@
</span><span class="cx">                                         $appendtype= 'Category';
</span><span class="cx">                                 }
</span><span class="cx">                                 //Page Menu Item
</span><del>-                                elseif ($type == 'pages')
-                                {
</del><ins>+                                elseif ( $type == 'pages' ) {
</ins><span class="cx">                                         $link = get_permalink($sub_item-&gt;ID);
</span><span class="cx">                                         $title = htmlentities($sub_item-&gt;post_title);
</span><span class="cx">                                         $parent_id = $sub_item-&gt;post_parent;
</span><span class="lines">@@ -955,8 +871,7 @@
</span><span class="cx">                                         $appendtype= 'Page';
</span><span class="cx">                                 }
</span><span class="cx">                                 //Custom Menu Item
</span><del>-                                else
-                                {
</del><ins>+                                else {
</ins><span class="cx">                                         $title = '';
</span><span class="cx">                                         $linktype = 'custom';
</span><span class="cx">                                         $appendtype= 'Custom';
</span><span class="lines">@@ -967,8 +882,7 @@
</span><span class="cx">                                 $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;);
</span><span class="cx">                                 if ($wp_result &gt; 0 &amp;&amp; isset($wp_result[0]-&gt;id)) {
</span><span class="cx">                                         $parent_id = $wp_result[0]-&gt;id;
</span><del>-                                }
-                                else {
</del><ins>+                                } else {
</ins><span class="cx">                                         //$parent_id = 0;
</span><span class="cx">                                 }
</span><span class="cx"> 
</span><span class="lines">@@ -979,14 +893,9 @@
</span><span class="cx">                                   $counter++;
</span><span class="cx">                                   $counter = get_children_menu_elements($itemid, $counter, $parent_id, $type, $menu_id, $table_name);
</span><span class="cx">                         }
</span><del>-                        //Do nothing
-                        else {
-
-                        }
</del><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">         return $counter;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-
</del><span class="cx"> ?&gt;
</span></span></pre>
</div>
</div>

</body>
</html>