Make WordPress Core


Ignore:
Timestamp:
01/29/2018 10:09:55 PM (8 years ago)
Author:
westonruter
Message:

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

Props audrasjb, westonruter.
Fixes #42991.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-customize-nav-menus.php

    r42343 r42611  
    382382                    'object_id'  => intval( $term->term_id ),
    383383                    'url'        => get_term_link( intval( $term->term_id ), $term->taxonomy ),
     384                );
     385            }
     386        }
     387
     388        // Add "Home" link if search term matches. Treat as a page, but switch to custom on add.
     389        if ( isset( $args['s'] ) ) {
     390            $title = _x( 'Home', 'nav menu home label' );
     391            $matches = function_exists( 'mb_stripos' ) ? false !== mb_stripos( $title, $args['s'] ) : false !== stripos( $title, $args['s'] );
     392            if ( $matches ) {
     393                $items[] = array(
     394                    'id'         => 'home',
     395                    'title'      => $title,
     396                    'type'       => 'custom',
     397                    'type_label' => __( 'Custom Link' ),
     398                    'object'     => '',
     399                    'url'        => home_url(),
    384400                );
    385401            }
Note: See TracChangeset for help on using the changeset viewer.