WordPress.org

Make WordPress Core


Ignore:
Timestamp:
01/30/2018 02:45:55 PM (3 years ago)
Author:
SergeyBiryukov
Message:

Customize: Include nav menu item for Home custom link in search results for "Home".

Props audrasjb, westonruter.
Merges [42611] to the 4.9 branch.
Fixes #42991.

Location:
branches/4.9
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.9

  • branches/4.9/src/wp-includes/class-wp-customize-nav-menus.php

    r42149 r42621  
    367367                    'object_id'  => intval( $term->term_id ),
    368368                    'url'        => get_term_link( intval( $term->term_id ), $term->taxonomy ),
     369                );
     370            }
     371        }
     372
     373        // Add "Home" link if search term matches. Treat as a page, but switch to custom on add.
     374        if ( isset( $args['s'] ) ) {
     375            $title = _x( 'Home', 'nav menu home label' );
     376            $matches = function_exists( 'mb_stripos' ) ? false !== mb_stripos( $title, $args['s'] ) : false !== stripos( $title, $args['s'] );
     377            if ( $matches ) {
     378                $items[] = array(
     379                    'id'         => 'home',
     380                    'title'      => $title,
     381                    'type'       => 'custom',
     382                    'type_label' => __( 'Custom Link' ),
     383                    'object'     => '',
     384                    'url'        => home_url(),
    369385                );
    370386            }
Note: See TracChangeset for help on using the changeset viewer.