<!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>[13331] trunk: Nav cleanup.</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/13331">13331</a></dd>
<dt>Author</dt> <dd>ryan</dd>
<dt>Date</dt> <dd>2010-02-23 17:13:24 +0000 (Tue, 23 Feb 2010)</dd>
</dl>
<h3>Log Message</h3>
<pre>Nav cleanup. see <a href="http://trac.wordpress.org/ticket/11817">#11817</a></pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadmincustomnavigationphp">trunk/wp-admin/custom-navigation.php</a></li>
<li><a href="#trunkwpincludescustomnavigationphp">trunk/wp-includes/custom-navigation.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadmincustomnavigationphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/custom-navigation.php (13330 => 13331)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/custom-navigation.php        2010-02-23 11:14:35 UTC (rev 13330)
+++ trunk/wp-admin/custom-navigation.php        2010-02-23 17:13:24 UTC (rev 13331)
</span><span class="lines">@@ -176,23 +176,20 @@
</span><span class="cx">                 $messagesdiv = '<div id="message" class="updated fade below-h2"><p>' . __('The menu has been updated.') . '</p></div>';
</span><span class="cx">         }
</span><span class="cx">
</span><del>-                 //DISPLAY Custom Navigation
</del><ins>+                 // DISPLAY Custom Navigation
</ins><span class="cx">                 ?>
</span><span class="cx">                 <div id="pages-left">
</span><span class="cx">                         <div class="inside">
</span><span class="cx">                         <h2 class="maintitle"><?php esc_html_e('Custom Navigation') ?></h2>
</span><span class="cx">                         <?php
</span><span class="cx">
</span><del>-                                //CHECK if custom menu has been enabled
</del><ins>+                                // CHECK if custom menu has been enabled
</ins><span class="cx">                                 $enabled_menu = get_option('wp_custom_nav_menu');
</span><span class="cx">                          $checked = strtolower($enabled_menu);
</span><span class="cx">
</span><del>-                                if ($checked == 'true') {
-                                } else {
</del><ins>+                                if ( $checked != 'true' )
</ins><span class="cx">                                         echo '<div id="message-enabled" class="error fade below-h2"><p><strong>' . __('The Custom Menu has not been Enabled yet. Please enable it in order to use it -------->') . '</strong></p></div>';
</span><del>-                                }
</del><span class="cx">
</span><del>-
</del><span class="cx">                         ?>
</span><span class="cx">                         <?php echo $messagesdiv; ?>
</span><span class="cx">                         <form onsubmit="updatepostdata()" action="custom-navigation.php" method="post" enctype="multipart/form-data">
</span><span class="lines">@@ -215,9 +212,9 @@
</span><span class="cx">                         <?php
</span><span class="cx">                         //DISPLAY existing menu
</span><span class="cx">                         if ( $menu_selected_id > 0 ) {
</span><del>-                                //SET output type
</del><ins>+                                // SET output type
</ins><span class="cx">                                 $output_type = "backend";
</span><del>-                                //MAIN OUTPUT FUNCTION
</del><ins>+                                // MAIN OUTPUT FUNCTION
</ins><span class="cx">                                 wp_custom_navigation_output( 'type='.$output_type.'&name='.$menu_title.'&id='.$menu_selected_id );
</span><span class="cx">                         }
</span><span class="cx">                         ?>
</span><span class="lines">@@ -248,7 +245,7 @@
</span><span class="cx">
</span><span class="cx">                                         <?php
</span><span class="cx">
</span><del>-                                 //SETUP Custom Menu
</del><ins>+                                 // Setup custom menu
</ins><span class="cx">
</span><span class="cx">                                         $enabled_menu = get_option('wp_custom_nav_menu');
</span><span class="cx">
</span><span class="lines">@@ -281,7 +278,7 @@
</span><span class="cx">                                         <select id="menu_select" name="menu_select">
</span><span class="cx">                                                 <?php
</span><span class="cx">
</span><del>-                                                //DISPLAY SELECT OPTIONS
</del><ins>+                                                // Display select options
</ins><span class="cx">                                                 foreach ( $custom_menus as $menu ) {
</span><span class="cx">                                                         $menu_term = get_term( $menu, 'nav_menu' );
</span><span class="cx">                                                         if ( ( $menu_id_in_edit == $menu->term_id ) || ( $menu_selected_id == $menu->term_id ) )
</span><span class="lines">@@ -314,16 +311,12 @@
</span><span class="cx">
</span><span class="cx">                                         <?php
</span><span class="cx">
</span><del>-                                 //UPDATE and DISPLAY Menu Description Option
</del><ins>+                                 // UPDATE and DISPLAY Menu Description Option
</ins><span class="cx">                                  if ( isset($_POST['menu-descriptions']) ) {
</span><del>-
-                                                if ( isset($_POST['switch_menu']) ) {
-
-                                                } else {
</del><ins>+                                                if ( !isset($_POST['switch_menu']) ) {
</ins><span class="cx">                                                         $menu_options_to_edit = $_POST['menu_id_in_edit'];
</span><span class="cx">                                                  update_option('wp_settings_custom_nav_'.$menu_options_to_edit.'_descriptions',$_POST['menu-descriptions']);
</span><span class="cx">                                                 }
</span><del>-
</del><span class="cx">                                  }
</span><span class="cx">
</span><span class="cx">                                  if ( $menu_id_in_edit > 0 )
</span><span class="lines">@@ -381,7 +374,7 @@
</span><span class="cx">                                                         $page_name .= htmlentities($post->post_title).'|';
</span><span class="cx">                                                 }
</span><span class="cx">                                         } else {
</span><del>-                                                $page_name = "No pages available";
</del><ins>+                                                $page_name = __('No pages available');
</ins><span class="cx">                                         }
</span><span class="cx">
</span><span class="cx">                                         ?>
</span><span class="lines">@@ -448,7 +441,7 @@
</span><span class="cx">                                         $cat_name = '';
</span><span class="cx">                                         //CHECK for results
</span><span class="cx">                                         if ( $categories ) {
</span><del>-                                                foreach( $categories as $category ) {
</del><ins>+                                                foreach ( $categories as $category ) {
</ins><span class="cx">                                                         $cat_id = $category->term_id;
</span><span class="cx">
</span><span class="cx">                                                         $cat_args = array(
</span><span class="lines">@@ -507,8 +500,8 @@
</span><span class="cx">
</span><span class="cx">                                         <ul id="existing-categories" class="list">
</span><span class="cx">                         <?php
</span><del>-                                                         //Get default Categories
-                                 $intCounter = wp_custom_nav_get_categories($intCounter,'default');
</del><ins>+                                                         // Get default Categories
+                                 $intCounter = wp_custom_nav_get_categories($intCounter, 'default');
</ins><span class="cx">                                                 ?>
</span><span class="cx">                                 </ul>
</span><span class="cx">
</span><span class="lines">@@ -557,7 +550,6 @@
</span><span class="cx">         </div>
</span><span class="cx">
</span><span class="cx"> <?php
</span><del>-
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> include("admin-footer.php");
</span></span></pre></div>
<a id="trunkwpincludescustomnavigationphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/custom-navigation.php (13330 => 13331)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/custom-navigation.php        2010-02-23 11:14:35 UTC (rev 13330)
+++ trunk/wp-includes/custom-navigation.php        2010-02-23 17:13:24 UTC (rev 13331)
</span><span class="lines">@@ -31,7 +31,6 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> function wp_custom_navigation_setup($override = false) {
</span><del>-
</del><span class="cx">         // Custom Navigation Menu Setup
</span><span class="cx">
</span><span class="cx">         // Override for menu descriptions
</span><span class="lines">@@ -44,6 +43,7 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx"> }
</span><ins>+
</ins><span class="cx"> function wp_custom_navigation_delete_menu( $menu_term_id ) {
</span><span class="cx">         $term_id = (int) $menu_term_id;
</span><span class="cx">         if ( $term_id > 0 ) {
</span><span class="lines">@@ -57,10 +57,100 @@
</span><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+function setup_menu_item($menu_item) {
+        global $parent_menu_order;
+
+        $menu_item->type = get_post_meta($menu_item->ID, 'menu_type', true);
+        $menu_item->object_id = get_post_meta($menu_item->ID, 'object_id', true);
+        //$parent_menu_order[ $menu_item->ID ] = $menu_item->menu_order;
+        if ( isset( $parent_menu_order[ $menu_item->post_parent ] ) )
+                $menu_item->parent_item = $parent_menu_order[ $menu_item->post_parent ];
+        else
+                $menu_item->parent_item = 0;
+
+        switch ( $menu_item->type ) {
+                // Page Menu Item
+                case 'page':
+                        if ( $menu_item->guid == '' )
+                                $menu_item->link = get_permalink( $menu_item->object_id );
+                        else
+                                $menu_item->link = $menu_item->guid;
+
+                        if ( $menu_item->post_title == '' )
+                                $menu_item->title = htmlentities( get_the_title( $menu_item->object_id ) );
+                        else
+                                $menu_item->title = htmlentities( $menu_item->post_title );
+
+                        if ( $menu_item->post_content == '' )
+                                $menu_item->description = htmlentities( get_post_meta( $menu_item->ID, 'page-description', true ) );
+                        else
+                                $menu_item->description = htmlentities( $menu_item->post_content );
+                        $menu_item->target = '';
+                break;
+                // Category Menu Item
+                case 'category':
+                        if ( $menu_item->guid == '' )
+                                $menu_item->link = get_category_link( $menu_item->object_id );
+                        else
+                                $menu_item->link = $menu_item->guid;
+
+                        if ( $menu_item->post_title == '' ) {
+                                $title_raw = get_categories( array('include' => $menu_item->object_id) );
+                                $menu_item->title = htmlentities($title_raw[0]->cat_name);
+                        } else {
+                                $menu_item->title = htmlentities( $menu_item->post_title );
+                        }
+
+                        if ( $menu_item->post_content == '' )
+                                $menu_item->description = htmlentities( strip_tags( category_description( $menu_item->object_id ) ) );
+                        else
+                                $menu_item->description = htmlentities( $menu_item->post_content );
+                        $menu_item->target = '';
+                break;
+                default:
+                        // Custom Menu Item
+                        $menu_item->link = $menu_item->guid;
+                        $menu_item->title = htmlentities( $menu_item->post_title );
+                        $menu_item->description = htmlentities( $menu_item->post_content );
+                        $menu_item->target = 'target="_blank"';
+                break;
+        }
+
+        $menu_item->li_class = '';
+        global $wp_query;
+        if ( $menu_item->ID == $wp_query->get_queried_object_id() )
+                $menu_item->li_class = 'class="current_page_item"';
+
+/* @todo: update to use tax/post data
+
+                        //SET anchor title
+                        if (isset($wp_custom_nav_menu_items->custom_anchor_title)) {
+                                $anchor_title = htmlentities($wp_custom_nav_menu_items->custom_anchor_title);
+                        }
+                        else {
+                                $anchor_title = $title;
+                        }
+
+                        if ($queried_id == $wp_custom_nav_menu_items->post_id) {
+                                $li_class = 'class="current_page_item"';
+                        }
+
+                        if (isset($wp_custom_nav_menu_items->new_window)) {
+                                if ($wp_custom_nav_menu_items->new_window > 0) {
+                                        $target = 'target="_blank"';
+                                }
+                                else {
+                                        $target = '';
+                                }
+                        }
+*/
+
+        return $menu_item;
+}
+
</ins><span class="cx"> /*-----------------------------------------------------------------------------------*/
</span><span class="cx"> /* Custom Navigation Functions */
</span><span class="cx"> /* wp_custom_navigation_output() displays the menu in the back/frontend
</span><del>-/* wp_custom_navigation_sub_items() is a recursive sub menu item function
</del><span class="cx"> /* wp_custom_nav_get_pages()
</span><span class="cx"> /* wp_custom_nav_get_categories()
</span><span class="cx"> /* wp_custom_navigation_default_sub_items() is a recursive sub menu item function
</span><span class="lines">@@ -76,9 +166,7 @@
</span><span class="cx"> /* before_title - html before title is outputted in <a> tag
</span><span class="cx"> /* after_title - html after title is outputted in <a> tag
</span><span class="cx"> /*-----------------------------------------------------------------------------------*/
</span><del>-
</del><span class="cx"> function wp_custom_navigation_output( $args = array() ) {
</span><del>-
</del><span class="cx">                 // Defaults
</span><span class="cx">                 $defaults = array( 'type' => 'frontend', 'name' => 'Menu 1', 'id' => 0, 'desc' => 2, 'before_title' => '', 'after_title' => '');
</span><span class="cx">
</span><span class="lines">@@ -87,139 +175,57 @@
</span><span class="cx">
</span><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>-                //O verride for menu descriptions
</del><ins>+                // Override 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="cx">
</span><del>-                $queried_id = 0;
-                global $wp_query;
-                if ( is_page() )
-                        $queried_id = $wp_query->get_queried_object_id();
-                elseif ( is_category() )
-                        $queried_id = $wp_query->get_queried_object_id();
-
</del><span class="cx">                 $parent_stack = array();
</span><span class="cx">                 $current_parent = 0;
</span><span class="cx">                 $parent_menu_order = array();
</span><del>-         // Display Loop
</del><ins>+                // Setup parentage
</ins><span class="cx">                 foreach ( $menu_items as $key => $menu_item ) {
</span><del>-                        $menu_type = get_post_meta($menu_item->ID, 'menu_type', true);
-                        $object_id = get_post_meta($menu_item->ID, 'object_id', true);
</del><span class="cx">                         $parent_menu_order[ $menu_item->ID ] = $menu_item->menu_order;
</span><del>-                        if ( isset( $parent_menu_order[ $menu_item->post_parent ] ) )
-                                $parent_item = $parent_menu_order[ $menu_item->post_parent ];
-                        else
-                                $parent_item = 0;
</del><ins>+                }
</ins><span class="cx">
</span><del>-                        switch ( $menu_type ) {
-                                // Page Menu Item
-                                case 'page':
-                                        if ( $menu_item->guid == '' )
-                                                $link = get_permalink( $object_id );
-                                        else
-                                                $link = $menu_item->guid;
-
-                                        if ( $menu_item->post_title == '' )
-                                                $title = htmlentities( get_the_title( $object_id ) );
-                                        else
-                                                $title = htmlentities( $menu_item->post_title );
-
-                                        if ( $menu_item->post_content == '' )
-                                                $description = htmlentities( get_post_meta( $menu_item->ID, 'page-description', true ) );
-                                        else
-                                                $description = htmlentities( $menu_item->post_content );
-                                        $target = '';
-                                break;
-                                // Category Menu Item
-                                case 'category':
-                                        if ( $menu_item->guid == '' )
-                                                $link = get_category_link( $object_id );
-                                        else
-                                                $link = $menu_item->guid;
-
-                                        if ( $menu_item->post_title == '' ) {
-                                                $title_raw = get_categories( array('include' => $object_id) );
-                                                $title = htmlentities($title_raw[0]->cat_name);
-                                        } else {
-                                                $title = htmlentities( $menu_item->post_title );
-                                        }
-
-                                        if ( $menu_item->post_content == '' )
-                                                $description = htmlentities( strip_tags( category_description( $object_id ) ) );
-                                        else
-                                                $description = htmlentities( $menu_item->post_content );
-                                        $target = '';
-                                break;
-                                default:
-                                        // Custom Menu Item
-                                        $link = $menu_item->guid;
-                                        $title = htmlentities( $menu_item->post_title );
-                                        $description = htmlentities( $menu_item->post_content );
-                                        $target = 'target="_blank"';
-                                break;
-                        }
-
-                        $li_class = '';
-/* @todo: update to use tax/post data
-
-                        //SET anchor title
-                        if (isset($wp_custom_nav_menu_items->custom_anchor_title)) {
-                                $anchor_title = htmlentities($wp_custom_nav_menu_items->custom_anchor_title);
-                        }
-                        else {
-                                $anchor_title = $title;
-                        }
-
-                        if ($queried_id == $wp_custom_nav_menu_items->post_id) {
-                                $li_class = 'class="current_page_item"';
-                        }
-
-                        if (isset($wp_custom_nav_menu_items->new_window)) {
-                                if ($wp_custom_nav_menu_items->new_window > 0) {
-                                        $target = 'target="_blank"';
-                                }
-                                else {
-                                        $target = '';
-                                }
-                        }
-*/
</del><ins>+         // Display Loop
+                foreach ( $menu_items as $key => $menu_item ) {
+                        $menu_item = setup_menu_item($menu_item);
</ins><span class="cx">                         // List Items
</span><del>-                        ?><li id="menu-<?php echo $menu_item->ID; ?>" value="<?php echo $menu_item->ID; ?>" <?php echo $li_class; ?>><?php
</del><ins>+                        ?><li id="menu-<?php echo $menu_item->ID; ?>" value="<?php echo $menu_item->ID; ?>" <?php echo $menu_item->li_class; ?>><?php
</ins><span class="cx">                                         //@todo: update front end to use post data
</span><span class="cx">                                         //FRONTEND Link
</span><span class="cx">                                         if ( $type == 'frontend' ) {
</span><del>-                                                ?><a title="<?php echo $anchor_title; ?>" href="<?php echo $link; ?>" <?php echo $target; ?>><?php echo $before_title.$title.$after_title; ?><?php
</del><ins>+                                                ?><a title="<?php echo $menu_item->anchor_title; ?>" href="<?php echo $menu_item->link; ?>" <?php echo $menu_item->target; ?>><?php echo $before_title.$menu_item->title.$after_title; ?><?php
</ins><span class="cx">
</span><span class="cx">                                                         if ( $advanced_option_descriptions == 'no' ) {
</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><span class="cx">                                                                 if ( ($desc == 1) || ($desc == 0) ) {
</span><del>-                                                                        ?><span class="nav-description"><?php echo $description; ?></span><?php
</del><ins>+                                                                        ?><span class="nav-description"><?php echo $menu_item->description; ?></span><?php
</ins><span class="cx">                                                                 }
</span><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="cx">                                                                 // 0 widget override not set
</span><span class="cx">                                                                 if ( $desc == 1 ) {
</span><del>-                                                                        ?><span class="nav-description"><?php echo $description; ?></span><?php
</del><ins>+                                                                        ?><span class="nav-description"><?php echo $menu_item->description; ?></span><?php
</ins><span class="cx">                                                                 }
</span><span class="cx">                                                         }
</span><span class="cx">
</span><span class="cx">                                                 ?></a><?php
</span><span class="cx">                                         } elseif ( $type == 'backend' ) {
</span><del>-                                                $link_type = $menu_type;
</del><span class="cx">                                                 ?>
</span><span class="cx">
</span><span class="cx">                                                 <dl>
</span><span class="cx">                                                         <dt>
</span><del>-                                                                <span class="title"><?php echo $title; ?></span>
</del><ins>+                                                                <span class="title"><?php echo $menu_item->title; ?></span>
</ins><span class="cx">                                                                 <span class="controls">
</span><del>-                                                                <span class="type"><?php echo $link_type; ?></span>
-                                                                <a id="edit<?php echo $menu_item->menu_order; ?>" onclick="edititem(<?php echo $menu_item->menu_order; ?>)" value="<?php echo $menu_item->menu_order; ?>"><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 $menu_item->menu_order; ?>" onclick="removeitem(<?php echo $menu_item->menu_order; ?>)" value="<?php echo $menu_item->menu_order; ?>"><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 id="view<?php echo $menu_item->menu_order; ?>" target="_blank" href="<?php echo $link; ?>"><img alt="View Page" title="View Page" src="<?php echo get_bloginfo('url'); ?>/wp-admin/images/ico-viewpage.png" /></a>
</del><ins>+                                                                <span class="type"><?php echo $menu_item->type; ?></span>
+                                                                <a id="edit<?php echo $menu_item->menu_order; ?>" onclick="edititem(<?php echo $menu_item->menu_order; ?>)" value="<?php echo $menu_item->menu_order; ?>"><img class="edit" alt="Edit Menu Item" title="Edit Menu Item" src="<?php echo admin_url('images/ico-edit.png'); ?>" /></a>
+                                                                <a id="remove<?php echo $menu_item->menu_order; ?>" onclick="removeitem(<?php echo $menu_item->menu_order; ?>)" value="<?php echo $menu_item->menu_order; ?>"><img class="remove" alt="Remove from Custom Menu" title="Remove from Custom Menu" src="<?php echo admin_url('images/ico-close.png'); ?>" /></a>
+                                                                <a id="view<?php echo $menu_item->menu_order; ?>" target="_blank" href="<?php echo $menu_item->link; ?>"><img alt="View Page" title="View Page" src="<?php echo admin_url('images/ico-viewpage.png'); ?>" /></a>
</ins><span class="cx">                                                                 </span>
</span><span class="cx">                                                         </dt>
</span><span class="cx">                                                 </dl>
</span><span class="lines">@@ -227,13 +233,13 @@
</span><span class="cx">                                                 <a><span class=""></span></a>
</span><span class="cx">                                                 <input type="hidden" name="dbid<?php echo $menu_item->menu_order; ?>" id="dbid<?php echo $menu_item->menu_order; ?>" value="<?php echo $menu_item->ID; ?>" />
</span><span class="cx">                                                 <input type="hidden" name="postmenu<?php echo $menu_item->menu_order; ?>" id="postmenu<?php echo $menu_item->menu_order; ?>" value="<?php echo $id; ?>" />
</span><del>-                                                <input type="hidden" name="parent<?php echo $menu_item->menu_order; ?>" id="parent<?php echo $menu_item->menu_order; ?>" value="<?php echo $parent_item; ?>" />
-                                                <input type="hidden" name="title<?php echo $menu_item->menu_order; ?>" id="title<?php echo $menu_item->menu_order; ?>" value="<?php echo $title; ?>" />
-                                                <input type="hidden" name="linkurl<?php echo $menu_item->menu_order; ?>" id="linkurl<?php echo $menu_item->menu_order; ?>" value="<?php echo $link; ?>" />
-                                                <input type="hidden" name="description<?php echo $menu_item->menu_order; ?>" id="description<?php echo $menu_item->menu_order; ?>" value="<?php echo $description; ?>" />
</del><ins>+                                                <input type="hidden" name="parent<?php echo $menu_item->menu_order; ?>" id="parent<?php echo $menu_item->menu_order; ?>" value="<?php echo $menu_item->parent_item; ?>" />
+                                                <input type="hidden" name="title<?php echo $menu_item->menu_order; ?>" id="title<?php echo $menu_item->menu_order; ?>" value="<?php echo $menu_item->title; ?>" />
+                                                <input type="hidden" name="linkurl<?php echo $menu_item->menu_order; ?>" id="linkurl<?php echo $menu_item->menu_order; ?>" value="<?php echo $menu_item->link; ?>" />
+                                                <input type="hidden" name="description<?php echo $menu_item->menu_order; ?>" id="description<?php echo $menu_item->menu_order; ?>" value="<?php echo $menu_item->description; ?>" />
</ins><span class="cx">                                                 <input type="hidden" name="icon<?php echo $menu_item->menu_order; ?>" id="icon<?php echo $menu_item->menu_order; ?>" value="0" />
</span><span class="cx">                                                 <input type="hidden" name="position<?php echo $menu_item->menu_order; ?>" id="position<?php echo $menu_item->menu_order; ?>" value="<?php echo $menu_item->menu_order; ?>" />
</span><del>-                                                <input type="hidden" name="linktype<?php echo $menu_item->menu_order; ?>" id="linktype<?php echo $menu_item->menu_order; ?>" value="<?php echo $link_type; ?>" />
</del><ins>+                                                <input type="hidden" name="linktype<?php echo $menu_item->menu_order; ?>" id="linktype<?php echo $menu_item->menu_order; ?>" value="<?php echo $menu_item->type; ?>" />
</ins><span class="cx">                                                 <input type="hidden" name="anchortitle<?php echo $menu_item->menu_order; ?>" id="anchortitle<?php echo $menu_item->menu_order; ?>" value="<?php echo esc_html( $menu_item->post_excerpt ); ?>" />
</span><span class="cx">                                                 <input type="hidden" name="newwindow<?php echo $menu_item->menu_order; ?>" id="newwindow<?php echo $menu_item->menu_order; ?>" value="<?php echo ( '' == $menu_item->post_content_filtered ? '0' : '1' ); ?>" />
</span><span class="cx">
</span><span class="lines">@@ -259,187 +265,7 @@
</span><span class="cx"> <?php                        }
</span><span class="cx">         }                
</span><span class="cx"> }
</span><del>-//@todo: implement menu heirarchy
-//RECURSIVE Sub Menu Items
-function wp_custom_navigation_sub_items($post_id, $type, $table_name, $output_type, $menu_id = 0) {
</del><span class="cx">
</span><del>-        $parent_id = 0;
-        global $wpdb;
-
-        //GET sub menu items
-        $wp_custom_nav_menu = $wpdb->get_results("SELECT id,post_id,parent_id,position,custom_title,custom_link,custom_description,menu_icon,link_type,custom_anchor_title,new_window FROM ".$table_name." WHERE parent_id = '".$post_id."' AND menu_id='".$menu_id."' ORDER BY position ASC");
-
-        if (empty($wp_custom_nav_menu))
-        {
-
-        }
-        else
-        {
-                ?><ul id="sub-custom-nav">
-                <?php
-         $queried_id = 0;
-                global $wp_query;
- if (is_page()) {
-                 $queried_id = $wp_query->post->ID;
-         }
-         elseif (is_category()) {
-                 $queried_id = $wp_query->query_vars['cat'];
-         }
-         else {
-
-         }
-         //DISPLAY Loop
-                foreach ($wp_custom_nav_menu as $sub_item)
-                {
-                        //Figure out where the menu item sits
-                        $counter=$sub_item->position;
-
-                        //Prepare Menu Data
-                        //Category Menu Item
-                        if ($sub_item->link_type == 'category')
-                        {
-
-                                $parent_id = $sub_item->parent_id;
-                                $post_id = $sub_item->post_id;
-
-                                if ($sub_item->custom_link == '') {
-                                        $link = get_category_link($sub_item->post_id);
-                                }
-                                else {
-                                        $link = $sub_item->custom_link;
-                                }
-
-                                if ($sub_item->custom_title == '') {
-                                        $title_raw = get_categories('include='.$sub_item->post_id);
-                                        $title = htmlentities($title_raw[0]->cat_name);
-                                }
-                                else {
-                                        $title = htmlentities($sub_item->custom_title);
-                                }
-
-                                if ($sub_item->custom_description == '') {
-                                        $description = strip_tags(category_description($sub_item->post_id));
-                                }
-                                else {
-                                        $description = $sub_item->custom_description;
-                                }
-                                $target = '';
-                        }
-                        //Page Menu Item
-                        elseif ($sub_item->link_type == 'page')
-                        {
-
-                                $parent_id = $sub_item->parent_id;
-                                $post_id = $sub_item->post_id;
-
-                                if ($sub_item->custom_link == '') {
-                                        $link = get_permalink($sub_item->post_id);
-                                }
-                                else {
-                                        $link = $sub_item->custom_link;
-                                }
-
-                                if ($sub_item->custom_title == '') {
-                                        $title = htmlentities(get_the_title($sub_item->post_id));
-                                }
-                                else {
-                                        $title = htmlentities($sub_item->custom_title);
-                                }
-
-                                if ($sub_item->custom_description == '') {
-                                        $description = get_post_meta($sub_item->post_id, 'page-description', true);
-                                }
-                                else {
-                                        $description = $sub_item->custom_description;
-                                }
-                                $target = '';
-
-                        }
-                        //Custom Menu Item
-                        else
-                        {
-                                $link = $sub_item->custom_link;
-                                $title = htmlentities($sub_item->custom_title);
-                                $parent_id = $sub_item->parent_id;
-                                $post_id = $sub_item->post_id;
-                                $description = $sub_item->custom_description;
-                                $target = 'target="_blank"';
-                        }
-                        if ($queried_id == $sub_item->post_id) {
-                                $li_class = 'class="current_page_item"';
-                        }
-                        else {
-                                $li_class = '';
-                        }
-
-                        //SET anchor title
-                        if (isset($sub_item->custom_anchor_title)) {
-                                $anchor_title = htmlentities($sub_item->custom_anchor_title);
-                        }
-                        else {
-                                $anchor_title = $title;
-                        }
-
-                        if (isset($sub_item->new_window)) {
-                                if ($sub_item->new_window > 0) {
-                                        $target = 'target="_blank"';
-                                }
-                        }
-
-                        //List Items
-                        ?><li id="menu-<?php echo $counter; ?>" value="<?php echo $counter; ?>" <?php echo $li_class; ?>><?php
-                                                //FRONTEND
-                                                if ($output_type == "frontend")
-                                                {
-                                                        ?><a title="<?php echo $anchor_title; ?>" href="<?php echo $link; ?>" <?php echo $target; ?>><?php echo $title; ?></a><?php
-                                                }
-                                                //BACKEND
-                                                elseif ($output_type == "backend")
-                                                {
-                                                        ?>
-                                                        <dl>
-                                                        <dt>
-                                                                <span class="title"><?php echo $title; ?></span>
-                                                                <span class="controls">
-                                                                <span class="type"><?php echo $sub_item->link_type; ?></span>
-                                                                <a id="edit<?php echo $counter; ?>" onclick="edititem(<?php echo $counter; ?>)" value="<?php echo $counter; ?>"><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 $counter; ?>" onclick="removeitem(<?php echo $counter; ?>)" value="<?php echo $counter; ?>"><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 id="view<?php echo $counter; ?>" target="_blank" href="<?php echo $link; ?>"><img alt="View Page" title="View Page" src="<?php echo get_bloginfo('url'); ?>/wp-admin/images/ico-viewpage.png" /></a>
-                                                                </span>
-                                                        </dt>
-                                                        </dl>
-                                                        <a class="hide" href="<?php echo $link; ?>"><?php echo $title; ?></a>
-                                                        <input type="hidden" name="dbid<?php echo $counter; ?>" id="dbid<?php echo $counter; ?>" value="<?php echo $sub_item->id; ?>" />
-                                                        <input type="hidden" name="postmenu<?php echo $counter; ?>" id="postmenu<?php echo $counter; ?>" value="<?php echo $post_id; ?>" />
-                                                        <input type="hidden" name="parent<?php echo $counter; ?>" id="parent<?php echo $counter; ?>" value="<?php echo $parent_id; ?>" />
-                                                        <input type="hidden" name="title<?php echo $counter; ?>" id="title<?php echo $counter; ?>" value="<?php echo $title; ?>" />
-                                                        <input type="hidden" name="linkurl<?php echo $counter; ?>" id="linkurl<?php echo $counter; ?>" value="<?php echo $link; ?>" />
-                                                        <input type="hidden" name="description<?php echo $counter; ?>" id="description<?php echo $counter; ?>" value="<?php echo $description; ?>" />
-                                                        <input type="hidden" name="icon<?php echo $counter; ?>" id="icon<?php echo $counter; ?>" value="0" />
-                                                        <input type="hidden" name="position<?php echo $counter; ?>" id="position<?php echo $counter; ?>" value="<?php echo $counter; ?>" />
-                                                        <input type="hidden" name="linktype<?php echo $counter; ?>" id="linktype<?php echo $counter; ?>" value="<?php echo $sub_item->link_type; ?>" />
-                                                        <input type="hidden" name="anchortitle<?php echo $counter; ?>" id="anchortitle<?php echo $counter; ?>" value="<?php echo $anchor_title; ?>" />
-                                                        <input type="hidden" name="newwindow<?php echo $counter; ?>" id="newwindow<?php echo $counter; ?>" value="<?php echo $sub_item->new_window; ?>" />
-                                                        <?php
-                                                }
-
-                                                //Do recursion
-                                                wp_custom_navigation_sub_items($sub_item->id,$sub_item->link_type,$table_name,$output_type,$menu_id);
-                        ?></li>
-                        <?php
-
-                }
-
-        ?></ul>
-        <?php
-
-        }
-
-        return $parent_id;
-
-}
-
-
</del><span class="cx"> // Outputs All Pages and Sub Items
</span><span class="cx"> function wp_custom_nav_get_pages($counter, $type) {
</span><span class="cx">
</span><span class="lines">@@ -561,7 +387,7 @@
</span><span class="cx">         return $intCounter;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-//Outputs All Categories and Sub Items
</del><ins>+// Outputs All Categories and Sub Items
</ins><span class="cx"> function wp_custom_nav_get_categories($counter, $type) {
</span><span class="cx">
</span><span class="cx">         $category_args = array(
</span><span class="lines">@@ -589,7 +415,6 @@
</span><span class="cx">
</span><span class="cx">         // Display Loop
</span><span class="cx">         foreach ( $categories_array as $cat_item ) {
</span><del>-
</del><span class="cx">                 if ( $cat_item->parent == 0 ) {
</span><span class="cx">                         // Custom Menu
</span><span class="cx">                         if ( $type == 'menu' ) {
</span><span class="lines">@@ -598,15 +423,15 @@
</span><span class="cx">                                 <li id="menu-<?php echo $intCounter; ?>" value="<?php echo $intCounter; ?>">
</span><span class="cx">                                         <dl>
</span><span class="cx">                                         <dt>
</span><del>-                                                <span class="title"><?php echo $cat_item->cat_name; ?></span>
</del><ins>+                                                <span class="title"><?php echo esc_html($cat_item->cat_name); ?></span>
</ins><span class="cx">                                                 <span class="controls">
</span><span class="cx">                                                 <span class="type">category</span>
</span><del>-                                                <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>
</del><ins>+                                                <a id="edit<?php echo $intCounter; ?>" onclick="edititem(<?php echo $intCounter; ?>)" value="<?php echo $intCounter; ?>"><img class="edit" alt="<?php esc_attr_e('Edit Menu Item'); ?>" title="="<?php esc_attr_e('Edit Menu Item'); ?>" src="<?php echo admin_url('images/ico-edit.png'); ?>" /></a>
</ins><span class="cx">                                                 <a id="remove<?php echo $intCounter; ?>" onclick="removeitem(<?php echo $intCounter; ?>)" value="<?php echo $intCounter; ?>">
</span><del>-                                                        <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" />
</del><ins>+                                                        <img class="remove" alt="="<?php esc_attr_e('Remove from Custom Menu'); ?>" title="="<?php esc_attr_e('Remove from Custom Menu'); ?>" src="<?php echo admin_url('images/ico-close.png'); ?>" />
</ins><span class="cx">                                                 </a>
</span><span class="cx">                                                 <a target="_blank" href="<?php echo get_category_link($cat_item->cat_ID); ?>">
</span><del>-                                                        <img alt="View Page" title="View Page" src="<?php echo get_bloginfo('url'); ?>/wp-admin/images/ico-viewpage.png" />
</del><ins>+                                                        <img alt="="<?php esc_attr_e('View Page'); ?>" title="="<?php esc_attr_e('View Page'); ?>" src="<?php echo admin_url('images/ico-viewpage.png'); ?>" />
</ins><span class="cx">                                                 </a>
</span><span class="cx">                                                 </span>
</span><span class="cx">
</span><span class="lines">@@ -622,20 +447,20 @@
</span><span class="cx">                                                                 </a>
</span><span class="cx">                                         <input type="hidden" name="postmenu<?php echo $intCounter; ?>" id="postmenu<?php echo $intCounter; ?>" value="<?php echo $cat_item->cat_ID; ?>" />
</span><span class="cx">                                         <input type="hidden" name="parent<?php echo $intCounter; ?>" id="parent<?php echo $intCounter; ?>" value="0" />
</span><del>-                                        <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); ?>" />
</del><ins>+                                        <input type="hidden" name="title<?php echo $intCounter; ?>" id="title<?php echo $intCounter; ?>" value="<?php echo esc_attr($cat_item->cat_name); ?>" />
+                                        <input type="hidden" name="linkurl<?php echo $intCounter; ?>" id="linkurl<?php echo $intCounter; ?>" value="<?php echo esc_attr(get_category_link($cat_item->cat_ID)); ?>" />
+                                        <input type="hidden" name="description<?php echo $intCounter; ?>" id="description<?php echo $intCounter; ?>" value="<?php echo esc_attr($cat_item->category_description); ?>" />
</ins><span class="cx">                                         <input type="hidden" name="icon<?php echo $intCounter; ?>" id="icon<?php echo $intCounter; ?>" value="0" />
</span><span class="cx">                                         <input type="hidden" name="position<?php echo $intCounter; ?>" id="position<?php echo $intCounter; ?>" value="<?php echo $intCounter; ?>" />
</span><span class="cx">                                         <input type="hidden" name="linktype<?php echo $intCounter; ?>" id="linktype<?php echo $intCounter; ?>" value="category" />
</span><del>-                                        <input type="hidden" name="anchortitle<?php echo $intCounter; ?>" id="anchortitle<?php echo $intCounter; ?>" value="<?php echo htmlentities($cat_item->cat_name); ?>" />
</del><ins>+                                        <input type="hidden" name="anchortitle<?php echo $intCounter; ?>" id="anchortitle<?php echo $intCounter; ?>" value="<?php echo esc_attr($cat_item->cat_name); ?>" />
</ins><span class="cx">                                         <input type="hidden" name="newwindow<?php echo $intCounter; ?>" id="newwindow<?php echo $intCounter; ?>" value="0" />
</span><span class="cx">
</span><span class="cx">                                         <?php $parentli = $cat_item->cat_ID; ?>
</span><span class="cx">                                         <?php $intCounter++; ?>
</span><span class="cx">                                         <?php
</span><span class="cx">
</span><del>-                                                //Recursive function
</del><ins>+                                                // Recursive function
</ins><span class="cx">                                                 $intCounter = wp_custom_navigation_default_sub_items($cat_item->cat_ID, $intCounter, $parentli, 'categories','menu');
</span><span class="cx">
</span><span class="cx">                                         ?>
</span><span class="lines">@@ -643,7 +468,7 @@
</span><span class="cx">                                 </li>
</span><span class="cx">
</span><span class="cx">                                 <?php
</span><del>-                        } elseif ($type == 'default') {
</del><ins>+                        } elseif ( $type == 'default' ) {
</ins><span class="cx">                                 // Sidebar Menu
</span><span class="cx">                                 ?>
</span><span class="cx">                                 <li>
</span><span class="lines">@@ -657,13 +482,13 @@
</span><span class="cx">                                         $description = htmlentities(strip_tags($cat_item->description));
</span><span class="cx">                                         ?>
</span><span class="cx">                                         <?php $templatedir = get_bloginfo('url'); ?>
</span><del>-                                        <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>
</del><ins>+                                        <span class="title"><?php echo esc_html($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="="<?php esc_attr_e('Add to Custom Menu'); ?>" title="="<?php esc_attr_e('Add to Custom Menu'); ?>" src="<?php echo admin_url('images/ico-add.png'); ?>" /></a> </dt>
</ins><span class="cx">                                         </dl>
</span><span class="cx">                                         <?php $parentli = $cat_item->cat_ID; ?>
</span><span class="cx">                                         <?php $intCounter++; ?>
</span><span class="cx">                                         <?php
</span><del>-                                                //Recursive function
-                                                $intCounter = wp_custom_navigation_default_sub_items($cat_item->cat_ID, $intCounter, $parentli, 'categories','default');
</del><ins>+                                                // Recursive function
+                                                $intCounter = wp_custom_navigation_default_sub_items($cat_item->cat_ID, $intCounter, $parentli, 'categories', 'default');
</ins><span class="cx">                                         ?>
</span><span class="cx">
</span><span class="cx">                                 </li>
</span><span class="lines">@@ -682,12 +507,12 @@
</span><span class="cx">         $counter = $intCounter;
</span><span class="cx">
</span><span class="cx">         // Custom Menu
</span><del>-        if ($output_type == 'menu') {
</del><ins>+        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>-        } elseif ($output_type == 'default') {
</del><ins>+        } elseif ( $output_type == 'default' ) {
</ins><span class="cx">                 // Sidebar Menu
</span><span class="cx">                 $sub_args = array(
</span><span class="cx">                 'child_of' => $childof,
</span><span class="lines">@@ -708,15 +533,14 @@
</span><span class="cx">
</span><span class="cx">         if ( $sub_array ) {
</span><span class="cx">                 ?>
</span><del>-
</del><span class="cx">                 <ul id="sub-custom-nav-<?php echo $type ?>">
</span><span class="cx">
</span><span class="cx">                 <?php
</span><span class="cx">                 // Display Loop
</span><span class="cx">                 foreach ( $sub_array as $sub_item ) {
</span><del>-                        //Prepare Menu Data
-                        //Category Menu Item
</del><ins>+                        // Prepare Menu Data
</ins><span class="cx">                         if ( $type == 'categories' ) {
</span><ins>+                                // Category Menu Item
</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">@@ -749,12 +573,12 @@
</span><span class="cx">                                                 <span class="title"><?php echo $title; ?></span>
</span><span class="cx">                                                         <span class="controls">
</span><span class="cx">                                                         <span class="type"><?php echo $linktype; ?></span>
</span><del>-                                                        <a id="edit<?php echo $counter; ?>" onclick="edititem(<?php echo $counter; ?>)" value="<?php echo $counter; ?>"><img class="edit" alt="Edit Menu Item" title="Edit Menu Item" src="<?php echo get_bloginfo('url'); ?>/wp-admin/images/ico-edit.png" /></a>
</del><ins>+                                                        <a id="edit<?php echo $counter; ?>" onclick="edititem(<?php echo $counter; ?>)" value="<?php echo $counter; ?>"><img class="edit" alt="<?php esc_attr_e('Edit Menu Item'); ?>" title="<?php esc_attr_e('Edit Menu Item'); ?>" src="<?php echo admin_url('images/ico-edit.png'); ?>" /></a>
</ins><span class="cx">                                                                 <a id="remove<?php echo $counter; ?>" onclick="removeitem(<?php echo $counter; ?>)" value="<?php echo $counter; ?>">
</span><del>-                                                                        <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" />
</del><ins>+                                                                        <img class="remove" alt="<?php esc_attr_e('Remove from Custom Menu'); ?>" title="<?php esc_attr_e('Remove from Custom Menu'); ?>" src="<?php echo admin_url('images/ico-close.png'); ?>" />
</ins><span class="cx">                                                                 </a>
</span><span class="cx">                                                                 <a target="_blank" href="<?php echo $link; ?>">
</span><del>-                                                                        <img alt="View Page" title="View Page" src="<?php echo get_bloginfo('url'); ?>/wp-admin/images/ico-viewpage.png" />
</del><ins>+                                                                        <img alt="<?php esc_attr_e('View Page'); ?>" title="<?php esc_attr_e('View Page'); ?>" src="<?php echo admin_url('images/ico-viewpage.png'); ?>" />
</ins><span class="cx">                                                                 </a>
</span><span class="cx">                                                 </span>
</span><span class="cx">
</span><span class="lines">@@ -776,7 +600,7 @@
</span><span class="cx">                                         <?php $counter++; ?>
</span><span class="cx">                                         <?php
</span><span class="cx">
</span><del>-                                                //Do recursion
</del><ins>+                                                // Do recursion
</ins><span class="cx">                                                 $counter = wp_custom_navigation_default_sub_items($parent_id, $counter, $parent_id, $type, 'menu');
</span><span class="cx">
</span><span class="cx">                                         ?>
</span><span class="lines">@@ -791,11 +615,11 @@
</span><span class="cx">                                         <dt>
</span><span class="cx">
</span><span class="cx">                                         <?php $templatedir = get_bloginfo('url'); ?>
</span><del>-                                        <span class="title"><?php echo $title; ?></span> <a onclick="appendToList('<?php echo $templatedir; ?>','<?php echo $appendtype; ?>','<?php echo $title; ?>','<?php echo $link; ?>','<?php echo $itemid; ?>','<?php echo $parent_id ?>','<?php echo $description; ?>')" name="<?php echo $title; ?>" value="<?php echo $link; ?>"><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>
</del><ins>+                                        <span class="title"><?php echo $title; ?></span> <a onclick="appendToList('<?php echo $templatedir; ?>','<?php echo $appendtype; ?>','<?php echo $title; ?>','<?php echo $link; ?>','<?php echo $itemid; ?>','<?php echo $parent_id ?>','<?php echo $description; ?>')" name="<?php echo $title; ?>" value="<?php echo $link; ?>"><img alt="<?php esc_attr_e('Add to Custom Menu'); ?>" title="<?php esc_attr_e('Add to Custom Menu'); ?>" src="<?php echo admin_url('images/ico-add.png'); ?>" /></a> </dt>
</ins><span class="cx">                                         </dl>
</span><span class="cx">                                         <?php
</span><span class="cx">
</span><del>-                                                //Do recursion
</del><ins>+                                                // Do recursion
</ins><span class="cx">                                                 $counter = wp_custom_navigation_default_sub_items($itemid, $counter, $parent_id, $type, 'default');
</span><span class="cx">
</span><span class="cx">                                         ?>
</span><span class="lines">@@ -824,17 +648,15 @@
</span><span class="cx">
</span><span class="cx">         $counter = $intCounter;
</span><span class="cx">
</span><del>-        //Get Sub Category Items
</del><span class="cx">         if ( $type == 'categories' ) {
</span><ins>+                // Get Sub Category Items
</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">                 $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_args = array(
</span><span class="cx">                         'child_of' => $childof,
</span><span class="cx">                         'parent' => $childof);
</span><span class="lines">@@ -846,18 +668,17 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if ( $sub_array ) {
</span><del>-                //DISPLAY Loop
</del><ins>+                // DISPLAY Loop
</ins><span class="cx">                 foreach ( $sub_array as $sub_item ) {
</span><del>-                        if ( isset($sub_item->parent) ) {
</del><ins>+                        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><del>-                        }
</del><span class="cx">
</span><span class="cx">                         // Is child
</span><span class="cx">                         if ( $sub_item_parent == $childof ) {
</span><del>-                                //Prepare Menu Data
-                                //Category Menu Item
</del><ins>+                                // Prepare Menu Data
+                                // Category Menu Item
</ins><span class="cx">                                 if ( $type == 'categories' ) {
</span><span class="cx">                                         $link = get_category_link($sub_item->cat_ID);
</span><span class="cx">                                         $title = htmlentities($sub_item->cat_name);
</span><span class="lines">@@ -866,7 +687,7 @@
</span><span class="cx">                                         $linktype = 'category';
</span><span class="cx">                                         $appendtype= 'Category';
</span><span class="cx">                                 }
</span><del>-                                //Page Menu Item
</del><ins>+                                // Page Menu Item
</ins><span class="cx">                                 elseif ( $type == 'pages' ) {
</span><span class="cx">                                         $link = get_permalink($sub_item->ID);
</span><span class="cx">                                         $title = htmlentities($sub_item->post_title);
</span><span class="lines">@@ -875,21 +696,18 @@
</span><span class="cx">                                         $itemid = $sub_item->ID;
</span><span class="cx">                                         $appendtype= 'Page';
</span><span class="cx">                                 }
</span><del>-                                //Custom Menu Item
</del><ins>+                                // Custom Menu Item
</ins><span class="cx">                                 else {
</span><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>-                                //CHECK for existing parent records
-                                //echo $parent_id;
</del><ins>+                                // CHECK for existing parent records
+                                // echo $parent_id;
</ins><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><del>-                                if ($wp_result > 0 && isset($wp_result[0]->id)) {
</del><ins>+                                if ( $wp_result > 0 && isset($wp_result[0]->id) )
</ins><span class="cx">                                         $parent_id = $wp_result[0]->id;
</span><del>-                                } else {
-                                        //$parent_id = 0;
-                                }
</del><span class="cx">
</span><span class="cx">                                 //INSERT item
</span><span class="cx">                                 $insert = "INSERT INTO ".$table_name." (position,post_id,parent_id,custom_title,custom_link,custom_description,menu_icon,link_type,menu_id,custom_anchor_title) "."VALUES ('".$counter."','".$itemid."','".$parent_id."','".$title."','".$link."','','','".$linktype."','".$menu_id."','".$title."')";
</span></span></pre>
</div>
</div>
</body>
</html>