<!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') <> '') {
-                $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 <> $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' => 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->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->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 <a> 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' => 'frontend', 'name' => 'Menu 1', 'id' => 0, 'desc' => 2, 'before_title' => '', 'after_title' => '');
</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">                                                                         ?><span class="nav-description"><?php echo $description; ?></span><?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">                                                                         ?><span class="nav-description"><?php echo $description; ?></span><?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">                                                 ?></a><?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' => 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->post_parent == 0)
-                        {
-                                //Custom Menu
-                                if ($type == 'menu')
-                                {
-                                        $description = get_post_meta($post->ID, 'page-description', true);
-                                        ?>
</del><ins>+        // Display Loop
+        foreach ( $pages_array as $post ) {
+                if ($post->post_parent == 0) {
+                        // Custom Menu
+                        if ( $type == 'menu' ) {
+                                $description = get_post_meta($post->ID, 'page-description', true);
+                                ?>
</ins><span class="cx">
</span><del>-                                        <li id="menu-<?php echo $intCounter; ?>" value="<?php echo $intCounter; ?>">
</del><ins>+                                <li id="menu-<?php echo $intCounter; ?>" value="<?php echo $intCounter; ?>">
</ins><span class="cx">
</span><del>-                                                <dl>
-                                                <dt>
-                                                <span class="title"><?php echo $post->post_title; ?></span>
-                                                <span class="controls">
-                                                        <span class="type">page</span>
-                                                        <a id="edit<?php echo $intCounter; ?>" onclick="edititem(<?php echo $intCounter; ?>)" value="<?php echo $intCounter; ?>"><img class="edit" alt="Edit Menu Item" title="Edit Menu Item" src="<?php echo get_bloginfo('url'); ?>/wp-admin/images/ico-edit.png" /></a>
-                                                        <a id="remove<?php echo $intCounter; ?>" onclick="removeitem(<?php echo $intCounter; ?>)" value="<?php echo $intCounter; ?>">
-                                                                <img class="remove" alt="Remove from Custom Menu" title="Remove from Custom Menu" src="<?php echo get_bloginfo('url'); ?>/wp-admin/images/ico-close.png" />
-                                                        </a>
-                                                        <a target="_blank" href="<?php echo get_permalink($post->ID); ?>">
-                                                                <img alt="View Page" title="View Page" src="<?php echo get_bloginfo('url'); ?>/wp-admin/images/ico-viewpage.png" />
-                                                        </a>
-                                                </span>
</del><ins>+                                        <dl>
+                                        <dt>
+                                        <span class="title"><?php echo $post->post_title; ?></span>
+                                        <span class="controls">
+                                                <span class="type">page</span>
+                                                <a id="edit<?php echo $intCounter; ?>" onclick="edititem(<?php echo $intCounter; ?>)" value="<?php echo $intCounter; ?>"><img class="edit" alt="Edit Menu Item" title="Edit Menu Item" src="<?php echo get_bloginfo('url'); ?>/wp-admin/images/ico-edit.png" /></a>
+                                                <a id="remove<?php echo $intCounter; ?>" onclick="removeitem(<?php echo $intCounter; ?>)" value="<?php echo $intCounter; ?>">
+                                                        <img class="remove" alt="Remove from Custom Menu" title="Remove from Custom Menu" src="<?php echo get_bloginfo('url'); ?>/wp-admin/images/ico-close.png" />
+                                                </a>
+                                                <a target="_blank" href="<?php echo get_permalink($post->ID); ?>">
+                                                        <img alt="View Page" title="View Page" src="<?php echo get_bloginfo('url'); ?>/wp-admin/images/ico-viewpage.png" />
+                                                </a>
+                                        </span>
</ins><span class="cx">
</span><del>-                                                </dt>
-                                                </dl>
-                                                <a class="hide" href="<?php echo get_permalink($post->ID); ?>"><span class="title"><?php echo $post->post_title; ?></span>
-                                  </a>
-                                  <input type="hidden" name="postmenu<?php echo $intCounter; ?>" id="postmenu<?php echo $intCounter; ?>" value="<?php echo $post->ID; ?>" />
-                                                <input type="hidden" name="parent<?php echo $intCounter; ?>" id="parent<?php echo $intCounter; ?>" value="0" />
-                                                <input type="hidden" name="title<?php echo $intCounter; ?>" id="title<?php echo $intCounter; ?>" value="<?php echo htmlentities($post->post_title); ?>" />
-                                                <input type="hidden" name="linkurl<?php echo $intCounter; ?>" id="linkurl<?php echo $intCounter; ?>" value="<?php echo get_permalink($post->ID); ?>" />
-                                                <input type="hidden" name="description<?php echo $intCounter; ?>" id="description<?php echo $intCounter; ?>" value="<?php echo $description; ?>" />
-                                                <input type="hidden" name="icon<?php echo $intCounter; ?>" id="icon<?php echo $intCounter; ?>" value="0" />
-                                                <input type="hidden" name="position<?php echo $intCounter; ?>" id="position<?php echo $intCounter; ?>" value="<?php echo $intCounter; ?>" />
-                                                <input type="hidden" name="linktype<?php echo $intCounter; ?>" id="linktype<?php echo $intCounter; ?>" value="page" />
-                                                <input type="hidden" name="anchortitle<?php echo $intCounter; ?>" id="anchortitle<?php echo $intCounter; ?>" value="<?php echo htmlentities($post->post_title); ?>" />
-                                                <input type="hidden" name="newwindow<?php echo $intCounter; ?>" id="newwindow<?php echo $intCounter; ?>" value="0" />
</del><ins>+                                        </dt>
+                                        </dl>
+                                        <a class="hide" href="<?php echo get_permalink($post->ID); ?>"><span class="title"><?php echo $post->post_title; ?></span>
+                                        </a>
+                                        <input type="hidden" name="postmenu<?php echo $intCounter; ?>" id="postmenu<?php echo $intCounter; ?>" value="<?php echo $post->ID; ?>" />
+                                        <input type="hidden" name="parent<?php echo $intCounter; ?>" id="parent<?php echo $intCounter; ?>" value="0" />
+                                        <input type="hidden" name="title<?php echo $intCounter; ?>" id="title<?php echo $intCounter; ?>" value="<?php echo htmlentities($post->post_title); ?>" />
+                                        <input type="hidden" name="linkurl<?php echo $intCounter; ?>" id="linkurl<?php echo $intCounter; ?>" value="<?php echo get_permalink($post->ID); ?>" />
+                                        <input type="hidden" name="description<?php echo $intCounter; ?>" id="description<?php echo $intCounter; ?>" value="<?php echo $description; ?>" />
+                                        <input type="hidden" name="icon<?php echo $intCounter; ?>" id="icon<?php echo $intCounter; ?>" value="0" />
+                                        <input type="hidden" name="position<?php echo $intCounter; ?>" id="position<?php echo $intCounter; ?>" value="<?php echo $intCounter; ?>" />
+                                        <input type="hidden" name="linktype<?php echo $intCounter; ?>" id="linktype<?php echo $intCounter; ?>" value="page" />
+                                        <input type="hidden" name="anchortitle<?php echo $intCounter; ?>" id="anchortitle<?php echo $intCounter; ?>" value="<?php echo htmlentities($post->post_title); ?>" />
+                                        <input type="hidden" name="newwindow<?php echo $intCounter; ?>" id="newwindow<?php echo $intCounter; ?>" value="0" />
</ins><span class="cx">
</span><del>-                                                <?php $parentli = $post->ID; ?>
-                                                <?php $intCounter++; ?>
-                                                <?php
</del><ins>+                                        <?php $parentli = $post->ID; ?>
+                                        <?php $intCounter++; ?>
+                                        <?php
</ins><span class="cx">
</span><del>-                                                        //Recursive function
-                                                        $intCounter = wp_custom_navigation_default_sub_items($post->ID, $intCounter, $parentli, 'pages', 'menu');
</del><ins>+                                                //Recursive function
+                                                $intCounter = wp_custom_navigation_default_sub_items($post->ID, $intCounter, $parentli, 'pages', 'menu');
</ins><span class="cx">
</span><del>-                                                ?>
</del><ins>+                                        ?>
</ins><span class="cx">
</span><del>-                                        </li>
</del><ins>+                                </li>
</ins><span class="cx">
</span><del>-                                        <?php
</del><ins>+                                <?php
</ins><span class="cx">
</span><del>-                                }
-                                //Sidebar Menu
-                                elseif ($type == 'default')
-                                {
-                                        ?>
</del><ins>+                        } elseif ( $type == 'default' ) {
+                                // Sidebar Menu
+                                ?>
</ins><span class="cx">
</span><del>-                                         <li>
-                                 <dl>
-                                 <dt>
-                                 <?php
-                                         $post_text = htmlentities($post->post_title);
-                                         $post_url = get_permalink($post->ID);
-                                         $post_id = $post->ID;
-                                         $post_parent_id = $post->post_parent;
</del><ins>+                                 <li>
+                                        <dl>
+                                        <dt>
+                                        <?php
+                                                $post_text = htmlentities($post->post_title);
+                                                $post_url = get_permalink($post->ID);
+                                                $post_id = $post->ID;
+                                                $post_parent_id = $post->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>-                                 ?>
-                                 <?php $templatedir = get_bloginfo('url'); ?>
</del><ins>+                                        ?>
+                                        <?php $templatedir = get_bloginfo('url'); ?>
</ins><span class="cx">
</span><del>-                                 <span class="title"><?php echo $post->post_title; ?></span> <a onclick="appendToList('<?php echo $templatedir; ?>','Page','<?php echo $post_text; ?>','<?php echo $post_url; ?>','<?php echo $post_id; ?>','<?php echo $post_parent_id ?>','<?php echo $description; ?>')" name="<?php echo $post_text; ?>" value="<?php echo get_permalink($post->ID); ?>"><img alt="Add to Custom Menu" title="Add to Custom Menu" src="<?php echo get_bloginfo('url'); ?>/wp-admin/images/ico-add.png" /></a></dt>
-                                 </dl>
-                                 <?php $parentli = $post->ID; ?>
-                                                <?php $intCounter++; ?>
-                                 <?php
</del><ins>+                                        <span class="title"><?php echo $post->post_title; ?></span> <a onclick="appendToList('<?php echo $templatedir; ?>','Page','<?php echo $post_text; ?>','<?php echo $post_url; ?>','<?php echo $post_id; ?>','<?php echo $post_parent_id ?>','<?php echo $description; ?>')" name="<?php echo $post_text; ?>" value="<?php echo get_permalink($post->ID); ?>"><img alt="Add to Custom Menu" title="Add to Custom Menu" src="<?php echo get_bloginfo('url'); ?>/wp-admin/images/ico-add.png" /></a></dt>
+                                        </dl>
+                                        <?php $parentli = $post->ID; ?>
+                                        <?php $intCounter++; ?>
+                                        <?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>-                                                 ?>
</del><ins>+                                         ?>
</ins><span class="cx">
</span><del>-                                        </li>
</del><ins>+                                </li>
</ins><span class="cx">
</span><del>-                                        <?php
</del><ins>+                                <?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' => '',
</span><span class="cx">                         'pad_counts' => 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->parent == 0)
-                        {
-                                //Custom Menu
-                                if ($type == 'menu')
-                                {
-                                        ?>
</del><ins>+        // Display Loop
+        foreach ( $categories_array as $cat_item ) {
</ins><span class="cx">
</span><del>-                                 <li id="menu-<?php echo $intCounter; ?>" value="<?php echo $intCounter; ?>">
-                                         <dl>
-                         <dt>
-                                 <span class="title"><?php echo $cat_item->cat_name; ?></span>
-                                                        <span class="controls">
-                                                        <span class="type">category</span>
-                                                        <a id="edit<?php echo $intCounter; ?>" onclick="edititem(<?php echo $intCounter; ?>)" value="<?php echo $intCounter; ?>"><img class="edit" alt="Edit Menu Item" title="Edit Menu Item" src="<?php echo get_bloginfo('url'); ?>/wp-admin/images/ico-edit.png" /></a>
-                                                        <a id="remove<?php echo $intCounter; ?>" onclick="removeitem(<?php echo $intCounter; ?>)" value="<?php echo $intCounter; ?>">
-                                                                <img class="remove" alt="Remove from Custom Menu" title="Remove from Custom Menu" src="<?php echo get_bloginfo('url'); ?>/wp-admin/images/ico-close.png" />
-                                                        </a>
-                                                        <a target="_blank" href="<?php echo get_category_link($cat_item->cat_ID); ?>">
-                                                                <img alt="View Page" title="View Page" src="<?php echo get_bloginfo('url'); ?>/wp-admin/images/ico-viewpage.png" />
-                                                        </a>
-                                                        </span>
</del><ins>+                if ( $cat_item->parent == 0 ) {
+                        // Custom Menu
+                        if ( $type == 'menu' ) {
+                                ?>
</ins><span class="cx">
</span><del>-                         </dt>
-                         </dl>
-                         <a class="hide" href="<?php echo get_category_link($cat_item->cat_ID); ?>"><span class="title"><?php echo $cat_item->cat_name; ?></span>
-                         <?php
-                         $use_cats_raw = get_option('wp_settings_custom_nav_descriptions');
-                                                 $use_cats = strtolower($use_cats_raw);
-                                                 if ($use_cats == 'yes') { ?>
-                         <br/> <span><?php echo $cat_item->category_description; ?></span>
-                         <?php } ?>
-                                 </a>
-                         <input type="hidden" name="postmenu<?php echo $intCounter; ?>" id="postmenu<?php echo $intCounter; ?>" value="<?php echo $cat_item->cat_ID; ?>" />
-                         <input type="hidden" name="parent<?php echo $intCounter; ?>" id="parent<?php echo $intCounter; ?>" value="0" />
-                         <input type="hidden" name="title<?php echo $intCounter; ?>" id="title<?php echo $intCounter; ?>" value="<?php echo htmlentities($cat_item->cat_name); ?>" />
-                                                <input type="hidden" name="linkurl<?php echo $intCounter; ?>" id="linkurl<?php echo $intCounter; ?>" value="<?php echo get_category_link($cat_item->cat_ID); ?>" />
-                                                <input type="hidden" name="description<?php echo $intCounter; ?>" id="description<?php echo $intCounter; ?>" value="<?php echo htmlentities($cat_item->category_description); ?>" />
-                                                <input type="hidden" name="icon<?php echo $intCounter; ?>" id="icon<?php echo $intCounter; ?>" value="0" />
-                                                <input type="hidden" name="position<?php echo $intCounter; ?>" id="position<?php echo $intCounter; ?>" value="<?php echo $intCounter; ?>" />
-                                                <input type="hidden" name="linktype<?php echo $intCounter; ?>" id="linktype<?php echo $intCounter; ?>" value="category" />
-                                                <input type="hidden" name="anchortitle<?php echo $intCounter; ?>" id="anchortitle<?php echo $intCounter; ?>" value="<?php echo htmlentities($cat_item->cat_name); ?>" />
-                                                <input type="hidden" name="newwindow<?php echo $intCounter; ?>" id="newwindow<?php echo $intCounter; ?>" value="0" />
</del><ins>+                                <li id="menu-<?php echo $intCounter; ?>" value="<?php echo $intCounter; ?>">
+                                        <dl>
+                                        <dt>
+                                                <span class="title"><?php echo $cat_item->cat_name; ?></span>
+                                                <span class="controls">
+                                                <span class="type">category</span>
+                                                <a id="edit<?php echo $intCounter; ?>" onclick="edititem(<?php echo $intCounter; ?>)" value="<?php echo $intCounter; ?>"><img class="edit" alt="Edit Menu Item" title="Edit Menu Item" src="<?php echo get_bloginfo('url'); ?>/wp-admin/images/ico-edit.png" /></a>
+                                                <a id="remove<?php echo $intCounter; ?>" onclick="removeitem(<?php echo $intCounter; ?>)" value="<?php echo $intCounter; ?>">
+                                                        <img class="remove" alt="Remove from Custom Menu" title="Remove from Custom Menu" src="<?php echo get_bloginfo('url'); ?>/wp-admin/images/ico-close.png" />
+                                                </a>
+                                                <a target="_blank" href="<?php echo get_category_link($cat_item->cat_ID); ?>">
+                                                        <img alt="View Page" title="View Page" src="<?php echo get_bloginfo('url'); ?>/wp-admin/images/ico-viewpage.png" />
+                                                </a>
+                                                </span>
</ins><span class="cx">
</span><del>-                         <?php $parentli = $cat_item->cat_ID; ?>
-                         <?php $intCounter++; ?>
-                                 <?php
</del><ins>+                                        </dt>
+                                        </dl>
+                                        <a class="hide" href="<?php echo get_category_link($cat_item->cat_ID); ?>"><span class="title"><?php echo $cat_item->cat_name; ?></span>
+                                        <?php
+                                        $use_cats_raw = get_option('wp_settings_custom_nav_descriptions');
+                                        $use_cats = strtolower($use_cats_raw);
+                                        if ( $use_cats == 'yes' ) { ?>
+                                        <br/> <span><?php echo $cat_item->category_description; ?></span>
+                                        <?php } ?>
+                                                                </a>
+                                        <input type="hidden" name="postmenu<?php echo $intCounter; ?>" id="postmenu<?php echo $intCounter; ?>" value="<?php echo $cat_item->cat_ID; ?>" />
+                                        <input type="hidden" name="parent<?php echo $intCounter; ?>" id="parent<?php echo $intCounter; ?>" value="0" />
+                                        <input type="hidden" name="title<?php echo $intCounter; ?>" id="title<?php echo $intCounter; ?>" value="<?php echo htmlentities($cat_item->cat_name); ?>" />
+                                        <input type="hidden" name="linkurl<?php echo $intCounter; ?>" id="linkurl<?php echo $intCounter; ?>" value="<?php echo get_category_link($cat_item->cat_ID); ?>" />
+                                        <input type="hidden" name="description<?php echo $intCounter; ?>" id="description<?php echo $intCounter; ?>" value="<?php echo htmlentities($cat_item->category_description); ?>" />
+                                        <input type="hidden" name="icon<?php echo $intCounter; ?>" id="icon<?php echo $intCounter; ?>" value="0" />
+                                        <input type="hidden" name="position<?php echo $intCounter; ?>" id="position<?php echo $intCounter; ?>" value="<?php echo $intCounter; ?>" />
+                                        <input type="hidden" name="linktype<?php echo $intCounter; ?>" id="linktype<?php echo $intCounter; ?>" value="category" />
+                                        <input type="hidden" name="anchortitle<?php echo $intCounter; ?>" id="anchortitle<?php echo $intCounter; ?>" value="<?php echo htmlentities($cat_item->cat_name); ?>" />
+                                        <input type="hidden" name="newwindow<?php echo $intCounter; ?>" id="newwindow<?php echo $intCounter; ?>" value="0" />
</ins><span class="cx">
</span><del>-                                                        //Recursive function
-                                                        $intCounter = wp_custom_navigation_default_sub_items($cat_item->cat_ID, $intCounter, $parentli, 'categories','menu');
</del><ins>+                                        <?php $parentli = $cat_item->cat_ID; ?>
+                                        <?php $intCounter++; ?>
+                                        <?php
</ins><span class="cx">
</span><del>-                                                ?>
</del><ins>+                                                //Recursive function
+                                                $intCounter = wp_custom_navigation_default_sub_items($cat_item->cat_ID, $intCounter, $parentli, 'categories','menu');
</ins><span class="cx">
</span><del>-                                 </li>
</del><ins>+                                        ?>
</ins><span class="cx">
</span><del>-                                 <?php
-                         }
-                         //Sidebar Menu
-                         elseif ($type == 'default')
-                         {
-                                 ?>
-                                 <li>
-                                                <dl>
-                                                <dt>
-                                                <?php
-                                 $post_text = htmlentities($cat_item->cat_name);
-                                 $post_url = get_category_link($cat_item->cat_ID);
-                                 $post_id = $cat_item->cat_ID;
-                                 $post_parent_id = $cat_item->parent;
-                                 $description = htmlentities(strip_tags($cat_item->description));
-                                 ?>
-                                 <?php $templatedir = get_bloginfo('url'); ?>
-                                                <span class="title"><?php echo $cat_item->cat_name; ?></span> <a onclick="appendToList('<?php echo $templatedir; ?>','Category','<?php echo $post_text; ?>','<?php echo $post_url; ?>','<?php echo $post_id; ?>','<?php echo $post_parent_id ?>','<?php echo $description; ?>')" name="<?php echo $post_text; ?>" value="<?php echo $post_url; ?>"><img alt="Add to Custom Menu" title="Add to Custom Menu" src="<?php echo get_bloginfo('url'); ?>/wp-admin/images/ico-add.png" /></a> </dt>
-                                                </dl>
-                                                <?php $parentli = $cat_item->cat_ID; ?>
-                         <?php $intCounter++; ?>
-                                                <?php
-                                                        //Recursive function
-                                                        $intCounter = wp_custom_navigation_default_sub_items($cat_item->cat_ID, $intCounter, $parentli, 'categories','default');
-                                                ?>
</del><ins>+                                </li>
</ins><span class="cx">
</span><del>-                                        </li>
-
</del><ins>+                                <?php
+                        } elseif ($type == 'default') {
+                                // Sidebar Menu
+                                ?>
+                                <li>
+                                        <dl>
+                                        <dt>
</ins><span class="cx">                                         <?php
</span><del>-                         }
</del><ins>+                                        $post_text = htmlentities($cat_item->cat_name);
+                                        $post_url = get_category_link($cat_item->cat_ID);
+                                        $post_id = $cat_item->cat_ID;
+                                        $post_parent_id = $cat_item->parent;
+                                        $description = htmlentities(strip_tags($cat_item->description));
+                                        ?>
+                                        <?php $templatedir = get_bloginfo('url'); ?>
+                                        <span class="title"><?php echo $cat_item->cat_name; ?></span> <a onclick="appendToList('<?php echo $templatedir; ?>','Category','<?php echo $post_text; ?>','<?php echo $post_url; ?>','<?php echo $post_id; ?>','<?php echo $post_parent_id ?>','<?php echo $description; ?>')" name="<?php echo $post_text; ?>" value="<?php echo $post_url; ?>"><img alt="Add to Custom Menu" title="Add to Custom Menu" src="<?php echo get_bloginfo('url'); ?>/wp-admin/images/ico-add.png" /></a> </dt>
+                                        </dl>
+                                        <?php $parentli = $cat_item->cat_ID; ?>
+                                        <?php $intCounter++; ?>
+                                        <?php
+                                                //Recursive function
+                                                $intCounter = wp_custom_navigation_default_sub_items($cat_item->cat_ID, $intCounter, $parentli, 'categories','default');
+                                        ?>
+
+                                </li>
+
+                                <?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' => $childof,
</span><span class="cx">                 'hide_empty' => false,
</span><span class="cx">                 'parent' => $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' => $childof,
</span><span class="cx">                 'hide_empty' => false,
</span><span class="cx">                 'parent' => $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">                 ?>
</span><span class="cx">
</span><span class="cx">                 <ul id="sub-custom-nav-<?php echo $type ?>">
</span><span class="cx">
</span><span class="cx">                 <?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->cat_ID);
</span><span class="cx">                                 $title = htmlentities($sub_item->cat_name);
</span><span class="cx">                                 $parent_id = $sub_item->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->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->ID);
</span><span class="cx">                                 $title = htmlentities($sub_item->post_title);
</span><span class="cx">                                 $parent_id = $sub_item->ID;
</span><span class="lines">@@ -793,18 +728,15 @@
</span><span class="cx">                                 $itemid = $sub_item->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">                                 ?>
</span><span class="cx">                                 <li id="menu-<?php echo $counter; ?>" value="<?php echo $counter; ?>">
</span><span class="cx">                                         <dl>
</span><span class="lines">@@ -846,11 +778,8 @@
</span><span class="cx">
</span><span class="cx">                                 </li>
</span><span class="cx">                                 <?php
</span><del>-                        }
-                        //Sidebar Menu
-                        elseif ($output_type == 'default')
-                        {
-
</del><ins>+                        } elseif ($output_type == 'default') {
+                                // Sidebar Menu
</ins><span class="cx">                                 ?>
</span><span class="cx">                                 <li>
</span><span class="cx">                                         <dl>
</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' => $childof,
</span><span class="cx">                         'hide_empty' => 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->parent)) {
</del><ins>+                foreach ( $sub_array as $sub_item ) {
+                        if ( isset($sub_item->parent) ) {
</ins><span class="cx">                                 $sub_item_parent = $sub_item->parent;
</span><del>-                        }
-                        elseif (isset($sub_item->post_parent)) {
</del><ins>+                        } elseif (isset($sub_item->post_parent)) {
</ins><span class="cx">                                 $sub_item_parent = $sub_item->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->cat_ID);
</span><span class="cx">                                         $title = htmlentities($sub_item->cat_name);
</span><span class="cx">                                         $parent_id = $sub_item->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->ID);
</span><span class="cx">                                         $title = htmlentities($sub_item->post_title);
</span><span class="cx">                                         $parent_id = $sub_item->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->get_results("SELECT id FROM ".$table_name." WHERE post_id='".$parent_id."' AND link_type='".$linktype."' AND menu_id='".$menu_id."'");
</span><span class="cx">                                 if ($wp_result > 0 && isset($wp_result[0]->id)) {
</span><span class="cx">                                         $parent_id = $wp_result[0]->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"> ?>
</span></span></pre>
</div>
</div>
</body>
</html>