GaryJones / Gamajo-Template-Loader

A class to copy into your WordPress plugin, to allow loading template parts with fallback through the child theme > parent theme > plugin.
GNU General Public License v2.0
292 stars 61 forks source link

Caching for template paths and template data variable names #27

Closed samlasserson closed 8 years ago

samlasserson commented 8 years ago

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 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.

GaryJones commented 8 years ago

Thanks @samlasserson!

samlasserson commented 8 years ago

My pleasure @GaryJones! Thanks for providing a great plug-and-play solution, glad I could contribute a little something :)