Paid Memberships Pro - Version 1.8.13.4

Version Description

  • BUG/ENHANCEMENT: Changed the pmpro_button shortcode to pmpro_checkout_button. (The old pmpro_button will also still work. checkout_button works if you have Register Helper installed.)
Download this release

Release Info

Developer strangerstudios
Plugin Icon 128x128 Paid Memberships Pro
Version 1.8.13.4
Comparing to
See all releases

Code changes from version 1.8.13.3 to 1.8.13.4

adminpages/discountcodes.php CHANGED
@@ -3,21 +3,21 @@
3
if(!function_exists("current_user_can") || (!current_user_can("manage_options") && !current_user_can("pmpro_discountcodes")))
4
{
5
die(__("You do not have permissions to perform this action.", "pmpro"));
6
- }
7
-
8
//vars
9
global $wpdb, $pmpro_currency_symbol;
10
-
11
- if(isset($_REQUEST['edit']))
12
$edit = intval($_REQUEST['edit']);
13
else
14
$edit = false;
15
-
16
if(isset($_REQUEST['delete']))
17
$delete = intval($_REQUEST['delete']);
18
else
19
$delete = false;
20
-
21
if(isset($_REQUEST['saveid']))
22
$saveid = intval($_POST['saveid']);
23
else
@@ -45,42 +45,53 @@
45
$starts = date_i18n("Y-m-d", strtotime($starts_month . "/" . $starts_day . "/" . $starts_year, current_time("timestamp")));
46
$expires = date_i18n("Y-m-d", strtotime($expires_month . "/" . $expires_day . "/" . $expires_year, current_time("timestamp")));
47
48
- //updating or new?
49
- if($saveid > 0)
50
- {
51
- $sqlQuery = "UPDATE $wpdb->pmpro_discount_codes SET code = '" . esc_sql($code) . "', starts = '" . $starts . "', expires = '" . $expires . "', uses = '" . intval($uses) . "' WHERE id = '" . $saveid . "' LIMIT 1";
52
- if($wpdb->query($sqlQuery) !== false)
53
- {
54
- $pmpro_msg = __("Discount code updated successfully.", "pmpro");
55
- $pmpro_msgt = "success";
56
- $saved = true;
57
- $edit = $saveid;
58
- }
59
- else
60
- {
61
- $pmpro_msg = __("Error updating discount code. That code may already be in use.", "pmpro");
62
- $pmpro_msgt = "error";
63
- }
64
- }
65
- else
66
- {
67
- $sqlQuery = "INSERT INTO $wpdb->pmpro_discount_codes (code, starts, expires, uses) VALUES('" . esc_sql($code) . "', '" . $starts . "', '" . $expires . "', '" . intval($uses) . "')";
68
- if($wpdb->query($sqlQuery) !== false)
69
- {
70
$pmpro_msg = __("Discount code added successfully.", "pmpro");
71
$pmpro_msgt = "success";
72
$saved = true;
73
$edit = $wpdb->insert_id;
74
- //$saveid = $edit;
75
}
76
- else
77
- {
78
- $pmpro_msg = __("Error adding discount code. That code may already be in use.", "pmpro") . $wpdb->last_error;
79
$pmpro_msgt = "error";
80
}
81
- }
82
-
83
- //now add the membership level rows
84
if($saved && $edit > 0)
85
{
86
//get the submitted values
@@ -90,25 +101,27 @@
90
else
91
$levels_a = array();
92
$initial_payment_a = $_REQUEST['initial_payment'];
93
if(!empty($_REQUEST['recurring']))
94
- $recurring_a = $_REQUEST['recurring'];
95
$billing_amount_a = $_REQUEST['billing_amount'];
96
$cycle_number_a = $_REQUEST['cycle_number'];
97
$cycle_period_a = $_REQUEST['cycle_period'];
98
$billing_limit_a = $_REQUEST['billing_limit'];
99
if(!empty($_REQUEST['custom_trial']))
100
$custom_trial_a = $_REQUEST['custom_trial'];
101
$trial_amount_a = $_REQUEST['trial_amount'];
102
- $trial_limit_a = $_REQUEST['trial_limit'];
103
if(!empty($_REQUEST['expiration']))
104
$expiration_a = $_REQUEST['expiration'];
105
$expiration_number_a = $_REQUEST['expiration_number'];
106
$expiration_period_a = $_REQUEST['expiration_period'];
107
-
108
//clear the old rows
109
- $sqlQuery = "DELETE FROM $wpdb->pmpro_discount_codes_levels WHERE code_id = '" . $edit . "'";
110
- $wpdb->query($sqlQuery);
111
-
112
//add a row for each checked level
113
if(!empty($levels_a))
114
{
@@ -117,7 +130,7 @@
117
//get the values ready
118
$n = array_search($level_id, $all_levels_a); //this is the key location of this level's values
119
$initial_payment = sanitize_text_field($initial_payment_a[$n]);
120
-
121
//is this recurring?
122
if(!empty($recurring_a))
123
{
@@ -128,14 +141,14 @@
128
}
129
else
130
$recurring = 0;
131
-
132
if(!empty($recurring))
133
{
134
$billing_amount = sanitize_text_field($billing_amount_a[$n]);
135
$cycle_number = intval($cycle_number_a[$n]);
136
$cycle_period = sanitize_text_field($cycle_period_a[$n]);
137
$billing_limit = intval($billing_limit_a[$n]);
138
-
139
//custom trial
140
if(!empty($custom_trial_a))
141
{
@@ -146,7 +159,7 @@
146
}
147
else
148
$custom_trial = 0;
149
-
150
if(!empty($custom_trial))
151
{
152
$trial_amount = sanitize_text_field($trial_amount_a[$n]);
@@ -168,7 +181,7 @@
168
$trial_amount = '';
169
$trial_limit = '';
170
}
171
-
172
if(!empty($expiration_a))
173
{
174
if(in_array($level_id, $expiration_a))
@@ -178,7 +191,7 @@
178
}
179
else
180
$expiration = 0;
181
-
182
if(!empty($expiration))
183
{
184
$expiration_number = intval($expiration_number_a[$n]);
@@ -189,55 +202,84 @@
189
$expiration_number = '';
190
$expiration_period = 'Month';
191
}
192
193
//okay, do the insert
194
- $sqlQuery = "INSERT INTO $wpdb->pmpro_discount_codes_levels (code_id, level_id, initial_payment, billing_amount, cycle_number, cycle_period, billing_limit, trial_amount, trial_limit, expiration_number, expiration_period) VALUES('" . esc_sql($edit) . "', '" . esc_sql($level_id) . "', '" . (double)esc_sql($initial_payment) . "', '" . (double)esc_sql($billing_amount) . "', '" . intval(esc_sql($cycle_number)) . "', '" . esc_sql($cycle_period) . "', '" . intval(esc_sql($billing_limit)) . "', '" . (double)esc_sql($trial_amount) . "', '" . intval(esc_sql($trial_limit)) . "', '" . intval(esc_sql($expiration_number)) . "', '" . esc_sql($expiration_period) . "')";
195
196
- if($wpdb->query($sqlQuery) !== false)
197
{
198
- //okay
199
- do_action("pmpro_save_discount_code_level", $edit, $level_id);
200
}
201
else
202
- {
203
- $level_errors[] = sprintf(__("Error saving values for the %s level.", "pmpro"), $wpdb->get_var("SELECT name FROM $wpdb->pmpro_membership_levels WHERE id = '" . $level_id . "' LIMIT 1"));
204
}
205
}
206
}
207
-
208
//errors?
209
if(!empty($level_errors))
210
- {
211
$pmpro_msg = __("There were errors updating the level values: ", "pmpro") . implode(" ", $level_errors);
212
- $pmpro_msgt = "error";
213
}
214
else
215
{
216
//all good. set edit = NULL so we go back to the overview page
217
$edit = NULL;
218
-
219
do_action("pmpro_save_discount_code", $saveid);
220
}
221
}
222
}
223
-
224
//are we deleting?
225
if(!empty($delete))
226
{
227
//is this a code?
228
- $code = $wpdb->get_var("SELECT code FROM $wpdb->pmpro_discount_codes WHERE id = '" . $delete . "' LIMIT 1");
229
if(!empty($code))
230
{
231
//action
232
do_action("pmpro_delete_discount_code", $delete);
233
-
234
//delete the code levels
235
- $r1 = $wpdb->query("DELETE FROM $wpdb->pmpro_discount_codes_levels WHERE code_id = '" . $delete . "'");
236
-
237
if($r1 !== false)
238
{
239
//delete the code
240
- $r2 = $wpdb->query("DELETE FROM $wpdb->pmpro_discount_codes WHERE id = '" . $delete . "' LIMIT 1");
241
242
if($r2 !== false)
243
{
@@ -262,12 +304,12 @@
262
$pmpro_msgt = "error";
263
}
264
}
265
-
266
- require_once(dirname(__FILE__) . "/admin_header.php");
267
?>
268
-
269
<?php if($edit) { ?>
270
-
271
<h2>
272
<?php
273
if($edit > 0)
@@ -276,24 +318,45 @@
276
echo __("Add New Discount Code", "pmpro");
277
?>
278
</h2>
279
-
280
<?php if(!empty($pmpro_msg)) { ?>
281
<div id="message" class="<?php if($pmpro_msgt == "success") echo "updated fade"; else echo "error"; ?>"><p><?php echo $pmpro_msg?></p></div>
282
<?php } ?>
283
-
284
<div>
285
<?php
286
// get the code...
287
if($edit > 0)
288
{
289
- $code = $wpdb->get_row("SELECT *, UNIX_TIMESTAMP(starts) as starts, UNIX_TIMESTAMP(expires) as expires FROM $wpdb->pmpro_discount_codes WHERE id = '" . $edit . "' LIMIT 1", OBJECT);
290
- $uses = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->pmpro_discount_codes_uses WHERE code_id = '" . $code->id . "'");
291
- $levels = $wpdb->get_results("SELECT l.id, l.name, cl.initial_payment, cl.billing_amount, cl.cycle_number, cl.cycle_period, cl.billing_limit, cl.trial_amount, cl.trial_limit FROM $wpdb->pmpro_membership_levels l LEFT JOIN $wpdb->pmpro_discount_codes_levels cl ON l.id = cl.level_id WHERE cl.code_id = '" . $code->code . "'");
292
$temp_id = $code->id;
293
}
294
- elseif(!empty($copy) && $copy > 0)
295
- {
296
- $code = $wpdb->get_row("SELECT *, UNIX_TIMESTAMP(starts) as starts, UNIX_TIMESTAMP(expires) as expires FROM $wpdb->pmpro_discount_codes WHERE id = '" . $copy . "' LIMIT 1", OBJECT);
297
$temp_id = $level->id;
298
$level->id = NULL;
299
}
@@ -306,7 +369,7 @@
306
{
307
$code = new stdClass();
308
$code->code = pmpro_getDiscountCode();
309
- }
310
?>
311
<form action="" method="post">
312
<input name="saveid" type="hidden" value="<?php echo $edit?>" />
@@ -315,13 +378,13 @@
315
<tr>
316
<th scope="row" valign="top"><label><?php _e('ID', 'pmpro');?>:</label></th>
317
<td class="pmpro_lite"><?php if(!empty($code->id)) echo $code->id; else echo __("This will be generated when you save.", "pmpro");?></td>
318
- </tr>
319
-
320
<tr>
321
<th scope="row" valign="top"><label for="code"><?php _e('Code', 'pmpro');?>:</label></th>
322
<td><input name="code" type="text" size="20" value="<?php echo str_replace("\"", "&quot;", stripslashes($code->code))?>" /></td>
323
</tr>
324
-
325
<?php
326
//some vars for the dates
327
$current_day = date_i18n("j");
@@ -333,7 +396,7 @@
333
$selected_expires_day = date_i18n("j", $code->expires);
334
else
335
$selected_expires_day = $current_day;
336
-
337
$current_month = date_i18n("M");
338
if(!empty($code->starts))
339
$selected_starts_month = date_i18n("m", $code->starts);
@@ -342,9 +405,9 @@
342
if(!empty($code->expires))
343
$selected_expires_month = date_i18n("m", $code->expires);
344
else
345
- $selected_expires_month = date_i18n("m");
346
-
347
- $current_year = date_i18n("Y");
348
if(!empty($code->starts))
349
$selected_starts_year = date_i18n("Y", $code->starts);
350
else
@@ -354,12 +417,12 @@
354
else
355
$selected_expires_year = (int)$current_year + 1;
356
?>
357
-
358
<tr>
359
<th scope="row" valign="top"><label for="starts"><?php _e('Start Date', 'pmpro');?>:</label></th>
360
<td>
361
<select name="starts_month">
362
- <?php
363
for($i = 1; $i < 13; $i++)
364
{
365
?>
@@ -372,12 +435,12 @@
372
<input name="starts_year" type="text" size="4" value="<?php echo $selected_starts_year?>" />
373
</td>
374
</tr>
375
-
376
<tr>
377
<th scope="row" valign="top"><label for="expires"><?php _e('Expiration Date', 'pmpro');?>:</label></th>
378
<td>
379
<select name="expires_month">
380
- <?php
381
for($i = 1; $i < 13; $i++)
382
{
383
?>
@@ -390,7 +453,7 @@
390
<input name="expires_year" type="text" size="4" value="<?php echo $selected_expires_year?>" />
391
</td>
392
</tr>
393
-
394
<tr>
395
<th scope="row" valign="top"><label for="uses"><?php _e('Uses', 'pmpro');?>:</label></th>
396
<td>
@@ -398,14 +461,14 @@
398
<small class="pmpro_lite"><?php _e('Leave blank for unlimited uses.', 'pmpro');?></small>
399
</td>
400
</tr>
401
-
402
</tbody>
403
</table>
404
-
405
<?php do_action("pmpro_discount_code_after_settings", $edit); ?>
406
-
407
<h3><?php _e('Which Levels Will This Code Apply To?', 'pmpro'); ?></h3>
408
-
409
<div class="pmpro_discount_levels">
410
<?php
411
$levels = $wpdb->get_results("SELECT * FROM $wpdb->pmpro_membership_levels");
@@ -414,9 +477,17 @@
414
//if this level is already managed for this discount code, use the code values
415
if($edit > 0)
416
{
417
- $code_level = $wpdb->get_row("SELECT l.id, cl.*, l.name, l.description, l.allow_signups FROM $wpdb->pmpro_discount_codes_levels cl LEFT JOIN $wpdb->pmpro_membership_levels l ON cl.level_id = l.id WHERE cl.code_id = '" . $edit . "' AND cl.level_id = '" . $level->id . "' LIMIT 1");
418
if($code_level)
419
- {
420
$level = $code_level;
421
$level->checked = true;
422
}
@@ -424,7 +495,7 @@
424
$level_checked = false;
425
}
426
else
427
- $level_checked = false;
428
?>
429
<div>
430
<input type="hidden" name="all_levels[]" value="<?php echo $level->id?>" />
@@ -440,7 +511,7 @@
440
if(pmpro_getCurrencyPosition() == "left")
441
echo $pmpro_currency_symbol;
442
?>
443
- <input name="initial_payment[]" type="text" size="20" value="<?php echo str_replace("\"", "&quot;", stripslashes($level->initial_payment))?>" />
444
<?php
445
if(pmpro_getCurrencyPosition() == "right")
446
echo $pmpro_currency_symbol;
@@ -448,12 +519,12 @@
448
<small><?php _e('The initial amount collected at registration.', 'pmpro');?></small>
449
</td>
450
</tr>
451
-
452
<tr>
453
<th scope="row" valign="top"><label><?php _e('Recurring Subscription', 'pmpro');?>:</label></th>
454
<td><input class="recurring_checkbox" id="recurring_<?php echo $level->id;?>" name="recurring[]" type="checkbox" value="<?php echo $level->id?>" <?php if(pmpro_isLevelRecurring($level)) { echo "checked='checked'"; } ?> onclick="if(jQuery(this).attr('checked')) { jQuery(this).parent().parent().siblings('.recurring_info').show(); if(!jQuery('#custom_trial_<?php echo $level->id?>').is(':checked')) jQuery(this).parent().parent().siblings('.trial_info').hide();} else jQuery(this).parent().parent().siblings('.recurring_info').hide();" /> <label for="recurring_<?php echo $level->id;?>"><?php _e('Check if this level has a recurring subscription payment.', 'pmpro');?></label></td>
455
</tr>
456
-
457
<tr class="recurring_info" <?php if(!pmpro_isLevelRecurring($level)) {?>style="display: none;"<?php } ?>>
458
<th scope="row" valign="top"><label for="billing_amount"><?php _e('Billing Amount', 'pmpro');?>:</label></th>
459
<td>
@@ -461,7 +532,7 @@
461
if(pmpro_getCurrencyPosition() == "left")
462
echo $pmpro_currency_symbol;
463
?>
464
- <input name="billing_amount[]" type="text" size="20" value="<?php echo str_replace("\"", "&quot;", stripslashes($level->billing_amount))?>" />
465
<?php
466
if(pmpro_getCurrencyPosition() == "right")
467
echo $pmpro_currency_symbol;
@@ -478,23 +549,23 @@
478
}
479
?>
480
</select>
481
- <br /><small><?php _e('The amount to be billed one cycle after the initial payment.', 'pmpro');?></small>
482
</td>
483
- </tr>
484
-
485
<tr class="recurring_info" <?php if(!pmpro_isLevelRecurring($level)) {?>style="display: none;"<?php } ?>>
486
<th scope="row" valign="top"><label for="billing_limit"><?php _e('Billing Cycle Limit', 'pmpro');?>:</label></th>
487
<td>
488
<input name="billing_limit[]" type="text" size="20" value="<?php echo $level->billing_limit?>" />
489
<br /><small><?php _e('The <strong>total</strong> number of recurring billing cycles for this level, including the trial period (if applicable) but not including the initial payment. Set to zero if membership is indefinite.', 'pmpro');?></small>
490
</td>
491
- </tr>
492
-
493
<tr class="recurring_info" <?php if (!pmpro_isLevelRecurring($level)) echo "style='display:none;'";?>>
494
<th scope="row" valign="top"><label><?php _e('Custom Trial', 'pmpro');?>:</label></th>
495
<td><input id="custom_trial_<?php echo $level->id?>" id="custom_trial_<?php echo $level->id;?>" name="custom_trial[]" type="checkbox" value="<?php echo $level->id?>" <?php if ( pmpro_isLevelTrial($level) ) { echo "checked='checked'"; } ?> onclick="if(jQuery(this).attr('checked')) jQuery(this).parent().parent().siblings('.trial_info').show(); else jQuery(this).parent().parent().siblings('.trial_info').hide();" /> <label for="custom_trial_<?php echo $level->id;?>"><?php _e('Check to add a custom trial period.', 'pmpro');?></label></td>
496
</tr>
497
-
498
<tr class="trial_info recurring_info" <?php if (!pmpro_isLevelTrial($level)) echo "style='display:none;'";?>>
499
<th scope="row" valign="top"><label for="trial_amount"><?php _e('Trial Billing Amount', 'pmpro');?>:</label></th>
500
<td>
@@ -509,18 +580,18 @@
509
?>
510
<small><?php _e('for the first', 'pmpro');?></small>
511
<input name="trial_limit[]" type="text" size="10" value="<?php echo str_replace("\"", "&quot;", stripslashes($level->trial_limit))?>" />
512
- <small><?php _e('subscription payments', 'pmpro');?>.</small>
513
</td>
514
</tr>
515
-
516
<tr>
517
<th scope="row" valign="top"><label><?php _e('Membership Expiration', 'pmpro');?>:</label></th>
518
<td><input id="expiration_<?php echo $level->id;?>" name="expiration[]" type="checkbox" value="<?php echo $level->id?>" <?php if(pmpro_isLevelExpiring($level)) { echo "checked='checked'"; } ?> onclick="if(jQuery(this).is(':checked')) { jQuery(this).parent().parent().siblings('.expiration_info').show(); } else { jQuery(this).parent().parent().siblings('.expiration_info').hide();}" /> <label for="expiration_<?php echo $level->id;?>"><?php _e('Check this to set when membership access expires.', 'pmpro');?></label></td>
519
</tr>
520
-
521
<tr class="expiration_info" <?php if(!pmpro_isLevelExpiring($level)) {?>style="display: none;"<?php } ?>>
522
<th scope="row" valign="top"><label for="billing_amount"><?php _e('Expires In', 'pmpro');?>:</label></th>
523
- <td>
524
<input id="expiration_number" name="expiration_number[]" type="text" size="10" value="<?php echo str_replace("\"", "&quot;", stripslashes($level->expiration_number))?>" />
525
<select id="expiration_period" name="expiration_period[]">
526
<?php
@@ -532,72 +603,72 @@
532
}
533
?>
534
</select>
535
- <br /><small><?php _e('Set the duration of membership access. Note that the any future payments (recurring subscription, if any) will be cancelled when the membership expires.', 'pmpro');?></small>
536
</td>
537
- </tr>
538
</tbody>
539
</table>
540
-
541
<?php do_action("pmpro_discount_code_after_level_settings", $edit, $level); ?>
542
-
543
- </div>
544
</div>
545
- <script>
546
-
547
</script>
548
<?php
549
}
550
?>
551
</div>
552
-
553
<p class="submit topborder">
554
- <input name="save" type="submit" class="button button-primary" value="Save Code" />
555
<input name="cancel" type="button" class="button button-secondary" value="Cancel" onclick="location.href='<?php echo get_admin_url(NULL, '/admin.php?page=pmpro-discountcodes')?>';" />
556
</p>
557
</form>
558
</div>
559
-
560
- <?php } else { ?>
561
-
562
<h2>
563
<?php _e('Memberships Discount Codes', 'pmpro');?>
564
<a href="admin.php?page=pmpro-discountcodes&edit=-1" class="add-new-h2"><?php _e('Add New Discount Code', 'pmpro');?></a>
565
- </h2>
566
-
567
<?php if(!empty($pmpro_msg)) { ?>
568
<div id="message" class="<?php if($pmpro_msgt == "success") echo "updated fade"; else echo "error"; ?>"><p><?php echo $pmpro_msg?></p></div>
569
<?php } ?>
570
-
571
- <form id="posts-filter" method="get" action="">
572
<p class="search-box">
573
<label class="screen-reader-text" for="post-search-input"><?php _e('Search Discount Codes', 'pmpro');?>:</label>
574
<input type="hidden" name="page" value="pmpro-discountcodes" />
575
<input id="post-search-input" type="text" value="<?php if(!empty($s)) echo $s;?>" name="s" size="30" />
576
<input class="button" type="submit" value="<?php _e('Search', 'pmpro');?>" id="search-submit "/>
577
- </p>
578
- </form>
579
-
580
<br class="clear" />
581
<?php
582
$sqlQuery = "SELECT *, UNIX_TIMESTAMP(starts) as starts, UNIX_TIMESTAMP(expires) as expires FROM $wpdb->pmpro_discount_codes ";
583
if(!empty($s))
584
$sqlQuery .= "WHERE code LIKE '%$s%' ";
585
- $sqlQuery .= "ORDER BY id ASC";
586
-
587
- $codes = $wpdb->get_results($sqlQuery, OBJECT);
588
- ?>
589
<table class="widefat">
590
<thead>
591
<tr>
592
<th><?php _e('ID', 'pmpro');?></th>
593
<th><?php _e('Code', 'pmpro');?></th>
594
<th><?php _e('Starts', 'pmpro');?></th>
595
- <th><?php _e('Expires', 'pmpro');?></th>
596
<th><?php _e('Uses', 'pmpro');?></th>
597
<th><?php _e('Levels', 'pmpro');?></th>
598
<?php do_action("pmpro_discountcodes_extra_cols_header", $codes);?>
599
- <th></th>
600
- <th></th>
601
</tr>
602
</thead>
603
<tbody>
@@ -605,7 +676,7 @@
605
if(!$codes)
606
{
607
?>
608
- <tr><td colspan="7" class="pmpro_pad20">
609
<p><?php _e('Discount codes allow you to offer your memberships at discounted prices to select customers.', 'pmpro');?> <a href="admin.php?page=pmpro-discountcodes&edit=-1"><?php _e('Create your first discount code now', 'pmpro');?></a>.</p>
610
</td></tr>
611
<?php
@@ -629,7 +700,7 @@
629
</td>
630
<td>
631
<?php
632
- $uses = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->pmpro_discount_codes_uses WHERE code_id = '" . $code->id . "'");
633
if($code->uses > 0)
634
echo "<strong>" . (int)$uses . "</strong>/" . $code->uses;
635
else
@@ -637,25 +708,32 @@
637
?>
638
</td>
639
<td>
640
- <?php
641
- $sqlQuery = "SELECT l.id, l.name FROM $wpdb->pmpro_membership_levels l LEFT JOIN $wpdb->pmpro_discount_codes_levels cl ON l.id = cl.level_id WHERE cl.code_id = '" . $code->id . "'";
642
$levels = $wpdb->get_results($sqlQuery);
643
-
644
$level_names = array();
645
foreach($levels as $level)
646
$level_names[] = "<a target=\"_blank\" href=\"" . pmpro_url("checkout", "?level=" . $level->id . "&discount_code=" . $code->code) . "\">" . $level->name . "</a>";
647
if($level_names)
648
- echo implode(", ", $level_names);
649
else
650
echo "None";
651
?>
652
</td>
653
<?php do_action("pmpro_discountcodes_extra_cols_body", $code);?>
654
<td>
655
- <a href="?page=pmpro-discountcodes&edit=<?php echo $code->id?>"><?php _e('edit', 'pmpro');?></a>
656
</td>
657
<td>
658
- <a href="javascript:askfirst('<?php echo str_replace("'", "\'", sprintf(__('Are you sure you want to delete the %s discount code? The subscriptions for existing users will not change, but new users will not be able to use this code anymore.', 'pmpro'), $code->code));?>', '?page=pmpro-discountcodes&delete=<?php echo $code->id?>'); void(0);"><?php _e('delete', 'pmpro');?></a>
659
</td>
660
</tr>
661
<?php
@@ -664,9 +742,9 @@
664
?>
665
</tbody>
666
</table>
667
-
668
<?php } ?>
669
-
670
<?php
671
- require_once(dirname(__FILE__) . "/admin_footer.php");
672
?>
3
if(!function_exists("current_user_can") || (!current_user_can("manage_options") && !current_user_can("pmpro_discountcodes")))
4
{
5
die(__("You do not have permissions to perform this action.", "pmpro"));
6
+ }
7
+
8
//vars
9
global $wpdb, $pmpro_currency_symbol;
10
+
11
+ if(isset($_REQUEST['edit']))
12
$edit = intval($_REQUEST['edit']);
13
else
14
$edit = false;
15
+
16
if(isset($_REQUEST['delete']))
17
$delete = intval($_REQUEST['delete']);
18
else
19
$delete = false;
20
+
21
if(isset($_REQUEST['saveid']))
22
$saveid = intval($_POST['saveid']);
23
else
45
$starts = date_i18n("Y-m-d", strtotime($starts_month . "/" . $starts_day . "/" . $starts_year, current_time("timestamp")));
46
$expires = date_i18n("Y-m-d", strtotime($expires_month . "/" . $expires_day . "/" . $expires_year, current_time("timestamp")));
47
48
+ //insert/update/replace discount code
49
+ $wpdb->replace(
50
+ $wpdb->pmpro_discount_codes,
51
+ array(
52
+ 'id'=>max($saveid, 0),
53
+ 'code' => $code,
54
+ 'starts' => $starts,
55
+ 'expires' => $expires,
56
+ 'uses' => $uses
57
+ ),
58
+ array(
59
+ '%d',
60
+ '%s',
61
+ '%s',
62
+ '%s',
63
+ '%d'
64
+ )
65
+ );
66
+
67
+ //check for errors and show appropriate message if inserted or updated
68
+ if(empty($wpdb->last_error)) {
69
+ if($saveid < 1) {
70
+ //insert
71
$pmpro_msg = __("Discount code added successfully.", "pmpro");
72
$pmpro_msgt = "success";
73
$saved = true;
74
$edit = $wpdb->insert_id;
75
+ } else {
76
+ //updated
77
+ $pmpro_msg = __("Discount code updated successfully.", "pmpro");
78
+ $pmpro_msgt = "success";
79
+ $saved = true;
80
+ $edit = $saveid;
81
}
82
+ } else {
83
+ if($saveid < 1) {
84
+ //error inserting
85
+ $pmpro_msg = __("Error adding discount code. That code may already be in use.", "pmpro") . $wpdb->last_error;
86
+ $pmpro_msgt = "error";
87
+ } else {
88
+ //error updating
89
+ $pmpro_msg = __("Error updating discount code. That code may already be in use.", "pmpro");
90
$pmpro_msgt = "error";
91
}
92
+ }
93
+
94
+ //now add the membership level rows
95
if($saved && $edit > 0)
96
{
97
//get the submitted values
101
else
102
$levels_a = array();
103
$initial_payment_a = $_REQUEST['initial_payment'];
104
+
105
if(!empty($_REQUEST['recurring']))
106
+ $recurring_a = $_REQUEST['recurring'];
107
$billing_amount_a = $_REQUEST['billing_amount'];
108
$cycle_number_a = $_REQUEST['cycle_number'];
109
$cycle_period_a = $_REQUEST['cycle_period'];
110
$billing_limit_a = $_REQUEST['billing_limit'];
111
+
112
if(!empty($_REQUEST['custom_trial']))
113
$custom_trial_a = $_REQUEST['custom_trial'];
114
$trial_amount_a = $_REQUEST['trial_amount'];
115
+ $trial_limit_a = $_REQUEST['trial_limit'];
116
+
117
if(!empty($_REQUEST['expiration']))
118
$expiration_a = $_REQUEST['expiration'];
119
$expiration_number_a = $_REQUEST['expiration_number'];
120
$expiration_period_a = $_REQUEST['expiration_period'];
121
+
122
//clear the old rows
123
+ $wpdb->delete($wpdb->pmpro_discount_codes_levels, array('code_id' => $edit), array('%d'));
124
+
125
//add a row for each checked level
126
if(!empty($levels_a))
127
{
130
//get the values ready
131
$n = array_search($level_id, $all_levels_a); //this is the key location of this level's values
132
$initial_payment = sanitize_text_field($initial_payment_a[$n]);
133
+
134
//is this recurring?
135
if(!empty($recurring_a))
136
{
141
}
142
else
143
$recurring = 0;
144
+
145
if(!empty($recurring))
146
{
147
$billing_amount = sanitize_text_field($billing_amount_a[$n]);
148
$cycle_number = intval($cycle_number_a[$n]);
149
$cycle_period = sanitize_text_field($cycle_period_a[$n]);
150
$billing_limit = intval($billing_limit_a[$n]);
151
+
152
//custom trial
153
if(!empty($custom_trial_a))
154
{
159
}
160
else
161
$custom_trial = 0;
162
+
163
if(!empty($custom_trial))
164
{
165
$trial_amount = sanitize_text_field($trial_amount_a[$n]);
181
$trial_amount = '';
182
$trial_limit = '';
183
}
184
+
185
if(!empty($expiration_a))
186
{
187
if(in_array($level_id, $expiration_a))
191
}
192
else
193
$expiration = 0;
194
+
195
if(!empty($expiration))
196
{
197
$expiration_number = intval($expiration_number_a[$n]);
202
$expiration_number = '';
203
$expiration_period = 'Month';
204
}
205
+
206
+
207
208
//okay, do the insert
209
+ $wpdb->insert(
210
+ $wpdb->pmpro_discount_codes_levels,
211
+ array(
212
+ 'code_id' => $edit,
213
+ 'level_id' => $level_id,
214
+ 'initial_payment' => $initial_payment,
215
+ 'billing_amount' => $billing_amount,
216
+ 'cycle_number' => $cycle_number,
217
+ 'cycle_period' => $cycle_period,
218
+ 'billing_limit' => $billing_limit,
219
+ 'trial_amount' => $trial_amount,
220
+ 'expiration_number' => $expiration_number,
221
+ 'expiration_period' => $expiration_period
222
+ ),
223
+ array(
224
+ '%d',
225
+ '%d',
226
+ '%f',
227
+ '%f',
228
+ '%d',
229
+ '%s',
230
+ '%d',
231
+ '%f',
232
+ '%d',
233
+ '%s'
234
+ )
235
+ );
236
237
+ if(empty($wpdb->last_error))
238
{
239
+ //okay
240
+ do_action("pmpro_save_discount_code_level", $edit, $level_id);
241
}
242
else
243
+ {
244
+ $level = pmpro_getLevel($level_id);
245
+ $level_errors[] = sprintf(__("Error saving values for the %s level.", "pmpro"), $level->name);
246
}
247
}
248
}
249
+
250
//errors?
251
if(!empty($level_errors))
252
+ {
253
$pmpro_msg = __("There were errors updating the level values: ", "pmpro") . implode(" ", $level_errors);
254
+ $pmpro_msgt = "error";
255
}
256
else
257
{
258
//all good. set edit = NULL so we go back to the overview page
259
$edit = NULL;
260
+
261
do_action("pmpro_save_discount_code", $saveid);
262
}
263
}
264
}
265
+
266
//are we deleting?
267
if(!empty($delete))
268
{
269
//is this a code?
270
+ $code = $wpdb->get_var( $wpdb->prepare( "SELECT code FROM $wpdb->pmpro_discount_codes WHERE id = %d LIMIT 1", $delete ) );
271
if(!empty($code))
272
{
273
//action
274
do_action("pmpro_delete_discount_code", $delete);
275
+
276
//delete the code levels
277
+ $r1 = $wpdb->delete($wpdb->pmpro_discount_codes_levels, array('code_id'=>$delete), array('%d'));
278
+
279
if($r1 !== false)
280
{
281
//delete the code
282
+ $r2 = $wpdb->delete($wpdb->pmpro_discount_codes, array('id'=>$delete), array('%d'));
283
284
if($r2 !== false)
285
{
304
$pmpro_msgt = "error";
305
}
306
}
307
+
308
+ require_once(dirname(__FILE__) . "/admin_header.php");
309
?>
310
+
311
<?php if($edit) { ?>
312
+
313
<h2>
314
<?php
315
if($edit > 0)
318
echo __("Add New Discount Code", "pmpro");
319
?>
320
</h2>
321
+
322
<?php if(!empty($pmpro_msg)) { ?>
323
<div id="message" class="<?php if($pmpro_msgt == "success") echo "updated fade"; else echo "error"; ?>"><p><?php echo $pmpro_msg?></p></div>
324
<?php } ?>
325
+
326
<div>
327
<?php
328
// get the code...
329
if($edit > 0)
330
{
331
+ $code = $wpdb->get_row(
332
+ $wpdb->prepare("
333
+ SELECT *, UNIX_TIMESTAMP(starts) as starts, UNIX_TIMESTAMP(expires) as expires
334
+ FROM $wpdb->pmpro_discount_codes
335
+ WHERE id = %d LIMIT 1",
336
+ $edit ),
337
+ OBJECT
338
+ );
339
+
340
+ $uses = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->pmpro_discount_codes_uses WHERE code_id = %d", $code->id ) );
341
+ $levels = $wpdb->get_results( $wpdb->prepare("
342
+ SELECT l.id, l.name, cl.initial_payment, cl.billing_amount, cl.cycle_number, cl.cycle_period, cl.billing_limit, cl.trial_amount, cl.trial_limit
343
+ FROM $wpdb->pmpro_membership_levels l
344
+ LEFT JOIN $wpdb->pmpro_discount_codes_levels cl
345
+ ON l.id = cl.level_id
346
+ WHERE cl.code_id = %s",
347
+ $code->code
348
+ ) );
349
$temp_id = $code->id;
350
}
351
+ elseif(!empty($copy) && $copy > 0)
352
+ {
353
+ $code = $wpdb->get_row( $wpdb->prepare("
354
+ SELECT *, UNIX_TIMESTAMP(starts) as starts, UNIX_TIMESTAMP(expires) as expires
355
+ FROM $wpdb->pmpro_discount_codes
356
+ WHERE id = %d LIMIT 1",
357
+ $copy ),
358
+ OBJECT
359
+ );
360
$temp_id = $level->id;
361
$level->id = NULL;
362
}
369
{
370
$code = new stdClass();
371
$code->code = pmpro_getDiscountCode();
372
+ }
373
?>
374
<form action="" method="post">
375
<input name="saveid" type="hidden" value="<?php echo $edit?>" />
378
<tr>
379
<th scope="row" valign="top"><label><?php _e('ID', 'pmpro');?>:</label></th>
380
<td class="pmpro_lite"><?php if(!empty($code->id)) echo $code->id; else echo __("This will be generated when you save.", "pmpro");?></td>
381
+ </tr>
382
+
383
<tr>
384
<th scope="row" valign="top"><label for="code"><?php _e('Code', 'pmpro');?>:</label></th>
385
<td><input name="code" type="text" size="20" value="<?php echo str_replace("\"", "&quot;", stripslashes($code->code))?>" /></td>
386
</tr>
387
+
388
<?php
389
//some vars for the dates
390
$current_day = date_i18n("j");
396
$selected_expires_day = date_i18n("j", $code->expires);
397
else
398
$selected_expires_day = $current_day;
399
+
400
$current_month = date_i18n("M");
401
if(!empty($code->starts))
402
$selected_starts_month = date_i18n("m", $code->starts);
405
if(!empty($code->expires))
406
$selected_expires_month = date_i18n("m", $code->expires);
407
else
408
+ $selected_expires_month = date_i18n("m");
409
+
410
+ $current_year = date_i18n("Y");
411
if(!empty($code->starts))
412
$selected_starts_year = date_i18n("Y", $code->starts);
413
else
417
else
418
$selected_expires_year = (int)$current_year + 1;
419
?>
420
+
421
<tr>
422
<th scope="row" valign="top"><label for="starts"><?php _e('Start Date', 'pmpro');?>:</label></th>
423
<td>
424
<select name="starts_month">
425
+ <?php
426
for($i = 1; $i < 13; $i++)
427
{
428
?>
435
<input name="starts_year" type="text" size="4" value="<?php echo $selected_starts_year?>" />
436
</td>
437
</tr>
438
+
439
<tr>
440
<th scope="row" valign="top"><label for="expires"><?php _e('Expiration Date', 'pmpro');?>:</label></th>
441
<td>
442
<select name="expires_month">
443
+ <?php
444
for($i = 1; $i < 13; $i++)
445
{
446
?>
453
<input name="expires_year" type="text" size="4" value="<?php echo $selected_expires_year?>" />
454
</td>
455
</tr>
456
+
457
<tr>
458
<th scope="row" valign="top"><label for="uses"><?php _e('Uses', 'pmpro');?>:</label></th>
459
<td>
461
<small class="pmpro_lite"><?php _e('Leave blank for unlimited uses.', 'pmpro');?></small>
462
</td>
463
</tr>
464
+
465
</tbody>
466
</table>
467
+
468
<?php do_action("pmpro_discount_code_after_settings", $edit); ?>
469
+
470
<h3><?php _e('Which Levels Will This Code Apply To?', 'pmpro'); ?></h3>
471
+
472
<div class="pmpro_discount_levels">
473
<?php
474
$levels = $wpdb->get_results("SELECT * FROM $wpdb->pmpro_membership_levels");
477
//if this level is already managed for this discount code, use the code values
478
if($edit > 0)
479
{
480
+ $code_level = $wpdb->get_row( $wpdb->prepare("
481
+ SELECT l.id, cl.*, l.name, l.description, l.allow_signups
482
+ FROM $wpdb->pmpro_discount_codes_levels cl
483
+ LEFT JOIN $wpdb->pmpro_membership_levels l
484
+ ON cl.level_id = l.id
485
+ WHERE cl.code_id = %d AND cl.level_id = %d LIMIT 1",
486
+ $edit,
487
+ $level->id )
488
+ );
489
if($code_level)
490
+ {
491
$level = $code_level;
492
$level->checked = true;
493
}
495
$level_checked = false;
496
}
497
else
498
+ $level_checked = false;
499
?>
500
<div>
501
<input type="hidden" name="all_levels[]" value="<?php echo $level->id?>" />
511
if(pmpro_getCurrencyPosition() == "left")
512
echo $pmpro_currency_symbol;
513
?>
514
+ <input name="initial_payment[]" type="text" size="20" value="<?php echo str_replace("\"", "&quot;", stripslashes($level->initial_payment))?>" />
515
<?php
516
if(pmpro_getCurrencyPosition() == "right")
517
echo $pmpro_currency_symbol;
519
<small><?php _e('The initial amount collected at registration.', 'pmpro');?></small>
520
</td>
521
</tr>
522
+
523
<tr>
524
<th scope="row" valign="top"><label><?php _e('Recurring Subscription', 'pmpro');?>:</label></th>
525
<td><input class="recurring_checkbox" id="recurring_<?php echo $level->id;?>" name="recurring[]" type="checkbox" value="<?php echo $level->id?>" <?php if(pmpro_isLevelRecurring($level)) { echo "checked='checked'"; } ?> onclick="if(jQuery(this).attr('checked')) { jQuery(this).parent().parent().siblings('.recurring_info').show(); if(!jQuery('#custom_trial_<?php echo $level->id?>').is(':checked')) jQuery(this).parent().parent().siblings('.trial_info').hide();} else jQuery(this).parent().parent().siblings('.recurring_info').hide();" /> <label for="recurring_<?php echo $level->id;?>"><?php _e('Check if this level has a recurring subscription payment.', 'pmpro');?></label></td>
526
</tr>
527
+
528
<tr class="recurring_info" <?php if(!pmpro_isLevelRecurring($level)) {?>style="display: none;"<?php } ?>>
529
<th scope="row" valign="top"><label for="billing_amount"><?php _e('Billing Amount', 'pmpro');?>:</label></th>
530
<td>
532
if(pmpro_getCurrencyPosition() == "left")
533
echo $pmpro_currency_symbol;
534
?>
535
+ <input name="billing_amount[]" type="text" size="20" value="<?php echo str_replace("\"", "&quot;", stripslashes($level->billing_amount))?>" />
536
<?php
537
if(pmpro_getCurrencyPosition() == "right")
538
echo $pmpro_currency_symbol;
549
}
550
?>
551
</select>
552
+ <br /><small><?php _e('The amount to be billed one cycle after the initial payment.', 'pmpro');?></small>
553
</td>
554
+ </tr>
555
+
556
<tr class="recurring_info" <?php if(!pmpro_isLevelRecurring($level)) {?>style="display: none;"<?php } ?>>
557
<th scope="row" valign="top"><label for="billing_limit"><?php _e('Billing Cycle Limit', 'pmpro');?>:</label></th>
558
<td>
559
<input name="billing_limit[]" type="text" size="20" value="<?php echo $level->billing_limit?>" />
560
<br /><small><?php _e('The <strong>total</strong> number of recurring billing cycles for this level, including the trial period (if applicable) but not including the initial payment. Set to zero if membership is indefinite.', 'pmpro');?></small>
561
</td>
562
+ </tr>
563
+
564
<tr class="recurring_info" <?php if (!pmpro_isLevelRecurring($level)) echo "style='display:none;'";?>>
565
<th scope="row" valign="top"><label><?php _e('Custom Trial', 'pmpro');?>:</label></th>
566
<td><input id="custom_trial_<?php echo $level->id?>" id="custom_trial_<?php echo $level->id;?>" name="custom_trial[]" type="checkbox" value="<?php echo $level->id?>" <?php if ( pmpro_isLevelTrial($level) ) { echo "checked='checked'"; } ?> onclick="if(jQuery(this).attr('checked')) jQuery(this).parent().parent().siblings('.trial_info').show(); else jQuery(this).parent().parent().siblings('.trial_info').hide();" /> <label for="custom_trial_<?php echo $level->id;?>"><?php _e('Check to add a custom trial period.', 'pmpro');?></label></td>
567
</tr>
568
+
569
<tr class="trial_info recurring_info" <?php if (!pmpro_isLevelTrial($level)) echo "style='display:none;'";?>>
570
<th scope="row" valign="top"><label for="trial_amount"><?php _e('Trial Billing Amount', 'pmpro');?>:</label></th>
571
<td>
580
?>
581
<small><?php _e('for the first', 'pmpro');?></small>
582
<input name="trial_limit[]" type="text" size="10" value="<?php echo str_replace("\"", "&quot;", stripslashes($level->trial_limit))?>" />
583
+ <small><?php _e('subscription payments', 'pmpro');?>.</small>
584
</td>
585
</tr>
586
+
587
<tr>
588
<th scope="row" valign="top"><label><?php _e('Membership Expiration', 'pmpro');?>:</label></th>
589
<td><input id="expiration_<?php echo $level->id;?>" name="expiration[]" type="checkbox" value="<?php echo $level->id?>" <?php if(pmpro_isLevelExpiring($level)) { echo "checked='checked'"; } ?> onclick="if(jQuery(this).is(':checked')) { jQuery(this).parent().parent().siblings('.expiration_info').show(); } else { jQuery(this).parent().parent().siblings('.expiration_info').hide();}" /> <label for="expiration_<?php echo $level->id;?>"><?php _e('Check this to set when membership access expires.', 'pmpro');?></label></td>
590
</tr>
591
+
592
<tr class="expiration_info" <?php if(!pmpro_isLevelExpiring($level)) {?>style="display: none;"<?php } ?>>
593
<th scope="row" valign="top"><label for="billing_amount"><?php _e('Expires In', 'pmpro');?>:</label></th>
594
+ <td>
595
<input id="expiration_number" name="expiration_number[]" type="text" size="10" value="<?php echo str_replace("\"", "&quot;", stripslashes($level->expiration_number))?>" />
596
<select id="expiration_period" name="expiration_period[]">
597
<?php
603
}
604
?>
605
</select>
606
+ <br /><small><?php _e('Set the duration of membership access. Note that the any future payments (recurring subscription, if any) will be cancelled when the membership expires.', 'pmpro');?></small>
607
</td>
608
+ </tr>
609
</tbody>
610
</table>
611
+
612
<?php do_action("pmpro_discount_code_after_level_settings", $edit, $level); ?>
613
+
614
+ </div>
615
</div>
616
+ <script>
617
+
618
</script>
619
<?php
620
}
621
?>
622
</div>
623
+
624
<p class="submit topborder">
625
+ <input name="save" type="submit" class="button button-primary" value="Save Code" />
626
<input name="cancel" type="button" class="button button-secondary" value="Cancel" onclick="location.href='<?php echo get_admin_url(NULL, '/admin.php?page=pmpro-discountcodes')?>';" />
627
</p>
628
</form>
629
</div>
630
+
631
+ <?php } else { ?>
632
+
633
<h2>
634
<?php _e('Memberships Discount Codes', 'pmpro');?>
635
<a href="admin.php?page=pmpro-discountcodes&edit=-1" class="add-new-h2"><?php _e('Add New Discount Code', 'pmpro');?></a>
636
+ </h2>
637
+
638
<?php if(!empty($pmpro_msg)) { ?>
639
<div id="message" class="<?php if($pmpro_msgt == "success") echo "updated fade"; else echo "error"; ?>"><p><?php echo $pmpro_msg?></p></div>
640
<?php } ?>
641
+
642
+ <form id="posts-filter" method="get" action="">
643
<p class="search-box">
644
<label class="screen-reader-text" for="post-search-input"><?php _e('Search Discount Codes', 'pmpro');?>:</label>
645
<input type="hidden" name="page" value="pmpro-discountcodes" />
646
<input id="post-search-input" type="text" value="<?php if(!empty($s)) echo $s;?>" name="s" size="30" />
647
<input class="button" type="submit" value="<?php _e('Search', 'pmpro');?>" id="search-submit "/>
648
+ </p>
649
+ </form>
650
+
651
<br class="clear" />
652
<?php
653
$sqlQuery = "SELECT *, UNIX_TIMESTAMP(starts) as starts, UNIX_TIMESTAMP(expires) as expires FROM $wpdb->pmpro_discount_codes ";
654
if(!empty($s))
655
$sqlQuery .= "WHERE code LIKE '%$s%' ";
656
+ $sqlQuery .= "ORDER BY id ASC";
657
+
658
+ $codes = $wpdb->get_results($sqlQuery, OBJECT);
659
+ ?>
660
<table class="widefat">
661
<thead>
662
<tr>
663
<th><?php _e('ID', 'pmpro');?></th>
664
<th><?php _e('Code', 'pmpro');?></th>
665
<th><?php _e('Starts', 'pmpro');?></th>
666
+ <th><?php _e('Expires', 'pmpro');?></th>
667
<th><?php _e('Uses', 'pmpro');?></th>
668
<th><?php _e('Levels', 'pmpro');?></th>
669
<?php do_action("pmpro_discountcodes_extra_cols_header", $codes);?>
670
+ <th></th>
671
+ <th></th>
672
</tr>
673
</thead>
674
<tbody>
676
if(!$codes)
677
{
678
?>
679
+ <tr><td colspan="7" class="pmpro_pad20">
680
<p><?php _e('Discount codes allow you to offer your memberships at discounted prices to select customers.', 'pmpro');?> <a href="admin.php?page=pmpro-discountcodes&edit=-1"><?php _e('Create your first discount code now', 'pmpro');?></a>.</p>
681
</td></tr>
682
<?php
700
</td>
701
<td>
702
<?php
703
+ $uses = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->pmpro_discount_codes_uses WHERE code_id = %d", $code->id ) );
704
if($code->uses > 0)
705
echo "<strong>" . (int)$uses . "</strong>/" . $code->uses;
706
else
708
?>
709
</td>
710
<td>
711
+ <?php
712
+ $sqlQuery = $wpdb->prepare("
713
+ SELECT l.id, l.name
714
+ FROM $wpdb->pmpro_membership_levels l
715
+ LEFT JOIN $wpdb->pmpro_discount_codes_levels cl
716
+ ON l.id = cl.level_id
717
+ WHERE cl.code_id = %d",
718
+ $code->id
719
+ );
720
$levels = $wpdb->get_results($sqlQuery);
721
+
722
$level_names = array();
723
foreach($levels as $level)
724
$level_names[] = "<a target=\"_blank\" href=\"" . pmpro_url("checkout", "?level=" . $level->id . "&discount_code=" . $code->code) . "\">" . $level->name . "</a>";
725
if($level_names)
726
+ echo implode(", ", $level_names);
727
else
728
echo "None";
729
?>
730
</td>
731
<?php do_action("pmpro_discountcodes_extra_cols_body", $code);?>
732
<td>
733
+ <a href="?page=pmpro-discountcodes&edit=<?php echo $code->id?>"><?php _e('edit', 'pmpro');?></a>
734
</td>
735
<td>
736
+ <a href="javascript:askfirst('<?php echo str_replace("'", "\'", sprintf(__('Are you sure you want to delete the %s discount code? The subscriptions for existing users will not change, but new users will not be able to use this code anymore.', 'pmpro'), $code->code));?>', '?page=pmpro-discountcodes&delete=<?php echo $code->id?>'); void(0);"><?php _e('delete', 'pmpro');?></a>
737
</td>
738
</tr>
739
<?php
742
?>
743
</tbody>
744
</table>
745
+
746
<?php } ?>
747
+
748
<?php
749
+ require_once(dirname(__FILE__) . "/admin_footer.php");
750
?>
paid-memberships-pro.php CHANGED
@@ -3,7 +3,7 @@
3
Plugin Name: Paid Memberships Pro
4
Plugin URI: http://www.paidmembershipspro.com
5
Description: Plugin to Handle Memberships
6
- Version: 1.8.13.3
7
Author: Stranger Studios
8
Author URI: http://www.strangerstudios.com
9
Text Domain: pmpro
@@ -15,7 +15,7 @@ Domain Path: /languages
15
*/
16
17
//version constant
18
- define("PMPRO_VERSION", "1.8.13.3");
19
define("PMPRO_USER_AGENT", "Paid Memberships Pro v" . PMPRO_VERSION . "; " . site_url());
20
21
//if the session has been started yet, start it (ignore if running from command line)
@@ -69,7 +69,7 @@ require_once(PMPRO_DIR . "/includes/capabilities.php"); //manage PMPro capabil
69
70
require_once(PMPRO_DIR . "/includes/xmlrpc.php"); //xmlrpc methods
71
72
- require_once(PMPRO_DIR . "/shortcodes/checkout_button.php"); //[checkout_button] shortcode to show link to checkout for a level
73
require_once(PMPRO_DIR . "/shortcodes/membership.php"); //[membership] shortcode to hide/show member content
74
require_once(PMPRO_DIR . "/shortcodes/pmpro_account.php"); //[pmpro_account] shortcode to show account information
75
3
Plugin Name: Paid Memberships Pro
4
Plugin URI: http://www.paidmembershipspro.com
5
Description: Plugin to Handle Memberships
6
+ Version: 1.8.13.4
7
Author: Stranger Studios
8
Author URI: http://www.strangerstudios.com
9
Text Domain: pmpro
15
*/
16
17
//version constant
18
+ define("PMPRO_VERSION", "1.8.13.4");
19
define("PMPRO_USER_AGENT", "Paid Memberships Pro v" . PMPRO_VERSION . "; " . site_url());
20
21
//if the session has been started yet, start it (ignore if running from command line)
69
70
require_once(PMPRO_DIR . "/includes/xmlrpc.php"); //xmlrpc methods
71
72
+ require_once(PMPRO_DIR . "/shortcodes/checkout_button.php"); //[pmpro_checkout_button] shortcode to show link to checkout for a level
73
require_once(PMPRO_DIR . "/shortcodes/membership.php"); //[membership] shortcode to hide/show member content
74
require_once(PMPRO_DIR . "/shortcodes/pmpro_account.php"); //[pmpro_account] shortcode to show account information
75
readme.txt CHANGED
@@ -1,9 +1,9 @@
1
=== Paid Memberships Pro ===
2
Contributors: strangerstudios
3
Tags: memberships, membership, authorize.net, ecommerce, paypal, stripe, braintree, restrict access, restrict content, directory site, payflow
4
- Requires at least: 3.5
5
- Tested up to: 4.7.1
6
- Stable tag: 1.8.13.3
7
8
A revenue-generating machine for membership sites. Unlimited levels with recurring payment, protected content and member management.
9
@@ -115,8 +115,10 @@ Not sure? You can find out by doing a bit a research.
115
[View All Screenshots](http://www.paidmembershipspro.com/features/screenshots/)
116
117
== Changelog ==
118
119
- = 1.8.13.2 =
120
* BUG: Fixed bug when using a secondary gateway (e.g. PayPal Express) with Stripe as your primary gateway.
121
122
= 1.8.13.2 =
1
=== Paid Memberships Pro ===
2
Contributors: strangerstudios
3
Tags: memberships, membership, authorize.net, ecommerce, paypal, stripe, braintree, restrict access, restrict content, directory site, payflow
4
+ Requires at least: 4
5
+ Tested up to: 4.7.2
6
+ Stable tag: 1.8.13.4
7
8
A revenue-generating machine for membership sites. Unlimited levels with recurring payment, protected content and member management.
9
115
[View All Screenshots](http://www.paidmembershipspro.com/features/screenshots/)
116
117
== Changelog ==
118
+ = 1.8.13.4 =
119
+ * BUG/ENHANCEMENT: Changed the pmpro_button shortcode to pmpro_checkout_button. (The old pmpro_button will also still work. checkout_button works if you have Register Helper installed.)
120
121
+ = 1.8.13.3 =
122
* BUG: Fixed bug when using a secondary gateway (e.g. PayPal Express) with Stripe as your primary gateway.
123
124
= 1.8.13.2 =
shortcodes/checkout_button.php CHANGED
@@ -7,7 +7,7 @@ function pmpro_checkout_button_shortcode($atts, $content=null, $code="")
7
// $atts ::= array of attributes
8
// $content ::= text within enclosing form of shortcode element
9
// $code ::= the shortcode found, when == callback name
10
- // examples: [checkout_button level="3"]
11
12
extract(shortcode_atts(array(
13
'level' => NULL,
@@ -18,3 +18,4 @@ function pmpro_checkout_button_shortcode($atts, $content=null, $code="")
18
return pmpro_getCheckoutButton($level, $text, $class);
19
}
20
add_shortcode("pmpro_button", "pmpro_checkout_button_shortcode");
7
// $atts ::= array of attributes
8
// $content ::= text within enclosing form of shortcode element
9
// $code ::= the shortcode found, when == callback name
10
+ // examples: [pmpro_checkout_button level="3"]
11
12
extract(shortcode_atts(array(
13
'level' => NULL,
18
return pmpro_getCheckoutButton($level, $text, $class);
19
}
20
add_shortcode("pmpro_button", "pmpro_checkout_button_shortcode");
21
+ add_shortcode("pmpro_checkout_button", "pmpro_checkout_button_shortcode");