facelordgists
5/1/2019 - 6:50 PM

wordpress: list all installed plugins in an array

<?php
function get_all_plugin_data(){
	$all_plugins = get_plugins();
	$list_of_all_plugins = array();
	foreach ($all_plugins as $path => $data) {
	  $parts  = explode('/', $path);
	  $slug = $parts[0];
	  $list_of_all_plugins[$slug] = array(
	    'Slug' => $slug,
	    'path' => $path,
	    'Name' => $data['Name'],
	    'Version' => $data['Version'],
	    'Description' => $data['Description'],
	    'Author' => $data['Author'],
	    'AuthorURI' => $data['AuthorURI'],
	    'Status' => (is_plugin_active($path) ? 'active' : 'inactive'),
	  );
	}
	return $list_of_all_plugins;
}
/* Sample item
[wordpress-seo] => Array(
  [Slug] => wordpress-seo
  [path] => wordpress-seo/wp-seo.php
  [Name] => Yoast SEO
  [Version] => 9.6
  [Description] => The first true all-in-one SEO solution for WordPress, including on-page content analysis, XML sitemaps and much more.
  [Author] => Team Yoast
  [AuthorURI] => https://yoa.st/1uk
  [Status] => active
)
*/