#42991 closed defect (bug) (fixed)
Customizer: Search Menu item not working on Custom Link
Reported by: | monikarao | Owned by: | westonruter |
---|---|---|---|
Milestone: | 4.9.3 | Priority: | normal |
Severity: | normal | Version: | 4.3 |
Component: | Customize | Keywords: | has-patch commit fixed-major |
Focuses: | ui | Cc: |
Description
In Customizer "Search Menu Item Field" is present to search all menu items but it's not working on Custom Links.
Ex. Added "Home" as Custom Link but when searching this "Home" it displayed message "no-result-found".
Attachments (9)
Change History (35)
#3
@
7 years ago
- Keywords has-patch added
Hi @monikarao @melchoyce
I made a patch for this ticket. It works well.
Here is a screenshot of the result.
Cheers,
Jb
This ticket was mentioned in Slack in #core-customize by westonruter. View the logs.
7 years ago
#5
@
7 years ago
- Keywords needs-testing added
- Owner set to melchoyce
- Status changed from new to assigned
This ticket was mentioned in Slack in #core by desrosj. View the logs.
7 years ago
#8
@
7 years ago
- Keywords has-patch needs-testing removed
Thanks for the patch, looking over it I notice it's currently appending the Home
menu item to any search.
It will need an if statement there to make sure the translatable Home
label matches before being appended
#9
@
7 years ago
- Keywords has-patch added
Thanks @Clorith for the review, you're right !
In 42991.2.diff
I added a condition to check if the entered string matches with Home
(translatable).
#10
@
7 years ago
@audrasjb tip: you can use stripos()
instead of strpos()
with multiple strtolower()
calls.
#11
@
7 years ago
- Keywords needs-patch needs-testing added; has-patch removed
On second thought, this perhaps should use mb_stripos()
if possible since the translation string will have multi-byte characters in it. For example compare:
wp> stripos( 'PAPÁ', 'á' ) => bool(false) wp> mb_stripos( 'PAPÁ', 'á' ) => int(3)
I believe you'll have to check if the mb_stripos()
function exists since the multibyte string functions may not be present, and in such case you'll need to use stripos()
. At least, _wp_json_convert_string()
checks for the existence of an mb_*
function prior to using it.
#12
@
7 years ago
Thanks @westonruter for your help, this is very interesting I'm really happy to learn things at the same time I contribute :)
So, here is a new tested patch which seems to work fine. Is this better?
#14
@
7 years ago
@audrasjb I suggest removing some of the duplication, following something like this:
<?php 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( // ... 'title' => $title, // ... ); } }
#15
@
7 years ago
Thanks @westonruter for the suggestion and for this hint. I was wondering if I had to duplicate or not…
Let's roll!
Will send a new version soon.
#16
@
7 years ago
@melchoyce does 42991.5.diff work as you expect?
This ticket was mentioned in Slack in #core-customize by melchoyce. View the logs.
7 years ago
#19
@
7 years ago
- Keywords commit added; needs-testing removed
- Owner changed from melchoyce to westonruter
- Status changed from assigned to accepted
#21
@
7 years ago
- Keywords fixed-major added
- Resolution fixed deleted
- Status changed from closed to reopened
- Version changed from trunk to 4.3
#24
@
7 years ago
Hi @monikarao,
In the past only the patch author would generally get the props, however recently we've indeed started to give props for other contributions as well, including bug reports. I'll make sure to include you in the contributors list for 4.9.3. Thanks for the ticket!
Created Home Custom Link