Can anyone explain how to interpret and make sense of the active_plugins option_value string in WordPress. And then use this string/ array to disable and activate specific plugins?
Here is an example:
a:8:{i:0;s:21:"adrotate/adrotate.php";i:1;s:19:"akismet/akismet.php";i:2;s:33:"better-related/better-related.php";i:3;s:17:"clicky/clicky.php";i:4;s:49:"custom-post-permalinks/custom-post-permalinks.php";i:5;s:32:"disqus-comment-system/disqus.php";i:6;s:33:"export-to-text/export-to-text.php";i:7;s:36:"google-sitemap-generator/sitemap.php";}
That’s a serialized array.
Use
maybe_unserialize()
orunserialize()
to transform it back to an array.It looks very heavy duty in comparison with JSON! Though also not too hard.
Here’s mine before modification. I want to disable Google Authenticator to allow myself to log in again. My provider now provides HTTPS for free thankfully, though before this I relied on authenticator as a protection against password sniffing. It’s still a very useful feature to have, HTTPS or not. So I intend to reset and re-enable it once my phone has a new token for it.
It looks like “Array, length 5” and for each item “Index, Length, Value”. I’ve highlighted the entry for Authenticator. My modification was to delete this entry, modify the array length to 4 and reduce the index values for all subsequent entries.
Here’s the diff showing the change. I’ve formatted it for easier read here. I wouldn’t expect it to work if formatted like this!
I had more than a few times where I could NOT disable plugins on our WordPress site, and the only avenue was database access. I could read/write to the DB, so I made this python tool to list the plugins in human-readable form; delete them from the list by line number; save the delete plugin entries to a backup file; and create a new PHP string to insert back into the database.
As I drew inspiration partly from this thread, I thought I’d add a link to it here:
https://github.com/Solarbotics/Wordpress_plugin_managment_by_db