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

2 lines
37 KiB
JavaScript

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