Last active
October 14, 2019 21:16
-
-
Save vineettalwar/59d4966304290b91d3d917cdb4ec7fc1 to your computer and use it in GitHub Desktop.
Check if plugin is active based on text domain
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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