/**
  * Handles processing of Pro Form billing updates.
  *
  * @package optimizeMember\Stripe
  * @since 140617
  *
  * @attaches-to ``add_action('init');``
  */
 public static function stripe_update()
 {
     if (!empty($_POST['optimizemember_pro_stripe_update']['nonce']) && ($nonce = $_POST['optimizemember_pro_stripe_update']['nonce']) && wp_verify_nonce($nonce, 'optimizemember-pro-stripe-update')) {
         $GLOBALS['ws_plugin__optimizemember_pro_stripe_update_response'] = array();
         // This holds the global response details.
         $global_response =& $GLOBALS['ws_plugin__optimizemember_pro_stripe_update_response'];
         $post_vars = c_ws_plugin__optimizemember_utils_strings::trim_deep(stripslashes_deep($_POST['optimizemember_pro_stripe_update']));
         $post_vars['attr'] = !empty($post_vars['attr']) ? (array) unserialize(c_ws_plugin__optimizemember_utils_encryption::decrypt($post_vars['attr'])) : array();
         $post_vars['attr'] = apply_filters('ws_plugin__optimizemember_pro_stripe_update_post_attr', $post_vars['attr'], get_defined_vars());
         $post_vars['recaptcha_challenge_field'] = isset($_POST['recaptcha_challenge_field']) ? trim(stripslashes($_POST['recaptcha_challenge_field'])) : '';
         $post_vars['recaptcha_response_field'] = isset($_POST['recaptcha_response_field']) ? trim(stripslashes($_POST['recaptcha_response_field'])) : '';
         if (!c_ws_plugin__optimizemember_pro_stripe_responses::stripe_form_attr_validation_errors($post_vars['attr'])) {
             if (!($form_submission_validation_errors = c_ws_plugin__optimizemember_pro_stripe_responses::stripe_form_submission_validation_errors('update', $post_vars))) {
                 if (is_user_logged_in() && ($user = wp_get_current_user()) && ($user_id = $user->ID)) {
                     if (($cur__subscr_cid = get_user_option('optimizemember_subscr_cid')) && ($cur__subscr_id = get_user_option('optimizemember_subscr_id'))) {
                         if (is_object($stripe_subscription = c_ws_plugin__optimizemember_pro_stripe_utilities::get_customer_subscription($cur__subscr_cid, $cur__subscr_id)) && !preg_match('/^canceled$/i', $stripe_subscription->status) && !$stripe_subscription->cancel_at_period_end) {
                             unset($_POST['optimizemember_pro_stripe_update']['card_token']);
                             // These are good one-time only.
                             unset($_POST['optimizemember_pro_stripe_update']['card_token_summary']);
                             if (is_object($set_customer_card_token = c_ws_plugin__optimizemember_pro_stripe_utilities::set_customer_card_token($cur__subscr_cid, $post_vars['card_token']))) {
                                 $global_response = array('response' => _x('<strong>Confirmed.</strong> Your billing information has been updated.', 's2member-front', 's2member'));
                                 if ($post_vars['attr']['success'] && ($custom_success_url = str_ireplace(array('%%s_response%%', '%%response%%'), array(urlencode(c_ws_plugin__optimizemember_utils_encryption::encrypt($global_response['response'])), urlencode($global_response['response'])), $post_vars['attr']['success'])) && ($custom_success_url = trim(preg_replace('/%%(.+?)%%/i', '', $custom_success_url)))) {
                                     wp_redirect(c_ws_plugin__optimizemember_utils_urls::add_optimizemember_sig($custom_success_url, 's2p-v')) . exit;
                                 }
                             } else {
                                 $global_response = array('response' => $set_customer_card_token, 'error' => TRUE);
                             }
                         } else {
                             $global_response = array('response' => _x('<strong>Unable to update.</strong> You have NO recurring fees. Or, your billing profile is no longer active. Please contact Support if you need assistance.', 's2member-front', 's2member'), 'error' => TRUE);
                         }
                     } else {
                         $global_response = array('response' => _x('<strong>Oops.</strong> No Customer|Subscr. ID. Please contact Support for assistance.', 's2member-front', 's2member'), 'error' => TRUE);
                     }
                 } else {
                     $global_response = array('response' => _x('You\'re <strong>NOT</strong> logged in.', 's2member-front', 's2member'), 'error' => TRUE);
                 }
             } else {
                 // Input form field validation errors.
                 $global_response = $form_submission_validation_errors;
             }
         }
     }
 }
Beispiel #2
0
 /**
  * Forces a redirection to the Membership Options Page for optimizeMember.
  *
  * This can be used by 3rd party apps that are not aware of which Page is currently set as the Membership Options Page.
  * Example usage: `http://example.com/?optimizemember_membership_options_page=1`
  *
  * Redirection URLs containing array brackets MUST be URL encoded to get through: ``wp_sanitize_redirect()``.
  * 	So we pass everything to ``urlencode_deep()``, as an array. It handles this via ``_http_build_query()``.
  * 	See bug report here: {@link http://core.trac.wordpress.org/ticket/17052}
  *
  * @package optimizeMember\Membership_Options_Page
  * @since 3.5
  *
  * @attaches-to ``add_action("init");``
  *
  * @return null Or exits script execution after redirection w/ `301` status.
  */
 public static function membership_options_page()
 {
     do_action("ws_plugin__optimizemember_before_membership_options_page", get_defined_vars());
     /**/
     if (!empty($_GET["optimizemember_membership_options_page"]) && is_array($_g = c_ws_plugin__optimizemember_utils_strings::trim_deep(stripslashes_deep($_GET)))) {
         $args = array();
         /**/
         foreach ($_g as $var => $value) {
             /* Include all of the `_?optimizemember_` variables. */
             /* Do NOT include `optimizemember_membership_options_page`; creates a redirection loop. */
             if (preg_match("/^_?optimizemember_/", $var) && $var !== "optimizemember_membership_options_page") {
                 $args[$var] = $value;
             }
         }
         /**/
         wp_redirect(add_query_arg(urlencode_deep($args), get_page_link($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["membership_options_page"])), 301) . exit;
     }
     /**/
     do_action("ws_plugin__optimizemember_after_membership_options_page", get_defined_vars());
 }
Beispiel #3
0
 /**
  * Saves Custom Fields after an admin updates Profile.
  *
  * @package optimizeMember\Users_List
  * @since 3.5
  *
  * @attaches-to ``add_action("edit_user_profile_update");``
  * @attaches-to ``add_action("personal_options_update");``
  *
  * @param int|str $user_id Expects a numeric WordPress User ID passed in by the Action Hook.
  * @return null
  */
 public static function users_list_update_cols($user_id = FALSE)
 {
     global $current_site, $current_blog;
     /**/
     eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
     do_action("ws_plugin__optimizemember_before_users_list_update_cols", get_defined_vars());
     unset($__refs, $__v);
     /**/
     $user = new WP_User($user_id);
     $current_user = is_user_logged_in() ? wp_get_current_user() : false;
     /**/
     if (is_object($user) && !empty($user->ID) && ($user_id = $user->ID) && is_object($current_user) && !empty($current_user->ID)) {
         if (current_user_can("edit_users") && (!is_multisite() || is_super_admin() || is_user_member_of_blog($user_id))) {
             if (!empty($_POST) && is_array($_p = c_ws_plugin__optimizemember_utils_strings::trim_deep(stripslashes_deep($_POST)))) {
                 $old_user = unserialize(serialize($user));
                 $old_role = c_ws_plugin__optimizemember_user_access::user_access_role($old_user);
                 /**/
                 $role = isset($_p["role"]) && $_p["role"] !== $old_role ? $_p["role"] : $old_role;
                 $level = c_ws_plugin__optimizemember_user_access::user_access_role_to_level($role);
                 /**/
                 $user->roles = isset($_p["role"]) && $_p["role"] !== $old_role ? array($_p["role"]) : $old_user->roles;
                 $user->user_email = isset($_p["email"]) && is_email($_p["email"]) && $_p["email"] !== $old_user->user_email && !email_exists($_p["email"]) ? $_p["email"] : $old_user->user_email;
                 $user->first_name = isset($_p["first_name"]) && $_p["first_name"] !== $old_user->first_name ? $_p["first_name"] : $old_user->first_name;
                 $user->last_name = isset($_p["last_name"]) && $_p["last_name"] !== $old_user->last_name ? $_p["last_name"] : $old_user->last_name;
                 /**/
                 $auto_eot_time = !empty($_p["ws_plugin__optimizemember_profile_optimizemember_auto_eot_time"]) ? strtotime($_p["ws_plugin__optimizemember_profile_optimizemember_auto_eot_time"]) : "";
                 /**/
                 if ($role !== $old_role) {
                     /* In this case, we need to fire Hook: `ws_plugin__optimizemember_during_collective_mods`. */
                     do_action("ws_plugin__optimizemember_during_collective_mods", $user_id, get_defined_vars(), "user-role-change", "modification", $role, $user, $old_user);
                 }
                 /**/
                 if (isset($_p["ws_plugin__optimizemember_profile_optimizemember_originating_blog"]) && is_multisite() && is_super_admin()) {
                     update_user_meta($user_id, "optimizemember_originating_blog", $_p["ws_plugin__optimizemember_profile_optimizemember_originating_blog"]);
                 }
                 /**/
                 if (isset($_p["ws_plugin__optimizemember_profile_optimizemember_subscr_gateway"])) {
                     update_user_option($user_id, "optimizemember_subscr_gateway", $_p["ws_plugin__optimizemember_profile_optimizemember_subscr_gateway"]);
                 }
                 /**/
                 if (isset($_p["ws_plugin__optimizemember_profile_optimizemember_subscr_id"])) {
                     update_user_option($user_id, "optimizemember_subscr_id", $_p["ws_plugin__optimizemember_profile_optimizemember_subscr_id"]);
                 }
                 /**/
                 if (isset($_p["ws_plugin__optimizemember_profile_optimizemember_custom"])) {
                     update_user_option($user_id, "optimizemember_custom", $_p["ws_plugin__optimizemember_profile_optimizemember_custom"]);
                 }
                 /**/
                 if (isset($_p["ws_plugin__optimizemember_profile_optimizemember_registration_ip"])) {
                     update_user_option($user_id, "optimizemember_registration_ip", $_p["ws_plugin__optimizemember_profile_optimizemember_registration_ip"]);
                 }
                 /**/
                 if (isset($_p["ws_plugin__optimizemember_profile_optimizemember_notes"])) {
                     update_user_option($user_id, "optimizemember_notes", $_p["ws_plugin__optimizemember_profile_optimizemember_notes"]);
                 }
                 /**/
                 if (isset($_p["ws_plugin__optimizemember_profile_optimizemember_auto_eot_time"]) && isset($auto_eot_time)) {
                     update_user_option($user_id, "optimizemember_auto_eot_time", $auto_eot_time);
                 }
                 /**/
                 if (isset($_p["ws_plugin__optimizemember_profile_optimizemember_ccaps"])) {
                     foreach ($user->allcaps as $cap => $cap_enabled) {
                         if (preg_match("/^access_optimizemember_ccap_/", $cap)) {
                             $user->remove_cap($ccap = $cap);
                         }
                     }
                     /**/
                     if (!empty($_p["ws_plugin__optimizemember_profile_optimizemember_ccaps"])) {
                         foreach (preg_split("/[\r\n\t\\s;,]+/", $_p["ws_plugin__optimizemember_profile_optimizemember_ccaps"]) as $ccap) {
                             if (strlen($ccap = trim(strtolower(preg_replace("/[^a-z_0-9]/i", "", $ccap))))) {
                                 $user->add_cap("access_optimizemember_ccap_" . $ccap);
                             }
                         }
                     }
                 }
                 if ($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["custom_reg_fields"]) {
                     foreach (json_decode($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["custom_reg_fields"], true) as $field) {
                         $field_var = preg_replace("/[^a-z0-9]/i", "_", strtolower($field["id"]));
                         $field_id_class = preg_replace("/_/", "-", $field_var);
                         /**/
                         if (isset($_p["ws_plugin__optimizemember_profile_" . $field_var])) {
                             if (is_array($_p["ws_plugin__optimizemember_profile_" . $field_var]) && !empty($_p["ws_plugin__optimizemember_profile_" . $field_var]) || is_string($_p["ws_plugin__optimizemember_profile_" . $field_var]) && strlen($_p["ws_plugin__optimizemember_profile_" . $field_var])) {
                                 $fields[$field_var] = $_p["ws_plugin__optimizemember_profile_" . $field_var];
                             } else {
                                 unset($fields[$field_var]);
                             }
                         } else {
                             unset($fields[$field_var]);
                         }
                     }
                 }
                 if (!empty($fields)) {
                     update_user_option($user_id, "optimizemember_custom_fields", $fields);
                 } else {
                     delete_user_option($user_id, "optimizemember_custom_fields");
                 }
                 /**/
                 if ($level > 0) {
                     $pr_times = get_user_option("optimizemember_paid_registration_times", $user_id);
                     $pr_times["level"] = empty($pr_times["level"]) ? time() : $pr_times["level"];
                     $pr_times["level" . $level] = empty($pr_times["level" . $level]) ? time() : $pr_times["level" . $level];
                     update_user_option($user_id, "optimizemember_paid_registration_times", $pr_times);
                     /* Update now. */
                 }
                 if (!empty($_p["ws_plugin__optimizemember_profile_opt_in"]) && !empty($role) && $level >= 0) {
                     c_ws_plugin__optimizemember_list_servers::process_list_servers($role, $level, $user->user_login, !empty($_p["pass1"]) ? $_p["pass1"] : "", $user->user_email, $user->first_name, $user->last_name, false, true, true, $user_id);
                 }
                 /**/
                 if (!empty($_p["ws_plugin__optimizemember_profile_ip_restrictions"])) {
                     c_ws_plugin__optimizemember_ip_restrictions::delete_reset_specific_ip_restrictions(strtolower($user->user_login));
                 }
                 /**/
                 eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
                 do_action("ws_plugin__optimizemember_during_users_list_update_cols", get_defined_vars());
                 unset($__refs, $__v);
             }
         } else {
             if ($current_user->ID === $user->ID) {
                 if (!empty($_POST) && is_array($_p = c_ws_plugin__optimizemember_utils_strings::trim_deep(stripslashes_deep($_POST)))) {
                     $role = c_ws_plugin__optimizemember_user_access::user_access_role($user);
                     $level = c_ws_plugin__optimizemember_user_access::user_access_role_to_level($role);
                     /**/
                     if ($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["custom_reg_fields"]) {
                         if ($fields_applicable = c_ws_plugin__optimizemember_custom_reg_fields::custom_fields_configured_at_level($level, "profile")) {
                             $_existing_fields = get_user_option("optimizemember_custom_fields", $user_id);
                             /**/
                             foreach (json_decode($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["custom_reg_fields"], true) as $field) {
                                 $field_var = preg_replace("/[^a-z0-9]/i", "_", strtolower($field["id"]));
                                 $field_id_class = preg_replace("/_/", "-", $field_var);
                                 /**/
                                 if (!in_array($field["id"], $fields_applicable) || strpos($field["editable"], "no") === 0) {
                                     if (isset($_existing_fields[$field_var]) && (is_array($_existing_fields[$field_var]) && !empty($_existing_fields[$field_var]) || is_string($_existing_fields[$field_var]) && strlen($_existing_fields[$field_var]))) {
                                         $fields[$field_var] = $_existing_fields[$field_var];
                                     } else {
                                         /* Else ``unset()``. */
                                         unset($fields[$field_var]);
                                     }
                                 } else {
                                     if ($field["required"] === "yes" && (!isset($_p["ws_plugin__optimizemember_profile_" . $field_var]) || !is_array($_p["ws_plugin__optimizemember_profile_" . $field_var]) && !is_string($_p["ws_plugin__optimizemember_profile_" . $field_var]) || is_array($_p["ws_plugin__optimizemember_profile_" . $field_var]) && empty($_p["ws_plugin__optimizemember_profile_" . $field_var]) || is_string($_p["ws_plugin__optimizemember_profile_" . $field_var]) && !strlen($_p["ws_plugin__optimizemember_profile_" . $field_var]))) {
                                         if (isset($_existing_fields[$field_var]) && (is_array($_existing_fields[$field_var]) && !empty($_existing_fields[$field_var]) || is_string($_existing_fields[$field_var]) && strlen($_existing_fields[$field_var]))) {
                                             $fields[$field_var] = $_existing_fields[$field_var];
                                         } else {
                                             /* Else ``unset()``. */
                                             unset($fields[$field_var]);
                                         }
                                     } else {
                                         if (isset($_p["ws_plugin__optimizemember_profile_" . $field_var])) {
                                             if (is_array($_p["ws_plugin__optimizemember_profile_" . $field_var]) && !empty($_p["ws_plugin__optimizemember_profile_" . $field_var]) || is_string($_p["ws_plugin__optimizemember_profile_" . $field_var]) && strlen($_p["ws_plugin__optimizemember_profile_" . $field_var])) {
                                                 $fields[$field_var] = $_p["ws_plugin__optimizemember_profile_" . $field_var];
                                             } else {
                                                 unset($fields[$field_var]);
                                             }
                                         } else {
                                             unset($fields[$field_var]);
                                         }
                                     }
                                 }
                             }
                             if (!empty($fields)) {
                                 update_user_option($user_id, "optimizemember_custom_fields", $fields);
                             } else {
                                 delete_user_option($user_id, "optimizemember_custom_fields");
                             }
                         }
                     }
                     eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
                     do_action("ws_plugin__optimizemember_during_users_list_update_cols", get_defined_vars());
                     unset($__refs, $__v);
                 }
             }
         }
     }
     eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
     do_action("ws_plugin__optimizemember_after_users_list_update_cols", get_defined_vars());
     unset($__refs, $__v);
     /**/
     return;
 }
Beispiel #4
0
 /**
  * Handles Google XML Checkout redirections.
  *
  * @package optimizeMember\Google
  * @since 1.5
  *
  * @attaches-to ``add_action("init");``
  *
  * @return null Or exits script execution after redirection to Google Checkout.
  */
 public static function google_co()
 {
     global $current_site, $current_blog;
     /**/
     if (!empty($_GET["optimizemember_pro_google_co"]) && c_ws_plugin__optimizemember_utils_urls::optimizemember_sig_ok($_SERVER["REQUEST_URI"]) && !empty($_GET["co"]) && is_array($attr = c_ws_plugin__optimizemember_utils_strings::trim_deep(stripslashes_deep($_GET["co"]))) && $GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["pro_google_merchant_id"]) {
         $attr = shortcode_atts(array("ids" => "0", "exp" => "72", "level" => "1", "ccaps" => "", "desc" => "", "cc" => "USD", "custom" => $_SERVER["HTTP_HOST"], "ta" => "0", "tp" => "0", "tt" => "D", "ra" => "0.01", "rp" => "1", "rt" => "M", "rr" => "1", "modify" => "0", "cancel" => "0", "sp" => "0", "image" => "default", "output" => "anchor"), $attr);
         /**/
         $attr["tt"] = strtoupper($attr["tt"]);
         /* Term lengths absolutely must be provided in upper-case format. Only after running shortcode_atts(). */
         $attr["rt"] = strtoupper($attr["rt"]);
         /* Term lengths absolutely must be provided in upper-case format. Only after running shortcode_atts(). */
         $attr["rr"] = strtoupper($attr["rr"]);
         /* Must be provided in upper-case format. Numerical, or BN value. Only after running shortcode_atts(). */
         $attr["ccaps"] = strtolower($attr["ccaps"]);
         /* Custom Capabilities must be typed in lower-case format. Only after running shortcode_atts(). */
         $attr["rr"] = $attr["rt"] === "L" ? "BN" : $attr["rr"];
         /* Lifetime Subscriptions require Buy Now. Only after running shortcode_atts(). */
         $attr["rr"] = $attr["level"] === "*" ? "BN" : $attr["rr"];
         /* Independent Ccaps do NOT recur. Only after running shortcode_atts(). */
         $attr["rr"] = !$attr["tp"] && !$attr["rr"] ? "BN" : $attr["rr"];
         /* No Trial / non-recurring. Only after running shortcode_atts(). */
         /**/
         if ($attr["modify"] || $attr["cancel"]) {
             $endpoint = $GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["pro_google_sandbox"] ? "sandbox.google.com/checkout" : "checkout.google.com";
             /**/
             wp_redirect("https://" . $endpoint . "/");
         } else {
             if ($attr["sp"]) {
                 $attr["uniqid"] = uniqid();
                 /* Unique ID. */
                 $attr["referencing"] = c_ws_plugin__optimizemember_utils_users::get_user_subscr_or_wp_id();
                 /**/
                 $attr["sp_ids_exp"] = "sp:" . $attr["ids"] . ":" . $attr["exp"];
                 /* Combined "sp:ids:expiration hours". */
                 $attr["sp_access_link"] = c_ws_plugin__optimizemember_sp_access::sp_access_link_gen($attr["ids"], $attr["exp"]);
                 /**/
                 $xml = '<?xml version="1.0" encoding="UTF-8"?>';
                 $xml .= '<checkout-shopping-cart xmlns="http://checkout.google.com/schema/2">';
                 $xml .= '<shopping-cart>';
                 $xml .= '<items>';
                 /**/
                 $xml .= '<item>';
                 /**/
                 $xml .= '<quantity>1</quantity>';
                 $xml .= '<item-name>' . esc_html($attr["desc"]) . '</item-name>';
                 $xml .= '<item-description>(TID:s2-' . esc_html($attr["uniqid"]) . ') ' . esc_html(_x("Grants you immediate access.", "s2member-front", "s2member")) . '</item-description>';
                 $xml .= '<unit-price currency="' . esc_attr($attr["cc"]) . '">' . esc_html($attr["ra"]) . '</unit-price>';
                 /**/
                 $xml .= '<merchant-private-item-data>';
                 $xml .= '<s2_txn_id>s2-' . esc_html($attr["uniqid"]) . '</s2_txn_id>';
                 $xml .= '<s2_custom>' . esc_html($attr["custom"]) . '</s2_custom>';
                 $xml .= '<s2_item_number>' . esc_html($attr["sp_ids_exp"]) . '</s2_item_number>';
                 $xml .= '<s2_customer_ip>' . esc_html($_SERVER["REMOTE_ADDR"]) . '</s2_customer_ip>';
                 $xml .= $attr["referencing"] ? '<s2_referencing>' . esc_html($attr["referencing"]) . '</s2_referencing>' : '';
                 $xml .= '</merchant-private-item-data>';
                 /**/
                 $xml .= '<digital-content>';
                 $xml .= '<display-disposition>PESSIMISTIC</display-disposition>';
                 $xml .= '<description>' . esc_html($attr["desc"]) . '</description>';
                 $xml .= '<url>' . esc_html($attr["sp_access_link"]) . '</url>';
                 $xml .= '</digital-content>';
                 /**/
                 $xml .= '</item>';
                 /**/
                 $xml .= '</items>';
                 $xml .= '</shopping-cart>';
                 /**/
                 $xml .= '<checkout-flow-support>';
                 $xml .= '<merchant-checkout-flow-support>';
                 $xml .= '<edit-cart-url>' . esc_html(get_page_link($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["membership_options_page"])) . '</edit-cart-url>';
                 $xml .= '<continue-shopping-url>' . esc_html($attr["sp_access_link"]) . '</continue-shopping-url>';
                 $xml .= '</merchant-checkout-flow-support>';
                 $xml .= '</checkout-flow-support>';
                 /**/
                 $xml .= '</checkout-shopping-cart>';
                 /**/
                 $endpoint = $GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["pro_google_sandbox"] ? "sandbox.google.com/checkout" : "checkout.google.com";
                 /**/
                 if (($xml = c_ws_plugin__optimizemember_utils_urls::remote("https://" . $endpoint . "/api/checkout/v2/merchantCheckout/Merchant/" . $GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["pro_google_merchant_id"], $xml, array_merge(c_ws_plugin__optimizemember_pro_google_utilities::google_api_headers(), array("timeout" => 20)))) && preg_match("/\\<redirect-url\\>(.+?)\\<\\/redirect-url\\>/i", preg_replace("/[\r\n\t]+/", "", $xml), $m) && ($google = $m[1])) {
                     wp_redirect(wp_specialchars_decode($google, ENT_QUOTES));
                 } else {
                     /* Display error message. */
                     echo strip_tags($xml);
                 }
             } else {
                 if ($attr["level"] === "*") {
                     $attr["uniqid"] = uniqid();
                     /* Unique ID. */
                     $attr["referencing"] = c_ws_plugin__optimizemember_utils_users::get_user_subscr_or_wp_id();
                     /**/
                     $attr["level_ccaps_eotper"] = $attr["rt"] !== "L" ? $attr["level"] . ":" . $attr["ccaps"] . ":" . $attr["rp"] . " " . $attr["rt"] : $attr["level"] . ":" . $attr["ccaps"];
                     $attr["level_ccaps_eotper"] = rtrim($attr["level_ccaps_eotper"], ":");
                     /* Right-trim separators from this string so we don't have trailing colons. */
                     /**/
                     $xml = '<?xml version="1.0" encoding="UTF-8"?>';
                     $xml .= '<checkout-shopping-cart xmlns="http://checkout.google.com/schema/2">';
                     $xml .= '<shopping-cart>';
                     $xml .= '<items>';
                     /**/
                     $xml .= '<item>';
                     /**/
                     $xml .= '<quantity>1</quantity>';
                     $xml .= '<item-name>' . esc_html($attr["desc"]) . '</item-name>';
                     $xml .= '<item-description>(TID:s2-' . esc_html($attr["uniqid"]) . ') ' . esc_html(_x("Grants you immediate access.", "s2member-front", "s2member")) . '</item-description>';
                     $xml .= '<unit-price currency="' . esc_attr($attr["cc"]) . '">' . esc_html($attr["ra"]) . '</unit-price>';
                     /**/
                     $xml .= '<merchant-private-item-data>';
                     $xml .= '<s2_txn_id>s2-' . esc_html($attr["uniqid"]) . '</s2_txn_id>';
                     $xml .= '<s2_custom>' . esc_html($attr["custom"]) . '</s2_custom>';
                     $xml .= '<s2_customer_ip>' . esc_html($_SERVER["REMOTE_ADDR"]) . '</s2_customer_ip>';
                     $xml .= '<s2_item_number>' . esc_html($attr["level_ccaps_eotper"]) . '</s2_item_number>';
                     $xml .= '<s2_referencing>' . esc_html($attr["referencing"]) . '</s2_referencing>';
                     $xml .= '</merchant-private-item-data>';
                     /**/
                     $xml .= '<digital-content>';
                     $xml .= '<display-disposition>PESSIMISTIC</display-disposition>';
                     $xml .= '<description>' . esc_html(sprintf(_x('You now have access to:<br />%s<br />( <a href="%s">please log back in now</a> )', "s2member-front", "s2member"), $attr["desc"], esc_attr(wp_login_url()))) . '</description>';
                     $xml .= '<url>' . esc_html(wp_login_url()) . '</url>';
                     $xml .= '</digital-content>';
                     /**/
                     $xml .= '</item>';
                     /**/
                     $xml .= '</items>';
                     $xml .= '</shopping-cart>';
                     /**/
                     $xml .= '<checkout-flow-support>';
                     $xml .= '<merchant-checkout-flow-support>';
                     $xml .= '<edit-cart-url>' . esc_html(get_page_link($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["membership_options_page"])) . '</edit-cart-url>';
                     $xml .= '<continue-shopping-url>' . esc_html(wp_login_url()) . '</continue-shopping-url>';
                     $xml .= '</merchant-checkout-flow-support>';
                     $xml .= '</checkout-flow-support>';
                     /**/
                     $xml .= '</checkout-shopping-cart>';
                     /**/
                     $endpoint = $GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["pro_google_sandbox"] ? "sandbox.google.com/checkout" : "checkout.google.com";
                     /**/
                     if (($xml = c_ws_plugin__optimizemember_utils_urls::remote("https://" . $endpoint . "/api/checkout/v2/merchantCheckout/Merchant/" . $GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["pro_google_merchant_id"], $xml, array_merge(c_ws_plugin__optimizemember_pro_google_utilities::google_api_headers(), array("timeout" => 20)))) && preg_match("/\\<redirect-url\\>(.+?)\\<\\/redirect-url\\>/i", preg_replace("/[\r\n\t]+/", "", $xml), $m) && ($google = $m[1])) {
                         wp_redirect(wp_specialchars_decode($google, ENT_QUOTES));
                     } else {
                         /* Display error message. */
                         echo strip_tags($xml);
                     }
                 } else {
                     if ($attr["rr"] === "BN" || !$attr["tp"] && !$attr["rr"]) {
                         $attr["uniqid"] = uniqid();
                         /* Unique ID. */
                         $attr["referencing"] = c_ws_plugin__optimizemember_utils_users::get_user_subscr_or_wp_id();
                         /**/
                         $attr["desc"] = !$attr["desc"] ? $GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["level" . $attr["level"] . "_label"] : $attr["desc"];
                         /**/
                         $attr["level_ccaps_eotper"] = $attr["rt"] !== "L" ? $attr["level"] . ":" . $attr["ccaps"] . ":" . $attr["rp"] . " " . $attr["rt"] : $attr["level"] . ":" . $attr["ccaps"];
                         $attr["level_ccaps_eotper"] = rtrim($attr["level_ccaps_eotper"], ":");
                         /* Right-trim separators from this string so we don't have trailing colons. */
                         /**/
                         $attr["register_access_link"] = c_ws_plugin__optimizemember_register_access::register_link_gen("google", "s2-" . $attr["uniqid"], $attr["custom"], $attr["level_ccaps_eotper"]);
                         /**/
                         $xml = '<?xml version="1.0" encoding="UTF-8"?>';
                         $xml .= '<checkout-shopping-cart xmlns="http://checkout.google.com/schema/2">';
                         $xml .= '<shopping-cart>';
                         $xml .= '<items>';
                         /**/
                         $xml .= '<item>';
                         /**/
                         $xml .= '<quantity>1</quantity>';
                         $xml .= '<item-name>' . esc_html($attr["desc"]) . '</item-name>';
                         $xml .= '<item-description>(TID:s2-' . esc_html($attr["uniqid"]) . ') ' . esc_html(_x("Grants you immediate access.", "s2member-front", "s2member")) . '</item-description>';
                         $xml .= '<unit-price currency="' . esc_attr($attr["cc"]) . '">' . esc_html($attr["ra"]) . '</unit-price>';
                         /**/
                         $xml .= '<merchant-private-item-data>';
                         $xml .= '<s2_txn_id>s2-' . esc_html($attr["uniqid"]) . '</s2_txn_id>';
                         $xml .= '<s2_custom>' . esc_html($attr["custom"]) . '</s2_custom>';
                         $xml .= '<s2_customer_ip>' . esc_html($_SERVER["REMOTE_ADDR"]) . '</s2_customer_ip>';
                         $xml .= '<s2_item_number>' . esc_html($attr["level_ccaps_eotper"]) . '</s2_item_number>';
                         $xml .= $attr["referencing"] ? '<s2_referencing>' . esc_html($attr["referencing"]) . '</s2_referencing>' : '';
                         $xml .= '</merchant-private-item-data>';
                         /**/
                         $xml .= '<digital-content>';
                         $xml .= '<display-disposition>PESSIMISTIC</display-disposition>';
                         /**/
                         if ($attr["referencing"]) {
                             $xml .= '<description>' . esc_html(sprintf(_x('You\'ve been updated to:<br />%s<br />( <a href="%s">please log back in now</a> )', "s2member-front", "s2member"), $attr["desc"], esc_attr(wp_login_url()))) . '</description>';
                             $xml .= '<url>' . esc_html(wp_login_url()) . '</url>';
                         } else {
                             $xml .= '<description>' . esc_html(sprintf(_x('%s<br />( the next step is to Register a Username )', "s2member-front", "s2member"), $attr["desc"])) . '</description>';
                             $xml .= '<url>' . esc_html($attr["register_access_link"]) . '</url>';
                         }
                         /**/
                         $xml .= '</digital-content>';
                         /**/
                         $xml .= '</item>';
                         /**/
                         $xml .= '</items>';
                         $xml .= '</shopping-cart>';
                         /**/
                         $xml .= '<checkout-flow-support>';
                         $xml .= '<merchant-checkout-flow-support>';
                         $xml .= '<edit-cart-url>' . esc_html(get_page_link($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["membership_options_page"])) . '</edit-cart-url>';
                         $xml .= '<continue-shopping-url>' . esc_html($attr["referencing"] ? wp_login_url() : $attr["register_access_link"]) . '</continue-shopping-url>';
                         $xml .= '</merchant-checkout-flow-support>';
                         $xml .= '</checkout-flow-support>';
                         /**/
                         $xml .= '</checkout-shopping-cart>';
                         /**/
                         $endpoint = $GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["pro_google_sandbox"] ? "sandbox.google.com/checkout" : "checkout.google.com";
                         /**/
                         if (($xml = c_ws_plugin__optimizemember_utils_urls::remote("https://" . $endpoint . "/api/checkout/v2/merchantCheckout/Merchant/" . $GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["pro_google_merchant_id"], $xml, array_merge(c_ws_plugin__optimizemember_pro_google_utilities::google_api_headers(), array("timeout" => 20)))) && preg_match("/\\<redirect-url\\>(.+?)\\<\\/redirect-url\\>/i", preg_replace("/[\r\n\t]+/", "", $xml), $m) && ($google = $m[1])) {
                             wp_redirect(wp_specialchars_decode($google, ENT_QUOTES));
                         } else {
                             /* Display error message. */
                             echo strip_tags($xml);
                         }
                     } else {
                         $attr["uniqid"] = uniqid();
                         /* Unique ID. */
                         $attr["referencing"] = c_ws_plugin__optimizemember_utils_users::get_user_subscr_or_wp_id();
                         /**/
                         $attr["desc"] = !$attr["desc"] ? $GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["level" . $attr["level"] . "_label"] : $attr["desc"];
                         /**/
                         $attr["level_ccaps_eotper"] = $attr["level"] . ":" . $attr["ccaps"];
                         /* Actual Subscriptions will always end on their own. */
                         $attr["level_ccaps_eotper"] = rtrim($attr["level_ccaps_eotper"], ":");
                         /* Clean any trailing separators from this string. */
                         /**/
                         $attr["periodicity"] = c_ws_plugin__optimizemember_pro_google_utilities::google_periodicity($attr["rp"] . " " . $attr["rt"]);
                         /* Google periodicity. */
                         /**/
                         $attr["register_access_link"] = c_ws_plugin__optimizemember_register_access::register_link_gen("google", "s2-" . $attr["uniqid"], $attr["custom"], $attr["level_ccaps_eotper"]);
                         /**/
                         if ($attr["tp"]) {
                             $attr["start_time"] = c_ws_plugin__optimizemember_pro_google_utilities::google_start_time($attr["tp"] . " " . $attr["tt"]);
                             /**/
                             $xml = '<?xml version="1.0" encoding="UTF-8"?>';
                             $xml .= '<checkout-shopping-cart xmlns="http://checkout.google.com/schema/2">';
                             $xml .= '<shopping-cart>';
                             $xml .= '<items>';
                             /**/
                             $xml .= '<item>';
                             /**/
                             $xml .= '<quantity>1</quantity>';
                             $xml .= '<item-name>' . esc_html($attr["desc"]) . '</item-name>';
                             $xml .= $attr["ta"] < 0.01 ? '<item-description>(SID:s2-' . esc_html($attr["uniqid"]) . ') ' . esc_html(_x("100% free trial. NO charge today.", "s2member-front", "s2member")) . '</item-description>' : '<item-description>(SID:s2-' . esc_html($attr["uniqid"]) . ') ' . esc_html(_x("First payment for immediate access.", "s2member-front", "s2member")) . '</item-description>';
                             $xml .= '<unit-price currency="' . esc_attr($attr["cc"]) . '">' . esc_html($attr["ta"]) . '</unit-price>';
                             /**/
                             $xml .= '<merchant-private-item-data>';
                             $xml .= '<s2_subscr_id>s2-' . esc_html($attr["uniqid"]) . '</s2_subscr_id>';
                             $xml .= '<s2_custom>' . esc_html($attr["custom"]) . '</s2_custom>';
                             $xml .= '<s2_customer_ip>' . esc_html($_SERVER["REMOTE_ADDR"]) . '</s2_customer_ip>';
                             $xml .= '<s2_item_number>' . esc_html($attr["level_ccaps_eotper"]) . '</s2_item_number>';
                             $xml .= '<s2_period1>' . esc_html($attr["tp"] . " " . $attr["tt"]) . '</s2_period1>';
                             $xml .= '<s2_period3>' . esc_html($attr["rp"] . " " . $attr["rt"]) . '</s2_period3>';
                             $xml .= $attr["rr"] ? '<s2_recurring>' . esc_html($attr["rr"]) . '</s2_recurring>' : '';
                             $xml .= $attr["referencing"] ? '<s2_referencing>' . esc_html($attr["referencing"]) . '</s2_referencing>' : '';
                             $xml .= '</merchant-private-item-data>';
                             /**/
                             $xml .= '<digital-content>';
                             $xml .= '<display-disposition>PESSIMISTIC</display-disposition>';
                             $xml .= '<description>' . esc_html(_x("You'll receive an email confirmation within 15 minutes.", "s2member-front", "s2member")) . '</description>';
                             $xml .= '</digital-content>';
                             /**/
                             $xml .= '</item>';
                             /**/
                             $xml .= '<item>';
                             /**/
                             $xml .= '<quantity>1</quantity>';
                             $xml .= '<item-name>' . esc_html($attr["desc"]) . '</item-name>';
                             $xml .= '<item-description>(SID:s2-' . esc_html($attr["uniqid"]) . ') ' . esc_html(sprintf(_x("Cancel at any time to avoid %s.", "s2member-front", "s2member"), !$attr["rr"] ? _x("this charge", "s2member-front", "s2member") : _x("charges", "s2member-front", "s2member"))) . '</item-description>';
                             $xml .= '<unit-price currency="' . esc_attr($attr["cc"]) . '">0.00</unit-price>';
                             /**/
                             $xml .= '<merchant-private-item-data>';
                             $xml .= '<s2_subscr_id>s2-' . esc_html($attr["uniqid"]) . '</s2_subscr_id>';
                             $xml .= '<s2_custom>' . esc_html($attr["custom"]) . '</s2_custom>';
                             $xml .= '<s2_customer_ip>' . esc_html($_SERVER["REMOTE_ADDR"]) . '</s2_customer_ip>';
                             $xml .= '<s2_item_number>' . esc_html($attr["level_ccaps_eotper"]) . '</s2_item_number>';
                             $xml .= '<s2_period1>' . esc_html($attr["tp"] . " " . $attr["tt"]) . '</s2_period1>';
                             $xml .= '<s2_period3>' . esc_html($attr["rp"] . " " . $attr["rt"]) . '</s2_period3>';
                             $xml .= $attr["rr"] ? '<s2_recurring>' . esc_html($attr["rr"]) . '</s2_recurring>' : '';
                             $xml .= $attr["referencing"] ? '<s2_referencing>' . esc_html($attr["referencing"]) . '</s2_referencing>' : '';
                             $xml .= '</merchant-private-item-data>';
                             /**/
                             $xml .= '<digital-content>';
                             $xml .= '<display-disposition>PESSIMISTIC</display-disposition>';
                             /**/
                             if ($attr["referencing"]) {
                                 $xml .= '<description>' . esc_html(sprintf(_x('You\'ve been updated to:<br />%s<br />( <a href="%s">please log back in now</a> )', "s2member-front", "s2member"), $attr["desc"], esc_attr(wp_login_url()))) . '</description>';
                                 $xml .= '<url>' . esc_html(wp_login_url()) . '</url>';
                             } else {
                                 $xml .= '<description>' . esc_html(sprintf(_x('%s<br />( the next step is to Register a Username )', "s2member-front", "s2member"), $attr["desc"])) . '</description>';
                                 $xml .= '<url>' . esc_html($attr["register_access_link"]) . '</url>';
                             }
                             /**/
                             $xml .= '</digital-content>';
                             /**/
                             $xml .= '<subscription type="google" period="' . esc_attr($attr["periodicity"]) . '" start-date="' . esc_attr(date("Y-m-d", $attr["start_time"]) . "T00:00:00Z") . '">';
                             /**/
                             $xml .= '<payments>';
                             $xml .= '<subscription-payment' . (!$attr["rr"] ? ' times="1"' : '') . '>';
                             $xml .= '<maximum-charge currency="' . esc_attr($attr["cc"]) . '">' . esc_html($attr["ra"]) . '</maximum-charge>';
                             $xml .= '</subscription-payment>';
                             $xml .= '</payments>';
                             /**/
                             $xml .= '<recurrent-item>';
                             /**/
                             $xml .= '<quantity>1</quantity>';
                             $xml .= '<item-name>' . esc_html($attr["desc"]) . '</item-name>';
                             $xml .= '<item-description>(SID:s2-' . esc_html($attr["uniqid"]) . ') ' . esc_html(_x("Covers ongoing access.", "s2member-front", "s2member")) . '</item-description>';
                             $xml .= '<unit-price currency="' . esc_attr($attr["cc"]) . '">' . esc_html($attr["ra"]) . '</unit-price>';
                             /**/
                             $xml .= '<merchant-private-item-data>';
                             $xml .= '<s2_subscr_payment>1</s2_subscr_payment>';
                             $xml .= '<s2_subscr_id>s2-' . esc_html($attr["uniqid"]) . '</s2_subscr_id>';
                             $xml .= '<s2_custom>' . esc_html($attr["custom"]) . '</s2_custom>';
                             $xml .= '<s2_customer_ip>' . esc_html($_SERVER["REMOTE_ADDR"]) . '</s2_customer_ip>';
                             $xml .= '<s2_item_number>' . esc_html($attr["level_ccaps_eotper"]) . '</s2_item_number>';
                             $xml .= '<s2_period1>' . esc_html($attr["tp"] . " " . $attr["tt"]) . '</s2_period1>';
                             $xml .= '<s2_period3>' . esc_html($attr["rp"] . " " . $attr["rt"]) . '</s2_period3>';
                             $xml .= $attr["rr"] ? '<s2_recurring>' . esc_html($attr["rr"]) . '</s2_recurring>' : '';
                             $xml .= $attr["referencing"] ? '<s2_referencing>' . esc_html($attr["referencing"]) . '</s2_referencing>' : '';
                             $xml .= '</merchant-private-item-data>';
                             /**/
                             $xml .= '<digital-content>';
                             $xml .= '<display-disposition>PESSIMISTIC</display-disposition>';
                             $xml .= '<description>' . esc_html($attr["desc"]) . '</description>';
                             $xml .= '<url>' . esc_html(home_url("/")) . '</url>';
                             $xml .= '</digital-content>';
                             /**/
                             $xml .= '</recurrent-item>';
                             /**/
                             $xml .= '</subscription>';
                             /**/
                             $xml .= '</item>';
                             /**/
                             $xml .= '</items>';
                             $xml .= '</shopping-cart>';
                             /**/
                             $xml .= '<checkout-flow-support>';
                             $xml .= '<merchant-checkout-flow-support>';
                             $xml .= '<edit-cart-url>' . esc_html(get_page_link($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["membership_options_page"])) . '</edit-cart-url>';
                             $xml .= '<continue-shopping-url>' . esc_html($attr["referencing"] ? wp_login_url() : $attr["register_access_link"]) . '</continue-shopping-url>';
                             $xml .= '</merchant-checkout-flow-support>';
                             $xml .= '</checkout-flow-support>';
                             /**/
                             $xml .= '</checkout-shopping-cart>';
                         } else {
                             if (!$attr["tp"] && $attr["rr"]) {
                                 $attr["start_time"] = c_ws_plugin__optimizemember_pro_google_utilities::google_start_time($attr["rp"] . " " . $attr["rt"]);
                                 /**/
                                 $xml = '<?xml version="1.0" encoding="UTF-8"?>';
                                 $xml .= '<checkout-shopping-cart xmlns="http://checkout.google.com/schema/2">';
                                 $xml .= '<shopping-cart>';
                                 $xml .= '<items>';
                                 /**/
                                 $xml .= '<item>';
                                 /**/
                                 $xml .= '<quantity>1</quantity>';
                                 $xml .= '<item-name>' . esc_html($attr["desc"]) . '</item-name>';
                                 $xml .= '<item-description>(SID:s2-' . esc_html($attr["uniqid"]) . ') ' . esc_html(_x("First payment for immediate access.", "s2member-front", "s2member")) . '</item-description>';
                                 $xml .= '<unit-price currency="' . esc_attr($attr["cc"]) . '">' . esc_html($attr["ra"]) . '</unit-price>';
                                 /**/
                                 $xml .= '<merchant-private-item-data>';
                                 $xml .= '<s2_subscr_id>s2-' . esc_html($attr["uniqid"]) . '</s2_subscr_id>';
                                 $xml .= '<s2_custom>' . esc_html($attr["custom"]) . '</s2_custom>';
                                 $xml .= '<s2_customer_ip>' . esc_html($_SERVER["REMOTE_ADDR"]) . '</s2_customer_ip>';
                                 $xml .= '<s2_item_number>' . esc_html($attr["level_ccaps_eotper"]) . '</s2_item_number>';
                                 $xml .= '<s2_period1>0 D</s2_period1>';
                                 /* There is no Trial Period. */
                                 $xml .= '<s2_period3>' . esc_html($attr["rp"] . " " . $attr["rt"]) . '</s2_period3>';
                                 $xml .= '<s2_recurring>' . esc_html($attr["rr"]) . '</s2_recurring>';
                                 $xml .= $attr["referencing"] ? '<s2_referencing>' . esc_html($attr["referencing"]) . '</s2_referencing>' : '';
                                 $xml .= '</merchant-private-item-data>';
                                 /**/
                                 $xml .= '<digital-content>';
                                 $xml .= '<display-disposition>PESSIMISTIC</display-disposition>';
                                 $xml .= '<description>' . esc_html(_x("You'll receive an email confirmation within 15 minutes.", "s2member-front", "s2member")) . '</description>';
                                 $xml .= '</digital-content>';
                                 /**/
                                 $xml .= '</item>';
                                 /**/
                                 $xml .= '<item>';
                                 /**/
                                 $xml .= '<quantity>1</quantity>';
                                 $xml .= '<item-name>' . esc_html($attr["desc"]) . '</item-name>';
                                 $xml .= '<item-description>(SID:s2-' . esc_html($attr["uniqid"]) . ') ' . esc_html(_x("Cancel at any time to avoid charges.", "s2member-front", "s2member")) . '</item-description>';
                                 $xml .= '<unit-price currency="' . esc_attr($attr["cc"]) . '">0.00</unit-price>';
                                 /**/
                                 $xml .= '<merchant-private-item-data>';
                                 $xml .= '<s2_subscr_id>s2-' . esc_html($attr["uniqid"]) . '</s2_subscr_id>';
                                 $xml .= '<s2_custom>' . esc_html($attr["custom"]) . '</s2_custom>';
                                 $xml .= '<s2_customer_ip>' . esc_html($_SERVER["REMOTE_ADDR"]) . '</s2_customer_ip>';
                                 $xml .= '<s2_item_number>' . esc_html($attr["level_ccaps_eotper"]) . '</s2_item_number>';
                                 $xml .= '<s2_period1>0 D</s2_period1>';
                                 /* There is no Trial Period. */
                                 $xml .= '<s2_period3>' . esc_html($attr["rp"] . " " . $attr["rt"]) . '</s2_period3>';
                                 $xml .= '<s2_recurring>' . esc_html($attr["rr"]) . '</s2_recurring>';
                                 $xml .= $attr["referencing"] ? '<s2_referencing>' . esc_html($attr["referencing"]) . '</s2_referencing>' : '';
                                 $xml .= '</merchant-private-item-data>';
                                 /**/
                                 $xml .= '<digital-content>';
                                 $xml .= '<display-disposition>PESSIMISTIC</display-disposition>';
                                 /**/
                                 if ($attr["referencing"]) {
                                     $xml .= '<description>' . esc_html(sprintf(_x('You\'ve been updated to:<br />%s<br />( <a href="%s">please log back in now</a> )', "s2member-front", "s2member"), $attr["desc"], esc_attr(wp_login_url()))) . '</description>';
                                     $xml .= '<url>' . esc_html(wp_login_url()) . '</url>';
                                 } else {
                                     $xml .= '<description>' . esc_html(sprintf(_x('%s<br />( the next step is to Register a Username )', "s2member-front", "s2member"), $attr["desc"])) . '</description>';
                                     $xml .= '<url>' . esc_html($attr["register_access_link"]) . '</url>';
                                 }
                                 /**/
                                 $xml .= '</digital-content>';
                                 /**/
                                 $xml .= '<subscription type="google" period="' . esc_attr($attr["periodicity"]) . '" start-date="' . esc_attr(date("Y-m-d", $attr["start_time"]) . "T00:00:00Z") . '">';
                                 /**/
                                 $xml .= '<payments>';
                                 $xml .= '<subscription-payment>';
                                 $xml .= '<maximum-charge currency="' . esc_attr($attr["cc"]) . '">' . esc_html($attr["ra"]) . '</maximum-charge>';
                                 $xml .= '</subscription-payment>';
                                 $xml .= '</payments>';
                                 /**/
                                 $xml .= '<recurrent-item>';
                                 /**/
                                 $xml .= '<quantity>1</quantity>';
                                 $xml .= '<item-name>' . esc_html($attr["desc"]) . '</item-name>';
                                 $xml .= '<item-description>(SID:s2-' . esc_html($attr["uniqid"]) . ') ' . esc_html(_x("Covers ongoing access.", "s2member-front", "s2member")) . '</item-description>';
                                 $xml .= '<unit-price currency="' . esc_attr($attr["cc"]) . '">' . esc_html($attr["ra"]) . '</unit-price>';
                                 /**/
                                 $xml .= '<merchant-private-item-data>';
                                 $xml .= '<s2_subscr_payment>1</s2_subscr_payment>';
                                 $xml .= '<s2_subscr_id>s2-' . esc_html($attr["uniqid"]) . '</s2_subscr_id>';
                                 $xml .= '<s2_custom>' . esc_html($attr["custom"]) . '</s2_custom>';
                                 $xml .= '<s2_customer_ip>' . esc_html($_SERVER["REMOTE_ADDR"]) . '</s2_customer_ip>';
                                 $xml .= '<s2_item_number>' . esc_html($attr["level_ccaps_eotper"]) . '</s2_item_number>';
                                 $xml .= '<s2_period1>0 D</s2_period1>';
                                 /* There is no Trial Period. */
                                 $xml .= '<s2_period3>' . esc_html($attr["rp"] . " " . $attr["rt"]) . '</s2_period3>';
                                 $xml .= '<s2_recurring>' . esc_html($attr["rr"]) . '</s2_recurring>';
                                 $xml .= $attr["referencing"] ? '<s2_referencing>' . esc_html($attr["referencing"]) . '</s2_referencing>' : '';
                                 $xml .= '</merchant-private-item-data>';
                                 /**/
                                 $xml .= '<digital-content>';
                                 $xml .= '<display-disposition>PESSIMISTIC</display-disposition>';
                                 $xml .= '<description>' . esc_html($attr["desc"]) . '</description>';
                                 $xml .= '<url>' . esc_html(home_url("/")) . '</url>';
                                 $xml .= '</digital-content>';
                                 /**/
                                 $xml .= '</recurrent-item>';
                                 /**/
                                 $xml .= '</subscription>';
                                 /**/
                                 $xml .= '</item>';
                                 /**/
                                 $xml .= '</items>';
                                 $xml .= '</shopping-cart>';
                                 /**/
                                 $xml .= '<checkout-flow-support>';
                                 $xml .= '<merchant-checkout-flow-support>';
                                 $xml .= '<edit-cart-url>' . esc_html(get_page_link($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["membership_options_page"])) . '</edit-cart-url>';
                                 $xml .= '<continue-shopping-url>' . esc_html($attr["referencing"] ? wp_login_url() : $attr["register_access_link"]) . '</continue-shopping-url>';
                                 $xml .= '</merchant-checkout-flow-support>';
                                 $xml .= '</checkout-flow-support>';
                                 /**/
                                 $xml .= '</checkout-shopping-cart>';
                             }
                         }
                         /**/
                         $endpoint = $GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["pro_google_sandbox"] ? "sandbox.google.com/checkout" : "checkout.google.com";
                         /**/
                         if (($xml = c_ws_plugin__optimizemember_utils_urls::remote("https://" . $endpoint . "/api/checkout/v2/merchantCheckout/Merchant/" . $GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["pro_google_merchant_id"], $xml, array_merge(c_ws_plugin__optimizemember_pro_google_utilities::google_api_headers(), array("timeout" => 20)))) && preg_match("/\\<redirect-url\\>(.+?)\\<\\/redirect-url\\>/i", preg_replace("/[\r\n\t]+/", "", $xml), $m) && ($google = $m[1])) {
                             wp_redirect(wp_specialchars_decode($google, ENT_QUOTES));
                         } else {
                             /* Display error message. */
                             echo strip_tags($xml);
                         }
                     }
                 }
             }
         }
         /**/
         exit;
         /* Clean exit. */
     }
 }
 /**
  * Shortcode `[optimizeMember-Pro-Stripe-Form /]`.
  *
  * @package optimizeMember\Stripe
  * @since 140617
  *
  * @attaches-to ``add_shortcode('optimizeMember-Pro-Stripe-Form');``
  *
  * @param array  $attr An array of Attributes.
  * @param string $content Content inside the Shortcode.
  * @param string $shortcode The actual Shortcode name itself.
  *
  * @return string The resulting Form Code, HTML markup.
  */
 public static function sc_stripe_form($attr, $content = '', $shortcode = '')
 {
     $raw_content = $content;
     foreach (array_keys(get_defined_vars()) as $__v) {
         $__refs[$__v] =& ${$__v};
     }
     do_action('ws_plugin__optimizemember_pro_before_sc_stripe_form', get_defined_vars());
     unset($__refs, $__v);
     // Ditch these temporary vars.
     c_ws_plugin__optimizemember_no_cache::no_cache_constants(TRUE);
     $attr = c_ws_plugin__optimizemember_utils_strings::trim_qts_deep((array) $attr);
     $options = array();
     // Initialize options to an empty array.
     $option_selections = '';
     // Initialize w/ no options.
     if ($content && ($content = strip_tags($content))) {
         // This allows for nested Pro Form Shortcodes as options.
         $content = str_replace('optimizeMember-Pro-Stripe-Form ', 'optimizeMember-Pro-Stripe-xFormOption ', $content);
     }
     if ($content && ($content_options = do_shortcode($content))) {
         foreach (preg_split('/\\s*\\|\\:\\:\\|\\s*/', $content_options, NULL, PREG_SPLIT_NO_EMPTY) as $_content_option_key => $_content_option) {
             $_content_option_id = $_content_option_key + 1;
             $options[$_content_option_id] = maybe_unserialize(trim($_content_option));
             if (!is_array($options[$_content_option_id])) {
                 unset($options[$_content_option_id]);
                 continue;
                 // Invalid option.
             }
             if (!empty($_REQUEST['s2p-option']) && (int) $_REQUEST['s2p-option'] === $_content_option_id) {
                 $options[$_content_option_id]['selected'] = TRUE;
             }
         }
         unset($_content_option_key, $_content_option, $_content_option_id);
         // Housekeeping.
         foreach ($options as $_option_id => $_option) {
             if (!empty($_option['selected'])) {
                 $attr = array_merge($attr, $_option);
                 $_selected_option_id = $_option_id;
             }
         }
         unset($_option_id, $_option);
         // Housekeeping.
         if (empty($_selected_option_id)) {
             foreach ($options as $_option_id => $_option) {
                 $attr = array_merge($attr, $_option);
                 break;
                 // Force a selected option (default).
             }
         }
         unset($_option_id, $_option, $_selected_option_id);
         // Housekeeping.
         foreach ($options as $_option_id => $_option) {
             // Build option selections.
             $option_selections .= '<option value="' . esc_attr($_option_id) . '"' . (!empty($_option['selected']) ? ' selected="selected"' : '') . '>' . esc_html($_option['desc']) . '</option>';
         }
         unset($_option_id, $_option);
         // Housekeeping.
     }
     $attr = shortcode_atts(array('ids' => '0', 'exp' => '72', 'level' => @$attr['register'] ? '0' : '1', 'ccaps' => '', 'desc' => '', 'cc' => 'USD', 'custom' => $_SERVER['HTTP_HOST'], 'ta' => '0', 'tp' => '0', 'tt' => 'D', 'ra' => '0.01', 'rp' => '1', 'rt' => 'M', 'rr' => '1', 'rrt' => '', 'modify' => '0', 'cancel' => '0', 'sp' => '0', 'register' => '0', 'update' => '0', 'coupon' => '', 'accept_coupons' => '0', 'default_country_code' => 'US', 'captcha' => '', 'template' => '', 'success' => ''), $attr);
     $attr['tt'] = strtoupper($attr['tt']);
     // Term lengths absolutely must be provided in upper-case format. Only after running shortcode_atts().
     $attr['rt'] = strtoupper($attr['rt']);
     // Term lengths absolutely must be provided in upper-case format. Only after running shortcode_atts().
     $attr['rr'] = strtoupper($attr['rr']);
     // Must be provided in upper-case format. Numerical, or BN value. Only after running shortcode_atts().
     $attr['ccaps'] = strtolower($attr['ccaps']);
     // Custom Capabilities must be typed in lower-case format. Only after running shortcode_atts().
     $attr['ccaps'] = str_replace(' ', '', $attr['ccaps']);
     // Custom Capabilities should not have spaces.
     $attr['rr'] = $attr['rt'] === 'L' ? 'BN' : $attr['rr'];
     // Lifetime Subscriptions require Buy Now. Only after running shortcode_atts().
     $attr['rr'] = $attr['level'] === '*' ? 'BN' : $attr['rr'];
     // Independent Ccaps require Buy Now. Only after running shortcode_atts().
     $attr['rr'] = !$attr['tp'] && !$attr['rr'] ? 'BN' : $attr['rr'];
     // No Trial / non-recurring. Only after running shortcode_atts().
     $attr['default_country_code'] = strtoupper($attr['default_country_code']);
     // This MUST be in uppercase format.
     $attr['success'] = c_ws_plugin__optimizemember_utils_urls::n_amps($attr['success']);
     // Normalize ampersands.
     $attr['coupon'] = !empty($_GET['s2p-coupon']) ? trim(strip_tags(stripslashes($_GET['s2p-coupon']))) : $attr['coupon'];
     $attr['singular'] = get_the_ID();
     // Collect the Singular ID for this Post/Page.
     foreach (array_keys(get_defined_vars()) as $__v) {
         $__refs[$__v] =& ${$__v};
     }
     do_action('ws_plugin__optimizemember_pro_before_sc_stripe_form_after_shortcode_atts', get_defined_vars());
     unset($__refs, $__v);
     // Ditch these temporary vars.
     if ($attr['cancel']) {
         $_p = c_ws_plugin__optimizemember_utils_strings::trim_deep(stripslashes_deep($_POST));
         $response = c_ws_plugin__optimizemember_pro_stripe_responses::stripe_cancellation_response($attr);
         $_p = $response['response'] && !$response['error'] ? array() : $_p;
         if ($attr['captcha']) {
             $captcha = '<div id="optimizemember-pro-stripe-cancellation-form-captcha-section" class="optimizemember-pro-stripe-form-section optimizemember-pro-stripe-cancellation-form-section optimizemember-pro-stripe-form-captcha-section optimizemember-pro-stripe-cancellation-form-captcha-section">' . "\n";
             $captcha .= '<div id="optimizemember-pro-stripe-cancellation-form-captcha-section-title" class="optimizemember-pro-stripe-form-section-title optimizemember-pro-stripe-cancellation-form-section-title optimizemember-pro-stripe-form-captcha-section-title optimizemember-pro-stripe-cancellation-form-captcha-section-title">' . "\n";
             $captcha .= _x('Security Code', 's2member-front', 's2member') . "\n";
             $captcha .= '</div>' . "\n";
             $captcha .= '<div id="optimizemember-pro-stripe-cancellation-form-captcha-div" class="optimizemember-pro-stripe-form-div optimizemember-pro-stripe-cancellation-form-div optimizemember-pro-stripe-form-captcha-div optimizemember-pro-stripe-cancellation-form-captcha-div">' . "\n";
             $captcha .= '<label id="optimizemember-pro-stripe-cancellation-form-captcha-label" class="optimizemember-pro-stripe-form-captcha-label optimizemember-pro-stripe-cancellation-form-captcha-label">' . "\n";
             $captcha .= c_ws_plugin__optimizemember_utils_captchas::recaptcha_script_tag($attr['captcha'], 10) . "\n";
             $captcha .= '</label>' . "\n";
             $captcha .= '</div>' . "\n";
             $captcha .= '</div>' . "\n";
         } else {
             $captcha = '';
         }
         // Not applicable.
         $hidden_inputs = '<input type="hidden" name="optimizemember_pro_stripe_cancellation[nonce]" id="optimizemember-pro-stripe-cancellation-nonce" value="' . esc_attr(wp_create_nonce('optimizemember-pro-stripe-cancellation')) . '" />';
         $hidden_inputs .= '<input type="hidden" name="optimizemember_pro_stripe_cancellation[attr]" id="optimizemember-pro-stripe-cancellation-attr" value="' . esc_attr(c_ws_plugin__optimizemember_utils_encryption::encrypt(serialize($attr))) . '" />';
         $hidden_inputs .= '<input type="hidden" name="s2p-option" value="' . esc_attr((string) @$_REQUEST['s2p-option']) . '" />';
         $custom_template = file_exists(TEMPLATEPATH . '/stripe-cancellation-form.php') ? TEMPLATEPATH . '/stripe-cancellation-form.php' : FALSE;
         $custom_template = file_exists(TEMPLATEPATH . '/stripe-cancellation-form.html') ? TEMPLATEPATH . '/stripe-cancellation-form.html' : $custom_template;
         $custom_template = $attr['template'] && file_exists(TEMPLATEPATH . '/' . $attr['template']) ? TEMPLATEPATH . '/' . $attr['template'] : $custom_template;
         $custom_template = $attr['template'] && file_exists(WP_CONTENT_DIR . '/' . $attr['template']) ? WP_CONTENT_DIR . '/' . $attr['template'] : $custom_template;
         $code = trim(file_get_contents($custom_template ? $custom_template : dirname(dirname(dirname(dirname(__FILE__)))) . '/templates/forms/stripe-cancellation-form.php'));
         $code = trim(!$custom_template || !is_multisite() || !c_ws_plugin__optimizemember_utils_conds::is_multisite_farm() || is_main_site() ? c_ws_plugin__optimizemember_utilities::evl($code) : $code);
         $code = preg_replace('/%%action%%/', c_ws_plugin__optimizemember_utils_strings::esc_refs(esc_attr($_SERVER['REQUEST_URI'])), $code);
         $code = preg_replace('/%%response%%/', c_ws_plugin__optimizemember_utils_strings::esc_refs($response['response']), $code);
         $code = preg_replace('/%%description%%/', c_ws_plugin__optimizemember_utils_strings::esc_refs($attr['desc']), $code);
         $code = preg_replace('/%%captcha%%/', c_ws_plugin__optimizemember_utils_strings::esc_refs($captcha), $code);
         $code = preg_replace('/%%hidden_inputs%%/', c_ws_plugin__optimizemember_utils_strings::esc_refs($hidden_inputs), $code);
         foreach (array_keys(get_defined_vars()) as $__v) {
             $__refs[$__v] =& ${$__v};
         }
         do_action('ws_plugin__optimizemember_pro_during_sc_stripe_cancellation_form', get_defined_vars());
         unset($__refs, $__v);
         // Ditch these temporary vars.
     } else {
         if ($attr['register']) {
             $_p = c_ws_plugin__optimizemember_utils_strings::trim_deep(stripslashes_deep($_POST));
             $response = c_ws_plugin__optimizemember_pro_stripe_responses::stripe_registration_response($attr);
             $_p = $response['response'] && !$response['error'] ? array() : $_p;
             $custom_fields = '';
             // Initialize custom fields.
             if ($GLOBALS['WS_PLUGIN__']['optimizemember']['o']['custom_reg_fields']) {
                 // Only display Custom Fields if configured.
                 if ($fields_applicable = c_ws_plugin__optimizemember_custom_reg_fields::custom_fields_configured_at_level($attr['level'], 'registration')) {
                     $tabindex = 99;
                     // Start tabindex at 99 ( +1 below = 100 ).
                     $custom_fields = '<div id="optimizemember-pro-stripe-registration-form-custom-fields-section" class="optimizemember-pro-stripe-form-section optimizemember-pro-stripe-registration-form-section optimizemember-pro-stripe-form-custom-fields-section optimizemember-pro-stripe-registration-form-custom-fields-section">' . "\n";
                     $custom_fields .= '<div id="optimizemember-pro-stripe-registration-form-custom-fields-section-title" class="optimizemember-pro-stripe-form-section-title optimizemember-pro-stripe-registration-form-section-title optimizemember-pro-stripe-form-custom-fields-section-title optimizemember-pro-stripe-registration-form-custom-fields-section-title">' . "\n";
                     $custom_fields .= _x('Additional Info', 's2member-front', 's2member') . "\n";
                     $custom_fields .= '</div>' . "\n";
                     foreach (json_decode($GLOBALS['WS_PLUGIN__']['optimizemember']['o']['custom_reg_fields'], TRUE) as $field) {
                         if (in_array($field['id'], $fields_applicable)) {
                             $field_var = preg_replace('/[^a-z0-9]/i', '_', strtolower($field['id']));
                             $field_id_class = preg_replace('/_/', '-', $field_var);
                             if (!empty($field['section']) && $field['section'] === 'yes') {
                                 // Starts a new section?
                                 $custom_fields .= '<div id="optimizemember-pro-stripe-registration-form-custom-reg-field-' . $field_id_class . '-divider-section" class="optimizemember-pro-stripe-form-div optimizemember-pro-stripe-registration-form-div optimizemember-pro-stripe-form-custom-reg-field-divider-section' . (!empty($field['sectitle']) ? '-title' : '') . ' optimizemember-pro-stripe-form-custom-reg-field-' . $field_id_class . '-divider-section' . (!empty($field['sectitle']) ? '-title' : '') . ' optimizemember-pro-stripe-registration-form-custom-reg-field-' . $field_id_class . '-divider-section' . (!empty($field['sectitle']) ? '-title' : '') . '">' . (!empty($field['sectitle']) ? $field['sectitle'] : '') . '</div>';
                             }
                             $custom_fields .= '<div id="optimizemember-pro-stripe-registration-form-custom-reg-field-' . $field_id_class . '-div" class="optimizemember-pro-stripe-form-div optimizemember-pro-stripe-registration-form-div optimizemember-pro-stripe-form-custom-reg-field-' . $field_id_class . '-div optimizemember-pro-stripe-registration-form-custom-reg-field-' . $field_id_class . '-div">' . "\n";
                             $custom_fields .= '<label for="optimizemember-pro-stripe-registration-custom-reg-field-' . esc_attr($field_id_class) . '" id="optimizemember-pro-stripe-registration-form-custom-reg-field-' . $field_id_class . '-label" class="optimizemember-pro-stripe-form-custom-reg-field-' . $field_id_class . '-label optimizemember-pro-stripe-registration-form-custom-reg-field-' . $field_id_class . '-label">' . "\n";
                             $custom_fields .= '<span' . (preg_match('/^(checkbox|pre_checkbox)$/', $field['type']) ? ' style="display:none;"' : '') . '>' . $field['label'] . ($field['required'] === 'yes' ? ' *' : '') . '</span></label>' . (preg_match('/^(checkbox|pre_checkbox)$/', $field['type']) ? '' : '<br />') . "\n";
                             $custom_fields .= c_ws_plugin__optimizemember_custom_reg_fields::custom_field_gen(__FUNCTION__, $field, 'optimizemember_pro_stripe_registration[custom_fields][', 'optimizemember-pro-stripe-registration-custom-reg-field-', 'optimizemember-pro-stripe-custom-reg-field-' . $field_id_class . ' optimizemember-pro-stripe-registration-custom-reg-field-' . $field_id_class, '', $tabindex = $tabindex + 1, '', $_p, @$_p['optimizemember_pro_stripe_registration']['custom_fields'][$field_var], 'registration');
                             $custom_fields .= '</div>' . "\n";
                         }
                     }
                     $custom_fields .= '</div>' . "\n";
                 }
             }
             if ($attr['captcha']) {
                 $captcha = '<div id="optimizemember-pro-stripe-registration-form-captcha-section" class="optimizemember-pro-stripe-form-section optimizemember-pro-stripe-registration-form-section optimizemember-pro-stripe-form-captcha-section optimizemember-pro-stripe-registration-form-captcha-section">' . "\n";
                 $captcha .= '<div id="optimizemember-pro-stripe-registration-form-captcha-section-title" class="optimizemember-pro-stripe-form-section-title optimizemember-pro-stripe-registration-form-section-title optimizemember-pro-stripe-form-captcha-section-title optimizemember-pro-stripe-registration-form-captcha-section-title">' . "\n";
                 $captcha .= _x('Security Code', 's2member-front', 's2member') . "\n";
                 $captcha .= '</div>' . "\n";
                 $captcha .= '<div id="optimizemember-pro-stripe-registration-form-captcha-div" class="optimizemember-pro-stripe-form-div optimizemember-pro-stripe-registration-form-div optimizemember-pro-stripe-form-captcha-div optimizemember-pro-stripe-registration-form-captcha-div">' . "\n";
                 $captcha .= '<label id="optimizemember-pro-stripe-registration-form-captcha-label" class="optimizemember-pro-stripe-form-captcha-label optimizemember-pro-stripe-registration-form-captcha-label">' . "\n";
                 $captcha .= c_ws_plugin__optimizemember_utils_captchas::recaptcha_script_tag($attr['captcha'], 200) . "\n";
                 $captcha .= '</label>' . "\n";
                 $captcha .= '</div>' . "\n";
                 $captcha .= '</div>' . "\n";
             } else {
                 $captcha = '';
             }
             // Not applicable.
             if ($GLOBALS['WS_PLUGIN__']['optimizemember']['o']['custom_reg_opt_in'] && c_ws_plugin__optimizemember_list_servers::list_servers_integrated()) {
                 $opt_in = '<div id="optimizemember-pro-stripe-registration-form-custom-reg-field-opt-in-div" class="optimizemember-pro-stripe-form-div optimizemember-pro-stripe-registration-form-div optimizemember-pro-stripe-form-custom-reg-field-opt-in-div optimizemember-pro-stripe-registration-form-custom-reg-field-opt-in-div">' . "\n";
                 $opt_in .= '<label for="optimizemember-pro-stripe-registration-form-custom-reg-field-opt-in" id="optimizemember-pro-stripe-registration-form-custom-reg-field-opt-in-label" class="optimizemember-pro-stripe-form-custom-reg-field-opt-in-label optimizemember-pro-stripe-registration-form-custom-reg-field-opt-in-label">' . "\n";
                 $opt_in .= '<input type="checkbox" name="optimizemember_pro_stripe_registration[custom_fields][opt_in]" id="optimizemember-pro-stripe-registration-form-custom-reg-field-opt-in" class="optimizemember-pro-stripe-form-custom-reg-field-opt-in optimizemember-pro-stripe-registration-form-custom-reg-field-opt-in" value="1"' . (empty($_p) && $GLOBALS['WS_PLUGIN__']['optimizemember']['o']['custom_reg_opt_in'] == 1 || @$_p['optimizemember_pro_stripe_registration']['custom_fields']['opt_in'] ? ' checked="checked"' : '') . ' tabindex="300" />' . "\n";
                 $opt_in .= $GLOBALS['WS_PLUGIN__']['optimizemember']['o']['custom_reg_opt_in_label'] . "\n";
                 $opt_in .= '</label>' . '\\n';
                 $opt_in .= '</div>' . '\\n';
             } else {
                 $opt_in = '';
             }
             // Not applicable.
             $hidden_inputs = '<input type="hidden" name="optimizemember_pro_stripe_registration[nonce]" id="optimizemember-pro-stripe-registration-nonce" value="' . esc_attr(wp_create_nonce('optimizemember-pro-stripe-registration')) . '" />';
             $hidden_inputs .= !$GLOBALS['WS_PLUGIN__']['optimizemember']['o']['custom_reg_names'] ? '<input type="hidden" id="optimizemember-pro-stripe-registration-names-not-required-or-not-possible" value="1" />' : '';
             $hidden_inputs .= !$GLOBALS['WS_PLUGIN__']['optimizemember']['o']['custom_reg_password'] ? '<input type="hidden" id="optimizemember-pro-stripe-registration-password-not-required-or-not-possible" value="1" />' : '';
             $hidden_inputs .= '<input type="hidden" name="optimizemember_pro_stripe_registration[attr]" id="optimizemember-pro-stripe-registration-attr" value="' . esc_attr(c_ws_plugin__optimizemember_utils_encryption::encrypt(serialize($attr))) . '" />';
             $hidden_inputs .= '<input type="hidden" name="s2p-option" value="' . esc_attr((string) @$_REQUEST['s2p-option']) . '" />';
             $custom_template = file_exists(TEMPLATEPATH . '/stripe-registration-form.php') ? TEMPLATEPATH . '/stripe-registration-form.php' : FALSE;
             $custom_template = file_exists(TEMPLATEPATH . '/stripe-registration-form.html') ? TEMPLATEPATH . '/stripe-registration-form.html' : $custom_template;
             $custom_template = $attr['template'] && file_exists(TEMPLATEPATH . '/' . $attr['template']) ? TEMPLATEPATH . '/' . $attr['template'] : $custom_template;
             $custom_template = $attr['template'] && file_exists(WP_CONTENT_DIR . '/' . $attr['template']) ? WP_CONTENT_DIR . '/' . $attr['template'] : $custom_template;
             $code = trim(file_get_contents($custom_template ? $custom_template : dirname(dirname(dirname(dirname(__FILE__)))) . '/templates/forms/stripe-registration-form.php'));
             $code = trim(!$custom_template || !is_multisite() || !c_ws_plugin__optimizemember_utils_conds::is_multisite_farm() || is_main_site() ? c_ws_plugin__optimizemember_utilities::evl($code) : $code);
             $code = preg_replace('/%%action%%/', c_ws_plugin__optimizemember_utils_strings::esc_refs(esc_attr($_SERVER['REQUEST_URI'])), $code);
             $code = preg_replace('/%%response%%/', c_ws_plugin__optimizemember_utils_strings::esc_refs($response['response']), $code);
             $code = preg_replace('/%%options%%/', c_ws_plugin__optimizemember_utils_strings::esc_refs($option_selections), $code);
             $code = preg_replace('/%%description%%/', c_ws_plugin__optimizemember_utils_strings::esc_refs($attr['desc']), $code);
             $code = preg_replace('/%%first_name_value%%/', c_ws_plugin__optimizemember_utils_strings::esc_refs(esc_attr(@$_p['optimizemember_pro_stripe_registration']['first_name'])), $code);
             $code = preg_replace('/%%last_name_value%%/', c_ws_plugin__optimizemember_utils_strings::esc_refs(esc_attr(@$_p['optimizemember_pro_stripe_registration']['last_name'])), $code);
             $code = preg_replace('/%%email_value%%/', c_ws_plugin__optimizemember_utils_strings::esc_refs(format_to_edit(@$_p['optimizemember_pro_stripe_registration']['email'])), $code);
             $code = preg_replace('/%%username_value%%/', c_ws_plugin__optimizemember_utils_strings::esc_refs(format_to_edit(@$_p['optimizemember_pro_stripe_registration']['username'])), $code);
             $code = preg_replace('/%%password1_value%%/', c_ws_plugin__optimizemember_utils_strings::esc_refs(format_to_edit(@$_p['optimizemember_pro_stripe_registration']['password1'])), $code);
             $code = preg_replace('/%%password2_value%%/', c_ws_plugin__optimizemember_utils_strings::esc_refs(format_to_edit(@$_p['optimizemember_pro_stripe_registration']['password2'])), $code);
             $code = preg_replace('/%%custom_fields%%/', c_ws_plugin__optimizemember_utils_strings::esc_refs($custom_fields), $code);
             $code = preg_replace('/%%captcha%%/', c_ws_plugin__optimizemember_utils_strings::esc_refs($captcha), $code);
             $code = preg_replace('/%%opt_in%%/', c_ws_plugin__optimizemember_utils_strings::esc_refs($opt_in), $code);
             $code = preg_replace('/%%hidden_inputs%%/', c_ws_plugin__optimizemember_utils_strings::esc_refs($hidden_inputs), $code);
             foreach (array_keys(get_defined_vars()) as $__v) {
                 $__refs[$__v] =& ${$__v};
             }
             do_action('ws_plugin__optimizemember_pro_during_sc_stripe_registration_form', get_defined_vars());
             unset($__refs, $__v);
             // Ditch these temporary vars.
         } else {
             if ($attr['update']) {
                 $_p = c_ws_plugin__optimizemember_utils_strings::trim_deep(stripslashes_deep($_POST));
                 $response = c_ws_plugin__optimizemember_pro_stripe_responses::stripe_update_response($attr);
                 $_p = $response['response'] && !$response['error'] ? array() : $_p;
                 if ($attr['captcha']) {
                     $captcha = '<div id="optimizemember-pro-stripe-update-form-captcha-section" class="optimizemember-pro-stripe-form-section optimizemember-pro-stripe-update-form-section optimizemember-pro-stripe-form-captcha-section optimizemember-pro-stripe-update-form-captcha-section">' . "\n";
                     $captcha .= '<div id="optimizemember-pro-stripe-update-form-captcha-section-title" class="optimizemember-pro-stripe-form-section-title optimizemember-pro-stripe-update-form-section-title optimizemember-pro-stripe-form-captcha-section-title optimizemember-pro-stripe-update-form-captcha-section-title">' . "\n";
                     $captcha .= _x('Security Code', 's2member-front', 's2member') . "\n";
                     $captcha .= '</div>' . "\n";
                     $captcha .= '<div id="optimizemember-pro-stripe-update-form-captcha-div" class="optimizemember-pro-stripe-form-div optimizemember-pro-stripe-update-form-div optimizemember-pro-stripe-form-captcha-div optimizemember-pro-stripe-update-form-captcha-div">' . "\n";
                     $captcha .= '<label id="optimizemember-pro-stripe-update-form-captcha-label" class="optimizemember-pro-stripe-form-captcha-label optimizemember-pro-stripe-update-form-captcha-label">' . "\n";
                     $captcha .= c_ws_plugin__optimizemember_utils_captchas::recaptcha_script_tag($attr['captcha'], 200) . "\n";
                     $captcha .= '</label>' . "\n";
                     $captcha .= '</div>' . "\n";
                     $captcha .= '</div>' . "\n";
                 } else {
                     $captcha = '';
                 }
                 // Not applicable.
                 $hidden_inputs = '<input type="hidden" name="optimizemember_pro_stripe_update[nonce]" id="optimizemember-pro-stripe-update-nonce" value="' . esc_attr(wp_create_nonce('optimizemember-pro-stripe-update')) . '" />';
                 $hidden_inputs .= '<input type="hidden" name="optimizemember_pro_stripe_update[card_token]" id="optimizemember-pro-stripe-update-card-token" value="' . esc_attr(@$_p['optimizemember_pro_stripe_update']['card_token']) . '" />';
                 $hidden_inputs .= '<input type="hidden" name="optimizemember_pro_stripe_update[card_token_summary]" id="optimizemember-pro-stripe-update-card-token-summary" value="' . esc_attr(@$_p['optimizemember_pro_stripe_update']['card_token_summary']) . '" />';
                 $hidden_inputs .= '<input type="hidden" name="optimizemember_pro_stripe_update[attr]" id="optimizemember-pro-stripe-update-attr" value="' . esc_attr(c_ws_plugin__optimizemember_utils_encryption::encrypt(serialize($attr))) . '" />';
                 $hidden_inputs .= '<input type="hidden" name="s2p-option" value="' . esc_attr((string) @$_REQUEST['s2p-option']) . '" />';
                 $custom_template = file_exists(TEMPLATEPATH . '/stripe-update-form.php') ? TEMPLATEPATH . '/stripe-update-form.php' : FALSE;
                 $custom_template = file_exists(TEMPLATEPATH . '/stripe-update-form.html') ? TEMPLATEPATH . '/stripe-update-form.html' : $custom_template;
                 $custom_template = $attr['template'] && file_exists(TEMPLATEPATH . '/' . $attr['template']) ? TEMPLATEPATH . '/' . $attr['template'] : $custom_template;
                 $custom_template = $attr['template'] && file_exists(WP_CONTENT_DIR . '/' . $attr['template']) ? WP_CONTENT_DIR . '/' . $attr['template'] : $custom_template;
                 $code = trim(file_get_contents($custom_template ? $custom_template : dirname(dirname(dirname(dirname(__FILE__)))) . '/templates/forms/stripe-update-form.php'));
                 $code = trim(!$custom_template || !is_multisite() || !c_ws_plugin__optimizemember_utils_conds::is_multisite_farm() || is_main_site() ? c_ws_plugin__optimizemember_utilities::evl($code) : $code);
                 $code = preg_replace('/%%action%%/', c_ws_plugin__optimizemember_utils_strings::esc_refs(esc_attr($_SERVER['REQUEST_URI'])), $code);
                 $code = preg_replace('/%%response%%/', c_ws_plugin__optimizemember_utils_strings::esc_refs($response['response']), $code);
                 $code = preg_replace('/%%description%%/', c_ws_plugin__optimizemember_utils_strings::esc_refs($attr['desc']), $code);
                 $code = preg_replace('/%%card_token%%/', c_ws_plugin__optimizemember_utils_strings::esc_refs(esc_html(@$_p['optimizemember_pro_stripe_update']['card_token'])), $code);
                 $code = preg_replace('/%%card_token_summary%%/', c_ws_plugin__optimizemember_utils_strings::esc_refs(esc_html(@$_p['optimizemember_pro_stripe_update']['card_token_summary'])), $code);
                 $code = preg_replace('/%%captcha%%/', c_ws_plugin__optimizemember_utils_strings::esc_refs($captcha), $code);
                 $code = preg_replace('/%%hidden_inputs%%/', c_ws_plugin__optimizemember_utils_strings::esc_refs($hidden_inputs), $code);
                 foreach (array_keys(get_defined_vars()) as $__v) {
                     $__refs[$__v] =& ${$__v};
                 }
                 do_action('ws_plugin__optimizemember_pro_during_sc_stripe_update_form', get_defined_vars());
                 unset($__refs, $__v);
                 // Ditch these temporary vars.
             } else {
                 if ($attr['sp']) {
                     $_p = c_ws_plugin__optimizemember_utils_strings::trim_deep(stripslashes_deep($_POST));
                     $attr['sp_ids_exp'] = 'sp:' . $attr['ids'] . ':' . $attr['exp'];
                     // Combined `sp:ids:expiration hours`.
                     $attr['coupon'] = !empty($_p['optimizemember_pro_stripe_sp_checkout']['coupon']) ? $_p['optimizemember_pro_stripe_sp_checkout']['coupon'] : $attr['coupon'];
                     $response = c_ws_plugin__optimizemember_pro_stripe_responses::stripe_sp_checkout_response($attr);
                     $_p = $response['response'] && !$response['error'] ? array() : $_p;
                     $country_default_by_currency = !@$_p['optimizemember_pro_stripe_sp_checkout']['country'] && $attr['cc'] === 'USD' ? 'US' : '';
                     $country_default_by_currency = !@$_p['optimizemember_pro_stripe_sp_checkout']['country'] && $attr['cc'] === 'CAD' ? 'CA' : $country_default_by_currency;
                     $country_default_by_currency = !@$_p['optimizemember_pro_stripe_sp_checkout']['country'] && $attr['cc'] === 'GBP' ? 'GB' : $country_default_by_currency;
                     $country_default_by_currency = apply_filters('ws_plugin__optimizemember_pro_stripe_default_country', $country_default_by_currency, get_defined_vars());
                     $default_country_v = $attr['default_country_code'] ? $attr['default_country_code'] : $country_default_by_currency;
                     $country_options = '<option value=""></option>';
                     // Start with an empty option value.
                     foreach (preg_split('/[' . "\r\n" . ']+/', file_get_contents(dirname(dirname(dirname(dirname(__FILE__)))) . '/iso-3166-1.txt')) as $country) {
                         list($country_l, $country_v) = preg_split('/;/', $country, 2);
                         if ($country_l && $country_v) {
                             // Here we also check on the default pre-selected country; as determined above; based on currency.
                             $country_options .= '<option value="' . esc_attr(strtoupper($country_v)) . '"' . (@$_p['optimizemember_pro_stripe_sp_checkout']['country'] === $country_v || $default_country_v === $country_v ? ' selected="selected"' : '') . '>' . esc_html(ucwords(strtolower($country_l))) . '</option>';
                         }
                     }
                     if ($attr['captcha']) {
                         $captcha = '<div id="optimizemember-pro-stripe-sp-checkout-form-captcha-section" class="optimizemember-pro-stripe-form-section optimizemember-pro-stripe-sp-checkout-form-section optimizemember-pro-stripe-form-captcha-section optimizemember-pro-stripe-sp-checkout-form-captcha-section">' . "\n";
                         $captcha .= '<div id="optimizemember-pro-stripe-sp-checkout-form-captcha-section-title" class="optimizemember-pro-stripe-form-section-title optimizemember-pro-stripe-sp-checkout-form-section-title optimizemember-pro-stripe-form-captcha-section-title optimizemember-pro-stripe-sp-checkout-form-captcha-section-title">' . "\n";
                         $captcha .= _x('Security Code', 's2member-front', 's2member') . "\n";
                         $captcha .= '</div>' . "\n";
                         $captcha .= '<div id="optimizemember-pro-stripe-sp-checkout-form-captcha-div" class="optimizemember-pro-stripe-form-div optimizemember-pro-stripe-sp-checkout-form-div optimizemember-pro-stripe-form-captcha-div optimizemember-pro-stripe-sp-checkout-form-captcha-div">' . "\n";
                         $captcha .= '<label id="optimizemember-pro-stripe-sp-checkout-form-captcha-label" class="optimizemember-pro-stripe-form-captcha-label optimizemember-pro-stripe-sp-checkout-form-captcha-label">' . "\n";
                         $captcha .= c_ws_plugin__optimizemember_utils_captchas::recaptcha_script_tag($attr['captcha'], 300) . "\n";
                         $captcha .= '</label>' . "\n";
                         $captcha .= '</div>' . "\n";
                         $captcha .= '</div>' . "\n";
                     } else {
                         $captcha = '';
                     }
                     // Not applicable.
                     /*
                     Build the opt-in checkbox.
                     */
                     if ($GLOBALS['WS_PLUGIN__']['optimizemember']['o']['custom_reg_opt_in'] && c_ws_plugin__optimizemember_list_servers::list_servers_integrated()) {
                         $opt_in = '<div id="optimizemember-pro-stripe-sp-checkout-form-custom-reg-field-opt-in-div" class="optimizemember-pro-stripe-form-div optimizemember-pro-stripe-sp-checkout-form-div optimizemember-pro-stripe-form-custom-reg-field-opt-in-div optimizemember-pro-stripe-sp-checkout-form-custom-reg-field-opt-in-div">' . "\n";
                         $opt_in .= '<label for="optimizemember-pro-stripe-sp-checkout-form-custom-reg-field-opt-in" id="optimizemember-pro-stripe-sp-checkout-form-custom-reg-field-opt-in-label" class="optimizemember-pro-stripe-form-custom-reg-field-opt-in-label optimizemember-pro-stripe-sp-checkout-form-custom-reg-field-opt-in-label">' . "\n";
                         $opt_in .= '<input type="checkbox" name="optimizemember_pro_stripe_sp_checkout[custom_fields][opt_in]" id="optimizemember-pro-stripe-sp-checkout-form-custom-reg-field-opt-in" class="optimizemember-pro-stripe-form-custom-reg-field-opt-in optimizemember-pro-stripe-sp-checkout-form-custom-reg-field-opt-in" value="1"' . (empty($_p) && $GLOBALS['WS_PLUGIN__']['optimizemember']['o']['custom_reg_opt_in'] == 1 || @$_p['optimizemember_pro_stripe_sp_checkout']['custom_fields']['opt_in'] ? ' checked="checked"' : '') . ' tabindex="400" />' . "\n";
                         $opt_in .= $GLOBALS['WS_PLUGIN__']['optimizemember']['o']['custom_reg_opt_in_label'] . "\n";
                         $opt_in .= '</label>' . "\n";
                         $opt_in .= '</div>' . "\n";
                     } else {
                         $opt_in = '';
                     }
                     // Not applicable.
                     $hidden_inputs = '<input type="hidden" name="optimizemember_pro_stripe_sp_checkout[nonce]" id="optimizemember-pro-stripe-sp-checkout-nonce" value="' . esc_attr(wp_create_nonce('optimizemember-pro-stripe-sp-checkout')) . '" />';
                     $hidden_inputs .= '<input type="hidden" name="optimizemember_pro_stripe_sp_checkout[card_token]" id="optimizemember-pro-stripe-sp-checkout-card-token" value="' . esc_attr(@$_p['optimizemember_pro_stripe_sp_checkout']['card_token']) . '" />';
                     $hidden_inputs .= '<input type="hidden" name="optimizemember_pro_stripe_sp_checkout[card_token_summary]" id="optimizemember-pro-stripe-sp-checkout-card-token-summary" value="' . esc_attr(@$_p['optimizemember_pro_stripe_sp_checkout']['card_token_summary']) . '" />';
                     $hidden_inputs .= !$attr['accept_coupons'] ? '<input type="hidden" id="optimizemember-pro-stripe-sp-checkout-coupons-not-required-or-not-possible" value="1" />' : '';
                     $hidden_inputs .= !c_ws_plugin__optimizemember_pro_stripe_utilities::tax_may_apply() ? '<input type="hidden" id="optimizemember-pro-stripe-sp-checkout-tax-not-required-or-not-possible" value="1" />' : '';
                     $hidden_inputs .= ($cp_attr = c_ws_plugin__optimizemember_pro_stripe_utilities::apply_coupon($attr, $attr['coupon'])) && $cp_attr['ta'] <= 0.0 && $cp_attr['ra'] <= 0.0 ? '<input type="hidden" id="optimizemember-pro-stripe-sp-checkout-payment-not-required-or-not-possible" value="1" />' : '';
                     $hidden_inputs .= '<input type="hidden" name="optimizemember_pro_stripe_sp_checkout[attr]" id="optimizemember-pro-stripe-sp-checkout-attr" value="' . esc_attr(c_ws_plugin__optimizemember_utils_encryption::encrypt(serialize($attr))) . '" />';
                     $custom_template = file_exists(TEMPLATEPATH . '/stripe-sp-checkout-form.php') ? TEMPLATEPATH . '/stripe-sp-checkout-form.php' : FALSE;
                     $custom_template = file_exists(TEMPLATEPATH . '/stripe-sp-checkout-form.html') ? TEMPLATEPATH . '/stripe-sp-checkout-form.html' : $custom_template;
                     $custom_template = $attr['template'] && file_exists(TEMPLATEPATH . '/' . $attr['template']) ? TEMPLATEPATH . '/' . $attr['template'] : $custom_template;
                     $custom_template = $attr['template'] && file_exists(WP_CONTENT_DIR . '/' . $attr['template']) ? WP_CONTENT_DIR . '/' . $attr['template'] : $custom_template;
                     $code = trim(file_get_contents($custom_template ? $custom_template : dirname(dirname(dirname(dirname(__FILE__)))) . '/templates/forms/stripe-sp-checkout-form.php'));
                     $code = trim(!$custom_template || !is_multisite() || !c_ws_plugin__optimizemember_utils_conds::is_multisite_farm() || is_main_site() ? c_ws_plugin__optimizemember_utilities::evl($code) : $code);
                     $code = preg_replace('/%%action%%/', c_ws_plugin__optimizemember_utils_strings::esc_refs(esc_attr($_SERVER['REQUEST_URI'])), $code);
                     $code = preg_replace('/%%response%%/', c_ws_plugin__optimizemember_utils_strings::esc_refs($response['response']), $code);
                     $code = preg_replace('/%%options%%/', c_ws_plugin__optimizemember_utils_strings::esc_refs($option_selections), $code);
                     $code = preg_replace('/%%description%%/', c_ws_plugin__optimizemember_utils_strings::esc_refs($attr['desc']), $code);
                     $code = preg_replace('/%%coupon_response%%/', c_ws_plugin__optimizemember_utils_strings::esc_refs(c_ws_plugin__optimizemember_pro_stripe_utilities::apply_coupon($attr, $attr['coupon'], 'response', array('affiliates-1px-response'))), $code);
                     $code = preg_replace('/%%coupon_value%%/', c_ws_plugin__optimizemember_utils_strings::esc_refs(format_to_edit($attr['coupon'])), $code);
                     $code = preg_replace('/%%first_name_value%%/', c_ws_plugin__optimizemember_utils_strings::esc_refs(esc_attr(@$_p['optimizemember_pro_stripe_sp_checkout']['first_name'])), $code);
                     $code = preg_replace('/%%last_name_value%%/', c_ws_plugin__optimizemember_utils_strings::esc_refs(esc_attr(@$_p['optimizemember_pro_stripe_sp_checkout']['last_name'])), $code);
                     $code = preg_replace('/%%email_value%%/', c_ws_plugin__optimizemember_utils_strings::esc_refs(format_to_edit(@$_p['optimizemember_pro_stripe_sp_checkout']['email'])), $code);
                     $code = preg_replace('/%%card_token%%/', c_ws_plugin__optimizemember_utils_strings::esc_refs(esc_html(@$_p['optimizemember_pro_stripe_sp_checkout']['card_token'])), $code);
                     $code = preg_replace('/%%card_token_summary%%/', c_ws_plugin__optimizemember_utils_strings::esc_refs(esc_html(@$_p['optimizemember_pro_stripe_sp_checkout']['card_token_summary'])), $code);
                     $code = preg_replace('/%%state_value%%/', c_ws_plugin__optimizemember_utils_strings::esc_refs(format_to_edit(@$_p['optimizemember_pro_stripe_sp_checkout']['state'])), $code);
                     $code = preg_replace('/%%country_options%%/', c_ws_plugin__optimizemember_utils_strings::esc_refs($country_options), $code);
                     $code = preg_replace('/%%zip_value%%/', c_ws_plugin__optimizemember_utils_strings::esc_refs(format_to_edit(@$_p['optimizemember_pro_stripe_sp_checkout']['zip'])), $code);
                     $code = preg_replace('/%%captcha%%/', c_ws_plugin__optimizemember_utils_strings::esc_refs($captcha), $code);
                     $code = preg_replace('/%%opt_in%%/', c_ws_plugin__optimizemember_utils_strings::esc_refs($opt_in), $code);
                     $code = preg_replace('/%%hidden_inputs%%/', c_ws_plugin__optimizemember_utils_strings::esc_refs($hidden_inputs), $code);
                     foreach (array_keys(get_defined_vars()) as $__v) {
                         $__refs[$__v] =& ${$__v};
                     }
                     do_action('ws_plugin__optimizemember_pro_during_sc_stripe_sp_form', get_defined_vars());
                     unset($__refs, $__v);
                     // Ditch these temporary vars.
                 } else {
                     $_p = c_ws_plugin__optimizemember_utils_strings::trim_deep(stripslashes_deep($_POST));
                     $attr['level_ccaps_eotper'] = $attr['rr'] === 'BN' && $attr['rt'] !== 'L' ? $attr['level'] . ':' . $attr['ccaps'] . ':' . $attr['rp'] . ' ' . $attr['rt'] : $attr['level'] . ':' . $attr['ccaps'];
                     $attr['level_ccaps_eotper'] = rtrim($attr['level_ccaps_eotper'], ':');
                     // Clean any trailing separators from this string.
                     $attr['coupon'] = !empty($_p['optimizemember_pro_stripe_checkout']['coupon']) ? $_p['optimizemember_pro_stripe_checkout']['coupon'] : $attr['coupon'];
                     $response = c_ws_plugin__optimizemember_pro_stripe_responses::stripe_checkout_response($attr);
                     $_p = $response['response'] && !$response['error'] ? array() : $_p;
                     $country_default_by_currency = !@$_p['optimizemember_pro_stripe_checkout']['country'] && $attr['cc'] === 'USD' ? 'US' : '';
                     $country_default_by_currency = !@$_p['optimizemember_pro_stripe_checkout']['country'] && $attr['cc'] === 'CAD' ? 'CA' : $country_default_by_currency;
                     $country_default_by_currency = !@$_p['optimizemember_pro_stripe_checkout']['country'] && $attr['cc'] === 'GBP' ? 'GB' : $country_default_by_currency;
                     $country_default_by_currency = apply_filters('ws_plugin__optimizemember_pro_stripe_default_country', $country_default_by_currency, get_defined_vars());
                     $default_country_v = $attr['default_country_code'] ? $attr['default_country_code'] : $country_default_by_currency;
                     $country_options = '<option value=""></option>';
                     // Start with an empty option value.
                     foreach (preg_split('/[' . "\r\n" . ']+/', file_get_contents(dirname(dirname(dirname(dirname(__FILE__)))) . '/iso-3166-1.txt')) as $country) {
                         list($country_l, $country_v) = preg_split('/;/', $country, 2);
                         if ($country_l && $country_v) {
                             // Here we also check on the default pre-selected country; as determined above; based on currency.
                             $country_options .= '<option value="' . esc_attr(strtoupper($country_v)) . '"' . (@$_p['optimizemember_pro_stripe_checkout']['country'] === $country_v || $default_country_v === $country_v ? ' selected="selected"' : '') . '>' . esc_html(ucwords(strtolower($country_l))) . '</option>';
                         }
                     }
                     $custom_fields = '';
                     // Initialize custom fields.
                     if ($GLOBALS['WS_PLUGIN__']['optimizemember']['o']['custom_reg_fields']) {
                         // Only display Custom Fields if configured.
                         if ($fields_applicable = c_ws_plugin__optimizemember_custom_reg_fields::custom_fields_configured_at_level($attr['level'] === '*' ? 'auto-detection' : $attr['level'], 'registration')) {
                             $tabindex = 99;
                             // Start tabindex at 99 (+1 below = 100).
                             $custom_fields = '<div id="optimizemember-pro-stripe-checkout-form-custom-fields-section" class="optimizemember-pro-stripe-form-section optimizemember-pro-stripe-checkout-form-section optimizemember-pro-stripe-form-custom-fields-section optimizemember-pro-stripe-checkout-form-custom-fields-section">' . "\n";
                             $custom_fields .= '<div id="optimizemember-pro-stripe-checkout-form-custom-fields-section-title" class="optimizemember-pro-stripe-form-section-title optimizemember-pro-stripe-checkout-form-section-title optimizemember-pro-stripe-form-custom-fields-section-title optimizemember-pro-stripe-checkout-form-custom-fields-section-title">' . "\n";
                             $custom_fields .= _x('Additional Info', 's2member-front', 's2member') . "\n";
                             $custom_fields .= '</div>' . "\n";
                             foreach (json_decode($GLOBALS['WS_PLUGIN__']['optimizemember']['o']['custom_reg_fields'], TRUE) as $field) {
                                 if (in_array($field['id'], $fields_applicable)) {
                                     $field_var = preg_replace('/[^a-z0-9]/i', '_', strtolower($field['id']));
                                     $field_id_class = preg_replace('/_/', '-', $field_var);
                                     if (!empty($field['section']) && $field['section'] === 'yes') {
                                         // Starts a new section?
                                         $custom_fields .= '<div id="optimizemember-pro-stripe-checkout-form-custom-reg-field-' . $field_id_class . '-divider-section" class="optimizemember-pro-stripe-form-div optimizemember-pro-stripe-checkout-form-div optimizemember-pro-stripe-form-custom-reg-field-divider-section' . (!empty($field['sectitle']) ? '-title' : '') . ' optimizemember-pro-stripe-form-custom-reg-field-' . $field_id_class . '-divider-section' . (!empty($field['sectitle']) ? '-title' : '') . ' optimizemember-pro-stripe-checkout-form-custom-reg-field-' . $field_id_class . '-divider-section' . (!empty($field['sectitle']) ? '-title' : '') . '">' . (!empty($field['sectitle']) ? $field['sectitle'] : '') . '</div>';
                                     }
                                     $custom_fields .= '<div id="optimizemember-pro-stripe-checkout-form-custom-reg-field-' . $field_id_class . '-div" class="optimizemember-pro-stripe-form-div optimizemember-pro-stripe-checkout-form-div optimizemember-pro-stripe-form-custom-reg-field-' . $field_id_class . '-div optimizemember-pro-stripe-checkout-form-custom-reg-field-' . $field_id_class . '-div">' . "\n";
                                     $custom_fields .= '<label for="optimizemember-pro-stripe-checkout-custom-reg-field-' . esc_attr($field_id_class) . '" id="optimizemember-pro-stripe-checkout-form-custom-reg-field-' . $field_id_class . '-label" class="optimizemember-pro-stripe-form-custom-reg-field-' . $field_id_class . '-label optimizemember-pro-stripe-checkout-form-custom-reg-field-' . $field_id_class . '-label">' . "\n";
                                     $custom_fields .= '<span' . (preg_match('/^(checkbox|pre_checkbox)$/', $field['type']) ? ' style="display:none;"' : '') . '>' . $field['label'] . ($field['required'] === 'yes' ? ' *' : '') . '</span></label>' . (preg_match('/^(checkbox|pre_checkbox)$/', $field['type']) ? '' : '<br />') . "\n";
                                     $custom_fields .= c_ws_plugin__optimizemember_custom_reg_fields::custom_field_gen(__FUNCTION__, $field, 'optimizemember_pro_stripe_checkout[custom_fields][', 'optimizemember-pro-stripe-checkout-custom-reg-field-', 'optimizemember-pro-stripe-custom-reg-field-' . $field_id_class . ' optimizemember-pro-stripe-checkout-custom-reg-field-' . $field_id_class, '', $tabindex = $tabindex + 1, '', $_p, @$_p['optimizemember_pro_stripe_checkout']['custom_fields'][$field_var], 'registration');
                                     $custom_fields .= '</div>' . "\n";
                                 }
                             }
                             $custom_fields .= '</div>' . "\n";
                         }
                     }
                     if ($attr['captcha']) {
                         $captcha = '<div id="optimizemember-pro-stripe-checkout-form-captcha-section" class="optimizemember-pro-stripe-form-section optimizemember-pro-stripe-checkout-form-section optimizemember-pro-stripe-form-captcha-section optimizemember-pro-stripe-checkout-form-captcha-section">' . "\n";
                         $captcha .= '<div id="optimizemember-pro-stripe-checkout-form-captcha-section-title" class="optimizemember-pro-stripe-form-section-title optimizemember-pro-stripe-checkout-form-section-title optimizemember-pro-stripe-form-captcha-section-title optimizemember-pro-stripe-checkout-form-captcha-section-title">' . "\n";
                         $captcha .= _x('Security Code', 's2member-front', 's2member') . "\n";
                         $captcha .= '</div>' . "\n";
                         $captcha .= '<div id="optimizemember-pro-stripe-checkout-form-captcha-div" class="optimizemember-pro-stripe-form-div optimizemember-pro-stripe-checkout-form-div optimizemember-pro-stripe-form-captcha-div optimizemember-pro-stripe-checkout-form-captcha-div">' . "\n";
                         $captcha .= '<label id="optimizemember-pro-stripe-checkout-form-captcha-label" class="optimizemember-pro-stripe-form-captcha-label optimizemember-pro-stripe-checkout-form-captcha-label">' . "\n";
                         $captcha .= c_ws_plugin__optimizemember_utils_captchas::recaptcha_script_tag($attr['captcha'], 400) . "\n";
                         $captcha .= '</label>' . "\n";
                         $captcha .= '</div>' . "\n";
                         $captcha .= '</div>' . "\n";
                     } else {
                         $captcha = '';
                     }
                     // Not applicable.
                     if ($GLOBALS['WS_PLUGIN__']['optimizemember']['o']['custom_reg_opt_in'] && c_ws_plugin__optimizemember_list_servers::list_servers_integrated()) {
                         $opt_in = '<div id="optimizemember-pro-stripe-checkout-form-custom-reg-field-opt-in-div" class="optimizemember-pro-stripe-form-div optimizemember-pro-stripe-checkout-form-div optimizemember-pro-stripe-form-custom-reg-field-opt-in-div optimizemember-pro-stripe-checkout-form-custom-reg-field-opt-in-div">' . "\n";
                         $opt_in .= '<label for="optimizemember-pro-stripe-checkout-form-custom-reg-field-opt-in" id="optimizemember-pro-stripe-checkout-form-custom-reg-field-opt-in-label" class="optimizemember-pro-stripe-form-custom-reg-field-opt-in-label optimizemember-pro-stripe-checkout-form-custom-reg-field-opt-in-label">' . "\n";
                         $opt_in .= '<input type="checkbox" name="optimizemember_pro_stripe_checkout[custom_fields][opt_in]" id="optimizemember-pro-stripe-checkout-form-custom-reg-field-opt-in" class="optimizemember-pro-stripe-form-custom-reg-field-opt-in optimizemember-pro-stripe-checkout-form-custom-reg-field-opt-in" value="1"' . (empty($_p) && $GLOBALS['WS_PLUGIN__']['optimizemember']['o']['custom_reg_opt_in'] == 1 || @$_p['optimizemember_pro_stripe_checkout']['custom_fields']['opt_in'] ? ' checked="checked"' : '') . ' tabindex="500" />' . "\n";
                         $opt_in .= $GLOBALS['WS_PLUGIN__']['optimizemember']['o']['custom_reg_opt_in_label'] . "\n";
                         $opt_in .= '</label>' . "\n";
                         $opt_in .= '</div>' . "\n";
                     } else {
                         $opt_in = '';
                     }
                     // Not applicable.
                     $hidden_inputs = '<input type="hidden" name="optimizemember_pro_stripe_checkout[nonce]" id="optimizemember-pro-stripe-checkout-nonce" value="' . esc_attr(wp_create_nonce('optimizemember-pro-stripe-checkout')) . '" />';
                     $hidden_inputs .= '<input type="hidden" name="optimizemember_pro_stripe_checkout[card_token]" id="optimizemember-pro-stripe-checkout-card-token" value="' . esc_attr(@$_p['optimizemember_pro_stripe_checkout']['card_token']) . '" />';
                     $hidden_inputs .= '<input type="hidden" name="optimizemember_pro_stripe_checkout[card_token_summary]" id="optimizemember-pro-stripe-checkout-card-token-summary" value="' . esc_attr(@$_p['optimizemember_pro_stripe_checkout']['card_token_summary']) . '" />';
                     $hidden_inputs .= !$attr['accept_coupons'] ? '<input type="hidden" id="optimizemember-pro-stripe-checkout-coupons-not-required-or-not-possible" value="1" />' : '';
                     $hidden_inputs .= !$GLOBALS['WS_PLUGIN__']['optimizemember']['o']['custom_reg_password'] ? '<input type="hidden" id="optimizemember-pro-stripe-checkout-password-not-required-or-not-possible" value="1" />' : '';
                     $hidden_inputs .= !c_ws_plugin__optimizemember_pro_stripe_utilities::tax_may_apply() ? '<input type="hidden" id="optimizemember-pro-stripe-checkout-tax-not-required-or-not-possible" value="1" />' : '';
                     $hidden_inputs .= ($cp_attr = c_ws_plugin__optimizemember_pro_stripe_utilities::apply_coupon($attr, $attr['coupon'])) && $cp_attr['ta'] <= 0.0 && $cp_attr['ra'] <= 0.0 ? '<input type="hidden" id="optimizemember-pro-stripe-checkout-payment-not-required-or-not-possible" value="1" />' : '';
                     $hidden_inputs .= '<input type="hidden" name="optimizemember_pro_stripe_checkout[attr]" id="optimizemember-pro-stripe-checkout-attr" value="' . esc_attr(c_ws_plugin__optimizemember_utils_encryption::encrypt(serialize($attr))) . '" />';
                     $custom_template = file_exists(TEMPLATEPATH . '/stripe-checkout-form.php') ? TEMPLATEPATH . '/stripe-checkout-form.php' : FALSE;
                     $custom_template = file_exists(TEMPLATEPATH . '/stripe-checkout-form.html') ? TEMPLATEPATH . '/stripe-checkout-form.html' : $custom_template;
                     $custom_template = $attr['template'] && file_exists(TEMPLATEPATH . '/' . $attr['template']) ? TEMPLATEPATH . '/' . $attr['template'] : $custom_template;
                     $custom_template = $attr['template'] && file_exists(WP_CONTENT_DIR . '/' . $attr['template']) ? WP_CONTENT_DIR . '/' . $attr['template'] : $custom_template;
                     $code = trim(file_get_contents($custom_template ? $custom_template : dirname(dirname(dirname(dirname(__FILE__)))) . '/templates/forms/stripe-checkout-form.php'));
                     $code = trim(!$custom_template || !is_multisite() || !c_ws_plugin__optimizemember_utils_conds::is_multisite_farm() || is_main_site() ? c_ws_plugin__optimizemember_utilities::evl($code) : $code);
                     $code = preg_replace('/%%action%%/', c_ws_plugin__optimizemember_utils_strings::esc_refs(esc_attr($_SERVER['REQUEST_URI'])), $code);
                     $code = preg_replace('/%%response%%/', c_ws_plugin__optimizemember_utils_strings::esc_refs($response['response']), $code);
                     $code = preg_replace('/%%options%%/', c_ws_plugin__optimizemember_utils_strings::esc_refs($option_selections), $code);
                     $code = preg_replace('/%%description%%/', c_ws_plugin__optimizemember_utils_strings::esc_refs($attr['desc']), $code);
                     $code = preg_replace('/%%coupon_response%%/', c_ws_plugin__optimizemember_utils_strings::esc_refs(c_ws_plugin__optimizemember_pro_stripe_utilities::apply_coupon($attr, $attr['coupon'], 'response', array('affiliates-1px-response'))), $code);
                     $code = preg_replace('/%%coupon_value%%/', c_ws_plugin__optimizemember_utils_strings::esc_refs(format_to_edit($attr['coupon'])), $code);
                     $code = preg_replace('/%%first_name_value%%/', c_ws_plugin__optimizemember_utils_strings::esc_refs(esc_attr(@$_p['optimizemember_pro_stripe_checkout']['first_name'])), $code);
                     $code = preg_replace('/%%last_name_value%%/', c_ws_plugin__optimizemember_utils_strings::esc_refs(esc_attr(@$_p['optimizemember_pro_stripe_checkout']['last_name'])), $code);
                     $code = preg_replace('/%%email_value%%/', c_ws_plugin__optimizemember_utils_strings::esc_refs(format_to_edit(@$_p['optimizemember_pro_stripe_checkout']['email'])), $code);
                     $code = preg_replace('/%%username_value%%/', c_ws_plugin__optimizemember_utils_strings::esc_refs(format_to_edit(@$_p['optimizemember_pro_stripe_checkout']['username'])), $code);
                     $code = preg_replace('/%%password1_value%%/', c_ws_plugin__optimizemember_utils_strings::esc_refs(format_to_edit(@$_p['optimizemember_pro_stripe_checkout']['password1'])), $code);
                     $code = preg_replace('/%%password2_value%%/', c_ws_plugin__optimizemember_utils_strings::esc_refs(format_to_edit(@$_p['optimizemember_pro_stripe_checkout']['password2'])), $code);
                     $code = preg_replace('/%%custom_fields%%/', c_ws_plugin__optimizemember_utils_strings::esc_refs($custom_fields), $code);
                     $code = preg_replace('/%%card_token%%/', c_ws_plugin__optimizemember_utils_strings::esc_refs(esc_html(@$_p['optimizemember_pro_stripe_checkout']['card_token'])), $code);
                     $code = preg_replace('/%%card_token_summary%%/', c_ws_plugin__optimizemember_utils_strings::esc_refs(esc_html(@$_p['optimizemember_pro_stripe_checkout']['card_token_summary'])), $code);
                     $code = preg_replace('/%%state_value%%/', c_ws_plugin__optimizemember_utils_strings::esc_refs(format_to_edit(@$_p['optimizemember_pro_stripe_checkout']['state'])), $code);
                     $code = preg_replace('/%%country_options%%/', c_ws_plugin__optimizemember_utils_strings::esc_refs($country_options), $code);
                     $code = preg_replace('/%%zip_value%%/', c_ws_plugin__optimizemember_utils_strings::esc_refs(format_to_edit(@$_p['optimizemember_pro_stripe_checkout']['zip'])), $code);
                     $code = preg_replace('/%%captcha%%/', c_ws_plugin__optimizemember_utils_strings::esc_refs($captcha), $code);
                     $code = preg_replace('/%%opt_in%%/', c_ws_plugin__optimizemember_utils_strings::esc_refs($opt_in), $code);
                     $code = preg_replace('/%%hidden_inputs%%/', c_ws_plugin__optimizemember_utils_strings::esc_refs($hidden_inputs), $code);
                     if (!empty($raw_content)) {
                         $code = preg_replace('/%%submit_button%%/', $raw_content, $code);
                     } else {
                         $button_code = '<button style="padding:15px;" type="submit" id="optimizemember-pro-stripe-checkout-submit" class="optimizemember-pro-stripe-submit optimizemember-pro-stripe-checkout-submit btn btn-primary" tabindex="600">' . esc_html(_x("Submit Form", "s2member-front", "s2member")) . '</button>';
                         $code = preg_replace('/%%submit_button%%/', $button_code, $code);
                     }
                     foreach (array_keys(get_defined_vars()) as $__v) {
                         $__refs[$__v] =& ${$__v};
                     }
                     $attr['modify'] ? do_action('ws_plugin__optimizemember_pro_during_sc_stripe_modification_form', get_defined_vars()) : do_action('ws_plugin__optimizemember_pro_during_sc_stripe_form', get_defined_vars());
                     unset($__refs, $__v);
                     // Ditch these temporary vars.
                 }
             }
         }
     }
     return apply_filters('ws_plugin__optimizemember_pro_sc_stripe_form', $code, get_defined_vars());
 }
Beispiel #6
0
 /**
  * Fixes incomplete private key wrappers for RSA-SHA1 signing.
  *
  * Used by {@link optimizeMember\Utilities\c_ws_plugin__optimizemember_utils_strings::rsa_sha1_sign()}.
  *
  * @package optimizeMember\Utilities
  * @since 111017
  *
  * @param str $key The secret key to be used in an RSA-SHA1 signature.
  * @return str Key with incomplete wrappers corrected, when/if possible.
  *
  * @see http://www.faqs.org/qa/qa-14736.html
  */
 public static function _rsa_sha1_key_fix_wrappers($key = FALSE)
 {
     if (($key = trim((string) $key)) && (strpos($key, "-----BEGIN RSA PRIVATE KEY-----") === false || strpos($key, "-----END RSA PRIVATE KEY-----") === false)) {
         foreach ($lines = c_ws_plugin__optimizemember_utils_strings::trim_deep(preg_split("/[\r\n]+/", $key)) as $line => $value) {
             if (strpos($value, "-") === 0) {
                 $boundaries = empty($boundaries) ? 1 : $boundaries + 1;
                 /* Counter. */
                 unset($lines[$line]);
                 /* Remove this boundary line. We'll fix these below. */
             }
         }
         if (empty($boundaries) || $boundaries <= 2) {
             /* Do NOT modify keys with more than 2 boundaries. */
             $key = "-----BEGIN RSA PRIVATE KEY-----\n" . implode("\n", $lines) . "\n-----END RSA PRIVATE KEY-----";
         }
     }
     return $key;
     /* Always a trimmed string here. */
 }
 /**
  * Handles processing of Pro Forms for Specific Post/Page checkout.
  *
  * @package optimizeMember\AuthNet
  * @since 1.5
  *
  * @attaches-to ``add_action("init");``
  *
  * @return null Or exits script execution after a custom URL redirection.
  */
 public static function authnet_sp_checkout()
 {
     if (!empty($_POST["optimizemember_pro_authnet_sp_checkout"]["nonce"]) && ($nonce = $_POST["optimizemember_pro_authnet_sp_checkout"]["nonce"]) && wp_verify_nonce($nonce, "s2member-pro-authnet-sp-checkout")) {
         $GLOBALS["ws_plugin__optimizemember_pro_authnet_sp_checkout_response"] = array();
         /* This holds the global response details. */
         $global_response =& $GLOBALS["ws_plugin__optimizemember_pro_authnet_sp_checkout_response"];
         /* This is a shorter reference. */
         /**/
         $post_vars = c_ws_plugin__optimizemember_utils_strings::trim_deep(stripslashes_deep($_POST["optimizemember_pro_authnet_sp_checkout"]));
         $post_vars["attr"] = unserialize(c_ws_plugin__optimizemember_utils_encryption::decrypt($post_vars["attr"]));
         /* And Filter. */
         $post_vars["attr"] = apply_filters("ws_plugin__optimizemember_pro_authnet_sp_checkout_post_attr", $post_vars["attr"], get_defined_vars());
         /**/
         $post_vars["recaptcha_challenge_field"] = !$post_vars["recaptcha_challenge_field"] ? trim(stripslashes($_POST["recaptcha_challenge_field"])) : $post_vars["recaptcha_challenge_field"];
         $post_vars["recaptcha_response_field"] = !$post_vars["recaptcha_response_field"] ? trim(stripslashes($_POST["recaptcha_response_field"])) : $post_vars["recaptcha_response_field"];
         /**/
         $post_vars["name"] = trim($post_vars["first_name"] . " " . $post_vars["last_name"]);
         $post_vars["email"] = apply_filters("user_registration_email", sanitize_email($post_vars["email"]), get_defined_vars());
         /**/
         if (!c_ws_plugin__optimizemember_pro_authnet_responses::authnet_form_attr_validation_errors($post_vars["attr"])) {
             if (!($error = c_ws_plugin__optimizemember_pro_authnet_responses::authnet_form_submission_validation_errors("sp-checkout", $post_vars))) {
                 $cp_attr = c_ws_plugin__optimizemember_pro_authnet_utilities::authnet_apply_coupon($post_vars["attr"], $post_vars["coupon"], "attr", array("affiliates-silent-post"));
                 $cost_calculations = c_ws_plugin__optimizemember_pro_authnet_utilities::authnet_cost(null, $cp_attr["ra"], $post_vars["state"], $post_vars["country"], $post_vars["zip"], $cp_attr["cc"], $cp_attr["desc"]);
                 /**/
                 if (!($authnet = array())) {
                     $authnet["x_type"] = "AUTH_CAPTURE";
                     $authnet["x_method"] = "CC";
                     /**/
                     $authnet["x_email"] = $post_vars["email"];
                     $authnet["x_first_name"] = $post_vars["first_name"];
                     $authnet["x_last_name"] = $post_vars["last_name"];
                     $authnet["x_customer_ip"] = $_SERVER["REMOTE_ADDR"];
                     /**/
                     $authnet["x_invoice_num"] = "s2-" . uniqid();
                     $authnet["x_description"] = $cost_calculations["desc"];
                     /**/
                     $authnet["s2_invoice"] = $post_vars["attr"]["sp_ids_exp"];
                     $authnet["s2_custom"] = $post_vars["attr"]["custom"];
                     /**/
                     $authnet["x_tax"] = $cost_calculations["tax"];
                     $authnet["x_amount"] = $cost_calculations["total"];
                     /**/
                     $authnet["x_card_num"] = preg_replace("/[^0-9]/", "", $post_vars["card_number"]);
                     $authnet["x_exp_date"] = c_ws_plugin__optimizemember_pro_authnet_utilities::authnet_exp_date($post_vars["card_expiration"]);
                     $authnet["x_card_code"] = $post_vars["card_verification"];
                     /**/
                     #if (in_array ($post_vars["card_type"], array ("Maestro", "Solo")))
                     #	if (preg_match ("/^[0-9]{2}\/[0-9]{4}$/", $post_vars["card_start_date_issue_number"]))
                     #		$authnet["x_card_start_date"] = preg_replace ("/[^0-9]/", "", $post_vars["card_start_date_issue_number"]);
                     #	else /* Otherwise, we assume they provided an issue number instead. */
                     #		$authnet["x_card_issue_number"] = $post_vars["card_start_date_issue_number"];
                     /**/
                     $authnet["x_address"] = $post_vars["street"];
                     $authnet["x_city"] = $post_vars["city"];
                     $authnet["x_state"] = $post_vars["state"];
                     $authnet["x_country"] = $post_vars["country"];
                     $authnet["x_zip"] = $post_vars["zip"];
                 }
                 /**/
                 if (($authnet = c_ws_plugin__optimizemember_pro_authnet_utilities::authnet_aim_response($authnet)) && empty($authnet["__error"])) {
                     $new__txn_id = $authnet["transaction_id"];
                     /**/
                     if (!($ipn = array())) {
                         $ipn["txn_type"] = "web_accept";
                         $ipn["txn_id"] = $new__txn_id;
                         $ipn["custom"] = $post_vars["attr"]["custom"];
                         /**/
                         $ipn["mc_gross"] = $cost_calculations["total"];
                         $ipn["mc_currency"] = $cost_calculations["cur"];
                         $ipn["tax"] = $cost_calculations["tax"];
                         /**/
                         $ipn["payer_email"] = $post_vars["email"];
                         $ipn["first_name"] = $post_vars["first_name"];
                         $ipn["last_name"] = $post_vars["last_name"];
                         /**/
                         if (is_user_logged_in() && ($referencing = c_ws_plugin__optimizemember_utils_users::get_user_subscr_or_wp_id())) {
                             $ipn["option_name1"] = "Referencing Customer ID";
                             $ipn["option_selection1"] = $referencing;
                         } else {
                             $ipn["option_name1"] = "Originating Domain";
                             $ipn["option_selection1"] = $_SERVER["HTTP_HOST"];
                         }
                         /**/
                         $ipn["option_name2"] = "Customer IP Address";
                         $ipn["option_selection2"] = $_SERVER["REMOTE_ADDR"];
                         /**/
                         $ipn["item_name"] = $cost_calculations["desc"];
                         $ipn["item_number"] = $post_vars["attr"]["sp_ids_exp"];
                         /**/
                         $ipn_q = "&optimizemember_paypal_proxy=authnet&optimizemember_paypal_proxy_use=pro-emails";
                         $ipn_q .= "&optimizemember_paypal_proxy_verification=" . urlencode(c_ws_plugin__optimizemember_paypal_utilities::paypal_proxy_key_gen());
                         $ipn_q .= "&optimizemember_paypal_proxy_return_url=" . rawurlencode($post_vars["attr"]["success"]);
                         /**/
                         $ipn["optimizemember_authnet_proxy_return_url"] = trim(c_ws_plugin__optimizemember_utils_urls::remote(site_url("/?optimizemember_paypal_notify=1" . $ipn_q), $ipn, array("timeout" => 20)));
                     }
                     /**/
                     if ($sp_access_url = c_ws_plugin__optimizemember_sp_access::sp_access_link_gen($post_vars["attr"]["ids"], $post_vars["attr"]["exp"])) {
                         setcookie("optimizemember_sp_tracking", $optimizemember_sp_tracking = c_ws_plugin__optimizemember_utils_encryption::encrypt($new__txn_id), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie("optimizemember_sp_tracking", $optimizemember_sp_tracking, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN) . ($_COOKIE["optimizemember_sp_tracking"] = $optimizemember_sp_tracking);
                         /**/
                         $global_response = array("response" => sprintf(_x('<strong>Thank you.</strong> Your purchase has been approved.<br />&mdash; Please <a href="%s" rel="nofollow">click here</a> to proceed.', "s2member-front", "s2member"), esc_attr($sp_access_url)));
                         /**/
                         if ($post_vars["attr"]["success"] && substr($ipn["optimizemember_authnet_proxy_return_url"], 0, 2) === substr($post_vars["attr"]["success"], 0, 2) && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__optimizemember_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $ipn["optimizemember_authnet_proxy_return_url"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
                             wp_redirect(c_ws_plugin__optimizemember_utils_urls::add_optimizemember_sig($custom_success_url, "s2p-v")) . exit;
                         }
                     } else {
                         $global_response = array("response" => _x('<strong>Oops.</strong> Unable to generate Access Link. Please contact Support for assistance.', "s2member-front", "s2member"), "error" => true);
                     }
                 } else {
                     $global_response = array("response" => $authnet["__error"], "error" => true);
                 }
             } else {
                 $global_response = $error;
             }
         }
     }
 }
 /**
  * Get ``$_POST`` or ``$_REQUEST`` vars from ccBill.
  *
  * @package optimizeMember\ccBill
  * @since 1.5
  *
  * @return array|bool An array of verified ``$_POST`` or ``$_REQUEST`` variables, else false.
  *
  * @todo Continue optimizing this routine with ``empty()`` and ``isset()``.
  * @todo Candidate for the use of ``ifsetor()``?
  * @todo Update to use ``strcasecmp()``.
  */
 public static function ccbill_postvars()
 {
     if (isset($_REQUEST["optimizemember_pro_ccbill_return"]) && strlen($_REQUEST["optimizemember_pro_ccbill_return"]) || isset($_REQUEST["optimizemember_pro_ccbill_notify"]) && strlen($_REQUEST["optimizemember_pro_ccbill_notify"])) {
         $postvars = c_ws_plugin__optimizemember_utils_strings::trim_deep(stripslashes_deep($_REQUEST));
         /**/
         foreach ($postvars as $var => $value) {
             if (preg_match("/^optimizemember_/", $var)) {
                 unset($postvars[$var]);
             }
         }
         /**/
         $denial_digest_vars = $postvars["denialId"] . "0";
         $approval_digest_vars = $postvars["subscription_id"] . "1";
         /**/
         if ($postvars["responseDigest"] === md5($approval_digest_vars . $GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["pro_ccbill_salt_key"])) {
             return $postvars;
         } else {
             if ($postvars["responseDigest"] === md5($denial_digest_vars . $GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["pro_ccbill_salt_key"])) {
                 return $postvars;
             } else {
                 /* Nope. */
                 return false;
             }
         }
     } else {
         /* Nope. */
         return false;
     }
 }
Beispiel #9
0
/**
* Deprecated in optimizeMember v3.5+.
*
* Needed by the optimizeMember Pro upgrader prior to optimizeMember Pro v1.5+.
*
* @package optimizeMember
* @since 3.0
*
* @deprecated Starting with optimizeMember v3.5+, please use:
* 	``c_ws_plugin__optimizemember_utils_strings::trim_deep()``
*
* @see optimizeMember\Utilities\c_ws_plugin__optimizemember_utils_strings::trim_deep()
*/
function ws_plugin__optimizemember_trim_deep($data = FALSE)
{
    return c_ws_plugin__optimizemember_utils_strings::trim_deep($data);
}
 /**
  * Handles processing of Pro Forms for Specific Post/Page checkout.
  *
  * @package optimizeMember\Stripe
  * @since 140617
  *
  * @attaches-to ``add_action('init');``
  *
  * @return null Or exits script execution after a custom URL redirection.
  */
 public static function stripe_sp_checkout()
 {
     if (!empty($_POST['optimizemember_pro_stripe_sp_checkout']['nonce']) && ($nonce = $_POST['optimizemember_pro_stripe_sp_checkout']['nonce']) && wp_verify_nonce($nonce, 'optimizemember-pro-stripe-sp-checkout')) {
         $GLOBALS['ws_plugin__optimizemember_pro_stripe_sp_checkout_response'] = array();
         // This holds the global response details.
         $global_response =& $GLOBALS['ws_plugin__optimizemember_pro_stripe_sp_checkout_response'];
         $post_vars = c_ws_plugin__optimizemember_utils_strings::trim_deep(stripslashes_deep($_POST['optimizemember_pro_stripe_sp_checkout']));
         $post_vars['attr'] = !empty($post_vars['attr']) ? (array) unserialize(c_ws_plugin__optimizemember_utils_encryption::decrypt($post_vars['attr'])) : array();
         $post_vars['attr'] = apply_filters('ws_plugin__optimizemember_pro_stripe_sp_checkout_post_attr', $post_vars['attr'], get_defined_vars());
         $post_vars['name'] = trim($post_vars['first_name'] . ' ' . $post_vars['last_name']);
         $post_vars['email'] = apply_filters('user_registration_email', sanitize_email($post_vars['email']), get_defined_vars());
         $post_vars['recaptcha_challenge_field'] = isset($_POST['recaptcha_challenge_field']) ? trim(stripslashes($_POST['recaptcha_challenge_field'])) : '';
         $post_vars['recaptcha_response_field'] = isset($_POST['recaptcha_response_field']) ? trim(stripslashes($_POST['recaptcha_response_field'])) : '';
         if (!c_ws_plugin__optimizemember_pro_stripe_responses::stripe_form_attr_validation_errors($post_vars['attr'])) {
             if (!($form_submission_validation_errors = c_ws_plugin__optimizemember_pro_stripe_responses::stripe_form_submission_validation_errors('sp-checkout', $post_vars))) {
                 unset($_POST['optimizemember_pro_stripe_sp_checkout']['card_token']);
                 // These are good one-time only.
                 unset($_POST['optimizemember_pro_stripe_sp_checkout']['card_token_summary']);
                 $cp_attr = c_ws_plugin__optimizemember_pro_stripe_utilities::apply_coupon($post_vars['attr'], $post_vars['coupon'], 'attr', array('affiliates-silent-post'));
                 $cost_calculations = c_ws_plugin__optimizemember_pro_stripe_utilities::cost(NULL, $cp_attr['ra'], $post_vars['state'], $post_vars['country'], $post_vars['zip'], $cp_attr['cc'], $cp_attr['desc']);
                 if (!$global_response) {
                     if ($cost_calculations['total'] > 0) {
                         if (!is_object($stripe_customer = c_ws_plugin__optimizemember_pro_stripe_utilities::get_customer(get_current_user_id(), $post_vars['email'], $post_vars['first_name'], $post_vars['last_name']))) {
                             $global_response = array('response' => $stripe_customer, 'error' => TRUE);
                         } else {
                             if (!is_object($stripe_customer = c_ws_plugin__optimizemember_pro_stripe_utilities::set_customer_card_token($stripe_customer->id, $post_vars['card_token']))) {
                                 $global_response = array('response' => $stripe_customer, 'error' => TRUE);
                             } else {
                                 if (!is_object($stripe_charge = c_ws_plugin__optimizemember_pro_stripe_utilities::create_customer_charge($stripe_customer->id, $cost_calculations['total'], $cost_calculations['cur'], $cost_calculations['desc']))) {
                                     $global_response = array('response' => $stripe_charge, 'error' => TRUE);
                                 } else {
                                     $new__txn_cid = $stripe_customer->id;
                                     $new__txn_id = $stripe_charge->id;
                                 }
                             }
                         }
                     }
                 }
                 if (!$global_response) {
                     if (empty($new__txn_cid)) {
                         $new__txn_cid = strtoupper('free-' . uniqid());
                     }
                     if (empty($new__txn_id)) {
                         $new__txn_id = strtoupper('free-' . uniqid());
                     }
                     $ipn['txn_type'] = 'web_accept';
                     $ipn['txn_cid'] = $new__txn_cid;
                     $ipn['txn_id'] = $new__txn_id;
                     $ipn['custom'] = $post_vars['attr']['custom'];
                     $ipn['mc_gross'] = $cost_calculations['total'];
                     $ipn['mc_currency'] = $cost_calculations['cur'];
                     $ipn['tax'] = $cost_calculations['tax'];
                     $ipn['payer_email'] = $post_vars['email'];
                     $ipn['first_name'] = $post_vars['first_name'];
                     $ipn['last_name'] = $post_vars['last_name'];
                     if (is_user_logged_in() && ($referencing = c_ws_plugin__optimizemember_utils_users::get_user_subscr_or_wp_id())) {
                         $ipn['option_name1'] = 'Referencing Customer ID';
                         $ipn['option_selection1'] = $referencing;
                     } else {
                         $ipn['option_name1'] = 'Originating Domain';
                         $ipn['option_selection1'] = $_SERVER['HTTP_HOST'];
                     }
                     $ipn['option_name2'] = 'Customer IP Address';
                     $ipn['option_selection2'] = $_SERVER['REMOTE_ADDR'];
                     $ipn['item_name'] = $cost_calculations['desc'];
                     $ipn['item_number'] = $post_vars['attr']['sp_ids_exp'];
                     $ipn['optimizemember_paypal_proxy'] = 'stripe';
                     $ipn['optimizemember_paypal_proxy_use'] = 'pro-emails';
                     $ipn['optimizemember_paypal_proxy_coupon'] = array('coupon_code' => $cp_attr['_coupon_code'], 'full_coupon_code' => $cp_attr['_full_coupon_code'], 'affiliate_id' => $cp_attr['_coupon_affiliate_id']);
                     $ipn['optimizemember_paypal_proxy_verification'] = c_ws_plugin__optimizemember_paypal_utilities::paypal_proxy_key_gen();
                     $ipn['optimizemember_paypal_proxy_return_url'] = $post_vars['attr']['success'];
                     $ipn['optimizemember_stripe_proxy_return_url'] = trim(c_ws_plugin__optimizemember_utils_urls::remote(site_url('/?optimizemember_paypal_notify=1'), $ipn, array('timeout' => 20)));
                     setcookie('optimizemember_sp_tracking', $optimizemember_sp_tracking = c_ws_plugin__optimizemember_utils_encryption::encrypt($new__txn_id), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie('optimizemember_sp_tracking', $optimizemember_sp_tracking, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN) . ($_COOKIE['optimizemember_sp_tracking'] = $optimizemember_sp_tracking);
                     if ($sp_access_url = c_ws_plugin__optimizemember_sp_access::sp_access_link_gen($post_vars['attr']['ids'], $post_vars['attr']['exp'])) {
                         $global_response = array('response' => sprintf(_x('<strong>Thank you.</strong> Your purchase has been approved.<br />&mdash; Please <a href="%s" rel="nofollow">click here</a> to proceed.', 's2member-front', 'optimizemember'), esc_attr($sp_access_url)));
                         if ($post_vars['attr']['success'] && substr($ipn['optimizemember_stripe_proxy_return_url'], 0, 2) === substr($post_vars['attr']['success'], 0, 2) && ($custom_success_url = str_ireplace(array('%%s_response%%', '%%response%%'), array(urlencode(c_ws_plugin__optimizemember_utils_encryption::encrypt($global_response['response'])), urlencode($global_response['response'])), $ipn['optimizemember_stripe_proxy_return_url'])) && ($custom_success_url = trim(preg_replace('/%%(.+?)%%/i', '', $custom_success_url)))) {
                             wp_redirect(c_ws_plugin__optimizemember_utils_urls::add_optimizemember_sig($custom_success_url, 's2p-v')) . exit;
                         }
                     } else {
                         $global_response = array('response' => _x('<strong>Oops.</strong> Unable to generate Access Link. Please contact Support for assistance.', 's2member-front', 's2member'), 'error' => TRUE);
                     }
                 }
             } else {
                 // Input form field validation errors.
                 $global_response = $form_submission_validation_errors;
             }
         }
     }
 }
 /**
  * Calls upon the PayPal PayFlow API, and returns the response.
  *
  * @package optimizeMember\PayPal
  * @since 120514
  *
  * @param array $post_vars An array of variables to send through the PayPal PayFlow API call.
  * @return array An array of variables returned by the PayPal PayFlow API.
  */
 public static function paypal_payflow_api_response($post_vars = FALSE)
 {
     global $current_site, $current_blog;
     /**/
     eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
     do_action("ws_plugin__optimizemember_before_paypal_payflow_api_response", get_defined_vars());
     unset($__refs, $__v);
     /**/
     $url = "https://" . ($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["paypal_sandbox"] ? "pilot-payflowpro.paypal.com" : "payflowpro.paypal.com");
     /**/
     $post_vars = apply_filters("ws_plugin__optimizemember_paypal_payflow_api_post_vars", $post_vars, get_defined_vars());
     $post_vars = is_array($post_vars) ? $post_vars : array();
     /**/
     $post_vars["VERBOSITY"] = "MEDIUM";
     $post_vars["USER"] = $GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["paypal_payflow_api_username"];
     $post_vars["PARTNER"] = $GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["paypal_payflow_api_partner"];
     $post_vars["VENDOR"] = $GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["paypal_payflow_api_vendor"];
     $post_vars["PWD"] = $GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["paypal_payflow_api_password"];
     /**/
     foreach ($post_vars as $_key => &$_value) {
         $_value = c_ws_plugin__optimizemember_paypal_utilities::paypal_payflow_api_nv_cleanup($_key, $_value);
     }
     unset($_key, $_value);
     /**/
     $input_time = date("D M j, Y g:i:s a T");
     /**/
     $nvp_post_vars = "";
     foreach ($post_vars as $_key => $_value) {
         $nvp_post_vars .= ($nvp_post_vars ? "&" : "") . $_key . "[" . strlen($_value) . "]=" . $_value;
     }
     unset($_key, $_value);
     /**/
     $nvp = trim(c_ws_plugin__optimizemember_utils_urls::remote($url, $nvp_post_vars, array("timeout" => 20, "headers" => array("Content-Type" => "text/namevalue"))));
     /**/
     $output_time = date("D M j, Y g:i:s a T");
     /**/
     wp_parse_str($nvp, $response);
     $response = c_ws_plugin__optimizemember_utils_strings::trim_deep($response);
     /**/
     if ($response["RESULT"] !== "0") {
         if (strlen($response["RESPMSG"])) {
             /* translators: Exclude `%2$s`. These are English details returned by PayPal. Replace `%2$s` with: `Unable to process, please try again`, or something to that affect. Or, if you prefer, you could Filter ``$response["__error"]`` with `ws_plugin__optimizemember_paypal_payflow_api_response`. */
             $response["__error"] = sprintf(_x('Error #%1$s. %2$s.', "s2member-front", "s2member"), $response["RESULT"], rtrim($response["RESPMSG"], "."));
         } else {
             $response["__error"] = _x("Error. Please contact Support for assistance.", "s2member-front", "s2member");
         }
     } else {
         if (isset($response["TRXRESULT"]) && $response["TRXRESULT"] !== "0") {
             if (strlen($response["TRXRESPMSG"])) {
                 /* translators: Exclude `%2$s`. These are English details returned by PayPal. Replace `%2$s` with: `Unable to process, please try again`, or something to that affect. Or, if you prefer, you could Filter ``$response["__error"]`` with `ws_plugin__optimizemember_paypal_payflow_api_response`. */
                 $response["__error"] = sprintf(_x('Error #%1$s. %2$s.', "s2member-front", "s2member"), $response["TRXRESULT"], rtrim($response["TRXRESPMSG"], "."));
             } else {
                 $response["__error"] = _x("Error. Please contact Support for assistance.", "s2member-front", "s2member");
             }
         }
     }
     /**/
     $logv = c_ws_plugin__optimizemember_utilities::ver_details();
     $logm = c_ws_plugin__optimizemember_utilities::mem_details();
     $log4 = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] . "\nUser-Agent: " . $_SERVER["HTTP_USER_AGENT"];
     $log4 = is_multisite() && !is_main_site() ? ($_log4 = $current_blog->domain . $current_blog->path) . "\n" . $log4 : $log4;
     $log2 = is_multisite() && !is_main_site() ? "paypal-payflow-api-4-" . trim(preg_replace("/[^a-z0-9]/i", "-", $_log4), "-") . ".log" : "paypal-payflow-api.log";
     /**/
     if (isset($post_vars["ACCT"]) && strlen($post_vars["ACCT"]) > 4) {
         $post_vars["ACCT"] = str_repeat("*", strlen($post_vars["ACCT"]) - 4) . substr($post_vars["ACCT"], -4);
     }
     /**/
     if ($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["gateway_debug_logs"]) {
         if (is_dir($logs_dir = $GLOBALS["WS_PLUGIN__"]["optimizemember"]["c"]["logs_dir"])) {
             if (is_writable($logs_dir) && c_ws_plugin__optimizemember_utils_logs::archive_oversize_log_files()) {
                 if ($log = "-------- Input vars: ( " . $input_time . " ) --------\n" . $nvp_post_vars . "\n" . var_export($post_vars, true) . "\n") {
                     if ($log .= "-------- Output string/vars: ( " . $output_time . " ) --------\n" . $nvp . "\n" . var_export($response, true)) {
                         file_put_contents($logs_dir . "/" . $log2, $logv . "\n" . $logm . "\n" . $log4 . "\n" . $log . "\n\n", FILE_APPEND);
                     }
                 }
             }
         }
     }
     /**/
     return apply_filters("ws_plugin__optimizemember_paypal_payflow_api_response", c_ws_plugin__optimizemember_paypal_utilities::_paypal_payflow_api_response_filters($response), get_defined_vars());
 }
Beispiel #12
0
 /**
  * Test if this WordPress instance is a specific Remote Operation.
  *
  * @package optimizeMember\API_Remote_Ops
  * @since 110713
  *
  * @param str $_op The Remote Operation to test this instance against.
  * @return bool True if instance is the specified Operation, else false.
  */
 public static function is_remote_op($_op = FALSE)
 {
     if (!empty($_GET["optimizemember_pro_remote_op"]) && !empty($_POST["optimizemember_pro_remote_op"])) {
         if (is_array($op = maybe_unserialize(c_ws_plugin__optimizemember_utils_strings::trim_deep(stripslashes_deep($_POST["optimizemember_pro_remote_op"]))))) {
             if (is_array($op = c_ws_plugin__optimizemember_utils_strings::trim_deep($op))) {
                 if (!empty($op["api_key"]) && $op["api_key"] === c_ws_plugin__optimizemember_pro_remote_ops::remote_ops_key_gen()) {
                     if (!empty($op["op"]) && $op["op"] === $_op) {
                         return true;
                     }
                 }
             }
         }
     }
     return false;
 }
 /**
  * Handles Profile modifications for Custom Fields *( created with optimizeMember )*; integrated with BuddyPress.
  *
  * @package optimizeMember\Profiles
  * @since 3.5
  *
  * @attaches-to ``add_action("init");``
  *
  * @return null After re-configuring the ``$current_user`` object.
  */
 public static function handle_profile_modifications_4bp()
 {
     global $current_user;
     /* We'll need to update this global object. */
     /**/
     $user =& $current_user;
     /* Shorter reference to the ``$current_user`` object. */
     /**/
     do_action("ws_plugin__optimizemember_before_handle_profile_modifications_4bp", get_defined_vars());
     /**/
     if (!empty($_POST["ws_plugin__optimizemember_profile_4bp_save"]) && is_user_logged_in() && is_object($user) && !empty($user->ID) && ($user_id = $user->ID)) {
         if (($nonce = $_POST["ws_plugin__optimizemember_profile_4bp_save"]) && wp_verify_nonce($nonce, "ws-plugin--optimizemember-profile-4bp-save")) {
             $GLOBALS["ws_plugin__optimizemember_profile_4bp_saved"] = true;
             /* Global flag as having been saved/updated successfully. */
             /**/
             $_p = c_ws_plugin__optimizemember_utils_strings::trim_deep(stripslashes_deep($_POST));
             /* Clean ``$_POST`` vars. */
             /**/
             if ($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["custom_reg_fields"]) {
                 if ($fields_applicable = c_ws_plugin__optimizemember_custom_reg_fields::custom_fields_configured_at_level("auto-detection", "profile")) {
                     $_existing_fields = get_user_option("optimizemember_custom_fields", $user_id);
                     /**/
                     foreach (json_decode($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["custom_reg_fields"], true) as $field) {
                         $field_var = preg_replace("/[^a-z0-9]/i", "_", strtolower($field["id"]));
                         $field_id_class = preg_replace("/_/", "-", $field_var);
                         /**/
                         if (!in_array($field["id"], $fields_applicable) || strpos($field["editable"], "no") === 0) {
                             if (isset($_existing_fields[$field_var]) && (is_array($_existing_fields[$field_var]) && !empty($_existing_fields[$field_var]) || is_string($_existing_fields[$field_var]) && strlen($_existing_fields[$field_var]))) {
                                 $fields[$field_var] = $_existing_fields[$field_var];
                             } else {
                                 /* Else ``unset()``. */
                                 unset($fields[$field_var]);
                             }
                         } else {
                             if ($field["required"] === "yes" && (!isset($_p["ws_plugin__optimizemember_profile_4bp_" . $field_var]) || !is_array($_p["ws_plugin__optimizemember_profile_4bp_" . $field_var]) && !is_string($_p["ws_plugin__optimizemember_profile_4bp_" . $field_var]) || is_array($_p["ws_plugin__optimizemember_profile_4bp_" . $field_var]) && empty($_p["ws_plugin__optimizemember_profile_4bp_" . $field_var]) || is_string($_p["ws_plugin__optimizemember_profile_4bp_" . $field_var]) && !strlen($_p["ws_plugin__optimizemember_profile_4bp_" . $field_var]))) {
                                 if (isset($_existing_fields[$field_var]) && (is_array($_existing_fields[$field_var]) && !empty($_existing_fields[$field_var]) || is_string($_existing_fields[$field_var]) && strlen($_existing_fields[$field_var]))) {
                                     $fields[$field_var] = $_existing_fields[$field_var];
                                 } else {
                                     /* Else ``unset()``. */
                                     unset($fields[$field_var]);
                                 }
                             } else {
                                 if (isset($_p["ws_plugin__optimizemember_profile_4bp_" . $field_var])) {
                                     if (is_array($_p["ws_plugin__optimizemember_profile_4bp_" . $field_var]) && !empty($_p["ws_plugin__optimizemember_profile_4bp_" . $field_var]) || is_string($_p["ws_plugin__optimizemember_profile_4bp_" . $field_var]) && strlen($_p["ws_plugin__optimizemember_profile_4bp_" . $field_var])) {
                                         $fields[$field_var] = $_p["ws_plugin__optimizemember_profile_4bp_" . $field_var];
                                     } else {
                                         /* Else ``unset()``. */
                                         unset($fields[$field_var]);
                                     }
                                 } else {
                                     /* Else ``unset()``. */
                                     unset($fields[$field_var]);
                                 }
                             }
                         }
                     }
                     /**/
                     if (!empty($fields)) {
                         update_user_option($user_id, "optimizemember_custom_fields", $fields);
                     } else {
                         /* Else delete their Custom Fields? */
                         delete_user_option($user_id, "optimizemember_custom_fields");
                     }
                 }
             }
             /**/
             eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
             do_action("ws_plugin__optimizemember_during_handle_profile_modifications_4bp", get_defined_vars());
             unset($__refs, $__v);
             /* Unset defined __refs, __v. */
             /**/
             $user = new WP_User($user_id);
             /* Update the ``WP_User`` object for the current User/Member. */
             function_exists("setup_userdata") ? setup_userdata() : null;
             /* Update global vars. */
         }
     }
     /**/
     do_action("ws_plugin__optimizemember_after_handle_profile_modifications_4bp", get_defined_vars());
     /**/
     return;
     /* Return for uniformity. */
 }
 /**
  * Handles processing of Pro Form registrations.
  *
  * @package optimizeMember\PayPal
  * @since 1.5
  *
  * @attaches-to ``add_action("init");``
  *
  * @return null Or exits script execution after a custom URL redirection.
  */
 public static function paypal_registration()
 {
     if (!empty($_POST["optimizemember_pro_paypal_registration"]["nonce"]) && ($nonce = $_POST["optimizemember_pro_paypal_registration"]["nonce"]) && wp_verify_nonce($nonce, "s2member-pro-paypal-registration")) {
         $GLOBALS["ws_plugin__optimizemember_pro_paypal_registration_response"] = array();
         /* This holds the global response details. */
         $global_response =& $GLOBALS["ws_plugin__optimizemember_pro_paypal_registration_response"];
         /* This is a shorter reference. */
         /**/
         $post_vars = c_ws_plugin__optimizemember_utils_strings::trim_deep(stripslashes_deep($_POST["optimizemember_pro_paypal_registration"]));
         $post_vars["attr"] = unserialize(c_ws_plugin__optimizemember_utils_encryption::decrypt($post_vars["attr"]));
         /* And run a Filter. */
         $post_vars["attr"] = apply_filters("ws_plugin__optimizemember_pro_paypal_registration_post_attr", $post_vars["attr"], get_defined_vars());
         /**/
         $post_vars["recaptcha_challenge_field"] = !$post_vars["recaptcha_challenge_field"] ? trim(stripslashes($_POST["recaptcha_challenge_field"])) : $post_vars["recaptcha_challenge_field"];
         $post_vars["recaptcha_response_field"] = !$post_vars["recaptcha_response_field"] ? trim(stripslashes($_POST["recaptcha_response_field"])) : $post_vars["recaptcha_response_field"];
         /**/
         $post_vars["name"] = trim($post_vars["first_name"] . " " . $post_vars["last_name"]);
         $post_vars["email"] = apply_filters("user_registration_email", sanitize_email($post_vars["email"]), get_defined_vars());
         $post_vars["username"] = preg_replace("/\\s+/", "", sanitize_user($post_vars["username"], is_multisite()));
         /**/
         if (!c_ws_plugin__optimizemember_pro_paypal_responses::paypal_form_attr_validation_errors($post_vars["attr"])) {
             if (!($error = c_ws_plugin__optimizemember_pro_paypal_responses::paypal_form_submission_validation_errors("registration", $post_vars))) {
                 if (!($create_user = array())) {
                     $_POST["ws_plugin__optimizemember_custom_reg_field_user_pass1"] = $post_vars["password1"];
                     /* Fake this for registration configuration. */
                     $_POST["ws_plugin__optimizemember_custom_reg_field_first_name"] = $post_vars["first_name"];
                     /* Fake this for registration configuration. */
                     $_POST["ws_plugin__optimizemember_custom_reg_field_last_name"] = $post_vars["last_name"];
                     /* Fake this for registration configuration. */
                     $_POST["ws_plugin__optimizemember_custom_reg_field_opt_in"] = $post_vars["custom_fields"]["opt_in"];
                     /* Fake this too. */
                     /**/
                     if ($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["custom_reg_fields"]) {
                         foreach (json_decode($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["custom_reg_fields"], true) as $field) {
                             $field_var = preg_replace("/[^a-z0-9]/i", "_", strtolower($field["id"]));
                             $field_id_class = preg_replace("/_/", "-", $field_var);
                             /**/
                             if (isset($post_vars["custom_fields"][$field_var])) {
                                 $_POST["ws_plugin__optimizemember_custom_reg_field_" . $field_var] = $post_vars["custom_fields"][$field_var];
                             }
                         }
                     }
                     /**/
                     $GLOBALS["ws_plugin__optimizemember_registration_vars"]["ws_plugin__optimizemember_custom_reg_field_optimizemember_level"] = $post_vars["attr"]["level"];
                     $GLOBALS["ws_plugin__optimizemember_registration_vars"]["ws_plugin__optimizemember_custom_reg_field_optimizemember_ccaps"] = $post_vars["attr"]["ccaps"];
                     $GLOBALS["ws_plugin__optimizemember_registration_vars"]["ws_plugin__optimizemember_custom_reg_field_optimizemember_auto_eot_time"] = $post_vars["attr"]["tp"] . " " . $post_vars["attr"]["tt"];
                     $_EOT_ =& $GLOBALS["ws_plugin__optimizemember_registration_vars"]["ws_plugin__optimizemember_custom_reg_field_optimizemember_auto_eot_time"];
                     /* Quick/shorter reference to this var. */
                     $_EOT_ = $post_vars["attr"]["tp"] && $post_vars["attr"]["tt"] ? date("Y-m-d H:i:s", c_ws_plugin__optimizemember_utils_time::auto_eot_time("", "", "", $_EOT_)) : "";
                     $GLOBALS["ws_plugin__optimizemember_registration_vars"]["ws_plugin__optimizemember_custom_reg_field_optimizemember_custom"] = $post_vars["attr"]["custom"];
                     unset($_EOT_);
                     /* We can unset this shorter/reference variable now. */
                     /**/
                     $GLOBALS["ws_plugin__optimizemember_registration_return_url"] = $post_vars["attr"]["success"];
                     /* Custom success return. */
                     /**/
                     $create_user["user_login"] = $post_vars["username"];
                     /* Copy this into a separate array for `wp_create_user()`. */
                     $create_user["user_pass"] = wp_generate_password();
                     /* Which may fire `c_ws_plugin__optimizemember_registrations::generate_password()`. */
                     $create_user["user_email"] = $post_vars["email"];
                     /* Copy this into a separate array for `wp_create_user()`. */
                 }
                 /**/
                 if ($post_vars["password1"] && $post_vars["password1"] === $create_user["user_pass"]) {
                     if ((is_multisite() && ($new__user_id = c_ws_plugin__optimizemember_registrations::ms_create_existing_user($create_user["user_login"], $create_user["user_email"], $create_user["user_pass"])) || ($new__user_id = wp_create_user($create_user["user_login"], $create_user["user_pass"], $create_user["user_email"]))) && !is_wp_error($new__user_id)) {
                         update_user_option($new__user_id, "default_password_nag", false, true);
                         wp_new_user_notification($new__user_id, $create_user["user_pass"]);
                         /**/
                         $global_response = array("response" => sprintf(_x('<strong>Thank you.</strong> Please <a href="%s" rel="nofollow">login</a>.', "s2member-front", "s2member"), esc_attr(wp_login_url())));
                         /**/
                         if ($post_vars["attr"]["success"] && substr($GLOBALS["ws_plugin__optimizemember_registration_return_url"], 0, 2) === substr($post_vars["attr"]["success"], 0, 2) && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__optimizemember_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $GLOBALS["ws_plugin__optimizemember_registration_return_url"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
                             wp_redirect(c_ws_plugin__optimizemember_utils_urls::add_optimizemember_sig($custom_success_url, "s2p-v")) . exit;
                         }
                     } else {
                         $global_response = array("response" => _x('<strong>Oops.</strong> A slight problem. Please contact Support for assistance.', "s2member-front", "s2member"), "error" => true);
                     }
                 } else {
                     if ((is_multisite() && ($new__user_id = c_ws_plugin__optimizemember_registrations::ms_create_existing_user($create_user["user_login"], $create_user["user_email"], $create_user["user_pass"])) || ($new__user_id = wp_create_user($create_user["user_login"], $create_user["user_pass"], $create_user["user_email"]))) && !is_wp_error($new__user_id)) {
                         update_user_option($new__user_id, "default_password_nag", true, true);
                         wp_new_user_notification($new__user_id, $create_user["user_pass"]);
                         /**/
                         $global_response = array("response" => _x('<strong>Thank you.</strong> You\'ll receive an email momentarily.', "s2member-front", "s2member"));
                         /**/
                         if ($post_vars["attr"]["success"] && substr($GLOBALS["ws_plugin__optimizemember_registration_return_url"], 0, 2) === substr($post_vars["attr"]["success"], 0, 2) && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__optimizemember_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $GLOBALS["ws_plugin__optimizemember_registration_return_url"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
                             wp_redirect(c_ws_plugin__optimizemember_utils_urls::add_optimizemember_sig($custom_success_url, "s2p-v")) . exit;
                         }
                     } else {
                         $global_response = array("response" => _x('<strong>Oops.</strong> A slight problem. Please contact Support for assistance.', "s2member-front", "s2member"), "error" => true);
                     }
                 }
             } else {
                 $global_response = $error;
             }
         }
     }
 }
 /**
  * Adds Custom Fields to BuddyPress Registration Form.
  *
  * @package optimizeMember\Custom_Reg_Fields
  * @since 110524RC
  *
  * @attaches-to ``add_action("bp_after_signup_profile_fields");``
  *
  * @return null
  *
  * @todo Optimize with ``empty()``.
  */
 public static function custom_registration_fields_4bp()
 {
     static $processed = false;
     /* Process this routine only one time. */
     /**/
     do_action("ws_plugin__optimizemember_before_custom_registration_fields_4bp", get_defined_vars());
     /**/
     if (!$processed && in_array("registration", $GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["custom_reg_fields_4bp"])) {
         if (apply_filters("ws_plugin__optimizemember_custom_registration_fields_4bp_display", true, get_defined_vars())) {
             if (bp_is_register_page() && ($processed = true)) {
                 $_p = !empty($_POST) ? c_ws_plugin__optimizemember_utils_strings::trim_deep(stripslashes_deep($_POST)) : array();
                 /**/
                 if ($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["custom_reg_fields"]) {
                     if (($fields_applicable = c_ws_plugin__optimizemember_custom_reg_fields::custom_fields_configured_at_level("auto-detection", "registration")) || $GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["custom_reg_opt_in"] && c_ws_plugin__optimizemember_list_servers::list_servers_integrated()) {
                         if ($close_section_container = true) {
                             echo '<div id="ws-plugin--optimizemember-custom-reg-fields-4bp-section" class="ws-plugin--optimizemember-custom-reg-fields-4bp-section register-section">' . "\n";
                             echo '<div id="ws-plugin--optimizemember-custom-reg-fields-4bp-container" class="ws-plugin--optimizemember-custom-reg-fields-4bp-container">' . "\n";
                             echo '<input type="hidden" name="ws_plugin__optimizemember_registration" value="' . esc_attr(wp_create_nonce("ws-plugin--optimizemember-registration")) . '" />' . "\n";
                         }
                     }
                 }
                 /**/
                 eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
                 do_action("ws_plugin__optimizemember_during_custom_registration_fields_4bp_before", get_defined_vars());
                 unset($__refs, $__v);
                 /* Unset defined __refs, __v. */
                 /**/
                 if ($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["custom_reg_fields"]) {
                     if ($fields_applicable = c_ws_plugin__optimizemember_custom_reg_fields::custom_fields_configured_at_level("auto-detection", "registration")) {
                         foreach (json_decode($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["custom_reg_fields"], true) as $field) {
                             eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
                             do_action("ws_plugin__optimizemember_during_custom_registration_fields_4bp_before_custom_fields", get_defined_vars());
                             unset($__refs, $__v);
                             /* Unset defined __refs, __v. */
                             /**/
                             if (in_array($field["id"], $fields_applicable)) {
                                 $field_var = preg_replace("/[^a-z0-9]/i", "_", strtolower($field["id"]));
                                 $field_id_class = preg_replace("/_/", "-", $field_var);
                                 /**/
                                 eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
                                 if (apply_filters("ws_plugin__optimizemember_during_custom_registration_fields_4bp_during_custom_fields_display", true, get_defined_vars())) {
                                     if (!empty($field["section"]) && $field["section"] === "yes") {
                                         /* Starts a new section? */
                                         echo '<div class="ws-plugin--optimizemember-custom-reg-field-4bp-divider-section' . (!empty($field["sectitle"]) ? '-title' : '') . '">' . (!empty($field["sectitle"]) ? $field["sectitle"] : '') . '</div>';
                                     }
                                     /**/
                                     echo '<div class="ws-plugin--optimizemember-custom-reg-field-4bp ws-plugin--optimizemember-custom-reg-field-4bp-' . esc_attr($field_id_class) . ' field_' . esc_attr($field_var) . ' editfield">' . "\n";
                                     echo '<label for="ws-plugin--optimizemember-custom-reg-field-4bp-' . esc_attr($field_id_class) . '">' . "\n";
                                     echo '<span' . (preg_match("/^(checkbox|pre_checkbox)\$/", $field["type"]) ? ' style="display:none;"' : '') . '>' . $field["label"] . ($field["required"] === "yes" ? ' *' : '') . '</span></label>' . "\n";
                                     echo c_ws_plugin__optimizemember_custom_reg_fields::custom_field_gen(__FUNCTION__, $field, "ws_plugin__optimizemember_custom_reg_field_", "ws-plugin--optimizemember-custom-reg-field-4bp-", "ws-plugin--optimizemember-custom-reg-field-4bp", "", "", "", $_p, $_p["ws_plugin__optimizemember_custom_reg_field_" . $field_var], "registration");
                                     echo '</div>' . "\n";
                                 }
                                 unset($__refs, $__v);
                                 /* Unset defined __refs, __v. */
                             }
                             /**/
                             eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
                             do_action("ws_plugin__optimizemember_during_custom_registration_fields_4bp_after_custom_fields", get_defined_vars());
                             unset($__refs, $__v);
                             /* Unset defined __refs, __v. */
                         }
                     }
                 }
                 /**/
                 if ($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["custom_reg_opt_in"] && c_ws_plugin__optimizemember_list_servers::list_servers_integrated()) {
                     eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
                     do_action("ws_plugin__optimizemember_during_custom_registration_fields_4bp_before_opt_in", get_defined_vars());
                     unset($__refs, $__v);
                     /* Unset defined __refs, __v. */
                     /**/
                     echo '<div class="ws-plugin--optimizemember-custom-reg-field-4bp field_opt_in editfield">' . "\n";
                     echo '<label for="ws-plugin--optimizemember-custom-reg-field-4bp-opt-in">' . "\n";
                     echo '<input type="checkbox" name="ws_plugin__optimizemember_custom_reg_field_opt_in" id="ws-plugin--optimizemember-custom-reg-field-4bp-opt-in" class="ws-plugin--optimizemember-custom-reg-field-4bp" value="1"' . (empty($_p) && $GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["custom_reg_opt_in"] == 1 || $_p["ws_plugin__optimizemember_custom_reg_field_opt_in"] ? ' checked="checked"' : '') . ' />' . "\n";
                     echo $GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["custom_reg_opt_in_label"] . "\n";
                     echo '</label>' . "\n";
                     echo '</div>' . "\n";
                     /**/
                     eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
                     do_action("ws_plugin__optimizemember_during_custom_registration_fields_4bp_after_opt_in", get_defined_vars());
                     unset($__refs, $__v);
                     /* Unset defined __refs, __v. */
                 }
                 /**/
                 if (isset($close_section_container) && $close_section_container) {
                     echo '</div>' . "\n" . '</div>' . "\n";
                 }
                 /**/
                 eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
                 do_action("ws_plugin__optimizemember_during_custom_registration_fields_4bp_after", get_defined_vars());
                 unset($__refs, $__v);
                 /* Unset defined __refs, __v. */
             }
         }
     }
     /**/
     do_action("ws_plugin__optimizemember_after_custom_registration_fields_4bp", get_defined_vars());
     /**/
     return;
     /* Return for uniformity. */
 }
 /**
  * Handles processing of Pro Forms for Specific Post/Page checkout.
  *
  * @package optimizeMember\PayPal
  * @since 1.5
  *
  * @attaches-to ``add_action("init");``
  *
  * @return null Or exits script execution after a custom URL redirection; or upon Express Checkout redirection.
  */
 public static function sp_checkout()
 {
     if (!empty($_POST["optimizemember_pro_paypal_sp_checkout"]["nonce"]) && ($nonce = $_POST["optimizemember_pro_paypal_sp_checkout"]["nonce"]) && wp_verify_nonce($nonce, "s2member-pro-paypal-sp-checkout") || !empty($_GET["optimizemember_paypal_xco"]) && $_GET["optimizemember_paypal_xco"] === "optimizemember_pro_paypal_sp_checkout_return" && !empty($_GET["token"]) && ($_GET["token"] = esc_html($_GET["token"])) && (empty($_GET["PayerID"]) || ($_GET["PayerID"] = esc_html($_GET["PayerID"]))) && ($xco_post_vars = get_transient("s2m_" . md5("optimizemember_transient_express_checkout_" . $_GET["token"])))) {
         $GLOBALS["ws_plugin__optimizemember_pro_paypal_sp_checkout_response"] = array();
         /* This holds the global response details. */
         $global_response =& $GLOBALS["ws_plugin__optimizemember_pro_paypal_sp_checkout_response"];
         /* This is a shorter reference. */
         /**/
         $post_vars = $xco_post_vars ? $xco_post_vars : $_POST["optimizemember_pro_paypal_sp_checkout"];
         $post_vars = c_ws_plugin__optimizemember_utils_strings::trim_deep(stripslashes_deep($post_vars));
         $post_vars["attr"] = !$xco_post_vars ? unserialize(c_ws_plugin__optimizemember_utils_encryption::decrypt($post_vars["attr"])) : $post_vars["attr"];
         $post_vars["attr"] = !$xco_post_vars ? apply_filters("ws_plugin__optimizemember_pro_paypal_sp_checkout_post_attr", $post_vars["attr"], get_defined_vars()) : $post_vars["attr"];
         /**/
         if ($xco_post_vars) {
             /* No need to re-validate this upon return from Express Checkout. */
             $post_vars["attr"]["captcha"] = "0";
         }
         /**/
         $post_vars["recaptcha_challenge_field"] = !$post_vars["recaptcha_challenge_field"] ? trim(stripslashes($_POST["recaptcha_challenge_field"])) : $post_vars["recaptcha_challenge_field"];
         $post_vars["recaptcha_response_field"] = !$post_vars["recaptcha_response_field"] ? trim(stripslashes($_POST["recaptcha_response_field"])) : $post_vars["recaptcha_response_field"];
         /**/
         $post_vars["name"] = trim($post_vars["first_name"] . " " . $post_vars["last_name"]);
         $post_vars["email"] = apply_filters("user_registration_email", sanitize_email($post_vars["email"]), get_defined_vars());
         /**/
         !empty($_GET["token"]) ? delete_transient("s2m_" . md5("optimizemember_transient_express_checkout_" . $_GET["token"])) : null;
         /**/
         if (!c_ws_plugin__optimizemember_pro_paypal_responses::paypal_form_attr_validation_errors($post_vars["attr"])) {
             if (!($error = c_ws_plugin__optimizemember_pro_paypal_responses::paypal_form_submission_validation_errors("sp-checkout", $post_vars))) {
                 $cp_attr = c_ws_plugin__optimizemember_pro_paypal_utilities::paypal_apply_coupon($post_vars["attr"], $post_vars["coupon"], "attr", array("affiliates-silent-post"));
                 $cp_2gbp_attr = c_ws_plugin__optimizemember_pro_paypal_utilities::paypal_maestro_solo_2gbp($cp_attr, $post_vars["card_type"]);
                 $cost_calculations = c_ws_plugin__optimizemember_pro_paypal_utilities::paypal_cost(null, $cp_2gbp_attr["ra"], $post_vars["state"], $post_vars["country"], $post_vars["zip"], $cp_2gbp_attr["cc"], $cp_2gbp_attr["desc"]);
                 /**/
                 if (empty($_GET["optimizemember_paypal_xco"]) && $post_vars["card_type"] === "PayPal") {
                     $return_url = $cancel_url = is_ssl() ? "https://" : "http://";
                     $return_url = $cancel_url = ($return_url = $cancel_url) . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
                     $return_url = $cancel_url = remove_query_arg(array("token", "PayerID"), $return_url = $cancel_url);
                     $return_url = add_query_arg("optimizemember_paypal_xco", urlencode("optimizemember_pro_paypal_sp_checkout_return"), $return_url);
                     $cancel_url = add_query_arg("optimizemember_paypal_xco", urlencode("optimizemember_pro_paypal_sp_checkout_cancel"), $cancel_url);
                     /**/
                     $user = is_user_logged_in() && is_object($user = wp_get_current_user()) && ($user_id = $user->ID) ? $user : false;
                     /**/
                     $post_vars["attr"]["invoice"] = uniqid() . "~" . $_SERVER["REMOTE_ADDR"];
                     /* Unique invoice w/ IP address too. */
                     /**/
                     if (!($paypal_set_xco = array())) {
                         $paypal_set_xco["METHOD"] = "SetExpressCheckout";
                         /**/
                         $paypal_set_xco["RETURNURL"] = $return_url;
                         $paypal_set_xco["CANCELURL"] = $cancel_url;
                         /**/
                         $paypal_set_xco["PAGESTYLE"] = $post_vars["attr"]["ps"];
                         $paypal_set_xco["LOCALECODE"] = $post_vars["attr"]["lc"];
                         $paypal_set_xco["NOSHIPPING"] = $post_vars["attr"]["ns"];
                         $paypal_set_xco["SOLUTIONTYPE"] = "Sole";
                         $paypal_set_xco["LANDINGPAGE"] = "Billing";
                         $paypal_set_xco["ALLOWNOTE"] = "0";
                         /**/
                         $paypal_set_xco["PAYMENTREQUEST_0_PAYMENTACTION"] = "Sale";
                         $paypal_set_xco["MAXAMT"] = $cost_calculations["total"];
                         /**/
                         $paypal_set_xco["PAYMENTREQUEST_0_DESC"] = $cost_calculations["desc"];
                         $paypal_set_xco["PAYMENTREQUEST_0_CUSTOM"] = $post_vars["attr"]["custom"];
                         $paypal_set_xco["PAYMENTREQUEST_0_INVNUM"] = $post_vars["attr"]["invoice"];
                         /**/
                         $paypal_set_xco["PAYMENTREQUEST_0_CURRENCYCODE"] = $cost_calculations["cur"];
                         $paypal_set_xco["PAYMENTREQUEST_0_ITEMAMT"] = $cost_calculations["sub_total"];
                         $paypal_set_xco["PAYMENTREQUEST_0_TAXAMT"] = $cost_calculations["tax"];
                         $paypal_set_xco["PAYMENTREQUEST_0_AMT"] = $cost_calculations["total"];
                         /**/
                         $paypal_set_xco["L_PAYMENTREQUEST_0_QTY0"] = "1";
                         /* Always (1). */
                         $paypal_set_xco["L_PAYMENTREQUEST_0_NAME0"] = $cost_calculations["desc"];
                         $paypal_set_xco["L_PAYMENTREQUEST_0_NUMBER0"] = $post_vars["attr"]["sp_ids_exp"];
                         $paypal_set_xco["L_PAYMENTREQUEST_0_AMT0"] = $cost_calculations["sub_total"];
                         /**/
                         $paypal_set_xco["PAYMENTREQUEST_0_SHIPTONAME"] = $post_vars["name"];
                         $paypal_set_xco["PAYMENTREQUEST_0_SHIPTOSTREET"] = $post_vars["street"];
                         $paypal_set_xco["PAYMENTREQUEST_0_SHIPTOCITY"] = $post_vars["city"];
                         $paypal_set_xco["PAYMENTREQUEST_0_SHIPTOSTATE"] = $post_vars["state"];
                         $paypal_set_xco["PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE"] = $post_vars["country"];
                         $paypal_set_xco["PAYMENTREQUEST_0_SHIPTOZIP"] = $post_vars["zip"];
                         /**/
                         $paypal_set_xco["EMAIL"] = $post_vars["email"];
                     }
                     /**/
                     if (($paypal_set_xco = c_ws_plugin__optimizemember_paypal_utilities::paypal_api_response($paypal_set_xco)) && empty($paypal_set_xco["__error"])) {
                         set_transient("s2m_" . md5("optimizemember_transient_express_checkout_" . $paypal_set_xco["TOKEN"]), $post_vars, 10800);
                         /**/
                         $endpoint = $GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["paypal_sandbox"] ? "www.sandbox.paypal.com" : "www.paypal.com";
                         /**/
                         wp_redirect(add_query_arg("token", urlencode($paypal_set_xco["TOKEN"]), "https://" . $endpoint . "/cgi-bin/webscr?cmd=_express-checkout"));
                         /**/
                         exit;
                         /* Clean exit. */
                     } else {
                         $global_response = array("response" => $paypal_set_xco["__error"], "error" => true);
                     }
                 } else {
                     if (empty($post_vars["attr"]["invoice"])) {
                         /* Only if it's empty. */
                         $post_vars["attr"]["invoice"] = uniqid() . "~" . $_SERVER["REMOTE_ADDR"];
                     }
                     /**/
                     if (!($paypal = array())) {
                         if ($_GET["optimizemember_paypal_xco"] === "optimizemember_pro_paypal_sp_checkout_return" && !empty($_GET["token"]) && ($paypal_xco_details = array("METHOD" => "GetExpressCheckoutDetails", "TOKEN" => $_GET["token"])) && ($paypal_xco_details = c_ws_plugin__optimizemember_paypal_utilities::paypal_api_response($paypal_xco_details)) && empty($paypal_xco_details["__error"])) {
                             $paypal["METHOD"] = "DoExpressCheckoutPayment";
                             /**/
                             $paypal["TOKEN"] = $paypal_xco_details["TOKEN"];
                             $paypal["PAYERID"] = $paypal_xco_details["PAYERID"];
                             /**/
                             $paypal["PAYMENTREQUEST_0_PAYMENTACTION"] = "Sale";
                             /**/
                             $paypal["PAYMENTREQUEST_0_DESC"] = $cost_calculations["desc"];
                             $paypal["PAYMENTREQUEST_0_CUSTOM"] = $post_vars["attr"]["custom"];
                             $paypal["PAYMENTREQUEST_0_INVNUM"] = $post_vars["attr"]["invoice"];
                             /**/
                             $paypal["PAYMENTREQUEST_0_CURRENCYCODE"] = $cost_calculations["cur"];
                             $paypal["PAYMENTREQUEST_0_ITEMAMT"] = $cost_calculations["sub_total"];
                             $paypal["PAYMENTREQUEST_0_TAXAMT"] = $cost_calculations["tax"];
                             $paypal["PAYMENTREQUEST_0_AMT"] = $cost_calculations["total"];
                             /**/
                             $paypal["L_PAYMENTREQUEST_0_QTY0"] = "1";
                             /* Always (1). */
                             $paypal["L_PAYMENTREQUEST_0_NAME0"] = $cost_calculations["desc"];
                             $paypal["L_PAYMENTREQUEST_0_NUMBER0"] = $post_vars["attr"]["sp_ids_exp"];
                             $paypal["L_PAYMENTREQUEST_0_AMT0"] = $cost_calculations["sub_total"];
                         } else {
                             $paypal["METHOD"] = "DoDirectPayment";
                             $paypal["PAYMENTACTION"] = "Sale";
                             /**/
                             $paypal["EMAIL"] = $post_vars["email"];
                             $paypal["FIRSTNAME"] = $post_vars["first_name"];
                             $paypal["LASTNAME"] = $post_vars["last_name"];
                             $paypal["IPADDRESS"] = $_SERVER["REMOTE_ADDR"];
                             /**/
                             $paypal["DESC"] = $cost_calculations["desc"];
                             $paypal["CUSTOM"] = $post_vars["attr"]["custom"];
                             $paypal["INVNUM"] = $post_vars["attr"]["invoice"];
                             /**/
                             $paypal["CURRENCYCODE"] = $cost_calculations["cur"];
                             $paypal["ITEMAMT"] = $cost_calculations["sub_total"];
                             $paypal["TAXAMT"] = $cost_calculations["tax"];
                             $paypal["AMT"] = $cost_calculations["total"];
                             /**/
                             $paypal["L_QTY0"] = "1";
                             /* Always (1). */
                             $paypal["L_NAME0"] = $cost_calculations["desc"];
                             $paypal["L_NUMBER0"] = $post_vars["attr"]["sp_ids_exp"];
                             $paypal["L_AMT0"] = $cost_calculations["sub_total"];
                             /**/
                             $paypal["CREDITCARDTYPE"] = $post_vars["card_type"];
                             $paypal["ACCT"] = preg_replace("/[^0-9]/", "", $post_vars["card_number"]);
                             $paypal["EXPDATE"] = preg_replace("/[^0-9]/", "", $post_vars["card_expiration"]);
                             $paypal["CVV2"] = $post_vars["card_verification"];
                             /**/
                             if (in_array($post_vars["card_type"], array("Maestro", "Solo"))) {
                                 if (preg_match("/^[0-9]{2}\\/[0-9]{4}\$/", $post_vars["card_start_date_issue_number"])) {
                                     $paypal["STARTDATE"] = preg_replace("/[^0-9]/", "", $post_vars["card_start_date_issue_number"]);
                                 } else {
                                     /* Otherwise, we assume they provided an Issue Number instead. */
                                     $paypal["ISSUENUMBER"] = $post_vars["card_start_date_issue_number"];
                                 }
                             }
                             /**/
                             $paypal["STREET"] = $post_vars["street"];
                             $paypal["CITY"] = $post_vars["city"];
                             $paypal["STATE"] = $post_vars["state"];
                             $paypal["COUNTRYCODE"] = $post_vars["country"];
                             $paypal["ZIP"] = $post_vars["zip"];
                         }
                     }
                     /**/
                     if (($paypal = c_ws_plugin__optimizemember_paypal_utilities::paypal_api_response($paypal)) && empty($paypal["__error"])) {
                         $new__txn_id = !empty($paypal["PAYMENTINFO_0_TRANSACTIONID"]) ? $paypal["PAYMENTINFO_0_TRANSACTIONID"] : false;
                         $new__txn_id = !$new__txn_id && !empty($paypal["TRANSACTIONID"]) ? $paypal["TRANSACTIONID"] : $new__txn_id;
                         /**/
                         if (!($ipn = array())) {
                             $ipn["txn_type"] = "web_accept";
                             $ipn["txn_id"] = $new__txn_id;
                             $ipn["custom"] = $post_vars["attr"]["custom"];
                             $ipn["invoice"] = $post_vars["attr"]["invoice"];
                             /**/
                             $ipn["mc_gross"] = $cost_calculations["total"];
                             $ipn["mc_currency"] = $cost_calculations["cur"];
                             $ipn["tax"] = $cost_calculations["tax"];
                             /**/
                             $ipn["payer_email"] = $post_vars["email"];
                             $ipn["first_name"] = $post_vars["first_name"];
                             $ipn["last_name"] = $post_vars["last_name"];
                             /**/
                             if (is_user_logged_in() && ($referencing = c_ws_plugin__optimizemember_utils_users::get_user_subscr_or_wp_id())) {
                                 $ipn["option_name1"] = "Referencing Customer ID";
                                 $ipn["option_selection1"] = $referencing;
                             } else {
                                 $ipn["option_name1"] = "Originating Domain";
                                 $ipn["option_selection1"] = $_SERVER["HTTP_HOST"];
                             }
                             /**/
                             $ipn["option_name2"] = "Customer IP Address";
                             $ipn["option_selection2"] = $_SERVER["REMOTE_ADDR"];
                             /**/
                             $ipn["item_name"] = $cost_calculations["desc"];
                             $ipn["item_number"] = $post_vars["attr"]["sp_ids_exp"];
                             /**/
                             $ipn_q = "&optimizemember_paypal_proxy=paypal&optimizemember_paypal_proxy_use=pro-emails";
                             $ipn_q .= "&optimizemember_paypal_proxy_verification=" . urlencode(c_ws_plugin__optimizemember_paypal_utilities::paypal_proxy_key_gen());
                             $ipn_q .= "&optimizemember_paypal_proxy_return_url=" . rawurlencode($post_vars["attr"]["success"]);
                             /**/
                             $ipn["optimizemember_paypal_proxy_return_url"] = trim(c_ws_plugin__optimizemember_utils_urls::remote(site_url("/?optimizemember_paypal_notify=1" . $ipn_q), $ipn, array("timeout" => 20)));
                         }
                         /**/
                         if ($sp_access_url = c_ws_plugin__optimizemember_sp_access::sp_access_link_gen($post_vars["attr"]["ids"], $post_vars["attr"]["exp"])) {
                             setcookie("optimizemember_sp_tracking", $optimizemember_sp_tracking = c_ws_plugin__optimizemember_utils_encryption::encrypt($new__txn_id), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie("optimizemember_sp_tracking", $optimizemember_sp_tracking, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN) . ($_COOKIE["optimizemember_sp_tracking"] = $optimizemember_sp_tracking);
                             /**/
                             $global_response = array("response" => sprintf(_x('<strong>Thank you.</strong> Your purchase has been approved.<br />&mdash; Please <a href="%s" rel="nofollow">click here</a> to proceed.', "s2member-front", "s2member"), esc_attr($sp_access_url)));
                             /**/
                             if ($post_vars["attr"]["success"] && substr($ipn["optimizemember_paypal_proxy_return_url"], 0, 2) === substr($post_vars["attr"]["success"], 0, 2) && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__optimizemember_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $ipn["optimizemember_paypal_proxy_return_url"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
                                 wp_redirect(c_ws_plugin__optimizemember_utils_urls::add_optimizemember_sig($custom_success_url, "s2p-v")) . exit;
                             }
                         } else {
                             $global_response = array("response" => _x('<strong>Oops.</strong> Unable to generate Access Link. Please contact Support for assistance.', "s2member-front", "s2member"), "error" => true);
                         }
                     } else {
                         $global_response = array("response" => $paypal["__error"], "error" => true);
                     }
                 }
             } else {
                 $global_response = $error;
             }
         }
     }
 }
 /**
  * Handles processing of Pro Form registrations.
  *
  * @package optimizeMember\Stripe
  * @since 140617
  *
  * @attaches-to ``add_action('init');``
  */
 public static function stripe_registration()
 {
     if (!empty($_POST['optimizemember_pro_stripe_registration']['nonce']) && ($nonce = $_POST['optimizemember_pro_stripe_registration']['nonce']) && wp_verify_nonce($nonce, 'optimizemember-pro-stripe-registration')) {
         $GLOBALS['ws_plugin__optimizemember_pro_stripe_registration_response'] = array();
         // This holds the global response details.
         $global_response =& $GLOBALS['ws_plugin__optimizemember_pro_stripe_registration_response'];
         $post_vars = c_ws_plugin__optimizemember_utils_strings::trim_deep(stripslashes_deep($_POST['optimizemember_pro_stripe_registration']));
         $post_vars['attr'] = !empty($post_vars['attr']) ? (array) unserialize(c_ws_plugin__optimizemember_utils_encryption::decrypt($post_vars['attr'])) : array();
         $post_vars['attr'] = apply_filters('ws_plugin__optimizemember_pro_stripe_registration_post_attr', $post_vars['attr'], get_defined_vars());
         $post_vars['name'] = trim($post_vars['first_name'] . ' ' . $post_vars['last_name']);
         $post_vars['email'] = apply_filters('user_registration_email', sanitize_email($post_vars['email']), get_defined_vars());
         $post_vars['username'] = is_multisite() ? strtolower($post_vars['username']) : $post_vars['username'];
         // Force lowercase.
         $post_vars['username'] = preg_replace('/\\s+/', '', sanitize_user($post_vars['_o_username'] = $post_vars['username'], is_multisite()));
         $post_vars['recaptcha_challenge_field'] = isset($_POST['recaptcha_challenge_field']) ? trim(stripslashes($_POST['recaptcha_challenge_field'])) : '';
         $post_vars['recaptcha_response_field'] = isset($_POST['recaptcha_response_field']) ? trim(stripslashes($_POST['recaptcha_response_field'])) : '';
         if (!c_ws_plugin__optimizemember_pro_stripe_responses::stripe_form_attr_validation_errors($post_vars['attr'])) {
             if (!($form_submission_validation_errors = c_ws_plugin__optimizemember_pro_stripe_responses::stripe_form_submission_validation_errors('registration', $post_vars))) {
                 $GLOBALS['ws_plugin__optimizemember_registration_vars']['ws_plugin__optimizemember_custom_reg_field_user_pass1'] = $post_vars['password1'];
                 $GLOBALS['ws_plugin__optimizemember_registration_vars']['ws_plugin__optimizemember_custom_reg_field_first_name'] = $post_vars['first_name'];
                 $GLOBALS['ws_plugin__optimizemember_registration_vars']['ws_plugin__optimizemember_custom_reg_field_last_name'] = $post_vars['last_name'];
                 $GLOBALS['ws_plugin__optimizemember_registration_vars']['ws_plugin__optimizemember_custom_reg_field_opt_in'] = @$post_vars['custom_fields']['opt_in'];
                 if ($GLOBALS['WS_PLUGIN__']['optimizemember']['o']['custom_reg_fields']) {
                     foreach (json_decode($GLOBALS['WS_PLUGIN__']['optimizemember']['o']['custom_reg_fields'], TRUE) as $field) {
                         $field_var = preg_replace('/[^a-z0-9]/i', '_', strtolower($field['id']));
                         $field_id_class = preg_replace('/_/', '-', $field_var);
                         if (isset($post_vars['custom_fields'][$field_var])) {
                             $GLOBALS['ws_plugin__optimizemember_registration_vars']['ws_plugin__optimizemember_custom_reg_field_' . $field_var] = $post_vars['custom_fields'][$field_var];
                         }
                     }
                 }
                 $GLOBALS['ws_plugin__optimizemember_registration_vars']['ws_plugin__optimizemember_custom_reg_field_optimizemember_level'] = $post_vars['attr']['level'];
                 $GLOBALS['ws_plugin__optimizemember_registration_vars']['ws_plugin__optimizemember_custom_reg_field_optimizemember_ccaps'] = $post_vars['attr']['ccaps'];
                 $GLOBALS['ws_plugin__optimizemember_registration_vars']['ws_plugin__optimizemember_custom_reg_field_optimizemember_custom'] = $post_vars['attr']['custom'];
                 $GLOBALS['ws_plugin__optimizemember_registration_vars']['ws_plugin__optimizemember_custom_reg_field_optimizemember_auto_eot_time'] = $post_vars['attr']['tp'] && $post_vars['attr']['tt'] ? date('Y-m-d H:i:s', c_ws_plugin__optimizemember_utils_time::auto_eot_time('', '', '', $post_vars['attr']['tp'] . ' ' . $post_vars['attr']['tt'])) : '';
                 $GLOBALS['ws_plugin__optimizemember_registration_return_url'] = $post_vars['attr']['success'];
                 $create_user['user_email'] = $post_vars['email'];
                 // Copy this into a separate array for `wp_create_user()`.
                 $create_user['user_login'] = $post_vars['username'];
                 // Copy this into a separate array for `wp_create_user()`.
                 $create_user['user_pass'] = wp_generate_password();
                 // Which may fire `c_ws_plugin__optimizemember_registrations::generate_password()`.
                 $has_custom_password = $post_vars['password1'] && $post_vars['password1'] === $create_user['user_pass'];
                 if ((is_multisite() && ($new__user_id = c_ws_plugin__optimizemember_registrations::ms_create_existing_user($create_user['user_login'], $create_user['user_email'], $create_user['user_pass'])) || ($new__user_id = wp_create_user($create_user['user_login'], $create_user['user_pass'], $create_user['user_email']))) && !is_wp_error($new__user_id)) {
                     update_user_option($new__user_id, 'default_password_nag', $has_custom_password ? FALSE : TRUE, TRUE);
                     wp_new_user_notification($new__user_id, $create_user['user_pass']);
                     if ($has_custom_password) {
                         $global_response = array('response' => sprintf(_x('<strong>Thank you.</strong> Please <a href="%s" rel="nofollow">login</a>.', 's2member-front', 'optimizemember'), esc_attr(wp_login_url())));
                     } else {
                         $global_response = array('response' => _x('<strong>Thank you.</strong> You\'ll receive an email momentarily.', 's2member-front', 's2member'));
                     }
                     if ($post_vars['attr']['success'] && substr($GLOBALS['ws_plugin__optimizemember_registration_return_url'], 0, 2) === substr($post_vars['attr']['success'], 0, 2) && ($custom_success_url = str_ireplace(array('%%s_response%%', '%%response%%'), array(urlencode(c_ws_plugin__optimizemember_utils_encryption::encrypt($global_response['response'])), urlencode($global_response['response'])), $GLOBALS['ws_plugin__optimizemember_registration_return_url'])) && ($custom_success_url = trim(preg_replace('/%%(.+?)%%/i', '', $custom_success_url)))) {
                         wp_redirect(c_ws_plugin__optimizemember_utils_urls::add_optimizemember_sig($custom_success_url, 's2p-v')) . exit;
                     }
                 } else {
                     $global_response = array('response' => _x('<strong>Oops.</strong> A slight problem. Please contact Support for assistance.', 's2member-front', 's2member'), 'error' => TRUE);
                 }
             } else {
                 // Input form field validation errors.
                 $global_response = $form_submission_validation_errors;
             }
         }
     }
 }
Beispiel #18
0
 /**
  * Handles the importation of Users/Members.
  *
  * @package optimizeMember\Imports
  * @since 110815
  *
  * @return null
  */
 public static function import_users()
 {
     if (!empty($_POST["ws_plugin__optimizemember_pro_import_users"]) && ($nonce = $_POST["ws_plugin__optimizemember_pro_import_users"]) && wp_verify_nonce($nonce, "ws-plugin--optimizemember-pro-import-users") && current_user_can("create_users")) {
         global $wpdb;
         global $current_site, $current_blog;
         /**/
         @set_time_limit(0);
         @ini_set("memory_limit", apply_filters("admin_memory_limit", WP_MAX_MEMORY_LIMIT));
         /**/
         remove_all_actions("profile_update") . remove_all_actions("user_register");
         remove_all_actions("added_existing_user") . remove_all_actions("add_user_to_blog");
         /**/
         if (!empty($_FILES["ws_plugin__optimizemember_pro_import_users_file"]) && empty($_FILES["ws_plugin__optimizemember_pro_import_users_file"]["error"])) {
             $file = fopen($_FILES["ws_plugin__optimizemember_pro_import_users_file"]["tmp_name"], "r");
         } else {
             if (!empty($_POST["ws_plugin__optimizemember_pro_import_users_direct_input"])) {
                 fwrite($file = tmpfile(), trim(stripslashes($_POST["ws_plugin__optimizemember_pro_import_users_direct_input"]))) . fseek($file, 0);
             }
         }
         /**/
         if (isset($file) && is_resource($file) && !($imported = 0)) {
             $custom_field_vars = array();
             if ($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["custom_reg_fields"]) {
                 foreach (json_decode($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["custom_reg_fields"], TRUE) as $field) {
                     $custom_field_var = preg_replace("/[^a-z0-9]/i", "_", strtolower($field["id"]));
                     $custom_field_vars[] = $custom_field_var;
                 }
             }
             sort($custom_field_vars, SORT_STRING);
             /**/
             while (($data = version_compare(PHP_VERSION, "5.3", ">=") ? fgetcsv($file, 0, ",", '"', '"') : fgetcsv($file, 0, ",", '"')) !== false) {
                 $line = (int) $line + 1;
                 /**/
                 $data = c_ws_plugin__optimizemember_utils_strings::trim_deep($data);
                 $data = stripslashes_deep($data);
                 /**/
                 if ($line === 1 && strtoupper($data[0]) === "ID") {
                     $line = $line - 1;
                     continue;
                 }
                 if (is_multisite() && c_ws_plugin__optimizemember_utils_conds::is_multisite_farm() && !is_main_site()) {
                     $ID = $data[0];
                     /**/
                     $user_login = preg_replace("/\\s+/", "", sanitize_user($data[1], is_multisite()));
                     $user_pass = (string) "";
                     /**/
                     $first_name = $data[2];
                     $last_name = $data[3];
                     $display_name = $data[4];
                     /**/
                     $user_email = sanitize_email($data[5]);
                     $user_url = $data[6];
                     /**/
                     $role = $data[7];
                     $custom_capabilities = $data[8];
                     /**/
                     $user_registered = $data[9] ? date("Y-m-d H:i:s", strtotime($data[9])) : "";
                     $paid_registration_times = $data[10] ? maybe_unserialize($data[10]) : "";
                     $last_payment_time = $data[11] ? strtotime($data[11]) : "";
                     $auto_eot_time = $data[12] ? strtotime($data[12]) : "";
                     /**/
                     $custom = $data[13];
                     $subscr_id = $data[14];
                     $subscr_gateway = strtolower($data[15]);
                     /**/
                     $custom_fields = array();
                     if (count($data) > 16) {
                         for ($i = 16, $j = 0; $i < count($data); $i++, $j++) {
                             if (isset($custom_field_vars[$j])) {
                                 $custom_fields[$custom_field_vars[$j]] = maybe_unserialize($data[$i]);
                             }
                         }
                     }
                 } else {
                     $ID = $data[0];
                     /**/
                     $user_login = preg_replace("/\\s+/", "", sanitize_user($data[1], is_multisite()));
                     $user_pass = $data[2];
                     /**/
                     $first_name = $data[3];
                     $last_name = $data[4];
                     $display_name = $data[5];
                     /**/
                     $user_email = sanitize_email($data[6]);
                     $user_url = $data[7];
                     /**/
                     $role = $data[8];
                     $custom_capabilities = $data[9];
                     /**/
                     $user_registered = $data[10] ? date("Y-m-d H:i:s", strtotime($data[10])) : "";
                     $paid_registration_times = $data[11] ? maybe_unserialize($data[11]) : "";
                     $last_payment_time = $data[12] ? strtotime($data[12]) : "";
                     $auto_eot_time = $data[13] ? strtotime($data[13]) : "";
                     /**/
                     $custom = $data[14];
                     $subscr_id = $data[15];
                     $subscr_gateway = strtolower($data[16]);
                     /**/
                     $custom_fields = array();
                     if (count($data) > 17) {
                         for ($i = 17, $j = 0; $i < count($data); $i++, $j++) {
                             if (isset($custom_field_vars[$j])) {
                                 $custom_fields[$custom_field_vars[$j]] = maybe_unserialize($data[$i]);
                             }
                         }
                     }
                 }
                 $role = is_numeric($role) ? $role == 0 ? "subscriber" : "optimizemember_level" . $role : $role;
                 /**/
                 if ($paid_registration_times && !is_array($paid_registration_times)) {
                     $paid_registration_times = array("level" => strtotime($paid_registration_times));
                 }
                 $paid_registration_times = !$paid_registration_times || !is_array($paid_registration_times) ? array() : $paid_registration_times;
                 /**/
                 $user_details = compact("ID", "user_login", "user_pass", "first_name", "last_name", "display_name", "user_email", "user_url", "role", "user_registered");
                 if (empty($user_details["user_pass"])) {
                     /* If there was NO Password given. */
                     unset($user_details["user_pass"]);
                 }
                 /* Unset the Password array element. */
                 /**/
                 if ($ID) {
                     if (is_object($user = new WP_User($ID)) && $user->ID) {
                         if (!is_multisite() || is_user_member_of_blog($ID)) {
                             if ((!is_multisite() || !is_super_admin($ID)) && !$user->has_cap("administrator")) {
                                 if (strtolower($role) !== "administrator") {
                                     if ($user_email && is_email($user_email)) {
                                         if ($user_login) {
                                             if (validate_username($user_login)) {
                                                 if (($_same_email = strtolower($user_email) === strtolower($user->user_email)) || !email_exists($user_email)) {
                                                     if (($_same_login = strtolower($user_login) === strtolower($user->user_login)) || !username_exists($user_login)) {
                                                         if (!is_multisite() || $_same_email && $_same_login || ($_ = wpmu_validate_user_signup($user_login, $user_email)) && (!is_wp_error($_["errors"]) || !$_["errors"]->get_error_code())) {
                                                             if (is_multisite() && c_ws_plugin__optimizemember_utils_conds::is_multisite_farm() && !is_main_site()) {
                                                                 unset($user_details["user_login"], $user_details["user_pass"]);
                                                             }
                                                             /**/
                                                             if ($user_id = wp_update_user($user_details)) {
                                                                 update_user_option($user_id, "optimizemember_custom", $custom);
                                                                 update_user_option($user_id, "optimizemember_subscr_id", $subscr_id);
                                                                 update_user_option($user_id, "optimizemember_subscr_gateway", $subscr_gateway);
                                                                 update_user_option($user_id, "optimizemember_auto_eot_time", $auto_eot_time);
                                                                 update_user_option($user_id, "optimizemember_paid_registration_times", $paid_registration_times);
                                                                 update_user_option($user_id, "optimizemember_last_payment_time", $last_payment_time);
                                                                 update_user_option($user_id, "optimizemember_custom_fields", $custom_fields);
                                                                 /**/
                                                                 foreach ($user->allcaps as $cap => $cap_enabled) {
                                                                     if (preg_match("/^access_optimizemember_ccap_/", $cap)) {
                                                                         $user->remove_cap($ccap = $cap);
                                                                     }
                                                                 }
                                                                 /**/
                                                                 if ($custom_capabilities && preg_replace("/^-all[\r\n\t\\s;,]*/", "", str_replace("+", "", $custom_capabilities))) {
                                                                     foreach (preg_split("/[\r\n\t\\s;,]+/", preg_replace("/^-all[\r\n\t\\s;,]*/", "", str_replace("+", "", $custom_capabilities))) as $ccap) {
                                                                         if (strlen($ccap = trim(strtolower(preg_replace("/[^a-z_0-9]/i", "", $ccap))))) {
                                                                             $user->add_cap("access_optimizemember_ccap_" . $ccap);
                                                                         }
                                                                     }
                                                                 }
                                                                 /**/
                                                                 $imported = $imported + 1;
                                                             } else {
                                                                 $errors[] = "Line #" . $line . ". User ID# <code>" . $ID . "</code> could NOT be updated. Unknown error, please try again.";
                                                             }
                                                         } else {
                                                             $errors[] = "Line #" . $line . ". Network. The Username and/or Email ( <code>" . esc_html($user_login) . "</code> / <code>" . esc_html($user_email) . "</code> ) are in conflict w/ Network rules.";
                                                         }
                                                     } else {
                                                         $errors[] = "Line #" . $line . ". Conflicting. The Username ( <code>" . esc_html($user_login) . "</code> ), already exists.";
                                                     }
                                                 } else {
                                                     $errors[] = "Line #" . $line . ". Conflicting. The Email address ( <code>" . esc_html($user_email) . "</code> ), already exists.";
                                                 }
                                             } else {
                                                 $errors[] = "Line #" . $line . ". Invalid Username ( <code>" . esc_html($user_login) . "</code> ). Lowercase alphanumerics are required.";
                                             }
                                         } else {
                                             $errors[] = "Line #" . $line . ". Missing Username; please try again.";
                                         }
                                         /* We have two separate errors for Usernames. This provides clarity. */
                                     } else {
                                         $errors[] = "Line #" . $line . ". Missing or invalid Email address ( <code>" . esc_html($user_email) . "</code> ); please try again.";
                                     }
                                 } else {
                                     $errors[] = "Line #" . $line . ". User ID# <code>" . $ID . "</code> cannot be updated to an Administrator. Bypassing this line for security.";
                                 }
                             } else {
                                 $errors[] = "Line #" . $line . ". User ID# <code>" . $ID . "</code> belongs to an Administrator. Bypassing this line for security.";
                             }
                         } else {
                             $errors[] = "Line #" . $line . ". User ID# <code>" . $ID . "</code> does NOT belong to an existing User on this site.";
                         }
                     } else {
                         $errors[] = "Line #" . $line . ". User ID# <code>" . $ID . "</code> does NOT belong to an existing User.";
                     }
                 } else {
                     if (is_multisite() && ($user_id = c_ws_plugin__optimizemember_utils_users::ms_user_login_email_exists_but_not_on_blog($user_login, $user_email)) && !is_super_admin($user_id)) {
                         if (strtolower($role) !== "administrator") {
                             if (add_existing_user_to_blog(array("user_id" => $user_id, "role" => $role))) {
                                 if (is_object($user = new WP_User($user_id)) && $user->ID) {
                                     update_user_option($user_id, "optimizemember_custom", $custom);
                                     update_user_option($user_id, "optimizemember_subscr_id", $subscr_id);
                                     update_user_option($user_id, "optimizemember_subscr_gateway", $subscr_gateway);
                                     update_user_option($user_id, "optimizemember_auto_eot_time", $auto_eot_time);
                                     update_user_option($user_id, "optimizemember_paid_registration_times", $paid_registration_times);
                                     update_user_option($user_id, "optimizemember_last_payment_time", $last_payment_time);
                                     update_user_option($user_id, "optimizemember_custom_fields", $custom_fields);
                                     /**/
                                     foreach ($user->allcaps as $cap => $cap_enabled) {
                                         if (preg_match("/^access_optimizemember_ccap_/", $cap)) {
                                             $user->remove_cap($ccap = $cap);
                                         }
                                     }
                                     /**/
                                     if ($custom_capabilities && preg_replace("/^-all[\r\n\t\\s;,]*/", "", str_replace("+", "", $custom_capabilities))) {
                                         foreach (preg_split("/[\r\n\t\\s;,]+/", preg_replace("/^-all[\r\n\t\\s;,]*/", "", str_replace("+", "", $custom_capabilities))) as $ccap) {
                                             if (strlen($ccap = trim(strtolower(preg_replace("/[^a-z_0-9]/i", "", $ccap))))) {
                                                 $user->add_cap("access_optimizemember_ccap_" . $ccap);
                                             }
                                         }
                                     }
                                     /**/
                                     $imported = $imported + 1;
                                 } else {
                                     $errors[] = "Line #" . $line . ". Unknown object error, please try again.";
                                 }
                             } else {
                                 $errors[] = "Line #" . $line . ". Unknown User/site addition error, please try again.";
                             }
                         } else {
                             $errors[] = "Line #" . $line . ". Role cannot be Administrator. Bypassing this line for security.";
                         }
                     } else {
                         if (strtolower($role) !== "administrator") {
                             if ($user_email && is_email($user_email)) {
                                 if ($user_login) {
                                     if (validate_username($user_login)) {
                                         if (!email_exists($user_email)) {
                                             if (!username_exists($user_login)) {
                                                 if (!is_multisite() || ($_ = wpmu_validate_user_signup($user_login, $user_email)) && (!is_wp_error($_["errors"]) || !$_["errors"]->get_error_code())) {
                                                     if ($user_id = wp_insert_user($user_details)) {
                                                         if (is_object($user = new WP_User($user_id)) && $user->ID) {
                                                             if ($user_pass) {
                                                                 /* If we are given an "un-encrypted Password". */
                                                                 wp_update_user(array("ID" => $user_id, "user_pass" => $user_pass));
                                                             }
                                                             /**/
                                                             if (is_multisite()) {
                                                                 /* New Users on a Multisite Network need this too. */
                                                                 update_user_meta($user_id, "optimizemember_originating_blog", $current_blog->blog_id);
                                                             }
                                                             /**/
                                                             update_user_option($user_id, "optimizemember_custom", $custom);
                                                             update_user_option($user_id, "optimizemember_subscr_id", $subscr_id);
                                                             update_user_option($user_id, "optimizemember_subscr_gateway", $subscr_gateway);
                                                             update_user_option($user_id, "optimizemember_auto_eot_time", $auto_eot_time);
                                                             update_user_option($user_id, "optimizemember_paid_registration_times", $paid_registration_times);
                                                             update_user_option($user_id, "optimizemember_last_payment_time", $last_payment_time);
                                                             update_user_option($user_id, "optimizemember_custom_fields", $custom_fields);
                                                             /**/
                                                             foreach ($user->allcaps as $cap => $cap_enabled) {
                                                                 if (preg_match("/^access_optimizemember_ccap_/", $cap)) {
                                                                     $user->remove_cap($ccap = $cap);
                                                                 }
                                                             }
                                                             /**/
                                                             if ($custom_capabilities && preg_replace("/^-all[\r\n\t\\s;,]*/", "", str_replace("+", "", $custom_capabilities))) {
                                                                 foreach (preg_split("/[\r\n\t\\s;,]+/", preg_replace("/^-all[\r\n\t\\s;,]*/", "", str_replace("+", "", $custom_capabilities))) as $ccap) {
                                                                     if (strlen($ccap = trim(strtolower(preg_replace("/[^a-z_0-9]/i", "", $ccap))))) {
                                                                         $user->add_cap("access_optimizemember_ccap_" . $ccap);
                                                                     }
                                                                 }
                                                             }
                                                             /**/
                                                             $imported = $imported + 1;
                                                         } else {
                                                             $errors[] = "Line #" . $line . ". Unknown object error, please try again.";
                                                         }
                                                     } else {
                                                         $errors[] = "Line #" . $line . ". Unknown insertion error, please try again.";
                                                     }
                                                 } else {
                                                     $errors[] = "Line #" . $line . ". Network. The Username and/or Email ( <code>" . esc_html($user_login) . "</code> / <code>" . esc_html($user_email) . "</code> ) are in conflict w/ Network rules.";
                                                 }
                                             } else {
                                                 $errors[] = "Line #" . $line . ". Conflicting. The Username ( <code>" . esc_html($user_login) . "</code> ), already exists.";
                                             }
                                         } else {
                                             $errors[] = "Line #" . $line . ". Conflicting. The Email address ( <code>" . esc_html($user_email) . "</code> ), already exists.";
                                         }
                                     } else {
                                         $errors[] = "Line #" . $line . ". Invalid Username ( <code>" . esc_html($user_login) . "</code> ). Lowercase alphanumerics are required.";
                                     }
                                 } else {
                                     $errors[] = "Line #" . $line . ". Missing Username; please try again.";
                                 }
                                 /* We have two separate errors for Usernames. This provides clarity. */
                             } else {
                                 $errors[] = "Line #" . $line . ". Missing or invalid Email address ( <code>" . esc_html($user_email) . "</code> ); please try again.";
                             }
                         } else {
                             $errors[] = "Line #" . $line . ". Role cannot be Administrator. Bypassing this line for security.";
                         }
                     }
                 }
             }
             /**/
             fclose($file);
         } else {
             $errors[] = "No data was received. Please try again.";
         }
         /* The upload failed, or it was empty. */
         /**/
         c_ws_plugin__optimizemember_admin_notices::display_admin_notice('Operation complete. Users/Members imported: <code>' . (int) $imported . '</code>.');
         /**/
         if (!empty($errors)) {
             /* Here is where a detailed error log will be returned to the Site Owner; as a way of clarifying what just happened during importation. */
             c_ws_plugin__optimizemember_admin_notices::display_admin_notice('<strong>The following errors were encountered during importation:</strong><ul style="font-size:80%; list-style:disc outside; margin-left:25px;"><li>' . implode("</li><li>", $errors) . '</li></ul>', true);
         }
     }
     /**/
     return;
     /* Return for uniformity. */
 }
 /**
  * Handles processing of Pro Form billing updates.
  *
  * @package optimizeMember\PayPal
  * @since 1.5
  *
  * @attaches-to ``add_action("init");``
  *
  * @return null Or exits script execution after a custom URL redirection.
  */
 public static function paypal_update()
 {
     if (!empty($_POST["optimizemember_pro_paypal_update"]["nonce"]) && ($nonce = $_POST["optimizemember_pro_paypal_update"]["nonce"]) && wp_verify_nonce($nonce, "s2member-pro-paypal-update")) {
         $GLOBALS["ws_plugin__optimizemember_pro_paypal_update_response"] = array();
         /* This holds the global response details. */
         $global_response =& $GLOBALS["ws_plugin__optimizemember_pro_paypal_update_response"];
         /* This is a shorter reference. */
         /**/
         $post_vars = c_ws_plugin__optimizemember_utils_strings::trim_deep(stripslashes_deep($_POST["optimizemember_pro_paypal_update"]));
         $post_vars["attr"] = unserialize(c_ws_plugin__optimizemember_utils_encryption::decrypt($post_vars["attr"]));
         /* And run a Filter. */
         $post_vars["attr"] = apply_filters("ws_plugin__optimizemember_pro_paypal_update_post_attr", $post_vars["attr"], get_defined_vars());
         /**/
         $post_vars["recaptcha_challenge_field"] = !$post_vars["recaptcha_challenge_field"] ? trim(stripslashes($_POST["recaptcha_challenge_field"])) : $post_vars["recaptcha_challenge_field"];
         $post_vars["recaptcha_response_field"] = !$post_vars["recaptcha_response_field"] ? trim(stripslashes($_POST["recaptcha_response_field"])) : $post_vars["recaptcha_response_field"];
         /**/
         if (!c_ws_plugin__optimizemember_pro_paypal_responses::paypal_form_attr_validation_errors($post_vars["attr"])) {
             if (!($error = c_ws_plugin__optimizemember_pro_paypal_responses::paypal_form_submission_validation_errors("update", $post_vars))) {
                 if ($post_vars["card_type"] === "PayPal") {
                     $global_response = array("response" => sprintf(_x('Please <a href="%s" rel="nofollow">log in at PayPal</a> to update your billing information.', "s2member-front", "s2member"), esc_attr("https://" . ($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["paypal_sandbox"] ? "www.sandbox.paypal.com" : "www.paypal.com") . "/")), "error" => true);
                 } else {
                     if (is_user_logged_in() && ($user = wp_get_current_user()) && ($user_id = $user->ID)) {
                         if (($paypal = array("METHOD" => "GetRecurringPaymentsProfileDetails")) && ($paypal["PROFILEID"] = $cur__subscr_id = get_user_option("optimizemember_subscr_id"))) {
                             if (($paypal = c_ws_plugin__optimizemember_paypal_utilities::paypal_api_response($paypal)) && empty($paypal["__error"]) && strlen($paypal["ACCT"]) === 4 && preg_match("/^(Active|ActiveProfile|Suspended|SuspendedProfile)\$/i", $paypal["STATUS"])) {
                                 $paypal = array();
                                 /* Reset the PayPal array. */
                                 /**/
                                 $paypal["METHOD"] = "UpdateRecurringPaymentsProfile";
                                 $paypal["PROFILEID"] = $cur__subscr_id;
                                 /**/
                                 $paypal["EMAIL"] = $user->user_email;
                                 $paypal["FIRSTNAME"] = $user->first_name;
                                 $paypal["LASTNAME"] = $user->last_name;
                                 /**/
                                 $paypal["CREDITCARDTYPE"] = $post_vars["card_type"];
                                 $paypal["ACCT"] = preg_replace("/[^0-9]/", "", $post_vars["card_number"]);
                                 $paypal["EXPDATE"] = preg_replace("/[^0-9]/", "", $post_vars["card_expiration"]);
                                 $paypal["CVV2"] = $post_vars["card_verification"];
                                 /**/
                                 if (in_array($post_vars["card_type"], array("Maestro", "Solo"))) {
                                     if (preg_match("/^[0-9]{2}\\/[0-9]{4}\$/", $post_vars["card_start_date_issue_number"])) {
                                         $paypal["STARTDATE"] = preg_replace("/[^0-9]/", "", $post_vars["card_start_date_issue_number"]);
                                     } else {
                                         /* Otherwise, we assume they provided an issue number instead. */
                                         $paypal["ISSUENUMBER"] = $post_vars["card_start_date_issue_number"];
                                     }
                                 }
                                 /**/
                                 $paypal["STREET"] = $post_vars["street"];
                                 $paypal["CITY"] = $post_vars["city"];
                                 $paypal["STATE"] = $post_vars["state"];
                                 $paypal["COUNTRYCODE"] = $post_vars["country"];
                                 $paypal["ZIP"] = $post_vars["zip"];
                                 /**/
                                 if (($paypal = c_ws_plugin__optimizemember_paypal_utilities::paypal_api_response($paypal)) && empty($paypal["__error"])) {
                                     $global_response = array("response" => _x('<strong>Confirmed.</strong> Your billing information has been updated.', "s2member-front", "s2member"));
                                     /**/
                                     if ($post_vars["attr"]["success"] && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__optimizemember_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $post_vars["attr"]["success"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
                                         wp_redirect(c_ws_plugin__optimizemember_utils_urls::add_optimizemember_sig($custom_success_url, "s2p-v")) . exit;
                                     }
                                 } else {
                                     $global_response = array("response" => $paypal["__error"], "error" => true);
                                 }
                             } else {
                                 if ($paypal && empty($paypal["__error"]) && strlen($paypal["ACCT"]) === 4 && preg_match("/^(Pending|PendingProfile)\$/i", $paypal["STATUS"])) {
                                     $global_response = array("response" => _x('<strong>Unable to update at this time.</strong> Your account is pending other changes. Please try again in 15 minutes.', "s2member-front", "s2member"), "error" => true);
                                 } else {
                                     if ($paypal && empty($paypal["__error"]) && strlen($paypal["ACCT"]) === 4 && !preg_match("/^(Active|ActiveProfile|Suspended|SuspendedProfile)\$/i", $paypal["STATUS"])) {
                                         $global_response = array("response" => _x('<strong>Unable to update.</strong> You have NO recurring fees. Or, your billing profile is no longer active. Please contact Support if you need assistance.', "s2member-front", "s2member"), "error" => true);
                                     } else {
                                         if ($paypal && empty($paypal["__error"]) && strlen($paypal["ACCT"]) !== 4) {
                                             $global_response = array("response" => sprintf(_x('Please <a href="%s" rel="nofollow">log in at PayPal</a> to update your billing information.', "s2member-front", "s2member"), esc_attr("https://" . ($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["paypal_sandbox"] ? "www.sandbox.paypal.com" : "www.paypal.com") . "/")), "error" => true);
                                         } else {
                                             if ($paypal && !empty($paypal["__error"]) && $paypal["L_ERRORCODE0"] === "11592") {
                                                 $global_response = array("response" => sprintf(_x('Please <a href="%s" rel="nofollow">log in at PayPal</a> to update your billing information.', "s2member-front", "s2member"), esc_attr("https://" . ($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["paypal_sandbox"] ? "www.sandbox.paypal.com" : "www.paypal.com") . "/")), "error" => true);
                                             } else {
                                                 $global_response = array("response" => $paypal["__error"], "error" => true);
                                             }
                                         }
                                     }
                                 }
                             }
                         } else {
                             $global_response = array("response" => _x('<strong>Oops.</strong> No Subscr. ID. Please contact Support for assistance.', "s2member-front", "s2member"), "error" => true);
                         }
                     } else {
                         $global_response = array("response" => _x('You\'re <strong>NOT</strong> logged in.', "s2member-front", "s2member"), "error" => true);
                     }
                 }
             } else {
                 $global_response = $error;
             }
         }
     }
 }
Beispiel #20
0
 /**
  * Saves data entered into meta boxes on Post/Page editing stations.
  *
  * @package optimizeMember\Meta_Boxes
  * @since 3.5
  *
  * @attaches-to ``add_action("save_post");``
  *
  * @param int|str $post_id Numeric Post/Page ID.
  * @return null
  */
 public static function save_meta_boxes($post_id = FALSE)
 {
     eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
     do_action("ws_plugin__optimizemember_before_save_meta_boxes", get_defined_vars());
     unset($__refs, $__v);
     /* Unset defined __refs, __v. */
     /**/
     if ($post_id && !empty($_POST["ws_plugin__optimizemember_security_meta_box_save"]) && ($nonce = $_POST["ws_plugin__optimizemember_security_meta_box_save"]) && wp_verify_nonce($nonce, "ws-plugin--optimizemember-security-meta-box-save")) {
         if (!empty($_POST["ws_plugin__optimizemember_security_meta_box_save_id"]) && $post_id == $_POST["ws_plugin__optimizemember_security_meta_box_save_id"] && !empty($_POST["post_type"])) {
             $_p = c_ws_plugin__optimizemember_utils_strings::trim_deep(stripslashes_deep($_POST));
             /* Clean and create a local copy. */
             /**/
             if ($_p["post_type"] === "page" && current_user_can("edit_page", $post_id) || current_user_can("edit_post", $post_id)) {
                 if ($_p["post_type"] === "page" && ($page_id = $post_id)) {
                     if (isset($_p["ws_plugin__optimizemember_security_meta_box_level"])) {
                         for ($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["optimizemember"]["c"]["levels"]; $n++) {
                             $pages[$n] = array_unique(preg_split("/[\r\n\t\\s;,]+/", $GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["level" . $n . "_pages"]));
                         }
                         /**/
                         for ($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["optimizemember"]["c"]["levels"]; $n++) {
                             $posts[$n] = array_unique(preg_split("/[\r\n\t\\s;,]+/", $GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["level" . $n . "_posts"]));
                         }
                         /**/
                         for ($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["optimizemember"]["c"]["levels"]; $n++) {
                             if (($i = array_search($page_id, $pages[$n])) !== false) {
                                 unset($pages[$n][$i]);
                             }
                         }
                         /**/
                         if (isset($pages[$_p["ws_plugin__optimizemember_security_meta_box_level"]]) && is_array($pages[$_p["ws_plugin__optimizemember_security_meta_box_level"]])) {
                             if ($pages[$_p["ws_plugin__optimizemember_security_meta_box_level"]] !== array("all") && !in_array("all-pages", $posts[$_p["ws_plugin__optimizemember_security_meta_box_level"]])) {
                                 array_push($pages[$_p["ws_plugin__optimizemember_security_meta_box_level"]], (string) $page_id);
                             }
                         }
                         /**/
                         for ($n = 0, $new_options = array(); $n <= $GLOBALS["WS_PLUGIN__"]["optimizemember"]["c"]["levels"]; $n++) {
                             $new_options = array_merge($new_options, array("ws_plugin__optimizemember_level" . $n . "_pages" => trim(implode(",", $pages[$n]))));
                         }
                         /**/
                         eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
                         do_action("ws_plugin__optimizemember_during_save_meta_boxes", get_defined_vars());
                         unset($__refs, $__v);
                         /* Unset defined __refs, __v. */
                         /**/
                         c_ws_plugin__optimizemember_menu_pages::update_all_options($new_options, true, false, array("page-conflict-warnings"), true);
                     }
                 } else {
                     if (isset($_p["ws_plugin__optimizemember_security_meta_box_level"])) {
                         for ($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["optimizemember"]["c"]["levels"]; $n++) {
                             $posts[$n] = array_unique(preg_split("/[\r\n\t\\s;,]+/", $GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["level" . $n . "_posts"]));
                         }
                         /**/
                         for ($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["optimizemember"]["c"]["levels"]; $n++) {
                             if (($i = array_search($post_id, $posts[$n])) !== false) {
                                 unset($posts[$n][$i]);
                             }
                         }
                         /**/
                         if (isset($posts[$_p["ws_plugin__optimizemember_security_meta_box_level"]]) && is_array($posts[$_p["ws_plugin__optimizemember_security_meta_box_level"]])) {
                             if ($posts[$_p["ws_plugin__optimizemember_security_meta_box_level"]] !== array("all") && !in_array("all-" . $_p["post_type"] . "s", $posts[$_p["ws_plugin__optimizemember_security_meta_box_level"]])) {
                                 array_push($posts[$_p["ws_plugin__optimizemember_security_meta_box_level"]], (string) $post_id);
                             }
                         }
                         /**/
                         for ($n = 0, $new_options = array(); $n <= $GLOBALS["WS_PLUGIN__"]["optimizemember"]["c"]["levels"]; $n++) {
                             $new_options = array_merge($new_options, array("ws_plugin__optimizemember_level" . $n . "_posts" => trim(implode(",", $posts[$n]))));
                         }
                         /**/
                         eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
                         do_action("ws_plugin__optimizemember_during_save_meta_boxes", get_defined_vars());
                         unset($__refs, $__v);
                         /* Unset defined __refs, __v. */
                         /**/
                         c_ws_plugin__optimizemember_menu_pages::update_all_options($new_options, true, false, array("page-conflict-warnings"), true);
                     }
                 }
                 /**/
                 if ($_p["post_type"] === "page" && ($page_id = $post_id)) {
                     if (isset($_p["ws_plugin__optimizemember_security_meta_box_ccaps"])) {
                         $ccaps_req = trim(strtolower($_p["ws_plugin__optimizemember_security_meta_box_ccaps"]), ",");
                         $ccaps_req = trim(preg_replace("/[^a-z_0-9,]/", "", $ccaps_req), ",");
                         /**/
                         if (strlen($ccaps_req) && ($optimizemember_ccaps_req = preg_split("/[\r\n\t\\s;,]+/", $ccaps_req))) {
                             update_post_meta($page_id, "optimizemember_ccaps_req", $optimizemember_ccaps_req);
                         } else {
                             /* Otherwise, the array is empty. Safe to delete. */
                             delete_post_meta($page_id, "optimizemember_ccaps_req");
                         }
                     }
                     if (isset($_p["ws_plugin__optimizemember_drip_days"])) {
                         $drip_days = trim($_p["ws_plugin__optimizemember_drip_days"]);
                         /**/
                         if (strlen($drip_days)) {
                             update_post_meta($page_id, "optimizemember_drip_days", $drip_days);
                         } else {
                             /* Otherwise, the array is empty. Safe to delete. */
                             delete_post_meta($page_id, "optimizemember_drip_days");
                         }
                     }
                     if (isset($_p["ws_plugin__optimizemember_drip_redirect_url"])) {
                         $drip_redirect_url = trim($_p["ws_plugin__optimizemember_drip_redirect_url"]);
                         /**/
                         if (strlen($drip_redirect_url)) {
                             update_post_meta($page_id, "optimizemember_drip_redirect_url", $drip_redirect_url);
                         } else {
                             /* Otherwise, the array is empty. Safe to delete. */
                             delete_post_meta($page_id, "optimizemember_drip_redirect_url");
                         }
                     }
                     if (isset($_p["ws_plugin__optimizemember_force_ssl"])) {
                         $force_ssl = trim($_p["ws_plugin__optimizemember_force_ssl"]);
                         /**/
                         if (strlen($force_ssl)) {
                             update_post_meta($page_id, "optimizemember_force_ssl", $force_ssl);
                         } else {
                             /* Otherwise, the array is empty. Safe to delete. */
                             delete_post_meta($page_id, "optimizemember_force_ssl");
                         }
                     } else {
                         delete_post_meta($page_id, "optimizemember_force_ssl");
                     }
                 } else {
                     //die(print_r($_p));
                     if (isset($_p["ws_plugin__optimizemember_security_meta_box_ccaps"])) {
                         $ccaps_req = trim(strtolower($_p["ws_plugin__optimizemember_security_meta_box_ccaps"]), ",");
                         $ccaps_req = trim(preg_replace("/[^a-z_0-9,]/", "", $ccaps_req), ",");
                         /**/
                         if (strlen($ccaps_req) && ($optimizemember_ccaps_req = preg_split("/[\r\n\t\\s;,]+/", $ccaps_req))) {
                             update_post_meta($post_id, "optimizemember_ccaps_req", $optimizemember_ccaps_req);
                         } else {
                             /* Otherwise, the array is empty. Safe to delete. */
                             delete_post_meta($post_id, "optimizemember_ccaps_req");
                         }
                     }
                     if (isset($_p["ws_plugin__optimizemember_drip_days"])) {
                         $drip_days = trim($_p["ws_plugin__optimizemember_drip_days"]);
                         /**/
                         if (strlen($drip_days)) {
                             update_post_meta($post_id, "optimizemember_drip_days", $drip_days);
                         } else {
                             /* Otherwise, the array is empty. Safe to delete. */
                             delete_post_meta($post_id, "optimizemember_drip_days");
                         }
                     }
                     if (isset($_p["ws_plugin__optimizemember_drip_redirect_url"])) {
                         $drip_redirect_url = trim($_p["ws_plugin__optimizemember_drip_redirect_url"]);
                         /**/
                         if (strlen($drip_redirect_url)) {
                             update_post_meta($post_id, "optimizemember_drip_redirect_url", $drip_redirect_url);
                         } else {
                             /* Otherwise, the array is empty. Safe to delete. */
                             delete_post_meta($post_id, "optimizemember_drip_redirect_url");
                         }
                     }
                     if (isset($_p["ws_plugin__optimizemember_force_ssl"])) {
                         $force_ssl = trim($_p["ws_plugin__optimizemember_force_ssl"]);
                         /**/
                         if (strlen($force_ssl)) {
                             update_post_meta($post_id, "optimizemember_force_ssl", $force_ssl);
                         } else {
                             /* Otherwise, the array is empty. Safe to delete. */
                             delete_post_meta($post_id, "optimizemember_force_ssl");
                         }
                     } else {
                         delete_post_meta($post_id, "optimizemember_force_ssl");
                     }
                 }
             }
         }
     }
     /**/
     do_action("ws_plugin__optimizemember_after_save_meta_boxes", get_defined_vars());
     /**/
     return;
     /* Return for uniformity. */
 }
Beispiel #21
0
 /**
  * Generates Specific Post/Page Access links via AJAX.
  *
  * @package optimizeMember\SP_Access
  * @since 3.5
  *
  * @attaches-to ``add_action("wp_ajax_ws_plugin__optimizemember_sp_access_link_via_ajax");``
  *
  * @return null Exits script execution after returning data for AJAX caller.
  */
 public static function sp_access_link_via_ajax()
 {
     do_action("ws_plugin__optimizemember_before_sp_access_link_via_ajax", get_defined_vars());
     /**/
     status_header(200);
     /* Send a 200 OK status header. */
     header("Content-Type: text/plain; charset=utf-8");
     /* Content-Type with UTF-8. */
     eval('while (@ob_end_clean ());');
     /* End/clean all output buffers that may exist. */
     /**/
     if (current_user_can("create_users")) {
         /* Check priveledges as well. Ability to create Users? */
         /**/
         if (!empty($_POST["ws_plugin__optimizemember_sp_access_link_via_ajax"]) && is_string($nonce = $_POST["ws_plugin__optimizemember_sp_access_link_via_ajax"]) && wp_verify_nonce($nonce, "ws-plugin--optimizemember-sp-access-link-via-ajax")) {
             /**/
             if (($_p = c_ws_plugin__optimizemember_utils_strings::trim_deep(stripslashes_deep($_POST))) && isset($_p["optimizemember_sp_access_link_ids"], $_p["optimizemember_sp_access_link_hours"])) {
                 $sp_access_link = c_ws_plugin__optimizemember_sp_access::sp_access_link_gen((string) $_p["optimizemember_sp_access_link_ids"], (string) $_p["optimizemember_sp_access_link_hours"]);
             }
         }
     }
     /**/
     exit(apply_filters("ws_plugin__optimizemember_sp_access_link_via_ajax", !empty($sp_access_link) ? $sp_access_link : "", get_defined_vars()));
 }
 /**
  * Handles processing of Pro Form cancellations.
  *
  * @package optimizeMember\AuthNet
  * @since 1.5
  *
  * @attaches-to ``add_action("init");``
  *
  * @return null Or exits script execution after a custom URL redirection.
  */
 public static function authnet_cancellation()
 {
     if (!empty($_POST["optimizemember_pro_authnet_cancellation"]["nonce"]) && ($nonce = $_POST["optimizemember_pro_authnet_cancellation"]["nonce"]) && wp_verify_nonce($nonce, "s2member-pro-authnet-cancellation")) {
         $GLOBALS["ws_plugin__optimizemember_pro_authnet_cancellation_response"] = array();
         /* This holds the global response details. */
         $global_response =& $GLOBALS["ws_plugin__optimizemember_pro_authnet_cancellation_response"];
         /* This is a shorter reference. */
         /**/
         $post_vars = c_ws_plugin__optimizemember_utils_strings::trim_deep(stripslashes_deep($_POST["optimizemember_pro_authnet_cancellation"]));
         $post_vars["attr"] = unserialize(c_ws_plugin__optimizemember_utils_encryption::decrypt($post_vars["attr"]));
         /* And run a Filter. */
         $post_vars["attr"] = apply_filters("ws_plugin__optimizemember_pro_authnet_cancellation_post_attr", $post_vars["attr"], get_defined_vars());
         /**/
         $post_vars["recaptcha_challenge_field"] = !$post_vars["recaptcha_challenge_field"] ? trim(stripslashes($_POST["recaptcha_challenge_field"])) : $post_vars["recaptcha_challenge_field"];
         $post_vars["recaptcha_response_field"] = !$post_vars["recaptcha_response_field"] ? trim(stripslashes($_POST["recaptcha_response_field"])) : $post_vars["recaptcha_response_field"];
         /**/
         if (!c_ws_plugin__optimizemember_pro_authnet_responses::authnet_form_attr_validation_errors($post_vars["attr"])) {
             if (!($error = c_ws_plugin__optimizemember_pro_authnet_responses::authnet_form_submission_validation_errors("cancellation", $post_vars))) {
                 if (is_user_logged_in() && is_object($user = wp_get_current_user()) && ($user_id = $user->ID)) {
                     if (($authnet = array("x_method" => "status")) && ($authnet["x_subscription_id"] = $cur__subscr_id = get_user_option("optimizemember_subscr_id"))) {
                         if (($authnet = c_ws_plugin__optimizemember_pro_authnet_utilities::authnet_arb_response($authnet)) && empty($authnet["__error"]) && $authnet["subscription_status"]) {
                             if (preg_match("/^(active|suspended)\$/i", $authnet["subscription_status"])) {
                                 if (!($ipn = array())) {
                                     /* With Authorize.Net, we need their IPN signup vars. */
                                     if (is_array($ipn_signup_vars = c_ws_plugin__optimizemember_utils_users::get_user_ipn_signup_vars())) {
                                         $ipn["txn_type"] = "subscr_cancel";
                                         $ipn["subscr_id"] = $ipn_signup_vars["subscr_id"];
                                         $ipn["custom"] = $ipn_signup_vars["custom"];
                                         /**/
                                         $ipn["period1"] = $ipn_signup_vars["period1"];
                                         $ipn["period3"] = $ipn_signup_vars["period3"];
                                         /**/
                                         $ipn["payer_email"] = $ipn_signup_vars["payer_email"];
                                         $ipn["first_name"] = $ipn_signup_vars["first_name"];
                                         $ipn["last_name"] = $ipn_signup_vars["last_name"];
                                         /**/
                                         $ipn["option_name1"] = $ipn_signup_vars["option_name1"];
                                         $ipn["option_selection1"] = $ipn_signup_vars["option_selection1"];
                                         /**/
                                         $ipn["option_name2"] = $ipn_signup_vars["option_name2"];
                                         $ipn["option_selection2"] = $ipn_signup_vars["option_selection2"];
                                         /**/
                                         $ipn["item_name"] = $ipn_signup_vars["item_name"];
                                         $ipn["item_number"] = $ipn_signup_vars["item_number"];
                                         /**/
                                         $ipn_q = "&optimizemember_paypal_proxy=authnet&optimizemember_paypal_proxy_use=pro-emails";
                                         $ipn_q .= "&optimizemember_paypal_proxy_verification=" . urlencode(c_ws_plugin__optimizemember_paypal_utilities::paypal_proxy_key_gen());
                                         /**/
                                         c_ws_plugin__optimizemember_utils_urls::remote(site_url("/?optimizemember_paypal_notify=1" . $ipn_q), $ipn, array("timeout" => 20));
                                     }
                                 }
                                 /**/
                                 if ($authnet = array("x_method" => "cancel", "x_subscription_id" => $cur__subscr_id)) {
                                     c_ws_plugin__optimizemember_pro_authnet_utilities::authnet_arb_response($authnet);
                                     /**/
                                     $global_response = array("response" => _x('<strong>Billing termination confirmed.</strong> Your account has been cancelled.', "s2member-front", "s2member"));
                                     /**/
                                     if ($post_vars["attr"]["success"] && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__optimizemember_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $post_vars["attr"]["success"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
                                         wp_redirect(c_ws_plugin__optimizemember_utils_urls::add_optimizemember_sig($custom_success_url, "s2p-v")) . exit;
                                     }
                                 }
                             } else {
                                 $global_response = array("response" => _x('<strong>Billing terminated.</strong> Your account has been cancelled.', "s2member-front", "s2member"));
                                 /**/
                                 if ($post_vars["attr"]["success"] && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__optimizemember_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $post_vars["attr"]["success"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
                                     wp_redirect(c_ws_plugin__optimizemember_utils_urls::add_optimizemember_sig($custom_success_url, "s2p-v")) . exit;
                                 }
                             }
                         } else {
                             $global_response = array("response" => _x('<strong>Billing terminated.</strong> Your account has been cancelled.', "s2member-front", "s2member"));
                             /**/
                             if ($post_vars["attr"]["success"] && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__optimizemember_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $post_vars["attr"]["success"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
                                 wp_redirect(c_ws_plugin__optimizemember_utils_urls::add_optimizemember_sig($custom_success_url, "s2p-v")) . exit;
                             }
                         }
                     } else {
                         $global_response = array("response" => _x('<strong>Billing terminated.</strong> Your account has been cancelled.', "s2member-front", "s2member"));
                         /**/
                         if ($post_vars["attr"]["success"] && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__optimizemember_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $post_vars["attr"]["success"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
                             wp_redirect(c_ws_plugin__optimizemember_utils_urls::add_optimizemember_sig($custom_success_url, "s2p-v")) . exit;
                         }
                     }
                 } else {
                     $global_response = array("response" => _x('You\'re <strong>NOT</strong> logged in.', "s2member-front", "s2member"), "error" => true);
                 }
             } else {
                 $global_response = $error;
             }
         }
     }
 }
 /**
  * Handles processing of Pro Form cancellations.
  *
  * @package optimizeMember\PayPal
  * @since 1.5
  *
  * @attaches-to ``add_action("init");``
  *
  * @return null Or exits script execution after a custom URL redirection.
  */
 public static function paypal_cancellation()
 {
     if (!empty($_POST["optimizemember_pro_paypal_cancellation"]["nonce"]) && ($nonce = $_POST["optimizemember_pro_paypal_cancellation"]["nonce"]) && wp_verify_nonce($nonce, "s2member-pro-paypal-cancellation")) {
         $GLOBALS["ws_plugin__optimizemember_pro_paypal_cancellation_response"] = array();
         /* This holds the global response details. */
         $global_response =& $GLOBALS["ws_plugin__optimizemember_pro_paypal_cancellation_response"];
         /* This is a shorter reference. */
         /**/
         $post_vars = c_ws_plugin__optimizemember_utils_strings::trim_deep(stripslashes_deep($_POST["optimizemember_pro_paypal_cancellation"]));
         $post_vars["attr"] = unserialize(c_ws_plugin__optimizemember_utils_encryption::decrypt($post_vars["attr"]));
         /* And run a Filter. */
         $post_vars["attr"] = apply_filters("ws_plugin__optimizemember_pro_paypal_cancellation_post_attr", $post_vars["attr"], get_defined_vars());
         /**/
         $post_vars["recaptcha_challenge_field"] = !$post_vars["recaptcha_challenge_field"] ? trim(stripslashes($_POST["recaptcha_challenge_field"])) : $post_vars["recaptcha_challenge_field"];
         $post_vars["recaptcha_response_field"] = !$post_vars["recaptcha_response_field"] ? trim(stripslashes($_POST["recaptcha_response_field"])) : $post_vars["recaptcha_response_field"];
         /**/
         if (!c_ws_plugin__optimizemember_pro_paypal_responses::paypal_form_attr_validation_errors($post_vars["attr"])) {
             if (!($error = c_ws_plugin__optimizemember_pro_paypal_responses::paypal_form_submission_validation_errors("cancellation", $post_vars))) {
                 if (is_user_logged_in() && is_object($user = wp_get_current_user()) && ($user_id = $user->ID)) {
                     if ($cur__subscr_id = get_user_option("optimizemember_subscr_id")) {
                         if (($paypal = c_ws_plugin__optimizemember_pro_paypal_utilities::payflow_get_profile($cur__subscr_id)) && $paypal["TENDER"] !== "P") {
                             if (preg_match("/^(Active|ActiveProfile|Suspended|SuspendedProfile)\$/i", $paypal["STATUS"])) {
                                 if (!($ipn = array())) {
                                     $ipn["txn_type"] = "subscr_cancel";
                                     $ipn["subscr_id"] = $paypal["PROFILEID"];
                                     $ipn["custom"] = get_user_option("optimizemember_custom");
                                     /**/
                                     $ipn["period1"] = c_ws_plugin__optimizemember_paypal_utilities::paypal_pro_period1($paypal);
                                     $ipn["period3"] = c_ws_plugin__optimizemember_paypal_utilities::paypal_pro_period3($paypal);
                                     /**/
                                     $ipn["payer_email"] = $paypal["EMAIL"];
                                     $ipn["first_name"] = $paypal["FIRSTNAME"];
                                     $ipn["last_name"] = $paypal["LASTNAME"];
                                     /**/
                                     $ipn["option_name1"] = "Referencing Customer ID";
                                     $ipn["option_selection1"] = $paypal["PROFILEID"];
                                     /**/
                                     $ipn["option_name2"] = "Customer IP Address";
                                     /* IP Address. */
                                     $ipn["option_selection2"] = get_user_option("optimizemember_registration_ip");
                                     /**/
                                     $ipn["item_name"] = $paypal["DESC"] ? $paypal["DESC"] : $paypal["PROFILENAME"];
                                     $ipn["item_number"] = c_ws_plugin__optimizemember_paypal_utilities::paypal_pro_item_number($paypal);
                                     /**/
                                     $ipn_q = "&optimizemember_paypal_proxy=paypal&optimizemember_paypal_proxy_use=pro-emails";
                                     $ipn_q .= "&optimizemember_paypal_proxy_verification=" . urlencode(c_ws_plugin__optimizemember_paypal_utilities::paypal_proxy_key_gen());
                                     /**/
                                     c_ws_plugin__optimizemember_utils_urls::remote(site_url("/?optimizemember_paypal_notify=1" . $ipn_q), $ipn, array("timeout" => 20));
                                 }
                                 /**/
                                 c_ws_plugin__optimizemember_pro_paypal_utilities::payflow_cancel_profile($paypal["PROFILEID"]);
                                 /**/
                                 $global_response = array("response" => _x('<strong>Billing termination confirmed.</strong> Your account has been cancelled.', "s2member-front", "s2member"));
                                 /**/
                                 if ($post_vars["attr"]["success"] && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__optimizemember_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $post_vars["attr"]["success"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
                                     wp_redirect(c_ws_plugin__optimizemember_utils_urls::add_optimizemember_sig($custom_success_url, "s2p-v")) . exit;
                                 }
                             } else {
                                 if (preg_match("/^(Pending|PendingProfile)\$/i", $paypal["STATUS"])) {
                                     $global_response = array("response" => _x('<strong>Unable to cancel at this time.</strong> Your account is pending other changes. Please try again in 15 minutes.', "s2member-front", "s2member"), "error" => true);
                                 } else {
                                     $global_response = array("response" => _x('<strong>Billing terminated.</strong> Your account has been cancelled.', "s2member-front", "s2member"));
                                     /**/
                                     if ($post_vars["attr"]["success"] && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__optimizemember_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $post_vars["attr"]["success"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
                                         wp_redirect(c_ws_plugin__optimizemember_utils_urls::add_optimizemember_sig($custom_success_url, "s2p-v")) . exit;
                                     }
                                 }
                             }
                         } else {
                             if ($paypal && $paypal["TENDER"] === "P") {
                                 $global_response = array("response" => sprintf(_x('Please <a href="%s" rel="nofollow">log in at PayPal</a> to cancel your Subscription.', "s2member-front", "s2member"), esc_attr("https://" . ($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["paypal_sandbox"] ? "www.sandbox.paypal.com" : "www.paypal.com") . "/cgi-bin/webscr?cmd=_subscr-find&amp;alias=" . urlencode($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["paypal_business"]))), "error" => true);
                             } else {
                                 $global_response = array("response" => _x('<strong>Billing terminated.</strong> Your account has been cancelled.', "s2member-front", "s2member"));
                                 /**/
                                 if ($post_vars["attr"]["success"] && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__optimizemember_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $post_vars["attr"]["success"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
                                     wp_redirect(c_ws_plugin__optimizemember_utils_urls::add_optimizemember_sig($custom_success_url, "s2p-v")) . exit;
                                 }
                             }
                         }
                     } else {
                         $global_response = array("response" => _x('<strong>Billing terminated.</strong> Your account has been cancelled.', "s2member-front", "s2member"));
                         /**/
                         if ($post_vars["attr"]["success"] && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__optimizemember_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $post_vars["attr"]["success"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
                             wp_redirect(c_ws_plugin__optimizemember_utils_urls::add_optimizemember_sig($custom_success_url, "s2p-v")) . exit;
                         }
                     }
                 } else {
                     $global_response = array("response" => _x('You\'re <strong>NOT</strong> logged in.', "s2member-front", "s2member"), "error" => true);
                 }
             } else {
                 $global_response = $error;
             }
         }
     }
 }
 /**
  * Checks to see if a Coupon Code was supplied, and if so; what does it provide?
  *
  * @package optimizeMember\PayPal
  * @since 1.5
  *
  * @param array $attr An array of Pro Form Attributes.
  * @param str $coupon_code Optional. A possible Coupon Code supplied by the Customer.
  * @param str $return Optional. Return type. One of `response|attr`. Defaults to `attr`.
  * @param array $process Optional. An array of additional processing routines to run here.
  * 	One or more of these values: `affiliates-1px-response|affiliates-silent-post|notifications`.
  * @return array|str Original array, with prices and description modified when/if a Coupon Code is accepted.
  * 	Or, if ``$return === "response"``, return a string response, indicating status.
  *
  * @todo See if it's possible to simplify this routine.
  * @todo Add support for tracking Coupon Code usage.
  * @todo Add support for a fixed number of uses.
  */
 public static function paypal_apply_coupon($attr = FALSE, $coupon_code = FALSE, $return = FALSE, $process = FALSE)
 {
     if (($coupon_code = trim(strtolower($coupon_code))) || ($coupon_code = trim(strtolower($attr["coupon"])))) {
         if ($attr["accept_coupons"] && $GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["pro_coupon_codes"]) {
             $cs = c_ws_plugin__optimizemember_utils_cur::symbol($attr["cc"]);
             $tx = c_ws_plugin__optimizemember_pro_paypal_utilities::paypal_tax_may_apply() ? _x(" + tax", "s2member-front", "s2member") : "";
             $ps = _x("%", "s2member-front percentage-symbol", "s2member");
             /**/
             if (strlen($affiliate_suffix_chars = $GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["pro_affiliate_coupon_code_suffix_chars"])) {
                 if (preg_match("/^(.+?)" . preg_quote($affiliate_suffix_chars, "/") . "([0-9]+)\$/i", $coupon_code, $m)) {
                     ($full_coupon_code = $m[0]) . ($coupon_code = $m[1]) . ($affiliate_id = $m[2]);
                 }
             }
             unset($affiliate_suffix_chars, $m);
             /**/
             foreach (c_ws_plugin__optimizemember_utils_strings::trim_deep(preg_split("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["pro_coupon_codes"])) as $_line) {
                 if (($_line = trim($_line, " \r\n\t\v|")) && is_array($_coupon = preg_split("/\\|/", $_line))) {
                     $coupon["code"] = !empty($_coupon[0]) ? trim(strtolower($_coupon[0])) : "";
                     /**/
                     $coupon["percentage"] = !empty($_coupon[1]) && preg_match("/%/", $_coupon[1]) ? (double) $_coupon[1] : 0;
                     $coupon["flat-rate"] = !empty($_coupon[1]) && !preg_match("/%/", $_coupon[1]) ? (double) $_coupon[1] : 0;
                     /**/
                     $coupon["expired"] = !empty($_coupon[2]) && strtotime($_coupon[2]) < time() ? $_coupon[2] : false;
                     /**/
                     $coupon["directive"] = !empty($_coupon[3]) && ($_coupon[3] = strtolower($_coupon[3])) ? preg_replace("/_/", "-", $_coupon[3]) : "all";
                     $coupon["directive"] = preg_match("/^(ta-only|ra-only|all)\$/", $coupon["directive"]) ? $coupon["directive"] : "all";
                     /**/
                     $coupon["singulars"] = !empty($_coupon[4]) && ($_coupon[4] = strtolower($_coupon[4])) && $_coupon[4] !== "all" ? $_coupon[4] : "all";
                     $coupon["singulars"] = $coupon["singulars"] !== "all" ? preg_split("/[\r\n\t\\s;,]+/", trim(preg_replace("/[^0-9,]/", "", $coupon["singulars"]), ",")) : array("all");
                     /**/
                     unset($_line, $_coupon);
                     /**/
                     if ($coupon_code === $coupon["code"] && !$coupon["expired"]) {
                         if ($coupon["singulars"] === array("all") || in_array($attr["singular"], $coupon["singulars"])) {
                             $coupon_accepted = true;
                             /**/
                             if ($coupon["flat-rate"]) {
                                 if (($coupon["directive"] === "ra-only" || $coupon["directive"] === "all") && $attr["sp"]) {
                                     $coupon_applies = true;
                                     /**/
                                     $ta = number_format($attr["ta"], 2, ".", "");
                                     $ta = $ta >= 0.0 ? $ta : "0.00";
                                     /**/
                                     $ra = number_format($attr["ra"] - $coupon["flat-rate"], 2, ".", "");
                                     $ra = $ra >= 0.01 ? $ra : "0.01";
                                     /**/
                                     $desc = sprintf(_x("COUPON %s off. ( Now: %s )", "s2member-front", "s2member"), $cs . number_format($coupon["flat-rate"], 2, ".", ""), $cs . $ra . $tx);
                                     $response = sprintf(_x('<div>Coupon: <strong>%s off</strong>. ( Now: <strong>%s</strong> )</div>', "s2member-front", "s2member"), $cs . number_format($coupon["flat-rate"], 2, ".", ""), $cs . $ra . $tx);
                                 } else {
                                     if ($coupon["directive"] === "ta-only" && $attr["tp"] && !$attr["sp"]) {
                                         $coupon_applies = true;
                                         /**/
                                         $ta = number_format($attr["ta"] - $coupon["flat-rate"], 2, ".", "");
                                         $ta = $ta >= 0.0 ? $ta : "0.00";
                                         /**/
                                         $ra = number_format($attr["ra"], 2, ".", "");
                                         $ra = $ra >= 0.01 ? $ra : "0.01";
                                         /**/
                                         $desc = sprintf(_x("COUPON %s off. ( Now: %s, then %s )", "s2member-front", "s2member"), $cs . number_format($coupon["flat-rate"], 2, ".", ""), $cs . c_ws_plugin__optimizemember_utils_time::amount_period_term($ta, $attr["tp"] . " " . $attr["tt"]) . $tx, $cs . c_ws_plugin__optimizemember_utils_time::amount_period_term($ra, $attr["rp"] . " " . $attr["rt"], $attr["rr"]));
                                         $response = sprintf(_x('<div>Coupon: <strong>%s off</strong>. ( Now: <strong>%s, then %s</strong> )</div>', "s2member-front", "s2member"), $cs . number_format($coupon["flat-rate"], 2, ".", ""), $cs . c_ws_plugin__optimizemember_utils_time::amount_period_term($ta, $attr["tp"] . " " . $attr["tt"]) . $tx, $cs . c_ws_plugin__optimizemember_utils_time::amount_period_term($ra, $attr["rp"] . " " . $attr["rt"], $attr["rr"]));
                                     } else {
                                         if ($coupon["directive"] === "ra-only" && $attr["tp"] && !$attr["sp"]) {
                                             $coupon_applies = true;
                                             /**/
                                             $ta = number_format($attr["ta"], 2, ".", "");
                                             $ta = $ta >= 0.0 ? $ta : "0.00";
                                             /**/
                                             $ra = number_format($attr["ra"] - $coupon["flat-rate"], 2, ".", "");
                                             $ra = $ra >= 0.01 ? $ra : "0.01";
                                             /**/
                                             $desc = sprintf(_x("COUPON %s off. ( Now: %s, then %s )", "s2member-front", "s2member"), $cs . number_format($coupon["flat-rate"], 2, ".", ""), $cs . c_ws_plugin__optimizemember_utils_time::amount_period_term($ta, $attr["tp"] . " " . $attr["tt"]) . $tx, $cs . c_ws_plugin__optimizemember_utils_time::amount_period_term($ra, $attr["rp"] . " " . $attr["rt"], $attr["rr"]));
                                             $response = sprintf(_x('<div>Coupon: <strong>%s off</strong>. ( Now: <strong>%s, then %s</strong> )</div>', "s2member-front", "s2member"), $cs . number_format($coupon["flat-rate"], 2, ".", ""), $cs . c_ws_plugin__optimizemember_utils_time::amount_period_term($ta, $attr["tp"] . " " . $attr["tt"]) . $tx, $cs . c_ws_plugin__optimizemember_utils_time::amount_period_term($ra, $attr["rp"] . " " . $attr["rt"], $attr["rr"]));
                                         } else {
                                             if ($coupon["directive"] === "all" && $attr["tp"] && !$attr["sp"]) {
                                                 $coupon_applies = true;
                                                 /**/
                                                 $ta = number_format($attr["ta"] - $coupon["flat-rate"], 2, ".", "");
                                                 $ta = $ta >= 0.0 ? $ta : "0.00";
                                                 /**/
                                                 $ra = number_format($attr["ra"] - $coupon["flat-rate"], 2, ".", "");
                                                 $ra = $ra >= 0.01 ? $ra : "0.01";
                                                 /**/
                                                 $desc = sprintf(_x("COUPON %s off. ( Now: %s, then %s )", "s2member-front", "s2member"), $cs . number_format($coupon["flat-rate"], 2, ".", ""), $cs . c_ws_plugin__optimizemember_utils_time::amount_period_term($ta, $attr["tp"] . " " . $attr["tt"]) . $tx, $cs . c_ws_plugin__optimizemember_utils_time::amount_period_term($ra, $attr["rp"] . " " . $attr["rt"], $attr["rr"]));
                                                 $response = sprintf(_x('<div>Coupon: <strong>%s off</strong>. ( Now: <strong>%s, then %s</strong> )</div>', "s2member-front", "s2member"), $cs . number_format($coupon["flat-rate"], 2, ".", ""), $cs . c_ws_plugin__optimizemember_utils_time::amount_period_term($ta, $attr["tp"] . " " . $attr["tt"]) . $tx, $cs . c_ws_plugin__optimizemember_utils_time::amount_period_term($ra, $attr["rp"] . " " . $attr["rt"], $attr["rr"]));
                                             } else {
                                                 if ($coupon["directive"] === "ra-only" && !$attr["tp"] && !$attr["sp"]) {
                                                     $coupon_applies = true;
                                                     /**/
                                                     $ta = number_format($attr["ta"], 2, ".", "");
                                                     $ta = $ta >= 0.0 ? $ta : "0.00";
                                                     /**/
                                                     $ra = number_format($attr["ra"] - $coupon["flat-rate"], 2, ".", "");
                                                     $ra = $ra >= 0.01 ? $ra : "0.01";
                                                     /**/
                                                     $desc = sprintf(_x("COUPON %s off. ( Now: %s )", "s2member-front", "s2member"), $cs . number_format($coupon["flat-rate"], 2, ".", ""), $cs . c_ws_plugin__optimizemember_utils_time::amount_period_term($ra, $attr["rp"] . " " . $attr["rt"], $attr["rr"]) . $tx);
                                                     $response = sprintf(_x('<div>Coupon: <strong>%s off</strong>. ( Now: <strong>%s</strong> )</div>', "s2member-front", "s2member"), $cs . number_format($coupon["flat-rate"], 2, ".", ""), $cs . c_ws_plugin__optimizemember_utils_time::amount_period_term($ra, $attr["rp"] . " " . $attr["rt"], $attr["rr"]) . $tx);
                                                 } else {
                                                     if ($coupon["directive"] === "all" && !$attr["tp"] && !$attr["sp"]) {
                                                         $coupon_applies = true;
                                                         /**/
                                                         $ta = number_format($attr["ta"] - $coupon["flat-rate"], 2, ".", "");
                                                         $ta = $ta >= 0.0 ? $ta : "0.00";
                                                         /**/
                                                         $ra = number_format($attr["ra"] - $coupon["flat-rate"], 2, ".", "");
                                                         $ra = $ra >= 0.01 ? $ra : "0.01";
                                                         /**/
                                                         $desc = sprintf(_x("COUPON %s off. ( Now: %s )", "s2member-front", "s2member"), $cs . number_format($coupon["flat-rate"], 2, ".", ""), $cs . c_ws_plugin__optimizemember_utils_time::amount_period_term($ra, $attr["rp"] . " " . $attr["rt"], $attr["rr"]) . $tx);
                                                         $response = sprintf(_x('<div>Coupon: <strong>%s off</strong>. ( Now: <strong>%s</strong> )</div>', "s2member-front", "s2member"), $cs . number_format($coupon["flat-rate"], 2, ".", ""), $cs . c_ws_plugin__optimizemember_utils_time::amount_period_term($ra, $attr["rp"] . " " . $attr["rt"], $attr["rr"]) . $tx);
                                                     } else {
                                                         /* Otherwise, we need a default response to display. */
                                                         $response = _x('<div>Sorry, your Coupon is not applicable.</div>', "s2member-front", "s2member");
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             } else {
                                 if ($coupon["percentage"]) {
                                     if (($coupon["directive"] === "ra-only" || $coupon["directive"] === "all") && $attr["sp"]) {
                                         $coupon_applies = true;
                                         /**/
                                         $p = $attr["ta"] / 100 * $coupon["percentage"];
                                         $ta = number_format($attr["ta"], 2, ".", "");
                                         $ta = $ta >= 0.0 ? $ta : "0.00";
                                         /**/
                                         $p = $attr["ra"] / 100 * $coupon["percentage"];
                                         $ra = number_format($attr["ra"] - $p, 2, ".", "");
                                         $ra = $ra >= 0.01 ? $ra : "0.01";
                                         /**/
                                         $desc = sprintf(_x("COUPON %s off. ( Now: %s )", "s2member-front", "s2member"), number_format($coupon["percentage"], 0) . $ps, $cs . $ra . $tx);
                                         $response = sprintf(_x('<div>Coupon: <strong>%s off</strong>. ( Now: <strong>%s</strong> )</div>', "s2member-front", "s2member"), number_format($coupon["percentage"], 0) . $ps, $cs . $ra . $tx);
                                     } else {
                                         if ($coupon["directive"] === "ta-only" && $attr["tp"] && !$attr["sp"]) {
                                             $coupon_applies = true;
                                             /**/
                                             $p = $attr["ta"] / 100 * $coupon["percentage"];
                                             $ta = number_format($attr["ta"] - $p, 2, ".", "");
                                             $ta = $ta >= 0.0 ? $ta : "0.00";
                                             /**/
                                             $p = $attr["ra"] / 100 * $coupon["percentage"];
                                             $ra = number_format($attr["ra"], 2, ".", "");
                                             $ra = $ra >= 0.01 ? $ra : "0.01";
                                             /**/
                                             $desc = sprintf(_x("COUPON %s off. ( Now: %s, then %s )", "s2member-front", "s2member"), number_format($coupon["percentage"], 0) . $ps, $cs . c_ws_plugin__optimizemember_utils_time::amount_period_term($ta, $attr["tp"] . " " . $attr["tt"]) . $tx, $cs . c_ws_plugin__optimizemember_utils_time::amount_period_term($ra, $attr["rp"] . " " . $attr["rt"], $attr["rr"]));
                                             $response = sprintf(_x('<div>Coupon: <strong>%s off</strong>. ( Now: <strong>%s, then %s</strong> )</div>', "s2member-front", "s2member"), number_format($coupon["percentage"], 0) . $ps, $cs . c_ws_plugin__optimizemember_utils_time::amount_period_term($ta, $attr["tp"] . " " . $attr["tt"]) . $tx, $cs . c_ws_plugin__optimizemember_utils_time::amount_period_term($ra, $attr["rp"] . " " . $attr["rt"], $attr["rr"]));
                                         } else {
                                             if ($coupon["directive"] === "ra-only" && $attr["tp"] && !$attr["sp"]) {
                                                 $coupon_applies = true;
                                                 /**/
                                                 $p = $attr["ta"] / 100 * $coupon["percentage"];
                                                 $ta = number_format($attr["ta"], 2, ".", "");
                                                 $ta = $ta >= 0.0 ? $ta : "0.00";
                                                 /**/
                                                 $p = $attr["ra"] / 100 * $coupon["percentage"];
                                                 $ra = number_format($attr["ra"] - $p, 2, ".", "");
                                                 $ra = $ra >= 0.01 ? $ra : "0.01";
                                                 /**/
                                                 $desc = sprintf(_x("COUPON %s off. ( Now: %s, then %s )", "s2member-front", "s2member"), number_format($coupon["percentage"], 0) . $ps, $cs . c_ws_plugin__optimizemember_utils_time::amount_period_term($ta, $attr["tp"] . " " . $attr["tt"]) . $tx, $cs . c_ws_plugin__optimizemember_utils_time::amount_period_term($ra, $attr["rp"] . " " . $attr["rt"], $attr["rr"]));
                                                 $response = sprintf(_x('<div>Coupon: <strong>%s off</strong>. ( Now: <strong>%s, then %s</strong> )</div>', "s2member-front", "s2member"), number_format($coupon["percentage"], 0) . $ps, $cs . c_ws_plugin__optimizemember_utils_time::amount_period_term($ta, $attr["tp"] . " " . $attr["tt"]) . $tx, $cs . c_ws_plugin__optimizemember_utils_time::amount_period_term($ra, $attr["rp"] . " " . $attr["rt"], $attr["rr"]));
                                             } else {
                                                 if ($coupon["directive"] === "all" && $attr["tp"] && !$attr["sp"]) {
                                                     $coupon_applies = true;
                                                     /**/
                                                     $p = $attr["ta"] / 100 * $coupon["percentage"];
                                                     $ta = number_format($attr["ta"] - $p, 2, ".", "");
                                                     $ta = $ta >= 0.0 ? $ta : "0.00";
                                                     /**/
                                                     $p = $attr["ra"] / 100 * $coupon["percentage"];
                                                     $ra = number_format($attr["ra"] - $p, 2, ".", "");
                                                     $ra = $ra >= 0.01 ? $ra : "0.01";
                                                     /**/
                                                     $desc = sprintf(_x("COUPON %s off. ( Now: %s, then %s )", "s2member-front", "s2member"), number_format($coupon["percentage"], 0) . $ps, $cs . c_ws_plugin__optimizemember_utils_time::amount_period_term($ta, $attr["tp"] . " " . $attr["tt"]) . $tx, $cs . c_ws_plugin__optimizemember_utils_time::amount_period_term($ra, $attr["rp"] . " " . $attr["rt"], $attr["rr"]));
                                                     $response = sprintf(_x('<div>Coupon: <strong>%s off</strong>. ( Now: <strong>%s, then %s</strong> )</div>', "s2member-front", "s2member"), number_format($coupon["percentage"], 0) . $ps, $cs . c_ws_plugin__optimizemember_utils_time::amount_period_term($ta, $attr["tp"] . " " . $attr["tt"]) . $tx, $cs . c_ws_plugin__optimizemember_utils_time::amount_period_term($ra, $attr["rp"] . " " . $attr["rt"], $attr["rr"]));
                                                 } else {
                                                     if ($coupon["directive"] === "ra-only" && !$attr["tp"] && !$attr["sp"]) {
                                                         $coupon_applies = true;
                                                         /**/
                                                         $p = $attr["ta"] / 100 * $coupon["percentage"];
                                                         $ta = number_format($attr["ta"], 2, ".", "");
                                                         $ta = $ta >= 0.0 ? $ta : "0.00";
                                                         /**/
                                                         $p = $attr["ra"] / 100 * $coupon["percentage"];
                                                         $ra = number_format($attr["ra"] - $p, 2, ".", "");
                                                         $ra = $ra >= 0.01 ? $ra : "0.01";
                                                         /**/
                                                         $desc = sprintf(_x("COUPON %s off. ( Now: %s )", "s2member-front", "s2member"), number_format($coupon["percentage"], 0) . $ps, $cs . c_ws_plugin__optimizemember_utils_time::amount_period_term($ra, $attr["rp"] . " " . $attr["rt"], $attr["rr"]) . $tx);
                                                         $response = sprintf(_x('<div>Coupon: <strong>%s off</strong>. ( Now: <strong>%s</strong> )</div>', "s2member-front", "s2member"), number_format($coupon["percentage"], 0) . $ps, $cs . c_ws_plugin__optimizemember_utils_time::amount_period_term($ra, $attr["rp"] . " " . $attr["rt"], $attr["rr"]) . $tx);
                                                     } else {
                                                         if ($coupon["directive"] === "all" && !$attr["tp"] && !$attr["sp"]) {
                                                             $coupon_applies = true;
                                                             /**/
                                                             $p = $attr["ta"] / 100 * $coupon["percentage"];
                                                             $ta = number_format($attr["ta"] - $p, 2, ".", "");
                                                             $ta = $ta >= 0.0 ? $ta : "0.00";
                                                             /**/
                                                             $p = $attr["ra"] / 100 * $coupon["percentage"];
                                                             $ra = number_format($attr["ra"] - $p, 2, ".", "");
                                                             $ra = $ra >= 0.01 ? $ra : "0.01";
                                                             /**/
                                                             $desc = sprintf(_x("COUPON %s off. ( Now: %s )", "s2member-front", "s2member"), number_format($coupon["percentage"], 0) . $ps, $cs . c_ws_plugin__optimizemember_utils_time::amount_period_term($ra, $attr["rp"] . " " . $attr["rt"], $attr["rr"]) . $tx);
                                                             $response = sprintf(_x('<div>Coupon: <strong>%s off</strong>. ( Now: <strong>%s</strong> )</div>', "s2member-front", "s2member"), number_format($coupon["percentage"], 0) . $ps, $cs . c_ws_plugin__optimizemember_utils_time::amount_period_term($ra, $attr["rp"] . " " . $attr["rt"], $attr["rr"]) . $tx);
                                                         } else {
                                                             /* Otherwise, we need a default response to display. */
                                                             $response = _x('<div>Sorry, your Coupon is not applicable.</div>', "s2member-front", "s2member");
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 } else {
                                     /* Else there was no discount applied at all. */
                                     $response = sprintf(_x('<div>Coupon: <strong>%s0.00 off</strong>.</div>', "s2member-front", "s2member"), $cs);
                                 }
                             }
                         } else {
                             /* Otherwise, we need a response that indicates not applicable for this purchase. */
                             $response = _x('<div>Sorry, your Coupon cannot be applied to this particular purchase.</div>', "s2member-front", "s2member");
                         }
                     } else {
                         if ($coupon_code === $coupon["code"] && $coupon["expired"]) {
                             $response = sprintf(_x('<div>Sorry, your Coupon <strong>expired</strong>: <em>%s</em>.</div>', "s2member-front", "s2member"), $coupon["expired"]);
                         }
                     }
                 }
             }
             /**/
             if (isset($coupon_applies, $desc) && $coupon_applies) {
                 /* translators: `%1$s` is new price/description, after coupon applied. `%2$s` is original description. */
                 $attr["desc"] = sprintf(_x('%1$s ~ ORIGINALLY: %2$s', "s2member-front", "s2member"), $desc, $attr["desc"]);
             }
             /**/
             $attr["ta"] = isset($coupon_applies, $ta) && $coupon_applies ? $ta : $attr["ta"];
             $attr["ra"] = isset($coupon_applies, $ra) && $coupon_applies ? $ra : $attr["ra"];
             /**/
             if (is_array($process) && (in_array("affiliates-silent-post", $process) || in_array("affiliates-1px-response", $process))) {
                 if (isset($coupon_applies) && $coupon_applies && !empty($affiliate_id)) {
                     if (empty($_COOKIE["idev"])) {
                         if ($_urls = $GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["pro_affiliate_coupon_code_tracking_urls"]) {
                             /**/
                             foreach (preg_split("/[\r\n\t]+/", $_urls) as $_url) {
                                 /**/
                                 if ($_url = preg_replace("/%%full_coupon_code%%/i", c_ws_plugin__optimizemember_utils_strings::esc_ds(urlencode($full_coupon_code)), $_url)) {
                                     if ($_url = preg_replace("/%%coupon_code%%/i", c_ws_plugin__optimizemember_utils_strings::esc_ds(urlencode($coupon_code)), $_url)) {
                                         if ($_url = preg_replace("/%%affiliate_id%%/i", c_ws_plugin__optimizemember_utils_strings::esc_ds(urlencode($affiliate_id)), $_url)) {
                                             if ($_url = preg_replace("/%%user_ip%%/i", c_ws_plugin__optimizemember_utils_strings::esc_ds(urlencode($_SERVER["REMOTE_ADDR"])), $_url)) {
                                                 if ($_url = trim(preg_replace("/%%(.+?)%%/i", "", $_url))) {
                                                     /**/
                                                     if (!($_r = 0) && ($_url = preg_replace("/^silent-php\\|/i", "", $_url, 1, $_r)) && $_r && in_array("affiliates-silent-post", $process)) {
                                                         c_ws_plugin__optimizemember_utils_urls::remote($_url, false, array("blocking" => false));
                                                     } else {
                                                         if (!($_r = 0) && ($_url = preg_replace("/^img-1px\\|/i", "", $_url, 1, $_r)) && $_r && in_array("affiliates-1px-response", $process)) {
                                                             if (!empty($response) && $return === "response") {
                                                                 $response .= "\n" . '<img src="' . esc_attr($_url) . '" style="width:0; height:0; border:0;" alt="" />';
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
             unset($_urls, $_url, $_r);
             /**/
             if (empty($response)) {
                 /* Is ``$response`` NOT set by now? If it's not, we need a default ``$response``. */
                 $response = _x('<div>Sorry, your Coupon is N/A, invalid or expired.</div>', "s2member-front", "s2member");
             }
         } else {
             /* Otherwise, we need a default response to display. */
             $response = _x('<div>Sorry, your Coupon is N/A, invalid or expired.</div>', "s2member-front", "s2member");
         }
     }
     /**/
     return $return === "response" ? $response : $attr;
 }
 /**
  * Parses s2Vars passed through by ClickBank®.
  *
  * @package optimizeMember\ClickBank
  * @since 111205
  *
  * @param str $cvendthru Expects the URL-encoded query string of s2Vars, including `_optimizemember_sig`.
  * @param str $type Optional. The type of ClickBank® transaction. This deals with backward compatibility.
  * 	For SALE transactions, do NOT accept the older format. For others, remain backward compatible.
  * @return array Array of s2Vars. Possibly an empty array.
  */
 public static function clickbank_parse_s2vars($cvendthru = FALSE, $type = FALSE)
 {
     wp_parse_str((string) $cvendthru, $s2vars);
     $s2vars = c_ws_plugin__optimizemember_utils_strings::trim_deep($s2vars);
     foreach ($s2vars as $var => $value) {
         if (!in_array($var, array("cbskin", "cbfid", "cbur", "cbf"), TRUE)) {
             // These may be included in a signature too.
             if (!preg_match("/^(?:s2_|_optimizemember_sig)/", $var)) {
                 // These will always be included in a signature.
                 unset($s2vars[$var]);
             }
         }
     }
     $is_sale = preg_match("/^(?:TEST_)?SALE\$/i", (string) $type);
     if (!$is_sale || c_ws_plugin__optimizemember_utils_urls::optimizemember_sig_ok(http_build_query($s2vars, null, "&"))) {
         return $s2vars;
     }
     return array();
 }
 /**
  * Checks to see if a Coupon Code was supplied, and if so; what does it provide?
  *
  * @package optimizeMember\Stripe
  * @since 140617
  *
  * @param array  $attr An array of Pro Form Attributes.
  * @param string $coupon_code Optional. A possible Coupon Code supplied by the Customer.
  * @param string $return Optional. Return type. One of `response|attr`. Defaults to `attr`.
  * @param array  $process Optional. An array of additional processing routines to run here.
  *   One or more of these values: `affiliates-1px-response|affiliates-silent-post|notifications`.
  *
  * @return array|string Original array, with prices and description modified when/if a Coupon Code is accepted.
  *   Or, if ``$return === 'response'``, return a string response, indicating status.
  */
 public static function apply_coupon($attr = array(), $coupon_code = '', $return = '', $process = array())
 {
     if (($coupon_code = trim(strtolower($coupon_code))) || ($coupon_code = trim(strtolower($attr['coupon'])))) {
         if ($attr['accept_coupons'] && $GLOBALS['WS_PLUGIN__']['optimizemember']['o']['pro_coupon_codes']) {
             $cs = c_ws_plugin__optimizemember_utils_cur::symbol($attr['cc']);
             $tx = c_ws_plugin__optimizemember_pro_stripe_utilities::tax_may_apply() ? _x(' + tax', 's2member-front', 's2member') : '';
             $ps = _x('%', 'optimizemember-front percentage-symbol', 's2member');
             $full_coupon_code = '';
             // Initialize.
             if (strlen($affiliate_suffix_chars = $GLOBALS['WS_PLUGIN__']['optimizemember']['o']['pro_affiliate_coupon_code_suffix_chars'])) {
                 if (preg_match('/^(.+?)' . preg_quote($affiliate_suffix_chars, '/') . '([0-9]+)$/i', $coupon_code, $m)) {
                     ($full_coupon_code = $m[0]) . ($coupon_code = $m[1]) . ($affiliate_id = $m[2]);
                 }
             }
             unset($affiliate_suffix_chars, $m);
             // Just a little housekeeping here.
             foreach (c_ws_plugin__optimizemember_utils_strings::trim_deep(preg_split('/[' . "\r\n\t" . ']+/', $GLOBALS['WS_PLUGIN__']['optimizemember']['o']['pro_coupon_codes'])) as $_line) {
                 if (($_line = trim($_line, ' ' . "\r\n\t\v" . '|')) && is_array($_coupon = preg_split('/\\|/', $_line))) {
                     $coupon['code'] = !empty($_coupon[0]) ? trim(strtolower($_coupon[0])) : '';
                     $coupon['percentage'] = !empty($_coupon[1]) && preg_match('/%/', $_coupon[1]) ? (double) $_coupon[1] : 0;
                     $coupon['flat-rate'] = !empty($_coupon[1]) && !preg_match('/%/', $_coupon[1]) ? (double) $_coupon[1] : 0;
                     $coupon['expired'] = !empty($_coupon[2]) && strtotime($_coupon[2]) < time() ? $_coupon[2] : FALSE;
                     $coupon['directive'] = !empty($_coupon[3]) && ($_coupon[3] = strtolower($_coupon[3])) ? preg_replace('/_/', '-', $_coupon[3]) : 'all';
                     $coupon['directive'] = preg_match('/^(ta-only|ra-only|all)$/', $coupon['directive']) ? $coupon['directive'] : 'all';
                     $coupon['singulars'] = !empty($_coupon[4]) && ($_coupon[4] = strtolower($_coupon[4])) && $_coupon[4] !== 'all' ? $_coupon[4] : 'all';
                     $coupon['singulars'] = $coupon['singulars'] !== 'all' ? preg_split('/[' . "\r\n\t" . '\\s;,]+/', trim(preg_replace('/[^0-9,]/', '', $coupon['singulars']), ',')) : array('all');
                     unset($_line, $_coupon);
                     // Just a little housekeeping here. Unset these temporary variables.
                     if ($coupon_code === $coupon['code'] && !$coupon['expired']) {
                         if ($coupon['singulars'] === array('all') || in_array($attr['singular'], $coupon['singulars'])) {
                             $coupon_accepted = TRUE;
                             // Yes, this Coupon Code has been accepted.
                             if ($coupon['flat-rate']) {
                                 if (($coupon['directive'] === 'ra-only' || $coupon['directive'] === 'all') && $attr['sp']) {
                                     $coupon_applies = TRUE;
                                     // Applying.
                                     $ta = number_format($attr['ta'], 2, '.', '');
                                     $ta = $ta >= 0.5 ? $ta : '0.00';
                                     $ra = number_format($attr['ra'] - $coupon['flat-rate'], 2, '.', '');
                                     $ra = $ra >= 0.5 ? $ra : '0.00';
                                     $desc = sprintf(_x('COUPON %s off. (Now: %s)', 's2member-front', 's2member'), $cs . number_format($coupon['flat-rate'], 2, '.', ''), $cs . $ra . $tx);
                                     $response = sprintf(_x('<div>Coupon: <strong>%s off</strong>. (Now: <strong>%s</strong>)</div>', 's2member-front', 's2member'), $cs . number_format($coupon['flat-rate'], 2, '.', ''), $cs . $ra . $tx);
                                 } else {
                                     if ($coupon['directive'] === 'ta-only' && $attr['tp'] && !$attr['sp']) {
                                         $coupon_applies = TRUE;
                                         // Applying.
                                         $ta = number_format($attr['ta'] - $coupon['flat-rate'], 2, '.', '');
                                         $ta = $ta >= 0.5 ? $ta : '0.00';
                                         $ra = number_format($attr['ra'], 2, '.', '');
                                         $ra = $ra >= 0.5 ? $ra : '0.00';
                                         $desc = sprintf(_x('COUPON %s off. (Now: %s, then %s)', 's2member-front', 's2member'), $cs . number_format($coupon['flat-rate'], 2, '.', ''), $cs . c_ws_plugin__optimizemember_utils_time::amount_period_term($ta, $attr['tp'] . ' ' . $attr['tt']) . $tx, $cs . c_ws_plugin__optimizemember_utils_time::amount_period_term($ra, $attr['rp'] . ' ' . $attr['rt'], $attr['rr']));
                                         $response = sprintf(_x('<div>Coupon: <strong>%s off</strong>. (Now: <strong>%s, then %s</strong>)</div>', 's2member-front', 's2member'), $cs . number_format($coupon['flat-rate'], 2, '.', ''), $cs . c_ws_plugin__optimizemember_utils_time::amount_period_term($ta, $attr['tp'] . ' ' . $attr['tt']) . $tx, $cs . c_ws_plugin__optimizemember_utils_time::amount_period_term($ra, $attr['rp'] . ' ' . $attr['rt'], $attr['rr']));
                                     } else {
                                         if ($coupon['directive'] === 'ra-only' && $attr['tp'] && !$attr['sp']) {
                                             $coupon_applies = TRUE;
                                             // Applying.
                                             $ta = number_format($attr['ta'], 2, '.', '');
                                             $ta = $ta >= 0.5 ? $ta : '0.00';
                                             $ra = number_format($attr['ra'] - $coupon['flat-rate'], 2, '.', '');
                                             $ra = $ra >= 0.5 ? $ra : '0.00';
                                             $desc = sprintf(_x('COUPON %s off. (Now: %s, then %s)', 's2member-front', 's2member'), $cs . number_format($coupon['flat-rate'], 2, '.', ''), $cs . c_ws_plugin__optimizemember_utils_time::amount_period_term($ta, $attr['tp'] . ' ' . $attr['tt']) . $tx, $cs . c_ws_plugin__optimizemember_utils_time::amount_period_term($ra, $attr['rp'] . ' ' . $attr['rt'], $attr['rr']));
                                             $response = sprintf(_x('<div>Coupon: <strong>%s off</strong>. (Now: <strong>%s, then %s</strong>)</div>', 's2member-front', 's2member'), $cs . number_format($coupon['flat-rate'], 2, '.', ''), $cs . c_ws_plugin__optimizemember_utils_time::amount_period_term($ta, $attr['tp'] . ' ' . $attr['tt']) . $tx, $cs . c_ws_plugin__optimizemember_utils_time::amount_period_term($ra, $attr['rp'] . ' ' . $attr['rt'], $attr['rr']));
                                         } else {
                                             if ($coupon['directive'] === 'all' && $attr['tp'] && !$attr['sp']) {
                                                 $coupon_applies = TRUE;
                                                 // Applying.
                                                 $ta = number_format($attr['ta'] - $coupon['flat-rate'], 2, '.', '');
                                                 $ta = $ta >= 0.5 ? $ta : '0.00';
                                                 $ra = number_format($attr['ra'] - $coupon['flat-rate'], 2, '.', '');
                                                 $ra = $ra >= 0.5 ? $ra : '0.00';
                                                 $desc = sprintf(_x('COUPON %s off. (Now: %s, then %s)', 's2member-front', 's2member'), $cs . number_format($coupon['flat-rate'], 2, '.', ''), $cs . c_ws_plugin__optimizemember_utils_time::amount_period_term($ta, $attr['tp'] . ' ' . $attr['tt']) . $tx, $cs . c_ws_plugin__optimizemember_utils_time::amount_period_term($ra, $attr['rp'] . ' ' . $attr['rt'], $attr['rr']));
                                                 $response = sprintf(_x('<div>Coupon: <strong>%s off</strong>. (Now: <strong>%s, then %s</strong>)</div>', 's2member-front', 's2member'), $cs . number_format($coupon['flat-rate'], 2, '.', ''), $cs . c_ws_plugin__optimizemember_utils_time::amount_period_term($ta, $attr['tp'] . ' ' . $attr['tt']) . $tx, $cs . c_ws_plugin__optimizemember_utils_time::amount_period_term($ra, $attr['rp'] . ' ' . $attr['rt'], $attr['rr']));
                                             } else {
                                                 if ($coupon['directive'] === 'ra-only' && !$attr['tp'] && !$attr['sp']) {
                                                     $coupon_applies = TRUE;
                                                     // Applying.
                                                     $ta = number_format($attr['ta'], 2, '.', '');
                                                     $ta = $ta >= 0.5 ? $ta : '0.00';
                                                     $ra = number_format($attr['ra'] - $coupon['flat-rate'], 2, '.', '');
                                                     $ra = $ra >= 0.5 ? $ra : '0.00';
                                                     $desc = sprintf(_x('COUPON %s off. (Now: %s)', 's2member-front', 's2member'), $cs . number_format($coupon['flat-rate'], 2, '.', ''), $cs . c_ws_plugin__optimizemember_utils_time::amount_period_term($ra, $attr['rp'] . ' ' . $attr['rt'], $attr['rr']) . $tx);
                                                     $response = sprintf(_x('<div>Coupon: <strong>%s off</strong>. (Now: <strong>%s</strong>)</div>', 's2member-front', 's2member'), $cs . number_format($coupon['flat-rate'], 2, '.', ''), $cs . c_ws_plugin__optimizemember_utils_time::amount_period_term($ra, $attr['rp'] . ' ' . $attr['rt'], $attr['rr']) . $tx);
                                                 } else {
                                                     if ($coupon['directive'] === 'all' && !$attr['tp'] && !$attr['sp']) {
                                                         $coupon_applies = TRUE;
                                                         // Applying.
                                                         $ta = number_format($attr['ta'] - $coupon['flat-rate'], 2, '.', '');
                                                         $ta = $ta >= 0.5 ? $ta : '0.00';
                                                         $ra = number_format($attr['ra'] - $coupon['flat-rate'], 2, '.', '');
                                                         $ra = $ra >= 0.5 ? $ra : '0.00';
                                                         $desc = sprintf(_x('COUPON %s off. (Now: %s)', 's2member-front', 's2member'), $cs . number_format($coupon['flat-rate'], 2, '.', ''), $cs . c_ws_plugin__optimizemember_utils_time::amount_period_term($ra, $attr['rp'] . ' ' . $attr['rt'], $attr['rr']) . $tx);
                                                         $response = sprintf(_x('<div>Coupon: <strong>%s off</strong>. (Now: <strong>%s</strong>)</div>', 's2member-front', 's2member'), $cs . number_format($coupon['flat-rate'], 2, '.', ''), $cs . c_ws_plugin__optimizemember_utils_time::amount_period_term($ra, $attr['rp'] . ' ' . $attr['rt'], $attr['rr']) . $tx);
                                                     } else {
                                                         // Otherwise, we need a default response to display.
                                                         $response = _x('<div>Sorry, your Coupon is not applicable.</div>', 's2member-front', 's2member');
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             } else {
                                 if ($coupon['percentage']) {
                                     if (($coupon['directive'] === 'ra-only' || $coupon['directive'] === 'all') && $attr['sp']) {
                                         $coupon_applies = TRUE;
                                         // Applying.
                                         $p = $attr['ta'] / 100 * $coupon['percentage'];
                                         $ta = number_format($attr['ta'], 2, '.', '');
                                         $ta = $ta >= 0.5 ? $ta : '0.00';
                                         $p = $attr['ra'] / 100 * $coupon['percentage'];
                                         $ra = number_format($attr['ra'] - $p, 2, '.', '');
                                         $ra = $ra >= 0.5 ? $ra : '0.00';
                                         $desc = sprintf(_x('COUPON %s off. (Now: %s)', 's2member-front', 's2member'), number_format($coupon['percentage'], 0) . $ps, $cs . $ra . $tx);
                                         $response = sprintf(_x('<div>Coupon: <strong>%s off</strong>. (Now: <strong>%s</strong>)</div>', 's2member-front', 's2member'), number_format($coupon['percentage'], 0) . $ps, $cs . $ra . $tx);
                                     } else {
                                         if ($coupon['directive'] === 'ta-only' && $attr['tp'] && !$attr['sp']) {
                                             $coupon_applies = TRUE;
                                             // Applying.
                                             $p = $attr['ta'] / 100 * $coupon['percentage'];
                                             $ta = number_format($attr['ta'] - $p, 2, '.', '');
                                             $ta = $ta >= 0.5 ? $ta : '0.00';
                                             $p = $attr['ra'] / 100 * $coupon['percentage'];
                                             $ra = number_format($attr['ra'], 2, '.', '');
                                             $ra = $ra >= 0.5 ? $ra : '0.00';
                                             $desc = sprintf(_x('COUPON %s off. (Now: %s, then %s)', 's2member-front', 's2member'), number_format($coupon['percentage'], 0) . $ps, $cs . c_ws_plugin__optimizemember_utils_time::amount_period_term($ta, $attr['tp'] . ' ' . $attr['tt']) . $tx, $cs . c_ws_plugin__optimizemember_utils_time::amount_period_term($ra, $attr['rp'] . ' ' . $attr['rt'], $attr['rr']));
                                             $response = sprintf(_x('<div>Coupon: <strong>%s off</strong>. (Now: <strong>%s, then %s</strong>)</div>', 's2member-front', 's2member'), number_format($coupon['percentage'], 0) . $ps, $cs . c_ws_plugin__optimizemember_utils_time::amount_period_term($ta, $attr['tp'] . ' ' . $attr['tt']) . $tx, $cs . c_ws_plugin__optimizemember_utils_time::amount_period_term($ra, $attr['rp'] . ' ' . $attr['rt'], $attr['rr']));
                                         } else {
                                             if ($coupon['directive'] === 'ra-only' && $attr['tp'] && !$attr['sp']) {
                                                 $coupon_applies = TRUE;
                                                 // Applying.
                                                 $p = $attr['ta'] / 100 * $coupon['percentage'];
                                                 $ta = number_format($attr['ta'], 2, '.', '');
                                                 $ta = $ta >= 0.5 ? $ta : '0.00';
                                                 $p = $attr['ra'] / 100 * $coupon['percentage'];
                                                 $ra = number_format($attr['ra'] - $p, 2, '.', '');
                                                 $ra = $ra >= 0.5 ? $ra : '0.00';
                                                 $desc = sprintf(_x('COUPON %s off. (Now: %s, then %s)', 's2member-front', 's2member'), number_format($coupon['percentage'], 0) . $ps, $cs . c_ws_plugin__optimizemember_utils_time::amount_period_term($ta, $attr['tp'] . ' ' . $attr['tt']) . $tx, $cs . c_ws_plugin__optimizemember_utils_time::amount_period_term($ra, $attr['rp'] . ' ' . $attr['rt'], $attr['rr']));
                                                 $response = sprintf(_x('<div>Coupon: <strong>%s off</strong>. (Now: <strong>%s, then %s</strong>)</div>', 's2member-front', 's2member'), number_format($coupon['percentage'], 0) . $ps, $cs . c_ws_plugin__optimizemember_utils_time::amount_period_term($ta, $attr['tp'] . ' ' . $attr['tt']) . $tx, $cs . c_ws_plugin__optimizemember_utils_time::amount_period_term($ra, $attr['rp'] . ' ' . $attr['rt'], $attr['rr']));
                                             } else {
                                                 if ($coupon['directive'] === 'all' && $attr['tp'] && !$attr['sp']) {
                                                     $coupon_applies = TRUE;
                                                     // Applying.
                                                     $p = $attr['ta'] / 100 * $coupon['percentage'];
                                                     $ta = number_format($attr['ta'] - $p, 2, '.', '');
                                                     $ta = $ta >= 0.5 ? $ta : '0.00';
                                                     $p = $attr['ra'] / 100 * $coupon['percentage'];
                                                     $ra = number_format($attr['ra'] - $p, 2, '.', '');
                                                     $ra = $ra >= 0.5 ? $ra : '0.00';
                                                     $desc = sprintf(_x('COUPON %s off. (Now: %s, then %s)', 's2member-front', 's2member'), number_format($coupon['percentage'], 0) . $ps, $cs . c_ws_plugin__optimizemember_utils_time::amount_period_term($ta, $attr['tp'] . ' ' . $attr['tt']) . $tx, $cs . c_ws_plugin__optimizemember_utils_time::amount_period_term($ra, $attr['rp'] . ' ' . $attr['rt'], $attr['rr']));
                                                     $response = sprintf(_x('<div>Coupon: <strong>%s off</strong>. (Now: <strong>%s, then %s</strong>)</div>', 's2member-front', 's2member'), number_format($coupon['percentage'], 0) . $ps, $cs . c_ws_plugin__optimizemember_utils_time::amount_period_term($ta, $attr['tp'] . ' ' . $attr['tt']) . $tx, $cs . c_ws_plugin__optimizemember_utils_time::amount_period_term($ra, $attr['rp'] . ' ' . $attr['rt'], $attr['rr']));
                                                 } else {
                                                     if ($coupon['directive'] === 'ra-only' && !$attr['tp'] && !$attr['sp']) {
                                                         $coupon_applies = TRUE;
                                                         // Applying.
                                                         $p = $attr['ta'] / 100 * $coupon['percentage'];
                                                         $ta = number_format($attr['ta'], 2, '.', '');
                                                         $ta = $ta >= 0.5 ? $ta : '0.00';
                                                         $p = $attr['ra'] / 100 * $coupon['percentage'];
                                                         $ra = number_format($attr['ra'] - $p, 2, '.', '');
                                                         $ra = $ra >= 0.5 ? $ra : '0.00';
                                                         $desc = sprintf(_x('COUPON %s off. (Now: %s)', 's2member-front', 's2member'), number_format($coupon['percentage'], 0) . $ps, $cs . c_ws_plugin__optimizemember_utils_time::amount_period_term($ra, $attr['rp'] . ' ' . $attr['rt'], $attr['rr']) . $tx);
                                                         $response = sprintf(_x('<div>Coupon: <strong>%s off</strong>. (Now: <strong>%s</strong>)</div>', 's2member-front', 's2member'), number_format($coupon['percentage'], 0) . $ps, $cs . c_ws_plugin__optimizemember_utils_time::amount_period_term($ra, $attr['rp'] . ' ' . $attr['rt'], $attr['rr']) . $tx);
                                                     } else {
                                                         if ($coupon['directive'] === 'all' && !$attr['tp'] && !$attr['sp']) {
                                                             $coupon_applies = TRUE;
                                                             // Applying.
                                                             $p = $attr['ta'] / 100 * $coupon['percentage'];
                                                             $ta = number_format($attr['ta'] - $p, 2, '.', '');
                                                             $ta = $ta >= 0.5 ? $ta : '0.00';
                                                             $p = $attr['ra'] / 100 * $coupon['percentage'];
                                                             $ra = number_format($attr['ra'] - $p, 2, '.', '');
                                                             $ra = $ra >= 0.5 ? $ra : '0.00';
                                                             $desc = sprintf(_x('COUPON %s off. (Now: %s)', 's2member-front', 's2member'), number_format($coupon['percentage'], 0) . $ps, $cs . c_ws_plugin__optimizemember_utils_time::amount_period_term($ra, $attr['rp'] . ' ' . $attr['rt'], $attr['rr']) . $tx);
                                                             $response = sprintf(_x('<div>Coupon: <strong>%s off</strong>. (Now: <strong>%s</strong>)</div>', 's2member-front', 's2member'), number_format($coupon['percentage'], 0) . $ps, $cs . c_ws_plugin__optimizemember_utils_time::amount_period_term($ra, $attr['rp'] . ' ' . $attr['rt'], $attr['rr']) . $tx);
                                                         } else {
                                                             // Otherwise, we need a default response to display.
                                                             $response = _x('<div>Sorry, your Coupon is not applicable.</div>', 's2member-front', 's2member');
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 } else {
                                     // Else there was no discount applied at all.
                                     $response = sprintf(_x('<div>Coupon: <strong>%s0.00 off</strong>.</div>', 's2member-front', 's2member'), $cs);
                                 }
                             }
                         } else {
                             // Otherwise, we need a response that indicates not applicable for this purchase.
                             $response = _x('<div>Sorry, your Coupon cannot be applied to this particular purchase.</div>', 's2member-front', 's2member');
                         }
                     } else {
                         if ($coupon_code === $coupon['code'] && $coupon['expired']) {
                             $response = sprintf(_x('<div>Sorry, your Coupon <strong>expired</strong>: <em>%s</em>.</div>', 's2member-front', 's2member'), $coupon['expired']);
                         }
                     }
                 }
             }
             if (isset($coupon_applies, $full_coupon_code, $desc) && $coupon_applies) {
                 // translators: `%1$s` is new price/description, after coupon applied. `%2$s` is original description.
                 $attr['desc'] = sprintf(_x('%1$s %2$s ~ ORIGINALLY: %3$s', 's2member-front', 's2member'), strtoupper($full_coupon_code), $desc, $attr['desc']);
             }
             $attr['ta'] = isset($coupon_applies, $ta) && $coupon_applies ? $ta : $attr['ta'];
             // Do we have a new Trial Amount?
             $attr['ra'] = isset($coupon_applies, $ra) && $coupon_applies ? $ra : $attr['ra'];
             // A new Regular Amount?
             if (is_array($process) && (in_array('affiliates-silent-post', $process) || in_array('affiliates-1px-response', $process))) {
                 if (isset($coupon_applies) && $coupon_applies && !empty($affiliate_id)) {
                     if (empty($_COOKIE['idev'])) {
                         if ($_urls = $GLOBALS['WS_PLUGIN__']['optimizemember']['o']['pro_affiliate_coupon_code_tracking_urls']) {
                             foreach (preg_split('/[' . "\r\n\t" . ']+/', $_urls) as $_url) {
                                 if ($_url = preg_replace('/%%full_coupon_code%%/i', c_ws_plugin__optimizemember_utils_strings::esc_refs(urlencode($full_coupon_code)), $_url)) {
                                     if ($_url = preg_replace('/%%coupon_code%%/i', c_ws_plugin__optimizemember_utils_strings::esc_refs(urlencode($coupon_code)), $_url)) {
                                         if ($_url = preg_replace('/%%(?:coupon_affiliate_id|affiliate_id)%%/i', c_ws_plugin__optimizemember_utils_strings::esc_refs(urlencode($affiliate_id)), $_url)) {
                                             if ($_url = preg_replace('/%%user_ip%%/i', c_ws_plugin__optimizemember_utils_strings::esc_refs(urlencode($_SERVER['REMOTE_ADDR'])), $_url)) {
                                                 if ($_url = trim(preg_replace('/%%(.+?)%%/i', '', $_url))) {
                                                     if (!($_r = 0) && ($_url = preg_replace('/^silent-php\\|/i', '', $_url, 1, $_r)) && $_r && in_array('affiliates-silent-post', $process)) {
                                                         c_ws_plugin__optimizemember_utils_urls::remote($_url, FALSE, array('blocking' => FALSE));
                                                     } else {
                                                         if (!($_r = 0) && ($_url = preg_replace('/^img-1px\\|/i', '', $_url, 1, $_r)) && $_r && in_array('affiliates-1px-response', $process)) {
                                                             if (!empty($response) && $return === 'response') {
                                                                 $response .= '\\n' . '<img src="' . esc_attr($_url) . '" style="width:0; height:0; border:0;" alt="" />';
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
             unset($_urls, $_url, $_r);
             // Just a little housekeeping here. Unset these variables.
             if (empty($response)) {
                 // Is ``$response`` NOT set by now? If it's not, we need a default ``$response``.
                 $response = _x('<div>Sorry, your Coupon is N/A, invalid or expired.</div>', 's2member-front', 's2member');
             }
         } else {
             // Otherwise, we need a default response to display.
             $response = _x('<div>Sorry, your Coupon is N/A, invalid or expired.</div>', 's2member-front', 's2member');
         }
     }
     $attr['_coupon_applies'] = isset($coupon_applies) && $coupon_applies ? '1' : '0';
     $attr['_coupon_code'] = isset($coupon_applies) && $coupon_applies ? $coupon_code : '';
     $attr['_full_coupon_code'] = isset($coupon_applies) && $coupon_applies && !empty($full_coupon_code) ? $full_coupon_code : (isset($coupon_applies) && $coupon_applies ? $coupon_code : '');
     $attr['_coupon_affiliate_id'] = isset($coupon_applies) && $coupon_applies && !empty($affiliate_id) && empty($_COOKIE['idev']) ? $affiliate_id : '';
     return $return === 'response' ? !empty($response) ? (string) $response : '' : $attr;
 }
 /**
  * Handles Profile modifications.
  *
  * @package optimizeMember\Profiles
  * @since 3.5
  *
  * @attaches-to ``add_action("init");``
  *
  * @return null After re-configuring the ``$current_user`` object.
  * 	May also exit script execution when handling the Stand-Alone Profile Modification Form.
  */
 public static function handle_profile_modifications()
 {
     global $current_user;
     /* We'll need to update this global object. */
     /**/
     $user =& $current_user;
     /* Shorter reference to the $current_user object. */
     /**/
     do_action("ws_plugin__optimizemember_before_handle_profile_modifications", get_defined_vars());
     /**/
     if (!empty($_POST["ws_plugin__optimizemember_profile_save"]) && is_user_logged_in() && is_object($user) && !empty($user->ID) && ($user_id = $user->ID)) {
         if (($nonce = $_POST["ws_plugin__optimizemember_profile_save"]) && wp_verify_nonce($nonce, "ws-plugin--optimizemember-profile-save")) {
             $GLOBALS["ws_plugin__optimizemember_profile_saved"] = true;
             /* Global flag as having been saved/updated successfully. */
             /**/
             $_p = c_ws_plugin__optimizemember_utils_strings::trim_deep(stripslashes_deep($_POST));
             /* Clean ``$_POST`` vars. */
             /**/
             $userdata["ID"] = $user_id;
             /**/
             if (!empty($_p["ws_plugin__optimizemember_profile_email"])) {
                 if (is_email($_p["ws_plugin__optimizemember_profile_email"]) && !email_exists($_p["ws_plugin__optimizemember_profile_email"])) {
                     $userdata["user_email"] = $_p["ws_plugin__optimizemember_profile_email"];
                 }
             }
             /**/
             if (!empty($_p["ws_plugin__optimizemember_profile_password1"])) {
                 if ($user->user_login !== "demo") {
                     /* No pass change on demo! */
                     $userdata["user_pass"] = $_p["ws_plugin__optimizemember_profile_password1"];
                 }
             }
             /**/
             if (!empty($_p["ws_plugin__optimizemember_profile_first_name"])) {
                 $userdata["first_name"] = $_p["ws_plugin__optimizemember_profile_first_name"];
             }
             /**/
             if (!empty($_p["ws_plugin__optimizemember_profile_display_name"])) {
                 $userdata["display_name"] = $_p["ws_plugin__optimizemember_profile_display_name"];
             }
             /**/
             if (!empty($_p["ws_plugin__optimizemember_profile_last_name"])) {
                 $userdata["last_name"] = $_p["ws_plugin__optimizemember_profile_last_name"];
             }
             /**/
             wp_update_user($userdata);
             /* OK. Now send this array for an update. */
             /**/
             if ($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["custom_reg_fields"]) {
                 if ($fields_applicable = c_ws_plugin__optimizemember_custom_reg_fields::custom_fields_configured_at_level("auto-detection", "profile")) {
                     $_existing_fields = get_user_option("optimizemember_custom_fields", $user_id);
                     /**/
                     foreach (json_decode($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["custom_reg_fields"], true) as $field) {
                         $field_var = preg_replace("/[^a-z0-9]/i", "_", strtolower($field["id"]));
                         $field_id_class = preg_replace("/_/", "-", $field_var);
                         /**/
                         if (!in_array($field["id"], $fields_applicable) || strpos($field["editable"], "no") === 0) {
                             if (isset($_existing_fields[$field_var]) && (is_array($_existing_fields[$field_var]) && !empty($_existing_fields[$field_var]) || is_string($_existing_fields[$field_var]) && strlen($_existing_fields[$field_var]))) {
                                 $fields[$field_var] = $_existing_fields[$field_var];
                             } else {
                                 /* Else ``unset()``. */
                                 unset($fields[$field_var]);
                             }
                         } else {
                             if ($field["required"] === "yes" && (!isset($_p["ws_plugin__optimizemember_profile_" . $field_var]) || !is_array($_p["ws_plugin__optimizemember_profile_" . $field_var]) && !is_string($_p["ws_plugin__optimizemember_profile_" . $field_var]) || is_array($_p["ws_plugin__optimizemember_profile_" . $field_var]) && empty($_p["ws_plugin__optimizemember_profile_" . $field_var]) || is_string($_p["ws_plugin__optimizemember_profile_" . $field_var]) && !strlen($_p["ws_plugin__optimizemember_profile_" . $field_var]))) {
                                 if (isset($_existing_fields[$field_var]) && (is_array($_existing_fields[$field_var]) && !empty($_existing_fields[$field_var]) || is_string($_existing_fields[$field_var]) && strlen($_existing_fields[$field_var]))) {
                                     $fields[$field_var] = $_existing_fields[$field_var];
                                 } else {
                                     /* Else ``unset()``. */
                                     unset($fields[$field_var]);
                                 }
                             } else {
                                 if (isset($_p["ws_plugin__optimizemember_profile_" . $field_var])) {
                                     if (is_array($_p["ws_plugin__optimizemember_profile_" . $field_var]) && !empty($_p["ws_plugin__optimizemember_profile_" . $field_var]) || is_string($_p["ws_plugin__optimizemember_profile_" . $field_var]) && strlen($_p["ws_plugin__optimizemember_profile_" . $field_var])) {
                                         $fields[$field_var] = $_p["ws_plugin__optimizemember_profile_" . $field_var];
                                     } else {
                                         /* Else ``unset()``. */
                                         unset($fields[$field_var]);
                                     }
                                 } else {
                                     /* Else ``unset()``. */
                                     unset($fields[$field_var]);
                                 }
                             }
                         }
                     }
                     /**/
                     if (!empty($fields)) {
                         update_user_option($user_id, "optimizemember_custom_fields", $fields);
                     } else {
                         /* Else delete their Custom Fields? */
                         delete_user_option($user_id, "optimizemember_custom_fields");
                     }
                 }
             }
             /**/
             eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
             do_action("ws_plugin__optimizemember_during_handle_profile_modifications", get_defined_vars());
             unset($__refs, $__v);
             /* Unset defined __refs, __v. */
             /**/
             $user = new WP_User($user_id);
             /* Update the ``WP_User`` object for the current User/Member. */
             function_exists("setup_userdata") ? setup_userdata() : null;
             /* Update global vars. */
             /**/
             $lwp = c_ws_plugin__optimizemember_login_redirects::login_redirection_url($user);
             $lwp = !$lwp ? get_page_link($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["login_welcome_page"]) : $lwp;
             /**/
             if (empty($_p["ws_plugin__optimizemember_sc_profile_save"])) {
                 echo '<script type="text/javascript">' . "\n";
                 echo "if(window.parent && window.parent != window) { window.parent.alert('" . c_ws_plugin__optimizemember_utils_strings::esc_js_sq(_x("Profile updated successfully.", "s2member-front", "s2member")) . "'); window.parent.location = '" . c_ws_plugin__optimizemember_utils_strings::esc_js_sq($lwp) . "'; }";
                 echo "else if(window.opener) { window.alert('" . c_ws_plugin__optimizemember_utils_strings::esc_js_sq(_x("Profile updated successfully.", "s2member-front", "s2member")) . "'); window.opener.location = '" . c_ws_plugin__optimizemember_utils_strings::esc_js_sq($lwp) . "'; window.close(); }";
                 echo "else { alert('" . c_ws_plugin__optimizemember_utils_strings::esc_js_sq(_x("Profile updated successfully.", "s2member-front", "s2member")) . "'); window.location = '" . c_ws_plugin__optimizemember_utils_strings::esc_js_sq($lwp) . "'; }";
                 echo '</script>' . "\n";
                 /**/
                 exit;
                 /* Clean exit. */
             }
         }
     }
     /**/
     do_action("ws_plugin__optimizemember_after_handle_profile_modifications", get_defined_vars());
     /**/
     return;
     /* Return for uniformity. */
 }
 /**
  * Shortcode `[optimizeMember-Pro-AuthNet-Form /]`.
  *
  * @package optimizeMember\AuthNet
  * @since 1.5
  *
  * @attaches-to ``add_shortcode("optimizeMember-Pro-AuthNet-Form");``
  *
  * @param array $attr An array of Attributes.
  * @param str $content Content inside the Shortcode.
  * @param str $shortcode The actual Shortcode name itself.
  * @return str The resulting Form Code, HTML markup.
  */
 public static function sc_authnet_form($attr = FALSE, $content = FALSE, $shortcode = FALSE)
 {
     eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
     do_action("ws_plugin__optimizemember_pro_before_sc_authnet_form", get_defined_vars());
     unset($__refs, $__v);
     /* Unset defined __refs, __v. */
     /**/
     c_ws_plugin__optimizemember_no_cache::no_cache_constants(true);
     /**/
     $attr = c_ws_plugin__optimizemember_utils_strings::trim_qts_deep((array) $attr);
     /**/
     $attr = shortcode_atts(array("ids" => "0", "exp" => "72", "level" => $attr["register"] ? "0" : "1", "ccaps" => "", "desc" => "", "cc" => "USD", "custom" => $_SERVER["HTTP_HOST"], "ta" => "0", "tp" => "0", "tt" => "D", "ra" => "0.01", "rp" => "1", "rt" => "M", "rr" => "1", "rrt" => "", "modify" => "0", "cancel" => "0", "sp" => "0", "register" => "0", "update" => "0", "accept" => "visa,mastercard,amex,discover", "coupon" => "", "accept_coupons" => "0", "default_country_code" => "US", "captcha" => "", "template" => "", "success" => ""), $attr);
     /**/
     $attr["tt"] = strtoupper($attr["tt"]);
     $attr["rt"] = strtoupper($attr["rt"]);
     $attr["rr"] = strtoupper($attr["rr"]);
     $attr["ccaps"] = strtolower($attr["ccaps"]);
     $attr["rr"] = $attr["rt"] === "L" ? "BN" : $attr["rr"];
     $attr["rr"] = $attr["level"] === "*" ? "BN" : $attr["rr"];
     $attr["rr"] = !$attr["tp"] && !$attr["rr"] ? "BN" : $attr["rr"];
     $attr["cc"] = "USD";
     $attr["default_country_code"] = strtoupper($attr["default_country_code"]);
     $attr["success"] = c_ws_plugin__optimizemember_utils_urls::n_amps($attr["success"]);
     /**/
     $attr["accept"] = trim($attr["accept"]) ? preg_split("/[;,]+/", preg_replace("/[\r\n\t\\s]+/", "", strtolower($attr["accept"]))) : array();
     $attr["accept"] = empty($attr["accept"]) ? array_merge($attr["accept"], array("visa")) : $attr["accept"];
     /**/
     $attr["coupon"] = $_GET["s2p-coupon"] ? trim(strip_tags(stripslashes($_GET["s2p-coupon"]))) : $attr["coupon"];
     /**/
     $attr["singular"] = get_the_ID();
     /**/
     eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
     do_action("ws_plugin__optimizemember_pro_before_sc_authnet_form_after_shortcode_atts", get_defined_vars());
     unset($__refs, $__v);
     /* Unset defined __refs, __v. */
     /**/
     if ($attr["cancel"]) {
         $_p = c_ws_plugin__optimizemember_utils_strings::trim_deep(stripslashes_deep($_POST));
         /*
         Obtain a possible response and/or validation error.
         */
         $response = c_ws_plugin__optimizemember_pro_authnet_responses::authnet_cancellation_response($attr);
         /*
         Empty post vars on successful response.
         */
         $_p = $response["response"] && !$response["error"] ? array() : $_p;
         /*
         Build the reCaptcha box via JavaScript.
         */
         if ($attr["captcha"]) {
             $captcha = '<div id="s2member-pro-authnet-cancellation-form-captcha-section" class="s2member-pro-authnet-form-section s2member-pro-authnet-cancellation-form-section s2member-pro-authnet-form-captcha-section s2member-pro-authnet-cancellation-form-captcha-section">' . "\n";
             /**/
             $captcha .= '<div id="s2member-pro-authnet-cancellation-form-captcha-section-title" class="s2member-pro-authnet-form-section-title s2member-pro-authnet-cancellation-form-section-title s2member-pro-authnet-form-captcha-section-title s2member-pro-authnet-cancellation-form-captcha-section-title">' . "\n";
             $captcha .= _x("Security Code", "s2member-front", "s2member") . "\n";
             $captcha .= '</div>' . "\n";
             /**/
             $captcha .= '<div id="s2member-pro-authnet-cancellation-form-captcha-div" class="s2member-pro-authnet-form-div s2member-pro-authnet-cancellation-form-div s2member-pro-authnet-form-captcha-div s2member-pro-authnet-cancellation-form-captcha-div">' . "\n";
             /**/
             $captcha .= '<label id="s2member-pro-authnet-cancellation-form-captcha-label" class="s2member-pro-authnet-form-captcha-label s2member-pro-authnet-cancellation-form-captcha-label">' . "\n";
             $captcha .= c_ws_plugin__optimizemember_utils_captchas::recaptcha_script_tag($attr["captcha"], 10) . "\n";
             $captcha .= '</label>' . "\n";
             /**/
             $captcha .= '</div>' . "\n";
             /**/
             $captcha .= '</div>' . "\n";
         }
         /*
         Build the hidden input variables.
         */
         $hidden_inputs = '<input type="hidden" name="optimizemember_pro_authnet_cancellation[nonce]" id="s2member-pro-authnet-cancellation-nonce" value="' . esc_attr(wp_create_nonce("s2member-pro-authnet-cancellation")) . '" />';
         $hidden_inputs .= '<input type="hidden" name="optimizemember_pro_authnet_cancellation[attr]" id="s2member-pro-authnet-cancellation-attr" value="' . esc_attr(c_ws_plugin__optimizemember_utils_encryption::encrypt(serialize($attr))) . '" />';
         /*
         Get the form template.
         */
         $custom_template = file_exists(TEMPLATEPATH . "/authnet-cancellation-form.php") ? TEMPLATEPATH . "/authnet-cancellation-form.php" : false;
         $custom_template = file_exists(TEMPLATEPATH . "/authnet-cancellation-form.html") ? TEMPLATEPATH . "/authnet-cancellation-form.html" : $custom_template;
         $custom_template = $attr["template"] && file_exists(TEMPLATEPATH . "/" . $attr["template"]) ? TEMPLATEPATH . "/" . $attr["template"] : $custom_template;
         $custom_template = $attr["template"] && file_exists(WP_CONTENT_DIR . "/" . $attr["template"]) ? WP_CONTENT_DIR . "/" . $attr["template"] : $custom_template;
         /**/
         $code = trim(file_get_contents($custom_template ? $custom_template : dirname(dirname(dirname(dirname(__FILE__)))) . "/templates/forms/authnet-cancellation-form.php"));
         $code = trim(!$custom_template || !is_multisite() || !c_ws_plugin__optimizemember_utils_conds::is_multisite_farm() || is_main_site() ? c_ws_plugin__optimizemember_utilities::evl($code) : $code);
         /*
         Fill in the action.
         */
         $code = preg_replace("/%%action%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds(esc_attr($_SERVER["REQUEST_URI"])), $code);
         /*
         Fill in the response.
         */
         $code = preg_replace("/%%response%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds($response["response"]), $code);
         /*
         Fill in the description.
         */
         $code = preg_replace("/%%description%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds($attr["desc"]), $code);
         /*
         Fill the captcha section.
         */
         $code = preg_replace("/%%captcha%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds($captcha), $code);
         /*
         Fill hidden inputs.
         */
         $code = preg_replace("/%%hidden_inputs%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds($hidden_inputs), $code);
         /**/
         eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
         do_action("ws_plugin__optimizemember_pro_during_sc_authnet_cancellation_form", get_defined_vars());
         unset($__refs, $__v);
         /* Unset defined __refs, __v. */
     } else {
         if ($attr["register"]) {
             $_p = c_ws_plugin__optimizemember_utils_strings::trim_deep(stripslashes_deep($_POST));
             /*
             Obtain a possible response and/or validation error.
             */
             $response = c_ws_plugin__optimizemember_pro_authnet_responses::authnet_registration_response($attr);
             /*
             Empty post vars on successful response.
             */
             $_p = $response["response"] && !$response["error"] ? array() : $_p;
             /*
             Build all of the custom fields.
             */
             if ($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["custom_reg_fields"]) {
                 /* Only display Custom Fields if configured. */
                 if ($fields_applicable = c_ws_plugin__optimizemember_custom_reg_fields::custom_fields_configured_at_level($attr["level"], "registration")) {
                     $tabindex = 99;
                     /* Start tabindex at 99 ( +1 below = 100 ). */
                     /**/
                     $custom_fields = '<div id="s2member-pro-authnet-registration-form-custom-fields-section" class="s2member-pro-authnet-form-section s2member-pro-authnet-registration-form-section s2member-pro-authnet-form-custom-fields-section s2member-pro-authnet-registration-form-custom-fields-section">' . "\n";
                     /**/
                     $custom_fields .= '<div id="s2member-pro-authnet-registration-form-custom-fields-section-title" class="s2member-pro-authnet-form-section-title s2member-pro-authnet-registration-form-section-title s2member-pro-authnet-form-custom-fields-section-title s2member-pro-authnet-registration-form-custom-fields-section-title">' . "\n";
                     $custom_fields .= _x("Additional Info", "s2member-front", "s2member") . "\n";
                     $custom_fields .= '</div>' . "\n";
                     /**/
                     foreach (json_decode($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["custom_reg_fields"], true) as $field) {
                         if (in_array($field["id"], $fields_applicable)) {
                             $field_var = preg_replace("/[^a-z0-9]/i", "_", strtolower($field["id"]));
                             $field_id_class = preg_replace("/_/", "-", $field_var);
                             /**/
                             if (!empty($field["section"]) && $field["section"] === "yes") {
                                 /* Starts a new section? */
                                 $custom_fields .= '<div id="s2member-pro-authnet-registration-form-custom-reg-field-' . $field_id_class . '-divider-section" class="s2member-pro-authnet-form-div s2member-pro-authnet-registration-form-div s2member-pro-authnet-form-custom-reg-field-divider-section' . (!empty($field["sectitle"]) ? '-title' : '') . ' s2member-pro-authnet-form-custom-reg-field-' . $field_id_class . '-divider-section' . (!empty($field["sectitle"]) ? '-title' : '') . ' s2member-pro-authnet-registration-form-custom-reg-field-' . $field_id_class . '-divider-section' . (!empty($field["sectitle"]) ? '-title' : '') . '">' . (!empty($field["sectitle"]) ? $field["sectitle"] : '') . '</div>';
                             }
                             /**/
                             $custom_fields .= '<div id="s2member-pro-authnet-registration-form-custom-reg-field-' . $field_id_class . '-div" class="s2member-pro-authnet-form-div s2member-pro-authnet-registration-form-div s2member-pro-authnet-form-custom-reg-field-' . $field_id_class . '-div s2member-pro-authnet-registration-form-custom-reg-field-' . $field_id_class . '-div">' . "\n";
                             /**/
                             $custom_fields .= '<label for="s2member-pro-authnet-registration-custom-reg-field-' . esc_attr($field_id_class) . '" id="s2member-pro-authnet-registration-form-custom-reg-field-' . $field_id_class . '-label" class="s2member-pro-authnet-form-custom-reg-field-' . $field_id_class . '-label s2member-pro-authnet-registration-form-custom-reg-field-' . $field_id_class . '-label">' . "\n";
                             $custom_fields .= '<span' . (preg_match("/^(checkbox|pre_checkbox)\$/", $field["type"]) ? ' style="display:none;"' : '') . '>' . $field["label"] . ($field["required"] === "yes" ? ' *' : '') . '</span></label>' . (preg_match("/^(checkbox|pre_checkbox)\$/", $field["type"]) ? '' : '<br />') . "\n";
                             $custom_fields .= c_ws_plugin__optimizemember_custom_reg_fields::custom_field_gen(__FUNCTION__, $field, "optimizemember_pro_authnet_registration[custom_fields][", "s2member-pro-authnet-registration-custom-reg-field-", "s2member-pro-authnet-custom-reg-field-" . $field_id_class . " s2member-pro-authnet-registration-custom-reg-field-" . $field_id_class, "", $tabindex = $tabindex + 1, "", $_p, $_p["optimizemember_pro_authnet_registration"]["custom_fields"][$field_var], "registration");
                             /**/
                             $custom_fields .= '</div>' . "\n";
                         }
                     }
                     /**/
                     $custom_fields .= '</div>' . "\n";
                 }
             }
             /*
             Build the reCaptcha box via JavaScript.
             */
             if ($attr["captcha"]) {
                 $captcha = '<div id="s2member-pro-authnet-registration-form-captcha-section" class="s2member-pro-authnet-form-section s2member-pro-authnet-registration-form-section s2member-pro-authnet-form-captcha-section s2member-pro-authnet-registration-form-captcha-section">' . "\n";
                 /**/
                 $captcha .= '<div id="s2member-pro-authnet-registration-form-captcha-section-title" class="s2member-pro-authnet-form-section-title s2member-pro-authnet-registration-form-section-title s2member-pro-authnet-form-captcha-section-title s2member-pro-authnet-registration-form-captcha-section-title">' . "\n";
                 $captcha .= _x("Security Code", "s2member-front", "s2member") . "\n";
                 $captcha .= '</div>' . "\n";
                 /**/
                 $captcha .= '<div id="s2member-pro-authnet-registration-form-captcha-div" class="s2member-pro-authnet-form-div s2member-pro-authnet-registration-form-div s2member-pro-authnet-form-captcha-div s2member-pro-authnet-registration-form-captcha-div">' . "\n";
                 /**/
                 $captcha .= '<label id="s2member-pro-authnet-registration-form-captcha-label" class="s2member-pro-authnet-form-captcha-label s2member-pro-authnet-registration-form-captcha-label">' . "\n";
                 $captcha .= c_ws_plugin__optimizemember_utils_captchas::recaptcha_script_tag($attr["captcha"], 200) . "\n";
                 $captcha .= '</label>' . "\n";
                 /**/
                 $captcha .= '</div>' . "\n";
                 /**/
                 $captcha .= '</div>' . "\n";
             }
             /*
             Build the opt-in checkbox.
             */
             if ($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["custom_reg_opt_in"] && c_ws_plugin__optimizemember_list_servers::list_servers_integrated()) {
                 $opt_in = '<div id="s2member-pro-authnet-registration-form-custom-reg-field-opt-in-div" class="s2member-pro-authnet-form-div s2member-pro-authnet-registration-form-div s2member-pro-authnet-form-custom-reg-field-opt-in-div s2member-pro-authnet-registration-form-custom-reg-field-opt-in-div">' . "\n";
                 /**/
                 $opt_in .= '<label for="s2member-pro-authnet-registration-form-custom-reg-field-opt-in" id="s2member-pro-authnet-registration-form-custom-reg-field-opt-in-label" class="s2member-pro-authnet-form-custom-reg-field-opt-in-label s2member-pro-authnet-registration-form-custom-reg-field-opt-in-label">' . "\n";
                 $opt_in .= '<input type="checkbox" name="optimizemember_pro_authnet_registration[custom_fields][opt_in]" id="s2member-pro-authnet-registration-form-custom-reg-field-opt-in" class="s2member-pro-authnet-form-custom-reg-field-opt-in s2member-pro-authnet-registration-form-custom-reg-field-opt-in" value="1"' . (empty($_p) && $GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["custom_reg_opt_in"] == 1 || $_p["optimizemember_pro_authnet_registration"]["custom_fields"]["opt_in"] ? ' checked="checked"' : '') . ' tabindex="300" />' . "\n";
                 $opt_in .= $GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["custom_reg_opt_in_label"] . "\n";
                 $opt_in .= '</label>' . "\n";
                 /**/
                 $opt_in .= '</div>' . "\n";
             }
             /*
             Build the hidden input variables.
             */
             $hidden_inputs = '<input type="hidden" name="optimizemember_pro_authnet_registration[nonce]" id="s2member-pro-authnet-registration-nonce" value="' . esc_attr(wp_create_nonce("s2member-pro-authnet-registration")) . '" />';
             $hidden_inputs .= !$GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["custom_reg_names"] ? '<input type="hidden" id="s2member-pro-authnet-registration-names-not-required-or-not-possible" value="1" />' : '';
             $hidden_inputs .= !$GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["custom_reg_password"] ? '<input type="hidden" id="s2member-pro-authnet-registration-password-not-required-or-not-possible" value="1" />' : '';
             $hidden_inputs .= '<input type="hidden" name="optimizemember_pro_authnet_registration[attr]" id="s2member-pro-authnet-registration-attr" value="' . esc_attr(c_ws_plugin__optimizemember_utils_encryption::encrypt(serialize($attr))) . '" />';
             /*
             Get the form template.
             */
             $custom_template = file_exists(TEMPLATEPATH . "/authnet-registration-form.php") ? TEMPLATEPATH . "/authnet-registration-form.php" : false;
             $custom_template = file_exists(TEMPLATEPATH . "/authnet-registration-form.html") ? TEMPLATEPATH . "/authnet-registration-form.html" : $custom_template;
             $custom_template = $attr["template"] && file_exists(TEMPLATEPATH . "/" . $attr["template"]) ? TEMPLATEPATH . "/" . $attr["template"] : $custom_template;
             $custom_template = $attr["template"] && file_exists(WP_CONTENT_DIR . "/" . $attr["template"]) ? WP_CONTENT_DIR . "/" . $attr["template"] : $custom_template;
             /**/
             $code = trim(file_get_contents($custom_template ? $custom_template : dirname(dirname(dirname(dirname(__FILE__)))) . "/templates/forms/authnet-registration-form.php"));
             $code = trim(!$custom_template || !is_multisite() || !c_ws_plugin__optimizemember_utils_conds::is_multisite_farm() || is_main_site() ? c_ws_plugin__optimizemember_utilities::evl($code) : $code);
             /*
             Fill in the action.
             */
             $code = preg_replace("/%%action%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds(esc_attr($_SERVER["REQUEST_URI"])), $code);
             /*
             Fill in the response.
             */
             $code = preg_replace("/%%response%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds($response["response"]), $code);
             /*
             Fill in the description.
             */
             $code = preg_replace("/%%description%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds($attr["desc"]), $code);
             /*
             Fill in the registration section.
             */
             $code = preg_replace("/%%first_name_value%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds(esc_attr($_p["optimizemember_pro_authnet_registration"]["first_name"])), $code);
             $code = preg_replace("/%%last_name_value%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds(esc_attr($_p["optimizemember_pro_authnet_registration"]["last_name"])), $code);
             $code = preg_replace("/%%email_value%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds(format_to_edit($_p["optimizemember_pro_authnet_registration"]["email"])), $code);
             $code = preg_replace("/%%username_value%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds(format_to_edit($_p["optimizemember_pro_authnet_registration"]["username"])), $code);
             $code = preg_replace("/%%password1_value%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds(format_to_edit($_p["optimizemember_pro_authnet_registration"]["password1"])), $code);
             $code = preg_replace("/%%password2_value%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds(format_to_edit($_p["optimizemember_pro_authnet_registration"]["password2"])), $code);
             /*
             Fill in the custom fields section.
             */
             $code = preg_replace("/%%custom_fields%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds($custom_fields), $code);
             /*
             Fill the captcha section.
             */
             $code = preg_replace("/%%captcha%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds($captcha), $code);
             /*
             Fill the opt-in box.
             */
             $code = preg_replace("/%%opt_in%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds($opt_in), $code);
             /*
             Fill hidden inputs.
             */
             $code = preg_replace("/%%hidden_inputs%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds($hidden_inputs), $code);
             /**/
             eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
             do_action("ws_plugin__optimizemember_pro_during_sc_authnet_registration_form", get_defined_vars());
             unset($__refs, $__v);
             /* Unset defined __refs, __v. */
         } else {
             if ($attr["update"]) {
                 $_p = c_ws_plugin__optimizemember_utils_strings::trim_deep(stripslashes_deep($_POST));
                 /*
                 Obtain a possible response and/or validation error.
                 */
                 $response = c_ws_plugin__optimizemember_pro_authnet_responses::authnet_update_response($attr);
                 /*
                 Empty post vars on successful response.
                 */
                 $_p = $response["response"] && !$response["error"] ? array() : $_p;
                 /*
                 Build the list of card type options.
                 */
                 foreach (array("Visa" => _x("Visa", "s2member-front", "s2member"), "MasterCard" => _x("MasterCard", "s2member-front", "s2member"), "Discover" => _x("Discover", "s2member-front", "s2member"), "Amex" => _x("American Express", "s2member-front", "s2member")) as $card_type_v => $card_type_l) {
                     $card_type_options .= '<label for="s2member-pro-authnet-update-card-type-' . esc_attr(strtolower($card_type_v)) . '" id="s2member-pro-authnet-update-form-card-type-' . esc_attr(strtolower($card_type_v)) . '-label" class="s2member-pro-authnet-form-card-type-label s2member-pro-authnet-update-form-card-type-label s2member-pro-authnet-form-card-type-' . esc_attr(strtolower($card_type_v)) . '-label s2member-pro-authnet-update-form-card-type-' . esc_attr(strtolower($card_type_v)) . '-label' . (!in_array(strtolower($card_type_v), $attr["accept"]) ? ' disabled' : '') . '">' . "\n" . '<input type="radio" aria-required="true" name="optimizemember_pro_authnet_update[card_type]" id="s2member-pro-authnet-update-card-type-' . esc_attr(strtolower($card_type_v)) . '" class="s2member-pro-authnet-card-type-' . esc_attr(strtolower($card_type_v)) . ' s2member-pro-authnet-update-card-type-' . esc_attr(strtolower($card_type_v)) . '" value="' . esc_attr($card_type_v) . '"' . (!empty($_p["optimizemember_pro_authnet_update"]["card_type"]) && in_array(strtolower($_p["optimizemember_pro_authnet_update"]["card_type"]), $attr["accept"]) && $_p["optimizemember_pro_authnet_update"]["card_type"] === $card_type_v ? ' checked="checked"' : '') . (!in_array(strtolower($card_type_v), $attr["accept"]) ? ' disabled="disabled"' : '') . ' tabindex="10" />' . "\n" . '</label>';
                 }
                 /*
                 Build the list of country code options.
                 $country_default_by_currency = false. Authorize.Net always processes in USD, so the country is empty by default.
                 Authorize.Net always processes in USD. International transactions are converted automatically through banking institutions.
                 */
                 $country_default_by_currency = !$_p["optimizemember_pro_authnet_update"]["country"] && $attr["cc"] === "USD" ? "US" : $country_default_by_currency;
                 $country_default_by_currency = !$_p["optimizemember_pro_authnet_update"]["country"] && $attr["cc"] === "CAD" ? "CA" : $country_default_by_currency;
                 $country_default_by_currency = !$_p["optimizemember_pro_authnet_update"]["country"] && $attr["cc"] === "GBP" ? "GB" : $country_default_by_currency;
                 $country_default_by_currency = apply_filters("ws_plugin__optimizemember_pro_authnet_default_country", false, get_defined_vars());
                 /**/
                 $default_country_v = $attr["default_country_code"] ? $attr["default_country_code"] : $country_default_by_currency;
                 /**/
                 $country_options = '<option value=""></option>';
                 /* Start with an empty option value. */
                 /**/
                 foreach (preg_split("/[\r\n]+/", file_get_contents(dirname(dirname(dirname(dirname(__FILE__)))) . "/iso-3166-1.txt")) as $country) {
                     list($country_l, $country_v) = preg_split("/;/", $country, 2);
                     /**/
                     if ($country_l && $country_v) {
                         /* Here we also check on the default pre-selected country; as determined above; based on currency. */
                         $country_options .= '<option value="' . esc_attr(strtoupper($country_v)) . '"' . ($_p["optimizemember_pro_authnet_update"]["country"] === $country_v || $default_country_v === $country_v ? ' selected="selected"' : '') . '>' . esc_html(ucwords(strtolower($country_l))) . '</option>';
                     }
                 }
                 /*
                 Build the reCaptcha box via JavaScript.
                 */
                 if ($attr["captcha"]) {
                     $captcha = '<div id="s2member-pro-authnet-update-form-captcha-section" class="s2member-pro-authnet-form-section s2member-pro-authnet-update-form-section s2member-pro-authnet-form-captcha-section s2member-pro-authnet-update-form-captcha-section">' . "\n";
                     /**/
                     $captcha .= '<div id="s2member-pro-authnet-update-form-captcha-section-title" class="s2member-pro-authnet-form-section-title s2member-pro-authnet-update-form-section-title s2member-pro-authnet-form-captcha-section-title s2member-pro-authnet-update-form-captcha-section-title">' . "\n";
                     $captcha .= _x("Security Code", "s2member-front", "s2member") . "\n";
                     $captcha .= '</div>' . "\n";
                     /**/
                     $captcha .= '<div id="s2member-pro-authnet-update-form-captcha-div" class="s2member-pro-authnet-form-div s2member-pro-authnet-update-form-div s2member-pro-authnet-form-captcha-div s2member-pro-authnet-update-form-captcha-div">' . "\n";
                     /**/
                     $captcha .= '<label id="s2member-pro-authnet-update-form-captcha-label" class="s2member-pro-authnet-form-captcha-label s2member-pro-authnet-update-form-captcha-label">' . "\n";
                     $captcha .= c_ws_plugin__optimizemember_utils_captchas::recaptcha_script_tag($attr["captcha"], 200) . "\n";
                     $captcha .= '</label>' . "\n";
                     /**/
                     $captcha .= '</div>' . "\n";
                     /**/
                     $captcha .= '</div>' . "\n";
                 }
                 /*
                 Build the hidden input variables.
                 */
                 $hidden_inputs = '<input type="hidden" name="optimizemember_pro_authnet_update[nonce]" id="s2member-pro-authnet-update-nonce" value="' . esc_attr(wp_create_nonce("s2member-pro-authnet-update")) . '" />';
                 $hidden_inputs .= '<input type="hidden" name="optimizemember_pro_authnet_update[attr]" id="s2member-pro-authnet-update-attr" value="' . esc_attr(c_ws_plugin__optimizemember_utils_encryption::encrypt(serialize($attr))) . '" />';
                 /*
                 Get the form template.
                 */
                 $custom_template = file_exists(TEMPLATEPATH . "/authnet-update-form.php") ? TEMPLATEPATH . "/authnet-update-form.php" : false;
                 $custom_template = file_exists(TEMPLATEPATH . "/authnet-update-form.html") ? TEMPLATEPATH . "/authnet-update-form.html" : $custom_template;
                 $custom_template = $attr["template"] && file_exists(TEMPLATEPATH . "/" . $attr["template"]) ? TEMPLATEPATH . "/" . $attr["template"] : $custom_template;
                 $custom_template = $attr["template"] && file_exists(WP_CONTENT_DIR . "/" . $attr["template"]) ? WP_CONTENT_DIR . "/" . $attr["template"] : $custom_template;
                 /**/
                 $code = trim(file_get_contents($custom_template ? $custom_template : dirname(dirname(dirname(dirname(__FILE__)))) . "/templates/forms/authnet-update-form.php"));
                 $code = trim(!$custom_template || !is_multisite() || !c_ws_plugin__optimizemember_utils_conds::is_multisite_farm() || is_main_site() ? c_ws_plugin__optimizemember_utilities::evl($code) : $code);
                 /*
                 Fill in the action.
                 */
                 $code = preg_replace("/%%action%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds(esc_attr($_SERVER["REQUEST_URI"])), $code);
                 /*
                 Fill in the response.
                 */
                 $code = preg_replace("/%%response%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds($response["response"]), $code);
                 /*
                 Fill in the description.
                 */
                 $code = preg_replace("/%%description%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds($attr["desc"]), $code);
                 /*
                 Fill in the billing method section.
                 */
                 $code = preg_replace("/%%card_type_options%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds($card_type_options), $code);
                 $code = preg_replace("/%%card_number_value%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds(format_to_edit($_p["optimizemember_pro_authnet_update"]["card_number"])), $code);
                 $code = preg_replace("/%%card_expiration_value%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds(format_to_edit($_p["optimizemember_pro_authnet_update"]["card_expiration"])), $code);
                 $code = preg_replace("/%%card_verification_value%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds(format_to_edit($_p["optimizemember_pro_authnet_update"]["card_verification"])), $code);
                 $code = preg_replace("/%%card_start_date_issue_number_value%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds(format_to_edit($_p["optimizemember_pro_authnet_update"]["card_start_date_issue_number"])), $code);
                 /*
                 Fill in the billing address section.
                 */
                 $code = preg_replace("/%%street_value%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds(format_to_edit($_p["optimizemember_pro_authnet_update"]["street"])), $code);
                 $code = preg_replace("/%%city_value%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds(format_to_edit($_p["optimizemember_pro_authnet_update"]["city"])), $code);
                 $code = preg_replace("/%%state_value%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds(format_to_edit($_p["optimizemember_pro_authnet_update"]["state"])), $code);
                 $code = preg_replace("/%%country_options%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds($country_options), $code);
                 $code = preg_replace("/%%zip_value%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds(format_to_edit($_p["optimizemember_pro_authnet_update"]["zip"])), $code);
                 /*
                 Fill the captcha section.
                 */
                 $code = preg_replace("/%%captcha%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds($captcha), $code);
                 /*
                 Fill hidden inputs.
                 */
                 $code = preg_replace("/%%hidden_inputs%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds($hidden_inputs), $code);
                 /**/
                 eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
                 do_action("ws_plugin__optimizemember_pro_during_sc_authnet_update_form", get_defined_vars());
                 unset($__refs, $__v);
                 /* Unset defined __refs, __v. */
             } else {
                 if ($attr["sp"]) {
                     $_p = c_ws_plugin__optimizemember_utils_strings::trim_deep(stripslashes_deep($_POST));
                     /*
                     Configure internal attributes.
                     */
                     $attr["sp_ids_exp"] = "sp:" . $attr["ids"] . ":" . $attr["exp"];
                     /* Combined `sp:ids:expiration hours`. */
                     $attr["coupon"] = $_p["optimizemember_pro_authnet_sp_checkout"]["coupon"] ? $_p["optimizemember_pro_authnet_sp_checkout"]["coupon"] : $attr["coupon"];
                     /*
                     Obtain a possible response and/or validation error.
                     */
                     $response = c_ws_plugin__optimizemember_pro_authnet_responses::authnet_sp_checkout_response($attr);
                     /*
                     Empty post vars on successful response.
                     */
                     $_p = $response["response"] && !$response["error"] ? array() : $_p;
                     /*
                     Build the list of card type options.
                     */
                     foreach (array("Visa" => _x("Visa", "s2member-front", "s2member"), "MasterCard" => _x("MasterCard", "s2member-front", "s2member"), "Discover" => _x("Discover", "s2member-front", "s2member"), "Amex" => _x("American Express", "s2member-front", "s2member")) as $card_type_v => $card_type_l) {
                         $card_type_options .= '<label for="s2member-pro-authnet-sp-checkout-card-type-' . esc_attr(strtolower($card_type_v)) . '" id="s2member-pro-authnet-sp-checkout-form-card-type-' . esc_attr(strtolower($card_type_v)) . '-label" class="s2member-pro-authnet-form-card-type-label s2member-pro-authnet-sp-checkout-form-card-type-label s2member-pro-authnet-form-card-type-' . esc_attr(strtolower($card_type_v)) . '-label s2member-pro-authnet-sp-checkout-form-card-type-' . esc_attr(strtolower($card_type_v)) . '-label' . (!in_array(strtolower($card_type_v), $attr["accept"]) ? ' disabled' : '') . '">' . "\n" . '<input type="radio" aria-required="true" name="optimizemember_pro_authnet_sp_checkout[card_type]" id="s2member-pro-authnet-sp-checkout-card-type-' . esc_attr(strtolower($card_type_v)) . '" class="s2member-pro-authnet-card-type-' . esc_attr(strtolower($card_type_v)) . ' s2member-pro-authnet-sp-checkout-card-type-' . esc_attr(strtolower($card_type_v)) . '" value="' . esc_attr($card_type_v) . '"' . (!empty($_p["optimizemember_pro_authnet_sp_checkout"]["card_type"]) && in_array(strtolower($_p["optimizemember_pro_authnet_sp_checkout"]["card_type"]), $attr["accept"]) && $_p["optimizemember_pro_authnet_sp_checkout"]["card_type"] === $card_type_v ? ' checked="checked"' : '') . (!in_array(strtolower($card_type_v), $attr["accept"]) ? ' disabled="disabled"' : '') . ' tabindex="100" />' . "\n" . '</label>';
                     }
                     /*
                     Build the list of country code options.
                     $country_default_by_currency = false. Authorize.Net always processes in USD, so the country is empty by default.
                     Authorize.Net always processes in USD. International transactions are converted automatically through banking institutions.
                     */
                     $country_default_by_currency = !$_p["optimizemember_pro_authnet_sp_checkout"]["country"] && $attr["cc"] === "USD" ? "US" : $country_default_by_currency;
                     $country_default_by_currency = !$_p["optimizemember_pro_authnet_sp_checkout"]["country"] && $attr["cc"] === "CAD" ? "CA" : $country_default_by_currency;
                     $country_default_by_currency = !$_p["optimizemember_pro_authnet_sp_checkout"]["country"] && $attr["cc"] === "GBP" ? "GB" : $country_default_by_currency;
                     $country_default_by_currency = apply_filters("ws_plugin__optimizemember_pro_authnet_default_country", false, get_defined_vars());
                     /**/
                     $default_country_v = $attr["default_country_code"] ? $attr["default_country_code"] : $country_default_by_currency;
                     /**/
                     $country_options = '<option value=""></option>';
                     /* Start with an empty option value. */
                     /**/
                     foreach (preg_split("/[\r\n]+/", file_get_contents(dirname(dirname(dirname(dirname(__FILE__)))) . "/iso-3166-1.txt")) as $country) {
                         list($country_l, $country_v) = preg_split("/;/", $country, 2);
                         /**/
                         if ($country_l && $country_v) {
                             /* Here we also check on the default pre-selected country; as determined above; based on currency. */
                             $country_options .= '<option value="' . esc_attr(strtoupper($country_v)) . '"' . ($_p["optimizemember_pro_authnet_sp_checkout"]["country"] === $country_v || $default_country_v === $country_v ? ' selected="selected"' : '') . '>' . esc_html(ucwords(strtolower($country_l))) . '</option>';
                         }
                     }
                     /*
                     Build the reCaptcha box via JavaScript.
                     */
                     if ($attr["captcha"]) {
                         $captcha = '<div id="s2member-pro-authnet-sp-checkout-form-captcha-section" class="s2member-pro-authnet-form-section s2member-pro-authnet-sp-checkout-form-section s2member-pro-authnet-form-captcha-section s2member-pro-authnet-sp-checkout-form-captcha-section">' . "\n";
                         /**/
                         $captcha .= '<div id="s2member-pro-authnet-sp-checkout-form-captcha-section-title" class="s2member-pro-authnet-form-section-title s2member-pro-authnet-sp-checkout-form-section-title s2member-pro-authnet-form-captcha-section-title s2member-pro-authnet-sp-checkout-form-captcha-section-title">' . "\n";
                         $captcha .= _x("Security Code", "s2member-front", "s2member") . "\n";
                         $captcha .= '</div>' . "\n";
                         /**/
                         $captcha .= '<div id="s2member-pro-authnet-sp-checkout-form-captcha-div" class="s2member-pro-authnet-form-div s2member-pro-authnet-sp-checkout-form-div s2member-pro-authnet-form-captcha-div s2member-pro-authnet-sp-checkout-form-captcha-div">' . "\n";
                         /**/
                         $captcha .= '<label id="s2member-pro-authnet-sp-checkout-form-captcha-label" class="s2member-pro-authnet-form-captcha-label s2member-pro-authnet-sp-checkout-form-captcha-label">' . "\n";
                         $captcha .= c_ws_plugin__optimizemember_utils_captchas::recaptcha_script_tag($attr["captcha"], 300) . "\n";
                         $captcha .= '</label>' . "\n";
                         /**/
                         $captcha .= '</div>' . "\n";
                         /**/
                         $captcha .= '</div>' . "\n";
                     }
                     /*
                     Build the opt-in checkbox.
                     */
                     if ($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["custom_reg_opt_in"] && c_ws_plugin__optimizemember_list_servers::list_servers_integrated()) {
                         $opt_in = '<div id="s2member-pro-authnet-sp-checkout-form-custom-reg-field-opt-in-div" class="s2member-pro-authnet-form-div s2member-pro-authnet-sp-checkout-form-div s2member-pro-authnet-form-custom-reg-field-opt-in-div s2member-pro-authnet-sp-checkout-form-custom-reg-field-opt-in-div">' . "\n";
                         /**/
                         $opt_in .= '<label for="s2member-pro-authnet-sp-checkout-form-custom-reg-field-opt-in" id="s2member-pro-authnet-sp-checkout-form-custom-reg-field-opt-in-label" class="s2member-pro-authnet-form-custom-reg-field-opt-in-label s2member-pro-authnet-sp-checkout-form-custom-reg-field-opt-in-label">' . "\n";
                         $opt_in .= '<input type="checkbox" name="optimizemember_pro_authnet_sp_checkout[custom_fields][opt_in]" id="s2member-pro-authnet-sp-checkout-form-custom-reg-field-opt-in" class="s2member-pro-authnet-form-custom-reg-field-opt-in s2member-pro-authnet-sp-checkout-form-custom-reg-field-opt-in" value="1"' . (empty($_p) && $GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["custom_reg_opt_in"] == 1 || $_p["optimizemember_pro_authnet_sp_checkout"]["custom_fields"]["opt_in"] ? ' checked="checked"' : '') . ' tabindex="400" />' . "\n";
                         $opt_in .= $GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["custom_reg_opt_in_label"] . "\n";
                         $opt_in .= '</label>' . "\n";
                         /**/
                         $opt_in .= '</div>' . "\n";
                     }
                     /*
                     Build the hidden input variables.
                     */
                     $hidden_inputs = '<input type="hidden" name="optimizemember_pro_authnet_sp_checkout[nonce]" id="s2member-pro-authnet-sp-checkout-nonce" value="' . esc_attr(wp_create_nonce("s2member-pro-authnet-sp-checkout")) . '" />';
                     $hidden_inputs .= !$attr["accept_coupons"] ? '<input type="hidden" id="s2member-pro-authnet-sp-checkout-coupons-not-required-or-not-possible" value="1" />' : '';
                     $hidden_inputs .= !c_ws_plugin__optimizemember_pro_authnet_utilities::authnet_tax_may_apply() ? '<input type="hidden" id="s2member-pro-authnet-sp-checkout-tax-not-required-or-not-possible" value="1" />' : '';
                     $hidden_inputs .= '<input type="hidden" name="optimizemember_pro_authnet_sp_checkout[attr]" id="s2member-pro-authnet-sp-checkout-attr" value="' . esc_attr(c_ws_plugin__optimizemember_utils_encryption::encrypt(serialize($attr))) . '" />';
                     /*
                     Get the form template.
                     */
                     $custom_template = file_exists(TEMPLATEPATH . "/authnet-sp-checkout-form.php") ? TEMPLATEPATH . "/authnet-sp-checkout-form.php" : false;
                     $custom_template = file_exists(TEMPLATEPATH . "/authnet-sp-checkout-form.html") ? TEMPLATEPATH . "/authnet-sp-checkout-form.html" : $custom_template;
                     $custom_template = $attr["template"] && file_exists(TEMPLATEPATH . "/" . $attr["template"]) ? TEMPLATEPATH . "/" . $attr["template"] : $custom_template;
                     $custom_template = $attr["template"] && file_exists(WP_CONTENT_DIR . "/" . $attr["template"]) ? WP_CONTENT_DIR . "/" . $attr["template"] : $custom_template;
                     /**/
                     $code = trim(file_get_contents($custom_template ? $custom_template : dirname(dirname(dirname(dirname(__FILE__)))) . "/templates/forms/authnet-sp-checkout-form.php"));
                     $code = trim(!$custom_template || !is_multisite() || !c_ws_plugin__optimizemember_utils_conds::is_multisite_farm() || is_main_site() ? c_ws_plugin__optimizemember_utilities::evl($code) : $code);
                     /*
                     Fill in the action.
                     */
                     $code = preg_replace("/%%action%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds(esc_attr($_SERVER["REQUEST_URI"])), $code);
                     /*
                     Fill in the response.
                     */
                     $code = preg_replace("/%%response%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds($response["response"]), $code);
                     /*
                     Fill in the description.
                     */
                     $code = preg_replace("/%%description%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds($attr["desc"]), $code);
                     /*
                     Fill in the coupon value.
                     */
                     $code = preg_replace("/%%coupon_response%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds(c_ws_plugin__optimizemember_pro_authnet_utilities::authnet_apply_coupon($attr, $attr["coupon"], "response", array("affiliates-1px-response"))), $code);
                     $code = preg_replace("/%%coupon_value%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds(format_to_edit($attr["coupon"])), $code);
                     /*
                     Fill in the registration section.
                     */
                     $code = preg_replace("/%%first_name_value%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds(esc_attr($_p["optimizemember_pro_authnet_sp_checkout"]["first_name"])), $code);
                     $code = preg_replace("/%%last_name_value%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds(esc_attr($_p["optimizemember_pro_authnet_sp_checkout"]["last_name"])), $code);
                     $code = preg_replace("/%%email_value%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds(format_to_edit($_p["optimizemember_pro_authnet_sp_checkout"]["email"])), $code);
                     /*
                     Fill in the billing method section.
                     */
                     $code = preg_replace("/%%card_type_options%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds($card_type_options), $code);
                     $code = preg_replace("/%%card_number_value%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds(format_to_edit($_p["optimizemember_pro_authnet_sp_checkout"]["card_number"])), $code);
                     $code = preg_replace("/%%card_expiration_value%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds(format_to_edit($_p["optimizemember_pro_authnet_sp_checkout"]["card_expiration"])), $code);
                     $code = preg_replace("/%%card_verification_value%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds(format_to_edit($_p["optimizemember_pro_authnet_sp_checkout"]["card_verification"])), $code);
                     $code = preg_replace("/%%card_start_date_issue_number_value%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds(format_to_edit($_p["optimizemember_pro_authnet_sp_checkout"]["card_start_date_issue_number"])), $code);
                     /*
                     Fill in the billing address section.
                     */
                     $code = preg_replace("/%%street_value%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds(format_to_edit($_p["optimizemember_pro_authnet_sp_checkout"]["street"])), $code);
                     $code = preg_replace("/%%city_value%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds(format_to_edit($_p["optimizemember_pro_authnet_sp_checkout"]["city"])), $code);
                     $code = preg_replace("/%%state_value%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds(format_to_edit($_p["optimizemember_pro_authnet_sp_checkout"]["state"])), $code);
                     $code = preg_replace("/%%country_options%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds($country_options), $code);
                     $code = preg_replace("/%%zip_value%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds(format_to_edit($_p["optimizemember_pro_authnet_sp_checkout"]["zip"])), $code);
                     /*
                     Fill the captcha section.
                     */
                     $code = preg_replace("/%%captcha%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds($captcha), $code);
                     /*
                     Fill the opt-in box.
                     */
                     $code = preg_replace("/%%opt_in%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds($opt_in), $code);
                     /*
                     Fill hidden inputs.
                     */
                     $code = preg_replace("/%%hidden_inputs%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds($hidden_inputs), $code);
                     /**/
                     eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
                     do_action("ws_plugin__optimizemember_pro_during_sc_authnet_sp_form", get_defined_vars());
                     unset($__refs, $__v);
                     /* Unset defined __refs, __v. */
                 } else {
                     $_p = c_ws_plugin__optimizemember_utils_strings::trim_deep(stripslashes_deep($_POST));
                     /*
                     Configure internal attributes.
                     */
                     $attr["level_ccaps_eotper"] = $attr["rr"] === "BN" && $attr["rt"] !== "L" ? $attr["level"] . ":" . $attr["ccaps"] . ":" . $attr["rp"] . " " . $attr["rt"] : $attr["level"] . ":" . $attr["ccaps"];
                     $attr["level_ccaps_eotper"] = rtrim($attr["level_ccaps_eotper"], ":");
                     /* Clean any trailing separators from this string. */
                     $attr["coupon"] = $_p["optimizemember_pro_authnet_checkout"]["coupon"] ? $_p["optimizemember_pro_authnet_checkout"]["coupon"] : $attr["coupon"];
                     /*
                     Obtain a possible response and/or validation error.
                     */
                     $response = c_ws_plugin__optimizemember_pro_authnet_responses::authnet_checkout_response($attr);
                     /*
                     Empty post vars on successful response.
                     */
                     $_p = $response["response"] && !$response["error"] ? array() : $_p;
                     /*
                     Build the list of card type options.
                     */
                     foreach (array("Visa" => _x("Visa", "s2member-front", "s2member"), "MasterCard" => _x("MasterCard", "s2member-front", "s2member"), "Discover" => _x("Discover", "s2member-front", "s2member"), "Amex" => _x("American Express", "s2member-front", "s2member")) as $card_type_v => $card_type_l) {
                         $card_type_options .= '<label for="s2member-pro-authnet-checkout-card-type-' . esc_attr(strtolower($card_type_v)) . '" id="s2member-pro-authnet-checkout-form-card-type-' . esc_attr(strtolower($card_type_v)) . '-label" class="s2member-pro-authnet-form-card-type-label s2member-pro-authnet-checkout-form-card-type-label s2member-pro-authnet-form-card-type-' . esc_attr(strtolower($card_type_v)) . '-label s2member-pro-authnet-checkout-form-card-type-' . esc_attr(strtolower($card_type_v)) . '-label' . (!in_array(strtolower($card_type_v), $attr["accept"]) ? ' disabled' : '') . '">' . "\n" . '<input type="radio" aria-required="true" name="optimizemember_pro_authnet_checkout[card_type]" id="s2member-pro-authnet-checkout-card-type-' . esc_attr(strtolower($card_type_v)) . '" class="s2member-pro-authnet-card-type-' . esc_attr(strtolower($card_type_v)) . ' s2member-pro-authnet-checkout-card-type-' . esc_attr(strtolower($card_type_v)) . '" value="' . esc_attr($card_type_v) . '"' . (!empty($_p["optimizemember_pro_authnet_checkout"]["card_type"]) && in_array(strtolower($_p["optimizemember_pro_authnet_checkout"]["card_type"]), $attr["accept"]) && $_p["optimizemember_pro_authnet_checkout"]["card_type"] === $card_type_v ? ' checked="checked"' : '') . (!in_array(strtolower($card_type_v), $attr["accept"]) ? ' disabled="disabled"' : '') . ' tabindex="200" />' . "\n" . '</label>';
                     }
                     /*
                     Build the list of country code options.
                     $country_default_by_currency = false. Authorize.Net always processes in USD, so the country is empty by default.
                     Authorize.Net always processes in USD. International transactions are converted automatically through banking institutions.
                     */
                     $country_default_by_currency = !$_p["optimizemember_pro_authnet_checkout"]["country"] && $attr["cc"] === "USD" ? "US" : $country_default_by_currency;
                     $country_default_by_currency = !$_p["optimizemember_pro_authnet_checkout"]["country"] && $attr["cc"] === "CAD" ? "CA" : $country_default_by_currency;
                     $country_default_by_currency = !$_p["optimizemember_pro_authnet_checkout"]["country"] && $attr["cc"] === "GBP" ? "GB" : $country_default_by_currency;
                     $country_default_by_currency = apply_filters("ws_plugin__optimizemember_pro_authnet_default_country", false, get_defined_vars());
                     /**/
                     $default_country_v = $attr["default_country_code"] ? $attr["default_country_code"] : $country_default_by_currency;
                     /**/
                     $country_options = '<option value=""></option>';
                     /* Start with an empty option value. */
                     /**/
                     foreach (preg_split("/[\r\n]+/", file_get_contents(dirname(dirname(dirname(dirname(__FILE__)))) . "/iso-3166-1.txt")) as $country) {
                         list($country_l, $country_v) = preg_split("/;/", $country, 2);
                         /**/
                         if ($country_l && $country_v) {
                             /* Here we also check on the default pre-selected country; as determined above; based on currency. */
                             $country_options .= '<option value="' . esc_attr(strtoupper($country_v)) . '"' . ($_p["optimizemember_pro_authnet_checkout"]["country"] === $country_v || $default_country_v === $country_v ? ' selected="selected"' : '') . '>' . esc_html(ucwords(strtolower($country_l))) . '</option>';
                         }
                     }
                     /*
                     Build all of the custom fields.
                     */
                     if ($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["custom_reg_fields"]) {
                         /* Only display Custom Fields if configured. */
                         if ($fields_applicable = c_ws_plugin__optimizemember_custom_reg_fields::custom_fields_configured_at_level($attr["level"] === "*" ? "auto-detection" : $attr["level"], "registration")) {
                             $tabindex = 99;
                             /* Start tabindex at 99 ( +1 below = 100 ). */
                             /**/
                             $custom_fields = '<div id="s2member-pro-authnet-checkout-form-custom-fields-section" class="s2member-pro-authnet-form-section s2member-pro-authnet-checkout-form-section s2member-pro-authnet-form-custom-fields-section s2member-pro-authnet-checkout-form-custom-fields-section">' . "\n";
                             /**/
                             $custom_fields .= '<div id="s2member-pro-authnet-checkout-form-custom-fields-section-title" class="s2member-pro-authnet-form-section-title s2member-pro-authnet-checkout-form-section-title s2member-pro-authnet-form-custom-fields-section-title s2member-pro-authnet-checkout-form-custom-fields-section-title">' . "\n";
                             $custom_fields .= _x("Additional Info", "s2member-front", "s2member") . "\n";
                             $custom_fields .= '</div>' . "\n";
                             /**/
                             foreach (json_decode($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["custom_reg_fields"], true) as $field) {
                                 if (in_array($field["id"], $fields_applicable)) {
                                     $field_var = preg_replace("/[^a-z0-9]/i", "_", strtolower($field["id"]));
                                     $field_id_class = preg_replace("/_/", "-", $field_var);
                                     /**/
                                     if (!empty($field["section"]) && $field["section"] === "yes") {
                                         /* Starts a new section? */
                                         $custom_fields .= '<div id="s2member-pro-authnet-checkout-form-custom-reg-field-' . $field_id_class . '-divider-section" class="s2member-pro-authnet-form-div s2member-pro-authnet-checkout-form-div s2member-pro-authnet-form-custom-reg-field-divider-section' . (!empty($field["sectitle"]) ? '-title' : '') . ' s2member-pro-authnet-form-custom-reg-field-' . $field_id_class . '-divider-section' . (!empty($field["sectitle"]) ? '-title' : '') . ' s2member-pro-authnet-checkout-form-custom-reg-field-' . $field_id_class . '-divider-section' . (!empty($field["sectitle"]) ? '-title' : '') . '">' . (!empty($field["sectitle"]) ? $field["sectitle"] : '') . '</div>';
                                     }
                                     /**/
                                     $custom_fields .= '<div id="s2member-pro-authnet-checkout-form-custom-reg-field-' . $field_id_class . '-div" class="s2member-pro-authnet-form-div s2member-pro-authnet-checkout-form-div s2member-pro-authnet-form-custom-reg-field-' . $field_id_class . '-div s2member-pro-authnet-checkout-form-custom-reg-field-' . $field_id_class . '-div">' . "\n";
                                     /**/
                                     $custom_fields .= '<label for="s2member-pro-authnet-checkout-custom-reg-field-' . esc_attr($field_id_class) . '" id="s2member-pro-authnet-checkout-form-custom-reg-field-' . $field_id_class . '-label" class="s2member-pro-authnet-form-custom-reg-field-' . $field_id_class . '-label s2member-pro-authnet-checkout-form-custom-reg-field-' . $field_id_class . '-label">' . "\n";
                                     $custom_fields .= '<span' . (preg_match("/^(checkbox|pre_checkbox)\$/", $field["type"]) ? ' style="display:none;"' : '') . '>' . $field["label"] . ($field["required"] === "yes" ? ' *' : '') . '</span></label>' . (preg_match("/^(checkbox|pre_checkbox)\$/", $field["type"]) ? '' : '<br />') . "\n";
                                     $custom_fields .= c_ws_plugin__optimizemember_custom_reg_fields::custom_field_gen(__FUNCTION__, $field, "optimizemember_pro_authnet_checkout[custom_fields][", "s2member-pro-authnet-checkout-custom-reg-field-", "s2member-pro-authnet-custom-reg-field-" . $field_id_class . " s2member-pro-authnet-checkout-custom-reg-field-" . $field_id_class, "", $tabindex = $tabindex + 1, "", $_p, $_p["optimizemember_pro_authnet_checkout"]["custom_fields"][$field_var], "registration");
                                     /**/
                                     $custom_fields .= '</div>' . "\n";
                                 }
                             }
                             /**/
                             $custom_fields .= '</div>' . "\n";
                         }
                     }
                     /*
                     Build the reCaptcha box via JavaScript.
                     */
                     if ($attr["captcha"]) {
                         $captcha = '<div id="s2member-pro-authnet-checkout-form-captcha-section" class="s2member-pro-authnet-form-section s2member-pro-authnet-checkout-form-section s2member-pro-authnet-form-captcha-section s2member-pro-authnet-checkout-form-captcha-section">' . "\n";
                         /**/
                         $captcha .= '<div id="s2member-pro-authnet-checkout-form-captcha-section-title" class="s2member-pro-authnet-form-section-title s2member-pro-authnet-checkout-form-section-title s2member-pro-authnet-form-captcha-section-title s2member-pro-authnet-checkout-form-captcha-section-title">' . "\n";
                         $captcha .= _x("Security Code", "s2member-front", "s2member") . "\n";
                         $captcha .= '</div>' . "\n";
                         /**/
                         $captcha .= '<div id="s2member-pro-authnet-checkout-form-captcha-div" class="s2member-pro-authnet-form-div s2member-pro-authnet-checkout-form-div s2member-pro-authnet-form-captcha-div s2member-pro-authnet-checkout-form-captcha-div">' . "\n";
                         /**/
                         $captcha .= '<label id="s2member-pro-authnet-checkout-form-captcha-label" class="s2member-pro-authnet-form-captcha-label s2member-pro-authnet-checkout-form-captcha-label">' . "\n";
                         $captcha .= c_ws_plugin__optimizemember_utils_captchas::recaptcha_script_tag($attr["captcha"], 400) . "\n";
                         $captcha .= '</label>' . "\n";
                         /**/
                         $captcha .= '</div>' . "\n";
                         /**/
                         $captcha .= '</div>' . "\n";
                     }
                     /*
                     Build the opt-in checkbox.
                     */
                     if ($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["custom_reg_opt_in"] && c_ws_plugin__optimizemember_list_servers::list_servers_integrated()) {
                         $opt_in = '<div id="s2member-pro-authnet-checkout-form-custom-reg-field-opt-in-div" class="s2member-pro-authnet-form-div s2member-pro-authnet-checkout-form-div s2member-pro-authnet-form-custom-reg-field-opt-in-div s2member-pro-authnet-checkout-form-custom-reg-field-opt-in-div">' . "\n";
                         /**/
                         $opt_in .= '<label for="s2member-pro-authnet-checkout-form-custom-reg-field-opt-in" id="s2member-pro-authnet-checkout-form-custom-reg-field-opt-in-label" class="s2member-pro-authnet-form-custom-reg-field-opt-in-label s2member-pro-authnet-checkout-form-custom-reg-field-opt-in-label">' . "\n";
                         $opt_in .= '<input type="checkbox" name="optimizemember_pro_authnet_checkout[custom_fields][opt_in]" id="s2member-pro-authnet-checkout-form-custom-reg-field-opt-in" class="s2member-pro-authnet-form-custom-reg-field-opt-in s2member-pro-authnet-checkout-form-custom-reg-field-opt-in" value="1"' . (empty($_p) && $GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["custom_reg_opt_in"] == 1 || $_p["optimizemember_pro_authnet_checkout"]["custom_fields"]["opt_in"] ? ' checked="checked"' : '') . ' tabindex="500" />' . "\n";
                         $opt_in .= $GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["custom_reg_opt_in_label"] . "\n";
                         $opt_in .= '</label>' . "\n";
                         /**/
                         $opt_in .= '</div>' . "\n";
                     }
                     /*
                     Build the hidden input variables.
                     */
                     $hidden_inputs = '<input type="hidden" name="optimizemember_pro_authnet_checkout[nonce]" id="s2member-pro-authnet-checkout-nonce" value="' . esc_attr(wp_create_nonce("s2member-pro-authnet-checkout")) . '" />';
                     $hidden_inputs .= !$attr["accept_coupons"] ? '<input type="hidden" id="s2member-pro-authnet-checkout-coupons-not-required-or-not-possible" value="1" />' : '';
                     $hidden_inputs .= !$GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["custom_reg_password"] ? '<input type="hidden" id="s2member-pro-authnet-checkout-password-not-required-or-not-possible" value="1" />' : '';
                     $hidden_inputs .= !c_ws_plugin__optimizemember_pro_authnet_utilities::authnet_tax_may_apply() ? '<input type="hidden" id="s2member-pro-authnet-checkout-tax-not-required-or-not-possible" value="1" />' : '';
                     $hidden_inputs .= '<input type="hidden" name="optimizemember_pro_authnet_checkout[attr]" id="s2member-pro-authnet-checkout-attr" value="' . esc_attr(c_ws_plugin__optimizemember_utils_encryption::encrypt(serialize($attr))) . '" />';
                     /*
                     Get the form template.
                     */
                     $custom_template = file_exists(TEMPLATEPATH . "/authnet-checkout-form.php") ? TEMPLATEPATH . "/authnet-checkout-form.php" : false;
                     $custom_template = file_exists(TEMPLATEPATH . "/authnet-checkout-form.html") ? TEMPLATEPATH . "/authnet-checkout-form.html" : $custom_template;
                     $custom_template = $attr["template"] && file_exists(TEMPLATEPATH . "/" . $attr["template"]) ? TEMPLATEPATH . "/" . $attr["template"] : $custom_template;
                     $custom_template = $attr["template"] && file_exists(WP_CONTENT_DIR . "/" . $attr["template"]) ? WP_CONTENT_DIR . "/" . $attr["template"] : $custom_template;
                     /**/
                     $code = trim(file_get_contents($custom_template ? $custom_template : dirname(dirname(dirname(dirname(__FILE__)))) . "/templates/forms/authnet-checkout-form.php"));
                     $code = trim(!$custom_template || !is_multisite() || !c_ws_plugin__optimizemember_utils_conds::is_multisite_farm() || is_main_site() ? c_ws_plugin__optimizemember_utilities::evl($code) : $code);
                     /*
                     Fill in the action.
                     */
                     $code = preg_replace("/%%action%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds(esc_attr($_SERVER["REQUEST_URI"])), $code);
                     /*
                     Fill in the response.
                     */
                     $code = preg_replace("/%%response%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds($response["response"]), $code);
                     /*
                     Fill in the description.
                     */
                     $code = preg_replace("/%%description%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds($attr["desc"]), $code);
                     /*
                     Fill in the coupon value.
                     */
                     $code = preg_replace("/%%coupon_response%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds(c_ws_plugin__optimizemember_pro_authnet_utilities::authnet_apply_coupon($attr, $attr["coupon"], "response", array("affiliates-1px-response"))), $code);
                     $code = preg_replace("/%%coupon_value%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds(format_to_edit($attr["coupon"])), $code);
                     /*
                     Fill in the registration section.
                     */
                     $code = preg_replace("/%%first_name_value%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds(esc_attr($_p["optimizemember_pro_authnet_checkout"]["first_name"])), $code);
                     $code = preg_replace("/%%last_name_value%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds(esc_attr($_p["optimizemember_pro_authnet_checkout"]["last_name"])), $code);
                     $code = preg_replace("/%%email_value%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds(format_to_edit($_p["optimizemember_pro_authnet_checkout"]["email"])), $code);
                     $code = preg_replace("/%%username_value%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds(format_to_edit($_p["optimizemember_pro_authnet_checkout"]["username"])), $code);
                     $code = preg_replace("/%%password1_value%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds(format_to_edit($_p["optimizemember_pro_authnet_checkout"]["password1"])), $code);
                     $code = preg_replace("/%%password2_value%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds(format_to_edit($_p["optimizemember_pro_authnet_checkout"]["password2"])), $code);
                     /*
                     Fill in the custom fields section.
                     */
                     $code = preg_replace("/%%custom_fields%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds($custom_fields), $code);
                     /*
                     Fill in the billing method section.
                     */
                     $code = preg_replace("/%%card_type_options%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds($card_type_options), $code);
                     $code = preg_replace("/%%card_number_value%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds(format_to_edit($_p["optimizemember_pro_authnet_checkout"]["card_number"])), $code);
                     $code = preg_replace("/%%card_expiration_value%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds(format_to_edit($_p["optimizemember_pro_authnet_checkout"]["card_expiration"])), $code);
                     $code = preg_replace("/%%card_verification_value%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds(format_to_edit($_p["optimizemember_pro_authnet_checkout"]["card_verification"])), $code);
                     $code = preg_replace("/%%card_start_date_issue_number_value%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds(format_to_edit($_p["optimizemember_pro_authnet_checkout"]["card_start_date_issue_number"])), $code);
                     /*
                     Fill in the billing address section.
                     */
                     $code = preg_replace("/%%street_value%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds(format_to_edit($_p["optimizemember_pro_authnet_checkout"]["street"])), $code);
                     $code = preg_replace("/%%city_value%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds(format_to_edit($_p["optimizemember_pro_authnet_checkout"]["city"])), $code);
                     $code = preg_replace("/%%state_value%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds(format_to_edit($_p["optimizemember_pro_authnet_checkout"]["state"])), $code);
                     $code = preg_replace("/%%country_options%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds($country_options), $code);
                     $code = preg_replace("/%%zip_value%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds(format_to_edit($_p["optimizemember_pro_authnet_checkout"]["zip"])), $code);
                     /*
                     Fill the captcha section.
                     */
                     $code = preg_replace("/%%captcha%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds($captcha), $code);
                     /*
                     Fill the opt-in box.
                     */
                     $code = preg_replace("/%%opt_in%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds($opt_in), $code);
                     /*
                     Fill hidden inputs.
                     */
                     $code = preg_replace("/%%hidden_inputs%%/", c_ws_plugin__optimizemember_utils_strings::esc_ds($hidden_inputs), $code);
                     /*
                      * Custom button
                      */
                     if (!empty($content)) {
                         $code = preg_replace('/%%button_markup%%/', $content, $code);
                     } else {
                         $code = preg_replace("/%%button_markup%%/", sprintf('<input type="submit" id="s2member-pro-authnet-checkout-submit" class="s2member-pro-authnet-submit s2member-pro-authnet-checkout-submit" value="%s" tabindex="600" />', esc_attr(_x("Submit Form", "s2member-front", "s2member"))), $code);
                     }
                     /**/
                     eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
                     $attr["modify"] ? do_action("ws_plugin__optimizemember_pro_during_sc_authnet_modification_form", get_defined_vars()) : do_action("ws_plugin__optimizemember_pro_during_sc_authnet_form", get_defined_vars());
                     unset($__refs, $__v);
                     /* Unset defined __refs, __v. */
                 }
             }
         }
     }
     /**/
     $code = preg_replace('/^\\s+|\\n|\\r|\\s+$/m', '', $code);
     return apply_filters("ws_plugin__optimizemember_pro_sc_authnet_form", $code, get_defined_vars());
 }
 /**
  * Handles processing of Pro Form checkouts.
  *
  * @package optimizeMember\PayPal
  * @since 1.5
  *
  * @attaches-to ``add_action("init");``
  *
  * @return null Or exits script execution after a custom URL redirection; or upon Express Checkout redirection.
  */
 public static function paypal_checkout()
 {
     if (!empty($_POST["optimizemember_pro_paypal_checkout"]["nonce"]) && ($nonce = $_POST["optimizemember_pro_paypal_checkout"]["nonce"]) && wp_verify_nonce($nonce, "s2member-pro-paypal-checkout") || !empty($_GET["optimizemember_paypal_xco"]) && $_GET["optimizemember_paypal_xco"] === "optimizemember_pro_paypal_checkout_return" && !empty($_GET["token"]) && ($_GET["token"] = esc_html($_GET["token"])) && (empty($_GET["PayerID"]) || ($_GET["PayerID"] = esc_html($_GET["PayerID"]))) && ($xco_post_vars = get_transient("s2m_" . md5("optimizemember_transient_express_checkout_" . $_GET["token"])))) {
         $GLOBALS["ws_plugin__optimizemember_pro_paypal_checkout_response"] = array();
         /* This holds the global response details. */
         $global_response =& $GLOBALS["ws_plugin__optimizemember_pro_paypal_checkout_response"];
         /* This is a shorter reference. */
         /**/
         $post_vars = $xco_post_vars ? $xco_post_vars : $_POST["optimizemember_pro_paypal_checkout"];
         $post_vars = c_ws_plugin__optimizemember_utils_strings::trim_deep(stripslashes_deep($post_vars));
         /* And Filter. */
         $post_vars["attr"] = !$xco_post_vars ? unserialize(c_ws_plugin__optimizemember_utils_encryption::decrypt($post_vars["attr"])) : $post_vars["attr"];
         $post_vars["attr"] = !$xco_post_vars ? apply_filters("ws_plugin__optimizemember_pro_paypal_checkout_post_attr", $post_vars["attr"], get_defined_vars()) : $post_vars["attr"];
         /**/
         if ($xco_post_vars) {
             /* No need to re-validate this upon return from Express Checkout. */
             $post_vars["attr"]["captcha"] = "0";
         }
         /**/
         $post_vars["recaptcha_challenge_field"] = !$post_vars["recaptcha_challenge_field"] ? trim(stripslashes($_POST["recaptcha_challenge_field"])) : $post_vars["recaptcha_challenge_field"];
         $post_vars["recaptcha_response_field"] = !$post_vars["recaptcha_response_field"] ? trim(stripslashes($_POST["recaptcha_response_field"])) : $post_vars["recaptcha_response_field"];
         /**/
         $post_vars["name"] = trim($post_vars["first_name"] . " " . $post_vars["last_name"]);
         $post_vars["email"] = apply_filters("user_registration_email", sanitize_email($post_vars["email"]), get_defined_vars());
         $post_vars["username"] = preg_replace("/\\s+/", "", sanitize_user($post_vars["username"], is_multisite()));
         /**/
         !empty($_GET["token"]) ? delete_transient("s2m_" . md5("optimizemember_transient_express_checkout_" . $_GET["token"])) : null;
         /**/
         if (!c_ws_plugin__optimizemember_pro_paypal_responses::paypal_form_attr_validation_errors($post_vars["attr"])) {
             if (!($error = c_ws_plugin__optimizemember_pro_paypal_responses::paypal_form_submission_validation_errors("checkout", $post_vars))) {
                 $cp_attr = c_ws_plugin__optimizemember_pro_paypal_utilities::paypal_apply_coupon($post_vars["attr"], $post_vars["coupon"], "attr", array("affiliates-silent-post"));
                 $cp_2gbp_attr = c_ws_plugin__optimizemember_pro_paypal_utilities::paypal_maestro_solo_2gbp($cp_attr, $post_vars["card_type"]);
                 $cost_calculations = c_ws_plugin__optimizemember_pro_paypal_utilities::paypal_cost($cp_2gbp_attr["ta"], $cp_2gbp_attr["ra"], $post_vars["state"], $post_vars["country"], $post_vars["zip"], $cp_2gbp_attr["cc"], $cp_2gbp_attr["desc"]);
                 /**/
                 $use_recurring_profile = $post_vars["attr"]["rr"] === "BN" || !$post_vars["attr"]["tp"] && !$post_vars["attr"]["rr"] ? false : true;
                 $is_independent_ccaps_sale = $post_vars["attr"]["level"] === "*" ? true : false;
                 /* Selling Independent Custom Capabilities? */
                 /**/
                 if (empty($_GET["optimizemember_paypal_xco"]) && $post_vars["card_type"] === "PayPal") {
                     $return_url = $cancel_url = is_ssl() ? "https://" : "http://";
                     $return_url = $cancel_url = ($return_url = $cancel_url) . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
                     $return_url = $cancel_url = remove_query_arg(array("token", "PayerID"), $return_url = $cancel_url);
                     $return_url = add_query_arg("optimizemember_paypal_xco", urlencode("optimizemember_pro_paypal_checkout_return"), $return_url);
                     $cancel_url = add_query_arg("optimizemember_paypal_xco", urlencode("optimizemember_pro_paypal_checkout_cancel"), $cancel_url);
                     /**/
                     $user = is_user_logged_in() && is_object($user = wp_get_current_user()) && ($user_id = $user->ID) ? $user : false;
                     /**/
                     if (!($paypal_set_xco = array())) {
                         $paypal_set_xco["METHOD"] = "SetExpressCheckout";
                         /**/
                         $paypal_set_xco["RETURNURL"] = $return_url;
                         $paypal_set_xco["CANCELURL"] = $cancel_url;
                         /**/
                         $paypal_set_xco["PAGESTYLE"] = $post_vars["attr"]["ps"];
                         $paypal_set_xco["LOCALECODE"] = $post_vars["attr"]["lc"];
                         $paypal_set_xco["NOSHIPPING"] = $post_vars["attr"]["ns"];
                         $paypal_set_xco["SOLUTIONTYPE"] = "Sole";
                         $paypal_set_xco["LANDINGPAGE"] = "Billing";
                         $paypal_set_xco["ALLOWNOTE"] = "0";
                         /**/
                         if ($use_recurring_profile) {
                             $paypal_set_xco["L_BILLINGTYPE0"] = "RecurringPayments";
                             $paypal_set_xco["L_BILLINGAGREEMENTDESCRIPTION0"] = $cost_calculations["desc"];
                             if ($post_vars["attr"]["tp"] && $cost_calculations["trial_total"] > 0) {
                                 $paypal_set_xco["MAXAMT"] = $cost_calculations["trial_total"];
                             } else {
                                 $paypal_set_xco["MAXAMT"] = $cost_calculations["total"];
                             }
                         } else {
                             $paypal_set_xco["PAYMENTREQUEST_0_PAYMENTACTION"] = "Sale";
                             $paypal_set_xco["MAXAMT"] = $cost_calculations["total"];
                             /**/
                             $paypal_set_xco["PAYMENTREQUEST_0_DESC"] = $cost_calculations["desc"];
                             $paypal_set_xco["PAYMENTREQUEST_0_CUSTOM"] = $post_vars["attr"]["custom"];
                             /**/
                             $paypal_set_xco["PAYMENTREQUEST_0_CURRENCYCODE"] = $cost_calculations["cur"];
                             $paypal_set_xco["PAYMENTREQUEST_0_ITEMAMT"] = $cost_calculations["sub_total"];
                             $paypal_set_xco["PAYMENTREQUEST_0_TAXAMT"] = $cost_calculations["tax"];
                             $paypal_set_xco["PAYMENTREQUEST_0_AMT"] = $cost_calculations["total"];
                             /**/
                             $paypal_set_xco["L_PAYMENTREQUEST_0_QTY0"] = "1";
                             /* Always (1). */
                             $paypal_set_xco["L_PAYMENTREQUEST_0_NAME0"] = $cost_calculations["desc"];
                             $paypal_set_xco["L_PAYMENTREQUEST_0_NUMBER0"] = $post_vars["attr"]["level_ccaps_eotper"];
                             $paypal_set_xco["L_PAYMENTREQUEST_0_AMT0"] = $cost_calculations["sub_total"];
                         }
                         /**/
                         $paypal_set_xco["PAYMENTREQUEST_0_SHIPTONAME"] = $post_vars["name"];
                         $paypal_set_xco["PAYMENTREQUEST_0_SHIPTOSTREET"] = $post_vars["street"];
                         $paypal_set_xco["PAYMENTREQUEST_0_SHIPTOCITY"] = $post_vars["city"];
                         $paypal_set_xco["PAYMENTREQUEST_0_SHIPTOSTATE"] = $post_vars["state"];
                         $paypal_set_xco["PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE"] = $post_vars["country"];
                         $paypal_set_xco["PAYMENTREQUEST_0_SHIPTOZIP"] = $post_vars["zip"];
                         /**/
                         $paypal_set_xco["EMAIL"] = $user ? $user->user_email : $post_vars["email"];
                     }
                     /**/
                     if (($paypal_set_xco = c_ws_plugin__optimizemember_paypal_utilities::paypal_api_response($paypal_set_xco)) && empty($paypal_set_xco["__error"])) {
                         set_transient("s2m_" . md5("optimizemember_transient_express_checkout_" . $paypal_set_xco["TOKEN"]), $post_vars, 10800);
                         /**/
                         $endpoint = $GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["paypal_sandbox"] ? "www.sandbox.paypal.com" : "www.paypal.com";
                         /**/
                         wp_redirect(add_query_arg("token", urlencode($paypal_set_xco["TOKEN"]), "https://" . $endpoint . "/cgi-bin/webscr?cmd=_express-checkout"));
                         /**/
                         exit;
                         /* Clean exit. */
                     } else {
                         $global_response = array("response" => $paypal_set_xco["__error"], "error" => true);
                     }
                 } else {
                     if ($use_recurring_profile && is_user_logged_in() && is_object($user = wp_get_current_user()) && ($user_id = $user->ID)) {
                         if (!($cur__subscr_id = get_user_option("optimizemember_subscr_id")) || !($paypal = c_ws_plugin__optimizemember_paypal_utilities::paypal_api_response(array("METHOD" => "GetRecurringPaymentsProfileDetails", "PROFILEID" => $cur__subscr_id))) || !empty($paypal["__error"]) || !preg_match("/^(Pending|PendingProfile)\$/i", $paypal["STATUS"])) {
                             $period1 = c_ws_plugin__optimizemember_paypal_utilities::paypal_pro_period1($post_vars["attr"]["tp"] . " " . $post_vars["attr"]["tt"]);
                             $period3 = c_ws_plugin__optimizemember_paypal_utilities::paypal_pro_period3($post_vars["attr"]["rp"] . " " . $post_vars["attr"]["rt"]);
                             /**/
                             $start_time = $post_vars["attr"]["tp"] ? c_ws_plugin__optimizemember_pro_paypal_utilities::paypal_start_time($period1) : c_ws_plugin__optimizemember_pro_paypal_utilities::paypal_start_time($period3);
                             /* Or next billing cycle. */
                             /**/
                             $reference = $start_time . ":" . $period1 . ":" . $period3 . "~" . $_SERVER["HTTP_HOST"] . "~" . $post_vars["attr"]["level_ccaps_eotper"];
                             /**/
                             update_user_meta($user_id, "first_name", $post_vars["first_name"]) . update_user_meta($user_id, "last_name", $post_vars["last_name"]);
                             /**/
                             if (!($paypal = array())) {
                                 $paypal["METHOD"] = "CreateRecurringPaymentsProfile";
                                 /**/
                                 $paypal["EMAIL"] = $user->user_email;
                                 $paypal["FIRSTNAME"] = $post_vars["first_name"];
                                 $paypal["LASTNAME"] = $post_vars["last_name"];
                                 $paypal["SUBSCRIBERNAME"] = $post_vars["name"];
                                 /**/
                                 $paypal["DESC"] = $cost_calculations["desc"];
                                 $paypal["PROFILEREFERENCE"] = $reference;
                                 /**/
                                 if (!$post_vars["attr"]["tp"] || $post_vars["attr"]["tp"] && $cost_calculations["trial_total"] > 0) {
                                     $paypal["INITAMT"] = $post_vars["attr"]["tp"] ? $cost_calculations["trial_total"] : $cost_calculations["total"];
                                     $paypal["FAILEDINITAMTACTION"] = "CancelOnFailure";
                                 }
                                 /**/
                                 $paypal["CURRENCYCODE"] = $cost_calculations["cur"];
                                 $paypal["AMT"] = $cost_calculations["sub_total"];
                                 $paypal["TAXAMT"] = $cost_calculations["tax"];
                                 /**/
                                 $paypal["MAXFAILEDPAYMENTS"] = $post_vars["attr"]["rra"];
                                 $paypal["AUTOBILLOUTAMT"] = apply_filters("ws_plugin__optimizemember_pro_paypal_auto_bill_op", "AddToNextBilling", get_defined_vars());
                                 /**/
                                 $paypal["PROFILESTARTDATE"] = date("Y-m-d", $start_time) . "T00:00:00Z";
                                 /**/
                                 $paypal["BILLINGPERIOD"] = c_ws_plugin__optimizemember_paypal_utilities::paypal_pro_term($post_vars["attr"]["rt"]);
                                 $paypal["TOTALBILLINGCYCLES"] = $post_vars["attr"]["rr"] ? $post_vars["attr"]["rrt"] ? $post_vars["attr"]["rrt"] : "0" : "1";
                                 $paypal["BILLINGFREQUENCY"] = $post_vars["attr"]["rp"];
                                 /**/
                                 if ($_GET["optimizemember_paypal_xco"] === "optimizemember_pro_paypal_checkout_return" && !empty($_GET["token"]) && ($paypal_xco_details = array("METHOD" => "GetExpressCheckoutDetails", "TOKEN" => $_GET["token"])) && ($paypal_xco_details = c_ws_plugin__optimizemember_paypal_utilities::paypal_api_response($paypal_xco_details)) && empty($paypal_xco_details["__error"])) {
                                     $paypal["TOKEN"] = $paypal_xco_details["TOKEN"];
                                 } else {
                                     $paypal["CREDITCARDTYPE"] = $post_vars["card_type"];
                                     $paypal["ACCT"] = preg_replace("/[^0-9]/", "", $post_vars["card_number"]);
                                     $paypal["EXPDATE"] = preg_replace("/[^0-9]/", "", $post_vars["card_expiration"]);
                                     $paypal["CVV2"] = $post_vars["card_verification"];
                                     /**/
                                     if (in_array($post_vars["card_type"], array("Maestro", "Solo"))) {
                                         if (preg_match("/^[0-9]{2}\\/[0-9]{4}\$/", $post_vars["card_start_date_issue_number"])) {
                                             $paypal["STARTDATE"] = preg_replace("/[^0-9]/", "", $post_vars["card_start_date_issue_number"]);
                                         } else {
                                             /* Otherwise, we assume they provided an Issue Number instead. */
                                             $paypal["ISSUENUMBER"] = $post_vars["card_start_date_issue_number"];
                                         }
                                     }
                                     /**/
                                     $paypal["STREET"] = $post_vars["street"];
                                     $paypal["CITY"] = $post_vars["city"];
                                     $paypal["STATE"] = $post_vars["state"];
                                     $paypal["COUNTRYCODE"] = $post_vars["country"];
                                     $paypal["ZIP"] = $post_vars["zip"];
                                 }
                             }
                             /**/
                             if (($paypal = c_ws_plugin__optimizemember_paypal_utilities::paypal_api_response($paypal)) && empty($paypal["__error"])) {
                                 $old__subscr_or_wp_id = c_ws_plugin__optimizemember_utils_users::get_user_subscr_or_wp_id();
                                 $old__subscr_id = get_user_option("optimizemember_subscr_id");
                                 $new__subscr_id = $paypal["PROFILEID"];
                                 /**/
                                 if (!($ipn = array())) {
                                     $ipn["txn_type"] = "subscr_signup";
                                     $ipn["subscr_id"] = $new__subscr_id;
                                     $ipn["custom"] = $post_vars["attr"]["custom"];
                                     /**/
                                     $ipn["txn_id"] = $new__subscr_id;
                                     /**/
                                     $ipn["period1"] = $period1;
                                     $ipn["period3"] = $period3;
                                     /**/
                                     $ipn["mc_amount1"] = $cost_calculations["trial_total"];
                                     $ipn["mc_amount3"] = $cost_calculations["total"];
                                     /**/
                                     $ipn["mc_gross"] = preg_match("/^[1-9]/", $ipn["period1"]) ? $ipn["mc_amount1"] : $ipn["mc_amount3"];
                                     /**/
                                     $ipn["mc_currency"] = $cost_calculations["cur"];
                                     $ipn["tax"] = $cost_calculations["tax"];
                                     /**/
                                     $ipn["recurring"] = $post_vars["attr"]["rr"] ? "1" : "";
                                     /**/
                                     $ipn["payer_email"] = $user->user_email;
                                     $ipn["first_name"] = $post_vars["first_name"];
                                     $ipn["last_name"] = $post_vars["last_name"];
                                     /**/
                                     $ipn["option_name1"] = "Referencing Customer ID";
                                     $ipn["option_selection1"] = $old__subscr_or_wp_id;
                                     /**/
                                     $ipn["option_name2"] = "Customer IP Address";
                                     $ipn["option_selection2"] = $_SERVER["REMOTE_ADDR"];
                                     /**/
                                     $ipn["item_name"] = $cost_calculations["desc"];
                                     $ipn["item_number"] = $post_vars["attr"]["level_ccaps_eotper"];
                                     /**/
                                     $ipn_q = "&optimizemember_paypal_proxy=paypal&optimizemember_paypal_proxy_use=pro-emails";
                                     $ipn_q .= $ipn["mc_gross"] > 0 ? ",subscr-signup-as-subscr-payment" : "";
                                     /* Use as first payment? */
                                     $ipn_q .= "&optimizemember_paypal_proxy_verification=" . urlencode(c_ws_plugin__optimizemember_paypal_utilities::paypal_proxy_key_gen());
                                     $ipn_q .= "&optimizemember_paypal_proxy_return_url=" . rawurlencode($post_vars["attr"]["success"]);
                                     /**/
                                     $ipn["optimizemember_paypal_proxy_return_url"] = trim(c_ws_plugin__optimizemember_utils_urls::remote(site_url("/?optimizemember_paypal_notify=1" . $ipn_q), $ipn, array("timeout" => 20)));
                                 }
                                 /**/
                                 if (!($paypal = array()) && ($paypal["PROFILEID"] = $old__subscr_id)) {
                                     $paypal["METHOD"] = "ManageRecurringPaymentsProfileStatus";
                                     $paypal["ACTION"] = "Cancel";
                                     /**/
                                     c_ws_plugin__optimizemember_paypal_utilities::paypal_api_response($paypal);
                                 }
                                 /**/
                                 setcookie("optimizemember_tracking", $optimizemember_tracking = c_ws_plugin__optimizemember_utils_encryption::encrypt($new__subscr_id), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie("optimizemember_tracking", $optimizemember_tracking, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN) . ($_COOKIE["optimizemember_tracking"] = $optimizemember_tracking);
                                 /**/
                                 $global_response = array("response" => sprintf(_x('<strong>Thank you.</strong> Your account has been updated.<br />&mdash; Please <a href="%s" rel="nofollow">log back in</a> now.', "s2member-front", "s2member"), esc_attr(wp_login_url())));
                                 /**/
                                 if ($post_vars["attr"]["success"] && substr($ipn["optimizemember_paypal_proxy_return_url"], 0, 2) === substr($post_vars["attr"]["success"], 0, 2) && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__optimizemember_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $ipn["optimizemember_paypal_proxy_return_url"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
                                     wp_redirect(c_ws_plugin__optimizemember_utils_urls::add_optimizemember_sig($custom_success_url, "s2p-v")) . exit;
                                 }
                             } else {
                                 $global_response = array("response" => $paypal["__error"], "error" => true);
                             }
                         } else {
                             $global_response = array("response" => _x('<strong>Sorry.</strong> Your account is pending other changes. Please try again in 15 minutes.', "s2member-front", "s2member"), "error" => true);
                         }
                     } else {
                         if ($use_recurring_profile && !is_user_logged_in()) {
                             $period1 = c_ws_plugin__optimizemember_paypal_utilities::paypal_pro_period1($post_vars["attr"]["tp"] . " " . $post_vars["attr"]["tt"]);
                             $period3 = c_ws_plugin__optimizemember_paypal_utilities::paypal_pro_period3($post_vars["attr"]["rp"] . " " . $post_vars["attr"]["rt"]);
                             /**/
                             $start_time = $post_vars["attr"]["tp"] ? c_ws_plugin__optimizemember_pro_paypal_utilities::paypal_start_time($period1) : c_ws_plugin__optimizemember_pro_paypal_utilities::paypal_start_time($period3);
                             /* Or next billing cycle. */
                             /**/
                             $reference = $start_time . ":" . $period1 . ":" . $period3 . "~" . $_SERVER["HTTP_HOST"] . "~" . $post_vars["attr"]["level_ccaps_eotper"];
                             /**/
                             if (!($paypal = array())) {
                                 $paypal["METHOD"] = "CreateRecurringPaymentsProfile";
                                 /**/
                                 $paypal["EMAIL"] = $post_vars["email"];
                                 $paypal["FIRSTNAME"] = $post_vars["first_name"];
                                 $paypal["LASTNAME"] = $post_vars["last_name"];
                                 $paypal["SUBSCRIBERNAME"] = $post_vars["name"];
                                 /**/
                                 $paypal["DESC"] = $cost_calculations["desc"];
                                 $paypal["PROFILEREFERENCE"] = $reference;
                                 /**/
                                 if (!$post_vars["attr"]["tp"] || $post_vars["attr"]["tp"] && $cost_calculations["trial_total"] > 0) {
                                     $paypal["INITAMT"] = $post_vars["attr"]["tp"] ? $cost_calculations["trial_total"] : $cost_calculations["total"];
                                     $paypal["FAILEDINITAMTACTION"] = "CancelOnFailure";
                                 }
                                 /**/
                                 $paypal["CURRENCYCODE"] = $cost_calculations["cur"];
                                 $paypal["AMT"] = $cost_calculations["sub_total"];
                                 $paypal["TAXAMT"] = $cost_calculations["tax"];
                                 /**/
                                 $paypal["MAXFAILEDPAYMENTS"] = $post_vars["attr"]["rra"];
                                 $paypal["AUTOBILLOUTAMT"] = apply_filters("ws_plugin__optimizemember_pro_paypal_auto_bill_op", "AddToNextBilling", get_defined_vars());
                                 /**/
                                 $paypal["PROFILESTARTDATE"] = date("Y-m-d", $start_time) . "T00:00:00Z";
                                 /**/
                                 $paypal["BILLINGPERIOD"] = c_ws_plugin__optimizemember_paypal_utilities::paypal_pro_term($post_vars["attr"]["rt"]);
                                 $paypal["TOTALBILLINGCYCLES"] = $post_vars["attr"]["rr"] ? $post_vars["attr"]["rrt"] ? $post_vars["attr"]["rrt"] : "0" : "1";
                                 $paypal["BILLINGFREQUENCY"] = $post_vars["attr"]["rp"];
                                 /**/
                                 if ($_GET["optimizemember_paypal_xco"] === "optimizemember_pro_paypal_checkout_return" && !empty($_GET["token"]) && ($paypal_xco_details = array("METHOD" => "GetExpressCheckoutDetails", "TOKEN" => $_GET["token"])) && ($paypal_xco_details = c_ws_plugin__optimizemember_paypal_utilities::paypal_api_response($paypal_xco_details)) && empty($paypal_xco_details["__error"])) {
                                     $paypal["TOKEN"] = $paypal_xco_details["TOKEN"];
                                 } else {
                                     $paypal["CREDITCARDTYPE"] = $post_vars["card_type"];
                                     $paypal["ACCT"] = preg_replace("/[^0-9]/", "", $post_vars["card_number"]);
                                     $paypal["EXPDATE"] = preg_replace("/[^0-9]/", "", $post_vars["card_expiration"]);
                                     $paypal["CVV2"] = $post_vars["card_verification"];
                                     /**/
                                     if (in_array($post_vars["card_type"], array("Maestro", "Solo"))) {
                                         if (preg_match("/^[0-9]{2}\\/[0-9]{4}\$/", $post_vars["card_start_date_issue_number"])) {
                                             $paypal["STARTDATE"] = preg_replace("/[^0-9]/", "", $post_vars["card_start_date_issue_number"]);
                                         } else {
                                             /* Otherwise, we assume they provided an Issue Number instead. */
                                             $paypal["ISSUENUMBER"] = $post_vars["card_start_date_issue_number"];
                                         }
                                     }
                                     /**/
                                     $paypal["STREET"] = $post_vars["street"];
                                     $paypal["CITY"] = $post_vars["city"];
                                     $paypal["STATE"] = $post_vars["state"];
                                     $paypal["COUNTRYCODE"] = $post_vars["country"];
                                     $paypal["ZIP"] = $post_vars["zip"];
                                 }
                             }
                             /**/
                             if (($paypal = c_ws_plugin__optimizemember_paypal_utilities::paypal_api_response($paypal)) && empty($paypal["__error"])) {
                                 $new__subscr_id = $paypal["PROFILEID"];
                                 /**/
                                 if (!($ipn = array())) {
                                     $ipn["txn_type"] = "subscr_signup";
                                     $ipn["subscr_id"] = $new__subscr_id;
                                     $ipn["custom"] = $post_vars["attr"]["custom"];
                                     /**/
                                     $ipn["txn_id"] = $new__subscr_id;
                                     /**/
                                     $ipn["period1"] = $period1;
                                     $ipn["period3"] = $period3;
                                     /**/
                                     $ipn["mc_amount1"] = $cost_calculations["trial_total"];
                                     $ipn["mc_amount3"] = $cost_calculations["total"];
                                     /**/
                                     $ipn["mc_gross"] = preg_match("/^[1-9]/", $ipn["period1"]) ? $ipn["mc_amount1"] : $ipn["mc_amount3"];
                                     /**/
                                     $ipn["mc_currency"] = $cost_calculations["cur"];
                                     $ipn["tax"] = $cost_calculations["tax"];
                                     /**/
                                     $ipn["recurring"] = $post_vars["attr"]["rr"] ? "1" : "";
                                     /**/
                                     $ipn["payer_email"] = $post_vars["email"];
                                     $ipn["first_name"] = $post_vars["first_name"];
                                     $ipn["last_name"] = $post_vars["last_name"];
                                     /**/
                                     $ipn["option_name1"] = "Originating Domain";
                                     $ipn["option_selection1"] = $_SERVER["HTTP_HOST"];
                                     /**/
                                     $ipn["option_name2"] = "Customer IP Address";
                                     $ipn["option_selection2"] = $_SERVER["REMOTE_ADDR"];
                                     /**/
                                     $ipn["item_name"] = $cost_calculations["desc"];
                                     $ipn["item_number"] = $post_vars["attr"]["level_ccaps_eotper"];
                                     /**/
                                     $ipn_q = "&optimizemember_paypal_proxy=paypal&optimizemember_paypal_proxy_use=pro-emails";
                                     $ipn_q .= $ipn["mc_gross"] > 0 ? ",subscr-signup-as-subscr-payment" : "";
                                     /* Use as first payment? */
                                     $ipn_q .= "&optimizemember_paypal_proxy_verification=" . urlencode(c_ws_plugin__optimizemember_paypal_utilities::paypal_proxy_key_gen());
                                     $ipn_q .= "&optimizemember_paypal_proxy_return_url=" . rawurlencode($post_vars["attr"]["success"]);
                                 }
                                 /**/
                                 if (!($create_user = array())) {
                                     $_POST["ws_plugin__optimizemember_custom_reg_field_user_pass1"] = $post_vars["password1"];
                                     /* Fake this for registration configuration. */
                                     $_POST["ws_plugin__optimizemember_custom_reg_field_first_name"] = $post_vars["first_name"];
                                     /* Fake this for registration configuration. */
                                     $_POST["ws_plugin__optimizemember_custom_reg_field_last_name"] = $post_vars["last_name"];
                                     /* Fake this for registration configuration. */
                                     $_POST["ws_plugin__optimizemember_custom_reg_field_opt_in"] = $post_vars["custom_fields"]["opt_in"];
                                     /* Fake this too. */
                                     /**/
                                     if ($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["custom_reg_fields"]) {
                                         foreach (json_decode($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["custom_reg_fields"], true) as $field) {
                                             $field_var = preg_replace("/[^a-z0-9]/i", "_", strtolower($field["id"]));
                                             $field_id_class = preg_replace("/_/", "-", $field_var);
                                             /**/
                                             if (isset($post_vars["custom_fields"][$field_var])) {
                                                 $_POST["ws_plugin__optimizemember_custom_reg_field_" . $field_var] = $post_vars["custom_fields"][$field_var];
                                             }
                                         }
                                     }
                                     /**/
                                     $_COOKIE["optimizemember_subscr_gateway"] = c_ws_plugin__optimizemember_utils_encryption::encrypt("paypal");
                                     /* Fake this for registration configuration. */
                                     $_COOKIE["optimizemember_subscr_id"] = c_ws_plugin__optimizemember_utils_encryption::encrypt($new__subscr_id);
                                     /* Fake this for registration configuration. */
                                     $_COOKIE["optimizemember_custom"] = c_ws_plugin__optimizemember_utils_encryption::encrypt($post_vars["attr"]["custom"]);
                                     /* Fake this for registration configuration. */
                                     $_COOKIE["optimizemember_item_number"] = c_ws_plugin__optimizemember_utils_encryption::encrypt($post_vars["attr"]["level_ccaps_eotper"]);
                                     /* Fake this too. */
                                     /**/
                                     $create_user["user_login"] = $post_vars["username"];
                                     /* Copy this into a separate array for `wp_create_user()`. */
                                     $create_user["user_pass"] = wp_generate_password();
                                     /* Which may fire `c_ws_plugin__optimizemember_registrations::generate_password()`. */
                                     $create_user["user_email"] = $post_vars["email"];
                                     /* Copy this into a separate array for `wp_create_user()`. */
                                 }
                                 /**/
                                 if ($post_vars["password1"] && $post_vars["password1"] === $create_user["user_pass"]) {
                                     if ((is_multisite() && ($new__user_id = c_ws_plugin__optimizemember_registrations::ms_create_existing_user($create_user["user_login"], $create_user["user_email"], $create_user["user_pass"])) || ($new__user_id = wp_create_user($create_user["user_login"], $create_user["user_pass"], $create_user["user_email"]))) && !is_wp_error($new__user_id)) {
                                         wp_new_user_notification($new__user_id, $create_user["user_pass"]);
                                         /**/
                                         $ipn["optimizemember_paypal_proxy_return_url"] = trim(c_ws_plugin__optimizemember_utils_urls::remote(site_url("/?optimizemember_paypal_notify=1" . $ipn_q), $ipn, array("timeout" => 20)));
                                         /**/
                                         $global_response = array("response" => sprintf(_x('<strong>Thank you.</strong> Your account has been approved.<br />&mdash; Please <a href="%s" rel="nofollow">login</a>.', "s2member-front", "s2member"), esc_attr(wp_login_url())));
                                         /**/
                                         if ($post_vars["attr"]["success"] && substr($ipn["optimizemember_paypal_proxy_return_url"], 0, 2) === substr($post_vars["attr"]["success"], 0, 2) && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__optimizemember_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $ipn["optimizemember_paypal_proxy_return_url"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
                                             wp_redirect(c_ws_plugin__optimizemember_utils_urls::add_optimizemember_sig($custom_success_url, "s2p-v")) . exit;
                                         }
                                     } else {
                                         c_ws_plugin__optimizemember_utils_urls::remote(site_url("/?optimizemember_paypal_notify=1" . $ipn_q), $ipn, array("timeout" => 20));
                                         /**/
                                         $global_response = array("response" => _x('<strong>Oops.</strong> A slight problem. Please contact Support for assistance.', "s2member-front", "s2member"), "error" => true);
                                     }
                                 } else {
                                     if ((is_multisite() && ($new__user_id = c_ws_plugin__optimizemember_registrations::ms_create_existing_user($create_user["user_login"], $create_user["user_email"], $create_user["user_pass"])) || ($new__user_id = wp_create_user($create_user["user_login"], $create_user["user_pass"], $create_user["user_email"]))) && !is_wp_error($new__user_id)) {
                                         update_user_option($new__user_id, "default_password_nag", true, true);
                                         /* Password nag. */
                                         wp_new_user_notification($new__user_id, $create_user["user_pass"]);
                                         /**/
                                         $ipn["optimizemember_paypal_proxy_return_url"] = trim(c_ws_plugin__optimizemember_utils_urls::remote(site_url("/?optimizemember_paypal_notify=1" . $ipn_q), $ipn, array("timeout" => 20)));
                                         /**/
                                         $global_response = array("response" => _x('<strong>Thank you.</strong> Your account has been approved.<br />&mdash; You\'ll receive an email momentarily.', "s2member-front", "s2member"));
                                         /**/
                                         if ($post_vars["attr"]["success"] && substr($ipn["optimizemember_paypal_proxy_return_url"], 0, 2) === substr($post_vars["attr"]["success"], 0, 2) && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__optimizemember_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $ipn["optimizemember_paypal_proxy_return_url"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
                                             wp_redirect(c_ws_plugin__optimizemember_utils_urls::add_optimizemember_sig($custom_success_url, "s2p-v")) . exit;
                                         }
                                     } else {
                                         c_ws_plugin__optimizemember_utils_urls::remote(site_url("/?optimizemember_paypal_notify=1" . $ipn_q), $ipn, array("timeout" => 20));
                                         /**/
                                         $global_response = array("response" => _x('<strong>Oops.</strong> A slight problem. Please contact Support for assistance.', "s2member-front", "s2member"), "error" => true);
                                     }
                                 }
                             } else {
                                 $global_response = array("response" => $paypal["__error"], "error" => true);
                             }
                         } else {
                             if (!$use_recurring_profile && is_user_logged_in() && is_object($user = wp_get_current_user()) && ($user_id = $user->ID)) {
                                 if ($is_independent_ccaps_sale || !($cur__subscr_id = get_user_option("optimizemember_subscr_id")) || !($paypal = c_ws_plugin__optimizemember_paypal_utilities::paypal_api_response(array("METHOD" => "GetRecurringPaymentsProfileDetails", "PROFILEID" => $cur__subscr_id))) || !empty($paypal["__error"]) || !preg_match("/^(Pending|PendingProfile)\$/i", $paypal["STATUS"])) {
                                     update_user_meta($user_id, "first_name", $post_vars["first_name"]) . update_user_meta($user_id, "last_name", $post_vars["last_name"]);
                                     /**/
                                     if (!($paypal = array())) {
                                         if ($_GET["optimizemember_paypal_xco"] === "optimizemember_pro_paypal_checkout_return" && !empty($_GET["token"]) && ($paypal_xco_details = array("METHOD" => "GetExpressCheckoutDetails", "TOKEN" => $_GET["token"])) && ($paypal_xco_details = c_ws_plugin__optimizemember_paypal_utilities::paypal_api_response($paypal_xco_details)) && empty($paypal_xco_details["__error"])) {
                                             $paypal["METHOD"] = "DoExpressCheckoutPayment";
                                             /**/
                                             $paypal["TOKEN"] = $paypal_xco_details["TOKEN"];
                                             $paypal["PAYERID"] = $paypal_xco_details["PAYERID"];
                                             /**/
                                             $paypal["PAYMENTREQUEST_0_PAYMENTACTION"] = "Sale";
                                             /**/
                                             $paypal["PAYMENTREQUEST_0_DESC"] = $cost_calculations["desc"];
                                             $paypal["PAYMENTREQUEST_0_CUSTOM"] = $post_vars["attr"]["custom"];
                                             /**/
                                             $paypal["PAYMENTREQUEST_0_CURRENCYCODE"] = $cost_calculations["cur"];
                                             $paypal["PAYMENTREQUEST_0_ITEMAMT"] = $cost_calculations["sub_total"];
                                             $paypal["PAYMENTREQUEST_0_TAXAMT"] = $cost_calculations["tax"];
                                             $paypal["PAYMENTREQUEST_0_AMT"] = $cost_calculations["total"];
                                             /**/
                                             $paypal["L_PAYMENTREQUEST_0_QTY0"] = "1";
                                             /* Always (1). */
                                             $paypal["L_PAYMENTREQUEST_0_NAME0"] = $cost_calculations["desc"];
                                             $paypal["L_PAYMENTREQUEST_0_NUMBER0"] = $post_vars["attr"]["level_ccaps_eotper"];
                                             $paypal["L_PAYMENTREQUEST_0_AMT0"] = $cost_calculations["sub_total"];
                                         } else {
                                             $paypal["METHOD"] = "DoDirectPayment";
                                             $paypal["PAYMENTACTION"] = "Sale";
                                             /**/
                                             $paypal["EMAIL"] = $user->user_email;
                                             $paypal["FIRSTNAME"] = $post_vars["first_name"];
                                             $paypal["LASTNAME"] = $post_vars["last_name"];
                                             $paypal["IPADDRESS"] = $_SERVER["REMOTE_ADDR"];
                                             /**/
                                             $paypal["DESC"] = $cost_calculations["desc"];
                                             $paypal["CUSTOM"] = $post_vars["attr"]["custom"];
                                             /**/
                                             $paypal["CURRENCYCODE"] = $cost_calculations["cur"];
                                             $paypal["ITEMAMT"] = $cost_calculations["sub_total"];
                                             $paypal["TAXAMT"] = $cost_calculations["tax"];
                                             $paypal["AMT"] = $cost_calculations["total"];
                                             /**/
                                             $paypal["L_QTY0"] = "1";
                                             /* Always (1). */
                                             $paypal["L_NAME0"] = $cost_calculations["desc"];
                                             $paypal["L_NUMBER0"] = $post_vars["attr"]["level_ccaps_eotper"];
                                             $paypal["L_AMT0"] = $cost_calculations["sub_total"];
                                             /**/
                                             $paypal["CREDITCARDTYPE"] = $post_vars["card_type"];
                                             $paypal["ACCT"] = preg_replace("/[^0-9]/", "", $post_vars["card_number"]);
                                             $paypal["EXPDATE"] = preg_replace("/[^0-9]/", "", $post_vars["card_expiration"]);
                                             $paypal["CVV2"] = $post_vars["card_verification"];
                                             /**/
                                             if (in_array($post_vars["card_type"], array("Maestro", "Solo"))) {
                                                 if (preg_match("/^[0-9]{2}\\/[0-9]{4}\$/", $post_vars["card_start_date_issue_number"])) {
                                                     $paypal["STARTDATE"] = preg_replace("/[^0-9]/", "", $post_vars["card_start_date_issue_number"]);
                                                 } else {
                                                     /* Otherwise, we assume they provided an Issue Number instead. */
                                                     $paypal["ISSUENUMBER"] = $post_vars["card_start_date_issue_number"];
                                                 }
                                             }
                                             /**/
                                             $paypal["STREET"] = $post_vars["street"];
                                             $paypal["CITY"] = $post_vars["city"];
                                             $paypal["STATE"] = $post_vars["state"];
                                             $paypal["COUNTRYCODE"] = $post_vars["country"];
                                             $paypal["ZIP"] = $post_vars["zip"];
                                         }
                                     }
                                     /**/
                                     if (($paypal = c_ws_plugin__optimizemember_paypal_utilities::paypal_api_response($paypal)) && empty($paypal["__error"])) {
                                         $old__subscr_id = get_user_option("optimizemember_subscr_id");
                                         $old__subscr_or_wp_id = c_ws_plugin__optimizemember_utils_users::get_user_subscr_or_wp_id();
                                         $new__subscr_id = $new__txn_id = !empty($paypal["PAYMENTINFO_0_TRANSACTIONID"]) ? $paypal["PAYMENTINFO_0_TRANSACTIONID"] : false;
                                         $new__subscr_id = $new__txn_id = !$new__subscr_id && !empty($paypal["TRANSACTIONID"]) ? $paypal["TRANSACTIONID"] : $new__subscr_id;
                                         /**/
                                         if (!($ipn = array())) {
                                             $ipn["txn_type"] = "web_accept";
                                             $ipn["txn_id"] = $new__subscr_id;
                                             $ipn["custom"] = $post_vars["attr"]["custom"];
                                             /**/
                                             $ipn["mc_gross"] = $cost_calculations["total"];
                                             $ipn["mc_currency"] = $cost_calculations["cur"];
                                             $ipn["tax"] = $cost_calculations["tax"];
                                             /**/
                                             $ipn["payer_email"] = $user->user_email;
                                             $ipn["first_name"] = $post_vars["first_name"];
                                             $ipn["last_name"] = $post_vars["last_name"];
                                             /**/
                                             $ipn["option_name1"] = "Referencing Customer ID";
                                             $ipn["option_selection1"] = $old__subscr_or_wp_id;
                                             /**/
                                             $ipn["option_name2"] = "Customer IP Address";
                                             $ipn["option_selection2"] = $_SERVER["REMOTE_ADDR"];
                                             /**/
                                             $ipn["item_name"] = $cost_calculations["desc"];
                                             $ipn["item_number"] = $post_vars["attr"]["level_ccaps_eotper"];
                                             /**/
                                             $ipn_q = "&optimizemember_paypal_proxy=paypal&optimizemember_paypal_proxy_use=pro-emails";
                                             $ipn_q .= "&optimizemember_paypal_proxy_verification=" . urlencode(c_ws_plugin__optimizemember_paypal_utilities::paypal_proxy_key_gen());
                                             $ipn_q .= "&optimizemember_paypal_proxy_return_url=" . rawurlencode($post_vars["attr"]["success"]);
                                             /**/
                                             $ipn["optimizemember_paypal_proxy_return_url"] = trim(c_ws_plugin__optimizemember_utils_urls::remote(site_url("/?optimizemember_paypal_notify=1" . $ipn_q), $ipn, array("timeout" => 20)));
                                         }
                                         /**/
                                         if (!$is_independent_ccaps_sale) {
                                             /* Independent? */
                                             if (!($paypal = array()) && ($paypal["PROFILEID"] = $old__subscr_id)) {
                                                 $paypal["METHOD"] = "ManageRecurringPaymentsProfileStatus";
                                                 $paypal["ACTION"] = "Cancel";
                                                 /**/
                                                 c_ws_plugin__optimizemember_paypal_utilities::paypal_api_response($paypal);
                                             }
                                         }
                                         /**/
                                         setcookie("optimizemember_tracking", $optimizemember_tracking = c_ws_plugin__optimizemember_utils_encryption::encrypt($new__subscr_id), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie("optimizemember_tracking", $optimizemember_tracking, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN) . ($_COOKIE["optimizemember_tracking"] = $optimizemember_tracking);
                                         /**/
                                         $global_response = array("response" => sprintf(_x('<strong>Thank you.</strong> Your account has been updated.<br />&mdash; Please <a href="%s" rel="nofollow">log back in</a> now.', "s2member-front", "s2member"), esc_attr(wp_login_url())));
                                         /**/
                                         if ($post_vars["attr"]["success"] && substr($ipn["optimizemember_paypal_proxy_return_url"], 0, 2) === substr($post_vars["attr"]["success"], 0, 2) && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__optimizemember_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $ipn["optimizemember_paypal_proxy_return_url"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
                                             wp_redirect(c_ws_plugin__optimizemember_utils_urls::add_optimizemember_sig($custom_success_url, "s2p-v")) . exit;
                                         }
                                     } else {
                                         $global_response = array("response" => $paypal["__error"], "error" => true);
                                     }
                                 } else {
                                     $global_response = array("response" => _x('<strong>Sorry.</strong> Your account is pending other changes. Please try again in 15 minutes.', "s2member-front", "s2member"), "error" => true);
                                 }
                             } else {
                                 if (!$use_recurring_profile && !is_user_logged_in()) {
                                     if (!($paypal = array())) {
                                         if ($_GET["optimizemember_paypal_xco"] === "optimizemember_pro_paypal_checkout_return" && !empty($_GET["token"]) && ($paypal_xco_details = array("METHOD" => "GetExpressCheckoutDetails", "TOKEN" => $_GET["token"])) && ($paypal_xco_details = c_ws_plugin__optimizemember_paypal_utilities::paypal_api_response($paypal_xco_details)) && empty($paypal_xco_details["__error"])) {
                                             $paypal["METHOD"] = "DoExpressCheckoutPayment";
                                             /**/
                                             $paypal["TOKEN"] = $paypal_xco_details["TOKEN"];
                                             $paypal["PAYERID"] = $paypal_xco_details["PAYERID"];
                                             /**/
                                             $paypal["PAYMENTREQUEST_0_PAYMENTACTION"] = "Sale";
                                             /**/
                                             $paypal["PAYMENTREQUEST_0_DESC"] = $cost_calculations["desc"];
                                             $paypal["PAYMENTREQUEST_0_CUSTOM"] = $post_vars["attr"]["custom"];
                                             /**/
                                             $paypal["PAYMENTREQUEST_0_CURRENCYCODE"] = $cost_calculations["cur"];
                                             $paypal["PAYMENTREQUEST_0_ITEMAMT"] = $cost_calculations["sub_total"];
                                             $paypal["PAYMENTREQUEST_0_TAXAMT"] = $cost_calculations["tax"];
                                             $paypal["PAYMENTREQUEST_0_AMT"] = $cost_calculations["total"];
                                             /**/
                                             $paypal["L_PAYMENTREQUEST_0_QTY0"] = "1";
                                             /* Always (1). */
                                             $paypal["L_PAYMENTREQUEST_0_NAME0"] = $cost_calculations["desc"];
                                             $paypal["L_PAYMENTREQUEST_0_NUMBER0"] = $post_vars["attr"]["level_ccaps_eotper"];
                                             $paypal["L_PAYMENTREQUEST_0_AMT0"] = $cost_calculations["sub_total"];
                                         } else {
                                             $paypal["METHOD"] = "DoDirectPayment";
                                             $paypal["PAYMENTACTION"] = "Sale";
                                             /**/
                                             $paypal["EMAIL"] = $post_vars["email"];
                                             $paypal["FIRSTNAME"] = $post_vars["first_name"];
                                             $paypal["LASTNAME"] = $post_vars["last_name"];
                                             $paypal["IPADDRESS"] = $_SERVER["REMOTE_ADDR"];
                                             /**/
                                             $paypal["DESC"] = $cost_calculations["desc"];
                                             $paypal["CUSTOM"] = $post_vars["attr"]["custom"];
                                             /**/
                                             $paypal["CURRENCYCODE"] = $cost_calculations["cur"];
                                             $paypal["ITEMAMT"] = $cost_calculations["sub_total"];
                                             $paypal["TAXAMT"] = $cost_calculations["tax"];
                                             $paypal["AMT"] = $cost_calculations["total"];
                                             /**/
                                             $paypal["L_QTY0"] = "1";
                                             /* Always (1). */
                                             $paypal["L_NAME0"] = $cost_calculations["desc"];
                                             $paypal["L_NUMBER0"] = $post_vars["attr"]["level_ccaps_eotper"];
                                             $paypal["L_AMT0"] = $cost_calculations["sub_total"];
                                             /**/
                                             $paypal["CREDITCARDTYPE"] = $post_vars["card_type"];
                                             $paypal["ACCT"] = preg_replace("/[^0-9]/", "", $post_vars["card_number"]);
                                             $paypal["EXPDATE"] = preg_replace("/[^0-9]/", "", $post_vars["card_expiration"]);
                                             $paypal["CVV2"] = $post_vars["card_verification"];
                                             /**/
                                             if (in_array($post_vars["card_type"], array("Maestro", "Solo"))) {
                                                 if (preg_match("/^[0-9]{2}\\/[0-9]{4}\$/", $post_vars["card_start_date_issue_number"])) {
                                                     $paypal["STARTDATE"] = preg_replace("/[^0-9]/", "", $post_vars["card_start_date_issue_number"]);
                                                 } else {
                                                     /* Otherwise, we assume they provided an Issue Number instead. */
                                                     $paypal["ISSUENUMBER"] = $post_vars["card_start_date_issue_number"];
                                                 }
                                             }
                                             /**/
                                             $paypal["STREET"] = $post_vars["street"];
                                             $paypal["CITY"] = $post_vars["city"];
                                             $paypal["STATE"] = $post_vars["state"];
                                             $paypal["COUNTRYCODE"] = $post_vars["country"];
                                             $paypal["ZIP"] = $post_vars["zip"];
                                         }
                                     }
                                     /**/
                                     if (($paypal = c_ws_plugin__optimizemember_paypal_utilities::paypal_api_response($paypal)) && empty($paypal["__error"])) {
                                         $new__subscr_id = !empty($paypal["PAYMENTINFO_0_TRANSACTIONID"]) ? $paypal["PAYMENTINFO_0_TRANSACTIONID"] : false;
                                         $new__subscr_id = !$new__subscr_id && !empty($paypal["TRANSACTIONID"]) ? $paypal["TRANSACTIONID"] : $new__subscr_id;
                                         /**/
                                         if (!($ipn = array())) {
                                             $ipn["txn_type"] = "web_accept";
                                             $ipn["txn_id"] = $new__subscr_id;
                                             $ipn["custom"] = $post_vars["attr"]["custom"];
                                             /**/
                                             $ipn["mc_gross"] = $cost_calculations["total"];
                                             $ipn["mc_currency"] = $cost_calculations["cur"];
                                             $ipn["tax"] = $cost_calculations["tax"];
                                             /**/
                                             $ipn["payer_email"] = $post_vars["email"];
                                             $ipn["first_name"] = $post_vars["first_name"];
                                             $ipn["last_name"] = $post_vars["last_name"];
                                             /**/
                                             $ipn["option_name1"] = "Originating Domain";
                                             $ipn["option_selection1"] = $_SERVER["HTTP_HOST"];
                                             /**/
                                             $ipn["option_name2"] = "Customer IP Address";
                                             $ipn["option_selection2"] = $_SERVER["REMOTE_ADDR"];
                                             /**/
                                             $ipn["item_name"] = $cost_calculations["desc"];
                                             $ipn["item_number"] = $post_vars["attr"]["level_ccaps_eotper"];
                                             /**/
                                             $ipn_q = "&optimizemember_paypal_proxy=paypal&optimizemember_paypal_proxy_use=pro-emails";
                                             $ipn_q .= "&optimizemember_paypal_proxy_verification=" . urlencode(c_ws_plugin__optimizemember_paypal_utilities::paypal_proxy_key_gen());
                                             $ipn_q .= "&optimizemember_paypal_proxy_return_url=" . rawurlencode($post_vars["attr"]["success"]);
                                         }
                                         /**/
                                         if (!($create_user = array())) {
                                             $_POST["ws_plugin__optimizemember_custom_reg_field_user_pass1"] = $post_vars["password1"];
                                             /* Fake this for registration configuration. */
                                             $_POST["ws_plugin__optimizemember_custom_reg_field_first_name"] = $post_vars["first_name"];
                                             /* Fake this for registration configuration. */
                                             $_POST["ws_plugin__optimizemember_custom_reg_field_last_name"] = $post_vars["last_name"];
                                             /* Fake this for registration configuration. */
                                             $_POST["ws_plugin__optimizemember_custom_reg_field_opt_in"] = $post_vars["custom_fields"]["opt_in"];
                                             /* Fake this too. */
                                             /**/
                                             if ($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["custom_reg_fields"]) {
                                                 foreach (json_decode($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["custom_reg_fields"], true) as $field) {
                                                     $field_var = preg_replace("/[^a-z0-9]/i", "_", strtolower($field["id"]));
                                                     $field_id_class = preg_replace("/_/", "-", $field_var);
                                                     /**/
                                                     if (isset($post_vars["custom_fields"][$field_var])) {
                                                         $_POST["ws_plugin__optimizemember_custom_reg_field_" . $field_var] = $post_vars["custom_fields"][$field_var];
                                                     }
                                                 }
                                             }
                                             /**/
                                             $_COOKIE["optimizemember_subscr_gateway"] = c_ws_plugin__optimizemember_utils_encryption::encrypt("paypal");
                                             /* Fake this for registration configuration. */
                                             $_COOKIE["optimizemember_subscr_id"] = c_ws_plugin__optimizemember_utils_encryption::encrypt($new__subscr_id);
                                             /* Fake this for registration configuration. */
                                             $_COOKIE["optimizemember_custom"] = c_ws_plugin__optimizemember_utils_encryption::encrypt($post_vars["attr"]["custom"]);
                                             /* Fake this for registration configuration. */
                                             $_COOKIE["optimizemember_item_number"] = c_ws_plugin__optimizemember_utils_encryption::encrypt($post_vars["attr"]["level_ccaps_eotper"]);
                                             /* Fake this too. */
                                             /**/
                                             $create_user["user_login"] = $post_vars["username"];
                                             /* Copy this into a separate array for `wp_create_user()`. */
                                             $create_user["user_pass"] = wp_generate_password();
                                             /* Which may fire `c_ws_plugin__optimizemember_registrations::generate_password()`. */
                                             $create_user["user_email"] = $post_vars["email"];
                                             /* Copy this into a separate array for `wp_create_user()`. */
                                         }
                                         /**/
                                         if ($post_vars["password1"] && $post_vars["password1"] === $create_user["user_pass"]) {
                                             if ((is_multisite() && ($new__user_id = c_ws_plugin__optimizemember_registrations::ms_create_existing_user($create_user["user_login"], $create_user["user_email"], $create_user["user_pass"])) || ($new__user_id = wp_create_user($create_user["user_login"], $create_user["user_pass"], $create_user["user_email"]))) && !is_wp_error($new__user_id)) {
                                                 wp_new_user_notification($new__user_id, $create_user["user_pass"]);
                                                 /**/
                                                 $ipn["optimizemember_paypal_proxy_return_url"] = trim(c_ws_plugin__optimizemember_utils_urls::remote(site_url("/?optimizemember_paypal_notify=1" . $ipn_q), $ipn, array("timeout" => 20)));
                                                 /**/
                                                 $global_response = array("response" => sprintf(_x('<strong>Thank you.</strong> Your account has been approved.<br />&mdash; Please <a href="%s" rel="nofollow">login</a>.', "s2member-front", "s2member"), esc_attr(wp_login_url())));
                                                 /**/
                                                 if ($post_vars["attr"]["success"] && substr($ipn["optimizemember_paypal_proxy_return_url"], 0, 2) === substr($post_vars["attr"]["success"], 0, 2) && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__optimizemember_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $ipn["optimizemember_paypal_proxy_return_url"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
                                                     wp_redirect(c_ws_plugin__optimizemember_utils_urls::add_optimizemember_sig($custom_success_url, "s2p-v")) . exit;
                                                 }
                                             } else {
                                                 c_ws_plugin__optimizemember_utils_urls::remote(site_url("/?optimizemember_paypal_notify=1" . $ipn_q), $ipn, array("timeout" => 20));
                                                 /**/
                                                 $global_response = array("response" => _x('<strong>Oops.</strong> A slight problem. Please contact Support for assistance.', "s2member-front", "s2member"), "error" => true);
                                             }
                                         } else {
                                             if ((is_multisite() && ($new__user_id = c_ws_plugin__optimizemember_registrations::ms_create_existing_user($create_user["user_login"], $create_user["user_email"], $create_user["user_pass"])) || ($new__user_id = wp_create_user($create_user["user_login"], $create_user["user_pass"], $create_user["user_email"]))) && !is_wp_error($new__user_id)) {
                                                 update_user_option($new__user_id, "default_password_nag", true, true);
                                                 /* Password nag. */
                                                 wp_new_user_notification($new__user_id, $create_user["user_pass"]);
                                                 /**/
                                                 $ipn["optimizemember_paypal_proxy_return_url"] = trim(c_ws_plugin__optimizemember_utils_urls::remote(site_url("/?optimizemember_paypal_notify=1" . $ipn_q), $ipn, array("timeout" => 20)));
                                                 /**/
                                                 $global_response = array("response" => _x('<strong>Thank you.</strong> Your account has been approved.<br />&mdash; You\'ll receive an email momentarily.', "s2member-front", "s2member"));
                                                 /**/
                                                 if ($post_vars["attr"]["success"] && substr($ipn["optimizemember_paypal_proxy_return_url"], 0, 2) === substr($post_vars["attr"]["success"], 0, 2) && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__optimizemember_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $ipn["optimizemember_paypal_proxy_return_url"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
                                                     wp_redirect(c_ws_plugin__optimizemember_utils_urls::add_optimizemember_sig($custom_success_url, "s2p-v")) . exit;
                                                 }
                                             } else {
                                                 c_ws_plugin__optimizemember_utils_urls::remote(site_url("/?optimizemember_paypal_notify=1" . $ipn_q), $ipn, array("timeout" => 20));
                                                 /**/
                                                 $global_response = array("response" => _x('<strong>Oops.</strong> A slight problem. Please contact Support for assistance.', "s2member-front", "s2member"), "error" => true);
                                             }
                                         }
                                     } else {
                                         $global_response = array("response" => $paypal["__error"], "error" => true);
                                     }
                                 } else {
                                     $global_response = array("response" => _x('<strong>Unknown error.</strong> Please contact Support for assistance.', "s2member-front", "s2member"), "error" => true);
                                 }
                             }
                         }
                     }
                 }
             } else {
                 $global_response = $error;
             }
         }
     }
 }
 /**
  * Get ``$_POST`` or ``$_REQUEST`` vars from Google.
  *
  * @package optimizeMember\Google
  * @since 1.5
  *
  * @return array|bool An array of verified ``$_POST`` or ``$_REQUEST`` variables, else false.
  *
  * @todo Continue optimizing this routine with ``empty()`` and ``isset()``.
  * @todo Candidate for the use of ``ifsetor()``?
  */
 public static function google_postvars()
 {
     if (!empty($_REQUEST["optimizemember_pro_google_notify"]) && !empty($_REQUEST["serial-number"])) {
         $postback["_type"] = "notification-history-request";
         $postback["serial-number"] = trim(stripslashes((string) $_REQUEST["serial-number"]));
         /**/
         $endpoint = $GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["pro_google_sandbox"] ? "sandbox.google.com/checkout" : "checkout.google.com";
         /**/
         if (($response = c_ws_plugin__optimizemember_utils_urls::remote("https://" . $endpoint . "/api/checkout/v2/reportsForm/Merchant/" . $GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["pro_google_merchant_id"], $postback, array_merge(c_ws_plugin__optimizemember_pro_google_utilities::google_api_headers(), array("timeout" => 20)))) && wp_parse_str($response, $postvars) !== "nill" && !empty($postvars["_type"])) {
             return c_ws_plugin__optimizemember_utils_strings::trim_deep($postvars);
         } else {
             /* Nope. Return false. */
             return false;
         }
     } else {
         /* Nope. */
         return false;
     }
 }