Changeset 9363
- Timestamp:
- 12/19/2019 08:03:44 AM (5 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/class-themes-api.php
r8999 r9363 450 450 $cache_key = sanitize_key( __METHOD__ . ':' . get_locale() . ':' . md5( serialize( $this->request ) . serialize( $this->fields ) ) ); 451 451 if ( false !== ( $this->response = wp_cache_get( $cache_key, $this->cache_group ) ) && empty( $this->request->cache_buster ) ) { 452 return;452 // return; 453 453 } 454 454 … … 487 487 } 488 488 489 wp_cache_set( $cache_key, $this->response, $this->cache_group, $this->cache_life );489 //wp_cache_set( $cache_key, $this->response, $this->cache_group, $this->cache_life ); 490 490 } 491 491 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/query-modifications.php
r9188 r9363 136 136 ! in_array( $query->query_vars['browse'], array( 'favorites', 'new', 'updated' ) ) 137 137 ) { 138 add_filter( 'posts_clauses', 'wporg_themes_prioritize_translated_posts_clauses' ); 139 } 140 138 add_filter( 'posts_clauses', 'wporg_themes_prioritize_translated_posts_clauses', 11 ); 139 } 140 141 if ( $query->is_search() ) { 142 add_filter( 'posts_clauses', 'wporg_themes_prioritize_exact_matches_clauses', 10, 2 ); 143 } 141 144 } 142 145 add_action( 'pre_get_posts', 'wporg_themes_pre_get_posts' ); … … 160 163 161 164 /** 165 * Filters SQL clauses, to prioritise exact theme slug matches. 166 */ 167 function wporg_themes_prioritize_exact_matches_clauses( $clauses, $query ) { 168 global $wpdb; 169 170 // Override the post_modified check to allow matching when an exact title/slug match is found. 171 $clauses['where'] = preg_replace_callback( 172 "!{$wpdb->posts}.post_modified > '(.+?)'!is", 173 function( $m ) use ( $query ) { 174 global $wpdb; 175 176 return $wpdb->prepare( 177 "( {$wpdb->posts}.post_modified > %s OR {$wpdb->posts}.post_name = %s OR {$wpdb->posts}.post_title = %s )", 178 $m[1], 179 $query->get('s'), 180 $query->get('s') 181 ); 182 }, 183 $clauses['where'] 184 ); 185 186 // Prioritize exact-match slug/titles in search results 187 $clauses['orderby'] = $wpdb->prepare( 188 "( {$wpdb->posts}.post_name = %s OR {$wpdb->posts}.post_title = %s ) DESC, ", 189 $query->get( 's' ), 190 $query->get( 's' ) 191 ) . $clauses['orderby']; 192 193 return $clauses; 194 } 195 196 /** 162 197 * Handle proper 404 errors for requests. 163 198 */
Note: See TracChangeset
for help on using the changeset viewer.