Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup organization #1558

Merged
merged 3 commits into from
Oct 13, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 3 additions & 15 deletions lib/assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
namespace Roots\Sage\Assets;

/**
* Scripts and stylesheets
* Get paths for assets
*/

class JsonManifest {
private $manifest;

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

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

Expand All @@ -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);
47 changes: 26 additions & 21 deletions lib/setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,18 @@

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
*/
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');
Expand All @@ -39,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');
Expand Down Expand Up @@ -98,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);