Media: move get_available_post_mime_types to wp-includes/post.php making it more generally available.

Address an issue since r44947 where calling `wp_enqueue_media` on the front-end would result in a PHP fatal.

Props david.binda.
Fixes #46795.


git-svn-id: https://develop.svn.wordpress.org/trunk@45219 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Adam Silverstein 2019-04-16 20:29:42 +00:00
parent 4f3f0fae08
commit 70f16b6bf4
2 changed files with 17 additions and 17 deletions

View File

@ -1184,23 +1184,6 @@ function wp_edit_posts_query( $q = false ) {
return $avail_post_stati; return $avail_post_stati;
} }
/**
* Get all available post MIME types for a given post type.
*
* @since 2.5.0
*
* @global wpdb $wpdb WordPress database abstraction object.
*
* @param string $type
* @return mixed
*/
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;
}
/** /**
* Get the query variables for the current attachments request. * Get the query variables for the current attachments request.
* *

View File

@ -6891,3 +6891,20 @@ function _filter_query_attachment_filenames( $clauses ) {
function wp_cache_set_posts_last_changed() { function wp_cache_set_posts_last_changed() {
wp_cache_set( 'last_changed', microtime(), 'posts' ); wp_cache_set( 'last_changed', microtime(), 'posts' );
} }
/**
* Get all available post MIME types for a given post type.
*
* @since 2.5.0
*
* @global wpdb $wpdb WordPress database abstraction object.
*
* @param string $type
* @return mixed
*/
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;
}