Example #1
0
 /**
  * Before we changed errors and blog-specific storage on a MS network.
  *
  * @since 151002 Improving multisite compat.
  */
 protected function fromLte150807()
 {
     if (version_compare($this->prev_version, '150807', '<=')) {
         delete_site_option(GLOBAL_NS . '_errors');
         // No longer necessary.
         if (is_multisite() && is_array($child_blogs = wp_get_sites())) {
             $current_site = get_current_site();
             // Current site.
             foreach ($child_blogs as $_child_blog) {
                 switch_to_blog($_child_blog['blog_id']);
                 delete_option(GLOBAL_NS . '_errors');
                 delete_option(GLOBAL_NS . '_notices');
                 delete_option(GLOBAL_NS . '_options');
                 delete_option(GLOBAL_NS . '_apc_warning_bypass');
                 if ((int) $_child_blog['blog_id'] !== (int) $current_site->blog_id) {
                     wp_clear_scheduled_hook('_cron_' . GLOBAL_NS . '_auto_cache');
                     wp_clear_scheduled_hook('_cron_' . GLOBAL_NS . '_cleanup');
                 }
                 restore_current_blog();
                 // Restore current blog.
             }
             unset($_child_blog);
             // Housekeeping.
         }
         if (is_array($existing_options = get_site_option(GLOBAL_NS . '_options'))) {
             if (isset($existing_options['admin_bar_enable'])) {
                 $this->plugin->options['cache_clear_admin_bar_enable'] = $existing_options['admin_bar_enable'];
                 $this->plugin->updateOptions($this->plugin->options, false);
                 // Save/update options.
             }
         }
     }
 }
 /**
  * Query for our sites
  *
  * @since 1.0.1
  */
 public function get_sites()
 {
     if (empty($this->sites)) {
         $this->sites = wp_get_sites(array('deleted' => false));
     }
     return $this->sites;
 }
Example #3
0
/**
 * The uninstalling process.
 *
 * @since    1.0
 */
function awf_uninstall_arabic_webfonts_plugin()
{
    if (function_exists('is_multisite') && is_multisite()) {
        // check permission
        if (false == is_super_admin()) {
            return;
        }
        // get all sites in network
        $sites = wp_get_sites();
        foreach ($sites as $site) {
            switch_to_blog($site['blog_id']);
            // delete custom post type
            awf_delete_custom_post_type();
            // remove all theme mods
            awf_remove_all_theme_mods();
            restore_current_blog();
        }
    } else {
        if (!current_user_can('activate_plugins')) {
            return;
        }
        // delete custom post type
        awf_delete_custom_post_type();
        // remove all theme mods
        awf_remove_all_theme_mods();
    }
}
Example #4
0
 /**
  * Maybe uninstall.
  *
  * @since 160524 Uninstall utils.
  */
 public function maybeUninstall()
 {
     // See: <https://core.trac.wordpress.org/ticket/14955>
     if ($this->App->Config->§specs['§type'] !== 'plugin') {
         return;
         // For plugins only at this time.
     } elseif (!defined('WP_UNINSTALL_PLUGIN')) {
         return;
         // Not applicable.
     } elseif ($this->s::conflictsExist()) {
         return;
         // Stop on conflicts.
     } elseif (!$this->App->Config->§uninstall) {
         return;
         // Not uninstalling.
     }
     $this->site_counter = 0;
     // Initialize site counter.
     if ($this->Wp->is_multisite) {
         // For each site in the network.
         foreach (($sites = wp_get_sites()) ? $sites : [] as $_site) {
             ++$this->site_counter;
             switch_to_blog($_site['blog_id']);
             $this->uninstall();
             restore_current_blog();
         }
         // unset($_site);
     } else {
         ++$this->site_counter;
         $this->uninstall();
     }
 }
 /**
  * Returns an array of all sites in the current network.
  * The array index is the blog-ID and the array value the blog title.
  *
  * @since  1.0.0
  * @param  bool $only_public By default only public sites are returned.
  * @return array
  */
 public static function get_blogs($only_public = true)
 {
     static $List = array();
     $key = $only_public ? 'public' : 'all';
     if (!isset($List['_cache'])) {
         $List['_cache'] = array();
     }
     if (!isset($List[$key])) {
         $args = array('limit' => 0, 'public' => true, 'spam' => false, 'deleted' => false);
         if ($only_public) {
             $args['archived'] = false;
             $args['mature'] = false;
         }
         $sites = wp_get_sites($args);
         $List[$key] = array();
         foreach ($sites as $site_data) {
             $blog_id = $site_data['blog_id'];
             if (isset($List['_cache'][$blog_id])) {
                 $title = $List['_cache'][$blog_id];
             } else {
                 switch_to_blog($blog_id);
                 $title = get_bloginfo('title');
                 $List['_cache'][$blog_id] = $title;
                 restore_current_blog();
             }
             $List[$key][$blog_id] = $title;
         }
     }
     return $List[$key];
 }
