window.wp=window.wp||{},function(a,b,c){b.updates={},b.updates.ajaxNonce=window._wpUpdatesSettings.ajax_nonce,b.updates.l10n=window._wpUpdatesSettings.l10n,b.updates.shouldRequestFilesystemCredentials=null,b.updates.filesystemCredentials={ftp:{host:null,username:null,password:null,connectionType:null},ssh:{publicKey:null,privateKey:null}},b.updates.updateLock=!1,b.updates.updateDoneSuccessfully=!1,b.updates.updateQueue=[],b.updates.$elToReturnFocusToFromCredentialsModal=null,b.updates.decrementCount=function(b){var c,d,e=a("#wp-admin-bar-updates .ab-label"),f=a('a[href="update-core.php"] .update-plugins'),g=a("#menu-plugins");if(c=e.text(),c=parseInt(c,10)-1,!(0>c||isNaN(c))&&(a("#wp-admin-bar-updates .ab-item").removeAttr("title"),e.text(c),f.each(function(a,b){b.className=b.className.replace(/count-\d+/,"count-"+c)}),f.removeAttr("title"),f.find(".update-count").text(c),"plugin"===b)){if(d=g.find(".plugin-count").eq(0).text(),d=parseInt(d,10)-1,0>d||isNaN(d))return;g.find(".plugin-count").text(d),g.find(".update-plugins").each(function(a,b){b.className=b.className.replace(/count-\d+/,"count-"+d)}),d>0?a(".subsubsub .upgrade .count").text("("+d+")"):a(".subsubsub .upgrade").remove()}},b.updates.updatePlugin=function(d,e){var f,g,h=a(".plugin-card-"+e);if("plugins"===c||"plugins-network"===c?f=a('[data-plugin="'+d+'"]').next().find(".update-message"):"plugin-install"===c&&(f=h.find(".update-now"),g=f.data("name"),f.attr("aria-label",b.updates.l10n.updatingLabel.replace("%s",g)),h.removeClass("plugin-card-update-failed").find(".notice.notice-error").remove()),f.addClass("updating-message"),f.html()!==b.updates.l10n.updating&&f.data("originaltext",f.html()),f.text(b.updates.l10n.updating),b.a11y.speak(b.updates.l10n.updatingMsg),b.updates.updateLock)return void b.updates.updateQueue.push({type:"update-plugin",data:{plugin:d,slug:e}});b.updates.updateLock=!0;var i={_ajax_nonce:b.updates.ajaxNonce,plugin:d,slug:e,username:b.updates.filesystemCredentials.ftp.username,password:b.updates.filesystemCredentials.ftp.password,hostname:b.updates.filesystemCredentials.ftp.hostname,connection_type:b.updates.filesystemCredentials.ftp.connectionType,public_key:b.updates.filesystemCredentials.ssh.publicKey,private_key:b.updates.filesystemCredentials.ssh.privateKey};b.ajax.post("update-plugin",i).done(b.updates.updateSuccess).fail(b.updates.updateError)},b.updates.updateSuccess=function(d){var e,f,g,h;"plugins"===c||"plugins-network"===c?(g=a('[data-plugin="'+d.plugin+'"]').first(),e=g.next().find(".update-message"),g.addClass("updated").removeClass("update"),h=g.find(".plugin-version-author-uri").html().replace(d.oldVersion,d.newVersion),g.find(".plugin-version-author-uri").html(h),g.next().addClass("updated")):"plugin-install"===c&&(e=a(".plugin-card-"+d.slug).find(".update-now"),e.addClass("button-disabled"),f=e.data("name"),e.attr("aria-label",b.updates.l10n.updatedLabel.replace("%s",f))),e.removeClass("updating-message").addClass("updated-message"),e.text(b.updates.l10n.updated),b.a11y.speak(b.updates.l10n.updatedMsg),b.updates.decrementCount("plugin"),b.updates.updateDoneSuccessfully=!0,b.updates.updateLock=!1,a(document).trigger("wp-plugin-update-success",d),b.updates.queueChecker()},b.updates.updateError=function(d){var e,f,g,h,i=a(".plugin-card-"+d.slug);return b.updates.updateDoneSuccessfully=!1,d.errorCode&&"unable_to_connect_to_filesystem"==d.errorCode&&b.updates.shouldRequestFilesystemCredentials?void b.updates.credentialError(d,"update-plugin"):(h=b.updates.l10n.updateFailed.replace("%s",d.error),"plugins"===c||"plugins-network"===c?(e=a('[data-plugin="'+d.plugin+'"]').next().find(".update-message"),e.html(h).removeClass("updating-message")):"plugin-install"===c&&(f=i.find(".update-now"),g=f.data("name"),i.addClass("plugin-card-update-failed").append('
"),f.attr("aria-label",b.updates.l10n.updateFailedLabel.replace("%s",g)).html(b.updates.l10n.updateFailedShort).removeClass("updating-message"),i.on("click",".notice.is-dismissible .notice-dismiss",function(){setTimeout(function(){i.removeClass("plugin-card-update-failed").find(".column-name a").focus()},200)})),b.a11y.speak(h,"assertive"),b.updates.updateLock=!1,a(document).trigger("wp-plugin-update-error",d),void b.updates.queueChecker())},b.updates.showErrorInCredentialsForm=function(b){var c=a(".notification-dialog");c.find(".error").remove(),c.find("h3").after(''+b+"
")},b.updates.credentialError=function(a,c){b.updates.updateQueue.push({type:c,data:{plugin:a.plugin,slug:a.slug}}),b.updates.showErrorInCredentialsForm(a.error),b.updates.requestFilesystemCredentials()},b.updates.queueChecker=function(){if(!(b.updates.updateLock||b.updates.updateQueue.length<=0)){var a=b.updates.updateQueue.shift();b.updates.updatePlugin(a.data.plugin,a.data.slug)}},b.updates.requestFilesystemCredentials=function(d){b.updates.updateDoneSuccessfully===!1&&("plugin-install"===c&&d&&(b.updates.$elToReturnFocusToFromCredentialsModal=a(d.target)),b.updates.updateLock=!0,b.updates.requestForCredentialsModalOpen())},b.updates.keydown=function(c){27===c.keyCode?b.updates.requestForCredentialsModalCancel():9===c.keyCode&&("upgrade"!==c.target.id||c.shiftKey?"hostname"===c.target.id&&c.shiftKey&&(a("#upgrade").focus(),c.preventDefault()):(a("#hostname").focus(),c.preventDefault()))},b.updates.requestForCredentialsModalOpen=function(){var c=a("#request-filesystem-credentials-dialog");a("body").addClass("modal-open"),c.show(),c.find("input:enabled:first").focus(),c.keydown(b.updates.keydown)},b.updates.requestForCredentialsModalClose=function(){a("#request-filesystem-credentials-dialog").hide(),a("body").removeClass("modal-open"),b.updates.$elToReturnFocusToFromCredentialsModal.focus()},b.updates.requestForCredentialsModalCancel=function(){var d,e;(b.updates.updateLock!==!1||0!==b.updates.updateQueue.length)&&(d=b.updates.updateQueue[0].data,b.updates.updateLock=!1,b.updates.updateQueue=[],b.updates.requestForCredentialsModalClose(),"plugins"===c||"plugins-network"===c?e=a('[data-plugin="'+d.plugin+'"]').next().find(".update-message"):"plugin-install"===c&&(e=a(".plugin-card-"+d.slug).find(".update-now")),e.removeClass("updating-message"),e.html(e.data("originaltext")),b.a11y.speak(b.updates.l10n.updateCancel))},b.updates.beforeunload=function(){return b.updates.updateLock?b.updates.l10n.beforeunload:void 0},a(document).ready(function(){b.updates.shouldRequestFilesystemCredentials=a("#request-filesystem-credentials-dialog").length<=0?!1:!0,a("#request-filesystem-credentials-dialog form").on("submit",function(){return b.updates.filesystemCredentials.ftp.hostname=a("#hostname").val(),b.updates.filesystemCredentials.ftp.username=a("#username").val(),b.updates.filesystemCredentials.ftp.password=a("#password").val(),b.updates.filesystemCredentials.ftp.connectionType=a('input[name="connection_type"]:checked').val(),b.updates.filesystemCredentials.ssh.publicKey=a("#public_key").val(),b.updates.filesystemCredentials.ssh.privateKey=a("#private_key").val(),b.updates.requestForCredentialsModalClose(),b.updates.updateLock=!1,b.updates.queueChecker(),!1}),a('#request-filesystem-credentials-dialog [data-js-action="close"], .notification-dialog-background').on("click",function(){b.updates.requestForCredentialsModalCancel()}),a('#request-filesystem-credentials-dialog input[name="connection_type"]').on("change",function(){a(this).parents("form").find("#private_key, #public_key").parents("label").toggle("ssh"==a(this).val())}).change(),a(".plugin-update-tr").on("click",".update-link",function(c){c.preventDefault(),b.updates.shouldRequestFilesystemCredentials&&!b.updates.updateLock&&b.updates.requestFilesystemCredentials(c);var d=a(c.target).parents(".plugin-update-tr");b.updates.$elToReturnFocusToFromCredentialsModal=d.prev().find(".check-column input"),b.updates.updatePlugin(d.data("plugin"),d.data("slug"))}),a(".plugin-card").on("click",".update-now",function(c){c.preventDefault();var d=a(c.target);b.updates.shouldRequestFilesystemCredentials&&!b.updates.updateLock&&b.updates.requestFilesystemCredentials(c),b.updates.updatePlugin(d.data("plugin"),d.data("slug"))}),a("#plugin_update_from_iframe").on("click",function(b){var c,d;c=window.parent==window?null:window.parent,a.support.postMessage=!!window.postMessage,a.support.postMessage!==!1&&null!==c&&-1===window.parent.location.pathname.indexOf("update-core.php")&&(b.preventDefault(),d={action:"updatePlugin",type:"update-plugin",data:{plugin:a(this).data("plugin"),slug:a(this).data("slug")}},c.postMessage(JSON.stringify(d),window.location.origin))})}),a(window).on("message",function(c){var d,e=c.originalEvent,f=document.location,g=f.protocol+"//"+f.hostname;if(e.origin===g&&(d=a.parseJSON(e.data),"undefined"!=typeof d.action))switch(d.action){case"decrementUpdateCount":b.updates.decrementCount(d.upgradeType);break;case"updatePlugin":tb_remove(),b.updates.updateQueue.push(d),b.updates.queueChecker()}}),a(window).on("beforeunload",b.updates.beforeunload)}(jQuery,window.wp,window.pagenow,window.ajaxurl);