Previously, a nested foreach() meant that dirname() was called on plugins in each iteration of the parent foreach().
This PR adds two new private properties:
plugin_dirnames
plugin_dirnames_cache
Now, dirname() will only be run on plugins if plugin_dirnames is empty, or has items but doesn't match plugin_dirnames_cache, which handles plugin changes during runtime. An additional PHPUnit test has been added to cover this latter case.
In addition, early returns have been added if $this->slugs or $this->plugins are empty.
Previously, a nested
foreach()
meant thatdirname()
was called on plugins in each iteration of the parentforeach()
.This PR adds two new
private
properties:plugin_dirnames
plugin_dirnames_cache
Now,
dirname()
will only be run on plugins ifplugin_dirnames
is empty, or has items but doesn't matchplugin_dirnames_cache
, which handles plugin changes during runtime. An additional PHPUnit test has been added to cover this latter case.In addition, early returns have been added if
$this->slugs
or$this->plugins
are empty.Props to @jrfnl for help on this one!