public function was_activated($module_name = 'networks')
 {
     PodcastList::with_network_scope(function () {
         PodcastList::build();
     });
     Template::with_network_scope(function () {
         Template::build();
     });
 }
 /**
  * Network Lists
  * 
  * List network lists.
  * Use the `slug` parameter to access a specific list.
  * 
  * **Examples**
  * 
  * Iterate over all lists.
  * 
  * ```jinja
  * {% for list in network.lists %}
  *     {{ list.title }}
  * {% endfor %}
  * ```
  * 
  * Access a specific list by id.
  * 
  * ```jinja
  * {{ network.lists({id: "example"}).title }}
  * ```
  * 
  * @see list
  * @accessor
  */
 public function lists($args = [])
 {
     NetworksModel\PodcastList::activate_network_scope();
     if (isset($args['id'])) {
         if ($list = NetworksModel\PodcastList::find_one_by_slug($args['id'])) {
             return new NetworksTemplate\PodcastList($list);
         }
     }
     $lists = [];
     foreach (NetworksModel\PodcastList::all() as $list) {
         $lists[] = new PodcastList($list);
     }
     NetworksModel\PodcastList::deactivate_network_scope();
     return $lists;
 }
 public function prepare_items()
 {
     // define column headers
     $columns = $this->get_columns();
     $hidden = array();
     $sortable = false;
     $this->_column_headers = array($columns, $hidden, $sortable);
     PodcastList::activate_network_scope();
     $items = \Podlove\Modules\Networks\Model\PodcastList::all();
     PodcastList::deactivate_network_scope();
     uasort($items, function ($a, $b) {
         return strnatcmp($a->title, $b->title);
     });
     $this->items = $items;
 }
            $subqueries[] = $podcast->with_blog_scope(function () use($podcast) {
                global $wpdb;
                $query = "(SELECT p.ID, p.post_title, p.post_date, b.blog_id FROM " . $wpdb->posts . " p, " . $wpdb->blogs . " b\n";
                $query .= "WHERE p.post_type = 'podcast'";
                $query .= "AND p.post_status = 'publish'";
                $query .= "AND b.blog_id = " . $podcast->get_blog_id() . ")";
                return $query;
            });
        }
        $query = implode("UNION\n", $subqueries) . " ORDER BY {$orderby} {$order} LIMIT 0, " . (int) $number_of_episodes;
        $recent_posts = $wpdb->get_results($query);
        $episodes = [];
        foreach ($recent_posts as $post) {
            switch_to_blog($post->blog_id);
            if ($episode = \Podlove\Model\Episode::find_one_by_post_id($post->ID)) {
                $episodes[] = new \Podlove\Template\Episode($episode);
            }
            restore_current_blog();
        }
        return $episodes;
    }
}
PodcastList::property('id', 'INT NOT NULL AUTO_INCREMENT PRIMARY KEY');
PodcastList::property('title', 'VARCHAR(255)');
PodcastList::property('slug', 'VARCHAR(255)');
PodcastList::property('subtitle', 'TEXT');
PodcastList::property('description', 'TEXT');
PodcastList::property('url', 'TEXT');
PodcastList::property('logo', 'TEXT');
PodcastList::property('podcasts', 'TEXT');
    function page()
    {
        if (isset($_GET["action"]) and $_GET["action"] == 'confirm_delete' and isset($_REQUEST['list'])) {
            PodcastList::activate_network_scope();
            $list = PodcastList::find_by_id($_REQUEST['list']);
            PodcastList::deactivate_network_scope();
            ?>
			<div class="updated">
				<p>
					<strong>
						<?php 
            echo sprintf(__('You selected to delete the list "%s". Please confirm this action.', 'podlove'), $list->title);
            ?>
					</strong>
				</p>
				<p>
					<?php 
            echo self::get_action_link($list, __('Delete list permanently', 'podlove'), 'delete', 'button');
            ?>
					<?php 
            echo self::get_action_link($list, __('Don\'t change anything', 'podlove'), 'keep', 'button-primary');
            ?>
				</p>
			</div>
			<?php 
        }
        ?>
		<div class="wrap">
			<?php 
        screen_icon('podlove-podcast');
        ?>
			<h2><?php 
        echo __('Lists', 'podlove');
        ?>
 <a href="?page=<?php 
        echo $_REQUEST['page'];
        ?>
&amp;action=new" class="add-new-h2"><?php 
        echo __('Add New', 'podlove');
        ?>
</a></h2>
			<?php 
        if (isset($_GET["action"])) {
            switch ($_GET["action"]) {
                case 'new':
                    $this->new_template();
                    break;
                case 'edit':
                    $this->edit_template();
                    break;
                default:
                    $this->view_template();
                    break;
            }
        } else {
            $this->view_template();
        }
        ?>
		</div>	
		<?php 
    }
 private static function podcast_ids()
 {
     return Model\PodcastList::with_network_scope(function () {
         return Model\Network::podcast_blog_ids();
     });
 }