WP-Optimize - Version 2.2.11

Version Description

  • 16/Jan/2019 =

  • FIX: A regression in the "identify table by owner" feature caused optimizing to silently fail on some tables

  • TWEAK: Added ability to exclude lazy load images by class

Download this release

Release Info

Developer DavidAnderson
Plugin Icon 128x128 WP-Optimize
Version 2.2.11
Comparing to
See all releases

Code changes from version 2.2.10 to 2.2.11

js/wpadmin.js CHANGED
@@ -468,7 +468,7 @@ var WP_Optimize = function (send_command) {
468
 
469
  // Get table type information.
470
  table_type = $table_information.eq(5).text();
471
- table = $table_information.eq(1).text();
472
  optimizable = $table_information.eq(5).data('optimizable');
473
 
474
  // Make sure the table isnt blank.
@@ -477,7 +477,7 @@ var WP_Optimize = function (send_command) {
477
  if ('1' == optimizable || optimization_force) {
478
  var data = {
479
  optimization_id: id,
480
- optimization_table: $table_information.eq(1).text(),
481
  optimization_table_type: table_type,
482
  optimization_force: optimization_force
483
  };
468
 
469
  // Get table type information.
470
  table_type = $table_information.eq(5).text();
471
+ table = $table_information.eq(1).data('tablename');
472
  optimizable = $table_information.eq(5).data('optimizable');
473
 
474
  // Make sure the table isnt blank.
477
  if ('1' == optimizable || optimization_force) {
478
  var data = {
479
  optimization_id: id,
480
+ optimization_table: table,
481
  optimization_table_type: table_type,
482
  optimization_force: optimization_force
483
  };
js/wpadmin.min.js CHANGED
@@ -1 +1 @@
1
- wp_optimize_send_command_admin_ajax=function(e,t,i,o){o="undefined"==typeof o||o;var n={action:"wp_optimize_ajax",subaction:e,nonce:wp_optimize_ajax_nonce,data:t};return jQuery.post(ajaxurl,n,function(e){if(o){try{var t=JSON.parse(e)}catch(n){return console.log(n),console.log(e),void alert(wpoptimize.error_unexpected_response)}"undefined"!=typeof i&&i(t)}else"undefined"!=typeof i&&i(e)})},jQuery(document).ready(function(e){WP_Optimize=WP_Optimize(wp_optimize_send_command_admin_ajax)});var WP_Optimize=function(send_command){function enable_or_disable_schedule_options(){if($("#enable-schedule").length){var e=$("#enable-schedule").is(":checked");e?$("#wp-optimize-auto-options").css("opacity","1"):$("#wp-optimize-auto-options").css("opacity","0.5")}}function temporarily_display_notice(e,t,i){t="undefined"==typeof t?"#wp-optimize-wrap":t,i="undefined"==typeof i?15:i,$(e).hide().prependTo(t).slideDown("fast").delay(1e3*i).slideUp("fast",function(){$(this).remove()})}function enable_or_disable_feature(e,t){var i={type:e,enable:t?1:0};$("#"+e+"_spinner").show(),send_command("enable_or_disable_feature",i,function(t){if($("#"+e+"_spinner").hide(),t&&t.hasOwnProperty("output"))for(var i=0,o=t.output.length;i<o;i++){var n='<div class="updated"><p>'+t.output[i]+"</p></div>";temporarily_display_notice(n,"#"+e+"_notice")}})}function toggle_mobile_menu(e){e?$("#wp-optimize-wrap").addClass("wpo-mobile-menu-opened"):$("#wp-optimize-wrap").removeClass("wpo-mobile-menu-opened")}function gather_settings(e){var t="",e="undefined"==typeof e?"string":e;return"object"==e?t=$("#wp-optimize-general-settings form input[name!='action'], #wp-optimize-general-settings form textarea, #wp-optimize-general-settings form select, #wp-optimize-nav-tab-contents-optimize input[type='checkbox'], .wp-optimize-nav-tab-contents input[name^='enable-auto-backup-']").serializeJSON({useIntKeysAsArrayIndex:!0}):(t=$("#wp-optimize-general-settings form input[name!='action'], #wp-optimize-general-settings form textarea, #wp-optimize-general-settings form select, #wp-optimize-nav-tab-contents-optimize input[type='checkbox'], .wp-optimize-nav-tab-contents input[name^='enable-auto-backup-']").serialize(),$.each($('#wp-optimize-general-settings form input[type=checkbox], .wp-optimize-nav-tab-contents input[name^="enable-auto-backup-"]').filter(function(e){return 0==$(this).prop("checked")}),function(e,i){var o="0";t+="&"+$(i).attr("name")+"="+o})),t}function process_done(){send_command("optimizations_done",{},function(){})}function process_queue(){if(!queue.get_lock())return void(debug_level>0&&console.log("WP-Optimize: process_queue(): queue is currently locked - exiting"));debug_level>0&&console.log("WP-Optimize: process_queue(): got queue lock");var e=queue.peek();return"object"==typeof e?(data=e,e=e.optimization_id):data={},"undefined"==typeof e?(debug_level>0&&console.log("WP-Optimize: process_queue(): queue is apparently empty - exiting"),queue.unlock(),void process_done()):(debug_level>0&&console.log("WP-Optimize: process_queue(): processing item: "+e),queue.dequeue(),$(document).trigger(["do_optimization_",e,"_start"].join("")),void send_command("do_optimization",{optimization_id:e,data:data},function(t){if($("#optimization_spinner_"+e).hide(),$("#optimization_checkbox_"+e).show(),$(".optimization_button_"+e).prop("disabled",!1),$(document).trigger(["do_optimization_",e,"_done"].join(""),t),t){for(var i="",o=0,n=t.errors.length;o<n;o++)i+='<span class="error">'+t.errors[o]+"</span><br>";for(var o=0,n=t.messages.length;o<n;o++)i+=t.errors[o]+"<br>";for(var o=0,n=t.result.output.length;o<n;o++)i+=t.result.output[o]+"<br>";if($("#optimization_info_"+e).html(i),t.hasOwnProperty("status_box_contents")&&$("#wp_optimize_status_box").css("opacity","1").find(".inside").html(t.status_box_contents),t.hasOwnProperty("table_list")&&$("#wpoptimize_table_list tbody").html($(t.table_list).find("tbody").html()),t.hasOwnProperty("total_size")&&$("#optimize_current_db_size").html(t.total_size),"optimizetables"==e&&data.optimization_table&&(queue.is_empty()?($("#optimization_spinner_"+e).hide(),$("#optimization_checkbox_"+e).show(),$(".optimization_button_"+e).prop("disabled",!1),$("#optimization_info_"+e).html(wpoptimize.optimization_complete)):($("#optimization_checkbox_"+e).hide(),$("#optimization_spinner_"+e).show(),$(".optimization_button_"+e).prop("disabled",!0))),t.result.meta&&t.result.meta.hasOwnProperty("awaiting_mod")){var s=t.result.meta.awaiting_mod;s>0?$("#adminmenu .awaiting-mod .pending-count").remove(s):$("#adminmenu .awaiting-mod").remove()}}setTimeout(function(){queue.unlock(),process_queue()},10)}))}function do_optimization(e){var t=$("#wp-optimize-nav-tab-contents-optimize .wp-optimize-settings-"+e);t||console.log("do_optimization: row corresponding to this optimization ("+e+") not found");var i={},o=0;if($('input[type="checkbox"]',$("#optimization_info_"+e)).each(function(){var e=$(this);e.is(":checked")&&(i[e.attr("name")]=e.val(),o++)}),1!=$(".optimization_button_"+e).prop("disabled")){if($("#optimization_checkbox_"+e).hide(),$("#optimization_spinner_"+e).show(),$(".optimization_button_"+e).prop("disabled",!0),$("#optimization_info_"+e).html("..."),"optimizetables"==e){var n=$("#wpoptimize_table_list #the-list tr");$(n).each(function(t){var i=$(this).find("td");if(table_type=i.eq(5).text(),table=i.eq(1).text(),optimizable=i.eq(5).data("optimizable"),""!=table&&("1"==optimizable||optimization_force)){var o={optimization_id:e,optimization_table:i.eq(1).text(),optimization_table_type:table_type,optimization_force:optimization_force};queue.enqueue(o)}})}else if(o>0){data={optimization_id:e};for(var s in i)i.hasOwnProperty(s)&&(data[s]=i[s]);queue.enqueue(data)}else queue.enqueue(e);process_queue()}}function save_sites_list_and_do_action(e){$("#wpo_settings_sites_list").length?send_command("save_site_settings",{"wpo-sites":get_selected_sites_list()},function(){e&&e()}):e&&e()}function get_selected_sites_list(){var e=[];return $('#wpo_settings_sites_list input[type="checkbox"]').each(function(){var t=$(this);t.is(":checked")&&e.push(t.attr("value"))}),e}function run_optimizations(){var e=!1;$("#enable-auto-backup").is(":checked")&&(e=!0),save_auto_backup_options(),1==e?take_a_backup_with_updraftplus(run_optimization):run_optimization()}function take_a_backup_with_updraftplus(e){"function"==typeof updraft_backupnow_inpage_go?updraft_backupnow_inpage_go(function(){$("#updraft-backupnow-inpage-modal").dialog("close"),e&&e()},"","autobackup",0,1,0,wpoptimize.automatic_backup_before_optimizations):e&&e()}function save_auto_backup_options(){var e=gather_settings("object");e.auto_backup=$("#enable-auto-backup").is(":checked"),send_command("save_auto_backup_option",e)}function define_moreoptions_settings(e,t,i,o){e.on("click",function(){return t.hasClass("wpo_always_visible")||t.toggleClass("wpo_hidden"),!1}),define_select_all_checkbox(i,o)}function define_select_all_checkbox(e,t){e.on("change",function(){e.is(":checked")?t.prop("checked",!0):t.prop("checked",!1),update_wpo_all_items_checkbox_state(e,t)}),t.on("change",function(){update_wpo_all_items_checkbox_state(e,t)}),update_wpo_all_items_checkbox_state(e,t)}function update_wpo_all_items_checkbox_state(e,t){var i=0,o=0;if(t.each(function(){$(this).is(":checked")&&o++,i++}),e.next().is("label")&&e.next().data("label")){var n=e.next(),s=n.data("label");i==o?n.text(s):n.text(s.replace("all",[o," of ",i].join("")))}i==o?e.prop("checked",!0):e.prop("checked",!1)}function run_optimization(){$optimizations=$("#optimizations_list .optimization_checkbox:checked"),$optimizations.sort(function(e,t){return e=$(e).closest(".wp-optimize-settings").data("optimization_run_sort_order"),t=$(t).closest(".wp-optimize-settings").data("optimization_run_sort_order"),e>t?1:e<t?-1:0});var e={};$optimizations.each(function(t){var i=$(this).closest(".wp-optimize-settings").data("optimization_id");return i?(e[i]={active:1},void do_optimization(i)):void console.log("Optimization ID corresponding to pressed button not found")}),send_command("save_manual_run_optimization_options",e)}function run_single_table_optimization(e){var t=e.next(),i=t.next(),o=e.data("table"),n=e.data("type"),s={optimization_id:"optimizetables",optimization_table:o,optimization_table_type:n};e.hide(),single_table_optimization_force.is(":checked")&&(s.optimization_force=!0),t.removeClass("visibility-hidden"),send_command("do_optimization",{optimization_id:"optimizetables",data:s},function(){e.prop("disabled",!1),t.addClass("visibility-hidden"),i.show().removeClass("visibility-hidden").delay(2500).fadeOut("fast",function(){e.show()})})}function update_single_table_optimization_buttons(e){$(".run-single-table-optimization").each(function(){var t=$(this);t.data("disabled")&&(e?t.prop("disabled",!1):t.prop("disabled",!0))})}function is_sites_selected(){return 0==wpo_settings_sites_list.length||0!=$('input[type="checkbox"]:checked',wpo_settings_sites_list).length}function update_optimizations_info_view(e){var t,i,o;if(e)for(t in e)e.hasOwnProperty(t)&&(i=["#wp-optimize-settings-",e[t].dom_id].join(""),o=e[t].info?e[t].info.join("<br>"):"",$(i+" .wp-optimize-settings-optimization-info").html(o))}function update_optimizations_info(){var e=["",get_selected_sites_list().join("_")].join("");get_optimizations_info_cache.hasOwnProperty(e)?update_optimizations_info_view(get_optimizations_info_cache[e]):send_command("get_optimizations_info",{"wpo-sites":get_selected_sites_list()},function(t){t&&(get_optimizations_info_cache[e]=t,update_optimizations_info_view(t))})}function import_settings(e){var t=$("#wpo_import_spinner"),i=$("#wpo_import_success_message"),o=$("#wpo_import_error_message");t.show(),send_command("import_settings",{settings:e},function(e){t.hide(),e&&e.errors&&e.errors.length?(o.text(e.errors.join("<br>")),o.slideDown()):e&&e.messages&&e.messages.length&&(i.text(e.messages.join("<br>")),i.slideDown(),setTimeout(function(){window.location.reload()},500)),$("#wpo_import_settings_btn").prop("disabled",!1)})}function wpo_download_json_file(e,t){var i=document.body.appendChild(document.createElement("a")),o=new Date,n=o.getFullYear(),s=o.getMonth()<10?["0",o.getMonth()].join(""):o.getMonth(),a=o.getDay()<10?["0",o.getDay()].join(""):o.getDay();t=t?t:["wpo-settings-",n,"-",s,"-",a,".json"].join(""),i.setAttribute("download",t),i.setAttribute("style","display:none;"),i.setAttribute("href","data:text/json;charset=UTF-8,"+encodeURIComponent(JSON.stringify(e))),i.click()}function remove_single_db_table(e){var t=e.next(),i=t.next(),o=e.data("table"),n={optimization_id:"orphanedtables",optimization_table:o};t.removeClass("visibility-hidden"),send_command("do_optimization",{optimization_id:"orphanedtables",data:n},function(n){if(n.result.meta.success){var s=e.closest("tr");e.prop("disabled",!1),t.addClass("visibility-hidden"),i.show().removeClass("visibility-hidden"),setTimeout(function(){s.fadeOut("slow",function(){s.remove(),change_actions_column_visibility()})},500)}else e.prop("disabled",!1),t.addClass("visibility-hidden"),alert(wpoptimize.table_was_not_deleted.replace("%s",o))})}function change_actions_column_visibility(){var e=$("#wpoptimize_table_list"),t=!0;$("tr",e).each(function(){var e=$(this);if($("button",e).length>0)return t=!1,!1}),$("tr",e).each(function(){var e=$(this);t?$("td:last, th:last",e).hide():$("td:last, th:last",e).show()})}function validate_logger_settings(){var e=!0;return $(".wpo_logger_addition_option, .wpo_logger_type").each(function(){validate_field($(this),!0)?$(this).removeClass("wpo_error_field"):(e=!1,$(this).addClass("wpo_error_field"))}),e?$("#wp-optimize-logger-settings .save_settings_reminder").slideUp():$("#wp-optimize-settings-save-results").show().addClass("wpo_alert_notice").text(wpoptimize.fill_all_settings_fields).delay(5e3).fadeOut(3e3,function(){$(this).removeClass("wpo_alert_notice")}),e}function validate_field(e,t){var i=e.val(),o=e.data("validate");if(!o&&t)return""!=$.trim(i);if(o&&!t&&""==$.trim(i))return!0;var n=!0;switch(o){case"email":for(var s=/\S+@\S+\.\S+/,a=i.split(","),_="",p=0;p<a.length;p++)_=$.trim(a[p]),""!=_&&s.test(_)||(n=!1);break;case"url":var s=/^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,}))\.?)(?::\d{2,5})?(?:[\/?#]\S*)?$/i;n=s.test(i)}return n}var $=jQuery,debug_level=0,queue=new Updraft_Queue;define_select_all_checkbox($("#select_all_optimizations"),$("#optimizations_list .optimization_checkbox")),enable_or_disable_schedule_options(),$("#enable-schedule").change(function(){enable_or_disable_schedule_options()});var table_list_filter=$("#wpoptimize_table_list_filter"),table_list=$("#wpoptimize_table_list"),table_footer_line=$("#wpoptimize_table_list tbody:last"),tables_not_found=$("#wpoptimize_table_list_tables_not_found");$(function(){$.tablesorter.addParser({id:"sizes",is:function(e){return!1},format:function(s){var kb=1024,mb=1024*kb,gb=1024*mb;return eval(s.toLowerCase().replace(/kb/,["* ",kb].join("")).replace(/mb/,["* ",mb].join("")).replace(/gb/,["* ",gb].join("")).replace(/[^0-9\.\*\s]/g,""))},type:"numeric"}),table_list.tablesorter({theme:"default",widgets:["zebra","rows","filter"],cssInfoBlock:"tablesorter-no-sort",headers:{2:{sorter:"digit"},3:{sorter:"sizes"},4:{sorter:"sizes"},7:{sorter:!1}},widgetOptions:{filter_external:table_list_filter,filter_defaultFilter:{2:"~{query}"}}}),table_list.on("filterEnd",function(){var e=$.trim(table_list_filter.val());""==e?table_footer_line.show():table_footer_line.hide(),0==$("#the-list tr:visible",table_list).length?tables_not_found.show():tables_not_found.hide()})}),$("#wp-optimize-disable-enable-trackbacks-enable").click(function(){enable_or_disable_feature("trackbacks",!0)}),$("#wp-optimize-disable-enable-trackbacks-disable").click(function(){enable_or_disable_feature("trackbacks",!1)}),$("#wp-optimize-disable-enable-comments-enable").click(function(){enable_or_disable_feature("comments",!0)}),$("#wp-optimize-disable-enable-comments-disable").click(function(){enable_or_disable_feature("comments",!1)}),$(".wpo-pages-menu").on("click","a",function(e){e.preventDefault(),$(this).is(".active")||($(".wpo-pages-menu a.active").removeClass("active"),$(".wpo-page.active").removeClass("active"),$(this).addClass("active"),$('.wpo-page[data-whichpage="'+$(this).data("menuslug")+'"]').addClass("active"),window.scroll(0,0)),$("#wp-optimize-nav-page-menu").trigger("click")}),$(".nav-tab-wrapper .nav-tab").click(function(e){e.preventDefault();var t=$(this).attr("id"),i=$(this).closest(".nav-tab-wrapper");if(t){if(toggle_mobile_menu(!1),$(this).is('[role="toggle-menu"]'))return void toggle_mobile_menu(!0);i.find(".nav-tab:not(#wp-optimize-nav-tab-"+t+")").removeClass("nav-tab-active"),$(this).addClass("nav-tab-active"),$(this).closest(".wpo-page").find(".wp-optimize-nav-tab-contents").hide(),$("#"+t+"-contents").show()}}),$("#wp-optimize-nav-page-menu").on("click",function(e){e.preventDefault(),$(this).toggleClass("opened")}),$("#wp-optimize-nav-tab-wpo_database-optimize-contents").on("click","button.wp-optimize-settings-optimization-run-button",function(){var e=$(this).closest(".wp-optimize-settings").data("optimization_id");return e?void(1!=$(".optimization_button_"+e).prop("disabled")&&($(".optimization_button_"+e).prop("disabled",!0),save_sites_list_and_do_action(function(){$(".optimization_button_"+e).prop("disabled",!1),do_optimization(e)}))):void console.log("Optimization ID corresponding to pressed button not found")}),$("#wp-optimize-nav-tab-wpo_database-optimize-contents").on("click","#wp-optimize",function(e){var t=$(this);e.preventDefault(),t.prop("disabled",!0),save_sites_list_and_do_action(function(){t.prop("disabled",!1),run_optimizations()})});var browser_cache_enable_btn=$("#wp_optimize_browser_cache_enable");browser_cache_enable_btn.closest("form").submit(function(e){return e.preventDefault(),browser_cache_enable_btn.trigger("click"),!1}),$("#wp_optimize_gzip_compression_enable").on("click",function(){var e=$(this),t=e.next();t.show(),send_command("enable_gzip_compression",{enable:e.data("enable")},function(i){var o=$("#wpo_gzip_compression_status");i?(i.enabled?(e.text(wpoptimize.disable),e.data("enable","0"),o.removeClass("wpo-disabled").addClass("wpo-enabled")):(e.text(wpoptimize.enable),e.data("enable","1"),o.addClass("wpo-disabled").removeClass("wpo-enabled")),i.message?$("#wpo_gzip_compression_error_message").text(i.message).show():$("#wpo_gzip_compression_error_message").hide(),i.output?$("#wpo_gzip_compression_output").html(i.output).show():$("#wpo_gzip_compression_output").hide()):alert(wpoptimize.error_unexpected_response),t.hide()}).fail(function(){alert(wpoptimize.error_unexpected_response),t.hide()})}),browser_cache_enable_btn.on("click",function(){var e=$("#wpo_browser_cache_expire_days"),t=$("#wpo_browser_cache_expire_hours"),i=parseInt(e.val(),10),o=parseInt(t.val(),10),n=$(this),s=n.next();return isNaN(i)&&(i=0),isNaN(o)&&(o=0),i<0||o<0?($("#wpo_browser_cache_error_message").text(wpoptimize.please_use_positive_integers).show(),!1):o>23?($("#wpo_browser_cache_error_message").text(wpoptimize.please_use_valid_values).show(),!1):($("#wpo_browser_cache_error_message").hide(),e.val(i),t.val(o),s.show(),void send_command("enable_browser_cache",{browser_cache_expire_days:i,browser_cache_expire_hours:o},function(e){var t=$("#wpo_browser_cache_status");e?(e.enabled?(n.text(wpoptimize.update),t.removeClass("wpo-disabled").addClass("wpo-enabled")):(n.text(wpoptimize.enable),t.addClass("wpo-disabled").removeClass("wpo-enabled")),e.message?$("#wpo_browser_cache_message").text(e.message).show():$("#wpo_browser_cache_message").hide(),e.error_message?$("#wpo_browser_cache_error_message").text(e.error_message).show():$("#wpo_browser_cache_error_message").hide(),e.output?$("#wpo_browser_cache_output").html(e.output).show():$("#wpo_browser_cache_output").hide()):alert(wpoptimize.error_unexpected_response),s.hide()}).fail(function(){alert(wpoptimize.error_unexpected_response),s.hide()}))});var wpo_settings_sites_list=$("#wpo_settings_sites_list"),wpo_settings_sites_list_ul=wpo_settings_sites_list.find("ul").first(),wpo_settings_sites_list_items=$('input[type="checkbox"]',wpo_settings_sites_list_ul),wpo_settings_all_sites_checkbox=wpo_settings_sites_list.find("#wpo_all_sites"),wpo_sitelist_show_moreoptions_link=$("#wpo_sitelist_show_moreoptions"),wpo_sitelist_moreoptions_div=$("#wpo_sitelist_moreoptions"),wpo_settings_sites_list_cron=$("#wpo_settings_sites_list_cron"),wpo_settings_sites_list_cron_ul=wpo_settings_sites_list_cron.find("ul").first(),wpo_settings_sites_list_cron_items=$('input[type="checkbox"]',wpo_settings_sites_list_cron_ul),wpo_settings_all_sites_cron_checkbox=wpo_settings_sites_list_cron.find("#wpo_all_sites_cron"),wpo_sitelist_show_moreoptions_cron_link=$("#wpo_sitelist_show_moreoptions_cron"),wpo_sitelist_moreoptions_cron_div=$("#wpo_sitelist_moreoptions_cron");define_moreoptions_settings(wpo_sitelist_show_moreoptions_link,wpo_sitelist_moreoptions_div,wpo_settings_all_sites_checkbox,wpo_settings_sites_list_items);var sites_list_clicked_count=0;$([wpo_settings_all_sites_checkbox,wpo_settings_sites_list_items]).each(function(){$(this).on("change",function(){sites_list_clicked_count++,setTimeout(function(){sites_list_clicked_count--,0==sites_list_clicked_count&&update_optimizations_info()},1e3)})}),define_moreoptions_settings(wpo_sitelist_show_moreoptions_cron_link,wpo_sitelist_moreoptions_cron_div,wpo_settings_all_sites_cron_checkbox,wpo_settings_sites_list_cron_items),$("#wp_optimize_table_list_refresh").click(function(e){e.preventDefault(),$("#wpoptimize_table_list tbody").css("opacity","0.5"),send_command("get_table_list",!1,function(e){if(e.hasOwnProperty("table_list")){var t=!0,i=function(e){$("#wpoptimize_table_list tbody").css("opacity","1")};$("#wpoptimize_table_list").trigger("updateAll",[t,i])}e.hasOwnProperty("total_size")&&$("#optimize_current_db_size").html(e.total_size),update_single_table_optimization_buttons(single_table_optimization_force.is(":checked"))})}),$("#settings_form").on("click","#wp-optimize-settings-save",function(e){if(e.preventDefault(),!validate_logger_settings())return!1;console.log("What?"),$("#save_spinner").show();var t=gather_settings();send_command("save_settings",t,function(e){if($("#save_spinner").hide(),$("#save_done").show().delay(5e3).fadeOut(),e&&e.hasOwnProperty("save_results")&&e.save_results&&e.save_results.hasOwnProperty("errors")){for(var t=0,i=e.save_results.errors.length;t<i;t++){var o='<div class="error">'+e.errors[t]+"</div>";temporarily_display_notice(o,"#wp-optimize-settings-save-results")}console.log(e.save_results.messages)}e&&e.hasOwnProperty("status_box_contents")&&$("#wp_optimize_status_box .inside").html(e.status_box_contents),e&&e.hasOwnProperty("optimizations_table")&&$("#optimizations_list").replaceWith(e.optimizations_table),e.save_results.refresh&&location.reload()})}),$("#wp_optimize_status_box").on("click","#wp_optimize_status_box_refresh",function(e){e.preventDefault(),$("#wp_optimize_status_box").css("opacity","0.5"),send_command("get_status_box_contents",null,function(e){$("#wp_optimize_status_box").css("opacity","1").find(".inside").html(e)})});var optimization_force_checkbox=$("#innodb_force_optimize"),optimization_force=optimization_force_checkbox.is(":checked"),optimization_row=optimization_force_checkbox.closest("tr"),single_table_optimization_force=$("#innodb_force_optimize_single");optimization_force_checkbox.on("change",function(){$('button, input[type="checkbox"]',optimization_row).each(function(){optimization_force=optimization_force_checkbox.is(":checked");var e=$(this);e.data("disabled")&&(optimization_force?e.prop("disabled",!1):e.prop("disabled",!0))})}),$("#wpoptimize_table_list").on("click",".run-single-table-optimization",function(){var e=$("#enable-auto-backup-1");e.is(":checked")?take_a_backup_with_updraftplus(run_single_table_optimization($(this))):run_single_table_optimization($(this))}),single_table_optimization_force.change(function(){update_single_table_optimization_buttons(single_table_optimization_force.is(":checked"))}),update_single_table_optimization_buttons(single_table_optimization_force.is(":checked"));var get_optimizations_info_cache={};setTimeout(function(){send_command("check_overdue_crons",null,function(e){e&&e.hasOwnProperty("m")&&$("#wpo_settings_warnings").append(e.m)})},11e3),$("#wpo_import_settings_btn").on("click",function(e){var t=$("#wpo_import_settings_file"),i=t.val(),o=t[0].files[0],n=new FileReader;return $("#wpo_import_settings_btn").prop("disabled",!0),/\.json$/.test(i)?(n.onload=function(){import_settings(this.result)},n.readAsText(o),!1):(e.preventDefault(),$("#wpo_import_settings_btn").prop("disabled",!1),$("#wpo_import_error_message").text(wpoptimize.please_select_settings_file).slideDown(),!1)}),$("#wpo_import_settings_file").on("change",function(){$("#wpo_import_error_message").slideUp()}),$("#wpo_export_settings_btn").on("click",function(e){return wpo_download_json_file(gather_settings("object")),!1});var optimization_get_info=function(e,t,i){return send_command("get_optimization_info",{optimization_id:t,data:i},function(i){var o=i&&i.result&&i.result.meta?i.result.meta:{},n=i&&i.result&&i.result.output?i.result.output.join("<br>"):"...";$(document).trigger(["optimization_get_info_",t].join(""),n),e.html(n),o.finished?$(document).trigger(["optimization_get_info_",t,"_done"].join(""),i):setTimeout(function(){optimization_get_info(e,t,o)},1)})};return $(document).ready(function(){$(".wp-optimize-optimization-info-ajax").each(function(){var e=$(this),t=e.parent(),i=e.data("id");$(document).trigger(["optimization_get_info_",i,"_start"].join("")),optimization_get_info(t,i,{support_ajax_get_info:!0})})}),$("#wpoptimize_table_list").on("click",".run-single-table-repair",function(){var e=$(this),t=e.next(),i=t.next(),o=e.data("table"),n={optimization_id:"repairtables",optimization_table:o};t.removeClass("visibility-hidden"),send_command("do_optimization",{optimization_id:"repairtables",data:n},function(n){if(n.result.meta.success){var s=e.closest("tr"),a=n.result.meta.tableinfo;e.prop("disabled",!1),t.addClass("visibility-hidden"),i.show().removeClass("visibility-hidden"),$("td:eq(2)",s).text(a.rows),$("td:eq(3)",s).text(a.data_size),$("td:eq(4)",s).text(a.index_size),$("td:eq(5)",s).text(a.type),a.is_optimizable?$("td:eq(6)",s).html(['<span color="',a.overhead>0?"#0000FF":"#004600",'">',a.overhead,"</span>"].join("")):$("td:eq(6)",s).html('<span color="#0000FF">-</span>'),setTimeout(function(){var t=e.closest("td"),i=e.closest(".wpo_button_wrap");i.fadeOut("fast",function(){i.closest(".wpo_button_wrap").remove(),a.is_optimizable&&$(".wpo_button_wrap",t).removeClass("wpo_hidden")}),change_actions_column_visibility()},1e3)}else e.prop("disabled",!1),t.addClass("visibility-hidden"),alert(wpoptimize.table_was_not_repaired.replace("%s",o))})}),$("#wpoptimize_table_list").on("click",".run-single-table-delete",function(){if(!confirm(wpoptimize.are_you_sure_you_want_to_remove_this_table))return!1;var e=$("#enable-auto-backup-1");e.is(":checked")?take_a_backup_with_updraftplus(remove_single_db_table($(this))):e()}),change_actions_column_visibility(),setTimeout(function(){send_command("check_overdue_crons",null,function(e){e&&e.hasOwnProperty("m")&&$("#wpo_settings_warnings").append(e.m)})},11e3),{send_command:send_command,optimization_get_info:optimization_get_info,take_a_backup_with_updraftplus:take_a_backup_with_updraftplus,save_auto_backup_options:save_auto_backup_options}};jQuery(document).ready(function(e){function t(t){var i=["#",t.data("additional")].join("");t.is(":checked")?e(i).show():e(i).hide()}function i(){var t=e("#wp-optimize-logger-settings .save_settings_reminder");t.is(":visible")||t.slideDown("normal")}function o(){e(".wpo_logger_type").each(function(){n(e(this))})}function n(t){var i,o,n=s();for(i in n)o=n[i],wpoptimize.loggers_classes_info[o].allow_multiple?e('option[value="'+o+'"]',t).show():e('option[value="'+o+'"]',t).hide()}function s(){var t=[];return e(".wpo_logging_row, .wpo_logger_type").each(function(){var i=e(this).is("select")?e(this).val():e(this).data("id");i&&t.push(i)}),t}function a(){var e,t=['<option value="">Select destination</option>'];for(e in wpoptimize.loggers_classes_info)wpoptimize.loggers_classes_info.hasOwnProperty(e)&&wpoptimize.loggers_classes_info[e].available&&t.push(['<option value="',e,'">',wpoptimize.loggers_classes_info[e].description,"</option>"].join(""));return['<div class="wpo_add_logger_form">','<select class="wpo_logger_type" name="wpo-logger-type[]">',t.join(""),"<select>",'<a href="#" class="wpo_delete_logger dashicons dashicons-no-alt"></a>','<div class="wpo_additional_logger_options"></div>',"</div>"].join("")}function _(t){if(!wpoptimize.loggers_classes_info[t].options)return"";var i,o=wpoptimize.loggers_classes_info[t].options,n=[],s="",a="";for(i in o)o.hasOwnProperty(i)&&(e.isArray(o[i])?(s=e.trim(o[i][0]),a=e.trim(o[i][1])):(s=e.trim(o[i]),a=""),n.push(['<input class="wpo_logger_addition_option" type="text" name="wpo-logger-options[',i,'][]" value="" ','placeholder="',s,'" ',""!==a?'data-validate="'+a+'"':"","/>"].join("")));return n.push('<input type="hidden" name="wpo-logger-options[active][]" value="1" />'),n.join("")}e(".wp-optimize-logging-settings").each(function(){var i=e(this);t(i),i.on("change",function(){t(i)})});var p=e("#wpo_add_logger_link");p.on("click",function(t){t.preventDefault(),e("#wp-optimize-logger-settings .save_settings_reminder").after(a()),n(e(".wpo_logger_type").first())}),e("#wp-optimize-general-settings").on("change",".wpo_logger_type",function(){var t=e(this),o=t.val(),n=t.parent().find(".wpo_additional_logger_options");n.html(_(o)),t.val()&&i()}),e(".wpo_logging_actions_row .dashicons-edit").on("click",function(){var t=e(this),i=t.closest(".wpo_logging_row");return e(".wpo_additional_logger_options",i).removeClass("wpo_hidden"),e(".wpo_logging_options_row",i).text(""),e(".wpo_logging_status_row",i).text(""),t.hide(),!1}),e("#wp-optimize-logger-settings").on("change",".wpo_logger_addition_option",function(){i()}),e(".wpo_logger_active_checkbox").on("change",function(){var t=e(this),i=t.closest("label").find('input[type="hidden"]');i.val(t.is(":checked")?"1":"0")}),e("#wp-optimize-general-settings").on("click",".wpo_delete_logger",function(){if(!confirm(wpoptimize.are_you_sure_you_want_to_remove_logging_destination))return!1;var t=e(this);return t.closest(".wpo_logging_row, .wpo_add_logger_form").remove(),o(),0==e("#wp-optimize-logging-options .wpo_logging_row").length&&e("#wp-optimize-logging-options").hide(),i(),!1});var r=!1;e(window).on("scroll",function(t){window.requestAnimationFrame(function(){var t=e(".wpo-main-header").length?e(".wpo-main-header")[0].offsetTop:0;window.pageYOffset>t-20!=r&&(r=!r,e("body").toggleClass("is-scrolled",r))})})});
1
+ wp_optimize_send_command_admin_ajax=function(e,t,i,o){o="undefined"==typeof o||o;var n={action:"wp_optimize_ajax",subaction:e,nonce:wp_optimize_ajax_nonce,data:t};return jQuery.post(ajaxurl,n,function(e){if(o){try{var t=JSON.parse(e)}catch(n){return console.log(n),console.log(e),void alert(wpoptimize.error_unexpected_response)}"undefined"!=typeof i&&i(t)}else"undefined"!=typeof i&&i(e)})},jQuery(document).ready(function(e){WP_Optimize=WP_Optimize(wp_optimize_send_command_admin_ajax)});var WP_Optimize=function(send_command){function enable_or_disable_schedule_options(){if($("#enable-schedule").length){var e=$("#enable-schedule").is(":checked");e?$("#wp-optimize-auto-options").css("opacity","1"):$("#wp-optimize-auto-options").css("opacity","0.5")}}function temporarily_display_notice(e,t,i){t="undefined"==typeof t?"#wp-optimize-wrap":t,i="undefined"==typeof i?15:i,$(e).hide().prependTo(t).slideDown("fast").delay(1e3*i).slideUp("fast",function(){$(this).remove()})}function enable_or_disable_feature(e,t){var i={type:e,enable:t?1:0};$("#"+e+"_spinner").show(),send_command("enable_or_disable_feature",i,function(t){if($("#"+e+"_spinner").hide(),t&&t.hasOwnProperty("output"))for(var i=0,o=t.output.length;i<o;i++){var n='<div class="updated"><p>'+t.output[i]+"</p></div>";temporarily_display_notice(n,"#"+e+"_notice")}})}function toggle_mobile_menu(e){e?$("#wp-optimize-wrap").addClass("wpo-mobile-menu-opened"):$("#wp-optimize-wrap").removeClass("wpo-mobile-menu-opened")}function gather_settings(e){var t="",e="undefined"==typeof e?"string":e;return"object"==e?t=$("#wp-optimize-general-settings form input[name!='action'], #wp-optimize-general-settings form textarea, #wp-optimize-general-settings form select, #wp-optimize-nav-tab-contents-optimize input[type='checkbox'], .wp-optimize-nav-tab-contents input[name^='enable-auto-backup-']").serializeJSON({useIntKeysAsArrayIndex:!0}):(t=$("#wp-optimize-general-settings form input[name!='action'], #wp-optimize-general-settings form textarea, #wp-optimize-general-settings form select, #wp-optimize-nav-tab-contents-optimize input[type='checkbox'], .wp-optimize-nav-tab-contents input[name^='enable-auto-backup-']").serialize(),$.each($('#wp-optimize-general-settings form input[type=checkbox], .wp-optimize-nav-tab-contents input[name^="enable-auto-backup-"]').filter(function(e){return 0==$(this).prop("checked")}),function(e,i){var o="0";t+="&"+$(i).attr("name")+"="+o})),t}function process_done(){send_command("optimizations_done",{},function(){})}function process_queue(){if(!queue.get_lock())return void(debug_level>0&&console.log("WP-Optimize: process_queue(): queue is currently locked - exiting"));debug_level>0&&console.log("WP-Optimize: process_queue(): got queue lock");var e=queue.peek();return"object"==typeof e?(data=e,e=e.optimization_id):data={},"undefined"==typeof e?(debug_level>0&&console.log("WP-Optimize: process_queue(): queue is apparently empty - exiting"),queue.unlock(),void process_done()):(debug_level>0&&console.log("WP-Optimize: process_queue(): processing item: "+e),queue.dequeue(),$(document).trigger(["do_optimization_",e,"_start"].join("")),void send_command("do_optimization",{optimization_id:e,data:data},function(t){if($("#optimization_spinner_"+e).hide(),$("#optimization_checkbox_"+e).show(),$(".optimization_button_"+e).prop("disabled",!1),$(document).trigger(["do_optimization_",e,"_done"].join(""),t),t){for(var i="",o=0,n=t.errors.length;o<n;o++)i+='<span class="error">'+t.errors[o]+"</span><br>";for(var o=0,n=t.messages.length;o<n;o++)i+=t.errors[o]+"<br>";for(var o=0,n=t.result.output.length;o<n;o++)i+=t.result.output[o]+"<br>";if($("#optimization_info_"+e).html(i),t.hasOwnProperty("status_box_contents")&&$("#wp_optimize_status_box").css("opacity","1").find(".inside").html(t.status_box_contents),t.hasOwnProperty("table_list")&&$("#wpoptimize_table_list tbody").html($(t.table_list).find("tbody").html()),t.hasOwnProperty("total_size")&&$("#optimize_current_db_size").html(t.total_size),"optimizetables"==e&&data.optimization_table&&(queue.is_empty()?($("#optimization_spinner_"+e).hide(),$("#optimization_checkbox_"+e).show(),$(".optimization_button_"+e).prop("disabled",!1),$("#optimization_info_"+e).html(wpoptimize.optimization_complete)):($("#optimization_checkbox_"+e).hide(),$("#optimization_spinner_"+e).show(),$(".optimization_button_"+e).prop("disabled",!0))),t.result.meta&&t.result.meta.hasOwnProperty("awaiting_mod")){var s=t.result.meta.awaiting_mod;s>0?$("#adminmenu .awaiting-mod .pending-count").remove(s):$("#adminmenu .awaiting-mod").remove()}}setTimeout(function(){queue.unlock(),process_queue()},10)}))}function do_optimization(e){var t=$("#wp-optimize-nav-tab-contents-optimize .wp-optimize-settings-"+e);t||console.log("do_optimization: row corresponding to this optimization ("+e+") not found");var i={},o=0;if($('input[type="checkbox"]',$("#optimization_info_"+e)).each(function(){var e=$(this);e.is(":checked")&&(i[e.attr("name")]=e.val(),o++)}),1!=$(".optimization_button_"+e).prop("disabled")){if($("#optimization_checkbox_"+e).hide(),$("#optimization_spinner_"+e).show(),$(".optimization_button_"+e).prop("disabled",!0),$("#optimization_info_"+e).html("..."),"optimizetables"==e){var n=$("#wpoptimize_table_list #the-list tr");$(n).each(function(t){var i=$(this).find("td");if(table_type=i.eq(5).text(),table=i.eq(1).data("tablename"),optimizable=i.eq(5).data("optimizable"),""!=table&&("1"==optimizable||optimization_force)){var o={optimization_id:e,optimization_table:table,optimization_table_type:table_type,optimization_force:optimization_force};queue.enqueue(o)}})}else if(o>0){data={optimization_id:e};for(var s in i)i.hasOwnProperty(s)&&(data[s]=i[s]);queue.enqueue(data)}else queue.enqueue(e);process_queue()}}function save_sites_list_and_do_action(e){$("#wpo_settings_sites_list").length?send_command("save_site_settings",{"wpo-sites":get_selected_sites_list()},function(){e&&e()}):e&&e()}function get_selected_sites_list(){var e=[];return $('#wpo_settings_sites_list input[type="checkbox"]').each(function(){var t=$(this);t.is(":checked")&&e.push(t.attr("value"))}),e}function run_optimizations(){var e=!1;$("#enable-auto-backup").is(":checked")&&(e=!0),save_auto_backup_options(),1==e?take_a_backup_with_updraftplus(run_optimization):run_optimization()}function take_a_backup_with_updraftplus(e){"function"==typeof updraft_backupnow_inpage_go?updraft_backupnow_inpage_go(function(){$("#updraft-backupnow-inpage-modal").dialog("close"),e&&e()},"","autobackup",0,1,0,wpoptimize.automatic_backup_before_optimizations):e&&e()}function save_auto_backup_options(){var e=gather_settings("object");e.auto_backup=$("#enable-auto-backup").is(":checked"),send_command("save_auto_backup_option",e)}function define_moreoptions_settings(e,t,i,o){e.on("click",function(){return t.hasClass("wpo_always_visible")||t.toggleClass("wpo_hidden"),!1}),define_select_all_checkbox(i,o)}function define_select_all_checkbox(e,t){e.on("change",function(){e.is(":checked")?t.prop("checked",!0):t.prop("checked",!1),update_wpo_all_items_checkbox_state(e,t)}),t.on("change",function(){update_wpo_all_items_checkbox_state(e,t)}),update_wpo_all_items_checkbox_state(e,t)}function update_wpo_all_items_checkbox_state(e,t){var i=0,o=0;if(t.each(function(){$(this).is(":checked")&&o++,i++}),e.next().is("label")&&e.next().data("label")){var n=e.next(),s=n.data("label");i==o?n.text(s):n.text(s.replace("all",[o," of ",i].join("")))}i==o?e.prop("checked",!0):e.prop("checked",!1)}function run_optimization(){$optimizations=$("#optimizations_list .optimization_checkbox:checked"),$optimizations.sort(function(e,t){return e=$(e).closest(".wp-optimize-settings").data("optimization_run_sort_order"),t=$(t).closest(".wp-optimize-settings").data("optimization_run_sort_order"),e>t?1:e<t?-1:0});var e={};$optimizations.each(function(t){var i=$(this).closest(".wp-optimize-settings").data("optimization_id");return i?(e[i]={active:1},void do_optimization(i)):void console.log("Optimization ID corresponding to pressed button not found")}),send_command("save_manual_run_optimization_options",e)}function run_single_table_optimization(e){var t=e.next(),i=t.next(),o=e.data("table"),n=e.data("type"),s={optimization_id:"optimizetables",optimization_table:o,optimization_table_type:n};e.hide(),single_table_optimization_force.is(":checked")&&(s.optimization_force=!0),t.removeClass("visibility-hidden"),send_command("do_optimization",{optimization_id:"optimizetables",data:s},function(){e.prop("disabled",!1),t.addClass("visibility-hidden"),i.show().removeClass("visibility-hidden").delay(2500).fadeOut("fast",function(){e.show()})})}function update_single_table_optimization_buttons(e){$(".run-single-table-optimization").each(function(){var t=$(this);t.data("disabled")&&(e?t.prop("disabled",!1):t.prop("disabled",!0))})}function is_sites_selected(){return 0==wpo_settings_sites_list.length||0!=$('input[type="checkbox"]:checked',wpo_settings_sites_list).length}function update_optimizations_info_view(e){var t,i,o;if(e)for(t in e)e.hasOwnProperty(t)&&(i=["#wp-optimize-settings-",e[t].dom_id].join(""),o=e[t].info?e[t].info.join("<br>"):"",$(i+" .wp-optimize-settings-optimization-info").html(o))}function update_optimizations_info(){var e=["",get_selected_sites_list().join("_")].join("");get_optimizations_info_cache.hasOwnProperty(e)?update_optimizations_info_view(get_optimizations_info_cache[e]):send_command("get_optimizations_info",{"wpo-sites":get_selected_sites_list()},function(t){t&&(get_optimizations_info_cache[e]=t,update_optimizations_info_view(t))})}function import_settings(e){var t=$("#wpo_import_spinner"),i=$("#wpo_import_success_message"),o=$("#wpo_import_error_message");t.show(),send_command("import_settings",{settings:e},function(e){t.hide(),e&&e.errors&&e.errors.length?(o.text(e.errors.join("<br>")),o.slideDown()):e&&e.messages&&e.messages.length&&(i.text(e.messages.join("<br>")),i.slideDown(),setTimeout(function(){window.location.reload()},500)),$("#wpo_import_settings_btn").prop("disabled",!1)})}function wpo_download_json_file(e,t){var i=document.body.appendChild(document.createElement("a")),o=new Date,n=o.getFullYear(),s=o.getMonth()<10?["0",o.getMonth()].join(""):o.getMonth(),a=o.getDay()<10?["0",o.getDay()].join(""):o.getDay();t=t?t:["wpo-settings-",n,"-",s,"-",a,".json"].join(""),i.setAttribute("download",t),i.setAttribute("style","display:none;"),i.setAttribute("href","data:text/json;charset=UTF-8,"+encodeURIComponent(JSON.stringify(e))),i.click()}function remove_single_db_table(e){var t=e.next(),i=t.next(),o=e.data("table"),n={optimization_id:"orphanedtables",optimization_table:o};t.removeClass("visibility-hidden"),send_command("do_optimization",{optimization_id:"orphanedtables",data:n},function(n){if(n.result.meta.success){var s=e.closest("tr");e.prop("disabled",!1),t.addClass("visibility-hidden"),i.show().removeClass("visibility-hidden"),setTimeout(function(){s.fadeOut("slow",function(){s.remove(),change_actions_column_visibility()})},500)}else e.prop("disabled",!1),t.addClass("visibility-hidden"),alert(wpoptimize.table_was_not_deleted.replace("%s",o))})}function change_actions_column_visibility(){var e=$("#wpoptimize_table_list"),t=!0;$("tr",e).each(function(){var e=$(this);if($("button",e).length>0)return t=!1,!1}),$("tr",e).each(function(){var e=$(this);t?$("td:last, th:last",e).hide():$("td:last, th:last",e).show()})}function validate_logger_settings(){var e=!0;return $(".wpo_logger_addition_option, .wpo_logger_type").each(function(){validate_field($(this),!0)?$(this).removeClass("wpo_error_field"):(e=!1,$(this).addClass("wpo_error_field"))}),e?$("#wp-optimize-logger-settings .save_settings_reminder").slideUp():$("#wp-optimize-settings-save-results").show().addClass("wpo_alert_notice").text(wpoptimize.fill_all_settings_fields).delay(5e3).fadeOut(3e3,function(){$(this).removeClass("wpo_alert_notice")}),e}function validate_field(e,t){var i=e.val(),o=e.data("validate");if(!o&&t)return""!=$.trim(i);if(o&&!t&&""==$.trim(i))return!0;var n=!0;switch(o){case"email":for(var s=/\S+@\S+\.\S+/,a=i.split(","),_="",p=0;p<a.length;p++)_=$.trim(a[p]),""!=_&&s.test(_)||(n=!1);break;case"url":var s=/^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,}))\.?)(?::\d{2,5})?(?:[\/?#]\S*)?$/i;n=s.test(i)}return n}var $=jQuery,debug_level=0,queue=new Updraft_Queue;define_select_all_checkbox($("#select_all_optimizations"),$("#optimizations_list .optimization_checkbox")),enable_or_disable_schedule_options(),$("#enable-schedule").change(function(){enable_or_disable_schedule_options()});var table_list_filter=$("#wpoptimize_table_list_filter"),table_list=$("#wpoptimize_table_list"),table_footer_line=$("#wpoptimize_table_list tbody:last"),tables_not_found=$("#wpoptimize_table_list_tables_not_found");$(function(){$.tablesorter.addParser({id:"sizes",is:function(e){return!1},format:function(s){var kb=1024,mb=1024*kb,gb=1024*mb;return eval(s.toLowerCase().replace(/kb/,["* ",kb].join("")).replace(/mb/,["* ",mb].join("")).replace(/gb/,["* ",gb].join("")).replace(/[^0-9\.\*\s]/g,""))},type:"numeric"}),table_list.tablesorter({theme:"default",widgets:["zebra","rows","filter"],cssInfoBlock:"tablesorter-no-sort",headers:{2:{sorter:"digit"},3:{sorter:"sizes"},4:{sorter:"sizes"},7:{sorter:!1}},widgetOptions:{filter_external:table_list_filter,filter_defaultFilter:{2:"~{query}"}}}),table_list.on("filterEnd",function(){var e=$.trim(table_list_filter.val());""==e?table_footer_line.show():table_footer_line.hide(),0==$("#the-list tr:visible",table_list).length?tables_not_found.show():tables_not_found.hide()})}),$("#wp-optimize-disable-enable-trackbacks-enable").click(function(){enable_or_disable_feature("trackbacks",!0)}),$("#wp-optimize-disable-enable-trackbacks-disable").click(function(){enable_or_disable_feature("trackbacks",!1)}),$("#wp-optimize-disable-enable-comments-enable").click(function(){enable_or_disable_feature("comments",!0)}),$("#wp-optimize-disable-enable-comments-disable").click(function(){enable_or_disable_feature("comments",!1)}),$(".wpo-pages-menu").on("click","a",function(e){e.preventDefault(),$(this).is(".active")||($(".wpo-pages-menu a.active").removeClass("active"),$(".wpo-page.active").removeClass("active"),$(this).addClass("active"),$('.wpo-page[data-whichpage="'+$(this).data("menuslug")+'"]').addClass("active"),window.scroll(0,0)),$("#wp-optimize-nav-page-menu").trigger("click")}),$(".nav-tab-wrapper .nav-tab").click(function(e){e.preventDefault();var t=$(this).attr("id"),i=$(this).closest(".nav-tab-wrapper");if(t){if(toggle_mobile_menu(!1),$(this).is('[role="toggle-menu"]'))return void toggle_mobile_menu(!0);i.find(".nav-tab:not(#wp-optimize-nav-tab-"+t+")").removeClass("nav-tab-active"),$(this).addClass("nav-tab-active"),$(this).closest(".wpo-page").find(".wp-optimize-nav-tab-contents").hide(),$("#"+t+"-contents").show()}}),$("#wp-optimize-nav-page-menu").on("click",function(e){e.preventDefault(),$(this).toggleClass("opened")}),$("#wp-optimize-nav-tab-wpo_database-optimize-contents").on("click","button.wp-optimize-settings-optimization-run-button",function(){var e=$(this).closest(".wp-optimize-settings").data("optimization_id");return e?void(1!=$(".optimization_button_"+e).prop("disabled")&&($(".optimization_button_"+e).prop("disabled",!0),save_sites_list_and_do_action(function(){$(".optimization_button_"+e).prop("disabled",!1),do_optimization(e)}))):void console.log("Optimization ID corresponding to pressed button not found")}),$("#wp-optimize-nav-tab-wpo_database-optimize-contents").on("click","#wp-optimize",function(e){var t=$(this);e.preventDefault(),t.prop("disabled",!0),save_sites_list_and_do_action(function(){t.prop("disabled",!1),run_optimizations()})});var browser_cache_enable_btn=$("#wp_optimize_browser_cache_enable");browser_cache_enable_btn.closest("form").submit(function(e){return e.preventDefault(),browser_cache_enable_btn.trigger("click"),!1}),$("#wp_optimize_gzip_compression_enable").on("click",function(){var e=$(this),t=e.next();t.show(),send_command("enable_gzip_compression",{enable:e.data("enable")},function(i){var o=$("#wpo_gzip_compression_status");i?(i.enabled?(e.text(wpoptimize.disable),e.data("enable","0"),o.removeClass("wpo-disabled").addClass("wpo-enabled")):(e.text(wpoptimize.enable),e.data("enable","1"),o.addClass("wpo-disabled").removeClass("wpo-enabled")),i.message?$("#wpo_gzip_compression_error_message").text(i.message).show():$("#wpo_gzip_compression_error_message").hide(),i.output?$("#wpo_gzip_compression_output").html(i.output).show():$("#wpo_gzip_compression_output").hide()):alert(wpoptimize.error_unexpected_response),t.hide()}).fail(function(){alert(wpoptimize.error_unexpected_response),t.hide()})}),browser_cache_enable_btn.on("click",function(){var e=$("#wpo_browser_cache_expire_days"),t=$("#wpo_browser_cache_expire_hours"),i=parseInt(e.val(),10),o=parseInt(t.val(),10),n=$(this),s=n.next();return isNaN(i)&&(i=0),isNaN(o)&&(o=0),i<0||o<0?($("#wpo_browser_cache_error_message").text(wpoptimize.please_use_positive_integers).show(),!1):o>23?($("#wpo_browser_cache_error_message").text(wpoptimize.please_use_valid_values).show(),!1):($("#wpo_browser_cache_error_message").hide(),e.val(i),t.val(o),s.show(),void send_command("enable_browser_cache",{browser_cache_expire_days:i,browser_cache_expire_hours:o},function(e){var t=$("#wpo_browser_cache_status");e?(e.enabled?(n.text(wpoptimize.update),t.removeClass("wpo-disabled").addClass("wpo-enabled")):(n.text(wpoptimize.enable),t.addClass("wpo-disabled").removeClass("wpo-enabled")),e.message?$("#wpo_browser_cache_message").text(e.message).show():$("#wpo_browser_cache_message").hide(),e.error_message?$("#wpo_browser_cache_error_message").text(e.error_message).show():$("#wpo_browser_cache_error_message").hide(),e.output?$("#wpo_browser_cache_output").html(e.output).show():$("#wpo_browser_cache_output").hide()):alert(wpoptimize.error_unexpected_response),s.hide()}).fail(function(){alert(wpoptimize.error_unexpected_response),s.hide()}))});var wpo_settings_sites_list=$("#wpo_settings_sites_list"),wpo_settings_sites_list_ul=wpo_settings_sites_list.find("ul").first(),wpo_settings_sites_list_items=$('input[type="checkbox"]',wpo_settings_sites_list_ul),wpo_settings_all_sites_checkbox=wpo_settings_sites_list.find("#wpo_all_sites"),wpo_sitelist_show_moreoptions_link=$("#wpo_sitelist_show_moreoptions"),wpo_sitelist_moreoptions_div=$("#wpo_sitelist_moreoptions"),wpo_settings_sites_list_cron=$("#wpo_settings_sites_list_cron"),wpo_settings_sites_list_cron_ul=wpo_settings_sites_list_cron.find("ul").first(),wpo_settings_sites_list_cron_items=$('input[type="checkbox"]',wpo_settings_sites_list_cron_ul),wpo_settings_all_sites_cron_checkbox=wpo_settings_sites_list_cron.find("#wpo_all_sites_cron"),wpo_sitelist_show_moreoptions_cron_link=$("#wpo_sitelist_show_moreoptions_cron"),wpo_sitelist_moreoptions_cron_div=$("#wpo_sitelist_moreoptions_cron");define_moreoptions_settings(wpo_sitelist_show_moreoptions_link,wpo_sitelist_moreoptions_div,wpo_settings_all_sites_checkbox,wpo_settings_sites_list_items);var sites_list_clicked_count=0;$([wpo_settings_all_sites_checkbox,wpo_settings_sites_list_items]).each(function(){$(this).on("change",function(){sites_list_clicked_count++,setTimeout(function(){sites_list_clicked_count--,0==sites_list_clicked_count&&update_optimizations_info()},1e3)})}),define_moreoptions_settings(wpo_sitelist_show_moreoptions_cron_link,wpo_sitelist_moreoptions_cron_div,wpo_settings_all_sites_cron_checkbox,wpo_settings_sites_list_cron_items),$("#wp_optimize_table_list_refresh").click(function(e){e.preventDefault(),$("#wpoptimize_table_list tbody").css("opacity","0.5"),send_command("get_table_list",!1,function(e){if(e.hasOwnProperty("table_list")){var t=!0,i=function(e){$("#wpoptimize_table_list tbody").css("opacity","1")};$("#wpoptimize_table_list").trigger("updateAll",[t,i])}e.hasOwnProperty("total_size")&&$("#optimize_current_db_size").html(e.total_size),update_single_table_optimization_buttons(single_table_optimization_force.is(":checked"))})}),$("#settings_form").on("click","#wp-optimize-settings-save",function(e){if(e.preventDefault(),!validate_logger_settings())return!1;console.log("What?"),$("#save_spinner").show();var t=gather_settings();send_command("save_settings",t,function(e){if($("#save_spinner").hide(),$("#save_done").show().delay(5e3).fadeOut(),e&&e.hasOwnProperty("save_results")&&e.save_results&&e.save_results.hasOwnProperty("errors")){for(var t=0,i=e.save_results.errors.length;t<i;t++){var o='<div class="error">'+e.errors[t]+"</div>";temporarily_display_notice(o,"#wp-optimize-settings-save-results")}console.log(e.save_results.messages)}e&&e.hasOwnProperty("status_box_contents")&&$("#wp_optimize_status_box .inside").html(e.status_box_contents),e&&e.hasOwnProperty("optimizations_table")&&$("#optimizations_list").replaceWith(e.optimizations_table),e.save_results.refresh&&location.reload()})}),$("#wp_optimize_status_box").on("click","#wp_optimize_status_box_refresh",function(e){e.preventDefault(),$("#wp_optimize_status_box").css("opacity","0.5"),send_command("get_status_box_contents",null,function(e){$("#wp_optimize_status_box").css("opacity","1").find(".inside").html(e)})});var optimization_force_checkbox=$("#innodb_force_optimize"),optimization_force=optimization_force_checkbox.is(":checked"),optimization_row=optimization_force_checkbox.closest("tr"),single_table_optimization_force=$("#innodb_force_optimize_single");optimization_force_checkbox.on("change",function(){$('button, input[type="checkbox"]',optimization_row).each(function(){optimization_force=optimization_force_checkbox.is(":checked");var e=$(this);e.data("disabled")&&(optimization_force?e.prop("disabled",!1):e.prop("disabled",!0))})}),$("#wpoptimize_table_list").on("click",".run-single-table-optimization",function(){var e=$("#enable-auto-backup-1");e.is(":checked")?take_a_backup_with_updraftplus(run_single_table_optimization($(this))):run_single_table_optimization($(this))}),single_table_optimization_force.change(function(){update_single_table_optimization_buttons(single_table_optimization_force.is(":checked"))}),update_single_table_optimization_buttons(single_table_optimization_force.is(":checked"));var get_optimizations_info_cache={};setTimeout(function(){send_command("check_overdue_crons",null,function(e){e&&e.hasOwnProperty("m")&&$("#wpo_settings_warnings").append(e.m)})},11e3),$("#wpo_import_settings_btn").on("click",function(e){var t=$("#wpo_import_settings_file"),i=t.val(),o=t[0].files[0],n=new FileReader;return $("#wpo_import_settings_btn").prop("disabled",!0),/\.json$/.test(i)?(n.onload=function(){import_settings(this.result)},n.readAsText(o),!1):(e.preventDefault(),$("#wpo_import_settings_btn").prop("disabled",!1),$("#wpo_import_error_message").text(wpoptimize.please_select_settings_file).slideDown(),!1)}),$("#wpo_import_settings_file").on("change",function(){$("#wpo_import_error_message").slideUp()}),$("#wpo_export_settings_btn").on("click",function(e){return wpo_download_json_file(gather_settings("object")),!1});var optimization_get_info=function(e,t,i){return send_command("get_optimization_info",{optimization_id:t,data:i},function(i){var o=i&&i.result&&i.result.meta?i.result.meta:{},n=i&&i.result&&i.result.output?i.result.output.join("<br>"):"...";$(document).trigger(["optimization_get_info_",t].join(""),n),e.html(n),o.finished?$(document).trigger(["optimization_get_info_",t,"_done"].join(""),i):setTimeout(function(){optimization_get_info(e,t,o)},1)})};return $(document).ready(function(){$(".wp-optimize-optimization-info-ajax").each(function(){var e=$(this),t=e.parent(),i=e.data("id");$(document).trigger(["optimization_get_info_",i,"_start"].join("")),optimization_get_info(t,i,{support_ajax_get_info:!0})})}),$("#wpoptimize_table_list").on("click",".run-single-table-repair",function(){var e=$(this),t=e.next(),i=t.next(),o=e.data("table"),n={optimization_id:"repairtables",optimization_table:o};t.removeClass("visibility-hidden"),send_command("do_optimization",{optimization_id:"repairtables",data:n},function(n){if(n.result.meta.success){var s=e.closest("tr"),a=n.result.meta.tableinfo;e.prop("disabled",!1),t.addClass("visibility-hidden"),i.show().removeClass("visibility-hidden"),$("td:eq(2)",s).text(a.rows),$("td:eq(3)",s).text(a.data_size),$("td:eq(4)",s).text(a.index_size),$("td:eq(5)",s).text(a.type),a.is_optimizable?$("td:eq(6)",s).html(['<span color="',a.overhead>0?"#0000FF":"#004600",'">',a.overhead,"</span>"].join("")):$("td:eq(6)",s).html('<span color="#0000FF">-</span>'),setTimeout(function(){var t=e.closest("td"),i=e.closest(".wpo_button_wrap");i.fadeOut("fast",function(){i.closest(".wpo_button_wrap").remove(),a.is_optimizable&&$(".wpo_button_wrap",t).removeClass("wpo_hidden")}),change_actions_column_visibility()},1e3)}else e.prop("disabled",!1),t.addClass("visibility-hidden"),alert(wpoptimize.table_was_not_repaired.replace("%s",o))})}),$("#wpoptimize_table_list").on("click",".run-single-table-delete",function(){if(!confirm(wpoptimize.are_you_sure_you_want_to_remove_this_table))return!1;var e=$("#enable-auto-backup-1");e.is(":checked")?take_a_backup_with_updraftplus(remove_single_db_table($(this))):e()}),change_actions_column_visibility(),setTimeout(function(){send_command("check_overdue_crons",null,function(e){e&&e.hasOwnProperty("m")&&$("#wpo_settings_warnings").append(e.m)})},11e3),{send_command:send_command,optimization_get_info:optimization_get_info,take_a_backup_with_updraftplus:take_a_backup_with_updraftplus,save_auto_backup_options:save_auto_backup_options}};jQuery(document).ready(function(e){function t(t){var i=["#",t.data("additional")].join("");t.is(":checked")?e(i).show():e(i).hide()}function i(){var t=e("#wp-optimize-logger-settings .save_settings_reminder");t.is(":visible")||t.slideDown("normal")}function o(){e(".wpo_logger_type").each(function(){n(e(this))})}function n(t){var i,o,n=s();for(i in n)o=n[i],wpoptimize.loggers_classes_info[o].allow_multiple?e('option[value="'+o+'"]',t).show():e('option[value="'+o+'"]',t).hide()}function s(){var t=[];return e(".wpo_logging_row, .wpo_logger_type").each(function(){var i=e(this).is("select")?e(this).val():e(this).data("id");i&&t.push(i)}),t}function a(){var e,t=['<option value="">Select destination</option>'];for(e in wpoptimize.loggers_classes_info)wpoptimize.loggers_classes_info.hasOwnProperty(e)&&wpoptimize.loggers_classes_info[e].available&&t.push(['<option value="',e,'">',wpoptimize.loggers_classes_info[e].description,"</option>"].join(""));return['<div class="wpo_add_logger_form">','<select class="wpo_logger_type" name="wpo-logger-type[]">',t.join(""),"<select>",'<a href="#" class="wpo_delete_logger dashicons dashicons-no-alt"></a>','<div class="wpo_additional_logger_options"></div>',"</div>"].join("")}function _(t){if(!wpoptimize.loggers_classes_info[t].options)return"";var i,o=wpoptimize.loggers_classes_info[t].options,n=[],s="",a="";for(i in o)o.hasOwnProperty(i)&&(e.isArray(o[i])?(s=e.trim(o[i][0]),a=e.trim(o[i][1])):(s=e.trim(o[i]),a=""),n.push(['<input class="wpo_logger_addition_option" type="text" name="wpo-logger-options[',i,'][]" value="" ','placeholder="',s,'" ',""!==a?'data-validate="'+a+'"':"","/>"].join("")));return n.push('<input type="hidden" name="wpo-logger-options[active][]" value="1" />'),n.join("")}e(".wp-optimize-logging-settings").each(function(){var i=e(this);t(i),i.on("change",function(){t(i)})});var p=e("#wpo_add_logger_link");p.on("click",function(t){t.preventDefault(),e("#wp-optimize-logger-settings .save_settings_reminder").after(a()),n(e(".wpo_logger_type").first())}),e("#wp-optimize-general-settings").on("change",".wpo_logger_type",function(){var t=e(this),o=t.val(),n=t.parent().find(".wpo_additional_logger_options");n.html(_(o)),t.val()&&i()}),e(".wpo_logging_actions_row .dashicons-edit").on("click",function(){var t=e(this),i=t.closest(".wpo_logging_row");return e(".wpo_additional_logger_options",i).removeClass("wpo_hidden"),e(".wpo_logging_options_row",i).text(""),e(".wpo_logging_status_row",i).text(""),t.hide(),!1}),e("#wp-optimize-logger-settings").on("change",".wpo_logger_addition_option",function(){i()}),e(".wpo_logger_active_checkbox").on("change",function(){var t=e(this),i=t.closest("label").find('input[type="hidden"]');i.val(t.is(":checked")?"1":"0")}),e("#wp-optimize-general-settings").on("click",".wpo_delete_logger",function(){if(!confirm(wpoptimize.are_you_sure_you_want_to_remove_logging_destination))return!1;var t=e(this);return t.closest(".wpo_logging_row, .wpo_add_logger_form").remove(),o(),0==e("#wp-optimize-logging-options .wpo_logging_row").length&&e("#wp-optimize-logging-options").hide(),i(),!1});var r=!1;e(window).on("scroll",function(t){window.requestAnimationFrame(function(){var t=e(".wpo-main-header").length?e(".wpo-main-header")[0].offsetTop:0;window.pageYOffset>t-20!=r&&(r=!r,e("body").toggleClass("is-scrolled",r))})})});
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://david.dw-perspective.org.uk/donate
4
  Tags: comments, spam, optimize, database, revisions, users, posts, trash, schedule, automatic, clean, phpmyadmin, meta, postmeta, responsive, mobile
5
  Requires at least: 3.8
6
  Tested up to: 5.0
7
- Stable tag: 2.2.10
8
  License: GPLv2+
9
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -143,6 +143,11 @@ Please check your database for corrupted tables. That can happen, usually your w
143
 
144
  == Changelog ==
145
 
 
 
 
 
 
146
  = 2.2.10 - 11/Jan/2019 =
147
 
148
  * FEATURE: Added the ability to download unused images list (Premium version) as a CSV file
@@ -461,4 +466,4 @@ Please check your database for corrupted tables. That can happen, usually your w
461
  * Fix Interface
462
 
463
  == Upgrade Notice ==
464
- * 2.2.10 : Fix a few annoyances/errors on some installs. A recommended update for all.
4
  Tags: comments, spam, optimize, database, revisions, users, posts, trash, schedule, automatic, clean, phpmyadmin, meta, postmeta, responsive, mobile
5
  Requires at least: 3.8
6
  Tested up to: 5.0
7
+ Stable tag: 2.2.11
8
  License: GPLv2+
9
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
10
 
143
 
144
  == Changelog ==
145
 
146
+ = 2.2.11 - 16/Jan/2019 =
147
+
148
+ * FIX: A regression in the "identify table by owner" feature caused optimizing to silently fail on some tables
149
+ * TWEAK: Added ability to exclude lazy load images by class
150
+
151
  = 2.2.10 - 11/Jan/2019 =
152
 
153
  * FEATURE: Added the ability to download unused images list (Premium version) as a CSV file
466
  * Fix Interface
467
 
468
  == Upgrade Notice ==
469
+ * 2.2.11 : Fix a silent failure in optimization for some tables. A recommended update for all.
templates/database/tables-body.php CHANGED
@@ -22,7 +22,7 @@
22
  $no++;
23
  echo "<tr>\n";
24
  echo '<td data-colname="'.__('No.', 'wp-optimize').'">'.number_format_i18n($no).'</td>'."\n";
25
- echo '<td data-colname="'.__('Table', 'wp-optimize').'">'.htmlspecialchars($tablestatus->Name);
26
 
27
  if ($tablestatus->plugin) {
28
  echo "<br><span style='font-size: 11px;'>".__('Belongs to:', 'wp-optimize')."</span> ";
22
  $no++;
23
  echo "<tr>\n";
24
  echo '<td data-colname="'.__('No.', 'wp-optimize').'">'.number_format_i18n($no).'</td>'."\n";
25
+ echo '<td data-tablename="'.esc_attr($tablestatus->Name).'" data-colname="'.__('Table', 'wp-optimize').'">'.htmlspecialchars($tablestatus->Name);
26
 
27
  if ($tablestatus->plugin) {
28
  echo "<br><span style='font-size: 11px;'>".__('Belongs to:', 'wp-optimize')."</span> ";
wp-optimize.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: WP-Optimize
4
  Plugin URI: https://getwpo.com
5
  Description: WP-Optimize is WordPress's #1 most installed optimization plugin. With it, you can clean up your database easily and safely, without manual queries.
6
- Version: 2.2.10
7
  Author: David Anderson, Ruhani Rabin, Team Updraft
8
  Author URI: https://updraftplus.com
9
  Text Domain: wp-optimize
@@ -15,7 +15,7 @@ if (!defined('ABSPATH')) die('No direct access allowed');
15
 
16
  // Check to make sure if WP_Optimize is already call and returns.
17
  if (!class_exists('WP_Optimize')) :
18
- define('WPO_VERSION', '2.2.10');
19
  define('WPO_PLUGIN_URL', plugin_dir_url(__FILE__));
20
  define('WPO_PLUGIN_MAIN_PATH', plugin_dir_path(__FILE__));
21
  define('WPO_PREMIUM_NOTIFICATION', false);
3
  Plugin Name: WP-Optimize
4
  Plugin URI: https://getwpo.com
5
  Description: WP-Optimize is WordPress's #1 most installed optimization plugin. With it, you can clean up your database easily and safely, without manual queries.
6
+ Version: 2.2.11
7
  Author: David Anderson, Ruhani Rabin, Team Updraft
8
  Author URI: https://updraftplus.com
9
  Text Domain: wp-optimize
15
 
16
  // Check to make sure if WP_Optimize is already call and returns.
17
  if (!class_exists('WP_Optimize')) :
18
+ define('WPO_VERSION', '2.2.11');
19
  define('WPO_PLUGIN_URL', plugin_dir_url(__FILE__));
20
  define('WPO_PLUGIN_MAIN_PATH', plugin_dir_path(__FILE__));
21
  define('WPO_PREMIUM_NOTIFICATION', false);