Asset CleanUp: Page Speed Booster - Version 1.3.3.3

Version Description

  • New Feature: Option to preload CSS/JS files by ticking "Preload (if kept loaded)" checkbox for the corresponding file (More info: https://developers.google.com/web/tools/lighthouse/audits/preload)
  • Hide irrelevant Asset CleanUp MetaBoxes when custom post types from "Popup Maker" & "Popup Builder" plugins are edited
Download this release

Release Info

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

Code changes from version 1.3.3.2 to 1.3.3.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)}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(),a(".wpacu_asset_row").removeClass("wpacu-loading"),a("#wpacu-assets-reloading").remove()},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_except_settings"===a("#wpacu-reset-drop-down").val()?d=wpacu_object.reset_everything_except_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)}),a("#wpacu-import-form").submit(function(){if(!confirm(wpacu_object.import_confirm_msg))return!1;a(this).find("button").addClass("wpacu-importing").prop("disabled",!0)});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-plugin-check-all").on("click",function(b){b.preventDefault();var c=a(this).attr("data-wpacu-plugin");a('table.wpacu_list_by_location[data-wpacu-plugin="'+c+'"]').find(".input-unload-on-this-page.wpacu-not-locked").prop("checked",!0).closest("tr").addClass("wpacu_not_load")}),a(".wpacu-plugin-uncheck-all").on("click",function(b){b.preventDefault();var c=a(this).attr("data-wpacu-plugin");a('table.wpacu_list_by_location[data-wpacu-plugin="'+c+'"]').find(".input-unload-on-this-page.wpacu-not-locked").prop("checked",!1).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-add-handle-note").on("click",function(b){b.preventDefault();var c=a(this).attr("data-handle"),d=a('.wpacu-handle-notes-field[data-handle="'+c+'"]');d.is(":hidden")?a(d).show():a(d).hide()}),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_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-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_frontend").click(function(){a(this).prop("checked")?a("#wpacu-settings-frontend-exceptions").fadeIn("fast"):a("#wpacu-settings-frontend-exceptions").fadeOut("fast")}),a("#wpacu_assets_list_layout").on("click change",function(){"by-location"===a(this).val()?a("#wpacu-assets-list-by-location-selected").fadeIn("fast"):a("#wpacu-assets-list-by-location-selected").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"]');f.click(function(){a("#wpacu-updating-settings").show()});var g=a("#wpacu-update-front-settings-area .wpacu_update_btn");if(g.parents("form").submit(function(){return g.attr("disabled",!0).addClass("wpacu_submitting"),a("#wpacu-updating-front-settings").show(),!0}),a("form#wpacu-settings-form, form#wpacu_home_page_form").submit(function(){return f.attr("disabled",!0),!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_restore_position").click(function(){var b=a(this).parents(".wpacu_restore_position_row");a(this).prop("checked")?b.addClass("wpacu_selected"):b.removeClass("wpacu_selected")}),a(".wpacu_remove_global_attr").click(function(){var b=a(this).parents(".wpacu_remove_global_attr_row");a(this).prop("checked")?b.addClass("wpacu_selected"):b.removeClass("wpacu_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.post-php .edit-post-header__settings button.is-primary",function(){var c=function(){if(0===a(".edit-post-header__settings .is-saving").length){if(a("#wpacu_unload_assets_area_loaded").length>0&&a("#wpacu_unload_assets_area_loaded").val()){a("#wpacu-assets-reloading").remove();var c='<span id="wpacu-assets-reloading" class="editor-post-saved-state is-wpacu-reloading">'+wpacu_object.reload_icon+wpacu_object.reload_msg+"</span>";a(".wp-admin.post-php .edit-post-header__settings").prepend(c)}a(".wpacu_asset_row").addClass("wpacu-loading"),b(),clearInterval(d)}},d=setInterval(c,900)})});
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)}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(),a(".wpacu_asset_row").removeClass("wpacu-loading"),a("#wpacu-assets-reloading").remove()},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_except_settings"===a("#wpacu-reset-drop-down").val()?d=wpacu_object.reset_everything_except_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)}),a("#wpacu-import-form").submit(function(){if(!confirm(wpacu_object.import_confirm_msg))return!1;a(this).find("button").addClass("wpacu-importing").prop("disabled",!0)});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-plugin-check-all").on("click",function(b){b.preventDefault();var c=a(this).attr("data-wpacu-plugin");a('table.wpacu_list_by_location[data-wpacu-plugin="'+c+'"]').find(".input-unload-on-this-page.wpacu-not-locked").prop("checked",!0).closest("tr").addClass("wpacu_not_load")}),a(".wpacu-plugin-uncheck-all").on("click",function(b){b.preventDefault();var c=a(this).attr("data-wpacu-plugin");a('table.wpacu_list_by_location[data-wpacu-plugin="'+c+'"]').find(".input-unload-on-this-page.wpacu-not-locked").prop("checked",!1).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-add-handle-note").on("click",function(b){b.preventDefault();var c,d=a(this).attr("data-handle");a(this).hasClass("wpacu-for-script")?c=a('.wpacu-handle-notes-field[data-script-handle="'+d+'"]'):a(this).hasClass("wpacu-for-style")&&(c=a('.wpacu-handle-notes-field[data-style-handle="'+d+'"]')),c.is(":hidden")?c.show():c.hide()}),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_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-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_frontend").click(function(){a(this).prop("checked")?a("#wpacu-settings-frontend-exceptions").fadeIn("fast"):a("#wpacu-settings-frontend-exceptions").fadeOut("fast")}),a("#wpacu_assets_list_layout").on("click change",function(){"by-location"===a(this).val()?a("#wpacu-assets-list-by-location-selected").fadeIn("fast"):a("#wpacu-assets-list-by-location-selected").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"]');f.click(function(){a("#wpacu-updating-settings").show()});var g=a("#wpacu-update-front-settings-area .wpacu_update_btn");if(g.parents("form").submit(function(){return g.attr("disabled",!0).addClass("wpacu_submitting"),a("#wpacu-updating-front-settings").show(),!0}),a("form#wpacu-settings-form, form#wpacu_home_page_form").submit(function(){return f.attr("disabled",!0),!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_restore_position").click(function(){var b=a(this).parents(".wpacu_restore_position_row");a(this).prop("checked")?b.addClass("wpacu_selected"):b.removeClass("wpacu_selected")}),a(".wpacu_remove_global_attr").click(function(){var b=a(this).parents(".wpacu_remove_global_attr_row");a(this).prop("checked")?b.addClass("wpacu_selected"):b.removeClass("wpacu_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.post-php .edit-post-header__settings button.is-primary",function(){var c=function(){if(0===a(".edit-post-header__settings .is-saving").length){if(a("#wpacu_unload_assets_area_loaded").length>0&&a("#wpacu_unload_assets_area_loaded").val()){a("#wpacu-assets-reloading").remove();var c='<span id="wpacu-assets-reloading" class="editor-post-saved-state is-wpacu-reloading">'+wpacu_object.reload_icon+wpacu_object.reload_msg+"</span>";a(".wp-admin.post-php .edit-post-header__settings").prepend(c)}a(".wpacu_asset_row").addClass("wpacu-loading"),b(),clearInterval(d)}},d=setInterval(c,900)})});
classes/BulkUnloads.php CHANGED
@@ -91,6 +91,12 @@ class BulkUnloads
91
  public function filterPostTypesList($postTypes)
