Changeset 13332
- Timestamp:
- 02/23/2010 06:17:51 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/custom-navigation.php
r13331 r13332 58 58 } 59 59 60 function setup_menu_item($menu_item ) {60 function setup_menu_item($menu_item, $type = 'item', $position = 0) { 61 61 global $parent_menu_order; 62 62 63 $menu_item->type = get_post_meta($menu_item->ID, 'menu_type', true); 64 $menu_item->object_id = get_post_meta($menu_item->ID, 'object_id', true); 65 //$parent_menu_order[ $menu_item->ID ] = $menu_item->menu_order; 66 if ( isset( $parent_menu_order[ $menu_item->post_parent ] ) ) 67 $menu_item->parent_item = $parent_menu_order[ $menu_item->post_parent ]; 68 else 69 $menu_item->parent_item = 0; 63 if ( 'item' == $type ) { 64 $menu_item->type = get_post_meta($menu_item->ID, 'menu_type', true); 65 $menu_item->object_id = get_post_meta($menu_item->ID, 'object_id', true); 66 if ( isset( $parent_menu_order[ $menu_item->post_parent ] ) ) 67 $menu_item->parent_item = $parent_menu_order[ $menu_item->post_parent ]; 68 else 69 $menu_item->parent_item = 0; 70 } elseif ( 'category' == $type ) { 71 $menu_item->type = $type; 72 $menu_item->object_id = $menu_item->term_id; 73 $menu_item->parent_item = $menu_item->parent; 74 $menu_item->menu_order = $position; 75 } elseif ( 'page' == $type ) { 76 $menu_item->type = $type; 77 $menu_item->object_id = $menu_item->ID; 78 $menu_item->parent_item = $menu_item->post_parent; 79 $menu_item->menu_order = $position; 80 } 70 81 71 82 switch ( $menu_item->type ) { … … 87 98 $menu_item->description = htmlentities( $menu_item->post_content ); 88 99 $menu_item->target = ''; 100 $menu_item->append = 'Page'; 89 101 break; 90 102 // Category Menu Item … … 107 119 $menu_item->description = htmlentities( $menu_item->post_content ); 108 120 $menu_item->target = ''; 121 $menu_item->append = 'Category'; 109 122 break; 110 123 default: … … 114 127 $menu_item->description = htmlentities( $menu_item->post_content ); 115 128 $menu_item->target = 'target="_blank"'; 129 $menu_item->append = 'Custom'; 116 130 break; 117 131 } … … 147 161 148 162 return $menu_item; 163 } 164 165 function output_menu_item($menu_item, $context) { 166 switch( $context ) { 167 case 'backend': 168 case 'menu': 169 ?> 170 <dl> 171 <dt> 172 <span class="title"><?php echo esc_html($menu_item->title); ?></span> 173 <span class="controls"> 174 <span class="type"><?php echo esc_html($menu_item->type); ?></span> 175 <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="<?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> 176 <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="<?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> 177 <a id="view<?php echo $menu_item->menu_order; ?>" target="_blank" href="<?php echo $menu_item->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> 178 </span> 179 </dt> 180 </dl> 181 <?php if ( 'backend' == $context ) { ?> 182 <a><span class=""></span></a> 183 <php } else { ?> 184 <a class="hide" href="<?php echo $menu_item->link; ?>"><?php echo $menu_item->title; ?></a> 185 <?php } ?> 186 <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; ?>" /> 187 <input type="hidden" name="postmenu<?php echo $menu_item->menu_order; ?>" id="postmenu<?php echo $menu_item->menu_order; ?>" value="<?php echo $menu_item->ID; ?>" /> 188 <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; ?>" /> 189 <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; ?>" /> 190 <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; ?>" /> 191 <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; ?>" /> 192 <input type="hidden" name="icon<?php echo $menu_item->menu_order; ?>" id="icon<?php echo $menu_item->menu_order; ?>" value="0" /> 193 <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; ?>" /> 194 <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; ?>" /> 195 <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 ); ?>" /> 196 <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' ); ?>" /> 197 <?php 198 break; 199 } 149 200 } 150 201 … … 217 268 ?></a><?php 218 269 } elseif ( $type == 'backend' ) { 219 ?> 220 221 <dl> 222 <dt> 223 <span class="title"><?php echo $menu_item->title; ?></span> 224 <span class="controls"> 225 <span class="type"><?php echo $menu_item->type; ?></span> 226 <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> 227 <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> 228 <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> 229 </span> 230 </dt> 231 </dl> 232 233 <a><span class=""></span></a> 234 <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; ?>" /> 235 <input type="hidden" name="postmenu<?php echo $menu_item->menu_order; ?>" id="postmenu<?php echo $menu_item->menu_order; ?>" value="<?php echo $id; ?>" /> 236 <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; ?>" /> 237 <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; ?>" /> 238 <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; ?>" /> 239 <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; ?>" /> 240 <input type="hidden" name="icon<?php echo $menu_item->menu_order; ?>" id="icon<?php echo $menu_item->menu_order; ?>" value="0" /> 241 <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; ?>" /> 242 <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; ?>" /> 243 <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 ); ?>" /> 244 <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' ); ?>" /> 245 246 <?php 270 output_menu_item($menu_item, 'backend'); 247 271 } 248 272 // Indent children … … 302 326 if ( $type == 'menu' ) { 303 327 $description = get_post_meta($post->ID, 'page-description', true); 328 $post = setup_menu_item($post, 'page', $intCounter); 304 329 ?> 305 330 306 331 <li id="menu-<?php echo $intCounter; ?>" value="<?php echo $intCounter; ?>"> 307 332 308 <dl> 309 <dt> 310 <span class="title"><?php echo $post->post_title; ?></span> 311 <span class="controls"> 312 <span class="type">page</span> 313 <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> 314 <a id="remove<?php echo $intCounter; ?>" onclick="removeitem(<?php echo $intCounter; ?>)" value="<?php echo $intCounter; ?>"> 315 <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" /> 316 </a> 317 <a target="_blank" href="<?php echo get_permalink($post->ID); ?>"> 318 <img alt="View Page" title="View Page" src="<?php echo get_bloginfo('url'); ?>/wp-admin/images/ico-viewpage.png" /> 319 </a> 320 </span> 321 322 </dt> 323 </dl> 324 <a class="hide" href="<?php echo get_permalink($post->ID); ?>"><span class="title"><?php echo $post->post_title; ?></span> 325 </a> 326 <input type="hidden" name="postmenu<?php echo $intCounter; ?>" id="postmenu<?php echo $intCounter; ?>" value="<?php echo $post->ID; ?>" /> 327 <input type="hidden" name="parent<?php echo $intCounter; ?>" id="parent<?php echo $intCounter; ?>" value="0" /> 328 <input type="hidden" name="title<?php echo $intCounter; ?>" id="title<?php echo $intCounter; ?>" value="<?php echo htmlentities($post->post_title); ?>" /> 329 <input type="hidden" name="linkurl<?php echo $intCounter; ?>" id="linkurl<?php echo $intCounter; ?>" value="<?php echo get_permalink($post->ID); ?>" /> 330 <input type="hidden" name="description<?php echo $intCounter; ?>" id="description<?php echo $intCounter; ?>" value="<?php echo $description; ?>" /> 331 <input type="hidden" name="icon<?php echo $intCounter; ?>" id="icon<?php echo $intCounter; ?>" value="0" /> 332 <input type="hidden" name="position<?php echo $intCounter; ?>" id="position<?php echo $intCounter; ?>" value="<?php echo $intCounter; ?>" /> 333 <input type="hidden" name="linktype<?php echo $intCounter; ?>" id="linktype<?php echo $intCounter; ?>" value="page" /> 334 <input type="hidden" name="anchortitle<?php echo $intCounter; ?>" id="anchortitle<?php echo $intCounter; ?>" value="<?php echo htmlentities($post->post_title); ?>" /> 335 <input type="hidden" name="newwindow<?php echo $intCounter; ?>" id="newwindow<?php echo $intCounter; ?>" value="0" /> 333 <?php output_menu_item($post, 'menu', $intCounter); ?> 336 334 337 335 <?php $parentli = $post->ID; ?>
Note: See TracChangeset
for help on using the changeset viewer.