Asset CleanUp: Page Speed Booster - Version 1.3.6.9

Version Description

  • Improvement: Save resources and do not check anything for optimization when the feed URL (e.g. /feed/) is loaded (the plugin should be inactive for these kinds of requests)
  • Improvement: Do not trigger the plugin when WooCommerce makes AJAX calls (no point in using extra resources from Asset CleanUp)
  • Improvement: When Google Fonts are marked for removal, nullify other related settings, leading to the usage of fewer resources
  • The strings "/cart/" and "/checkout/" are added to the exclusion list where Asset CleanUp Pro is not triggered if the pattern is matched (read more: https://assetcleanup.com/docs/?p=488); These kinds of pages usually do not need optimization and if the admin decides to do some, he/she can remove the exclusion
  • Fix (writing files to cache directory): If the handle name contained forward-slash (/), make sure that the final file name gets sanitized (including slash removal) to avoid errors related to file_put_contents() such as trying to write to directories that are non-existent
  • Fix (unnecessary cached files): The plugin was caching CSS/JS files that did not need to be cached (e.g. already minified JS), leading to unnecessary extra disk space
  • "WP-Optimize" minify is not triggering anymore when /?wpacu_clean_load is used for debugging purposes (viewing all files loading from their original location)
  • Do not strip inline CSS/JS associated with the handle if the original file is empty as there's a high chance the inline code is needed
Download this release

Release Info

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

Code changes from version 1.3.6.8 to 1.3.6.9

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)}function wpacuBytesToSize(a){return 0===a?"N/A":(a/1024).toFixed(4)+" KB"}function wpacuAjaxClearCache(){jQuery.post(wpacu_object.ajax_url+"?wpacu_clear_cache",{action:wpacu_object.plugin_id+"_clear_cache",time_r:(new Date).getTime()},function(a){setTimeout(function(){wpacuClearAutoptimizeCache(),wpacu_object.is_frontend_view?jQuery.post(wpacu_object.ajax_url+"?wpacu_preload_guest",{action:wpacu_object.plugin_id+"_preload",page_url:wpacu_object.page_url,time_r:(new Date).getTime()}):jQuery.get(wpacu_object.page_url,{wpacu_preload:1,wpacu_no_frontend_show:1,time_r:(new Date).getTime()},function(){jQuery.post(wpacu_object.ajax_url+"?wpacu_preload_guest",{action:wpacu_object.plugin_id+"_preload",page_url:wpacu_object.page_url,time_r:(new Date).getTime()})})},150)})}function wpacuClearAutoptimizeCache(){jQuery("#wp-admin-bar-autoptimize-default li").length>0&&void 0!==autoptimize_ajax_object.ajaxurl&&void 0!==autoptimize_ajax_object.nonce&&jQuery.ajax({type:"GET",url:autoptimize_ajax_object.ajaxurl,data:{action:"autoptimize_delete_cache",nonce:autoptimize_ajax_object.nonce},dataType:"json",cache:!1,timeout:9e3,success:function(a){},error:function(a,b){}})}jQuery(document).ready(function(a){function b(){if(!a("#wpacu_ajax_fetch_assets_list_dashboard_view").length)return!1;var b={};if("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,d){if("error"===b.statusText){if(404===b.status)return void c(b.responseText,b.status);var e=b.responseText.replace(/(<([^>]+)>)/gi,"");try{e=String(e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}catch(a){console.log(a)}var f=wpacu_object.ajax_direct_fetch_error;f=f.replace(/{wpacu_output}/,e),f=f.replace(/{wpacu_status_code_error}/,b.status),a("#wpacu_meta_box_content").html(f)}}}).done(function(b){a("#wpacu-fetch-list-step-1-wrap").addClass("wpacu-completed"),a("#wpacu-fetch-list-step-1-status").html(a("#wpacu-list-step-completed-status").html()),a("#wpacu-fetch-list-step-2-status").html(a("#wpacu-list-step-default-status").html()),c(b)});else if("wp_remote_post"===wpacu_object.dom_get_type){var d={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,wpacu_taxonomy:wpacu_object.wpacu_taxonomy,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(){f.load(),setTimeout(function(){f.checkSourcesFor404Errors()},100)},200)})}}function c(b,c){if(b.lastIndexOf(wpacu_object.start_del_e)<0||b.lastIndexOf(wpacu_object.end_del_e)<0||b.lastIndexOf(wpacu_object.start_del_h)<0||b.lastIndexOf(wpacu_object.end_del_h)<0){var d=wpacu_object.ajax_direct_fetch_error_with_success_response;d=d.replace(/{wpacu_output}/,xhr.responseText.replace(/(<([^>]+)>)/gi,""));try{d=String(d).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}catch(a){console.log(a)}return void a("#wpacu_meta_box_content").html(d)}var e=b.substring(b.lastIndexOf(wpacu_object.start_del_e)+wpacu_object.start_del_e.length,b.lastIndexOf(wpacu_object.end_del_e)),g=b.substring(b.lastIndexOf(wpacu_object.start_del_h)+wpacu_object.start_del_h.length,b.lastIndexOf(wpacu_object.end_del_h)),h={action:wpacu_object.plugin_name+"_get_loaded_assets",wpacu_list_e:e,wpacu_list_h:g,post_id:wpacu_object.post_id,page_url:wpacu_object.page_url,tag_id:wpacu_object.tag_id,wpacu_taxonomy:wpacu_object.wpacu_taxonomy,time_r:(new Date).getTime()};a.post(wpacu_object.ajax_url,h,function(b){b&&(a("#wpacu_meta_box_content").html(b),404===c&&a("#wpacu_meta_box_content").prepend('<p><span class="dashicons dashicons-warning"></span> '+wpacu_object.server_returned_404_not_found+"</p><hr />"),a("#wpacu_home_page_form").length>0&&a("#submit").show(),setTimeout(function(){f.load(),a(".wpacu_asset_row").removeClass("wpacu-loading"),a("#wpacu-assets-reloading").remove(),f.checkSourcesFor404Errors()},200))})}a('input[name="wpacu_sub_tab_area"]').click(function(){a(this).prop("checked")&&a("#wpacu-selected-sub-tab-area").val(a(this).val())}),a("#wpacu_minify_css_enable, #wpacu_combine_loaded_css_enable, #wpacu_minify_js_enable, #wpacu_combine_loaded_js_enable, #wpacu_cdn_rewrite_enable, #wpacu_enable_test_mode").click(function(){a(this).prop("checked")?a('[data-linked-to="'+a(this).attr("id")+'"]').find(".wpacu-circle-status").addClass("wpacu-on").removeClass("wpacu-off"):a('[data-linked-to="'+a(this).attr("id")+'"]').find(".wpacu-circle-status").addClass("wpacu-off").removeClass("wpacu-on")}),a(document).on("click","#wpacu_inline_css_files_below_size_checkbox",function(){a(this).is(":checked")?a("#wpacu_inline_css_files_enable").prop("checked",!0).trigger("tick"):""===a("#wpacu_inline_css_files_list").val()&&a("#wpacu_inline_css_files_enable").prop("checked",!1).trigger("tick")}),a(document).on("click","#wpacu_inline_js_files_below_size_checkbox",function(){if(a(this).is(":checked")){if(!confirm(wpacu_object.inline_auto_js_files_confirm_msg))return!1;a("#wpacu_inline_js_files_enable").prop("checked",!0).trigger("tick")}else""===a("#wpacu_inline_js_files_list").val()&&a("#wpacu_inline_js_files_enable").prop("checked",!1).trigger("tick")}),a("#wpacu-mark-license-valid-button").click(function(){return confirm(wpacu_object.mark_license_valid_confirm)}),a("#wpacu-license-form").submit(function(){a("#edd_license_activate_btn").attr("disabled","disabled"),a("#edd_license_deactivate_btn").attr("disabled","disabled"),a(".wpacu-license-spinner").show()});var d,e;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, #wpacu-cache-assets-remove-area").addClass("wpacu-visible"):a("#wpacu-license-data-remove-area, #wpacu-cache-assets-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(),d=a(this).find("option:selected"),a("#"+d.attr("data-id")).show()}),a("#wpacu-reset-submit-btn").on("click",function(){if("reset_settings"===a("#wpacu-reset-drop-down").val()?e=wpacu_object.reset_settings_confirm_msg:"reset_everything_except_settings"===a("#wpacu-reset-drop-down").val()?e=wpacu_object.reset_everything_except_settings_confirm_msg:"reset_everything"===a("#wpacu-reset-drop-down").val()&&(e=wpacu_object.reset_everything_confirm_msg),!confirm(e))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 f={load:function(){var b,c,d,e=".input-unload-on-this-page.wpacu-not-locked";a(".input-unload-on-this-page").on("click change",function(e){if(b=a(this).attr("data-handle"),c=a(this).hasClass("wpacu_unload_rule_for_style")?"style":"script",a(this).prop("checked")){if("click"===e.type&&!f.triggerAlertWhenAnyUnloadRuleIsChosen(b,c))return!1;f.uncheckAllOtherBulkUnloadRules(a(this),!1),f.showHandleLoadExceptionArea(c,b),a(this).closest("tr").addClass("wpacu_not_load")}else a(this).closest("tr").removeClass("wpacu_not_load"),d=a(this).parents(".wpacu_asset_row"),f.hideHandleLoadExceptionArea(d,b,c)}),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(e).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(e).prop("checked",!1).closest("tr").removeClass("wpacu_not_load")}),a(".wpacu-plugin-check-load-all").on("click change",function(b){b.preventDefault();var c=a(this).attr("data-wpacu-plugin"),d=a('table.wpacu_list_by_location[data-wpacu-plugin="'+c+'"]');d.find(".wpacu_load_it_option_one.wpacu_load_exception").prop("checked",!0).closest("tr.wpacu_is_bulk_unloaded").removeClass("wpacu_not_load"),d.find(e).prop("checked",!1).trigger("change")}),a(".wpacu-plugin-uncheck-load-all").on("click change",function(b){b.preventDefault();var c=a(this).attr("data-wpacu-plugin"),d=a('table.wpacu_list_by_location[data-wpacu-plugin="'+c+'"]');d.find(".wpacu_load_it_option_one.wpacu_load_exception").prop("checked",!1).closest("tr.wpacu_is_bulk_unloaded").addClass("wpacu_not_load"),d.find(e).prop("checked",!1).trigger("change")}),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").on("click change",function(e){b=a(this).attr("data-handle"),c=a(this).attr("data-handle-for"),d=a("[data-"+c+'-handle-row="'+b+'"]');var g=a(this).parents("li");if(a(this).prop("checked")){if("click"===e.type&&!f.triggerAlertWhenAnyUnloadRuleIsChosen(b,c))return!1;a(this).hasClass("wpacu_unload_it_regex_checkbox")?(g.find("label").addClass("wpacu_unload_checked"),g.find("textarea").prop("disabled",!1).focus().removeClass("wpacu_disabled"),g.find(".wpacu_handle_unload_regex_input_wrap").removeClass("wpacu_hide")):(a(this).parent("label").addClass("wpacu_input_load_checked"),a(this).closest("tr").addClass("wpacu_not_load")),f.showHandleLoadExceptionArea(c,b),a(this).hasClass("wpacu_global_unload")?(f.uncheckAllOtherBulkUnloadRules(a(this),!0),a('.input-unload-on-this-page[data-handle-for="'+c+'"][data-handle="'+b+'"]').prop("checked",!1)):a(this).hasClass("wpacu_post_type_unload")&&(f.uncheckAllOtherBulkUnloadRules(a(this),!1),a('.input-unload-on-this-page[data-handle-for="'+c+'"][data-handle="'+b+'"]').prop("checked",!1))}else a(this).hasClass("wpacu_unload_it_regex_checkbox")?(g.find("label").removeClass("wpacu_unload_checked"),g.find("textarea").blur().addClass("wpacu_disabled"),""===g.find("textarea").val().trim()&&(g.find("textarea").prop("disabled",!0).val(""),g.find(".wpacu_handle_unload_regex_input_wrap").addClass("wpacu_hide"))):(a(this).parent("label").removeClass("wpacu_input_load_checked"),a(this).closest("tr").removeClass("wpacu_not_load")),f.hideHandleLoadExceptionArea(d,b,c);d.hasClass("wpacu_is_bulk_unloaded")||a(".wpacu_bulk_unload:not(.wpacu_unload_it_regex_checkbox)").is(":checked")||a(this).closest("tr").removeClass("wpacu_not_load")}),a(".wpacu_load_it_option_one.wpacu_load_exception").on("click change",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_load_it_option_two").on("click change",function(){var b=a(this).parents("li");a(this).prop("checked")?(b.find("label").addClass("wpacu_bold"),b.find("textarea").prop("disabled",!1).focus().removeClass("wpacu_disabled"),b.find(".wpacu_load_regex_input_wrap").removeClass("wpacu_hide")):(b.find("label").removeClass("wpacu_bold"),b.find("textarea").blur().addClass("wpacu_disabled"),""===b.find("textarea").val().trim()&&(b.find("textarea").prop("disabled",!0).val(""),b.find(".wpacu_load_regex_input_wrap").addClass("wpacu_hide")))}),a(".wpacu_script_attr_rule_input").on("click change",function(b){if(a(this).is(":checked")){if("click"===b.type){var c=a(this).parents("tr.wpacu_asset_row").attr("data-script-child-handles"),d=wpacu_object.script_is_parent_alert;if(void 0!==c&&""!==c&&(d=d.replace("{wpacu_script_child_handles}",c),!confirm(d)))return!1}a(this).parents("ul").find(".wpacu_script_attr_rule_input").not(a(this)).prop("checked",!1),a(this).hasClass("wpacu_script_attr_rule_global")&&a(this).parents("ul").find(".wpacu-script-attr-make-exception").removeClass("wpacu_hide")}a(this).parents("ul").find(".wpacu_script_attr_rule_global").is(":checked")||a(this).parents("ul").find(".wpacu-script-attr-make-exception").addClass("wpacu_hide")}),a(".wpacu-add-handle-note").on("click",function(b){b.preventDefault();var c,d,e=a(this).attr("data-handle");a(this).hasClass("wpacu-for-script")?c=a('.wpacu-handle-notes-field[data-script-handle="'+e+'"]'):a(this).hasClass("wpacu-for-style")&&(c=a('.wpacu-handle-notes-field[data-style-handle="'+e+'"]')),c.length<1||(d=c.find(":input"),c.is(":hidden")?(c.show(),d.prop("disabled",!1)):(c.hide(),""===d.val().trim()&&"true"===d.attr("data-wpacu-is-empty-on-page-load")&&d.prop("disabled",!0).val("")))}),a(".wpacu-external-file-size").on("click",function(b){b.preventDefault();var c,d=a(this),e=d.attr("data-src");d.hide(),c=d.next(),c.show(),e.includes("/?")?a.get(e,{},function(a,b,d){if("success"!==b)return"N/A";c.html(wpacuBytesToSize(a.length))}):a.post(wpacu_object.ajax_url,{action:wpacu_object.plugin_id+"_get_external_file_size",wpacu_remote_file:e},function(a){c.html(a)})}),a(".wpacu_handle_row_expand_contract").on("click",function(b){b.preventDefault();var c=a(this).attr("data-wpacu-handle"),d=a(this).attr("data-wpacu-handle-for");a(this).find("span").hasClass("dashicons-minus")?(a(this).parents("td").attr("data-wpacu-row-status","contracted").find(".wpacu_handle_row_expanded_area").addClass("wpacu_hide"),a(this).find("span").removeClass("dashicons-minus").addClass("dashicons-plus"),a("#wpacu_"+d+"_"+c+"_row_contracted_area").val("1")):a(this).find("span").hasClass("dashicons-plus")&&(a(this).parents("td").attr("data-wpacu-row-status","expanded").find(".wpacu_handle_row_expanded_area").removeClass("wpacu_hide"),a(this).find("span").removeClass("dashicons-plus").addClass("dashicons-minus"),a("#wpacu_"+d+"_"+c+"_row_contracted_area").val(""))});a('[data-is-hardcoded-asset="true"]').length>0&&(a.each(a('[data-is-hardcoded-asset="true"]'),function(b,c){f.updateHardcodedDataHiddenFieldStatus(a(this))}),a('[data-is-hardcoded-asset="true"]').on("click",".wpacu_unload_rule_input",function(){f.updateHardcodedDataHiddenFieldStatus(a(this).parents("[data-is-hardcoded-asset]"))}))},updateHardcodedDataHiddenFieldStatus:function(b){var c=!1;b.is("[data-style-handle-row]")?c=b.attr("data-style-handle-row"):b.is("[data-script-handle-row]")&&(c=b.attr("data-script-handle-row")),c&&(b.find(".wpacu_unload_rule_input:checked").length>0||b.hasClass("wpacu_not_load")?a("#"+c+"_hardcoded_data").prop("disabled",!1):a("#"+c+"_hardcoded_data").prop("disabled",!0))},triggerAlertWhenAnyUnloadRuleIsChosen:function(b,c){if("dashicons"===b&&"style"===c&&a('input[name="wpacu_ignore_child[styles][nf-display]').length>0&&!confirm(wpacu_object.dashicons_unload_alert_ninja_forms))return!1;if("script"===c){if(("jquery"===b||"jquery-core"===b)&&a("#script_jquery_ignore_children").length>0&&!confirm(wpacu_object.jquery_unload_alert))return!1;if("js-cookie"===b&&!confirm(wpacu_object.woo_js_cookie_unload_alert))return!1;if("wc-cart-fragments"===b&&!confirm(wpacu_object.woo_wc_cart_fragments_unload_alert))return!1;if(("backbone"===b||"underscore"===b)&&!confirm(wpacu_object.sensitive_library_unload_alert))return!1}return!0},pluginLoadManager:function(){a(".wpacu_plugin_load_it").on("click",function(){var b=a(this).attr("data-wpacu-plugin-path");a(this).prop("checked")&&(f.hidePluginLoadExceptionArea(b),a('.wpacu_plugin_unload_regex_input_wrap[data-wpacu-plugin-path="'+b+'"]').addClass("wpacu_hide"),a('.wpacu_plugin_unload_site_wide[data-wpacu-plugin-path="'+b+'"]').parent("label").removeClass("wpacu_plugin_unload_rule_input_checked"),a('.wpacu_plugin_unload_regex_radio[data-wpacu-plugin-path="'+b+'"]').parent("label").removeClass("wpacu_plugin_unload_rule_input_checked"))}),a(".wpacu_plugin_unload_site_wide").on("click",function(){var b=a(this).attr("data-wpacu-plugin-path");a(this).prop("checked")?(a(this).parent("label").addClass("wpacu_plugin_unload_rule_input_checked"),a('.wpacu_plugin_unload_regex_radio[data-wpacu-plugin-path="'+b+'"]').parent("label").removeClass("wpacu_plugin_unload_rule_input_checked"),a('.wpacu_plugin_unload_regex_input_wrap[data-wpacu-plugin-path="'+b+'"]').addClass("wpacu_hide"),f.showPluginLoadExceptionArea(b)):(a(this).parent("label").removeClass("wpacu_plugin_unload_rule_input_checked"),a('.wrap_plugin_load_exception_options[data-wpacu-plugin-path="'+b+'"]').addClass("wpacu_hide").find('input[type="checkbox"]').prop("disabled",!0))}),a(".wpacu_plugin_unload_regex_radio").on("click",function(){var b=a(this).attr("data-wpacu-plugin-path");a(this).prop("checked")?(a(this).parent("label").addClass("wpacu_plugin_unload_rule_input_checked"),a('.wpacu_plugin_unload_regex_input_wrap[data-wpacu-plugin-path="'+b+'"]').removeClass("wpacu_hide"),f.showPluginLoadExceptionArea(b),a('.wpacu_plugin_unload_site_wide[data-wpacu-plugin-path="'+b+'"]').prop("checked",!1).parent("label").removeClass("wpacu_plugin_unload_rule_input_checked")):(a('.wpacu_plugin_unload_regex_input_wrap[data-wpacu-plugin-path="'+b+'"]').addClass("wpacu_hide"),a(this).parent("label").removeClass("wpacu_plugin_unload_rule_input_checked"),a('.wrap_plugin_load_exception_options[data-wpacu-plugin-path="'+b+'"]').addClass("wpacu_hide"))}),a(".wpacu_plugin_load_exception_regex").on("click",function(){var b=a(this).attr("data-wpacu-plugin-path");a(this).prop("checked")?a('.wpacu_load_regex_input_wrap[data-wpacu-plugin-path="'+b+'"]').removeClass("wpacu_hide"):a('.wpacu_load_regex_input_wrap[data-wpacu-plugin-path="'+b+'"]').addClass("wpacu_hide")})},showPluginLoadExceptionArea:function(b){a('.wrap_plugin_load_exception_options[data-wpacu-plugin-path="'+b+'"]').removeClass("wpacu_hide").find('input[type="checkbox"]').prop("disabled",!1)},hidePluginLoadExceptionArea:function(b){a('.wrap_plugin_load_exception_options[data-wpacu-plugin-path="'+b+'"]').addClass("wpacu_hide").find('input[type="checkbox"]').prop("disabled",!0)},showHandleLoadExceptionArea:function(b,c){var d=a("div.wpacu_exception_options_area_wrap[data-"+b+'-handle="'+c+'"]');d.parent("div").removeClass("wpacu_hide"),d.find('input[type="checkbox"]').prop("disabled",!1)},hideHandleLoadExceptionArea:function(b,c,d){if(!b.hasClass("wpacu_is_bulk_unloaded")&&!b.find(".wpacu_bulk_unload").is(":checked")){var e=a("div.wpacu_exception_options_area_wrap[data-"+d+'-handle="'+c+'"]');e.parent("div").addClass("wpacu_hide"),e.find('input[type="checkbox"]').prop("disabled",!0)}},uncheckAllOtherBulkUnloadRules:function(a,b){var c=".wpacu_bulk_unload";!1===b&&(c=".wpacu_bulk_unload:not(.wpacu_unload_it_regex_checkbox)"),a.closest("tr").find(c).not(a).prop("checked",!1).parent("label").removeClass("wpacu_input_load_checked").removeClass("wpacu_unload_checked")},checkSourcesFor404Errors:function(){var b=a("[data-wpacu-external-source]");if(!(b.length<1)){var c=b.length,d="";b.each(function(b){var e=a(this),f=e.attr("data-wpacu-external-source");d+=f+"-at-wpacu-at-",b===c-1&&jQuery.post(wpacu_object.ajax_url+"?wpacu_check_external_url",{action:wpacu_object.plugin_id+"_check_external_urls_for_status_code",wpacu_check_urls:d},function(b){var c=jQuery.parseJSON(b);a.each(c,function(b,c){a('[data-wpacu-external-source="'+c+'"]').css({color:"#cc0000"}).parent("div").find("[data-wpacu-external-source-status]").html('<small>* <em style="font-weight: 600;">'+wpacu_object.source_load_error_msg+"</em></small>")})})})}}};a(window).on("load",function(){f.checkSourcesFor404Errors()}),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").show():a("#wpacu-settings-assets-retrieval-mode").hide()}),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").show():a("#wpacu-settings-frontend-exceptions").hide()}),a(".google_fonts_combine_type").change(function(){a(".wpacu_google_fonts_combine_type_area").hide(),"async"===a(this).val()?a("#wpacu_google_fonts_combine_type_async_info_area").fadeIn():"async_preload"===a(this).val()?a("#wpacu_google_fonts_combine_type_async_preload_info_area").fadeIn():a("#wpacu_google_fonts_combine_type_rb_info_area").fadeIn()}),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("[data-target-opacity]").on("click change tick",function(){a(this).prop("checked")?a("#"+a(this).attr("data-target-opacity")).css({opacity:1}):a("#"+a(this).attr("data-target-opacity")).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 g=a('#wpacu-update-button-area input[type="submit"]');g.parents("form").submit(function(){g.attr("disabled",!0),a("#wpacu-updating-settings").show()});var h=a("#wpacu-update-front-settings-area .wpacu_update_btn");if(h.parents("form").submit(function(){return h.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 g.attr("disabled",!0),!0}),a(".wpacu_bulk_rule_checkbox, .wpacu_remove_preload").click(function(){var b=a(this).parents(".wpacu_bulk_change_row");a(this).prop("checked")?b.addClass("wpacu_selected"):b.removeClass("wpacu_selected")}),a(".wpacu_remove_regex").click(function(){var b=a(this).parents(".wpacu_regex_rule_row");a(this).prop("checked")?b.addClass("wpacu_enabled"):b.removeClass("wpacu_enabled")}),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(){f.load()},200),a("#wpacu-plugins-load-manager-wrap").length>0&&setTimeout(function(){f.pluginLoadManager()},200),"undefined"==typeof wpacu_object||a("#wpacu_meta_box_content").length<1)return!1;("default"===wpacu_object.list_show_status||""===wpacu_object.list_show_status||wpacu_object.override_assets_list_load)&&b(),"fetch_on_click"===wpacu_object.list_show_status&&a("#wpacu_ajax_fetch_on_click_btn").click(function(c){c.preventDefault(),a(this).hide(),a("#wpacu_fetching_assets_list_wrap").show(),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(),wpacuAjaxClearCache(),clearInterval(d)}},d=setInterval(c,900)})}),""!==wpacu_object.clear_cache_on_page_load&&wpacuAjaxClearCache(),""!==wpacu_object.clear_other_caches&&setTimeout(function(){wpacuClearAutoptimizeCache()},150),jQuery(document).ready(function(a){try{var b;a('input[type="hidden"][name="_wp_http_referer"]').length>0&&(b=a('input[type="hidden"][name="_wp_http_referer"]').val(),b.includes("term.php?taxonomy=")&&b.includes("message=")&&wpacuAjaxClearCache(),b.includes("post.php?post=")&&b.includes("message=")&&wpacuAjaxClearCache())}catch(a){console.log(a)}});
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)}function wpacuBytesToSize(a){return 0===a?"N/A":(a/1024).toFixed(4)+" KB"}function wpacuAjaxClearCache(){jQuery.post(wpacu_object.ajax_url+"?wpacu_clear_cache",{action:wpacu_object.plugin_id+"_clear_cache",time_r:(new Date).getTime()},function(a){setTimeout(function(){wpacuClearAutoptimizeCache(),wpacu_object.is_frontend_view?jQuery.post(wpacu_object.ajax_url+"?wpacu_preload_guest",{action:wpacu_object.plugin_id+"_preload",page_url:wpacu_object.page_url,time_r:(new Date).getTime()}):jQuery.get(wpacu_object.page_url,{wpacu_preload:1,wpacu_no_frontend_show:1,time_r:(new Date).getTime()},function(){jQuery.post(wpacu_object.ajax_url+"?wpacu_preload_guest",{action:wpacu_object.plugin_id+"_preload",page_url:wpacu_object.page_url,time_r:(new Date).getTime()})})},150)})}function wpacuClearAutoptimizeCache(){jQuery("#wp-admin-bar-autoptimize-default li").length>0&&void 0!==autoptimize_ajax_object.ajaxurl&&void 0!==autoptimize_ajax_object.nonce&&jQuery.ajax({type:"GET",url:autoptimize_ajax_object.ajaxurl,data:{action:"autoptimize_delete_cache",nonce:autoptimize_ajax_object.nonce},dataType:"json",cache:!1,timeout:9e3,success:function(a){},error:function(a,b){}})}jQuery(document).ready(function(a){function b(){if(!a("#wpacu_ajax_fetch_assets_list_dashboard_view").length)return!1;var b={};if("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,d){if("error"===b.statusText){if(404===b.status)return void c(b.responseText,b.status);var e=b.responseText.replace(/(<([^>]+)>)/gi,"");try{e=String(e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}catch(a){console.log(a)}var f=wpacu_object.ajax_direct_fetch_error;f=f.replace(/{wpacu_output}/,e),f=f.replace(/{wpacu_status_code_error}/,b.status),a("#wpacu_meta_box_content").html(f)}}}).done(function(b){a("#wpacu-fetch-list-step-1-wrap").addClass("wpacu-completed"),a("#wpacu-fetch-list-step-1-status").html(a("#wpacu-list-step-completed-status").html()),a("#wpacu-fetch-list-step-2-status").html(a("#wpacu-list-step-default-status").html()),c(b)});else if("wp_remote_post"===wpacu_object.dom_get_type){var d={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,wpacu_taxonomy:wpacu_object.wpacu_taxonomy,time_r:(new Date).getTime(),force_manage_dash:wpacu_object.force_manage_dash};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(){f.load(),setTimeout(function(){f.checkSourcesFor404Errors()},100)},200)})}}function c(b,c){if(b.lastIndexOf(wpacu_object.start_del_e)<0||b.lastIndexOf(wpacu_object.end_del_e)<0||b.lastIndexOf(wpacu_object.start_del_h)<0||b.lastIndexOf(wpacu_object.end_del_h)<0){var d=wpacu_object.ajax_direct_fetch_error_with_success_response;d=d.replace(/{wpacu_output}/,xhr.responseText.replace(/(<([^>]+)>)/gi,""));try{d=String(d).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}catch(a){console.log(a)}return void a("#wpacu_meta_box_content").html(d)}var e=b.substring(b.lastIndexOf(wpacu_object.start_del_e)+wpacu_object.start_del_e.length,b.lastIndexOf(wpacu_object.end_del_e)),g=b.substring(b.lastIndexOf(wpacu_object.start_del_h)+wpacu_object.start_del_h.length,b.lastIndexOf(wpacu_object.end_del_h)),h={action:wpacu_object.plugin_name+"_get_loaded_assets",wpacu_list_e:e,wpacu_list_h:g,post_id:wpacu_object.post_id,page_url:wpacu_object.page_url,tag_id:wpacu_object.tag_id,wpacu_taxonomy:wpacu_object.wpacu_taxonomy,force_manage_dash:wpacu_object.force_manage_dash,time_r:(new Date).getTime()};a.post(wpacu_object.ajax_url,h,function(b){b&&(a("#wpacu_meta_box_content").html(b),404===c&&a("#wpacu_meta_box_content").prepend('<p><span class="dashicons dashicons-warning"></span> '+wpacu_object.server_returned_404_not_found+"</p><hr />"),a("#wpacu_home_page_form").length>0&&a("#submit").show(),setTimeout(function(){f.load(),a(".wpacu_asset_row").removeClass("wpacu-loading"),a("#wpacu-assets-reloading").remove(),f.checkSourcesFor404Errors()},200))})}a('input[name="wpacu_sub_tab_area"]').click(function(){a(this).prop("checked")&&a("#wpacu-selected-sub-tab-area").val(a(this).val())}),a("#wpacu_minify_css_enable, #wpacu_combine_loaded_css_enable, #wpacu_minify_js_enable, #wpacu_combine_loaded_js_enable, #wpacu_cdn_rewrite_enable, #wpacu_enable_test_mode").click(function(){a(this).prop("checked")?a('[data-linked-to="'+a(this).attr("id")+'"]').find(".wpacu-circle-status").addClass("wpacu-on").removeClass("wpacu-off"):a('[data-linked-to="'+a(this).attr("id")+'"]').find(".wpacu-circle-status").addClass("wpacu-off").removeClass("wpacu-on")}),a(document).on("click","#wpacu_inline_css_files_below_size_checkbox",function(){a(this).is(":checked")?a("#wpacu_inline_css_files_enable").prop("checked",!0).trigger("tick"):""===a("#wpacu_inline_css_files_list").val()&&a("#wpacu_inline_css_files_enable").prop("checked",!1).trigger("tick")}),a(document).on("click","#wpacu_inline_js_files_below_size_checkbox",function(){if(a(this).is(":checked")){if(!confirm(wpacu_object.inline_auto_js_files_confirm_msg))return!1;a("#wpacu_inline_js_files_enable").prop("checked",!0).trigger("tick")}else""===a("#wpacu_inline_js_files_list").val()&&a("#wpacu_inline_js_files_enable").prop("checked",!1).trigger("tick")}),a("#wpacu-mark-license-valid-button").click(function(){return confirm(wpacu_object.mark_license_valid_confirm)}),a("#wpacu-license-form").submit(function(){a("#edd_license_activate_btn").attr("disabled","disabled"),a("#edd_license_deactivate_btn").attr("disabled","disabled"),a(".wpacu-license-spinner").show()});var d,e;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, #wpacu-cache-assets-remove-area").addClass("wpacu-visible"):a("#wpacu-license-data-remove-area, #wpacu-cache-assets-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(),d=a(this).find("option:selected"),a("#"+d.attr("data-id")).show()}),a("#wpacu-reset-submit-btn").on("click",function(){if("reset_settings"===a("#wpacu-reset-drop-down").val()?e=wpacu_object.reset_settings_confirm_msg:"reset_everything_except_settings"===a("#wpacu-reset-drop-down").val()?e=wpacu_object.reset_everything_except_settings_confirm_msg:"reset_everything"===a("#wpacu-reset-drop-down").val()&&(e=wpacu_object.reset_everything_confirm_msg),!confirm(e))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 f={load:function(){var b,c,d,e=".input-unload-on-this-page.wpacu-not-locked";a(".input-unload-on-this-page").on("click change",function(e){if(b=a(this).attr("data-handle"),c=a(this).hasClass("wpacu_unload_rule_for_style")?"style":"script",a(this).prop("checked")){if("click"===e.type&&!f.triggerAlertWhenAnyUnloadRuleIsChosen(b,c))return!1;f.uncheckAllOtherBulkUnloadRules(a(this),!1),f.showHandleLoadExceptionArea(c,b),a(this).closest("tr").addClass("wpacu_not_load")}else a(this).closest("tr").removeClass("wpacu_not_load"),d=a(this).parents(".wpacu_asset_row"),f.hideHandleLoadExceptionArea(d,b,c)}),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(e).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(e).prop("checked",!1).closest("tr").removeClass("wpacu_not_load")}),a(".wpacu-plugin-check-load-all").on("click change",function(b){b.preventDefault();var c=a(this).attr("data-wpacu-plugin"),d=a('table.wpacu_list_by_location[data-wpacu-plugin="'+c+'"]');d.find(".wpacu_load_it_option_one.wpacu_load_exception").prop("checked",!0).closest("tr.wpacu_is_bulk_unloaded").removeClass("wpacu_not_load"),d.find(e).prop("checked",!1).trigger("change")}),a(".wpacu-plugin-uncheck-load-all").on("click change",function(b){b.preventDefault();var c=a(this).attr("data-wpacu-plugin"),d=a('table.wpacu_list_by_location[data-wpacu-plugin="'+c+'"]');d.find(".wpacu_load_it_option_one.wpacu_load_exception").prop("checked",!1).closest("tr.wpacu_is_bulk_unloaded").addClass("wpacu_not_load"),d.find(e).prop("checked",!1).trigger("change")}),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").on("click change",function(e){b=a(this).attr("data-handle"),c=a(this).attr("data-handle-for"),d=a("[data-"+c+'-handle-row="'+b+'"]');var g=a(this).parents("li");if(a(this).prop("checked")){if("click"===e.type&&!f.triggerAlertWhenAnyUnloadRuleIsChosen(b,c))return!1;a(this).hasClass("wpacu_unload_it_regex_checkbox")?(g.find("label").addClass("wpacu_unload_checked"),g.find("textarea").prop("disabled",!1).focus().removeClass("wpacu_disabled"),g.find(".wpacu_handle_unload_regex_input_wrap").removeClass("wpacu_hide")):(a(this).parent("label").addClass("wpacu_input_load_checked"),a(this).closest("tr").addClass("wpacu_not_load")),f.showHandleLoadExceptionArea(c,b),a(this).hasClass("wpacu_global_unload")?(f.uncheckAllOtherBulkUnloadRules(a(this),!0),a('.input-unload-on-this-page[data-handle-for="'+c+'"][data-handle="'+b+'"]').prop("checked",!1)):a(this).hasClass("wpacu_post_type_unload")&&(f.uncheckAllOtherBulkUnloadRules(a(this),!1),a('.input-unload-on-this-page[data-handle-for="'+c+'"][data-handle="'+b+'"]').prop("checked",!1))}else a(this).hasClass("wpacu_unload_it_regex_checkbox")?(g.find("label").removeClass("wpacu_unload_checked"),g.find("textarea").blur().addClass("wpacu_disabled"),""===g.find("textarea").val().trim()&&(g.find("textarea").prop("disabled",!0).val(""),g.find(".wpacu_handle_unload_regex_input_wrap").addClass("wpacu_hide"))):(a(this).parent("label").removeClass("wpacu_input_load_checked"),a(this).closest("tr").removeClass("wpacu_not_load")),f.hideHandleLoadExceptionArea(d,b,c);d.hasClass("wpacu_is_bulk_unloaded")||a(".wpacu_bulk_unload:not(.wpacu_unload_it_regex_checkbox)").is(":checked")||a(this).closest("tr").removeClass("wpacu_not_load")}),a(".wpacu_load_it_option_one.wpacu_load_exception").on("click change",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_load_it_option_two").on("click change",function(){var b=a(this).parents("li");a(this).prop("checked")?(b.find("label").addClass("wpacu_bold"),b.find("textarea").prop("disabled",!1).focus().removeClass("wpacu_disabled"),b.find(".wpacu_load_regex_input_wrap").removeClass("wpacu_hide")):(b.find("label").removeClass("wpacu_bold"),b.find("textarea").blur().addClass("wpacu_disabled"),""===b.find("textarea").val().trim()&&(b.find("textarea").prop("disabled",!0).val(""),b.find(".wpacu_load_regex_input_wrap").addClass("wpacu_hide")))}),a(".wpacu_script_attr_rule_input").on("click change",function(b){if(a(this).is(":checked")){if("click"===b.type){var c=a(this).parents("tr.wpacu_asset_row").attr("data-script-child-handles"),d=wpacu_object.script_is_parent_alert;if(void 0!==c&&""!==c&&(d=d.replace("{wpacu_script_child_handles}",c),!confirm(d)))return!1}a(this).parents("ul").find(".wpacu_script_attr_rule_input").not(a(this)).prop("checked",!1),a(this).hasClass("wpacu_script_attr_rule_global")&&a(this).parents("ul").find(".wpacu-script-attr-make-exception").removeClass("wpacu_hide")}a(this).parents("ul").find(".wpacu_script_attr_rule_global").is(":checked")||a(this).parents("ul").find(".wpacu-script-attr-make-exception").addClass("wpacu_hide")}),a(".wpacu-add-handle-note").on("click",function(b){b.preventDefault();var c,d,e=a(this).attr("data-handle");a(this).hasClass("wpacu-for-script")?c=a('.wpacu-handle-notes-field[data-script-handle="'+e+'"]'):a(this).hasClass("wpacu-for-style")&&(c=a('.wpacu-handle-notes-field[data-style-handle="'+e+'"]')),c.length<1||(d=c.find(":input"),c.is(":hidden")?(c.show(),d.prop("disabled",!1)):(c.hide(),""===d.val().trim()&&"true"===d.attr("data-wpacu-is-empty-on-page-load")&&d.prop("disabled",!0).val("")))}),a(".wpacu-external-file-size").on("click",function(b){b.preventDefault();var c,d=a(this),e=d.attr("data-src");d.hide(),c=d.next(),c.show(),e.includes("/?")?a.get(e,{},function(a,b,d){if("success"!==b)return"N/A";c.html(wpacuBytesToSize(a.length))}):a.post(wpacu_object.ajax_url,{action:wpacu_object.plugin_id+"_get_external_file_size",wpacu_remote_file:e},function(a){c.html(a)})}),a(".wpacu_handle_row_expand_contract").on("click",function(b){b.preventDefault();var c=a(this).attr("data-wpacu-handle"),d=a(this).attr("data-wpacu-handle-for");a(this).find("span").hasClass("dashicons-minus")?(a(this).parents("td").attr("data-wpacu-row-status","contracted").find(".wpacu_handle_row_expanded_area").addClass("wpacu_hide"),a(this).find("span").removeClass("dashicons-minus").addClass("dashicons-plus"),a("#wpacu_"+d+"_"+c+"_row_contracted_area").val("1")):a(this).find("span").hasClass("dashicons-plus")&&(a(this).parents("td").attr("data-wpacu-row-status","expanded").find(".wpacu_handle_row_expanded_area").removeClass("wpacu_hide"),a(this).find("span").removeClass("dashicons-plus").addClass("dashicons-minus"),a("#wpacu_"+d+"_"+c+"_row_contracted_area").val(""))});a('[data-is-hardcoded-asset="true"]').length>0&&(a.each(a('[data-is-hardcoded-asset="true"]'),function(b,c){f.updateHardcodedDataHiddenFieldStatus(a(this))}),a('[data-is-hardcoded-asset="true"]').on("click",".wpacu_unload_rule_input",function(){f.updateHardcodedDataHiddenFieldStatus(a(this).parents("[data-is-hardcoded-asset]"))}))},updateHardcodedDataHiddenFieldStatus:function(b){var c=!1;b.is("[data-style-handle-row]")?c=b.attr("data-style-handle-row"):b.is("[data-script-handle-row]")&&(c=b.attr("data-script-handle-row")),c&&(b.find(".wpacu_unload_rule_input:checked").length>0||b.hasClass("wpacu_not_load")?a("#"+c+"_hardcoded_data").prop("disabled",!1):a("#"+c+"_hardcoded_data").prop("disabled",!0))},triggerAlertWhenAnyUnloadRuleIsChosen:function(b,c){if("dashicons"===b&&"style"===c&&a('input[name="wpacu_ignore_child[styles][nf-display]').length>0&&!confirm(wpacu_object.dashicons_unload_alert_ninja_forms))return!1;if("script"===c){if(("jquery"===b||"jquery-core"===b)&&a("#script_jquery_ignore_children").length>0&&!confirm(wpacu_object.jquery_unload_alert))return!1;if("js-cookie"===b&&!confirm(wpacu_object.woo_js_cookie_unload_alert))return!1;if("wc-cart-fragments"===b&&!confirm(wpacu_object.woo_wc_cart_fragments_unload_alert))return!1;if(("backbone"===b||"underscore"===b)&&!confirm(wpacu_object.sensitive_library_unload_alert))return!1}return!0},pluginLoadManager:function(){a(".wpacu_plugin_load_it").on("click",function(){var b=a(this).attr("data-wpacu-plugin-path");a(this).prop("checked")&&(f.hidePluginLoadExceptionArea(b),a('.wpacu_plugin_unload_regex_input_wrap[data-wpacu-plugin-path="'+b+'"]').addClass("wpacu_hide"),a('.wpacu_plugin_unload_site_wide[data-wpacu-plugin-path="'+b+'"]').parent("label").removeClass("wpacu_plugin_unload_rule_input_checked"),a('.wpacu_plugin_unload_regex_radio[data-wpacu-plugin-path="'+b+'"]').parent("label").removeClass("wpacu_plugin_unload_rule_input_checked"))}),a(".wpacu_plugin_unload_site_wide").on("click",function(){var b=a(this).attr("data-wpacu-plugin-path");a(this).prop("checked")?(a(this).parent("label").addClass("wpacu_plugin_unload_rule_input_checked"),a('.wpacu_plugin_unload_regex_radio[data-wpacu-plugin-path="'+b+'"]').parent("label").removeClass("wpacu_plugin_unload_rule_input_checked"),a('.wpacu_plugin_unload_regex_input_wrap[data-wpacu-plugin-path="'+b+'"]').addClass("wpacu_hide"),f.showPluginLoadExceptionArea(b)):(a(this).parent("label").removeClass("wpacu_plugin_unload_rule_input_checked"),a('.wrap_plugin_load_exception_options[data-wpacu-plugin-path="'+b+'"]').addClass("wpacu_hide").find('input[type="checkbox"]').prop("disabled",!0))}),a(".wpacu_plugin_unload_regex_radio").on("click",function(){var b=a(this).attr("data-wpacu-plugin-path");a(this).prop("checked")?(a(this).parent("label").addClass("wpacu_plugin_unload_rule_input_checked"),a('.wpacu_plugin_unload_regex_input_wrap[data-wpacu-plugin-path="'+b+'"]').removeClass("wpacu_hide"),f.showPluginLoadExceptionArea(b),a('.wpacu_plugin_unload_site_wide[data-wpacu-plugin-path="'+b+'"]').prop("checked",!1).parent("label").removeClass("wpacu_plugin_unload_rule_input_checked")):(a('.wpacu_plugin_unload_regex_input_wrap[data-wpacu-plugin-path="'+b+'"]').addClass("wpacu_hide"),a(this).parent("label").removeClass("wpacu_plugin_unload_rule_input_checked"),a('.wrap_plugin_load_exception_options[data-wpacu-plugin-path="'+b+'"]').addClass("wpacu_hide"))}),a(".wpacu_plugin_load_exception_regex").on("click",function(){var b=a(this).attr("data-wpacu-plugin-path");a(this).prop("checked")?a('.wpacu_load_regex_input_wrap[data-wpacu-plugin-path="'+b+'"]').removeClass("wpacu_hide"):a('.wpacu_load_regex_input_wrap[data-wpacu-plugin-path="'+b+'"]').addClass("wpacu_hide")})},showPluginLoadExceptionArea:function(b){a('.wrap_plugin_load_exception_options[data-wpacu-plugin-path="'+b+'"]').removeClass("wpacu_hide").find('input[type="checkbox"]').prop("disabled",!1)},hidePluginLoadExceptionArea:function(b){a('.wrap_plugin_load_exception_options[data-wpacu-plugin-path="'+b+'"]').addClass("wpacu_hide").find('input[type="checkbox"]').prop("disabled",!0)},showHandleLoadExceptionArea:function(b,c){var d=a("div.wpacu_exception_options_area_wrap[data-"+b+'-handle="'+c+'"]');d.parent("div").removeClass("wpacu_hide"),d.find('input[type="checkbox"]').prop("disabled",!1)},hideHandleLoadExceptionArea:function(b,c,d){if(!b.hasClass("wpacu_is_bulk_unloaded")&&!b.find(".wpacu_bulk_unload").is(":checked")){var e=a("div.wpacu_exception_options_area_wrap[data-"+d+'-handle="'+c+'"]');e.parent("div").addClass("wpacu_hide"),e.find('input[type="checkbox"]').prop("disabled",!0)}},uncheckAllOtherBulkUnloadRules:function(a,b){var c=".wpacu_bulk_unload";!1===b&&(c=".wpacu_bulk_unload:not(.wpacu_unload_it_regex_checkbox)"),a.closest("tr").find(c).not(a).prop("checked",!1).parent("label").removeClass("wpacu_input_load_checked").removeClass("wpacu_unload_checked")},checkSourcesFor404Errors:function(){var b=a("[data-wpacu-external-source]");if(!(b.length<1)){var c=b.length,d="";b.each(function(b){var e=a(this),f=e.attr("data-wpacu-external-source");d+=f+"-at-wpacu-at-",b===c-1&&jQuery.post(wpacu_object.ajax_url+"?wpacu_check_external_url",{action:wpacu_object.plugin_id+"_check_external_urls_for_status_code",wpacu_check_urls:d},function(b){var c=jQuery.parseJSON(b);a.each(c,function(b,c){a('[data-wpacu-external-source="'+c+'"]').css({color:"#cc0000"}).parent("div").find("[data-wpacu-external-source-status]").html('<small>* <em style="font-weight: 600;">'+wpacu_object.source_load_error_msg+"</em></small>")})})})}}};a(window).on("load",function(){f.checkSourcesFor404Errors()}),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").show():a("#wpacu-settings-assets-retrieval-mode").hide()}),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").show():a("#wpacu-settings-frontend-exceptions").hide()}),a(".google_fonts_combine_type").change(function(){a(".wpacu_google_fonts_combine_type_area").hide(),"async"===a(this).val()?a("#wpacu_google_fonts_combine_type_async_info_area").fadeIn():"async_preload"===a(this).val()?a("#wpacu_google_fonts_combine_type_async_preload_info_area").fadeIn():a("#wpacu_google_fonts_combine_type_rb_info_area").fadeIn()}),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("[data-target-opacity]").on("click change tick",function(){a(this).prop("checked")?a("#"+a(this).attr("data-target-opacity")).css({opacity:1}):a("#"+a(this).attr("data-target-opacity")).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 g=a('#wpacu-update-button-area input[type="submit"]');g.parents("form").submit(function(){g.attr("disabled",!0),a("#wpacu-updating-settings").show()});var h=a("#wpacu-update-front-settings-area .wpacu_update_btn");if(h.parents("form").submit(function(){return h.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 g.attr("disabled",!0),!0}),a(".wpacu_bulk_rule_checkbox, .wpacu_remove_preload").click(function(){var b=a(this).parents(".wpacu_bulk_change_row");a(this).prop("checked")?b.addClass("wpacu_selected"):b.removeClass("wpacu_selected")}),a(".wpacu_remove_regex").click(function(){var b=a(this).parents(".wpacu_regex_rule_row");a(this).prop("checked")?b.addClass("wpacu_enabled"):b.removeClass("wpacu_enabled")}),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(){f.load()},200),a("#wpacu-plugins-load-manager-wrap").length>0&&setTimeout(function(){f.pluginLoadManager()},200),"undefined"==typeof wpacu_object||a("#wpacu_meta_box_content").length<1)return!1;("default"===wpacu_object.list_show_status||""===wpacu_object.list_show_status||wpacu_object.override_assets_list_load)&&b(),"fetch_on_click"===wpacu_object.list_show_status&&a("#wpacu_ajax_fetch_on_click_btn").click(function(c){c.preventDefault(),a(this).hide(),a("#wpacu_fetching_assets_list_wrap").show(),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(),wpacuAjaxClearCache(),clearInterval(d)}},d=setInterval(c,900)})}),""!==wpacu_object.clear_cache_on_page_load&&wpacuAjaxClearCache(),""!==wpacu_object.clear_other_caches&&setTimeout(function(){wpacuClearAutoptimizeCache()},150),jQuery(document).ready(function(a){try{var b;a('input[type="hidden"][name="_wp_http_referer"]').length>0&&(b=a('input[type="hidden"][name="_wp_http_referer"]').val(),b.includes("term.php?taxonomy=")&&b.includes("message=")&&wpacuAjaxClearCache(),b.includes("post.php?post=")&&b.includes("message=")&&wpacuAjaxClearCache())}catch(a){console.log(a)}});
classes/FileSystem.php CHANGED
@@ -1,8 +1,6 @@
1
  <?php
2
  namespace WpAssetCleanUp;
3
 
4
- use WpAssetCleanUp\OptimiseAssets\CombineCssImports;
5
-
6
  /**
7
  * Class FileSystem
8
  * @package WpAssetCleanUp
@@ -56,7 +54,7 @@ class FileSystem
56
  // ONLY relevant for CSS files
57
  if ($alter === 'combine_css_imports') {
58
  // This custom class does not minify as it's custom made for combining @import
59
- $optimizer = new CombineCssImports($localPathToFile);
60
  return $optimizer->minify();
61
  }
62
 
@@ -78,9 +76,15 @@ class FileSystem
78
  {
79
  // Fallback
80
  if (! self::init()) {
81
- return @file_put_contents($localPathToFile, $contents);
 
 
 
 
 
 
82
  }
83
 
84
- return self::init()->put_contents($localPathToFile, $contents, FS_CHMOD_FILE);
85
  }
86
  }
1
  <?php
2
  namespace WpAssetCleanUp;
3
 
 
 
4
  /**
5
  * Class FileSystem
6
  * @package WpAssetCleanUp
54
  // ONLY relevant for CSS files
55
  if ($alter === 'combine_css_imports') {
56
  // This custom class does not minify as it's custom made for combining @import
57
+ $optimizer = new \WpAssetCleanUp\OptimiseAssets\CombineCssImports($localPathToFile);
58
  return $optimizer->minify();
59
  }
60
 
76
  {
77
  // Fallback
78
  if (! self::init()) {
79
+ $return = @file_put_contents($localPathToFile, $contents);
80
+ } else {
81
+ $return = self::init()->put_contents( $localPathToFile, $contents, FS_CHMOD_FILE );
82
+ }
83
+
84
+ if (! $return) {
85
+ error_log('Asset CleanUp: Could not write to '.$localPathToFile);
86
  }
87
 
88
+ return $return;
89
  }
90
  }
classes/Main.php CHANGED
@@ -2095,7 +2095,7 @@ SQL;
2095
  )
2096
  ));
2097
 
2098
- $contents = ((! is_wp_error($wpRemotePost)) && isset( $wpRemotePost['body'] )) ? $wpRemotePost['body'] : '';
2099
 
2100
  // Enqueued List
2101
  if ($contents
@@ -2125,9 +2125,16 @@ SQL;
2125
  // EITHER the enqueued or hardcoded list of assets HAS TO BE RETRIEVED
2126
  // Print out the 'error' response to make the user aware about it
2127
  if ( ! ($wpacuListE || $wpacuListH) ) {
2128
- if (isset($wpRemotePost['body']) && $wpRemotePost['body']) {
2129
- $wpRemotePost['body'] = strip_tags($wpRemotePost['body'], '<p><a><strong><b><em><i>');
2130
- }
 
 
 
 
 
 
 
2131
 
2132
  $data = array(
2133
  'is_dashboard_view' => true,
@@ -2222,6 +2229,7 @@ SQL;
2222
 
2223
  $data['wpacu_type'] = $type;
2224
 
 
2225
  $data['load_exceptions'] = $this->getLoadExceptions($type, $postId);
2226
 
2227
  $data['handle_rows_contracted'] = self::getHandleRowStatus();
2095
  )
2096
  ));
2097
 
2098
+ $contents = (isset($wpRemotePost['body']) && (! is_wp_error($wpRemotePost))) ? $wpRemotePost['body'] : '';
2099
 
2100
  // Enqueued List
2101
  if ($contents
2125
  // EITHER the enqueued or hardcoded list of assets HAS TO BE RETRIEVED
2126
  // Print out the 'error' response to make the user aware about it
2127
  if ( ! ($wpacuListE || $wpacuListH) ) {
2128
+ // 'body' is set and it's not an array
2129
+ if ( is_wp_error($wpRemotePost) ) {
2130
+ $wpRemotePost['response']['message'] = $wpRemotePost->get_error_message();
2131
+ } elseif ( isset( $wpRemotePost['body']) ) {
2132
+ if ( trim( $wpRemotePost['body'] ) === '' ) {
2133
+ $wpRemotePost['body'] = '<strong>Error (blank page):</strong> It looks the targeted page is loading, but it has no content. The page seems to be blank. Please load it in incognito mode (when you are not logged-in) via your browser.';
2134
+ } elseif ( ! is_array( $wpRemotePost['body'] ) ) {
2135
+ $wpRemotePost['body'] = strip_tags( $wpRemotePost['body'], '<p><a><strong><b><em><i>' );
2136
+ }
2137
+ }
2138
 
2139
  $data = array(
2140
  'is_dashboard_view' => true,
2229
 
2230
  $data['wpacu_type'] = $type;
2231
 
2232
+ // e.g. Load it on this page
2233
  $data['load_exceptions'] = $this->getLoadExceptions($type, $postId);
2234
 
2235
  $data['handle_rows_contracted'] = self::getHandleRowStatus();
classes/OptimiseAssets/OptimizeCommon.php CHANGED
@@ -150,6 +150,11 @@ class OptimizeCommon
150
  return;
151
  }
152
 
 
 
 
 
 
153
  /*
154
  * CASE 1: The admin is logged-in and manages the assets in the front-end view
155
  * */
@@ -189,6 +194,11 @@ class OptimizeCommon
189
  define('WPACU_ALTER_HTML_SOURCE_DONE', 1);
190
  }
191
 
 
 
 
 
 
192
  // Dashboard View
193
  // Return the HTML as it is without performing any optimisations to save resources
194
  // Since the page has to be as clean as possible when fetching the assets
150
  return;
151
  }
152
 
153
+ if (is_feed()) {
154
+ // The plugin should be inactive for feed URLs
155
+ return;
156
+ }
157
+
158
  /*
159
  * CASE 1: The admin is logged-in and manages the assets in the front-end view
160
  * */
194
  define('WPACU_ALTER_HTML_SOURCE_DONE', 1);
195
  }
196
 
197
+ if (is_feed()) {
198
+ // The plugin should not do any alterations for the feed content
199
+ return $htmlSource;
200
+ }
201
+
202
  // Dashboard View
203
  // Return the HTML as it is without performing any optimisations to save resources
204
  // Since the page has to be as clean as possible when fetching the assets
classes/OptimiseAssets/OptimizeCss.php CHANGED
@@ -28,19 +28,20 @@ class OptimizeCss
28
  {
29
  add_action('init', array($this, 'triggersAfterInit'));
30
  add_action('wp_footer', static function() {
 
 
31
  /* [wpacu_timing] */ Misc::scriptExecTimer( 'prepare_optimize_files_css' ); /* [/wpacu_timing] */
32
  self::prepareOptimizeList();
33
  /* [wpacu_timing] */ Misc::scriptExecTimer( 'prepare_optimize_files_css', 'end' ); /* [/wpacu_timing] */
34
- }, PHP_INT_MAX);
35
-
36
- add_action('wp_footer', static function() {
37
- if ( Plugin::preventAnyChanges() || Main::isTestModeActive() ) {
38
- return;
39
- }
40
 
41
  echo self::MOVE_NOSCRIPT_TO_BODY_FOR_ASYNC_PRELOADS;
42
  }, PHP_INT_MAX);
43
 
 
 
 
 
 
44
  add_filter('wpacu_add_async_preloads_noscript', array($this, 'appendNoScriptAsyncPreloads'));
45
  }
46
 
@@ -388,7 +389,7 @@ class OptimizeCss
388
  */
389
  $fileVer = sha1($cssContent);
390
 
391
- $newFilePathUri = self::getRelPathCssCacheDir() . OptimizeCommon::$optimizedSingleFilesDir . '/' . $value->handle . '-v' . $fileVer;
392
  $newFilePathUri .= '.css';
393
 
394
  if ($cssContent === '') {
@@ -750,14 +751,12 @@ class OptimizeCss
750
 
751
  // Strip it as its content (after optimization, for instance) is empty; no point in having extra HTTP requests
752
  if ($isEmptyOptimizedFile) {
753
- $htmlSourceBefore = $htmlSource;
 
 
754
  $htmlSource = str_replace($linkSourceTag, '', $htmlSource);
755
- $htmlSourceAfter = $htmlSource;
756
 
757
- if ( ( $htmlSourceAfter !== $htmlSourceBefore ) && $scriptExtraAfterHtml = self::generateInlineAssocHtmlForHandle( $listValues[3] ) ) {
758
- $htmlSource = str_replace( $scriptExtraAfterHtml, '', $htmlSource );
759
- }
760
- } else {
761
  // Do the replacement
762
  $newLinkSourceTag = self::updateOriginalToOptimizedTag( $linkSourceTag, $sourceUrlList, $optimizeUrl );
763
  $linkTagsToUpdate[$linkSourceTag] = $newLinkSourceTag;
28
  {
29
  add_action('init', array($this, 'triggersAfterInit'));
30
  add_action('wp_footer', static function() {
31
+ if ( Plugin::preventAnyChanges() || Main::isTestModeActive() ) { return; }
32
+
33
  /* [wpacu_timing] */ Misc::scriptExecTimer( 'prepare_optimize_files_css' ); /* [/wpacu_timing] */
34
  self::prepareOptimizeList();
35
  /* [wpacu_timing] */ Misc::scriptExecTimer( 'prepare_optimize_files_css', 'end' ); /* [/wpacu_timing] */
 
 
 
 
 
 
36
 
37
  echo self::MOVE_NOSCRIPT_TO_BODY_FOR_ASYNC_PRELOADS;
38
  }, PHP_INT_MAX);
39
 
40
+ add_filter('wpacu_html_source_after_optimization', static function($htmlSource) {
41
+ // Are any the marks still there & weren't replaced? Strip them to have a clean HTML output!
42
+ return str_replace(self::MOVE_NOSCRIPT_TO_BODY_FOR_ASYNC_PRELOADS, '', $htmlSource);
43
+ });
44
+
45
  add_filter('wpacu_add_async_preloads_noscript', array($this, 'appendNoScriptAsyncPreloads'));
46
  }
47
 
389
  */
390
  $fileVer = sha1($cssContent);
391
 
392
+ $newFilePathUri = self::getRelPathCssCacheDir() . OptimizeCommon::$optimizedSingleFilesDir . '/' . sanitize_title($value->handle) . '-v' . $fileVer;
393
  $newFilePathUri .= '.css';
394
 
395
  if ($cssContent === '') {
751
 
752
  // Strip it as its content (after optimization, for instance) is empty; no point in having extra HTTP requests
753
  if ($isEmptyOptimizedFile) {
754
+ // Note: As for September 3, 2020, the inline CSS associated with the handle is no longer removed if the main CSS file is empty
755
+ // There could be cases when the main CSS file is empty (e.g. theme's styling), but the inline STYLE tag associated with it has syntax that is needed
756
+
757
  $htmlSource = str_replace($linkSourceTag, '', $htmlSource);
 
758
 
759
+ } else {
 
 
 
760
  // Do the replacement
761
  $newLinkSourceTag = self::updateOriginalToOptimizedTag( $linkSourceTag, $sourceUrlList, $optimizeUrl );
762
  $linkTagsToUpdate[$linkSourceTag] = $newLinkSourceTag;
classes/OptimiseAssets/OptimizeJs.php CHANGED
@@ -231,35 +231,54 @@ class OptimizeJs
231
  $jsContent = $jsContentBefore = FileSystem::file_get_contents($localAssetPath);
232
  }
233
 
 
 
234
  $jsContent = trim($jsContent);
235
 
236
  // If it stays like this, it means there is content there, even if only comments
237
  $jsContentBecomesEmptyAfterMin = false;
238
 
239
- if ($doFileMinify && $jsContent) { // only bother to minify it if it has any content, save resources
240
  // Minify this file?
241
  $jsContentBeforeMin = $jsContent;
242
  $jsContentAfterMin = MinifyJs::applyMinification($jsContentBeforeMin);
243
 
244
  $jsContent = $jsContentAfterMin;
245
 
246
- if ($jsContentBeforeMin && $jsContentAfterMin === '') {
247
  // It had content, but became empty after minification, most likely it had only comments (e.g. a default child theme's style)
248
  $jsContentBecomesEmptyAfterMin = true;
 
 
 
 
 
 
 
249
  }
250
  }
251
 
252
- if ($jsContentBecomesEmptyAfterMin || $jsContent === '') {
253
  $jsContent = '/**/';
254
  } else {
255
- $jsContent = self::maybeAlterContentForJsFile( $jsContent, false );
256
-
257
- if ( $isJsFile && trim( $jsContent, '; ' ) === trim( $jsContentBefore, '; ' ) ) {
258
- // The (static) JS file is already minified / No need to copy it in to the cache (save disk space)
259
- return array();
 
 
 
 
 
 
 
 
 
260
  }
261
 
262
- $jsContent = self::maybeDoJsFixes( $jsContent, $pathToAssetDir . '/' ); // Minify it and save it to /wp-content/cache/js/min/
 
263
  }
264
  /*
265
  * [END] JS Content Optimization
@@ -269,7 +288,7 @@ class OptimizeJs
269
  // Save it to /wp-content/cache/js/{OptimizeCommon::$optimizedSingleFilesDir}/
270
  $fileVer = sha1($jsContent);
271
 
272
- $newFilePathUri = self::getRelPathJsCacheDir() . OptimizeCommon::$optimizedSingleFilesDir . '/' . $value->handle . '-v' . $fileVer;
273
  $newFilePathUri .= '.js';
274
 
275
  if ($jsContent === '') {
@@ -318,12 +337,12 @@ class OptimizeJs
318
  * @param $jsContent
319
  * @param bool $doJsMinify (false by default as it could be already minified or non-minify type)
320
  *
321
- * @return mixed|string|string[]|null
322
  */
323
  public static function maybeAlterContentForJsFile($jsContent, $doJsMinify = false)
324
  {
325
  if (! trim($jsContent)) { // No Content! Return it as it, no point in doing extra checks
326
- return $jsContent;
327
  }
328
 
329
  /* [START] Change JS Content */
@@ -339,12 +358,14 @@ class OptimizeJs
339
  }
340
  /* [END] Change JS Content */
341
 
 
 
342
  // Does it have a source map? Strip it
343
  if (strpos($jsContent, 'sourceMappingURL') !== false) {
344
  $jsContent = OptimizeCommon::stripSourceMap($jsContent);
345
  }
346
 
347
- return $jsContent;
348
  }
349
 
350
  /**
@@ -537,17 +558,10 @@ class OptimizeJs
537
  // Strip it as its content (after optimization, for instance) is empty; no point in having extra HTTP requests
538
  $scriptTagsToUpdate[$scriptSourceTag.'</script>'] = '';
539
 
540
- // Any SCRIPT inline associated with the tag? Strip it
541
- foreach (array('data', 'before', 'after') as $inlineType) {
542
- if ( $scriptExtraAfterHtml = self::generateInlineAssocHtmlForHandle( $listValues[3], $inlineType ) ) {
543
- if (strlen($scriptExtraAfterHtml) < 200) { // strtr() does better with smaller keys
544
- $scriptTagsToUpdate[ $scriptExtraAfterHtml ] = '';
545
- } else {
546
- $htmlSource = str_replace( $scriptExtraAfterHtml, '', $htmlSource );
547
- }
548
- }
549
- }
550
- } else {
551
  $newScriptSourceTag = self::updateOriginalToOptimizedTag( $scriptSourceTag, $sourceUrlList, $optimizeUrl );
552
  $scriptTagsToUpdate[$scriptSourceTag] = $newScriptSourceTag;
553
  }
231
  $jsContent = $jsContentBefore = FileSystem::file_get_contents($localAssetPath);
232
  }
233
 
234
+ $hadToBeMinified = false;
235
+
236
  $jsContent = trim($jsContent);
237
 
238
  // If it stays like this, it means there is content there, even if only comments
239
  $jsContentBecomesEmptyAfterMin = false;
240
 
241
+ if ( $doFileMinify && $jsContent ) { // only bother to minify it if it has any content, save resources
242
  // Minify this file?
243
  $jsContentBeforeMin = $jsContent;
244
  $jsContentAfterMin = MinifyJs::applyMinification($jsContentBeforeMin);
245
 
246
  $jsContent = $jsContentAfterMin;
247
 
248
+ if ( $jsContentBeforeMin && $jsContentAfterMin === '' ) {
249
  // It had content, but became empty after minification, most likely it had only comments (e.g. a default child theme's style)
250
  $jsContentBecomesEmptyAfterMin = true;
251
+ } else {
252
+ $jsContentCompare = md5(trim( $jsContentBeforeMin, '; ' ));
253
+ $jsContentCompareWith = md5(trim( $jsContentAfterMin, '; ' ));
254
+
255
+ if ( $jsContentCompare !== $jsContentCompareWith ) {
256
+ $hadToBeMinified = true;
257
+ }
258
  }
259
  }
260
 
261
+ if ( $jsContentBecomesEmptyAfterMin || $jsContent === '' ) {
262
  $jsContent = '/**/';
263
  } else {
264
+ $jsContentArray = self::maybeAlterContentForJsFile( $jsContent, false );
265
+ $jsContent = $jsContentArray['content']; // resulting content after alteration
266
+ $jsContentAfterAlterToCompare = $jsContentArray['content_after_alter_to_compare'];
267
+
268
+ if ( $isJsFile && ( ! $hadToBeMinified ) ) {
269
+ $jsContentCompare = md5(trim( $jsContent, '; ' ));
270
+ $jsContentCompareWith = md5(trim( $jsContentAfterAlterToCompare, '; ' ));
271
+
272
+ if ( $jsContentCompare === $jsContentCompareWith ) {
273
+ // 1: The file was not minified
274
+ // 2: It doesn't need any alteration (e.g. no Google Fonts to strip from its content)
275
+ // No need to copy it in to the cache (save disk space)
276
+ return array();
277
+ }
278
  }
279
 
280
+ // Change the necessary relative paths before the file is copied to the caching directory (e.g. /wp-content/cache/asset-cleanup/)
281
+ $jsContent = self::maybeDoJsFixes( $jsContent, $pathToAssetDir . '/' );
282
  }
283
  /*
284
  * [END] JS Content Optimization
288
  // Save it to /wp-content/cache/js/{OptimizeCommon::$optimizedSingleFilesDir}/
289
  $fileVer = sha1($jsContent);
290
 
291
+ $newFilePathUri = self::getRelPathJsCacheDir() . OptimizeCommon::$optimizedSingleFilesDir . '/' . sanitize_title($value->handle) . '-v' . $fileVer;
292
  $newFilePathUri .= '.js';
293
 
294
  if ($jsContent === '') {
337
  * @param $jsContent
338
  * @param bool $doJsMinify (false by default as it could be already minified or non-minify type)
339
  *
340
+ * @return array
341
  */
342
  public static function maybeAlterContentForJsFile($jsContent, $doJsMinify = false)
343
  {
344
  if (! trim($jsContent)) { // No Content! Return it as it, no point in doing extra checks
345
+ return array('content' => $jsContent);
346
  }
347
 
348
  /* [START] Change JS Content */
358
  }
359
  /* [END] Change JS Content */
360
 
361
+ $jsContentAfterAlterToCompare = $jsContent; // new possible values
362
+
363
  // Does it have a source map? Strip it
364
  if (strpos($jsContent, 'sourceMappingURL') !== false) {
365
  $jsContent = OptimizeCommon::stripSourceMap($jsContent);
366
  }
367
 
368
+ return array('content' => $jsContent , 'content_after_alter_to_compare' => $jsContentAfterAlterToCompare);
369
  }
370
 
371
  /**
558
  // Strip it as its content (after optimization, for instance) is empty; no point in having extra HTTP requests
559
  $scriptTagsToUpdate[$scriptSourceTag.'</script>'] = '';
560
 
561
+ // Note: As for September 3, 2020, the inline JS associated with the handle is no longer removed if the main JS file is empty
562
+ // There could be cases when the main JS file is empty, but the inline JS tag associated with it has code that is needed
563
+
564
+ } else {
 
 
 
 
 
 
 
565
  $newScriptSourceTag = self::updateOriginalToOptimizedTag( $scriptSourceTag, $sourceUrlList, $optimizeUrl );
566
  $scriptTagsToUpdate[$scriptSourceTag] = $newScriptSourceTag;
567
  }
classes/Overview.php CHANGED
@@ -232,8 +232,19 @@ SQL;
232
  $wpacuGlobalData = get_option(WPACU_PLUGIN_ID . '_global_data');
233
  $wpacuGlobalDataArray = @json_decode($wpacuGlobalData, ARRAY_A);
234
 
 
 
235
  foreach (array('styles', 'scripts') as $assetType) {
236
- foreach (array('load_it_logged_in', 'preloads', 'positions', 'notes', 'ignore_child', 'everywhere', 'date', '404', 'search') as $dataType) {
 
 
 
 
 
 
 
 
 
237
  if ( isset( $wpacuGlobalDataArray[ $assetType ][$dataType] ) && ! empty( $wpacuGlobalDataArray[ $assetType ][$dataType] ) ) {
238
  foreach ( $wpacuGlobalDataArray[ $assetType ][$dataType] as $assetHandle => $dataValue ) {
239
  if ($dataType === 'everywhere' && $assetType === 'scripts' && isset($dataValue['attributes'])) {
@@ -287,7 +298,7 @@ SQL;
287
  }
288
 
289
  /*
290
- * Bulk Unload Rules - post, page, custom post type (e.g. product, download), taxonomy (e.g. category), 404, date, etc.
291
  */
292
  $wpacuBulkUnloadData = get_option(WPACU_PLUGIN_ID . '_bulk_unload');
293
  $wpacuBulkUnloadDataArray = @json_decode($wpacuBulkUnloadData, ARRAY_A);
@@ -299,14 +310,14 @@ SQL;
299
  continue;
300
  }
301
 
302
- // $unloadBulkType could be 'post_type', 'date', '404', 'taxonomy', 'search'
303
  if ($unloadBulkType === 'post_type') {
304
  foreach ($unloadBulkValues as $postType => $assetHandles) {
305
  foreach ($assetHandles as $assetHandle) {
306
  $allHandles[ $assetType ][ $assetHandle ]['unload_bulk']['post_type'][] = $postType;
307
  }
308
  }
309
- } elseif (in_array($unloadBulkType, array('date', '404', 'search'))) {
310
  foreach ($unloadBulkValues as $assetHandle) {
311
  $allHandles[ $assetType ][ $assetHandle ]['unload_bulk'][$unloadBulkType] = 1;
312
  }
@@ -458,6 +469,18 @@ SQL;
458
  $handleExtras[24] = '404 Not Found attributes: <strong>'.implode(', ', $handleData['script_attrs']['search']).'</strong>';
459
  }
460
 
 
 
 
 
 
 
 
 
 
 
 
 
461
  // Per post page
462
  if (isset($handleData['script_attrs']['post']) && ! empty($handleData['script_attrs']['post'])) {
463
  $handleExtras[3] = 'Per post attributes: ';
@@ -523,7 +546,7 @@ SQL;
523
  if (isset($handleData['script_site_wide_attrs'])) {
524
  $handleExtras[4] = 'Site-wide attributes: ';
525
  foreach ( $handleData['script_site_wide_attrs'] as $attrValue ) {
526
- $handleExtras[4] .= '<strong>' . $attrValue . '</strong>, ';
527
 
528
  // Are there any exceptions? e.g. async, defer unloaded site-wide, but loaded on the homepage
529
  if ( isset( $handleData['attrs_no_load'] ) && ! empty( $handleData['attrs_no_load'] ) ) {
@@ -549,6 +572,11 @@ SQL;
549
  $handleAttrsExceptionsList .= ' Search Results, ';
550
  }
551
 
 
 
 
 
 
552
  // Post pages such as posts, pages, product (WooCommerce), download (Easy Digital Downloads), etc.
553
  if ( $attrSetIn === 'post' ) {
554
  $postPagesList = '';
@@ -621,6 +649,8 @@ SQL;
621
  $handleExtras[4] .= $handleAttrsExceptionsList;
622
  $handleExtras[4] .= '</em>), ';
623
  }
 
 
624
  }
625
 
626
  $handleExtras[4] = trim($handleExtras[4], ', ');
@@ -716,7 +746,14 @@ SQL;
716
  $anyGroupPostUnloadRule = true;
717
  }
718
 
719
- if (isset($handleData['unload_bulk']['date']) || isset($handleData['unload_bulk']['404']) || isset($handleData['unload_bulk']['search'])) {
 
 
 
 
 
 
 
720
  foreach ($handleData['unload_bulk'] as $bulkType => $bulkValue) {
721
  if ($bulkType === 'date' && $bulkValue === 1) {
722
  $handleChangesOutput['bulk'] .= ' Unloaded on all archive `Date` pages (any date), ';
@@ -727,6 +764,10 @@ SQL;
727
  if ($bulkType === 404 && $bulkValue === 1) {
728
  $handleChangesOutput['bulk'] .= ' Unloaded on `404 Not Found` page (any URL), ';
729
  }
 
 
 
 
730
  }
731
  }
732
 
@@ -934,6 +975,19 @@ HTML;
934
  $anyLoadExceptionRule = true;
935
  }
936
 
 
 
 
 
 
 
 
 
 
 
 
 
 
937
  if (isset($handleData['load_regex']) && $handleData['load_regex']) {
938
  if ($anyLoadExceptionRule) {
939
  $textToShow = ' <strong>or</strong> if the request URI (from the URL) matches this RegEx';
232
  $wpacuGlobalData = get_option(WPACU_PLUGIN_ID . '_global_data');
233
  $wpacuGlobalDataArray = @json_decode($wpacuGlobalData, ARRAY_A);
234
 
235
+ $allPossibleDataTypes = array('load_it_logged_in', 'preloads', 'positions', 'notes', 'ignore_child', 'everywhere', 'date', '404', 'search');
236
+
237
  foreach (array('styles', 'scripts') as $assetType) {
238
+ if ($assetType === 'scripts' && isset( $wpacuGlobalDataArray[ $assetType ])) {
239
+ foreach (array_keys($wpacuGlobalDataArray[ $assetType ]) as $dataType) {
240
+ if ( strpos( $dataType, 'custom_post_type_archive_' ) !== false ) {
241
+ $allPossibleDataTypes[] = $dataType;
242
+ }
243
+ }
244
+
245
+ }
246
+
247
+ foreach ($allPossibleDataTypes as $dataType) {
248
  if ( isset( $wpacuGlobalDataArray[ $assetType ][$dataType] ) && ! empty( $wpacuGlobalDataArray[ $assetType ][$dataType] ) ) {
249
  foreach ( $wpacuGlobalDataArray[ $assetType ][$dataType] as $assetHandle => $dataValue ) {
250
  if ($dataType === 'everywhere' && $assetType === 'scripts' && isset($dataValue['attributes'])) {
298
  }
299
 
300
  /*
301
+ * Bulk Unload Rules - post, page, custom post type (e.g. product, download), taxonomy (e.g. category), 404, date, archive (for custom post type) with pagination etc.
302
  */
303
  $wpacuBulkUnloadData = get_option(WPACU_PLUGIN_ID . '_bulk_unload');
304
  $wpacuBulkUnloadDataArray = @json_decode($wpacuBulkUnloadData, ARRAY_A);
310
  continue;
311
  }
312
 
313
+ // $unloadBulkType could be 'post_type', 'date', '404', 'taxonomy', 'search', 'custom_post_type_archive_[post_type_name_here]', etc.
314
  if ($unloadBulkType === 'post_type') {
315
  foreach ($unloadBulkValues as $postType => $assetHandles) {
316
  foreach ($assetHandles as $assetHandle) {
317
  $allHandles[ $assetType ][ $assetHandle ]['unload_bulk']['post_type'][] = $postType;
318
  }
319
  }
320
+ } elseif (in_array($unloadBulkType, array('date', '404', 'search')) || (strpos($unloadBulkType, 'custom_post_type_archive_') !== false)) {
321
  foreach ($unloadBulkValues as $assetHandle) {
322
  $allHandles[ $assetType ][ $assetHandle ]['unload_bulk'][$unloadBulkType] = 1;
323
  }
469
  $handleExtras[24] = '404 Not Found attributes: <strong>'.implode(', ', $handleData['script_attrs']['search']).'</strong>';
470
  }
471
 
472
+ // Archive page for Custom Post Type (those created via theme editing or via plugins such as "Custom Post Type UI")
473
+ $scriptAttrsStr = (isset($handleData['script_attrs']) && is_array($handleData['script_attrs'])) ? implode('', array_keys($handleData['script_attrs'])) : '';
474
+
475
+ if (strpos($scriptAttrsStr, 'custom_post_type_archive_') !== false) {
476
+ $keyNo = 225;
477
+ foreach ($handleData['script_attrs'] as $scriptAttrsKey => $scriptAttrsValue) {
478
+ $customPostTypeName = str_replace('custom_post_type_archive_', '', $scriptAttrsKey);
479
+ $handleExtras[$keyNo] = 'Archive custom post type page "'.$customPostTypeName.'" attributes: <strong>'.implode(', ', $handleData['script_attrs'][$scriptAttrsKey]).'</strong>';
480
+ $keyNo++;
481
+ }
482
+ }
483
+
484
  // Per post page
485
  if (isset($handleData['script_attrs']['post']) && ! empty($handleData['script_attrs']['post'])) {
486
  $handleExtras[3] = 'Per post attributes: ';
546
  if (isset($handleData['script_site_wide_attrs'])) {
547
  $handleExtras[4] = 'Site-wide attributes: ';
548
  foreach ( $handleData['script_site_wide_attrs'] as $attrValue ) {
549
+ $handleExtras[4] .= '<strong>' . $attrValue . '</strong>';
550
 
551
  // Are there any exceptions? e.g. async, defer unloaded site-wide, but loaded on the homepage
552
  if ( isset( $handleData['attrs_no_load'] ) && ! empty( $handleData['attrs_no_load'] ) ) {
572
  $handleAttrsExceptionsList .= ' Search Results, ';
573
  }
574
 
575
+ if (strpos($attrSetIn, 'custom_post_type_archive_') !== false) {
576
+ $customPostTypeName = str_replace('custom_post_type_archive_', '', $attrSetIn);
577
+ $handleAttrsExceptionsList .= ' Archive "'.$customPostTypeName.'" custom post type, ';
578
+ }
579
+
580
  // Post pages such as posts, pages, product (WooCommerce), download (Easy Digital Downloads), etc.
581
  if ( $attrSetIn === 'post' ) {
582
  $postPagesList = '';
649
  $handleExtras[4] .= $handleAttrsExceptionsList;
650
  $handleExtras[4] .= '</em>), ';
651
  }
652
+
653
+ $handleExtras[4] .= ', ';
654
  }
655
 
656
  $handleExtras[4] = trim($handleExtras[4], ', ');
746
  $anyGroupPostUnloadRule = true;
747
  }
748
 
749
+ $unloadBulkKeys = isset($handleData['unload_bulk']) ? array_keys($handleData['unload_bulk']) : array();
750
+ $unloadBulkKeysStr = implode('', $unloadBulkKeys);
751
+
752
+ if (isset($handleData['unload_bulk']['date'])
753
+ || isset($handleData['unload_bulk']['404'])
754
+ || isset($handleData['unload_bulk']['search'])
755
+ || (strpos($unloadBulkKeysStr, 'custom_post_type_archive_') !== false)
756
+ ) {
757
  foreach ($handleData['unload_bulk'] as $bulkType => $bulkValue) {
758
  if ($bulkType === 'date' && $bulkValue === 1) {
759
  $handleChangesOutput['bulk'] .= ' Unloaded on all archive `Date` pages (any date), ';
764
  if ($bulkType === 404 && $bulkValue === 1) {
765
  $handleChangesOutput['bulk'] .= ' Unloaded on `404 Not Found` page (any URL), ';
766
  }
767
+ if (strpos($bulkType, 'custom_post_type_archive_') !== false) {
768
+ $customPostType = str_replace('custom_post_type_archive_', '', $bulkType);
769
+ $handleChangesOutput['bulk'] .= ' Unloaded on the archive (list of posts) page of `'.$customPostType.'` custom post type';
770
+ }
771
  }
772
  }
773
 
975
  $anyLoadExceptionRule = true;
976
  }
977
 
978
+ // Load exceptions? Custom post type archive page
979
+ $loadExceptionsPageStr = isset($handleData['load_exception_on_this_page']) && is_array($handleData['load_exception_on_this_page']) ? implode('', array_keys($handleData['load_exception_on_this_page'])) : '';
980
+ if (strpos($loadExceptionsPageStr, 'custom_post_type_archive_') !== false) {
981
+ foreach (array_keys($handleData['load_exception_on_this_page']) as $loadExceptionForDataType) {
982
+ if (strpos($loadExceptionForDataType, 'custom_post_type_archive_') !== false) {
983
+ $customPostType = str_replace('custom_post_type_archive_', '', $loadExceptionForDataType);
984
+ $handleChangesOutput['load_exception_on_'.$loadExceptionForDataType] = '<span style="color: green;">Loaded (as an exception)</span> in an archive page (custom post type: <em>'.$customPostType.'</em>)';
985
+ }
986
+ }
987
+
988
+ $anyLoadExceptionRule = true;
989
+ }
990
+
991
  if (isset($handleData['load_regex']) && $handleData['load_regex']) {
992
  if ($anyLoadExceptionRule) {
993
  $textToShow = ' <strong>or</strong> if the request URI (from the URL) matches this RegEx';
classes/OwnAssets.php CHANGED
@@ -43,6 +43,10 @@ class OwnAssets
43
  $wpacu_object_data['ajax_url'] = admin_url('admin-ajax.php');
44
  $wpacu_object_data['is_frontend_view'] = false;
45
 
 
 
 
 
46
  // Current Page URL (for preloading) in the front-end view
47
  if (! is_admin()) {
48
  $wpacu_object_data['page_url'] = Misc::getCurrentPageUrl();
43
  $wpacu_object_data['ajax_url'] = admin_url('admin-ajax.php');
44
  $wpacu_object_data['is_frontend_view'] = false;
45
 
46
+ if (array_key_exists('wpacu_manage_dash', $_GET)) {
47
+ $wpacu_object_data['force_manage_dash'] = true;
48
+ }
49
+
50
  // Current Page URL (for preloading) in the front-end view
51
  if (! is_admin()) {
52
  $wpacu_object_data['page_url'] = Misc::getCurrentPageUrl();
classes/Settings.php CHANGED
@@ -248,7 +248,10 @@ class Settings
248
 
249
  'fetch_cached_files_details_from' => 'disk', // Do not add more rows to the database by default (options table can become quite large)
250
 
251
- 'clear_cached_files_after' => '7'
 
 
 
252
  );
253
  }
254
 
@@ -499,6 +502,28 @@ class Settings
499
  $settings['inline_js_files'] = false;
500
  }
501
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
502
  if (isset($_GET['wpacu_settings']) && is_array($_GET['wpacu_settings']) && ! empty($_GET['wpacu_settings'])) {
503
  foreach ($_GET['wpacu_settings'] as $settingKey => $settingValue) {
504
  if ($settingValue === 'true') {
248
 
249
  'fetch_cached_files_details_from' => 'disk', // Do not add more rows to the database by default (options table can become quite large)
250
 
251
+ 'clear_cached_files_after' => '7',
252
+
253
+ // Starting from v1.3.6.9 (Lite) & v1.1.7.9 (Pro), /cart/ & /checkout/ pages are added to the exclusion list by default
254
+ 'do_not_load_plugin_patterns' => '/cart/'. "\n". '/checkout/',
255
  );
256
  }
257
 
502
  $settings['inline_js_files'] = false;
503
  }
504
 
505
+ // /?wpacu_manage_front -> "Manage in the Front-end" via query string request
506
+ // Useful when working for a client and you prefer him to view the pages (while logged-in) without the CSS/JS list at the bottom
507
+ if (array_key_exists('wpacu_manage_front', $_GET)) {
508
+ $settings['frontend_show'] = true;
509
+ }
510
+
511
+ // /?wpacu_manage_dash -> "Manage in the Dashboard" via query string request
512
+ // For debugging purposes
513
+ if (is_admin() && (array_key_exists('wpacu_manage_dash', $_REQUEST) || array_key_exists('force_manage_dash', $_REQUEST))) {
514
+ $settings['dashboard_show'] = true;
515
+ }
516
+
517
+ // Google Fonts Removal is enabled; make sure other related settings are nulled
518
+ if ($settings['google_fonts_remove']) {
519
+ $settings['google_fonts_combine']
520
+ = $settings['google_fonts_combine_type']
521
+ = $settings['google_fonts_display']
522
+ = $settings['google_fonts_preconnect']
523
+ = $settings['google_fonts_preload_files']
524
+ = '';
525
+ }
526
+
527
  if (isset($_GET['wpacu_settings']) && is_array($_GET['wpacu_settings']) && ! empty($_GET['wpacu_settings'])) {
528
  foreach ($_GET['wpacu_settings'] as $settingKey => $settingValue) {
529
  if ($settingValue === 'true') {
early-triggers.php CHANGED
@@ -16,6 +16,9 @@ if (array_key_exists('wpacu_clean_load', $_GET)) {
16
  add_action( 'litespeed_disable_all', static function($reason) {
17
  do_action( 'litespeed_debug', '[API] Disabled_all due to: A clean load of the page was requested via '. WPACU_PLUGIN_TITLE );
18
  } );
 
 
 
19
  }
20
 
21
  if (! function_exists('assetCleanUpHasNoLoadMatches')) {
@@ -296,6 +299,12 @@ if (! function_exists('assetCleanUpNoLoad')) {
296
  return true;
297
  }
298
 
 
 
 
 
 
 
299
  // Stop triggering Asset CleanUp (completely) on specific front-end pages
300
  // Do the trigger here and if necessary exit as early as possible to save resources via "registered_taxonomy" action hook)
301
  if (assetCleanUpHasNoLoadMatches()) {
16
  add_action( 'litespeed_disable_all', static function($reason) {
17
  do_action( 'litespeed_debug', '[API] Disabled_all due to: A clean load of the page was requested via '. WPACU_PLUGIN_TITLE );
18
  } );
19
+
20
+ // No "WP-Optimize – Clean, Compress, Cache." minify
21
+ add_filter('pre_option_wpo_minify_config', function() { return array(); });
22
  }
23
 
24
  if (! function_exists('assetCleanUpHasNoLoadMatches')) {
299
  return true;
300
  }
301
 
302
+ // e.g. WooCommerce's AJAX call to /?wc-ajax=checkout | no need to trigger Asset CleanUp then, not only avoiding any errors, but also saving resources
303
+ // "wc-ajax" could be one of the following: update_order_review, apply_coupon, checkout, etc.
304
+ if (isset($_REQUEST['wc-ajax']) && $_SERVER['REQUEST_METHOD'] === 'POST') {
305
+ return true;
306
+ }
307
+
308
  // Stop triggering Asset CleanUp (completely) on specific front-end pages
309
  // Do the trigger here and if necessary exit as early as possible to save resources via "registered_taxonomy" action hook)
310
  if (assetCleanUpHasNoLoadMatches()) {
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: gabelivan
3
  Tags: minify css, minify javascript, defer css javascript, page speed, dequeue, performance
4
  Donate link: https://www.gabelivan.com/items/wp-asset-cleanup-pro/?utm_source=wp_org_lite&utm_medium=donate
5
  Requires at least: 4.5
6
- Tested up to: 5.5
7
- Stable tag: 1.3.6.8
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl.html
10
 
@@ -187,6 +187,16 @@ With the recently released "Test Mode" feature, you can safely unload assets on
187
  4. Homepage CSS & JS Management (List sorted by location)
188
 
189
  == Changelog ==
 
 
 
 
 
 
 
 
 
 
190
  = 1.3.6.8 =
191
  * Make the plugin's user aware about jQuery Migrate not loading starting from WordPress 5.5 (a notice is showing in "Settings" -> "Site-Wide Common Unloads" if the WP version >= 5.5)
192
  * Add alerts for WooCommerce assets when the user is about to unload them to make sure he/she is aware of the consequences (e.g. "js-cookie", "wc-cart-fragments")
3
  Tags: minify css, minify javascript, defer css javascript, page speed, dequeue, performance
4
  Donate link: https://www.gabelivan.com/items/wp-asset-cleanup-pro/?utm_source=wp_org_lite&utm_medium=donate
5
  Requires at least: 4.5
6
+ Tested up to: 5.5.1
7
+ Stable tag: 1.3.6.9
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl.html
10
 
187
  4. Homepage CSS & JS Management (List sorted by location)
188
 
189
  == Changelog ==
190
+ = 1.3.6.9 =
191
+ * Improvement: Save resources and do not check anything for optimization when the feed URL (e.g. /feed/) is loaded (the plugin should be inactive for these kinds of requests)
192
+ * Improvement: Do not trigger the plugin when WooCommerce makes AJAX calls (no point in using extra resources from Asset CleanUp)
193
+ * Improvement: When Google Fonts are marked for removal, nullify other related settings, leading to the usage of fewer resources
194
+ * The strings "/cart/" and "/checkout/" are added to the exclusion list where Asset CleanUp Pro is not triggered if the pattern is matched (read more: https://assetcleanup.com/docs/?p=488); These kinds of pages usually do not need optimization and if the admin decides to do some, he/she can remove the exclusion
195
+ * Fix (writing files to cache directory): If the handle name contained forward-slash (/), make sure that the final file name gets sanitized (including slash removal) to avoid errors related to file_put_contents() such as trying to write to directories that are non-existent
196
+ * Fix (unnecessary cached files): The plugin was caching CSS/JS files that did not need to be cached (e.g. already minified JS), leading to unnecessary extra disk space
197
+ * "WP-Optimize" minify is not triggering anymore when /?wpacu_clean_load is used for debugging purposes (viewing all files loading from their original location)
198
+ * Do not strip inline CSS/JS associated with the handle if the original file is empty as there's a high chance the inline code is needed
199
+
200
  = 1.3.6.8 =
201
  * Make the plugin's user aware about jQuery Migrate not loading starting from WordPress 5.5 (a notice is showing in "Settings" -> "Site-Wide Common Unloads" if the WP version >= 5.5)
202
  * Add alerts for WooCommerce assets when the user is about to unload them to make sure he/she is aware of the consequences (e.g. "js-cookie", "wc-cart-fragments")
templates/_admin-page-getting-started-areas/_lite-vs-pro.php CHANGED
@@ -29,11 +29,11 @@ HTML;
29
  <td><strong><?php _e('License Price', 'wp-asset-clean-up'); ?></strong> <small>* <?php echo sprintf(
30
  __('after the first year, you will save %s off the initial purchase price, and be charged only %s', 'wp-asset-clean-up'),
31
  '30%',
32
- '$29<sup>.40</sup>'
33
  );
34
  ?></small></td>
35
  <td><span class="txt-top">$</span><span class="txt-l">0</span></td>
36
- <td><span class="txt-top">$</span><span class="txt-l">42</span></td>
37
  </tr>
38
  <tr>
39
  <td><?php _e('Manage CSS &amp; JavaScript files on Homepage, Posts, Pages &amp; Custom Post Types (e.g. WooCommerce product pages, Easy Digital Downloads download items)', 'wp-asset-clean-up'); ?></td>
29
  <td><strong><?php _e('License Price', 'wp-asset-clean-up'); ?></strong> <small>* <?php echo sprintf(
30
  __('after the first year, you will save %s off the initial purchase price, and be charged only %s', 'wp-asset-clean-up'),
31
  '30%',
32
+ '$32<sup>.90</sup>'
33
  );
34
  ?></small></td>
35
  <td><span class="txt-top">$</span><span class="txt-l">0</span></td>
36
+ <td><span class="txt-top">$</span><span class="txt-l">47</span></td>
37
  </tr>
38
  <tr>
39
  <td><?php _e('Manage CSS &amp; JavaScript files on Homepage, Posts, Pages &amp; Custom Post Types (e.g. WooCommerce product pages, Easy Digital Downloads download items)', 'wp-asset-clean-up'); ?></td>
templates/_admin-pages-assets-manager/_homepage.php CHANGED
@@ -98,11 +98,18 @@ if ($data['show_on_front'] === 'page') {
98
  </p>
99
  <?php
100
  } else {
 
 
 
 
 
 
 
101
  ?>
102
- <form id="wpacu_home_page_form"
103
- method="post"
104
- action="<?php echo admin_url('admin.php?page='.WPACU_PLUGIN_ID.'_assets_manager&wpacu_rand='.uniqid(time(), true)); ?>">
105
- <input type="hidden" name="wpacu_manage_home_page_assets" value="1" />
106
 
107
  <input type="hidden"
108
  id="wpacu_ajax_fetch_assets_list_dashboard_view"
98
  </p>
99
  <?php
100
  } else {
101
+ $strAdminUrl = 'admin.php?page='.WPACU_PLUGIN_ID.'_assets_manager&wpacu_rand='.uniqid(time(), true);
102
+
103
+ if (array_key_exists('wpacu_manage_dash', $_GET) || array_key_exists('force_manage_dash', $_REQUEST)) { // For debugging purposes
104
+ $strAdminUrl .= '&wpacu_manage_dash';
105
+ }
106
+
107
+ $wpacuAdminUrl = admin_url($strAdminUrl);
108
  ?>
109
+ <form id="wpacu_home_page_form" method="post" action="<?php echo $wpacuAdminUrl; ?>">
110
+ <input type="hidden"
111
+ name="wpacu_manage_home_page_assets"
112
+ value="1" />
113
 
114
  <input type="hidden"
115
  id="wpacu_ajax_fetch_assets_list_dashboard_view"
templates/meta-box.php CHANGED
@@ -23,8 +23,6 @@ if ($data['is_list_fetchable']) {
23
  ?>
24
  <div id="wpacu_fetching_assets_list_wrap" <?php if ($data['fetch_assets_on_click']) { echo 'style="display: none;"'; } ?>>
25
  <?php
26
- $wpacuLoadingSpinnerFetchAssets = '<img src="'.admin_url('images/spinner.gif').'" align="top" width="20" height="20" alt="" />';
27
-
28
  if ($data['dom_get_type'] === 'direct') {
29
  $wpacuDefaultFetchListStepDefaultStatus = '<img src="'.admin_url('images/spinner.gif').'" align="top" width="20" height="20" alt="" />&nbsp; Please wait...';
30
  $wpacuDefaultFetchListStepCompletedStatus = '<span style="color: green;" class="dashicons dashicons-yes-alt"></span> Completed';
23
  ?>
24
  <div id="wpacu_fetching_assets_list_wrap" <?php if ($data['fetch_assets_on_click']) { echo 'style="display: none;"'; } ?>>
25
  <?php
 
 
26
  if ($data['dom_get_type'] === 'direct') {
27
  $wpacuDefaultFetchListStepDefaultStatus = '<img src="'.admin_url('images/spinner.gif').'" align="top" width="20" height="20" alt="" />&nbsp; Please wait...';
28
  $wpacuDefaultFetchListStepCompletedStatus = '<span style="color: green;" class="dashicons dashicons-yes-alt"></span> Completed';
wpacu-load.php CHANGED
@@ -94,8 +94,6 @@ if (is_admin()) {
94
 
95
  $wpacuTools = new \WpAssetCleanUp\Tools();
96
  $wpacuTools->init();
97
-
98
- \WpAssetCleanUp\Preloads::instance()->init();
99
  } elseif (\WpAssetCleanUp\Misc::triggerFrontendOptimization()) {
100
  /*
101
  * Trigger the CSS & JS combination only in the front-end view in certain conditions (not within the Dashboard)
@@ -120,3 +118,5 @@ if (is_admin()) {
120
  $wpacuFontsGoogle = new \WpAssetCleanUp\OptimiseAssets\FontsGoogle();
121
  $wpacuFontsGoogle->init();
122
  }
 
 
94
 
95
  $wpacuTools = new \WpAssetCleanUp\Tools();
96
  $wpacuTools->init();
 
 
97
  } elseif (\WpAssetCleanUp\Misc::triggerFrontendOptimization()) {
98
  /*
99
  * Trigger the CSS & JS combination only in the front-end view in certain conditions (not within the Dashboard)
118
  $wpacuFontsGoogle = new \WpAssetCleanUp\OptimiseAssets\FontsGoogle();
119
  $wpacuFontsGoogle->init();
120
  }
121
+
122
+ \WpAssetCleanUp\Preloads::instance()->init();
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.6.8
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/
@@ -12,7 +12,7 @@
12
 
13
  // Is the Pro version triggered before the Lite one and are both plugins active?
14
  if (! defined('WPACU_PLUGIN_VERSION')) {
15
- define('WPACU_PLUGIN_VERSION', '1.3.6.8');
16
  }
17
 
18
  // Exit if accessed directly
@@ -35,19 +35,21 @@ if (assetCleanUpNoLoad()) {
35
  }
36
 
37
  // Premium plugin version already exists, is it active?
38
- // Do not load the LITE version as it's pointless
39
  // This action is valid starting from LITE version 1.2.6.8
40
  // From 1.0.3, the PRO version works independently (does not need anymore LITE to be active and act as a parent plugin)
 
41
 
42
  // If the pro version (version above 1.0.2) was triggered first, we'll just check one of its constants
43
  // If the lite version was triggered first, then we'll check if the pro version is active
44
- if ( defined('WPACU_PRO_NO_LITE_NEEDED') && WPACU_PRO_NO_LITE_NEEDED !== false
45
- && defined('WPACU_PRO_PLUGIN_VERSION') && WPACU_PRO_PLUGIN_VERSION !== false ) {
 
 
46
  return;
47
  }
48
 
49
- define('WPACU_PLUGIN_FILE', __FILE__);
50
- define('WPACU_PLUGIN_BASE', plugin_basename(WPACU_PLUGIN_FILE));
51
 
52
  define('WPACU_ADMIN_PAGE_ID_START', WPACU_PLUGIN_ID . '_getting_started');
53
 
@@ -119,3 +121,30 @@ if (WPACU_GET_LOADED_ASSETS_ACTION === true || ! is_admin()) {
119
  require_once WPACU_PLUGIN_DIR . '/vendor/autoload.php';
120
  }
121
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  /*
3
  * Plugin Name: Asset CleanUp: Page Speed Booster
4
  * Plugin URI: https://wordpress.org/plugins/wp-asset-clean-up/
5
+ * Version: 1.3.6.9
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/
12
 
13
  // Is the Pro version triggered before the Lite one and are both plugins active?
14
  if (! defined('WPACU_PLUGIN_VERSION')) {
15
+ define('WPACU_PLUGIN_VERSION', '1.3.6.9');
16
  }
17
 
18
  // Exit if accessed directly
35
  }
36
 
37
  // Premium plugin version already exists, is it active?
 
38
  // This action is valid starting from LITE version 1.2.6.8
39
  // From 1.0.3, the PRO version works independently (does not need anymore LITE to be active and act as a parent plugin)
40
+ // However, it's good to have both versions active for compatibility with plugins such as "WP Cloudflare Super Page Cache"
41
 
42
  // If the pro version (version above 1.0.2) was triggered first, we'll just check one of its constants
43
  // If the lite version was triggered first, then we'll check if the pro version is active
44
+ // Lastly, check if the Pro version is activated via is_plugin_active()
45
+ if ( (defined('WPACU_PRO_NO_LITE_NEEDED') && WPACU_PRO_NO_LITE_NEEDED !== false && defined('WPACU_PRO_PLUGIN_VERSION') && WPACU_PRO_PLUGIN_VERSION !== false)
46
+ || (function_exists('is_plugin_active') && is_plugin_active('wp-asset-clean-up-pro/wpacu.php')) ) {
47
+ // Stop here as the Pro version handles everything the Lite does
48
  return;
49
  }
50
 
51
+ define('WPACU_PLUGIN_FILE', __FILE__);
52
+ define('WPACU_PLUGIN_BASE', plugin_basename(WPACU_PLUGIN_FILE));
53
 
54
  define('WPACU_ADMIN_PAGE_ID_START', WPACU_PLUGIN_ID . '_getting_started');
55
 
121
  require_once WPACU_PLUGIN_DIR . '/vendor/autoload.php';
122
  }
123
 
124
+ // No plugin changes are needed when a feed is loaded
125
+ add_action('setup_theme', static function() {
126
+ // Only in the front-end view and when a request URI is there (e.g. not triggering the WP environment via an SSH terminal)
127
+ if ( ! isset($_SERVER['REQUEST_URI']) || is_admin() ) {
128
+ return;
129
+ }
130
+
131
+ global $wp_rewrite;
132
+
133
+ if (isset($wp_rewrite->feed_base) &&
134
+ $wp_rewrite->feed_base &&
135
+ strpos($_SERVER['REQUEST_URI'], '/'.$wp_rewrite->feed_base) !== false) {
136
+ $currentPageUrl = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http') . '://' . parse_url(site_url(), PHP_URL_HOST) . $_SERVER['REQUEST_URI'];
137
+
138
+ $cleanCurrentPageUrl = $currentPageUrl;
139
+ if (strpos($currentPageUrl, '?') !== false) {
140
+ list($cleanCurrentPageUrl) = explode('?', $currentPageUrl);
141
+ }
142
+
143
+ // /{feed_slug_here}/ or /{feed_slug_here}/atom/
144
+ if ($cleanCurrentPageUrl === site_url().'/'.$wp_rewrite->feed_base.'/'
145
+ || $cleanCurrentPageUrl === site_url().'/'.$wp_rewrite->feed_base.'/atom/') {
146
+ \WpAssetCleanUp\Plugin::preventAnyChanges();
147
+ }
148
+ }
149
+ });
150
+