/**
  * Prepare our list items for display
  *
  * @todo pagination
  */
 public function prepare_items()
 {
     // Make sure we have an array for $this->items.
     if (!is_array($this->items)) {
         $this->items = array();
     }
     // Get all the blogs.
     $blogs = Aggregator::get_sites();
     // Our array of portals.
     $portals = array();
     // Check if we have sync jobs for those sites.
     foreach ($blogs as $blog) {
         if ($sync_blogs = get_site_option("aggregator_{$blog->blog_id}_source_blogs")) {
             $portals[$blog->blog_id] = $sync_blogs;
         }
         unset($sync_blogs);
     }
     if (!empty($portals)) {
         $this->items = $portals;
     } else {
         $this->items = array();
     }
 }
 * Templating for the network admin screen
 *
 * @package Aggregator
 */
// Get the blog ID from the URL, if set.
$portal_id = isset($_GET['portal']) ? intval($_GET['portal']) : 0;
// Input var okay.
$source_id = isset($_GET['source']) ? intval($_GET['source']) : 0;
// Input var okay.
// Determine/set the action to perform.
$action = isset($_GET['action']) ? sanitize_text_field(wp_unslash($_GET['action'])) : 'list';
// Input var okay.
switch ($action) {
    case 'add':
        // Just print a dropdown which we can redirect to the edit page.
        $blogs = Aggregator::get_sites();
        ?>
		<div class="wrap">
			<h2><?php 
        esc_html_e('Add New Sync Job');
        ?>
</h2>
			<form class="new_aggregator" action="" method="get">
				<p>
					<label for="portal"><?php 
        esc_html_e('Choose the site that will act as the "portal" site:');
        ?>
 </label>
					<select name="portal" id="portal">
						<option selected="selected">-- Select a blog --</option>
						<?php 
 /**
  * Provide a list of sync jobs.
  *
  * @return array|bool An array of Aggregator_Job objects, false on error
  */
 public function get_jobs()
 {
     // Get a list of sites.
     $blogs = Aggregator::get_sites();
     // Should never be empty, but hey, let's play safe.
     if (empty($blogs)) {
         return false;
     }
     // Holder for the jobs.
     $jobs = array();
     // Loop through each blog, getting any sync jobs.
     foreach ($blogs as $portal) {
         // Find any portal jobs.
         // @todo There's probably a better way to do this...
         foreach ($blogs as $source) {
             // Don't try and find any blogs syncing to themselves.
             if ($portal->blog_id === $source->blog_id) {
                 continue;
             }
             // Get any jobs.
             $job = new Aggregator_Job($portal->blog_id, $source->blog_id);
             if (is_null($job->post_id)) {
                 continue;
             } else {
                 $jobs[] = $job;
             }
         }
     }
     return $jobs;
 }