Changeset 13334
- Timestamp:
- 02/23/2010 06:45:59 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/custom-navigation.php
r13332 r13334 71 71 $menu_item->type = $type; 72 72 $menu_item->object_id = $menu_item->term_id; 73 $menu_item->ID = $menu_item->term_id; 73 74 $menu_item->parent_item = $menu_item->parent; 74 75 $menu_item->menu_order = $position; … … 102 103 // Category Menu Item 103 104 case 'category': 104 if ( $menu_item->guid == '')105 if ( empty($menu_item->guid) ) 105 106 $menu_item->link = get_category_link( $menu_item->object_id ); 106 107 else 107 108 $menu_item->link = $menu_item->guid; 108 109 109 if ( $menu_item->post_title == '') {110 $title_raw = get_categor ies( array('include' => $menu_item->object_id));111 $menu_item->title = htmlentities($title_raw [0]->cat_name);110 if ( empty($menu_item->post_title) ) { 111 $title_raw = get_category( $menu_item->object_id ); 112 $menu_item->title = htmlentities($title_raw->cat_name); 112 113 } else { 113 114 $menu_item->title = htmlentities( $menu_item->post_title ); 114 115 } 115 116 116 if ( $menu_item->post_content == '')117 if ( empty($menu_item->post_content) ) 117 118 $menu_item->description = htmlentities( strip_tags( category_description( $menu_item->object_id ) ) ); 118 119 else … … 325 326 // Custom Menu 326 327 if ( $type == 'menu' ) { 327 $description = get_post_meta($post->ID, 'page-description', true);328 328 $post = setup_menu_item($post, 'page', $intCounter); 329 329 ?> … … 415 415 foreach ( $categories_array as $cat_item ) { 416 416 if ( $cat_item->parent == 0 ) { 417 $cat_item = setup_menu_item($cat_item, 'category', $intCounter); 417 418 // Custom Menu 418 419 if ( $type == 'menu' ) { … … 420 421 421 422 <li id="menu-<?php echo $intCounter; ?>" value="<?php echo $intCounter; ?>"> 422 <dl> 423 <dt> 424 <span class="title"><?php echo esc_html($cat_item->cat_name); ?></span> 425 <span class="controls"> 426 <span class="type">category</span> 427 <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> 428 <a id="remove<?php echo $intCounter; ?>" onclick="removeitem(<?php echo $intCounter; ?>)" value="<?php echo $intCounter; ?>"> 429 <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'); ?>" /> 430 </a> 431 <a target="_blank" href="<?php echo get_category_link($cat_item->cat_ID); ?>"> 432 <img alt="="<?php esc_attr_e('View Page'); ?>" title="="<?php esc_attr_e('View Page'); ?>" src="<?php echo admin_url('images/ico-viewpage.png'); ?>" /> 433 </a> 434 </span> 435 436 </dt> 437 </dl> 438 <a class="hide" href="<?php echo get_category_link($cat_item->cat_ID); ?>"><span class="title"><?php echo $cat_item->cat_name; ?></span> 439 <?php 440 $use_cats_raw = get_option('wp_settings_custom_nav_descriptions'); 441 $use_cats = strtolower($use_cats_raw); 442 if ( $use_cats == 'yes' ) { ?> 443 <br/> <span><?php echo $cat_item->category_description; ?></span> 444 <?php } ?> 445 </a> 446 <input type="hidden" name="postmenu<?php echo $intCounter; ?>" id="postmenu<?php echo $intCounter; ?>" value="<?php echo $cat_item->cat_ID; ?>" /> 447 <input type="hidden" name="parent<?php echo $intCounter; ?>" id="parent<?php echo $intCounter; ?>" value="0" /> 448 <input type="hidden" name="title<?php echo $intCounter; ?>" id="title<?php echo $intCounter; ?>" value="<?php echo esc_attr($cat_item->cat_name); ?>" /> 449 <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)); ?>" /> 450 <input type="hidden" name="description<?php echo $intCounter; ?>" id="description<?php echo $intCounter; ?>" value="<?php echo esc_attr($cat_item->category_description); ?>" /> 451 <input type="hidden" name="icon<?php echo $intCounter; ?>" id="icon<?php echo $intCounter; ?>" value="0" /> 452 <input type="hidden" name="position<?php echo $intCounter; ?>" id="position<?php echo $intCounter; ?>" value="<?php echo $intCounter; ?>" /> 453 <input type="hidden" name="linktype<?php echo $intCounter; ?>" id="linktype<?php echo $intCounter; ?>" value="category" /> 454 <input type="hidden" name="anchortitle<?php echo $intCounter; ?>" id="anchortitle<?php echo $intCounter; ?>" value="<?php echo esc_attr($cat_item->cat_name); ?>" /> 455 <input type="hidden" name="newwindow<?php echo $intCounter; ?>" id="newwindow<?php echo $intCounter; ?>" value="0" /> 456 423 <?php output_menu_item($cat_item, 'menu'); ?> 457 424 <?php $parentli = $cat_item->cat_ID; ?> 458 425 <?php $intCounter++; ?> … … 521 488 if ( $type == 'categories' ) { 522 489 // Get Sub Category Items 490 $item_type = 'category'; 523 491 $sub_array = get_categories($sub_args); 524 492 } elseif ($type == 'pages') { 525 493 // Get Sub Page Items 494 $item_type = 'page'; 526 495 $sub_array = get_pages($sub_args); 527 496 } else { 497 $item_type = 'custom'; 528 498 $sub_array = array(); 529 499 } … … 538 508 foreach ( $sub_array as $sub_item ) { 539 509 // Prepare Menu Data 510 $sub_item = setup_menu_item($sub_item, $item_type, $counter); 511 540 512 if ( $type == 'categories' ) { 541 513 // Category Menu Item … … 567 539 ?> 568 540 <li id="menu-<?php echo $counter; ?>" value="<?php echo $counter; ?>"> 569 <dl> 570 <dt> 571 <span class="title"><?php echo $title; ?></span> 572 <span class="controls"> 573 <span class="type"><?php echo $linktype; ?></span> 574 <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> 575 <a id="remove<?php echo $counter; ?>" onclick="removeitem(<?php echo $counter; ?>)" value="<?php echo $counter; ?>"> 576 <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'); ?>" /> 577 </a> 578 <a target="_blank" href="<?php echo $link; ?>"> 579 <img alt="<?php esc_attr_e('View Page'); ?>" title="<?php esc_attr_e('View Page'); ?>" src="<?php echo admin_url('images/ico-viewpage.png'); ?>" /> 580 </a> 581 </span> 582 583 </dt> 584 </dl> 585 <a class="hide" href="<?php echo $link; ?>"><?php echo $title; ?></a> 586 <input type="hidden" name="dbid<?php echo $counter; ?>" id="dbid<?php echo $counter; ?>" value="<?php echo $sub_item->id; ?>" /> 587 <input type="hidden" name="postmenu<?php echo $counter; ?>" id="postmenu<?php echo $counter; ?>" value="<?php echo $parent_id; ?>" /> 588 <input type="hidden" name="parent<?php echo $counter; ?>" id="parent<?php echo $counter; ?>" value="<?php echo $parentli; ?>" /> 589 <input type="hidden" name="title<?php echo $counter; ?>" id="title<?php echo $counter; ?>" value="<?php echo $title; ?>" /> 590 <input type="hidden" name="linkurl<?php echo $counter; ?>" id="linkurl<?php echo $counter; ?>" value="<?php echo $link; ?>" /> 591 <input type="hidden" name="description<?php echo $counter; ?>" id="description<?php echo $counter; ?>" value="<?php echo $description; ?>" /> 592 <input type="hidden" name="icon<?php echo $counter; ?>" id="icon<?php echo $counter; ?>" value="0" /> 593 <input type="hidden" name="position<?php echo $counter; ?>" id="position<?php echo $counter; ?>" value="<?php echo $counter; ?>" /> 594 <input type="hidden" name="linktype<?php echo $counter; ?>" id="linktype<?php echo $counter; ?>" value="<?php echo $linktype; ?>" /> 595 <input type="hidden" name="anchortitle<?php echo $counter; ?>" id="anchortitle<?php echo $counter; ?>" value="<?php echo $title; ?>" /> 596 <input type="hidden" name="newwindow<?php echo $counter; ?>" id="newwindow<?php echo $counter; ?>" value="0" /> 597 541 <?php output_menu_item($sub_item, 'menu'); ?> 598 542 <?php $counter++; ?> 599 543 <?php … … 638 582 } 639 583 640 /*-----------------------------------------------------------------------------------*/641 /* Recursive get children */642 /*-----------------------------------------------------------------------------------*/643 644 function get_children_menu_elements($childof, $intCounter, $parentli, $type, $menu_id, $table_name) {645 global $wpdb;646 647 $counter = $intCounter;648 649 if ( $type == 'categories' ) {650 // Get Sub Category Items651 $sub_args = array(652 'child_of' => $childof,653 'hide_empty' => false,654 'parent' => $childof);655 $sub_array = get_categories($sub_args);656 } elseif ($type == 'pages') {657 // Get Sub Page Items658 $sub_args = array(659 'child_of' => $childof,660 'parent' => $childof);661 662 $sub_array = get_pages($sub_args);663 664 } else {665 $sub_array = array();666 }667 668 if ( $sub_array ) {669 // DISPLAY Loop670 foreach ( $sub_array as $sub_item ) {671 if ( isset($sub_item->parent) )672 $sub_item_parent = $sub_item->parent;673 elseif (isset($sub_item->post_parent))674 $sub_item_parent = $sub_item->post_parent;675 676 // Is child677 if ( $sub_item_parent == $childof ) {678 // Prepare Menu Data679 // Category Menu Item680 if ( $type == 'categories' ) {681 $link = get_category_link($sub_item->cat_ID);682 $title = htmlentities($sub_item->cat_name);683 $parent_id = $sub_item->category_parent;684 $itemid = $sub_item->cat_ID;685 $linktype = 'category';686 $appendtype= 'Category';687 }688 // Page Menu Item689 elseif ( $type == 'pages' ) {690 $link = get_permalink($sub_item->ID);691 $title = htmlentities($sub_item->post_title);692 $parent_id = $sub_item->post_parent;693 $linktype = 'page';694 $itemid = $sub_item->ID;695 $appendtype= 'Page';696 }697 // Custom Menu Item698 else {699 $title = '';700 $linktype = 'custom';701 $appendtype= 'Custom';702 }703 704 // CHECK for existing parent records705 // echo $parent_id;706 $wp_result = $wpdb->get_results("SELECT id FROM ".$table_name." WHERE post_id='".$parent_id."' AND link_type='".$linktype."' AND menu_id='".$menu_id."'");707 if ( $wp_result > 0 && isset($wp_result[0]->id) )708 $parent_id = $wp_result[0]->id;709 710 //INSERT item711 $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."')";712 $results = $wpdb->query( $insert );713 714 $counter++;715 $counter = get_children_menu_elements($itemid, $counter, $parent_id, $type, $menu_id, $table_name);716 }717 }718 }719 return $counter;720 }721 722 584 ?>
Note: See TracChangeset
for help on using the changeset viewer.