Changeset 13317
- Timestamp:
- 02/22/2010 11:14:03 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/custom-navigation.php
r13312 r13317 33 33 function wp_custom_navigation_setup($override = false) { 34 34 35 $nav_version = '1.1.0'; 36 //Custom Navigation Menu Setup 37 38 //Check for Upgrades 39 if (get_option('wp_settings_custom_nav_version') <> '') { 40 $nav_version_in_db = get_option('wp_settings_custom_nav_version'); 41 } 42 else { 43 $nav_version_in_db = '0'; 44 } 45 46 //Override for menu descriptions 47 update_option('wp_settings_custom_nav_advanced_options','yes'); 48 49 if(($nav_version_in_db <> $nav_version) || ($override)) 50 update_option('wp_settings_custom_nav_version',$nav_version); 35 // Custom Navigation Menu Setup 36 37 // Override for menu descriptions 38 update_option('wp_settings_custom_nav_advanced_options', 'yes'); 51 39 52 40 $custom_menus = get_terms( 'nav_menu', array( 'hide_empty' => false ) ); 53 41 if ( !empty( $custom_menus ) ) { 54 foreach ( $custom_menus as $menu ) {42 foreach ( $custom_menus as $menu ) { 55 43 $menu_objects = get_objects_in_term( $menu->term_id, 'nav_menu' ); 56 44 if ( !empty( $menu_objects ) ) { 57 foreach ( $menu_objects as $item )45 foreach ( $menu_objects as $item ) { 58 46 wp_delete_post( $item ); 47 } 59 48 } 60 49 wp_delete_term( $menu->term_id, 'nav_menu' ); 61 50 } 62 51 } 63 64 52 } 65 53 … … 84 72 /*-----------------------------------------------------------------------------------*/ 85 73 86 function wp_custom_navigation_output($args = array()) { 87 88 //DEFAULT ARGS 89 $type = 'frontend'; 90 $name = 'Menu 1'; 91 $id = 0; 92 $desc = 2; 93 $before_title = ''; 94 $after_title = ''; 95 96 if (isset($args)) { 97 98 if ( !is_array($args) ) 99 parse_str( $args, $args ); 100 101 extract($args); 102 } 74 function wp_custom_navigation_output( $args = array() ) { 75 76 // Defaults 77 $defaults = array( 'type' => 'frontend', 'name' => 'Menu 1', 'id' => 0, 'desc' => 2, 'before_title' => '', 'after_title' => ''); 78 79 $args = wp_parse_args($args, $defaults); 80 extract($args, EXTR_SKIP); 103 81 104 82 $menu_objects = get_objects_in_term( $id, 'nav_menu' ); 105 83 $menu_items = wp_custom_navigation_get_menu_items( $menu_objects, 'menu_order' ); 106 //O verride for menu descriptions84 //O verride for menu descriptions 107 85 $advanced_option_descriptions = get_option('wp_settings_custom_nav_advanced_options'); 108 86 if ( $advanced_option_descriptions == 'no' ) … … 212 190 // 1 widget override display descriptions 213 191 // 0 widget override not set 214 if (($desc == 1) || ($desc == 0) ) 215 { 192 if ( ($desc == 1) || ($desc == 0) ) { 216 193 ?><span class="nav-description"><?php echo $description; ?></span><?php 217 194 } 218 elseif ($desc == 2)219 { }220 else221 { }222 195 } else { 223 196 // 2 widget override do NOT display descriptions … … 227 200 ?><span class="nav-description"><?php echo $description; ?></span><?php 228 201 } 229 elseif (($desc == 2) || ($desc == 0))230 { }231 else232 { }233 202 } 234 203 … … 288 257 //@todo: implement menu heirarchy 289 258 //RECURSIVE Sub Menu Items 290 function wp_custom_navigation_sub_items($post_id, $type,$table_name,$output_type,$menu_id = 0) {259 function wp_custom_navigation_sub_items($post_id, $type, $table_name, $output_type, $menu_id = 0) { 291 260 292 261 $parent_id = 0; … … 467 436 468 437 469 // Outputs All Pages and Sub Items470 function wp_custom_nav_get_pages($counter, $type) {438 // Outputs All Pages and Sub Items 439 function wp_custom_nav_get_pages($counter, $type) { 471 440 472 441 $pages_args = array( … … 491 460 $parentli = $intCounter; 492 461 493 if ($pages_array) 494 { 495 //DISPLAY Loop 496 foreach ($pages_array as $post) 497 { 498 499 if ($post->post_parent == 0) 500 { 501 //Custom Menu 502 if ($type == 'menu') 503 { 504 $description = get_post_meta($post->ID, 'page-description', true); 462 if ( !$pages_array ) { 463 echo 'Not Found'; 464 return $intCounter; 465 } 466 467 // Display Loop 468 foreach ( $pages_array as $post ) { 469 if ($post->post_parent == 0) { 470 // Custom Menu 471 if ( $type == 'menu' ) { 472 $description = get_post_meta($post->ID, 'page-description', true); 473 ?> 474 475 <li id="menu-<?php echo $intCounter; ?>" value="<?php echo $intCounter; ?>"> 476 477 <dl> 478 <dt> 479 <span class="title"><?php echo $post->post_title; ?></span> 480 <span class="controls"> 481 <span class="type">page</span> 482 <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> 483 <a id="remove<?php echo $intCounter; ?>" onclick="removeitem(<?php echo $intCounter; ?>)" value="<?php echo $intCounter; ?>"> 484 <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" /> 485 </a> 486 <a target="_blank" href="<?php echo get_permalink($post->ID); ?>"> 487 <img alt="View Page" title="View Page" src="<?php echo get_bloginfo('url'); ?>/wp-admin/images/ico-viewpage.png" /> 488 </a> 489 </span> 490 491 </dt> 492 </dl> 493 <a class="hide" href="<?php echo get_permalink($post->ID); ?>"><span class="title"><?php echo $post->post_title; ?></span> 494 </a> 495 <input type="hidden" name="postmenu<?php echo $intCounter; ?>" id="postmenu<?php echo $intCounter; ?>" value="<?php echo $post->ID; ?>" /> 496 <input type="hidden" name="parent<?php echo $intCounter; ?>" id="parent<?php echo $intCounter; ?>" value="0" /> 497 <input type="hidden" name="title<?php echo $intCounter; ?>" id="title<?php echo $intCounter; ?>" value="<?php echo htmlentities($post->post_title); ?>" /> 498 <input type="hidden" name="linkurl<?php echo $intCounter; ?>" id="linkurl<?php echo $intCounter; ?>" value="<?php echo get_permalink($post->ID); ?>" /> 499 <input type="hidden" name="description<?php echo $intCounter; ?>" id="description<?php echo $intCounter; ?>" value="<?php echo $description; ?>" /> 500 <input type="hidden" name="icon<?php echo $intCounter; ?>" id="icon<?php echo $intCounter; ?>" value="0" /> 501 <input type="hidden" name="position<?php echo $intCounter; ?>" id="position<?php echo $intCounter; ?>" value="<?php echo $intCounter; ?>" /> 502 <input type="hidden" name="linktype<?php echo $intCounter; ?>" id="linktype<?php echo $intCounter; ?>" value="page" /> 503 <input type="hidden" name="anchortitle<?php echo $intCounter; ?>" id="anchortitle<?php echo $intCounter; ?>" value="<?php echo htmlentities($post->post_title); ?>" /> 504 <input type="hidden" name="newwindow<?php echo $intCounter; ?>" id="newwindow<?php echo $intCounter; ?>" value="0" /> 505 506 <?php $parentli = $post->ID; ?> 507 <?php $intCounter++; ?> 508 <?php 509 510 //Recursive function 511 $intCounter = wp_custom_navigation_default_sub_items($post->ID, $intCounter, $parentli, 'pages', 'menu'); 512 505 513 ?> 506 514 507 <li id="menu-<?php echo $intCounter; ?>" value="<?php echo $intCounter; ?>"> 508 509 <dl> 510 <dt> 511 <span class="title"><?php echo $post->post_title; ?></span> 512 <span class="controls"> 513 <span class="type">page</span> 514 <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> 515 <a id="remove<?php echo $intCounter; ?>" onclick="removeitem(<?php echo $intCounter; ?>)" value="<?php echo $intCounter; ?>"> 516 <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" /> 517 </a> 518 <a target="_blank" href="<?php echo get_permalink($post->ID); ?>"> 519 <img alt="View Page" title="View Page" src="<?php echo get_bloginfo('url'); ?>/wp-admin/images/ico-viewpage.png" /> 520 </a> 521 </span> 522 523 </dt> 524 </dl> 525 <a class="hide" href="<?php echo get_permalink($post->ID); ?>"><span class="title"><?php echo $post->post_title; ?></span> 526 </a> 527 <input type="hidden" name="postmenu<?php echo $intCounter; ?>" id="postmenu<?php echo $intCounter; ?>" value="<?php echo $post->ID; ?>" /> 528 <input type="hidden" name="parent<?php echo $intCounter; ?>" id="parent<?php echo $intCounter; ?>" value="0" /> 529 <input type="hidden" name="title<?php echo $intCounter; ?>" id="title<?php echo $intCounter; ?>" value="<?php echo htmlentities($post->post_title); ?>" /> 530 <input type="hidden" name="linkurl<?php echo $intCounter; ?>" id="linkurl<?php echo $intCounter; ?>" value="<?php echo get_permalink($post->ID); ?>" /> 531 <input type="hidden" name="description<?php echo $intCounter; ?>" id="description<?php echo $intCounter; ?>" value="<?php echo $description; ?>" /> 532 <input type="hidden" name="icon<?php echo $intCounter; ?>" id="icon<?php echo $intCounter; ?>" value="0" /> 533 <input type="hidden" name="position<?php echo $intCounter; ?>" id="position<?php echo $intCounter; ?>" value="<?php echo $intCounter; ?>" /> 534 <input type="hidden" name="linktype<?php echo $intCounter; ?>" id="linktype<?php echo $intCounter; ?>" value="page" /> 535 <input type="hidden" name="anchortitle<?php echo $intCounter; ?>" id="anchortitle<?php echo $intCounter; ?>" value="<?php echo htmlentities($post->post_title); ?>" /> 536 <input type="hidden" name="newwindow<?php echo $intCounter; ?>" id="newwindow<?php echo $intCounter; ?>" value="0" /> 537 538 <?php $parentli = $post->ID; ?> 539 <?php $intCounter++; ?> 540 <?php 541 542 //Recursive function 543 $intCounter = wp_custom_navigation_default_sub_items($post->ID, $intCounter, $parentli, 'pages', 'menu'); 544 545 ?> 546 547 </li> 548 515 </li> 516 517 <?php 518 519 } elseif ( $type == 'default' ) { 520 // Sidebar Menu 521 ?> 522 523 <li> 524 <dl> 525 <dt> 549 526 <?php 550 551 } 552 //Sidebar Menu 553 elseif ($type == 'default') 554 { 527 $post_text = htmlentities($post->post_title); 528 $post_url = get_permalink($post->ID); 529 $post_id = $post->ID; 530 $post_parent_id = $post->post_parent; 531 532 $description = htmlentities(get_post_meta($post_id, 'page-description', true)); 533 555 534 ?> 556 557 <li> 558 <dl> 559 <dt> 560 <?php 561 $post_text = htmlentities($post->post_title); 562 $post_url = get_permalink($post->ID); 563 $post_id = $post->ID; 564 $post_parent_id = $post->post_parent; 565 566 $description = htmlentities(get_post_meta($post_id, 'page-description', true)); 567 568 ?> 569 <?php $templatedir = get_bloginfo('url'); ?> 570 571 <span class="title"><?php echo $post->post_title; ?></span> <a onclick="appendToList('<?php echo $templatedir; ?>','Page','<?php echo $post_text; ?>','<?php echo $post_url; ?>','<?php echo $post_id; ?>','<?php echo $post_parent_id ?>','<?php echo $description; ?>')" name="<?php echo $post_text; ?>" value="<?php echo get_permalink($post->ID); ?>"><img alt="Add to Custom Menu" title="Add to Custom Menu" src="<?php echo get_bloginfo('url'); ?>/wp-admin/images/ico-add.png" /></a></dt> 572 </dl> 573 <?php $parentli = $post->ID; ?> 574 <?php $intCounter++; ?> 575 <?php 576 577 //Recursive function 578 $intCounter = wp_custom_navigation_default_sub_items($post_id, $intCounter, $parentli, 'pages', 'default'); 579 580 ?> 581 582 </li> 583 535 <?php $templatedir = get_bloginfo('url'); ?> 536 537 <span class="title"><?php echo $post->post_title; ?></span> <a onclick="appendToList('<?php echo $templatedir; ?>','Page','<?php echo $post_text; ?>','<?php echo $post_url; ?>','<?php echo $post_id; ?>','<?php echo $post_parent_id ?>','<?php echo $description; ?>')" name="<?php echo $post_text; ?>" value="<?php echo get_permalink($post->ID); ?>"><img alt="Add to Custom Menu" title="Add to Custom Menu" src="<?php echo get_bloginfo('url'); ?>/wp-admin/images/ico-add.png" /></a></dt> 538 </dl> 539 <?php $parentli = $post->ID; ?> 540 <?php $intCounter++; ?> 584 541 <?php 585 542 586 } 587 else 588 { 589 590 } 543 //Recursive function 544 $intCounter = wp_custom_navigation_default_sub_items($post_id, $intCounter, $parentli, 'pages', 'default'); 545 546 ?> 547 548 </li> 549 550 <?php 551 591 552 } 592 553 } 593 }594 else595 {596 echo 'Not Found';597 554 } 598 555 … … 616 573 'pad_counts' => false ); 617 574 618 619 620 575 $intCounter = $counter; 621 576 622 // GETall categories577 // Get all categories 623 578 $categories_array = get_categories($category_args); 624 579 625 if ($categories_array) 626 { 627 //DISPLAY Loop 628 foreach ($categories_array as $cat_item) 629 { 630 631 if ($cat_item->parent == 0) 632 { 633 //Custom Menu 634 if ($type == 'menu') 635 { 580 if ( !$categories_array ) { 581 echo 'Not Found'; 582 return $intCounter; 583 } 584 585 // Display Loop 586 foreach ( $categories_array as $cat_item ) { 587 588 if ( $cat_item->parent == 0 ) { 589 // Custom Menu 590 if ( $type == 'menu' ) { 591 ?> 592 593 <li id="menu-<?php echo $intCounter; ?>" value="<?php echo $intCounter; ?>"> 594 <dl> 595 <dt> 596 <span class="title"><?php echo $cat_item->cat_name; ?></span> 597 <span class="controls"> 598 <span class="type">category</span> 599 <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> 600 <a id="remove<?php echo $intCounter; ?>" onclick="removeitem(<?php echo $intCounter; ?>)" value="<?php echo $intCounter; ?>"> 601 <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" /> 602 </a> 603 <a target="_blank" href="<?php echo get_category_link($cat_item->cat_ID); ?>"> 604 <img alt="View Page" title="View Page" src="<?php echo get_bloginfo('url'); ?>/wp-admin/images/ico-viewpage.png" /> 605 </a> 606 </span> 607 608 </dt> 609 </dl> 610 <a class="hide" href="<?php echo get_category_link($cat_item->cat_ID); ?>"><span class="title"><?php echo $cat_item->cat_name; ?></span> 611 <?php 612 $use_cats_raw = get_option('wp_settings_custom_nav_descriptions'); 613 $use_cats = strtolower($use_cats_raw); 614 if ( $use_cats == 'yes' ) { ?> 615 <br/> <span><?php echo $cat_item->category_description; ?></span> 616 <?php } ?> 617 </a> 618 <input type="hidden" name="postmenu<?php echo $intCounter; ?>" id="postmenu<?php echo $intCounter; ?>" value="<?php echo $cat_item->cat_ID; ?>" /> 619 <input type="hidden" name="parent<?php echo $intCounter; ?>" id="parent<?php echo $intCounter; ?>" value="0" /> 620 <input type="hidden" name="title<?php echo $intCounter; ?>" id="title<?php echo $intCounter; ?>" value="<?php echo htmlentities($cat_item->cat_name); ?>" /> 621 <input type="hidden" name="linkurl<?php echo $intCounter; ?>" id="linkurl<?php echo $intCounter; ?>" value="<?php echo get_category_link($cat_item->cat_ID); ?>" /> 622 <input type="hidden" name="description<?php echo $intCounter; ?>" id="description<?php echo $intCounter; ?>" value="<?php echo htmlentities($cat_item->category_description); ?>" /> 623 <input type="hidden" name="icon<?php echo $intCounter; ?>" id="icon<?php echo $intCounter; ?>" value="0" /> 624 <input type="hidden" name="position<?php echo $intCounter; ?>" id="position<?php echo $intCounter; ?>" value="<?php echo $intCounter; ?>" /> 625 <input type="hidden" name="linktype<?php echo $intCounter; ?>" id="linktype<?php echo $intCounter; ?>" value="category" /> 626 <input type="hidden" name="anchortitle<?php echo $intCounter; ?>" id="anchortitle<?php echo $intCounter; ?>" value="<?php echo htmlentities($cat_item->cat_name); ?>" /> 627 <input type="hidden" name="newwindow<?php echo $intCounter; ?>" id="newwindow<?php echo $intCounter; ?>" value="0" /> 628 629 <?php $parentli = $cat_item->cat_ID; ?> 630 <?php $intCounter++; ?> 631 <?php 632 633 //Recursive function 634 $intCounter = wp_custom_navigation_default_sub_items($cat_item->cat_ID, $intCounter, $parentli, 'categories','menu'); 635 636 636 ?> 637 637 638 <li id="menu-<?php echo $intCounter; ?>" value="<?php echo $intCounter; ?>"> 639 <dl> 640 <dt> 641 <span class="title"><?php echo $cat_item->cat_name; ?></span> 642 <span class="controls"> 643 <span class="type">category</span> 644 <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> 645 <a id="remove<?php echo $intCounter; ?>" onclick="removeitem(<?php echo $intCounter; ?>)" value="<?php echo $intCounter; ?>"> 646 <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" /> 647 </a> 648 <a target="_blank" href="<?php echo get_category_link($cat_item->cat_ID); ?>"> 649 <img alt="View Page" title="View Page" src="<?php echo get_bloginfo('url'); ?>/wp-admin/images/ico-viewpage.png" /> 650 </a> 651 </span> 652 653 </dt> 654 </dl> 655 <a class="hide" href="<?php echo get_category_link($cat_item->cat_ID); ?>"><span class="title"><?php echo $cat_item->cat_name; ?></span> 656 <?php 657 $use_cats_raw = get_option('wp_settings_custom_nav_descriptions'); 658 $use_cats = strtolower($use_cats_raw); 659 if ($use_cats == 'yes') { ?> 660 <br/> <span><?php echo $cat_item->category_description; ?></span> 661 <?php } ?> 662 </a> 663 <input type="hidden" name="postmenu<?php echo $intCounter; ?>" id="postmenu<?php echo $intCounter; ?>" value="<?php echo $cat_item->cat_ID; ?>" /> 664 <input type="hidden" name="parent<?php echo $intCounter; ?>" id="parent<?php echo $intCounter; ?>" value="0" /> 665 <input type="hidden" name="title<?php echo $intCounter; ?>" id="title<?php echo $intCounter; ?>" value="<?php echo htmlentities($cat_item->cat_name); ?>" /> 666 <input type="hidden" name="linkurl<?php echo $intCounter; ?>" id="linkurl<?php echo $intCounter; ?>" value="<?php echo get_category_link($cat_item->cat_ID); ?>" /> 667 <input type="hidden" name="description<?php echo $intCounter; ?>" id="description<?php echo $intCounter; ?>" value="<?php echo htmlentities($cat_item->category_description); ?>" /> 668 <input type="hidden" name="icon<?php echo $intCounter; ?>" id="icon<?php echo $intCounter; ?>" value="0" /> 669 <input type="hidden" name="position<?php echo $intCounter; ?>" id="position<?php echo $intCounter; ?>" value="<?php echo $intCounter; ?>" /> 670 <input type="hidden" name="linktype<?php echo $intCounter; ?>" id="linktype<?php echo $intCounter; ?>" value="category" /> 671 <input type="hidden" name="anchortitle<?php echo $intCounter; ?>" id="anchortitle<?php echo $intCounter; ?>" value="<?php echo htmlentities($cat_item->cat_name); ?>" /> 672 <input type="hidden" name="newwindow<?php echo $intCounter; ?>" id="newwindow<?php echo $intCounter; ?>" value="0" /> 673 674 <?php $parentli = $cat_item->cat_ID; ?> 675 <?php $intCounter++; ?> 676 <?php 677 678 //Recursive function 679 $intCounter = wp_custom_navigation_default_sub_items($cat_item->cat_ID, $intCounter, $parentli, 'categories','menu'); 680 681 ?> 682 683 </li> 684 685 <?php 686 } 687 //Sidebar Menu 688 elseif ($type == 'default') 689 { 690 ?> 691 <li> 692 <dl> 693 <dt> 694 <?php 695 $post_text = htmlentities($cat_item->cat_name); 696 $post_url = get_category_link($cat_item->cat_ID); 697 $post_id = $cat_item->cat_ID; 698 $post_parent_id = $cat_item->parent; 699 $description = htmlentities(strip_tags($cat_item->description)); 700 ?> 701 <?php $templatedir = get_bloginfo('url'); ?> 702 <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> 703 </dl> 704 <?php $parentli = $cat_item->cat_ID; ?> 705 <?php $intCounter++; ?> 706 <?php 707 //Recursive function 708 $intCounter = wp_custom_navigation_default_sub_items($cat_item->cat_ID, $intCounter, $parentli, 'categories','default'); 709 ?> 710 711 </li> 712 638 </li> 639 640 <?php 641 } elseif ($type == 'default') { 642 // Sidebar Menu 643 ?> 644 <li> 645 <dl> 646 <dt> 713 647 <?php 714 } 648 $post_text = htmlentities($cat_item->cat_name); 649 $post_url = get_category_link($cat_item->cat_ID); 650 $post_id = $cat_item->cat_ID; 651 $post_parent_id = $cat_item->parent; 652 $description = htmlentities(strip_tags($cat_item->description)); 653 ?> 654 <?php $templatedir = get_bloginfo('url'); ?> 655 <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> 656 </dl> 657 <?php $parentli = $cat_item->cat_ID; ?> 658 <?php $intCounter++; ?> 659 <?php 660 //Recursive function 661 $intCounter = wp_custom_navigation_default_sub_items($cat_item->cat_ID, $intCounter, $parentli, 'categories','default'); 662 ?> 663 664 </li> 665 666 <?php 715 667 } 716 668 } 717 }718 else719 {720 echo 'Not Found';721 669 } 722 670 … … 729 677 $counter = $intCounter; 730 678 731 //Custom Menu 732 if ($output_type == 'menu') 733 { 679 // Custom Menu 680 if ($output_type == 'menu') { 734 681 $sub_args = array( 735 682 'child_of' => $childof, 736 683 'hide_empty' => false, 737 684 'parent' => $childof); 738 } 739 //Sidebar Menu 740 elseif ($output_type == 'default') 741 { 685 } elseif ($output_type == 'default') { 686 // Sidebar Menu 742 687 $sub_args = array( 743 688 'child_of' => $childof, … … 745 690 'parent' => $childof); 746 691 } 747 else 748 { 749 750 } 751 752 //Get Sub Category Items 753 if ($type == 'categories') 754 { 692 693 if ( $type == 'categories' ) { 694 // Get Sub Category Items 755 695 $sub_array = get_categories($sub_args); 756 } 757 //Get Sub Page Items 758 elseif ($type == 'pages') 759 { 696 } elseif ($type == 'pages') { 697 // Get Sub Page Items 760 698 $sub_array = get_pages($sub_args); 761 } 762 763 764 if ($sub_array) 765 { 699 } else { 700 $sub_array = array(); 701 } 702 703 704 if ( $sub_array ) { 766 705 ?> 767 706 … … 769 708 770 709 <?php 771 //DISPLAY Loop 772 foreach ($sub_array as $sub_item) 773 { 710 // Display Loop 711 foreach ( $sub_array as $sub_item ) { 774 712 //Prepare Menu Data 775 713 //Category Menu Item 776 if ($type == 'categories') 777 { 714 if ( $type == 'categories' ) { 778 715 $link = get_category_link($sub_item->cat_ID); 779 716 $title = htmlentities($sub_item->cat_name); … … 783 720 $appendtype = 'Category'; 784 721 $description = htmlentities(strip_tags($sub_item->description)); 785 } 786 //Page Menu Item 787 elseif ($type == 'pages') 788 { 722 } elseif ( $type == 'pages' ) { 723 //Page Menu Item 789 724 $link = get_permalink($sub_item->ID); 790 725 $title = htmlentities($sub_item->post_title); … … 794 729 $appendtype = 'Page'; 795 730 $description = htmlentities(get_post_meta($itemid, 'page-description', true)); 796 } 797 //Custom Menu Item 798 else 799 { 731 } else { 732 // Custom Menu Item 800 733 $title = ''; 801 734 $linktype = 'custom'; … … 803 736 } 804 737 805 //Custom Menu 806 if ($output_type == 'menu') 807 { 738 // Custom Menu 739 if ( $output_type == 'menu' ) { 808 740 ?> 809 741 <li id="menu-<?php echo $counter; ?>" value="<?php echo $counter; ?>"> … … 847 779 </li> 848 780 <?php 849 } 850 //Sidebar Menu 851 elseif ($output_type == 'default') 852 { 853 781 } elseif ($output_type == 'default') { 782 // Sidebar Menu 854 783 ?> 855 784 <li> … … 880 809 881 810 return $counter; 882 883 811 } 884 812 … … 888 816 889 817 function get_children_menu_elements($childof, $intCounter, $parentli, $type, $menu_id, $table_name) { 818 global $wpdb; 890 819 891 820 $counter = $intCounter; 892 821 893 global $wpdb;894 895 896 897 822 //Get Sub Category Items 898 if ($type == 'categories') 899 { 823 if ( $type == 'categories' ) { 900 824 $sub_args = array( 901 825 'child_of' => $childof, … … 913 837 $sub_array = get_pages($sub_args); 914 838 915 } 916 else { 917 918 } 919 920 if ($sub_array) 921 { 839 } else { 840 $sub_array = array(); 841 } 842 843 if ( $sub_array ) { 922 844 //DISPLAY Loop 923 foreach ($sub_array as $sub_item) 924 { 925 if (isset($sub_item->parent)) { 845 foreach ( $sub_array as $sub_item ) { 846 if ( isset($sub_item->parent) ) { 926 847 $sub_item_parent = $sub_item->parent; 927 } 928 elseif (isset($sub_item->post_parent)) { 848 } elseif (isset($sub_item->post_parent)) { 929 849 $sub_item_parent = $sub_item->post_parent; 930 850 } 931 else { 932 } 933 //Is child 934 if ($sub_item_parent == $childof) 935 { 851 852 // Is child 853 if ( $sub_item_parent == $childof ) { 936 854 //Prepare Menu Data 937 855 //Category Menu Item 938 if ($type == 'categories') 939 { 856 if ( $type == 'categories' ) { 940 857 $link = get_category_link($sub_item->cat_ID); 941 858 $title = htmlentities($sub_item->cat_name); … … 946 863 } 947 864 //Page Menu Item 948 elseif ($type == 'pages') 949 { 865 elseif ( $type == 'pages' ) { 950 866 $link = get_permalink($sub_item->ID); 951 867 $title = htmlentities($sub_item->post_title); … … 956 872 } 957 873 //Custom Menu Item 958 else 959 { 874 else { 960 875 $title = ''; 961 876 $linktype = 'custom'; … … 968 883 if ($wp_result > 0 && isset($wp_result[0]->id)) { 969 884 $parent_id = $wp_result[0]->id; 970 } 971 else { 885 } else { 972 886 //$parent_id = 0; 973 887 } … … 980 894 $counter = get_children_menu_elements($itemid, $counter, $parent_id, $type, $menu_id, $table_name); 981 895 } 982 //Do nothing983 else {984 985 }986 896 } 987 897 } … … 989 899 } 990 900 991 992 901 ?>
Note: See TracChangeset
for help on using the changeset viewer.