function check_positive_groups($posts) { global $wp_query, $M_options, $bp; $component = bp_current_component(); if (count($posts) > 1) { return $posts; } if (!empty($component) && $component == 'groups') { // we may be on a restricted post so check the URL and redirect if needed // If we aren't on a group then return if ($bp->groups->current_group == 0) { return $posts; } $redirect = false; $url = ''; $exclude = array(); if (!empty($M_options['registration_page'])) { $exclude[] = get_permalink((int) $M_options['registration_page']); $exclude[] = untrailingslashit(get_permalink((int) $M_options['registration_page'])); } if (!empty($M_options['account_page'])) { $exclude[] = get_permalink((int) $M_options['account_page']); $exclude[] = untrailingslashit(get_permalink((int) $M_options['account_page'])); } if (!empty($M_options['nocontent_page'])) { $exclude[] = get_permalink((int) $M_options['nocontent_page']); $exclude[] = untrailingslashit(get_permalink((int) $M_options['nocontent_page'])); } if (!empty($wp_query->query_vars['protectedfile']) && !$forceviewing) { $exclude[] = $host; $exclude[] = untrailingslashit($host); } $url = ''; if (is_ssl()) { $url = "https://"; } else { $url = "http://"; } $url .= $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; if (in_array(strtolower($url), $exclude)) { return $posts; } // we have the current page / url - get the groups selected $group_id = $this->get_group(); if ($group_id) { $group = new M_Urlgroup($group_id); if (!$group->url_matches($url)) { $redirect = true; } } if ($redirect === true && !empty($M_options['nocontent_page'])) { // we need to redirect $this->redirect(); } else { return $posts; } } return $posts; }
function show_urlgroup_edit($group_id) { global $page; if ($group_id === false) { $add = new M_Urlgroup(0); echo "<div class='wrap'>"; echo "<h2>" . __('Add URL group', 'membership') . "</h2>"; echo '<div id="poststuff" class="metabox-holder">'; ?> <div class="postbox"> <h3 class="hndle" style='cursor:auto;'><span><?php _e('Add URL group', 'membership'); ?> </span></h3> <div class="inside"> <?php echo '<form method="post" action="?page=' . $page . '">'; echo '<input type="hidden" name="ID" value="" />'; echo "<input type='hidden' name='action' value='added' />"; wp_nonce_field('add-group'); $add->addform(); echo '<p class="submit">'; echo '<input class="button-primary alignright" type="submit" name="go" value="' . __('Add group', 'membership') . '" /></p>'; echo '</form>'; echo '<br/>'; ?> </div> </div> <?php echo "</div>"; echo "</div>"; } else { $edit = new M_Urlgroup((int) $group_id); echo "<div class='wrap'>"; echo "<h2>" . __('Edit URL group', 'membership') . "</h2>"; echo '<div id="poststuff" class="metabox-holder">'; ?> <div class="postbox"> <h3 class="hndle" style='cursor:auto;'><span><?php _e('Edit URL group', 'membership'); ?> </span></h3> <div class="inside"> <?php echo '<form method="post" action="?page=' . $page . '">'; echo '<input type="hidden" name="ID" value="' . $group_id . '" />'; echo "<input type='hidden' name='action' value='updated' />"; wp_nonce_field('update-group-' . $group_id); $edit->editform(); echo '<p class="submit">'; echo '<input class="button-primary alignright" type="submit" name="go" value="' . __('Update group', 'membership') . '" /></p>'; echo '</form>'; echo '<br/>'; ?> </div> </div> <?php echo "</div>"; echo "</div>"; } }
function negative_check_request($wp) { $redirect = false; $host = ''; if (is_ssl()) { $host = "https://"; } else { $host = "http://"; } $host .= $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $exclude = array(); if (!empty($M_options['registration_page'])) { $exclude[] = get_permalink((int) $M_options['registration_page']); $exclude[] = untrailingslashit(get_permalink((int) $M_options['registration_page'])); } if (!empty($M_options['account_page'])) { $exclude[] = get_permalink((int) $M_options['account_page']); $exclude[] = untrailingslashit(get_permalink((int) $M_options['account_page'])); } if (!empty($M_options['nocontent_page'])) { $exclude[] = get_permalink((int) $M_options['nocontent_page']); $exclude[] = untrailingslashit(get_permalink((int) $M_options['nocontent_page'])); } if (!empty($wp_query->query_vars['protectedfile']) && !$forceviewing) { $exclude[] = $host; $exclude[] = untrailingslashit($host); } // we have the current page / url - get the groups selected foreach ((array) $this->data as $group_id) { $group = new M_Urlgroup($group_id); if ($group->url_matches($host) && !in_array(strtolower($host), $exclude)) { $redirect = true; } } if ($redirect === true) { // we need to redirect $this->redirect(); } }
function show_urlgroup_edit($group_id) { global $page; $group_id = (int) $group_id; $m_group = new M_Urlgroup($group_id); ?> <div class="wrap"> <h2><?php echo !$group_id ? esc_html__('Add URL group', 'membership') : esc_html__('Edit URL group', 'membership'); ?> </h2> <div id="poststuff" class="metabox-holder"> <div class="postbox"> <h3 class="hndle" style="cursor:auto;"> <span><?php echo !$group_id ? esc_html__('Add URL group', 'membership') : esc_html__('Edit URL group', 'membership'); ?> </span> </h3> <div class="inside"> <form action="?page=<?php echo $page; ?> " method="post"> <input type="hidden" name="ID" value="<?php echo $group_id; ?> "> <input type="hidden" name="action" value="<?php echo !$group_id ? 'added' : 'updated'; ?> "> <?php wp_nonce_field(!$group_id ? 'add-group' : 'update-group-' . $group_id); ?> <?php $m_group->render_form(); ?> <p class="submit"> <input type="reset" class="button" value="<?php esc_attr_e('Reset', 'membership'); ?> "> <input class="button-primary alignright" type="submit" name="go" value="<?php echo !$group_id ? esc_attr__('Add group', 'membership') : esc_attr__('Update group', 'membership'); ?> "> </p> </form> </div> </div> </div> <style type="text/css"> #urltestresults { margin: 10px 0; border: 1px dotted #ddd; } #urltestresults div { border: 1px dotted #ddd; padding: 10px; } #urltestresults div:last-child { border-bottom: 0 } #urltestresults span { float: right; } .rule-valid { color: green; font-weight: bold; } .rule-invalid { color: red; } </style> <div class="metabox-holder"> <div class="postbox"> <h3 class="hndle" style="cursor:auto"><?php esc_html_e('Test URL group', 'membership'); ?> </h3> <div class="inside"> <input type="text" id="url2test" class="widefat"> <div id="urltestresults"> <div><i><?php esc_html_e('Enter an URL above to test against rules in the group', 'membership'); ?> <i></div> </div> </div> </div> </div> </div><?php }
/** * Associates negative data with this rule. * * @access public * @param mixed $data The negative data to associate with the rule. */ public function on_negative($data) { $this->data = $data; if (!empty($this->data) && is_array($this->data)) { foreach ($this->data as $group_id) { $group = new M_Urlgroup($group_id); M_add_to_global_urlgroup($group->group_urls_array(), 'negative'); } } }