Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to toggle term counter #3007

Merged
merged 2 commits into from
Oct 11, 2022
Merged

Add option to toggle term counter #3007

merged 2 commits into from
Oct 11, 2022

Conversation

MARQAS
Copy link
Contributor

@MARQAS MARQAS commented Sep 19, 2022

Description of the Change

This PR adds an option to enable/disable the term count option in the Instant results widget.

Closes #2610

How to test the Change

  • By default the counter is enabled
  • Go to ElasticPress features -> Instant results -> Disable the term count option
  • Notice that the number of posts is disabled

Changelog Entry

Added - An option to toggle the term count in Instant results

Credits

Props @MARQAS

Checklist:

  • I agree to follow this project's Code of Conduct.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests pass.

@MARQAS MARQAS self-assigned this Sep 19, 2022
@MARQAS MARQAS marked this pull request as ready for review September 19, 2022 22:07
@MARQAS MARQAS assigned felipeelia and unassigned MARQAS Sep 19, 2022
@MARQAS MARQAS added this to the 4.4.0 milestone Sep 19, 2022
Copy link
Member

@felipeelia felipeelia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a minor change @MARQAS, let me know what you think about it. @JakePT, can I get your review here as well?

Comment on lines 949 to 951
if ( ! empty( $settings['instant-results']['term_count'] ) ) {
$settings['instant-results']['term_count'] = (bool) $settings['instant-results']['term_count'];
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MARQAS couldn't this be simplified just calling

$settings['instant-results']['term_count'] = ! empty( $settings['instant-results']['term_count'] );

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MARQAS @felipeelia Is this function required at all? None of the other Enabled/Disabled settings on the other features have anything like this. Also, sanitising as boolean isn't really worth it as the values are saved as '0' or '1' strings anyway, and the default value is '1' too.

@felipeelia felipeelia merged commit d14cca0 into develop Oct 11, 2022
@felipeelia felipeelia deleted the feature/2610 branch October 11, 2022 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Instant Results: Add option to toggle term count
3 participants