Skip to content

Instantly share code, notes, and snippets.

@vineettalwar
Last active October 14, 2019 21:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vineettalwar/59d4966304290b91d3d917cdb4ec7fc1 to your computer and use it in GitHub Desktop.
Save vineettalwar/59d4966304290b91d3d917cdb4ec7fc1 to your computer and use it in GitHub Desktop.
Check if plugin is active based on text domain
/**
* Check if plugin is active based on text domain
* Pass text domain to function, will return if plugin is active
*
* @param $plugin_text_domain
* @return bool
*/
function vt_is_plugin_active_by_textdomain( $plugin_text_domain ) {
$activated_plugins = [];
$active_plugins_option = get_option( 'active_plugins' );
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
$get_plugins = get_plugins();
foreach ( $active_plugins_option as $plugin ) {
if ( isset( $get_plugins[$plugin] ) ) {
array_push( $activated_plugins, $get_plugins[$plugin] );
}
}
return in_array( $plugin_text_domain, wp_list_pluck($activated_plugins, 'TextDomain')) ? true : false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment