WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#9973 closed defect (bug) (fixed)

execute function apply_filters before wp_mkdir_p

Reported by: toemon Owned by:
Milestone: 2.8 Priority: low
Severity: normal Version: 2.7.1
Component: Upload Keywords: has-patch needs-testing
Focuses: Cc:

Description

I'm sorry. I do not understand English so much.

It is a demand of function wp_upload_dir().

I wish execute function apply_filters( ) before wp_mkdir_p( ).
because I wants to change the upload path arbitrarily by changing $uploads by using function add_filters().

Attachments (2)

9973.diff (1.0 KB) - added by dd32 6 years ago.
uploads-folder.zip (3.8 KB) - added by Denis-de-Bernardy 6 years ago.
a plugin to test the patch

Download all attachments as: .zip

Change History (11)

comment:1 follow-up: @Denis-de-Bernardy6 years ago

  • Milestone Unassigned deleted
  • Resolution set to invalid
  • Status changed from new to closed

there is an upload_dir filter

comment:2 in reply to: ↑ 1 @toemon6 years ago

  • Version changed from 2.8 to 2.7.1

Replying to Denis-de-Bernardy:

there is an upload_dir filter

thanks.
But the upload_dir filter is executed after wp_mkdir_p( ).
And, function wp_mkdir_p makes the folder for the path before it changes.

comment:3 @dd326 years ago

  • Keywords has-patch added
  • Milestone set to 2.8
  • Resolution invalid deleted
  • Status changed from closed to reopened
  • Type changed from feature request to defect (bug)

The filter should filter it before any actions are taken on it.

@dd326 years ago

comment:4 @dd326 years ago

  • Keywords needs-testing added

Attached an untested patch.

@Denis-de-Bernardy6 years ago

a plugin to test the patch

comment:5 @Denis-de-Bernardy6 years ago

uploaded a plugin that makes use of the hook for reference

comment:6 @westi6 years ago

Ok.

Moving that filter looks good.

BTW that plugin doesn't do enough to make it all work as the attachments end up still pointing at the normal url.

And it needed some patching to work around errors:

                $path = get_option( 'upload_path' );
                $path = trim($path);
                if ( !$path )
                        $path = WP_CONTENT_DIR . '/uploads';

comment:7 follow-up: @westi6 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

(In [11493]) Move the upload_dir filter before the directory is created so that plugins can have a better effect. Fixes #9973 props dd32.

comment:8 in reply to: ↑ 7 @toemon6 years ago

Replying to westi:

(In [11493]) Move the upload_dir filter before the directory is created so that plugins can have a better effect. Fixes #9973 props dd32.

Thanks All.

comment:9 @Denis-de-Bernardy6 years ago

@westi: thanks for the bug report. :-)

Note: See TracTickets for help on using tickets.