Changeset 10117
- Timestamp:
- 08/05/2020 01:49:48 AM (4 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-query-plugins.php
r10115 r10117 66 66 } 67 67 68 // Temporary hacky block search69 $block_search = trim( strtolower( $request->get_param( 'block' ) ));68 // Block Directory searches 69 $block_search = $request->get_param( 'block' ); 70 70 if ( $block_search ) { 71 $meta_query = array( 72 'relation' => 'AND', 73 array( 74 'key' => 'block_files', 75 'compare' => 'EXISTS', 76 ), 77 array( 78 'relation' => 'OR', 79 array( 80 'key' => 'block_name', 81 'value' => '^' . preg_quote( $block_search ), 82 'compare' => 'RLIKE', 83 ), 84 array( 85 'key' => 'block_name', 86 'value' => '/' . $block_search, // search following the slash 87 'compare' => 'LIKE', 88 ), 89 array( 90 'key' => 'block_title', 91 'value' => $block_search, // search in title 92 'compare' => 'LIKE', 93 ), 94 array( 95 'key' => 'header_name', 96 'value' => $block_search, // search in plugin title 97 'compare' => 'LIKE', 98 ), 99 ) 100 ); 101 102 // Limit the search to the Block section 103 $query[ 'meta_query' ] = $meta_query; 104 $query[ 'tax_query' ] = array( 105 array( 106 'taxonomy' => 'plugin_section', 107 'field' => 'slug', 108 'terms' => 'block', 109 ) 110 ); 71 $query['s'] = $block_search; 72 $query['block_search'] = true; 111 73 } 112 74 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/libs/site-search/jetpack-search.php
r10115 r10117 430 430 } 431 431 432 // Block Search. 433 if ( !empty( $query->query['block_search'] ) ) { 434 $es_wp_query_args['block_search'] = $query->query['block_search']; 435 436 // Limit to the Block Tax. 437 $es_wp_query_args['filters'][] = array( 438 'term' => array( 439 'taxonomy.plugin_section.name' => array( 440 'value' => 'block' 441 ) 442 ) 443 ); 444 } 445 432 446 $es_wp_query_args['locale'] = $query->get( 'locale' ) ?: get_locale(); 433 447 … … 763 777 } 764 778 779 $is_block_search = ! empty( $args['block_search'] ); 780 765 781 if ( $args['locale'] && $args['locale'] !== 'en' && substr( $args['locale'], 0, 3 ) !== 'en_' ) { 766 782 $locale = $args['locale']; … … 788 804 'taxonomy.plugin_tags.name', 789 805 ); 806 if ( $is_block_search ) { 807 $boost_phrase_fields[] = 'block_title_' . $locale; 808 $boost_phrase_fields[] = 'block_title_en^' . $en_boost; 809 } 790 810 $boost_ngram_fields = array( 791 811 'title_' . $locale . '.ngram', … … 797 817 'slug_text', 798 818 ); 819 if ( $is_block_search ) { 820 $boost_title_fields[] = 'block_title_' . $locale; 821 $boost_title_fields[] = 'block_title_en^' . $en_boost; 822 $boost_title_fields[] = 'block_name'; 823 } 799 824 $boost_content_fields = array( 800 825 'excerpt_' . $locale, … … 814 839 'taxonomy.plugin_tags.name', 815 840 ); 841 if ( $is_block_search ) { 842 $boost_phrase_fields[] = 'block_title_en'; 843 } 816 844 $boost_ngram_fields = array( 817 845 'title_en.ngram', … … 821 849 'slug_text', 822 850 ); 851 if ( $is_block_search ) { 852 $boost_title_fields[] = 'block_title_en'; 853 $boost_title_fields[] = 'block_name'; 854 } 823 855 $boost_content_fields = array( 824 856 'excerpt_en',
Note: See TracChangeset
for help on using the changeset viewer.