Make WordPress Core


Ignore:
Timestamp:
07/17/2014 09:13:53 AM (11 years ago)
Author:
DrewAPicture
Message:

Fix syntax for single- and multi-line comments in wp-admin-directory files.

See #28931.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/nav-menus.php

    r28205 r29206  
    5454        break;
    5555    case 'move-down-menu-item' :
    56         // moving down a menu item is the same as moving up the next in order
     56
     57        // Moving down a menu item is the same as moving up the next in order.
    5758        check_admin_referer( 'move-menu_item' );
    5859        $menu_item_id = isset( $_REQUEST['menu-item'] ) ? (int) $_REQUEST['menu-item'] : 0;
     
    6465                $menu_item_data = (array) wp_setup_nav_menu_item( get_post( $menu_item_id ) );
    6566
    66                 // set up the data we need in one pass through the array of menu items
     67                // Set up the data we need in one pass through the array of menu items.
    6768                $dbids_to_orders = array();
    6869                $orders_to_dbids = array();
     
    7677                }
    7778
    78                 // get next in order
     79                // Get next in order.
    7980                if (
    8081                    isset( $orders_to_dbids[$dbids_to_orders[$menu_item_id] + 1] )
     
    8384                    $next_item_data = (array) wp_setup_nav_menu_item( get_post( $next_item_id ) );
    8485
    85                     // if not siblings of same parent, bubble menu item up but keep order
     86                    // If not siblings of same parent, bubble menu item up but keep order.
    8687                    if (
    8788                        ! empty( $menu_item_data['menu_item_parent'] ) &&
     
    103104                        }
    104105
    105                     // make menu item a child of its next sibling
     106                    // Make menu item a child of its next sibling.
    106107                    } else {
    107108                        $next_item_data['menu_order'] = $next_item_data['menu_order'] - 1;
     
    115116                    }
    116117
    117                 // the item is last but still has a parent, so bubble up
     118                // The item is last but still has a parent, so bubble up.
    118119                } elseif (
    119120                    ! empty( $menu_item_data['menu_item_parent'] ) &&
     
    137138                $menu_item_data = (array) wp_setup_nav_menu_item( get_post( $menu_item_id ) );
    138139
    139                 // set up the data we need in one pass through the array of menu items
     140                // Set up the data we need in one pass through the array of menu items.
    140141                $dbids_to_orders = array();
    141142                $orders_to_dbids = array();
     
    149150                }
    150151
    151                 // if this menu item is not first
     152                // If this menu item is not first.
    152153                if ( ! empty( $dbids_to_orders[$menu_item_id] ) && ! empty( $orders_to_dbids[$dbids_to_orders[$menu_item_id] - 1] ) ) {
    153154
    154                     // if this menu item is a child of the previous
     155                    // If this menu item is a child of the previous.
    155156                    if (
    156157                        ! empty( $menu_item_data['menu_item_parent'] ) &&
     
    165166                            $parent_data = (array) $parent_object;
    166167
    167                             // if there is something before the parent and parent a child of it, make menu item a child also of it
     168                            /*
     169                             * If there is something before the parent and parent a child of it,
     170                             * make menu item a child also of it.
     171                             */
    168172                            if (
    169173                                ! empty( $dbids_to_orders[$parent_db_id] ) &&
     
    173177                                $menu_item_data['menu_item_parent'] = $parent_data['menu_item_parent'];
    174178
    175                             // else if there is something before parent and parent not a child of it, make menu item a child of that something's parent
     179                            /*
     180                             * Else if there is something before parent and parent not a child of it,
     181                             * make menu item a child of that something's parent
     182                             */
    176183                            } elseif (
    177184                                ! empty( $dbids_to_orders[$parent_db_id] ) &&
     
    184191                                    $menu_item_data['menu_item_parent'] = 0;
    185192
    186                             // else there isn't something before the parent
     193                            // Else there isn't something before the parent.
    187194                            } else {
    188195                                $menu_item_data['menu_item_parent'] = 0;
    189196                            }
    190197
    191                             // set former parent's [menu_order] to that of menu-item's
     198                            // Set former parent's [menu_order] to that of menu-item's.
    192199                            $parent_data['menu_order'] = $parent_data['menu_order'] + 1;
    193200
    194                             // set menu-item's [menu_order] to that of former parent
     201                            // Set menu-item's [menu_order] to that of former parent.
    195202                            $menu_item_data['menu_order'] = $menu_item_data['menu_order'] - 1;
    196203
    197                             // save changes
     204                            // Save changes.
    198205                            update_post_meta( $menu_item_data['ID'], '_menu_item_menu_item_parent', (int) $menu_item_data['menu_item_parent'] );
    199206                            wp_update_post($menu_item_data);
     
    201208                        }
    202209
    203                     // else this menu item is not a child of the previous
     210                    // Else this menu item is not a child of the previous.
    204211                    } elseif (
    205212                        empty( $menu_item_data['menu_order'] ) ||
     
    209216                        $orders_to_dbids[$dbids_to_orders[$menu_item_id] - 1] != $menu_item_data['menu_item_parent']
    210217                    ) {
    211                         // just make it a child of the previous; keep the order
     218                        // Just make it a child of the previous; keep the order.
    212219                        $menu_item_data['menu_item_parent'] = (int) $orders_to_dbids[$dbids_to_orders[$menu_item_id] - 1];
    213220                        update_post_meta( $menu_item_data['ID'], '_menu_item_menu_item_parent', (int) $menu_item_data['menu_item_parent'] );
     
    233240            $deletion = wp_delete_nav_menu( $nav_menu_selected_id );
    234241        } else {
    235             // Reset the selected menu
     242            // Reset the selected menu.
    236243            $nav_menu_selected_id = 0;
    237244            unset( $_REQUEST['menu'] );
     
    267274        check_admin_referer( 'update-nav_menu', 'update-nav-menu-nonce' );
    268275
    269         // Remove menu locations that have been unchecked
     276        // Remove menu locations that have been unchecked.
    270277        foreach ( $locations as $location => $description ) {
    271278            if ( ( empty( $_POST['menu-locations'] ) || empty( $_POST['menu-locations'][ $location ] ) ) && isset( $menu_locations[ $location ] ) && $menu_locations[ $location ] == $nav_menu_selected_id )
     
    273280        }
    274281
    275         // Merge new and existing menu locations if any new ones are set
     282        // Merge new and existing menu locations if any new ones are set.
    276283        if ( isset( $_POST['menu-locations'] ) ) {
    277284            $new_menu_locations = array_map( 'absint', $_POST['menu-locations'] );
     
    279286        }
    280287
    281         // Set menu locations
     288        // Set menu locations.
    282289        set_theme_mod( 'nav_menu_locations', $menu_locations );
    283290
    284         // Add Menu
     291        // Add Menu.
    285292        if ( 0 == $nav_menu_selected_id ) {
    286293            $new_menu_title = trim( esc_html( $_POST['menu-name'] ) );
     
    315322                        set_theme_mod( 'nav_menu_locations', $menu_locations );
    316323                    }
     324
    317325                    // $messages[] = '<div id="message" class="updated"><p>' . sprintf( __( '<strong>%s</strong> has been created.' ), $nav_menu_selected_title ) . '</p></div>';
    318326                    wp_redirect( admin_url( 'nav-menus.php?menu=' . $_nav_menu_selected_id ) );
     
    323331            }
    324332
    325         // Update existing menu
     333        // Update existing menu.
    326334        } else {
    327335
     
    345353            }
    346354
    347             // Update menu items
     355            // Update menu items.
    348356            if ( ! is_wp_error( $_menu_object ) ) {
    349357                $messages = array_merge( $messages, wp_nav_menu_update_menu_items( $nav_menu_selected_id, $nav_menu_selected_title ) );
     
    372380}
    373381
    374 // Get all nav menus
     382// Get all nav menus.
    375383$nav_menus = wp_get_nav_menus( array('orderby' => 'name') );
    376384$menu_count = count( $nav_menus );
     
    381389$locations_screen = ( isset( $_GET['action'] ) && 'locations' == $_GET['action'] ) ? true : false;
    382390
    383 // If we have one theme location, and zero menus, we take them right into editing their first menu
     391/*
     392 * If we have one theme location, and zero menus, we take them right
     393 * into editing their first menu.
     394 */
    384395$page_count = wp_count_posts( 'page' );
    385396$one_theme_location_no_menus = ( 1 == count( get_registered_nav_menus() ) && ! $add_new_screen && empty( $nav_menus ) && ! empty( $page_count->publish ) ) ? true : false;
     
    405416wp_localize_script( 'nav-menu', 'menus', $nav_menus_l10n );
    406417
    407 // Redirect to add screen if there are no menus and this users has either zero, or more than 1 theme locations
     418/*
     419 * Redirect to add screen if there are no menus and this users has either zero,
     420 * or more than 1 theme locations.
     421 */
    408422if ( 0 == $menu_count && ! $add_new_screen && ! $one_theme_location_no_menus )
    409423    wp_redirect( admin_url( 'nav-menus.php?action=edit&menu=0' ) );
    410424
    411 // Get recently edited nav menu
     425// Get recently edited nav menu.
    412426$recently_edited = absint( get_user_option( 'nav_menu_recently_edited' ) );
    413427if ( empty( $recently_edited ) && is_nav_menu( $nav_menu_selected_id ) )
    414428    $recently_edited = $nav_menu_selected_id;
    415429
    416 // Use $recently_edited if none are selected
     430// Use $recently_edited if none are selected.
    417431if ( empty( $nav_menu_selected_id ) && ! isset( $_GET['menu'] ) && is_nav_menu( $recently_edited ) )
    418432    $nav_menu_selected_id = $recently_edited;
    419433
    420 // On deletion of menu, if another menu exists, show it
     434// On deletion of menu, if another menu exists, show it.
    421435if ( ! $add_new_screen && 0 < $menu_count && isset( $_GET['action'] ) && 'delete' == $_GET['action'] )
    422436    $nav_menu_selected_id = $nav_menus[0]->term_id;
    423437
    424 // Set $nav_menu_selected_id to 0 if no menus
     438// Set $nav_menu_selected_id to 0 if no menus.
    425439if ( $one_theme_location_no_menus ) {
    426440    $nav_menu_selected_id = 0;
    427441} elseif ( empty( $nav_menu_selected_id ) && ! empty( $nav_menus ) && ! $add_new_screen ) {
    428     // if we have no selection yet, and we have menus, set to the first one in the list
     442    // if we have no selection yet, and we have menus, set to the first one in the list.
    429443    $nav_menu_selected_id = $nav_menus[0]->term_id;
    430444}
    431445
    432 // Update the user's setting
     446// Update the user's setting.
    433447if ( $nav_menu_selected_id != $recently_edited && is_nav_menu( $nav_menu_selected_id ) )
    434448    update_user_meta( $current_user->ID, 'nav_menu_recently_edited', $nav_menu_selected_id );
     
    440454}
    441455
    442 // Generate truncated menu names
     456// Generate truncated menu names.
    443457foreach( (array) $nav_menus as $key => $_nav_menu ) {
    444458    $nav_menus[$key]->truncated_name = wp_html_excerpt( $_nav_menu->name, 40, '&hellip;' );
    445459}
    446460
    447 // Retrieve menu locations
     461// Retrieve menu locations.
    448462if ( current_theme_supports( 'menus' ) ) {
    449463    $locations = get_registered_nav_menus();
     
    451465}
    452466
    453 // Ensure the user will be able to scroll horizontally
    454 // by adding a class for the max menu depth.
     467/*
     468 * Ensure the user will be able to scroll horizontally
     469 * by adding a class for the max menu depth.
     470 */
    455471global $_wp_nav_menu_max_depth;
    456472$_wp_nav_menu_max_depth = 0;
    457473
    458 // Calling wp_get_nav_menu_to_edit generates $_wp_nav_menu_max_depth
     474// Calling wp_get_nav_menu_to_edit generates $_wp_nav_menu_max_depth.
    459475if ( is_nav_menu( $nav_menu_selected_id ) ) {
    460476    $menu_items = wp_get_nav_menu_items( $nav_menu_selected_id, array( 'post_status' => 'any' ) );
     
    511527        'content' => $editing_menus
    512528    ) );
    513 else : // Locations Tab
     529else : // Locations Tab.
    514530    $locations_overview  = '<p>' . __( 'This screen is used for globally assigning menus to locations defined by your theme.' ) . '</p>';
    515531    $locations_overview .= '<ul><li>' . __( 'To assign menus to one or more theme locations, <strong>select a menu from each location&#8217;s drop down.</strong> When you&#8217;re finished, <strong>click Save Changes</strong>' ) . '</li>';
     
    530546);
    531547
    532 // Get the admin header
     548// Get the admin header.
    533549require_once( ABSPATH . 'wp-admin/admin-header.php' );
    534550?>
     
    645661                            $assigned_locations = array_slice( $locations_assigned_to_this_menu, 0, absint( apply_filters( 'wp_nav_locations_listed_per_menu', 3 ) ) );
    646662
    647                             // Adds ellipses following the number of locations defined in $assigned_locations
     663                            // Adds ellipses following the number of locations defined in $assigned_locations.
    648664                            if ( ! empty( $assigned_locations ) ) {
    649665                                printf( ' (%1$s%2$s)',
Note: See TracChangeset for help on using the changeset viewer.