JS hacks with ManageWP

ManageWP is an amazing tool for managing all of your WordPress websites from a central dashboard. I use ManageWP to deploy plugin, theme, and security updates for my customers. Their tool is a powerful single page JS app. I discovered that you can do some pretty creative “coding” using Javascript right from the Google Chrome DevTools.

Manually Updating Premium Plugins

Sometimes premium plugins have issues updating through an automatic plugin update. With ManageWP there is no button which will target all sites with a particular plugin installed. This can be accomplished by following these steps.

  • Select all of your sites and then “Manage Plugins”
  • Search for the offending plugin by name
  • Select all active plugins
Screen Shot 2017-01-02 at 4.18.18 PM.png

Next, run the following in Chrome console:

// Collect all selected sites for a particular plugin into array
sites = [];
jQuery('.site-item.widget-item.selected').each(function() {
   site = jQuery(this).find(".site-url").text();
   sites.push(site);
});

Next, go back to your website list and deselect all sites, then run the following code in the Chrome console:

// Selects sites in array
sites.forEach(site => {
    jQuery('.websites-search span').click();
    jQuery('.websites-search input').val(site);
    jQuery('.websites-search input').trigger('change');
    jQuery('.manage-websites-list .websites-list-item label').trigger('click');
});

// Returns to all sites list after all sites have been selected
jQuery('.websites-search span').click();
jQuery('.websites-search input').val("");
jQuery('.websites-search input').trigger('change');

Now that the proper sites are selected, install a new plugin update through “Manage Plugins.” If manual intervention is needed, the following code will trigger ManageWP’s auto login for the selected websites.

jQuery('.custom-checkbox input:checked').parents('tr').each(function() { 
   link = jQuery(this).find('.fa.fa-wordpress.control').attr('href');
   window.open(link, '_blank')
});