self::is_in_network_admin(), 'is_this_a_multisite' => self::is_this_a_multisite(), 'is_plugin_active_network_wide' => self::is_plugin_active_network_wide(), 'current_blog_id' => self::get_current_blog_id() ); } /** * Looks for a previously cached multisite context variable (see * set_current_context()), and returns an associative array with * each key equal to the corresponding function name from this * class. If no context was cached, then it returns the current * context in the ARRAY_A form. * * Example: * returnedarray['is_in_network_admin'] is the cached value of * ABD_Multisite::is_in_network_admin() * * @param boolean refresh Whether to reset the cache with current user * context data first. * @return ARRAY_A An associative array containing the current context. */ public static function get_current_context( $refresh = false ) { if ( $refresh || !array_key_exists( 'abd_multisite_data', $_SESSION ) ) { // No context available or we want to update it... let's set it // and try again. self::set_current_context(); return self::get_current_context(); } // Okay, then we have the context return $_SESSION['abd_multisite_data']; } //////////////////////////////////////////// /// Abstraction Functions and Properties /// //////////////////////////////////////////// /** * Used in add_action calls for code to run after a new multisite blog * is created. * http://codex.wordpress.org/Function_Reference/wpmu_create_blog * @var string */ public static $blog_create_hook = "wpmu_create_blog"; /** * Used in add_action calls for code to run after a multisite blog * is deleted. http://codex.wordpress.org/Function_Reference/wpmu_delete_blog * @var string */ public static $blog_delete_hook = "wpmu_delete_blog"; /** * Determines whether the current WordPress website is configured as as * multisite. */ public static function is_this_a_multisite() { if ( !function_exists( 'is_multisite' ) ) { return false; } return is_multisite(); } /** * Determines whether the plugin is activated network wide (Network Activation) * or if it is site/blog specific. */ public static function is_plugin_active_network_wide() { if ( !function_exists( 'is_plugin_active_for_network' ) ) { return false; } return is_plugin_active_for_network( ABD_SUBDIR_AND_FILE ); } /** * Determines whether the user is in the network admin dashboard or not. */ public static function is_in_network_admin() { if ( !function_exists( 'is_network_admin' ) ) { return false; } return is_network_admin(); } /** * Gets ID of currently active site/blog. */ public static function get_current_blog_id() { if ( self::is_this_a_multisite() ) { global $wpdb; return $wpdb->blogid; } return 1; } } // end class } // end if ( !class_exists( ...