WordPress.org

Make WordPress Core


Ignore:
Timestamp:
04/16/2019 08:29:42 PM (16 months ago)
Author:
adamsilverstein
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/post.php

    r44785 r45219  
    68926892    wp_cache_set( 'last_changed', microtime(), 'posts' );
    68936893}
     6894
     6895/**
     6896 * Get all available post MIME types for a given post type.
     6897 *
     6898 * @since 2.5.0
     6899 *
     6900 * @global wpdb $wpdb WordPress database abstraction object.
     6901 *
     6902 * @param string $type
     6903 * @return mixed
     6904 */
     6905function get_available_post_mime_types( $type = 'attachment' ) {
     6906    global $wpdb;
     6907
     6908    $types = $wpdb->get_col( $wpdb->prepare( "SELECT DISTINCT post_mime_type FROM $wpdb->posts WHERE post_type = %s", $type ) );
     6909    return $types;
     6910}
Note: See TracChangeset for help on using the changeset viewer.