PluginProbe
s2Member – Excellent for All Kinds of Memberships, Content Restriction Paywalls & Member Access Subscriptions / 110913
s2Member – Excellent for All Kinds of Memberships, Content Restriction Paywalls & Member Access Subscriptions v110913
260917 260913 260909 260829 260814 260805 110710 110731 110812 110815 110912 110913 110915 110926 110927 111002 111003 111011 111017 111029 111105 111206 111216 111220 120213 All 189 releases
s2member / includes / menu-pages / menu-pages-s.js

menu-pages-s.js in s2Member – Excellent for All Kinds of Memberships, Content Restriction Paywalls & Member Access Subscriptions 110913, at includes/menu-pages/menu-pages-s.js

1,308 lines 84.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * Core JavaScript routines for s2Member menu pages.
3 *
4 * Copyright: © 2009-2011
5 * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
6 * ( coded in the USA )
7 *
8 * Released under the terms of the GNU General Public License.
9 * You should have received a copy of the GNU General Public License,
10 * along with this software. In the main directory, see: /licensing/
11 * If not, see: {@link http://www.gnu.org/licenses/}.
12 *
13 * @package s2Member\Menu_Pages
14 * @since 3.0
15 */
16 /*
17 These JavaScript routines are all specific to this software.
18 */
19 jQuery(document).ready (function($)
20 {
21 var esc_attr = esc_html = function(str) /* Convert special characters. */
22 {
23 return String(str).replace (/"/g, '&quot;').replace (/\</g, '&lt;').replace (/\>/g, '&gt;');
24 };
25 /**/
26 if (location.href.match (/page\=ws-plugin--s2member/)) /* Always on. */
27 {
28 $('input.ws-plugin--s2member-update-roles-button').click (function()
29 {
30 var $this = $(this); /* Save $(this) into $this. */
31 $this.val ('one moment please ...'); /* Indicate loading status ( please wait ). */
32 /**/
33 $.post (ajaxurl, {action: 'ws_plugin__s2member_update_roles_via_ajax', ws_plugin__s2member_update_roles_via_ajax: '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (wp_create_nonce ("ws-plugin--s2member-update-roles-via-ajax")); ?>'}, function(response)
34 {
35 if (response === '0')
36 alert('Sorry, your request failed.\ns2Member\'s Roles/Capabilities are locked by Filter:\nws_plugin__s2member_lock_roles_caps'), $this.val ('Update Roles/Capabilities');
37 else if (response === '1')
38 alert('s2Member\'s Roles/Capabilities updated successfully.'), $this.val ('Update Roles/Capabilities');
39 });
40 /**/
41 return false;
42 });
43 }
44 /**/
45 if (location.href.match (/page\=ws-plugin--s2member-mms-ops/))
46 {
47 $('select#ws-plugin--s2member-mms-registration-file').change (function()
48 {
49 if ($(this).val () === 'wp-signup') /* Expand/collapse relevant options; based on file selection. */
50 {
51 var gv = $('select#ws-plugin--s2member-mms-registration-grants').val (), l0v = $('input#ws-plugin--s2member-mms-registration-blogs-level0').val ();
52 $('div#ws-plugin--s2member-mms-registration-support-package-details-wrapper').show (), $('div.ws-plugin--s2member-mms-registration-wp-login, table.ws-plugin--s2member-mms-registration-wp-login').hide (), $('div.ws-plugin--s2member-mms-registration-wp-signup, table.ws-plugin--s2member-mms-registration-wp-signup').show ();
53 $('div.ws-plugin--s2member-mms-registration-wp-signup-blogs-level0, table.ws-plugin--s2member-mms-registration-wp-signup-blogs-level0')[((gv === 'all') ? 'show' : 'hide')] ();
54 $('input#ws-plugin--s2member-mms-registration-blogs-level0').val (((gv === 'all') ? ((l0v > 0) ? l0v : '1') : '0'));
55 }
56 else if ($(this).val () === 'wp-login') /* Expand/collapse relevant options. */
57 {
58 var gv = $('select#ws-plugin--s2member-mms-registration-grants').val (), l0v = $('input#ws-plugin--s2member-mms-registration-blogs-level0').val ();
59 $('div#ws-plugin--s2member-mms-registration-support-package-details-wrapper').hide (), $('div.ws-plugin--s2member-mms-registration-wp-login, table.ws-plugin--s2member-mms-registration-wp-login').show (), $('div.ws-plugin--s2member-mms-registration-wp-signup, table.ws-plugin--s2member-mms-registration-wp-signup').hide ();
60 $('div.ws-plugin--s2member-mms-registration-wp-signup-blogs-level0, table.ws-plugin--s2member-mms-registration-wp-signup-blogs-level0').hide ();
61 $('input#ws-plugin--s2member-mms-registration-blogs-level0').val ('0');
62 }
63 /**/
64 }).trigger ('change'); /* Fire on ready too. */
65 /**/
66 $('select#ws-plugin--s2member-mms-registration-grants').change (function()
67 {
68 $('select#ws-plugin--s2member-mms-registration-file').trigger ('change');
69 });
70 }
71 /**/
72 else if (location.href.match (/page\=ws-plugin--s2member-integrations/))
73 {
74 $('select#ws-plugin--s2member-bbpress-ovg').change (function()
75 {
76 if ($(this).val () === '0') /* Expand/collapse notation; based on selection. */
77 {
78 $('span#ws-plugin--s2member-bbpress-ovg-off-note').css ('display', 'inline');
79 /**/
80 var l = 'form#ws-plugin--s2member-bridge-bbpress-form label[for="ws_plugin--s2member-bridge-bbpress-min-level"]';
81 /**/
82 $(l).text ($(l).text ().replace (/to (read\/)?participate/i, 'to read/participate')), $('select#ws-plugin--s2member-bbpress-min-level option').each (function()
83 {
84 $(this).text ($(this).text ().replace (/\( to( read and)? participate \)/i, '( to read and participate )'));
85 });
86 }
87 else if ($(this).val () === '1') /* Expand/collapse notation. */
88 {
89 $('span#ws-plugin--s2member-bbpress-ovg-off-note').css ('display', 'none');
90 /**/
91 var l = 'form#ws-plugin--s2member-bridge-bbpress-form label[for="ws_plugin--s2member-bridge-bbpress-min-level"]';
92 /**/
93 $(l).text ($(l).text ().replace (/to (read\/)?participate/i, 'to participate')), $('select#ws-plugin--s2member-bbpress-min-level option').each (function()
94 {
95 $(this).text ($(this).text ().replace (/\( to( read and)? participate \)/i, '( to participate )'));
96 });
97 }
98 /**/
99 }).trigger ('change'); /* Fire on ready too. */
100 }
101 /**/
102 else if (location.href.match (/page\=ws-plugin--s2member-gen-ops/))
103 {
104 ws_plugin__s2member_generateSecurityKey = function() /* Generates a unique Security Key. */
105 {
106 var mt_rand = function(min, max) /* The JS equivalent to mt_rand(). */
107 {
108 min = (arguments.length < 1) ? 0 : min;
109 max = (arguments.length < 2) ? 2147483647 : max;
110 /**/
111 return Math.floor (Math.random () * (max - min + 1)) + min;
112 };
113 /**/
114 var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()';
115 for (var i = 0, key = ''; i < 64; i++) key += chars.substr (mt_rand(0, chars.length - 1), 1);
116 /**/
117 $('input#ws-plugin--s2member-sec-encryption-key').val (key);
118 /**/
119 return false;
120 };
121 /**/
122 ws_plugin__s2member_enableSecurityKey = function() /* Allow Security Key editing?? */
123 {
124 if (confirm('Edit Key? Are you sure?\nThis could break your installation!\n\n*Note* If you\'ve been testing s2Member, feel free to change this Key before you go live. Just don\'t go live, and then change it. You\'ll have unhappy Customers. Data corruption WILL occur! For your safety, s2Member keeps a history of the last 10 Keys that you\'ve used. If you get yourself into a real situation, s2Member will let you revert back to a previous Key.'))
125 $('input#ws-plugin--s2member-sec-encryption-key').removeAttr ('disabled');
126 /**/
127 return false;
128 };
129 /**/
130 ws_plugin__s2member_securityKeyHistory = function() /* Displays history of Keys. */
131 {
132 $('div#ws-plugin--s2member-sec-encryption-key-history').toggle ();
133 /**/
134 return false;
135 };
136 /**/
137 $('select#ws-plugin--s2member-new-user-emails-enabled').change (function()
138 {
139 var $pluggable = $('input#ws-plugin--s2member-pluggables-wp-new-user-notification'), $this = $(this), $newUserEmails = $('div#ws-plugin--s2member-new-user-emails');
140 /**/
141 if ($pluggable.val () === '0' || $this.val () === '0')
142 {
143 ($pluggable.val () === '0') ? $this.attr ('disabled', 'disabled') : $this.removeAttr ('disabled');
144 $(':input', $newUserEmails).attr ('disabled', 'disabled'), $newUserEmails.css ('opacity', '0.5');
145 }
146 else /* Else we allow the emails to be customized. */
147 $this.removeAttr ('disabled'), $(':input', $newUserEmails).removeAttr ('disabled'), $newUserEmails.css ('opacity', '');
148 /**/
149 }).trigger ('change'); /* Fire on ready too. */
150 /**/
151 if ($('input#ws-plugin--s2member-custom-reg-fields').length && $('div#ws-plugin--s2member-custom-reg-field-configuration').length)
152 {
153 (function() /* Wrap these routines inside a function to keep variables within relative scope. */
154 {
155 var i, fieldDefaults, tools, table, $tools, $table;
156 var $fields = $('input#ws-plugin--s2member-custom-reg-fields');
157 var $configuration = $('div#ws-plugin--s2member-custom-reg-field-configuration');
158 var fields = ($fields.val ()) ? $.JSON.parse ($fields.val ()) : [];
159 /**/
160 fields = (fields instanceof Array) ? fields : []; /* Force fields to an array. */
161 /**/
162 fieldDefaults = {section: 'no', sectitle: '', id: '', label: '', type: 'text', deflt: '', options: '', expected: '', required: 'yes', levels: 'all', editable: 'yes', classes: '', styles: '', attrs: ''};
163 /**/
164 for (i = 0; i < fields.length; i++) fields[i] = $.extend (true, {}, fieldDefaults, fields[i]); /* Extend, based on defaults ( for future proofing ). */
165 /**/
166 tools = '<div id="ws-plugin--s2member-custom-reg-field-configuration-tools"></div>', table = '<table id="ws-plugin--s2member-custom-reg-field-configuration-table"></table>';
167 /**/
168 $configuration.html (tools + table); /* Add tools div & table div to configuration div ( i.e. div#ws-plugin--s2member-custom-reg-field-configuration ). */
169 /**/
170 $tools = $('div#ws-plugin--s2member-custom-reg-field-configuration-tools'), $table = $('table#ws-plugin--s2member-custom-reg-field-configuration-table');
171 /**/
172 ws_plugin__s2member_customRegFieldSectionChange = function(select)
173 {
174 var section = $(select).val (); /* Current selection ( no|yes, selected by site owner ). */
175 /**/
176 var sectitle_trs = 'tr.ws-plugin--s2member-custom-reg-field-configuration-tools-form-sectitle';
177 /**/
178 (section === 'yes') ? $(sectitle_trs).css ('display', '') : $(sectitle_trs).css ('display', 'none');
179 };
180 /**/
181 ws_plugin__s2member_customRegFieldTypeChange = function(select) /* Handle change events here. */
182 {
183 var type = $(select).val (); /* Current selection ( type of Field, selected by site owner ). */
184 /**/
185 var deflt_trs = 'tr.ws-plugin--s2member-custom-reg-field-configuration-tools-form-deflt', options_trs = 'tr.ws-plugin--s2member-custom-reg-field-configuration-tools-form-options', expected_trs = 'tr.ws-plugin--s2member-custom-reg-field-configuration-tools-form-expected';
186 /**/
187 (type.match (/^(text|textarea)$/)) ? $(deflt_trs).css ('display', '') : $(deflt_trs).css ('display', 'none');
188 (type.match (/^(select|selects|checkboxes|radios)$/)) ? $(options_trs).css ('display', '') : $(options_trs).css ('display', 'none');
189 (type.match (/^(text|textarea)$/)) ? $(expected_trs).css ('display', '') : $(expected_trs).css ('display', 'none');
190 };
191 /**/
192 ws_plugin__s2member_customRegFieldDelete = function(index)
193 {
194 var newFields = new Array (); /* Build array. */
195 /**/
196 for (var i = 0; i < fields.length; i++)
197 if (i !== index) /* Omit index. */
198 newFields.push (fields[i]);
199 /**/
200 fields = newFields, updateFields (), buildTable ();
201 };
202 /**/
203 ws_plugin__s2member_customRegFieldMoveUp = function(index)
204 {
205 if (typeof fields[index] === 'object' && typeof fields[index - 1] === 'object')
206 {
207 var prevFieldObj = fields[index - 1], thisFieldObj = fields[index];
208 /**/
209 fields[index - 1] = thisFieldObj, fields[index] = prevFieldObj;
210 /**/
211 updateFields (), buildTable ();
212 }
213 };
214 /**/
215 ws_plugin__s2member_customRegFieldMoveDown = function(index)
216 {
217 if (typeof fields[index] === 'object' && typeof fields[index + 1] === 'object')
218 {
219 var nextFieldObj = fields[index + 1], thisFieldObj = fields[index];
220 /**/
221 fields[index + 1] = thisFieldObj, fields[index] = nextFieldObj;
222 /**/
223 updateFields (), buildTable ();
224 }
225 };
226 /**/
227 ws_plugin__s2member_customRegFieldCreate = function()
228 {
229 var $table = $('table#ws-plugin--s2member-custom-reg-field-configuration-tools-form'), field = {};
230 /**/
231 $(':input[property]', $table).each (function() /* Go through each property value. */
232 {
233 var $this = $(this), property = $this.attr ('property'), val = $.trim ($this.val ());
234 /**/
235 field[property] = val;
236 });
237 /**/
238 if ((field = validateField(field))) /* If it can be validated. */
239 {
240 fields.push (field), updateFields (), buildTools (), buildTable (), scrollReset ();
241 /**/
242 setTimeout(function() /* A momentary delay here for usability. */
243 {
244 var row = 'tr.ws-plugin--s2member-custom-reg-field-configuration-table-row-' + (fields.length - 1);
245 alert('Field created successfully.\n* Remember to "Save All Changes".');
246 $(row).effect ('highlight', 1500);
247 }, 500);
248 }
249 };
250 /**/
251 ws_plugin__s2member_customRegFieldUpdate = function(index)
252 {
253 var $table = $('table#ws-plugin--s2member-custom-reg-field-configuration-tools-form'), field = {};
254 /**/
255 $(':input[property]', $table).each (function() /* Go through each property value. */
256 {
257 var $this = $(this), property = $this.attr ('property'), val = $.trim ($this.val ());
258 /**/
259 field[property] = val;
260 });
261 /**/
262 if ((field = validateField(field, index))) /* If it validates. */
263 {
264 fields[index] = field, updateFields (), buildTools (), buildTable (), scrollReset ();
265 /**/
266 setTimeout(function() /* A momentary delay here for usability. */
267 {
268 var row = 'tr.ws-plugin--s2member-custom-reg-field-configuration-table-row-' + index;
269 alert('Field updated successfully.\n* Remember to "Save All Changes".');
270 $(row).effect ('highlight', 1500);
271 }, 500);
272 }
273 };
274 /**/
275 ws_plugin__s2member_customRegFieldAdd = function() /* Add new field links. */
276 {
277 buildTools(true); /* No need to reset scroll position. */
278 };
279 /**/
280 ws_plugin__s2member_customRegFieldEdit = function(index) /* Edit links. */
281 {
282 buildTools(false, index), scrollReset (); /* Reset scroll position. */
283 };
284 /**/
285 ws_plugin__s2member_customRegFieldCancel = function() /* Cancel form. */
286 {
287 buildTools (), scrollReset (); /* Re-build without the form. */
288 };
289 /**/
290 var validateField = function(field, index)
291 {
292 var editing = ( typeof index === 'number' && typeof fields[index] === 'object') ? true : false, errors = [], options, i;
293 /**/
294 if (typeof field !== 'object' || typeof (field = $.extend (true, {}, fieldDefaults, field)) !== 'object')
295 {
296 alert('Invalid field object. Please try again.');
297 return false;
298 }
299 /**/
300 field.sectitle = (field.section === 'yes') ? field.sectitle : '';
301 field.deflt = (field.type.match (/^(text|textarea)$/)) ? field.deflt : '';
302 field.deflt = (field.type.match (/^(text)$/)) ? field.deflt.replace (/[\r\n\t ]+/g, ' ') : field.deflt;
303 field.options = (field.type.match (/^(select|selects|checkboxes|radios)$/)) ? field.options : '';
304 field.expected = (field.type.match (/^(text|textarea)$/)) ? field.expected : '';
305 /**/
306 if (!field.id) /* Every Field must have a unique ID. */
307 {
308 errors.push ('Unique Field ID:\nThis is required. Please try again.');
309 }
310 else if (fieldIdExists(field.id) && (!editing || field.id !== fields[index].id))
311 {
312 errors.push ('Unique Field ID:\nThat Field ID already exists. Please try again.');
313 }
314 /**/
315 if (!field.label) /* Every Field must have a label. */
316 {
317 errors.push ('Field Label/Description:\nThis is required. Please try again.');
318 }
319 /**/
320 if (field.type.match (/^(select|selects|checkboxes|radios)$/) && !field.options)
321 {
322 errors.push ('Option Configuration File:\nThis is required. Please try again.');
323 }
324 else if (field.type.match (/^(select|selects|checkboxes|radios)$/))
325 {
326 for (i = 0; i < (options = field.options.split (/[\r\n]+/)).length; i++)
327 {
328 if (!(options[i] = $.trim (options[i])).match (/^([^\|]*)(\|)([^\|]*)(\|default)?$/))
329 {
330 errors.push ('Option Configuration File:\nInvalid configuration at line #' + (i + 1) + '.');
331 break; /* Break now. There could potentially be lots of lines with errors like this. */
332 }
333 }
334 /**/
335 field.options = $.trim (options.join ('\n')); /* Clean up. */
336 }
337 /**/
338 if (!(field.levels = field.levels.replace (/ /g, '')))
339 {
340 errors.push ('Applicable Levels:\nThis is required. Please try again.');
341 }
342 else if (!field.levels.match (/^(all|[0-9,]+)$/))
343 {
344 errors.push ('Applicable Levels:\nShould be comma-delimited Levels, or just type: all.\n( examples: 0,1,2,3,4 or type the word: all )');
345 }
346 /**/
347 if (field.classes && field.classes.match (/[^a-z 0-9 _ \-]/i))
348 {
349 errors.push ('CSS Classes:\nContains invalid characters. Please try again.\n( only: alphanumerics, underscores, hyphens, spaces )');
350 }
351 /**/
352 if (field.styles && field.styles.match (/["\=\>\<]/))
353 {
354 errors.push ('CSS Styles:\nContains invalid characters. Please try again.\n( do NOT use these characters: = " < > )');
355 }
356 /**/
357 if (field.attrs && field.attrs.match (/[\>\<]/))
358 {
359 errors.push ('Other Attributes:\nContains invalid characters. Please try again.\n( do NOT use these characters: < > )');
360 }
361 /**/
362 if (errors.length > 0) /* Errors? */
363 {
364 alert(errors.join ('\n\n'));
365 return false;
366 }
367 else /* Return. */
368 return field;
369 };
370 /**/
371 var updateFields = function() /* Update hidden input value. */
372 {
373 $fields.val (((fields.length > 0) ? $.JSON.stringify (fields) : ''));
374 };
375 /**/
376 var fieldId2Var = function(fieldId) /* Convert ids to variables. */
377 {
378 return ( typeof fieldId === 'string') ? $.trim (fieldId).toLowerCase ().replace (/[^a-z0-9]/g, '_') : '';
379 };
380 /**/
381 var fieldTypeDesc = function(type)
382 {
383 var types = {text: 'Text ( single line )', textarea: 'Textarea ( multi-line )', select: 'Select Menu ( drop-down )', selects: 'Select Menu ( multi-option )', checkbox: 'Checkbox ( single )', pre_checkbox: 'Checkbox ( pre-checked )', checkboxes: 'Checkboxes ( multi-option )', radios: 'Radio Buttons ( multi-option )'};
384 /**/
385 if (typeof types[type] === 'string')
386 return types[type];
387 /**/
388 return ''; /* Default. */
389 };
390 /**/
391 var fieldIdExists = function(fieldId) /* Already exists? */
392 {
393 for (var i = 0; i < fields.length; i++)
394 if (fields[i].id === fieldId)
395 return true;
396 };
397 /**/
398 var scrollReset = function() /* Return to Custom Fields section. */
399 {
400 scrollTo(0, $('div.ws-plugin--s2member-custom-reg-fields-section').offset ()['top'] - 100);
401 };
402 /**/
403 var buildTools = function(adding, index) /* This builds tools into the configuration. */
404 {
405 var i = 0, html = '', form = '', w = 0, h = 0, editing = ( typeof index === 'number' && typeof fields[index] === 'object') ? true : false, displayForm = (adding || editing) ? true : false, field = (editing) ? $.extend (true, {}, fieldDefaults, fields[index]) : fieldDefaults;
406 /**/
407 html += '<a href="#" onclick="ws_plugin__s2member_customRegFieldAdd(); return false;">Add New Field</a>'; /* Click to add a new Custom Registration Field. */
408 /**/
409 tb_remove (), $('div#ws-plugin--s2member-custom-reg-field-configuration-thickbox-tools-form').remove (); /* Remove an existing thickbox. */
410 /**/
411 if (displayForm) /* Do we need to display the adding/editing form at all?
412 *NOTE* This is NOT an actual <form>, because we're already inside another form tag. */
413 {
414 form += '<div id="ws-plugin--s2member-custom-reg-field-configuration-thickbox-tools-form">';
415 /**/
416 form += '<table id="ws-plugin--s2member-custom-reg-field-configuration-tools-form">';
417 form += '<tbody>';
418 /**/
419 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-section">';
420 form += '<td colspan="2">';
421 form += '<label for="ws-plugin--s2member-custom-reg-field-configuration-tools-form-section">Starts A New Section?</label>';
422 form += '</td>';
423 form += '</tr>';
424 /**/
425 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-section">';
426 form += '<td colspan="2">';
427 form += '<select property="section" onchange="ws_plugin__s2member_customRegFieldSectionChange(this);" id="ws-plugin--s2member-custom-reg-field-configuration-tools-form-section">';
428 form += '<option value="no"' + ((field.section === 'no') ? ' selected="selected"' : '') + '">No ( this Field flows normally )</option>';
429 form += '<option value="yes"' + ((field.section === 'yes') ? ' selected="selected"' : '') + '">Yes ( this Field begins a new section )</option>';
430 form += '</select><br />';
431 form += '<small>Optional. Allows Fields to be grouped into sections.</small>';
432 form += '</td>';
433 form += '</tr>';
434 /**/
435 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-spacer ws-plugin--s2member-custom-reg-field-configuration-tools-form-sectitle ws-plugin--s2member-custom-reg-field-configuration-tools-form-section"' + ((field.section === 'yes') ? '' : ' style="display:none;"') + '><td colspan="2"><hr /></td></tr>';
436 /**/
437 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-sectitle ws-plugin--s2member-custom-reg-field-configuration-tools-form-section"' + ((field.section === 'yes') ? '' : ' style="display:none;"') + '>';
438 form += '<td colspan="2">';
439 form += 'Title for this new section? ( optional )<br />';
440 form += '<input type="text" property="sectitle" value="' + esc_attr(field.sectitle) + '" id="ws-plugin--s2member-custom-reg-field-configuration-tools-form-sectitle" /><br />';
441 form += '<small>If empty, a simple divider will be used by default.</small>';
442 form += '</td>';
443 form += '</tr>';
444 /**/
445 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-spacer ws-plugin--s2member-custom-reg-field-configuration-tools-form-type"><td colspan="2">&nbsp;</td></tr>';
446 /**/
447 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-type">';
448 form += '<td colspan="2">';
449 form += '<label for="ws-plugin--s2member-custom-reg-field-configuration-tools-form-type">Form Field Type: *</label>';
450 form += '</td>';
451 form += '</tr>';
452 /**/
453 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-type">';
454 form += '<td colspan="2">';
455 form += '<select property="type" onchange="ws_plugin__s2member_customRegFieldTypeChange(this);" id="ws-plugin--s2member-custom-reg-field-configuration-tools-form-type">';
456 form += '<option value="text"' + ((field.type === 'text') ? ' selected="selected"' : '') + '">' + esc_html(fieldTypeDesc('text')) + '</option>';
457 form += '<option value="textarea"' + ((field.type === 'textarea') ? ' selected="selected"' : '') + '">' + esc_html(fieldTypeDesc('textarea')) + '</option>';
458 form += '<option value="select"' + ((field.type === 'select') ? ' selected="selected"' : '') + '">' + esc_html(fieldTypeDesc('select')) + '</option>';
459 form += '<option value="selects"' + ((field.type === 'selects') ? ' selected="selected"' : '') + '">' + esc_html(fieldTypeDesc('selects')) + '</option>';
460 form += '<option value="checkbox"' + ((field.type === 'checkbox') ? ' selected="selected"' : '') + '">' + esc_html(fieldTypeDesc('checkbox')) + '</option>';
461 form += '<option value="pre_checkbox"' + ((field.type === 'pre_checkbox') ? ' selected="selected"' : '') + '">' + esc_html(fieldTypeDesc('pre_checkbox')) + '</option>';
462 form += '<option value="checkboxes"' + ((field.type === 'checkboxes') ? ' selected="selected"' : '') + '">' + esc_html(fieldTypeDesc('checkboxes')) + '</option>';
463 form += '<option value="radios"' + ((field.type === 'radios') ? ' selected="selected"' : '') + '">' + esc_html(fieldTypeDesc('radios')) + '</option>';
464 form += '</select><br />';
465 form += '<small>The options below may change, based on the Field Type you choose here.</small>';
466 form += '</td>';
467 form += '</tr>';
468 /**/
469 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-spacer ws-plugin--s2member-custom-reg-field-configuration-tools-form-label"><td colspan="2">&nbsp;</td></tr>';
470 /**/
471 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-label">';
472 form += '<td colspan="2">';
473 form += '<label for="ws-plugin--s2member-custom-reg-field-configuration-tools-form-label">Field Label/Desc: *</label>';
474 form += '</td>';
475 form += '</tr>';
476 /**/
477 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-label">';
478 form += '<td colspan="2">';
479 form += '<input type="text" property="label" value="' + esc_attr(field.label) + '" id="ws-plugin--s2member-custom-reg-field-configuration-tools-form-label" /><br />';
480 form += '<small>Examples: <code>Choose Country</code>, <code>Street Address</code></small>';
481 form += '</td>';
482 form += '</tr>';
483 /**/
484 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-spacer ws-plugin--s2member-custom-reg-field-configuration-tools-form-id"><td colspan="2">&nbsp;</td></tr>';
485 /**/
486 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-id">';
487 form += '<td colspan="2">';
488 form += '<label for="ws-plugin--s2member-custom-reg-field-configuration-tools-form-id">Unique Field ID: *</label></label>';
489 form += '</td>';
490 form += '</tr>';
491 /**/
492 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-id">';
493 form += '<td colspan="2">';
494 form += '<input type="text" property="id" value="' + esc_attr(field.id) + '" maxlength="25" id="ws-plugin--s2member-custom-reg-field-configuration-tools-form-id" /><br />';
495 form += '<small>Examples: <code>country_code</code>, <code>street_address</code></small><br />';
496 form += '<small>e.g. <code>[s2Get user_field="country_code" /]</code></small>';
497 form += '</td>';
498 form += '</tr>';
499 /**/
500 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-spacer ws-plugin--s2member-custom-reg-field-configuration-tools-form-required"><td colspan="2">&nbsp;</td></tr>';
501 /**/
502 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-required">';
503 form += '<td colspan="2">';
504 form += '<label for="ws-plugin--s2member-custom-reg-field-configuration-tools-form-required">Field Required: *</label>';
505 form += '</td>';
506 form += '</tr>';
507 /**/
508 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-required">';
509 form += '<td colspan="2">';
510 form += '<select property="required" id="ws-plugin--s2member-custom-reg-field-configuration-tools-form-required">';
511 form += '<option value="yes"' + ((field.required === 'yes') ? ' selected="selected"' : '') + '">Yes ( required )</option>';
512 form += '<option value="no"' + ((field.required === 'no') ? ' selected="selected"' : '') + '">No ( optional )</option>';
513 form += '</select><br />';
514 form += '<small>If <code>yes</code>, only Users/Members will be "required" to enter this field.</small><br />';
515 form += '<small>* Administrators are exempt from this requirement.</small>';
516 form += '</td>';
517 form += '</tr>';
518 /**/
519 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-spacer ws-plugin--s2member-custom-reg-field-configuration-tools-form-deflt"' + ((field.type.match (/^(text|textarea)$/)) ? '' : ' style="display:none;"') + '><td colspan="2">&nbsp;</td></tr>';
520 /**/
521 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-deflt"' + ((field.type.match (/^(text|textarea)$/)) ? '' : ' style="display:none;"') + '>';
522 form += '<td colspan="2">';
523 form += '<label for="ws-plugin--s2member-custom-reg-field-configuration-tools-form-deflt">Default Text Value: ( optional )</label>';
524 form += '</td>';
525 form += '</tr>';
526 /**/
527 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-deflt"' + ((field.type.match (/^(text|textarea)$/)) ? '' : ' style="display:none;"') + '>';
528 form += '<td colspan="2">';
529 form += '<textarea property="deflt" rows="1" wrap="off" spellcheck="false" id="ws-plugin--s2member-custom-reg-field-configuration-tools-form-deflt">' + esc_html(field.deflt) + '</textarea><br />';
530 form += '<small>Default value before user input is received.</small>';
531 form += '</td>';
532 form += '</tr>';
533 /**/
534 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-spacer ws-plugin--s2member-custom-reg-field-configuration-tools-form-options"' + ((field.type.match (/^(select|selects|checkboxes|radios)$/)) ? '' : ' style="display:none;"') + '><td colspan="2">&nbsp;</td></tr>';
535 /**/
536 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-options"' + ((field.type.match (/^(select|selects|checkboxes|radios)$/)) ? '' : ' style="display:none;"') + '>';
537 form += '<td colspan="2">';
538 form += '<label for="ws-plugin--s2member-custom-reg-field-configuration-tools-form-options">Option Configuration File: * ( one option per line )</label><br />';
539 form += '<small>Use a pipe <code>|</code> delimited format: <code>option value|option label</code></small>';
540 form += '</td>';
541 form += '</tr>';
542 /**/
543 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-options"' + ((field.type.match (/^(select|selects|checkboxes|radios)$/)) ? '' : ' style="display:none;"') + '>';
544 form += '<td colspan="2">';
545 form += '<textarea property="options" rows="3" wrap="off" spellcheck="false" id="ws-plugin--s2member-custom-reg-field-configuration-tools-form-options">' + esc_html(field.options) + '</textarea><br />';
546 form += 'Here is a quick example:<br />';
547 form += '<small>You can also specify a <em>default</em> option:</small><br />';
548 form += '<code>US|United States|default</code><br />';
549 form += '<code>CA|Canada</code><br />';
550 form += '<code>VI|Virgin Islands (U.S.)</code>';
551 form += '</td>';
552 form += '</tr>';
553 /**/
554 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-spacer ws-plugin--s2member-custom-reg-field-configuration-tools-form-expected"' + ((field.type.match (/^(text|textarea)$/)) ? '' : ' style="display:none;"') + '><td colspan="2">&nbsp;</td></tr>';
555 /**/
556 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-expected"' + ((field.type.match (/^(text|textarea)$/)) ? '' : ' style="display:none;"') + '>';
557 form += '<td colspan="2">';
558 form += '<label for="ws-plugin--s2member-custom-reg-field-configuration-tools-form-expected">Expected Format: *</label>';
559 form += '</td>';
560 form += '</tr>';
561 /**/
562 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-expected"' + ((field.type.match (/^(text|textarea)$/)) ? '' : ' style="display:none;"') + '>';
563 form += '<td colspan="2">';
564 form += '<select property="expected" id="ws-plugin--s2member-custom-reg-field-configuration-tools-form-expected">';
565 /**/
566 form += '<option value=""' + ((field.expected === '') ? ' selected="selected"' : '') + '">Anything Goes</option>';
567 form += '<option disabled="disabled"></option>';
568 /**/
569 form += '<optgroup label="Specific Input Types">';
570 form += '<option value="numeric-wp-commas"' + ((field.expected === 'numeric-wp-commas') ? ' selected="selected"' : '') + '">Numeric ( with or without decimals, commas allowed )</option>';
571 form += '<option value="numeric"' + ((field.expected === 'numeric') ? ' selected="selected"' : '') + '">Numeric ( with or without decimals, no commas )</option>';
572 form += '<option value="integer"' + ((field.expected === 'integer') ? ' selected="selected"' : '') + '">Integer ( whole number, without any decimals )</option>';
573 form += '<option value="integer-gt-0"' + ((field.expected === 'integer-gt-0') ? ' selected="selected"' : '') + '">Integer > 0 ( whole number, no decimals, greater than 0 )</option>';
574 form += '<option value="float"' + ((field.expected === 'float') ? ' selected="selected"' : '') + '">Float ( floating point number, decimals required )</option>';
575 form += '<option value="float-gt-0"' + ((field.expected === 'float-gt-0') ? ' selected="selected"' : '') + '">Float > 0 ( floating point number, decimals required, greater than 0 )</option>';
576 form += '<option value="date"' + ((field.expected === 'date') ? ' selected="selected"' : '') + '">Date ( required date format: dd/mm/yyyy )</option>';
577 form += '<option value="email"' + ((field.expected === 'email') ? ' selected="selected"' : '') + '">Email ( require valid email )</option>';
578 form += '<option value="url"' + ((field.expected === 'url') ? ' selected="selected"' : '') + '">Full URL ( starting with http or https )</option>';
579 form += '<option value="domain"' + ((field.expected === 'domain') ? ' selected="selected"' : '') + '">Domain Name ( domain name only, without http )</option>';
580 form += '<option value="phone"' + ((field.expected === 'phone') ? ' selected="selected"' : '') + '">Phone # ( 10 digits w/possible hyphens,spaces,brackets )</option>';
581 form += '<option value="uszip"' + ((field.expected === 'uszip') ? ' selected="selected"' : '') + '">US Zipcode ( 5-9 digits w/possible hyphen )</option>';
582 form += '<option value="cazip"' + ((field.expected === 'cazip') ? ' selected="selected"' : '') + '">Canadian Zipcode ( 6 alpha-numerics w/possible space )</option>';
583 form += '<option value="uczip"' + ((field.expected === 'uczip') ? ' selected="selected"' : '') + '">US/Canadian Zipcode ( either a US or Canadian zipcode )</option>';
584 form += '</optgroup>';
585 /**/
586 form += '<option disabled="disabled"></option>';
587 /**/
588 form += '<optgroup label="Any Character Combination">';
589 for (i = 1; i <= 25; i++)
590 {
591 form += '<option value="any-' + i + '"' + ((field.expected === 'any-' + i) ? ' selected="selected"' : '') + '">Any Character Combination ( ' + i + ' character minimum )</option>';
592 form += '<option value="any-' + i + '-e"' + ((field.expected === 'any-' + i + '-e') ? ' selected="selected"' : '') + '">Any Character Combination ( exactly ' + i + ' character' + ((i > 1) ? 's' : '') + ' )</option>';
593 }
594 form += '</optgroup>';
595 /**/
596 form += '<option disabled="disabled"></option>';
597 /**/
598 form += '<optgroup label="Alphanumerics, Spaces &amp; Punctuation Only">';
599 for (i = 1; i <= 25; i++)
600 {
601 form += '<option value="alphanumerics-spaces-punctuation-' + i + '"' + ((field.expected === 'alphanumerics-spaces-punctuation-' + i) ? ' selected="selected"' : '') + '">Alphanumerics, Spaces &amp; Punctuation ( ' + i + ' character minimum )</option>';
602 form += '<option value="alphanumerics-spaces-punctuation-' + i + '-e"' + ((field.expected === 'alphanumerics-spaces-punctuation-' + i + '-e') ? ' selected="selected"' : '') + '">Alphanumerics, Spaces &amp; Punctuation ( exactly ' + i + ' character' + ((i > 1) ? 's' : '') + ' )</option>';
603 }
604 form += '</optgroup>';
605 /**/
606 form += '<option disabled="disabled"></option>';
607 /**/
608 form += '<optgroup label="Alphanumerics &amp; Spaces Only">';
609 for (i = 1; i <= 25; i++)
610 {
611 form += '<option value="alphanumerics-spaces-' + i + '"' + ((field.expected === 'alphanumerics-spaces-' + i) ? ' selected="selected"' : '') + '">Alphanumerics &amp; Spaces ( ' + i + ' character minimum )</option>';
612 form += '<option value="alphanumerics-spaces-' + i + '-e"' + ((field.expected === 'alphanumerics-spaces-' + i + '-e') ? ' selected="selected"' : '') + '">Alphanumerics &amp; Spaces ( exactly ' + i + ' character' + ((i > 1) ? 's' : '') + ' )</option>';
613 }
614 form += '</optgroup>';
615 /**/
616 form += '<option disabled="disabled"></option>';
617 /**/
618 form += '<optgroup label="Alphanumerics &amp; Punctuation Only">';
619 for (i = 1; i <= 25; i++)
620 {
621 form += '<option value="alphanumerics-punctuation-' + i + '"' + ((field.expected === 'alphanumerics-punctuation-' + i) ? ' selected="selected"' : '') + '">Alphanumerics &amp; Punctuation ( ' + i + ' character minimum )</option>';
622 form += '<option value="alphanumerics-punctuation-' + i + '-e"' + ((field.expected === 'alphanumerics-punctuation-' + i + '-e') ? ' selected="selected"' : '') + '">Alphanumerics &amp; Punctuation ( exactly ' + i + ' character' + ((i > 1) ? 's' : '') + ' )</option>';
623 }
624 form += '</optgroup>';
625 /**/
626 form += '<option disabled="disabled"></option>';
627 /**/
628 form += '<optgroup label="Alphanumerics Only">';
629 for (i = 1; i <= 25; i++)
630 {
631 form += '<option value="alphanumerics-' + i + '"' + ((field.expected === 'alphanumerics-' + i) ? ' selected="selected"' : '') + '">Alphanumerics ( ' + i + ' character minimum )</option>';
632 form += '<option value="alphanumerics-' + i + '-e"' + ((field.expected === 'alphanumerics-' + i + '-e') ? ' selected="selected"' : '') + '">Alphanumerics ( exactly ' + i + ' character' + ((i > 1) ? 's' : '') + ' )</option>';
633 }
634 form += '</optgroup>';
635 /**/
636 form += '<option disabled="disabled"></option>';
637 /**/
638 form += '<optgroup label="Alphabetics Only">';
639 for (i = 1; i <= 25; i++)
640 {
641 form += '<option value="alphabetics-' + i + '"' + ((field.expected === 'alphabetics-' + i) ? ' selected="selected"' : '') + '">Alphabetics ( ' + i + ' character minimum )</option>';
642 form += '<option value="alphabetics-' + i + '-e"' + ((field.expected === 'alphabetics-' + i + '-e') ? ' selected="selected"' : '') + '">Alphabetics ( exactly ' + i + ' character' + ((i > 1) ? 's' : '') + ' )</option>';
643 }
644 form += '</optgroup>';
645 /**/
646 form += '<option disabled="disabled"></option>';
647 /**/
648 form += '<optgroup label="Numeric Digits Only">';
649 for (i = 1; i <= 25; i++)
650 {
651 form += '<option value="numerics-' + i + '"' + ((field.expected === 'numerics-' + i) ? ' selected="selected"' : '') + '">Numeric Digits ( ' + i + ' digit minimum )</option>';
652 form += '<option value="numerics-' + i + '-e"' + ((field.expected === 'numerics-' + i + '-e') ? ' selected="selected"' : '') + '">Numeric Digits ( exactly ' + i + ' digit' + ((i > 1) ? 's' : '') + ' )</option>';
653 }
654 form += '</optgroup>';
655 /**/
656 form += '</select><br />';
657 form += '<small>Only Users/Members will be required to meet this criteria.</small><br />';
658 form += '<small>* Administrators are exempt from this.</small>';
659 form += '</td>';
660 form += '</tr>';
661 /**/
662 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-spacer ws-plugin--s2member-custom-reg-field-configuration-tools-form-levels"><td colspan="2">&nbsp;</td></tr>';
663 /**/
664 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-levels">';
665 form += '<td colspan="2">';
666 form += '<label for="ws-plugin--s2member-custom-reg-field-configuration-tools-form-levels">Applicable Membership Levels: *</label>';
667 form += '</td>';
668 form += '</tr>';
669 /**/
670 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-levels">';
671 form += '<td colspan="2">';
672 form += '<input type="text" property="levels" value="' + esc_attr(field.levels) + '" id="ws-plugin--s2member-custom-reg-field-configuration-tools-form-levels" /><br />';
673 form += '<small>Please use comma-delimited Level #\'s: <code>0,1,2,3,4</code> or type: <code>all</code>.</small><br />';
674 form += '<small>This allows you to enable this field - only at specific Membership Levels.</small>';
675 form += '</td>';
676 form += '</tr>';
677 /**/
678 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-spacer ws-plugin--s2member-custom-reg-field-configuration-tools-form-editable"><td colspan="2">&nbsp;</td></tr>';
679 /**/
680 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-editable">';
681 form += '<td colspan="2">';
682 form += '<label for="ws-plugin--s2member-custom-reg-field-configuration-tools-form-editable">Allow Profile Edits: *</label>';
683 form += '</td>';
684 form += '</tr>';
685 /**/
686 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-editable">';
687 form += '<td colspan="2">';
688 form += '<select property="editable" id="ws-plugin--s2member-custom-reg-field-configuration-tools-form-editable">';
689 form += '<option value="yes"' + ((field.editable === 'yes') ? ' selected="selected"' : '') + '">Yes ( editable )</option>';
690 form += '<option value="no"' + ((field.editable === 'no') ? ' selected="selected"' : '') + '">No ( uneditable after registration )</option>';
691 form += '<option value="no-invisible"' + ((field.editable === 'no-invisible') ? ' selected="selected"' : '') + '">No ( uneditable &amp; totally invisible after registration )</option>';
692 form += '<option value="yes-invisible"' + ((field.editable === 'yes-invisible') ? ' selected="selected"' : '') + '">Yes ( editable after registration / invisible during registration )</option>';
693 form += '</select><br />';
694 form += '<small>If <code>No</code>, this field will be un-editable after registration.</small><br />';
695 form += '<small>* Administrators are exempt from this.</small>';
696 form += '</td>';
697 form += '</tr>';
698 /**/
699 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-spacer ws-plugin--s2member-custom-reg-field-configuration-tools-form-classes"><td colspan="2">&nbsp;</td></tr>';
700 /**/
701 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-classes">';
702 form += '<td colspan="2">';
703 form += '<label for="ws-plugin--s2member-custom-reg-field-configuration-tools-form-classes">CSS Classes: ( optional )</label>';
704 form += '</td>';
705 form += '</tr>';
706 /**/
707 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-classes">';
708 form += '<td colspan="2">';
709 form += '<input type="text" property="classes" value="' + esc_attr(field.classes) + '" id="ws-plugin--s2member-custom-reg-field-configuration-tools-form-classes" /><br />';
710 form += '<small>Example: <code>my-style-1 my-style-2</code></small>';
711 form += '</td>';
712 form += '</tr>';
713 /**/
714 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-spacer ws-plugin--s2member-custom-reg-field-configuration-tools-form-styles"><td colspan="2">&nbsp;</td></tr>';
715 /**/
716 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-styles">';
717 form += '<td colspan="2">';
718 form += '<label for="ws-plugin--s2member-custom-reg-field-configuration-tools-form-styles">CSS Styles: ( optional )</label>';
719 form += '</td>';
720 form += '</tr>';
721 /**/
722 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-styles">';
723 form += '<td colspan="2">';
724 form += '<input type="text" property="styles" value="' + esc_attr(field.styles) + '" id="ws-plugin--s2member-custom-reg-field-configuration-tools-form-styles" /><br />';
725 form += '<small>Example: <code>color:#000000; background:#FFFFFF;</code></small>';
726 form += '</td>';
727 form += '</tr>';
728 /**/
729 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-spacer ws-plugin--s2member-custom-reg-field-configuration-tools-form-attrs"><td colspan="2">&nbsp;</td></tr>';
730 /**/
731 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-attrs">';
732 form += '<td colspan="2">';
733 form += '<label for="ws-plugin--s2member-custom-reg-field-configuration-tools-form-attrs">Other Attributes: ( optional )</label>';
734 form += '</td>';
735 form += '</tr>';
736 /**/
737 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-attrs">';
738 form += '<td colspan="2">';
739 form += '<input type="text" property="attrs" value="' + esc_attr(field.attrs) + '" id="ws-plugin--s2member-custom-reg-field-configuration-tools-form-attrs" /><br />';
740 form += '<small>Example: <code>onkeyup="" onblur=""</code></small>';
741 form += '</td>';
742 form += '</tr>';
743 /**/
744 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-spacer ws-plugin--s2member-custom-reg-field-configuration-tools-form-buttons"><td colspan="2">&nbsp;</td></tr>';
745 /**/
746 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-buttons">';
747 form += '<td align="left">';
748 form += '<input type="button" value="Cancel" onclick="ws_plugin__s2member_customRegFieldCancel();" />';
749 form += '</td>';
750 form += '<td align="right">';
751 form += '<input type="button" value="' + ((editing) ? 'Update This Field' : 'Create Registration Field') + '" onclick="' + ((editing) ? 'ws_plugin__s2member_customRegFieldUpdate(' + index + ');' : 'ws_plugin__s2member_customRegFieldCreate();') + '" />';
752 form += '</td>';
753 form += '</tr>';
754 /**/
755 form += '</tbody>';
756 form += '</table>';
757 /**/
758 form += '<div>';
759 /**/
760 $('body').append (form);
761 /**/
762 tb_show(((editing) ? 'Editing Registration Field' : 'New Custom Registration Field'), '#TB_inline?inlineId=ws-plugin--s2member-custom-reg-field-configuration-thickbox-tools-form'), $(window).trigger ('resize');
763 /**/
764 $('table#ws-plugin--s2member-custom-reg-field-configuration-tools-form').show ();
765 }
766 /**/
767 $tools.html (html);
768 };
769 /**/
770 var attachTBResizer = function() /* Resize inline #TB_ajaxContent. */
771 {
772 $(window).resize (function()
773 {
774 var w, h; /* Initialize width/height vars. */
775 w = $(window).width (), h = $(window).height (), w = (w > 720) ? 720 : w;
776 $('#TB_ajaxContent').css ({'width': w - 50, 'height': h - 75, 'margin': 0, 'padding': 0});
777 });
778 };
779 /**/
780 var buildTable = function() /* This builds the table of existing fields. */
781 {
782 var l = fields.length, i = 0, html = '', eo = 'o';
783 /**/
784 html += '<tbody>';
785 /**/
786 html += '<tr>';
787 html += '<th>Order</th>';
788 html += '<th>Field Type</th>';
789 html += '<th>Unique ID</th>';
790 html += '<th>Required</th>';
791 html += '<th>Levels</th>';
792 html += '<th>- Tools -</th>';
793 html += '</tr>';
794 /**/
795 if (fields.length > 0) /* Any fields? */
796 {
797 for (i = 0; i < fields.length; i++)
798 {
799 html += '<tr class="' + esc_attr((eo = (eo === 'o') ? 'e' : 'o')) + ((fields[i].section === 'yes') ? ' s' : '') + ' ws-plugin--s2member-custom-reg-field-configuration-table-row-' + i + '">'; /* Odd/even + row identifier. */
800 html += '<td nowrap="nowrap"><a class="ws-plugin--s2member-custom-reg-field-configuration-move-up" href="#" onclick="ws_plugin__s2member_customRegFieldMoveUp(' + i + '); return false;"></a><a class="ws-plugin--s2member-custom-reg-field-configuration-move-down" href="#" onclick="ws_plugin__s2member_customRegFieldMoveDown(' + i + '); return false;"></a></td>';
801 html += '<td nowrap="nowrap">' + esc_html(fieldTypeDesc(fields[i].type)) + '</td>';
802 html += '<td nowrap="nowrap">' + esc_html(fields[i].id) + '</td>';
803 html += '<td nowrap="nowrap">' + esc_html(fields[i].required) + '</td>';
804 html += '<td nowrap="nowrap">' + esc_html(fields[i].levels) + '</td>';
805 html += '<td nowrap="nowrap"><a class="ws-plugin--s2member-custom-reg-field-configuration-edit" href="#" onclick="ws_plugin__s2member_customRegFieldEdit(' + i + '); return false;"></a><a class="ws-plugin--s2member-custom-reg-field-configuration-delete" href="#" onclick="ws_plugin__s2member_customRegFieldDelete(' + i + '); return false;"></a></td>';
806 html += '</tr>';
807 }
808 }
809 else /* Otherwise, there are no fields configured yet. */
810 {
811 html += '<tr>'; /* There are no fields yet. */
812 html += '<td colspan="6">No Custom Fields are configured.</td>';
813 html += '</tr>';
814 }
815 /**/
816 html += '</tbody>';
817 /**/
818 $table.html (html);
819 };
820 /* Initialize configuration. */
821 buildTools (), attachTBResizer (), buildTable ();
822 /**/
823 }) ();
824 }
825 }
826 /**/
827 else if (location.href.match (/page\=ws-plugin--s2member-res-ops/))
828 {
829 $('input#ws-plugin--s2member-brute-force-restrictions-reset-button').click (function()
830 {
831 var $this = $(this); /* Save $(this) into $this. */
832 $this.val ('one moment please ...'); /* Indicate loading status ( please wait ). */
833 /**/
834 $.post (ajaxurl, {action: 'ws_plugin__s2member_delete_reset_all_ip_restrictions_via_ajax', ws_plugin__s2member_delete_reset_all_ip_restrictions_via_ajax: '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (wp_create_nonce ("ws-plugin--s2member-delete-reset-all-ip-restrictions-via-ajax")); ?>'}, function(response)
835 {
836 alert('s2Member\'s Brute Force Restriction Logs have all been reset.'), $this.val ('Reset Brute Force Logs');
837 });
838 /**/
839 return false;
840 });
841 /**/
842 $('input#ws-plugin--s2member-ip-restrictions-reset-button').click (function()
843 {
844 var $this = $(this); /* Save $(this) into $this. */
845 $this.val ('one moment please ...'); /* Indicate loading status ( please wait ). */
846 /**/
847 $.post (ajaxurl, {action: 'ws_plugin__s2member_delete_reset_all_ip_restrictions_via_ajax', ws_plugin__s2member_delete_reset_all_ip_restrictions_via_ajax: '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (wp_create_nonce ("ws-plugin--s2member-delete-reset-all-ip-restrictions-via-ajax")); ?>'}, function(response)
848 {
849 alert('s2Member\'s IP Restriction Logs have all been reset.'), $this.val ('Reset IP Restriction Logs');
850 });
851 /**/
852 return false;
853 });
854 /**/
855 $('div.ws-plugin--s2member-query-level-access-section input[type="checkbox"][name="ws_plugin__s2member_filter_wp_query\[\]"]').change (function()
856 {
857 var thisChange = $(this).val (); /* Record value associated with change event. Allows for intutitive unchecking. */
858 /**/
859 $('div.ws-plugin--s2member-query-level-access-section input[type="checkbox"][name="ws_plugin__s2member_filter_wp_query\[\]"]').each (function()
860 {
861 var $this = $(this), val = $this.val (), checkboxes = 'input[type="checkbox"]';
862 /**/
863 if (val === 'all' && this.checked) /* All sub-items get checked/disabled. */
864 $this.nextAll (checkboxes).attr ({'checked': 'checked', 'disabled': 'disabled'});
865 /**/
866 else if (val === 'all' && !this.checked)
867 {
868 $this.nextAll (checkboxes).removeAttr ('disabled');
869 (thisChange === 'all') ? $this.nextAll (checkboxes).removeAttr ('checked') : null;
870 }
871 });
872 /**/
873 }).last ().trigger ('change');
874 }
875 /**/
876 else if (location.href.match (/page\=ws-plugin--s2member-paypal-ops/))
877 {
878 $('select#ws-plugin--s2member-auto-eot-system-enabled').change (function()
879 {
880 var $this = $(this), val = $this.val ();
881 var $viaCron = $('p#ws-plugin--s2member-auto-eot-system-enabled-via-cron');
882 /**/
883 if (val == 2) /* Display Cron instructions. */
884 $viaCron.show ()
885 else /* Hide instructions. */
886 $viaCron.hide ();
887 });
888 }
889 /**/
890 else if (location.href.match (/page\=ws-plugin--s2member-els-ops/))
891 {
892 $('select#ws-plugin--s2member-custom-reg-opt-in').change (function()
893 {
894 var $this = $(this), val = $this.val ();
895 var $rows = $('tr.ws-plugin--s2member-custom-reg-opt-in-label-row');
896 var $prevImg = $('img.ws-plugin--s2member-custom-reg-opt-in-label-prev-img');
897 /**/
898 if (val <= 0) /* Checkbox disabled. */
899 $rows.css ('display', 'none'), $prevImg.attr ('src', $prevImg.attr ('src').replace (/\/checked\.png$/, '/unchecked.png'));
900 /**/
901 else if (val == 1) /* Enabled, checked by default. */
902 $rows.css ('display', ''), $prevImg.attr ('src', $prevImg.attr ('src').replace (/\/unchecked\.png$/, '/checked.png'));
903 /**/
904 else if (val == 2) /* Enabled, unchecked by default. */
905 $rows.css ('display', ''), $prevImg.attr ('src', $prevImg.attr ('src').replace (/\/checked\.png$/, '/unchecked.png'));
906 });
907 /**/
908 $('div.ws-plugin--s2member-opt-out-section input[type="checkbox"][name="ws_plugin__s2member_custom_reg_auto_opt_outs\[\]"]').change (function()
909 {
910 var thisChange = $(this).val (), checkedIndexes = []; /* Record value associated with change event. Also initialize checkedIndexes array. */
911 /**/
912 $('div.ws-plugin--s2member-opt-out-section input[type="checkbox"][name="ws_plugin__s2member_custom_reg_auto_opt_outs\[\]"]').each (function()
913 {
914 var $this = $(this), val = $this.val (), checkboxes = 'input[type="checkbox"]';
915 /**/
916 if (val === 'removal-deletion' && this.checked) /* All sub-items get checked/disabled too. */
917 $this.nextAll (checkboxes).slice (0, 2).attr ({'checked': 'checked', 'disabled': 'disabled'});
918 /**/
919 else if (val === 'removal-deletion' && !this.checked)
920 {
921 $this.nextAll (checkboxes).slice (0, 2).removeAttr ('disabled');
922 (thisChange === 'removal-deletion') ? $this.nextAll (checkboxes).slice (0, 2).removeAttr ('checked') : null;
923 }
924 /**/
925 else if (val === 'modification' && this.checked) /* All sub-items get checked/disabled too. */
926 $this.nextAll (checkboxes).slice (0, 3).attr ({'checked': 'checked', 'disabled': 'disabled'});
927 /**/
928 else if (val === 'modification' && !this.checked)
929 {
930 (thisChange === 'modification') ? $this.nextAll (checkboxes).slice (0, 3).removeAttr ('checked') : null;
931 $this.nextAll (checkboxes).slice (0, 3).removeAttr ('disabled');
932 }
933 })
934 /**/
935 .each (function(index) /* Now, which ones are checked? */
936 {
937 (this.checked) ? checkedIndexes.push (index) : null;
938 });
939 /**/
940 $('select#ws-plugin--s2member-custom-reg-auto-opt-out-transitions').removeAttr ('disabled');
941 if ($.inArray (3, checkedIndexes) === -1 && $.inArray (4, checkedIndexes) === -1 && $.inArray (5, checkedIndexes) === -1 && $.inArray (6, checkedIndexes) === -1)
942 $('select#ws-plugin--s2member-custom-reg-auto-opt-out-transitions').attr ('disabled', 'disabled');
943 /**/
944 }).last ().trigger ('change');
945 }
946 /**/
947 else if (location.href.match (/page\=ws-plugin--s2member-paypal-buttons/))
948 {
949 $('div.ws-menu-page select[id]').filter (function() /* Filter all select elements with an id. */
950 {
951 return this.id.match (/^ws-plugin--s2member-(level[1-9][0-9]*|modification)-term$/);
952 }).change (function()
953 {
954 var button = this.id.replace (/^ws-plugin--s2member-(.+?)-term$/g, '$1');
955 var trialDisabled = ($(this).val ().split ('-')[2].replace (/[^0-1BN]/g, '') === 'BN') ? 1 : 0;
956 /**/
957 $('p#ws-plugin--s2member-' + button + '-trial-line').css ('display', (trialDisabled ? 'none' : ''));
958 $('span#ws-plugin--s2member-' + button + '-trial-then').css ('display', (trialDisabled ? 'none' : ''));
959 $('span#ws-plugin--s2member-' + button + '-20p-rule').css ('display', (trialDisabled ? 'none' : ''));
960 /**/
961 (trialDisabled) ? $('input#ws-plugin--s2member-' + button + '-trial-period').val (0) : null;
962 (trialDisabled) ? $('input#ws-plugin--s2member-' + button + '-trial-amount').val ('0.00') : null;
963 });
964 /**/
965 $('div.ws-menu-page input[id]').filter (function() /* Filter all input elements with an id. */
966 {
967 return this.id.match (/^ws-plugin--s2member-(level[1-9][0-9]*|modification|ccap)-ccaps$/);
968 }).keyup (function()
969 {
970 var value = this.value.replace (/^(-all|-al|-a|-)[;,]*/gi, ''), _all = (this.value.match (/^(-all|-al|-a|-)[;,]*/i)) ? '-all,' : '';
971 if (value.match (/[^a-z_0-9,]/)) /* Only if there is a problem with the actual values; because this causes interruptions. */
972 this.value = _all + $.trim ($.trim (value).replace (/[ \-]/g, '_').replace (/[^a-z_0-9,]/gi, '').toLowerCase ());
973 });
974 /**/
975 ws_plugin__s2member_paypalButtonGenerate = function(button) /* Handles PayPal® Button Generation. */
976 {
977 var shortCodeTemplate = '[s2Member-PayPal-Button %%attrs%% image="default" output="button" /]', shortCodeTemplateAttrs = '', labels = {};
978 /**/
979 eval("<?php echo c_ws_plugin__s2member_utils_strings::esc_dq($labels); ?>");
980 /**/
981 var shortCode = $('input#ws-plugin--s2member-' + button + '-shortcode');
982 var code = $('textarea#ws-plugin--s2member-' + button + '-button');
983 var modLevel = $('select#ws-plugin--s2member-modification-level');
984 /**/
985 var level = (button === 'modification') ? modLevel.val ().split (':', 2)[1] : button.replace (/^level/, '');
986 var label = labels['level' + level].replace (/"/g, ''); /* Labels may NOT contain any double-quotes. */
987 var desc = $.trim ($('input#ws-plugin--s2member-' + button + '-desc').val ().replace (/"/g, ""));
988 /**/
989 var trialAmount = $('input#ws-plugin--s2member-' + button + '-trial-amount').val ().replace (/[^0-9\.]/g, '');
990 var trialPeriod = $('input#ws-plugin--s2member-' + button + '-trial-period').val ().replace (/[^0-9]/g, '');
991 var trialTerm = $('select#ws-plugin--s2member-' + button + '-trial-term').val ().replace (/[^A-Z]/g, '');
992 /**/
993 var regAmount = $('input#ws-plugin--s2member-' + button + '-amount').val ().replace (/[^0-9\.]/g, '');
994 var regPeriod = $('select#ws-plugin--s2member-' + button + '-term').val ().split ('-')[0].replace (/[^0-9]/g, '');
995 var regTerm = $('select#ws-plugin--s2member-' + button + '-term').val ().split ('-')[1].replace (/[^A-Z]/g, '');
996 var regRecur = $('select#ws-plugin--s2member-' + button + '-term').val ().split ('-')[2].replace (/[^0-1BN]/g, '');
997 var regRecurTimes = '', regRecurRetry = '1'; /* These options are NOT yet configurable. */
998 /**/
999 var localeCode = '', digital = '0', noShipping = '1'; /* NOT yet configurable. */
1000 var pageStyle = $.trim ($('input#ws-plugin--s2member-' + button + '-page-style').val ().replace (/"/g, ''));
1001 var currencyCode = $('select#ws-plugin--s2member-' + button + '-currency').val ().replace (/[^A-Z]/g, '');
1002 /**/
1003 var cCaps = $.trim ($.trim ($('input#ws-plugin--s2member-' + button + '-ccaps').val ()).replace (/^(-all|-al|-a|-)[;,]*/gi, '').replace (/[ \-]/g, '_').replace (/[^a-z_0-9,]/gi, '').toLowerCase ());
1004 cCaps = ($.trim ($('input#ws-plugin--s2member-' + button + '-ccaps').val ()).match (/^(-all|-al|-a|-)[;,]*/i)) ? ((cCaps) ? '-all,' : '-all') + cCaps.toLowerCase () : cCaps.toLowerCase ();
1005 /**/
1006 trialPeriod = (regRecur === 'BN') ? '0' : trialPeriod; /* Lifetime ( 1-L-BN ) and Buy Now ( BN ) access is absolutely NOT compatible w/ Trial Periods. */
1007 trialAmount = (!trialAmount || isNaN(trialAmount) || trialAmount < 0.01 || trialPeriod <= 0) ? '0' : trialAmount; /* Validate Trial Amount. */
1008 /**/
1009 var levelCcapsPer = (regRecur === 'BN' && regTerm !== 'L') ? level + ':' + cCaps + ':' + regPeriod + ' ' + regTerm : level + ':' + cCaps;
1010 levelCcapsPer = levelCcapsPer.replace (/\:+$/g, ''); /* Clean any trailing separators from this string. */
1011 /**/
1012 if (trialAmount !== '0' && (isNaN(trialAmount) || trialAmount < 0.00))
1013 {
1014 alert('— Oops, a slight problem: —\n\nWhen provided, Trial Amount must be >= 0.00');
1015 return false;
1016 }
1017 else if (trialAmount !== '0' && trialAmount > 10000.00) /* $10,000.00 maximum. */
1018 {
1019 alert('— Oops, a slight problem: —\n\nMaximum Trial Amount is: 10000.00');
1020 return false;
1021 }
1022 else if (trialTerm === 'D' && trialPeriod > 7) /* Some validation on the Trial Period. Max days: 7. */
1023 {
1024 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.');
1025 return false;
1026 }
1027 else if (trialTerm === 'W' && trialPeriod > 52) /* Some validation on the Trial Period. 52 max. */
1028 {
1029 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.');
1030 return false;
1031 }
1032 else if (trialTerm === 'M' && trialPeriod > 12) /* Some validation on the Trial Period. 12 max. */
1033 {
1034 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.');
1035 return false;
1036 }
1037 else if (trialTerm === 'Y' && trialPeriod > 1) /* 1 year max. */
1038 {
1039 alert('— Oops, a slight problem: —\n\nMax Trial Period Years is: 1.');
1040 return false;
1041 }
1042 else if (!regAmount || isNaN(regAmount) || regAmount < 0.01)
1043 {
1044 alert('— Oops, a slight problem: —\n\nAmount must be >= 0.01');
1045 return false;
1046 }
1047 else if (regAmount > 10000.00) /* $10,000.00 maximum. */
1048 {
1049 alert('— Oops, a slight problem: —\n\nMaximum Amount is: 10000.00');
1050 return false;
1051 }
1052 else if (!desc) /* Each Button should have a Description. */
1053 {
1054 alert('— Oops, a slight problem: —\n\nPlease type a Description for this Button.');
1055 return false;
1056 }
1057 /**/
1058 code.html (code.val ().replace (/ \<\!--(\<input type\="hidden" name\="(amount|src|srt|sra|a1|p1|t1|a3|p3|t3)" value\="(.*?)" \/\>)--\>/g, " $1"));
1059 (parseInt(trialPeriod) <= 0) ? code.html (code.val ().replace (/ (\<input type\="hidden" name\="(a1|p1|t1)" value\="(.*?)" \/\>)/g, " <!--$1-->")) : null;
1060 (regRecur === 'BN') ? code.html (code.val ().replace (/ (\<input type\="hidden" name\="cmd" value\=")(.*?)(" \/\>)/g, " $1_xclick$3")) : null;
1061 (regRecur === 'BN') ? code.html (code.val ().replace (/ (\<input type\="hidden" name\="(src|srt|sra|a1|p1|t1|a3|p3|t3)" value\="(.*?)" \/\>)/g, " <!--$1-->")) : null;
1062 (regRecur !== 'BN') ? code.html (code.val ().replace (/ (\<input type\="hidden" name\="cmd" value\=")(.*?)(" \/\>)/g, " $1_xclick-subscriptions$3")) : null;
1063 (regRecur !== 'BN') ? code.html (code.val ().replace (/ (\<input type\="hidden" name\="amount" value\="(.*?)" \/\>)/g, " <!--$1-->")) : null;
1064 /**/
1065 shortCodeTemplateAttrs += (button === 'modification') ? 'modify="1" ' : ''; /* For Modification Buttons. */
1066 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"])); ?>"';
1067 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(regRecurRetry) + '"';
1068 shortCode.val (shortCodeTemplate.replace (/%%attrs%%/, shortCodeTemplateAttrs));
1069 /**/
1070 code.html (code.val ().replace (/ name\="lc" value\="(.*?)"/, ' name="lc" value="' + esc_attr(localeCode) + '"'));
1071 code.html (code.val ().replace (/ name\="no_shipping" value\="(.*?)"/, ' name="no_shipping" value="' + esc_attr(noShipping) + '"'));
1072 code.html (code.val ().replace (/ name\="item_name" value\="(.*?)"/, ' name="item_name" value="' + esc_attr(desc) + '"'));
1073 code.html (code.val ().replace (/ name\="item_number" value\="(.*?)"/, ' name="item_number" value="' + esc_attr(levelCcapsPer) + '"'));
1074 code.html (code.val ().replace (/ name\="page_style" value\="(.*?)"/, ' name="page_style" value="' + esc_attr(pageStyle) + '"'));
1075 code.html (code.val ().replace (/ name\="currency_code" value\="(.*?)"/, ' name="currency_code" value="' + esc_attr(currencyCode) + '"'));
1076 code.html (code.val ().replace (/ name\="custom" value\="(.*?)"/, ' name="custom" value="<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (esc_attr ($_SERVER["HTTP_HOST"])); ?>"'));
1077 /**/
1078 code.html (code.val ().replace (/ name\="modify" value\="(.*?)"/, ' name="modify" value="' + ((button === 'modification') ? '1' : '0') + '"'));
1079 /**/
1080 code.html (code.val ().replace (/ name\="amount" value\="(.*?)"/, ' name="amount" value="' + esc_attr(regAmount) + '"'));
1081 /**/
1082 code.html (code.val ().replace (/ name\="src" value\="(.*?)"/, ' name="src" value="' + esc_attr(regRecur) + '"'));
1083 code.html (code.val ().replace (/ name\="srt" value\="(.*?)"/, ' name="srt" value="' + esc_attr(regRecurTimes) + '"'));
1084 code.html (code.val ().replace (/ name\="sra" value\="(.*?)"/, ' name="sra" value="' + esc_attr(regRecurRetry) + '"'));
1085 /**/
1086 code.html (code.val ().replace (/ name\="a1" value\="(.*?)"/, ' name="a1" value="' + esc_attr(trialAmount) + '"'));
1087 code.html (code.val ().replace (/ name\="p1" value\="(.*?)"/, ' name="p1" value="' + esc_attr(trialPeriod) + '"'));
1088 code.html (code.val ().replace (/ name\="t1" value\="(.*?)"/, ' name="t1" value="' + esc_attr(trialTerm) + '"'));
1089 code.html (code.val ().replace (/ name\="a3" value\="(.*?)"/, ' name="a3" value="' + esc_attr(regAmount) + '"'));
1090 code.html (code.val ().replace (/ name\="p3" value\="(.*?)"/, ' name="p3" value="' + esc_attr(regPeriod) + '"'));
1091 code.html (code.val ().replace (/ name\="t3" value\="(.*?)"/, ' name="t3" value="' + esc_attr(regTerm) + '"'));
1092 /**/
1093 $('div#ws-plugin--s2member-' + button + '-button-prev').html (code.val ().replace (/\<form/, '<form target="_blank"').replace (/\<\?php echo S2MEMBER_VALUE_FOR_PP_INV\(\); \?\>/g, Math.round (new Date ().getTime ()) + '~<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (esc_attr ($_SERVER["REMOTE_ADDR"])); ?>').replace (/\<\?php echo S2MEMBER_CURRENT_USER_VALUE_FOR_PP_(ON0|OS0|ON1|OS1); \?\>/g, ''));
1094 /**/
1095 (button === 'modification') ? alert('Your Modification Button has been generated.\nPlease copy/paste the Shortcode Format into your Login Welcome Page, or wherever you feel it would be most appropriate.\n\n* Remember, Modification Buttons should be displayed to existing Users/Members, and they should be logged-in, BEFORE clicking this Button.') : alert('Your Button has been generated.\nPlease copy/paste the Shortcode Format into your Membership Options Page.');
1096 /**/
1097 shortCode.each (function() /* Focus and select the recommended Shortcode. */
1098 {
1099 this.focus (), this.select ();
1100 });
1101 /**/
1102 return false;
1103 };
1104 /**/
1105 ws_plugin__s2member_paypalCcapButtonGenerate = function() /* Handles PayPal® Button Generation for Independent Capabilities. */
1106 {
1107 var shortCodeTemplate = '[s2Member-PayPal-Button %%attrs%% image="default" output="button" /]', shortCodeTemplateAttrs = '';
1108 /**/
1109 var shortCode = $('input#ws-plugin--s2member-ccap-shortcode');
1110 var code = $('textarea#ws-plugin--s2member-ccap-button');
1111 /**/
1112 var desc = $.trim ($('input#ws-plugin--s2member-ccap-desc').val ().replace (/"/g, ''));
1113 /**/
1114 var regAmount = $('input#ws-plugin--s2member-ccap-amount').val ().replace (/[^0-9\.]/g, '');
1115 var regPeriod = $('select#ws-plugin--s2member-ccap-term').val ().split ('-')[0].replace (/[^0-9]/g, '');
1116 var regTerm = $('select#ws-plugin--s2member-ccap-term').val ().split ('-')[1].replace (/[^A-Z]/g, '');
1117 var regRecur = $('select#ws-plugin--s2member-ccap-term').val ().split ('-')[2].replace (/[^0-1BN]/g, '');
1118 /**/
1119 var localeCode = '', digital = '0', noShipping = '1'; /* NOT yet configurable. */
1120 var pageStyle = $.trim ($('input#ws-plugin--s2member-ccap-page-style').val ().replace (/"/g, ''));
1121 var currencyCode = $('select#ws-plugin--s2member-ccap-currency').val ().replace (/[^A-Z]/g, '');
1122 /**/
1123 var cCaps = $.trim ($.trim ($('input#ws-plugin--s2member-ccap-ccaps').val ()).replace (/^(-all|-al|-a|-)[;,]*/gi, '').replace (/[ \-]/g, '_').replace (/[^a-z_0-9,]/gi, '').toLowerCase ());
1124 cCaps = ($.trim ($('input#ws-plugin--s2member-ccap-ccaps').val ()).match (/^(-all|-al|-a|-)[;,]*/i)) ? ((cCaps) ? '-all,' : '-all') + cCaps.toLowerCase () : cCaps.toLowerCase ();
1125 /**/
1126 var levelCcapsPer = (regRecur === 'BN' && regTerm !== 'L') ? '*:' + cCaps + ':' + regPeriod + ' ' + regTerm : '*:' + cCaps;
1127 levelCcapsPer = levelCcapsPer.replace (/\:+$/g, ''); /* Clean any trailing separators from this string. */
1128 /**/
1129 if (!cCaps || cCaps === '-all') /* Must have some Independent Custom Capabilities. */
1130 {
1131 alert('— Oops, a slight problem: —\n\nPlease provide at least one Custom Capability.');
1132 return false;
1133 }
1134 else if (!regAmount || isNaN(regAmount) || regAmount < 0.01)
1135 {
1136 alert('— Oops, a slight problem: —\n\nAmount must be >= 0.01');
1137 return false;
1138 }
1139 else if (regAmount > 10000.00) /* $10,000.00 maximum. */
1140 {
1141 alert('— Oops, a slight problem: —\n\nMaximum Amount is: 10000.00');
1142 return false;
1143 }
1144 else if (!desc) /* Each Button should have a Description. */
1145 {
1146 alert('— Oops, a slight problem: —\n\nPlease type a Description for this Button.');
1147 return false;
1148 }
1149 /**/
1150 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) + '"';
1151 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) + '"';
1152 shortCode.val (shortCodeTemplate.replace (/%%attrs%%/, shortCodeTemplateAttrs));
1153 /**/
1154 code.html (code.val ().replace (/ name\="lc" value\="(.*?)"/, ' name="lc" value="' + esc_attr(localeCode) + '"'));
1155 code.html (code.val ().replace (/ name\="no_shipping" value\="(.*?)"/, ' name="no_shipping" value="' + esc_attr(noShipping) + '"'));
1156 code.html (code.val ().replace (/ name\="item_name" value\="(.*?)"/, ' name="item_name" value="' + esc_attr(desc) + '"'));
1157 code.html (code.val ().replace (/ name\="item_number" value\="(.*?)"/, ' name="item_number" value="' + esc_attr(levelCcapsPer) + '"'));
1158 code.html (code.val ().replace (/ name\="page_style" value\="(.*?)"/, ' name="page_style" value="' + esc_attr(pageStyle) + '"'));
1159 code.html (code.val ().replace (/ name\="currency_code" value\="(.*?)"/, ' name="currency_code" value="' + esc_attr(currencyCode) + '"'));
1160 code.html (code.val ().replace (/ name\="custom" value\="(.*?)"/, ' name="custom" value="<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (esc_attr ($_SERVER["HTTP_HOST"])); ?>"'));
1161 /**/
1162 code.html (code.val ().replace (/ name\="amount" value\="(.*?)"/, ' name="amount" value="' + esc_attr(regAmount) + '"'));
1163 /**/
1164 $('div#ws-plugin--s2member-ccap-button-prev').html (code.val ().replace (/\<form/, '<form target="_blank"').replace (/\<\?php echo S2MEMBER_VALUE_FOR_PP_INV\(\); \?\>/g, Math.round (new Date ().getTime ()) + '~<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (esc_attr ($_SERVER["REMOTE_ADDR"])); ?>').replace (/\<\?php echo S2MEMBER_CURRENT_USER_VALUE_FOR_PP_(ON0|OS0|ON1|OS1); \?\>/g, ''));
1165 /**/
1166 alert('Your Button has been generated.\nPlease copy/paste the Shortcode Format into your Login Welcome Page, or wherever you feel it would be most appropriate.\n\n* Remember, Independent Custom Capability Buttons should ONLY be displayed to existing Users/Members, and they MUST be logged-in, BEFORE clicking this Button.');
1167 /**/
1168 shortCode.each (function() /* Focus and select the recommended Shortcode. */
1169 {
1170 this.focus (), this.select ();
1171 });
1172 /**/
1173 return false;
1174 };
1175 /**/
1176 ws_plugin__s2member_paypalSpButtonGenerate = function() /* Handles PayPal® Button Generation for Specific Post/Page Access. */
1177 {
1178 var shortCodeTemplate = '[s2Member-PayPal-Button %%attrs%% image="default" output="button" /]', shortCodeTemplateAttrs = '';
1179 /**/
1180 var shortCode = $('input#ws-plugin--s2member-sp-shortcode');
1181 var code = $('textarea#ws-plugin--s2member-sp-button');
1182 /**/
1183 var leading = $('select#ws-plugin--s2member-sp-leading-id').val ().replace (/[^0-9]/g, '');
1184 var additionals = $('select#ws-plugin--s2member-sp-additional-ids').val () || [];
1185 var hours = $('select#ws-plugin--s2member-sp-hours').val ().replace (/[^0-9]/g, '');
1186 /**/
1187 var regAmount = $('input#ws-plugin--s2member-sp-amount').val ().replace (/[^0-9\.]/g, '');
1188 var desc = $.trim ($('input#ws-plugin--s2member-sp-desc').val ().replace (/"/g, ''));
1189 /**/
1190 var localeCode = '', digital = '0', noShipping = '1'; /* NOT yet configurable. */
1191 var pageStyle = $.trim ($('input#ws-plugin--s2member-sp-page-style').val ().replace (/"/g, ''));
1192 var currencyCode = $('select#ws-plugin--s2member-sp-currency').val ().replace (/[^A-Z]/g, '');
1193 /**/
1194 if (!leading) /* Must have a Leading Post/Page ID to work with. Otherwise, Link generation will fail. */
1195 {
1196 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.');
1197 return false;
1198 }
1199 else if (!regAmount || isNaN(regAmount) || regAmount < 0.01)
1200 {
1201 alert('— Oops, a slight problem: —\n\nAmount must be >= 0.01');
1202 return false;
1203 }
1204 else if (regAmount > 10000.00) /* $10,000.00 maximum. */
1205 {
1206 alert('— Oops, a slight problem: —\n\nMaximum Amount is: 10000.00');
1207 return false;
1208 }
1209 else if (!desc) /* Each Button should have a Description. */
1210 {
1211 alert('— Oops, a slight problem: —\n\nPlease type a Description for this Button.');
1212 return false;
1213 }
1214 /**/
1215 for (var i = 0, ids = leading; i < additionals.length; i++)
1216 if (additionals[i] && additionals[i] !== leading)
1217 ids += ',' + additionals[i];
1218 /**/
1219 var spIdsHours = 'sp:' + ids + ':' + hours; /* Combined sp:ids:expiration hours. */
1220 /**/
1221 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) + '"';
1222 shortCodeTemplateAttrs += ' custom="<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (esc_attr ($_SERVER["HTTP_HOST"])); ?>" ra="' + esc_attr(regAmount) + '"';
1223 shortCode.val (shortCodeTemplate.replace (/%%attrs%%/, shortCodeTemplateAttrs));
1224 /**/
1225 code.html (code.val ().replace (/ name\="lc" value\="(.*?)"/, ' name="lc" value="' + esc_attr(localeCode) + '"'));
1226 code.html (code.val ().replace (/ name\="no_shipping" value\="(.*?)"/, ' name="no_shipping" value="' + esc_attr(noShipping) + '"'));
1227 code.html (code.val ().replace (/ name\="item_name" value\="(.*?)"/, ' name="item_name" value="' + esc_attr(desc) + '"'));
1228 code.html (code.val ().replace (/ name\="item_number" value\="(.*?)"/, ' name="item_number" value="' + esc_attr(spIdsHours) + '"'));
1229 code.html (code.val ().replace (/ name\="page_style" value\="(.*?)"/, ' name="page_style" value="' + esc_attr(pageStyle) + '"'));
1230 code.html (code.val ().replace (/ name\="currency_code" value\="(.*?)"/, ' name="currency_code" value="' + esc_attr(currencyCode) + '"'));
1231 code.html (code.val ().replace (/ name\="custom" value\="(.*?)"/, ' name="custom" value="<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (esc_attr ($_SERVER["HTTP_HOST"])); ?>"'));
1232 /**/
1233 code.html (code.val ().replace (/ name\="amount" value\="(.*?)"/, ' name="amount" value="' + esc_attr(regAmount) + '"'));
1234 /**/
1235 $('div#ws-plugin--s2member-sp-button-prev').html (code.val ().replace (/\<form/, '<form target="_blank"').replace (/\<\?php echo S2MEMBER_VALUE_FOR_PP_INV\(\); \?\>/g, Math.round (new Date ().getTime ()) + '~<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (esc_attr ($_SERVER["REMOTE_ADDR"])); ?>').replace (/\<\?php echo S2MEMBER_CURRENT_USER_VALUE_FOR_PP_(ON0|OS0|ON1|OS1); \?\>/g, ''));
1236 /**/
1237 alert('Your Button has been generated.\nPlease copy/paste the Shortcode Format into your WordPress® Editor.');
1238 /**/
1239 shortCode.each (function() /* Focus and select the recommended Shortcode. */
1240 {
1241 this.focus (), this.select ();
1242 });
1243 /**/
1244 return false;
1245 };
1246 /**/
1247 ws_plugin__s2member_paypalRegLinkGenerate = function() /* Handles PayPal® Link Generation. */
1248 {
1249 var level = $('select#ws-plugin--s2member-reg-link-level').val ().replace (/[^0-9]/g, '');
1250 var subscrID = $.trim ($('input#ws-plugin--s2member-reg-link-subscr-id').val ());
1251 var custom = $.trim ($('input#ws-plugin--s2member-reg-link-custom').val ());
1252 var cCaps = $.trim ($.trim ($('input#ws-plugin--s2member-reg-link-ccaps').val ()).replace (/[ \-]/g, '_').replace (/[^a-z_0-9,]/gi, '').toLowerCase ());
1253 var fixedTerm = $.trim ($('input#ws-plugin--s2member-reg-link-fixed-term').val ().replace (/[^A-Z 0-9]/gi, '').toUpperCase ());
1254 var $link = $('p#ws-plugin--s2member-reg-link'), $loading = $('img#ws-plugin--s2member-reg-link-loading');
1255 /**/
1256 var levelCcapsPer = (fixedTerm && !fixedTerm.match (/L$/)) ? level + ':' + cCaps + ':' + fixedTerm : level + ':' + cCaps;
1257 levelCcapsPer = levelCcapsPer.replace (/\:+$/g, ''); /* Clean any trailing separators from this string. */
1258 /**/
1259 if (!subscrID) /* We must have a Paid Subscr. ID value. */
1260 {
1261 alert('— Oops, a slight problem: —\n\nPaid Subscr. ID is a required value.');
1262 return false;
1263 }
1264 else if (!custom || custom.indexOf ('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq ($_SERVER["HTTP_HOST"]); ?>') !== 0)
1265 {
1266 alert('— Oops, a slight problem: —\n\nThe Custom Value MUST start with your domain name.');
1267 return false;
1268 }
1269 else if (fixedTerm && !fixedTerm.match (/^[1-9]+ (D|W|M|Y|L)$/)) /* Check format. */
1270 {
1271 alert('— Oops, a slight problem: —\n\nThe Fixed Term Length is not formatted properly.');
1272 return false;
1273 }
1274 /**/
1275 $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)
1276 {
1277 $link.show ().html ('<a href="' + esc_attr(response) + '" target="_blank" rel="external">' + esc_html(response) + '</a>'), $loading.hide ();
1278 });
1279 /**/
1280 return false;
1281 };
1282 /**/
1283 ws_plugin__s2member_paypalSpLinkGenerate = function() /* Handles PayPal® Link Generation. */
1284 {
1285 var leading = $('select#ws-plugin--s2member-sp-link-leading-id').val ().replace (/[^0-9]/g, '');
1286 var additionals = $('select#ws-plugin--s2member-sp-link-additional-ids').val () || [];
1287 var hours = $('select#ws-plugin--s2member-sp-link-hours').val ().replace (/[^0-9]/g, '');
1288 var $link = $('p#ws-plugin--s2member-sp-link'), $loading = $('img#ws-plugin--s2member-sp-link-loading');
1289 /**/
1290 if (!leading) /* Must have a Leading Post/Page ID to work with. Otherwise, Link generation will fail. */
1291 {
1292 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.');
1293 return false;
1294 }
1295 /**/
1296 for (var i = 0, ids = leading; i < additionals.length; i++)
1297 if (additionals[i] && additionals[i] !== leading)
1298 ids += ',' + additionals[i];
1299 /**/
1300 $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)
1301 {
1302 $link.show ().html ('<a href="' + esc_attr(response) + '" target="_blank" rel="external">' + esc_html(response) + '</a>'), $loading.hide ();
1303 });
1304 /**/
1305 return false;
1306 };
1307 }
1308 });