admin管理员组文章数量:1386709
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";}
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";}
Share
Improve this question
edited Mar 10, 2012 at 16:22
jnthnclrk
asked Mar 10, 2012 at 10:09
jnthnclrkjnthnclrk
1,8454 gold badges25 silver badges52 bronze badges
1
- You can use the find and replace function within the Migrate DB plugin to disable individual plugins. You can't activate a plugin this way. – Andrew Commented Dec 16, 2014 at 12:21
3 Answers
Reset to default 8That's a serialized array.
// Serialized:
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";}
// dump:
var_dump( maybe_unserialize('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";}') );
// Result
array(8) {
[0]=>
string(21) "adrotate/adrotate.php"
[1]=>
string(19) "akismet/akismet.php"
[2]=>
string(33) "better-related/better-related.php"
[3]=>
string(17) "clicky/clicky.php"
[4]=>
string(49) "custom-post-permalinks/custom-post-permalinks.php"
[5]=>
string(32) "disqus-comment-system/disqus.php"
[6]=>
string(33) "export-to-text/export-to-text.php"
[7]=>
string(36) "google-sitemap-generator/sitemap.php"
}
Use maybe_unserialize()
or unserialize()
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/Solarbotics/Wordpress_plugin_managment_by_db
版权声明:本文标题:How to make sense of the active_plugins option_value to enable and disable certain plugins from the database? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744556112a2612484.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论