Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
148 changes: 105 additions & 43 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,70 +50,128 @@ function bundle_admin_and_common_js() {
/**
* Bundle Create
*/
// Bundle without external and internal js
// Bundle with common-functions, without external and internal js
function bundle_src_js() {
return gulp.src([
'js/src/apbct-common-functions.js',
'js/src/apbct-public--0*.js',
'js/src/apbct-public--1*.js',
'js/src/apbct-public--2*.js',
'js/src/apbct-public--3*.js',
'js/src/apbct-public--7*.js',
'js/src/apbct-common-functions.js',
])
// Unminified bundle
.pipe(concat('apbct-public-bundle.js'))
.pipe(concat('apbct-public-bundle_comm-func.js'))
.pipe(gulp.dest('js/src/'));
}

// Bundle with external js and without internal js
function bundle_src_js_external_protection() {
// Bundle without common-functions, external and internal js
function bundle_src_js_without_cf() {
return gulp.src([
'js/src/apbct-public--0*.js',
'js/src/apbct-public--1*.js',
'js/src/apbct-public--2*.js',
'js/src/apbct-public--3*.js',
'js/src/apbct-public--7*.js',
'js/src/apbct-public--5--external-forms.js',
'js/src/apbct-common-functions.js',
])
'js/src/apbct-public--0*.js',
'js/src/apbct-public--1*.js',
'js/src/apbct-public--2*.js',
'js/src/apbct-public--3*.js',
'js/src/apbct-public--7*.js',
])
// Unminified bundle
.pipe(concat('apbct-public-bundle_ext-protection.js'))
.pipe(concat('apbct-public-bundle.js'))
.pipe(gulp.dest('js/src/'));
}

// Bundle with internal js and without external js
// Bundle with common-functions, external js and without internal js
function bundle_src_js_external_protection() {
return gulp.src([
'js/src/apbct-common-functions.js',
'js/src/apbct-public--0*.js',
'js/src/apbct-public--1*.js',
'js/src/apbct-public--2*.js',
'js/src/apbct-public--3*.js',
'js/src/apbct-public--7*.js',
'js/src/apbct-public--5--external-forms.js',
])
// Unminified bundle
.pipe(concat('apbct-public-bundle_ext-protection_comm-func.js'))
.pipe(gulp.dest('js/src/'));
}

// Bundle with external js and without internal js, common-functions
function bundle_src_js_external_protection_without_cf() {
return gulp.src([
'js/src/apbct-public--0*.js',
'js/src/apbct-public--1*.js',
'js/src/apbct-public--2*.js',
'js/src/apbct-public--3*.js',
'js/src/apbct-public--7*.js',
'js/src/apbct-public--5--external-forms.js',
])
// Unminified bundle
.pipe(concat('apbct-public-bundle_ext-protection.js'))
.pipe(gulp.dest('js/src/'));
}

// Bundle with common-functions, internal js and without external js
function bundle_src_js_internal_protection() {
return gulp.src([
'js/src/apbct-common-functions.js',
'js/src/apbct-public--0*.js',
'js/src/apbct-public--1*.js',
'js/src/apbct-public--2*.js',
'js/src/apbct-public--3*.js',
'js/src/apbct-public--7*.js',
'js/src/apbct-public--6--internal-forms.js',
'js/src/apbct-common-functions.js',
])
// Unminified bundle
.pipe(concat('apbct-public-bundle_int-protection.js'))
.pipe(gulp.dest('js/src/'));
'js/src/apbct-common-functions.js',
'js/src/apbct-public--0*.js',
'js/src/apbct-public--1*.js',
'js/src/apbct-public--2*.js',
'js/src/apbct-public--3*.js',
'js/src/apbct-public--7*.js',
'js/src/apbct-public--6--internal-forms.js',
])
// Unminified bundle
.pipe(concat('apbct-public-bundle_int-protection_comm-func.js'))
.pipe(gulp.dest('js/src/'));
}

// Bundle with external and internal js
function bundle_src_js_ext_int_protection() {
// Bundle with internal js and without external js, common-functions
function bundle_src_js_internal_protection_without_cf() {
return gulp.src([
'js/src/apbct-common-functions.js',
'js/src/apbct-public--0*.js',
'js/src/apbct-public--1*.js',
'js/src/apbct-public--2*.js',
'js/src/apbct-public--3*.js',
'js/src/apbct-public--7*.js',
'js/src/apbct-public--5--external-forms.js',
'js/src/apbct-public--6--internal-forms.js',
'js/src/apbct-common-functions.js',
])
// Unminified bundle
.pipe(concat('apbct-public-bundle_full-protection.js'))
.pipe(gulp.dest('js/src/'));
'js/src/apbct-public--0*.js',
'js/src/apbct-public--1*.js',
'js/src/apbct-public--2*.js',
'js/src/apbct-public--3*.js',
'js/src/apbct-public--7*.js',
'js/src/apbct-public--6--internal-forms.js',
])
// Unminified bundle
.pipe(concat('apbct-public-bundle_int-protection.js'))
.pipe(gulp.dest('js/src/'));
}

