Last active
August 29, 2015 14:14
-
-
Save son0fhobs/bf4424ccfa7e5ae0720e to your computer and use it in GitHub Desktop.
Save active wordpress plugin - When deactivating for troubleshooting
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
/* Find the active plugins, save to array */ | |
$=jQuery; | |
plugin_states = []; | |
$('.row-actions-visible').each(function(i){ | |
// save state which is set as class "activate" or "deactivate" | |
plugin_state_class = $(this).children().eq(0).attr('class'); | |
plugin_states.push(plugin_state_class); | |
}); | |
plugin_states = JSON.stringify(plugin_states); | |
// print as array, remove outer quotes so that its an array, not a string, then copy into variable below | |
console.log(plugin_states); | |
/* reactivating plugins */ | |
$=jQuery; | |
// copy previously saved string to plugin_states array | |
plugin_states = ["deactivate","activate","activate","deactivate","0","deactivate","deactivate","activate","deactivate","activate","deactivate","deactivate","activate","activate","deactivate","deactivate","deactivate","activate","activate","0","deactivate","activate","activate","deactivate","activate"]; | |
$('.row-actions-visible').each(function(i){ | |
plugin_state_class = $(this).children().eq(0).attr('class'); | |
console.log("plugin_state_class = "+plugin_state_class+" | plugin_states[i] = "+plugin_states[i]); | |
// if saved and current state aren't the same, check the checkbox to do bulk edit | |
if(plugin_state_class !== plugin_states[i]){ | |
$(this).closest('tr').children('th').find('input').attr('checked', 'checked'); | |
} | |
}); | |
// run bulk activate/deactivate |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment