wpseek.com
A WordPress-centric search engine for devs and theme authors
_filter_query_attachment_filenames is private and should not be used in themes or plugins directly.
_filter_query_attachment_filenames › WordPress Function
Since4.7.0
Deprecatedn/a
› _filter_query_attachment_filenames ( $clauses )
Access: |
|
Parameters: |
|
Returns: |
|
Defined at: |
|
Codex: |
Filters the SQL clauses of an attachment query to include filenames.
Source
function _filter_query_attachment_filenames( $clauses ) { global $wpdb; remove_filter( 'posts_clauses', __FUNCTION__ ); // Add a LEFT JOIN of the postmeta table so we don't trample existing JOINs. $clauses['join'] .= " LEFT JOIN {$wpdb->postmeta} AS sq1 ON ( {$wpdb->posts}.ID = sq1.post_id AND sq1.meta_key = '_wp_attached_file' )"; $clauses['groupby'] = "{$wpdb->posts}.ID"; $clauses['where'] = preg_replace( "/\({$wpdb->posts}.post_content (NOT LIKE|LIKE) (\'[^']+\')\)/", '$0 OR ( sq1.meta_value $1 $2 )', $clauses['where'] ); return $clauses; }