CodeExplorer get_media_types example
protected function prepare_items_query( $prepared_args = array
(),
$request = null
) { $query_args = parent::
prepare_items_query( $prepared_args,
$request );
if ( empty( $query_args['post_status'
] ) ) { $query_args['post_status'
] = 'inherit';
} $media_types =
$this->
get_media_types();
if ( !
empty( $request['media_type'
] ) &&
isset( $media_types[ $request['media_type'
] ] ) ) { $query_args['post_mime_type'
] =
$media_types[ $request['media_type'
] ];
} if ( !
empty( $request['mime_type'
] ) ) { $parts =
explode( '/',
$request['mime_type'
] );
if ( isset( $media_types[ $parts[0
] ] ) &&
in_array( $request['mime_type'
],
$media_types[ $parts[0
] ], true
) ) { $query_args['post_mime_type'
] =
$request['mime_type'
];
} }