Last active
September 12, 2022 00:50
-
-
Save dlxsnippets/b989adc9ff8004cf11306317c96d6efb to your computer and use it in GitHub Desktop.
WordPress Function: is multisite. Check whether to perform multisite related tasks.
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
<?php | |
/** | |
* Checks if the plugin is installed and activated on a multisite install. | |
* | |
* @since 1.0.0 | |
* | |
* @param bool $network_admin Check if in network admin. | |
* @param string $slug Plugin slug. | |
* | |
* @return true if multisite, false if not. | |
*/ | |
public static function is_multisite( $network_admin = false, $slug = 'alerts-dlx' ) { | |
if ( ! function_exists( 'is_plugin_active_for_network' ) ) { | |
require_once ABSPATH . '/wp-admin/includes/plugin.php'; | |
} | |
$is_network_admin = false; | |
// Check if we're in network admin and the plugin slug is network activated. | |
if ( $network_admin ) { | |
if ( is_network_admin() ) { | |
if ( is_multisite() && is_plugin_active_for_network( $slug ) ) { | |
return true; | |
} | |
} else { | |
return false; | |
} | |
} | |
// Check if the plugin is network-activated on multisite. | |
if ( is_multisite() && is_plugin_active_for_network( $slug ) ) { | |
return true; | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment