Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/is plugin inactive

This page redirects to an external site: https://developer.wordpress.org/reference/functions/is_plugin_inactive/

Description

Checks if a plugin is not activated.

This function is the logical negation of is_plugin_active(). Used as a callback.

Usage

In the Admin Area:

<code style="color: #000000"><span style="color: #0000BB"><?php is_plugin_inactive</span><span style="color: #007700">(</span><span style="color: #0000BB">$plugin</span><span style="color: #007700">) </span><span style="color: #0000BB">?></span></code>

In the front end, in a theme, etc...

<code style="color: #000000"><span style="color: #0000BB"><?php </span><span style="color: #007700">include_once( </span><span style="color: #0000BB">ABSPATH </span><span style="color: #007700">. </span><span style="color: #DD0000">'wp-admin/includes/plugin.php' </span><span style="color: #007700">); </span><span style="color: #0000BB">?>
<?php is_plugin_inactive</span><span style="color: #007700">(</span><span style="color: #0000BB">$plugin</span><span style="color: #007700">) </span><span style="color: #0000BB">?></span></code>

Parameters

$plugin
(string) (required) The name of the plugin sub-directory/file.
Default: None

Return Values

True
if plugin is not activated, else false.

Examples

<code style="color: #000000"><span style="color: #0000BB"><?php
</span><span style="color: #FF8000">// Makes sure the plugin is defined before trying to use it
</span><span style="color: #007700">if ( ! </span><span style="color: #0000BB">function_exists</span><span style="color: #007700">(</span><span style="color: #DD0000">'is_plugin_inactive'</span><span style="color: #007700">)) {
    require_once( </span><span style="color: #0000BB">ABSPATH </span><span style="color: #007700">. </span><span style="color: #DD0000">'/wp-admin/includes/plugin.php' </span><span style="color: #007700">);
}

if (</span><span style="color: #0000BB">is_plugin_inactive</span><span style="color: #007700">(</span><span style="color: #DD0000">'plugin-directory/plugin-file.php'</span><span style="color: #007700">)) {
    </span><span style="color: #FF8000">//plugin is not activated
</span><span style="color: #007700">}
</span><span style="color: #0000BB">?></span></code>

Notes

The file that defines this function (wp-admin/includes/plugin.php) is only loaded in the admin sections. In order to use is_plugin_active outside the admin pages, it's necessary to include or require plugin.php before trying to use it (as shown in the example).

Change Log

Since Version 3.1

Source File

is_plugin_inactive() is defined in wp-admin/includes/plugin.php.

Related

See also index of Function Reference and index of Template Tags.