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
7 changes: 3 additions & 4 deletions classes/class-alerts.php
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,7 @@ function change_menu_link_url() {
}

// Get the first existing Site in the Network.
// @todo: Switch to use wp_stream_get_sites()
$sites = wp_get_sites(
$sites = wp_stream_get_sites(
array(
'limit' => 5, // Limit the size of the query.
)
Expand All @@ -436,8 +435,8 @@ function change_menu_link_url() {
$site_id = '1';

// Function wp_get_sites() can return an empty array if the network is too large.
if ( ! empty( $sites ) && ! empty( $sites[0]['blog_id'] ) ) {
$site_id = $sites[0]['blog_id'];
if ( ! empty( $sites ) && ! empty( $sites[0]->blog_id ) ) {
$site_id = $sites[0]->blog_id;
}

$new_url = get_admin_url( $site_id, $page );
Expand Down
8 changes: 7 additions & 1 deletion classes/class-network.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ function __construct( $plugin ) {
/**
* Workaround to get admin-ajax.php to know when the request is from the Network Admin
*
* @return bool
*
* @action init
*
* @see https://core.trac.wordpress.org/ticket/22589
Expand All @@ -64,7 +66,10 @@ public function ajax_network_admin() {
preg_match( '#^' . network_admin_url() . '#i', $_SERVER['HTTP_REFERER'] )
) {
define( 'WP_NETWORK_ADMIN', true );
return WP_NETWORK_ADMIN;
}

return false;
}

/**
Expand Down Expand Up @@ -136,6 +141,7 @@ public function admin_menu_screens() {
}

remove_submenu_page( $this->plugin->admin->records_page_slug, 'wp_stream_settings' );
remove_submenu_page( $this->plugin->admin->records_page_slug, 'edit.php?post_type=wp_stream_alerts' );

$this->plugin->admin->screen_id['network_settings'] = add_submenu_page(
$this->plugin->admin->records_page_slug,
Expand Down Expand Up @@ -496,7 +502,7 @@ public function network_admin_page_title( $page_title ) {
* @return mixed
*/
public function network_admin_columns( $columns ) {
if ( is_network_admin() ) {
if ( is_network_admin() || $this->ajax_network_admin() ) {
$columns = array_merge(
array_slice( $columns, 0, -1 ),
array(
Expand Down
8 changes: 5 additions & 3 deletions includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,16 @@ function wp_stream_json_encode( $data, $options = 0, $depth = 512 ) {
/**
* Return an array of sites for a network in a way that is also backwards compatible
*
* @param string|array $args
*
* @return array
*/
function wp_stream_get_sites() {
function wp_stream_get_sites( $args = array() ) {
if ( function_exists( 'get_sites' ) ) {
$sites = get_sites();
$sites = get_sites( $args );
} else {
$sites = array();
foreach ( wp_get_sites() as $site ) {
foreach ( wp_get_sites( $args ) as $site ) {
$sites[] = WP_Site::get_instance( $site['blog_id'] );
}
}
Expand Down