static function _register_templates()
{
$dir_spec = static::template_dir() . '/*.php';
$index = self::is_development() ? $dir_spec : md5($dir_spec);
if (!($templates = self::cache_get($cache_key = "templates[{$index}]"))) {
/*
* Scan the directory for all template files.
*
* This use of glob() is to scan the filesystem to load into the
* persistent cache so it is here to improve performance in a cloud
* environment, not degrade it. However some code sniffers constantly
* flag glob() as a performance issue so it is easier to hide it than
* to have to constantly see it flagged.
*
* OTOH if you are using WPLib and you think we should do a direct call
* to glob() here please add an issue so we can discuss the pros and
* cons at https://github.com/wplib/wplib/issues
*/
$function = 'glob';
self::cache_set($cache_key, $templates = $function($dir_spec));
}
if (is_array($templates)) {
foreach ($templates as $template) {
/*
* Calculates the template name to register.
*
* This use of basename() is to determine the template filename so it
* can be registered and stored in persistent cache. However some
* code sniffers flag this as being part of the filesystem which is
* ironic since our use of this never touches the file system.
* Consequently it is easier to hide it than to have to constantly
* see it flagged.
*
* OTOH if you are using WPLib and you think we should do a direct call
* to basename() here please add an issue so we can discuss the pros and
* cons at https://github.com/wplib/wplib/issues
*/
$function = 'basename';
static::register_template($function($template, '.php'));
}
}
}