Skip to content

Commit 2435d85

Browse files
committed
Merge pull request roots#1558 from roots/setup-organization
Setup organization
2 parents acd8f5a + 4072bb0 commit 2435d85

File tree

2 files changed

+29
-36
lines changed

2 files changed

+29
-36
lines changed

lib/assets.php

+3-15
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
namespace Roots\Sage\Assets;
44

55
/**
6-
* Scripts and stylesheets
6+
* Get paths for assets
77
*/
8-
98
class JsonManifest {
109
private $manifest;
1110

@@ -41,13 +40,13 @@ public function getPath($key = '', $default = null) {
4140
}
4241

4342
function asset_path($filename) {
44-
$dist_path = get_template_directory_uri() . DIST_DIR;
43+
$dist_path = get_template_directory_uri() . '/dist/';
4544
$directory = dirname($filename) . '/';
4645
$file = basename($filename);
4746
static $manifest;
4847

4948
if (empty($manifest)) {
50-
$manifest_path = get_template_directory() . DIST_DIR . 'assets.json';
49+
$manifest_path = get_template_directory() . '/dist/' . 'assets.json';
5150
$manifest = new JsonManifest($manifest_path);
5251
}
5352

@@ -57,14 +56,3 @@ function asset_path($filename) {
5756
return $dist_path . $directory . $file;
5857
}
5958
}
60-
61-
function assets() {
62-
wp_enqueue_style('sage/css', asset_path('styles/main.css'), false, null);
63-
64-
if (is_single() && comments_open() && get_option('thread_comments')) {
65-
wp_enqueue_script('comment-reply');
66-
}
67-
68-
wp_enqueue_script('sage/js', asset_path('scripts/main.js'), ['jquery'], null, true);
69-
}
70-
add_action('wp_enqueue_scripts', __NAMESPACE__ . '\\assets', 100);

lib/setup.php

+26-21
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,18 @@
44

55
use Roots\Sage\Assets;
66

7-
/**
8-
* Enable theme features
9-
*/
10-
add_theme_support('soil-clean-up'); // Enable clean up from Soil
11-
add_theme_support('soil-nav-walker'); // Enable cleaner nav walker from Soil
12-
add_theme_support('soil-relative-urls'); // Enable relative URLs from Soil
13-
add_theme_support('soil-nice-search'); // Enable nice search from Soil
14-
add_theme_support('soil-jquery-cdn'); // Enable to load jQuery from the Google CDN
15-
16-
/**
17-
* Configuration values
18-
*/
19-
if (!defined('DIST_DIR')) {
20-
// Path to the build directory for front-end assets
21-
define('DIST_DIR', '/dist/');
22-
}
23-
247
/**
258
* Theme setup
269
*/
2710
function setup() {
11+
// Enable features from Soil when plugin is activated
12+
// https://roots.io/plugins/soil/
13+
add_theme_support('soil-clean-up');
14+
add_theme_support('soil-nav-walker');
15+
add_theme_support('soil-nice-search');
16+
add_theme_support('soil-jquery-cdn');
17+
add_theme_support('soil-relative-urls');
18+
2819
// Make theme available for translation
2920
// Community translations can be found at https://github.com/roots/sage-translations
3021
load_theme_textdomain('sage', get_template_directory() . '/lang');
@@ -39,21 +30,21 @@ function setup() {
3930
'primary_navigation' => __('Primary Navigation', 'sage')
4031
]);
4132

42-
// Add post thumbnails
33+
// Enable post thumbnails
4334
// http://codex.wordpress.org/Post_Thumbnails
4435
// http://codex.wordpress.org/Function_Reference/set_post_thumbnail_size
4536
// http://codex.wordpress.org/Function_Reference/add_image_size
4637
add_theme_support('post-thumbnails');
4738

48-
// Add post formats
39+
// Enable post formats
4940
// http://codex.wordpress.org/Post_Formats
5041
add_theme_support('post-formats', ['aside', 'gallery', 'link', 'image', 'quote', 'video', 'audio']);
5142

52-
// Add HTML5 markup for captions
43+
// Enable HTML5 markup support
5344
// http://codex.wordpress.org/Function_Reference/add_theme_support#HTML5
5445
add_theme_support('html5', ['caption', 'comment-form', 'comment-list', 'gallery', 'search-form']);
5546

56-
// Tell the TinyMCE editor to use a custom stylesheet
47+
// Custom stylesheet for visual editor
5748
add_editor_style(Assets\asset_path('styles/editor-style.css'));
5849
}
5950
add_action('after_setup_theme', __NAMESPACE__ . '\\setup');
@@ -98,3 +89,17 @@ function display_sidebar() {
9889

9990
return apply_filters('sage/display_sidebar', $display);
10091
}
92+
93+
/**
94+
* Theme assets
95+
*/
96+
function assets() {
97+
wp_enqueue_style('sage/css', Assets\asset_path('styles/main.css'), false, null);
98+
99+
if (is_single() && comments_open() && get_option('thread_comments')) {
100+
wp_enqueue_script('comment-reply');
101+
}
102+
103+
wp_enqueue_script('sage/js', Assets\asset_path('scripts/main.js'), ['jquery'], null, true);
104+
}
105+
add_action('wp_enqueue_scripts', __NAMESPACE__ . '\\assets', 100);

0 commit comments

Comments
 (0)