public function was_activated($module_name = 'networks') { PodcastList::with_network_scope(function () { PodcastList::build(); }); Template::with_network_scope(function () { Template::build(); }); }
private function view_template() { echo __('Use network templates to share common templates in your podcast sites. They are available in all podcast sites. If you define a local template for a template ID that also exists network-wide, the local template takes precedence.', 'podlove'); $templates = Template::with_network_scope(function () { return Template::all(); }); ?> <div id="template-editor"> <div class="navigation"> <ul> <?php foreach ($templates as $template) { ?> <li> <a href="#" data-id="<?php echo $template->id; ?> "> <span class="filename"><?php echo $template->title; ?> </span> </a> </li> <?php } ?> </ul> <div class="add"> <a href="#">+ add new template</a> </div> </div> <div class="editor"> <div class="toolbar"> <div class="actions"> <a href="#" class="delete">delete</a> <a href="#" class="save button button-primary">Save</a> </div> <div class="title"> <input type="text"> </div> <div class="clear"></div> </div> <div class="editor-wrapper"> <div class="main" id="ace-editor"></div> <div id="fullscreen" class="fullscreen-on fullscreen-button"></div> </div> </div> <div class="clear"></div> </div> <?php }
/** * Returns all local + network templates. * * Local template override global templates with same title. * * @return array */ public static function all_globally() { if (!is_multisite()) { return Template::all(); } $local = Template::all(); $global = Template::with_network_scope(function () { return Template::all(); }); $all = []; foreach ($global as $template) { $all[$template->title] = $template; } foreach ($local as $template) { $all[$template->title] = $template; } ksort($all); return array_values($all); }