Last active
November 16, 2016 11:44
-
-
Save BinaryMoon/edb39e27ec0327d01f63d8b9bc55e071 to your computer and use it in GitHub Desktop.
Use gulp to check the textdomain in a WordPress theme
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Get theme folder from theme parameter or use granule | |
* | |
* @returns {String|util.env.theme} | |
*/ | |
function utilGetTheme() { | |
var theme = 'granule'; | |
if ( util.env.theme ) { | |
// check for a command line variable | |
// use it if it exists | |
theme = util.env.theme; | |
} | |
console.log( 'Theme Name: ' + UtilUpperCaseFirstWord( theme ) ); | |
return theme; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gulp.task( | |
'checktextdomain', | |
function() { | |
var theme_slug = utilGetTheme(); | |
return gulp | |
.src( './' + theme_slug + '/**/*.php') | |
.pipe( | |
checktextdomain( | |
{ | |
text_domain: theme_slug, //Specify allowed domain(s) | |
keywords: [ //List keyword specifications | |
'__:1,2d', | |
'_e:1,2d', | |
'_x:1,2c,3d', | |
'esc_html__:1,2d', | |
'esc_html_e:1,2d', | |
'esc_html_x:1,2c,3d', | |
'esc_attr__:1,2d', | |
'esc_attr_e:1,2d', | |
'esc_attr_x:1,2c,3d', | |
'_ex:1,2c,3d', | |
'_n:1,2,4d', | |
'_nx:1,2,4c,5d', | |
'_n_noop:1,2,3d', | |
'_nx_noop:1,2,3c,4d' | |
], | |
} | |
) | |
); | |
} | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var gulp = require( 'gulp' ); | |
var util = require( 'gulp-util' ); | |
var checktextdomain = require( 'gulp-checktextdomain' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment