From da51434648c663c1b8f6ef2a62f7fda8953c647c Mon Sep 17 00:00:00 2001 From: Ben Word Date: Sat, 10 Oct 2015 22:33:44 -0500 Subject: [PATCH 1/3] Remove DIST_DIR constant --- lib/assets.php | 4 ++-- lib/setup.php | 8 -------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/lib/assets.php b/lib/assets.php index 13d5616..87662ef 100644 --- a/lib/assets.php +++ b/lib/assets.php @@ -41,13 +41,13 @@ class JsonManifest { } function asset_path($filename) { - $dist_path = get_template_directory_uri() . DIST_DIR; + $dist_path = get_template_directory_uri() . '/dist/'; $directory = dirname($filename) . '/'; $file = basename($filename); static $manifest; if (empty($manifest)) { - $manifest_path = get_template_directory() . DIST_DIR . 'assets.json'; + $manifest_path = get_template_directory() . '/dist/' . 'assets.json'; $manifest = new JsonManifest($manifest_path); } diff --git a/lib/setup.php b/lib/setup.php index ae4fc16..7f4be5b 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -13,14 +13,6 @@ add_theme_support('soil-relative-urls'); // Enable relative URLs from Soil add_theme_support('soil-nice-search'); // Enable nice search from Soil add_theme_support('soil-jquery-cdn'); // Enable to load jQuery from the Google CDN -/** - * Configuration values - */ -if (!defined('DIST_DIR')) { - // Path to the build directory for front-end assets - define('DIST_DIR', '/dist/'); -} - /** * Theme setup */ From aa1026514d8e32f006a502e97f042a7c256ee36c Mon Sep 17 00:00:00 2001 From: Ben Word Date: Sat, 10 Oct 2015 22:48:03 -0500 Subject: [PATCH 2/3] Move Soil theme support into setup function --- lib/setup.php | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/lib/setup.php b/lib/setup.php index 7f4be5b..d030222 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -4,19 +4,18 @@ namespace Roots\Sage\Setup; use Roots\Sage\Assets; -/** - * Enable theme features - */ -add_theme_support('soil-clean-up'); // Enable clean up from Soil -add_theme_support('soil-nav-walker'); // Enable cleaner nav walker from Soil -add_theme_support('soil-relative-urls'); // Enable relative URLs from Soil -add_theme_support('soil-nice-search'); // Enable nice search from Soil -add_theme_support('soil-jquery-cdn'); // Enable to load jQuery from the Google CDN - /** * Theme setup */ function setup() { + // Enable features from Soil when plugin is activated + // https://roots.io/plugins/soil/ + add_theme_support('soil-clean-up'); + add_theme_support('soil-nav-walker'); + add_theme_support('soil-nice-search'); + add_theme_support('soil-jquery-cdn'); + add_theme_support('soil-relative-urls'); + // Make theme available for translation // Community translations can be found at https://github.com/roots/sage-translations load_theme_textdomain('sage', get_template_directory() . '/lang'); @@ -31,21 +30,21 @@ function setup() { 'primary_navigation' => __('Primary Navigation', 'sage') ]); - // Add post thumbnails + // Enable post thumbnails // http://codex.wordpress.org/Post_Thumbnails // http://codex.wordpress.org/Function_Reference/set_post_thumbnail_size // http://codex.wordpress.org/Function_Reference/add_image_size add_theme_support('post-thumbnails'); - // Add post formats + // Enable post formats // http://codex.wordpress.org/Post_Formats add_theme_support('post-formats', ['aside', 'gallery', 'link', 'image', 'quote', 'video', 'audio']); - // Add HTML5 markup for captions + // Enable HTML5 markup support // http://codex.wordpress.org/Function_Reference/add_theme_support#HTML5 add_theme_support('html5', ['caption', 'comment-form', 'comment-list', 'gallery', 'search-form']); - // Tell the TinyMCE editor to use a custom stylesheet + // Custom stylesheet for visual editor add_editor_style(Assets\asset_path('styles/editor-style.css')); } add_action('after_setup_theme', __NAMESPACE__ . '\\setup'); From 4072bb0d76bd509126814d79b1cf8a07e4766b81 Mon Sep 17 00:00:00 2001 From: Ben Word Date: Sat, 10 Oct 2015 22:58:16 -0500 Subject: [PATCH 3/3] Move CSS/JS enqueues to setup.php --- lib/assets.php | 14 +------------- lib/setup.php | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/lib/assets.php b/lib/assets.php index 87662ef..fba751c 100644 --- a/lib/assets.php +++ b/lib/assets.php @@ -3,9 +3,8 @@ namespace Roots\Sage\Assets; /** - * Scripts and stylesheets + * Get paths for assets */ - class JsonManifest { private $manifest; @@ -57,14 +56,3 @@ function asset_path($filename) { return $dist_path . $directory . $file; } } - -function assets() { - wp_enqueue_style('sage/css', asset_path('styles/main.css'), false, null); - - if (is_single() && comments_open() && get_option('thread_comments')) { - wp_enqueue_script('comment-reply'); - } - - wp_enqueue_script('sage/js', asset_path('scripts/main.js'), ['jquery'], null, true); -} -add_action('wp_enqueue_scripts', __NAMESPACE__ . '\\assets', 100); diff --git a/lib/setup.php b/lib/setup.php index d030222..a534e92 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -89,3 +89,17 @@ function display_sidebar() { return apply_filters('sage/display_sidebar', $display); } + +/** + * Theme assets + */ +function assets() { + wp_enqueue_style('sage/css', Assets\asset_path('styles/main.css'), false, null); + + if (is_single() && comments_open() && get_option('thread_comments')) { + wp_enqueue_script('comment-reply'); + } + + wp_enqueue_script('sage/js', Assets\asset_path('scripts/main.js'), ['jquery'], null, true); +} +add_action('wp_enqueue_scripts', __NAMESPACE__ . '\\assets', 100);