This commit is contained in:
Ben Word
2015-12-26 17:23:35 -06:00
parent fa0e51faa4
commit 67c190fc41
8 changed files with 26 additions and 20 deletions

View File

@@ -1,9 +1,10 @@
<?php namespace App;
/**
* Add postMessage support
* Theme customizer
*/
add_action('customize_register', function (\WP_Customize_Manager $wp_customize) {
// Add postMessage support
$wp_customize->get_setting('blogname')->transport = 'postMessage';
});
@@ -11,5 +12,5 @@ add_action('customize_register', function (\WP_Customize_Manager $wp_customize)
* Customizer JS
*/
add_action('customize_preview_init', function () {
wp_enqueue_script('sage/customizer', asset_path('scripts/customizer.js'), ['customize-preview'], null, true);
wp_enqueue_script('sage/customizer.js', asset_path('scripts/customizer.js'), ['customize-preview'], null, true);
});

View File

@@ -8,7 +8,7 @@ use Roots\Sage\Template\Wrapper;
* @link https://codex.wordpress.org/Conditional_Tags
*/
add_filter('sage/display_sidebar', function ($display) {
/** The sidebar will NOT be displayed if ANY of the following return true. */
// The sidebar will NOT be displayed if ANY of the following return true
return $display ? !in_array(true, [
is_404(),
is_front_page(),
@@ -36,15 +36,14 @@ add_filter('body_class', function (array $classes) {
});
/**
* Clean up the_excerpt()
* Add "… Continued" to the excerpt
*/
add_filter('excerpt_more', function () {
return ' &hellip; <a href="' . get_permalink() . '">' . __('Continued', 'sage') . '</a>';
});
/**
* Use Wrapper by default
* Use theme wrapper
*/
add_filter('template_include', function ($main) {
if (!is_string($main) || !(string) $main) {

View File

@@ -8,7 +8,6 @@ use Roots\Sage\Assets\ManifestInterface;
* @author QWp6t
*/
class Asset {
public static $dist = '/dist';
/** @var ManifestInterface Currently used manifest */

View File

@@ -6,7 +6,6 @@
* @author QWp6t
*/
interface ManifestInterface {
/**
* Get the cache-busted filename
*

View File

@@ -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;
}

View File

@@ -41,8 +41,7 @@ class Wrapper implements WrapperInterface {
}
/** {@inheritdoc} */
public function getTemplate()
{
public function getTemplate() {
return $this->template;
}
}

View File

@@ -6,7 +6,6 @@
* @author QWp6t
*/
interface WrapperInterface {
/**
* Get a list of potential wrappers
* Useful for passing to WordPress's locate_template()

View File

@@ -2,6 +2,14 @@
use Roots\Sage\Template;
/**
* Theme assets
*/
add_action('wp_enqueue_scripts', function () {
wp_enqueue_style('sage/main.css', asset_path('styles/main.css'), false, null);
wp_enqueue_script('sage/main.js', asset_path('scripts/main.js'), ['jquery'], null, true);
}, 100);
/**
* Theme setup
*/
@@ -29,7 +37,7 @@ add_action('after_setup_theme', function () {
add_theme_support('title-tag');
/**
* Register wp_nav_menu() menus
* Register navigation menus
* @link http://codex.wordpress.org/Function_Reference/register_nav_menus
*/
register_nav_menus([
@@ -58,7 +66,7 @@ add_action('after_setup_theme', function () {
/**
* Use main stylesheet for visual editor
* @see /assets/styles/layouts/_tinymce.scss
* @see assets/styles/layouts/_tinymce.scss
*/
add_editor_style(asset_path('styles/main.css'));
});
@@ -82,10 +90,3 @@ add_action('widgets_init', function () {
register_sidebar($config('Footer'));
});
/**
* Theme assets
*/
add_action('wp_enqueue_scripts', function () {
wp_enqueue_style('sage/main.css', asset_path('styles/main.css'), false, null);
wp_enqueue_script('sage/main.js', asset_path('scripts/main.js'), ['jquery'], null, true);
}, 100);