/**
 * Plugin activation hook.
 * When site is multisite and plugin is network activated, installer will run for each blog
 *
 * @param bool $network_wide
 */
function __download_monitor_install($network_wide = false)
{
    // Load installer functions
    require_once plugin_dir_path(DLM_PLUGIN_FILE_INSTALLER) . 'includes/class-dlm-installer.php';
    // DLM Installer
    $installer = new DLM_Installer();
    // check if
    if (!function_exists('is_plugin_active_for_network')) {
        require_once ABSPATH . '/wp-admin/includes/plugin.php';
    }
    // check if it's multisite
    if (is_multisite() && true == $network_wide) {
        // get websites
        $sites = wp_get_sites();
        // loop
        if (count($sites) > 0) {
            foreach ($sites as $site) {
                // switch to blog
                switch_to_blog($site['blog_id']);
                // run installer on blog
                $installer->install();
                // restore current blog
                restore_current_blog();
            }
        }
    } else {
        // no multisite so do normal install
        $installer->install();
    }
}
function sites_listing_shortcode($atts)
{
    extract(shortcode_atts(array('network_id' => 1, 'public' => null, 'archived' => null, 'mature' => null, 'spam' => null, 'deleted' => null, 'limit' => -1, 'offset' => 0), $atts));
    $options = array('network_id' => $network_id, 'public' => $public, 'archived' => $archived, 'mature' => $mature, 'spam' => $spam, 'deleted' => $deleted, 'limit' => $limit);
    $sites = wp_get_sites($options);
    ob_start();
    if (!empty($sites)) {
        ?>
        <ul class="sites-listing"> <?
            foreach($sites as $site) 
             switch_to_blog( $site['blog_id'] ); ?>
                <li id="site-<?php 
        echo $site['blog_id'];
        ?>
">
                    <a href="<?php 
        echo get_bloginfo('url');
        ?>
"><?php 
        echo get_bloginfo('name');
        ?>
</a>
                </li><?
             restore_current_blog();
            endforeach; ?>
        </ul> <?php 
    }
    ob_end_flush();
}
function bf_msn__admin_settings_sidebar_metabox_html()
{
    global $post, $buddyforms, $wpdb;
    if ($post->post_type != 'buddyforms') {
        return;
    }
    $buddyform = get_post_meta(get_the_ID(), '_buddyforms_options', true);
    $form_setup = array();
    $args = array('network_id' => $wpdb->siteid, 'public' => null, 'archived' => null, 'mature' => null, 'spam' => null, 'deleted' => null, 'limit' => 100, 'offset' => 0);
    $sites = wp_get_sites();
    $msn_sites['off'] = 'Disabled';
    foreach ($sites as $key => $site) {
        $msn_sites[$site['blog_id']] = $site['path'];
    }
    $msn_enabled = 'off';
    if (isset($buddyform['msn_enabled'])) {
        $msn_enabled = $buddyform['msn_enabled'];
    }
    $form_setup[] = new Element_Select("<b>" . __('Enable', 'buddyforms') . "</b>", "buddyforms_options[msn_enabled]", $msn_sites, array('value' => $msn_enabled, 'shortDesc' => __('Link this form to form to a site in the network.', 'buddyforms')));
    foreach ($form_setup as $key => $field) {
        echo '<div class="buddyforms_field_label">' . $field->getLabel() . '</div>';
        echo '<div class="buddyforms_field_description">' . $field->getShortDesc() . '</div>';
        echo '<div class="buddyforms_form_field">' . $field->render() . '</div>';
    }
}
function list_network_sites($atts)
{
    // Start by getting an array of information of all sites in the network.
    $info = array('network_id' => null, 'public' => null, 'archived' => null, 'mature' => null, 'spam' => null, 'deleted' => null, 'limit' => 100, 'offset' => 0);
    $siteInfos = wp_get_sites($info);
    // Use shortcode atts to determine list type, then begin the output variable $list with the right <li> tag.
    $listType = shortcode_atts(array('list' => "unordered"), $atts);
    if ($listType['list'] == "unordered") {
        $list = "<ul>";
    } else {
        if ($listType['list'] == "ordered") {
            $list = "<ol>";
        } else {
            $list = "Error: Incorrect shortcode was used. Please contact admin.";
            return $list;
        }
    }
    // Add the list content.
    foreach ($siteInfos as $siteInfo) {
        $blog_details = get_blog_details($siteInfo['blog_id']);
        $list .= "<li><a href='{$blog_details->siteurl}'>{$blog_details->blogname}</a></li>";
    }
    // Close the list tag.
    if ($listType['list'] == "unordered") {
        $list .= "</ul>";
    } else {
        $list .= "</ol>";
    }
    return $list;
}
 static function uninstall()
 {
     global $wpdb;
     if (is_multisite()) {
         // Cleanup Network install
         foreach (wp_get_sites(array('limit' => apply_filters('gadwp_sites_limit', 100))) as $blog) {
             switch_to_blog($blog['blog_id']);
             $sqlquery = $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_gadash%%'");
             $sqlquery = $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_timeout_gadash%%'");
             $sqlquery = $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_ga_dash%%'");
             $sqlquery = $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_timeout_ga_dash%%'");
             delete_option('gadash_options');
             delete_transient('ga_dash_lasterror');
             delete_transient('ga_dash_refresh_token');
             delete_transient('ga_dash_gapi_errors');
             restore_current_blog();
         }
         delete_site_option('gadash_network_options');
         delete_site_transient('ga_dash_refresh_token');
     } else {
         // Cleanup Single install
         $sqlquery = $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_gadash%%'");
         $sqlquery = $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_timeout_gadash%%'");
         $sqlquery = $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_ga_dash%%'");
         $sqlquery = $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_timeout_ga_dash%%'");
         delete_option('gadash_options');
         delete_transient('ga_dash_lasterror');
         delete_transient('ga_dash_refresh_token');
         delete_transient('ga_dash_gapi_errors');
     }
 }
