~canonical-sysadmins/wordpress/5.1

« back to all changes in this revision

Viewing changes to wp-includes/post.php

  • Committer: Jamon Camisso
  • Date: 2017-01-12 15:30:45 UTC
  • mto: This revision was merged to the branch mainline in revision 25.
  • Revision ID: jamon.camisso@canonical.com-20170112153045-dekfwsu8mcsdxa7x
New upstream release 4.7.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
6188
6188
        clean_post_cache( $post->ID );
6189
6189
        return $post_name;
6190
6190
}
 
6191
 
 
6192
/**
 
6193
 * Filter the SQL clauses of an attachment query to include filenames.
 
6194
 *
 
6195
 * @since 4.7.0
 
6196
 * @access private
 
6197
 *
 
6198
 * @global wpdb $wpdb WordPress database abstraction object.
 
6199
 *
 
6200
 * @param array $clauses An array including WHERE, GROUP BY, JOIN, ORDER BY,
 
6201
 *                       DISTINCT, fields (SELECT), and LIMITS clauses.
 
6202
 * @return array The modified clauses.
 
6203
 */
 
6204
function _filter_query_attachment_filenames( $clauses ) {
 
6205
        global $wpdb;
 
6206
        remove_filter( 'posts_clauses', __FUNCTION__ );
 
6207
 
 
6208
        // Add a LEFT JOIN of the postmeta table so we don't trample existing JOINs.
 
6209
        $clauses['join'] .= " LEFT JOIN {$wpdb->postmeta} AS sq1 ON ( {$wpdb->posts}.ID = sq1.post_id AND sq1.meta_key = '_wp_attached_file' )";
 
6210
 
 
6211
        $clauses['groupby'] = "{$wpdb->posts}.ID";
 
6212
 
 
6213
        $clauses['where'] = preg_replace(
 
6214
                "/\({$wpdb->posts}.post_content (NOT LIKE|LIKE) (\'[^']+\')\)/",
 
6215
                "$0 OR ( sq1.meta_value $1 $2 )",
 
6216
                $clauses['where'] );
 
6217
 
 
6218
        return $clauses;
 
6219
}