EVOLUTION-MANAGER
Edit File: import-export.js
!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.addLog(d,n),i("import_plugin",{perform:c,pluginSlug:e,paged:r}).done((function(i){r=1,i&&i.page&&i.page<i.total_pages&&(r=i.page+1,t.unshift(c)),"recalculate"===c&&i.total_items>0?s.updateSeoScores(i.data,e,t,n,r,o):("recalculate"===c&&0===i.total_items&&(i.message=(0,a.__)("No posts found without SEO score.","rank-math")),s.addLog(i.success?i.message:i.error,n),s.ajaxImport(e,t,n,r,o))})).fail((function(a){s.addLog(a.statusText,n),s.ajaxImport(e,t,n,null,o)}))},updateSeoScores:function(t,a,n,r,i,c){var d=this,u={};if("complete"!==t)return void 0===this.postIds&&(this.postIds=[]),new Promise((function(e){(0,o.forEach)(t,(function(e,t){if(-1===d.postIds.indexOf(t)){d.postIds.push(t);var a=new s.ResultManager,n=wp.i18n,r=new s.Paper;r.setTitle(e.title),r.setDescription(e.description),r.setText(e.content),r.setKeyword(e.keyword),r.setKeywords(e.keywords),r.setPermalink(e.url),r.setUrl(e.url),e.thumbnail&&r.setThumbnail(e.thumbnail),r.setContentAI(e.hasContentAi);var o=d.getResearchesTests(e);new s.Analyzer({i18n:n,analysis:o}).analyzeSome(o,r).then((function(n){a.update(r.getKeyword(),n,!0);var o=a.getScore(e.keyword);e.isProduct&&(o=e.isReviewEnabled?o+1:o,o=e.hasProductSchema?o+1:o),u[t]=o}))}})),e()})).then((function(){e.ajax({url:rankMath.api.root+"rankmath/v1/updateSeoScore",method:"POST",beforeSend:function(e){e.setRequestHeader("X-WP-Nonce",rankMath.restNonce)},data:{action:"rank_math_update_seo_score",postScores:u},success:function(e){d.addLog("SEO Scores updated",r),d.ajaxImport(a,n,r,i,c)},error:function(e){d.addLog(e.statusText,r)}})}));this.ajaxImport(a,n,r,i,c)},getResearchesTests:function(e){var t=rankMath.assessor.researchesTests;return t=(0,o.difference)(t,["keywordNotUsed"]),e.isProduct?t=(0,o.difference)(t,["keywordInSubheadings","linksHasExternals","linksNotAllExternals","linksHasInternal","titleSentiment","titleHasNumber","contentHasTOC"]):t},addLog:function(e,t){var a=new Date,n=t.val()+"["+(10>a.getHours()?"0":"")+a.getHours()+":"+(10>a.getMinutes()?"0":"")+a.getMinutes()+":"+(10>a.getSeconds()?"0":"")+a.getSeconds()+"] "+e+"\n";t.text(n).scrollTop(t[0].scrollHeight-t.height()-20)},cleanPlugin:function(t){var a=e(t.currentTarget),n=a.closest("form").find(".rank-math-box-tabs > .active-tab").text().trim();window.confirm(rankMath.cleanPluginConfirm.replace("%s",n))&&(a.prop("disabled",!0),i("clean_plugin",{pluginSlug:a.data("slug")}).always((function(){a.prop("disabled",!1),e("html, body").animate({scrollTop:0},"fast")})).done((function(t){t.success&&a.closest("tr").fadeOut((function(){e(this).remove()})),c(t.success?t.message:t.error,t.success?"success":"error",e(".wp-header-end"),5e3)})))}}).init()}))}();