Merge branch '8.0.0' of github.com:roots/roots into fix-gulp-rev

Conflicts:
	gulpfile.js
	package.json
This commit is contained in:
Austin Pray
2015-01-24 11:41:59 -06:00
28 changed files with 328 additions and 839 deletions

View File

@@ -9,9 +9,9 @@ namespace Roots\Sage\Assets;
* 1. /theme/dist/styles/main.css
*
* Enqueue scripts in the following order:
* 1. jquery-1.11.2.js via Google CDN
* 1. Latest jQuery via Google CDN (if enabled in config.php)
* 2. /theme/dist/scripts/modernizr.js
* 3. /theme/dist/scripts/app.js
* 3. /theme/dist/scripts/main.js
*
* Google Analytics is loaded after enqueued scripts if:
* - An ID has been defined in config.php
@@ -54,7 +54,7 @@ function assets() {
if (!is_admin() && current_theme_supports('jquery-cdn')) {
wp_deregister_script('jquery');
wp_register_script('jquery', '//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.js', array(), null, true);
wp_register_script('jquery', '//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js', [], null, true);
add_filter('script_loader_src', __NAMESPACE__ . '\\jquery_local_fallback', 10, 2);
}
@@ -63,9 +63,9 @@ function assets() {
wp_enqueue_script('comment-reply');
}
wp_enqueue_script('modernizr', asset_path('scripts/modernizr.js'), array(), null, true);
wp_enqueue_script('modernizr', asset_path('scripts/modernizr.js'), [], null, true);
wp_enqueue_script('jquery');
wp_enqueue_script('sage_js', asset_path('scripts/app.js'), array(), null, true);
wp_enqueue_script('sage_js', asset_path('scripts/main.js'), [], null, true);
}
add_action('wp_enqueue_scripts', __NAMESPACE__ . '\\assets', 100);
@@ -91,23 +91,27 @@ add_action('wp_head', __NAMESPACE__ . '\\jquery_local_fallback');
*
* Cookie domain is 'auto' configured. See: http://goo.gl/VUCHKM
*/
function google_analytics() { ?>
<script>
<?php if (WP_ENV === 'production') : ?>
(function(b,o,i,l,e,r){b.GoogleAnalyticsObject=l;b[l]||(b[l]=
function(){(b[l].q=b[l].q||[]).push(arguments)});b[l].l=+new Date;
e=o.createElement(i);r=o.getElementsByTagName(i)[0];
e.src='//www.google-analytics.com/analytics.js';
r.parentNode.insertBefore(e,r)}(window,document,'script','ga'));
<?php else : ?>
function ga() {
console.log('GoogleAnalytics: ' + [].slice.call(arguments));
}
<?php endif; ?>
ga('create','<?php echo GOOGLE_ANALYTICS_ID; ?>','auto');ga('send','pageview');
</script>
function google_analytics() {
?>
<script>
<?php if (WP_ENV === 'production' && !current_user_can('manage_options')) : ?>
(function(b,o,i,l,e,r){b.GoogleAnalyticsObject=l;b[l]||(b[l]=
function(){(b[l].q=b[l].q||[]).push(arguments)});b[l].l=+new Date;
e=o.createElement(i);r=o.getElementsByTagName(i)[0];
e.src='//www.google-analytics.com/analytics.js';
r.parentNode.insertBefore(e,r)}(window,document,'script','ga'));
<?php else : ?>
function ga() {
if (window.console) {
console.log('Google Analytics: ' + [].slice.call(arguments));
}
}
<?php endif; ?>
ga('create','<?= GOOGLE_ANALYTICS_ID; ?>','auto');ga('send','pageview');
</script>
<?php
}
<?php }
if (GOOGLE_ANALYTICS_ID && (WP_ENV !== 'production' || !current_user_can('manage_options'))) {
if (GOOGLE_ANALYTICS_ID) {
add_action('wp_footer', __NAMESPACE__ . '\\google_analytics', 20);
}

View File

@@ -1,6 +1,7 @@
<?php
namespace Roots\Sage\Config;
use Roots\Sage\Sidebar;
/**
@@ -41,28 +42,28 @@ function display_sidebar() {
static $display;
if (!isset($display)) {
$sidebar_config = new Sidebar\Sage_Sidebar(
$sidebar_config = new Sidebar\SageSidebar(
/**
* Conditional tag checks (http://codex.wordpress.org/Conditional_Tags)
* Any of these conditional tags that return true won't show the sidebar
*
* To use a function that accepts arguments, use the following format:
*
* array('function_name', array('arg1', 'arg2'))
* ['function_name', ['arg1', 'arg2']]
*
* The second element must be an array even if there's only 1 argument.
*/
array(
[
'is_404',
'is_front_page'
),
],
/**
* Page template checks (via is_page_template())
* Any of these page templates that return true won't show the sidebar
*/
array(
[
'template-custom.php'
)
]
);
$display = apply_filters('sage/display_sidebar', $sidebar_config->display);
}

