WordPress

Understanding the is_plugin_active WordPress Action

is_plugin_active() is a WordPress function, not an action. What it checks, why it can be undefined, and when class_exists() is the better test.

Shashank Dubey
·10 min read
is_plugin_active() is a WordPress function, not an action; test results show it returns true before the plugin's class is loaded and false for a slug-only path

is_plugin_active() is a WordPress function, not an action hook, even though people often search for it as “the is_plugin_active action”. You pass it a plugin’s path, such as woocommerce/woocommerce.php, and it returns true if that path is in the site’s list of active plugins or is network-active on a multisite. It only reads that list. It does not check that the plugin’s files exist or that its code has loaded, and that one detail explains most of the bugs people hit with it.

We rebuilt this guide on 18 November 2026 against WordPress 7.1.4. Every result below comes from running the code on a throwaway test install (PHP 8.5.5, WP-CLI 2.12.0), and every behaviour was checked against the core source in wp-admin/includes/plugin.php and wp-settings.php. One finding changes older advice, including the earlier version of this article: since WordPress 6.8 the function is loaded before regular plugins on every request, front end included. It is still missing inside must-use plugins and on older WordPress versions.

The short version

  • Signature: is_plugin_active( string $plugin ): bool. Available since WordPress 2.5.
  • Pass folder and main file: akismet/akismet.php, not akismet. A wrong path returns false with no warning.
  • It reads an option, not the disk. A plugin whose folder was deleted over FTP still reports active until someone opens the Plugins screen.
  • Active is not loaded. Called from a plugin that loads early, it can return true before the other plugin’s classes exist.
  • Defined for regular plugins and themes on WordPress 6.8 and later. Not defined while must-use plugins load, and not on the front end of 6.7 and earlier without an include.
  • To check that a feature is available, test the feature. Use class_exists(), function_exists() or the plugin’s own loaded hook. Use is_plugin_active() for admin screens and settings logic.

Is is_plugin_active an action or a function?

A function. WordPress has two kinds of hooks, actions and filters, and you attach code to them with add_action() and add_filter(). There is no hook named is_plugin_active: calling add_action( 'is_plugin_active', ... ) registers a callback that never runs. is_plugin_active() is a conditional you call directly, like is_admin() or is_singular(), and it hands back a boolean.

The confusion is understandable, because plugin activation does have real actions. These are the ones that fire around the same moments, all present in WordPress 7.1.4:

Hook

Type

When it fires

activated_plugin

Action

Right after any plugin is activated. Receives the plugin path and whether it was network-wide

deactivated_plugin

Action

Right after any plugin is deactivated

plugins_loaded

Action

After every active plugin’s main file has been loaded

activate_{plugin path}

Action

Fires for one specific plugin. Usually registered with register_activation_hook()

If you want code to run when a plugin is switched on or off, you want one of those actions. If you want to ask whether a plugin is switched on right now, you want the function. Our guide to WordPress dynamic hooks explains how hook names like the activate one above are built.

What does is_plugin_active() actually check?

Here is the whole function as it ships in WordPress 7.1.4. It is one line long.

<?php
// wp-admin/includes/plugin.php, WordPress 7.1.4 (checked 18 Nov 2026)
function is_plugin_active( $plugin ) {
	return in_array( $plugin, (array) get_option( 'active_plugins', array() ), true ) || is_plugin_active_for_network( $plugin );
}

Three consequences follow from that line, and we confirmed each on our test site.

  1. The match is exact. The third argument to in_array() is true, a strict comparison. Case, folder name and leading slashes all matter.
  2. It reads the active_plugins option. That option is a list of paths saved when you click Activate. Nothing in the function looks at the file system.
  3. On multisite it also checks network activation, through is_plugin_active_for_network(), which reads the active_sitewide_plugins network option. On a single site that second check always returns false.

We activated a test plugin at zzz-dep/zzz-dep.php and tried common variations. Only the exact path matched.

Value passed

Result

zzz-dep/zzz-dep.php

true

zzz-dep

false (slug only)

zzz-dep.php

false (file only)

ZZZ-Dep/zzz-dep.php

false (wrong case)

/zzz-dep/zzz-dep.php

false (leading slash)

hello.php

true (single-file plugin in the plugins root)

twp-probe.php

false (a must-use plugin)

The official reference page for is_plugin_active() documents the same contract: the parameter is the path relative to the plugins directory.

How do I find the right plugin path?