92
  {
93
  foreach ($postTypes as $postTypeKey => $postTypeValue) {
 
 
 
 
 
 
94
  if ($postTypeKey === 'product' && Misc::isPluginActive('woocommerce/woocommerce.php')) {
95
  $postTypes[$postTypeKey] = 'product &#10230; WooCommerce';
96
  }
91
  public function filterPostTypesList($postTypes)
92
  {
93
  foreach ($postTypes as $postTypeKey => $postTypeValue) {
94
+ // Exclude irrelevant custom post types
95
+ if (in_array($postTypeKey, MetaBoxes::$noMetaBoxesForPostTypes)) {
96
+ unset($postTypes[$postTypeKey]);
97
+ }
98
+
99
+ // Polish existing values
100
  if ($postTypeKey === 'product' && Misc::isPluginActive('woocommerce/woocommerce.php')) {
101
  $postTypes[$postTypeKey] = 'product &#10230; WooCommerce';
102
  }
classes/ImportExport.php CHANGED
@@ -180,7 +180,7 @@ SQL;
180
  $disableJQueryMigrate = isset($valuesArray['settings']['disable_jquery_migrate']) ? $valuesArray['settings']['disable_jquery_migrate'] : false;
181
  $disableCommentReply = isset($valuesArray['settings']['disable_comment_reply']) ? $valuesArray['settings']['disable_comment_reply'] : false;
182
 
183
- $wpacuSettings->loadUnloadCommon(array('jquery_migrate' => $disableJQueryMigrate, 'comment_reply' => $disableCommentReply));
184
 
185
  Misc::addUpdateOption(WPACU_PLUGIN_ID . '_settings', json_encode($valuesArray['settings']));
186
  $importedList[] = 'settings';
180
  $disableJQueryMigrate = isset($valuesArray['settings']['disable_jquery_migrate']) ? $valuesArray['settings']['disable_jquery_migrate'] : false;
181
  $disableCommentReply = isset($valuesArray['settings']['disable_comment_reply']) ? $valuesArray['settings']['disable_comment_reply'] : false;
182
 
183
+ $wpacuSettings->updateSiteWideRuleForCommonAssets(array('jquery_migrate' => $disableJQueryMigrate, 'comment_reply' => $disableCommentReply));
184
 
185
  Misc::addUpdateOption(WPACU_PLUGIN_ID . '_settings', json_encode($valuesArray['settings']));
186
  $importedList[] = 'settings';
classes/Main.php CHANGED
@@ -1,6 +1,10 @@
1
  <?php
2
  namespace WpAssetCleanUp;
3
 
 
 
 
 
4
  /**
5
  * Class Main
6
  * @package WpAssetCleanUp
@@ -247,7 +251,15 @@ class Main
247
  // Sometimes styles are loaded in the BODY section of the page
248
  add_action( 'wp_print_footer_scripts', array( $this, 'filterScripts' ), 1 );
249
  add_action( 'wp_print_footer_scripts', array( $this, 'filterStyles' ), 1 );
250
- }
 
 
 
 
 
 
 
 
251
 
252
  // Only trigger it within the Dashboard when an Asset CleanUp page is accessed and the transient is non-existent or expired
253
  if (is_admin()) {
@@ -495,10 +507,13 @@ class Main
495
 
496
  if (isset($jQueryRegScript->deps)) {
497
  $jQueryRegScript->deps = array_diff($jQueryRegScript->deps, array('jquery-migrate'));
498
- wp_dequeue_script($handle);
499
  }
500
 
501
- continue;
 
 
 
 
502
  }
503
 
504
  if (isset($ignoreChildParentList['scripts'], $this->wpAllScripts['registered'][$handle]->src) && is_array($ignoreChildParentList['scripts']) && array_key_exists($handle, $ignoreChildParentList['scripts'])) {
@@ -1344,6 +1359,7 @@ class Main
1344
  }
1345
  // [/wpacu_lite]
1346
 
 
1347
  $data['handle_notes'] = $this->getHandleNotes();
1348
  $data['ignore_child'] = $this->getIgnoreChildren();
1349
 
@@ -1517,6 +1533,7 @@ class Main
1517
 
1518
  $data['all_deps'] = $this->getAllDeps($data['all']);
1519
 
 
1520
  $data['handle_notes'] = $this->getHandleNotes();
1521
  $data['ignore_child'] = $this->getIgnoreChildren();
1522
 
@@ -1683,7 +1700,7 @@ class Main
1683
  $parentDir = isset($parts[1]) ? $parts[1] : '';
1684
 
1685
  // Loaded from WordPress directories (Core)
1686
- if (in_array($parentDir, array('wp-includes', 'wp-admin'))) {
1687
  $data['all']['scripts'][$key]->wp = true;
1688
  $data['core_scripts_loaded'] = true;
1689
  }
@@ -1696,7 +1713,7 @@ class Main
1696
  }
1697
  }
1698
 
1699
- if ($obj->handle === 'jquery') {
1700
  $data['all']['scripts'][$key]->wp = true;
1701
  $data['core_scripts_loaded'] = true;
1702
  }
1
  <?php
2
  namespace WpAssetCleanUp;
3
 
4
+ use WpAssetCleanUp\OptimiseAssets\OptimizeCommon;
5
+ use WpAssetCleanUp\OptimiseAssets\OptimizeCss;
6
+ use WpAssetCleanUp\OptimiseAssets\OptimizeJs;
7
+
8
  /**
9
  * Class Main
10
  * @package WpAssetCleanUp
251
  // Sometimes styles are loaded in the BODY section of the page
252
  add_action( 'wp_print_footer_scripts', array( $this, 'filterScripts' ), 1 );
253
  add_action( 'wp_print_footer_scripts', array( $this, 'filterStyles' ), 1 );
254
+
255
+ // Preloads
256
+ add_action('wp_head', function() {
257
+ echo Preloads::DEL_STYLES_PRELOADS . Preloads::DEL_SCRIPTS_PRELOADS;
258
+ }, 1);
259
+
260
+ Preloads::instance()->init();
261
+
262
+ }
263
 
264
  // Only trigger it within the Dashboard when an Asset CleanUp page is accessed and the transient is non-existent or expired
265
  if (is_admin()) {
507
 
508
  if (isset($jQueryRegScript->deps)) {
509
  $jQueryRegScript->deps = array_diff($jQueryRegScript->deps, array('jquery-migrate'));
 
510
  }
511
 
512
+ if (Misc::isPluginActive('jquery-updater/jquery-updater.php')) {
513
+ wp_dequeue_script($handle);
514
+ }
515
+
516
+ continue;
517
  }
518
 
519
  if (isset($ignoreChildParentList['scripts'], $this->wpAllScripts['registered'][$handle]->src) && is_array($ignoreChildParentList['scripts']) && array_key_exists($handle, $ignoreChildParentList['scripts'])) {
1359
  }
1360
  // [/wpacu_lite]
1361
 
1362
+ $data['preloads'] = Preloads::instance()->getPreloads();
1363
  $data['handle_notes'] = $this->getHandleNotes();
1364
  $data['ignore_child'] = $this->getIgnoreChildren();
1365
 
1533
 
1534
  $data['all_deps'] = $this->getAllDeps($data['all']);
1535
 
1536
+ $data['preloads'] = Preloads::instance()->getPreloads();
1537
  $data['handle_notes'] = $this->getHandleNotes();
1538
  $data['ignore_child'] = $this->getIgnoreChildren();
1539
 
1700
  $parentDir = isset($parts[1]) ? $parts[1] : '';
1701
 
1702
  // Loaded from WordPress directories (Core)
1703
+ if (in_array($parentDir, array('wp-includes', 'wp-admin')) || strpos($obj->src, '/plugins/jquery-updater/js/jquery-') !== false) {
1704
  $data['all']['scripts'][$key]->wp = true;
1705
  $data['core_scripts_loaded'] = true;
1706
  }
1713
  }
1714
  }
1715
 
1716
+ if (in_array($obj->handle, array('jquery', 'jquery-core', 'jquery-migrate'))) {
1717
  $data['all']['scripts'][$key]->wp = true;
1718
  $data['core_scripts_loaded'] = true;
1719
  }
classes/MetaBoxes.php CHANGED
@@ -10,13 +10,20 @@ class MetaBoxes
10
  /**
11
  * @var array
12
  */
13
- public $noMetaBoxesForPostTypes = array(
14
  // Oxygen Page Builder
15
  'ct_template',
16
 
17
  // Themify Page Builder (Layout & Layout Part)
18
  'tbuilder_layout',
19
- 'tbuilder_layout_part'
 
 
 
 
 
 
 
20
  );
21
 
22
  /**
@@ -44,7 +51,7 @@ class MetaBoxes
44
 
45
  // These are not public pages that are loading CSS/JS
46
  // e.g. URI request ending in '/ct_template/inner-content/'
47
- if (isset($obj->name) && in_array($obj->name, $this->noMetaBoxesForPostTypes)) {
48
  return;
49
  }
50
 
@@ -112,7 +119,7 @@ class MetaBoxes
112
 
113
  // These are not public pages that are loading CSS/JS
114
  // e.g. URI request ending in '/ct_template/inner-content/'
115
- if (isset($obj->name) && in_array($obj->name, $this->noMetaBoxesForPostTypes)) {
116
  return;
117
  }
118
 
10
  /**
11
  * @var array
12
  */
13
+ public static $noMetaBoxesForPostTypes = array(
14
  // Oxygen Page Builder
15
  'ct_template',
16
 
17
  // Themify Page Builder (Layout & Layout Part)
18
  'tbuilder_layout',
19
+ 'tbuilder_layout_part',
20
+
21
+ // "Popup Maker" plugin
22
+ 'popup',
23
+ 'popup_theme',
24
+
25
+ // "Popup Builder" plugin
26
+ 'popupbuilder'
27
  );
28
 
29
  /**
51
 
52
  // These are not public pages that are loading CSS/JS
53
  // e.g. URI request ending in '/ct_template/inner-content/'
54
+ if (isset($obj->name) && in_array($obj->name, self::$noMetaBoxesForPostTypes)) {
55
  return;
56
  }
57
 
119
 
120
  // These are not public pages that are loading CSS/JS
121
  // e.g. URI request ending in '/ct_template/inner-content/'
122
+ if (isset($obj->name) && in_array($obj->name, self::$noMetaBoxesForPostTypes)) {
123
  return;
124
  }
125
 
classes/Misc.php CHANGED
@@ -400,7 +400,7 @@ class Misc
400
  $wpfcOptionsJson = get_option('WpFastestCache');
401
  $wpfcOptions = @json_decode($wpfcOptionsJson, ARRAY_A);
402
 
403
- if (isset($wpfcOptions['wpFastestCacheMinifyCss']) || isset($wpfcOptions['wpFastestCacheMinifyCss'])) {
404
  $cssOptimizeEnabledIn[] = $pluginTitle;
405
 
406
  if ($returnType === 'if_enabled') { return true; }
400
  $wpfcOptionsJson = get_option('WpFastestCache');
401
  $wpfcOptions = @json_decode($wpfcOptionsJson, ARRAY_A);
402
 
403
+ if (isset($wpfcOptions['wpFastestCacheMinifyCss'])) {
404
  $cssOptimizeEnabledIn[] = $pluginTitle;
405
 
406
  if ($returnType === 'if_enabled') { return true; }
classes/OptimiseAssets/MinifyCss.php CHANGED
@@ -14,9 +14,9 @@ use WpAssetCleanUp\MetaBoxes;
14
  class MinifyCss
15
  {
16
  /**
17
- * MinifyCss constructor.
18
  */
19
- public function __construct()
20
  {
21
  add_action('wp_footer', function() {
22
  // Do not continue if "Minify CSS" is not enabled (in "Settings" or on the fly)
@@ -101,18 +101,8 @@ class MinifyCss
101
  $sourceUrl = site_url() . $listValues[0];
102
  $minUrl = site_url() . $listValues[1];
103
 
104
- $newLinkSourceTag = str_ireplace($sourceUrl, $minUrl, $linkSourceTag);
105
-
106
- if ($linkSourceTag !== $newLinkSourceTag) {
107
- // Strip ?ver=
108
- $newLinkSourceTag = str_replace('&#038;ver=', '?ver=', $newLinkSourceTag);
109
- $toStrip = Misc::extractBetween($newLinkSourceTag, '?ver=', ' ');
110
-
111
- if (in_array(substr($toStrip, -1), array('"', "'"))) {
112
- $toStrip = '?ver='. trim(trim($toStrip, '"'), "'");
113
- $newLinkSourceTag = str_replace($toStrip, '', $newLinkSourceTag);
114
- }
115
-
116
  $htmlSource = str_replace($linkSourceTag, $newLinkSourceTag, $htmlSource);
117
  break;
118
  }
@@ -123,6 +113,29 @@ class MinifyCss
123
  return $htmlSource;
124
  }
125
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
126
  /**
127
  * @param $value
128
  *
14
  class MinifyCss
15
  {
16
  /**
17
+ *
18
  */
19
+ public function init()
20
  {
21
  add_action('wp_footer', function() {
22
  // Do not continue if "Minify CSS" is not enabled (in "Settings" or on the fly)
101
  $sourceUrl = site_url() . $listValues[0];
102
  $minUrl = site_url() . $listValues[1];
103
 
104
+ if ($linkSourceTag !== str_ireplace($sourceUrl, $minUrl, $linkSourceTag)) {
105
+ $newLinkSourceTag = self::updateOriginalToMinifiedTag($linkSourceTag, $sourceUrl, $minUrl);
 
 
 
 
 
 
 
 
 
 
106
  $htmlSource = str_replace($linkSourceTag, $newLinkSourceTag, $htmlSource);
107
  break;
108
  }
113
  return $htmlSource;
114
  }
115
 
116
+ /**
117
+ * @param $linkSourceTag
118
+ * @param $sourceUrl
119
+ * @param $minUrl
120
+ *
121
+ * @return mixed
122
+ */
123
+ public static function updateOriginalToMinifiedTag($linkSourceTag, $sourceUrl, $minUrl)
124
+ {
125
+ $newLinkSourceTag = str_replace($sourceUrl, $minUrl, $linkSourceTag);
126
+
127
+ // Strip ?ver=
128
+ $newLinkSourceTag = str_replace('&#038;ver=', '?ver=', $newLinkSourceTag);
129
+ $toStrip = Misc::extractBetween($newLinkSourceTag, '?ver=', ' ');
130
+
131
+ if (in_array(substr($toStrip, -1), array('"', "'"))) {
132
+ $toStrip = '?ver='. trim(trim($toStrip, '"'), "'");
133
+ $newLinkSourceTag = str_replace($toStrip, '', $newLinkSourceTag);
134
+ }
135
+
136
+ return $newLinkSourceTag;
137
+ }
138
+
139
  /**
140
  * @param $value
141
  *
classes/OptimiseAssets/MinifyJs.php CHANGED
@@ -86,18 +86,9 @@ class MinifyJs
86
  $sourceUrl = site_url() . $listValues[0];
87
  $minUrl = site_url() . $listValues[1];
88
 
89
- $newScriptSourceTag = str_ireplace($sourceUrl, $minUrl, $scriptSourceTag);
90
-
91
- if ($scriptSourceTag !== $newScriptSourceTag) {
92
- // Strip ?ver=
93
- $toStrip = Misc::extractBetween($newScriptSourceTag, '?ver=', '>');
94
-
95
- if (in_array(substr($toStrip, -1), array('"', "'"))) {
96
- $toStrip = '?ver='. trim(trim($toStrip, '"'), "'");
97
- $newScriptSourceTag = str_replace($toStrip, '', $newScriptSourceTag);
98
- }
99
-
100
- $htmlSource = str_replace($scriptSourceTag, $newScriptSourceTag, $htmlSource);
101
  break;
102
  }
103
  }
@@ -106,6 +97,28 @@ class MinifyJs
106
  return $htmlSource;
107
  }
108
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
109
  /**
110
  * @param $value
111
  *
86
  $sourceUrl = site_url() . $listValues[0];
87
  $minUrl = site_url() . $listValues[1];
88
 
89
+ if ($scriptSourceTag !== str_ireplace($sourceUrl, $minUrl, $scriptSourceTag)) {
90
+ $newLinkSourceTag = self::updateOriginalToMinifiedTag($scriptSourceTag, $sourceUrl, $minUrl);
91
+ $htmlSource = str_replace($scriptSourceTag, $newLinkSourceTag, $htmlSource);
 
 
 
 
 
 
 
 
 
92
  break;
93
  }
94
  }
97
  return $htmlSource;
98
  }
99
 
100
+ /**
101
+ * @param $scriptSourceTag
102
+ * @param $sourceUrl
103
+ * @param $minUrl
104
+ *
105
+ * @return mixed
106
+ */
107
+ public static function updateOriginalToMinifiedTag($scriptSourceTag, $sourceUrl, $minUrl)
108
+ {
109
+ $newScriptSourceTag = str_replace($sourceUrl, $minUrl, $scriptSourceTag);
110
+
111
+ // Strip ?ver=
112
+ $toStrip = Misc::extractBetween($newScriptSourceTag, '?ver=', '>');
113
+
114
+ if (in_array(substr($toStrip, -1), array('"', "'"))) {
115
+ $toStrip = '?ver='. trim(trim($toStrip, '"'), "'");
116
+ $newScriptSourceTag = str_replace($toStrip, '', $newScriptSourceTag);
117
+ }
118
+
119
+ return $newScriptSourceTag;
120
+ }
121
+
122
  /**
123
  * @param $value
124
  *
classes/OptimiseAssets/OptimizeCss.php CHANGED
@@ -1,6 +1,7 @@
1
  <?php
2
  namespace WpAssetCleanUp\OptimiseAssets;
3
 
 
4
  use WpAssetCleanUp\FileSystem;
5
  use WpAssetCleanUp\CleanUp;
6
  use WpAssetCleanUp\Main;
@@ -60,6 +61,8 @@ class OptimizeCss
60
  $htmlSource = MinifyCss::updateHtmlSourceOriginalToMinCss($htmlSource);
61
  }
62
 
 
 
63
  if ( array_key_exists('wpacu_no_css_combine', $_GET) || // not on query string request (debugging purposes)
64
  ! $this->doCssCombine() ) {
65
  return $htmlSource;
@@ -133,15 +136,6 @@ class OptimizeCss
133
  //$htmlSource .= $attrObj->nodeValue."\n";
134
  $href = (string) $linkAttributes['href'];
135
 
136
- $localAssetPath = OptimizeCommon::getLocalAssetPath( $href, 'css' );
137
-
138
- // It will skip external stylesheets (from a different domain)
139
- if ( $localAssetPath ) {
140
- $combinedUriPaths[] = OptimizeCommon::getHrefRelPath( $href );
141
- $localAssetsPaths[ $href ] = $localAssetPath;
142
- $linkHrefs[] = $href;
143
- }
144
-
145
  $cssNotCombinable = false;
146
 
147
  // 1) Check if there is any rel="preload" connected to the rel="stylesheet"
@@ -153,6 +147,10 @@ class OptimizeCss
153
  $cssNotCombinable = true;
154
  }
155
 
 
 
 
 
156
  if ( array_key_exists( 'media',
157
  $linkAttributes ) && ! in_array( $linkAttributes['media'],
158
  array( 'all', 'screen' ) ) ) {
@@ -163,29 +161,14 @@ class OptimizeCss
163
  $cssNotCombinable = true;
164
  }
165
 
166
- if ( $cssNotCombinable ) {
167
- $hrefUriNotCombinableList[] = OptimizeCommon::getHrefRelPath( $href );
168
- }
169
- }
170
 
171
- // Any rel="preload" or media="print" found? Remove the stylesheet from the combination
172
- if ( ! empty( $hrefUriNotCombinableList ) ) {
173
- foreach ( $hrefUriNotCombinableList as $hrefUriNotCombinable ) {
174
- if ( in_array( $hrefUriNotCombinable, $combinedUriPaths ) ) {
175
- $linkHrefUriKey = array_search( $hrefUriNotCombinable, $combinedUriPaths );
176
- unset( $combinedUriPaths[ $linkHrefUriKey ] );
177
-
178
- foreach ( array_keys( $localAssetsPaths ) as $localAssetPathKey ) {
179
- if ( substr( $localAssetPathKey, - strlen( $hrefUriNotCombinable ) ) === $hrefUriNotCombinable ) {
180
- unset( $localAssetsPaths[ $localAssetPathKey ] );
181
- }
182
- }
183
-
184
- foreach ( $linkHrefs as $linkHrefKey => $linkHref ) {
185
- if ( substr( $linkHref, - strlen( $hrefUriNotCombinable ) ) === $hrefUriNotCombinable ) {
186
- unset( $linkHrefs[ $linkHrefKey ] );
187
- }
188
- }
189
  }
190
  }
191
  }
1
  <?php
2
  namespace WpAssetCleanUp\OptimiseAssets;
3
 
4
+ use WpAssetCleanUp\Preloads;
5
  use WpAssetCleanUp\FileSystem;
6
  use WpAssetCleanUp\CleanUp;
7
  use WpAssetCleanUp\Main;
61
  $htmlSource = MinifyCss::updateHtmlSourceOriginalToMinCss($htmlSource);
62
  }
63
 
64
+ $htmlSource = Preloads::instance()->doChanges($htmlSource);
65
+
66
  if ( array_key_exists('wpacu_no_css_combine', $_GET) || // not on query string request (debugging purposes)
67
  ! $this->doCssCombine() ) {
68
  return $htmlSource;
136
  //$htmlSource .= $attrObj->nodeValue."\n";
137
  $href = (string) $linkAttributes['href'];
138
 
 
 
 
 
 
 
 
 
 
139
  $cssNotCombinable = false;
140
 
141
  // 1) Check if there is any rel="preload" connected to the rel="stylesheet"
147
  $cssNotCombinable = true;
148
  }
149
 
150
+ if (isset($linkAttributes['data-wpacu-to-be-preloaded']) && $linkAttributes['data-wpacu-to-be-preloaded']) {
151
+ $cssNotCombinable = true;
152
+ }
153
+
154
  if ( array_key_exists( 'media',
155
  $linkAttributes ) && ! in_array( $linkAttributes['media'],
156
  array( 'all', 'screen' ) ) ) {
161
  $cssNotCombinable = true;
162
  }
163
 
164
+ if ( ! $cssNotCombinable ) {
165
+ $localAssetPath = OptimizeCommon::getLocalAssetPath( $href, 'css' );
 
 
166
 
167
+ // It will skip external stylesheets (from a different domain)
168
+ if ( $localAssetPath ) {
169
+ $combinedUriPaths[] = OptimizeCommon::getHrefRelPath( $href );
170
+ $localAssetsPaths[ $href ] = $localAssetPath;
171
+ $linkHrefs[] = $href;
 
 
 
 
 
 
 
 
 
 
 
 
 
172
  }
173
  }
174
  }
classes/OptimiseAssets/OptimizeJs.php CHANGED
@@ -7,6 +7,7 @@ use WpAssetCleanUp\Main;
7
  use WpAssetCleanUp\Menu;
8
  use WpAssetCleanUp\MetaBoxes;
9
  use WpAssetCleanUp\Misc;
 
10
 
11
  /**
12
  * Class CombineJs
@@ -64,6 +65,14 @@ class OptimizeJs
64
  $htmlSource = MinifyJs::updateHtmlSourceOriginalToMinJs($htmlSource);
65
  }
66
 
 
 
 
 
 
 
 
 
67
  if ( array_key_exists('wpacu_no_js_combine', $_GET) || // not on query string request (debugging purposes)
68
  ! $this->doJsCombine() ) {
69
  return $htmlSource;
@@ -141,34 +150,41 @@ class OptimizeJs
141
 
142
  $domTag->loadHTML($matchedSourceFromTag);
143
 
144
- $hasSrc = $src = false;
145
 
146
  foreach ($domTag->getElementsByTagName( 'script' ) as $tagObject) {
147
  if (! $tagObject->hasAttributes()) {
148
  continue;
149
  }
150
 
 
 
151
  foreach ( $tagObject->attributes as $attrObj ) {
152
- if ($attrObj->nodeName === 'src' && $attrObj->nodeValue) {
153
- $hasSrc = true;
154
- $src = (string) $attrObj->nodeValue;
155
-
156
- if ($this->skipCombine($src)) {
157
- $hasSrc = false;
158
- break;
159
- }
 
 
160
  }
161
 
162
  // Do not add it to the combination list if it has "async" or "defer" attributes
163
- if (in_array($attrObj->nodeName, array('async', 'defer'))) {
164
- $hasSrc = false;
165
- break;
 
 
 
166
  }
167
  }
168
 
169
  }
170
 
171
- if ( $hasSrc ) {
172
  $localAssetPath = OptimizeCommon::getLocalAssetPath( $src, 'js' );
173
 
174
  if ( $localAssetPath ) {
@@ -207,7 +223,7 @@ class OptimizeJs
207
  $groupIndex++;
208
  $reachedBody = true;
209
  }
210
- } else {
211
  $groupIndex ++;
212
  }
213
 
7
  use WpAssetCleanUp\Menu;
8
  use WpAssetCleanUp\MetaBoxes;
9
  use WpAssetCleanUp\Misc;
10
+ use WpAssetCleanUp\Preloads;
11
 
12
  /**
13
  * Class CombineJs
65
  $htmlSource = MinifyJs::updateHtmlSourceOriginalToMinJs($htmlSource);
66
  }
67
 
68
+ $preloads = Preloads::instance()->getPreloads();
69
+
70
+ if (isset($preloads['scripts']) && ! empty($preloads['scripts'])) {
71
+ $htmlSource = Preloads::appendPreloadsForScriptsToHead($htmlSource);
72
+ }
73
+
74
+ $htmlSource = str_replace(Preloads::DEL_SCRIPTS_PRELOADS, '', $htmlSource);
75
+
76
  if ( array_key_exists('wpacu_no_js_combine', $_GET) || // not on query string request (debugging purposes)
77
  ! $this->doJsCombine() ) {
78
  return $htmlSource;
150
 
151
  $domTag->loadHTML($matchedSourceFromTag);
152
 
153
+ $scriptNotCombinable = $scriptPreloaded = $src = false;
154
 
155
  foreach ($domTag->getElementsByTagName( 'script' ) as $tagObject) {
156
  if (! $tagObject->hasAttributes()) {
157
  continue;
158
  }
159
 
160
+ $scriptAttributes = array();
161
+
162
  foreach ( $tagObject->attributes as $attrObj ) {
163
+ $scriptAttributes[ $attrObj->nodeName ] = trim($attrObj->nodeValue);
164
+ }
165
+
166
+ if (isset($scriptAttributes['src']) && $scriptAttributes['src']) {
167
+ $src = (string) $scriptAttributes['src'];
168
+
169
+ $scriptNotCombinable = false;
170
+
171
+ if ($this->skipCombine($src)) {
172
+ $scriptNotCombinable = true;
173
  }
174
 
175
  // Do not add it to the combination list if it has "async" or "defer" attributes
176
+ if (in_array($scriptAttributes, array('async', 'defer'))) {
177
+ $scriptNotCombinable = true;
178
+ }
179
+
180
+ if (isset($scriptAttributes['data-wpacu-to-be-preloaded']) && $scriptAttributes['data-wpacu-to-be-preloaded']) {
181
+ $scriptNotCombinable = $scriptPreloaded = true;
182
  }
183
  }
184
 
185
  }
186
 
187
+ if ( $src && ! $scriptNotCombinable ) {
188
  $localAssetPath = OptimizeCommon::getLocalAssetPath( $src, 'js' );
189
 
190
  if ( $localAssetPath ) {
223
  $groupIndex++;
224
  $reachedBody = true;
225
  }
226
+ } elseif (! $scriptPreloaded) {
227
  $groupIndex ++;
228
  }
229
 
classes/OwnAssets.php CHANGED
@@ -8,7 +8,8 @@ namespace WpAssetCleanUp;
8
  *
9
  * @package WpAssetCleanUp
10
  */
11
- class OwnAssets {
 
12
  /**
13
  * @var bool
14
  */
@@ -17,7 +18,8 @@ class OwnAssets {
17
  /**
18
  *
19
  */
20
- public function init() {
 
21
  add_action('admin_enqueue_scripts', array($this, 'stylesAndScriptsForAdmin'));
22
  add_action('wp_enqueue_scripts', array($this, 'stylesAndScriptsForPublic'));
23
 
@@ -170,7 +172,8 @@ class OwnAssets {
170
  /**
171
  *
172
  */
173
- private function enqueueAdminStyles() {
 
174
  $styleRelPath = '/assets/style.min.css';
175
  wp_enqueue_style(WPACU_PLUGIN_ID . '-style', plugins_url($styleRelPath, WPACU_PLUGIN_FILE), array(),
176
  $this->_assetVer($styleRelPath));
@@ -307,7 +310,8 @@ HTML;
307
  /**
308
  *
309
  */
310
- private function enqueuePublicStyles() {
 
311
  $styleRelPath = '/assets/style.min.css';
312
  wp_enqueue_style(WPACU_PLUGIN_ID . '-style', plugins_url($styleRelPath, WPACU_PLUGIN_FILE), array(),
313
  $this->_assetVer($styleRelPath));
@@ -316,7 +320,8 @@ HTML;
316
  /**
317
  *
318
  */
319
- public function enqueuePublicScripts() {
 
320
  $scriptRelPath = '/assets/script.min.js';
321
  wp_enqueue_script(WPACU_PLUGIN_ID . '-script', plugins_url($scriptRelPath, WPACU_PLUGIN_FILE), array('jquery'),
322
  $this->_assetVer($scriptRelPath), true);
@@ -327,7 +332,8 @@ HTML;
327
  *
328
  * @return bool|false|int|string
329
  */
330
- private function _assetVer($relativePath) {
 
331
  $assetVer = @filemtime(dirname(WPACU_PLUGIN_FILE) . $relativePath);
332
 
333
  if (! $assetVer) {
8
  *
9
  * @package WpAssetCleanUp
10
  */
11
+ class OwnAssets
12
+ {
13
  /**
14
  * @var bool
15
  */
18
  /**
19
  *
20
  */
21
+ public function init()
22
+ {
23
  add_action('admin_enqueue_scripts', array($this, 'stylesAndScriptsForAdmin'));
24
  add_action('wp_enqueue_scripts', array($this, 'stylesAndScriptsForPublic'));
25
 
172
  /**
173
  *
174
  */
175
+ private function enqueueAdminStyles()
176
+ {
177
  $styleRelPath = '/assets/style.min.css';
178
  wp_enqueue_style(WPACU_PLUGIN_ID . '-style', plugins_url($styleRelPath, WPACU_PLUGIN_FILE), array(),
179
  $this->_assetVer($styleRelPath));
310
  /**
311
  *
312
  */
313
+ private function enqueuePublicStyles()
314
+ {
315
  $styleRelPath = '/assets/style.min.css';
316
  wp_enqueue_style(WPACU_PLUGIN_ID . '-style', plugins_url($styleRelPath, WPACU_PLUGIN_FILE), array(),
317
  $this->_assetVer($styleRelPath));
320
  /**
321
  *
322
  */
323
+ public function enqueuePublicScripts()
324
+ {
325
  $scriptRelPath = '/assets/script.min.js';
326
  wp_enqueue_script(WPACU_PLUGIN_ID . '-script', plugins_url($scriptRelPath, WPACU_PLUGIN_FILE), array('jquery'),
327
  $this->_assetVer($scriptRelPath), true);
332
  *
333
  * @return bool|false|int|string
334
  */
335
+ private function _assetVer($relativePath)
336
+ {
337
  $assetVer = @filemtime(dirname(WPACU_PLUGIN_FILE) . $relativePath);
338
 
339
  if (! $assetVer) {
classes/Preloads.php ADDED
@@ -0,0 +1,413 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace WpAssetCleanUp;
3
+
4
+ /**
5
+ * Class Preloads
6
+ * @package WpAssetCleanUp
7
+ */
8
+ class Preloads
9
+ {
10
+ /**
11
+ *
12
+ */
13
+ const DEL_STYLES_PRELOADS = '<meta name="wpacu-generator" content="ASSET CLEANUP STYLES PRELOADS">';
14
+
15
+ /**
16
+ *
17
+ */
18
+ const DEL_SCRIPTS_PRELOADS = '<meta name="wpacu-generator" content="ASSET CLEANUP SCRIPTS PRELOADS">';
19
+
20
+ /**
21
+ * @var array
22
+ */
23
+ public $preloads = array();
24
+
25
+ /**
26
+ * @var Preloads|null
27
+ */
28
+ private static $singleton;
29
+
30
+ /**
31
+ * @return null|Preloads
32
+ */
33
+ public static function instance()
34
+ {
35
+ if (self::$singleton === null) {
36
+ self::$singleton = new self();
37
+ }
38
+
39
+ return self::$singleton;
40
+ }
41
+
42
+ /**
43
+ * Preloads constructor.
44
+ */
45
+ public function __construct()
46
+ {
47
+ $this->preloads = $this->getPreloads();
48
+ }
49
+
50
+ /**
51
+ *
52
+ */
53
+ public function init()
54
+ {
55
+ if (! is_admin()) { // Trigger only in the front-end
56
+ if ($this->enablePreloads('css')) {
57
+ add_filter('style_loader_tag', array($this, 'preloadCss'), 10, 2);
58
+ }
59
+
60
+ if ($this->enablePreloads('js')) {
61
+ add_filter('script_loader_tag', array($this, 'preloadJs'), 10, 2);
62
+ }
63
+ } else { // Trigger only within the Dashboard
64
+ if (Misc::getVar('post', 'wpacu_remove_preloaded_assets_nonce')) {
65
+ add_action('admin_init', function() {
66
+ Preloads::removePreloadFromChosenAssets();
67
+ });
68
+ }
69
+
70
+ if (get_transient('wpacu_preloads_just_removed')) {
71
+ add_action('wpacu_admin_notices', array($this, 'noticePreloadsRemoved'));
72
+ delete_transient('wpacu_preloads_just_removed');
73
+ }
74
+ }
75
+ }
76
+
77
+ /**
78
+ * @param $htmlSource
79
+ *
80
+ * @return mixed
81
+ */
82
+ public function doChanges($htmlSource)
83
+ {
84
+ $preloads = $this->getPreloads();
85
+
86
+ if (isset($preloads['styles']) && ! empty($preloads['styles'])) {
87
+ $htmlSource = self::appendPreloadsForStylesToHead($htmlSource);
88
+ }
89
+
90
+ $htmlSource = str_replace(self::DEL_STYLES_PRELOADS, '', $htmlSource);
91
+
92
+ return $htmlSource;
93
+ }
94
+
95
+ /**
96
+ * @param string $for
97
+ * @return bool
98
+ */
99
+ public function enablePreloads($for)
100
+ {
101
+ if ($for === 'css' && ! (isset($this->preloads['styles']) && ! empty($this->preloads['styles']))) {
102
+ return false;
103
+ }
104
+
105
+ if ($for === 'js' && ! (isset($this->preloads['scripts']) && ! empty($this->preloads['scripts']))) {
106
+ return false;
107
+ }
108
+
109
+ // Do not use the preloads if "Optimize CSS Delivery" is enabled in WP Rocket
110
+ if ($for === 'css' && Misc::isPluginActive('wp-rocket/wp-rocket.php') && function_exists('get_rocket_option') && get_rocket_option('async_css')) {
111
+ return false;
112
+ }
113
+
114
+ // WP Fastest Cache: Combine CSS is enabled
115
+ if (Misc::isPluginActive('wp-fastest-cache/wpFastestCache.php')) {
116
+ $wpfcOptionsJson = get_option('WpFastestCache');
117
+ $wpfcOptions = @json_decode($wpfcOptionsJson, ARRAY_A);
118
+
119
+ if ($for === 'css' && isset($wpfcOptions['wpFastestCacheMinifyCss'])) {
120
+ return false;
121
+ }
122
+
123
+ if ($for === 'js' && isset($wpfcOptions['wpFastestCacheMinifyJs'])) {
124
+ return false;
125
+ }
126
+ }
127
+
128
+ // W3 Total Cache
129
+ if (Misc::isPluginActive('w3-total-cache/w3-total-cache.php')) {
130
+ $w3tcConfigMaster = Misc::getW3tcMasterConfig();
131
+
132
+ if ($for === 'css') {
133
+ $w3tcEnableCss = (int)trim(Misc::extractBetween($w3tcConfigMaster, '"minify.css.enable":', ','), '" ');
134
+
135
+ if ($w3tcEnableCss === 1) {
136
+ return false;
137
+ }
138
+ }
139
+
140
+ if ($for === 'js') {
141
+ $w3tcEnableJs = (int)trim(Misc::extractBetween($w3tcConfigMaster, '"minify.js.enable":', ','), '" ');
142
+
143
+ if ($w3tcEnableJs === 1) {
144
+ return false;
145
+ }
146
+ }
147
+ }
148
+
149
+ // LiteSpeed Cache
150
+ if (Misc::isPluginActive('litespeed-cache/litespeed-cache.php') && ($liteSpeedCacheConf = apply_filters('litespeed_cache_get_options', get_option('litespeed-cache-conf')))) {
151
+ if ($for === 'css' && isset($liteSpeedCacheConf['css_minify']) && $liteSpeedCacheConf['css_minify']) {
152
+ return false;
153
+ }
154
+
155
+ if ($for === 'js' && isset($liteSpeedCacheConf['js_minify']) && $liteSpeedCacheConf['js_minify']) {
156
+ return false;
157
+ }
158
+ }
159
+
160
+ return true;
161
+ }
162
+
163
+ /**
164
+ * @return array
165
+ */
166
+ public function getPreloads()
167
+ {
168
+ if (array_key_exists('styles', $this->preloads) && array_key_exists('scripts', $this->preloads)) {
169
+ return $this->preloads;
170
+ }
171
+
172
+ $preloads = array('styles' => array(), 'scripts' => array());
173
+
174
+ $preloadsListJson = get_option(WPACU_PLUGIN_ID . '_global_data');
175
+
176
+ if ($preloadsListJson) {
177
+ $preloadsList = @json_decode($preloadsListJson, true);
178
+
179
+ // Issues with decoding the JSON file? Return an empty list
180
+ if (Misc::jsonLastError() !== JSON_ERROR_NONE) {
181
+ return $preloads;
182
+ }
183
+
184
+ // Are new positions set for styles and scripts?
185
+ foreach (array('styles', 'scripts') as $assetKey) {
186
+ if ( isset( $preloadsList[$assetKey]['preloads'] ) && ! empty( $preloadsList[$assetKey]['preloads'] ) ) {
187
+ $preloads[$assetKey] = $preloadsList[$assetKey]['preloads'];
188
+ }
189
+ }
190
+ }
191
+
192
+ $this->preloads = $preloads;
193
+
194
+ return $this->preloads;
195
+ }
196
+
197
+ /**
198
+ * @param $htmlTag
199
+ * @param $handle
200
+ *
201
+ * @return string
202
+ */
203
+ public function preloadCss($htmlTag, $handle)
204
+ {
205
+ // Only valid for front-end pages with LINKs
206
+ if (is_admin() || strpos($htmlTag,'<link ') === false) {
207
+ return $htmlTag;
208
+ }
209
+
210
+ if (! isset($this->preloads['styles'])) {
211
+ return $htmlTag;
212
+ }
213
+
214
+ if (array_key_exists($handle, $this->preloads['styles']) && $this->preloads['styles'][$handle]) {
215
+ return str_replace('<link ', '<link data-wpacu-to-be-preloaded=\'1\' ', $htmlTag);
216
+ }
217
+
218
+ return $htmlTag;
219
+ }
220
+
221
+ /**
222
+ * @param $htmlTag
223
+ * @param $handle
224
+ * @param $src
225
+ * @return string
226
+ */
227
+ public function preloadJs($htmlTag, $handle)
228
+ {
229
+ // Only valid for front-end pages with SCRIPTs
230
+ if (is_admin() || strpos($htmlTag,'<script ') === false) {
231
+ return $htmlTag;
232
+ }
233
+
234
+ if (! isset($this->preloads['scripts'])) {
235
+ return $htmlTag;
236
+ }
237
+
238
+ if (array_key_exists($handle, $this->preloads['scripts']) && $this->preloads['scripts'][$handle]) {
239
+ return str_replace('<script ', '<script data-wpacu-to-be-preloaded=\'1\' ', $htmlTag);
240
+ }
241
+
242
+ return $htmlTag;
243
+ }
244
+
245
+ /**
246
+ * @param $htmlSource
247
+ *
248
+ * @return mixed
249
+ */
250
+ public static function appendPreloadsForStylesToHead($htmlSource)
251
+ {
252
+ $strContainsFormat = preg_quote('data-wpacu-to-be-preloaded=\'1\'', '/');
253
+ $regExpPattern = $regExpPattern = '#<link[^>]'.$strContainsFormat.'[^>]*' . 'href=(\'|")(.*)(\'|")' . '.*(>)#Usmi';
254
+
255
+ preg_match_all($regExpPattern, $htmlSource, $matchesSourcesFromLinkTags, PREG_SET_ORDER);
256
+
257
+ foreach ($matchesSourcesFromLinkTags as $linkTagArray) {
258
+ $linkHref = isset($linkTagArray[2]) ? $linkTagArray[2] : false;
259
+
260
+ if (! $linkHref) {
261
+ continue;
262
+ }
263
+
264
+ $linkPreload = '<link rel=\'preload\' as=\'style\' href=\''.$linkHref.'\' data-asset-cleanup-preload-css=\'1\'>'."\n";
265
+
266
+ $htmlSource = str_replace(self::DEL_STYLES_PRELOADS, $linkPreload . self::DEL_STYLES_PRELOADS, $htmlSource);
267
+ }
268
+
269
+ return $htmlSource;
270
+ }
271
+
272
+ /**
273
+ * @param $htmlSource
274
+ *
275
+ * @return mixed
276
+ */
277
+ public static function appendPreloadsForScriptsToHead($htmlSource)
278
+ {
279
+ $strContainsFormat = preg_quote('data-wpacu-to-be-preloaded=\'1\'', '/');
280
+ $regExpPattern = $regExpPattern = '#<script[^>]*'.$strContainsFormat.'[^>]*' . 'src=(\'|")(.*)(\'|")' . '.*(>)#Usmi';
281
+
282
+ preg_match_all($regExpPattern, $htmlSource, $matchesSourcesFromScriptTags, PREG_SET_ORDER);
283
+
284
+ if (empty($matchesSourcesFromScriptTags)) {
285
+ return $htmlSource;
286
+ }
287
+
288
+ foreach ($matchesSourcesFromScriptTags as $scriptTagArray) {
289
+ $scriptSrc = isset($scriptTagArray[2]) ? $scriptTagArray[2] : false;
290
+
291
+ if (! $scriptSrc) {
292
+ continue;
293
+ }
294
+
295
+ $linkPreload = '<link rel=\'preload\' as=\'script\' href=\''.$scriptSrc.'\' data-asset-cleanup-preload-js=\'1\'>'."\n";
296
+
297
+ $htmlSource = str_replace(self::DEL_SCRIPTS_PRELOADS, $linkPreload . self::DEL_SCRIPTS_PRELOADS, $htmlSource);
298
+ }
299
+
300
+ return $htmlSource;
301
+ }
302
+
303
+ /**
304
+ *
305
+ */
306
+ public static function updatePreloads()
307
+ {
308
+ if (! Misc::isValidRequest('post', 'wpacu_preloads')) {
309
+ return;
310
+ }
311
+
312
+ if (! isset($_POST['wpacu_preloads']['styles']) && ! isset($_POST['wpacu_preloads']['scripts'])) {
313
+ return;
314
+ }
315
+
316
+ $optionToUpdate = WPACU_PLUGIN_ID . '_global_data';
317
+ $globalKey = 'preloads';
318
+
319
+ $existingListEmpty = array('styles' => array($globalKey => array()), 'scripts' => array($globalKey => array()));
320
+ $existingListJson = get_option($optionToUpdate);
321
+
322
+ $existingListData = Main::instance()->existingList($existingListJson, $existingListEmpty);
323
+ $existingList = $existingListData['list'];
324
+
325
+ foreach ($_POST['wpacu_preloads']['styles'] as $styleHandle => $stylePreload) {
326
+ $stylePreload = trim($stylePreload);
327
+
328
+ if ($stylePreload === '' && isset($existingList['styles'][$globalKey][$styleHandle])) {
329
+ unset($existingList['styles'][$globalKey][$styleHandle]);
330
+ } elseif ($stylePreload !== '') {
331
+ $existingList['styles'][$globalKey][$styleHandle] = $stylePreload;
332
+ }
333
+ }
334
+
335
+ foreach ($_POST['wpacu_preloads']['scripts'] as $scriptHandle => $scriptPreload) {
336
+ $scriptPreload = trim($scriptPreload);
337
+
338
+ if ($scriptPreload === '' && isset($existingList['scripts'][$globalKey][$scriptHandle])) {
339
+ unset($existingList['scripts'][$globalKey][$scriptHandle]);
340
+ } elseif ($scriptPreload !== '') {
341
+ $existingList['scripts'][$globalKey][$scriptHandle] = $scriptPreload;
342
+ }
343
+ }
344
+
345
+ Misc::addUpdateOption($optionToUpdate, json_encode($existingList));
346
+ }
347
+
348
+ /**
349
+ * Triggered from "Bulk Unloads" - "Preloaded CSS/JS"
350
+ * after the selection is made and button is clicked
351
+ *
352
+ * @return void
353
+ */
354
+ public function removePreloadFromChosenAssets()
355
+ {
356
+ $stylesCheckedList = Misc::getVar('post', 'wpacu_styles_remove_preloads', array());
357
+ $scriptsCheckedList = Misc::getVar('post', 'wpacu_scripts_remove_preloads', array());
358
+
359
+ if (empty($stylesCheckedList) && empty($scriptsCheckedList)) {
360
+ return;
361
+ }
362
+
363
+ \check_admin_referer('wpacu_remove_preloaded_assets', 'wpacu_remove_preloaded_assets_nonce');
364
+
365
+ $optionToUpdate = WPACU_PLUGIN_ID . '_global_data';
366
+ $globalKey = 'preloads';
367
+
368
+ $existingListEmpty = array('styles' => array($globalKey => array()), 'scripts' => array($globalKey => array()));
369
+ $existingListJson = get_option($optionToUpdate);
370
+
371
+ $existingListData = Main::instance()->existingList($existingListJson, $existingListEmpty);
372
+ $existingList = $existingListData['list'];
373
+
374
+ if (! empty($stylesCheckedList)) {
375
+ foreach ($stylesCheckedList as $styleHandle => $action) {
376
+ if ($action === 'remove') {
377
+ unset($existingList['styles'][$globalKey][$styleHandle]);
378
+ }
379
+ }
380
+ }
381
+
382
+ if (! empty($scriptsCheckedList)) {
383
+ foreach ($scriptsCheckedList as $scriptHandle => $action) {
384
+ if ($action === 'remove') {
385
+ unset($existingList['scripts'][$globalKey][$scriptHandle]);
386
+ }
387
+ }
388
+ }
389
+
390
+ Misc::addUpdateOption($optionToUpdate, json_encode($existingList));
391
+
392
+ set_transient('wpacu_preloads_just_removed', 1, 30);
393
+
394
+ wp_safe_redirect(admin_url('admin.php?page=wpassetcleanup_bulk_unloads&wpacu_bulk_menu_tab=preloaded_assets&wpacu_time='.time()));
395
+ exit();
396
+ }
397
+
398
+ /**
399
+ *
400
+ */
401
+ public function noticePreloadsRemoved()
402
+ {
403
+ ?>
404
+ <div class="updated notice wpacu-notice is-dismissible">
405
+ <p><span class="dashicons dashicons-yes"></span>
406
+ <?php
407
+ _e('The preload option was removed for the chosen CSS/JS.', 'wp-asset-clean-up');
408
+ ?>
409
+ </p>
410
+ </div>
411
+ <?php
412
+ }
413
+ }
classes/Settings.php CHANGED
@@ -385,7 +385,7 @@ class Settings
385
  $disableJQueryMigrate = isset($_POST[WPACU_PLUGIN_ID . '_global_unloads']['disable_jquery_migrate']);
386
  $disableCommentReply = isset($_POST[WPACU_PLUGIN_ID . '_global_unloads']['disable_comment_reply']);
387
 
388
- $this->loadUnloadCommon(array(
389
  'jquery_migrate' => $disableJQueryMigrate,
390
  'comment_reply' => $disableCommentReply
391
  ));
@@ -406,7 +406,7 @@ class Settings
406
  /**
407
  * @param $unloadsList
408
  */
409
- public function loadUnloadCommon($unloadsList)
410
  {
411
  $wpacuUpdate = new Update;
412
 
385
  $disableJQueryMigrate = isset($_POST[WPACU_PLUGIN_ID . '_global_unloads']['disable_jquery_migrate']);
386
  $disableCommentReply = isset($_POST[WPACU_PLUGIN_ID . '_global_unloads']['disable_comment_reply']);
387
 
388
+ $this->updateSiteWideRuleForCommonAssets(array(
389
  'jquery_migrate' => $disableJQueryMigrate,
390
  'comment_reply' => $disableCommentReply
391
  ));
406
  /**
407
  * @param $unloadsList
408
  */
409
+ public function updateSiteWideRuleForCommonAssets($unloadsList)
410
  {
411
  $wpacuUpdate = new Update;
412
 
classes/Sorting.php CHANGED
@@ -180,7 +180,7 @@ class Sorting
180
 
181
  $src = isset($asset->src) ? $asset->src : '';
182
 
183
- $isJQueryHandle = in_array($asset->handle, array('jquery', 'jquery-core'));
184
  $startsWithWpIncludes = strpos($src,'/wp-includes/') === 0;
185
  $wpCoreOnJetpackCdn = strpos($src, '.wp.com/c/'.$wp_version.'/wp-includes/') !== false;
186
 
180
 
181
  $src = isset($asset->src) ? $asset->src : '';
182
 
183
+ $isJQueryHandle = in_array($asset->handle, array('jquery', 'jquery-core', 'jquery-migrate'));
184
  $startsWithWpIncludes = strpos($src,'/wp-includes/') === 0;
185
  $wpCoreOnJetpackCdn = strpos($src, '.wp.com/c/'.$wp_version.'/wp-includes/') !== false;
186
 
classes/Update.php CHANGED
@@ -140,6 +140,9 @@ HTML;
140
  return;
141
  }
142
 
 
 
 
143
  // Any handle notes?
144
  self::updateHandleNotes();
145
 
@@ -290,6 +293,9 @@ HTML;
290
  // Any positions changed?
291
  // For Pro Only
292
 
 
 
 
293
  // Any handle notes
294
  self::updateHandleNotes();
295
 
@@ -327,6 +333,9 @@ HTML;
327
  // Add / Remove Site-wide Unloads
328
  $this->updateEverywhereUnloads();
329
 
 
 
 
330
  // Any handle notes
331
  self::updateHandleNotes();
332
 
@@ -766,7 +775,7 @@ HTML;
766
 
767
  return $isUpdated;
768
  }
769
-
770
  /**
771
  *
772
  */
140
  return;
141
  }
142
 
143
+ // Any preloads
144
+ Preloads::updatePreloads();
145
+
146
  // Any handle notes?
147
  self::updateHandleNotes();
148
 
293
  // Any positions changed?
294
  // For Pro Only
295
 
296
+ // Any preloads
297
+ Preloads::updatePreloads();
298
+
299
  // Any handle notes
300
  self::updateHandleNotes();
301
 
333
  // Add / Remove Site-wide Unloads
334
  $this->updateEverywhereUnloads();
335
 
336
+ // Any preloads
337
+ Preloads::updatePreloads();
338
+
339
  // Any handle notes
340
  self::updateHandleNotes();
341
 
775
 
776
  return $isUpdated;
777
  }
778
+
779
  /**
780
  *
781
  */
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: pagespeed, page speed, dequeue, minify css, performance
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.2.2
7
- Stable tag: 1.3.3.2
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl.html
10
 
@@ -154,6 +154,10 @@ 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.3.2 =
158
  * Bug Fix: When pages were updated, jQuery Migrate and Comment Reply were loaded back (when they were marked for unloading)
159
  * Bug Fix: Sometimes, WP Rocket caching was not fully cleared because of an Asset CleanUp hook that interfered with it
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.2.2
7
+ Stable tag: 1.3.3.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.3.3 =
158
+ * New Feature: Option to preload CSS/JS files by ticking "Preload (if kept loaded)" checkbox for the corresponding file (More info: https://developers.google.com/web/tools/lighthouse/audits/preload)
159
+ * Hide irrelevant Asset CleanUp MetaBoxes when custom post types from "Popup Maker" & "Popup Builder" plugins are edited
160
+
161
  = 1.3.3.2 =
162
  * Bug Fix: When pages were updated, jQuery Migrate and Comment Reply were loaded back (when they were marked for unloading)
163
  * Bug Fix: Sometimes, WP Rocket caching was not fully cleared because of an Asset CleanUp hook that interfered with it
templates/_admin-page-settings-bulk-changes/_preloaded-assets.php ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * No direct access to this file
4
+ */
5
+ if (! isset($data)) {
6
+ exit;
7
+ }
8
+
9
+ if (! defined('WPACU_USE_MODAL_BOX')) {
10
+ define('WPACU_USE_MODAL_BOX', true);
11
+ }
12
+
13
+ use WpAssetCleanUp\Preloads;
14
+
15
+ $assetsPreloaded = Preloads::instance()->getPreloads();
16
+
17
+ $hasCssPreloads = isset($assetsPreloaded['styles']) && ! empty($assetsPreloaded['styles']);
18
+ $hasJsPreloads = isset($assetsPreloaded['scripts']) && ! empty($assetsPreloaded['scripts']);
19
+
20
+ $isUpdateable = $hasCssPreloads || $hasJsPreloads;
21
+
22
+ do_action('wpacu_admin_notices');
23
+ ?>
24
+ <p>This is the list of all the CSS/JS that were preloaded. &nbsp;&nbsp;<a id="wpacu-preloaded-assets-info-target" href="#wpacu-preloaded-assets-info" style="text-decoration: none;"><span class="dashicons dashicons-info"></span> How the list below gets filled?</a></p>
25
+
26
+ <form action="" method="post">
27
+ <h2>Styles (.css)</h2>
28
+ <?php if ($hasCssPreloads) { ?>
29
+ <table style="width: 96%;" class="wp-list-table widefat fixed striped">
30
+ <tr>
31
+ <td style="width: 280px;"><strong>Handle</strong></td>
32
+ <td><strong>Actions</strong></td>
33
+ </tr>
34
+
35
+ <?php
36
+ ksort($assetsPreloaded['styles']);
37
+
38
+ foreach ($assetsPreloaded['styles'] as $styleHandle => $preloadedStatus) {
39
+ ?>
40
+ <tr class="wpacu_remove_preload_row">
41
+ <td><strong style="color: green;"><?php echo $styleHandle; ?></strong></td>
42
+ <td>
43
+ <label><input type="checkbox"
44
+ class="wpacu_remove_preload"
45
+ name="wpacu_styles_remove_preloads[<?php echo $styleHandle; ?>]"
46
+ value="remove" /> Remove preload for this CSS file</label>
47
+ </td>
48
+ </tr>
49
+ <?php
50
+ }
51
+ ?>
52
+ </table>
53
+ <?php } else { ?>
54
+ <p>There are no preloaded stylesheets.</p>
55
+ <?php } ?>
56
+
57
+ <div style="margin: 20px 0; width: 96%;">
58
+ <hr/>
59
+ </div>
60
+
61
+ <h2>Scripts (.js)</h2>
62
+ <?php if ($hasJsPreloads) { ?>
63
+ <table style="width: 96%;" class="wp-list-table widefat fixed striped">
64
+ <tr>
65
+ <td style="width: 280px;"><strong>Handle</strong></td>
66
+ <td><strong>Actions</strong></td>
67
+ </tr>
68
+
69
+ <?php
70
+ ksort($assetsPreloaded['scripts']);
71
+
72
+ foreach ($assetsPreloaded['scripts'] as $scriptHandle => $preloadedStatus) {
73
+ ?>
74
+ <tr class="wpacu_remove_preload_row">
75
+ <td><strong style="color: green;"><?php echo $scriptHandle; ?></strong></td>
76
+ <td>
77
+ <label><input type="checkbox"
78
+ class="wpacu_remove_preload"
79
+ name="wpacu_scripts_remove_preloads[<?php echo $scriptHandle; ?>]"
80
+ value="remove" /> Remove preload for this JS file</label>
81
+ </td>
82
+ </tr>
83
+ <?php
84
+ }
85
+ ?>
86
+ </table>
87
+ <?php } else { ?>
88
+ <p>There are no preloaded scripts.</p>
89
+ <?php } ?>
90
+
91
+ <?php
92
+ if ($isUpdateable) {
93
+ wp_nonce_field('wpacu_remove_preloaded_assets', 'wpacu_remove_preloaded_assets_nonce');
94
+ }
95
+ ?>
96
+ <p style="margin: 20px 0 0 0;">
97
+ <input type="submit"
98
+ name="submit"
99
+ <?php if (! $isUpdateable) { ?>disabled="disabled"<?php } ?>
100
+ class="wpacu-remove-preloads-btn button button-primary"
101
+ value="Remove preload for chosen CSS/JS" />
102
+
103
+ <?php
104
+ if (! $isUpdateable) {
105
+ ?>
106
+ &nbsp;&nbsp; <small>Note: As there are no preloaded CSS/JS, the update button is not enabled.</small>
107
+ <?php
108
+ }
109
+ ?>
110
+ </p>
111
+ </form>
112
+
113
+ <!-- Start Site-Wide Modal -->
114
+ <div id="wpacu-preloaded-assets-info" class="wpacu-modal">
115
+ <div class="wpacu-modal-content">
116
+ <span class="wpacu-close">&times;</span>
117
+ <h2><?php _e('Preloading CSS/JS site-wide', 'wp-asset-clean-up'); ?></h2>
118
+ <p>This is an overview of all the assets (Stylesheets &amp; Scripts) that have were selected for preloading. Anything you see on this page is filled the moment you go to edit a page via the "CSS/JS Load Manager" (e.g. homepage or a post) and use the "Preload (if kept loaded)" option (checkbox) on any of the assets.</p>
119
+
120
+ <p>The preload for a CSS/JS can also be removed by editing a page that loads that particular file and just uncheck "Preload (if kept loaded)" option.</p>
121
+
122
+ <p>This is considered a bulk change because the preloading for the chosen file is applied site-wide (not just on the page where you activated the preloading).</p>
123
+ </div>
124
+ </div>
125
+ <!-- End Site-Wide Modal -->
templates/admin-page-settings-bulk-changes.php CHANGED
@@ -12,6 +12,7 @@ $wpacuTabCurrent = isset($_REQUEST['wpacu_bulk_menu_tab']) ? $_REQUEST['wpacu_bu
12
 
13
  $wpacuTabList = array(
14
  'bulk_unloaded' => __('Bulk Unloaded', 'wp-asset-clean-up'),
 
15
  'script_attrs' => __('Defer &amp; Async used on all pages', 'wp-asset-clean-up'),
16
  'assets_positions' => __('Updated CSS/JS positions', 'wp-asset-clean-up')
17
  );
@@ -31,6 +32,8 @@ $wpacuTabList = array(
31
  <?php
32
  if ($wpacuTabCurrent === 'bulk_unloaded') {
33
  include_once '_admin-page-settings-bulk-changes/_bulk-unloaded.php';
 
 
34
  } elseif ($wpacuTabCurrent === 'script_attrs') {
35
  include_once '_admin-page-settings-bulk-changes/_script-attrs.php';
36
  } elseif ($wpacuTabCurrent === 'assets_positions') {
12
 
13
  $wpacuTabList = array(
14
  'bulk_unloaded' => __('Bulk Unloaded', 'wp-asset-clean-up'),
15
+ 'preloaded_assets' => __('Preloaded CSS/JS', 'wp-asset-clean-up'),
16
  'script_attrs' => __('Defer &amp; Async used on all pages', 'wp-asset-clean-up'),
17
  'assets_positions' => __('Updated CSS/JS positions', 'wp-asset-clean-up')
18
  );
32
  <?php
33
  if ($wpacuTabCurrent === 'bulk_unloaded') {
34
  include_once '_admin-page-settings-bulk-changes/_bulk-unloaded.php';
35
+ } elseif ($wpacuTabCurrent === 'preloaded_assets') {
36
+ include_once '_admin-page-settings-bulk-changes/_preloaded-assets.php';
37
  } elseif ($wpacuTabCurrent === 'script_attrs') {
38
  include_once '_admin-page-settings-bulk-changes/_script-attrs.php';
39
  } elseif ($wpacuTabCurrent === 'assets_positions') {
templates/meta-box-loaded-assets/_asset-script-single-row.php CHANGED
@@ -66,8 +66,18 @@ $jqueryIconHtmlDepends = '<img src="'.WPACU_PLUGIN_URL.'/assets/icons/handles/ic
66
  }
67
 
68
  $appendAfterSrcHref = (strpos($data['row']['obj']->srcHref, '?') === false) ? '?' : '&';
 
 
 
 
69
  ?>
70
- <p><?php _e('Source:', 'wp-asset-clean-up'); ?> <a target="_blank" style="color: green;" href="<?php echo $data['row']['obj']->srcHref . $appendAfterSrcHref . 'ver='. $ver; ?>"><?php echo $relSrc; ?></a></p>
 
 
 
 
 
 
71
  <?php
72
  }
73
 
@@ -350,12 +360,12 @@ $jqueryIconHtmlDepends = '<img src="'.WPACU_PLUGIN_URL.'/assets/icons/handles/ic
350
  ?>
351
  <div class="wpacu-handle-notes">
352
  <?php if (! $handleNote) { ?>
353
- <p><small>No notes have been added about this JavaScript file (e.g. why you unloaded it or decided to keep it loaded) &#10230; <a data-handle="<?php echo $data['row']['obj']->handle; ?>" href="#" class="wpacu-add-handle-note"><span class="dashicons dashicons-welcome-write-blog"></span> <label for="wpacu_handle_note_<?php echo $data['row']['obj']->handle; ?>">Add Note</label></a></small></p>
354
  <?php } else { ?>
355
  <p><small>The following note has been added for this JavaScript file (<em>to have it removed on update, just leave the text area empty</em>):</small></p>
356
  <?php } ?>
357
- <div <?php if ($handleNote) { echo 'style="display: block;"'; } ?> data-handle="<?php echo $data['row']['obj']->handle; ?>" class="wpacu-handle-notes-field">
358
- <textarea id="wpacu_handle_note_<?php echo $data['row']['obj']->handle; ?>"
359
  rows="3"
360
  placeholder="<?php echo esc_attr('Add your note here about this JavaScript file', 'wp-asset-clean-up'); ?>"
361
  name="wpacu_handle_notes[scripts][<?php echo $data['row']['obj']->handle; ?>]"><?php echo (isset($data['handle_notes']['scripts'][$data['row']['obj']->handle]) ? $data['handle_notes']['scripts'][$data['row']['obj']->handle] : ''); ?></textarea>
66
  }
67
 
68
  $appendAfterSrcHref = (strpos($data['row']['obj']->srcHref, '?') === false) ? '?' : '&';
69
+
70
+ $isJsPreload = (isset($data['preloads']['scripts'][$data['row']['obj']->handle]) && $data['preloads']['scripts'][$data['row']['obj']->handle])
71
+ ? $data['preloads']['scripts'][$data['row']['obj']->handle]
72
+ : false;
73
  ?>
74
+ <p>
75
+ <?php _e('Source:', 'wp-asset-clean-up'); ?> <a target="_blank" style="color: green;" href="<?php echo $data['row']['obj']->srcHref . $appendAfterSrcHref . 'ver='. $ver; ?>"><?php echo $relSrc; ?></a>
76
+ &nbsp; &#10230; &nbsp;
77
+ <input type="hidden" name="wpacu_preloads[scripts][<?php echo $data['row']['obj']->handle; ?>]" value="" />
78
+ <label for="wpacu_js_preload_<?php echo $data['row']['obj']->handle; ?>">
79
+ <input <?php if ($isJsPreload) { echo 'checked="checked"'; } ?> id="wpacu_js_preload_<?php echo $data['row']['obj']->handle; ?>" type="checkbox" name="wpacu_preloads[scripts][<?php echo $data['row']['obj']->handle; ?>]" value="1" /> Preload (if kept loaded) <small>* applies site-wide</small></label> <small><a style="text-decoration: none; color: inherit;" target="_blank" href="https://developers.google.com/web/tools/lighthouse/audits/preload"><span class="dashicons dashicons-editor-help"></span></a></small>
80
+ </p>
81
  <?php
82
  }
83
 
360
  ?>
361
  <div class="wpacu-handle-notes">
362
  <?php if (! $handleNote) { ?>
363
+ <p><small>No notes have been added about this JavaScript file (e.g. why you unloaded it or decided to keep it loaded) &#10230; <a data-handle="<?php echo $data['row']['obj']->handle; ?>" href="#" class="wpacu-add-handle-note wpacu-for-script"><span class="dashicons dashicons-welcome-write-blog"></span> <label for="wpacu_handle_note_<?php echo $data['row']['obj']->handle; ?>">Add Note</label></a></small></p>
364
  <?php } else { ?>
365
  <p><small>The following note has been added for this JavaScript file (<em>to have it removed on update, just leave the text area empty</em>):</small></p>
366
  <?php } ?>
367
+ <div <?php if ($handleNote) { echo 'style="display: block;"'; } ?> data-script-handle="<?php echo $data['row']['obj']->handle; ?>" class="wpacu-handle-notes-field">
368
+ <textarea id="wpacu_handle_note_script_<?php echo $data['row']['obj']->handle; ?>"
369
  rows="3"
370
  placeholder="<?php echo esc_attr('Add your note here about this JavaScript file', 'wp-asset-clean-up'); ?>"
371
  name="wpacu_handle_notes[scripts][<?php echo $data['row']['obj']->handle; ?>]"><?php echo (isset($data['handle_notes']['scripts'][$data['row']['obj']->handle]) ? $data['handle_notes']['scripts'][$data['row']['obj']->handle] : ''); ?></textarea>
templates/meta-box-loaded-assets/_asset-style-single-row.php CHANGED
@@ -61,8 +61,18 @@ sort($childHandles);
61
  }
62
 
63
  $appendAfterSrcHref = (strpos($data['row']['obj']->srcHref, '?') === false) ? '?' : '&';
 
 
 
 
64
  ?>
65
- <p><?php _e('Source:', 'wp-asset-clean-up'); ?> <a target="_blank" style="color: green;" href="<?php echo $data['row']['obj']->srcHref . $appendAfterSrcHref . 'ver='.$ver; ?>"><?php echo $relSrc; ?></a></p>
 
 
 
 
 
 
66
  <?php
67
  }
68
 
@@ -323,12 +333,12 @@ sort($childHandles);
323
  ?>
324
  <div class="wpacu-handle-notes">
325
  <?php if (! $handleNote) { ?>
326
- <p><small>No notes have been added about this stylesheet file (e.g. why you unloaded it or decided to keep it loaded) &#10230; <a data-handle="<?php echo $data['row']['obj']->handle; ?>" href="#" class="wpacu-add-handle-note"><span class="dashicons dashicons-welcome-write-blog"></span> <label for="wpacu_handle_note_<?php echo $data['row']['obj']->handle; ?>">Add Note</label></a></small></p>
327
  <?php } else { ?>
328
  <p><small>The following note has been added for this stylesheet file (<em>to have it removed on update, just leave the text area empty</em>):</small></p>
329
  <?php } ?>
330
- <div <?php if ($handleNote) { echo 'style="display: block;"'; } ?> data-handle="<?php echo $data['row']['obj']->handle; ?>" class="wpacu-handle-notes-field">
331
- <textarea id="wpacu_handle_note_<?php echo $data['row']['obj']->handle; ?>"
332
  rows="3"
333
  placeholder="<?php echo esc_attr('Add your note here about this stylesheet file', 'wp-asset-clean-up'); ?>"
334
  name="wpacu_handle_notes[styles][<?php echo $data['row']['obj']->handle; ?>]"><?php echo $handleNote; ?></textarea>
61
  }
62
 
63
  $appendAfterSrcHref = (strpos($data['row']['obj']->srcHref, '?') === false) ? '?' : '&';
64
+
65
+ $isCssPreload = (isset($data['preloads']['styles'][$data['row']['obj']->handle]) && $data['preloads']['styles'][$data['row']['obj']->handle])
66
+ ? $data['preloads']['styles'][$data['row']['obj']->handle]
67
+ : false;
68
  ?>
69
+ <p>
70
+ <?php _e('Source:', 'wp-asset-clean-up'); ?> <a target="_blank" style="color: green;" href="<?php echo $data['row']['obj']->srcHref . $appendAfterSrcHref . 'ver='.$ver; ?>"><?php echo $relSrc; ?></a>
71
+ &nbsp; &#10230; &nbsp;
72
+ <input type="hidden" name="wpacu_preloads[styles][<?php echo $data['row']['obj']->handle; ?>]" value="" />
73
+ <label for="wpacu_css_preload_<?php echo $data['row']['obj']->handle; ?>">
74
+ <input <?php if ($isCssPreload) { echo 'checked="checked"'; } ?> id="wpacu_css_preload_<?php echo $data['row']['obj']->handle; ?>" type="checkbox" name="wpacu_preloads[styles][<?php echo $data['row']['obj']->handle; ?>]" value="1" /> Preload (if kept loaded) <small>* applies site-wide</small></label> <small><a style="text-decoration: none; color: inherit;" target="_blank" href="https://developers.google.com/web/tools/lighthouse/audits/preload"><span class="dashicons dashicons-editor-help"></span></a></small>
75
+ </p>
76
  <?php
77
  }
78
 
333
  ?>
334
  <div class="wpacu-handle-notes">
335
  <?php if (! $handleNote) { ?>
336
+ <p><small>No notes have been added about this stylesheet file (e.g. why you unloaded it or decided to keep it loaded) &#10230; <a data-handle="<?php echo $data['row']['obj']->handle; ?>" href="#" class="wpacu-add-handle-note wpacu-for-style"><span class="dashicons dashicons-welcome-write-blog"></span> <label for="wpacu_handle_note_<?php echo $data['row']['obj']->handle; ?>">Add Note</label></a></small></p>
337
  <?php } else { ?>
338
  <p><small>The following note has been added for this stylesheet file (<em>to have it removed on update, just leave the text area empty</em>):</small></p>
339
  <?php } ?>
340
+ <div <?php if ($handleNote) { echo 'style="display: block;"'; } ?> data-style-handle="<?php echo $data['row']['obj']->handle; ?>" class="wpacu-handle-notes-field">
341
+ <textarea id="wpacu_handle_note_style_<?php echo $data['row']['obj']->handle; ?>"
342
  rows="3"
343
  placeholder="<?php echo esc_attr('Add your note here about this stylesheet file', 'wp-asset-clean-up'); ?>"
344
  name="wpacu_handle_notes[styles][<?php echo $data['row']['obj']->handle; ?>]"><?php echo $handleNote; ?></textarea>
templates/meta-box-loaded.php CHANGED
@@ -44,28 +44,9 @@ if (! $metaBoxLoadedFine) {
44
  exit;
45
  }
46
 
47
- $pageTemplateInfoOutput = '';
48
-
49
  $tipsClass = new \WpAssetCleanUp\Tips();
50
  $data['tips'] = $tipsClass->list;
51
 
52
- if (isset($data['page_template'])) {
53
- ob_start();
54
-
55
- if (isset($data['all_page_templates'][$data['page_template']])) { ?>
56
- <u><?php echo $data['all_page_templates'][$data['page_template']]; ?></u>
57
- <?php } ?>
58
-
59
- (<?php echo $data['page_template'];
60
-
61
- if (isset($data['page_template_path'])) {
62
- echo '&nbsp; &#10230; &nbsp;<em>'.$data['page_template_path'].'</em>';
63
- }
64
- ?>)
65
- <?php
66
- $pageTemplateInfoOutput = ob_get_clean();
67
- }
68
-
69
  if (\WpAssetCleanUp\Misc::isHomePage()) {
70
  ?>
71
  <p><strong><span style="color: #0f6cab;" class="dashicons dashicons-admin-home"></span> <?php _e('You are currently viewing the home page.', 'wp-asset-clean-up'); ?></strong></p>
@@ -113,7 +94,6 @@ elseif ($data['bulk_unloaded_type'] === 'post_type') {
113
  <img src="<?php echo $iconShown; ?>" alt="" style="height: 40px !important; margin-top: -6px; margin-right: 5px;" align="middle" /> <strong>WooCommerce</strong>
114
  <?php } ?>
115
  <strong><?php if (! $iconShown) { ?><span style="color: #0f6cab;" class="dashicons dashicons-admin-<?php echo $dashIconPart; ?>"></span> <?php } ?> <u><?php echo $data['post_type']; ?></u> <?php if ($data['post_type'] !== 'post') { echo 'post'; } ?> type.</strong>
116
- <?php echo $pageTemplateInfoOutput; ?>
117
  </p>
118
  <?php
119
  }
44
  exit;
45
  }
46
 
 
 
47
  $tipsClass = new \WpAssetCleanUp\Tips();
48
  $data['tips'] = $tipsClass->list;
49
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  if (\WpAssetCleanUp\Misc::isHomePage()) {
51
  ?>
52
  <p><strong><span style="color: #0f6cab;" class="dashicons dashicons-admin-home"></span> <?php _e('You are currently viewing the home page.', 'wp-asset-clean-up'); ?></strong></p>
94
  <img src="<?php echo $iconShown; ?>" alt="" style="height: 40px !important; margin-top: -6px; margin-right: 5px;" align="middle" /> <strong>WooCommerce</strong>
95
  <?php } ?>
96
  <strong><?php if (! $iconShown) { ?><span style="color: #0f6cab;" class="dashicons dashicons-admin-<?php echo $dashIconPart; ?>"></span> <?php } ?> <u><?php echo $data['post_type']; ?></u> <?php if ($data['post_type'] !== 'post') { echo 'post'; } ?> type.</strong>
 
97
  </p>
98
  <?php
99
  }
wpacu-load.php CHANGED
@@ -75,7 +75,9 @@ if (\WpAssetCleanUp\Misc::triggerFrontendOptimization()) {
75
  // Combine/Minify CSS Files Setup
76
  $wpacuOptimizeCss = new \WpAssetCleanUp\OptimiseAssets\OptimizeCss();
77
  $wpacuOptimizeCss->init();
78
- new \WpAssetCleanUp\OptimiseAssets\MinifyCss();
 
 
79
 
80
  // Combine/Minify JS Files Setup
81
  $wpacuOptimizeJs = new \WpAssetCleanUp\OptimiseAssets\OptimizeJs();
@@ -95,6 +97,8 @@ if (is_admin()) {
95
 
96
  $wpacuTools = new \WpAssetCleanUp\Tools();
97
  $wpacuTools->init();
 
 
98
  } elseif (\WpAssetCleanUp\Misc::triggerFrontendOptimization()) {
99
  /*
100
  * Trigger only in the front-end view (e.g. Homepage URL, /contact/, /about/ etc.)
75
  // Combine/Minify CSS Files Setup
76
  $wpacuOptimizeCss = new \WpAssetCleanUp\OptimiseAssets\OptimizeCss();
77
  $wpacuOptimizeCss->init();
78
+
79
+ $wpacuMinifyCss = new \WpAssetCleanUp\OptimiseAssets\MinifyCss();
80
+ $wpacuMinifyCss->init();
81
 
82
  // Combine/Minify JS Files Setup
83
  $wpacuOptimizeJs = new \WpAssetCleanUp\OptimiseAssets\OptimizeJs();
97
 
98
  $wpacuTools = new \WpAssetCleanUp\Tools();
99
  $wpacuTools->init();
100
+
101
+ \WpAssetCleanUp\Preloads::instance()->init();
102
  } elseif (\WpAssetCleanUp\Misc::triggerFrontendOptimization()) {
103
  /*
104
  * Trigger only in the front-end view (e.g. Homepage URL, /contact/, /about/ etc.)
wpacu.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  * Plugin Name: Asset CleanUp: Page Speed Booster
4
  * Plugin URI: https://wordpress.org/plugins/wp-asset-clean-up/
5
- * Version: 1.3.3.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/
@@ -10,7 +10,7 @@
10
  * Domain Path: /languages
11
  */
12
 
13
- define('WPACU_PLUGIN_VERSION', '1.3.3.2');
14
 
15
  // Exit if accessed directly
16
  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.3.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/
10
  * Domain Path: /languages
11
  */
12
 
13
+ define('WPACU_PLUGIN_VERSION', '1.3.3.3');
14
 
15
  // Exit if accessed directly
16
  if (! defined('ABSPATH')) {