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/
146 stars 55 forks source link

Instantsearch template is not honoring the setting to remove the powered by Algolia badge #395

Closed KZeni closed 9 months ago

KZeni commented 9 months ago

I've enabled the setting to remove the Algolia logo as my search is no longer a free tier, but the search results page (instantsearch.php) still shows the logo.

As an aside, the site does have autocomplete turned off to help reduce search operations for now, if that happens to change things in any way (doesn't seem like it should.)

Searching this plugin's current files for the powered_by_enabled config setting (see: https://github.com/search?q=repo%3AWebDevStudios%2Fwp-search-with-algolia+powered_by_enabled&type=code) showed it's being used in the autocomplete.php template, but there's no mention of it in the instantsearch.php template.

Is there some way that the:

/* Search powered-by widget */
instantsearch.widgets.poweredBy({
    container: '#algolia-powered-by'
})

code snippet in the instantsearch.php template could check for whether it should be shown via something like:

if ( algolia.powered_by_enabled ) {
    /* Insert whatever applicable code's needed here */
}

as the autocomplete.php template is currently doing?

Just seems weird that the setting to remove the logo is seemingly only removing it from one of the two places it's then shown (unless this issue is unique to this particular site, of course, which doesn't really seem to be the case since the instantsearch.php doesn't seem to check for that setting while the autocomplete.php template does it in a way that looks to only then affects the autocomplete output.)

Of course, one could customize the instantsearch.php template via the theme files to manually remove it, but it'd ideally honor the setting without needing to do so per the autocomplete.php template already doing this (the algolia variable with those config values is being included on the search results page with the powered_by_enabled value being correct, but the template for the search results just doesn't check for it, currently.)

I’ve also posted this at https://wordpress.org/support/topic/instantsearch-template-is-not-honoring-the-setting-to-remove-powered-by-logo/ just in case others encounter this & check the plugin support forum while then possibly not thinking to also check GitHub.

tw2113 commented 9 months ago

Essentially yes to everything above. I checked our file history for instantsearch.php and changes from all the way back in the 2.0.x major release kind of lost this for instantsearch.php. The searchbox for previous versions of InstantsearchJS had a "poweredBy" boolean parameter.

So something like this should suffice:

if (algolia.powered_by_enabled) {
    search.addWidget(
        instantsearch.widgets.poweredBy({
            container: '#algolia-powered-by'
        }),
    )
}

I'm kind of thinking right in this spot here: https://github.com/WebDevStudios/wp-search-with-algolia/blob/main/templates/instantsearch.php#L199-L202

One question that I have to ask ourselves with WebDevStudios is how soon and how much do we want to get this out soon, or if we want to bundle it in with some other things.

tw2113 commented 9 months ago

Early PR for whenever we're ready to merge: https://github.com/WebDevStudios/wp-search-with-algolia/pull/396

KZeni commented 9 months ago

Ah, that makes sense!

It's not the highest priority item on my end, but seemed like a bug worth noting nonetheless. Doesn't matter much to me if it ends up being better on your end to bundle with stuff in a larger update. 👍

KZeni commented 9 months ago

Looks like the release of 2.7.1 means this can be closed (https://github.com/WebDevStudios/wp-search-with-algolia/commit/f297c35bd20460322d6395c7bab2b631105be08f).

tw2113 commented 9 months ago

Correct and thanks