| 315 | | if ( ! $current_site = wp_cache_get( 'current_network', 'site-options' ) ) { |
| 316 | | // Are there even two networks installed? |
| 317 | | $one_network = $wpdb->get_row( "SELECT * FROM $wpdb->site LIMIT 2" ); // [sic] |
| 318 | | if ( 1 === $wpdb->num_rows ) { |
| 319 | | $current_site = new WP_Network( $one_network ); |
| 320 | | wp_cache_add( 'current_network', $current_site, 'site-options' ); |
| 321 | | } elseif ( 0 === $wpdb->num_rows ) { |
| 322 | | // A network not found hook should fire here. |
| 323 | | return false; |
| 324 | | } |
| | 315 | // Are there even two networks installed? |
| | 316 | $network_query = new WP_Network_Query(); |
| | 317 | $args = array( 'number' => 2 ); |
| | 318 | $networks = $network_query->query( $args ); |
| | 319 | if ( 1 === $network_query->found_networks ) { |
| | 320 | $current_site = array_shift( $networks ); |
| | 321 | } elseif ( 0 === $network_query->found_networks ) { |
| | 322 | // A network not found hook should fire here. |
| | 323 | return false; |