Skip to content

Instantly share code, notes, and snippets.

@d4mation
Created October 18, 2022 13:48
Show Gist options
  • Save d4mation/c1ffb08370fdc29614374eb7af14d2ad to your computer and use it in GitHub Desktop.
Save d4mation/c1ffb08370fdc29614374eb7af14d2ad to your computer and use it in GitHub Desktop.
In the event that you have a site that you don't trust to run through Safe Update in Manage WP, or perhaps a client hasn't entered a service contract yet, you can use this to auto-uncheck updates for them before running updates for your other clients
let excludeSites = [
'urltoexclude.com',
'anotherurltoexclude.com',
];
jQuery( '.updates-container .update-row' ).each( function( index, updatesToggle ) {
if ( ! jQuery( updatesToggle ).hasClass( 'expand' ) ) {
jQuery( updatesToggle ).click();
}
let $updatesGroup = jQuery( updatesToggle ).closest( '.update-group' ),
$sites = $updatesGroup.find( '.site-url' );
$sites.each( function( siteIndex, site ) {
let $checkbox = jQuery( site ).closest( '.site-checkbox-label' ).find( 'mwp-custom-checkbox input[type="checkbox"]' );
if ( excludeSites.indexOf( jQuery( site ).text().trim() ) > -1 ) {
// The way that ManageWP's react setup handles state, we have to send a Click event. So we set the checked prop to the opposite of what we want first
$checkbox.prop( 'checked', true ).click();
}
else {
$checkbox.prop( 'checked', false ).click();
}
} );
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment