Changeset 54563 for branches/5.2/src/wp-includes/class-wp-query.php
- Timestamp:
- 10/17/2022 06:08:00 PM (2 years ago)
- Location:
- branches/5.2
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/5.2
- Property svn:mergeinfo changed
/trunk merged: 54521-54530,54541
- Property svn:mergeinfo changed
-
branches/5.2/src/wp-includes/class-wp-query.php
r47645 r54563 434 434 public $thumbnails_cached = false; 435 435 436 /** 437 * Controls whether an attachment query should include filenames or not. 438 * 439 * @since 6.0.3 440 * @var bool 441 */ 442 protected $allow_query_attachment_by_filename = false; 436 443 /** 437 444 * Cached list of search stopwords. … … 1370 1377 } 1371 1378 1372 $like = $n . $wpdb->esc_like( $term ) . $n; 1373 $search .= $wpdb->prepare( "{$searchand}(({$wpdb->posts}.post_title $like_op %s) $andor_op ({$wpdb->posts}.post_excerpt $like_op %s) $andor_op ({$wpdb->posts}.post_content $like_op %s))", $like, $like, $like ); 1379 $like = $n . $wpdb->esc_like( $term ) . $n; 1380 1381 if ( ! empty( $this->allow_query_attachment_by_filename ) ) { 1382 $search .= $wpdb->prepare( "{$searchand}(({$wpdb->posts}.post_title $like_op %s) $andor_op ({$wpdb->posts}.post_excerpt $like_op %s) $andor_op ({$wpdb->posts}.post_content $like_op %s) $andor_op (sq1.meta_value $like_op %s))", $like, $like, $like, $like ); 1383 } else { 1384 $search .= $wpdb->prepare( "{$searchand}(({$wpdb->posts}.post_title $like_op %s) $andor_op ({$wpdb->posts}.post_excerpt $like_op %s) $andor_op ({$wpdb->posts}.post_content $like_op %s))", $like, $like, $like ); 1385 } 1374 1386 $searchand = ' AND '; 1375 1387 } … … 1754 1766 $q = $this->fill_query_vars( $q ); 1755 1767 1768 /** 1769 * Filters whether an attachment query should include filenames or not. 1770 * 1771 * @since 6.0.3 1772 * 1773 * @param bool $allow_query_attachment_by_filename Whether or not to include filenames. 1774 */ 1775 $this->allow_query_attachment_by_filename = apply_filters( 'wp_allow_query_attachment_by_filename', false ); 1776 remove_all_filters( 'wp_allow_query_attachment_by_filename' ); 1777 1756 1778 // Parse meta query 1757 1779 $this->meta_query = new WP_Meta_Query(); … … 2184 2206 } 2185 2207 2186 if ( ! empty( $this->tax_query->queries ) || ! empty( $this->meta_query->queries ) ) {2208 if ( ! empty( $this->tax_query->queries ) || ! empty( $this->meta_query->queries ) || ! empty( $this->allow_query_attachment_by_filename ) ) { 2187 2209 $groupby = "{$wpdb->posts}.ID"; 2188 2210 } … … 2260 2282 } 2261 2283 $where .= $search . $whichauthor . $whichmimetype; 2284 2285 if ( ! empty( $this->allow_query_attachment_by_filename ) ) { 2286 $join .= " LEFT JOIN {$wpdb->postmeta} AS sq1 ON ( {$wpdb->posts}.ID = sq1.post_id AND sq1.meta_key = '_wp_attached_file' )"; 2287 } 2262 2288 2263 2289 if ( ! empty( $this->meta_query->queries ) ) {
Note: See TracChangeset
for help on using the changeset viewer.