wp_prevent_unsupported_mime_type_uploads хук-фильтрWP 6.8.0

Filter whether the server should prevent uploads for image types it doesn't support. Default true.

Developers can use this filter to enable uploads of certain image types. By default image types that are not supported by the server are prevented from being uploaded.

Использование

add_filter( 'wp_prevent_unsupported_mime_type_uploads', 'wp_kama_prevent_unsupported_mime_type_uploads_filter', 10, 2 );

/**
 * Function for `wp_prevent_unsupported_mime_type_uploads` filter-hook.
 * 
 * @param bool        $check_mime Whether to prevent uploads of unsupported image types.
 * @param string|null $mime_type  The mime type of the file being uploaded (if available).
 *
 * @return bool
 */
function wp_kama_prevent_unsupported_mime_type_uploads_filter( $check_mime, $mime_type ){
	// filter...
	return $check_mime;
}
$check_mime(true|false)
Whether to prevent uploads of unsupported image types.
$mime_type(строка|null)
The mime type of the file being uploaded (if available).

Список изменений

С версии 6.8.0 Введена.

Где вызывается хук

WP_REST_Attachments_Controller::create_item_permissions_check()
wp_prevent_unsupported_mime_type_uploads
media_upload_form()
wp_prevent_unsupported_mime_type_uploads
wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php 440
$prevent_unsupported_uploads = apply_filters( 'wp_prevent_unsupported_mime_type_uploads', true, $files['file']['type'] ?? null );
wp-admin/includes/media.php 2218
$prevent_unsupported_uploads = apply_filters( 'wp_prevent_unsupported_mime_type_uploads', true, null );

Где используется хук в WordPress

Использование не найдено.