/** * Adjusts the URL to the networks admin page to be part of the Global Administration panel. * * @since 1.0.0 * @access private * * @param string $url The original URL. * @return string The adjusted URL. */ function _ga_adjust_signups_admin_url($url, $admin_url, $r, $args) { if (!is_multinetwork()) { return $url; } $admin_url = global_admin_url('admin.php'); return add_query_arg($r, $admin_url); }
/** * Adjusts the URL to the networks admin page to be part of the Global Administration panel. * * @since 1.0.0 * @access private * * @param string $url The original URL. * @return string The adjusted URL. */ function _ga_adjust_networks_admin_url($url, $args) { if (!is_multinetwork()) { return $url; } $args = wp_parse_args($args, array('page' => 'networks')); return add_query_arg($args, global_admin_url('admin.php')); }
/** * Adds links to the Global Administration panel to the Toolbar as necessary. * * @since 1.0.0 * @access private * * @param WP_Admin_Bar $admin_bar The Toolbar instance. */ function _ga_adjust_admin_bar_my_sites_menu($admin_bar) { if (!is_user_logged_in() || !current_user_can('manage_global')) { return; } $admin_bar->add_group(array('parent' => 'my-sites', 'id' => 'my-sites-global-admin')); $admin_bar->add_menu(array('parent' => 'my-sites-global-admin', 'id' => 'global-admin', 'title' => __('Global Admin', 'global-admin'), 'href' => global_admin_url())); $admin_bar->add_menu(array('parent' => 'global-admin', 'id' => 'global-admin-d', 'title' => __('Dashboard'), 'href' => global_admin_url())); /** * Filters whether the Networks item should be shown in the Global Admin menu of the Toolbar. * * @private * @since 1.0.0 * * @param bool Whether to show the item. Defaults to false. */ if (apply_filters('_global_admin_show_admin_bar_networks', false)) { $admin_bar->add_menu(array('parent' => 'global-admin', 'id' => 'global-admin-n', 'title' => __('Networks', 'global-admin'), 'href' => add_query_arg(array('page' => 'networks'), global_admin_url('admin.php')))); } $admin_bar->add_menu(array('parent' => 'global-admin', 'id' => 'global-admin-u', 'title' => __('Users'), 'href' => global_admin_url('users.php'))); $admin_bar->add_menu(array('parent' => 'global-admin', 'id' => 'global-admin-o', 'title' => __('Settings'), 'href' => global_admin_url('settings.php'))); }
$title = __('Global Settings', 'global-admin'); $parent_file = 'settings.php'; get_current_screen()->add_help_tab(array('id' => 'overview', 'title' => __('Overview', 'global-admin'), 'content' => '<p>' . __('This screen sets and changes options for the entire setup as a whole. The settings on this page will affect all networks and sites.', 'global-admin') . '</p>')); 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/Global-Admin-Settings-Screen" target="_blank">Documentation on Global Settings</a>', 'global-admin') . '</p>'); if ($_POST) { check_admin_referer('global-options'); //TODO: process global settings $options = array(); foreach ($options as $option_name) { if (!isset($_POST[$option_name])) { continue; } $value = wp_unslash($_POST[$option_name]); update_global_option($option_name, $value); } wp_redirect(add_query_arg('updated', 'true', global_admin_url('settings.php'))); exit; } include ABSPATH . 'wp-admin/admin-header.php'; if (isset($_GET['updated'])) { ?> <div id="message" class="updated notice is-dismissible"><p><?php _e('Settings saved.'); ?> </p></div><?php } ?> <div class="wrap"> <h1><?php echo esc_html($title);
<?php /** * Action handler for Multisite Global Administration panels. * * @package GlobalAdmin * @since 1.0.0 */ /** Load WordPress Administration Bootstrap */ require_once dirname(__FILE__) . '/admin.php'; if (!is_multinetwork()) { wp_die(__('Multinetwork support is not enabled.', 'global-admin')); } if (empty($_GET['action'])) { wp_redirect(global_admin_url()); exit; } /** * Fires the requested handler action in the Global Administration panel. * * The dynamic portion of the hook name, `$_GET['action']`, refers to the name * of the requested action. * * @since 1.0.0 */ do_action('global_admin_edit_' . $_GET['action']); wp_redirect(global_admin_url()); exit;
/** * Renders the list table views. * * @since 1.0.0 * @access public * * @global string $role * * @return array */ protected function get_views() { global $role; $total_users = get_global_user_count(); //TODO: support view for global administrators $global_admins = array(); $total_admins = count($global_admins); $class = $role != 'super' ? ' class="current"' : ''; $role_links = array(); $role_links['all'] = "<a href='" . global_admin_url('users.php') . "'{$class}>" . sprintf(_nx('All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_users, 'users'), number_format_i18n($total_users)) . '</a>'; $class = $role === 'super' ? ' class="current"' : ''; $role_links['super'] = "<a href='" . global_admin_url('users.php?role=super') . "'{$class}>" . sprintf(_n('Super Admin <span class="count">(%s)</span>', 'Super Admins <span class="count">(%s)</span>', $total_admins), number_format_i18n($total_admins)) . '</a>'; return $role_links; }
case 'add': _e('User added.'); break; } ?> </p></div> <?php } ?> <div class="wrap"> <h1><?php esc_html_e('Users'); if (current_user_can('create_users')) { ?> <a href="<?php echo global_admin_url('user-new.php'); ?> " class="page-title-action"><?php echo esc_html_x('Add New', 'user'); ?> </a><?php } if (strlen($usersearch)) { /* translators: %s: search keywords */ printf('<span class="subtitle">' . __('Search results for “%s”') . '</span>', esc_html($usersearch)); } ?> </h1> <?php $wp_list_table->views();
* * A multi-step process allowing the user to enable a multinetwork setup of WordPress. * * @package GlobalAdmin * @since 1.0.0 */ define('WP_INSTALLING_GLOBAL', true); /** 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'); }
/** * Adjusts the edit user link to consider the Global Administration panel as well. * * @since 1.0.0 * @access private * * @param string $link The edit user link. * @param int $user_id The user ID. * @return string The adjusted link. */ function _ga_adjust_edit_user_link($link, $user_id) { if (get_current_user_id() == $user_id || !is_global_admin()) { return $link; } return add_query_arg('user_id', $user_id, global_admin_url('user-edit.php')); }