get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->site} WHERE id = %d LIMIT 1", $network_id ) ); if ( empty( $_network ) || is_wp_error( $_network ) ) { return false; } wp_cache_add( $network_id, $_network, 'networks' ); } return new WP_Network( $_network ); } /** * Create a new WP_Network object. * * Will populate object properties from the object provided and assign other * default properties based on that information. * * @since 4.4.0 * @access public * * @param WP_Network|object $network A network object. */ public function __construct( $network ) { foreach( get_object_vars( $network ) as $key => $value ) { $this->$key = $value; } $this->_set_cookie_domain(); } /** * Set the cookie domain based on the network domain if one has * not been populated. * * @todo What if the domain of the network doesn't match the current site? * * @since 4.4.0 * @access private */ private function _set_cookie_domain() { if ( ! empty( $this->cookie_domain ) ) { return; } $this->cookie_domain = $this->domain; if ( 'www.' === substr( $this->cookie_domain, 0, 4 ) ) { $this->cookie_domain = substr( $this->cookie_domain, 4 ); } } }