Changeset 54559 for branches/5.4/src/wp-includes/class-wp-query.php
- Timestamp:
- 10/17/2022 06:01:26 PM (2 years ago)
- Location:
- branches/5.4
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/5.4
- Property svn:mergeinfo changed
/trunk merged: 54521-54530,54541
- Property svn:mergeinfo changed
-
branches/5.4/src/wp-includes/class-wp-query.php
r47641 r54559 442 442 public $thumbnails_cached = false; 443 443 444 /** 445 * Controls whether an attachment query should include filenames or not. 446 * 447 * @since 6.0.3 448 * @var bool 449 */ 450 protected $allow_query_attachment_by_filename = false; 444 451 /** 445 452 * Cached list of search stopwords. … … 1389 1396 } 1390 1397 1391 $like = $n . $wpdb->esc_like( $term ) . $n; 1392 $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 ); 1398 $like = $n . $wpdb->esc_like( $term ) . $n; 1399 1400 if ( ! empty( $this->allow_query_attachment_by_filename ) ) { 1401 $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 ); 1402 } else { 1403 $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 ); 1404 } 1393 1405 $searchand = ' AND '; 1394 1406 } … … 1774 1786 $q = $this->fill_query_vars( $q ); 1775 1787 1788 /** 1789 * Filters whether an attachment query should include filenames or not. 1790 * 1791 * @since 6.0.3 1792 * 1793 * @param bool $allow_query_attachment_by_filename Whether or not to include filenames. 1794 */ 1795 $this->allow_query_attachment_by_filename = apply_filters( 'wp_allow_query_attachment_by_filename', false ); 1796 remove_all_filters( 'wp_allow_query_attachment_by_filename' ); 1797 1776 1798 // Parse meta query. 1777 1799 $this->meta_query = new WP_Meta_Query(); … … 2205 2227 } 2206 2228 2207 if ( ! empty( $this->tax_query->queries ) || ! empty( $this->meta_query->queries ) ) {2229 if ( ! empty( $this->tax_query->queries ) || ! empty( $this->meta_query->queries ) || ! empty( $this->allow_query_attachment_by_filename ) ) { 2208 2230 $groupby = "{$wpdb->posts}.ID"; 2209 2231 } … … 2281 2303 } 2282 2304 $where .= $search . $whichauthor . $whichmimetype; 2305 2306 if ( ! empty( $this->allow_query_attachment_by_filename ) ) { 2307 $join .= " LEFT JOIN {$wpdb->postmeta} AS sq1 ON ( {$wpdb->posts}.ID = sq1.post_id AND sq1.meta_key = '_wp_attached_file' )"; 2308 } 2283 2309 2284 2310 if ( ! empty( $this->meta_query->queries ) ) {
Note: See TracChangeset
for help on using the changeset viewer.