WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 7 years ago

Last modified 10 months 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 7 years ago.
uploads-folder.zip (3.8 KB) - added by Denis-de-Bernardy 7 years ago.
a plugin to test the patch

Download all attachments as: .zip

Change History (12)

#1 follow-up: @Denis-de-Bernardy
7 years ago

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

there is an upload_dir filter

#2 in reply to: ↑ 1 @toemon
7 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.

#3 @dd32
7 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.

@dd32
7 years ago

#4 @dd32
7 years ago

  • Keywords needs-testing added

Attached an untested patch.

@Denis-de-Bernardy
7 years ago

a plugin to test the patch

#5 @Denis-de-Bernardy
7 years ago

uploaded a plugin that makes use of the hook for reference

#6 @westi
7 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';

#7 follow-up: @westi
7 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.

#8 in reply to: ↑ 7 @toemon
7 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.

#9 @Denis-de-Bernardy
7 years ago

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

This ticket was mentioned in Slack in #feature-respimg by joemcgill. View the logs.


10 months ago

Note: See TracTickets for help on using tickets.