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

Filter to set number of fragments #3579

Closed
1 task done
dgnorrod opened this issue Aug 7, 2023 · 3 comments
Closed
1 task done

Filter to set number of fragments #3579

dgnorrod opened this issue Aug 7, 2023 · 3 comments
Milestone

Comments

@dgnorrod
Copy link
Contributor

dgnorrod commented Aug 7, 2023

Is your enhancement related to a problem? Please describe.

I would like a convenience filter to set the number of fragments for all or any fields.

Designs

Change includes/classes/Feature/Search/Search.php from:

$formatted_args['highlight']['fields'][ $field ] = [
				'pre_tags'            => [ $opening_tag ],
				'post_tags'           => [ $closing_tag ],
				'type'                => 'plain',
				'number_of_fragments' => 0,
			];

To:

$formatted_args['highlight']['fields'][ $field ] = [
				'pre_tags'            => [ $opening_tag ],
				'post_tags'           => [ $closing_tag ],
				'type'                => 'plain',
				'number_of_fragments' => apply_filters( 'ep_highlight_number_of_fragments', 0, $field ),
			];

Describe alternatives you've considered

I have also considered modifying the formatted args, but this seems easier.

Code of Conduct

  • I agree to follow this project's Code of Conduct

Tasks

Preview Give feedback
No tasks being tracked yet.
@felipeelia
Copy link
Member

Hi @dgnorrod, thanks for the suggestion! Do you want to open a PR with that change? If so, don't forget to add the docblock there too, okay? Thanks!

@felipeelia felipeelia added this to the 5.0.0 milestone Aug 10, 2023
@dgnorrod
Copy link
Contributor Author

I will.

@felipeelia
Copy link
Member

Closed by #3681

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants