Rename app to src

This commit is contained in:
QWp6t
2015-12-19 16:52:05 -08:00
committed by Ben Word
parent 9283bbbfb3
commit f752470b33
14 changed files with 8 additions and 8 deletions

View File

@@ -0,0 +1,48 @@
<?php namespace Roots\Sage\Template;
/**
* Class Wrapper
* @package Roots\Sage
* @author QWp6t
*/
class Wrapper implements WrapperInterface {
/** @var string Wrapper slug */
protected $slug;
/** @var string Template file that is being wrapped */
protected $template = '';
/** @var string[] Array of template wrappers; e.g., `base-singular.php`, `base-page.php`, `base.php` */
protected $wrappers = [];
/**
* Wrapper constructor
*
* @param string $templateSlug Template slug, typically from Template Heirarchy; e.g., `page`, `single`, `singular`
* @param string $base Wrapper's base template, this is what will wrap around $template
*/
public function __construct($templateSlug, $base = 'layouts/base.php') {
$this->slug = sanitize_title(basename($base, '.php'));
$this->wrappers = [$base];
$this->template = $templateSlug;
$str = substr($base, 0, -4);
array_unshift($this->wrappers, sprintf($str . '-%s.php', $templateSlug));
}
/** {@inheritdoc} */
public function getWrappers() {
$this->wrappers = apply_filters('sage/wrap_' . $this->slug, $this->wrappers) ?: $this->wrappers;
return $this->wrappers;
}
/** {@inheritdoc} */
public function getSlug() {
return $this->slug;
}
/** {@inheritdoc} */
public function getTemplate()
{
return $this->template;
}
}

View File

@@ -0,0 +1,27 @@
<?php namespace Roots\Sage\Template;
/**
* Interface WrapperInterface
* @package Roots\Sage
* @author QWp6t
*/
interface WrapperInterface {
/**
* Get a list of potential wrappers
* Useful for passing to WordPress's locate_template()
*
* @return string[] List of wrappers; e.g., `base-page.php`, `base.php`
*/
public function getWrappers();
/**
* @return string Template file that is being wrapped; e.g., `page.php`, `single.php`, `singular.php`
*/
public function getTemplate();
/**
* @return string Slug of the WrapperInterface; e.g., `base`
*/
public function getSlug();
}