You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 line
6.6 KiB
JavaScript

!function(){"use strict";var e,t={n:function(e){var a=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(a,{a:a}),a},d:function(e,a){for(var n in a)t.o(a,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:a[n]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}},a=wp.i18n,n=jQuery,r=t.n(n),o=lodash,s=rankMathAnalyzer;function i(e,t,a){return r().ajax({url:rankMath.ajaxurl,type:a||"POST",dataType:"json",data:r().extend(!0,{action:"rank_math_"+e,security:rankMath.security},t)})}function c(e,t,a,n){t=t||"error",n=n||!1;var o=r()('<div class="notice notice-'+t+' is-dismissible"><p>'+e+"</p></div>").hide();a.next(".notice").remove(),a.after(o),o.slideDown(),r()(document).trigger("wp-updates-notice-added"),n&&setTimeout((function(){o.fadeOut((function(){o.remove()}))}),n)}(e=r())((function(){({init:function(){var t,a,n=this;a=t||".rank-math-box-tabs",r()(a).children().on("click",(function(e){e.preventDefault();var t=r()(this),a=t.attr("href").substr(1);t.addClass("active-tab").siblings().removeClass("active-tab"),r()("#"+a).addClass("active-tab").siblings().removeClass("active-tab")})),e(document.body).on("click",".rank-math-action",(function(t){var a=e(t.currentTarget).data("action");a in n&&n[a](t)})),this.importConfirm()},importConfirm:function(){var t=e("#import-me");t.on("change",(function(){t.removeClass("invalid")})),e("#rank-math-import-form").on("submit",(function(e){if(!t.get(0).files.length)return t.addClass("invalid"),void e.preventDefault();window.confirm(rankMath.importSettingsConfirm)||e.preventDefault()}))},createBackup:function(t){var a=e(t.currentTarget);a.prop("disabled",!0),i("create_backup").always((function(){a.prop("disabled",!1)})).done((function(t){if(t.success){var n=a.parent().find("tbody"),r=n.find("tr:first").clone();r.removeClass("hidden").find("th").html(t.backup),r.find("[data-action]").attr("data-key",t.key),n.prepend(r),e("#rank-math-no-backup-message").addClass("hidden"),c(t.message,"success",e(".wp-header-end"),2e3)}else c(t.error,"error",e(".wp-header-end"),2e3)}))},restoreBackup:function(t){if(window.confirm(rankMath.restoreConfirm)){var a=e(t.currentTarget);a.prop("disabled",!0),i("restore_backup",{key:a.attr("data-key")}).always((function(){a.prop("disabled",!1)})).done((function(t){t.success?c(t.message,"success",e(".wp-header-end"),2e3):c(t.error,"error",e(".wp-header-end"),2e3)}))}},deleteBackup:function(t){if(window.confirm(rankMath.deleteBackupConfirm)){var a=e(t.currentTarget);a.prop("disabled",!0),i("delete_backup",{key:a.data("key")}).always((function(){a.prop("disabled",!1)})).done((function(t){if(t.success){var n=a.closest("table");a.closest("tr").fadeOut((function(){e(this).remove(),1>n.find("tr").length&&e("#rank-math-no-backup-message").show()})),c(t.message,"success",e(".wp-header-end"),2e3)}else c(t.error,"error",e(".wp-header-end"),2e3)}))}},getAllActions:function(){return e.map(e(".import-plugins .active-tab").find(".choices").find("input:checkbox:checked"),(function(e){return e.value}))},importPlugin:function(t){var a=e(t.currentTarget),n=a.closest("form").find(".rank-math-box-tabs > .active-tab").text().trim();if(window.confirm(rankMath.importPluginConfirm.replace("%s",n))){var r=this.getAllActions();if(1>r.length)c(rankMath.importPluginSelectAction,"error",e(".wp-header-end"),5e3);else{a.prop("disabled",!0),a.data("active")&&r.push("deactivate");var o=e('<textarea id="import-progress-area" class="import-progress-area large-text" disabled="disabled" rows="8" style="margin: 20px 0;background: #eee;"></textarea>');e("#import-progress-area").remove(),a.parents(".active-tab").find("table").after(o),this.addLog("Import started...",o),this.ajaxImport(a.data("slug"),r,o,null,(function(){a.prop("disabled",!1),setTimeout((function(){o.fadeOut((function(){o.remove()}))}),1e4)}))}}},ajaxImport:function(e,t,n,r,o){var s=this;if(0===t.length)return this.addLog("Import finished.",n),void o();var c=t.shift(),d="deactivate"===c?"Deactivating plugin":"Importing "+c;r=r||1,"recalculate"===c&&(d="Starting SEO score recalculation"),this