Make WordPress Core

Changeset 13317


Ignore:
Timestamp:
02/22/2010 11:14:03 PM (17 years ago)
Author:
ryan
Message:

Formatting cleanups. see #11817

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/custom-navigation.php

    r13312 r13317  
    3333function wp_custom_navigation_setup($override = false) {
    3434
    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');
    5139
    5240        $custom_menus = get_terms( 'nav_menu', array( 'hide_empty' => false ) );
    5341        if ( !empty( $custom_menus ) ) {
    54                 foreach( $custom_menus as $menu ) {
     42                foreach ( $custom_menus as $menu ) {
    5543                        $menu_objects = get_objects_in_term( $menu->term_id, 'nav_menu' );
    5644                        if ( !empty( $menu_objects ) ) {
    57                                 foreach( $menu_objects as $item )
     45                                foreach ( $menu_objects as $item ) {
    5846                                        wp_delete_post( $item );
     47                                }
    5948                        }
    6049                        wp_delete_term( $menu->term_id, 'nav_menu' );
    6150                }
    6251        }
    63 
    6452}
    6553
    … …  
    8472/*-----------------------------------------------------------------------------------*/
    8573
    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                 }
     74function 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);
    10381
    10482                $menu_objects = get_objects_in_term( $id, 'nav_menu' );
    10583                $menu_items = wp_custom_navigation_get_menu_items( $menu_objects, 'menu_order' );
    106                 //Override for menu descriptions
     84                //O verride for menu descriptions
    10785                $advanced_option_descriptions = get_option('wp_settings_custom_nav_advanced_options');
    10886                if ( $advanced_option_descriptions == 'no' )
    … …  
    212190                                                                // 1 widget override display descriptions
    213191                                                                // 0 widget override not set
    214                                                                 if (($desc == 1) || ($desc == 0) )
    215                                                                 {
     192                                                                if ( ($desc == 1) || ($desc == 0) ) {
    216193                                                                        ?><span class="nav-description"><?php echo $description; ?></span><?php
    217194                                                                }
    218                                                                 elseif ($desc == 2)
    219                                                                 { }
    220                                                                 else
    221                                                                 { }
    222195                                                        } else {
    223196                                                                // 2 widget override do NOT display descriptions
    … …  
    227200                                                                        ?><span class="nav-description"><?php echo $description; ?></span><?php
    228201                                                                }
    229                                                                 elseif (($desc == 2) || ($desc == 0))
    230                                                                 { }
    231                                                                 else
    232                                                                 { }
    233202                                                        }
    234203
    … …  
    288257//@todo: implement menu heirarchy
    289258//RECURSIVE Sub Menu Items
    290 function wp_custom_navigation_sub_items($post_id,$type,$table_name,$output_type,$menu_id = 0) {
     259function wp_custom_navigation_sub_items($post_id, $type, $table_name, $output_type, $menu_id = 0) {
    291260
    292261        $parent_id = 0;
    … …  
    467436
    468437
    469 //Outputs All Pages and Sub Items
    470 function wp_custom_nav_get_pages($counter,$type) {
     438// Outputs All Pages and Sub Items
     439function wp_custom_nav_get_pages($counter, $type) {
    471440
    472441        $pages_args = array(
    … …  
    491460        $parentli = $intCounter;
    492461
    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
    505513                                        ?>
    506514
    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>
    549526                                        <?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
    555534                                        ?>
    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++; ?>
    584541                                        <?php
    585542
    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
    591552                        }
    592553                }
    593         }
    594         else
    595         {
    596                 echo 'Not Found';
    597554        }
    598555
    … …  
    616573                        'pad_counts'               => false );
    617574
    618 
    619 
    620575        $intCounter = $counter;
    621576
    622         //GET all categories
     577        // Get all categories
    623578        $categories_array = get_categories($category_args);
    624579
    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
    636636                                        ?>
    637637
    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>
    713647                                        <?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
    715667                        }
    716668                }
    717         }
    718         else
    719         {
    720                 echo 'Not Found';
    721669        }
    722670
    … …  
    729677        $counter = $intCounter;
    730678
    731         //Custom Menu
    732         if ($output_type == 'menu')
    733         {
     679        // Custom Menu
     680        if ($output_type == 'menu') {
    734681                $sub_args = array(
    735682                'child_of' => $childof,
    736683                'hide_empty' => false,
    737684                'parent' => $childof);
    738         }
    739         //Sidebar Menu
    740         elseif ($output_type == 'default')
    741         {
     685        } elseif ($output_type == 'default') {
     686                // Sidebar Menu
    742687                $sub_args = array(
    743688                'child_of' => $childof,
    … …  
    745690                'parent' => $childof);
    746691        }
    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
    755695                $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
    760698                $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 ) {
    766705                ?>
    767706
    … …  
    769708
    770709                <?php
    771                 //DISPLAY Loop
    772                 foreach ($sub_array as $sub_item)
    773                 {
     710                // Display Loop
     711                foreach ( $sub_array as $sub_item ) {
    774712                        //Prepare Menu Data
    775713                        //Category Menu Item
    776                         if ($type == 'categories')
    777                         {
     714                        if ( $type == 'categories' ) {
    778715                                $link = get_category_link($sub_item->cat_ID);
    779716                                $title = htmlentities($sub_item->cat_name);
    … …  
    783720                                $appendtype = 'Category';
    784721                                $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
    789724                                $link = get_permalink($sub_item->ID);
    790725                                $title = htmlentities($sub_item->post_title);
    … …  
    794729                                $appendtype = 'Page';
    795730                                $description = htmlentities(get_post_meta($itemid, 'page-description', true));
    796                         }
    797                         //Custom Menu Item
    798                         else
    799                         {
     731                        } else {
     732                                // Custom Menu Item
    800733                                $title = '';
    801734                                $linktype = 'custom';
    … …  
    803736                        }
    804737
    805                         //Custom Menu
    806                         if ($output_type == 'menu')
    807                         {
     738                        // Custom Menu
     739                        if ( $output_type == 'menu' ) {
    808740                                ?>
    809741                                <li id="menu-<?php echo $counter; ?>" value="<?php echo $counter; ?>">
    … …  
    847779                                </li>
    848780                                <?php
    849                         }
    850                         //Sidebar Menu
    851                         elseif ($output_type == 'default')
    852                         {
    853 
     781                        } elseif ($output_type == 'default') {
     782                                // Sidebar Menu
    854783                                ?>
    855784                                <li>
    … …  
    880809
    881810        return $counter;
    882 
    883811}
    884812
    … …  
    888816
    889817function get_children_menu_elements($childof, $intCounter, $parentli, $type, $menu_id, $table_name) {
     818        global $wpdb;
    890819
    891820        $counter = $intCounter;
    892821
    893         global $wpdb;
    894 
    895 
    896 
    897822        //Get Sub Category Items
    898         if ($type == 'categories')
    899         {
     823        if ( $type == 'categories' ) {
    900824                $sub_args = array(
    901825                        'child_of' => $childof,
    … …  
    913837                $sub_array = get_pages($sub_args);
    914838
    915         }
    916         else {
    917 
    918         }
    919 
    920         if ($sub_array)
    921         {
     839        } else {
     840                $sub_array = array();
     841        }
     842
     843        if ( $sub_array ) {
    922844                //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) ) {
    926847                                $sub_item_parent = $sub_item->parent;
    927                         }
    928                         elseif (isset($sub_item->post_parent)) {
     848                        } elseif (isset($sub_item->post_parent)) {
    929849                                $sub_item_parent = $sub_item->post_parent;
    930850                        }
    931                         else {
    932                         }
    933                         //Is child
    934                         if ($sub_item_parent == $childof)
    935                         {
     851
     852                        // Is child
     853                        if ( $sub_item_parent == $childof ) {
    936854                                //Prepare Menu Data
    937855                                //Category Menu Item
    938                                 if ($type == 'categories')
    939                                 {
     856                                if ( $type == 'categories' ) {
    940857                                        $link = get_category_link($sub_item->cat_ID);
    941858                                        $title = htmlentities($sub_item->cat_name);
    … …  
    946863                                }
    947864                                //Page Menu Item
    948                                 elseif ($type == 'pages')
    949                                 {
     865                                elseif ( $type == 'pages' ) {
    950866                                        $link = get_permalink($sub_item->ID);
    951867                                        $title = htmlentities($sub_item->post_title);
    … …  
    956872                                }
    957873                                //Custom Menu Item
    958                                 else
    959                                 {
     874                                else {
    960875                                        $title = '';
    961876                                        $linktype = 'custom';
    … …  
    968883                                if ($wp_result > 0 && isset($wp_result[0]->id)) {
    969884                                        $parent_id = $wp_result[0]->id;
    970                                 }
    971                                 else {
     885                                } else {
    972886                                        //$parent_id = 0;
    973887                                }
    … …  
    980894                                $counter = get_children_menu_elements($itemid, $counter, $parent_id, $type, $menu_id, $table_name);
    981895                        }
    982                         //Do nothing
    983                         else {
    984 
    985                         }
    986896                }
    987897        }
    … …  
    989899}
    990900
    991 
    992901?>
Note: See TracChangeset for help on using the changeset viewer.