public function get_blog_prefix($blog_id = null) { if (is_multisite()) { if (null === $blog_id) { $blog_id = $this->blogid; } $blog_id = (int) $blog_id; if (defined('MULTISITE') && (0 == $blog_id || 1 == $blog_id)) { return $this->base_prefix; } else { return $this->base_prefix . $blog_id . '_'; } } else { return $this->base_prefix; } }
/** * Reinitialize the object * * Recreates the role objects. This is typically called only by switch_to_blog() * after switching wpdb to a new site ID. * * @since 3.5.0 * @access public */ public function reinit() { // There is no need to reinit if using the wp_user_roles global. if (!$this->use_db) { return; } // Duplicated from _init() to avoid an extra function call. $this->role_key = $this->db->get_blog_prefix() . 'user_roles'; $this->roles = get_option($this->role_key); if (empty($this->roles)) { return; } $this->role_objects = array(); $this->role_names = array(); foreach (array_keys($this->roles) as $role) { $this->role_objects[$role] = new WP_Role($role, $this->roles[$role]['capabilities']); $this->role_names[$role] = $this->roles[$role]['name']; } }