WebDevStudios / wp-search-with-algolia

Improve search on your site. Autocomplete is included, along with full control over look, feel and relevance.
https://wordpress.org/plugins/wp-search-with-algolia/
138 stars 54 forks source link

Prevent table content from being concatenated #400

Closed rodrigo-arias closed 4 months ago

rodrigo-arias commented 5 months ago

This PR prevents the contents of table blocks from being concatenated by making them unsearchable. A space is added after the cell tags so that they remain independent words after applying wp_strip_all_tags.

Before CleanShot 2024-02-20 at 15 49 55

After CleanShot 2024-02-20 at 15 50 43

tw2113 commented 5 months ago

Hey @rodrigo-arias overall things look good and it makes sense. One question I have is if there's need to cover the closing tags as well: </td> and </th> or if the changes you provide cover those cases enough.

tw2113 commented 5 months ago

Didn't mean to switch them. I meant more handling all 4. :)

rodrigo-arias commented 5 months ago

Hey @tw2113 adding a space in the closing tags as well would generate double spaces (end of one cell and opening of the next). However, your comment led me to update the code to replace the closing tags, this has two advantages:

Before CleanShot 2024-02-20 at 17 01 16

After CleanShot 2024-02-20 at 17 01 46

tw2113 commented 5 months ago

Duly noted on those change reasons.

Overall I approve of this, but we need to figure out a next release plan, so I'm not merging just yet.

tw2113 commented 5 months ago

I'm wondering if it'd maybe be better put in this spot: https://github.com/WebDevStudios/wp-search-with-algolia/blob/2.7.1/includes/class-algolia-utils.php#L199-L203

You'd be doing the exact same thing, essentially in the exact same process, except in one method call earlier, and it'd match up better with other similar code.

rodrigo-arias commented 5 months ago

No rush, I'm not actually using the plugin, I noticed it in my fork and wanted to contribute in case it was useful to someone else. Thank you.