From a8b77a1948590edea0ee64588e721e0c575aa73c Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Mon, 29 Jan 2018 22:10:33 +0000 Subject: [PATCH] Customize: Include nav menu item for Home custom link in search results for "Home". Props audrasjb, westonruter. Fixes #42991. Built from https://develop.svn.wordpress.org/trunk@42611 git-svn-id: http://core.svn.wordpress.org/trunk@42440 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-customize-nav-menus.php | 16 ++++++++++++++++ wp-includes/version.php | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/wp-includes/class-wp-customize-nav-menus.php b/wp-includes/class-wp-customize-nav-menus.php index 9529ce78a3..9ad9421c09 100644 --- a/wp-includes/class-wp-customize-nav-menus.php +++ b/wp-includes/class-wp-customize-nav-menus.php @@ -385,6 +385,22 @@ final class WP_Customize_Nav_Menus { } } + // Add "Home" link if search term matches. Treat as a page, but switch to custom on add. + if ( isset( $args['s'] ) ) { + $title = _x( 'Home', 'nav menu home label' ); + $matches = function_exists( 'mb_stripos' ) ? false !== mb_stripos( $title, $args['s'] ) : false !== stripos( $title, $args['s'] ); + if ( $matches ) { + $items[] = array( + 'id' => 'home', + 'title' => $title, + 'type' => 'custom', + 'type_label' => __( 'Custom Link' ), + 'object' => '', + 'url' => home_url(), + ); + } + } + /** * Filters the available menu items during a search request. * diff --git a/wp-includes/version.php b/wp-includes/version.php index 5097db7db5..1fbd563a5a 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '5.0-alpha-42610'; +$wp_version = '5.0-alpha-42611'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.