<!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>[13334] trunk/wp-includes/custom-navigation.php: More output consolidation.</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/13334">13334</a></dd>
<dt>Author</dt> <dd>ryan</dd>
<dt>Date</dt> <dd>2010-02-23 18:45:59 +0000 (Tue, 23 Feb 2010)</dd>
</dl>
<h3>Log Message</h3>
<pre>More output consolidation. 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 (13333 => 13334)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/custom-navigation.php        2010-02-23 18:23:26 UTC (rev 13333)
+++ trunk/wp-includes/custom-navigation.php        2010-02-23 18:45:59 UTC (rev 13334)
</span><span class="lines">@@ -70,6 +70,7 @@
</span><span class="cx">         } elseif ( 'category' == $type ) {
</span><span class="cx">                 $menu_item->type = $type;
</span><span class="cx">                 $menu_item->object_id = $menu_item->term_id;
</span><ins>+                $menu_item->ID = $menu_item->term_id;
</ins><span class="cx">                 $menu_item->parent_item = $menu_item->parent;
</span><span class="cx">                 $menu_item->menu_order = $position;
</span><span class="cx">         } elseif ( 'page' == $type ) {
</span><span class="lines">@@ -101,19 +102,19 @@
</span><span class="cx">                 break;
</span><span class="cx">                 // Category Menu Item
</span><span class="cx">                 case 'category':
</span><del>-                        if ( $menu_item->guid == '' )
</del><ins>+                        if ( empty($menu_item->guid) )
</ins><span class="cx">                                 $menu_item->link = get_category_link( $menu_item->object_id );
</span><span class="cx">                         else
</span><span class="cx">                                 $menu_item->link = $menu_item->guid;
</span><span class="cx">
</span><del>-                        if ( $menu_item->post_title == '' ) {
-                                $title_raw = get_categories( array('include' => $menu_item->object_id) );
-                                $menu_item->title = htmlentities($title_raw[0]->cat_name);
</del><ins>+                        if ( empty($menu_item->post_title) ) {
+                                $title_raw = get_category( $menu_item->object_id );
+                                $menu_item->title = htmlentities($title_raw->cat_name);
</ins><span class="cx">                         } else {
</span><span class="cx">                                 $menu_item->title = htmlentities( $menu_item->post_title );
</span><span class="cx">                         }
</span><span class="cx">
</span><del>-                        if ( $menu_item->post_content == '' )
</del><ins>+                        if ( empty($menu_item->post_content) )
</ins><span class="cx">                                 $menu_item->description = htmlentities( strip_tags( category_description( $menu_item->object_id ) ) );
</span><span class="cx">                         else
</span><span class="cx">                                 $menu_item->description = htmlentities( $menu_item->post_content );
</span><span class="lines">@@ -324,7 +325,6 @@
</span><span class="cx">                 if ($post->post_parent == 0) {
</span><span class="cx">                         // Custom Menu
</span><span class="cx">                         if ( $type == 'menu' ) {
</span><del>-                                $description = get_post_meta($post->ID, 'page-description', true);
</del><span class="cx">                                 $post = setup_menu_item($post, 'page', $intCounter);
</span><span class="cx">                                 ?>
</span><span class="cx">
</span><span class="lines">@@ -414,46 +414,13 @@
</span><span class="cx">         // Display Loop
</span><span class="cx">         foreach ( $categories_array as $cat_item ) {
</span><span class="cx">                 if ( $cat_item->parent == 0 ) {
</span><ins>+                        $cat_item = setup_menu_item($cat_item, 'category', $intCounter);
</ins><span class="cx">                         // Custom Menu
</span><span class="cx">                         if ( $type == 'menu' ) {
</span><span class="cx">                                 ?>
</span><span class="cx">
</span><span class="cx">                                 <li id="menu-<?php echo $intCounter; ?>" value="<?php echo $intCounter; ?>">
</span><del>-                                        <dl>
-                                        <dt>
-                                                <span class="title"><?php echo esc_html($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="<?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>
-                                                <a id="remove<?php echo $intCounter; ?>" onclick="removeitem(<?php echo $intCounter; ?>)" value="<?php echo $intCounter; ?>">
-                                                        <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'); ?>" />
-                                                </a>
-                                                <a target="_blank" href="<?php echo get_category_link($cat_item->cat_ID); ?>">
-                                                        <img alt="="<?php esc_attr_e('View Page'); ?>" title="="<?php esc_attr_e('View Page'); ?>" src="<?php echo admin_url('images/ico-viewpage.png'); ?>" />
-                                                </a>
-                                                </span>
-
-                                        </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 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); ?>" />
-                                        <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 esc_attr($cat_item->cat_name); ?>" />
-                                        <input type="hidden" name="newwindow<?php echo $intCounter; ?>" id="newwindow<?php echo $intCounter; ?>" value="0" />
-
</del><ins>+                                        <?php output_menu_item($cat_item, 'menu'); ?>
</ins><span class="cx">                                         <?php $parentli = $cat_item->cat_ID; ?>
</span><span class="cx">                                         <?php $intCounter++; ?>
</span><span class="cx">                                         <?php
</span><span class="lines">@@ -520,11 +487,14 @@
</span><span class="cx">
</span><span class="cx">         if ( $type == 'categories' ) {
</span><span class="cx">                 // Get Sub Category Items
</span><ins>+                $item_type = 'category';
</ins><span class="cx">                 $sub_array = get_categories($sub_args);
</span><span class="cx">         } elseif ($type == 'pages') {
</span><span class="cx">                 // Get Sub Page Items
</span><ins>+                $item_type = 'page';
</ins><span class="cx">                 $sub_array = get_pages($sub_args);
</span><span class="cx">         } else {
</span><ins>+                $item_type = 'custom';
</ins><span class="cx">                 $sub_array = array();
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -537,6 +507,8 @@
</span><span class="cx">                 // Display Loop
</span><span class="cx">                 foreach ( $sub_array as $sub_item ) {
</span><span class="cx">                         // Prepare Menu Data
</span><ins>+                        $sub_item = setup_menu_item($sub_item, $item_type, $counter);
+
</ins><span class="cx">                         if ( $type == 'categories' ) {
</span><span class="cx">                                 // Category Menu Item
</span><span class="cx">                                 $link = get_category_link($sub_item->cat_ID);
</span><span class="lines">@@ -566,35 +538,7 @@
</span><span class="cx">                         if ( $output_type == 'menu' ) {
</span><span class="cx">                                 ?>
</span><span class="cx">                                 <li id="menu-<?php echo $counter; ?>" value="<?php echo $counter; ?>">
</span><del>-                                        <dl>
-                                        <dt>
-                                                <span class="title"><?php echo $title; ?></span>
-                                                        <span class="controls">
-                                                        <span class="type"><?php echo $linktype; ?></span>
-                                                        <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>
-                                                                <a id="remove<?php echo $counter; ?>" onclick="removeitem(<?php echo $counter; ?>)" value="<?php echo $counter; ?>">
-                                                                        <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'); ?>" />
-                                                                </a>
-                                                                <a target="_blank" href="<?php echo $link; ?>">
-                                                                        <img alt="<?php esc_attr_e('View Page'); ?>" title="<?php esc_attr_e('View Page'); ?>" src="<?php echo admin_url('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 $parent_id; ?>" />
-                                        <input type="hidden" name="parent<?php echo $counter; ?>" id="parent<?php echo $counter; ?>" value="<?php echo $parentli; ?>" />
-                                        <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 $linktype; ?>" />
-                                        <input type="hidden" name="anchortitle<?php echo $counter; ?>" id="anchortitle<?php echo $counter; ?>" value="<?php echo $title; ?>" />
-                                        <input type="hidden" name="newwindow<?php echo $counter; ?>" id="newwindow<?php echo $counter; ?>" value="0" />
-
</del><ins>+                                        <?php output_menu_item($sub_item, 'menu'); ?>
</ins><span class="cx">                                         <?php $counter++; ?>
</span><span class="cx">                                         <?php
</span><span class="cx">
</span><span class="lines">@@ -637,86 +581,4 @@
</span><span class="cx">         return $counter;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-/*-----------------------------------------------------------------------------------*/
-/* Recursive get children */
-/*-----------------------------------------------------------------------------------*/
-
-function get_children_menu_elements($childof, $intCounter, $parentli, $type, $menu_id, $table_name) {
-        global $wpdb;
-
-        $counter = $intCounter;
-
-        if ( $type == 'categories' ) {
-                // Get Sub Category Items
-                $sub_args = array(
-                        'child_of' => $childof,
-                        'hide_empty' => false,
-                        'parent' => $childof);
-                $sub_array = get_categories($sub_args);
-        } elseif ($type == 'pages') {
-                // Get Sub Page Items
-                $sub_args = array(
-                        'child_of' => $childof,
-                        'parent' => $childof);
-
-                $sub_array = get_pages($sub_args);
-
-        } else {
-                $sub_array = array();
-        }
-
-        if ( $sub_array ) {
-                // DISPLAY Loop
-                foreach ( $sub_array as $sub_item ) {
-                        if ( isset($sub_item->parent) )
-                                $sub_item_parent = $sub_item->parent;
-                        elseif (isset($sub_item->post_parent))
-                                $sub_item_parent = $sub_item->post_parent;
-
-                        // Is child
-                        if ( $sub_item_parent == $childof ) {
-                                // Prepare Menu Data
-                                // Category Menu Item
-                                if ( $type == 'categories' ) {
-                                        $link = get_category_link($sub_item->cat_ID);
-                                        $title = htmlentities($sub_item->cat_name);
-                                        $parent_id = $sub_item->category_parent;
-                                        $itemid = $sub_item->cat_ID;
-                                        $linktype = 'category';
-                                        $appendtype= 'Category';
-                                }
-                                // Page Menu Item
-                                elseif ( $type == 'pages' ) {
-                                        $link = get_permalink($sub_item->ID);
-                                        $title = htmlentities($sub_item->post_title);
-                                        $parent_id = $sub_item->post_parent;
-                                        $linktype = 'page';
-                                        $itemid = $sub_item->ID;
-                                        $appendtype= 'Page';
-                                }
-                                // Custom Menu Item
-                                else {
-                                        $title = '';
-                                        $linktype = 'custom';
-                                        $appendtype= 'Custom';
-                                }
-
-                                // CHECK for existing parent records
-                                // echo $parent_id;
-                                $wp_result = $wpdb->get_results("SELECT id FROM ".$table_name." WHERE post_id='".$parent_id."' AND link_type='".$linktype."' AND menu_id='".$menu_id."'");
-                                if ( $wp_result > 0 && isset($wp_result[0]->id) )
-                                        $parent_id = $wp_result[0]->id;
-
-                                //INSERT item
-                                $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."')";
-                                 $results = $wpdb->query( $insert );
-
-                                 $counter++;
-                                 $counter = get_children_menu_elements($itemid, $counter, $parent_id, $type, $menu_id, $table_name);
-                        }
-                }
-        }
-        return $counter;
-}
-
</del><span class="cx"> ?>
</span></span></pre>
</div>
</div>
</body>
</html>