| 1 |
<?php |
| 2 |
|
| 3 |
namespace WPAdminify\Inc\Classes; |
| 4 |
|
| 5 |
// no direct access allowed |
| 6 |
if (!defined('ABSPATH')) exit; |
| 7 |
|
| 8 |
/** |
| 9 |
* @package WPAdminify |
| 10 |
* Multisite Helper |
| 11 |
* |
| 12 |
* @author Jewel Theme <support@jeweltheme.com> |
| 13 |
*/ |
| 14 |
|
| 15 |
class Multisite_Helper |
| 16 |
{ |
| 17 |
public function is_network_active() |
| 18 |
{ |
| 19 |
if (!function_exists('is_plugin_active_for_network') || !function_exists('is_plugin_active')) { |
| 20 |
require_once ABSPATH . '/wp-admin/includes/plugin.php'; |
| 21 |
} |
| 22 |
|
| 23 |
return (is_plugin_active_for_network('adminify/adminify.php') ? true : false); |
| 24 |
} |
| 25 |
|
| 26 |
/** |
| 27 |
* Check Multisite Supports |
| 28 |
* |
| 29 |
* @return void |
| 30 |
*/ |
| 31 |
public function is_multisite_supported() |
| 32 |
{ |
| 33 |
return ($this->is_network_active() && apply_filters('wp_adminify_ms_support', false) ? true : false); |
| 34 |
} |
| 35 |
|
| 36 |
/** |
| 37 |
* Check if it needed to switch blog |
| 38 |
* |
| 39 |
* @return void |
| 40 |
*/ |
| 41 |
public function needs_to_switch_blog() |
| 42 |
{ |
| 43 |
|
| 44 |
if (!$this->is_multisite_supported()) { |
| 45 |
return false; |
| 46 |
} |
| 47 |
|
| 48 |
global $blueprint; |
| 49 |
|
| 50 |
if (empty($blueprint) || get_current_blog_id() === $blueprint) { |
| 51 |
return false; |
| 52 |
} |
| 53 |
|
| 54 |
return true; |
| 55 |
} |
| 56 |
|
| 57 |
/** |
| 58 |
* Construct array of excluded sites |
| 59 |
* |
| 60 |
* @return array The array of excluded sites. |
| 61 |
*/ |
| 62 |
public function get_excluded_sites() |
| 63 |
{ |
| 64 |
|
| 65 |
global $blueprint; |
| 66 |
|
| 67 |
$array = array(); |
| 68 |
|
| 69 |
// Include blueprint site if it is defined. |
| 70 |
if (!empty($blueprint)) { |
| 71 |
$array[] = $blueprint; |
| 72 |
} |
| 73 |
|
| 74 |
if (get_site_option('wp_adminify_multisite_exclude')) { |
| 75 |
$excluded_sites = get_site_option('wp_adminify_multisite_exclude'); |
| 76 |
$excluded_sites = str_replace(' ', '', $excluded_sites); |
| 77 |
$excluded_sites = explode(',', $excluded_sites); |
| 78 |
} else { |
| 79 |
$excluded_sites = array(); |
| 80 |
} |
| 81 |
|
| 82 |
$excluded_sites = array_merge($array, $excluded_sites); |
| 83 |
|
| 84 |
return $excluded_sites; |
| 85 |
} |
| 86 |
} |
| 87 |
|