diff --git a/wp-admin/js/updates.js b/wp-admin/js/updates.js index 1e00589cec..29c7b85de2 100644 --- a/wp-admin/js/updates.js +++ b/wp-admin/js/updates.js @@ -34,6 +34,7 @@ __ = wp.i18n.__, _x = wp.i18n._x, _n = wp.i18n._n, + _nx = wp.i18n._nx, sprintf = wp.i18n.sprintf; wp = wp || {}; @@ -970,6 +971,8 @@ var $form = $( '#bulk-action-form' ), $views = $( '.subsubsub' ), $pluginRow = $( this ), + $currentView = $views.find( '[aria-current="page"]' ), + $itemsCount = $( '.displaying-num' ), columnCount = $form.find( 'thead th:not(.hidden), thead td' ).length, pluginDeletedRow = wp.template( 'item-deleted-row' ), /** @@ -977,7 +980,8 @@ * * @type {Object} */ - plugins = settings.plugins; + plugins = settings.plugins, + remainingCount; // Add a success message after deleting a plugin. if ( ! $pluginRow.hasClass( 'plugin-update-tr' ) ) { @@ -1057,6 +1061,17 @@ $form.find( '#the-list' ).append( '
'+t+"
"),a.on("click",".notice.is-dismissible .notice-dismiss",function(){setTimeout(function(){a.removeClass("plugin-card-update-failed").find(".column-name a").trigger("focus")},200)}),s.removeClass("updating-message").addClass("button-disabled").attr("aria-label",u(d("%s installation failed","plugin"),s.data("name"))).text(h("Installation failed.")),c.a11y.speak(t,"assertive"),m.trigger("wp-plugin-install-error",e))},c.updates.installImporterSuccess=function(e){c.updates.addAdminNotice({id:"install-success",className:"notice-success is-dismissible",message:u(h('Importer installed successfully. Run importer'),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":u(h("Run %s"),e.pluginName)}).text(h("Run Importer")),c.a11y.speak(h("Installation completed successfully.")),m.trigger("wp-importer-install-success",e)},c.updates.installImporterError=function(e){var t=u(h("Installation failed: %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").attr("aria-label",u(d("Install %s now","plugin"),s)).text(h("Install Now")),c.a11y.speak(t,"assertive"),m.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()!==h("Deleting...")&&t.data("originaltext",t.html()).text(h("Deleting...")),c.a11y.speak(h("Deleting...")),m.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()),-1!==_.indexOf(l["auto-update-enabled"],i.plugin)&&(l["auto-update-enabled"]=_.without(l["auto-update-enabled"],i.plugin),l["auto-update-enabled"].length?t.find(".auto-update-enabled .count").text("("+l["auto-update-enabled"].length+")"):t.find(".auto-update-enabled").remove()),-1!==_.indexOf(l["auto-update-disabled"],i.plugin)&&(l["auto-update-disabled"]=_.without(l["auto-update-disabled"],i.plugin),l["auto-update-disabled"].length?t.find(".auto-update-disabled .count").text("("+l["auto-update-disabled"].length+")"):t.find(".auto-update-disabled").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(''+e+"
'+t+"
"),a.on("click",".notice.is-dismissible .notice-dismiss",function(){setTimeout(function(){a.removeClass("plugin-card-update-failed").find(".column-name a").trigger("focus")},200)}),s.removeClass("updating-message").addClass("button-disabled").attr("aria-label",r(i("%s installation failed","plugin"),s.data("name"))).text(h("Installation failed.")),c.a11y.speak(t,"assertive"),m.trigger("wp-plugin-install-error",e))},c.updates.installImporterSuccess=function(e){c.updates.addAdminNotice({id:"install-success",className:"notice-success is-dismissible",message:r(h('Importer installed successfully. Run importer'),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":r(h("Run %s"),e.pluginName)}).text(h("Run Importer")),c.a11y.speak(h("Installation completed successfully.")),m.trigger("wp-importer-install-success",e)},c.updates.installImporterError=function(e){var t=r(h("Installation failed: %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").attr("aria-label",r(i("Install %s now","plugin"),s)).text(h("Install Now")),c.a11y.speak(t,"assertive"),m.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()!==h("Deleting...")&&t.data("originaltext",t.html()).text(h("Deleting...")),c.a11y.speak(h("Deleting...")),m.trigger("wp-plugin-deleting",e),c.updates.ajax("delete-plugin",e)},c.updates.deletePluginSuccess=function(u){p('[data-plugin="'+u.plugin+'"]').css({backgroundColor:"#faafaa"}).fadeOut(350,function(){var e=p("#bulk-action-form"),t=p(".subsubsub"),a=p(this),s=t.find('[aria-current="page"]'),n=p(".displaying-num"),l=e.find("thead th:not(.hidden), thead td").length,i=c.template("item-deleted-row"),d=g.plugins;a.hasClass("plugin-update-tr")||a.after(i({slug:u.slug,plugin:u.plugin,colspan:l,name:u.pluginName})),a.remove(),-1!==_.indexOf(d.upgrade,u.plugin)&&(d.upgrade=_.without(d.upgrade,u.plugin),c.updates.decrementCount("plugin")),-1!==_.indexOf(d.inactive,u.plugin)&&(d.inactive=_.without(d.inactive,u.plugin),d.inactive.length?t.find(".inactive .count").text("("+d.inactive.length+")"):t.find(".inactive").remove()),-1!==_.indexOf(d.active,u.plugin)&&(d.active=_.without(d.active,u.plugin),d.active.length?t.find(".active .count").text("("+d.active.length+")"):t.find(".active").remove()),-1!==_.indexOf(d.recently_activated,u.plugin)&&(d.recently_activated=_.without(d.recently_activated,u.plugin),d.recently_activated.length?t.find(".recently_activated .count").text("("+d.recently_activated.length+")"):t.find(".recently_activated").remove()),-1!==_.indexOf(d["auto-update-enabled"],u.plugin)&&(d["auto-update-enabled"]=_.without(d["auto-update-enabled"],u.plugin),d["auto-update-enabled"].length?t.find(".auto-update-enabled .count").text("("+d["auto-update-enabled"].length+")"):t.find(".auto-update-enabled").remove()),-1!==_.indexOf(d["auto-update-disabled"],u.plugin)&&(d["auto-update-disabled"]=_.without(d["auto-update-disabled"],u.plugin),d["auto-update-disabled"].length?t.find(".auto-update-disabled .count").text("("+d["auto-update-disabled"].length+")"):t.find(".auto-update-disabled").remove()),d.all=_.without(d.all,u.plugin),d.all.length?t.find(".all .count").text("("+d.all.length+")"):(e.find(".tablenav").css({visibility:"hidden"}),t.find(".all").remove(),e.find("tr.no-items").length||e.find("#the-list").append(''+e+"