"BMCreateButton", "BUTTONCODE" => "ENCRYPTED", "BUTTONTYPE" => (($attr["sp"] || $attr["rr"] === "BN") ? "BUYNOW" : "SUBSCRIBE"));
/**/
$i = 0; /* Initialize incremental variable counter. PayPal® wants these numbered using L_BUTTONVAR{n}; where {n} starts at zero. */
foreach ($inputs as $input => $value) /* Now run through each of the input variables that we parsed from the Full Button Code */
if (!preg_match ("/^cmd$/i", $input)) /* Don't include the `cmd` var; it will produce major errors in the API response. */
{
/* The PayPal® API method `BMCreateButton` expects (amount|a1|a3) to include 2 decimal places. */
if (preg_match ("/^(amount|a1|a3)$/i", $input))
$value = number_format ($value, 2, ".", "");
/**/
$paypal["L_BUTTONVAR" . $i] = $input . "=" . $value;
$i++; /* Increment variable counter. */
}
/**/
if (($paypal = c_ws_plugin__s2member_paypal_utilities::paypal_api_response ($paypal)) && empty ($paypal["__error"]) && !empty ($paypal["WEBSITECODE"]) && ($code = $paypal["WEBSITECODE"]))
/* Only proceed if we DID get a valid response from the PayPal® API. This works as a nice fallback; just in case the API connection fails. */
{
$default_image = "https://www.paypal.com/" . _x ("en_US", "s2member-front paypal-button-lang-code", "s2member") . "/i/btn/btn_xpressCheckout.gif";
/**/
$code = preg_replace ("/\
]+\>/i", "", $code); /* Remove the 1x1 pixel tracking image that PayPal® sticks in there. */
$code = preg_replace ("/(\]+)(\>)/ie", "'\\1'.rtrim(stripslashes('\\2'),'/').' /\\3'", $code); /* Use XHTML! */
/**/
$code = ($attr["image"] && $attr["image"] !== "default") ? preg_replace ('/ src\="(.*?)"/', ' src="' . c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr ($attr["image"])) . '"', $code) : preg_replace ('/ src\="(.*?)"/', ' src="' . c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr ($default_image)) . '"', $code);
/**/
$code = ($attr["output"] === "anchor") ? '
' : $code;
$code = ($attr["output"] === "url") ? c_ws_plugin__s2member_utils_forms::form_whips_2_url ($code) : $code;
/**/
($cache && $transient) ? set_transient ($transient, $code, apply_filters ("ws_plugin__s2member_sc_paypal_button_encryption_cache_exp_time", 3600, get_defined_vars ())) : null; /* Caching? */
}
}
}
/* No WordPress® Filters apply here. */
/* Instead, use: `ws_plugin__s2member_sc_paypal_button`. */
return $code; /* Button Code. Possibly w/ API encryption applied now. */
}
}
}
?>