WordPress/wp-admin/js/updates.min.js

1 line
32 KiB
JavaScript
Raw Permalink Normal View History

!function(r,p,d){var o=r(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 a,t=r(e.selector);delete e.selector,a=p.updates.adminNotice(e),(t=!t.length?r("#"+e.id):t).length?t.replaceWith(a):r(".wrap").find("> h1").after(a),o.trigger("wp-updates-notice-added")},p.updates.ajax=function(e,a){var t={};return p.updates.ajaxLocked?(p.updates.queue.push({action:e,data:a}),r.Deferred()):(p.updates.ajaxLocked=!0,a.success&&(t.success=a.success,delete a.success),a.error&&(t.error=a.error,delete a.error),t.data=_.extend(a,{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(t).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(r("<p />").html(e).text())})},p.updates.decrementCount=function(e){var a,t,s,n=r("#wp-admin-bar-updates"),l=r('a[href="update-core.php"] .update-plugins'),i=n.find(".ab-label").text();(i=parseInt(i,10)-1)<0||isNaN(i)||(n.find(".ab-item").removeAttr("title"),n.find(".ab-label").text(i),i||n.find(".ab-label").parents("li").remove(),l.each(function(e,a){a.className=a.className.replace(/count-\d+/,"count-"+i)}),l.removeAttr("title"),l.find(".update-count").text(i),"plugin"===e?t=(a=r("#menu-plugins")).find(".plugin-count"):"theme"===e&&(t=(a=r("#menu-appearance")).find(".theme-count")),t&&(s=t.eq(0).text(),s=parseInt(s,10)-1),s<0||isNaN(s)||(0<s?(r(".subsubsub .upgrade .count").text("("+s+")"),t.text(s),a.find(".update-plugins").each(function(e,a){a.className=a.className.replace(/count-\d+/,"count-"+s)})):(r(".subsubsub .upgrade").remove(),a.find(".update-plugins").remove())))},p.updates.updatePlugin=function(e){var a,t,s;return e=_.extend({success:p.updates.updatePluginSuccess,error:p.updates.updatePluginError},e),"plugins"===pagenow||"plugins-network"===pagenow?(t=(a=r('tr[data-plugin="'+e.plugin+'"]')).find(".update-message").removeClass("notice-error").addClass("updating-message notice-warning").find("p"),s=p.updates.l10n.updatingLabel.replace("%s",a.find(".plugin-title strong").text())):"plugin-install"!==pagenow&&"plugin-install-network"!==pagenow||(t=(a=r(".plugin-card-"+e.slug)).find(".update-now").addClass("updating-message"),s=p.updates.l10n.updatingLabel.replace("%s",t.data("name")),a.removeClass("plugin-card-update-failed").find(".notice.notice-error").remove()),t.html()!==p.updates.l10n.updating&&t.data("originaltext",t.html()),t.attr("aria-label",s).text(p.updates.l10n.updating),o.trigger("wp-plugin-updating",e),p.updates.ajax("update-plugin",e)},p.updates.updatePluginSuccess=function(e){var a,t,s;"plugins"===pagenow||"plugins-network"===pagenow?(t=(a=r('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=a.find(".plugin-version-author-uri").html().replace(e.oldVersion,e.newVersion),a.find(".plugin-version-author-uri").html(s)):"plugin-install"!==pagenow&&"plugin-install-network"!==pagenow||(t=r(".plugin-card-"+e.slug).find(".update-now").removeClass("updating-message").addClass("button-disable