Example #11
0
 function get($empty, $arg, $requete)
 {
     $is_result = apply_filters('eventpost_multisite_get', $empty, $arg, $requete);
     if ($is_result != $empty) {
         return $is_result;
     }
     if (!is_array($arg) || !isset($arg['blogs']) || '' == $arg['blogs']) {
         return $empty;
     }
     //print_r($arg);
     $blog_ids = array();
     if ($arg['blogs'] == 'all') {
         $blogs = wp_get_sites(array('limit' => 0));
         foreach ($blogs as $blog) {
             $blog_ids[] = $blog['blog_id'];
         }
     } elseif (!empty($arg['blogs'])) {
         $blog_ids = apply_filters('eventpost_multisite_blogids', explode(',', $arg['blogs']));
     } else {
         return $empty;
     }
     global $EventPost, $wpdb;
     $all_events = array();
     foreach ($blog_ids as $blog_id) {
         switch_to_blog($blog_id);
         $query = new WP_Query($requete);
         $events = $wpdb->get_col($query->request);
         foreach ($events as $k => $event) {
             $all_events[] = $EventPost->retreive($event);
         }
         restore_current_blog();
     }
     return $all_events;
 }
Example #12
0
function get_all_posts()
{
    $sites = wp_get_sites();
    foreach ($sites as $site) {
        switch_to_blog($site['blog_id']);
        get_all_posts_on_site();
    }
}
 /**
  * Constructor
  *
  * @param   Inpsyde_Property_List_Interface $plugin_data
  * @param   wpdb                            $wpdb
  * @param   Mlp_Version_Number_Interface    $current_version
  * @param   Mlp_Version_Number_Interface    $last_version
  * @return  Mlp_Update_Plugin_Data
  */
 public function __construct(Inpsyde_Property_List_Interface $plugin_data, wpdb $wpdb, Mlp_Version_Number_Interface $current_version, Mlp_Version_Number_Interface $last_version)
 {
     $this->plugin_data = $plugin_data;
     $this->last_version = $last_version;
     $this->current_version = $current_version;
     $this->wpdb = $wpdb;
     $this->all_sites = wp_get_sites();
 }
 public static function do_sync()
 {
     global $wpdb;
     $debug_mode = defined('KIGO_DEBUG') && KIGO_DEBUG;
     // Do not log into New Relic, because this function is slow and we know why
     if (extension_loaded('newrelic')) {
         newrelic_ignore_transaction();
     }
     //Check that cron is "enabled" and that the secret is correct
     if (!defined('KIGO_CRON_SECRET') || !isset($_GET[self::GET_PARAM_CRON_SECRET]) || $_GET[self::GET_PARAM_CRON_SECRET] !== KIGO_CRON_SECRET) {
         self::log(array('message' => 'Missing/Invalid cron secret', 'info' => $_SERVER));
         self::handle_logs($debug_mode);
         exit;
     }
     // Ensure that no other cron will run concurrently by acquiring an advisory lock (at MySQL database)
     if (!$wpdb->get_var($wpdb->prepare('SELECT GET_LOCK(%s, 0)', self::ADV_LOCK_PROCESSING))) {
         self::log('Previous cron execution is not finished, could not acquire cron lock');
         self::handle_logs($debug_mode);
         exit;
     }
     $prevTimeTotal = microtime(true);
     if (is_multisite()) {
         require_once dirname(__FILE__) . '/ext/class-zebra-curl.php';
         // Change the default value of wp_is_large_network necessary if # of sites reach the 10000
         add_filter('wp_is_large_network', array('Kigo_Network_Cron', 'custom_wp_is_large_network'), 1, 3);
         // Initialize the list of sites
         $sites = wp_get_sites(array('limit' => self::CUSTOM_WP_IS_LARGE_NETWORK, 'deleted' => 0, 'archived' => 0));
         shuffle($sites);
         // Filter the sites, not to trigger a sync for site where the solution data have not been updated since X months
         self::filter_old_sites($sites);
         self::log(array('nb_sites' => count($sites)));
         //Do the Zebra cURL call (asynchronous calls)
         $curl = new Zebra_cURL();
         $curl->option(CURLOPT_TIMEOUT, self::CURL_TIMEOUT);
         $curl->threads = self::CURL_PARALLEL_CALLS;
         //Prepare URLs to be called
         $urls = array_map(array('Kigo_Network_Cron', 'generate_curl_urls'), $sites);
         $urls = array_filter($urls, function ($url) {
             return is_string($url);
         });
         $curl->get($urls, array('Kigo_Network_Cron', 'zebra_curl_callback'));
     } else {
         set_error_handler(array('Kigo_Network_Cron', 'php_error_handler'));
         // Add our custom handler for wp_die() because some functions die on error, and we don't want the script to die !
         add_filter('wp_die_ajax_handler', array('Kigo_Network_Cron', 'kigo_cron_wp_die_handler_filter'));
         $site_cron = new Kigo_Site_Cron();
         self::log($site_cron->sync_entities() ? true : $site_cron->_errors);
         restore_error_handler();
     }
     self::log(array('total_execution_time' => microtime(true) - $prevTimeTotal));
     if (!$wpdb->query($wpdb->prepare('SELECT RELEASE_LOCK(%s)', self::ADV_LOCK_PROCESSING))) {
         self::log('Could not release cron lock');
     }
     // Echo the logs in debug mode or send them by mail
     self::handle_logs($debug_mode);
     exit;
 }
