diff --git a/.jscsrc b/.jscsrc new file mode 100644 index 0000000..0dbec3a --- /dev/null +++ b/.jscsrc @@ -0,0 +1,95 @@ +{ + "requireCurlyBraces": [ + "if", + "else", + "for", + "while", + "do", + "try", + "catch" + ], + "requireOperatorBeforeLineBreak": true, + "requireCamelCaseOrUpperCaseIdentifiers": true, + "maximumLineLength": { + "value": 80, + "allowComments": true, + "allowRegex": true + }, + "validateIndentation": 2, + "validateQuoteMarks": "'", + "disallowMultipleLineStrings": true, + "disallowMixedSpacesAndTabs": true, + "disallowTrailingWhitespace": true, + "disallowSpaceAfterPrefixUnaryOperators": true, + "disallowMultipleVarDecl": true, + "disallowKeywordsOnNewLine": [ + "else" + ], + "requireSpaceAfterKeywords": [ + "if", + "else", + "for", + "while", + "do", + "switch", + "return", + "try", + "catch" + ], + "requireSpaceBeforeBinaryOperators": [ + "=", + "+=", + "-=", + "*=", + "/=", + "%=", + "<<=", + ">>=", + ">>>=", + "&=", + "|=", + "^=", + "+=", + "+", + "-", + "*", + "/", + "%", + "<<", + ">>", + ">>>", + "&", + "|", + "^", + "&&", + "||", + "===", + "==", + ">=", + "<=", + "<", + ">", + "!=", + "!==" + ], + "requireSpaceAfterBinaryOperators": true, + "requireSpacesInConditionalExpression": true, + "requireSpaceBeforeBlockStatements": true, + "requireSpacesInForStatement": true, + "requireLineFeedAtFileEnd": true, + "requireSpacesInFunctionExpression": { + "beforeOpeningCurlyBrace": true + }, + "disallowSpacesInAnonymousFunctionExpression": { + "beforeOpeningRoundBrace": true + }, + "disallowSpacesInsideObjectBrackets": "all", + "disallowSpacesInsideArrayBrackets": "all", + "disallowSpacesInsideParentheses": true, + "validateJSDoc": { + "checkParamNames": true, + "requireParamTypes": true + }, + "disallowMultipleLineBreaks": true, + "disallowNewlineBeforeBlockStatements": true +} diff --git a/.jshintrc b/.jshintrc index 136eae5..02b1ec4 100644 --- a/.jshintrc +++ b/.jshintrc @@ -11,6 +11,5 @@ "newcap": true, "noarg": true, "node": true, - "strict": false, - "trailing": true + "strict": false } diff --git a/.travis.yml b/.travis.yml index 2228c1a..347d1c7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,9 +5,15 @@ php: - '5.6' - '5.5' - '5.4' + before_install: - - npm install -g bower + - npm install -g bower gulp jscs - npm install + - pyrus install pear/PHP_CodeSniffer + - phpenv rehash + script: - npm run build - npm run jshint + - npm run jscs + - phpcs --standard=ruleset.xml --extensions=php -n -s . diff --git a/CHANGELOG.md b/CHANGELOG.md index f74ccb4..c4ae76f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,15 @@ ### 8.0.0: TBD * Change theme name from Roots to Sage +* Bump required PHP version to >=5.4 +* Add coding standards based on PSR-2 * Add namespace +* Use short array syntax +* Use short echo syntax * Switch from Grunt to gulp, new workflow * Use wiredep for Sass and Less injection * Implement JSON file based asset pipeline * Re-organize asset file structure +* Use the theme styles for the editor stylesheet * Remove theme activation, move to [wp-cli-theme-activation](https://github.com/roots/wp-cli-theme-activation) * Add Travis CI * Update to jQuery 1.11.2 diff --git a/README.md b/README.md index cf8e3e3..bbcaac8 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,13 @@ Sage is a WordPress starter theme based on [HTML5 Boilerplate](http://html5boile * Newsletter: [Subscribe](http://roots.io/subscribe/) * Forum: [http://discourse.roots.io/](http://discourse.roots.io/) +## Requirements + +* PHP >= 5.4 +* Node.js >= 0.10 +* gulp (`npm install -g gulp`) +* Bower (`npm install -g bower`) + ## Features * [gulp](http://gulpjs.com/) for compiling Sass and LESS, checking for JavaScript errors, live reloading, concatenating and minifying files, and versioning assets diff --git a/assets/manifest.json b/assets/manifest.json index 443fed3..5e7f254 100644 --- a/assets/manifest.json +++ b/assets/manifest.json @@ -1,6 +1,6 @@ { "dependencies": { - "app.js": { + "main.js": { "files": [ "scripts/**/*", "scripts/main.js" diff --git a/assets/scripts/main.js b/assets/scripts/main.js index d736143..95502eb 100644 --- a/assets/scripts/main.js +++ b/assets/scripts/main.js @@ -16,61 +16,66 @@ (function($) { -// Use this variable to set up the common and page specific functions. If you -// rename this variable, you will also need to rename the namespace below. -var Sage = { - // All pages - common: { - init: function() { - // JavaScript to be fired on all pages + // Use this variable to set up the common and page specific functions. If you + // rename this variable, you will also need to rename the namespace below. + var Sage = { + // All pages + 'common': { + init: function() { + // JavaScript to be fired on all pages + }, + finalize: function() { + // JavaScript to be fired on all pages, after page specific JS is fired + } }, - finalize: function() { - // JavaScript to be fired on all pages, after page specific JS is fired - } - }, - // Home page - home: { - init: function() { - // JavaScript to be fired on the home page + // Home page + 'home': { + init: function() { + // JavaScript to be fired on the home page + }, + finalize: function() { + // JavaScript to be fired on the home page, after the init JS + } }, - finalize: function() { - // JavaScript to be fired on the home page, after the init JS + // About us page, note the change from about-us to about_us. + 'about_us': { + init: function() { + // JavaScript to be fired on the about us page + } } - }, - // About us page, note the change from about-us to about_us. - about_us: { - init: function() { - // JavaScript to be fired on the about us page + }; + + // The routing fires all common scripts, followed by the page specific scripts. + // Add additional events for more control over timing e.g. a finalize event + var UTIL = { + fire: function(func, funcname, args) { + var fire; + var namespace = Sage; + funcname = (funcname === undefined) ? 'init' : funcname; + fire = func !== ''; + fire = fire && namespace[func]; + fire = fire && typeof namespace[func][funcname] === 'function'; + + if (fire) { + namespace[func][funcname](args); + } + }, + loadEvents: function() { + // Fire common init JS + UTIL.fire('common'); + + // Fire page-specific init JS, and then finalize JS + $.each(document.body.className.replace(/-/g, '_').split(/\s+/), function(i, classnm) { + UTIL.fire(classnm); + UTIL.fire(classnm, 'finalize'); + }); + + // Fire common finalize JS + UTIL.fire('common', 'finalize'); } - } -}; + }; -// The routing fires all common scripts, followed by the page specific scripts. -// Add additional events for more control over timing e.g. a finalize event -var UTIL = { - fire: function(func, funcname, args) { - var namespace = Sage; - funcname = (funcname === undefined) ? 'init' : funcname; - if (func !== '' && namespace[func] && typeof namespace[func][funcname] === 'function') { - namespace[func][funcname](args); - } - }, - loadEvents: function() { - // Fire common init JS - UTIL.fire('common'); - - // Fire page-specific init JS, and then finalize JS - $.each(document.body.className.replace(/-/g, '_').split(/\s+/),function(i,classnm) { - UTIL.fire(classnm); - UTIL.fire(classnm, 'finalize'); - }); - - // Fire common finalize JS - UTIL.fire('common', 'finalize'); - } -}; - -// Load Events -$(document).ready(UTIL.loadEvents); + // Load Events + $(document).ready(UTIL.loadEvents); })(jQuery); // Fully reference jQuery after this point. diff --git a/assets/styles/editor-style.less b/assets/styles/editor-style.less index cdd4cf1..56abf72 100644 --- a/assets/styles/editor-style.less +++ b/assets/styles/editor-style.less @@ -1,687 +1,5 @@ -/** - * Updating this file with Bootstrap changes: - * - * 1. Go to http://getbootstrap.com/customize/ - * 2. Un-toggle everything - * 3. Check: 'Typography' - * 4. Download - * 5. Remove margin property on body tag - */ +@import "main.less"; -html { - font-family: sans-serif; - -ms-text-size-adjust: 100%; - -webkit-text-size-adjust: 100%; -} -article, -aside, -details, -figcaption, -figure, -footer, -header, -hgroup, -main, -nav, -section, -summary { - display: block; -} -audio, -canvas, -progress, -video { - display: inline-block; - vertical-align: baseline; -} -audio:not([controls]) { - display: none; - height: 0; -} -[hidden], -template { - display: none; -} -a { - background: transparent; -} -a:active, -a:hover { - outline: 0; -} -abbr[title] { - border-bottom: 1px dotted; -} -b, -strong { - font-weight: bold; -} -dfn { - font-style: italic; -} -h1 { - font-size: 2em; - margin: 0.67em 0; -} -mark { - background: #ff0; - color: #000; -} -small { - font-size: 80%; -} -sub, -sup { - font-size: 75%; - line-height: 0; - position: relative; - vertical-align: baseline; -} -sup { - top: -0.5em; -} -sub { - bottom: -0.25em; -} -img { - border: 0; -} -svg:not(:root) { - overflow: hidden; -} -figure { - margin: 1em 40px; -} -hr { - -moz-box-sizing: content-box; - box-sizing: content-box; - height: 0; -} -pre { - overflow: auto; -} -code, -kbd, -pre, -samp { - font-family: monospace, monospace; - font-size: 1em; -} -button, -input, -optgroup, -select, -textarea { - color: inherit; - font: inherit; - margin: 0; -} -button { - overflow: visible; -} -button, -select { - text-transform: none; -} -button, -html input[type="button"], -input[type="reset"], -input[type="submit"] { - -webkit-appearance: button; - cursor: pointer; -} -button[disabled], -html input[disabled] { - cursor: default; -} -button::-moz-focus-inner, -input::-moz-focus-inner { - border: 0; - padding: 0; -} -input { - line-height: normal; -} -input[type="checkbox"], -input[type="radio"] { - box-sizing: border-box; - padding: 0; -} -input[type="number"]::-webkit-inner-spin-button, -input[type="number"]::-webkit-outer-spin-button { - height: auto; -} -input[type="search"] { - -webkit-appearance: textfield; - -moz-box-sizing: content-box; - -webkit-box-sizing: content-box; - box-sizing: content-box; -} -input[type="search"]::-webkit-search-cancel-button, -input[type="search"]::-webkit-search-decoration { - -webkit-appearance: none; -} -fieldset { - border: 1px solid #c0c0c0; - margin: 0 2px; - padding: 0.35em 0.625em 0.75em; -} -legend { - border: 0; - padding: 0; -} -textarea { - overflow: auto; -} -optgroup { - font-weight: bold; -} -table { - border-collapse: collapse; - border-spacing: 0; -} -td, -th { - padding: 0; -} -* { - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - box-sizing: border-box; -} -*:before, -*:after { - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - box-sizing: border-box; -} -html { - font-size: 10px; - -webkit-tap-highlight-color: rgba(0, 0, 0, 0); -} body { - font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; - font-size: 14px; - line-height: 1.42857143; - color: #333333; - background-color: #ffffff; -} -input, -button, -select, -textarea { - font-family: inherit; - font-size: inherit; - line-height: inherit; -} -a { - color: #428bca; - text-decoration: none; -} -a:hover, -a:focus { - color: #2a6496; - text-decoration: underline; -} -a:focus { - outline: thin dotted; - outline: 5px auto -webkit-focus-ring-color; - outline-offset: -2px; -} -figure { - margin: 0; -} -img { - vertical-align: middle; -} -.img-responsive { - display: block; - width: 100% \9; - max-width: 100%; - height: auto; -} -.img-rounded { - border-radius: 6px; -} -.img-thumbnail { - padding: 4px; - line-height: 1.42857143; - background-color: #ffffff; - border: 1px solid #dddddd; - border-radius: 4px; - -webkit-transition: all 0.2s ease-in-out; - -o-transition: all 0.2s ease-in-out; - transition: all 0.2s ease-in-out; - display: inline-block; - width: 100% \9; - max-width: 100%; - height: auto; -} -.img-circle { - border-radius: 50%; -} -hr { - margin-top: 20px; - margin-bottom: 20px; - border: 0; - border-top: 1px solid #eeeeee; -} -.sr-only { - position: absolute; - width: 1px; - height: 1px; - margin: -1px; - padding: 0; - overflow: hidden; - clip: rect(0, 0, 0, 0); - border: 0; -} -.sr-only-focusable:active, -.sr-only-focusable:focus { - position: static; - width: auto; - height: auto; - margin: 0; - overflow: visible; - clip: auto; -} -h1, -h2, -h3, -h4, -h5, -h6, -.h1, -.h2, -.h3, -.h4, -.h5, -.h6 { - font-family: inherit; - font-weight: 500; - line-height: 1.1; - color: inherit; -} -h1 small, -h2 small, -h3 small, -h4 small, -h5 small, -h6 small, -.h1 small, -.h2 small, -.h3 small, -.h4 small, -.h5 small, -.h6 small, -h1 .small, -h2 .small, -h3 .small, -h4 .small, -h5 .small, -h6 .small, -.h1 .small, -.h2 .small, -.h3 .small, -.h4 .small, -.h5 .small, -.h6 .small { - font-weight: normal; - line-height: 1; - color: #777777; -} -h1, -.h1, -h2, -.h2, -h3, -.h3 { - margin-top: 20px; - margin-bottom: 10px; -} -h1 small, -.h1 small, -h2 small, -.h2 small, -h3 small, -.h3 small, -h1 .small, -.h1 .small, -h2 .small, -.h2 .small, -h3 .small, -.h3 .small { - font-size: 65%; -} -h4, -.h4, -h5, -.h5, -h6, -.h6 { - margin-top: 10px; - margin-bottom: 10px; -} -h4 small, -.h4 small, -h5 small, -.h5 small, -h6 small, -.h6 small, -h4 .small, -.h4 .small, -h5 .small, -.h5 .small, -h6 .small, -.h6 .small { - font-size: 75%; -} -h1, -.h1 { - font-size: 36px; -} -h2, -.h2 { - font-size: 30px; -} -h3, -.h3 { - font-size: 24px; -} -h4, -.h4 { - font-size: 18px; -} -h5, -.h5 { - font-size: 14px; -} -h6, -.h6 { - font-size: 12px; -} -p { - margin: 0 0 10px; -} -.lead { - margin-bottom: 20px; - font-size: 16px; - font-weight: 300; - line-height: 1.4; -} -@media (min-width: 768px) { - .lead { - font-size: 21px; - } -} -small, -.small { - font-size: 85%; -} -cite { - font-style: normal; -} -mark, -.mark { - background-color: #fcf8e3; - padding: .2em; -} -.text-left { - text-align: left; -} -.text-right { - text-align: right; -} -.text-center { - text-align: center; -} -.text-justify { - text-align: justify; -} -.text-nowrap { - white-space: nowrap; -} -.text-lowercase { - text-transform: lowercase; -} -.text-uppercase { - text-transform: uppercase; -} -.text-capitalize { - text-transform: capitalize; -} -.text-muted { - color: #777777; -} -.text-primary { - color: #428bca; -} -a.text-primary:hover { - color: #3071a9; -} -.text-success { - color: #3c763d; -} -a.text-success:hover { - color: #2b542c; -} -.text-info { - color: #31708f; -} -a.text-info:hover { - color: #245269; -} -.text-warning { - color: #8a6d3b; -} -a.text-warning:hover { - color: #66512c; -} -.text-danger { - color: #a94442; -} -a.text-danger:hover { - color: #843534; -} -.bg-primary { - color: #fff; - background-color: #428bca; -} -a.bg-primary:hover { - background-color: #3071a9; -} -.bg-success { - background-color: #dff0d8; -} -a.bg-success:hover { - background-color: #c1e2b3; -} -.bg-info { - background-color: #d9edf7; -} -a.bg-info:hover { - background-color: #afd9ee; -} -.bg-warning { - background-color: #fcf8e3; -} -a.bg-warning:hover { - background-color: #f7ecb5; -} -.bg-danger { - background-color: #f2dede; -} -a.bg-danger:hover { - background-color: #e4b9b9; -} -.page-header { - padding-bottom: 9px; - margin: 40px 0 20px; - border-bottom: 1px solid #eeeeee; -} -ul, -ol { - margin-top: 0; - margin-bottom: 10px; -} -ul ul, -ol ul, -ul ol, -ol ol { - margin-bottom: 0; -} -.list-unstyled { - padding-left: 0; - list-style: none; -} -.list-inline { - padding-left: 0; - list-style: none; - margin-left: -5px; -} -.list-inline > li { - display: inline-block; - padding-left: 5px; - padding-right: 5px; -} -dl { - margin-top: 0; - margin-bottom: 20px; -} -dt, -dd { - line-height: 1.42857143; -} -dt { - font-weight: bold; -} -dd { - margin-left: 0; -} -@media (min-width: 768px) { - .dl-horizontal dt { - float: left; - width: 160px; - clear: left; - text-align: right; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; - } - .dl-horizontal dd { - margin-left: 180px; - } -} -abbr[title], -abbr[data-original-title] { - cursor: help; - border-bottom: 1px dotted #777777; -} -.initialism { - font-size: 90%; - text-transform: uppercase; -} -blockquote { - padding: 10px 20px; - margin: 0 0 20px; - font-size: 17.5px; - border-left: 5px solid #eeeeee; -} -blockquote p:last-child, -blockquote ul:last-child, -blockquote ol:last-child { - margin-bottom: 0; -} -blockquote footer, -blockquote small, -blockquote .small { - display: block; - font-size: 80%; - line-height: 1.42857143; - color: #777777; -} -blockquote footer:before, -blockquote small:before, -blockquote .small:before { - content: '\2014 \00A0'; -} -.blockquote-reverse, -blockquote.pull-right { - padding-right: 15px; - padding-left: 0; - border-right: 5px solid #eeeeee; - border-left: 0; - text-align: right; -} -.blockquote-reverse footer:before, -blockquote.pull-right footer:before, -.blockquote-reverse small:before, -blockquote.pull-right small:before, -.blockquote-reverse .small:before, -blockquote.pull-right .small:before { - content: ''; -} -.blockquote-reverse footer:after, -blockquote.pull-right footer:after, -.blockquote-reverse small:after, -blockquote.pull-right small:after, -.blockquote-reverse .small:after, -blockquote.pull-right .small:after { - content: '\00A0 \2014'; -} -blockquote:before, -blockquote:after { - content: ""; -} -address { - margin-bottom: 20px; - font-style: normal; - line-height: 1.42857143; -} -.clearfix:before, -.clearfix:after, -.dl-horizontal dd:before, -.dl-horizontal dd:after { - content: " "; - display: table; -} -.clearfix:after, -.dl-horizontal dd:after { - clear: both; -} -.center-block { - display: block; - margin-left: auto; - margin-right: auto; -} -.pull-right { - float: right !important; -} -.pull-left { - float: left !important; -} -.hide { - display: none !important; -} -.show { - display: block !important; -} -.invisible { - visibility: hidden; -} -.text-hide { - font: 0/0 a; - color: transparent; - text-shadow: none; - background-color: transparent; - border: 0; -} -.hidden { - display: none !important; - visibility: hidden !important; -} -.affix { - position: fixed; - -webkit-transform: translate3d(0, 0, 0); - transform: translate3d(0, 0, 0); + margin: 12px !important; } diff --git a/base.php b/base.php index 80bb5fc..5bab6b1 100644 --- a/base.php +++ b/base.php @@ -1,8 +1,10 @@ diff --git a/functions.php b/functions.php index 0b4a2a5..c90e6bb 100644 --- a/functions.php +++ b/functions.php @@ -9,7 +9,7 @@ * * @link https://github.com/roots/sage/pull/1042 */ -$sage_includes = array( +$sage_includes = [ 'lib/utils.php', // Utility functions 'lib/init.php', // Initial theme setup and constants 'lib/wrapper.php', // Theme wrapper class @@ -20,7 +20,7 @@ $sage_includes = array( 'lib/nav.php', // Custom nav modifications 'lib/gallery.php', // Custom [gallery] modifications 'lib/extras.php', // Custom functions -); +]; foreach ($sage_includes as $file) { if (!$filepath = locate_template($file)) { diff --git a/gulpfile.js b/gulpfile.js index 6424eb6..edd2ff9 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -58,7 +58,7 @@ var revManifest = path.dist + 'assets.json'; var cssTasks = function(filename) { return lazypipe() .pipe($.plumber) - .pipe(function () { + .pipe(function() { return $.if(enabled.maps, $.sourcemaps.init()); }) .pipe(function() { @@ -78,14 +78,15 @@ var cssTasks = function(filename) { .pipe($.pleeease, { autoprefixer: { browsers: [ - 'last 2 versions', 'ie 8', 'ie 9', 'android 2.3', 'android 4', 'opera 12' + 'last 2 versions', 'ie 8', 'ie 9', 'android 2.3', 'android 4', + 'opera 12' ] } }) - .pipe(function () { + .pipe(function() { return $.if(enabled.rev, $.rev()); }) - .pipe(function () { + .pipe(function() { return $.if(enabled.maps, $.sourcemaps.write('.')); })(); }; @@ -99,22 +100,22 @@ var cssTasks = function(filename) { // ``` var jsTasks = function(filename) { return lazypipe() - .pipe(function () { + .pipe(function() { return $.if(enabled.maps, $.sourcemaps.init()); }) .pipe($.concat, filename) .pipe($.uglify) - .pipe(function () { + .pipe(function() { return $.if(enabled.rev, $.rev()); }) - .pipe(function () { + .pipe(function() { return $.if(enabled.maps, $.sourcemaps.write('.')); })(); }; // ### Write to Rev Manifest // If `--production` then write the revved assets to the manifest. -var writeToManifest = function (directory) { +var writeToManifest = function(directory) { return lazypipe() .pipe(gulp.dest, path.dist + directory) .pipe(require('gulp-debug')) @@ -134,7 +135,7 @@ var writeToManifest = function (directory) { // `gulp styles` - compiles, combines, and optimizes bower css and project css. gulp.task('styles', function() { var merged = merge(); - manifest.forEachDependency('css', function (dep) { + manifest.forEachDependency('css', function(dep) { merged.add(gulp.src(dep.globs) .pipe(cssTasks(dep.name))); }); @@ -147,7 +148,7 @@ gulp.task('styles', function() { // javascript and project javascript gulp.task('scripts', ['jshint'], function() { var merged = merge(); - manifest.forEachDependency('js', function (dep) { + manifest.forEachDependency('js', function(dep) { merged.add( gulp.src(dep.globs) .pipe(jsTasks(dep.name)) diff --git a/lib/assets.php b/lib/assets.php index 3589f06..6aa0c11 100644 --- a/lib/assets.php +++ b/lib/assets.php @@ -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() { ?> - +function google_analytics() { + ?> + + display); } diff --git a/lib/gallery.php b/lib/gallery.php index 874a8e1..fc56908 100644 --- a/lib/gallery.php +++ b/lib/gallery.php @@ -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); diff --git a/lib/init.php b/lib/init.php index e8fcf02..45cd711 100644 --- a/lib/init.php +++ b/lib/init.php @@ -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' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', - )); + ]); - register_sidebar(array( + register_sidebar([ 'name' => __('Footer', 'sage'), 'id' => 'sidebar-footer', 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', - )); + ]); } add_action('widgets_init', __NAMESPACE__ . '\\widgets_init'); diff --git a/lib/nav.php b/lib/nav.php index 45ed870..d9ca69d 100644 --- a/lib/nav.php +++ b/lib/nav.php @@ -9,31 +9,30 @@ namespace Roots\Sage\Nav; *
  • Home
  • *
  • Sample PageHome
  • * */ -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