Making WordPress.org

Changeset 3522


Ignore:
Timestamp:
06/21/2016 02:18:42 PM (9 years ago)
Author:
tellyworth
Message:

Plugin directory: search locale-specific fields when get_locale() is non-English.

English fields are still searched as a low-weighted default, in case translated content is not available.

See #1691, #1692

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/libs/site-search/jetpack-search.php

    r3505 r3522  
    268268        );
    269269
     270        $locale = get_locale();
     271        if ( $locale && substr( $locale, 0, 2 ) !== 'en' ) {
     272            $es_wp_query_args['query_fields'] = array( "title_{$locale}^2", 'title_en^0.5', "content_{$locale}^2", 'content_en^0.5', 'author', 'tag', 'category', 'slug_ngram', 'contributors' );
     273        } else {
     274            $es_wp_query_args['query_fields'] = array( 'title_en^2', 'content_en', 'author', 'tag', 'category', 'slug_ngram', 'contributors' );
     275        }
     276
    270277        // You can use this filter to modify the search query parameters, such as controlling the post_type.
    271278        // These arguments are in the format for convert_wp_es_to_es_args(), i.e. WP-style.
Note: See TracChangeset for help on using the changeset viewer.