The path is the plugin’s folder name, a slash, and the file that holds the plugin header comment. Most plugins name that file after the folder, but not all. Three reliable ways to read it:

  • WP-CLI: wp plugin list --fields=name,file,status prints the exact string. On our test site it showed sqlite-database-integration/load.php, a good example of a main file that does not match its folder.
  • PHP: the keys of get_plugins() are those paths. array_keys( get_plugins() ) lists every installed plugin.
  • The admin: the Plugin File Editor shows the main file of the selected plugin, and the activate link on the Plugins screen carries the path in its plugin= parameter.
# checked on 18 Nov 2026, WP-CLI 2.12.0
$ wp plugin list --fields=name,file,status --format=csv
name,file,status
akismet,akismet/akismet.php,inactive
hello,hello.php,active
sqlite-database-integration,sqlite-database-integration/load.php,inactive

Watch for plugins that change folder between free and paid versions, or between a WordPress.org download and a zip from the vendor. Checking a path you guessed from the plugin’s name is the most common reason the function returns false for a plugin that is plainly active.

Why do I get call to undefined function is_plugin_active()?

Because wp-admin/includes/plugin.php has not been loaded yet at the point your code runs. Where that happens changed in WordPress 6.8. Since that release, wp-settings.php requires the file just before it loads active plugins, so that core can read plugin headers for translations. We compared the source of each release: the line is absent in 6.7.2 and present in 6.8.

To see exactly where the function exists today, we added a must-use plugin that recorded function_exists( 'is_plugin_active' ) at each stage of a request, then loaded a front-end page, a REST API call, an admin-ajax call and wp-admin.

Where your code runs

Defined on WordPress 7.1.4?

Must-use plugin, at file load

No

muplugins_loaded action

No

Regular plugin, at file load

Yes

plugins_loaded, init, wp_loaded

Yes, on every request type we tested

Front end: wp, template_redirect

Yes

REST API: rest_api_init

Yes

Theme functions.php

Yes (themes load after plugins)

So on a current site the fatal error now mostly comes from must-use plugins, drop-ins and very early bootstrap code, or from a site still running 6.7 or older where the front end never loaded the file. Code you ship to other people should still guard the call, because you do not control their WordPress version.

<?php
// Safe on any WordPress version and in any context. Checked on 18 Nov 2026.
if ( ! function_exists( 'is_plugin_active' ) ) {
	require_once ABSPATH . 'wp-admin/includes/plugin.php';
}

if ( is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
	// The plugin is switched on. Its code may not have loaded yet, see below.
}

That is the same pattern the developer reference shows for front-end use. Including the file is cheap, and require_once keeps it from loading twice.

Is is_plugin_active() the right way to check for a dependency?

Usually not, and our tests show why. “Active” means “listed in an option”. What your code needs is “the classes and functions I am about to call exist”. Those two can disagree in two ordinary situations.

The other plugin has not loaded yet

WordPress loads active plugins in the order of the active_plugins list, which is sorted alphabetically by path. We made a plugin called aaa-probe that checks a plugin called zzz-dep, which defines a class ZZZ_Dep. At file load time inside aaa-probe:

Check

Result at file load

Result on plugins_loaded

is_plugin_active( 'zzz-dep/zzz-dep.php' )

true

true

class_exists( 'ZZZ_Dep' )

false

true

The function said the dependency was there before any of its code existed. Code that saw true and called new ZZZ_Dep() straight away would crash with a class-not-found error. The plugin dependencies announcement for WordPress 6.5 makes the same point: load order is not handled for you.

The other plugin’s files are gone

Next we moved the zzz-dep folder out of wp-content/plugins, the way an FTP delete or a failed deploy would, and loaded a page. is_plugin_active() still returned true, while class_exists( 'ZZZ_Dep' ) returned false even on plugins_loaded. The option still listed the plugin. WordPress skips missing files when it loads plugins, but it only removes them from the active list when someone opens the Plugins screen in wp-admin, where validate_active_plugins() deactivates them with a notice. If plugins vanish from a site without anyone deactivating them, our guide on what to do when a plugin deactivated itself covers the usual causes and how to get alerted.

What to use instead

Method

Answers the question

Best for

class_exists(), function_exists(), defined()

Is the code I need loaded right now?

Integrations that call another plugin’s API

The plugin’s own loaded action, e.g. woocommerce_loaded

Has the plugin finished booting?

Running integration code at the right moment

is_plugin_active()

Is the plugin switched on in settings?

Admin notices, settings screens, activation checks

Requires Plugins header

Can my plugin be activated at all?

Stopping activation without the dependency

WooCommerce’s own documentation on checking whether WooCommerce is active recommends hooking into woocommerce_loaded or woocommerce_init rather than checking the plugin list.

