Changeset 54524 for trunk/src/wp-includes/class-wp-query.php
- Timestamp:
- 10/17/2022 11:17:38 AM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-query.php
r54496 r54524 445 445 */ 446 446 public $thumbnails_cached = false; 447 448 /** 449 * Controls whether an attachment query should include filenames or not. 450 * 451 * @since 6.0.3 452 * @var bool 453 */ 454 protected $allow_query_attachment_by_filename = false; 447 455 448 456 /** … … 1430 1438 } 1431 1439 1432 $like = $n . $wpdb->esc_like( $term ) . $n; 1433 $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 ); 1440 $like = $n . $wpdb->esc_like( $term ) . $n; 1441 1442 if ( ! empty( $this->allow_query_attachment_by_filename ) ) { 1443 $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 ); 1444 } else { 1445 $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 ); 1446 } 1434 1447 $searchand = ' AND '; 1435 1448 } … … 1826 1839 $q = $this->fill_query_vars( $q ); 1827 1840 1841 /** 1842 * Filters whether an attachment query should include filenames or not. 1843 * 1844 * @since 6.0.3 1845 * 1846 * @param bool $allow_query_attachment_by_filename Whether or not to include filenames. 1847 */ 1848 $this->allow_query_attachment_by_filename = apply_filters( 'wp_allow_query_attachment_by_filename', false ); 1849 remove_all_filters( 'wp_allow_query_attachment_by_filename' ); 1850 1828 1851 // Parse meta query. 1829 1852 $this->meta_query = new WP_Meta_Query(); … … 2257 2280 } 2258 2281 2259 if ( ! empty( $this->tax_query->queries ) || ! empty( $this->meta_query->queries ) ) {2282 if ( ! empty( $this->tax_query->queries ) || ! empty( $this->meta_query->queries ) || ! empty( $this->allow_query_attachment_by_filename ) ) { 2260 2283 $groupby = "{$wpdb->posts}.ID"; 2261 2284 } … … 2333 2356 } 2334 2357 $where .= $search . $whichauthor . $whichmimetype; 2358 2359 if ( ! empty( $this->allow_query_attachment_by_filename ) ) { 2360 $join .= " LEFT JOIN {$wpdb->postmeta} AS sq1 ON ( {$wpdb->posts}.ID = sq1.post_id AND sq1.meta_key = '_wp_attached_file' )"; 2361 } 2335 2362 2336 2363 if ( ! empty( $this->meta_query->queries ) ) {
Note: See TracChangeset
for help on using the changeset viewer.