Changeset 54556 for branches/5.5/src/wp-includes/class-wp-query.php
- Timestamp:
- 10/17/2022 05:58:36 PM (2 years ago)
- Location:
- branches/5.5
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/5.5
- Property svn:mergeinfo changed
/trunk merged: 54521-54530,54541
- Property svn:mergeinfo changed
-
branches/5.5/src/wp-includes/class-wp-query.php
r48586 r54556 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. … … 1392 1399 1393 1400 $like = $n . $wpdb->esc_like( $term ) . $n; 1394 $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 ); 1401 1402 if ( ! empty( $this->allow_query_attachment_by_filename ) ) { 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) $andor_op (sq1.meta_value $like_op %s))", $like, $like, $like, $like ); 1404 } else { 1405 $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 ); 1406 } 1395 1407 $searchand = ' AND '; 1396 1408 } … … 1785 1797 $q = $this->fill_query_vars( $q ); 1786 1798 1799 /** 1800 * Filters whether an attachment query should include filenames or not. 1801 * 1802 * @since 6.0.3 1803 * 1804 * @param bool $allow_query_attachment_by_filename Whether or not to include filenames. 1805 */ 1806 $this->allow_query_attachment_by_filename = apply_filters( 'wp_allow_query_attachment_by_filename', false ); 1807 remove_all_filters( 'wp_allow_query_attachment_by_filename' ); 1808 1787 1809 // Parse meta query. 1788 1810 $this->meta_query = new WP_Meta_Query(); … … 2216 2238 } 2217 2239 2218 if ( ! empty( $this->tax_query->queries ) || ! empty( $this->meta_query->queries ) ) {2240 if ( ! empty( $this->tax_query->queries ) || ! empty( $this->meta_query->queries ) || ! empty( $this->allow_query_attachment_by_filename ) ) { 2219 2241 $groupby = "{$wpdb->posts}.ID"; 2220 2242 } … … 2292 2314 } 2293 2315 $where .= $search . $whichauthor . $whichmimetype; 2316 2317 if ( ! empty( $this->allow_query_attachment_by_filename ) ) { 2318 $join .= " LEFT JOIN {$wpdb->postmeta} AS sq1 ON ( {$wpdb->posts}.ID = sq1.post_id AND sq1.meta_key = '_wp_attached_file' )"; 2319 } 2294 2320 2295 2321 if ( ! empty( $this->meta_query->queries ) ) {
Note: See TracChangeset
for help on using the changeset viewer.