Skip to content

Instantly share code, notes, and snippets.

@dlxsnippets
Created September 11, 2025 19:04
Show Gist options
  • Select an option

  • Save dlxsnippets/b12706b0e11a42bab5a85e4f3ad53f87 to your computer and use it in GitHub Desktop.

Select an option

Save dlxsnippets/b12706b0e11a42bab5a85e4f3ad53f87 to your computer and use it in GitHub Desktop.
Checks if a Plugin is Active on Single-Site or Multisite
<?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