WordPress.org

Make WordPress Core


Ignore:
Timestamp:
01/29/2020 12:43:23 AM (18 months ago)
Author:
SergeyBiryukov
Message:

Docs: Improve inline comments per the documentation standards.

Includes minor code layout fixes for better readability.

See #48303.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/nav-menu-template.php

    r47097 r47122  
    7373
    7474    if ( ! in_array( $args['item_spacing'], array( 'preserve', 'discard' ), true ) ) {
    75         // invalid value, fall back to default.
     75        // Invalid value, fall back to default.
    7676        $args['item_spacing'] = $defaults['item_spacing'];
    7777    }
     
    114114    }
    115115
    116     // Get the nav menu based on the requested menu
     116    // Get the nav menu based on the requested menu.
    117117    $menu = wp_get_nav_menu_object( $args->menu );
    118118
    119     // Get the nav menu based on the theme_location
     119    // Get the nav menu based on the theme_location.
    120120    $locations = get_nav_menu_locations();
    121121    if ( ! $menu && $args->theme_location && $locations && isset( $locations[ $args->theme_location ] ) ) {
     
    123123    }
    124124
    125     // get the first menu that has items if we still can't find a menu
     125    // Get the first menu that has items if we still can't find a menu.
    126126    if ( ! $menu && ! $args->theme_location ) {
    127127        $menus = wp_get_nav_menus();
     
    183183    }
    184184
    185     // Set up the $menu_item variables
     185    // Set up the $menu_item variables.
    186186    _wp_menu_item_classes_by_context( $menu_items );
    187187
     
    195195    }
    196196
    197     // Add the menu-item-has-children class where applicable
     197    // Add the menu-item-has-children class where applicable.
    198198    if ( $menu_items_with_children ) {
    199199        foreach ( $sorted_menu_items as &$menu_item ) {
     
    219219    unset( $sorted_menu_items );
    220220
    221     // Attributes
     221    // Attributes.
    222222    if ( ! empty( $args->menu_id ) ) {
    223223        $wrap_id = $args->menu_id;
     
    390390        }
    391391
    392         // if the menu item corresponds to a taxonomy term for the currently-queried non-hierarchical post object
     392        // If the menu item corresponds to a taxonomy term for the currently queried non-hierarchical post object.
    393393        if ( $wp_query->is_singular && 'taxonomy' == $menu_item->type && in_array( $menu_item->object_id, $possible_object_parents ) ) {
    394394            $active_parent_object_ids[] = (int) $menu_item->object_id;
     
    396396            $active_object              = $queried_object->post_type;
    397397
    398             // if the menu item corresponds to the currently-queried post or taxonomy object
     398            // If the menu item corresponds to the currently queried post or taxonomy object.
    399399        } elseif (
    400400            $menu_item->object_id == $queried_object_id &&
     
    417417
    418418            if ( 'post_type' == $menu_item->type && 'page' == $menu_item->object ) {
    419                 // Back compat classes for pages to match wp_page_menu()
     419                // Back compat classes for pages to match wp_page_menu().
    420420                $classes[] = 'page_item';
    421421                $classes[] = 'page-item-' . $menu_item->object_id;
     
    427427            $active_object              = $menu_item->object;
    428428
    429             // if the menu item corresponds to the currently-queried post type archive
     429            // If the menu item corresponds to the currently queried post type archive.
    430430        } elseif (
    431431            'post_type_archive' == $menu_item->type &&
     
    445445            $active_parent_item_ids[] = (int) $menu_item->menu_item_parent;
    446446
    447             // if the menu item corresponds to the currently-requested URL
     447            // If the menu item corresponds to the currently requested URL.
    448448        } elseif ( 'custom' == $menu_item->object && isset( $_SERVER['HTTP_HOST'] ) ) {
    449449            $_root_relative_current = untrailingslashit( $_SERVER['REQUEST_URI'] );
    450450
    451             //if it is the customize page then it will strips the query var off the url before entering the comparison block.
     451            // If it's the customize page then it will strip the query var off the URL before entering the comparison block.
    452452            if ( is_customize_preview() ) {
    453453                $_root_relative_current = strtok( untrailingslashit( $_SERVER['REQUEST_URI'] ), '?' );
     
    481481
    482482                if ( in_array( home_url(), array( untrailingslashit( $current_url ), untrailingslashit( $_indexless_current ) ) ) ) {
    483                     // Back compat for home link to match wp_page_menu()
     483                    // Back compat for home link to match wp_page_menu().
    484484                    $classes[] = 'current_page_item';
    485485                }
     
    488488                $active_object              = $menu_item->object;
    489489
    490                 // give front page item current-menu-item class when extra query arguments involved
     490                // Give front page item the 'current-menu-item' class when extra query arguments are involved.
    491491            } elseif ( $item_url == $front_page_url && is_front_page() ) {
    492492                $classes[] = 'current-menu-item';
     
    498498        }
    499499
    500         // back-compat with wp_page_menu: add "current_page_parent" to static home page link for any non-page query
     500        // Back-compat with wp_page_menu(): add "current_page_parent" to static home page link for any non-page query.
    501501        if ( ! empty( $home_page_id ) && 'post_type' == $menu_item->type && empty( $wp_query->is_page ) && $home_page_id == $menu_item->object_id ) {
    502502            $classes[] = 'current_page_parent';
     
    509509    $active_parent_object_ids = array_filter( array_unique( $active_parent_object_ids ) );
    510510
    511     // set parent's class
     511    // Set parent's class.
    512512    foreach ( (array) $menu_items as $key => $parent_item ) {
    513513        $classes                                   = (array) $parent_item->classes;
     
    518518            isset( $parent_item->type ) &&
    519519            (
    520                 // ancestral post object
     520                // Ancestral post object.
    521521                (
    522522                    'post_type' == $parent_item->type &&
     
    527527                ) ||
    528528
    529                 // ancestral term
     529                // Ancestral term.
    530530                (
    531531                    'taxonomy' == $parent_item->type &&
     
    555555
    556556        if ( 'post_type' == $parent_item->type && 'page' == $parent_item->object ) {
    557             // Back compat classes for pages to match wp_page_menu()
     557            // Back compat classes for pages to match wp_page_menu().
    558558            if ( in_array( 'current-menu-parent', $classes ) ) {
    559559                $classes[] = 'current_page_parent';
Note: See TracChangeset for help on using the changeset viewer.