Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions classes/class-network.php
Original file line number Diff line number Diff line change
Expand Up @@ -394,10 +394,10 @@ public function list_table_filters( $filters ) {
);

// add all sites
foreach ( wp_get_sites() as $blog ) {
$blog_data = get_blog_details( $blog );
foreach ( wp_stream_get_sites() as $blog ) {
$blog_data = get_blog_details( $blog->blog_id );

$blogs[ $blog['blog_id'] ] = array(
$blogs[ $blog->blog_id ] = array(
'label' => $blog_data->blogname,
'disabled' => '',
);
Expand Down
4 changes: 2 additions & 2 deletions classes/class-uninstall.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ private function delete_all_options() {
$wpdb->query( "DELETE FROM {$wpdb->sitemeta} WHERE meta_key LIKE '%wp_stream%';" );

// Delete options from each blog on network
foreach ( wp_get_sites() as $blog ) {
$this->delete_blog_options( absint( $blog['blog_id'] ) );
foreach ( wp_stream_get_sites() as $blog ) {
$this->delete_blog_options( absint( $blog->blog_id ) );
}
}

Expand Down
4 changes: 2 additions & 2 deletions connectors/class-connector-blogs.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ public function get_context_labels() {
$labels = array();

if ( is_multisite() && ! wp_is_large_network() ) {
$blogs = wp_get_sites();
$blogs = wp_stream_get_sites();

foreach ( $blogs as $blog ) {
$blog_details = get_blog_details( $blog['blog_id'] );
$blog_details = get_blog_details( $blog->blog_id );
$key = sanitize_key( $blog_details->blogname );
$labels[ $key ] = $blog_details->blogname;
}
Expand Down
19 changes: 18 additions & 1 deletion includes/functions.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

/**
* Gets a specific external variable by name and optionally filters it.
*
Expand Down Expand Up @@ -87,6 +86,24 @@ function wp_stream_json_encode( $data, $options = 0, $depth = 512 ) {
return $json;
}

/**
* Return an array of sites for a network in a way that is also backwards compatible
*
* @return array
*/
function wp_stream_get_sites() {
if ( function_exists( 'get_sites' ) ) {
$sites = get_sites();
} else {
$sites = array();
foreach ( wp_get_sites() as $site ) {
$sites[] = WP_Site::get_instance( $site['blog_id'] );
}
}

return $sites;
}

/**
* Check if Stream is running on WordPress.com VIP
*
Expand Down