diff --git a/wp-includes/post.php b/wp-includes/post.php index 209a8be645..8e1da0ecbd 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -2639,16 +2639,72 @@ function wp_count_attachments( $mime_type = '' ) { * Get default post mime types. * * @since 2.9.0 + * @since 5.3.0 Added the 'Documents', 'Spreadsheets', and 'Archives' mime type groups. * * @return array List of post mime types. */ function get_post_mime_types() { $post_mime_types = array( // array( adj, noun ) - 'image' => array( __( 'Images' ), __( 'Manage Images' ), _n_noop( 'Image (%s)', 'Images (%s)' ) ), - 'audio' => array( __( 'Audio' ), __( 'Manage Audio' ), _n_noop( 'Audio (%s)', 'Audio (%s)' ) ), - 'video' => array( __( 'Video' ), __( 'Manage Video' ), _n_noop( 'Video (%s)', 'Video (%s)' ) ), + 'image' => array( + __( 'Images' ), + __( 'Manage Images' ), + _n_noop( 'Image (%s)', 'Images (%s)' ), + ), + 'audio' => array( + __( 'Audio' ), + __( 'Manage Audio' ), + _n_noop( 'Audio (%s)', 'Audio (%s)' ), + ), + 'video' => array( + __( 'Video' ), + __( 'Manage Video' ), + _n_noop( 'Video (%s)', 'Video (%s)' ), + ), + 'document' => array( + __( 'Documents' ), + __( 'Manage Documents' ), + _n_noop( 'Document (%s)', 'Documents (%s)' ), + ), + 'spreadsheet' => array( + __( 'Spreadsheets' ), + __( 'Manage Spreadsheets' ), + _n_noop( 'Spreadsheet (%s)', 'Spreadsheets (%s)' ), + ), + 'archive' => array( + __( 'Archives' ), + __( 'Manage Archives' ), + _n_noop( 'Archive (%s)', 'Archives (%s)' ), + ), ); + $ext_types = wp_get_ext_types(); + $mime_types = wp_get_mime_types(); + + foreach ( $post_mime_types as $group => $labels ) { + if ( in_array( $group, array( 'image', 'audio', 'video' ) ) ) { + continue; + } + + if ( ! isset( $ext_types[ $group ] ) ) { + unset( $post_mime_types[ $group ] ); + continue; + } + + $group_mime_types = array(); + foreach ( $ext_types[ $group ] as $extension ) { + foreach ( $mime_types as $exts => $mime ) { + if ( preg_match( '!^(' . $exts . ')$!i', $extension ) ) { + $group_mime_types[] = $mime; + break; + } + } + } + $group_mime_types = implode( ',', array_unique( $group_mime_types ) ); + + $post_mime_types[ $group_mime_types ] = $labels; + unset( $post_mime_types[ $group ] ); + } + /** * Filters the default list of post mime types. * diff --git a/wp-includes/version.php b/wp-includes/version.php index 756e576f8f..cc867445f6 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.3-alpha-45650'; +$wp_version = '5.3-alpha-45651'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.