Created
September 11, 2025 19:04
-
-
Save dlxsnippets/b12706b0e11a42bab5a85e4f3ad53f87 to your computer and use it in GitHub Desktop.
Checks if a Plugin is Active on Single-Site or Multisite
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 | |
| /** | |
| * Checks to see if an asset is activated or not. | |
| * | |
| * @param string $path Path to the asset (e.g., akismet/akismet.php). | |
| * | |
| * @return bool true if activated, false if not. | |
| */ | |
| function dlx_is_plugin_activated( $path ) { | |
| if ( ! function_exists( 'is_plugin_active_for_network' ) ) { | |
| require_once ABSPATH . '/wp-admin/includes/plugin.php'; | |
| } | |
| if ( is_multisite() ) { | |
| if ( is_plugin_active_for_network( $path ) ) { | |
| return true; | |
| } | |
| } | |
| if ( is_plugin_active( $path ) ) { | |
| return true; | |
| } | |
| return false; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment