Last active
February 3, 2023 11:56
-
-
Save isuke01/dbe24412ab71d1cb74bf6571c5c056c4 to your computer and use it in GitHub Desktop.
(WordPress/T2) Helper function to check if T2 feature is activated.
This file contains hidden or 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
<?php | |
/** | |
* Helper functio nto check if there is T2 feature activated. | |
* Example usage: t2_is_feature_activated( 't2/newsletter' ) | |
* | |
* @param string $feature The t2 feature e.g t2/newsletter. | |
* @return bool | |
*/ | |
function t2_is_feature_activated( string $feature ): bool { | |
if ( ! \is_plugin_active( 't2/t2.php' ) ) { | |
return false; | |
} | |
$t2_features = []; | |
if ( function_exists( '\T2\Extensions\get_active_extensions' ) ) { | |
$t2_features = array_merge( $t2_features, \T2\Extensions\get_active_extensions() ); | |
} | |
if ( function_exists( '\T2\Blocks\get_active_blocks' ) ) { | |
$t2_features = array_merge( $t2_features, \T2\Blocks\get_active_blocks() ); | |
} | |
return in_array( $feature, $t2_features, true ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment