wpseek.com
WordPress开发者和主题制作者的搜索引擎



get_available_post_mime_types › WordPress Function

Since2.5.0
已弃用n/a
get_available_post_mime_types ( $type = 'attachment' )
参数:
  • (string) $type
    Required: No
    默认: 'attachment'
返回:
  • (string[]) An array of MIME types.
定义在:
文档:

Gets all available post MIME types for a given post type.



源码

function get_available_post_mime_types( $type = 'attachment' ) {
	global $wpdb;

	/**
	 * Filters the list of available post MIME types for the given post type.
	 *
	 * @since 6.4.0
	 *
	 * @param string[]|null $mime_types An array of MIME types. Default null.
	 * @param string        $type       The post type name. Usually 'attachment' but can be any post type.
	 */
	$mime_types = apply_filters( 'pre_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;
}