Adding a cache for these, so repeated calls to get_template_part() for the same template don't need to loop through the array and check the filesystem.
(Assuming users wouldn't modify the template hierarchy in between requests for the same file, so the cache key is simply the first element in $template_names if it's an array or the string itself. Something like combining md5 and serialize would guard against this remote possibility but I figured that was overkill.)
Custom template data variable names
Adding a cache for these as well, so unset_template_data() can loop through them and remove each custom reference from $wp_query.
Template paths
Adding a cache for these, so repeated calls to
get_template_part()
for the same template don't need to loop through the array and check the filesystem.(Assuming users wouldn't modify the template hierarchy in between requests for the same file, so the cache key is simply the first element in
$template_names
if it's an array or the string itself. Something like combiningmd5
andserialize
would guard against this remote possibility but I figured that was overkill.)Custom template data variable names
Adding a cache for these as well, so
unset_template_data()
can loop through them and remove each custom reference from$wp_query
.