function set_default_options() { $settings = $this->default_options(); foreach ($settings as $setting => $default) { if (!isset($this->{$setting})) { $this->{$setting} = $default; } } if (!empty($this->terms_url) and !is_numeric($this->terms_url)) { $this->terms_url = trailingslashit($this->terms_url); } if (!isset($this->site_name) or !$this->site_name) { $this->site_name = get_option('blogname'); } if (!isset($this->terms)) { $this->terms = TouAppHelper::get_include_contents('classes/views/settings/terms.php'); } if (!isset($this->privacy_policy)) { $this->privacy_policy = TouAppHelper::get_include_contents('classes/views/settings/privacy_policy.php'); } }
function get_terms($atts = array()) { extract(shortcode_atts(array('display' => true, 'admin' => false, 'echo' => false), $atts)); global $user_ID, $tou_settings; $content = ''; $url = get_bloginfo('url'); $tou_name = stripslashes($tou_settings->site_name); if (!$tou_name) { $tou_name = get_option('blogname'); } $atts['terms'] = ''; $atts['privacy_policy'] = ''; foreach (array('terms', 'privacy_policy', 'member_agreement', 'agree', 'welcome') as $info) { $atts[$info] = str_replace('[website-name]', $tou_name, stripslashes($tou_settings->{$info})); $atts[$info] = wpautop(str_replace('[website-url]', $url, $atts[$info])); } $atts['error'] = ''; $atts['referer'] = (isset($_POST) and isset($_POST['tou_referer'])) ? $_POST['tou_referer'] : (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''); $atts['initials'] = (isset($_POST) and isset($_POST['initials'])) ? $_POST['initials'] : ''; $atts['show_buttons'] = true; //if user has already agreed, show the terms for reference if (TouAppHelper::get_user_meta($user_ID, 'terms_and_conditions')) { $atts['show_buttons'] = false; } $atts['disagree_url'] = wp_logout_url(); if ($admin) { $content .= '<div class="wrap tou">'; } if (!is_admin()) { $atts['disagree_url'] = $url; $atts['show_buttons'] = (isset($_GET['redirected']) or !$display) ? true : false; if (isset($_POST) and isset($_POST['terms-and-conditions'])) { if ($tou_settings->initials and !$_POST['initials']) { //the agreement page $atts['error'] = __('You must enter your initials', 'terms_of_use'); $content .= TouAppHelper::get_include_contents('classes/views/shared/agreement_form.php', $atts); return $content; } if ($user_ID) { TouAppHelper::save_meta($user_ID, $atts['initials']); } if (is_page($tou_settings->terms_url)) { $referrer = isset($_POST['tou_referrer']) ? $_POST['tou_referrer'] : $url; } else { global $post; $referrer = get_permalink($post->ID); } die("<script type='text/javascript'>location='" . $referrer . "' </script>"); } else { if ($atts['show_buttons']) { $content .= TouAppHelper::get_include_contents('classes/views/shared/agreement_form.php', $atts); } else { $content .= $atts['terms']; } } //Check if user has agreed to the terms and conditions, if not display the terms and conditions else save the settings and display the welcome message. } else { if (isset($_POST) and isset($_POST['terms-and-conditions'])) { //update current users terms_and_conditions if ($tou_settings->initials and !$_POST['initials']) { //the agreement page $atts['error'] = __('You must enter your initials', 'terms_of_use'); $content .= TouAppHelper::get_include_contents('classes/views/shared/agreement_form.php', $atts); } else { TouAppHelper::save_meta($user_ID, $initials); //display welcome message. $content .= $atts['welcome']; } } else { //the agreement page $content .= TouAppHelper::get_include_contents('classes/views/shared/agreement_form.php', $atts); } } if ($admin) { $content .= '</div>'; } if ($echo) { echo $content; } else { return $content; } }