Skip to content

Commit

Permalink
Add license validator.
Browse files Browse the repository at this point in the history
  • Loading branch information
fumikito committed Jun 12, 2019
1 parent 38a33cf commit 6102636
Show file tree
Hide file tree
Showing 10 changed files with 413 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/vendor/
composer.lock
/node_modules/
package-lock.json
/dist/
26 changes: 26 additions & 0 deletions assets/js/hiden-option-helper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* Option helper.
*/

/*global hoge: true*/


const $ = jQuery;

$( document ).ready( () => {
const api_key = $( '#hiden_api_key' ).val();
const $container = $( '#hiden_api_key_result' );
if ( ! api_key.length ) {
$container.removeClass( 'loading' ).addClass( 'invalid' );
return;
}
wp.apiRequest( {
path: '/hiden/v1/validator'
} ).done( response => {
$container.addClass( 'valid' ).find( 'strong' ).text( response.name );
}).fail( response => {
$container.addClass( 'invalid' );
}).always( () => {
$container.removeClass( 'loading' );
} );
});
3 changes: 3 additions & 0 deletions assets/scss/admin.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@charset "UTF-8";

@import "components/*";
34 changes: 34 additions & 0 deletions assets/scss/components/_license.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#hiden_api_key_result{

transition: opacity .5s linear;
opacity: 1;
min-height: 1em;
&.loading{
opacity: 0;
}
& > span {
visibility: hidden;
}
&.invalid {
.valid-string{
display: none;
}
.invalid-string{
visibility: visible;
}
}
&.valid{
.valid-string{
visibility: visible;
}
.invalid-string{
display: none;
}
}
.dashicons-yes{
color: #24e668;
}
.dashicons-no{
color: #e61f16;
}
}
130 changes: 130 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
var gulp = require('gulp'),
fs = require('fs'),
$ = require('gulp-load-plugins')(),
pngquant = require('imagemin-pngquant'),
eventStream = require('event-stream');

// Include Path for Scss
var includesPaths = [
'assets/scss'
];

// Source directory
var srcDir = {
scss: [
'assets/scss/**/*.scss'
],
js: [
'assets/js/**/*.js',
'!assets/js/**/_*.js'
],
jsHint: [
'assets/js/**/*.js'
],
jshintrc: [
'.jshintrc'
],
img: [
'assets/img/**/*'
]

};
// Destination directory
var destDir = {
scss: 'dist/css',
js: 'dist/js',
img: 'dist/img'
};

// Sass
gulp.task('sass', function () {

return gulp.src(srcDir.scss)
.pipe($.plumber({
errorHandler: $.notify.onError('<%= error.message %>')
}))
.pipe($.sassGlob())
.pipe($.sourcemaps.init())
.pipe($.sass({
errLogToConsole: true,
outputStyle : 'compressed',
sourceComments : 'normal',
sourcemap : true,
includePaths : includesPaths
}))
.pipe($.sourcemaps.write('./map'))
.pipe(gulp.dest(destDir.scss));
});


// Minify All
gulp.task('jsconcat', function () {
return gulp.src(srcDir.js)
.pipe($.plumber({
errorHandler: $.notify.onError('<%= error.message %>')
}))
.pipe($.sourcemaps.init({
loadMaps: true
}))
.pipe($.babel({
"presets": ["es2015"]
}))
.pipe($.uglify({
output:{
comments: /^!/
}
}))
.pipe($.sourcemaps.write('./map'))
.pipe(gulp.dest(destDir.js));
});


// JS Hint
gulp.task('jshint', function () {
return gulp.src(srcDir.jsHint)
.pipe($.plumber())
.pipe($.jshint({
lookup: srcDir.jshintrc
}))
.pipe($.jshint.reporter('jshint-stylish'));
});

// JS task
gulp.task('js', gulp.parallel('jshint', 'jsconcat'));


// Build Libraries.
gulp.task('copylib', function () {
// pass gulp tasks to event stream.
// return eventStream.merge(
// );
});

// Image min
gulp.task('imagemin', function () {
return gulp.src(srcDir.img)
.pipe($.imagemin({
progressive: true,
svgoPlugins: [{removeViewBox: false}],
use : [pngquant()]
}))
.pipe(gulp.dest(destDir.img));
});


// watch
gulp.task('watch', function () {
// Make SASS
gulp.watch(srcDir.scss, gulp.task( 'sass' ) );
// Uglify all
gulp.watch(srcDir.jsHint, gulp.task( 'js' ) );
// Minify Image
gulp.watch(srcDir.img, gulp.task( 'imagemin' ) );
});

// Build
gulp.task('build', gulp.parallel( 'js', 'sass', 'imagemin') );

// Default Tasks
gulp.task('default', gulp.parallel('watch'));

6 changes: 5 additions & 1 deletion hiden.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,19 @@
License: GPL 3.0 or later
Text Domain: hiden
Domain Path: /languages
*/

defined( 'ABSPATH' ) || die();

define( 'HIDEN_ROOT_DIR', dirname( __FILE__ ) );

/**
* Plugin init.
*/
function hiden_plugins_loaded() {
// Define hiden version.
$info = get_file_data( __FILE__, [ 'version' => 'Version' ] );
define( 'HIDEN_VERSION', $info['version'] );
// Register text domain.
load_plugin_textdomain( 'hiden', false, basename( __DIR__ ) . '/languages' );
// Load functions.
Expand Down
48 changes: 48 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"name": "hiden",
"version": "1.0.0",
"description": "",
"main": "gulpfile.js",
"directories": {
"test": "tests"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "gulp build",
"package": "gulp build",
"watch": "gulp build && gulp watch",
"gulp": "gulp"
},
"repository": {
"type": "git",
"url": ""
},
"keywords": [],
"author": "",
"license": "GPL-3.0-or-later",
"bugs": {
"url": ""
},
"homepage": "https://kunoichiwp.com",
"devDependencies": {
"babel-core": "^6.26.0",
"babel-preset-es2015": "^6.24.1",
"event-stream": "^4.0.1",
"gulp": "^4.0.0",
"gulp-autoprefixer": "^6.0.0",
"gulp-babel": "^7.0.0",
"gulp-imagemin": "^5.0.3",
"gulp-include": "^2.3.1",
"gulp-jshint": "^2.0.4",
"gulp-load-plugins": "^1.4.0",
"gulp-notify": "^3.0.0",
"gulp-plumber": "^1.1.0",
"gulp-sass": "^4.0.2",
"gulp-sass-glob": "^1.0.9",
"gulp-sourcemaps": "^2.4.0",
"gulp-uglify": "^3.0.1",
"imagemin-pngquant": "^7.0.0",
"jshint": "^2.9.4",
"jshint-stylish": "^2.2.1"
}
}
2 changes: 1 addition & 1 deletion src/Kunoichi/Hiden/API/Endpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ trait Endpoint {
* @return string
*/
protected function get_api_key() {
return get_option( 'hide_api_key', '' );
return get_option( 'hiden_api_key', '' );
}

/**
Expand Down
Loading

0 comments on commit 6102636

Please sign in to comment.