Changeset 38625 for trunk/src/wp-admin/includes/post.php
- Timestamp:
- 09/20/2016 01:44:07 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/post.php
r38572 r38625 1145 1145 } 1146 1146 1147 // Filter query clauses to include filenames. 1148 add_filter( 'posts_clauses', '_filter_query_attachment_filenames' ); 1149 1147 1150 return $q; 1151 } 1152 1153 /** 1154 * Filter the SQL clauses of an attachment query to include filenames. 1155 * 1156 * @since 4.7.0 1157 * @access private 1158 * 1159 * @param array $clauses An array including WHERE, GROUP BY, JOIN, ORDER BY, 1160 * DISTINCT, fields (SELECT), and LIMITS clauses. 1161 * @return array The modified clauses. 1162 */ 1163 function _filter_query_attachment_filenames( $clauses ) { 1164 global $wpdb; 1165 remove_filter( 'posts_clauses', __FUNCTION__ ); 1166 1167 $clauses['join'] = " INNER JOIN {$wpdb->postmeta} ON ( {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id )"; 1168 $clauses['groupby'] = "{$wpdb->posts}.ID"; 1169 1170 $clauses['where'] = preg_replace( 1171 "/\({$wpdb->posts}.post_content (NOT LIKE|LIKE) (\'[^']+\')\)/", 1172 "$0 OR ( {$wpdb->postmeta}.meta_key = '_wp_attached_file' AND {$wpdb->postmeta}.meta_value $1 $2 )", 1173 $clauses['where'] ); 1174 1175 return $clauses; 1148 1176 } 1149 1177
Note: See TracChangeset
for help on using the changeset viewer.