// Bundle with common-functions, external and internal js
function bundle_src_js_full_protection() {
return gulp.src([
'js/src/apbct-common-functions.js',
'js/src/apbct-public--0*.js',
'js/src/apbct-public--1*.js',
'js/src/apbct-public--2*.js',
'js/src/apbct-public--3*.js',
'js/src/apbct-public--7*.js',
'js/src/apbct-public--5--external-forms.js',
'js/src/apbct-public--6--internal-forms.js',
])
// Unminified bundle
.pipe(concat('apbct-public-bundle_full-protection_comm-func.js'))
.pipe(gulp.dest('js/src/'));
}

// Bundle with external and internal js, without common-functions
function bundle_src_js_full_protection_without_cf() {
return gulp.src([
'js/src/apbct-public--0*.js',
'js/src/apbct-public--1*.js',
'js/src/apbct-public--2*.js',
'js/src/apbct-public--3*.js',
'js/src/apbct-public--7*.js',
'js/src/apbct-public--5--external-forms.js',
'js/src/apbct-public--6--internal-forms.js',
])
// Unminified bundle
.pipe(concat('apbct-public-bundle_full-protection.js'))
.pipe(gulp.dest('js/src/'));
}

function bundle_js() {
Expand All @@ -129,9 +187,13 @@ function bundle_js() {

gulp.task('compress-js', gulp.series(
bundle_src_js,
bundle_src_js_without_cf,
bundle_src_js_external_protection,
bundle_src_js_external_protection_without_cf,
bundle_src_js_internal_protection,
bundle_src_js_ext_int_protection,
bundle_src_js_internal_protection_without_cf,
bundle_src_js_full_protection,
bundle_src_js_full_protection_without_cf,
bundle_js,
compress_all_js,
bundle_admin_and_common_js
Expand Down
19 changes: 3 additions & 16 deletions inc/cleantalk-public.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Cleantalk\ApbctWP\Variables\Post;
use Cleantalk\ApbctWP\Variables\Server;
use Cleantalk\ApbctWP\LinkConstructor;
use Cleantalk\ApbctWP\ApbctJsBundleResolver;

/**
* Init functions
Expand Down Expand Up @@ -1262,23 +1263,9 @@ function apbct_enqueue_and_localize_public_scripts()
global $apbct;

$in_footer = defined('CLEANTALK_PLACE_PUBLIC_JS_SCRIPTS_IN_FOOTER') && CLEANTALK_PLACE_PUBLIC_JS_SCRIPTS_IN_FOOTER;

// Different JS params
if (!$apbct->settings['forms__check_external'] && !$apbct->settings['forms__check_internal']) {
ApbctEnqueue::getInstance()->js('apbct-public-bundle.js', array(), $in_footer);
}

if ($apbct->settings['forms__check_external'] && !$apbct->settings['forms__check_internal']) {
ApbctEnqueue::getInstance()->js('apbct-public-bundle_ext-protection.js', array(), $in_footer);
}

if ($apbct->settings['forms__check_internal'] && !$apbct->settings['forms__check_external']) {
ApbctEnqueue::getInstance()->js('apbct-public-bundle_int-protection.js', array(), $in_footer);
}

if ($apbct->settings['forms__check_external'] && $apbct->settings['forms__check_internal']) {
ApbctEnqueue::getInstance()->js('apbct-public-bundle_full-protection.js', array(), $in_footer);
}
$bundle_name = ApbctJsBundleResolver::getBundleName($apbct->settings);
ApbctEnqueue::getInstance()->js($bundle_name, array(), $in_footer);

// Bot detector
if ( $apbct->settings['data__bot_detector_enabled'] && ! apbct_bot_detector_scripts_exclusion()) {
Expand Down
2 changes: 1 addition & 1 deletion js/apbct-public-bundle.min.js

Large diffs are not rendered by default.

5 changes: 0 additions & 5 deletions js/apbct-public-bundle.min.js.map

This file was deleted.

2 changes: 2 additions & 0 deletions js/apbct-public-bundle_comm-func.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions js/apbct-public-bundle_comm-func.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/apbct-public-bundle_ext-protection.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/apbct-public-bundle_ext-protection.min.js.map

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions js/apbct-public-bundle_ext-protection_comm-func.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions js/apbct-public-bundle_ext-protection_comm-func.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/apbct-public-bundle_full-protection.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/apbct-public-bundle_full-protection.min.js.map

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions js/apbct-public-bundle_full-protection_comm-func.min.js

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/apbct-public-bundle_int-protection.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/apbct-public-bundle_int-protection.min.js.map

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions js/apbct-public-bundle_int-protection_comm-func.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions js/apbct-public-bundle_int-protection_comm-func.min.js.map

Large diffs are not rendered by default.

Loading
Loading