Cleanup
This commit is contained in:
@@ -8,7 +8,6 @@ use Roots\Sage\Assets\ManifestInterface;
|
||||
* @author QWp6t
|
||||
*/
|
||||
class Asset {
|
||||
|
||||
public static $dist = '/dist';
|
||||
|
||||
/** @var ManifestInterface Currently used manifest */
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
* @author QWp6t
|
||||
*/
|
||||
interface ManifestInterface {
|
||||
|
||||
/**
|
||||
* Get the cache-busted filename
|
||||
*
|
||||
|
||||
@@ -40,6 +40,7 @@ class Template {
|
||||
end(self::$wrappers);
|
||||
$slug = key(self::$wrappers);
|
||||
}
|
||||
|
||||
$template = new static(self::$wrappers[$slug]->getTemplate(), $context);
|
||||
unset(self::$wrappers[$slug]);
|
||||
return $template;
|
||||
@@ -61,9 +62,11 @@ class Template {
|
||||
public static function convertParts($template, $delimeter = '-') {
|
||||
$templateParts = explode($delimeter, str_replace('.php', '', (string) $template));
|
||||
$templates[] = array_shift($templateParts);
|
||||
|
||||
foreach ($templateParts as $i => $templatePart) {
|
||||
$templates[] = $templates[$i] . $delimeter . $templatePart;
|
||||
}
|
||||
|
||||
return array_reverse($templates);
|
||||
}
|
||||
|
||||
@@ -102,10 +105,12 @@ class Template {
|
||||
$context = $this->context;
|
||||
extract($this->context);
|
||||
ob_start();
|
||||
|
||||
if ($template = $this->locate()) {
|
||||
/** @noinspection PhpIncludeInspection */
|
||||
include $template;
|
||||
}
|
||||
|
||||
$this->html = ob_get_clean() ?: '';
|
||||
return $this->html;
|
||||
}
|
||||
@@ -118,9 +123,11 @@ class Template {
|
||||
$this->templates = self::format($template);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!is_string($template) || !(string) $template) {
|
||||
return;
|
||||
}
|
||||
|
||||
// At this point, we assume it's something like `content-single.php` or `content-single-audio.php`
|
||||
$this->templates = self::format(self::convertParts($template));
|
||||
}
|
||||
@@ -135,6 +142,7 @@ class Template {
|
||||
if (substr($template, -4, 4) === '.php') {
|
||||
return $template;
|
||||
}
|
||||
|
||||
return $template . '.php';
|
||||
}, $templates);
|
||||
}
|
||||
@@ -147,6 +155,7 @@ class Template {
|
||||
$templates = array_map(function ($template) use ($templateDir) {
|
||||
return ($templateDir ?: self::$root) . $template;
|
||||
}, $this->templates);
|
||||
|
||||
$template = locate_template($templates);
|
||||
return apply_filters('sage/locate_template', $template, $templates) ?: $template;
|
||||
}
|
||||
|
||||
@@ -41,8 +41,7 @@ class Wrapper implements WrapperInterface {
|
||||
}
|
||||
|
||||
/** {@inheritdoc} */
|
||||
public function getTemplate()
|
||||
{
|
||||
public function getTemplate() {
|
||||
return $this->template;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
* @author QWp6t
|
||||
*/
|
||||
interface WrapperInterface {
|
||||
|
||||
/**
|
||||
* Get a list of potential wrappers
|
||||
* Useful for passing to WordPress's locate_template()
|
||||
|
||||
Reference in New Issue
Block a user