Source Code Documentation


pro\s2member-pro\includes\menu-pages\authnet-menu-pages-s.js


  1. /**
  2. * Core JavaScript routines for Authorize.Net® menu pages.
  3. *
  4. * Copyright: © 2009-2011
  5. * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
  6. * (coded in the USA)
  7. *
  8. * This WordPress® plugin (s2Member Pro) is comprised of two parts:
  9. *
  10. * o (1) Its PHP code is licensed under the GPL license, as is WordPress®.
  11. * You should have received a copy of the GNU General Public License,
  12. * along with this software. In the main directory, see: /licensing/
  13. * If not, see: {@link http://www.gnu.org/licenses/}.
  14. *
  15. * o (2) All other parts of (s2Member Pro); including, but not limited to:
  16. * the CSS code, some JavaScript code, images, and design;
  17. * are licensed according to the license purchased.
  18. * See: {@link http://www.s2member.com/prices/}
  19. *
  20. * Unless you have our prior written consent, you must NOT directly or indirectly license,
  21. * sub-license, sell, resell, or provide for free; part (2) of the s2Member Pro Module;
  22. * or make an offer to do any of these things. All of these things are strictly
  23. * prohibited with part (2) of the s2Member Pro Module.
  24. *
  25. * Your purchase of s2Member Pro includes free lifetime upgrades via s2Member.com
  26. * (i.e. new features, bug fixes, updates, improvements); along with full access
  27. * to our video tutorial library: {@link http://www.s2member.com/videos/}
  28. *
  29. * @package s2Member\Menu_Pages
  30. * @since 1.5
  31. */
  32. jQuery(document).ready (function($)
  33. {
  34. var esc_attr = esc_html = /* Convert special characters. */ function(str)
  35. {
  36. return String(str).replace (/"/g, '&quot;').replace (/\</g, '&lt;').replace (/\>/g, '&gt;');
  37. };
  38.  
  39. if (location.href.match (/page\=ws-plugin--s2member-pro-authnet-ops/))
  40. {
  41. $('select#ws-plugin--s2member-auto-eot-system-enabled').change (function()
  42. {
  43. var $this = $(this), val = $this.val ();
  44. var $viaCron = $('p#ws-plugin--s2member-auto-eot-system-enabled-via-cron');
  45.  
  46. if /* Display Cron instructions. */ (val == 2)
  47. $viaCron.show ()
  48. else // Hide instructions.
  49. $viaCron.hide ();
  50. });
  51. }
  52.  
  53. else if (location.href.match (/page\=ws-plugin--s2member-pro-authnet-forms/))
  54. {
  55. var taxMayApply = ('<?php echo (int)c_ws_plugin__s2member_pro_authnet_utilities::authnet_tax_may_apply(); ?>' === '1') ? true : false;
  56.  
  57. var handleFormDescriptions = /* This will be re-used on keyup & change events. */ function()
  58. {
  59. var form = this.id.replace (/^ws-plugin--s2member-pro-(.+?)-(trial-period|trial-amount|trial-term|amount|term|currency)$/g, '$1');
  60. var trialAmount = $('input#ws-plugin--s2member-pro-' + form + '-trial-amount').val ().replace (/[^0-9\.]/g, '');
  61. var trialPeriod = $('input#ws-plugin--s2member-pro-' + form + '-trial-period').val ().replace (/[^0-9]/g, '');
  62. var trialTermLabel = $.trim ($('select#ws-plugin--s2member-pro-' + form + '-trial-term :selected').text ());
  63. var regAmount = $('input#ws-plugin--s2member-pro-' + form + '-amount').val ().replace (/[^0-9\.]/g, '');
  64. var regTermLabel = $.trim ($('select#ws-plugin--s2member-pro-' + form + '-term :selected').text ());
  65. var currencyCode = $('select#ws-plugin--s2member-pro-' + form + '-currency').val ().replace (/[^A-Z]/g, '');
  66. $('input#ws-plugin--s2member-pro-' + form + '-desc').val (((trialPeriod > 0) ? trialPeriod + ' ' + ((trialPeriod == 1) ? trialTermLabel.replace (/s$/, '') : trialTermLabel) + ' ' + ((trialAmount > 0) ? '@ $' + trialAmount : 'free') + ' / then ' : '') + '$' + regAmount + ' ' + currencyCode + '' + ((taxMayApply) ? ' + tax' : '') + ' / ' + regTermLabel);
  67. };
  68.  
  69. $('div.ws-menu-page select[id]').filter ( /* Filter all select elements with an id. */function()
  70. {
  71. return this.id.match (/^ws-plugin--s2member-pro-(level[1-9][0-9]*|modification)-term$/);
  72. }).change (function()
  73. {
  74. var form = this.id.replace (/^ws-plugin--s2member-pro-(.+?)-term$/g, '$1');
  75. var trialDisabled = ($(this).val ().split ('-')[2].replace (/[^0-1BN]/g, '') === 'BN') ? 1 : 0;
  76. $('p#ws-plugin--s2member-pro-' + form + '-trial-line').css ('display', (trialDisabled ? 'none' : ''));
  77. $('span#ws-plugin--s2member-pro-' + form + '-trial-then').css ('display', (trialDisabled ? 'none' : ''));
  78. (trialDisabled) ? $('input#ws-plugin--s2member-pro-' + form + '-trial-period').val (0) : null;
  79. (trialDisabled) ? $('input#ws-plugin--s2member-pro-' + form + '-trial-amount').val ('0.00') : null;
  80. });
  81.  
  82. $('div.ws-menu-page input[id]').filter ( /* Filter all input elements with an id. */function()
  83. {
  84. return this.id.match (/^ws-plugin--s2member-pro-(level[1-9][0-9]*|modification|ccap)-ccaps$/);
  85. }).keyup (function()
  86. {
  87. var value = this.value.replace (/^(-all|-al|-a|-)[;,]*/gi, ''), _all = (this.value.match (/^(-all|-al|-a|-)[;,]*/i)) ? '-all,' : '';
  88. if /* Only if there is a problem with the actual values; because this causes interruptions. */ (value.match (/[^a-z_0-9,]/))
  89. this.value = _all + $.trim ($.trim (value).replace (/[ \-]/g, '_').replace (/[^a-z_0-9,]/gi, '').toLowerCase ());
  90. });
  91.  
  92. $('div.ws-menu-page input[id]').filter ( /* Filter all input elements with an id. */function()
  93. {
  94. return this.id.match (/^ws-plugin--s2member-pro-(level[1-9][0-9]*|modification)-trial-amount$/);
  95. }).keyup (handleFormDescriptions);
  96.  
  97. $('div.ws-menu-page input[id]').filter ( /* Filter all input elements with an id. */function()
  98. {
  99. return this.id.match (/^ws-plugin--s2member-pro-(level[1-9][0-9]*|modification)-trial-period$/);
  100. }).keyup (handleFormDescriptions);
  101.  
  102. $('div.ws-menu-page select[id]').filter ( /* Filter all select elements with an id. */function()
  103. {
  104. return this.id.match (/^ws-plugin--s2member-pro-(level[1-9][0-9]*|modification)-trial-term$/);
  105. }).change (handleFormDescriptions);
  106.  
  107. $('div.ws-menu-page input[id]').filter ( /* Filter all input elements with an id. */function()
  108. {
  109. return this.id.match (/^ws-plugin--s2member-pro-(level[1-9][0-9]*|modification)-amount$/);
  110. }).keyup (handleFormDescriptions);
  111.  
  112. $('div.ws-menu-page select[id]').filter ( /* Filter all select elements with an id. */function()
  113. {
  114. return this.id.match (/^ws-plugin--s2member-pro-(level[1-9][0-9]*|modification)-term$/);
  115. }).change (handleFormDescriptions);
  116.  
  117. $('div.ws-menu-page select[id]').filter ( /* Filter all select elements with an id. */function()
  118. {
  119. return this.id.match (/^ws-plugin--s2member-pro-(level[1-9][0-9]*|modification)-currency$/);
  120. }).change (handleFormDescriptions);
  121.  
  122. ws_plugin__s2member_pro_authnetFormGenerate = /* Handles Authorize.Net® Form Generation. */ function(form)
  123. {
  124. var shortCodeTemplate = '[s2Member-Pro-AuthNet-Form %%attrs%% accept="visa,mastercard,amex,discover" coupon="" accept_coupons="0" default_country_code="US" captcha="0" /]', shortCodeTemplateAttrs = '', labels = {};
  125.  
  126. eval("<?php echo c_ws_plugin__s2member_utils_strings::esc_dq($vars['labels']); ?>");
  127.  
  128. var shortCode = $('input#ws-plugin--s2member-pro-' + form + '-shortcode');
  129. var modLevel = $('select#ws-plugin--s2member-pro-modification-level');
  130.  
  131. var level = (form === 'modification') ? modLevel.val ().split (':', 2)[1] : form.replace (/^level/, '');
  132. var label = /* Label may NOT contain any double-quotes. */ labels['level' + level].replace (/"/g, "");
  133.  
  134. var trialAmount = $('input#ws-plugin--s2member-pro-' + form + '-trial-amount').val ().replace (/[^0-9\.]/g, '');
  135. var trialPeriod = $('input#ws-plugin--s2member-pro-' + form + '-trial-period').val ().replace (/[^0-9]/g, '');
  136. var trialTerm = $('select#ws-plugin--s2member-pro-' + form + '-trial-term').val ().replace (/[^A-Z]/g, '');
  137.  
  138. var regAmount = $('input#ws-plugin--s2member-pro-' + form + '-amount').val ().replace (/[^0-9\.]/g, '');
  139. var regPeriod = $('select#ws-plugin--s2member-pro-' + form + '-term').val ().split ('-')[0].replace (/[^0-9]/g, '');
  140. var regTerm = $('select#ws-plugin--s2member-pro-' + form + '-term').val ().split ('-')[1].replace (/[^A-Z]/g, '');
  141. var regRecur = $('select#ws-plugin--s2member-pro-' + form + '-term').val ().split ('-')[2].replace (/[^0-1BN]/g, '');
  142. var /* These options are NOT yet configurable. */ regRecurTimes = '';
  143.  
  144. var desc = $.trim ($('input#ws-plugin--s2member-pro-' + form + '-desc').val ().replace (/"/g, ''));
  145. var currencyCode = $('select#ws-plugin--s2member-pro-' + form + '-currency').val ().replace (/[^A-Z]/g, '');
  146.  
  147. var cCaps = $.trim ($.trim ($('input#ws-plugin--s2member-pro-' + form + '-ccaps').val ()).replace (/^(-all|-al|-a|-)[;,]*/gi, '').replace (/[ \-]/g, '_').replace (/[^a-z_0-9,]/gi, '').toLowerCase ());
  148. cCaps = ($.trim ($('input#ws-plugin--s2member-pro-' + form + '-ccaps').val ()).match (/^(-all|-al|-a|-)[;,]*/i)) ? ((cCaps) ? '-all,' : '-all') + cCaps.toLowerCase () : cCaps.toLowerCase ();
  149.  
  150. trialPeriod = /* Lifetime (1-L-BN) and Buy Now ( BN ) access is NOT compatible w/ Trial Periods. */ (regRecur === 'BN') ? '0' : trialPeriod;
  151. trialAmount = /* Validate Trial Amount. */ (!trialAmount || isNaN(trialAmount) || trialAmount < 0.01 || trialPeriod <= 0) ? '0' : trialAmount;
  152.  
  153. var levelCcapsPer = (regRecur === 'BN' && regTerm !== 'L') ? level + ':' + cCaps + ':' + regPeriod + ' ' + regTerm : level + ':' + cCaps;
  154. levelCcapsPer = /* Clean any trailing separators from this string. */ levelCcapsPer.replace (/\:+$/g, '');
  155.  
  156. if (trialAmount !== '0' && (isNaN(trialAmount) || trialAmount < 0.00))
  157. {
  158. alert('— Oops, a slight problem: —\n\nWhen provided, Trial Amount must be >= 0.00');
  159. return false;
  160. }
  161. else if (trialAmount !== '0' && trialAmount > /* $99,999.00 maximum. */ 99999.00)
  162. {
  163. alert('— Oops, a slight problem: —\n\nMaximum Trial Amount is: 99999.00');
  164. return false;
  165. }
  166. else if (trialTerm === 'D' && /* Some validation on the Trial Period. Max days: 7. */ trialPeriod > 7)
  167. {
  168. alert('— Oops, a slight problem: —\n\nMaximum Trial Days is: 7.\nIf you want to offer more than 7 days, please choose Weeks or Months from the drop-down.');
  169. return false;
  170. }
  171. else if (trialTerm === 'W' && /* Some validation on the Trial Period. 52 max. */ trialPeriod > 52)
  172. {
  173. alert('— Oops, a slight problem: —\n\nMaximum Trial Weeks is: 52.\nIf you want to offer more than 52 weeks, please choose Months from the drop-down.');
  174. return false;
  175. }
  176. else if (trialTerm === 'M' && /* Some validation on the Trial Period. 12 max. */ trialPeriod > 12)
  177. {
  178. alert('— Oops, a slight problem: —\n\nMaximum Trial Months is: 12.\nIf you want to offer more than 12 months, please choose Years from the drop-down.');
  179. return false;
  180. }
  181. else if (trialTerm === 'Y' && /* 1 year max for Authorize.Net®. */ trialPeriod > 1)
  182. {
  183. alert('— Oops, a slight problem: —\n\nMax Trial Period Years is: 1. *This is an Authorize.Net® limitation.');
  184. return false;
  185. }
  186. else if (!regAmount || isNaN(regAmount) || regAmount < 0.01)
  187. {
  188. alert('— Oops, a slight problem: —\n\nAmount must be >= 0.01');
  189. return false;
  190. }
  191. else if (regAmount > /* $99,999.00 maximum. */ 99999.00)
  192. {
  193. alert('— Oops, a slight problem: —\n\nMaximum Amount is: 99999.00');
  194. return false;
  195. }
  196. else if /* Each Form should have a Description. */ (!desc)
  197. {
  198. alert('— Oops, a slight problem: —\n\nPlease type a Description for this Form.');
  199. return false;
  200. }
  201.  
  202. shortCodeTemplateAttrs += /* For Modification Forms. */ (form === 'modification') ? 'modify="1" ' : '';
  203. shortCodeTemplateAttrs += 'level="' + esc_attr(level) + '" ccaps="' + esc_attr(cCaps) + '" desc="' + esc_attr(desc) + '" cc="' + esc_attr(currencyCode) + '" custom="<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (esc_attr ($_SERVER["HTTP_HOST"])); ?>"';
  204. shortCodeTemplateAttrs += ' ta="' + esc_attr(trialAmount) + '" tp="' + esc_attr(trialPeriod) + '" tt="' + esc_attr(trialTerm) + '" ra="' + esc_attr(regAmount) + '" rp="' + esc_attr(regPeriod) + '" rt="' + esc_attr(regTerm) + '" rr="' + esc_attr(regRecur) + '" rrt="' + esc_attr(regRecurTimes) + '"';
  205. shortCode.val (shortCodeTemplate.replace (/%%attrs%%/, shortCodeTemplateAttrs));
  206.  
  207. alert('Your Form has been generated.\nPlease copy/paste the Shortcode into your WordPress® Editor.');
  208.  
  209. shortCode.each ( /* Focus and select the Shortcode. */function()
  210. {
  211. this.focus (), this.select ();
  212. });
  213.  
  214. return false;
  215. };
  216.  
  217. ws_plugin__s2member_pro_authnetCcapFormGenerate = /* Handles Authorize.Net® Form Generation. */ function(form)
  218. {
  219. var shortCodeTemplate = '[s2Member-Pro-AuthNet-Form %%attrs%% accept="visa,mastercard,amex,discover" coupon="" accept_coupons="0" default_country_code="US" captcha="0" /]', shortCodeTemplateAttrs = '';
  220.  
  221. var shortCode = $('input#ws-plugin--s2member-pro-ccap-shortcode');
  222.  
  223. var desc = $.trim ($('input#ws-plugin--s2member-pro-ccap-desc').val ().replace (/"/g, ''));
  224.  
  225. var regAmount = $('input#ws-plugin--s2member-pro-ccap-amount').val ().replace (/[^0-9\.]/g, '');
  226. var regPeriod = $('select#ws-plugin--s2member-pro-ccap-term').val ().split ('-')[0].replace (/[^0-9]/g, '');
  227. var regTerm = $('select#ws-plugin--s2member-pro-ccap-term').val ().split ('-')[1].replace (/[^A-Z]/g, '');
  228. var regRecur = $('select#ws-plugin--s2member-pro-ccap-term').val ().split ('-')[2].replace (/[^0-1BN]/g, '');
  229.  
  230. var currencyCode = $('select#ws-plugin--s2member-pro-ccap-currency').val ().replace (/[^A-Z]/g, '');
  231.  
  232. var cCaps = $.trim ($.trim ($('input#ws-plugin--s2member-pro-ccap-ccaps').val ()).replace (/^(-all|-al|-a|-)[;,]*/gi, '').replace (/[ \-]/g, '_').replace (/[^a-z_0-9,]/gi, '').toLowerCase ());
  233. cCaps = ($.trim ($('input#ws-plugin--s2member-pro-ccap-ccaps').val ()).match (/^(-all|-al|-a|-)[;,]*/i)) ? ((cCaps) ? '-all,' : '-all') + cCaps.toLowerCase () : cCaps.toLowerCase ();
  234.  
  235. var levelCcapsPer = (regRecur === 'BN' && regTerm !== 'L') ? '*:' + cCaps + ':' + regPeriod + ' ' + regTerm : '*:' + cCaps;
  236. levelCcapsPer = /* Clean any trailing separators from this string. */ levelCcapsPer.replace (/\:+$/g, '');
  237.  
  238. if /* Must have some Independent Custom Capabilities. */ (!cCaps || cCaps === '-all')
  239. {
  240. alert('— Oops, a slight problem: —\n\nPlease provide at least one Custom Capability.');
  241. return false;
  242. }
  243. else if (!regAmount || isNaN(regAmount) || regAmount < 0.01)
  244. {
  245. alert('— Oops, a slight problem: —\n\nAmount must be >= 0.01');
  246. return false;
  247. }
  248. else if (regAmount > /* $99,999.00 maximum. */ 99999.00)
  249. {
  250. alert('— Oops, a slight problem: —\n\nMaximum Amount is: 99999.00');
  251. return false;
  252. }
  253. else if /* Each Form should have a Description. */ (!desc)
  254. {
  255. alert('— Oops, a slight problem: —\n\nPlease type a Description for this Form.');
  256. return false;
  257. }
  258.  
  259. shortCodeTemplateAttrs += 'level="*" ccaps="' + esc_attr(cCaps) + '" desc="' + esc_attr(desc) + '" cc="' + esc_attr(currencyCode) + '" custom="<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (esc_attr ($_SERVER["HTTP_HOST"])); ?>"';
  260. shortCodeTemplateAttrs += ' ra="' + esc_attr(regAmount) + '" rp="' + esc_attr(regPeriod) + '" rt="' + esc_attr(regTerm) + '" rr="' + esc_attr(regRecur) + '"';
  261. shortCode.val (shortCodeTemplate.replace (/%%attrs%%/, shortCodeTemplateAttrs));
  262.  
  263. alert('Your Form has been generated.\nPlease copy/paste the Shortcode into your WordPress® Editor.');
  264.  
  265. shortCode.each ( /* Focus and select the Shortcode. */function()
  266. {
  267. this.focus (), this.select ();
  268. });
  269.  
  270. return false;
  271. };
  272.  
  273. ws_plugin__s2member_pro_authnetSpFormGenerate = /* Handles Authorize.Net® Form Generation. */ function()
  274. {
  275. var shortCodeTemplate = '[s2Member-Pro-AuthNet-Form %%attrs%% accept="visa,mastercard,amex,discover" coupon="" accept_coupons="0" default_country_code="US" captcha="0" /]', shortCodeTemplateAttrs = '';
  276.  
  277. var shortCode = $('input#ws-plugin--s2member-pro-sp-shortcode');
  278.  
  279. var leading = $('select#ws-plugin--s2member-pro-sp-leading-id').val ().replace (/[^0-9]/g, '');
  280. var additionals = $('select#ws-plugin--s2member-pro-sp-additional-ids').val () || [];
  281. var hours = $('select#ws-plugin--s2member-pro-sp-hours').val ().replace (/[^0-9]/g, '');
  282. var regAmount = $('input#ws-plugin--s2member-pro-sp-amount').val ().replace (/[^0-9\.]/g, '');
  283. var desc = $.trim ($('input#ws-plugin--s2member-pro-sp-desc').val ().replace (/"/g, ''));
  284. var currencyCode = $('select#ws-plugin--s2member-pro-sp-currency').val ().replace (/[^A-Z]/g, '');
  285.  
  286. if /* Must have a Leading Post/Page ID to work with. Otherwise, Link generation will fail. */ (!leading)
  287. {
  288. alert('— Oops, a slight problem: —\n\nPlease select a Leading Post/Page.\n\n*Tip* If there are no Posts/Pages in the menu, it\'s because you\'ve not configured s2Member for Specific Post/Page Access yet. See: s2Member -› Restriction Options -› Specific Post/Page Access.');
  289. return false;
  290. }
  291. else if (!regAmount || isNaN(regAmount) || regAmount < 0.01)
  292. {
  293. alert('— Oops, a slight problem: —\n\nAmount must be >= 0.01');
  294. return false;
  295. }
  296. else if (regAmount > /* $99,999.00 maximum. */ 99999.00)
  297. {
  298. alert('— Oops, a slight problem: —\n\nMaximum Amount is: 99999.00');
  299. return false;
  300. }
  301. else if /* Each Form should have a Description. */ (!desc)
  302. {
  303. alert('— Oops, a slight problem: —\n\nPlease type a Description for this Form.');
  304. return false;
  305. }
  306.  
  307. for (var i = 0, ids = leading; i < additionals.length; i++)
  308. if (additionals[i] && additionals[i] !== leading)
  309. ids += ',' + additionals[i];
  310.  
  311. var spIdsHours = /* Combined sp:ids:expiration hours. */ 'sp:' + ids + ':' + hours;
  312.  
  313. shortCodeTemplateAttrs += 'sp="1" ids="' + esc_attr(ids) + '" exp="' + esc_attr(hours) + '" desc="' + esc_attr(desc) + '" cc="' + esc_attr(currencyCode) + '"';
  314. shortCodeTemplateAttrs += ' custom="<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (esc_attr ($_SERVER["HTTP_HOST"])); ?>" ra="' + esc_attr(regAmount) + '"';
  315. shortCode.val (shortCodeTemplate.replace (/%%attrs%%/, shortCodeTemplateAttrs));
  316.  
  317. alert('Your Form has been generated.\nPlease copy/paste the Shortcode into your WordPress® Editor.');
  318.  
  319. shortCode.each ( /* Focus and select the Shortcode. */function()
  320. {
  321. this.focus (), this.select ();
  322. });
  323.  
  324. return false;
  325. };
  326.  
  327. ws_plugin__s2member_pro_authnetRegLinkGenerate = /* Handles Authorize.Net® Link Generation. */ function()
  328. {
  329. var level = $('select#ws-plugin--s2member-pro-reg-link-level').val ().replace (/[^0-9]/g, '');
  330. var subscrID = $.trim ($('input#ws-plugin--s2member-pro-reg-link-subscr-id').val ());
  331. var custom = $.trim ($('input#ws-plugin--s2member-pro-reg-link-custom').val ());
  332. var cCaps = $.trim ($.trim ($('input#ws-plugin--s2member-pro-reg-link-ccaps').val ()).replace (/[ \-]/g, '_').replace (/[^a-z_0-9,]/gi, '').toLowerCase ());
  333. var fixedTerm = $.trim ($('input#ws-plugin--s2member-pro-reg-link-fixed-term').val ().replace (/[^A-Z 0-9]/gi, '').toUpperCase ());
  334. var $link = $('p#ws-plugin--s2member-pro-reg-link'), $loading = $('img#ws-plugin--s2member-pro-reg-link-loading');
  335.  
  336. var levelCcapsPer = (fixedTerm && !fixedTerm.match (/L$/)) ? level + ':' + cCaps + ':' + fixedTerm : level + ':' + cCaps;
  337. levelCcapsPer = /* Clean any trailing separators from this string. */ levelCcapsPer.replace (/\:+$/g, '');
  338.  
  339. if /* We must have a Paid Subscr. ID value. */ (!subscrID)
  340. {
  341. alert('— Oops, a slight problem: —\n\nPaid Subscr. ID is a required value.');
  342. return false;
  343. }
  344. else if (!custom || custom.indexOf ('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq ($_SERVER["HTTP_HOST"]); ?>') !== 0)
  345. {
  346. alert('— Oops, a slight problem: —\n\nThe Custom Value MUST start with your domain name.');
  347. return false;
  348. }
  349. else if /* Check format. */ (fixedTerm && !fixedTerm.match (/^[1-9]+ (D|W|M|Y|L)$/))
  350. {
  351. alert('— Oops, a slight problem: —\n\nThe Fixed Term Length is not formatted properly.');
  352. return false;
  353. }
  354.  
  355. $link.hide (), $loading.show (), $.post (ajaxurl, {action: 'ws_plugin__s2member_reg_access_link_via_ajax', ws_plugin__s2member_reg_access_link_via_ajax: '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (wp_create_nonce ("ws-plugin--s2member-reg-access-link-via-ajax")); ?>', s2member_reg_access_link_subscr_gateway: 'authnet', s2member_reg_access_link_subscr_id: subscrID, s2member_reg_access_link_custom: custom, s2member_reg_access_link_item_number: levelCcapsPer}, function(response)
  356. {
  357. $link.show ().html ('<a href="' + esc_attr(response) + '" target="_blank" rel="external">' + esc_html(response) + '</a>'), $loading.hide ();
  358. });
  359.  
  360. return false;
  361. };
  362.  
  363. ws_plugin__s2member_pro_authnetSpLinkGenerate = /* Handles Authorize.Net® Link Generation. */ function()
  364. {
  365. var leading = $('select#ws-plugin--s2member-pro-sp-link-leading-id').val ().replace (/[^0-9]/g, '');
  366. var additionals = $('select#ws-plugin--s2member-pro-sp-link-additional-ids').val () || [];
  367. var hours = $('select#ws-plugin--s2member-pro-sp-link-hours').val ().replace (/[^0-9]/g, '');
  368. var $link = $('p#ws-plugin--s2member-pro-sp-link'), $loading = $('img#ws-plugin--s2member-pro-sp-link-loading');
  369.  
  370. if /* Must have a Leading Post/Page ID to work with. Otherwise, Link generation will fail. */ (!leading)
  371. {
  372. alert('— Oops, a slight problem: —\n\nPlease select a Leading Post/Page.\n\n*Tip* If there are no Posts/Pages in the menu, it\'s because you\'ve not configured s2Member for Specific Post/Page Access yet. See: s2Member -› Restriction Options -› Specific Post/Page Access.');
  373. return false;
  374. }
  375.  
  376. for (var i = 0, ids = leading; i < additionals.length; i++)
  377. if (additionals[i] && additionals[i] !== leading)
  378. ids += ',' + additionals[i];
  379.  
  380. $link.hide (), $loading.show (), $.post (ajaxurl, {action: 'ws_plugin__s2member_sp_access_link_via_ajax', ws_plugin__s2member_sp_access_link_via_ajax: '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (wp_create_nonce ("ws-plugin--s2member-sp-access-link-via-ajax")); ?>', s2member_sp_access_link_ids: ids, s2member_sp_access_link_hours: hours}, function(response)
  381. {
  382. $link.show ().html ('<a href="' + esc_attr(response) + '" target="_blank" rel="external">' + esc_html(response) + '</a>'), $loading.hide ();
  383. });
  384.  
  385. return false;
  386. };
  387. }
  388. });

pro\s2member-pro\includes\menu-pages\authnet-menu-pages-s.js

Source Code Documentation