Compare commits

...

4 Commits

2 changed files with 19 additions and 1 deletions

View File

@ -17,7 +17,8 @@
"larapack/dd": "^1.1" "larapack/dd": "^1.1"
}, },
"suggest": { "suggest": {
"larapack/dd": "Required to use the dd method." "larapack/dd": "Required to use the dd method.",
"roots/wordpress": "This package need Wordpress environment to be used."
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {

View File

@ -12,6 +12,7 @@ use WP_Error;
class TemplateLoader { class TemplateLoader {
static array $templates_parts; static array $templates_parts;
private static $template_loaded = false;
/** /**
* Initializes the template rendering process. * Initializes the template rendering process.
@ -23,6 +24,7 @@ class TemplateLoader {
foreach ($templates_path as $path) { foreach ($templates_path as $path) {
if (file_exists($path)) { if (file_exists($path)) {
load_template($path); load_template($path);
self::$template_loaded = true;
} }
} }
@ -40,6 +42,7 @@ class TemplateLoader {
* @return void * @return void
*/ */
public static function getTemplates($template, $type, $templates) { public static function getTemplates($template, $type, $templates) {
if (self::$template_loaded) return;
if ($type === "home" || $type === "frontpage") $type = "page"; if ($type === "home" || $type === "frontpage") $type = "page";
$key = (int)$type !== 0 ? "errors" : preg_replace("/y$/m", "ie", $type)."s"; $key = (int)$type !== 0 ? "errors" : preg_replace("/y$/m", "ie", $type)."s";
@ -129,6 +132,20 @@ class TemplateLoader {
self::getDefault($template_path, $type, $templates); self::getDefault($template_path, $type, $templates);
} }
/**
* Processes and updates the singular templates by delegating to the default handler.
*
* @param string $template_path The base path to the templates used for singular views.
* @param string $type The specific type of singular content being processed.
* @param array $templates An array of template file names for singular content.
*
* @return void
*/
public static function getSingulars($template_path, $type, $templates): void {
self::getDefault($template_path, $type, $templates);
}
/** /**
* Generates an array of single templates with processed paths and stores them in the template parts. * Generates an array of single templates with processed paths and stores them in the template parts.
* *