aboutsummaryrefslogtreecommitdiff
path: root/srcs/wordpress/wp-admin/js/updates.min.js
blob: b9a7089b73ccf0012a71460b12f85d9aa60f4689 (plain)
1
!function(o,p,d){var c=o(document);(p=p||{}).updates={},p.updates.ajaxNonce=d.ajax_nonce,p.updates.l10n=d.l10n,p.updates.searchTerm="",p.updates.shouldRequestFilesystemCredentials=!1,p.updates.filesystemCredentials={ftp:{host:"",username:"",password:"",connectionType:""},ssh:{publicKey:"",privateKey:""},fsNonce:"",available:!1},p.updates.ajaxLocked=!1,p.updates.adminNotice=p.template("wp-updates-admin-notice"),p.updates.queue=[],p.updates.$elToReturnFocusToFromCredentialsModal=void 0,p.updates.addAdminNotice=function(e){var t,a=o(e.selector),s=o(".wp-header-end");delete e.selector,t=p.updates.adminNotice(e),a.length||(a=o("#"+e.id)),a.length?a.replaceWith(t):s.length?s.after(t):"customize"===pagenow?o(".customize-themes-notifications").append(t):o(".wrap").find("> h1").after(t),c.trigger("wp-updates-notice-added")},p.updates.ajax=function(e,t){var a={};return p.updates.ajaxLocked?(p.updates.queue.push({action:e,data:t}),o.Deferred()):(p.updates.ajaxLocked=!0,t.success&&(a.success=t.success,delete t.success),t.error&&(a.error=t.error,delete t.error),a.data=_.extend(t,{action:e,_ajax_nonce:p.updates.ajaxNonce,_fs_nonce:p.updates.filesystemCredentials.fsNonce,username:p.updates.filesystemCredentials.ftp.username,password:p.updates.filesystemCredentials.ftp.password,hostname:p.updates.filesystemCredentials.ftp.hostname,connection_type:p.updates.filesystemCredentials.ftp.connectionType,public_key:p.updates.filesystemCredentials.ssh.publicKey,private_key:p.updates.filesystemCredentials.ssh.privateKey}),p.ajax.send(a).always(p.updates.ajaxAlways))},p.updates.ajaxAlways=function(e){e.errorCode&&"unable_to_connect_to_filesystem"===e.errorCode||(p.updates.ajaxLocked=!1,p.updates.queueChecker()),void 0!==e.debug&&window.console&&window.console.log&&_.map(e.debug,function(e){window.console.log(p.sanitize.stripTagsAndEncodeText(e))})},p.updates.refreshCount=function(){var e,t=o("#wp-admin-bar-updates"),a=o('a[href="update-core.php"] .update-plugins'),s=o('a[href="plugins.php"] .update-plugins'),n=o('a[href="themes.php"] .update-plugins');t.find(".ab-item").removeAttr("title"),t.find(".ab-label").text(d.totals.counts.total),0===d.totals.counts.total&&t.find(".ab-label").parents("li").remove(),a.each(function(e,t){t.className=t.className.replace(/count-\d+/,"count-"+d.totals.counts.total)}),0<d.totals.counts.total?a.find(".update-count").text(d.totals.counts.total):a.remove(),s.each(function(e,t){t.className=t.className.replace(/count-\d+/,"count-"+d.totals.counts.plugins)}),0<d.totals.counts.total?s.find(".plugin-count").text(d.totals.counts.plugins):s.remove(),n.each(function(e,t){t.className=t.className.replace(/count-\d+/,"count-"+d.totals.counts.themes)}),0<d.totals.counts.total?n.find(".theme-count").text(d.totals.counts.themes):n.remove(),"plugins"===pagenow||"plugins-network"===pagenow?e=d.totals.counts.plugins:"themes"!==pagenow&&"themes-network"!==pagenow||(e=d.totals.counts.themes),0<e?o(".subsubsub .upgrade .count").text("("+e+")"):(o(".subsubsub .upgrade").remove(),o(".subsubsub li:last").html(function(){return o(this).children()}))},p.updates.decrementCount=function(e){d.totals.counts.total=Math.max(--d.totals.counts.total,0),"plugin"===e?d.totals.counts.plugins=Math.max(--d.totals.counts.plugins,0):"theme"===e&&(d.totals.counts.themes=Math.max(--d.totals.counts.themes,0)),p.updates.refreshCount(e)},p.updates.updatePlugin=function(e){var t,a,s,n;return e=_.extend({success:p.updates.updatePluginSuccess,error:p.updates.updatePluginError},e),"plugins"===pagenow||"plugins-network"===pagenow?(s=(t=o('tr[data-plugin="'+e.plugin+'"]')).find(".update-message").removeClass("notice-error").addClass("updating-message notice-warning").find("p"),n=p.updates.l10n.pluginUpdatingLabel.replace("%s",t.find(".plugin-title strong").text())):"plugin-install"!==pagenow&&"plugin-install-network"!==pagenow||(s=(a=o(".plugin-card-"+e.slug)).find(".update-now").addClass("updating-message"),n=p.updates.l10n.pluginUpdatingLabel.replace("%s",s.data("name")),a.removeClass("plugin-card-update-failed").find(".notice.notice-error").remove()),s.html()!==p.updates.l10n.updating&&s.data("originaltext",s.html()),s.attr("aria-label",n).text(p.updates.l10n.updating),c.trigger("wp-plugin-updating",e),p.updates.ajax("update-plugin",e)},p.updates.updatePluginSuccess=function(e){var t,a,s;"plugins"===pagenow||"plugins-network"===pagenow?(a=(t=o('tr[data-plugin="'+e.plugin+'"]').removeClass("update").addClass("updated")).find(".update-message").removeClass("updating-message notice-warning").addClass("updated-message notice-success").find("p"),s=t.find(".plugin-version-author-uri").html().replace(e.oldVersion,e.newVersion),t.find(".plugin-version-author-uri").html(s)):"plugin-install"!==pagenow&&"plugin-install-network"!==pagenow||(a=o(".plugin-card-"+e.slug).find(".update-now").removeClass("updating-message").addClass("button-disabled updated-message")),a.attr("aria-label",p.updates.l10n.pluginUpdatedLabel.replace("%s",e.pluginName)).text(p.updates.l10n.pluginUpdated),p.a11y.speak(p.updates.l10n.updatedMsg,"polite"),p.updates.decrementCount("plugin"),c.trigger("wp-plugin-update-success",e)},p.updates.updatePluginError=function(e){var t,a,s;p.updates.isValidResponse(e,"update")&&(p.updates.maybeHandleCredentialError(e,"update-plugin")||(s=p.updates.l10n.updateFailed.replace("%s",e.errorMessage),"plugins"===pagenow||"plugins-network"===pagenow?((a=e.plugin?o('tr[data-plugin="'+e.plugin+'"]').find(".update-message"):o('tr[data-slug="'+e.slug+'"]').find(".update-message")).removeClass("updating-message notice-warning").addClass("notice-error").find("p").html(s),e.pluginName?a.find("p").attr("aria-label",p.updates.l10n.pluginUpdateFailedLabel.replace("%s",e.pluginName)):a.find("p").removeAttr("aria-label")):"plugin-install"!==pagenow&&"plugin-install-network"!==pagenow||((t=o(".plugin-card-"+e.slug).addClass("plugin-card-update-failed").append(p.updates.adminNotice({className:"update-message notice-error notice-alt is-dismissible",message:s}))).find(".update-now").text(p.updates.l10n.updateFailedShort).removeClass("updating-message"),e.pluginName?t.find(".update-now").attr("aria-label",p.updates.l10n.pluginUpdateFailedLabel.replace("%s",e.pluginName)):t.find(".update-now").removeAttr("aria-label"),t.on("click",".notice.is-dismissible .notice-dismiss",function(){setTimeout(function(){t.removeClass("plugin-card-update-failed").find(".column-name a").focus(),t.find(".update-now").attr("aria-label",!1).text(p.updates.l10n.updateNow)},200)})),p.a11y.speak(s,"assertive"),c.trigger("wp-plugin-update-error",e)))},p.updates.installPlugin=function(e){var t=o(".plugin-card-"+e.slug),a=t.find(".install-now");return e=_.extend({success:p.updates.installPluginSuccess,error:p.updates.installPluginError},e),"import"===pagenow&&(a=o('[data-slug="'+e.slug+'"]')),a.html()!==p.updates.l10n.installing&&a.data("originaltext",a.html()),a.addClass("updating-message").attr("aria-label",p.updates.l10n.pluginInstallingLabel.replace("%s",a.data("name"))).text(p.updates.l10n.installing),p.a11y.speak(p.updates.l10n.installingMsg,"polite"),t.removeClass("plugin-card-install-failed").find(".notice.notice-error").remove(),c.trigger("wp-plugin-installing",e),p.updates.ajax("install-plugin",e)},p.updates.installPluginSuccess=function(e){var t=o(".plugin-card-"+e.slug).find(".install-now");t.removeClass("updating-message").addClass("updated-message installed button-disabled").attr("aria-label",p.updates.l10n.pluginInstalledLabel.replace("%s",e.pluginName)).text(p.updates.l10n.pluginInstalled),p.a11y.speak(p.updates.l10n.installedMsg,"polite"),c.trigger("wp-plugin-install-success",e),e.activateUrl&&setTimeout(function(){t.removeClass("install-now installed button-disabled updated-message").addClass("activate-now button-primary").attr("href",e.activateUrl).attr("aria-label",p.updates.l10n.activatePluginLabel.replace("%s",e.pluginName)).text(p.updates.l10n.activatePlugin)},1e3)},p.updates.installPluginError=function(e){var t,a=o(".plugin-card-"+e.slug),s=a.find(".install-now");p.updates.isValidResponse(e,"install")&&(p.updates.maybeHandleCredentialError(e,"install-plugin")|