Example #15
0
 /**
  * Class constructor.
  *
  * @since 141111 First documented version.
  */
 public function __construct()
 {
     parent::__construct();
     if ($this->plugin->enable_hooks) {
         return;
         // Not a good idea.
     }
     $this->plugin->setup();
     // Setup.
     if (!defined('WP_UNINSTALL_PLUGIN')) {
         return;
         // Disallow.
     }
     if (empty($GLOBALS[GLOBAL_NS . '_uninstalling'])) {
         return;
         // Expecting uninstall file.
     }
     if ($this->plugin->options['uninstall_safeguards_enable']) {
         return;
         // Nothing to do here; safeguarding.
     }
     if (!current_user_can($this->plugin->uninstall_cap)) {
         return;
         // Extra layer of security.
     }
     if (!current_user_can($this->plugin->cap)) {
         return;
         // Extra layer of security.
     }
     $this->deleteOptions();
     $this->deleteNotices();
     $this->deleteInstallTime();
     $this->deleteOptionKeys();
     $this->deleteTransientKeys();
     $this->deletePostMetaKeys();
     $this->deleteUserMetaKeys();
     $this->clearCronHooks();
     $this->dropDbTables();
     if (is_multisite() && is_array($child_blogs = wp_get_sites())) {
         foreach ($child_blogs as $_child_blog) {
             switch_to_blog($_child_blog['blog_id']);
             $this->deleteOptions();
             $this->deleteNotices();
             $this->deleteInstallTime();
             $this->deleteOptionKeys();
             $this->deleteTransientKeys();
             $this->deletePostMetaKeys();
             $this->deleteUserMetaKeys();
             $this->clearCronHooks();
             $this->dropDbTables();
             restore_current_blog();
         }
     }
     unset($_child_blog);
     // Housekeeping.
 }
 /**
  * Set the blog id(s) for a site
  */
 private function set_blog_ids()
 {
     $blog_ids = array(1);
     if (function_exists('is_multisite') && is_multisite()) {
         $args = array('limit' => false, 'spam' => 0, 'deleted' => 0, 'archived' => 0);
         $blogs = wp_get_sites($args);
         $blog_ids = wp_list_pluck($blogs, 'blog_id');
     }
     $this->blog_ids = $blog_ids;
 }
