/** * Checks if the specified rule-key defines a rule that is relevant for the * current site in the network. * * If network-wide protection is disabled this function always returns true. * * @since 1.0.0 * @param string $key * @return bool */ public static function is_current_site($key) { $res = true; $site_id = 0; if (MS_Plugin::is_network_wide()) { $parts = explode(':', $key); // Some rules have no site_id prefix (like URL rules) if (2 == count($parts)) { list($site_id, $type) = $parts; $site_id = intval($site_id); $res = MS_Factory::current_blog_id() == $site_id; } } return $res; }
/** * When network-wide protection is enabled then allow the user to choose the * source-site of the content. * * Protection options can only be changed on a site-by-site base. So if the * user has 3 sites he can protect all pages on all sites but has to select * each site individually here. * * @since 1.0.0 */ protected function site_filter() { if (!MS_Plugin::is_network_wide()) { return false; } $sites = MS_Helper_Settings::get_blogs(); $site_options = array(); $current_blog_id = MS_Factory::current_blog_id(); $admin_script = 'admin.php?' . $_SERVER['QUERY_STRING']; foreach ($sites as $blog_id => $title) { $key = get_admin_url($blog_id, $admin_script); if ($current_blog_id == $blog_id) { $current_value = $key; } $site_options[$key] = $title; } $site_list = array('id' => 'select-site', 'type' => MS_Helper_Html::INPUT_TYPE_SELECT, 'value' => $current_value, 'field_options' => $site_options); ?> <div class="ms-tab-container"> <label class="ms-tab-link" for="select-site"> <?php _e('Select Site', 'membership2'); ?> </label> </div> <div> <?php lib3()->html->element($site_list); ?> </div> <?php }