Opened 5 years ago
Last modified 4 years ago
#44083 reviewing enhancement
Add action to wp_mkdir_p() when directory is created successfully
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | Future Release | Priority: | normal |
Severity: | normal | Version: | 2.0.1 |
Component: | Filesystem API | Keywords: | good-first-bug has-patch has-unit-tests |
Focuses: | Cc: |
Description (last modified by )
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 (6)
Change History (21)
@
5 years ago
Before and after actions for directory creation has been implemented. Target attribute is set with documentation.
#2
@
5 years 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 years ago
This ticket was mentioned in Slack in #core by seusmaniqbal. View the logs.
5 years ago
#5
@
5 years ago
- Keywords needs-refresh added
@seusmaniqbal this is looking good. Handful of small things.
- Can we tweak the action names a bit more. How about
before_create_directory
/after_create_directory
. - The
@since
docblock tags don't need a description when it indicates the function is being introduced. Only when changes are made do these need notes. - Can we change the doclbock descriptions a bit? Thinking "Fires before the directory is created." and "Fires after the directory is created and the permissions are set." sound a bit better.
- For the after action, the
$target
parameter should not say attempt because it only fires if the directory is created. How about "Full path to the created directory."? - Please add spaces between the opening and closing parentheses and the contents of the actions to adhere to the coding standards.
- I think we could include the
$dir_permissions
as a second optional filter parameter. Might be useful for plugins to be able to match permissions or perform actions only when the directory has a certain permission level. - Can we move the after action below the
if()
statement? This way, if the permissions need to be reset because of the presence of a umask, the action can reasonably expect the permissions on the directory to be correct.
#7
@
5 years ago
Hello
I am trying to contribute to the WordPress first time and decided to help here a bit :) I have attached diff with all suggestions from @desrosj applied, I hope I helped
Additionally, I updated @since
to 5.0 (the same which I found in wp-includes/version.php)
This ticket was mentioned in Slack in #core by sergey. View the logs.
4 years ago
#9
@
4 years ago
- Milestone changed from Awaiting Review to 5.1
- Owner set to SergeyBiryukov
- Status changed from new to reviewing
Before and after actions for direction creation has been implemented.