Skip to content

Commit d98b2fe

Browse files
committed
fix: disable upload_path and upload_url_path options
1 parent 8444dea commit d98b2fe

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/Subscriber/UploadsSubscriber.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,22 @@ public static function getSubscribedEvents(): array
8989
{
9090
return [
9191
'pre_wp_unique_filename_file_list' => ['getUniqueFilenameList', 10, 3],
92+
'pre_option_upload_path' => 'disableOption',
93+
'pre_option_upload_url_path' => 'disableOption',
9294
'upload_dir' => 'replaceUploadDirectories',
9395
'upload_size_limit' => 'overrideUploadSizeLimit',
9496
'_wp_relative_upload_path' => ['useFileManagerForRelativePath', 10, 2],
9597
];
9698
}
9799

100+
/**
101+
* Disable the option by returning an empty string.
102+
*/
103+
public function disableOption(): string
104+
{
105+
return '';
106+
}
107+
98108
/**
99109
* Get the files used for wp_unique_filename() to prevent performance issues with scandir in large directories.
100110
*/

tests/Unit/Subscriber/UploadsSubscriberTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ public function testGetSubscribedEvents()
7171

7272
$subscribedEvents = [
7373
'pre_wp_unique_filename_file_list' => ['getUniqueFilenameList', 10, 3],
74+
'pre_option_upload_path' => 'disableOption',
75+
'pre_option_upload_url_path' => 'disableOption',
7476
'upload_dir' => 'replaceUploadDirectories',
7577
'upload_size_limit' => 'overrideUploadSizeLimit',
7678
'_wp_relative_upload_path' => ['useFileManagerForRelativePath', 10, 2],

0 commit comments

Comments
 (0)