Skip to content

Commit

Permalink
Merge pull request #7 from itthinx/tested-2.1.0-6.0
Browse files Browse the repository at this point in the history
Tested 2.1.0 6.0
  • Loading branch information
itthinx committed Aug 11, 2022
2 parents 0d1e656 + 3196ae2 commit 479c5c8
Show file tree
Hide file tree
Showing 10 changed files with 4,464 additions and 944 deletions.
192 changes: 96 additions & 96 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,117 +1,117 @@
module.exports = function(grunt) {

require('load-grunt-tasks')(grunt);
require('load-grunt-tasks')(grunt);

// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
// Project configuration.
grunt.initConfig( {
pkg: grunt.file.readJSON('package.json'),

uglify: {
options: {
compress: {
global_defs: {
"EO_SCRIPT_DEBUG": false
},
dead_code: true
},
banner: '/*! <%= pkg.title %> <%= pkg.version %> <%= grunt.template.today("yyyy-mm-dd HH:MM") %> */\n'
},
build: {
files: [{
expand: true, // Enable dynamic expansion.
src: ['js/*.js', '!js/*.min.js'], // Actual pattern(s) to match.
ext: '.min.js', // Dest filepaths will have this extension.
}]
}
},
jshint: {
options: {
reporter: require('jshint-stylish'),
globals: {
"EO_SCRIPT_DEBUG": false,
uglify: {
options: {
compress: {
global_defs: {
"EO_SCRIPT_DEBUG": false
},
dead_code: true
},
banner: '/*! <%= pkg.title %> <%= pkg.version %> <%= grunt.template.today("yyyy-mm-dd HH:MM") %> */\n'
},
'-W099': true, //Mixed spaces and tabs
'-W083': true,//TODO Fix functions within loop
'-W082': true, //Todo Function declarations should not be placed in blocks
'-W020': true, //Read only - error when assigning EO_SCRIPT_DEBUG a value.
build: {
files: [{
expand: true, // Enable dynamic expansion.
src: ['js/*.js', '!js/*.min.js'], // Actual pattern(s) to match.
ext: '.min.js', // Dest filepaths will have this extension.
}]
}
},
all: [ 'js/*.js', '!js/*.min.js' ]
},

watch: {
scripts: {
files: 'js/*.js',
tasks: ['jshint', 'uglify'],
jshint: {
options: {
debounceDelay: 250,
reporter: require('jshint-stylish'),
globals: {
"EO_SCRIPT_DEBUG": false,
},
'-W099': true, //Mixed spaces and tabs
'-W083': true,//TODO Fix functions within loop
'-W082': true, //Todo Function declarations should not be placed in blocks
'-W020': true, //Read only - error when assigning EO_SCRIPT_DEBUG a value.
},
}
},

// # Internationalization
all: [ 'js/*.js', '!js/*.min.js' ]
},

// Add text domain
addtextdomain: {
options: {
textdomain: '<%= pkg.name %>', // Project text domain.
},
target: {
files: {
src: ['*.php', '**/*.php', '**/**/*.php', '!node_modules/**', '!deploy/**']
watch: {
scripts: {
files: 'js/*.js',
tasks: ['jshint', 'uglify'],
options: {
debounceDelay: 250,
},
}
}
},
},

// Generate .pot file
makepot: {
target: {
// # Internationalization

// Add text domain
addtextdomain: {
options: {
domainPath: '/languages', // Where to save the POT file.
exclude: ['deploy'], // List of files or directories to ignore.
mainFile: '<%= pkg.name %>.php', // Main project file.
potFilename: '<%= pkg.name %>.pot', // Name of the POT file.
type: 'wp-plugin', // Type of project (wp-plugin or wp-theme).
potHeaders: {
'Report-Msgid-Bugs-To': 'https://github.com/itthinx/woocommerce-product-generator/issues'
}
textdomain: '<%= pkg.name %>', // Project text domain.
},
target: {
files: {
src: ['*.php', '**/*.php', '**/**/*.php', '!node_modules/**', '!deploy/**']
}
}
}
},

},

// bump version numbers (replace with version in package.json)
replace: {
Version: {
src: [
'readme.txt',
'<%= pkg.name %>.php'
],
overwrite: true,
replacements: [
{
from: /Stable tag:.*$/m,
to: "Stable tag: <%= pkg.version %>"
},
{
from: /Version:.*$/m,
to: "Version: <%= pkg.version %>"
},
{
from: /public \$version = \'.*.'/m,
to: "public $version = '<%= pkg.version %>'"
},
{
from: /public \$version = \'.*.'/m,
to: "public $version = '<%= pkg.version %>'"
// Generate .pot file
makepot: {
target: {
options: {
domainPath: '/languages', // Where to save the POT file.
exclude: ['deploy'], // List of files or directories to ignore.
mainFile: '<%= pkg.name %>.php', // Main project file.
potFilename: '<%= pkg.name %>.pot', // Name of the POT file.
type: 'wp-plugin', // Type of project (wp-plugin or wp-theme).
potHeaders: {
'Report-Msgid-Bugs-To': 'https://github.com/itthinx/woocommerce-product-generator/issues'
}
}
]
}
},

// bump version numbers (replace with version in package.json)
replace: {
Version: {
src: [
'readme.txt',
'<%= pkg.name %>.php'
],
overwrite: true,
replacements: [
{
from: /Stable tag:.*$/m,
to: "Stable tag: <%= pkg.version %>"
},
{
from: /Version:.*$/m,
to: "Version: <%= pkg.version %>"
},
{
from: /public \$version = \'.*.'/m,
to: "public $version = '<%= pkg.version %>'"
},
{
from: /public \$version = \'.*.'/m,
to: "public $version = '<%= pkg.version %>'"
}
]
}
}
}

});
} );

grunt.registerTask( 'test', [ 'jshint', 'newer:uglify' ] );
grunt.registerTask( 'build', [ 'replace', 'jshint', 'uglify' ] );
grunt.registerTask( 'release', [ 'build', 'addtextdomain', 'makepot' ] );
grunt.registerTask( 'test', [ 'jshint', 'newer:uglify' ] );
grunt.registerTask( 'build', [ 'replace', 'jshint', 'uglify' ] );
grunt.registerTask( 'release', [ 'build', 'addtextdomain', 'makepot' ] );

};
10 changes: 10 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
== Woocommerce Product Generator by itthinx - changelog.txt ==

= 2.1.0 =
* WordPress 6.0 compatible.
* WooCommerce 6.8 compatible.
* Updated the contributors info.
* Added product generation stats and performance are shown during generation.
* Added product generation stats and performance are logged to the debug.log; the WPG_LOG constant can be used to turn that off by setting it to false in the wp-config.php.
* Fixed generator JS not aware of updated limit directly after saving settings.
* Fixed missing output escaping in the admin section.
* Fixed superfluous and trailing whitespace in code and formatting issues.

= 2.0.0 =
* Requires WooCommerce 5.8.
* WooCommerce 6.8 compatible.
Expand Down
58 changes: 53 additions & 5 deletions js/product-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,14 @@ var ixprogen = {
running : false,
generating : false,
timeout : null,
limit : null
limit : null,
gendata : {
total : 0,
simple : 0,
variable : 0,
variation : 0,
time : 0.0
}
};

/**
Expand Down Expand Up @@ -52,13 +59,51 @@ ixprogen.generate = function() {
},
success : function ( data ) {
if ( typeof data.total !== "undefined" ) {
text = WC_Product_Generator.total.replace( "%d", data.total);
$update.html( '<p>' + text + '</p>' );

ixprogen.gendata.total = data.total; // not cumulative
ixprogen.gendata.simple += data.simple;
ixprogen.gendata.variable += data.variable;
ixprogen.gendata.variation += data.variation;
ixprogen.gendata.time += data.time;

text = '<div style="margin: 16px 0;">';
text += WC_Product_Generator.total.replace( "%d", ixprogen.gendata.total );
text += '</div>';
text += '<div style="margin: 16px 0;">';
text += '<strong>' + WC_Product_Generator.generation_stats + '</strong>';
text += '</div>';
text += '<div id="ixprogen-stats-container" style="display: grid; grid-template-columns: 10% 10% 10% 10% 15% auto; grid-column-gap: 24px;">';
text += '<div>';
text += WC_Product_Generator.stats_simple.replace( "%d", ixprogen.gendata.simple );
text += '</div>';
text += '<div>';
text += WC_Product_Generator.stats_variable.replace( "%d", ixprogen.gendata.variable );
text += '</div>';
text += '<div>';
text += WC_Product_Generator.stats_variations.replace( "%d", ixprogen.gendata.variation );
text += '</div>';
text += '<div>';
text += WC_Product_Generator.stats_sum.replace( "%d", ixprogen.gendata.simple + ixprogen.gendata.variable + ixprogen.gendata.variation );
text += '</div>';
text += '<div>';
text += WC_Product_Generator.stats_time.replace( "%s", ixprogen.gendata.time.toFixed(2) );
text += '</div>';
text += '<div>';
var pps = ixprogen.gendata.time > 0.0 ? ( ixprogen.gendata.simple + ixprogen.gendata.variable + ixprogen.gendata.variation ) / ixprogen.gendata.time : 0.0;
text += WC_Product_Generator.stats_pps.replace( "%s", pps.toFixed(3) );
text += '</div>';
text += '</div>';

if ( ixprogen.limit !== null ) {
if ( data.total >= ixprogen.limit ) {
ixprogen.stop();
text += '<div style="margin: 16px 0;">';
text += '<strong>' + WC_Product_Generator.limit_reached + '</strong>';
text += '</div>';
}
}

$update.html( '<div>' + text + '</div>' );
}
},
dataType : "json"
Expand Down Expand Up @@ -101,7 +146,10 @@ ixprogen.stop = function() {

jQuery(document).ready(function($){
ixprogen.limit = WC_Product_Generator.limit;

if ( typeof ixprogen_updated_limit !== 'undefined' ) {
ixprogen.limit = ixprogen_updated_limit;
}

$("#product-generator-run").on( 'click', function(e){
e.stopPropagation();
ixprogen.start();
Expand All @@ -112,4 +160,4 @@ jQuery(document).ready(function($){
ixprogen.stop();
});

}); // ready
}); // ready
4 changes: 2 additions & 2 deletions js/product-generator.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 479c5c8

Please sign in to comment.