WP_REST_Font_Faces_Controller::handle_font_file_upload_error()publicWP 6.5.0

Handles file upload error.

Метод класса: WP_REST_Font_Faces_Controller{}

Хуков нет.

Возвращает

WP_Error. WP_Error object.

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

$WP_REST_Font_Faces_Controller = new WP_REST_Font_Faces_Controller();
$WP_REST_Font_Faces_Controller->handle_font_file_upload_error( $file, $message );
$file(массив) (обязательный)
File upload data.
$message(строка) (обязательный)
Error message from wp_handle_upload().

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

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

Код WP_REST_Font_Faces_Controller::handle_font_file_upload_error() WP 6.7.1

public function handle_font_file_upload_error( $file, $message ) {
	$status = 500;
	$code   = 'rest_font_upload_unknown_error';

	if ( __( 'Sorry, you are not allowed to upload this file type.' ) === $message ) {
		$status = 400;
		$code   = 'rest_font_upload_invalid_file_type';
	}

	return new WP_Error( $code, $message, array( 'status' => $status ) );
}