Skip to content
This repository has been archived by the owner on Sep 16, 2019. It is now read-only.

Commit

Permalink
Added Wordpress Coding Standards Sniff to Gulp
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Rathke committed Dec 14, 2015
1 parent 5158a3d commit 1d9d3be
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -8,3 +8,4 @@ assets/javascript/vendor/
assets/javascript/foundation.js
assets/javascript/custom/demosite.js
packaged/
wpcs/
12 changes: 12 additions & 0 deletions README.md
Expand Up @@ -76,6 +76,18 @@ Version control on these files are turned off because they are automatically gen

* `assets/javascript/vendor`: Vendor scripts are copied from `assets/components/` to this directory. We use this path for enqueing the vendor scripts in WordPress.

### Check For WordPress Coding Standards

Foundation comes with everything you need to run tests that will check your theme for WordPress Coding Standards. To enable this feature you'll need to install PHP Codesniffer, along with the WordPress Coding Standards set of "Sniffs". You'll need to have [Composer](https://getcomposer.org/) To install both run the following:
```bash
$ composer create-project wp-coding-standards/wpcs:dev-master --no-dev
```

Once you have installed the packages, you can check your entire theme by running:
```bash
$ npm run phpcs
```

## Demo

* [Clean FoundationPress install](http://foundationpress.olefredrik.com/)
Expand Down
15 changes: 13 additions & 2 deletions gulpfile.js
Expand Up @@ -3,11 +3,12 @@

var $ = require('gulp-load-plugins')();
var argv = require('yargs').argv;
var gulp = require('gulp');
var gulp = require('gulp');
var browserSync = require('browser-sync').create();
var merge = require('merge-stream');
var sequence = require('run-sequence');
var colors = require('colors');
var phpcs = require('gulp-phpcs');

// Enter URL of your local server here
// Example: 'http://localwebsite.dev'
Expand Down Expand Up @@ -172,6 +173,16 @@ gulp.task('build', function(done) {
done);
});

gulp.task('phpcs', function() {
return gulp.src(['*.php'])
.pipe(phpcs({
bin: 'wpcs/vendor/bin/phpcs',
standard: './codesniffer.ruleset.xml',
showSniffCode: true,
}))
.pipe(phpcs.reporter('log'));
});

// Default gulp task
// Run build task and watch for file changes
gulp.task('default', ['build', 'browser-sync'], function() {
Expand All @@ -192,4 +203,4 @@ gulp.task('default', ['build', 'browser-sync'], function() {
.on('change', function(event) {
logFileChange(event);
});
});
});
4 changes: 3 additions & 1 deletion package.json
Expand Up @@ -33,6 +33,7 @@
"gulp-if": "^2.0.0",
"gulp-load-plugins": "^1.1.0",
"gulp-minify-css": "^1.2.2",
"gulp-phpcs": "^1.0.0",
"gulp-sass": "^2.1.0",
"gulp-sourcemaps": "^1.6.0",
"gulp-uglify": "^1.5.1",
Expand All @@ -47,8 +48,9 @@
"scripts": {
"build": "gulp build",
"package": "gulp package",
"phpcs": "gulp phpcs",
"postinstall": "bower install && gulp build",
"production": "gulp --production",
"watch": "gulp"
}
}
}

0 comments on commit 1d9d3be

Please sign in to comment.