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
5.1 KiB
JavaScript

!function(){"use strict";var t,e={n:function(t){var a=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(a,{a:a}),a},d:function(t,a){for(var o in a)e.o(a,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:a[o]})},o:function(t,e){return Object.prototype.hasOwnProperty.call(t,e)}},a=jQuery,o=e.n(a),n=lodash,r=rankMathAnalyzer,s=wp.i18n;function i(t){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i(t)}(t=o())((function(){var e=t(".rank-math-tab-nav");function a(a,o){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:5e3;o=o||"error";var r=t('<div class="notice is-dismissible rank-math-tool-notice"><p></p></div>');r.hide().addClass("notice-"+o).find("p").text(a),e.prev(".notice").remove(),e.before(r),r.slideDown(),t("html,body").animate({scrollTop:r.offset().top-50},"slow"),t(document).trigger("wp-updates-notice-added"),n&&setTimeout((function(){r.fadeOut()}),n)}var o=0,c=rankMath.batchSize,d=!t("#update_all_posts").length||t("#update_all_posts").is(":checked")?rankMath.totalPosts:rankMath.totalPostsWithoutScore,l=d?100/d:0,u=[],p=0;function h(e,a){var i={};return a.addClass("disabled"),t("#update_all_scores").prop("disabled",!0),"complete"===e?(t(".progress-bar span").css("width","100%"),t(".count span.update-posts-done").text(d),void t(".rank-math-modal-footer").removeClass("hidden")):new Promise((function(t){(0,n.forEach)(e,(function(t,e){if(-1===u.indexOf(e)){var a=r.Helpers.removeDiacritics(t.keyword);u.push(e);var o=new r.ResultManager,s=wp.i18n,c=new r.Paper("",{locale:rankMath.localeFull});c.setTitle(t.title),c.setDescription(t.description),c.setText(t.content),c.setKeyword(a),c.setKeywords(t.keywords),c.setPermalink(t.url),c.setUrl(r.Helpers.removeDiacritics(t.url)),t.thumbnail&&(c.setThumbnail(t.thumbnail),c.setThumbnailAltText(t.thumbnailAlt)),c.setContentAI(t.hasContentAi);var d=function(t){var e=rankMath.assessor.researchesTests;return e=(0,n.difference)(e,["keywordNotUsed"]),t.isProduct?e=(0,n.difference)(e,["keywordInSubheadings","linksHasExternals","linksNotAllExternals","linksHasInternal","titleSentiment","titleHasNumber","contentHasTOC"]):e}(t);new r.Analyzer({i18n:s,analysis:d}).analyzeSome(d,c).then((function(a){o.update(c.getKeyword(),a,!0);var n=o.getScore(c.getKeyword());t.isProduct&&(n=t.isReviewEnabled?n+1:n,n=t.hasProductSchema?n+1:n),i[e]=n}))}})),t()})).then((function(){t.ajax({url:rankMath.api.root+"rankmath/v1/updateSeoScore",method:"POST",beforeSend:function(t){t.setRequestHeader("X-WP-Nonce",rankMath.restNonce)},data:{action:"rank_math_update_seo_score",postScores:i},success:function(e){if(1==e)if(p+=c,o+=l*c,t(".progress-bar span").css("width",o+"%"),t(".count span.update-posts-done").text(p),p>=d)t(".progress-bar span").css("width","100%"),t(".count span.update-posts-done").text(d),t(".rank-math-modal-footer").removeClass("hidden");else{var n=a.data("args")||{};n.offset=p,a.data("args",n),f(a)}},error:function(e){t(".rank-math-modal-footer").removeClass("hidden").find("p").text((0,s.__)("Something went wrong. Please refresh the page and try again.","rank-math"))}})}))}function f(e){var o=e.data("action"),n=e.data("args");t.ajax({url:rankMath.api.root+"rankmath/v1/toolsAction",method:"POST",beforeSend:function(t){t.setRequestHeader("X-WP-Nonce",rankMath.restNonce)},data:{action:o,args:n}}).always((function(){e.removeAttr("disabled")})).fail((function(t){t&&(t.responseJSON&&t.responseJSON.message?a(t.responseJSON.message):a(t.statusText))})).done((function(t){if(t){if("update_seo_score"===o)return void h(t,e);if("string"==typeof t)return void a(t,"success",!1);if("object"===i(t)&&t.status&&t.message)return void a(t.message,t.status,!1)}a((0,s.__)("Something went wrong. Please try again later.","rank-math"))}))}t(".tools-action").on("click",(function(e){e.preventDefault();var a=t(this);return a.data("confirm")&&!confirm(a.data("confirm"))||(a.attr("disabled","disabled"),"update_seo_score"===a.data("action")&&t(".rank-math-modal-update-score").addClass("show"),f(a)),!1})),t(".rank-math-modal .rank-math-modal-close").on("click",(function(){if(void 0!==rankMath.startUpdateScore&&rankMath.startUpdateScore)return window.close(),!0;t(this).closest(".rank-math-modal").css("display","none")})),void 0!==rankMath.startUpdateScore&&rankMath.startUpdateScore&&t('.tools-action[data-action="update_seo_score"]').trigger("click");var m=t("tr.update_seo_score");if(m.length){var k=(0,s.__)("Include posts/pages where the score is already set","rank-math");rankMath.totalPostsWithoutScore>0&&m.find("td").append('<div class="update_all_scores"><label><input type="checkbox" name="update_all_scores" id="update_all_scores" value="1" checked="checked" /> '.concat(k,"</label></div>")),t("#update_all_scores").on("change",(function(){var e=t(this),a=m.find("a.button"),o=a.data("args")||{};o.update_all_scores=e.is(":checked")?1:0,a.data("args",o),d=e.is(":checked")?rankMath.totalPosts:rankMath.totalPostsWithoutScore,l=100/d,t(".count span.update-posts-total").text(d)})).trigger("change")}}))}();