From 85a9a39d063d6a56b6b76fdcde342e72b4bff654 Mon Sep 17 00:00:00 2001 From: Konstantin Obenland Date: Wed, 22 Jul 2026 18:05:14 -0500 Subject: [PATCH] Theme Directory: Also search language-agnostic ES fields so themes with a misdetected language remain findable Jetpack Search queries only locale-specific analyzed fields (title.en, content.en, etc.), selected by the language WP.com detected at index time. That detection is unreliable on short theme descriptions, so themes indexed as non-English have no .en fields and can never match a search on wordpress.org/themes. The .default analyzed fields exist on every document, so appending 'default' to the query languages makes those themes findable again without a reindex. Fixes #8376. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_011pfhLmrkpmrMsMMwrZEKJV --- .../theme-directory/query-modifications.php | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/wordpress.org/public_html/wp-content/plugins/theme-directory/query-modifications.php b/wordpress.org/public_html/wp-content/plugins/theme-directory/query-modifications.php index 59fee58bd0..06730b5f2b 100644 --- a/wordpress.org/public_html/wp-content/plugins/theme-directory/query-modifications.php +++ b/wordpress.org/public_html/wp-content/plugins/theme-directory/query-modifications.php @@ -224,6 +224,29 @@ function wporg_themes_restrict_search_to_published( $es_query_args, $query ) { } add_filter( 'jetpack_search_es_query_args', 'wporg_themes_restrict_search_to_published', 10, 2 ); +/** + * Adds the `default` language to the fields Jetpack Search queries against. + * + * Jetpack builds its Elasticsearch query against locale-specific analyzed + * fields only (`title.en`, `content.en`, etc.), chosen by the language WP.com + * detected for each document at index time. That detection is unreliable on + * short theme descriptions, so many themes are indexed as non-English and have + * no `.en` fields at all, making them unfindable in search. The `.default` + * analyzed fields exist on every document regardless of detected language, so + * including them ensures every theme can match. + * + * @param array $languages The languages Jetpack Search will query against. + * @return array + */ +function wporg_themes_search_default_language_fields( $languages ) { + if ( ! in_array( 'default', $languages, true ) ) { + $languages[] = 'default'; + } + + return $languages; +} +add_filter( 'jetpack_search_query_languages', 'wporg_themes_search_default_language_fields' ); + /** * Filters SQL clauses, to prioritize translated themes. *