Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

_filter_query_attachment_filenames() WordPress Function

The filter_query_attachment_filenames() function is used to filter the attachment filenames before they are added to the database. This function can be used to check for invalid characters or to modify the filename.

_filter_query_attachment_filenames( string[] $clauses ) #

Filters the SQL clauses of an attachment query to include filenames.


Parameters

$clauses

(string[])(Required)An array including WHERE, GROUP BY, JOIN, ORDER BY, DISTINCT, fields (SELECT), and LIMITS clauses.


Top ↑

Return

(string[]) The modified array of clauses.


Top ↑

Source

File: wp-includes/post.php

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;
}


Top ↑

Changelog

Changelog
VersionDescription
4.7.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More