[wp-trac] [WordPress Trac] #6531: Recursively search for files in theme and plugin editors
WordPress Trac
noreply at wordpress.org
Wed Oct 4 22:37:22 UTC 2017
#6531: Recursively search for files in theme and plugin editors
-------------------------------------------------+-------------------------
Reporter: torbens | Owner:
Type: defect (bug) | WraithKenny
Priority: high | Status: reviewing
Component: Themes | Milestone: 4.9
Severity: minor | Version: 2.5
Keywords: theme-editor has-patch has-unit- | Resolution:
tests | Focuses:
| administration
-------------------------------------------------+-------------------------
Changes (by schlessera):
* keywords: theme-editor has-patch needs-unit-tests => theme-editor has-
patch has-unit-tests
Comment:
Starting from @WraithKenny 's 6531.9.diff patch, I did the following
changes:
* I switched the `list_files()` implementation from a recursive function
to an iterator-based approach.
* The max. `$level` argument has been deprecated, as it doesn't make any
sense with iterators. I kept it in the signature though to stay safe wrt
BC. If we know this is not used, we can remove it from the signature to
clean up the code.
* The function returns an iterator object, not an array. This allows
consuming code to add further filtering, while working as usual with
`foreach()` loops.
* The iterator returns `SplFileInfo` objects. You can retrieve the path
or the filename individually from these. Casting them to a string will
result in a filename that includes the absolute path.
* I moved the exclusions filter from `list_info()` to
`get_plugin_files()`. As a result, the filter was renamed to
`get_plugin_files_exclusions`.
* I added the possibility to match a regex. This helps further filtering
files.
* I added the possibility to choose whether to skip hidden files or not.
* I truncated the transient label and added an md5 to keep it unique.
* I added basic unit tests for the `list_files()` function.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/6531#comment:59>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list