is_plugin_active_for_network() - WordPress 函数参考中文文档

返回介绍

is_plugin_active_for_network()

发布于 2017-09-11 字数2722 浏览 851 评论 0

is_plugin_active_for_network( string $plugin )

Check whether the plugin is active for the entire network.


描述

Only plugins installed in the plugins/ folder can be active.

Plugins in the mu-plugins/ folder can’t be "activated," so this function will return false for those plugins.


参数

$plugin

(string)
(Required)
Path to the main plugin file from plugins directory.


返回值

(bool) True, if active for the network, otherwise false.


源代码

File: wp-admin/includes/plugin.php

function is_plugin_active_for_network( $plugin ) {
	if ( !is_multisite() )
		return false;

	$plugins = get_site_option( 'active_sitewide_plugins');
	if ( isset($plugins[$plugin]) )
		return true;

	return false;
}

更新日志

Version 描述
3.0.0 Introduced.

相关函数

Uses

  • wp-includes/load.php:
    is_multisite()
  • wp-includes/option.php:
    get_site_option()

Used By

  • wp-admin/includes/class-wp-plugins-list-table.php:
    WP_Plugins_List_Table::single_row()
  • wp-admin/includes/class-wp-plugins-list-table.php:
    WP_Plugins_List_Table::prepare_items()
  • wp-admin/includes/class-plugin-upgrader-skin.php:
    Plugin_Upgrader_Skin::__construct()
  • wp-admin/includes/update.php:
    wp_plugin_update_row()
  • wp-admin/includes/plugin.php:
    is_plugin_active()
  • wp-admin/includes/plugin.php:
    deactivate_plugins()
  • Show 1 more used by
    Hide more used by


User Contributed Notes

  1. Skip to note content

    You must log in to vote on the helpfulness of this noteVote results for this note: 0You must log in to vote on the helpfulness of this note

    Contributed by Codex

    Example

    
    // Makes sure the plugin is defined before trying to use it
    if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
        require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
    }
     
    if ( is_plugin_active_for_network( 'plugin-directory/plugin-file.php' ) ) {
        // Plugin is activated
    }
    

上一篇:is_plugin_active()

下一篇:is_plugin_inactive()

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!