Merge pull request #1558 from roots/setup-organization
Setup organization
This commit is contained in:
@@ -3,9 +3,8 @@
|
|||||||
namespace Roots\Sage\Assets;
|
namespace Roots\Sage\Assets;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scripts and stylesheets
|
* Get paths for assets
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class JsonManifest {
|
class JsonManifest {
|
||||||
private $manifest;
|
private $manifest;
|
||||||
|
|
||||||
@@ -41,13 +40,13 @@ class JsonManifest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function asset_path($filename) {
|
function asset_path($filename) {
|
||||||
$dist_path = get_template_directory_uri() . DIST_DIR;
|
$dist_path = get_template_directory_uri() . '/dist/';
|
||||||
$directory = dirname($filename) . '/';
|
$directory = dirname($filename) . '/';
|
||||||
$file = basename($filename);
|
$file = basename($filename);
|
||||||
static $manifest;
|
static $manifest;
|
||||||
|
|
||||||
if (empty($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);
|
$manifest = new JsonManifest($manifest_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,14 +56,3 @@ function asset_path($filename) {
|
|||||||
return $dist_path . $directory . $file;
|
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);
|
|
||||||
|
|||||||
@@ -4,27 +4,18 @@ namespace Roots\Sage\Setup;
|
|||||||
|
|
||||||
use Roots\Sage\Assets;
|
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
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Configuration values
|
|
||||||
*/
|
|
||||||
if (!defined('DIST_DIR')) {
|
|
||||||
// Path to the build directory for front-end assets
|
|
||||||
define('DIST_DIR', '/dist/');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Theme setup
|
* Theme setup
|
||||||
*/
|
*/
|
||||||
function 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
|
// Make theme available for translation
|
||||||
// Community translations can be found at https://github.com/roots/sage-translations
|
// Community translations can be found at https://github.com/roots/sage-translations
|
||||||
load_theme_textdomain('sage', get_template_directory() . '/lang');
|
load_theme_textdomain('sage', get_template_directory() . '/lang');
|
||||||
@@ -39,21 +30,21 @@ function setup() {
|
|||||||
'primary_navigation' => __('Primary Navigation', 'sage')
|
'primary_navigation' => __('Primary Navigation', 'sage')
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Add post thumbnails
|
// Enable post thumbnails
|
||||||
// http://codex.wordpress.org/Post_Thumbnails
|
// http://codex.wordpress.org/Post_Thumbnails
|
||||||
// http://codex.wordpress.org/Function_Reference/set_post_thumbnail_size
|
// http://codex.wordpress.org/Function_Reference/set_post_thumbnail_size
|
||||||
// http://codex.wordpress.org/Function_Reference/add_image_size
|
// http://codex.wordpress.org/Function_Reference/add_image_size
|
||||||
add_theme_support('post-thumbnails');
|
add_theme_support('post-thumbnails');
|
||||||
|
|
||||||
// Add post formats
|
// Enable post formats
|
||||||
// http://codex.wordpress.org/Post_Formats
|
// http://codex.wordpress.org/Post_Formats
|
||||||
add_theme_support('post-formats', ['aside', 'gallery', 'link', 'image', 'quote', 'video', 'audio']);
|
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
|
// http://codex.wordpress.org/Function_Reference/add_theme_support#HTML5
|
||||||
add_theme_support('html5', ['caption', 'comment-form', 'comment-list', 'gallery', 'search-form']);
|
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_editor_style(Assets\asset_path('styles/editor-style.css'));
|
||||||
}
|
}
|
||||||
add_action('after_setup_theme', __NAMESPACE__ . '\\setup');
|
add_action('after_setup_theme', __NAMESPACE__ . '\\setup');
|
||||||
@@ -98,3 +89,17 @@ function display_sidebar() {
|
|||||||
|
|
||||||
return apply_filters('sage/display_sidebar', $display);
|
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);
|
||||||
|
|||||||
Reference in New Issue
Block a user