View File

@@ -36,7 +36,7 @@ function gallery($attr) {
}
}
extract(shortcode_atts(array(
extract(shortcode_atts([
'order' => 'ASC',
'orderby' => 'menu_order ID',
'id' => $post->ID,
@@ -48,7 +48,7 @@ function gallery($attr) {
'include' => '',
'exclude' => '',
'link' => ''
), $attr));
], $attr));
$id = intval($id);
$columns = (12 % $columns == 0) ? $columns: 4;
@@ -59,16 +59,16 @@ function gallery($attr) {
}
if (!empty($include)) {
$_attachments = get_posts(array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
$_attachments = get_posts(['include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby]);
$attachments = array();
$attachments = [];
foreach ($_attachments as $key => $val) {
$attachments[$val->ID] = $_attachments[$key];
}
} elseif (!empty($exclude)) {
$attachments = get_children(array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
$attachments = get_children(['post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby]);
} else {
$attachments = get_children(array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
$attachments = get_children(['post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby]);
}
if (empty($attachments)) {
@@ -93,7 +93,7 @@ function gallery($attr) {
$image = wp_get_attachment_link($id, $size, false, false);
break;
case 'none':
$image = wp_get_attachment_image($id, $size, false, array('class' => 'thumbnail img-thumbnail'));
$image = wp_get_attachment_image($id, $size, false, ['class' => 'thumbnail img-thumbnail']);
break;
default:
$image = wp_get_attachment_link($id, $size, true, false);

View File

@@ -16,9 +16,9 @@ function setup() {
// Register wp_nav_menu() menus
// http://codex.wordpress.org/Function_Reference/register_nav_menus
register_nav_menus(array(
register_nav_menus([
'primary_navigation' => __('Primary Navigation', 'sage')
));
]);
// Add post thumbnails
// http://codex.wordpress.org/Post_Thumbnails
@@ -28,14 +28,14 @@ function setup() {
// Add post formats
// http://codex.wordpress.org/Post_Formats
add_theme_support('post-formats', array('aside', 'gallery', 'link', 'image', 'quote', 'video', 'audio'));
add_theme_support('post-formats', ['aside', 'gallery', 'link', 'image', 'quote', 'video', 'audio']);
// Add HTML5 markup for captions
// http://codex.wordpress.org/Function_Reference/add_theme_support#HTML5
add_theme_support('html5', array('caption', 'comment-form', 'comment-list'));
add_theme_support('html5', ['caption', 'comment-form', 'comment-list']);
// Tell the TinyMCE editor to use a custom stylesheet
add_editor_style('/dist/css/editor-style.css');
add_editor_style('/dist/styles/editor-style.css');
}
add_action('after_setup_theme', __NAMESPACE__ . '\\setup');
@@ -43,22 +43,22 @@ add_action('after_setup_theme', __NAMESPACE__ . '\\setup');
* Register sidebars
*/
function widgets_init() {
register_sidebar(array(
register_sidebar([
'name' => __('Primary', 'sage'),
'id' => 'sidebar-primary',
'before_widget' => '<section class="widget %1$s %2$s">',
'after_widget' => '</section>',
'before_title' => '<h3>',
'after_title' => '</h3>',
));
]);
register_sidebar(array(
register_sidebar([
'name' => __('Footer', 'sage'),
'id' => 'sidebar-footer',
'before_widget' => '<section class="widget %1$s %2$s">',
'after_widget' => '</section>',
'before_title' => '<h3>',
'after_title' => '</h3>',
));
]);
}
add_action('widgets_init', __NAMESPACE__ . '\\widgets_init');

View File

@@ -9,31 +9,30 @@ namespace Roots\Sage\Nav;
* <li id="menu-item-8" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-8"><a href="/">Home</a></li>
* <li id="menu-item-9" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-9"><a href="/sample-page/">Sample Page</a></l
*
* Sage_Nav_Walker example output:
* SageNavWalker example output:
* <li class="menu-home"><a href="/">Home</a></li>
* <li class="menu-sample-page"><a href="/sample-page/">Sample Page</a></li>
*/
class Sage_Nav_Walker extends \Walker_Nav_Menu {
function check_current($classes) {
class SageNavWalker extends \Walker_Nav_Menu {
public function checkCurrent($classes) {
return preg_match('/(current[-_])|active|dropdown/', $classes);
}
function start_lvl(&$output, $depth = 0, $args = array()) {
// @codingStandardsIgnoreStart
function start_lvl(&$output, $depth = 0, $args = []) {
$output .= "\n<ul class=\"dropdown-menu\">\n";
}
function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0) {
function start_el(&$output, $item, $depth = 0, $args = [], $id = 0) {
$item_html = '';
parent::start_el($item_html, $item, $depth, $args);
if ($item->is_dropdown && ($depth === 0)) {
$item_html = str_replace('<a', '<a class="dropdown-toggle" data-toggle="dropdown" data-target="#"', $item_html);
$item_html = str_replace('</a>', ' <b class="caret"></b></a>', $item_html);
}
elseif (stristr($item_html, 'li class="divider')) {
} elseif (stristr($item_html, 'li class="divider')) {
$item_html = preg_replace('/<a[^>]*>.*?<\/a>/iU', '', $item_html);
}
elseif (stristr($item_html, 'li class="dropdown-header')) {
} elseif (stristr($item_html, 'li class="dropdown-header')) {
$item_html = preg_replace('/<a[^>]*>(.*)<\/a>/iU', '$1', $item_html);
}
@@ -50,6 +49,7 @@ class Sage_Nav_Walker extends \Walker_Nav_Menu {
parent::display_element($element, $children_elements, $max_depth, $depth, $args, $output);
}
// @codingStandardsIgnoreEnd
}
/**
@@ -82,10 +82,10 @@ add_filter('nav_menu_item_id', '__return_null');
* Clean up wp_nav_menu_args
*
* Remove the container
* Use Sage_Nav_Walker() by default
* Use SageNavWalker() by default
*/
function nav_menu_args($args = '') {
$nav_menu_args = array();
$nav_menu_args = [];
$nav_menu_args['container'] = false;

View File

@@ -14,25 +14,25 @@ namespace Roots\Sage\Sidebar;
*
* @return boolean True will display the sidebar, False will not
*/
class Sage_Sidebar {
class SageSidebar {
private $conditionals;
private $templates;
public $display = true;
function __construct($conditionals = array(), $templates = array()) {
public function __construct($conditionals = [], $templates = []) {
$this->conditionals = $conditionals;
$this->templates = $templates;
$conditionals = array_map(array($this, 'check_conditional_tag'), $this->conditionals);
$templates = array_map(array($this, 'check_page_template'), $this->templates);
$conditionals = array_map([$this, 'checkConditionalTag'], $this->conditionals);
$templates = array_map([$this, 'checkPageTemplate'], $this->templates);
if (in_array(true, $conditionals) || in_array(true, $templates)) {
$this->display = false;
}
}
private function check_conditional_tag($conditional_tag) {
private function checkConditionalTag($conditional_tag) {
$conditional_arg = is_array($conditional_tag) ? $conditional_tag[1] : false;
$conditional_tag = $conditional_arg ? $conditional_tag[0] : $conditional_tag;
@@ -43,7 +43,7 @@ class Sage_Sidebar {
}
}
private function check_page_template($page_template) {
private function checkPageTemplate($page_template) {
return is_page_template($page_template);
}
}

View File

@@ -10,29 +10,29 @@ namespace Roots\Sage\Wrapper;
*/
function template_path() {
return Sage_Wrapping::$main_template;
return SageWrapping::$main_template;
}
function sidebar_path() {
return new Sage_Wrapping('templates/sidebar.php');
return new SageWrapping('templates/sidebar.php');
}
class Sage_Wrapping {
class SageWrapping {
// Stores the full path to the main template file
public static $main_template;
// basename of template file
// Basename of template file
public $slug;
// array of templates
// Array of templates
public $templates;
// Stores the base name of the template file; e.g. 'page' for 'page.php' etc.
static $base;
public static $base;
public function __construct($template = 'base.php') {
$this->slug = basename($template, '.php');
$this->templates = array($template);
$this->templates = [$template];
if (self::$base) {
$str = substr($template, 0, -4);
@@ -45,7 +45,7 @@ class Sage_Wrapping {
return locate_template($this->templates);
}
static function wrap($main) {
public static function wrap($main) {
// Check for other filters returning null
if (!is_string($main)) {
return $main;
@@ -58,7 +58,7 @@ class Sage_Wrapping {
self::$base = false;
}
return new Sage_Wrapping();
return new SageWrapping();
}
}
add_filter('template_include', array(__NAMESPACE__ . '\\Sage_Wrapping', 'wrap'), 99);
add_filter('template_include', [__NAMESPACE__ . '\\SageWrapping', 'wrap'], 99);