Asset CleanUp: Page Speed Booster - Version 1.3.2.3

Version Description

  • New Option in "Assets List Layout": Sort by CSS/JS position (HEAD and BODY tags)
  • New Feature: Strip HTML Comments
  • Assets Meta Box update: Changed 'advanced' to 'normal' for $context parameter (e.g. Oxygen Builder 2.2 compatibility); added option to update the $content and $priority of the Asset CleanUp meta boxes via "add_filter" via the following tags (for each meta box): wpacu_asset_list_meta_box_context, wpacu_asset_list_meta_box_priority, wpacu_page_options_meta_box_context, wpacu_page_options_meta_box_priority
  • Bug Fix: Settings update now trigger on 'init' rather than 'plugins_loaded' for maximum compatibility with all WP installs;
  • Bug Fix: Make sure Emojis are always disabled when specified in the Settings and there is no DNS prefetch to //s.w.org
  • Potential WooCommerce bug fix (is_woocomerce() returns true while is_cart() isn't sometimes)
  • Added video tutorials in the "Getting Started" area
  • Removed HTML usage notice for Asset CleanUp
Download this release

Release Info

Developer gabelivan
Plugin Icon 128x128 Asset CleanUp: Page Speed Booster
Version 1.3.2.3
Comparing to
See all releases

Code changes from version 1.3.2.2 to 1.3.2.3

assets/script.min.js CHANGED
@@ -1 +1 @@
1
- function wpacuTabOpenSettingsArea(a,b){a.preventDefault();var c,d,e;for(d=document.getElementsByClassName("wpacu-settings-tab-content"),c=0;c<d.length;c++)d[c].style.display="none";for(e=document.getElementsByClassName("wpacu-settings-tab-link"),c=0;c<e.length;c++)e[c].className=e[c].className.replace(" active","");document.getElementById(b).style.display="table-cell",jQuery('a[href="#'+b+'"]').addClass("active"),jQuery("#wpacu-selected-tab-area").val(b),history.pushState(null,null,"#"+b)}if(jQuery(document).ready(function(a){function b(){if(!a("#wpacu_ajax_fetch_assets_list_dashboard_view").length)return!1;var b={};"direct"===wpacu_object.dom_get_type?(b[wpacu_object.plugin_name+"_load"]=1,b[wpacu_object.plugin_name+"_time_r"]=(new Date).getTime(),a.ajax({method:"GET",url:wpacu_object.page_url,data:b,cache:!1,complete:function(b,c){if("error"===b.statusText){var d=wpacu_object.ajax_direct_fetch_error;d=d.replace(/\{wpacu_output\}/,b.responseText),d=d.replace(/\{wpacu_status_code_error\}/,b.status),a("#wpacu_meta_box_content").html(d)}}}).done(function(b){var c=b.substring(b.lastIndexOf(wpacu_object.start_del)+wpacu_object.start_del.length,b.lastIndexOf(wpacu_object.end_del)),d={action:wpacu_object.plugin_name+"_get_loaded_assets",wpacu_list:c,post_id:wpacu_object.post_id,page_url:wpacu_object.page_url,tag_id:wpacu_object.tag_id,time_r:(new Date).getTime()};a.post(wpacu_object.ajax_url,d,function(b){if(!b)return!1;a("#wpacu_meta_box_content").html(b),a("#wpacu_home_page_form").length>0&&a("#submit").show(),setTimeout(function(){e.load()},200)})})):"wp_remote_post"===wpacu_object.dom_get_type&&(b={action:wpacu_object.plugin_name+"_get_loaded_assets",post_id:wpacu_object.post_id,page_url:wpacu_object.page_url,tag_id:wpacu_object.tag_id,time_r:(new Date).getTime()},a.post(wpacu_object.ajax_url,b,function(b){if(!b)return!1;a("#wpacu_meta_box_content").html(b),a("#wpacu_home_page_form").length>0&&a("#submit").show(),setTimeout(function(){e.load()},200)}))}a("#wpacu-mark-license-valid-button").click(function(){return confirm(wpacu_object.mark_license_valid_confirm)});var c,d;a("#wpacu-reset-drop-down").on("change keyup keydown mouseup mousedown click",function(){""===a(this).val()?(a("#wpacu-warning-read").removeClass("wpacu-visible"),a("#wpacu-reset-submit-btn").attr("disabled","disabled").removeClass("button-primary").addClass("button-secondary")):("reset_everything"===a(this).val()?a("#wpacu-license-data-remove-area").addClass("wpacu-visible"):a("#wpacu-license-data-remove-area").removeClass("wpacu-visible"),a("#wpacu-warning-read").addClass("wpacu-visible"),a("#wpacu-reset-submit-btn").removeAttr("disabled").removeClass("button-secondary").addClass("button-primary")),a(".wpacu-tools-area .wpacu-warning").hide(),c=a(this).find("option:selected"),a("#"+c.attr("data-id")).show()}),a("#wpacu-reset-submit-btn").on("click",function(){if("reset_settings"===a("#wpacu-reset-drop-down").val()?d=wpacu_object.reset_settings_confirm_msg:"reset_everything"===a("#wpacu-reset-drop-down").val()&&(d=wpacu_object.reset_everything_confirm_msg),!confirm(d))return!1;a("#wpacu-action-confirmed").val("yes"),setTimeout(function(){"yes"===a("#wpacu-action-confirmed").val()&&a("#wpacu-tools-form").submit()},1e3)});var e={load:function(){var b;a(".input-unload-on-this-page").on("click change",function(){a(this).prop("checked")?a(this).closest("tr").addClass("wpacu_not_load"):a(this).closest("tr").removeClass("wpacu_not_load")}),a(".wpacu_global_unload").click(function(){b=a(this).attr("data-handle"),a(this).prop("checked")?a(this).parent("label").addClass("wpacu_global_checked"):a(this).parent("label").removeClass("wpacu_global_checked")}),a(".wpacu_keep_bulk_rule").click(function(){a(this).prop("checked")&&a(this).parents("li").next().removeClass("remove_rule")}),a(".wpacu_remove_bulk_rule").click(function(){a(this).prop("checked")&&a(this).parents("li").addClass("remove_rule")}),a(".wpacu_bulk_unload").click(function(){a(this).prop("checked")?a(this).parent("label").addClass("wpacu_bulk_unload_active"):a(this).parent("label").removeClass("wpacu_bulk_unload_active")}),a(".wpacu_load_it_option").click(function(){var b=a(this).attr("data-handle");if(a(this).prop("checked")){a(this).parent("label").addClass("wpacu_global_unload_exception");var c="";a(this).hasClass("wpacu_style")?c="style":a(this).hasClass("wpacu_script")&&(c="script"),a("#"+c+"_"+b).prop("checked",!1).trigger("change")}else a(this).parent("label").removeClass("wpacu_global_unload_exception")}),a(".wpacu-external-file-size").on("click",function(b){b.preventDefault();var c,d=a(this);d.hide(),c=d.next(),c.show(),a.post(wpacu_object.ajax_url,{action:"get_external_file_size",wpacu_remote_file:d.attr("data-src")},function(a){c.html(a)})})}};a(".wpacu-dom-get-type-selection").change(function(){a(this).is(":checked")&&(a(".wpacu-dom-get-type-info").hide(),a("#"+a(this).attr("data-target")).fadeIn("fast"))}),a("#wpacu_post_type_select").change(function(){a("#wpacu_post_type_form").submit()}),a("#wpacu_taxonomy_select").change(function(){a("#wpacu_taxonomy_form").submit()}),a("#wpacu_dashboard").click(function(){a(this).prop("checked")?a("#wpacu-settings-assets-retrieval-mode").fadeIn("fast"):a("#wpacu-settings-assets-retrieval-mode").fadeOut("fast")}),a("#wpacu_disable_jquery_migrate").on("click",function(){return!a(this).is(":checked")||(!(!a(this).is(":checked")||!confirm(wpacu_object.jquery_migration_disable_confirm_msg))||(a(this).prop("checked",!1),!1))}),a("#wpacu_disable_comment_reply").on("click",function(){return!a(this).is(":checked")||(!(!a(this).is(":checked")||!confirm(wpacu_object.comment_reply_disable_confirm_msg))||(a(this).prop("checked",!1),!1))}),a("#wpacu_combine_loaded_css_enable").click(function(){a(this).prop("checked")?a("#combine_loaded_css_info_area").css({opacity:1}):a("#combine_loaded_css_info_area").css({opacity:.4})}),a("#wpacu_combine_loaded_js_enable").click(function(){a(this).prop("checked")?a("#combine_loaded_js_info_area").css({opacity:1}):a("#combine_loaded_js_info_area").css({opacity:.4})}),a("#wpacu_minify_css_enable").click(function(){a(this).prop("checked")?a("#wpacu_minify_css_exceptions_area").css({opacity:1}):a("#wpacu_minify_css_exceptions_area").css({opacity:.4})}),a("#wpacu_minify_js_enable").click(function(){a(this).prop("checked")?a("#wpacu_minify_js_exceptions_area").css({opacity:1}):a("#wpacu_minify_js_exceptions_area").css({opacity:.4})}),a("#wpacu_remove_html_comments").click(function(){a(this).prop("checked")?a("#wpacu_remove_html_comments_area").css({opacity:1}):a("#wpacu_remove_html_comments_area").css({opacity:.4})}),a(".wpacu-combine-loaded-js-level").change(function(){a(this).is(":checked")&&(a(".wpacu_combine_loaded_js_level_area").removeClass("wpacu_active"),a("#"+a(this).attr("data-target")).addClass("wpacu_active"))});var f=a('#wpacu-update-button-area input[type="submit"]');if(f.click(function(){a("#wpacu-updating-settings").show()}),a("form#wpacu-settings-form").submit(function(){return f.attr("disabled","disabled"),!0}),a(".wpacu_remove_rule").click(function(){var b=a(this).parents(".wpacu_global_rule_row");a(this).prop("checked")?b.addClass("selected"):b.removeClass("selected")}),a("#wpacu_wrap_assets").length>0&&setTimeout(function(){e.load()},200),"undefined"==typeof wpacu_object||a("#wpacu_meta_box_content").length<1)return!1;b(),a(document).on("click",".wp-admin.wp-editor .edit-post-header__settings button.is-primary",function(){var c=function(){0===a(".edit-post-header__settings .is-saving").length&&(b(),clearInterval(d))},d=setInterval(c,900)})}),-1!==location.href.indexOf("#")){var hashFromUrl=location.href.substr(location.href.indexOf("#"));jQuery('a[href="'+hashFromUrl+'"]').trigger("click")}
1
+ function wpacuTabOpenSettingsArea(a,b){a.preventDefault();var c,d,e;for(d=document.getElementsByClassName("wpacu-settings-tab-content"),c=0;c<d.length;c++)d[c].style.display="none";for(e=document.getElementsByClassName("wpacu-settings-tab-link"),c=0;c<e.length;c++)e[c].className=e[c].className.replace(" active","");document.getElementById(b).style.display="table-cell",jQuery('a[href="#'+b+'"]').addClass("active"),jQuery("#wpacu-selected-tab-area").val(b),history.pushState(null,null,"#"+b)}if(jQuery(document).ready(function(a){function b(){if(!a("#wpacu_ajax_fetch_assets_list_dashboard_view").length)return!1;var b={};"direct"===wpacu_object.dom_get_type?(b[wpacu_object.plugin_name+"_load"]=1,b[wpacu_object.plugin_name+"_time_r"]=(new Date).getTime(),a.ajax({method:"GET",url:wpacu_object.page_url,data:b,cache:!1,complete:function(b,c){if("error"===b.statusText){var d=wpacu_object.ajax_direct_fetch_error;d=d.replace(/\{wpacu_output\}/,b.responseText),d=d.replace(/\{wpacu_status_code_error\}/,b.status),a("#wpacu_meta_box_content").html(d)}}}).done(function(b){var c=b.substring(b.lastIndexOf(wpacu_object.start_del)+wpacu_object.start_del.length,b.lastIndexOf(wpacu_object.end_del)),d={action:wpacu_object.plugin_name+"_get_loaded_assets",wpacu_list:c,post_id:wpacu_object.post_id,page_url:wpacu_object.page_url,tag_id:wpacu_object.tag_id,time_r:(new Date).getTime()};a.post(wpacu_object.ajax_url,d,function(b){if(!b)return!1;a("#wpacu_meta_box_content").html(b),a("#wpacu_home_page_form").length>0&&a("#submit").show(),setTimeout(function(){e.load()},200)})})):"wp_remote_post"===wpacu_object.dom_get_type&&(b={action:wpacu_object.plugin_name+"_get_loaded_assets",post_id:wpacu_object.post_id,page_url:wpacu_object.page_url,tag_id:wpacu_object.tag_id,time_r:(new Date).getTime()},a.post(wpacu_object.ajax_url,b,function(b){if(!b)return!1;a("#wpacu_meta_box_content").html(b),a("#wpacu_home_page_form").length>0&&a("#submit").show(),setTimeout(function(){e.load()},200)}))}a("#wpacu-mark-license-valid-button").click(function(){return confirm(wpacu_object.mark_license_valid_confirm)});var c,d;a("#wpacu-reset-drop-down").on("change keyup keydown mouseup mousedown click",function(){""===a(this).val()?(a("#wpacu-warning-read").removeClass("wpacu-visible"),a("#wpacu-reset-submit-btn").attr("disabled","disabled").removeClass("button-primary").addClass("button-secondary")):("reset_everything"===a(this).val()?a("#wpacu-license-data-remove-area").addClass("wpacu-visible"):a("#wpacu-license-data-remove-area").removeClass("wpacu-visible"),a("#wpacu-warning-read").addClass("wpacu-visible"),a("#wpacu-reset-submit-btn").removeAttr("disabled").removeClass("button-secondary").addClass("button-primary")),a(".wpacu-tools-area .wpacu-warning").hide(),c=a(this).find("option:selected"),a("#"+c.attr("data-id")).show()}),a("#wpacu-reset-submit-btn").on("click",function(){if("reset_settings"===a("#wpacu-reset-drop-down").val()?d=wpacu_object.reset_settings_confirm_msg:"reset_everything"===a("#wpacu-reset-drop-down").val()&&(d=wpacu_object.reset_everything_confirm_msg),!confirm(d))return!1;a("#wpacu-action-confirmed").val("yes"),setTimeout(function(){"yes"===a("#wpacu-action-confirmed").val()&&a("#wpacu-tools-form").submit()},1e3)});var e={load:function(){var b;a(".input-unload-on-this-page").on("click change",function(){a(this).prop("checked")?a(this).closest("tr").addClass("wpacu_not_load"):a(this).closest("tr").removeClass("wpacu_not_load")}),a(".wpacu_global_unload").click(function(){b=a(this).attr("data-handle"),a(this).prop("checked")?a(this).parent("label").addClass("wpacu_global_checked"):a(this).parent("label").removeClass("wpacu_global_checked")}),a(".wpacu_keep_bulk_rule").click(function(){a(this).prop("checked")&&a(this).parents("li").next().removeClass("remove_rule")}),a(".wpacu_remove_bulk_rule").click(function(){a(this).prop("checked")&&a(this).parents("li").addClass("remove_rule")}),a(".wpacu_bulk_unload").click(function(){a(this).prop("checked")?a(this).parent("label").addClass("wpacu_bulk_unload_active"):a(this).parent("label").removeClass("wpacu_bulk_unload_active")}),a(".wpacu_load_it_option").click(function(){var b=a(this).attr("data-handle");if(a(this).prop("checked")){a(this).parent("label").addClass("wpacu_global_unload_exception");var c="";a(this).hasClass("wpacu_style")?c="style":a(this).hasClass("wpacu_script")&&(c="script"),a("#"+c+"_"+b).prop("checked",!1).trigger("change")}else a(this).parent("label").removeClass("wpacu_global_unload_exception")}),a(".wpacu-external-file-size").on("click",function(b){b.preventDefault();var c,d=a(this);d.hide(),c=d.next(),c.show(),a.post(wpacu_object.ajax_url,{action:"get_external_file_size",wpacu_remote_file:d.attr("data-src")},function(a){c.html(a)})})}};a(".wpacu-dom-get-type-selection").change(function(){a(this).is(":checked")&&(a(".wpacu-dom-get-type-info").hide(),a("#"+a(this).attr("data-target")).fadeIn("fast"))}),a("#wpacu_post_type_select").change(function(){a("#wpacu_post_type_form").submit()}),a("#wpacu_taxonomy_select").change(function(){a("#wpacu_taxonomy_form").submit()}),a("#wpacu_dashboard").click(function(){a(this).prop("checked")?a("#wpacu-settings-assets-retrieval-mode").fadeIn("fast"):a("#wpacu-settings-assets-retrieval-mode").fadeOut("fast")}),a("#wpacu_frontend").click(function(){a(this).prop("checked")?a("#wpacu-settings-frontend-exceptions").fadeIn("fast"):a("#wpacu-settings-frontend-exceptions").fadeOut("fast")}),a("#wpacu_disable_jquery_migrate").on("click",function(){return!a(this).is(":checked")||(!(!a(this).is(":checked")||!confirm(wpacu_object.jquery_migration_disable_confirm_msg))||(a(this).prop("checked",!1),!1))}),a("#wpacu_disable_comment_reply").on("click",function(){return!a(this).is(":checked")||(!(!a(this).is(":checked")||!confirm(wpacu_object.comment_reply_disable_confirm_msg))||(a(this).prop("checked",!1),!1))}),a("#wpacu_combine_loaded_css_enable").click(function(){a(this).prop("checked")?a("#combine_loaded_css_info_area").css({opacity:1}):a("#combine_loaded_css_info_area").css({opacity:.4})}),a("#wpacu_combine_loaded_js_enable").click(function(){a(this).prop("checked")?a("#combine_loaded_js_info_area").css({opacity:1}):a("#combine_loaded_js_info_area").css({opacity:.4})}),a("#wpacu_minify_css_enable").click(function(){a(this).prop("checked")?a("#wpacu_minify_css_exceptions_area").css({opacity:1}):a("#wpacu_minify_css_exceptions_area").css({opacity:.4})}),a("#wpacu_minify_js_enable").click(function(){a(this).prop("checked")?a("#wpacu_minify_js_exceptions_area").css({opacity:1}):a("#wpacu_minify_js_exceptions_area").css({opacity:.4})}),a("#wpacu_remove_html_comments").click(function(){a(this).prop("checked")?a("#wpacu_remove_html_comments_area").css({opacity:1}):a("#wpacu_remove_html_comments_area").css({opacity:.4})}),a(".wpacu-combine-loaded-js-level").change(function(){a(this).is(":checked")&&(a(".wpacu_combine_loaded_js_level_area").removeClass("wpacu_active"),a("#"+a(this).attr("data-target")).addClass("wpacu_active"))});var f=a('#wpacu-update-button-area input[type="submit"]');if(f.click(function(){a("#wpacu-updating-settings").show()}),a("form#wpacu-settings-form").submit(function(){return f.attr("disabled","disabled"),!0}),a(".wpacu_remove_rule").click(function(){var b=a(this).parents(".wpacu_global_rule_row");a(this).prop("checked")?b.addClass("selected"):b.removeClass("selected")}),a("#wpacu_wrap_assets").length>0&&setTimeout(function(){e.load()},200),"undefined"==typeof wpacu_object||a("#wpacu_meta_box_content").length<1)return!1;b(),a(document).on("click",".wp-admin.wp-editor .edit-post-header__settings button.is-primary",function(){var c=function(){0===a(".edit-post-header__settings .is-saving").length&&(b(),clearInterval(d))},d=setInterval(c,900)})}),-1!==location.href.indexOf("#")){var hashFromUrl=location.href.substr(location.href.indexOf("#"));jQuery('a[href="'+hashFromUrl+'"]').trigger("click")}
classes/AdminBar.php CHANGED
@@ -63,7 +63,7 @@ class AdminBar
63
if (! is_admin()) {
64
if ( ! Misc::isHomePage() ) {
65
// Not on the home page
66
- $homepageManageAssetsHref = Main::instance()->settings['frontend_show']
67
? get_site_url().'#wpacu_wrap_assets'
68
: admin_url( 'admin.php?page=' . WPACU_PLUGIN_ID . '_assets_manager&wpacu_for=homepage' );
69
@@ -76,7 +76,7 @@ class AdminBar
76
} else {
77
// On the home page
78
// Front-end view is disabled! Go to Dashboard link
79
- if ( ! Main::instance()->settings['frontend_show'] ) {
80
$wp_admin_bar->add_menu( array(
81
'parent' => 'assetcleanup-parent',
82
'id' => 'assetcleanup-homepage',
@@ -87,7 +87,7 @@ class AdminBar
87
}
88
}
89
90
- if (! is_admin() && Main::instance()->settings['frontend_show']) {
91
$wp_admin_bar->add_menu(array(
92
'parent' => 'assetcleanup-parent',
93
'id' => 'assetcleanup-jump-to-assets-list',
63
if (! is_admin()) {
64
if ( ! Misc::isHomePage() ) {
65
// Not on the home page
66
+ $homepageManageAssetsHref = Main::instance()->frontendShow()
67
? get_site_url().'#wpacu_wrap_assets'
68
: admin_url( 'admin.php?page=' . WPACU_PLUGIN_ID . '_assets_manager&wpacu_for=homepage' );
69
76
} else {
77
// On the home page
78
// Front-end view is disabled! Go to Dashboard link
79
+ if ( ! Main::instance()->frontendShow() ) {
80
$wp_admin_bar->add_menu( array(
81
'parent' => 'assetcleanup-parent',
82
'id' => 'assetcleanup-homepage',
87
}
88
}
89
90
+ if (! is_admin() && Main::instance()->frontendShow()) {
91
$wp_admin_bar->add_menu(array(
92
'parent' => 'assetcleanup-parent',
93
'id' => 'assetcleanup-jump-to-assets-list',
classes/CleanUp.php CHANGED
@@ -232,12 +232,23 @@ class CleanUp
232
return $htmlSource;
233
}
234
235
$domComments = new \DOMDocument();
236
$domComments->loadHTML($htmlSource);
237
238
$xpathComments = new \DOMXPath($domComments);
239
$comments = $xpathComments->query('//comment()');
240
241
if ($comments === null) {
242
return $htmlSource;
243
}
232
return $htmlSource;
233
}
234
235
+ if (! (function_exists('libxml_use_internal_errors')
236
+ && function_exists('libxml_clear_errors')
237
+ && class_exists('DOMDocument')))
238
+ {
239
+ return $htmlSource;
240
+ }
241
+
242
$domComments = new \DOMDocument();
243
+ libxml_use_internal_errors(true);
244
+
245
$domComments->loadHTML($htmlSource);
246
247
$xpathComments = new \DOMXPath($domComments);
248
$comments = $xpathComments->query('//comment()');
249
250
+ libxml_clear_errors();
251
+
252
if ($comments === null) {
253
return $htmlSource;
254
}
classes/Main.php CHANGED
@@ -228,7 +228,7 @@ class Main
228
$calledFromDashboard = isset($_REQUEST[WPACU_LOAD_ASSETS_REQ_KEY]);
229
230
// Fetch the page in the background to see what scripts/styles are already loading
231
- if ($calledFromDashboard || $this->settings['frontend_show']) {
232
if ($calledFromDashboard) {
233
Misc::noAdminBarLoad();
234
}
@@ -256,10 +256,16 @@ class Main
256
}
257
258
// If assets management within the Dashboard is not enabled, an explanation message will be shown within the box
259
- $metaboxes->initManagerMetaBox();
260
261
// Side Meta Box: Asset CleanUp Options
262
- $metaboxes->initCustomOptionsMetaBox();
263
}
264
265
if ($this->settings['disable_emojis'] == 1) {
@@ -272,7 +278,7 @@ class Main
272
*/
273
public function setVarsBeforeUpdate()
274
{
275
- $this->isFrontendEditView = ( $this->settings['frontend_show'] && Menu::userCanManageAssets()
276
&& !isset($_REQUEST[WPACU_LOAD_ASSETS_REQ_KEY])
277
&& !is_admin());
278
@@ -543,6 +549,9 @@ class Main
543
return;
544
}
545
546
if (empty($list)) {
547
return;
548
}
@@ -1234,12 +1243,13 @@ class Main
1234
$obj->src
1235
);
1236
1237
- list(,$parentDir) = explode('/', $part);
1238
1239
// Loaded from WordPress directories (Core)
1240
if (in_array($parentDir, array('wp-includes', 'wp-admin'))) {
1241
$data['all']['styles'][$key]->wp = true;
1242
- $data['core_styles_loaded'] = true;
1243
}
1244
1245
// Determine source href (starting with '/' but not starting with '//')
@@ -1284,7 +1294,8 @@ class Main
1284
$obj->src
1285
);
1286
1287
- list(,$parentDir) = explode('/', $part);
1288
1289
// Loaded from WordPress directories (Core)
1290
if (in_array($parentDir, array('wp-includes', 'wp-admin'))) {
@@ -1623,6 +1634,41 @@ class Main
1623
}
1624
// [/wpacu_lite]
1625
1626
/**
1627
* Make administrator more aware if "TEST MODE" is enabled or not
1628
*/
228
$calledFromDashboard = isset($_REQUEST[WPACU_LOAD_ASSETS_REQ_KEY]);
229
230
// Fetch the page in the background to see what scripts/styles are already loading
231
+ if ($calledFromDashboard || $this->frontendShow()) {
232
if ($calledFromDashboard) {
233
Misc::noAdminBarLoad();
234
}
256
}
257
258
// If assets management within the Dashboard is not enabled, an explanation message will be shown within the box
259
+ // unless the meta box is hidden completely
260
+ if (! $this->settings['hide_assets_meta_box']) {
261
+ $metaboxes->initManagerMetaBox();
262
+ }
263
264
// Side Meta Box: Asset CleanUp Options
265
+ // check if it's not hidden completely
266
+ if (! $this->settings['hide_options_meta_box']) {
267
+ $metaboxes->initCustomOptionsMetaBox();
268
+ }
269
}
270
271
if ($this->settings['disable_emojis'] == 1) {
278
*/
279
public function setVarsBeforeUpdate()
280
{
281
+ $this->isFrontendEditView = ( $this->frontendShow() && Menu::userCanManageAssets()
282
&& !isset($_REQUEST[WPACU_LOAD_ASSETS_REQ_KEY])
283
&& !is_admin());
284
549
return;
550
}
551
552
+ wp_cache_set('wpacu_all_styles_handles', array_keys($this->wpAllStyles['registered']));
553
+
554
+ // Nothing to unload?
555
if (empty($list)) {
556
return;
557
}
1243
$obj->src
1244
);
1245
1246
+ $parts = explode('/', $part);
1247
+ $parentDir = isset($parts[1]) ? $parts[1] : '';
1248
1249
// Loaded from WordPress directories (Core)
1250
if (in_array($parentDir, array('wp-includes', 'wp-admin'))) {
1251
$data['all']['styles'][$key]->wp = true;
1252
+ $data['core_styles_loaded'] = true;
1253
}
1254
1255
// Determine source href (starting with '/' but not starting with '//')
1294
$obj->src
1295
);
1296
1297
+ $parts = explode('/', $part);
1298
+ $parentDir = isset($parts[1]) ? $parts[1] : '';
1299
1300
// Loaded from WordPress directories (Core)
1301
if (in_array($parentDir, array('wp-includes', 'wp-admin'))) {
1634
}
1635
// [/wpacu_lite]
1636
1637
+ /**
1638
+ * @return bool
1639
+ */
1640
+ public function frontendShow()
1641
+ {
1642
+ // The option is disabled
1643
+ if (! $this->settings['frontend_show']) {
1644
+ return false;
1645
+ }
1646
+
1647
+ // The asset list is hidden via query string: /?wpacu_no_frontend_show
1648
+ if (array_key_exists('wpacu_no_frontend_show', $_GET)) {
1649
+ return false;
1650
+ }
1651
+
1652
+ // The option is enabled, but there are show exceptions, check if the list should be hidden
1653
+ if ($this->settings['frontend_show_exceptions']) {
1654
+ $frontendShowExceptions = trim( $this->settings['frontend_show_exceptions'] );
1655
+
1656
+ if ( strpos( $frontendShowExceptions, "\n" ) !== false ) {
1657
+ foreach ( explode( "\n", $frontendShowExceptions ) as $frontendShowException ) {
1658
+ $frontendShowException = trim($frontendShowException);
1659
+
1660
+ if ( strpos( $_SERVER['REQUEST_URI'], $frontendShowException ) !== false ) {
1661
+ return false;
1662
+ }
1663
+ }
1664
+ } elseif ( strpos( $_SERVER['REQUEST_URI'], $frontendShowExceptions ) !== false ) {
1665
+ return false;
1666
+ }
1667
+ }
1668
+
1669
+ return true;
1670
+ }
1671
+
1672
/**
1673
* Make administrator more aware if "TEST MODE" is enabled or not
1674
*/
classes/OptimiseAssets/MinifyCss.php CHANGED
@@ -36,23 +36,33 @@ class MinifyCss
36
37
global $wp_styles;
38
39
$cssMinifyList = array();
40
41
// [Start] Collect for caching
42
- foreach ($wp_styles->done as $handle) {
43
if (isset($wp_styles->registered[$handle])) {
44
$value = $wp_styles->registered[$handle];
45
- $minifyValues = $this->maybeMinifyIt( $value );
46
47
- if ( ! empty( $minifyValues ) ) {
48
$cssMinifyList[] = $minifyValues;
49
}
50
}
51
}
52
53
wp_cache_add('wpacu_css_minify_list', $cssMinifyList);
54
// [End] Collect for caching
55
- }, 1);
56
57
// Alter the HTML source by updating the original link URLs with the cached ones
58
}
36
37
global $wp_styles;
38
39
+ $allStylesHandles = wp_cache_get('wpacu_all_styles_handles');
40
+
41
+ if (empty($allStylesHandles)) {
42
+ return;
43
+ }
44
+
45
$cssMinifyList = array();
46
47
// [Start] Collect for caching
48
+ foreach ($allStylesHandles as $handle) {
49
if (isset($wp_styles->registered[$handle])) {
50
$value = $wp_styles->registered[$handle];
51
+ $minifyValues = $this->maybeMinifyIt($value);
52
53
+ if (! empty($minifyValues)) {
54
$cssMinifyList[] = $minifyValues;
55
}
56
}
57
}
58
59
+ if (empty($cssMinifyList)) {
60
+ return;
61
+ }
62
+
63
wp_cache_add('wpacu_css_minify_list', $cssMinifyList);
64
// [End] Collect for caching
65
+ }, PHP_INT_MAX);
66
67
// Alter the HTML source by updating the original link URLs with the cached ones
68
}
classes/OptimiseAssets/OptimizeCss.php CHANGED
@@ -224,12 +224,16 @@ class OptimizeCss
224
}
225
226
if ( ! empty($storageJsonContents) ) {
227
- foreach ($storageJsonContents as $locationTag => $storageJsonContent) {
228
- $storageJsonContent['link_hrefs'] = array_map( function ( $href ) {
229
return str_replace( '{site_url}', site_url(), $href );
230
- }, $storageJsonContent['link_hrefs'] );
231
232
- $finalTagUrl = WP_CONTENT_URL . self::$relPathCssCacheDir . $storageJsonContent['uri_to_final_css_file'];
233
234
$finalCssTag = <<<HTML
235
<link id='asset-cleanup-combined-css-{$locationTag}' rel='stylesheet' href='{$finalTagUrl}' type='text/css' media='all' />
@@ -238,14 +242,14 @@ HTML;
238
$htmlSourceBeforeAnyLinkTagReplacement = $htmlSource;
239
240
// Detect first LINK tag from the <$locationTag> and replace it with the final combined LINK tag
241
- $firstLinkTag = $this->getFirstLinkTag($storageJsonContent['link_hrefs'][0], $htmlSource);
242
243
if ($firstLinkTag) {
244
$htmlSource = str_replace( $firstLinkTag, $finalCssTag, $htmlSource );
245
}
246
247
if ($htmlSource !== $htmlSourceBeforeAnyLinkTagReplacement) {
248
- $htmlSource = OptimizeCommon::stripJustCombinedFileTags( $storageJsonContent['link_hrefs'], $htmlSource, 'css' ); // Strip the combined files to avoid duplicate code
249
250
// There should be at least two replacements made
251
if ( $htmlSource === 'do_not_combine' ) {
@@ -345,9 +349,14 @@ HTML;
345
$finalAssetsContents = trim($finalAssetsContents);
346
347
if ($finalAssetsContents) {
348
- if ($dirToUserCachedFile !== '' && isset($current_user->ID) && $current_user->ID > 0
349
- && !mkdir($localDirForCssFile) && !is_dir($localDirForCssFile)) {
350
- return array('uri_final_css_file' => '', 'local_final_css_file' => '');
351
}
352
353
@file_put_contents($localFinalCssFile, $finalAssetsContents);
224
}
225
226
if ( ! empty($storageJsonContents) ) {
227
+ foreach ($storageJsonContents as $locationTag => $storageJsonContentLocation) {
228
+ if (! isset($storageJsonContentLocation['link_hrefs'][0])) {
229
+ continue;
230
+ }
231
+
232
+ $storageJsonContentLocation['link_hrefs'] = array_map( function ( $href ) {
233
return str_replace( '{site_url}', site_url(), $href );
234
+ }, $storageJsonContentLocation['link_hrefs'] );
235
236
+ $finalTagUrl = WP_CONTENT_URL . self::$relPathCssCacheDir . $storageJsonContentLocation['uri_to_final_css_file'];
237
238
$finalCssTag = <<<HTML
239
<link id='asset-cleanup-combined-css-{$locationTag}' rel='stylesheet' href='{$finalTagUrl}' type='text/css' media='all' />
242
$htmlSourceBeforeAnyLinkTagReplacement = $htmlSource;
243
244
// Detect first LINK tag from the <$locationTag> and replace it with the final combined LINK tag
245
+ $firstLinkTag = $this->getFirstLinkTag($storageJsonContentLocation['link_hrefs'][0], $htmlSource);
246
247
if ($firstLinkTag) {
248
$htmlSource = str_replace( $firstLinkTag, $finalCssTag, $htmlSource );
249
}
250
251
if ($htmlSource !== $htmlSourceBeforeAnyLinkTagReplacement) {
252
+ $htmlSource = OptimizeCommon::stripJustCombinedFileTags( $storageJsonContentLocation['link_hrefs'], $htmlSource, 'css' ); // Strip the combined files to avoid duplicate code
253
254
// There should be at least two replacements made
255
if ( $htmlSource === 'do_not_combine' ) {
349
$finalAssetsContents = trim($finalAssetsContents);
350
351
if ($finalAssetsContents) {
352
+ if ($dirToUserCachedFile !== '' && isset($current_user->ID) && $current_user->ID > 0) {
353
+ if (! is_dir($localDirForCssFile)) {
354
+ $makeLocalDirForCss = @mkdir($localDirForCssFile);
355
+
356
+ if (! $makeLocalDirForCss) {
357
+ return array('uri_final_css_file' => '', 'local_final_css_file' => '');
358
+ }
359
+ }
360
}
361
362
@file_put_contents($localFinalCssFile, $finalAssetsContents);
classes/OwnAssets.php CHANGED
@@ -144,7 +144,7 @@ class OwnAssets
144
145
// Is the Admin Bar not showing and "Manage in the Front-end" option is not enabled in the plugin's "Settings"?
146
// In this case, there's no point in loading the assets below
147
- if (! is_admin_bar_showing() && ! Main::instance()->settings['frontend_show']) {
148
return;
149
}
150
144
145
// Is the Admin Bar not showing and "Manage in the Front-end" option is not enabled in the plugin's "Settings"?
146
// In this case, there's no point in loading the assets below
147
+ if (! is_admin_bar_showing() && ! Main::instance()->frontendShow()) {
148
return;
149
}
150
classes/Settings.php CHANGED
@@ -16,10 +16,18 @@ class Settings
16
// Stored in 'wpassetcleanup_settings'
17
'wiki_read',
18
19
'dashboard_show',
20
'dom_get_type',
21
'frontend_show',
22
23
'assets_list_layout',
24
'assets_list_layout_areas_status',
25
'assets_list_inline_code_status',
@@ -91,6 +99,8 @@ class Settings
91
// Direct AJAX call by default (not via WP Remote Post)
92
'dom_get_type' => 'direct',
93
94
// Since v1.2.9.3 (lite), the default value is "by-location" (All Styles & All Scripts - By Location (Theme, Plugins, Custom & External))
95
// Prior to that it's "two-lists" (All Styles & All Scripts - 2 separate lists)
96
'assets_list_layout' => 'by-location',
@@ -176,7 +186,7 @@ class Settings
176
foreach ($this->settingsKeys as $settingKey) {
177
// Special check for plugin versions < 1.2.4.4
178
if ($settingKey === 'frontend_show') {
179
- $data['frontend_show'] = $this->showOnFrontEnd();
180
}
181
}
182
@@ -196,7 +206,7 @@ class Settings
196
/**
197
* @return bool
198
*/
199
- public function showOnFrontEnd()
200
{
201
$settings = $this->getAll();
202
@@ -244,7 +254,7 @@ class Settings
244
245
// If it doesn't exist, it was never saved
246
// Make sure the default value is added to the textarea
247
- if ($settingsKey === 'minify_loaded_css_exceptions') {
248
$settings[$settingsKey] = self::$defaultSettings['minify_loaded_css_exceptions'];
249
}
250
}
16
// Stored in 'wpassetcleanup_settings'
17
'wiki_read',
18
19
+ // Dashboard Assets Management
20
'dashboard_show',
21
'dom_get_type',
22
+
23
+ 'hide_assets_meta_box', // Asset CleanUp Pro: CSS & JavaScript Manager
24
+ 'hide_options_meta_box', // Asset CleanUp Pro: Options
25
+
26
+ // Front-end View Assets Management
27
'frontend_show',
28
+ 'frontend_show_exceptions',
29
30
+ // The way the CSS/JS list is showing (various ways depending on the preference)
31
'assets_list_layout',
32
'assets_list_layout_areas_status',
33
'assets_list_inline_code_status',
99
// Direct AJAX call by default (not via WP Remote Post)
100
'dom_get_type' => 'direct',
101
102
+ 'frontend_show_exceptions' => 'et_fb=1',
103
+
104
// Since v1.2.9.3 (lite), the default value is "by-location" (All Styles & All Scripts - By Location (Theme, Plugins, Custom & External))
105
// Prior to that it's "two-lists" (All Styles & All Scripts - 2 separate lists)
106
'assets_list_layout' => 'by-location',
186
foreach ($this->settingsKeys as $settingKey) {
187
// Special check for plugin versions < 1.2.4.4
188
if ($settingKey === 'frontend_show') {
189
+ $data['frontend_show'] = $this->showOnFrontEndLegacy();
190
}
191
}
192
206
/**
207
* @return bool
208
*/
209
+ public function showOnFrontEndLegacy()
210
{
211
$settings = $this->getAll();
212
254
255
// If it doesn't exist, it was never saved
256
// Make sure the default value is added to the textarea
257
+ if (in_array($settingsKey, array('frontend_show_exceptions', 'minify_loaded_css_exceptions', 'minify_loaded_js_exceptions'))) {
258
$settings[$settingsKey] = self::$defaultSettings['minify_loaded_css_exceptions'];
259
}
260
}
classes/Update.php CHANGED
@@ -68,7 +68,7 @@ HTML;
68
*/
69
public function triggersAfterInit()
70
{
71
- if (! is_admin() && Main::instance()->settings['frontend_show']) {
72
if (! empty($_POST)) {
73
add_action( 'wp', array( $this, 'frontendUpdate' ), 9 );
74
}
@@ -95,8 +95,8 @@ HTML;
95
96
$updateAction = Misc::getVar('post', 'wpacu_update_asset_frontend');
97
98
- if (! isset($_POST[$nonceName]) || $updateAction != 1 || ! Main::instance()->settings['frontend_show']) {
99
- return;
100
}
101
102
// only for admins
@@ -415,6 +415,14 @@ HTML;
415
*/
416
public function updatePageOptions($postId)
417
{
418
$pageOptions = array_key_exists(WPACU_PLUGIN_ID.'_page_options', $_POST)
419
? $_POST[WPACU_PLUGIN_ID.'_page_options']
420
: array();
68
*/
69
public function triggersAfterInit()
70
{
71
+ if (! is_admin() && Main::instance()->frontendShow()) {
72
if (! empty($_POST)) {
73
add_action( 'wp', array( $this, 'frontendUpdate' ), 9 );
74
}
95
96
$updateAction = Misc::getVar('post', 'wpacu_update_asset_frontend');
97
98
+ if (! isset($_POST[$nonceName]) || $updateAction != 1 || ! Main::instance()->frontendShow()) {
99
+ return;
100
}
101
102
// only for admins
415
*/
416
public function updatePageOptions($postId)
417
{
418
+ // Is the "Asset CleanUp: Page Options" meta box not loaded?
419
+ // Then do not perform any update below
420
+ $pageOptionsMetaBoxLoaded = isset($_POST['wpacu_meta_box_page_options_loaded']) ? trim($_POST['wpacu_meta_box_page_options_loaded']) : false;
421
+
422
+ if (! $pageOptionsMetaBoxLoaded) {
423
+ return;
424
+ }
425
+
426
$pageOptions = array_key_exists(WPACU_PLUGIN_ID.'_page_options', $_POST)
427
? $_POST[WPACU_PLUGIN_ID.'_page_options']
428
: array();
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: gabelivan
3
Tags: pagespeed, page speed, dequeue, performance, gtmetrix
4
Donate link: https://gabelivan.com/items/wp-asset-cleanup-pro/?utm_source=wp_org_lite&utm_medium=donate
5
Requires at least: 4.4
6
- Tested up to: 5.1
7
- Stable tag: 1.3.2.2
8
License: GPLv3
9
License URI: http://www.gnu.org/licenses/gpl.html
10
@@ -154,6 +154,16 @@ With the recently released "Test Mode" feature, you can safely unload assets on
154
4. Homepage CSS & JS Management (List sorted by location)
155
156
== Changelog ==
157
= 1.3.2.2 =
158
* Security Fix: Updated Freemius SDK to 2.2.4
159
* Bug Fix: Within the Dashboard, an error related to an undefined constant in Plugin.php was showing up
3
Tags: pagespeed, page speed, dequeue, performance, gtmetrix
4
Donate link: https://gabelivan.com/items/wp-asset-cleanup-pro/?utm_source=wp_org_lite&utm_medium=donate
5
Requires at least: 4.4
6
+ Tested up to: 5.1.1
7
+ Stable tag: 1.3.2.3
8
License: GPLv3
9
License URI: http://www.gnu.org/licenses/gpl.html
10
154
4. Homepage CSS & JS Management (List sorted by location)
155
156
== Changelog ==
157
+ = 1.3.2.3 =
158
+ * New Option in "Assets List Layout": Sort by CSS/JS position (HEAD and BODY tags)
159
+ * New Feature: Strip HTML Comments
160
+ * Assets Meta Box update: Changed 'advanced' to 'normal' for $context parameter (e.g. Oxygen Builder 2.2 compatibility); added option to update the $content and $priority of the Asset CleanUp meta boxes via "add_filter" via the following tags (for each meta box): wpacu_asset_list_meta_box_context, wpacu_asset_list_meta_box_priority, wpacu_page_options_meta_box_context, wpacu_page_options_meta_box_priority
161
+ * Bug Fix: Settings update now trigger on 'init' rather than 'plugins_loaded' for maximum compatibility with all WP installs;
162
+ * Bug Fix: Make sure Emojis are always disabled when specified in the Settings and there is no DNS prefetch to //s.w.org
163
+ * Potential WooCommerce bug fix (is_woocomerce() returns true while is_cart() isn't sometimes)
164
+ * Added video tutorials in the "Getting Started" area
165
+ * Removed HTML usage notice for Asset CleanUp
166
+
167
= 1.3.2.2 =
168
* Security Fix: Updated Freemius SDK to 2.2.4
169
* Bug Fix: Within the Dashboard, an error related to an undefined constant in Plugin.php was showing up
templates/_admin-page-settings-plugin-areas/_plugin-usage-settings.php CHANGED
@@ -71,6 +71,14 @@ $styleTabContent = ($selectedTabArea === $tabIdArea) ? 'style="display: table-ce
71
</li>
72
</ul>
73
</div>
74
</td>
75
</tr>
76
<tr valign="top">
@@ -87,6 +95,15 @@ $styleTabContent = ($selectedTabArea === $tabIdArea) ? 'style="display: table-ce
87
&nbsp;
88
If you are logged in, this will make the list of assets show below the page that you view (either home page, a post or a page).
89
<p style="margin-top: 10px;">The area will be shown through the <code>wp_footer</code> action so in case you do not see the asset list at the bottom of the page, make sure the theme is using <a href="https://codex.wordpress.org/Function_Reference/wp_footer"><code>wp_footer()</code></a> function before the <code>&lt;/body&gt;</code> tag. Any theme that follows the standards should have it. If not, you will have to add it to make sure other plugins and code from functions.php will work fine.</p>
90
</td>
91
</tr>
92
<tr valign="top">
@@ -98,6 +115,7 @@ $styleTabContent = ($selectedTabArea === $tabIdArea) ? 'style="display: table-ce
98
<select id="wpacu_assets_list_layout"
99
name="<?php echo WPACU_PLUGIN_ID . '_settings'; ?>[assets_list_layout]">
100
<option <?php if ($data['assets_list_layout'] === 'by-location') { echo 'selected="selected"'; } ?> value="by-location">All Styles &amp; Scripts &#10230; One list grouped by location (themes, plugins, core &amp; external)</option>
101
<option <?php if (in_array($data['assets_list_layout'], array('two-lists', 'default'))) { echo 'selected="selected"'; } ?> value="two-lists">All Styles + All Scripts &#10230; Two lists</option>
102
<option disabled="disabled" value="all">All Styles &amp; Scripts &#10230; One list (Pro Version)</option>
103
</select>
71
</li>
72
</ul>
73
</div>
74
+
75
+ <div id="wpacu-settings-hide-meta-boxes">
76
+ <p>Whether you have this option enabled or not, the post/page plugin's meta boxes will always be generated. If you wish to hide them completely for any reason (e.g. you rarely manage the assets and you want to reduce cluttering in the edit post/page area, especially if you do lots of edits), you can do so using the options below (<em>don't forget to uncheck them whenever you wish to manage the CSS/JS assets again</em>):</p>
77
+ <ul>
78
+ <li><label for="wpacu-hide-assets-meta-box-checkbox"><input <?php echo (($data['hide_assets_meta_box'] == 1) ? 'checked="checked"' : ''); ?> id="wpacu-hide-assets-meta-box-checkbox" type="checkbox" name="<?php echo WPACU_PLUGIN_ID . '_settings'; ?>[hide_assets_meta_box]" value="1" /> Hide "Asset CleanUp Pro: CSS &amp; JavaScript Manager" meta box</label></li>
79
+ <li><label for="wpacu-hide-options-meta-box-checkbox"><input <?php echo (($data['hide_options_meta_box'] == 1) ? 'checked="checked"' : ''); ?> id="wpacu-hide-options-meta-box-checkbox" type="checkbox" name="<?php echo WPACU_PLUGIN_ID . '_settings'; ?>[hide_options_meta_box]" value="1" /> Hide "Asset CleanUp Pro: Options" meta box</label></li>
80
+ </ul>
81
+ </div>
82
</td>
83
</tr>
84
<tr valign="top">
95
&nbsp;
96
If you are logged in, this will make the list of assets show below the page that you view (either home page, a post or a page).
97
<p style="margin-top: 10px;">The area will be shown through the <code>wp_footer</code> action so in case you do not see the asset list at the bottom of the page, make sure the theme is using <a href="https://codex.wordpress.org/Function_Reference/wp_footer"><code>wp_footer()</code></a> function before the <code>&lt;/body&gt;</code> tag. Any theme that follows the standards should have it. If not, you will have to add it to make sure other plugins and code from functions.php will work fine.</p>
98
+
99
+ <div id="wpacu-settings-frontend-exceptions" <?php if (! ($data['frontend_show'] == 1)) { echo 'style="display: none;"'; } ?>>
100
+ <div style="margin: 0 0 10px;"><label for="wpacu_frontend_show_exceptions"><span class="dashicons dashicons-info"></span> In some situations, you might want to avoid showing the CSS/JS list at the bottom of the pages (e.g. you're using a page builder such as Divi, you often load specific pages as an admin and you don't need to manage assets there or you do it rarely etc.). If that's the case, you can use the following textarea to prevent the list from showing up on pages where the <strong>URI contains</strong> the specified strings (one per line):</label></div>
101
+ <textarea id="wpacu_frontend_show_exceptions"
102
+ name="<?php echo WPACU_PLUGIN_ID . '_settings'; ?>[frontend_show_exceptions]"
103
+ rows="5"
104
+ style="width: 100%;"><?php echo $data['frontend_show_exceptions']; ?></textarea>
105
+ <p><strong>Example:</strong> If the URI contains <strong>et_fb=1</strong> which triggers the front-end Divi page builder, then you can specify it in the list above (it's added by default) to prevent the asset list from showing below the page builder area.</p>
106
+ </div>
107
</td>
108
</tr>
109
<tr valign="top">
115
<select id="wpacu_assets_list_layout"
116
name="<?php echo WPACU_PLUGIN_ID . '_settings'; ?>[assets_list_layout]">
117
<option <?php if ($data['assets_list_layout'] === 'by-location') { echo 'selected="selected"'; } ?> value="by-location">All Styles &amp; Scripts &#10230; One list grouped by location (themes, plugins, core &amp; external)</option>
118
+ <option <?php if ($data['assets_list_layout'] === 'by-position') { echo 'selected="selected"'; } ?> value="by-position">All Styles &amp; Scripts &#10230; One list grouped by tag position: &lt;head&gt; &amp; &lt;body&gt;</option>
119
<option <?php if (in_array($data['assets_list_layout'], array('two-lists', 'default'))) { echo 'selected="selected"'; } ?> value="two-lists">All Styles + All Scripts &#10230; Two lists</option>
120
<option disabled="disabled" value="all">All Styles &amp; Scripts &#10230; One list (Pro Version)</option>
121
</select>
templates/meta-box-loaded-assets/_asset-script-rows.php CHANGED
@@ -5,16 +5,15 @@ if (! isset($data)) {
5
6
foreach ($data['all']['scripts'] as $obj) {
7
$data['row'] = array();
8
- $data['row']['obj'] = $obj;
9
10
$active = (isset($data['current']['scripts']) && in_array($data['row']['obj']->handle, $data['current']['scripts']));
11
12
- $data['row']['class'] = $active ? 'wpacu_not_load' : '';
13
$data['row']['checked'] = $active ? 'checked="checked"' : '';
14
15
/*
16
- * $data['row']['is_global_rule'] is only used to apply a red background in the style's area to point out that the style is unloaded
17
- * is set to `true` if either the asset is unloaded everywhere or it's unloaded on a group of pages (such as all pages belonging to 'page' post type)
18
*/
19
$data['row']['global_unloaded'] = $data['row']['is_post_type_unloaded'] = $data['row']['is_load_exception'] = $data['row']['is_global_rule'] = false;
20
@@ -64,9 +63,16 @@ foreach ($data['all']['scripts'] as $obj) {
64
if (isset($data['rows_by_location']) && $data['rows_by_location']) {
65
$data['rows_assets']
66
[$data['row']['obj']->locationMain]
67
- [$data['row']['obj']->locationChild]
68
- [$uniqueHandle]
69
- ['script'] = $templateRowOutput;
70
} else {
71
$data['rows_assets'][ $uniqueHandle ] = $templateRowOutput;
72
}
5
6
foreach ($data['all']['scripts'] as $obj) {
7
$data['row'] = array();
8
+ $data['row']['obj'] = $obj;
9
10
$active = (isset($data['current']['scripts']) && in_array($data['row']['obj']->handle, $data['current']['scripts']));
11
12
+ $data['row']['class'] = $active ? 'wpacu_not_load' : '';
13
$data['row']['checked'] = $active ? 'checked="checked"' : '';
14
15
/*
16
+ * $data['row']['is_global_rule'] is only used to apply a red background in the script's area to point out that the script is unloaded
17
*/
18
$data['row']['global_unloaded'] = $data['row']['is_post_type_unloaded'] = $data['row']['is_load_exception'] = $data['row']['is_global_rule'] = false;
19
63
if (isset($data['rows_by_location']) && $data['rows_by_location']) {
64
$data['rows_assets']
65
[$data['row']['obj']->locationMain]
66
+ [$data['row']['obj']->locationChild]
67
+ [$uniqueHandle]
68
+ ['script'] = $templateRowOutput;
69
+ } elseif (isset($data['rows_by_position']) && $data['rows_by_position']) {
70
+ $handlePosition = (isset($data['row']['obj']->position_new) && $data['row']['obj']->position_new) ? $data['row']['obj']->position_new : $data['row']['obj']->position;
71
+
72
+ $data['rows_assets']
73
+ [$handlePosition] // 'head', 'body'
74
+ [$uniqueHandle]
75
+ ['script'] = $templateRowOutput;
76
} else {
77
$data['rows_assets'][ $uniqueHandle ] = $templateRowOutput;
78
}
templates/meta-box-loaded-assets/_asset-script-single-row.php CHANGED
@@ -89,6 +89,7 @@ $isBulkUnloaded = ($data['row']['global_unloaded'] || $data['row']['is_post_ty
89
if ($data['row']['global_unloaded']) {
90
?>
91
<p><strong style="color: #d54e21;">This JavaScript file is unloaded everywhere</strong></p>
92
<?php
93
}
94
?>
@@ -172,7 +173,7 @@ $isBulkUnloaded = ($data['row']['global_unloaded'] || $data['row']['is_post_ty
172
type="radio"
173
name="wpacu_options_post_type_scripts[<?php echo $data['row']['obj']->handle; ?>]"
174
value="remove"/>
175
- Remove rule</label>
176
</li>
177
<?php
178
} else {
@@ -184,7 +185,7 @@ $isBulkUnloaded = ($data['row']['global_unloaded'] || $data['row']['is_post_ty
184
type="checkbox"
185
name="wpacu_bulk_unload_scripts[post_type][<?php echo $data['post_type']; ?>][]"
186
value="<?php echo $data['row']['obj']->handle; ?>"/>
187
- Unload on All Pages of <strong><?php echo $data['post_type']; ?></strong> post type <small>* bulk unload</small></label>
188
</li>
189
<?php
190
}
89
if ($data['row']['global_unloaded']) {
90
?>
91
<p><strong style="color: #d54e21;">This JavaScript file is unloaded everywhere</strong></p>
92
+ <div class="wpacu-clearfix"></div>
93
<?php
94
}
95
?>
173
type="radio"
174
name="wpacu_options_post_type_scripts[<?php echo $data['row']['obj']->handle; ?>]"
175
value="remove"/>
176
+ Remove bulk rule</label>
177
</li>
178
<?php
179
} else {
185
type="checkbox"
186
name="wpacu_bulk_unload_scripts[post_type][<?php echo $data['post_type']; ?>][]"
187
value="<?php echo $data['row']['obj']->handle; ?>"/>
188
+ Unload on All Pages of <u><?php echo $data['post_type']; ?></u> post type <small>* bulk unload</small></label>
189
</li>
190
<?php
191
}
templates/meta-box-loaded-assets/_asset-style-rows.php CHANGED
@@ -63,10 +63,17 @@ foreach ($data['all']['styles'] as $obj) {
63
64
if (isset($data['rows_by_location']) && $data['rows_by_location']) {
65
$data['rows_assets']
66
- [$data['row']['obj']->locationMain]
67
[$data['row']['obj']->locationChild]
68
- [$uniqueHandle]
69
- ['style']= $templateRowOutput;
70
} else {
71
$data['rows_assets'][$uniqueHandle] = $templateRowOutput;
72
}
63
64
if (isset($data['rows_by_location']) && $data['rows_by_location']) {
65
$data['rows_assets']
66
+ [$data['row']['obj']->locationMain] // 'plugins', 'themes' etc.
67
[$data['row']['obj']->locationChild]
68
+ [$uniqueHandle]
69
+ ['style'] = $templateRowOutput;
70
+ } elseif (isset($data['rows_by_position']) && $data['rows_by_position']) {
71
+ $handlePosition = (isset($data['row']['obj']->position_new) && $data['row']['obj']->position_new) ? $data['row']['obj']->position_new : $data['row']['obj']->position;
72
+
73
+ $data['rows_assets']
74
+ [$handlePosition] // 'head', 'body'
75
+ [$uniqueHandle]
76
+ ['style'] = $templateRowOutput;
77
} else {
78
$data['rows_assets'][$uniqueHandle] = $templateRowOutput;
79
}
templates/meta-box-loaded-assets/view-by-position.php ADDED
@@ -0,0 +1,112 @@
1
+ <?php
2
+ // no direct access
3
+ if (! isset($data)) {
4
+ exit;
5
+ }
6
+
7
+ // Show areas by:
8
+ // "Plugins", "Themes" (parent theme and child theme), "WordPress Core"
9
+ // External locations (outside plugins and themes)
10
+ // 3rd party external locations (e.g. Google API Fonts, CND urls such as the ones for Bootstrap etc.)
11
+ $listAreaStatus = $data['plugin_settings']['assets_list_layout_areas_status'];
12
+
13
+ /*
14
+ * -------------------------
15
+ * [START] BY EACH POSITION
16
+ * -------------------------
17
+ */
18
+ ?>
19
+
20
+ <div>
21
+ <?php
22
+ if (! empty($data['all']['styles']) || ! empty($data['all']['scripts'])) {
23
+ ?>
24
+ <p><?php echo sprintf(__('The following styles &amp; scripts are loading on this page. Please select the ones that are %sNOT NEEDED%s. If you are not sure which ones to unload, it is better to enable "Test Mode" (to make the changes apply only to you), while you are going through the trial &amp; error process.', WPACU_PLUGIN_TEXT_DOMAIN), '<span style="color: #CC0000;"><strong>', '</strong></span>'); ?></p>
25
+ <p><?php echo __('"Load in on this page (make exception)" will take effect when a bulk unload rule is used. Otherwise, the asset will load anyway unless you select it for unload.', WPACU_PLUGIN_TEXT_DOMAIN); ?></p>
26
+ <?php
27
+ if ($data['plugin_settings']['hide_core_files']) {
28
+ ?>
29
+ <div class="wpacu_note"><span class="dashicons dashicons-info"></span> WordPress CSS &amp; JavaScript core files are hidden as requested in the plugin's settings. They are meant to be managed by experienced developers in special situations.</div>
30
+ <div class="wpacu-clearfix" style="margin-top: 10px;"></div>
31
+ <?php
32
+ }
33
+
34
+ if ( ( (isset($data['core_styles_loaded']) && $data['core_styles_loaded']) || (isset($data['core_scripts_loaded']) && $data['core_scripts_loaded']) ) && ! $data['plugin_settings']['hide_core_files']) {
35
+ ?>
36
+ <div class="wpacu_note wpacu_warning"><em><?php
37
+ echo sprintf(
38
+ __('Assets that are marked with %s are part of WordPress core files. Be careful if you decide to unload them! If you are not sure what to do, just leave them loaded by default and consult with a developer.', WPACU_PLUGIN_TEXT_DOMAIN),
39
+ '<span class="dashicons dashicons-warning"></span>'
40
+ );
41
+ ?>
42
+ </em></div><br />
43
+ <?php
44
+ }
45
+ ?>
46
+ </div>
47
+ <?php
48
+ $positionsText = array(
49
+ 'head' => '<span class="dashicons dashicons-editor-code"></span>&nbsp; HEAD tag (.css &amp; .js)',
50
+ 'body' => '<span class="dashicons dashicons-editor-code"></span>&nbsp; BODY tag (.css &amp; .js)'
51
+ );
52
+
53
+ $data['view_by_position'] =
54
+ $data['rows_build_array'] =
55
+ $data['rows_by_position'] = true;
56
+
57
+ $data['rows_assets'] = array();
58
+
59
+ require_once __DIR__.'/_asset-style-rows.php';
60
+ require_once __DIR__.'/_asset-script-rows.php';
61
+
62
+ if (! empty($data['rows_assets'])) {
63
+ // Sorting: head and body
64
+ $rowsAssets = array('head' => array(), 'body' => array());
65
+
66
+ foreach ($data['rows_assets'] as $positionMain => $values) {
67
+ $rowsAssets[$positionMain] = $values;
68
+ }
69
+
70
+ foreach ($rowsAssets as $positionMain => $values) {
71
+ ksort($values);
72
+ ?>
73
+ <div class="wpacu-assets-collapsible-wrap wpacu-by-position wpacu-<?php echo $positionMain; ?>">
74
+ <a class="wpacu-assets-collapsible <?php if ($listAreaStatus !== 'contracted') { ?>wpacu-assets-collapsible-active<?php } ?>" href="#wpacu-assets-collapsible-content-<?php echo $positionMain; ?>">
75
+ <?php _e($positionsText[$positionMain], WPACU_PLUGIN_TEXT_DOMAIN); ?>
76
+ </a>
77
+
78
+ <div class="wpacu-assets-collapsible-content <?php if ($listAreaStatus !== 'contracted') { ?>wpacu-open<?php } ?>">
79
+ <?php if ($positionMain === 'head') { ?>
80
+ <p class="wpacu-assets-note">The files are loaded within <code>&lt;head&gt;</code> and <code>&lt;/head&gt;</code> tags. The output is done through <code>wp_head()</code> WordPress function which should be located before the closing <code>&lt;/head&gt;</code> tag of your theme.</p>
81
+ <?php } elseif ($positionMain === 'body') { ?>
82
+ <p class="wpacu-assets-note">The files are loaded within <code>&lt;body&gt;</code> and <code>&lt;/body&gt;</code> tags. The output is done through <code>wp_footer()</code> WordPress function which should be located before the closing <code>&lt;/body&gt;</code> tag of your theme.</p>
83
+ <?php } ?>
84
+
85
+ <table class="wpacu_list_table wpacu_list_by_position wpacu_widefat wpacu_striped">
86
+ <tbody>
87
+ <?php
88
+ ksort($values);
89
+
90
+ $assetRowIndex = 1;
91
+
92
+ foreach ($values as $assetType => $assetRows) {
93
+ foreach ($assetRows as $assetRow) {
94
+ echo $assetRow . "\n";
95
+ }
96
+ }
97
+ ?>
98
+ </tbody>
99
+ </table>
100
+ </div>
101
+ </div>
102
+ <?php
103
+ }
104
+ }
105
+ }
106
+ /*
107
+ * -----------------------
108
+ * [END] BY EACH POSITION
109
+ * -----------------------
110
+ */
111
+
112
+ include '_inline_js.php';
templates/meta-box-loaded.php CHANGED
@@ -121,9 +121,11 @@ if (! is_404()) {
121
}
122
123
if($data['plugin_settings']['assets_list_layout'] === 'by-location') {
124
- $viewAssetsMode = 'by-location';
125
} else {
126
- $viewAssetsMode = 'default';
127
}
128
?>
129
<div class="<?php if ($data['plugin_settings']['input_style'] !== 'standard') { ?>wpacu-switch-enhanced<?php } else { ?>wpacu-switch-standard<?php } ?>">
121
}
122
123
if($data['plugin_settings']['assets_list_layout'] === 'by-location') {
124
+ $viewAssetsMode = 'by-location'; // Plugins, Theme(s), Core Files, External etc.
125
+ } elseif ($data['plugin_settings']['assets_list_layout'] === 'by-position') {
126
+ $viewAssetsMode = 'by-position'; // <head> or <body> (two lists)
127
} else {
128
+ $viewAssetsMode = 'default'; // All Styles & All Scripts (two lists)
129
}
130
?>
131
<div class="<?php if ($data['plugin_settings']['input_style'] !== 'standard') { ?>wpacu-switch-enhanced<?php } else { ?>wpacu-switch-standard<?php } ?>">
templates/meta-box-side-page-options.php CHANGED
@@ -58,4 +58,5 @@ if (! isset($data)) {
58
</ul>
59
<hr/>
60
<p style="margin-top: 10px;"><strong><span style="color: #82878c;" class="dashicons dashicons-lightbulb"></span></strong> Use the "Preview" button if you wish to see how the options above, as well as the load/unload rules will apply before updating anything. It works like the "Test Mode" feature for this page only.</p>
61
- </div>
58
</ul>
59
<hr/>
60
<p style="margin-top: 10px;"><strong><span style="color: #82878c;" class="dashicons dashicons-lightbulb"></span></strong> Use the "Preview" button if you wish to see how the options above, as well as the load/unload rules will apply before updating anything. It works like the "Test Mode" feature for this page only.</p>
61
+ </div>
62
+ <input type="hidden" name="wpacu_meta_box_page_options_loaded" value="1" />
wpacu.php CHANGED
@@ -2,13 +2,13 @@
2
/*
3
* Plugin Name: Asset CleanUp: Page Speed Booster
4
* Plugin URI: https://wordpress.org/plugins/wp-asset-clean-up/
5
- * Version: 1.3.2.2
6
* Description: Unload Chosen Scripts & Styles from Posts/Pages to reduce HTTP Requests, Combine/Minify CSS/JS files
7
* Author: Gabriel Livan
8
* Author URI: http://gabelivan.com/
9
*/
10
11
- define('WPACU_PLUGIN_VERSION', '1.3.2.2');
12
13
// Exit if accessed directly
14
if (! defined('ABSPATH')) {
2
/*
3
* Plugin Name: Asset CleanUp: Page Speed Booster
4
* Plugin URI: https://wordpress.org/plugins/wp-asset-clean-up/
5
+ * Version: 1.3.2.3
6
* Description: Unload Chosen Scripts & Styles from Posts/Pages to reduce HTTP Requests, Combine/Minify CSS/JS files
7
* Author: Gabriel Livan
8
* Author URI: http://gabelivan.com/
9
*/
10
11
+ define('WPACU_PLUGIN_VERSION', '1.3.2.3');
12
13
// Exit if accessed directly
14
if (! defined('ABSPATH')) {