Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add get_available_post_mime_types filter
  • Loading branch information
rbcorrales committed Aug 24, 2023
commit 1ef448f6e73761a7bf6bdf6f2b2c0a9a872e19a3
17 changes: 15 additions & 2 deletions src/wp-includes/post.php
Original file line number Diff line number Diff line change
Expand Up @@ -7866,8 +7866,21 @@ function wp_cache_set_posts_last_changed() {
function get_available_post_mime_types( $type = 'attachment' ) {
global $wpdb;

$types = $wpdb->get_col( $wpdb->prepare( "SELECT DISTINCT post_mime_type FROM $wpdb->posts WHERE post_type = %s", $type ) );
return $types;
/**
* Filters the list of available post MIME types.
*
* @since 6.4.0
*
* @param string[]|null $mime_types An array of MIME types. Default null.
* @param string $type The post type. Default 'attachment'.
*/
$mime_types = apply_filters( 'get_available_post_mime_types', null, $type );

if ( ! is_array( $mime_types ) ) {
$mime_types = $wpdb->get_col( $wpdb->prepare( "SELECT DISTINCT post_mime_type FROM $wpdb->posts WHERE post_type = %s", $type ) );
}

return $mime_types;
}

/**
Expand Down