<?php
// Load an integration only when the dependency's code is really available.
// Checked on 18 Nov 2026, WordPress 7.1.4.
add_action( 'plugins_loaded', function () {
	if ( ! class_exists( 'WooCommerce' ) ) {
		return; // Not installed, not active, or files missing.
	}
	require_once __DIR__ . '/includes/class-my-woo-integration.php';
} );

How does is_plugin_active() behave on multisite?

It covers both kinds of activation, which is the main reason to use it over reading the option yourself. We converted our test site to a network, created a second site and network-activated zzz-dep. On the second site:

Check

Result

is_plugin_active( 'zzz-dep/zzz-dep.php' )

true

is_plugin_active_for_network( 'zzz-dep/zzz-dep.php' )

true

in_array( ..., get_option( 'active_plugins' ) )

false

Hand-written checks against get_option( 'active_plugins' ) miss every network-activated plugin, because those live in the network option active_sitewide_plugins. Use is_plugin_active() when you want either kind, and is_plugin_active_for_network() when you need to know specifically that it is active across the whole network, for example to hide a per-site settings page.

What about must-use plugins and drop-ins?

Both always return false. Must-use plugins in wp-content/mu-plugins and drop-ins such as db.php or object-cache.php are never activated, so they never appear in the option. The function’s docblock says so, and a request to change it, Trac ticket 24205, was closed as wontfix in 2016 with a documentation update instead.

To detect one, check for something it defines, or look for the file:

<?php
// Checked on 18 Nov 2026, WordPress 7.1.4.
$has_mu_file = file_exists( WPMU_PLUGIN_DIR . '/my-loader.php' );
$mu_list     = array_keys( get_mu_plugins() );         // e.g. array( 'my-loader.php' )
$has_dropin  = file_exists( WP_CONTENT_DIR . '/object-cache.php' );

get_mu_plugins() lives in the same plugin.php file, so the include guard above applies to it too. Our guide to must-use plugins covers why mu-plugins load first and when to use them.

Should I use the Requires Plugins header instead?

Use both. WordPress 6.5 added a Requires Plugins plugin header that takes a comma-separated list of WordPress.org slugs. With it, WordPress refuses to activate your plugin until the listed plugins are active, and the Plugins screen stops people deactivating a plugin that others depend on. The core team’s plugin dependencies announcement lists the rules.

<?php
/**
 * Plugin Name: My Woo Integration
 * Requires Plugins: woocommerce
 */

We tested the header with WP-CLI. Activating the dependent plugin first failed with “AAA Probe requires 1 plugin to be installed and activated: ZZZ Dependency”. After we activated the dependency, activation worked. Then we deactivated the dependency with wp plugin deactivate, and WP-CLI allowed it, leaving our plugin active without the code it needs. Files deleted over FTP are another way to end up there. The announcement also says the header has no version requirements and does not handle load order, and it tells authors to keep using class_exists() and similar checks. So the header protects the admin flow, and your runtime check protects the code.

How do I tell installed-but-inactive apart from missing?

is_plugin_active() gives the same false for a plugin that is installed and switched off and for one that was never installed. When your notice should say “activate it” in one case and “install it” in the other, combine it with get_plugins(), which reads the headers of every plugin folder on disk.

