From 7a7881fae09f5150008974657a2d1ea552744985 Mon Sep 17 00:00:00 2001 From: skycel Date: Wed, 5 Feb 2025 01:10:06 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20-=20R=C3=A9organisation=20et=20a?= =?UTF-8?q?m=C3=A9lioration=20de=20la=20structure=20CustomThemeTree?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CustomThemeTree.php | 28 +++++++++++++++++++++++----- custom-theme-tree.php | 8 +++++--- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/CustomThemeTree.php b/CustomThemeTree.php index 5b7e464..d7bb92f 100644 --- a/CustomThemeTree.php +++ b/CustomThemeTree.php @@ -53,13 +53,23 @@ class CustomThemeTree extends TemplateLoader { $this->theme_directory = $this->theme->get_theme_root() . "/" . get_template(); $this->config_directory = "config"; - if (!file_exists($this->theme_directory . "/" . $this->config_directory . "/" . $config_file)) { - if (!is_dir($this->theme_directory . "/config" )) { - $this->config_directory = $this->create_directory("config"); + if (!file_exists(trailingslashit($this->theme_directory) . trailingslashit($this->config_directory) . "theme.php")) { + if (!is_dir(trailingslashit($this->theme_directory) . $this->config_directory )) { + $this->config_directory = $this->create_directory($this->config_directory); } - file_put_contents($this->theme_directory . "/" . $this->config_directory . "/theme.php", "theme_directory . "/" . $this->config_directory . "/theme.php", "theme_directory . "/" . $this->config_directory . "/" . $config_file; + require_once $this->theme_directory . "/" . $this->config_directory . "/" . "theme.php"; + + if (!USE_CUSTOMTREE_PLUGIN) return; + + if (is_array(CUSTOMTREE) && count(CUSTOMTREE) > 0) { + $this->default = array_merge_recursive_distinct($this->default, CUSTOMTREE); + } + + define("Skycel\CustomTree\TEMPLATES_DIR", $this->default["templates"]); + define("Skycel\CustomTree\STYLESHEETS_DIR", $this->default["stylesheets"]); $this->init(); } @@ -85,7 +95,8 @@ class CustomThemeTree extends TemplateLoader { // Component loader $default_components = [ "header", "footer", - "sidebar", "search_form" + "sidebar", "search_form", + "topbar" ]; foreach ($default_components as $component) { add_filter("get_$component", [TemplateLoader::class, 'getComponents'], 10, 2); @@ -156,6 +167,13 @@ class CustomThemeTree extends TemplateLoader { * @return void */ private function create_required_files(): void { + // Create Wordpress required files + if (!file_exists($this->theme_directory . "/index.php")) file_put_contents($this->theme_directory . "/index.php", "theme_directory . "/header.php")) file_put_contents($this->theme_directory . "/header.php", "theme_directory . "/footer.php")) file_put_contents($this->theme_directory . "/footer.php", "theme_directory . "/" . STYLESHEETS_DIR . "/style.css")) file_put_contents($this->theme_directory . "/" . STYLESHEETS_DIR . "/css/style.css", ""); + // Create CustomThemeTree required files if (!file_exists($this->theme_directory . "/" . TEMPLATES_DIR . "/index.php")) file_put_contents($this->theme_directory . "/" . TEMPLATES_DIR . "/index.php", "New Files tree is operational !';"); if (!file_exists($this->theme_directory . "/" . TEMPLATES_DIR . "/components/header.php")) file_put_contents($this->theme_directory . "/" . TEMPLATES_DIR . "/components/header.php", "