Example #1
0
/**
 * Initializes the plugin.
 *
 * Loads the required files, registers the new DB table, global cache groups and global capabilities.
 *
 * @since 1.0.0
 */
function ga_init()
{
    if (!function_exists('wp_network_roles')) {
        add_action('admin_notices', 'ga_requirements_notice_network_roles');
        add_action('network_admin_notices', 'ga_requirements_notice_network_roles');
        return;
    }
    define('GA_PATH', plugin_dir_path(__FILE__));
    define('GA_URL', plugin_dir_url(__FILE__));
    require_once GA_PATH . 'global-admin/wp-includes/load.php';
    require_once GA_PATH . 'global-admin/wp-includes/option.php';
    require_once GA_PATH . 'global-admin/wp-includes/class-wp-global-role.php';
    require_once GA_PATH . 'global-admin/wp-includes/class-wp-global-roles.php';
    require_once GA_PATH . 'global-admin/wp-includes/capabilities.php';
    require_once GA_PATH . 'global-admin/wp-includes/class-wp-user-with-network-and-global-roles.php';
    require_once GA_PATH . 'global-admin/wp-includes/user.php';
    require_once GA_PATH . 'global-admin/wp-includes/link-template.php';
    require_once GA_PATH . 'global-admin/wp-includes/admin-bar.php';
    require_once GA_PATH . 'global-admin/wp-includes/ms-functions.php';
    require_once GA_PATH . 'global-admin/wp-includes/ms-default-filters.php';
    require_once GA_PATH . 'global-admin/wp-admin/includes/schema.php';
    require_once GA_PATH . 'global-admin/wp-admin/includes/hacks.php';
    require_once ABSPATH . 'wp-admin/includes/plugin.php';
    if (is_plugin_active('wp-multi-network/wpmn-loader.php')) {
        require_once GA_PATH . 'global-admin/multi-network-compat.php';
    }
    if (is_plugin_active('wp-user-signups/wp-user-signups.php')) {
        require_once GA_PATH . 'global-admin/user-signups-compat.php';
    }
    if (is_multinetwork()) {
        ga_register_table();
        add_action('setup_theme', 'ga_setup_wp_global_roles', 1);
    }
    if (function_exists('wp_cache_add_global_groups')) {
        wp_cache_add_global_groups(array('global-options', 'global-transient'));
    }
}
Example #2
0
/** WordPress Administration Bootstrap */
if (!defined('ABSPATH')) {
    require_once dirname(__FILE__) . '/admin.php';
}
if (!current_user_can('manage_network_options')) {
    wp_die(__('Sorry, you are not allowed to manage options for this network.', 'global-admin'));
}
if (is_multinetwork() && !is_global_admin()) {
    wp_redirect(global_admin_url('setup.php'));
    exit;
}
require_once GA_PATH . 'global-admin/wp-admin/includes/global.php';
// This would be it if it was part of Core.
//require_once( ABSPATH . 'wp-admin/includes/global.php' );
// We need to create references to ms global tables to enable Network.
ga_register_table();
if (!global_table_check() && (!defined('WP_ALLOW_MULTINETWORK') || !WP_ALLOW_MULTINETWORK)) {
    wp_die(printf(__('You must define the %1$s constant as true in your %2$s file to allow creation of a Multinetwork.', 'global-admin'), '<code>WP_ALLOW_MULTINETWORK</code>', '<code>wp-config.php</code>'));
}
if (is_global_admin()) {
    $title = __('Global Setup', 'global-admin');
} else {
    $title = __('Create a Multinetwork', 'global-admin');
}
$parent_file = 'settings.php';
$global_help = '<p>' . __('This screen allows you to configure a multinetwork setup which will provide you with a Global Admin panel to add further networks.', 'global-admin') . '</p>' . '<p>' . __('The next screen for Global Setup will give you individually-generated lines of code to add to your wp-config.php file. Make a backup copy of that file.', 'global-admin') . '</p>' . '<p>' . __('Add the designated lines of code to wp-config.php (just before <code>/*...stop editing...*/</code>).', 'global-admin') . '</p>' . '<p>' . __('Once you add this code and refresh your browser, multinetwork should be enabled. This screen, now in the Global Admin navigation menu, will keep an archive of the added code. You can toggle between Global Admin and Network Admin by clicking on the Global Admin or an individual network name under the My Networks dropdown in the Toolbar.', 'global-admin') . '</p>' . '<p><strong>' . __('For more information:', 'global-admin') . '</strong></p>' . '<p>' . __('<a href="https://github.com/felixarntz/global-admin/wiki/Create-A-Multinetwork" target="_blank">Documentation on Creating a Multinetwork</a>', 'global-admin') . '</p>';
get_current_screen()->add_help_tab(array('id' => 'global', 'title' => __('Multinetwork', 'global-admin'), 'content' => $global_help));
get_current_screen()->set_help_sidebar('<p><strong>' . __('For more information:', 'global-admin') . '</strong></p>' . '<p>' . __('<a href="https://github.com/felixarntz/global-admin/wiki/Create-A-Multinetwork" target="_blank">Documentation on Creating a Multinetwork</a>', 'global-admin') . '</p>');
// Only load admin header and footer files when loaded directly. Otherwise they are included by WP Core.
$_ga_load_admin_files = !did_action('in_admin_header');
if ($_ga_load_admin_files) {