2015-02-05 20:52:22 +01:00
|
|
|
window.wp=window.wp||{},function(a,b,c,d){b.updates={},b.updates.ajaxNonce=window._wpUpdatesSettings.ajax_nonce,b.updates.l10n=window._wpUpdatesSettings.l10n,b.updates.updateLock=!1,b.updates.updateQueue=[],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(e,f){var g;if("plugins"===c||"plugins-network"===c?g=a("#"+f).next().find(".update-message"):"plugin-install"===c&&(g=a(".plugin-card-"+f).find(".update-now")),g.addClass("updating-message"),g.text(b.updates.l10n.updating),b.updates.updateLock)return void b.updates.updateQueue.push({type:"update-plugin",data:{plugin:e,slug:f}});b.updates.updateLock=!0;var h={action:"update-plugin",_ajax_nonce:b.updates.ajaxNonce,plugin:e,slug:f};a.ajax({type:"post",url:d,data:h,complete:b.updates.updateRequestComplete})},b.updates.updateRequestComplete=function(a){if(b.updates.updateLock=!1,a.responseJSON&&a.responseJSON.success)b.updates.updateSuccess(a.responseJSON);else{var c=b.updates.l10n.updateFailed;a.responseJSON&&a.responseJSON.data&&a.responseJSON.data.error&&(c+=": "+a.responseJSON.data.error),window.alert(c),a.responseJSON&&a.responseJSON.data&&a.responseJSON.data.slug&&b.updates.updateError(a.responseJSON)}b.updates.queueChecker()},b.updates.updateSuccess=function(d){var e;"plugins"===c||"plugins-network"===c?(e=a("#"+d.data.slug).next().find(".update-message"),a("#"+d.data.slug).addClass("updated").removeClass("update"),a("#"+d.data.slug+"-update").addClass("updated").removeClass("update")):"plugin-install"===c&&(e=a(".plugin-card-"+d.data.slug).find(".update-now"),e.addClass("button-disabled")),e.removeClass("updating-message").addClass("updated-message"),e.text(b.updates.l10n.updated),b.updates.decrementCount("plugin")},b.updates.updateError=function(d){var e;"plugins"===c||"plugins-network"===c?e=a("#"+d.data.slug).next().find(".update-message"):"plugin-install"===c&&(e=a(".plugin-card-"+d.data.slug).find(".update-now")),e.removeClass("updating-message"),e.text(b.updates.l10n.updateFailed)},b.updates.installPlugin=function(c){var e=a(".plugin-card-"+c).find(".install-now");if(e.addClass("updating-message"),e.text(b.updates.l10n.installing),b.updates.updateLock)return void b.updates.updateQueue.push({type:"install-plugin",data:{slug:c}});b.updates.updateLock=!0;var f={action:"install-plugin",_ajax_nonce:b.updates.ajaxNonce,slug:c};a.ajax({type:"post",url:d,data:f,complete:b.updates.installRequestComplete})},b.updates.installRequestComplete=function(a){if(b.updates.updateLock=!1,a.responseJSON&&a.responseJSON.success)b.updates.installSuccess(a.responseJSON);else{var c=b.updates.l10n.installFailed;a.responseJSON&&a.responseJSON.data&&a.responseJSON.data.error&&(c+=": "+a.responseJSON.data.error),window.alert(c),a.responseJSON&&a.responseJSON.data&&a.responseJSON.data.slug&&b.updates.installError(a.responseJSON)}b.updates.queueChecker()},b.updates.installSuccess=function(c){var d=a(".plugin-card-"+c.data.slug).find(".install-now");d.removeClass("updating-message").addClass("updated-message button-disabled"),d.text(b.updates.l10n.installed)},b.updates.installError=function(c){var d=a(".plugin-card-"+c.data.slug).find(".install-now");d.removeClass("updating-message"),d.text(b.updates.l10n.installNow)},b.updates.queueChecker=function(){if(!(b.updates.updateLock||b.updates.updateQueue.length<=0)){var a=b.updates.updateQueue.shift();switch(a.type){case"update-plugin":b.updates.update
|