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

1 line
32 KiB
JavaScript

!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-disabled updated-message")),t.attr("aria-label",p.updates.l10n.updatedLabel.replace("%s",e.pluginName)).text(p.updates.l10n.updated),p.a11y.speak(p.updates.l10n.updatedMsg,"polite"),p.updates.decrementCount("plugin"),o.trigger("wp-plugin-update-success",e)},p.updates.updatePluginError=function(e){var a,t,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?((t=(e.plugin?r('tr[data-plugin="'+e.plugin+'"]'):r('tr[data-slug="'+e.slug+'"]')).find(".update-message")).removeClass("updating-message notice-warning").addClass("notice-error").find("p").html(s),e.pluginName?t.find("p").attr("aria-label",p.updates.l10n.updateFailedLabel.replace("%s",e.pluginName)):t.find("p").removeAttr("aria-label")):"plugin-install"!==pagenow&&"plugin-install-network"!==pagenow||((a=r(".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?a.find(".update-now").attr("aria-label",p.updates.l10n.updateFailedLabel.replace("%s",e.pluginName)):a.find(".update-now").removeAttr("aria-label"),a.on("click",".notice.is-dismissible .notice-dismiss",function(){setTimeout(function(){a.removeClass("plugin-card-update-failed").find(".column-name a").focus(),a.find(".update-now").attr("aria-label",!1).text(p.updates.l10n.updateNow)},200)})),p.a11y.speak(s,"assertive"),o.trigger("wp-plugin-update-error",e)))},p.updates.installPlugin=function(e){var a=r(".plugin-card-"+e.slug),t=a.find(".install-now");return e=_.extend({success:p.updates.installPluginSuccess,error:p.updates.installPluginError},e),(t="import"===pagenow?r('[data-slug="'+e.slug+'"]'):t).html()!==p.updates.l10n.installing&&t.data("originaltext",t.html()),t.addClass("updating-message").attr("aria-label",p.updates.l10n.pluginInstallingLabel.replace("%s",t.data("name"))).text(p.updates.l10n.installing),p.a11y.speak(p.updates.l10n.installingMsg,"polite"),a.removeClass("plugin-card-install-failed").find(".notice.notice-error").remove(),o.trigger("wp-plugin-installing",e),p.updates.ajax("install-plugin",e)},p.updates.installPluginSuccess=function(e){var a=r(".plugin-card-"+e.slug).find(".install-now");a.removeClass("updating-message").addClass("updated-message installed button-disabled").attr("aria-label",p.updates.l10n.pluginInstalledLabel.replace("%s",e.pluginName)).text(p.updates.l10n.installed),p.a11y.speak(p.updates.l10n.installedMsg,"polite"),o.trigger("wp-plugin-install-success",e),e.activateUrl&&setTimeout(function(){a.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 a,t=r(".plugin-card-"+e.slug),s=t.find(".install-now");p.updates.isValidResponse(e,"install")&&(p.updates.maybeHandleCredentialError(e,"install-plugin")||(a=p.updates.l10n.installFailed.replace("%s",e.errorMessage),t.addClass("plugin-card-update-failed").append('<div class="notice notice-error notice-alt is-dismissible"><p>'+a+"</p></div>"),t.on("click",".notice.is-dismissible .notice-dismiss",function(){setTimeout(function(){t.removeClass("plugin-card-update-failed").find(".column-name a").focus()},200)}),s.removeClass("updating-message").addClass("button-disabled").attr("aria-label",p.updates.l10n.pluginInstallFailedLabel.replace("%s",s.data("name"))).text(p.updates.l10n.installFailedShort),p.a11y.speak(a,"assertive"),o.trigger("wp-plugin-install-error",e)))},p.updates.installImporterSuccess=function(e){p.updates.addAdminNotice({id:"install-success",className:"notice-success is-dismissible",message:p.updates.l10n.importerInstalledMsg.replace("%s",e.activateUrl+"&from=import")}),r('[data-slug="'+e.slug+'"]').removeClass("install-now updating-message").addClass("activate-now").attr({href:e.activateUrl+"&from=import","aria-label":p.updates.l10n.activateImporterLabel.replace("%s",e.pluginName)}).text(p.updates.l10n.activateImporter),p.a11y.speak(p.updates.l10n.installedMsg,"polite"),o.trigger("wp-importer-install-success",e)},p.updates.installImporterError=function(e){var a=p.updates.l10n.installFailed.replace("%s",e.errorMessage),t=r('[data-slug="'+e.slug+'"]'),s=t.data("name");p.updates.isValidResponse(e,"install")&&(p.updates.maybeHandleCredentialError(e,"install-plugin")||(p.updates.addAdminNotice({id:e.errorCode,className:"notice-error is-dismissible",message:a}),t.removeClass("updating-message").text(p.updates.l10n.installNow).attr("aria-label",p.updates.l10n.installNowLabel.replace("%s",s)),p.a11y.speak(a,"assertive"),o.trigger("wp-importer-install-error",e)))},p.updates.deletePlugin=function(e){var a=r('[data-plugin="'+e.plugin+'"]').find(".row-actions a.delete");return e=_.extend({success:p.updates.deletePluginSuccess,error:p.updates.deletePluginError},e),a.html()!==p.updates.l10n.deleting&&a.data("originaltext",a.html()).text(p.updates.l10n.deleting),p.a11y.speak(p.updates.l10n.deleting,"polite"),o.trigger("wp-plugin-deleting",e),p.updates.ajax("delete-plugin",e)},p.updates.deletePluginSuccess=function(i){r('[data-plugin="'+i.plugin+'"]').css({backgroundColor:"#faafaa"}).fadeOut(350,function(){var e=r("#bulk-action-form"),a=r(".subsubsub"),t=r(this),s=e.find("thead th:not(.hidden), thead td").length,n=p.template("item-deleted-row"),l=d.plugins;t.hasClass("plugin-update-tr")||t.after(n({slug:i.slug,plugin:i.plugin,colspan:s,name:i.pluginName})),t.remove(),-1!==_.indexOf(l.upgrade,i.plugin)&&(l.upgrade=_.without(l.upgrade,i.plugin),p.updates.decrementCount("plugin")),-1!==_.indexOf(l.inactive,i.plugin)&&(l.inactive=_.without(l.inactive,i.plugin),l.inactive.length?a.find(".inactive .count").text("("+l.inactive.length+")"):a.find(".inactive").remove()),-1!==_.indexOf(l.active,i.plugin)&&(l.active=_.without(l.active,i.plugin),l.active.length?a.find(".active .count").text("("+l.active.length+")"):a.find(".active").remove()),-1!==_.indexOf(l.recently_activated,i.plugin)&&(l.recently_activated=_.without(l.recently_activated,i.plugin),l.recently_activated.length?a.find(".recently_activated .count").text("("+l.recently_activated.length+")"):a.find(".recently_activated").remove()),l.all=_.without(l.all,i.plugin),l.all.length?a.find(".all .count").text("("+l.all.length+")"):(e.find(".tablenav").css({visibility:"hidden"}),a.find(".all").remove(),e.find("tr.no-items").length||e.find("#the-list").append('<tr class="no-items"><td class="colspanchange" colspan="'+s+'">'+p.updates.l10n.noPlugins+"</td></tr>"))}),p.a11y.speak(p.updates.l10n.deleted,"polite"),o.trigger("wp-plugin-delete-success",i)},p.updates.deletePluginError=function(e){var a,t=p.template("item-update-row"),s=p.updates.adminNotice({className:"update-message notice-error notice-alt",message:e.errorMessage}),n=e.plugin?(a=r('tr.inactive[data-plugin="'+e.plugin+'"]')).siblings('[data-plugin="'+e.plugin+'"]'):(a=r('tr.inactive[data-slug="'+e.slug+'"]')).siblings('[data-slug="'+e.slug+'"]');p.updates.isValidResponse(e,"delete")&&(p.updates.maybeHandleCredentialError(e,"delete-plugin")||(n.length?(n.find(".notice-error").remove(),n.find(".plugin-update").append(s)):a.addClass("update").after(t({slug:e.slug,plugin:e.plugin||e.slug,colspan:r("#bulk-action-form").find("thead th:not(.hidden), thead td").length,content:s})),o.trigger("wp-plugin-delete-error",e)))},p.updates.updateTheme=function(e){var a;return e=_.extend({success:p.updates.updateThemeSuccess,error:p.updates.updateThemeError},e),(a="themes-network"===pagenow?r('[data-slug="'+e.slug+'"]').find(".update-message").removeClass("notice-error").addClass("updating-message notice-warning").find("p"):((a=r("#update-theme").closest(".notice").removeClass("notice-large")).find("h3").remove(),(a=a.add(r('[data-slug="'+e.slug+'"]').find(".update-message"))).addClass("updating-message").find("p"))).html()!==p.updates.l10n.updating&&a.data("originaltext",a.html()),p.a11y.speak(p.updates.l10n.updatingMsg,"polite"),a.text(p.updates.l10n.updating),o.trigger("wp-theme-updating",e),p.updates.ajax("update-theme",e)},p.updates.updateThemeSuccess=function(e){var a,t,s=r("body.modal-open").length,n=r('[data-slug="'+e.slug+'"]'),l={className:"updated-message notice-success notice-alt",message:p.updates.l10n.updated};"themes-network"===pagenow?(a=n.find(".update-message"),t=n.find(".theme-version-author-uri").html().replace(e.oldVersion,e.newVersion),n.find(".theme-version-author-uri").html(t)):(a=r(".theme-info .notice").add(n.find(".update-message")),(s?r(".load-customize:visible"):n.find(".load-customize")).focus()),p.updates.addAdminNotice(_.extend({selector:a},l)),p.a11y.speak(p.updates.l10n.updatedMsg,"polite"),p.updates.decrementCount("theme"),o.trigger("wp-theme-update-success",e),s&&r(".theme-info .theme-author").after(p.updates.adminNotice(l))},p.updates.updateThemeError=function(e){var a,t=r('[data-slug="'+e.slug+'"]'),s=p.updates.l10n.updateFailed.replace("%s",e.errorMessage);p.updates.isValidResponse(e,"update")&&(p.updates.maybeHandleCredentialError(e,"update-theme")||("themes-network"===pagenow?a=t.find(".update-message "):(a=r(".theme-info .notice").add(t.find(".notice")),(r("body.modal-open").length?r(".load-customize:visible"):t.find(".load-customize")).focus()),p.updates.addAdminNotice({selector:a,className:"update-message notice-error notice-alt is-dismissible",message:s}),p.a11y.speak(s,"polite"),o.trigger("wp-theme-update-error",e)))},p.updates.installTheme=function(e){var a=r('.theme-install[data-slug="'+e.slug+'"]');return e=_.extend({success:p.updates.installThemeSuccess,error:p.updates.installThemeError},e),a.addClass("updating-message"),a.parents(".theme").addClass("focus"),a.html()!==p.updates.l10n.installing&&a.data("originaltext",a.html()),a.text(p.updates.l10n.installing).attr("aria-label",p.updates.l10n.themeInstallingLabel.replace("%s",a.data("name"))),p.a11y.speak(p.updates.l10n.installingMsg,"polite"),r('.install-theme-info, [data-slug="'+e.slug+'"]').removeClass("theme-install-failed").find(".notice.notice-error").remove(),o.trigger("wp-theme-installing",e),p.updates.ajax("install-theme",e)},p.updates.installThemeSuccess=function(e){var a,t=r(".wp-full-overlay-header, [data-slug="+e.slug+"]");o.trigger("wp-theme-install-success",e),a=t.find(".button-primary").removeClass("updating-message").addClass("updated-message disabled").attr("aria-label",p.updates.l10n.themeInstalledLabel.replace("%s",e.themeName)).text(p.updates.l10n.installed),p.a11y.speak(p.updates.l10n.installedMsg,"polite"),setTimeout(function(){e.activateUrl&&a.attr("href",e.activateUrl).removeClass("theme-install updated-message disabled").addClass("activate").attr("aria-label",p.updates.l10n.activateThemeLabel.replace("%s",e.themeName)).text(p.updates.l10n.activateTheme),e.customizeUrl&&a.siblings(".preview").replaceWith(function(){return r("<a>").attr("href",e.customizeUrl).addClass("button button-secondary load-customize").text(p.updates.l10n.livePreview)})},1e3)},p.updates.installThemeError=function(e){var a,t=p.updates.l10n.installFailed.replace("%s",e.errorMessage),s=p.updates.adminNotice({className:"update-message notice-error notice-alt",message:t});p.updates.isValidResponse(e,"install")&&(p.updates.maybeHandleCredentialError(e,"install-theme")||(o.find("body").hasClass("full-overlay-active")?(a=r('.theme-install[data-slug="'+e.slug+'"]'),r(".install-theme-info").prepend(s)):a=r('[data-slug="'+e.slug+'"]').removeClass("focus").addClass("theme-install-failed").append(s).find(".theme-install"),a.removeClass("updating-message").attr("aria-label",p.updates.l10n.themeInstallFailedLabel.replace("%s",a.data("name"))).text(p.updates.l10n.installFailedShort),p.a11y.speak(t,"assertive"),o.trigger("wp-theme-install-error",e)))},p.updates.deleteTheme=function(e){var a;return"themes"===pagenow?a=r(".theme-actions .delete-theme"):"themes-network"===pagenow&&(a=r('[data-slug="'+e.slug+'"]').find(".row-actions a.delete")),e=_.extend({success:p.updates.deleteThemeSuccess,error:p.updates.deleteThemeError},e),a&&a.html()!==p.updates.l10n.deleting&&a.data("originaltext",a.html()).text(p.updates.l10n.deleting),p.a11y.speak(p.updates.l10n.deleting,"polite"),r(".theme-info .update-message").remove(),o.trigger("wp-theme-deleting",e),p.updates.ajax("delete-theme",e)},p.updates.deleteThemeSuccess=function(n){var e=r('[data-slug="'+n.slug+'"]');"themes-network"===pagenow&&e.css({backgroundColor:"#faafaa"}).fadeOut(350,function(){var e=r(".subsubsub"),a=r(this),t=d.totals,s=p.template("item-deleted-row");a.hasClass("plugin-update-tr")||a.after(s({slug:n.slug,colspan:r("#bulk-action-form").find("thead th:not(.hidden), thead td").length,name:a.find(".theme-title strong").text()})),a.remove(),a.hasClass("update")&&(t.upgrade--,p.updates.decrementCount("theme")),a.hasClass("inactive")&&(t.disabled--,t.disabled?e.find(".disabled .count").text("("+t.disabled+")"):e.find(".disabled").remove()),e.find(".all .count").text("("+--t.all+")")}),p.a11y.speak(p.updates.l10n.deleted,"polite"),o.trigger("wp-theme-delete-success",n)},p.updates.deleteThemeError=function(e){var a=r('tr.inactive[data-slug="'+e.slug+'"]'),t=r(".theme-actions .delete-theme"),s=p.template("item-update-row"),n=a.siblings("#"+e.slug+"-update"),l=p.updates.l10n.deleteFailed.replace("%s",e.errorMessage),i=p.updates.adminNotice({className:"update-message notice-error notice-alt",message:l});p.updates.maybeHandleCredentialError(e,"delete-theme")||("themes-network"===pagenow?n.length?(n.find(".notice-error").remove(),n.find(".plugin-update").append(i)):a.addClass("update").after(s({slug:e.slug,colspan:r("#bulk-action-form").find("thead th:not(.hidden), thead td").length,content:i})):r(".theme-info .theme-description").before(i),t.html(t.data("originaltext")),p.a11y.speak(l,"assertive"),o.trigger("wp-theme-delete-error",e))},p.updates._addCallbacks=function(e,a){return"import"===pagenow&&"install-plugin"===a&&(e.success=p.updates.installImporterSuccess,e.error=p.updates.installImporterError),e},p.updates.queueChecker=function(){var e;if(!p.updates.ajaxLocked&&p.updates.queue.length)switch((e=p.updates.queue.shift()).action){case"install-plugin":p.updates.installPlugin(e.data);break;case"update-plugin":p.updates.updatePlugin(e.data);break;case"delete-plugin":p.updates.deletePlugin(e.data);break;case"install-theme":p.updates.installTheme(e.data);break;case"update-theme":p.updates.updateTheme(e.data);break;case"delete-theme":p.updates.deleteTheme(e.data)}},p.updates.requestFilesystemCredentials=function(e){!1===p.updates.filesystemCredentials.available&&(e&&!p.updates.$elToReturnFocusToFromCredentialsModal&&(p.updates.$elToReturnFocusToFromCredentialsModal=r(e.target)),p.updates.ajaxLocked=!0,p.updates.requestForCredentialsModalOpen())},p.updates.maybeRequestFilesystemCredentials=function(e){p.updates.shouldRequestFilesystemCredentials&&!p.updates.ajaxLocked&&p.updates.requestFilesystemCredentials(e)},p.updates.keydown=function(e){27===e.keyCode?p.updates.requestForCredentialsModalCancel():9===e.keyCode&&("upgrade"!==e.target.id||e.shiftKey?"hostname"===e.target.id&&e.shiftKey&&(r("#upgrade").focus(),e.preventDefault()):(r("#hostname").focus(),e.preventDefault()))},p.updates.requestForCredentialsModalOpen=function(){var e=r("#request-filesystem-credentials-dialog");r("body").addClass("modal-open"),e.show(),e.find("input:enabled:first").focus(),e.on("keydown",p.updates.keydown)},p.updates.requestForCredentialsModalClose=function(){r("#request-filesystem-credentials-dialog").hide(),r("body").removeClass("modal-open"),p.updates.$elToReturnFocusToFromCredentialsModal&&p.updates.$elToReturnFocusToFromCredentialsModal.focus()},p.updates.requestForCredentialsModalCancel=function(){(p.updates.ajaxLocked||p.updates.queue.length)&&(_.each(p.updates.queue,function(e){o.trigger("credential-modal-cancel",e)}),p.updates.ajaxLocked=!1,p.updates.queue=[],p.updates.requestForCredentialsModalClose())},p.updates.showErrorInCredentialsForm=function(e){var a=r("#request-filesystem-credentials-form");a.find(".notice").remove(),a.find("#request-filesystem-credentials-title").after('<div class="notice notice-alt notice-error"><p>'+e+"</p></div>")},p.updates.credentialError=function(e,a){e=p.updates._addCallbacks(e,a),p.updates.queue.unshift({action:a,data:e}),p.updates.filesystemCredentials.available=!1,p.updates.showErrorInCredentialsForm(e.errorMessage),p.updates.requestFilesystemCredentials()},p.updates.maybeHandleCredentialError=function(e,a){return!(!p.updates.shouldRequestFilesystemCredentials||!e.errorCode||"unable_to_connect_to_filesystem"!==e.errorCode)&&(p.updates.credentialError(e,a),!0)},p.updates.isValidResponse=function(e,a){var t,s=p.updates.l10n.unknownError;if(_.isObject(e)&&!_.isFunction(e.always))return!0;switch(_.isString(e)&&"-1"===e?s=p.updates.l10n.nonceError:_.isString(e)?s=e:void 0!==e.readyState&&0===e.readyState?s=p.updates.l10n.connectionError:_.isString(e.responseText)&&""!==e.responseText?s=e.responseText:_.isString(e.statusText)&&(s=e.statusText),a){case"update":t=p.updates.l10n.updateFailed;break;case"install":t=p.updates.l10n.installFailed;break;case"delete":t=p.updates.l10n.deleteFailed}return s=s.replace(/<[\/a-z][^<>]*>/gi,""),t=t.replace("%s",s),p.updates.addAdminNotice({id:"unknown_error",className:"notice-error is-dismissible",message:_.escape(t)}),p.updates.ajaxLocked=!1,p.updates.queue=[],r(".button.updating-message").removeClass("updating-message").removeAttr("aria-label").prop("disabled",!0).text(p.updates.l10n.updateFailedShort),r(".updating-message:not(.button):not(.thickbox)").removeClass("updating-message notice-warning").addClass("notice-error").find("p").removeAttr("aria-label").text(t),p.a11y.speak(t,"assertive"),!1},p.updates.beforeunload=function(){if(p.updates.ajaxLocked)return p.updates.l10n.beforeunload},r(function(){var l=r("#plugin-filter"),u=r("#bulk-action-form"),e=r("#request-filesystem-credentials-dialog"),a=r(".plugins-php .wp-filter-search"),t=r(".plugin-install-php .wp-filter-search");p.updates.shouldRequestFilesystemCredentials=0<e.length,e.on("submit","form",function(e){e.preventDefault(),p.updates.filesystemCredentials.ftp.hostname=r("#hostname").val(),p.updates.filesystemCredentials.ftp.username=r("#username").val(),p.updates.filesystemCredentials.ftp.password=r("#password").val(),p.updates.filesystemCredentials.ftp.connectionType=r('input[name="connection_type"]:checked').val(),p.updates.filesystemCredentials.ssh.publicKey=r("#public_key").val(),p.updates.filesystemCredentials.ssh.privateKey=r("#private_key").val(),p.updates.filesystemCredentials.fsNonce=r("#_fs_nonce").val(),p.updates.filesystemCredentials.available=!0,p.updates.ajaxLocked=!1,p.updates.queueChecker(),p.updates.requestForCredentialsModalClose()}),e.on("click",'[data-js-action="close"], .notification-dialog-background',p.updates.requestForCredentialsModalCancel),e.on("change",'input[name="connection_type"]',function(){r("#ssh-keys").toggleClass("hidden","ssh"!==r(this).val())}).change(),o.on("credential-modal-cancel",function(e,a){var t,s=r(".updating-message");"import"===pagenow?s.removeClass("updating-message"):"plugins"===pagenow||"plugins-network"===pagenow?"update-plugin"===a.action?t=r('tr[data-plugin="'+a.data.plugin+'"]').find(".update-message"):"delete-plugin"===a.action&&(t=r('[data-plugin="'+a.data.plugin+'"]').find(".row-actions a.delete")):"themes"===pagenow||"themes-network"===pagenow?"update-theme"===a.action?t=r('[data-slug="'+a.data.slug+'"]').find(".update-message"):"delete-theme"===a.action&&"themes-network"===pagenow?t=r('[data-slug="'+a.data.slug+'"]').find(".row-actions a.delete"):"delete-theme"===a.action&&"themes"===pagenow&&(t=r(".theme-actions .delete-theme")):t=s,t&&t.hasClass("updating-message")&&(void 0===(s=t.data("originaltext"))&&(s=r("<p>").html(t.find("p").data("originaltext"))),t.removeClass("updating-message").html(s),"plugin-install"!==pagenow&&"plugin-install-network"!==pagenow||("update-plugin"===a.action?t.attr("aria-label",p.updates.l10n.updateNowLabel.replace("%s",t.data("name"))):"install-plugin"===a.action&&t.attr("aria-label",p.updates.l10n.installNowLabel.replace("%s",t.data("name"))))),p.a11y.speak(p.updates.l10n.updateCancel,"polite")}),u.on("click","[data-plugin] .update-link",function(e){var a=r(e.target),t=a.parents("tr");e.preventDefault(),a.hasClass("updating-message")||a.hasClass("button-disabled")||(p.updates.maybeRequestFilesystemCredentials(e),p.updates.$elToReturnFocusToFromCredentialsModal=t.find(".check-column input"),p.updates.updatePlugin({plugin:t.data("plugin"),slug:t.data("slug")}))}),l.on("click",".update-now",function(e){var a=r(e.target);e.preventDefault(),a.hasClass("updating-message")||a.hasClass("button-disabled")||(p.updates.maybeRequestFilesystemCredentials(e),p.updates.updatePlugin({plugin:a.data("plugin"),slug:a.data("slug")}))}),l.on("click",".install-now",function(e){var a=r(e.target);e.preventDefault(),a.hasClass("updating-message")||a.hasClass("button-disabled")||(p.updates.shouldRequestFilesystemCredentials&&!p.updates.ajaxLocked&&(p.updates.requestFilesystemCredentials(e),o.on("credential-modal-cancel",function(){r(".install-now.updating-message").removeClass("updating-message").text(p.updates.l10n.installNow),p.a11y.speak(p.updates.l10n.updateCancel,"polite")})),p.updates.installPlugin({slug:a.data("slug")}))}),o.on("click",".importer-item .install-now",function(e){var a=r(e.target),t=r(this).data("name");e.preventDefault(),a.hasClass("updating-message")||(p.updates.shouldRequestFilesystemCredentials&&!p.updates.ajaxLocked&&(p.updates.requestFilesystemCredentials(e),o.on("credential-modal-cancel",function(){a.removeClass("updating-message").text(p.updates.l10n.installNow).attr("aria-label",p.updates.l10n.installNowLabel.replace("%s",t)),p.a11y.speak(p.updates.l10n.updateCancel,"polite")})),p.updates.installPlugin({slug:a.data("slug"),success:p.updates.installImporterSuccess,error:p.updates.installImporterError}))}),u.on("click","[data-plugin] a.delete",function(e){var a=r(e.target).parents("tr");e.preventDefault(),window.confirm(p.updates.l10n.aysDeleteUninstall.replace("%s",a.find(".plugin-title strong").text()))&&(p.updates.maybeRequestFilesystemCredentials(e),p.updates.deletePlugin({plugin:a.data("plugin"),slug:a.data("slug")}))}),o.on("click",".themes-php.network-admin .update-link",function(e){var a=r(e.target),t=a.parents("tr");e.preventDefault(),a.hasClass("updating-message")||a.hasClass("button-disabled")||(p.updates.maybeRequestFilesystemCredentials(e),p.updates.$elToReturnFocusToFromCredentialsModal=t.find(".check-column input"),p.updates.updateTheme({slug:t.data("slug")}))}),o.on("click",".themes-php.network-admin a.delete",function(e){var a=r(e.target).parents("tr");e.preventDefault(),window.confirm(p.updates.l10n.aysDelete.replace("%s",a.find(".theme-title strong").text()))&&(p.updates.maybeRequestFilesystemCredentials(e),p.updates.deleteTheme({slug:a.data("slug")}))}),u.on("click",'[type="submit"]',function(e){var a,s,n=r(e.target).siblings("select").val(),t=u.find('input[name="checked[]"]:checked'),l=0,i=0,d=[];switch(pagenow){case"plugins":case"plugins-network":a="plugin";break;case"themes-network":a="theme";break;default:return}if(!t.length)return e.preventDefault(),r("html, body").animate({scrollTop:0}),p.updates.addAdminNotice({id:"no-items-selected",className:"notice-error is-dismissible",message:p.updates.l10n.noItemsSelected});switch(n){case"update-selected":s=n.replace("selected",a);break;case"delete-selected":if(!window.confirm("plugin"===a?p.updates.l10n.aysBulkDelete:p.updates.l10n.aysBulkDeleteThemes))return void e.preventDefault();s=n.replace("selected",a);break;default:return}p.updates.maybeRequestFilesystemCredentials(e),e.preventDefault(),u.find('.manage-column [type="checkbox"]').prop("checked",!1),o.trigger("wp-"+a+"-bulk-"+n,t),t.each(function(e,a){var t=r(a),a=t.parents("tr");"update-selected"!==n||a.hasClass("update")&&!a.find("notice-error").length?p.updates.queue.push({action:s,data:{plugin:a.data("plugin"),slug:a.data("slug")}}):t.prop("checked",!1)}),o.on("wp-plugin-update-success wp-plugin-update-error wp-theme-update-success wp-theme-update-error",function(e,a){var t,s=r('[data-slug="'+a.slug+'"]');"wp-"+a.update+"-update-success"===e.type?l++:(e=a.pluginName||s.find(".column-primary strong").text(),i++,d.push(e+": "+a.errorMessage)),s.find('input[name="checked[]"]:checked').prop("checked",!1),p.updates.adminNotice=p.template("wp-bulk-updates-admin-notice"),p.updates.addAdminNotice({id:"bulk-action-notice",className:"bulk-action-notice",successes:l,errors:i,errorMessages:d,type:a.update}),t=r("#bulk-action-notice").on("click","button",function(){r(this).toggleClass("bulk-action-errors-collapsed").attr("aria-expanded",!r(this).hasClass("bulk-action-errors-collapsed")),t.find(".bulk-action-errors").toggleClass("hidden")}),0<i&&!p.updates.queue.length&&r("html, body").animate({scrollTop:0})}),o.on("wp-updates-notice-added",function(){p.updates.adminNotice=p.template("wp-updates-admin-notice")}),p.updates.queueChecker()}),t.length&&t.attr("aria-describedby","live-search-desc"),t.on("keyup input",_.debounce(function(e,a){var t=r(".plugin-install-search"),s={_ajax_nonce:p.updates.ajaxNonce,s:e.target.value,tab:"search",type:r("#typeselector").val(),pagenow:pagenow},n=location.href.split("?")[0]+"?"+r.param(_.omit(s,["_ajax_nonce","pagenow"]));"keyup"===e.type&&27===e.which&&(e.target.value=""),p.updates.searchTerm===s.s&&"typechange"!==a||(l.empty(),p.updates.searchTerm=s.s,window.history&&window.history.replaceState&&window.history.replaceState(null,"",n),t.length||(t=r('<li class="plugin-install-search" />').append(r("<a />",{"class":"current",href:n,text:p.updates.l10n.searchResultsLabel})),r(".wp-filter .filter-links .current").removeClass("current").parents(".filter-links").prepend(t),l.prev("p").remove(),r(".plugins-popular-tags-wrapper").remove()),void 0!==p.updates.searchRequest&&p.updates.searchRequest.abort(),r("body").addClass("loading-content"),p.updates.searchRequest=p.ajax.post("search-install-plugins",s).done(function(e){r("body").removeClass("loading-content"),l.append(e.items),delete p.updates.searchRequest,0===e.count?p.a11y.speak(p.updates.l10n.noPluginsFound):p.a11y.speak(p.updates.l10n.pluginsFound.replace("%d",e.count))}))},500)),a.length&&a.attr("aria-describedby","live-search-desc"),a.on("keyup input",_.debounce(function(e){var s={_ajax_nonce:p.updates.ajaxNonce,s:e.target.value,pagenow:pagenow};"keyup"===e.type&&27===e.which&&(e.target.value=""),p.updates.searchTerm!==s.s&&(p.updates.searchTerm=s.s,window.history&&window.history.replaceState&&window.history.replaceState(null,"",location.href.split("?")[0]+"?s="+s.s),void 0!==p.updates.searchRequest&&p.updates.searchRequest.abort(),u.empty(),r("body").addClass("loading-content"),p.updates.searchRequest=p.ajax.post("search-plugins",s).done(function(e){var a=r("<span />").addClass("subtitle").html(p.updates.l10n.searchResults.replace("%s",_.escape(s.s))),t=r(".wrap .subtitle");s.s.length?t.length?t.replaceWith(a):r(".wrap h1").append(a):t.remove(),r("body").removeClass("loading-content"),u.append(e.items),delete p.updates.searchRequest,0===e.count?p.a11y.speak(p.updates.l10n.noPluginsFound):p.a11y.speak(p.updates.l10n.pluginsFound.replace("%d",e.count))}))},500)),o.on("submit",".search-plugins",function(e){e.preventDefault(),r("input.wp-filter-search").trigger("input")}),r("#typeselector").on("change",function(){var e=r('input[name="s"]');e.val().length&&e.trigger("input","typechange")}),r("#plugin_update_from_iframe").on("click",function(e){var a=window.parent===window?null:window.parent;r.support.postMessage=!!window.postMessage,!1!==r.support.postMessage&&null!==a&&-1===window.parent.location.pathname.indexOf("update-core.php")&&(e.preventDefault(),e={action:"update-plugin",data:{plugin:r(this).data("plugin"),slug:r(this).data("slug")}},a.postMessage(JSON.stringify(e),window.location.origin))}),r("#plugin_install_from_iframe").on("click",function(e){var a=window.parent===window?null:window.parent;r.support.postMessage=!!window.postMessage,!1!==r.support.postMessage&&null!==a&&-1===window.parent.location.pathname.indexOf("index.php")&&(e.preventDefault(),e={action:"install-plugin",data:{slug:r(this).data("slug")}},a.postMessage(JSON.stringify(e),window.location.origin))}),r(window).on("message",function(e){var a,t=e.originalEvent,e=document.location.protocol+"//"+document.location.hostname;if(t.origin===e){try{a=r.parseJSON(t.data)}catch(e){return}if(void 0!==a.action)switch(a.action){case"decrementUpdateCount":p.updates.decrementCount(a.upgradeType);break;case"install-plugin":case"update-plugin":window.tb_remove(),a.data=p.updates._addCallbacks(a.data,a.action),p.updates.queue.push(a),p.updates.queueChecker()}}}),r(window).on("beforeunload",p.updates.beforeunload)})}(jQuery,window.wp,_.extend(window._wpUpdatesSettings,window._wpUpdatesItemCounts||{}));