is_plugin_active()判断某个插件是否激活正在使用

目录

描述

Checks if a plugin is activated.

NOTE: defined in wp-admin/includes/plugin.php, so this is only available from within the admin pages, and any references to this function must be hooked to admin_init or a later action. If you want to use this function from within a template, you will need to manually require plugin.php, an example is below.

is_plugin_active() 描述

用法

In the Admin Area:<?php is_plugin_active($plugin?>In the front end, in a theme, etc...<?php include_once( ABSPATH 'wp-admin/includes/plugin.php' ); ?>
<?php is_plugin_active
($plugin?>

is_plugin_active() 用法

参数

$plugin

(string) (必填) The name of the plugin sub-directory/file.

默认值: None

is_plugin_active() 参数

返回值

True

if plugin is activated, else false.

is_plugin_active() 返回值

示例

Admin area

<?php
/**
 * Detect plugin. For use in Admin area only.
 */
if ( is_plugin_active'plugin-directory/plugin-file.php' ) ) {
  
//plugin is activated


Front end

<?php
/**
 * Detect plugin. For use on Front End only.
 */
include_once( ABSPATH 'wp-admin/includes/plugin.php' );

// check for plugin using plugin name
if ( is_plugin_active'plugin-directory/plugin-file.php' ) ) {
  
//plugin is activated


is_plugin_active() 示例

历史

添加于 版本 Version 2.5

is_plugin_active() 历史

源文件

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

is_plugin_active() 源文件

相关