⚰️ - Supprime le code mort et réorganise les inclusions dans le plugin CustomThemeTree
This commit is contained in:
parent
ed86100a4b
commit
6a50f12edb
@ -38,7 +38,6 @@ class CustomThemeTree extends TemplateLoader {
|
||||
]
|
||||
);
|
||||
|
||||
public function __construct($dirs = null, $config_file = "theme.php") {
|
||||
|
||||
/**
|
||||
* Constructor method to initialize theme settings and configuration.
|
||||
@ -59,7 +58,6 @@ class CustomThemeTree extends TemplateLoader {
|
||||
}
|
||||
file_put_contents($this->theme_directory . "/" . $this->config_directory . "/theme.php", "<?php\n\nconst USE_GITKEEP = true;\n\nconst USE_CUSTOMTREE_PLUGIN = true;\nconst CUSTOMTREE = array()");
|
||||
}
|
||||
require_once $this->theme_directory . "/" . $this->config_directory . "/" . $config_file;
|
||||
require_once $this->theme_directory . "/" . $this->config_directory . "/" . "theme.php";
|
||||
|
||||
if (!USE_CUSTOMTREE_PLUGIN) return;
|
||||
@ -110,7 +108,6 @@ class CustomThemeTree extends TemplateLoader {
|
||||
*/
|
||||
private function create_custom_directories(): void {
|
||||
// Make all directories for templates
|
||||
|
||||
$this->templates_directory = $this->create_directory(TEMPLATES_DIR);
|
||||
|
||||
if (!defined("TEMPLATES_SUBDIRS")) {
|
||||
@ -179,6 +176,5 @@ class CustomThemeTree extends TemplateLoader {
|
||||
if (!file_exists($this->theme_directory . "/" . TEMPLATES_DIR . "/components/header.php")) file_put_contents($this->theme_directory . "/" . TEMPLATES_DIR . "/components/header.php", "<?php\n\n");
|
||||
if (!file_exists($this->theme_directory . "/" . TEMPLATES_DIR . "/components/footer.php")) file_put_contents($this->theme_directory . "/" . TEMPLATES_DIR . "/components/footer.php", "<?php\n\n");
|
||||
|
||||
if (!file_exists($this->theme_directory . "/" . STYLESHEETS_DIR . "/style.css")) file_put_contents($this->theme_directory . "/" . STYLESHEETS_DIR . "/css/style.css", "");
|
||||
}
|
||||
}
|
@ -2,7 +2,6 @@
|
||||
|
||||
namespace Skycel\CustomTree;
|
||||
|
||||
use Error;
|
||||
use WP_Error;
|
||||
|
||||
/**
|
||||
@ -256,31 +255,7 @@ class TemplateLoader {
|
||||
$template_path = get_template_directory() . "/" . TEMPLATES_DIR . "/" . TEMPLATES_SUBDIRS["components"];
|
||||
|
||||
self::$templates_parts[] = $template_path . "/" . $component_name . ".php";
|
||||
// comments_template();
|
||||
|
||||
do_action("template_render", self::$templates_parts, $hook_name);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Old code
|
||||
|
||||
|
||||
|
||||
/*public static function getComponents($name, $args):string {
|
||||
global $wp_stylesheet_path;
|
||||
$wp_stylesheet_path = get_theme_root() . "/" . get_template() . "/" . TEMPLATES_DIR . "/" . TEMPLATES_SUBDIRS["components"];
|
||||
|
||||
$hook_name = current_filter();
|
||||
|
||||
$component_name = preg_replace("/^get_/m", "", $hook_name);
|
||||
|
||||
$file = $wp_stylesheet_path . "/" . $component_name . ".php";
|
||||
|
||||
if (file_exists($file)) {
|
||||
return $file;
|
||||
} else {
|
||||
return throw new Error("Template file not found: " . $file);
|
||||
}
|
||||
}*/
|
||||
}
|
@ -9,22 +9,9 @@
|
||||
|
||||
use Skycel\CustomTree\CustomThemeTree;
|
||||
|
||||
require_once __DIR__ . "/custom-template.php";
|
||||
require_once __DIR__ . "/functions.php";
|
||||
require_once __DIR__ . "/includes/custom-template.inc.php";
|
||||
require_once __DIR__ . "/includes/functions.inc.php";
|
||||
|
||||
function test_plugin(): void {
|
||||
if (!\defined('USE_CUSTOMTREE_PLUGIN') || USE_CUSTOMTREE_PLUGIN !== true) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!\defined("CUSTOMTREE") || !is_array(CUSTOMTREE)) {
|
||||
new CustomThemeTree();
|
||||
} else {
|
||||
new CustomThemeTree(\CUSTOMTREE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the custom tree plugin if enabled and properly configured.
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user