options_profile = $this->get_options('profile'); $this->options_lists = $this->get_options('lists'); // Must be called after the Newsletter::hook_init, since some constants are defined // there. add_action('init', array($this, 'hook_init'), 90); } function hook_init() { add_action('wp_loaded', array($this, 'hook_wp_loaded')); if (is_admin()) { add_action('admin_init', array($this, 'hook_admin_init')); } else { add_action('wp_enqueue_scripts', array($this, 'hook_wp_enqueue_scripts')); add_shortcode('newsletter', array($this, 'shortcode_newsletter')); add_shortcode('newsletter_form', array($this, 'shortcode_newsletter_form')); add_shortcode('newsletter_field', array($this, 'shortcode_newsletter_field')); } } function hook_admin_init() { if (isset($_GET['page']) && $_GET['page'] === 'newsletter_subscription_forms') { header('X-XSS-Protection: 0'); } if (function_exists('register_block_type')) { // Add custom blocks to Gutenberg wp_register_script('tnp-blocks', NEWSLETTER_URL . '/includes/tnp-blocks.js', array('wp-blocks', 'wp-element', 'wp-editor'), NEWSLETTER_VERSION); register_block_type('tnp/minimal', array('editor_script' => 'tnp-blocks')); } } function hook_wp_enqueue_scripts() { wp_enqueue_script('newsletter-subscription', plugins_url('newsletter') . '/subscription/validate.js', array(), NEWSLETTER_VERSION, true); $options = $this->get_options('profile', $this->get_current_language()); $data = array(); $data['messages'] = array(); if (isset($options['email_error'])) { $data['messages']['email_error'] = $options['email_error']; } if (isset($options['name_error'])) { $data['messages']['name_error'] = $options['name_error']; } if (isset($options['surname_error'])) { $data['messages']['surname_error'] = $options['surname_error']; } if (isset($options['profile_error'])) { $data['messages']['profile_error'] = $options['profile_error']; } if (isset($options['privacy_error'])) { $data['messages']['privacy_error'] = $options['privacy_error']; } $data['profile_max'] = NEWSLETTER_PROFILE_MAX; wp_localize_script('newsletter-subscription', 'newsletter', $data); } function ip_match($ip, $range) { if (strpos($range, '/')) { list ($subnet, $bits) = explode('/', $range); $ip = ip2long($ip); $subnet = ip2long($subnet); $mask = -1 << (32 - $bits); $subnet &= $mask; # nb: in case the supplied subnet wasn't correctly aligned return ($ip & $mask) == $subnet; } else { return strpos($range, $ip) === 0; } } function is_address_blacklisted($email) { // TODO: Optimize! $options = $this->get_options('antibot'); if (empty($options['address_blacklist'])) { return false; } $this->logger->debug('Address blacklist check'); $rev_email = strrev($email); foreach ($options['address_blacklist'] as $item) { if (strpos($rev_email, strrev($item)) === 0) { return true; } } return false; } function is_ip_blacklisted($ip) { // TODO: Optimize! $options = $this->get_options('antibot'); if (empty($options['ip_blacklist'])) { return false; } $this->logger->debug('IP blacklist check'); foreach ($options['ip_blacklist'] as $item) { if ($this->ip_match($ip, $item)) { return true; } } return false; } function is_missing_domain_mx($email) { // Actually not fully implemented return false; if (empty($this->options['domain_check'])) { return false; } $this->logger->debug('Domain MX check'); list($local, $domain) = explode('@', $email); $hosts = array(); if (!getmxrr($domain, $hosts)) { return true; } return false; } function is_flood($email, $ip) { global $wpdb; // TODO: Optimize! $options = $this->get_options('antibot'); if (empty($options['antiflood'])) { return false; } $this->logger->debug('Antiflood check'); $updated = $wpdb->get_var($wpdb->prepare("select updated from " . NEWSLETTER_USERS_TABLE . " where ip=%s or email=%s order by updated desc limit 1", $ip, $email)); if ($updated && time() - $updated < $options['antiflood']) { return true; } return false; } function is_spam_text($text) { if (stripos($text, 'http://') !== false || stripos($text, 'https://') !== false) { return true; } if (stripos($text, 'www.') !== false) { return true; } return false; } function is_spam_by_akismet($email, $name, $ip, $agent, $referrer) { // TODO: Optimize! $options = $this->get_options('antibot'); if (empty($options['akismet'])) { return false; } if (!class_exists('Akismet')) { return false; } $this->logger->debug('Akismet check'); $request = 'blog=' . urlencode(home_url()) . '&referrer=' . urlencode($referrer) . '&user_agent=' . urlencode($agent) . '&comment_type=signup' . '&comment_author_email=' . urlencode($email) . '&user_ip=' . urlencode($ip); if (!empty($name)) { $request .= '&comment_author=' . urlencode($name); } $response = Akismet::http_post($request, 'comment-check'); if ($response && $response[1] == 'true') { return true; } return false; } /** * * @global wpdb $wpdb * @return mixed */ function hook_wp_loaded() { global $wpdb; $newsletter = Newsletter::instance(); switch ($newsletter->action) { case 'profile-change': if ($this->antibot_form_check()) { $user = $this->get_user_from_request(); if (!$user || $user->status != 'C') { die('Subscriber not found or not active.'); } $email = $this->get_email_from_request(); if (!$email) { die('Newsletter not found'); } if (isset($_REQUEST['list'])) { $list_id = (int) $_REQUEST['list']; // Check if the list is public $list = $this->get_list($list_id); if (!$list || $list->status == 0) { die('Private list.'); } $url = $_REQUEST['redirect']; $this->set_user_list($user, $list_id, $_REQUEST['value']); $user = $this->get_user($user->id); $this->add_user_log($user, 'cta'); NewsletterStatistics::instance()->add_click($url, $user->id, $email->id); wp_redirect($url); die(); } } else { $this->request_to_antibot_form('Continue'); } die(); case 'm': case 'message': include dirname(__FILE__) . '/page.php'; die(); // normal subscription case 's': case 'subscribe': $ip = $this->get_remote_ip(); $email = $this->normalize_email($_REQUEST['ne']); $first_name = ''; if (isset($_REQUEST['nn'])) $first_name = $this->normalize_name($_REQUEST['nn']); $last_name = ''; if (isset($_REQUEST['ns'])) $last_name = $this->normalize_name($_REQUEST['ns']); $full_name = trim($first_name . ' ' . $last_name); $antibot_logger = new NewsletterLogger('antibot'); if ($_SERVER['REQUEST_METHOD'] !== 'POST') { $antibot_logger->fatal($email . ' - ' . $ip . ' - HTTP method invalid'); die('Invalid'); } $options_antibot = $this->get_options('antibot'); $captcha = !empty($options_antibot['captcha']); if (!empty($options_antibot['disabled']) || $this->antibot_form_check($captcha)) { if ($this->is_spam_text($full_name)) { $antibot_logger->fatal($email . ' - ' . $ip . ' - Name with http: ' . $full_name); header("HTTP/1.0 404 Not Found"); die(); } // Cannot check for administrator here, too early. if (true) { $this->logger->debug('Subscription of: ' . $email); // 404 is returned to attempt to make the bot believe the url has been changed if ($this->is_missing_domain_mx($email)) { $antibot_logger->fatal($email . ' - ' . $ip . ' - MX check failed'); header("HTTP/1.0 404 Not Found"); die(); } if ($this->is_ip_blacklisted($ip)) { $antibot_logger->fatal($email . ' - ' . $ip . ' - IP blacklisted'); header("HTTP/1.0 404 Not Found"); die(); } if ($this->is_address_blacklisted($email)) { $antibot_logger->fatal($email . ' - ' . $ip . ' - Address blacklisted'); header("HTTP/1.0 404 Not Found"); die(); } // Akismet check if ($this->is_spam_by_akismet($email, $full_name, $ip, $_SERVER['HTTP_USER_AGENT'], $_SERVER['HTTP_REFERER'])) { $antibot_logger->fatal($email . ' - ' . $ip . ' - Akismet blocked'); header("HTTP/1.0 404 Not Found"); die(); } // Flood check if ($this->is_flood($email, $ip)) { $antibot_logger->fatal($email . ' - ' . $ip . ' - Antiflood triggered'); header("HTTP/1.0 404 Not Found"); die('Too quick'); } $user = $this->subscribe(); if ($user->status == 'E') $this->show_message('error', $user); if ($user->status == 'C') $this->show_message('confirmed', $user); if ($user->status == 'A') $this->show_message('already_confirmed', $user); if ($user->status == 'S') $this->show_message('confirmation', $user); } } else { // Temporary store data //$data_key = wp_generate_password(16, false, false); //set_transient('newsletter_' . $data_key, $_REQUEST, 60); //$this->antibot_redirect($data_key); $this->request_to_antibot_form('Subscribe', $captcha); } die(); // AJAX subscription case 'ajaxsub': $user = $this->subscribe(); if ($user->status == 'E') $key = 'error'; if ($user->status == 'C') $key = 'confirmed'; if ($user->status == 'A') $key = 'already_confirmed'; if ($user->status == 'S') $key = 'confirmation'; $module = NewsletterSubscription::instance(); $message = $newsletter->replace($module->options[$key . '_text'], $user); if (isset($module->options[$key . '_tracking'])) { $message .= $module->options[$key . '_tracking']; } echo $message; die(); case 'c': case 'confirm': if ($this->antibot_form_check()) { $user = $this->confirm(); if ($user->status == 'E') { $this->show_message('error', $user->id); } else { setcookie('newsletter', $user->id . '-' . $user->token, time() + 60 * 60 * 24 * 365, '/'); $this->show_message('confirmed', $user); } } else { $this->request_to_antibot_form('Confirm'); } die(); break; default: return; } } function upgrade() { global $wpdb, $charset_collate; // Possible migration $options_antibot = $this->get_options('antibot'); if (empty($options_antibot)) { $options = $this->get_options(); foreach (array('address_blacklist', 'ip_blacklist', 'akismet', 'captcha', 'antiflood') as $key) { if (isset($options[$key])) { $options_antibot[$key] = $options[$key]; } } if (isset($options['antibot_disable'])) { $options_antibot['disabled'] = $options['antibot_disable']; } else { $options_antibot['disabled'] = 0; } $this->save_options($options_antibot, 'antibot'); } parent::upgrade(); $newsletter = Newsletter::instance(); $lists_options = $this->get_options('lists'); $profile_options = $this->get_options('profile'); if (empty($lists_options)) { foreach ($profile_options as $key => $value) { if (strpos($key, 'list_') === 0) { $lists_options[$key] = $value; } } } for ($i = 1; $i <= NEWSLETTER_LIST_MAX; $i++) { // Options migration to the new set if (!empty($profile_options['list_' . $i]) && empty($lists_options['list_' . $i])) { $lists_options['list_' . $i] = $profile_options['list_' . $i]; $lists_options['list_' . $i . '_checked'] = $profile_options['list_' . $i . '_checked']; $lists_options['list_' . $i . '_forced'] = $profile_options['list_' . $i . '_forced']; } if (!isset($profile_options['list_' . $i . '_forced'])) { $profile_options['list_' . $i . '_forced'] = empty($this->options['preferences_' . $i]) ? 0 : 1; $lists_options['list_' . $i . '_forced'] = empty($this->options['preferences_' . $i]) ? 0 : 1; } } $this->save_options($profile_options, 'profile'); $this->save_options($lists_options, 'lists'); $default_options = $this->get_default_options(); if (empty($this->options['error_text'])) { $this->options['error_text'] = $default_options['error_text']; $this->save_options($this->options); } if ($this->old_version < '2.0.0') { if (!isset($this->options['url']) && !empty($newsletter->options['url'])) { $this->options['url'] = $newsletter->options['url']; $this->save_options($this->options); } $options_template = $this->get_options('template'); if (empty($options_template) && isset($this->options['template'])) { $options_template['enabled'] = isset($this->options['template_enabled']) ? 1 : 0; $options_template['template'] = $this->options['template']; add_option('newsletter_subscription_template', $options_template, null, 'no'); } if (isset($this->options['template'])) { unset($this->options['template']); unset($this->options['template_enabled']); $this->save_options($this->options); } } $this->init_options('template', false); global $wpdb, $charset_collate; require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); $sql = "CREATE TABLE `" . $wpdb->prefix . "newsletter_user_logs` ( `id` int(11) NOT NULL AUTO_INCREMENT, `user_id` int(11) NOT NULL DEFAULT 0, `ip` varchar(50) NOT NULL DEFAULT '', `source` varchar(50) NOT NULL DEFAULT '', `data` longtext, `created` int(11) NOT NULL DEFAULT 0, PRIMARY KEY (`id`) ) $charset_collate;"; dbDelta($sql); return true; } function first_install() { } function admin_menu() { $this->add_menu_page('options', 'List building'); $this->add_menu_page('antibot', 'Security'); $this->add_admin_page('profile', 'Subscription Form'); $this->add_admin_page('forms', 'Forms'); $this->add_admin_page('lists', 'Lists'); $this->add_admin_page('template', 'Template'); } /** * This method has been redefined for compatibility with the old options naming. It would * be better to change them instead. The subscription options should be named * "newsletter_subscription" while the form field options, actually named * "newsletter_profile", should be renamed "newsletter_subscription_profile" (since * they are retrived with get_options('profile')) or "newsletter_subscription_fields" or * "newsletter_subscription_form". * * @param array $options * @param string $sub */ function save_options($options, $sub = '', $autoload = null, $language = '') { if (empty($sub) && empty($language)) { // For compatibility the options are wrongly named return update_option('newsletter', $options, $autoload); } if (empty($sub) && !empty($language)) { return update_option('newsletter_' . $language, $options, $autoload); } if ($sub == 'profile') { if (empty($language)) { $this->options_profile = $options; return update_option('newsletter_profile', $options, $autoload); } else { return update_option('newsletter_profile_' . $language, $options, $autoload); } // For compatibility the options are wrongly named } if ($sub == 'forms') { // For compatibility the options are wrongly named return update_option('newsletter_forms', $options, $autoload); } if ($sub == 'lists') { $this->options_lists = $options; } return parent::save_options($options, $sub, $autoload, $language); } function get_options($sub = '', $language = '') { if ($sub == '') { // For compatibility the options are wrongly named if ($language) { $options = get_option('newsletter_' . $language, array()); $options = array_merge(get_option('newsletter', array()), $options); } else { $options = get_option('newsletter', array()); } if (!is_array($options)) { $options = array(); } return $options; } if ($sub == 'profile') { if ($language) { $options = get_option('newsletter_profile_' . $language, array()); $options = array_merge(get_option('newsletter_profile', array()), $options); } else { $options = get_option('newsletter_profile', array()); } // For compatibility the options are wrongly named return $options; } if ($sub == 'forms') { // For compatibility the options are wrongly named return get_option('newsletter_forms', array()); } return parent::get_options($sub, $language); } function set_updated($user, $time = 0, $ip = '') { global $wpdb; if (!$time) { $time = time(); } if (!$ip) { $ip = $this->get_remote_ip(); } $ip = $this->process_ip($ip); if (is_object($user)) { $id = $user->id; } else if (is_array($user)) { $id = $user['id']; } $id = (int) $id; $wpdb->update(NEWSLETTER_USERS_TABLE, array('updated' => $time, 'ip' => $ip, 'geo' => 0), array('id' => $id)); } /** * Return the subscribed user. * * @param bool $registration If invoked from the registration process * @global Newsletter $newsletter */ function subscribe($status = null, $emails = true) { $opt_in = (int) $this->options['noconfirmation']; // 0 - double, 1 - single if (!empty($this->options['optin_override']) && isset($_REQUEST['optin'])) { switch ($_REQUEST['optin']) { case 'single': $opt_in = self::OPTIN_SINGLE; break; case 'double': $opt_in = self::OPTIN_DOUBLE; break; } } if ($status != null) { // If a status is forced and it is requested to be "confirmed" is like a single opt in // $status here can only be confirmed or not confirmed // TODO: Add a check on status values if ($status == Newsletter::STATUS_CONFIRMED) { $opt_in = self::OPTIN_SINGLE; } else { $opt_in = self::OPTIN_DOUBLE; } } $email = $this->normalize_email(stripslashes($_REQUEST['ne'])); // Shound never reach this point without a valid email address if ($email == null) { die('Wrong email'); } $user = $this->get_user($email); if ($user != null) { // Email already registered in our database $this->logger->info('Subscription of an address with status ' . $user->status); // Bounced // TODO: Manage other cases when added if ($user->status == 'B') { // Non persistent status to decide which message to show (error) $user->status = 'E'; return $user; } // Is there any relevant data change? If so we can proceed otherwise if repeated subscriptions are disabled // show an already subscribed message if (empty($this->options['multiple'])) { $user->status = 'E'; return $user; } if ($this->options['multiple'] == 2) { $lists_changed = false; if (isset($_REQUEST['nl']) && is_array($_REQUEST['nl'])) { foreach ($_REQUEST['nl'] as $list_id) { $list_id = (int) $list_id; if ($list_id <= 0 || $list_id > NEWSLETTER_LIST_MAX) continue; $field = 'list_' . $list_id; if ($user->$field == 0) { $lists_changed = true; break; } } } if (!$lists_changed) { $user->status = 'E'; return $user; } } // If the subscriber is confirmed, we cannot change his data in double opt in mode, we need to // temporary store and wait for activation if ($user->status == Newsletter::STATUS_CONFIRMED && $opt_in == self::OPTIN_DOUBLE) { set_transient($this->get_user_key($user), $_REQUEST, 3600 * 48); // This status is *not* stored it indicate a temporary status to show the correct messages $user->status = 'S'; $this->send_message('confirmation', $user); return $user; } } // Here we have a new subscription or we can process the subscription even with a pre-existant user for example // because it is not confirmed if ($user != null) { $this->logger->info("Email address subscribed but not confirmed"); $user = array('id' => $user->id); } else { $this->logger->info("New email address"); $user = array('email' => $email); } $user = $this->update_user_from_request($user); $user['token'] = $this->get_token(); $ip = $this->get_remote_ip(); $ip = $this->process_ip($ip); $user['ip'] = $ip; $user['geo'] = 0; $user['status'] = $opt_in == self::OPTIN_SINGLE ? Newsletter::STATUS_CONFIRMED : Newsletter::STATUS_NOT_CONFIRMED; $user['updated'] = time(); $user = apply_filters('newsletter_user_subscribe', $user); $user = $this->save_user($user); $this->add_user_log($user, 'subscribe'); // Notification to admin (only for new confirmed subscriptions) if ($user->status == Newsletter::STATUS_CONFIRMED) { do_action('newsletter_user_confirmed', $user); $this->notify_admin($user, 'Newsletter subscription'); setcookie('newsletter', $user->id . '-' . $user->token, time() + 60 * 60 * 24 * 365, '/'); } if ($emails) { $this->send_message(($user->status == Newsletter::STATUS_CONFIRMED) ? 'confirmed' : 'confirmation', $user); } return $user; } function add_microdata($message) { return $message . ''; } /** * Processes the request and fill in the *array* representing a subscriber with submitted values * (filtering when necessary). * * @param array $user An array partially filled with subscriber data * @return array The filled array representing a subscriber */ function update_user_from_request($user) { if (isset($_REQUEST['nn'])) { $user['name'] = $this->normalize_name(stripslashes($_REQUEST['nn'])); } // TODO: required checking if (isset($_REQUEST['ns'])) { $user['surname'] = $this->normalize_name(stripslashes($_REQUEST['ns'])); } // TODO: required checking if (!empty($_REQUEST['nx'])) { $user['sex'] = $this->normalize_sex($_REQUEST['nx'][0]); } // TODO: valid values check if (isset($_REQUEST['nr'])) { $user['referrer'] = strip_tags(trim($_REQUEST['nr'])); } $language = ''; if (!empty($_REQUEST['nlang'])) { $language = strtolower(strip_tags($_REQUEST['nlang'])); // TODO: Check if it's an allowed language code $user['language'] = $language; } // From the antibot form if (isset($_REQUEST['nhr'])) { $user['http_referer'] = strip_tags(trim($_REQUEST['nhr'])); } else if (isset($_SERVER['HTTP_REFERER'])) { $user['http_referer'] = strip_tags(trim($_SERVER['HTTP_REFERER'])); } if (strlen($user['http_referer']) > 200) { $user['http_referer'] = mb_substr($user['http_referer'], 0, 200); } // New profiles for ($i = 1; $i <= NEWSLETTER_PROFILE_MAX; $i++) { // If the profile cannot be set by subscriber, skip it. if ($this->options_profile['profile_' . $i . '_status'] == 0) { continue; } if (isset($_REQUEST['np' . $i])) { $user['profile_' . $i] = trim(stripslashes($_REQUEST['np' . $i])); } } // Preferences (field names are nl[] and values the list number so special forms with radio button can work) if (isset($_REQUEST['nl']) && is_array($_REQUEST['nl'])) { $lists = $this->get_lists_public(); //$this->logger->debug($_REQUEST['nl']); foreach ($lists as $list) { if (in_array('' . $list->id, $_REQUEST['nl'])) { $user['list_' . $list->id] = 1; } } } else { $this->logger->debug('No lists received'); } // Forced lists (general or by language) $lists = $this->get_lists(); foreach ($lists as $list) { if ($list->forced) { $user['list_' . $list->id] = 1; } if (in_array($language, $list->languages)) { $user['list_' . $list->id] = 1; } } // TODO: should be removed!!! if (defined('NEWSLETTER_FEED_VERSION')) { $options_feed = get_option('newsletter_feed', array()); if ($options_feed['add_new'] == 1) { $user['feed'] = 1; } } return $user; } /** * Sends a service message applying the template. * * @param TNP_User $user * @param string $subject * @param string $message * @return type */ function mail($user, $subject, $message) { $language = $this->get_user_language($user); $options_template = $this->get_options('template', $language); $template = trim($options_template['template']); if (empty($template) || strpos($template, '{message}') === false) { $template = '{message}'; } $message = str_replace('{message}', $message, $template); $headers = array('Auto-Submitted' => 'auto-generated'); // Replaces tags from the template $message = $this->replace($message, $user); $subject = $this->replace($subject, $user); return Newsletter::instance()->mail($user->email, $subject, $message, $headers); } /** * Confirms a subscription changing the user status and, possibly, merging the * temporary data if present. * * @param int $user_id Optional. If null the user is extracted from the request. * @return TNP_User */ function confirm($user_id = null, $emails = true) { if ($user_id == null) { $user = $this->get_user_from_request(true); // Is there any temporary data from a subscription to be confirmed? $data = get_transient($this->get_user_key($user)); if ($data !== false) { $_REQUEST = $data; // Update the user profile since it's now confirmed $user = $this->update_user_from_request((array) $user); $user = $this->save_user($user); delete_transient($this->get_user_key($user)); // Forced a fake status so the welcome email is sent $user->status = Newsletter::STATUS_NOT_CONFIRMED; } } else { $user = $this->get_user($user_id); if ($user == null) { die('No subscriber found.'); } } $this->update_user_last_activity($user); setcookie('newsletter', $user->id . '-' . $user->token, time() + 60 * 60 * 24 * 365, '/'); if ($user->status == TNP_User::STATUS_CONFIRMED) { $this->add_user_log($user, 'activate'); do_action('newsletter_user_confirmed', $user); return $user; } $this->set_user_status($user, TNP_User::STATUS_CONFIRMED); $user = $this->get_user($user); $this->add_user_log($user, 'activate'); do_action('newsletter_user_confirmed', $user); $this->notify_admin($user, 'Newsletter subscription'); if ($emails) { $this->send_message('confirmed', $user); } return $user; } /** * Sends a message (activation, welcome, cancellation, ...) with the correct template * and checking if the message itself is disabled * * @param string $type * @param TNP_User $user */ function send_message($type, $user, $force = false) { if (!$force && !empty($this->options[$type . '_disabled'])) { return true; } $language = $this->get_user_language($user); $options = $this->get_options('', $language); $message = $options[$type . '_message']; if ($user->status == Newsletter::STATUS_NOT_CONFIRMED) { $message = $this->add_microdata($message); } $subject = $options[$type . '_subject']; return $this->mail($user, $subject, $message); } /** * Saves the subscriber data. * * @return type */ function save_profile() { return NewsletterProfile::instance()->save_profile(); } function is_double_optin() { return $this->options['noconfirmation'] == 0; } /** * Sends the activation email without conditions. * * @param stdClass $user * @return bool */ function send_activation_email($user) { return $this->send_message('confirmation', $user, true); } /** * Finds the right way to show the message identified by $key (welcome, unsubscription, ...) redirecting the user to the * WordPress page or loading the configured url or activating the standard page. */ function show_message($key, $user, $alert = '', $email = null) { $url = ''; if (isset($_REQUEST['ncu'])) { // Custom URL from the form $url = $_REQUEST['ncu']; } else { // Per message custom URL from configuration (language variants could not be supported) $options = $this->get_options('', $this->get_user_language($user)); if (!empty($options[$key . '_url'])) { $url = $options[$key . '_url']; } } $url = Newsletter::instance()->build_message_url($url, $key, $user, $email, $alert); wp_redirect($url); die(); } function get_message_key_from_request() { if (empty($_GET['nm'])) { return 'subscription'; } $key = $_GET['nm']; switch ($key) { case 's': return 'confirmation'; case 'c': return 'confirmed'; case 'u': return 'unsubscription'; case 'uc': return 'unsubscribed'; case 'p': case 'pe': return 'profile'; default: return $key; } } var $privacy_url = false; function get_privacy_url() { if (!$this->privacy_url) { if (!empty($this->options_profile['privacy_use_wp_url']) && function_exists('get_privacy_policy_url')) { $this->privacy_url = get_privacy_policy_url(); } else { $this->privacy_url = $this->options_profile['privacy_url']; } } return $this->privacy_url; } function get_form_javascript() { $buffer = "\n\n"; $buffer .= '' . "\n\n"; return $buffer; } function shortcode_subscription($attrs, $content) { if (!is_array($attrs)) { $attrs = array(); } $attrs = array_merge(array('class' => 'newsletter', 'style' => ''), $attrs); $action = esc_attr($this->build_action_url('s')); $class = esc_attr($attrs['class']); $style = esc_attr($attrs['style']); $buffer = '
'; return $buffer; } function _shortcode_label($name, $attrs, $suffix = null) { $options_profile = $this->get_options('profile', $this->get_current_language()); if (!$suffix) { $suffix = $name; } $buffer = '\n"; return $buffer; } function shortcode_newsletter_field($attrs, $content) { $name = $attrs['name']; $buffer = ''; if ($name == 'email') { $buffer .= '