Conform to new rules

This commit is contained in:
QWp6t
2015-12-27 23:42:11 -08:00
committed by Ben Word
parent 2d02544173
commit 6a4d3bd51a
12 changed files with 306 additions and 281 deletions

View File

@@ -5,55 +5,61 @@
* @package Roots\Sage
* @author QWp6t
*/
class Wrapper implements WrapperInterface {
/** @var string Wrapper slug */
protected $slug;
class Wrapper implements WrapperInterface
{
/** @var string Wrapper slug */
protected $slug;
/** @var string Template file that is being wrapped */
protected $template = '';
/** @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 $wrapper = [];
/** @var string[] Array of template wrappers; e.g., `base-singular.php`, `base-page.php`, `base.php` */
protected $wrapper = [];
/** @var string[] Cache template locations */
protected static $locations = [];
/** @var string[] Cache template locations */
protected static $locations = [];
/**
* Wrapper constructor
*
* @param string $template Template file, as from Template Heirarchy; e.g., `page.php`, `single.php`, `singular.php`
* @param string $base Wrapper's base template, this is what will wrap around $template
*/
public function __construct($template, $base = 'layouts/base.php') {
$this->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')));
}
/**
* Wrapper constructor
*
* @param string $template Template file, as from Template Heirarchy; e.g., `page.php`, `single.php`, `singular.php`
* @param string $base Wrapper's base template, this is what will wrap around $template
*/
public function __construct($template, $base = 'layouts/base.php')
{
$this->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->getTemplate();
}
/**
* @return string
* @see getTemplate
*/
public function __toString()
{
return $this->getTemplate();
}
/** {@inheritdoc} */
public function getWrapper() {
$wrappers = apply_filters('sage/wrap_' . $this->slug, $this->wrapper) ?: $this->wrapper;
return locate_template($wrappers);
}
/** {@inheritdoc} */
public function getWrapper()
{
$wrappers = apply_filters('sage/wrap_' . $this->slug, $this->wrapper) ?: $this->wrapper;
return locate_template($wrappers);
}
/** {@inheritdoc} */
public function getSlug() {
return $this->slug;
}
/** {@inheritdoc} */
public function getSlug()
{
return $this->slug;
}
/** {@inheritdoc} */
public function getTemplate() {
$template = apply_filters('sage/unwrap_' . $this->slug, $this->template) ?: $this->template;
return locate_template($template);
}
/** {@inheritdoc} */
public function getTemplate()
{
$template = apply_filters('sage/unwrap_' . $this->slug, $this->template) ?: $this->template;
return locate_template($template);
}
}