Skip to content
Open
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
30225fc
Remove use of nested filters.
azaozz Apr 18, 2024
78fc27b
Merge remote-tracking branch 'upstream/trunk' into fix-uploading-of-f…
azaozz Apr 29, 2024
1617d81
Add $upload_dir as param to the font_dir filter
azaozz Apr 29, 2024
48339ed
Move _wp_filter_font_directory() to deprecated.php
azaozz Apr 29, 2024
b583c93
Merge remote-tracking branch 'upstream/trunk' into fix-uploading-of-f…
azaozz May 6, 2024
50e91f4
Merge remote-tracking branch 'upstream/trunk' into fix-uploading-of-f…
azaozz May 16, 2024
abc2610
Merge remote trunk
azaozz May 16, 2024
c4b4eb5
Merge remote-tracking branch 'upstream/trunk' into fix-uploading-of-f…
azaozz May 17, 2024
5c4039b
When creating the fonts dir use $font_dir['path'], not $font_dir['pa…
azaozz May 17, 2024
fe6d3b9
Merge remote-tracking branch 'upstream/trunk' into fix-uploading-of-f…
azaozz May 24, 2024
41ec0e8
Merge remote-tracking branch 'upstream/trunk' into fix-uploading-of-f…
azaozz May 29, 2024
86612b6
Update src/wp-includes/fonts.php
azaozz May 30, 2024
8d9e9d8
Update src/wp-includes/fonts.php
azaozz May 30, 2024
d391259
Update src/wp-admin/includes/file.php
azaozz May 30, 2024
4bad2e3
Docs: Remove @see annotations. Not needed there. Props peterwilsoncc.
azaozz May 31, 2024
076854a
Adjust the inline comment to match the changed code
azaozz May 31, 2024
d8c1cba
Merge remote-tracking branch 'upstream/trunk' into fix-uploading-of-f…
azaozz May 31, 2024
f5b0d01
Add docs and some sanity checks when using custom upload_dir data.
azaozz May 31, 2024
0a21712
Merge remote-tracking branch 'upstream/trunk' into fix-uploading-of-f…
azaozz Jul 8, 2024
95bb189
Merge remote-tracking branch 'upstream/trunk' into fix-uploading-of-f…
azaozz Jul 12, 2024
4908744
Merge remote-tracking branch 'upstream/trunk' into fix-uploading-of-f…
azaozz Jul 13, 2024
22b071c
Merge remote-tracking branch 'upstream/trunk' into fix-uploading-of-f…
azaozz Sep 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add docs and some sanity checks when using custom upload_dir data.
  • Loading branch information
azaozz committed May 31, 2024
commit f5b0d012ff7bf9bfe509c660d2d092908b833096
22 changes: 22 additions & 0 deletions src/wp-admin/includes/file.php
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,8 @@ function validate_file_to_edit( $file, $allowed_files = array() ) {
* @type string[] $mimes Array of allowed mime types keyed by their file extension regex.
* @type string[] $upload_dir Array of the uploads directory data as returned by
* wp_upload_dir() or wp_font_dir(). Defaults to wp_upload_dir().
* If using custom data array the uploads directory must exist.
* See additional comments below.
* }
* @param string $time Time formatted in 'yyyy/mm'.
* @param string $action Expected value for `$_POST['action']`.
Expand Down Expand Up @@ -975,7 +977,27 @@ function wp_handle_upload_error( &$file, $message ) {
}

if ( isset( $overrides['upload_dir'] ) ) {
/*
* As mentioned in the description $overrides['upload_dir'] is expected to be an array
* of the uploads directory data as returned by wp_uploads_dir() and wp_fonts_dir().
*
* It is possible to use custom data, however ensure the format matches exactly the array
* returned by the above fiunctions. In addition the uploads directory should exist and
* be accerssible before attempting to use it. For example that can be achieved
* by usig wp_mkdir_p(). This data can also be cached, however ensure any caching
* is reset after creating the directry.
*/
$uploads = $overrides['upload_dir'];

if ( ! is_array( $uploads ) || empty( $uploads['path'] ) || ! is_string( $uploads['path'] ) ) {
$uploads['error'] = __( 'The path to the uploads directory is incorrect.' );
} elseif ( ! is_dir( $uploads['path'] ) ) {
$uploads['error'] = __( 'The uploads directory does not exist.' );
}

if ( ! empty( $uploads['error'] ) ) {
return call_user_func_array( $upload_error_handler, array( &$file, $uploads['error'] ) );
}
} else {
$uploads = wp_upload_dir( $time );
}
Expand Down