Source Code Documentation


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


  1. /**
  2. * Core JavaScript routines for PayPal® 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-paypal-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-paypal-forms/))
  54. {
  55. var taxMayApply = ('<?php echo (int)c_ws_plugin__s2member_pro_paypal_utilities::paypal_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_paypalFormGenerate = /* Handles PayPal® Form Generation. */ function(form)
  123. {
  124. var shortCodeTemplate = '[s2Member-Pro-PayPal-Form %%attrs%% accept="paypal,visa,mastercard,amex,discover,maestro,solo" accept_via_paypal="paypal" coupon="" accept_coupons="0" default_country_code="" 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 = '', regRecurRetries = '2';
  143. /**/
  144. var desc = $.trim ($('input#ws-plugin--s2member-pro-' + form + '-desc').val ().replace (/"/g, ''));
  145. /**/
  146. var /* NOT yet configurable. */ localeCode = '', digital = '0', noShipping = '1';
  147. var pageStyle = $.trim ($('input#ws-plugin--s2member-pro-' + form + '-page-style').val ().replace (/"/g, ''));
  148. var currencyCode = $('select#ws-plugin--s2member-pro-' + form + '-currency').val ().replace (/[^A-Z]/g, '');
  149. /**/
  150. 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 ());
  151. cCaps = ($.trim ($('input#ws-plugin--s2member-pro-' + form + '-ccaps').val ()).match (/^(-all|-al|-a|-)[;,]*/i)) ? ((cCaps) ? '-all,' : '-all') + cCaps.toLowerCase () : cCaps.toLowerCase ();
  152. /**/
  153. trialPeriod = /* Lifetime ( 1-L-BN ) and Buy Now ( BN ) access is NOT compatible w/ Trial Periods. */ (regRecur === 'BN') ? '0' : trialPeriod;
  154. trialAmount = /* Validate Trial Amount. */ (!trialAmount || isNaN(trialAmount) || trialAmount < 0.01 || trialPeriod <= 0) ? '0' : trialAmount;
  155. /**/
  156. var levelCcapsPer = (regRecur === 'BN' && regTerm !== 'L') ? level + ':' + cCaps + ':' + regPeriod + ' ' + regTerm : level + ':' + cCaps;
  157. levelCcapsPer = /* Clean any trailing separators from this string. */ levelCcapsPer.replace (/\:+$/g, '');
  158. /**/
  159. if (trialAmount !== '0' && (isNaN(trialAmount) || trialAmount < 0.00))
  160. {
  161. alert('— Oops, a slight problem: —\n\nWhen provided, Trial Amount must be >= 0.00');
  162. return false;
  163. }
  164. else if (trialAmount !== '0' && trialAmount > /* $10,000.00 maximum. */ 10000.00)
  165. {
  166. alert('— Oops, a slight problem: —\n\nMaximum Trial Amount is: 10000.00');
  167. return false;
  168. }
  169. else if (!regAmount || isNaN(regAmount) || regAmount < 0.01)
  170. {
  171. alert('— Oops, a slight problem: —\n\nAmount must be >= 0.01');
  172. return false;
  173. }
  174. else if (regAmount > /* $10,000.00 maximum. */ 10000.00)
  175. {
  176. alert('— Oops, a slight problem: —\n\nMaximum Amount is: 10000.00');
  177. return false;
  178. }
  179. else if /* Each Form should have a Description. */ (!desc)
  180. {
  181. alert('— Oops, a slight problem: —\n\nPlease type a Description for this Form.');
  182. return false;
  183. }
  184. /**/
  185. shortCodeTemplateAttrs += /* For Modification Forms. */ (form === 'modification') ? 'modify="1" ' : '';
  186. shortCodeTemplateAttrs += 'level="' + esc_attr(level) + '" ccaps="' + esc_attr(cCaps) + '" desc="' + esc_attr(desc) + '" ps="' + esc_attr(pageStyle) + '" lc="' + esc_attr(localeCode) + '" cc="' + esc_attr(currencyCode) + '" dg="' + esc_attr(digital) + '" ns="' + esc_attr(noShipping) + '" custom="<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (esc_attr ($_SERVER["HTTP_HOST"])); ?>"';
  187. 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) + '" rra="' + esc_attr(regRecurRetries) + '"';
  188. shortCode.val (shortCodeTemplate.replace (/%%attrs%%/, shortCodeTemplateAttrs));
  189. /**/
  190. alert('Your Form has been generated.\nPlease copy/paste the Shortcode into your WordPress® Editor.');
  191. /**/
  192. shortCode.each ( /* Focus and select the Shortcode. */function()
  193. {
  194. this.focus (), this.select ();
  195. });
  196. /**/
  197. return false;
  198. };
  199. /**/
  200. ws_plugin__s2member_pro_paypalCcapFormGenerate = /* Handles PayPal® Form Generation. */ function()
  201. {
  202. var shortCodeTemplate = '[s2Member-Pro-PayPal-Form %%attrs%% accept="paypal,visa,mastercard,amex,discover,maestro,solo" accept_via_paypal="paypal" coupon="" accept_coupons="0" default_country_code="" captcha="0" /]', shortCodeTemplateAttrs = '';
  203. /**/
  204. var shortCode = $('input#ws-plugin--s2member-pro-ccap-shortcode');
  205. /**/
  206. var desc = $.trim ($('input#ws-plugin--s2member-pro-ccap-desc').val ().replace (/"/g, ''));
  207. /**/
  208. var regAmount = $('input#ws-plugin--s2member-pro-ccap-amount').val ().replace (/[^0-9\.]/g, '');
  209. var regPeriod = $('select#ws-plugin--s2member-pro-ccap-term').val ().split ('-')[0].replace (/[^0-9]/g, '');
  210. var regTerm = $('select#ws-plugin--s2member-pro-ccap-term').val ().split ('-')[1].replace (/[^A-Z]/g, '');
  211. var regRecur = $('select#ws-plugin--s2member-pro-ccap-term').val ().split ('-')[2].replace (/[^0-1BN]/g, '');
  212. /**/
  213. var /* NOT yet configurable. */ localeCode = '', digital = '0', noShipping = '1';
  214. var pageStyle = $.trim ($('input#ws-plugin--s2member-pro-ccap-page-style').val ().replace (/"/g, ''));
  215. var currencyCode = $('select#ws-plugin--s2member-pro-ccap-currency').val ().replace (/[^A-Z]/g, '');
  216. /**/
  217. 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 ());
  218. cCaps = ($.trim ($('input#ws-plugin--s2member-pro-ccap-ccaps').val ()).match (/^(-all|-al|-a|-)[;,]*/i)) ? ((cCaps) ? '-all,' : '-all') + cCaps.toLowerCase () : cCaps.toLowerCase ();
  219. /**/
  220. var levelCcapsPer = (regRecur === 'BN' && regTerm !== 'L') ? '*:' + cCaps + ':' + regPeriod + ' ' + regTerm : '*:' + cCaps;
  221. levelCcapsPer = /* Clean any trailing separators from this string. */ levelCcapsPer.replace (/\:+$/g, '');
  222. /**/
  223. if /* Must have some Independent Custom Capabilities. */ (!cCaps || cCaps === '-all')
  224. {
  225. alert('— Oops, a slight problem: —\n\nPlease provide at least one Custom Capability.');
  226. return false;
  227. }
  228. else if (!regAmount || isNaN(regAmount) || regAmount < 0.01)
  229. {
  230. alert('— Oops, a slight problem: —\n\nAmount must be >= 0.01');
  231. return false;
  232. }
  233. else if (regAmount > /* $10,000.00 maximum. */ 10000.00)
  234. {
  235. alert('— Oops, a slight problem: —\n\nMaximum Amount is: 10000.00');
  236. return false;
  237. }
  238. else if /* Each Form should have a Description. */ (!desc)
  239. {
  240. alert('— Oops, a slight problem: —\n\nPlease type a Description for this Form.');
  241. return false;
  242. }
  243. /**/
  244. shortCodeTemplateAttrs += 'level="*" ccaps="' + esc_attr(cCaps) + '" desc="' + esc_attr(desc) + '" ps="' + esc_attr(pageStyle) + '" lc="' + esc_attr(localeCode) + '" cc="' + esc_attr(currencyCode) + '" dg="' + esc_attr(digital) + '" ns="' + esc_attr(noShipping) + '"';
  245. shortCodeTemplateAttrs += ' custom="<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (esc_attr ($_SERVER["HTTP_HOST"])); ?>" ra="' + esc_attr(regAmount) + '" rp="' + esc_attr(regPeriod) + '" rt="' + esc_attr(regTerm) + '" rr="' + esc_attr(regRecur) + '"';
  246. shortCode.val (shortCodeTemplate.replace (/%%attrs%%/, shortCodeTemplateAttrs));
  247. /**/
  248. alert('Your Form has been generated.\nPlease copy/paste the Shortcode into your WordPress® Editor.');
  249. /**/
  250. shortCode.each ( /* Focus and select the Shortcode. */function()
  251. {
  252. this.focus (), this.select ();
  253. });
  254. /**/
  255. return false;
  256. };
  257. /**/
  258. ws_plugin__s2member_pro_paypalSpFormGenerate = /* Handles PayPal® Form Generation. */ function()
  259. {
  260. var shortCodeTemplate = '[s2Member-Pro-PayPal-Form %%attrs%% accept="paypal,visa,mastercard,amex,discover,maestro,solo" accept_via_paypal="paypal" coupon="" accept_coupons="0" default_country_code="" captcha="0" /]', shortCodeTemplateAttrs = '';
  261. /**/
  262. var shortCode = $('input#ws-plugin--s2member-pro-sp-shortcode');
  263. /**/
  264. var leading = $('select#ws-plugin--s2member-pro-sp-leading-id').val ().replace (/[^0-9]/g, '');
  265. var additionals = $('select#ws-plugin--s2member-pro-sp-additional-ids').val () || [];
  266. var hours = $('select#ws-plugin--s2member-pro-sp-hours').val ().replace (/[^0-9]/g, '');
  267. /**/
  268. var regAmount = $('input#ws-plugin--s2member-pro-sp-amount').val ().replace (/[^0-9\.]/g, '');
  269. var desc = $.trim ($('input#ws-plugin--s2member-pro-sp-desc').val ().replace (/"/g, ''));
  270. /**/
  271. var /* NOT yet configurable. */ localeCode = '', digital = '0', noShipping = '1';
  272. var pageStyle = $.trim ($('input#ws-plugin--s2member-pro-sp-page-style').val ().replace (/"/g, ''));
  273. var currencyCode = $('select#ws-plugin--s2member-pro-sp-currency').val ().replace (/[^A-Z]/g, '');
  274. /**/
  275. if /* Must have a Leading Post/Page ID to work with. Otherwise, Link generation will fail. */ (!leading)
  276. {
  277. 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.');
  278. return false;
  279. }
  280. else if (!regAmount || isNaN(regAmount) || regAmount < 0.01)
  281. {
  282. alert('— Oops, a slight problem: —\n\nAmount must be >= 0.01');
  283. return false;
  284. }
  285. else if (regAmount > /* $10,000.00 maximum. */ 10000.00)
  286. {
  287. alert('— Oops, a slight problem: —\n\nMaximum Amount is: 10000.00');
  288. return false;
  289. }
  290. else if /* Each Form should have a Description. */ (!desc)
  291. {
  292. alert('— Oops, a slight problem: —\n\nPlease type a Description for this Form.');
  293. return false;
  294. }
  295. /**/
  296. for (var i = 0, ids = leading; i < additionals.length; i++)
  297. if (additionals[i] && additionals[i] !== leading)
  298. ids += ',' + additionals[i];
  299. /**/
  300. var /* Combined sp:ids:expiration hours. */ spIdsHours = 'sp:' + ids + ':' + hours;
  301. /**/
  302. shortCodeTemplateAttrs += 'sp="1" ids="' + esc_attr(ids) + '" exp="' + esc_attr(hours) + '" desc="' + esc_attr(desc) + '" ps="' + esc_attr(pageStyle) + '" lc="' + esc_attr(localeCode) + '" cc="' + esc_attr(currencyCode) + '" dg="' + esc_attr(digital) + '" ns="' + esc_attr(noShipping) + '"';
  303. shortCodeTemplateAttrs += ' custom="<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (esc_attr ($_SERVER["HTTP_HOST"])); ?>" ra="' + esc_attr(regAmount) + '"';
  304. shortCode.val (shortCodeTemplate.replace (/%%attrs%%/, shortCodeTemplateAttrs));
  305. /**/
  306. alert('Your Form has been generated.\nPlease copy/paste the Shortcode into your WordPress® Editor.');
  307. /**/
  308. shortCode.each ( /* Focus and select the Shortcode. */function()
  309. {
  310. this.focus (), this.select ();
  311. });
  312. /**/
  313. return false;
  314. };
  315. /**/
  316. ws_plugin__s2member_pro_paypalRegLinkGenerate = /* Handles PayPal® Link Generation. */ function()
  317. {
  318. var level = $('select#ws-plugin--s2member-pro-reg-link-level').val ().replace (/[^0-9]/g, '');
  319. var subscrID = $.trim ($('input#ws-plugin--s2member-pro-reg-link-subscr-id').val ());
  320. var custom = $.trim ($('input#ws-plugin--s2member-pro-reg-link-custom').val ());
  321. var cCaps = $.trim ($.trim ($('input#ws-plugin--s2member-pro-reg-link-ccaps').val ()).replace (/[ \-]/g, '_').replace (/[^a-z_0-9,]/gi, '').toLowerCase ());
  322. var fixedTerm = $.trim ($('input#ws-plugin--s2member-pro-reg-link-fixed-term').val ().replace (/[^A-Z 0-9]/gi, '').toUpperCase ());
  323. var $link = $('p#ws-plugin--s2member-pro-reg-link'), $loading = $('img#ws-plugin--s2member-pro-reg-link-loading');
  324. /**/
  325. var levelCcapsPer = (fixedTerm && !fixedTerm.match (/L$/)) ? level + ':' + cCaps + ':' + fixedTerm : level + ':' + cCaps;
  326. levelCcapsPer = /* Clean any trailing separators from this string. */ levelCcapsPer.replace (/\:+$/g, '');
  327. /**/
  328. if /* We must have a Paid Subscr. ID value. */ (!subscrID)
  329. {
  330. alert('— Oops, a slight problem: —\n\nPaid Subscr. ID is a required value.');
  331. return false;
  332. }
  333. else if (!custom || custom.indexOf ('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq ($_SERVER["HTTP_HOST"]); ?>') !== 0)
  334. {
  335. alert('— Oops, a slight problem: —\n\nThe Custom Value MUST start with your domain name.');
  336. return false;
  337. }
  338. else if /* Check format. */ (fixedTerm && !fixedTerm.match (/^[1-9]+ (D|W|M|Y|L)$/))
  339. {
  340. alert('— Oops, a slight problem: —\n\nThe Fixed Term Length is not formatted properly.');
  341. return false;
  342. }
  343. /**/
  344. $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: 'paypal', s2member_reg_access_link_subscr_id: subscrID, s2member_reg_access_link_custom: custom, s2member_reg_access_link_item_number: levelCcapsPer}, function(response)
  345. {
  346. $link.show ().html ('<a href="' + esc_attr(response) + '" target="_blank" rel="external">' + esc_html(response) + '</a>'), $loading.hide ();
  347. });
  348. /**/
  349. return false;
  350. };
  351. /**/
  352. ws_plugin__s2member_pro_paypalSpLinkGenerate = /* Handles PayPal® Link Generation. */ function()
  353. {
  354. var leading = $('select#ws-plugin--s2member-pro-sp-link-leading-id').val ().replace (/[^0-9]/g, '');
  355. var additionals = $('select#ws-plugin--s2member-pro-sp-link-additional-ids').val () || [];
  356. var hours = $('select#ws-plugin--s2member-pro-sp-link-hours').val ().replace (/[^0-9]/g, '');
  357. var $link = $('p#ws-plugin--s2member-pro-sp-link'), $loading = $('img#ws-plugin--s2member-pro-sp-link-loading');
  358. /**/
  359. if /* Must have a Leading Post/Page ID to work with. Otherwise, Link generation will fail. */ (!leading)
  360. {
  361. 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.');
  362. return false;
  363. }
  364. /**/
  365. for (var i = 0, ids = leading; i < additionals.length; i++)
  366. if (additionals[i] && additionals[i] !== leading)
  367. ids += ',' + additionals[i];
  368. /**/
  369. $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)
  370. {
  371. $link.show ().html ('<a href="' + esc_attr(response) + '" target="_blank" rel="external">' + esc_html(response) + '</a>'), $loading.hide ();
  372. });
  373. /**/
  374. return false;
  375. };
  376. }
  377. });

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

Source Code Documentation