Changeset 54548 for branches/5.8/src/wp-includes/class-wp-query.php
- Timestamp:
- 10/17/2022 05:46:39 PM (2 years ago)
- Location:
- branches/5.8
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/5.8
- Property svn:mergeinfo changed
/trunk merged: 54397,54521-54530,54541
- Property svn:mergeinfo changed
-
branches/5.8/src/wp-includes/class-wp-query.php
r50576 r54548 445 445 public $thumbnails_cached = false; 446 446 447 /** 448 * Controls whether an attachment query should include filenames or not. 449 * 450 * @since 6.0.3 451 * @var bool 452 */ 453 protected $allow_query_attachment_by_filename = false; 447 454 /** 448 455 * Cached list of search stopwords. … … 1395 1402 1396 1403 $like = $n . $wpdb->esc_like( $term ) . $n; 1397 $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 1405 if ( ! empty( $this->allow_query_attachment_by_filename ) ) { 1406 $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 ); 1407 } else { 1408 $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 ); 1409 } 1398 1410 $searchand = ' AND '; 1399 1411 } … … 1790 1802 $q = $this->fill_query_vars( $q ); 1791 1803 1804 /** 1805 * Filters whether an attachment query should include filenames or not. 1806 * 1807 * @since 6.0.3 1808 * 1809 * @param bool $allow_query_attachment_by_filename Whether or not to include filenames. 1810 */ 1811 $this->allow_query_attachment_by_filename = apply_filters( 'wp_allow_query_attachment_by_filename', false ); 1812 remove_all_filters( 'wp_allow_query_attachment_by_filename' ); 1813 1792 1814 // Parse meta query. 1793 1815 $this->meta_query = new WP_Meta_Query(); … … 2221 2243 } 2222 2244 2223 if ( ! empty( $this->tax_query->queries ) || ! empty( $this->meta_query->queries ) ) {2245 if ( ! empty( $this->tax_query->queries ) || ! empty( $this->meta_query->queries ) || ! empty( $this->allow_query_attachment_by_filename ) ) { 2224 2246 $groupby = "{$wpdb->posts}.ID"; 2225 2247 } … … 2297 2319 } 2298 2320 $where .= $search . $whichauthor . $whichmimetype; 2321 2322 if ( ! empty( $this->allow_query_attachment_by_filename ) ) { 2323 $join .= " LEFT JOIN {$wpdb->postmeta} AS sq1 ON ( {$wpdb->posts}.ID = sq1.post_id AND sq1.meta_key = '_wp_attached_file' )"; 2324 } 2299 2325 2300 2326 if ( ! empty( $this->meta_query->queries ) ) {
Note: See TracChangeset
for help on using the changeset viewer.