wp_edit_attachments_query

Definition:
function wp_edit_attachments_query( $q = false ) {}

Parameters

  • unknown_type $q

Defined filters

  • upload_per_page
    apply_filters( 'upload_per_page', $media_per_page )

Source code

function wp_edit_attachments_query( $q = false ) {

	if ( false === $q )

		$q = $_GET;



	$q['m']   = isset( $q['m'] ) ? (int) $q['m'] : 0;

	$q['cat'] = isset( $q['cat'] ) ? (int) $q['cat'] : 0;

	$q['post_type'] = 'attachment';

	$post_type = get_post_type_object( 'attachment' );

	$states = 'inherit';

	if ( current_user_can( $post_type->cap->read_private_posts ) )

		$states .= ',private';



	$q['post_status'] = isset( $q['status'] ) && 'trash' == $q['status'] ? 'trash' : $states;

	$media_per_page = (int) get_user_option( 'upload_per_page' );

	if ( empty( $media_per_page ) || $media_per_page < 1 )

		$media_per_page = 20;

	$q['posts_per_page'] = apply_filters( 'upload_per_page', $media_per_page );



	$post_mime_types = get_post_mime_types();

	$avail_post_mime_types = get_available_post_mime_types('attachment');



	if ( isset($q['post_mime_type']) && !array_intersect( (array) $q['post_mime_type'], array_keys($post_mime_types) ) )

		unset($q['post_mime_type']);



	if ( isset($q['detached']) )

		add_filter('posts_where', '_edit_attachments_query_helper');



	wp( $q );



	if ( isset($q['detached']) )

		remove_filter('posts_where', '_edit_attachments_query_helper');



	return array($post_mime_types, $avail_post_mime_types);

}

3621

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: