コード例 #1
0
<?php

require_once 'admin.php';
if (!is_site_admin()) {
    wp_die(__('You do not have permission to access this page.'));
}
if (!isset($_GET['action']) || !isset($_GET['plugin'])) {
    wp_redirect('plugins.php');
}
if ('activate' == $_GET['action']) {
    check_admin_referer('activate-sitewide-plugin');
    if (!activate_sitewide_plugin($_GET['plugin'])) {
        wp_redirect('plugins.php?error=true');
    } else {
        do_action('activate_sitewide_plugin', $_GET['plugin']);
        wp_redirect('plugins.php?activate=true');
    }
} else {
    if ('deactivate' == $_GET['action']) {
        check_admin_referer('deactivate-sitewide-plugin');
        if (!deactivate_sitewide_plugin($_GET['plugin'])) {
            wp_redirect('plugins.php?error=true');
        } else {
            do_action('deactivate_sitewide_plugin', $_GET['plugin']);
            wp_redirect('plugins.php?deactivate=true');
        }
    }
}
die;
コード例 #2
0
/**
 * Deactivate a single plugin or multiple plugins.
 *
 * The deactivation hook is disabled by the plugin upgrader by using the $silent
 * parameter.
 *
 * @since unknown
 *
 * @param string|array $plugins Single plugin or list of plugins to deactivate.
 * @param bool $silent Optional, default is false. Prevent calling deactivate hook.
 */
function deactivate_plugins($plugins, $silent = false)
{
    $current = get_option('active_plugins');
    if (!is_array($plugins)) {
        $plugins = array($plugins);
    }
    foreach ($plugins as $plugin) {
        $plugin = plugin_basename($plugin);
        if (!is_plugin_active($plugin)) {
            continue;
        }
        if (!$silent) {
            do_action('deactivate_plugin', trim($plugin));
        }
        $key = array_search($plugin, (array) $current);
        if (false !== $key) {
            array_splice($current, $key, 1);
        }
        //Used by Plugin updater to internally deactivate plugin, however, not to notify plugins of the fact to prevent plugin output.
        if (!$silent) {
            do_action('deactivate_' . trim($plugin));
            do_action('deactivated_plugin', trim($plugin));
        }
        deactivate_sitewide_plugin(trim($plugin));
    }
    update_option('active_plugins', $current);
}
コード例 #3
0
ファイル: bp-chat.php プロジェクト: adisonc/MaineLearning
/**
 * bp_chat_load_buddypress()
 *
 * When we activate the component, we must make sure BuddyPress is loaded first (if active)
 * If it's not active, then the plugin should not be activated.
 */
function bp_chat_load_buddypress()
{
    if (function_exists('bp_core_setup_globals')) {
        return true;
    }
    /* Get the list of active sitewide plugins */
    $active_sitewide_plugins = maybe_unserialize(get_site_option('active_sitewide_plugins'));
    if (isset($active_sidewide_plugins['buddypress/bp-loader.php']) && !function_exists('bp_core_setup_globals')) {
        require_once WP_PLUGIN_DIR . '/buddypress/bp-loader.php';
        return true;
    }
    /* If we get to here, BuddyPress is not active, so we need to deactive the plugin and redirect. */
    require_once ABSPATH . 'wp-admin/includes/plugin.php';
    if (file_exists(ABSPATH . 'wp-admin/includes/mu.php')) {
        require_once ABSPATH . 'wp-admin/includes/mu.php';
    }
    deactivate_plugins(basename(__FILE__), true);
    if (function_exists('deactivate_sitewide_plugin')) {
        deactivate_sitewide_plugin(basename(__FILE__), true);
    }
    wp_redirect(get_bloginfo('wpurl') . '/wp-admin/plugins.php');
}