Example #17
0
 public function get_multisites()
 {
     $multisites = wp_get_sites();
     $this->load_included_site_ids();
     $result = [];
     foreach ($multisites as $blog) {
         $result[] = $this->prepare_item($blog);
     }
     return $result;
 }
 public function login_radius_update_old_blogs($oldConfig)
 {
     global $loginradius_api_settings;
     if (isset($loginradius_api_settings['multisite_config']) && $loginradius_api_settings['multisite_config'] == '1') {
         $settings = get_option('LoginRadius_share_settings');
         $blogs = wp_get_sites();
         foreach ($blogs as $blog) {
             update_blog_option($blog['blog_id'], 'LoginRadius_share_settings', $settings);
         }
     }
 }
Example #19
0
 /**
  * Set 'mucd_duplicable' option to "yes" for the list of blogs, other to "no"
  * @since 0.2.0
  * @param array $blogs list of blogs we want the option set to "yes"
  */
 public static function set_duplicable_option($blogs)
 {
     $network_blogs = wp_get_sites(array('limit' => MUCD_MAX_NUMBER_OF_SITE));
     foreach ($network_blogs as $blog) {
         if (in_array($blog['blog_id'], $blogs)) {
             update_blog_option($blog['blog_id'], 'mucd_duplicable', "yes");
         } else {
             update_blog_option($blog['blog_id'], 'mucd_duplicable', "no");
         }
     }
 }
Example #20
0
 public function get_sites()
 {
     $sites = wp_get_sites();
     $pages = array();
     foreach ($sites as $site) {
         switch_to_blog($site['blog_id']);
         $pages[] = array('blog_id' => $site['blog_id'], 'pages' => get_pages());
         restore_current_blog();
     }
     $this->sites = $pages;
 }
 public function oss_update_old_blogs($oldConfig)
 {
     global $oss_api_settings;
     if (isset($oss_api_settings['multisite_config']) && $oss_api_settings['multisite_config'] == '1') {
         $settings = get_option('OpenSocialShare_share_settings');
         $blogs = wp_get_sites();
         foreach ($blogs as $blog) {
             update_blog_option($blog['blog_id'], 'OpenSocialShare_share_settings', $settings);
         }
     }
 }
 /**
  * Get a list of wordpress site ids.
  *
  * @return \Guzzle\Http\Message\Response
  */
 public static function getSites()
 {
     if (is_multisite() && ($sites = wp_get_sites())) {
         $blogIDs = [];
         foreach ($sites as $value) {
             $blogIDs[] = $value['blog_id'];
         }
         return $blogIDs;
     }
     return [get_current_blog_id()];
 }
 /**
  * Get all duplicable sites
  * @since 0.2.0
  * @return array of blog data
  */
 public static function get_site_list()
 {
     $site_list = array();
     $network_blogs = wp_get_sites(array('limit' => MUCD_MAX_NUMBER_OF_SITE));
     foreach ($network_blogs as $blog) {
         if (MUCD_Functions::is_duplicable($blog['blog_id']) && MUCD_SITE_DUPLICATION_EXCLUDE != $blog['blog_id']) {
             $site_list[] = $blog;
         }
     }
     return $site_list;
 }
