Plugin Author
Ajay
(@ajay)
this is because “8” is also a search term and that would get highlighted.
Yes, “8” is the search term, but the result isn’t correct, because it highlights the entity of “-” which is – and contains the “8”.
In the backend it looks like DISPLAYTAUSCH (TOUCH + LCD) -, I don’t get why the entity code get searched too for “8”.
So, can I exclude expressions from the search, so they are ignored in the result? That would be a possible workaround.
ty
Plugin Author
Ajay
(@ajay)
Thanks. That’s clear now by what you mean by entity! Can you show me where on your site you’re seeing this?
I think a possible way to avoid that would be to only highlight terms that are 2 characters and longer.
Are you in a position to make code edits on your site?
Hi, I am using the search only for the cpt price tabs on the page https://www.webillusions.it/unsere-preisliste/. There are listed all prices for smartphone repairs. If someone search for “iphone 8”, it should display all results for “iphone” and “8”, so to highlight terms that are 2 characters and longer would not be a good solution.
I can make code edits, in fact, I am web developer, so coding is not a huge problem.
Page price list: https://snipboard.io/VKjGqi.jpg
Page price list – dev tools: https://snipboard.io/lHMAUD.jpg
Page price list – search result: https://snipboard.io/vfSpH1.jpg
Plugin Author
Ajay
(@ajay)
I’m thinking this might be as simple as decoding the HTML entities.
In this line to first run html_entity_decode
https://github.com/WebberZone/better-search/blob/v3.0.3/includes/utilities.php#L382
$output = preg_replace( $reg_ex, '<span class="bsearch_highlight">$1</span>', html_entity_decode( $input ) );
Plugin Author
Ajay
(@ajay)
Another alternative could be to use word boundaries in the regex:
i.e. using this pattern
'/\b('.implode('|', $keys).')\b(?![^<]*[>])/iu'
Ok, I replaced the code snippet $output = preg_replace( $reg_ex, '<span class="bsearch_highlight">$1</span>', html_entity_decode( $input ) ); in utilities.php of your plugin, it works perfect.
Can I perhaps hook in your plugin to make this change secure for future updates of your plugin?
ty
Plugin Author
Ajay
(@ajay)
Thanks for confirming. I’ve filed an issue in Github to be implemented in v3.1.0
Plugin Author
Ajay
(@ajay)
I’ve added a bug-fix release within Github. Will you be in a position to install and test this?
https://github.com/WebberZone/better-search/releases/tag/v3.1.0-beta1
You can download the zip file there and install it via Plugins > Add New > upload