jQuery(function(t){WP_Optimize=WP_Optimize(),"undefined"!=typeof WP_Optimize_Cache&&(WP_Optimize_Cache=WP_Optimize_Cache()),"undefined"!=typeof wp_optimize.minify&&(WP_Optimize_Minify=wp_optimize.minify.init())}),function(t){var i=[];t.fn.form_errors=function(){return this},t.fn.form_errors.add=function(t,e){!1===this.has_error(t)&&i.push({type:t,message:e})},t.fn.form_errors.remove=function(t){var e=this.has_error(t);e!==!1&&i.splice(e,1)},t.fn.form_errors.has_error=function(e){var o=!1;return t.each(i,function(t,i){console.log(t,i),e==i.type&&(o=t)}.bind(this)),o},t.fn.form_errors.has_errors=function(){return i.length>0}}(jQuery);var WP_Optimize=function(){function t(){if(D("#enable-schedule").length){var t=D("#enable-schedule").is(":checked");t?D("#wp-optimize-auto-options").css("opacity","1"):D("#wp-optimize-auto-options").css("opacity","0.5")}}function i(t,i,e){i="undefined"==typeof i?"#wp-optimize-wrap":i,e="undefined"==typeof e?15:e,D(t).hide().prependTo(i).slideDown("fast").delay(1e3*e).slideUp("fast",function(){D(this).remove()})}function e(t,e){var o={type:t,enable:e?1:0};D("#"+t+"_spinner").show(),T("enable_or_disable_feature",o,function(e){if(D("#"+t+"_spinner").hide(),e&&e.hasOwnProperty("output"))for(var o=0,n=e.output.length;o";i(a,"#"+t+"_notice")}})}function o(t){t?D("#wp-optimize-wrap").addClass("wpo-mobile-menu-opened"):D("#wp-optimize-wrap").removeClass("wpo-mobile-menu-opened")}function n(){if(!S){var t=D(".wpo-page[data-whichpage=WP-Optimize]"),i=t.find(".wpo_shade");i.removeClass("hidden"),T("get_database_tabs",{},function(i){S=!0,i.hasOwnProperty("optimizations")&&t.find(".wp-optimize-optimizations-table-placeholder").replaceWith(i.optimizations),w(i),D(document).trigger("wpo_database_tabs_loaded")}).always(function(){i.addClass("hidden")})}}function a(t){var i="",t="undefined"==typeof t?"string":t,e=D("#wp-optimize-database-settings form input[name!='action'], #wp-optimize-database-settings form select, #wp-optimize-database-settings form textarea, #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-']");return"object"==t?i=e.serializeJSON({useIntKeysAsArrayIndex:!0}):(i=e.serialize(),D.each(D('#wp-optimize-database-settings form input[type=checkbox], #wp-optimize-general-settings form input[type=checkbox], .wp-optimize-nav-tab-contents input[name^="enable-auto-backup-"]').filter(function(t){return 0==D(this).prop("checked")}),function(t,e){var o="0";i+="&"+D(e).attr("name")+"="+o})),i}function s(){T("optimizations_done",{},function(){}),F=!1}function p(){if(!q.get_lock())return void(W>0&&console.log("WP-Optimize: process_queue(): queue is currently locked - exiting"));W>0&&console.log("WP-Optimize: process_queue(): got queue lock");var t=q.peek();if("object"==typeof t?(data=t,t=t.optimization_id):data={},"undefined"==typeof t)return W>0&&console.log("WP-Optimize: process_queue(): queue is apparently empty - exiting"),q.unlock(),void s();if(W>0&&console.log("WP-Optimize: process_queue(): processing item: "+t),q.dequeue(),D(document).trigger(["do_optimization_",t,"_start"].join("")),"optimizetables"===t){D("#optimization_info_"+t).html(wpoptimize.optimizing_table+" "+data.optimization_table);var i=parseInt(wpoptimize.table_optimization_timeout)?parseInt(wpoptimize.table_optimization_timeout):12e4,e={timeout:i,error:function(e,o){F=!0,"timeout"===o?console.warn("The request to optimize the table "+data.optimization_table+" timed out after "+i/1e3+" seconds"):console.warn('There was an error when running the optimization "'+t+'".',o,e,data),q.is_empty()&&(D("#optimization_spinner_"+t).hide(),D("#optimization_checkbox_"+t).show(),D(".optimization_button_"+t).prop("disabled",!1),D("#optimization_info_"+t).html(wpoptimize.optimization_complete+" "+wpoptimize.with_warnings)),setTimeout(function(){q.unlock(),p()},500)}}}else var e={};T("do_optimization",{optimization_id:t,data:data},function(i){if(D("#optimization_spinner_"+t).hide(),D("#optimization_checkbox_"+t).show(),D(".optimization_button_"+t).prop("disabled",!1),D(document).trigger(["do_optimization_",t,"_done"].join(""),i),i){for(var e="",o=0,n=i.errors.length;o'+i.errors[o]+"
";for(var o=0,n=i.messages.length;o";for(var o=0,n=i.result.output.length;o";if(D("#optimization_info_"+t).html(e),i.hasOwnProperty("status_box_contents")&&D("#wp_optimize_status_box").css("opacity","1").find(".inside").html(i.status_box_contents),i.hasOwnProperty("table_list")&&D("#wpoptimize_table_list tbody").html(D(i.table_list).find("tbody").html()),i.hasOwnProperty("total_size")&&D("#optimize_current_db_size").html(i.total_size),"optimizetables"==t&&data.optimization_table&&(q.is_empty()?(D("#optimization_spinner_"+t).hide(),D("#optimization_checkbox_"+t).show(),D(".optimization_button_"+t).prop("disabled",!1),D("#optimization_info_"+t).html(wpoptimize.optimization_complete+(F?" "+wpoptimize.with_warnings:""))):(D("#optimization_checkbox_"+t).hide(),D("#optimization_spinner_"+t).show(),D(".optimization_button_"+t).prop("disabled",!0))),i.result.meta&&i.result.meta.hasOwnProperty("awaiting_mod")){var a=i.result.meta.awaiting_mod;a>0?D("#adminmenu .awaiting-mod .pending-count").remove(a):D("#adminmenu .awaiting-mod").remove()}}setTimeout(function(){q.unlock(),p()},500)},!0,e)}function r(t){var i=D("#wp-optimize-nav-tab-contents-optimize .wp-optimize-settings-"+t);i||console.log("do_optimization: row corresponding to this optimization ("+t+") not found");var e={},o=0;if(D('input[type="checkbox"]',D("#optimization_info_"+t)).each(function(){var t=D(this);t.is(":checked")&&(e[t.attr("name")]=t.val(),o++)}),1!=D(".optimization_button_"+t).prop("disabled")){if(D("#optimization_checkbox_"+t).hide(),D("#optimization_spinner_"+t).show(),D(".optimization_button_"+t).prop("disabled",!0),D("#optimization_info_"+t).html("..."),"optimizetables"==t){var n=D("#wpoptimize_table_list #the-list tr");D(n).each(function(i){var e=(D(this).find("td"),D(this).data("type")),o=D(this).data("tablename"),n=D(this).data("optimizable");if(""!=o&&(1==parseInt(n)||A)){var a={optimization_id:t,optimization_table:o,optimization_table_type:e,optimization_force:A};q.enqueue(a)}})}else if(o>0){data={optimization_id:t};for(var a in e)e.hasOwnProperty(a)&&(data[a]=e[a]);q.enqueue(data)}else q.enqueue(t);p()}}function l(t){D("#wpo_settings_sites_list").length?T("save_site_settings",{"wpo-sites":c()},function(){t&&t()}):t&&t()}function c(){var t=[];return D('#wpo_settings_sites_list input[type="checkbox"]').each(function(){var i=D(this);i.is(":checked")&&t.push(i.attr("value"))}),t}function _(){var t=!1;D("#enable-auto-backup").is(":checked")&&(t=!0),u(),1==t?d(h):h()}function d(t,i){"undefined"==typeof i&&(i="");var e=i?0:1;"function"==typeof updraft_backupnow_inpage_go?updraft_backupnow_inpage_go(function(){D("#updraft-backupnow-inpage-modal").dialog("close"),t&&t()},i,"autobackup",0,e,0,wpoptimize.automatic_backup_before_optimizations):t&&t()}function u(){var t=a("object");t.auto_backup=D("#enable-auto-backup").is(":checked"),T("save_auto_backup_option",t)}function m(t,i,e,o){t.on("click",function(){return i.hasClass("wpo_always_visible")||i.toggleClass("wpo_hidden"),!1}),f(e,o)}function f(t,i){t.on("change",function(){t.is(":checked")?i.prop("checked",!0):i.prop("checked",!1),g(t,i)}),i.on("change",function(){g(t,i)}),g(t,i)}function g(t,i){var e=0,o=0;if(i.each(function(){D(this).is(":checked")&&o++,e++}),t.next().is("label")&&t.next().data("label")){var n=t.next(),a=n.data("label");e==o?n.text(a):n.text(a.replace("all",[o," of ",e].join("")))}e==o?t.prop("checked",!0):t.prop("checked",!1)}function h(){$optimizations=D("#optimizations_list .optimization_checkbox:checked"),$optimizations.sort(function(t,i){return t=D(t).closest(".wp-optimize-settings").data("optimization_run_sort_order"),i=D(i).closest(".wp-optimize-settings").data("optimization_run_sort_order"),t>i?1:t tbody:last th:eq(6)").html(['',a.overhead_formatted,""].join(""))}t.prop("disabled",!1),i.addClass("visibility-hidden"),e.show().removeClass("visibility-hidden").delay(2500).fadeOut("fast",function(){t.show()})})}function z(t,i){D("td:eq(2)",t).text(i.rows),D("td:eq(3)",t).text(i.data_size),D("td:eq(4)",t).text(i.index_size),D("td:eq(5)",t).text(i.type),i.is_optimizable?D("td:eq(6)",t).html(['',i.overhead,""].join("")):D("td:eq(6)",t).html('-')}function v(t){D(".run-single-table-optimization").each(function(){var i=D(this);i.data("disabled")&&(t?i.prop("disabled",!1):i.prop("disabled",!0))})}function y(t){var i,e,o;if(t)for(i in t)t.hasOwnProperty(i)&&(e=["#wp-optimize-settings-",t[i].dom_id].join(""),o=t[i].info?t[i].info.join("
"):"",D(e+" .wp-optimize-settings-optimization-info").html(o))}function k(){var t=["",c().join("_")].join("");L.hasOwnProperty(t)?y(L[t]):T("get_optimizations_info",{"wpo-sites":c()},function(i){i&&(L[t]=i,y(i))})}function x(t){var i=D("#wpo_import_spinner"),e=D("#wpo_import_success_message"),o=D("#wpo_import_error_message");i.show(),T("import_settings",{settings:t},function(t){i.hide(),t&&t.errors&&t.errors.length?(o.text(t.errors.join("
")),o.slideDown()):t&&t.messages&&t.messages.length&&(e.text(t.messages.join("
")),e.slideDown(),setTimeout(function(){window.location.reload()},500)),D("#wpo_import_settings_btn").prop("disabled",!1)})}function O(t,i){var e=document.body.appendChild(document.createElement("a")),o=new Date,n=o.getFullYear(),a=o.getMonth()<10?["0",o.getMonth()].join(""):o.getMonth(),s=o.getDay()<10?["0",o.getDay()].join(""):o.getDay();i=i?i:["wpo-settings-",n,"-",a,"-",s,".json"].join(""),e.setAttribute("download",i),e.setAttribute("style","display:none;"),e.setAttribute("href","data:text/json;charset=UTF-8,"+encodeURIComponent(JSON.stringify(t))),e.click()}function C(){var t=X.next(),i=t.next(),e=X.data("table"),o={optimization_id:"orphanedtables",optimization_table:e};t.removeClass("visibility-hidden"),T("do_optimization",{optimization_id:"orphanedtables",data:o},function(t){if(t.result.meta.success){var o=X.closest("tr");i.show().removeClass("visibility-hidden"),setTimeout(function(){o.fadeOut("slow",function(){o.remove(),j()})},500)}else{var n=wpoptimize.table_was_not_deleted.replace("%s",e);t.result.meta.message&&(n+="("+t.result.meta.message+")"),alert(n)}}).always(function(){X.prop("disabled",!1),t.addClass("visibility-hidden")})}function j(){var t=D("#wpoptimize_table_list"),i=!0;D("tr",t).each(function(){var t=D(this);if(D("button",t).length>0)return i=!1,!1}),D("tr",t).each(function(){var t=D(this);i?D("td:last, th:last",t).hide():D("td:last, th:last",t).show()})}function P(t,i){var e=t.val(),o=t.data("validate");if(!o&&i)return""!=D.trim(e);if(o&&!i&&""==D.trim(e))return!0;var n=!0;switch(o){case"email":for(var a=/\S+@\S+\.\S+/,s=e.split(","),p="",r=0;r";i(a,"#wp-optimize-settings-save-results")}console.log(t.save_results.messages)}t&&t.hasOwnProperty("status_box_contents")&&D(t.status_box_contents).each(function(t,i){D(i).is("#wp_optimize_status_box")&&D("#wp_optimize_status_box").replaceWith(D(i))}),t&&t.hasOwnProperty("optimizations_table")&&D("#optimizations_list").replaceWith(t.optimizations_table),t.save_results.refresh&&location.reload()}).always(function(){o.hide()}))}),D("#settings_form").on("click",".wpo-wipe-settings",function(){var t=D(this).parent().find(".wpo_spinner");t.show(),T("wipe_settings",{},function(){t.next().removeClass("display-none").delay(5e3).fadeOut(),alert(wpoptimize.settings_have_been_deleted_successfully),location.replace(wpoptimize.settings_page_url)}).always(function(){t.hide()})}),D("#wp-optimize-wrap").on("click","#wp_optimize_status_box_refresh",function(t){t.preventDefault(),D("#wp_optimize_status_box").css("opacity","0.5"),T("get_status_box_contents",null,function(t){D("#wp_optimize_status_box").css("opacity","1"),D(t).each(function(t,i){D(i).is("#wp_optimize_status_box")&&D("#wp_optimize_status_box").replaceWith(D(i))})})});var L={};D("#wpo_import_settings_btn").on("click",function(t){var i=D("#wpo_import_settings_file"),e=i.val(),o=i[0].files[0],n=new FileReader;return D("#wpo_import_settings_btn").prop("disabled",!0),/\.json$/.test(e)?(n.onload=function(){x(this.result)},n.readAsText(o),!1):(t.preventDefault(),D("#wpo_import_settings_btn").prop("disabled",!1),D("#wpo_import_error_message").text(wpoptimize.please_select_settings_file).slideDown(),!1)}),D("#wpo_import_settings_file").on("change",function(){D("#wpo_import_error_message").slideUp()}),D("#wpo_export_settings_btn").on("click",function(t){return O(a("object")),!1});var V=function(t,i,e){return T("get_optimization_info",{optimization_id:i,data:e},function(e){var o=e&&e.result&&e.result.meta?e.result.meta:{},n=e&&e.result&&e.result.output?e.result.output.join("
"):"...";D(document).trigger(["optimization_get_info_",i].join(""),[n,o]),t.html(n),o.finished?D(document).trigger(["optimization_get_info_",i,"_done"].join(""),e):setTimeout(function(){var e=V(t,i,o);D(document).trigger(["optimization_get_info_xhr_",i].join(""),[e,o])},1)})};jQuery(function(){D(".wp-optimize-optimization-info-ajax").each(function(){var t=D(this),i=t.parent(),e=t.data("id");D(document).trigger(["optimization_get_info_",e,"_start"].join("")),V(i,e,{support_ajax_get_info:!0})})}),D("#wpoptimize_table_list").on("click",".run-single-table-optimization",function(){var t=D("#enable-auto-backup-1"),i=D(this);t.is(":checked")?d(function(){b(i)}):b(i)}),D("#wpoptimize_table_list").on("click",".run-single-table-repair",function(){var t=D(this),i=t.next(),e=i.next(),o=t.data("table"),n={optimization_id:"repairtables",optimization_table:o};i.removeClass("visibility-hidden"),T("do_optimization",{optimization_id:"repairtables",data:n},function(n){if(n.result.meta.success){var a=t.closest("tr"),s=n.result.meta.tableinfo;t.prop("disabled",!1),i.addClass("visibility-hidden"),e.show().removeClass("visibility-hidden"),z(a,s),setTimeout(function(){var i=t.closest("td"),e=t.closest(".wpo_button_wrap");e.fadeOut("fast",function(){e.closest(".wpo_button_wrap").remove(),s.is_type_supported&&D(".wpo_button_wrap",i).removeClass("wpo_hidden")}),j()},1e3)}else t.prop("disabled",!1),i.addClass("visibility-hidden"),alert(wpoptimize.table_was_not_repaired.replace("%s",o))})});var X;return D("#wpoptimize_table_list").on("click",".run-single-table-delete",function(){X=D(this);var t=D("#enable-auto-backup-1");wp_optimize.modal.open({className:"wpo-confirm",events:{"click .wpo-modal--bg":"close","click .delete-table":"deleteTable","change #confirm_deletion_without_backup":"changeConfirm","change #confirm_table_deletion":"changeConfirm"},content:function(){var i=wp.template("wpo-table-delete"),e=X.closest("tr").find(".table-plugins").html();return i({no_backup:!t.is(":checked"),plugins_list:e,table_name:X.data("table")})},changeConfirm:function(){var t=!0,i=this.$("#confirm_deletion_without_backup"),e=this.$("#confirm_table_deletion");i.length&&!i.is(":checked")&&(t=!1),e.is(":checked")||(t=!1),this.$(".delete-table").prop("disabled",!t)},deleteTable:function(){t.is(":checked")?d(C):C(),this.close()}})}),j(),D("#wp-optimize-general-settings").on("wpo-saving-form-data",function(){var t=!0,i=D(this);D(".wpo_logger_addition_option, .wpo_logger_type").each(function(){P(D(this),!0)?D(this).removeClass("wpo_error_field"):(t=!1,D(this).addClass("wpo_error_field"))}),t?(i.form_errors.remove("missing-fields"),D("#wp-optimize-logger-settings .save_settings_reminder").slideUp()):(i.form_errors.add("missing-fields",""),D("#wp-optimize-settings-save-results").show().addClass("wpo_alert_notice").text(wpoptimize.fill_all_settings_fields).delay(5e3).fadeOut(3e3,function(){D(this).removeClass("wpo_alert_notice")}))}),setTimeout(function(){T("check_overdue_crons",null,function(t){t&&t.hasOwnProperty("m")&&D("#wpo_settings_warnings").append(t.m)})},11e3),D(".wpo-introduction-notice .notice-dismiss, .wpo-introduction-notice .close").on("click",function(t){D(".wpo-introduction-notice").remove(),T("dismiss_install_or_update_notice",null,function(t){t&&t.hasOwnProperty("error")&&console.log("There was an error dismissing the install or update notice (dismiss_install_or_update_notice)",t)})}),{send_command:T,optimization_get_info:V,take_a_backup_with_updraftplus:d,save_auto_backup_options:u}};jQuery(function(t){function i(i){var e=["#",i.data("additional")].join("");i.is(":checked")?t(e).show():t(e).hide()}function e(){var i=t("#wp-optimize-logger-settings .save_settings_reminder");i.is(":visible")||i.slideDown("normal")}function o(){t(".wpo_logger_type").each(function(){n(t(this))})}function n(i){var e,o,n=a();for(e in n)o=n[e],wpoptimize.loggers_classes_info[o].allow_multiple?t('option[value="'+o+'"]',i).show():t('option[value="'+o+'"]',i).hide()}function a(){var i=[];return t(".wpo_logging_row, .wpo_logger_type").each(function(){var e=t(this).is("select")?t(this).val():t(this).data("id");e&&i.push(e)}),i}function s(){var t,i=[''];for(t in wpoptimize.loggers_classes_info)wpoptimize.loggers_classes_info.hasOwnProperty(t)&&wpoptimize.loggers_classes_info[t].available&&i.push(['"].join(""));return['
','",'','
',"
"].join("")}function p(i){if(!wpoptimize.loggers_classes_info[i].options)return"";var e,o=wpoptimize.loggers_classes_info[i].options,n=[],a="",s="";for(e in o)o.hasOwnProperty(e)&&(Array.isArray(o[e])?(a=t.trim(o[e][0]),s=t.trim(o[e][1])):(a=t.trim(o[e]),s=""),n.push(['"].join("")));return n.push(''),n.join("")}t(".wp-optimize-logging-settings").each(function(){var e=t(this);i(e),e.on("change",function(){i(e)})});var r=t("#wpo_add_logger_link");r.on("click",function(i){i.preventDefault(),t("#wp-optimize-logger-settings .save_settings_reminder").after(s()),n(t(".wpo_logger_type").first())}),t("#wp-optimize-general-settings").on("change",".wpo_logger_type",function(){var i=t(this),o=i.val(),n=i.parent().find(".wpo_additional_logger_options");n.html(p(o)),i.val()&&e()}),t(".wpo_logging_actions_row .dashicons-edit").on("click",function(){var i=t(this),e=i.closest(".wpo_logging_row");return t(".wpo_additional_logger_options",e).removeClass("wpo_hidden"),t(".wpo_logging_options_row",e).text(""),t(".wpo_logging_status_row",e).text(""),i.hide(),!1}),t("#wp-optimize-logger-settings").on("change",".wpo_logger_addition_option",function(){e()}),t(".wpo_logger_active_checkbox").on("change",function(){var i=t(this),e=i.closest("label").find('input[type="hidden"]');e.val(i.is(":checked")?"1":"0")}),t("#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 i=t(this);return i.closest(".wpo_logging_row, .wpo_add_logger_form").remove(),o(),0==t("#wp-optimize-logging-options .wpo_logging_row").length&&t("#wp-optimize-logging-options").hide(),e(),!1});var l=!1;t(window).on("scroll",function(i){window.requestAnimationFrame(function(){var i=t(".wpo-main-header").length?t(".wpo-main-header")[0].offsetTop:0;window.pageYOffset>i-20!=l&&(l=!l,t("body").toggleClass("is-scrolled",l))})}),t(".wpo-info__trigger").on("click",function(i){i.preventDefault();var e=t(this).closest(".wpo-info");e.toggleClass("opened")}),t(".wpo-video-preview a").on("click",function(i){var e=t(this).data("embed");if(e){i.preventDefault();var o=t('