diff --git a/config.php b/config.php index a79c13e..cf7e3b6 100644 --- a/config.php +++ b/config.php @@ -3,6 +3,7 @@ return [ "debug" => true, "flex-file-prefix" => "flex", + "excerpt-more-text" => "…", /** * excerpt-length @@ -75,8 +76,6 @@ return [ "menus", ], - "excerpt_more_text" => "…", - /** * disable * diff --git a/functions.php b/functions.php index 19e0a64..141adf8 100644 --- a/functions.php +++ b/functions.php @@ -5,12 +5,7 @@ require __DIR__ . '/vendor/autoload.php'; use ofc\Site; -# Declare a new Site object -$site = new Site(); - -# Allow the Site object to be accessed in other files function site(): Site { - global $site; - return $site; + return Site::getInstance(); } diff --git a/vendor/open-function-computers-llc/rad-theme-engine/src/Site.php b/vendor/open-function-computers-llc/rad-theme-engine/src/Site.php index ab5612f..171deeb 100644 --- a/vendor/open-function-computers-llc/rad-theme-engine/src/Site.php +++ b/vendor/open-function-computers-llc/rad-theme-engine/src/Site.php @@ -17,7 +17,18 @@ class Site private $templateDirectory; public $cptSlugs = []; - public function __construct($config = []) + // singleton instance goes here + private static ?Site $instance = null; + + public static function getInstance(): Site + { + if (self::$instance === null) { + self::$instance = new self(); + } + return self::$instance; + } + + private function __construct($config = []) { if ($config == [] && file_exists(TEMPLATEPATH . "/config.php")) { $config = include(TEMPLATEPATH . "/config.php"); @@ -34,8 +45,8 @@ class Site wp_dequeue_style('classic-theme-styles'); }, 20); - if (isset($this->config["excerpt_more_text"])) { - add_filter('excerpt_more', fn ($more) => $this->config["excerpt_more_text"]); + if (isset($this->config["excerpt-more-text"])) { + add_filter('excerpt_more', fn ($more) => $this->config["excerpt-more-text"]); } // disable various things @@ -601,6 +612,7 @@ class Site "flex" => \ofc\RadThemeEngine::processFlex(), "nl2br" => \ofc\RadThemeEngine::nl2br(), "assetURL" => \ofc\RadThemeEngine::assetURL(), + "assetUrl" => \ofc\RadThemeEngine::assetURL(), "assetContents" => \ofc\RadThemeEngine::assetContents(), ]; foreach ($helpers as $name => $callback) {