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

1 line
35 KiB
JavaScript
Raw Normal View History

!function(r,o,d){var p=r(document);(o=o||{}).updates={},o.updates.ajaxNonce=d.ajax_nonce,o.updates.l10n=d.l10n,o.updates.searchTerm="",o.updates.shouldRequestFilesystemCredentials=!1,o.updates.filesystemCredentials={ftp:{host:"",username:"",password:"",connectionType:""},ssh:{publicKey:"",privateKey:""},fsNonce:"",available:!1},o.updates.ajaxLocked=!1,o.updates.adminNotice=o.template("wp-updates-admin-notice"),o.updates.queue=[],o.updates.$elToReturnFocusToFromCredentialsModal=void 0,o.updates.addAdminNotice=function(e){var t,a=r(e.selector),s=r(".wp-header-end");delete e.selector,t=o.updates.adminNotice(e),(a=!a.length?r("#"+e.id):a).length?a.replaceWith(t):s.length?s.after(t):"customize"===pagenow?r(".customize-themes-notifications").append(t):r(".wrap").find("> h1").after(t),p.trigger("wp-updates-notice-added")},o.updates.ajax=function(e,t){var a={};return o.updates.ajaxLocked?(o.updates.queue.push({action:e,data:t}),r.Deferred()):(o.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:o.updates.ajaxNonce,_fs_nonce:o.updates.filesystemCredentials.fsNonce,username:o.updates.filesystemCredentials.ftp.username,password:o.updates.filesystemCredentials.ftp.password,hostname:o.updates.filesystemCredentials.ftp.hostname,connection_type:o.updates.filesystemCredentials.ftp.connectionType,public_key:o.updates.filesystemCredentials.ssh.publicKey,private_key:o.updates.filesystemCredentials.ssh.privateKey}),o.ajax.send(a).always(o.updates.ajaxAlways))},o.updates.ajaxAlways=function(e){e.errorCode&&"unable_to_connect_to_filesystem"===e.errorCode||(o.updates.ajaxLocked=!1,o.updates.queueChecker()),void 0!==e.debug&&window.console&&window.console.log&&_.map(e.debug,function(e){window.console.log(o.sanitize.stripTagsAndEncodeText(e))})},o.updates.refreshCount=function(){var e,t=r("#wp-admin-bar-updates"),a=r('a[href="update-core.php"] .update-plugins'),s=r('a[href="plugins.php"] .update-plugins'),n=r('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?r(".subsubsub .upgrade .count").text("("+e+")"):(r(".subsubsub .upgrade").remove(),r(".subsubsub li:last").html(function(){return r(this).children()}))},o.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)),o.updates.refreshCount(e)},o.updates.updatePlugin=function(e){var t,a,s;return e=_.extend({success:o.updates.updatePluginSuccess,error:o.updates.updatePluginError},e),"plugins"===pagenow||"plugins-network"===pagenow?(a=(t=r('tr[data-plugin="'+e.plugin+'"]')).find(".update-message").removeClass("notice-error").addClass("updating-message notice-warning").find("p"),s=o.updates.l10n.pluginUpdatingLabel.replace("%s",t.find(".plugin-title strong").text())):"plugin-install"!==pagenow&&"plugin-install-network"!==pagenow||(a=(t=r(".plugin-card-"+e.slug)).find(".update-now").addClass("updating-message"),s=o.updates.l10n.pluginUpdatingLabel.replace("%s",a.data("name")),t.removeClass("plugin-card-update-failed").find(".notice.notice-error").remove()),a.html()!==o.