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