WordPress.org

Make WordPress Core


Ignore:
Timestamp:
08/19/2019 04:06:15 AM (12 months ago)
Author:
SergeyBiryukov
Message:

Menus: Trim whitespace from custom link URLs.

Props majemedia, SergeyBiryukov.
Merges [45655] and [45656] to the 5.2 branch.
Fixes #47723.

Location:
branches/5.2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.2

  • branches/5.2/src/wp-includes/nav-menu.php

    r44167 r45832  
    457457    $original_parent = 0 < $menu_item_db_id ? get_post_field( 'post_parent', $menu_item_db_id ) : 0;
    458458
    459     if ( 'custom' != $args['menu-item-type'] ) {
    460         /* if non-custom menu item, then:
    461             * use original object's URL
    462             * blank default title to sync with original object's
    463         */
     459    if ( 'custom' === $args['menu-item-type'] ) {
     460        // If custom menu item, trim the URL.
     461        $args['menu-item-url'] = trim( $args['menu-item-url'] );
     462    } else {
     463        /*
     464         * If non-custom menu item, then:
     465         * - use the original object's URL.
     466         * - blank default title to sync with the original object's title.
     467         */
    464468
    465469        $args['menu-item-url'] = '';
Note: See TracChangeset for help on using the changeset viewer.