I’ve shown, in a previous post, a function to check if a plugin is installed and have thought to extrapolate and de-contextualize it for my future usage
/**
* Checks if a WordPress plugin is installed.
*
* @param string $pluginTitle The plugin title (e.g. "My Plugin")
*
* @return string/boolean The plugin file/folder relative to the plugins folder path (e.g. "my-plugin/my-plugin.php") or false
*/
function is_plugin_installed($pluginTitle)
{
// get all the plugins
$installedPlugins = get_plugins();
foreach ($installedPlugins as $installedPlugin => $data) {
// check for the plugin title
if ($data['Title'] == $pluginTitle) {
// return the plugin folder/file
return $installedPlugin;
}
}
return false;
}
I’ve created a gist to make the function an easy grab.