Example #24
0
 function tearDown()
 {
     parent::tearDown();
     if (is_multisite()) {
         $blogs = wp_get_sites();
         foreach ($blogs as $blog) {
             if (1 !== (int) $blog['blog_id']) {
                 wpmu_delete_blog($blog['blog_id'], true);
             }
         }
     }
 }
 public static function run_multisite_deployment($action)
 {
     global $gfpdfe_data;
     /* add additional check incase someone doesn't call this correctly */
     if (!is_multisite() || !is_super_admin()) {
         return false;
     }
     /*
      * Get multisites which aren't deleted
      */
     $sites = wp_get_sites(array('deleted' => 0));
     if (sizeof($sites) > 0) {
         $problem = array();
         foreach ($sites as $site) {
             switch_to_blog((int) $site['blog_id']);
             /*
              * Reset the directory structure
              */
             $gfpdfe_data->set_directory_structure();
             /*
              * Test if the blog has gravity forms and PDF Extended active
              * If so, we can initialise
              */
             $gravityforms = 'gravityforms/gravityforms.php';
             /* have to hardcode the folder name as they don't set it in a constant or variable */
             $pdfextended = GF_PDF_EXTENDED_PLUGIN_BASENAME;
             /* no need to hardcode the basename here */
             if (is_plugin_active_for_network($gravityforms) && is_plugin_active_for_network($pdfextended) || is_plugin_active($gravityforms) && is_plugin_active($pdfextended)) {
                 /* run our deployment and output any problems */
                 $deploy = call_user_func($action);
                 if ($deploy === false) {
                     $problem[] = $site;
                 } elseif ($deploy === 'false') {
                     /*
                      * Asking for the access details so we can write to the server
                      * Exit early
                      */
                     return $deploy;
                 }
             }
             restore_current_blog();
             /*
              * Reset the directory structure
              */
             $gfpdfe_data->set_directory_structure();
         }
         if (sizeof($problem) > 0) {
             $gfpdfe_data->network_error = $problem;
             return false;
         }
         return true;
     }
 }
 public function get_multisites()
 {
     $multisites = wp_get_sites();
     $result = [];
     foreach ($multisites as $blog) {
         if (!in_array($blog['blog_id'], $this->INCLUDED_SITE_IDS)) {
             continue;
         }
         $result[] = $this->prepare_item($blog);
     }
     return $result;
 }
 protected function network_callback(callable $callback, array $args = array())
 {
     if (function_exists('is_multisite') && is_multisite()) {
         foreach (wp_get_sites(array('public' => 1)) as $blog) {
             switch_to_blog($blog['blog_id']);
             call_user_func_array($callback, $args);
         }
         restore_current_blog();
     } else {
         call_user_func_array($callback, $args);
     }
 }
Example #28
0
 public static function uninstall()
 {
     $obj = new self();
     $obj->uninstallTables("");
     if (is_multisite()) {
         $sites = wp_get_sites();
         foreach ($sites as $site) {
             $blogsId = $site['blog_id'] . "_";
             $obj->uninstallTables($blogsId);
         }
     }
 }
Example #29
0
 /**
  * Return translated context labels
  *
  * @return array Context label translations
  */
 public static function get_context_labels()
 {
     $labels = array();
     if (is_multisite() && !wp_is_large_network()) {
         $blogs = wp_get_sites();
         foreach ($blogs as $blog) {
             $blog_details = get_blog_details($blog['blog_id']);
             $key = sanitize_key($blog_details->blogname);
             $labels[$key] = $blog_details->blogname;
         }
     }
     return $labels;
 }
 /**
  * Prepares sites to use the plugin during single or network-wide activation
  *
  * @mvc Controller
  *
  * @param bool $network_wide
  */
 public function activate($network_wide)
 {
     if ($network_wide && is_multisite()) {
         $sites = wp_get_sites(array('limit' => false));
         foreach ($sites as $site) {
             switch_to_blog($site['blog_id']);
             $this->single_activate($network_wide);
         }
         restore_current_blog();
     } else {
         $this->single_activate($network_wide);
     }
 }