Created
October 18, 2022 13:48
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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