From 766de41c58a4de9a967496d8416ac301d22c922a Mon Sep 17 00:00:00 2001 From: ryan Date: Mon, 22 Feb 2010 23:14:03 +0000 Subject: [PATCH] Formatting cleanups. see #11817 git-svn-id: http://svn.automattic.com/wordpress/trunk@13317 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/custom-navigation.php | 515 ++++++++++++------------------ 1 file changed, 212 insertions(+), 303 deletions(-) diff --git a/wp-includes/custom-navigation.php b/wp-includes/custom-navigation.php index 8e328289cc..5fb4abf34f 100644 --- a/wp-includes/custom-navigation.php +++ b/wp-includes/custom-navigation.php @@ -32,35 +32,23 @@ function wp_custom_navigation_get_menu_items( $menu_objects, $key = 'ID' ) { function wp_custom_navigation_setup($override = false) { - $nav_version = '1.1.0'; - //Custom Navigation Menu Setup + // Custom Navigation Menu Setup - //Check for Upgrades - if (get_option('wp_settings_custom_nav_version') <> '') { - $nav_version_in_db = get_option('wp_settings_custom_nav_version'); - } - else { - $nav_version_in_db = '0'; - } - - //Override for menu descriptions - update_option('wp_settings_custom_nav_advanced_options','yes'); - - if(($nav_version_in_db <> $nav_version) || ($override)) - update_option('wp_settings_custom_nav_version',$nav_version); + // Override for menu descriptions + update_option('wp_settings_custom_nav_advanced_options', 'yes'); $custom_menus = get_terms( 'nav_menu', array( 'hide_empty' => false ) ); if ( !empty( $custom_menus ) ) { - foreach( $custom_menus as $menu ) { + foreach ( $custom_menus as $menu ) { $menu_objects = get_objects_in_term( $menu->term_id, 'nav_menu' ); if ( !empty( $menu_objects ) ) { - foreach( $menu_objects as $item ) + foreach ( $menu_objects as $item ) { wp_delete_post( $item ); + } } wp_delete_term( $menu->term_id, 'nav_menu' ); } } - } /*-----------------------------------------------------------------------------------*/ @@ -83,27 +71,17 @@ function wp_custom_navigation_setup($override = false) { /* after_title - html after title is outputted in tag /*-----------------------------------------------------------------------------------*/ -function wp_custom_navigation_output($args = array()) { +function wp_custom_navigation_output( $args = array() ) { - //DEFAULT ARGS - $type = 'frontend'; - $name = 'Menu 1'; - $id = 0; - $desc = 2; - $before_title = ''; - $after_title = ''; + // Defaults + $defaults = array( 'type' => 'frontend', 'name' => 'Menu 1', 'id' => 0, 'desc' => 2, 'before_title' => '', 'after_title' => ''); - if (isset($args)) { - - if ( !is_array($args) ) - parse_str( $args, $args ); - - extract($args); - } + $args = wp_parse_args($args, $defaults); + extract($args, EXTR_SKIP); $menu_objects = get_objects_in_term( $id, 'nav_menu' ); $menu_items = wp_custom_navigation_get_menu_items( $menu_objects, 'menu_order' ); - //Override for menu descriptions + //O verride for menu descriptions $advanced_option_descriptions = get_option('wp_settings_custom_nav_advanced_options'); if ( $advanced_option_descriptions == 'no' ) $desc = 2; @@ -211,14 +189,9 @@ function wp_custom_navigation_output($args = array()) { // 2 widget override do NOT display descriptions // 1 widget override display descriptions // 0 widget override not set - if (($desc == 1) || ($desc == 0) ) - { + if ( ($desc == 1) || ($desc == 0) ) { ?> 0, @@ -490,111 +459,99 @@ function wp_custom_nav_get_pages($counter,$type) { $intCounter = $counter; $parentli = $intCounter; - if ($pages_array) - { - //DISPLAY Loop - foreach ($pages_array as $post) - { + if ( !$pages_array ) { + echo 'Not Found'; + return $intCounter; + } - if ($post->post_parent == 0) - { - //Custom Menu - if ($type == 'menu') - { - $description = get_post_meta($post->ID, 'page-description', true); - ?> + // Display Loop + foreach ( $pages_array as $post ) { + if ($post->post_parent == 0) { + // Custom Menu + if ( $type == 'menu' ) { + $description = get_post_meta($post->ID, 'page-description', true); + ?> - + + + post_title; ?> + + + + + + + + + + + + ID; ?> + ID, $intCounter, $parentli, 'pages', 'menu'); + ?> -
  • -
    -
    - post_title); - $post_url = get_permalink($post->ID); - $post_id = $post->ID; - $post_parent_id = $post->post_parent; +
  • - $description = htmlentities(get_post_meta($post_id, 'page-description', true)); + - + } elseif ( $type == 'default' ) { + // Sidebar Menu + ?> - post_title; ?> Add to Custom Menu - - ID; ?> - - +
    +
    + post_title); + $post_url = get_permalink($post->ID); + $post_id = $post->ID; + $post_parent_id = $post->post_parent; - //Recursive function - $intCounter = wp_custom_navigation_default_sub_items($post_id, $intCounter, $parentli, 'pages', 'default'); + $description = htmlentities(get_post_meta($post_id, 'page-description', true)); - ?> - - + ?> + + post_title; ?> Add to Custom Menu
    +
    + ID; ?> + + + + + '', 'pad_counts' => false ); - - $intCounter = $counter; - //GET all categories + // Get all categories $categories_array = get_categories($category_args); - if ($categories_array) - { - //DISPLAY Loop - foreach ($categories_array as $cat_item) - { + if ( !$categories_array ) { + echo 'Not Found'; + return $intCounter; + } + + // Display Loop + foreach ( $categories_array as $cat_item ) { + + if ( $cat_item->parent == 0 ) { + // Custom Menu + if ( $type == 'menu' ) { + ?> + + - - -
  • -
    -
    - cat_name); - $post_url = get_category_link($cat_item->cat_ID); - $post_id = $cat_item->cat_ID; - $post_parent_id = $cat_item->parent; - $description = htmlentities(strip_tags($cat_item->description)); - ?> - - cat_name; ?> Add to Custom Menu
    -
    - cat_ID; ?> - - cat_ID, $intCounter, $parentli, 'categories','default'); - ?> - -
  • + + +
  • +
    +
    cat_name); + $post_url = get_category_link($cat_item->cat_ID); + $post_id = $cat_item->cat_ID; + $post_parent_id = $cat_item->parent; + $description = htmlentities(strip_tags($cat_item->description)); + ?> + + cat_name; ?> Add to Custom Menu
    +
    + cat_ID; ?> + + cat_ID, $intCounter, $parentli, 'categories','default'); + ?> + +
  • + + $childof, + 'hide_empty' => false, + 'parent' => $childof); + } elseif ($output_type == 'default') { + // Sidebar Menu $sub_args = array( 'child_of' => $childof, 'hide_empty' => false, 'parent' => $childof); } - //Sidebar Menu - elseif ($output_type == 'default') - { - $sub_args = array( - 'child_of' => $childof, - 'hide_empty' => false, - 'parent' => $childof); - } - else - { - } - - //Get Sub Category Items - if ($type == 'categories') - { + if ( $type == 'categories' ) { + // Get Sub Category Items $sub_array = get_categories($sub_args); - } - //Get Sub Page Items - elseif ($type == 'pages') - { + } elseif ($type == 'pages') { + // Get Sub Page Items $sub_array = get_pages($sub_args); + } else { + $sub_array = array(); } - if ($sub_array) - { + if ( $sub_array ) { ?>