WordPress.org

Make WordPress Core

Opened 6 weeks ago

Last modified 5 weeks ago

#44083 new enhancement

Add action to wp_mkdir_p() when directory is created successfully

Reported by: johnjamesjacoby Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 2.0.1
Component: Filesystem API Keywords: good-first-bug has-patch
Focuses: Cc:

Description (last modified by johnjamesjacoby)

It would be nice if the wp_mkdir_p() function contained a hook for plugins to interact with when a directory gets created.

The use-case I have currently is that Easy Digital Downloads (for example) creates .htaccess files and empty index.php files in its own uploads/edd directory, and each directory inside it, as one way of protecting those empty directories from being publicly browsable.

Because there is no action hook here, EDD uses a daily transient, which leaves new directories potentially open until the transient expires.

An action hook on directory creation would allow for EDD to create those files immediately.

Attachments (3)

44083.1.diff (573 bytes) - added by nx2017 6 weeks ago.
Before and after actions for direction creation has been implemented.
44083.2.diff (930 bytes) - added by nx2017 6 weeks ago.
Before and after actions for directory creation has been implemented. Target attribute is set with documentation.
44083.3.diff (871 bytes) - added by seusmaniqbal 5 weeks ago.

Download all attachments as: .zip

Change History (6)

#1 @johnjamesjacoby
6 weeks ago

  • Description modified (diff)

@nx2017
6 weeks ago

Before and after actions for direction creation has been implemented.

@nx2017
6 weeks ago

Before and after actions for directory creation has been implemented. Target attribute is set with documentation.

@seusmaniqbal
5 weeks ago

#2 @seusmaniqbal
5 weeks ago

  • Keywords has-patch added; needs-patch removed

Following concerns about the above patch:

  • Remove extra line from the inline documentation.
  • As for the hook, I think it should be more specific with its name like before_directory_creation.

Thanks

This ticket was mentioned in Slack in #core by abdullahramzan. View the logs.


5 weeks ago

Note: See TracTickets for help on using tickets.