From 4c5727bbf2cc5e7a3eb80a41acd8a76c07ed5044 Mon Sep 17 00:00:00 2001 From: dgnorrod <139880719+dgnorrod@users.noreply.github.com> Date: Mon, 14 Aug 2023 13:44:35 -0400 Subject: [PATCH 1/3] New Filter ep_highlight_number_of_fragments. Add to ./includes/classes/Feature/Search/Search.php a new filter to set the maximum number of fragments to highlight. --- includes/classes/Feature/Search/Search.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/includes/classes/Feature/Search/Search.php b/includes/classes/Feature/Search/Search.php index 42a714830a..bbc40b9d3a 100644 --- a/includes/classes/Feature/Search/Search.php +++ b/includes/classes/Feature/Search/Search.php @@ -237,7 +237,15 @@ public function add_search_highlight_tags( $formatted_args, $args ) { 'pre_tags' => [ $opening_tag ], 'post_tags' => [ $closing_tag ], 'type' => 'plain', - 'number_of_fragments' => 0, + /** + * Filter the maximum number of fragments highlighted for a searched field. + * + * @since 5.0.0 + * @hook ep_highlight_number_of_fragments + * @param {string} $field Search field being setup. + * @return {int} New maximum number of fragments to highlight for the searched field. + */ + 'number_of_fragments' => apply_filters( 'ep_highlight_number_of_fragments', 0, $field ), ]; } From c961ac64166163625bee5ec676626aaed59f14b9 Mon Sep 17 00:00:00 2001 From: dgnorrod <139880719+dgnorrod@users.noreply.github.com> Date: Mon, 18 Sep 2023 09:02:25 -0400 Subject: [PATCH 2/3] Corrected comments to include max_fragments parameter. --- includes/classes/Feature/Search/Search.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/includes/classes/Feature/Search/Search.php b/includes/classes/Feature/Search/Search.php index bbc40b9d3a..0297c0191f 100644 --- a/includes/classes/Feature/Search/Search.php +++ b/includes/classes/Feature/Search/Search.php @@ -242,8 +242,9 @@ public function add_search_highlight_tags( $formatted_args, $args ) { * * @since 5.0.0 * @hook ep_highlight_number_of_fragments - * @param {string} $field Search field being setup. - * @return {int} New maximum number of fragments to highlight for the searched field. + * @param {int} $max_fragments Maximum number of fragments for field. + * @param {string} $field Search field being setup. + * @return {int} New maximum number of fragments to highlight for the searched field. */ 'number_of_fragments' => apply_filters( 'ep_highlight_number_of_fragments', 0, $field ), ]; From 7bb0cb6726e0078103214d20c59be802091c41a6 Mon Sep 17 00:00:00 2001 From: Felipe Elia Date: Wed, 4 Oct 2023 18:11:51 -0300 Subject: [PATCH 3/3] Fix lint and adjust `@since` tag --- includes/classes/Feature/Search/Search.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/includes/classes/Feature/Search/Search.php b/includes/classes/Feature/Search/Search.php index 0297c0191f..7d15aaf353 100644 --- a/includes/classes/Feature/Search/Search.php +++ b/includes/classes/Feature/Search/Search.php @@ -240,10 +240,10 @@ public function add_search_highlight_tags( $formatted_args, $args ) { /** * Filter the maximum number of fragments highlighted for a searched field. * - * @since 5.0.0 + * @since 4.7.2 * @hook ep_highlight_number_of_fragments - * @param {int} $max_fragments Maximum number of fragments for field. - * @param {string} $field Search field being setup. + * @param {int} $max_fragments Maximum number of fragments for field. + * @param {string} $field Search field being setup. * @return {int} New maximum number of fragments to highlight for the searched field. */ 'number_of_fragments' => apply_filters( 'ep_highlight_number_of_fragments', 0, $field ),