<?php
// Checked on 18 Nov 2026, WordPress 7.1.4.
if ( ! function_exists( 'get_plugins' ) ) {
	require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
$path      = 'woocommerce/woocommerce.php';
$installed = array_key_exists( $path, get_plugins() );
$state     = $installed ? ( is_plugin_active( $path ) ? 'active' : 'inactive' ) : 'missing';

get_plugins() scans the plugins folder and parses headers, so it costs far more than is_plugin_active(). WordPress caches the result for the rest of the request, but keep it to admin screens rather than front-end page loads. A site carrying dozens of plugins feels that scan most, and our batch sibling asking whether 50 plugins are too many for a store looks at what large plugin counts really cost.

If you need the version as well, get_plugins() already returns it in each entry’s Version field. For a plugin that is loaded, its own constant or property is quicker and more honest, for example WC()->version for WooCommerce, which is what WooCommerce’s own docs use for compatibility checks. After a plugin update changes a folder name or a constant, every hard-coded check in your code needs a second look, which is one reason our guide on how to safely update WordPress starts with a staging copy.

Practical examples

An admin notice when a dependency is off

This is where is_plugin_active() fits best, because the question really is “has the site owner switched it on”.

<?php
// Checked on 18 Nov 2026, WordPress 7.1.4.
add_action( 'admin_notices', function () {
	if ( ! current_user_can( 'activate_plugins' ) ) {
		return;
	}
	if ( ! function_exists( 'is_plugin_active' ) ) {
		require_once ABSPATH . 'wp-admin/includes/plugin.php';
	}
	if ( is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
		return;
	}
	printf(
		'<div class="notice notice-error"><p>%s</p></div>',
		esc_html__( 'My Woo Integration needs WooCommerce to be active.', 'my-woo-integration' )
	);
} );

Two details matter. The capability check keeps the notice away from editors who cannot fix it, and esc_html__() escapes the translated text, which the earlier version of this article skipped.

Theme code that uses a plugin’s template function

Themes load after plugins, so by the time functions.php and your templates run, the plugin’s functions either exist or never will. Check the function itself.

<?php
// In a template file. Checked on 18 Nov 2026.
if ( function_exists( 'yoast_breadcrumb' ) ) {
	yoast_breadcrumb( '<nav class="breadcrumbs">', '</nav>' );
}

Checking a list of plugins at once

<?php
// Returns the required plugin paths that are not active. Checked on 18 Nov 2026.
function myplugin_missing_plugins( array $required ) {
	if ( ! function_exists( 'is_plugin_active' ) ) {
		require_once ABSPATH . 'wp-admin/includes/plugin.php';
	}
	return array_values( array_filter( $required, function ( $path ) {
		return ! is_plugin_active( $path );
	} ) );
}

$missing = myplugin_missing_plugins( array( 'woocommerce/woocommerce.php', 'akismet/akismet.php' ) );

The function reads an option that WordPress has already loaded into memory, so calling it many times on one request costs very little. You do not need to cache its result.

Common mistakes people report

These come up repeatedly in support forums and the WordPress bug tracker. We checked each source on 18 November 2026.

  • Fatal error: call to undefined function is_plugin_active(). A wordpress.org user reported it from a plugin’s Yoast SEO integration file in 2017, and an earlier thread shows the same error. Both are the missing include, which on 6.8 and later now mostly affects must-use plugins and early code.
  • The same error from the network version. In this thread a plugin called is_plugin_active_for_network() too early and took a multisite down with a 500 error until an update fixed it.
  • Expecting true for a must-use plugin. Developers asked for is_plugin_active() to cover mu-plugins and drop-ins in Trac ticket 24205. Core declined and documented the limit instead.
  • Treating active as loaded. The plugin dependencies post tells authors to keep using class_exists() style checks because neither the header nor the active list handles load order. Our alphabetical test showed the crash this prevents.
  • Guessing the path. The function fails silently on a slug or a wrong folder name, because the developer reference page defines the parameter as the exact path relative to the plugins directory, and our path table shows the result of every near miss. Read the path from WP-CLI or get_plugins().

Frequently asked questions

Is is_plugin_active() a hook?

No. It is a function that returns true or false. Attaching code with add_action( ‘is_plugin_active’... ) does nothing because no such hook is ever fired.

Does is_plugin_active() work on the front end?

Yes on WordPress 6.8 and later, from any regular plugin or theme. On 6.7 and earlier, and inside must-use plugins, include wp-admin/includes/plugin.php first.

Why does is_plugin_active() return false for an active plugin?

Almost always a wrong path. Pass the folder and main file exactly as wp plugin list - fields=file shows it. Must-use plugins also return false by design.

Can is_plugin_active() return true for a plugin that is not running?

Yes. If the plugin’s files were deleted without deactivating it, or if its code has not loaded yet, the option still lists it as active.

Does it work for network-activated plugins?

Yes. It checks the network list as well as the site list, so it returns true on every site of the network.

Is there an is_plugin_inactive() function?

Yes, since WordPress 3.1. It returns the opposite of is_plugin_active() and lives in the same file.

Should I check for a plugin with is_plugin_active() or class_exists()?

Use class_exists() or function_exists() when you are about to call the plugin’s code, and is_plugin_active() when you are showing settings or notices about the plugin.

How do I check if a theme is active?

Use wp_get_theme() and compare its stylesheet or template, or test for a function the theme defines. is_plugin_active() only knows about plugins.

How we tested this

All results above came from a throwaway WordPress 7.1.4 install on 18 November 2026, running PHP 8.5.5 with WP-CLI 2.12.0 and the WordPress SQLite Database Integration plugin 3.1.3. We used two small test plugins (one named to load first, one to load last), a must-use plugin that logged when is_plugin_active() was defined, and PHP’s built-in web server to make real front-end, REST, admin-ajax and wp-admin requests. The multisite checks used the same install after wp core multisite-convert. The 6.8 change was confirmed by comparing wp-settings.php in the 6.7.2 and 6.8 releases of the WordPress source.

Part of the Wbcom Designs family

The all-in-one WordPress community stack

Also ours: wbcomdesigns.comvapvarun.combrndle.com