Skip to content

Commit 0c0ccb7

Browse files
committed
Improve filepond uploader
1 parent c7bb1d4 commit 0c0ccb7

3 files changed

Lines changed: 4 additions & 3 deletions

File tree

dist/main.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

includes/class-helpers.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ public static function get_uploader_configurations(): array {
168168
'labelIdle' => $plugin_options['easy_dragdrop_button_label'] ?? 'Browse Image',
169169
'labelMaxFileSize' => apply_filters( 'easy_dragdrop_label_max_file_size', '' ),
170170
'rest' => rest_url( Routes::get_namespace() ),
171+
'nonce' => wp_create_nonce( 'wp_rest' )
171172
);
172173

173174
$file_type_error = $plugin_options['easy_dragdrop_file_type_error'] ?? '';

src/dragdrop/main.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function getDragDropConfiguration(configuration) {
3333
process: {
3434
method: "POST",
3535
headers: {
36-
'X-WP-Nonce': wpApiSettings.nonce
36+
'X-WP-Nonce': configuration.nonce
3737
},
3838
ondata: (formData) => {
3939
formData.append("size", configuration.maxFileSize);
@@ -60,7 +60,7 @@ function getDragDropConfiguration(configuration) {
6060
},
6161
revert: {
6262
headers: {
63-
'X-WP-Nonce': wpApiSettings.nonce
63+
'X-WP-Nonce': configuration.nonce
6464
},
6565
url: `${configuration.rest}/delete`
6666
}

0 commit comments

Comments
 (0)