Changeset 54568 for branches/4.8/src/wp-includes/class-wp-query.php
- Timestamp:
- 10/17/2022 06:10:19 PM (2 years ago)
- Location:
- branches/4.8
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.8
- Property svn:mergeinfo changed
/trunk merged: 54521-54530,54541
- Property svn:mergeinfo changed
-
branches/4.8/src/wp-includes/class-wp-query.php
r47649 r54568 487 487 private $compat_methods = array( 'init_query_flags', 'parse_tax_query' ); 488 488 489 /** 490 * Controls whether an attachment query should include filenames or not. 491 * 492 * @since 6.0.3 493 * @var bool 494 */ 495 protected $allow_query_attachment_by_filename = false; 489 496 /** 490 497 * Resets query flags to false. … … 1347 1354 1348 1355 $like = $n . $wpdb->esc_like( $term ) . $n; 1349 $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 ); 1356 1357 if ( ! empty( $this->allow_query_attachment_by_filename ) ) { 1358 $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 ); 1359 } else { 1360 $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 ); 1361 } 1350 1362 $searchand = ' AND '; 1351 1363 } … … 1684 1696 $q = $this->fill_query_vars($q); 1685 1697 1698 /** 1699 * Filters whether an attachment query should include filenames or not. 1700 * 1701 * @since 6.0.3 1702 * 1703 * @param bool $allow_query_attachment_by_filename Whether or not to include filenames. 1704 */ 1705 $this->allow_query_attachment_by_filename = apply_filters( 'wp_allow_query_attachment_by_filename', false ); 1706 remove_all_filters( 'wp_allow_query_attachment_by_filename' ); 1707 1686 1708 // Parse meta query 1687 1709 $this->meta_query = new WP_Meta_Query(); … … 2088 2110 } 2089 2111 2090 if ( ! empty( $this->tax_query->queries ) || !empty( $this->meta_query->queries) ) {2112 if ( ! empty( $this->tax_query->queries ) || ! empty( $this->meta_query->queries ) || ! empty( $this->allow_query_attachment_by_filename ) ) { 2091 2113 $groupby = "{$wpdb->posts}.ID"; 2092 2114 } … … 2136 2158 } 2137 2159 $where .= $search . $whichauthor . $whichmimetype; 2160 2161 if ( ! empty( $this->allow_query_attachment_by_filename ) ) { 2162 $join .= " LEFT JOIN {$wpdb->postmeta} AS sq1 ON ( {$wpdb->posts}.ID = sq1.post_id AND sq1.meta_key = '_wp_attached_file' )"; 2163 } 2138 2164 2139 2165 if ( ! empty( $this->meta_query->queries ) ) {
Note: See TracChangeset
for help on using the changeset viewer.