$t) { $filename = preg_replace("/^single-/m", "", $t); $tax = ""; preg_match("/[A-z0-9]+/", $filename, $tax); $tax = count($templates) - 1 <= $i ? "" : trailingslashit($tax[0]); $filename = str_replace( str_replace("/", "", $tax) . "-", "", $filename); $tmpl[] = trailingslashit($template_path) . $tax . $filename; } $tmpl[] = $template_path . "/singular.php"; self::$templates_parts = $tmpl; } /** * Generates and sets attachment file paths based on provided templates. * * @param string $template_path Base path for the templates. * @param string $type Type of attachment (not explicitly used in method logic). * @param array $templates List of template filenames. * @return void */ public static function getAttachments($template_path, $type, $templates): void { foreach($templates as $i => $t) { $folder = ""; preg_match("/^([A-z]+)-/m", $t, $folder); $folder = count($folder) > 1 ? trailingslashit($folder[1]) : ""; $filename = sanitize_file_name(str_replace(sanitize_file_name($folder), "", $t)); self::$templates_parts[] = trailingslashit($template_path) . $folder . $filename; } } /** * Updates the list of templates with taxonomy-specific paths based on the provided data. * * @param string $template_path The base path to the templates. * @param string $type The type of taxonomy being processed. * @param array $templates An array of template file names to process. * * @return void */ public static function getTaxonomies($template_path, $type, $templates): void { $tmpl = []; foreach($templates as $i => $t) { $filename = preg_replace("/^taxonomy-/m", "", $t); $tax = ""; preg_match("/[A-z0-9]+/", $filename, $tax); $tax = count($templates) - 1 <= $i ? "" : trailingslashit($tax[0]); $filename = str_replace( str_replace("/", "", $tax) . "-", "", $filename); $tmpl[] = trailingslashit($template_path) . $tax . $filename; } self::$templates_parts = $tmpl; } /** * Retrieves tags based on the provided parameters. * * @param string $template_path The path to the template. * @param string $type The type of the template. * @param array $templates The list of templates. * @return void */ public static function getTags($template_path, $type, $templates): void { self::getDefault($template_path, $type, $templates); } /** * Generates date-based template paths and appends them to the templates parts list. * * @param string $template_path The base path for the templates. * @param string $type The type of template to append. * @param array $templates Not used in this method. * @return void */ public static function getDates($template_path, $type, $templates): void { self::$templates_parts[] = is_year() ? $template_path . "/year.php" : (is_month() ? $template_path ."/month.php" : $template_path . "/day.php"); self::$templates_parts[] = $template_path . "/$type.php"; } /** * Appends a search template path to the templates array. * * @param string $template_path The base path to the templates. * @param string $type The type of the search template. * @param array $templates The list of existing templates. * @return void */ public static function getSearchs($template_path, $type, $templates): void { self::$templates_parts[] = $template_path . "/$type.php"; } /** * Retrieves and processes the components associated with the current filter hook. * * @param string $name The name of the component being retrieved. * @param mixed|null $args Optional. Additional arguments passed to the component. * @return void */ public static function getComponents($name, $args = null) { $hook_name = current_filter(); $component_name = preg_replace("/^get_/m", "", $hook_name); $template_path = get_template_directory() . "/" . TEMPLATES_DIR . "/" . TEMPLATES_SUBDIRS["components"]; self::$templates_parts[] = $template_path . "/" . $component_name . ".php"; do_action("template_render", self::$templates_parts, $hook_name); } }