Changeset 54569 for branches/4.9/src/wp-includes/class-wp-query.php
- Timestamp:
- 10/17/2022 06:11:47 PM (2 years ago)
- Location:
- branches/4.9
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.9
- Property svn:mergeinfo changed
/trunk merged: 54521-54530,54541
- Property svn:mergeinfo changed
-
branches/4.9/src/wp-includes/class-wp-query.php
r47648 r54569 438 438 private $compat_methods = array( 'init_query_flags', 'parse_tax_query' ); 439 439 440 /** 441 * Controls whether an attachment query should include filenames or not. 442 * 443 * @since 6.0.3 444 * @var bool 445 */ 446 protected $allow_query_attachment_by_filename = false; 440 447 /** 441 448 * Resets query flags to false. … … 1299 1306 1300 1307 $like = $n . $wpdb->esc_like( $term ) . $n; 1301 $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 ); 1308 1309 if ( ! empty( $this->allow_query_attachment_by_filename ) ) { 1310 $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 ); 1311 } else { 1312 $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 ); 1313 } 1302 1314 $searchand = ' AND '; 1303 1315 } … … 1635 1647 $q = $this->fill_query_vars($q); 1636 1648 1649 /** 1650 * Filters whether an attachment query should include filenames or not. 1651 * 1652 * @since 6.0.3 1653 * 1654 * @param bool $allow_query_attachment_by_filename Whether or not to include filenames. 1655 */ 1656 $this->allow_query_attachment_by_filename = apply_filters( 'wp_allow_query_attachment_by_filename', false ); 1657 remove_all_filters( 'wp_allow_query_attachment_by_filename' ); 1658 1637 1659 // Parse meta query 1638 1660 $this->meta_query = new WP_Meta_Query(); … … 2039 2061 } 2040 2062 2041 if ( ! empty( $this->tax_query->queries ) || !empty( $this->meta_query->queries) ) {2063 if ( ! empty( $this->tax_query->queries ) || ! empty( $this->meta_query->queries ) || ! empty( $this->allow_query_attachment_by_filename ) ) { 2042 2064 $groupby = "{$wpdb->posts}.ID"; 2043 2065 } … … 2111 2133 } 2112 2134 $where .= $search . $whichauthor . $whichmimetype; 2135 2136 if ( ! empty( $this->allow_query_attachment_by_filename ) ) { 2137 $join .= " LEFT JOIN {$wpdb->postmeta} AS sq1 ON ( {$wpdb->posts}.ID = sq1.post_id AND sq1.meta_key = '_wp_attached_file' )"; 2138 } 2113 2139 2114 2140 if ( ! empty( $this->meta_query->queries ) ) {
Note: See TracChangeset
for help on using the changeset viewer.