diff --git a/src/lib/Sage/Template.php b/src/lib/Sage/Template.php deleted file mode 100644 index 6c0ab98..0000000 --- a/src/lib/Sage/Template.php +++ /dev/null @@ -1,46 +0,0 @@ -wrapper = $wrapper; - self::$instances[$wrapper->slug()] = $this; - } - - /** - * @return string Layout (FQPN of, e.g., `base-page.php`, `base.php`) - */ - public function layout() - { - return $this->wrapper->wrap(); - } - - /** - * @return string Main template (FQPN of, e.g., `page.php`, `single.php`, `singular.php`) - */ - public function main() - { - return $this->wrapper->unwrap(); - } - - /** - * @param string $template Delimited template path - * @return string Partial template (FQPN of, e.g., `content.php`, `page-header.php` - */ - public function partial($template) - { - return (new Partial($template, $this->main()))->path(); - } -} diff --git a/src/lib/Sage/Template/Partial.php b/src/lib/Sage/Template/Partial.php deleted file mode 100644 index daa8dc4..0000000 --- a/src/lib/Sage/Template/Partial.php +++ /dev/null @@ -1,72 +0,0 @@ -template = $template; - $this->main = $main; - } - - public function __toString() - { - return (string) $this->path(); - } - - /** - * Converts template into array of parts to be passed to locate_template() - * - * Here's an example of what happens: - * (new Template('partials/content-single-audio'))->parts(); - * // => ['partials/content-single-audio.php', 'partials/content-single.php', 'partials/content.php'] - * @return array Array of parts to pass to locate_template() - */ - public function parts() - { - if ($parts = $this->cache('parts')) { - return $parts; - } - $parts = explode($this->delimiter, str_replace('.php', '', $this->template)); - $templates[] = array_shift($parts); - foreach ($parts as $i => $part) { - $templates[] = $templates[$i] . $this->delimiter . $part; - } - if ($this->main) { - $templates = array_merge($templates, array_map(function ($template) { - return $template . $this->delimiter . basename($this->main, '.php'); - }, $templates)); - } - $templates = array_map(function ($template) { - return $template . '.php'; - }, $templates); - return $this->cache('parts', array_reverse($templates)); - } - - /** - * Passes $this->parts() to locate_template() to retrieve template location - * @return string Location of template - */ - public function path() - { - if (!$path = $this->cache('path')) { - $path = $this->cache('path', locate_template($this->parts())); - } - return apply_filters('sage/partial_' . basename($path, '.php'), $path, $this->parts()) ?: $path; - } - - protected function cache($key, $value = null) - { - if ($value !== null) { - self::$cache[$this->template][$key] = $value; - } - return isset(self::$cache[$this->template][$key]) ? self::$cache[$this->template][$key] : null; - } -} diff --git a/src/lib/Sage/Template/Wrapper.php b/src/lib/Sage/Template/Wrapper.php deleted file mode 100644 index b751d65..0000000 --- a/src/lib/Sage/Template/Wrapper.php +++ /dev/null @@ -1,64 +0,0 @@ -slug = sanitize_title(basename($base, '.php')); - $this->wrapper = [$base]; - $this->template = $template; - $str = substr($base, 0, -4); - array_unshift($this->wrapper, sprintf($str . '-%s.php', basename($template, '.php'))); - } - - /** - * @return string - * @see getTemplate - */ - public function __toString() - { - return $this->unwrap(); - } - - /** {@inheritdoc} */ - public function wrap() - { - $wrappers = apply_filters('sage/wrap_' . $this->slug, $this->wrapper) ?: $this->wrapper; - return locate_template($wrappers); - } - - /** {@inheritdoc} */ - public function slug() - { - return $this->slug; - } - - /** {@inheritdoc} */ - public function unwrap() - { - $template = apply_filters('sage/unwrap_' . $this->slug, $this->template) ?: $this->template; - return locate_template($template) ?: $template; - } -} diff --git a/src/lib/Sage/Template/WrapperInterface.php b/src/lib/Sage/Template/WrapperInterface.php deleted file mode 100644 index dcb9eb3..0000000 --- a/src/lib/Sage/Template/WrapperInterface.php +++ /dev/null @@ -1,29 +0,0 @@ -