diff --git a/projects/packages/search/changelog/fix-blaskan_theme_body_class_conflict_with_inline_highlighter b/projects/packages/search/changelog/fix-blaskan_theme_body_class_conflict_with_inline_highlighter new file mode 100644 index 0000000000000..71cd592b7648f --- /dev/null +++ b/projects/packages/search/changelog/fix-blaskan_theme_body_class_conflict_with_inline_highlighter @@ -0,0 +1,4 @@ +Significance: minor +Type: fixed + +Addresses body_class filter fatal in older versions of the Blaskan theme. diff --git a/projects/packages/search/src/inline-search/class-inline-search-highlighter.php b/projects/packages/search/src/inline-search/class-inline-search-highlighter.php index 200b15c629e3d..1a98161233e85 100644 --- a/projects/packages/search/src/inline-search/class-inline-search-highlighter.php +++ b/projects/packages/search/src/inline-search/class-inline-search-highlighter.php @@ -77,10 +77,19 @@ public function process_results( array $results ): void { * @return string The filtered title. */ public function filter_highlighted_title( string $title, ?int $post_id = null ): string { - // o2 is currently rendering tags in post titles, so we need to return the original. - $body_class = get_body_class(); - if ( is_array( $body_class ) && in_array( 'o2', $body_class, true ) ) { - return $title; + $incompatible_themes = array( + 'blaskan', // Blaskan incorrectly uses wp_nav_menu() in body_class filter, causing infinite recursion. + 'p2020', // P2 loads o2 as a plugin, which calls the_title() filter incorrectly. + ); + + $theme = wp_get_theme(); + $theme_name = strtolower( $theme->get( 'Name' ) ); + $theme_template = strtolower( $theme->get_template() ); + + foreach ( $incompatible_themes as $incompatible_theme ) { + if ( $theme_name === $incompatible_theme || $theme_template === $incompatible_theme ) { + return $title; + } } if ( ! $this->is_search_result( $post_id ) ) { diff --git a/projects/plugins/jetpack/changelog/fix-blaskan_theme_body_class_conflict_with_inline_highlighter b/projects/plugins/jetpack/changelog/fix-blaskan_theme_body_class_conflict_with_inline_highlighter new file mode 100644 index 0000000000000..b5a489048b144 --- /dev/null +++ b/projects/plugins/jetpack/changelog/fix-blaskan_theme_body_class_conflict_with_inline_highlighter @@ -0,0 +1,4 @@ +Significance: minor +Type: bugfix + +Addresses body_class filter fatal in older versions of the Blaskan theme. diff --git a/projects/plugins/search/changelog/fix-blaskan_theme_body_class_conflict_with_inline_highlighter b/projects/plugins/search/changelog/fix-blaskan_theme_body_class_conflict_with_inline_highlighter new file mode 100644 index 0000000000000..71cd592b7648f --- /dev/null +++ b/projects/plugins/search/changelog/fix-blaskan_theme_body_class_conflict_with_inline_highlighter @@ -0,0 +1,4 @@ +Significance: minor +Type: fixed + +Addresses body_class filter fatal in older versions of the Blaskan theme.