How to make sense of the active_plugins option_value to enable and disable certain plugins from the database?

That’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.

Leave a Comment