Version Description
- SECURITY: No longer showing email addresses in output when cron jobs are processed by non-admins. (Thanks, Daniel Bachhuber)
- BUG: Better handling of errors when validating PayPal IPN requests. Added pmpro_ipn_validate filter. PayPal users should read the release notes here: http://www.paidmembershipspro.com/2015/10/pmpro-update-1-8-6-3/
- BUG: Fixed bug where both the return and first order INS would change membership and update the order twice, leading to unwanted cancellations and emails. (Thanks, Steffen Dressler)
- BUG: No longer using the $pmpro_levels global in pages/levels.php.
Download this release
Release Info
Developer | strangerstudios |
Plugin | Paid Memberships Pro |
Version | 1.8.6.3 |
Comparing to | |
See all releases |
Code changes from version 1.8.6.1 to 1.8.6.3
- adminpages/functions.php +1 -2
- adminpages/reports.php +65 -61
- adminpages/reports/login.php +32 -16
- adminpages/reports/memberships.php +624 -660
- adminpages/reports/sales.php +415 -406
- adminpages/templates/orders-email.php +71 -0
- adminpages/templates/orders-print.php +89 -61
- classes/class.pmproemail.php +5 -5
- css/admin.css +122 -118
- includes/content.php +48 -4
- includes/functions.php +2157 -2116
- pages/levels.php +31 -12
- paid-memberships-pro.php +2 -2
- preheaders/checkout.php +764 -754
- readme.txt +19 -338
- scheduled/crons.php +16 -4
- services/ipnhandler.php +37 -11
- services/twocheckout-ins.php +28 -5
- shortcodes/pmpro_account.php +4 -1
adminpages/functions.php
CHANGED
@@ -55,8 +55,7 @@ function pmpro_checkLevelForStripeCompatibility($level = NULL)
|
|
55 |
$level = $wpdb->get_row("SELECT * FROM $wpdb->pmpro_membership_levels WHERE id = '" . esc_sql($level) . "' LIMIT 1");
|
56 |
|
57 |
//check this level
|
58 |
-
if(
|
59 |
-
$level->billing_limit > 0)
|
60 |
{
|
61 |
return false;
|
62 |
}
|
55 |
$level = $wpdb->get_row("SELECT * FROM $wpdb->pmpro_membership_levels WHERE id = '" . esc_sql($level) . "' LIMIT 1");
|
56 |
|
57 |
//check this level
|
58 |
+
if($level->billing_limit > 0)
|
|
|
59 |
{
|
60 |
return false;
|
61 |
}
|
adminpages/reports.php
CHANGED
@@ -1,62 +1,66 @@
|
|
1 |
-
<?php
|
2 |
-
global $pmpro_reports;
|
3 |
-
|
4 |
-
require_once(dirname(__FILE__) . "/admin_header.php");
|
5 |
-
|
6 |
-
//default view, report widgets
|
7 |
-
if(empty($_REQUEST['report']))
|
8 |
-
{
|
9 |
-
//wrapper
|
10 |
-
?>
|
11 |
-
<div id="dashboard-widgets-wrap">
|
12 |
-
<div id="dashboard-widgets" class="metabox-holder pmpro_reports-holder
|
13 |
-
<div id="postbox-container-1" class="postbox-container">
|
14 |
-
<div id="normal-sortables" class="meta-box-sortables ui-sortable">
|
15 |
-
<?php
|
16 |
-
|
17 |
-
//report widgets
|
18 |
-
$count = 0;
|
19 |
-
$nreports = count($pmpro_reports);
|
20 |
-
$split = false;
|
21 |
-
foreach($pmpro_reports as $report => $title)
|
22 |
-
{
|
23 |
-
//make sure title is translated (since these are set before translations happen)
|
24 |
-
$title = __($title, "pmpro");
|
25 |
-
|
26 |
-
//put half of the report widgets in postbox-container-2
|
27 |
-
if(!$split && $count++ > $nreports/2)
|
28 |
-
{
|
29 |
-
$split = true;
|
30 |
-
?>
|
31 |
-
</div></div><div id="postbox-container-2" class="postbox-container"><div id="side-sortables" class="meta-box-sortables ui-sortable">
|
32 |
-
<?php
|
33 |
-
}
|
34 |
-
?>
|
35 |
-
<div id="pmpro_report_<?php echo $report; ?>" class="postbox pmpro_clickable" onclick="location.href='<?php echo admin_url("admin.php?page=pmpro-reports&report=" . $report);?>';">
|
36 |
-
<h3 class="hndle"><span><?php echo $title; ?></span></h3>
|
37 |
-
<div class="inside">
|
38 |
-
<?php call_user_func("pmpro_report_" . $report . "_widget"); ?>
|
39 |
-
<
|
40 |
-
<a class="button button-primary" href="<?php echo admin_url("admin.php?page=pmpro-reports&report=" . $report);?>"><?php _e('Details', 'pmpro');?></a>
|
41 |
-
</
|
42 |
-
</div>
|
43 |
-
</div>
|
44 |
-
<?php
|
45 |
-
}
|
46 |
-
|
47 |
-
//end wrapper
|
48 |
-
?>
|
49 |
-
</div>
|
50 |
-
</div>
|
51 |
-
</div>
|
52 |
-
<?php
|
53 |
-
}
|
54 |
-
else
|
55 |
-
{
|
56 |
-
//view a single report
|
57 |
-
$report = sanitize_text_field($_REQUEST['report']);
|
58 |
-
call_user_func("pmpro_report_" . $report . "_page");
|
59 |
-
|
60 |
-
|
61 |
-
|
|
|
|
|
|
|
|
|
62 |
?>
|
1 |
+
<?php
|
2 |
+
global $pmpro_reports;
|
3 |
+
|
4 |
+
require_once(dirname(__FILE__) . "/admin_header.php");
|
5 |
+
|
6 |
+
//default view, report widgets
|
7 |
+
if(empty($_REQUEST['report']))
|
8 |
+
{
|
9 |
+
//wrapper
|
10 |
+
?>
|
11 |
+
<div id="dashboard-widgets-wrap">
|
12 |
+
<div id="dashboard-widgets" class="metabox-holder pmpro_reports-holder">
|
13 |
+
<div id="postbox-container-1" class="postbox-container">
|
14 |
+
<div id="normal-sortables" class="meta-box-sortables ui-sortable">
|
15 |
+
<?php
|
16 |
+
|
17 |
+
//report widgets
|
18 |
+
$count = 0;
|
19 |
+
$nreports = count($pmpro_reports);
|
20 |
+
$split = false;
|
21 |
+
foreach($pmpro_reports as $report => $title)
|
22 |
+
{
|
23 |
+
//make sure title is translated (since these are set before translations happen)
|
24 |
+
$title = __($title, "pmpro");
|
25 |
+
|
26 |
+
//put half of the report widgets in postbox-container-2
|
27 |
+
if(!$split && $count++ > $nreports/2)
|
28 |
+
{
|
29 |
+
$split = true;
|
30 |
+
?>
|
31 |
+
</div></div><div id="postbox-container-2" class="postbox-container"><div id="side-sortables" class="meta-box-sortables ui-sortable">
|
32 |
+
<?php
|
33 |
+
}
|
34 |
+
?>
|
35 |
+
<div id="pmpro_report_<?php echo $report; ?>" class="postbox pmpro_clickable" onclick="location.href='<?php echo admin_url("admin.php?page=pmpro-reports&report=" . $report);?>';">
|
36 |
+
<h3 class="hndle"><span><?php echo $title; ?></span></h3>
|
37 |
+
<div class="inside">
|
38 |
+
<?php call_user_func("pmpro_report_" . $report . "_widget"); ?>
|
39 |
+
<p style="text-align:center;">
|
40 |
+
<a class="button button-primary" href="<?php echo admin_url("admin.php?page=pmpro-reports&report=" . $report);?>"><?php _e('Details', 'pmpro');?></a>
|
41 |
+
</p>
|
42 |
+
</div>
|
43 |
+
</div>
|
44 |
+
<?php
|
45 |
+
}
|
46 |
+
|
47 |
+
//end wrapper
|
48 |
+
?>
|
49 |
+
</div>
|
50 |
+
</div>
|
51 |
+
</div>
|
52 |
+
<?php
|
53 |
+
}
|
54 |
+
else
|
55 |
+
{
|
56 |
+
//view a single report
|
57 |
+
$report = sanitize_text_field($_REQUEST['report']);
|
58 |
+
call_user_func("pmpro_report_" . $report . "_page");
|
59 |
+
?>
|
60 |
+
<hr />
|
61 |
+
<a class="button button-primary" href="<?php echo admin_url("admin.php?page=pmpro-reports");?>"><?php _e('Back to Reports Dashboard', 'pmpro');?></a>
|
62 |
+
<?php
|
63 |
+
}
|
64 |
+
|
65 |
+
require_once(dirname(__FILE__) . "/admin_footer.php");
|
66 |
?>
|
adminpages/reports/login.php
CHANGED
@@ -23,22 +23,38 @@ function pmpro_report_login_widget()
|
|
23 |
$views = get_option("pmpro_views", array("today"=>0, "thisday"=>date("Y-m-d", $now), "alltime"=>0, "month"=>0, "thismonth"=>date("n", $now)));
|
24 |
$logins = get_option("pmpro_logins", array("today"=>0, "thisday"=>date("Y-m-d", $now), "alltime"=>0, "month"=>0, "thismonth"=>date("n", $now)));
|
25 |
?>
|
26 |
-
<
|
27 |
-
<
|
28 |
-
<
|
29 |
-
|
30 |
-
|
31 |
-
<
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
</
|
36 |
-
<
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
<?php
|
43 |
}
|
44 |
|
23 |
$views = get_option("pmpro_views", array("today"=>0, "thisday"=>date("Y-m-d", $now), "alltime"=>0, "month"=>0, "thismonth"=>date("n", $now)));
|
24 |
$logins = get_option("pmpro_logins", array("today"=>0, "thisday"=>date("Y-m-d", $now), "alltime"=>0, "month"=>0, "thismonth"=>date("n", $now)));
|
25 |
?>
|
26 |
+
<span id="pmpro_report_login">
|
27 |
+
<table class="wp-list-table widefat fixed striped">
|
28 |
+
<thead>
|
29 |
+
<tr>
|
30 |
+
<th scope="col"> </th>
|
31 |
+
<th scope="col"><?php _e('Visits','pmpro'); ?></th>
|
32 |
+
<th scope="col"><?php _e('Views','pmpro'); ?></th>
|
33 |
+
<th scope="col"><?php _e('Logins','pmpro'); ?></th>
|
34 |
+
</tr>
|
35 |
+
</thead>
|
36 |
+
<tbody>
|
37 |
+
<tr>
|
38 |
+
<th scope="row"><?php _e('Today','pmpro'); ?></th>
|
39 |
+
<td><?php echo number_format_i18n($visits['today']); ?></td>
|
40 |
+
<td><?php echo number_format_i18n($views['today']); ?></td>
|
41 |
+
<td><?php echo number_format_i18n($logins['today']);?></td>
|
42 |
+
</tr>
|
43 |
+
<tr>
|
44 |
+
<th scope="row"><?php _e('This Month','pmpro'); ?></th>
|
45 |
+
<td><?php echo number_format_i18n($visits['month']); ?></td>
|
46 |
+
<td><?php echo number_format_i18n($views['month']); ?></td>
|
47 |
+
<td><?php echo number_format_i18n($logins['month']); ?></td>
|
48 |
+
</tr>
|
49 |
+
<tr>
|
50 |
+
<th scope="row"><?php _e('All Time','pmpro'); ?></th>
|
51 |
+
<td><?php echo number_format_i18n($visits['alltime']); ?></td>
|
52 |
+
<td><?php echo number_format_i18n($views['alltime']);?></td>
|
53 |
+
<td><?php echo number_format_i18n($logins['alltime']); ?></td>
|
54 |
+
</tr>
|
55 |
+
</tbody>
|
56 |
+
</table>
|
57 |
+
</span>
|
58 |
<?php
|
59 |
}
|
60 |
|
adminpages/reports/memberships.php
CHANGED
@@ -1,660 +1,624 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
PMPro Report
|
4 |
-
Title: Membership Stats
|
5 |
-
Slug: memberships
|
6 |
-
|
7 |
-
For each report, add a line like:
|
8 |
-
global $pmpro_reports;
|
9 |
-
$pmpro_reports['slug'] = 'Title';
|
10 |
-
|
11 |
-
For each report, also write two functions:
|
12 |
-
* pmpro_report_{slug}_widget() to show up on the report homepage.
|
13 |
-
* pmpro_report_{slug}_page() to show up when users click on the report page widget.
|
14 |
-
*/
|
15 |
-
|
16 |
-
global $pmpro_reports;
|
17 |
-
|
18 |
-
$pmpro_reports['memberships'] = __('Membership Stats', 'pmpro');
|
19 |
-
|
20 |
-
//queue Google Visualization JS on report page
|
21 |
-
function pmpro_report_memberships_init() {
|
22 |
-
if(is_admin() && isset($_REQUEST['report']) && $_REQUEST['report'] == "memberships" && isset($_REQUEST['page']) && $_REQUEST['page'] == "pmpro-reports")
|
23 |
-
wp_enqueue_script("jsapi", "https://www.google.com/jsapi");
|
24 |
-
}
|
25 |
-
add_action( 'init', 'pmpro_report_memberships_init' );
|
26 |
-
|
27 |
-
|
28 |
-
//widget
|
29 |
-
function pmpro_report_memberships_widget() {
|
30 |
-
global $wpdb
|
31 |
-
?>
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
<
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
<
|
55 |
-
<
|
56 |
-
</
|
57 |
-
<
|
58 |
-
<
|
59 |
-
<
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
$
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
$
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
$
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
$
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
{
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
<
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
{
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
}
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
$
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
$
|
515 |
-
|
516 |
-
//
|
517 |
-
if(!empty($
|
518 |
-
$
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
//
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
$
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
$
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
//
|
599 |
-
$
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
}
|
623 |
-
|
624 |
-
|
625 |
-
function pmpro_getLTV($period, $levels = 'all', $mrr = NULL, $signups = NULL, $cancellation_rate = NULL)
|
626 |
-
{
|
627 |
-
if(empty($mrr))
|
628 |
-
$mrr = pmpro_getMRR($period, $levels);
|
629 |
-
if(empty($signups))
|
630 |
-
$signups = pmpro_getSignups($period, $levels);
|
631 |
-
if(empty($cancellation_rate))
|
632 |
-
$cancellation_rate = pmpro_getCancellationRate($period, $levels);
|
633 |
-
|
634 |
-
//average monthly spend
|
635 |
-
if(empty($signups))
|
636 |
-
return false;
|
637 |
-
|
638 |
-
if($signups > 0)
|
639 |
-
$ams = $mrr / $signups;
|
640 |
-
else
|
641 |
-
$ams = 0;
|
642 |
-
|
643 |
-
if($cancellation_rate > 0)
|
644 |
-
$ltv = $ams * (1/$cancellation_rate);
|
645 |
-
else
|
646 |
-
$ltv = $ams;
|
647 |
-
|
648 |
-
return $ltv;
|
649 |
-
}
|
650 |
-
|
651 |
-
//delete transients when an order goes through
|
652 |
-
function pmpro_report_memberships_delete_transients()
|
653 |
-
{
|
654 |
-
delete_transient("pmpro_report_mrr");
|
655 |
-
delete_transient("pmpro_report_cancellation_rate");
|
656 |
-
delete_transient("pmpro_report_memberships_cancellations");
|
657 |
-
delete_transient("pmpro_report_memberships_signups");
|
658 |
-
}
|
659 |
-
add_action("pmpro_after_checkout", "pmpro_report_memberships_delete_transients");
|
660 |
-
add_action("pmpro_updated_order", "pmpro_report_memberships_delete_transients");
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
PMPro Report
|
4 |
+
Title: Membership Stats
|
5 |
+
Slug: memberships
|
6 |
+
|
7 |
+
For each report, add a line like:
|
8 |
+
global $pmpro_reports;
|
9 |
+
$pmpro_reports['slug'] = 'Title';
|
10 |
+
|
11 |
+
For each report, also write two functions:
|
12 |
+
* pmpro_report_{slug}_widget() to show up on the report homepage.
|
13 |
+
* pmpro_report_{slug}_page() to show up when users click on the report page widget.
|
14 |
+
*/
|
15 |
+
|
16 |
+
global $pmpro_reports;
|
17 |
+
|
18 |
+
$pmpro_reports['memberships'] = __('Membership Stats', 'pmpro');
|
19 |
+
|
20 |
+
//queue Google Visualization JS on report page
|
21 |
+
function pmpro_report_memberships_init() {
|
22 |
+
if(is_admin() && isset($_REQUEST['report']) && $_REQUEST['report'] == "memberships" && isset($_REQUEST['page']) && $_REQUEST['page'] == "pmpro-reports")
|
23 |
+
wp_enqueue_script("jsapi", "https://www.google.com/jsapi");
|
24 |
+
}
|
25 |
+
add_action( 'init', 'pmpro_report_memberships_init' );
|
26 |
+
|
27 |
+
|
28 |
+
//widget
|
29 |
+
function pmpro_report_memberships_widget() {
|
30 |
+
global $wpdb;
|
31 |
+
?>
|
32 |
+
<span id="pmpro_report_memberships">
|
33 |
+
<table class="wp-list-table widefat fixed striped">
|
34 |
+
<thead>
|
35 |
+
<tr>
|
36 |
+
<th scope="col"> </th>
|
37 |
+
<th scope="col"><?php _e('Signups','pmpro'); ?></th>
|
38 |
+
<th scope="col"><?php _e('Cancellations','pmpro'); ?></th>
|
39 |
+
</tr>
|
40 |
+
</thead>
|
41 |
+
<tbody>
|
42 |
+
<tr>
|
43 |
+
<th scope="row"><?php _e('Today','pmpro'); ?></th>
|
44 |
+
<td><?php echo number_format_i18n(pmpro_getSignups('today')); ?></td>
|
45 |
+
<td><?php echo number_format_i18n(pmpro_getCancellations('today')); ?></td>
|
46 |
+
</tr>
|
47 |
+
<tr>
|
48 |
+
<th scope="row"><?php _e('This Month','pmpro'); ?></th>
|
49 |
+
<td><?php echo number_format_i18n(pmpro_getSignups('this month')); ?></td>
|
50 |
+
<td><?php echo number_format_i18n(pmpro_getCancellations('this month')); ?></td>
|
51 |
+
</tr>
|
52 |
+
<tr>
|
53 |
+
<th scope="row"><?php _e('This Year','pmpro'); ?></th>
|
54 |
+
<td><?php echo number_format_i18n(pmpro_getSignups('this year')); ?></td>
|
55 |
+
<td><?php echo number_format_i18n(pmpro_getCancellations('this year')); ?></td>
|
56 |
+
</tr>
|
57 |
+
<tr>
|
58 |
+
<th scope="row"><?php _e('All Time','pmpro'); ?></th>
|
59 |
+
<td><?php echo number_format_i18n(pmpro_getSignups('all time')); ?></td>
|
60 |
+
<td><?php echo number_format_i18n(pmpro_getCancellations('all time')); ?></td>
|
61 |
+
</tr>
|
62 |
+
</tbody>
|
63 |
+
</table>
|
64 |
+
</span>
|
65 |
+
<?php
|
66 |
+
}
|
67 |
+
|
68 |
+
function pmpro_report_memberships_page()
|
69 |
+
{
|
70 |
+
global $wpdb, $pmpro_currency_symbol;
|
71 |
+
|
72 |
+
//get values from form
|
73 |
+
if(isset($_REQUEST['type']))
|
74 |
+
$type = sanitize_text_field($_REQUEST['type']);
|
75 |
+
else
|
76 |
+
$type = "signup_v_cancel";
|
77 |
+
|
78 |
+
if(isset($_REQUEST['period']))
|
79 |
+
$period = sanitize_text_field($_REQUEST['period']);
|
80 |
+
else
|
81 |
+
$period = "monthly";
|
82 |
+
|
83 |
+
if(isset($_REQUEST['month']))
|
84 |
+
$month = intval($_REQUEST['month']);
|
85 |
+
else
|
86 |
+
$month = date("n");
|
87 |
+
|
88 |
+
$thisyear = date("Y");
|
89 |
+
if(isset($_REQUEST['year']))
|
90 |
+
$year = intval($_REQUEST['year']);
|
91 |
+
else
|
92 |
+
$year = date("Y");
|
93 |
+
|
94 |
+
if(isset($_REQUEST['level']))
|
95 |
+
$l = intval($_REQUEST['level']);
|
96 |
+
else
|
97 |
+
$l = "";
|
98 |
+
|
99 |
+
//calculate start date and how to group dates returned from DB
|
100 |
+
if($period == "daily")
|
101 |
+
{
|
102 |
+
$startdate = $year . '-' . substr("0" . $month, strlen($month) - 1, 2) . '-01';
|
103 |
+
$enddate = $year . '-' . substr("0" . $month, strlen($month) - 1, 2) . '-32';
|
104 |
+
$date_function = 'DAY';
|
105 |
+
}
|
106 |
+
elseif($period == "monthly")
|
107 |
+
{
|
108 |
+
$startdate = $year . '-01-01';
|
109 |
+
$enddate = strval(intval($year)+1) . '-01-01';
|
110 |
+
$date_function = 'MONTH';
|
111 |
+
}
|
112 |
+
elseif($period == "annual")
|
113 |
+
{
|
114 |
+
$startdate = '1960-01-01'; //all time
|
115 |
+
$date_function = 'YEAR';
|
116 |
+
}
|
117 |
+
|
118 |
+
//testing or live data
|
119 |
+
$gateway_environment = pmpro_getOption("gateway_environment");
|
120 |
+
|
121 |
+
//get data
|
122 |
+
if ( $type === "signup_v_cancel" ) {
|
123 |
+
$sqlQuery = "SELECT $date_function(startdate) as date, COUNT(DISTINCT user_id) as signups
|
124 |
+
FROM $wpdb->pmpro_memberships_users WHERE startdate >= '" . $startdate . "' ";
|
125 |
+
|
126 |
+
if(!empty($enddate))
|
127 |
+
$sqlQuery .= "AND startdate < '" . $enddate . "' ";
|
128 |
+
}
|
129 |
+
if ( $type === "mrr_ltv" ) {
|
130 |
+
// Get total revenue, number of months in system, and date
|
131 |
+
if ( $period == 'annual' )
|
132 |
+
$sqlQuery = "SELECT SUM(total) as total, COUNT(DISTINCT MONTH(timestamp)) as months, $date_function(timestamp) as date
|
133 |
+
FROM $wpdb->pmpro_membership_orders WHERE status NOT IN('refunded', 'review', 'token')
|
134 |
+
AND timestamp >= '" . $startdate . "' AND gateway_environment = '" . esc_sql($gateway_environment) . "' ";
|
135 |
+
|
136 |
+
if ( $period == 'monthly' )
|
137 |
+
$sqlQuery = "SELECT SUM(total) as total, $date_function(timestamp) as date
|
138 |
+
FROM $wpdb->pmpro_membership_orders WHERE status NOT IN('refunded', 'review', 'token')
|
139 |
+
AND timestamp >= '" . $startdate . "' AND gateway_environment = '" . esc_sql($gateway_environment) . "' ";
|
140 |
+
|
141 |
+
if(!empty($enddate))
|
142 |
+
$sqlQuery .= "AND timestamp < '" . $enddate . "' ";
|
143 |
+
}
|
144 |
+
|
145 |
+
if(!empty($l))
|
146 |
+
$sqlQuery .= "AND membership_id IN(" . $l . ") ";
|
147 |
+
|
148 |
+
$sqlQuery .= " GROUP BY date ORDER BY date ";
|
149 |
+
|
150 |
+
$dates = $wpdb->get_results($sqlQuery);
|
151 |
+
|
152 |
+
//fill in blanks in dates
|
153 |
+
$cols = array();
|
154 |
+
if($period == "daily")
|
155 |
+
{
|
156 |
+
$lastday = date("t", strtotime($startdate, current_time("timestamp")));
|
157 |
+
|
158 |
+
for($i = 1; $i <= $lastday; $i++)
|
159 |
+
{
|
160 |
+
// Signups vs. Cancellations
|
161 |
+
if ( $type === "signup_v_cancel" ) {
|
162 |
+
$cols[$i] = new stdClass();
|
163 |
+
$cols[$i]->signups = 0;
|
164 |
+
foreach($dates as $date)
|
165 |
+
{
|
166 |
+
if( $date->date == $i ) {
|
167 |
+
$cols[$i]->signups = $date->signups;
|
168 |
+
}
|
169 |
+
}
|
170 |
+
}
|
171 |
+
}
|
172 |
+
}
|
173 |
+
elseif($period == "monthly")
|
174 |
+
{
|
175 |
+
for($i = 1; $i < 13; $i++)
|
176 |
+
{
|
177 |
+
// Signups vs. Cancellations
|
178 |
+
if ( $type === "signup_v_cancel" ) {
|
179 |
+
$cols[$i] = new stdClass();
|
180 |
+
$cols[$i]->date = $i;
|
181 |
+
$cols[$i]->signups = 0;
|
182 |
+
foreach($dates as $date)
|
183 |
+
{
|
184 |
+
if( $date->date == $i ) {
|
185 |
+
$cols[$i]->date = $date->date;
|
186 |
+
$cols[$i]->signups = $date->signups;
|
187 |
+
}
|
188 |
+
}
|
189 |
+
}
|
190 |
+
|
191 |
+
// MRR & LTV
|
192 |
+
if ( $type === "mrr_ltv" ) {
|
193 |
+
$cols[$i] = new stdClass();
|
194 |
+
$cols[$i]->date = $i;
|
195 |
+
$cols[$i]->months = 1;
|
196 |
+
foreach($dates as $date)
|
197 |
+
{
|
198 |
+
if( $date->date == $i ) {
|
199 |
+
$cols[$i]->total = $date->total;
|
200 |
+
}
|
201 |
+
}
|
202 |
+
}
|
203 |
+
}
|
204 |
+
}
|
205 |
+
elseif($period == "annual") //annual
|
206 |
+
{
|
207 |
+
}
|
208 |
+
|
209 |
+
$dates = ( ! empty( $cols ) ) ? $cols : $dates;
|
210 |
+
|
211 |
+
// Signups vs. cancellations
|
212 |
+
if ( $type === "signup_v_cancel" )
|
213 |
+
{
|
214 |
+
$sqlQuery = "SELECT $date_function(mu1.modified) as date, COUNT(DISTINCT mu1.user_id) as cancellations
|
215 |
+
FROM $wpdb->pmpro_memberships_users mu1
|
216 |
+
LEFT JOIN $wpdb->pmpro_memberships_users mu2 ON mu1.user_id = mu2.user_id AND
|
217 |
+
mu2.modified > mu1.enddate AND
|
218 |
+
DATE_ADD(mu1.modified, INTERVAL 1 DAY) > mu2.startdate
|
219 |
+
WHERE mu1.status = 'inactive'
|
220 |
+
AND mu2.id IS NULL
|
221 |
+
AND mu1.startdate >= '" . $startdate . "'
|
222 |
+
AND mu1.startdate < '" . $enddate . "' ";
|
223 |
+
|
224 |
+
//restrict by level
|
225 |
+
if(!empty($l))
|
226 |
+
$sqlQuery .= "AND membership_id IN(" . $l . ") ";
|
227 |
+
|
228 |
+
$sqlQuery .= " GROUP BY date ORDER BY date ";
|
229 |
+
|
230 |
+
$cdates = $wpdb->get_results($sqlQuery, OBJECT_K);
|
231 |
+
|
232 |
+
foreach( $dates as &$date )
|
233 |
+
{
|
234 |
+
if(!empty($cdates) && !empty($cdates[$date->date]))
|
235 |
+
$date->cancellations = $cdates[$date->date]->cancellations;
|
236 |
+
else
|
237 |
+
$date->cancellations = 0;
|
238 |
+
}
|
239 |
+
}
|
240 |
+
|
241 |
+
// MRR & LTV
|
242 |
+
if ( $type === "mrr_ltv" && count( $dates ) === 1 ) {
|
243 |
+
$dummy_date = new stdClass();
|
244 |
+
$dummy_date->total = 0;
|
245 |
+
$dummy_date->months = 0;
|
246 |
+
$dummy_date->date = $dates[0]->date - 1;
|
247 |
+
array_unshift( $dates, $dummy_date ); // Add to beginning
|
248 |
+
}
|
249 |
+
?>
|
250 |
+
<form id="posts-filter" method="get" action="">
|
251 |
+
<h2>
|
252 |
+
<?php _e('Membership Stats', 'pmpro');?>
|
253 |
+
</h2>
|
254 |
+
<ul class="subsubsub">
|
255 |
+
<li>
|
256 |
+
<?php _ex('Show', 'Dropdown label, e.g. Show Daily Revenue for January', 'pmpro')?>
|
257 |
+
<select id="period" name="period">
|
258 |
+
<option value="daily" <?php selected($period, "daily");?>><?php _e('Daily', 'pmpro');?></option>
|
259 |
+
<option value="monthly" <?php selected($period, "monthly");?>><?php _e('Monthly', 'pmpro');?></option>
|
260 |
+
<option value="annual" <?php selected($period, "annual");?>><?php _e('Annual', 'pmpro');?></option>
|
261 |
+
</select>
|
262 |
+
<select id="type" name="type">
|
263 |
+
<option value="signup_v_cancel" <?php selected($type, "signup_v_cancel");?>><?php _e('Signups vs. Cancellations', 'pmpro');?></option>
|
264 |
+
<?php /*
|
265 |
+
<option value="mrr_ltv" <?php selected($type, "mrr_ltv");?>><?php _e('MRR & LTV', 'pmpro');?></option>
|
266 |
+
*/ ?>
|
267 |
+
</select>
|
268 |
+
<span id="for"><?php _ex('for', 'Dropdown label, e.g. Show Daily Revenue for January', 'pmpro')?></span>
|
269 |
+
<select id="month" name="month">
|
270 |
+
<?php for($i = 1; $i < 13; $i++) { ?>
|
271 |
+
<option value="<?php echo $i;?>" <?php selected($month, $i);?>><?php echo date("F", mktime(0, 0, 0, $i, 2));?></option>
|
272 |
+
<?php } ?>
|
273 |
+
</select>
|
274 |
+
<select id="year" name="year">
|
275 |
+
<?php for($i = $thisyear; $i > 2007; $i--) { ?>
|
276 |
+
<option value="<?php echo $i;?>" <?php selected($year, $i);?>><?php echo $i;?></option>
|
277 |
+
<?php } ?>
|
278 |
+
</select>
|
279 |
+
<span id="for"><?php _ex('for', 'Dropdown label, e.g. Show Daily Revenue for January', 'pmpro')?></span>
|
280 |
+
<select name="level">
|
281 |
+
<option value="" <?php if(!$l) { ?>selected="selected"<?php } ?>><?php _e('All Levels', 'pmpro');?></option>
|
282 |
+
<?php
|
283 |
+
$levels = $wpdb->get_results("SELECT id, name FROM $wpdb->pmpro_membership_levels ORDER BY name");
|
284 |
+
foreach($levels as $level)
|
285 |
+
{
|
286 |
+
?>
|
287 |
+
<option value="<?php echo $level->id?>" <?php if($l == $level->id) { ?>selected="selected"<?php } ?>><?php echo $level->name?></option>
|
288 |
+
<?php
|
289 |
+
}
|
290 |
+
?>
|
291 |
+
</select>
|
292 |
+
|
293 |
+
<input type="hidden" name="page" value="pmpro-reports" />
|
294 |
+
<input type="hidden" name="report" value="memberships" />
|
295 |
+
<input type="submit" value="<?php _ex('Generate Report', 'Submit button value.', 'pmpro');?>" />
|
296 |
+
</li>
|
297 |
+
</ul>
|
298 |
+
|
299 |
+
<div id="chart_div" style="clear: both; width: 100%; height: 500px;"></div>
|
300 |
+
|
301 |
+
<script>
|
302 |
+
//update month/year when period dropdown is changed
|
303 |
+
jQuery(document).ready(function() {
|
304 |
+
jQuery('#period').change(function() {
|
305 |
+
pmpro_ShowMonthOrYear();
|
306 |
+
});
|
307 |
+
});
|
308 |
+
|
309 |
+
function pmpro_ShowMonthOrYear()
|
310 |
+
{
|
311 |
+
var period = jQuery('#period').val();
|
312 |
+
if(period == 'daily')
|
313 |
+
{
|
314 |
+
jQuery('#for').show();
|
315 |
+
jQuery('#month').show();
|
316 |
+
jQuery('#year').show();
|
317 |
+
}
|
318 |
+
else if(period == 'monthly')
|
319 |
+
{
|
320 |
+
jQuery('#for').show();
|
321 |
+
jQuery('#month').hide();
|
322 |
+
jQuery('#year').show();
|
323 |
+
}
|
324 |
+
else
|
325 |
+
{
|
326 |
+
jQuery('#for').hide();
|
327 |
+
jQuery('#month').hide();
|
328 |
+
jQuery('#year').hide();
|
329 |
+
}
|
330 |
+
}
|
331 |
+
|
332 |
+
pmpro_ShowMonthOrYear();
|
333 |
+
|
334 |
+
//draw the chart
|
335 |
+
google.load("visualization", "1", {packages:["corechart"]});
|
336 |
+
google.setOnLoadCallback(drawChart);
|
337 |
+
function drawChart() {
|
338 |
+
|
339 |
+
var data = google.visualization.arrayToDataTable([
|
340 |
+
<?php if ( $type === "signup_v_cancel" ) : // Signups vs. cancellations ?>
|
341 |
+
['<?php echo $date_function;?>', 'Signups', 'Cancellations'],
|
342 |
+
<?php foreach($dates as $key => $value) { ?>
|
343 |
+
['<?php if($period == "monthly") echo date("M", mktime(0,0,0,$value->date,2)); else if($period == "daily") echo $key; else echo $value->date;?>', <?php echo $value->signups; ?>, <?php echo $value->cancellations; ?>],
|
344 |
+
<?php } ?>
|
345 |
+
<?php endif; ?>
|
346 |
+
|
347 |
+
<?php if ( $type === "mrr_ltv" ) : // Signups vs. cancellations ?>
|
348 |
+
['<?php echo $date_function;?>', 'MRR', 'LTV'],
|
349 |
+
<?php foreach($dates as $key => $value) { ?>
|
350 |
+
['<?php if($period == "monthly") echo date("M", mktime(0,0,0,$value->date,2)); else if($period == "daily") echo $key; else echo $value->date;?>', <?php echo (($mrr = $value->total / $value->months) && $mrr != 0) ? $mrr : 0; ?>, <?php echo pmpro_getLTV($period, NULL, $mrr ); ?>],
|
351 |
+
<?php } ?>
|
352 |
+
<?php endif; ?>
|
353 |
+
]);
|
354 |
+
|
355 |
+
var options = {
|
356 |
+
colors: ['#0099c6', '#dc3912'],
|
357 |
+
hAxis: {title: '<?php echo $date_function;?>', titleTextStyle: {color: 'black'}, maxAlternation: 1},
|
358 |
+
vAxis: {color: 'green', titleTextStyle: {color: '#51a351'}},
|
359 |
+
};
|
360 |
+
|
361 |
+
<?php if ( $type === "signup_v_cancel" ) : // Signups vs. cancellations ?>
|
362 |
+
var chart = new google.visualization.ColumnChart(document.getElementById('chart_div'));
|
363 |
+
<?php elseif ( $type === "mrr_ltv" ) : // MRR & LTV ?>
|
364 |
+
|
365 |
+
<?php
|
366 |
+
//prefix or suffix?
|
367 |
+
if(pmpro_getCurrencyPosition() == "right")
|
368 |
+
$position = "suffix";
|
369 |
+
else
|
370 |
+
$position = "prefix";
|
371 |
+
?>
|
372 |
+
|
373 |
+
var formatter = new google.visualization.NumberFormat({<?php echo $position;?>: '<?php echo html_entity_decode($pmpro_currency_symbol);?>'});
|
374 |
+
formatter.format(data, 2);
|
375 |
+
var formatter = new google.visualization.NumberFormat({<?php echo $position;?>: '<?php echo html_entity_decode($pmpro_currency_symbol);?>'});
|
376 |
+
formatter.format(data, 1);
|
377 |
+
|
378 |
+
var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
|
379 |
+
<?php endif; ?>
|
380 |
+
chart.draw(data, options);
|
381 |
+
}
|
382 |
+
</script>
|
383 |
+
|
384 |
+
</form>
|
385 |
+
<?php
|
386 |
+
}
|
387 |
+
|
388 |
+
|
389 |
+
|
390 |
+
/*
|
391 |
+
Other code required for your reports. This file is loaded every time WP loads with PMPro enabled.
|
392 |
+
*/
|
393 |
+
|
394 |
+
//get signups
|
395 |
+
function pmpro_getSignups($period = false, $levels = 'all')
|
396 |
+
{
|
397 |
+
//check for a transient
|
398 |
+
$cache = get_transient( 'pmpro_report_memberships_signups' );
|
399 |
+
if( ! empty( $cache ) && ! empty( $cache[$period] ) && ! empty( $cache[$period][$levels] ) )
|
400 |
+
return $cache[$period][$levels];
|
401 |
+
|
402 |
+
//a sale is an order with status = success
|
403 |
+
if( $period == 'today' )
|
404 |
+
$startdate = date(' Y-m-d' );
|
405 |
+
elseif( $period == 'this month')
|
406 |
+
$startdate = date( 'Y-m' ) . '-01';
|
407 |
+
elseif( $period == 'this year')
|
408 |
+
$startdate = date( 'Y' ) . '-01-01';
|
409 |
+
else
|
410 |
+
$startdate = '';
|
411 |
+
|
412 |
+
|
413 |
+
//build query
|
414 |
+
global $wpdb;
|
415 |
+
|
416 |
+
$sqlQuery = "SELECT COUNT(DISTINCT user_id) FROM $wpdb->pmpro_memberships_users WHERE startdate >= '" . $startdate . "' ";
|
417 |
+
|
418 |
+
//restrict by level
|
419 |
+
if(!empty($levels) && $levels != 'all')
|
420 |
+
$sqlQuery .= "AND membership_id IN(" . $levels . ") ";
|
421 |
+
|
422 |
+
$signups = $wpdb->get_var($sqlQuery);
|
423 |
+
|
424 |
+
//save in cache
|
425 |
+
if(!empty($cache) && !empty($cache[$period]))
|
426 |
+
$cache[$period][$levels] = $signups;
|
427 |
+
elseif(!empty($cache))
|
428 |
+
$cache[$period] = array($levels => $signups);
|
429 |
+
else
|
430 |
+
$cache = array($period => array($levels => $signups));
|
431 |
+
|
432 |
+
set_transient("pmpro_report_memberships_signups", $cache, 3600*24);
|
433 |
+
|
434 |
+
return $signups;
|
435 |
+
}
|
436 |
+
|
437 |
+
//get cancellations
|
438 |
+
function pmpro_getCancellations($period = false, $levels = 'all')
|
439 |
+
{
|
440 |
+
//check for a transient
|
441 |
+
$cache = get_transient( 'pmpro_report_memberships_cancellations' );
|
442 |
+
if( ! empty( $cache ) && ! empty( $cache[$period] ) && ! empty( $cache[$period][$levels] ) )
|
443 |
+
return $cache[$period][$levels];
|
444 |
+
|
445 |
+
//figure out start date
|
446 |
+
if( $period == 'today' )
|
447 |
+
$startdate = date(' Y-m-d' );
|
448 |
+
elseif( $period == 'this month')
|
449 |
+
$startdate = date( 'Y-m' ) . '-01';
|
450 |
+
elseif( $period == 'this year')
|
451 |
+
$startdate = date( 'Y' ) . '-01-01';
|
452 |
+
else
|
453 |
+
$startdate = '';
|
454 |
+
|
455 |
+
$startdate_plus_one = strtotime( $startdate . + ' + 1 day', current_time("timestamp") );
|
456 |
+
|
457 |
+
/*
|
458 |
+
build query.
|
459 |
+
cancellations are marked in the memberships users table with status = 'inactive'
|
460 |
+
we try to ignore cancellations when the user gets a new level with 24 hours (probably an upgrade or downgrade)
|
461 |
+
*/
|
462 |
+
global $wpdb;
|
463 |
+
|
464 |
+
//$sqlQuery = "SELECT mu1.user_id, mu2.user_id FROM $wpdb->pmpro_memberships_users mu1 LEFT JOIN $wpdb->pmpro_memberships_users mu2 ON mu1.user_id = mu2.user_id AND mu2.status = 'inactive' AND mu2.startdate > mu1.startdate";
|
465 |
+
$sqlQuery = "SELECT COUNT(mu1.id)
|
466 |
+
FROM $wpdb->pmpro_memberships_users mu1
|
467 |
+
LEFT JOIN $wpdb->pmpro_memberships_users mu2 ON mu1.user_id = mu2.user_id AND
|
468 |
+
mu2.modified > mu1.enddate AND
|
469 |
+
DATE_ADD(mu1.modified, INTERVAL 1 DAY) > mu2.startdate
|
470 |
+
WHERE mu1.status = 'inactive'
|
471 |
+
AND mu2.id IS NULL
|
472 |
+
AND mu1.startdate >= '" . $startdate . "' ";
|
473 |
+
|
474 |
+
//restrict by level
|
475 |
+
if(!empty($levels) && $levels != 'all')
|
476 |
+
$sqlQuery .= "AND membership_id IN(" . $levels . ") ";
|
477 |
+
|
478 |
+
$cancellations = $wpdb->get_var($sqlQuery);
|
479 |
+
|
480 |
+
//save in cache
|
481 |
+
if(!empty($cache) && !empty($cache[$period]) && is_array($cache[$period]))
|
482 |
+
$cache[$period][$levels] = $cancellations;
|
483 |
+
elseif(!empty($cache))
|
484 |
+
$cache[$period] = array($levels => $cancellations);
|
485 |
+
else
|
486 |
+
$cache = array($period => array($levels => $cancellations));
|
487 |
+
|
488 |
+
set_transient("pmpro_report_memberships_cancellations", $cache, 3600*24);
|
489 |
+
|
490 |
+
return $cancellations;
|
491 |
+
}
|
492 |
+
|
493 |
+
//get MRR
|
494 |
+
function pmpro_getMRR($period, $levels = 'all')
|
495 |
+
{
|
496 |
+
//check for a transient
|
497 |
+
//$cache = get_transient("pmpro_report_mrr");
|
498 |
+
if(!empty($cache) && !empty($cache[$period]) && !empty($cache[$period][$levels]))
|
499 |
+
return $cache[$period][$levels];
|
500 |
+
|
501 |
+
//a sale is an order with status NOT IN refunded, review, token, error
|
502 |
+
if($period == "this month")
|
503 |
+
$startdate = date("Y-m") . "-01";
|
504 |
+
elseif($period == "this year")
|
505 |
+
$startdate = date("Y") . "-01-01";
|
506 |
+
else
|
507 |
+
$startdate = "";
|
508 |
+
|
509 |
+
$gateway_environment = pmpro_getOption("gateway_environment");
|
510 |
+
|
511 |
+
//build query
|
512 |
+
global $wpdb;
|
513 |
+
// Get total revenue
|
514 |
+
$sqlQuery = "SELECT SUM(total) FROM $wpdb->pmpro_membership_orders WHERE status NOT IN('refunded', 'review', 'token', 'error') AND timestamp >= '" . $startdate . "' AND gateway_environment = '" . esc_sql($gateway_environment) . "' ";
|
515 |
+
|
516 |
+
//restrict by level
|
517 |
+
if(!empty($levels) && $levels != 'all') {
|
518 |
+
$sqlQuery .= "AND membership_id IN(" . $levels . ") ";
|
519 |
+
}
|
520 |
+
|
521 |
+
$revenue = $wpdb->get_var($sqlQuery);
|
522 |
+
|
523 |
+
//when was the first order
|
524 |
+
$first_order_timestamp = $wpdb->get_var("SELECT UNIX_TIMESTAMP(`timestamp`) FROM $wpdb->pmpro_membership_orders WHERE `timestamp` IS NOT NULL AND `timestamp` > '0000-00-00 00:00:00' ORDER BY `timestamp` LIMIT 1");
|
525 |
+
|
526 |
+
//if we don't have a timestamp, we can't do this
|
527 |
+
if(empty($first_order_timestamp))
|
528 |
+
return false;
|
529 |
+
|
530 |
+
//how many months ago was the first order
|
531 |
+
$months = $wpdb->get_var("SELECT PERIOD_DIFF('" . date("Ym") . "', '" . date("Ym", $first_order_timestamp) . "')");
|
532 |
+
|
533 |
+
/* this works in PHP 5.3+ without using MySQL to get the diff
|
534 |
+
$date1 = new DateTime(date("Y-m-d", $first_order_timestamp));
|
535 |
+
$date2 = new DateTime(date("Y-m-d"));
|
536 |
+
$interval = $date1->diff($date2);
|
537 |
+
$years = intval($interval->format('%y'));
|
538 |
+
$months = $years*12 + intval($interval->format('%m'));
|
539 |
+
*/
|
540 |
+
|
541 |
+
if($months > 0)
|
542 |
+
$mrr = $revenue / $months;
|
543 |
+
else
|
544 |
+
$mrr = 0;
|
545 |
+
|
546 |
+
//save in cache
|
547 |
+
if(!empty($cache) && !empty($cache[$period]))
|
548 |
+
$cache[$period][$levels] = $mrr;
|
549 |
+
elseif(!empty($cache))
|
550 |
+
$cache[$period] = array($levels => $mrr);
|
551 |
+
else
|
552 |
+
$cache = array($period => array($levels => $mrr));
|
553 |
+
|
554 |
+
set_transient("pmpro_report_mrr", $cache, 3600*24);
|
555 |
+
|
556 |
+
return $mrr;
|
557 |
+
}
|
558 |
+
|
559 |
+
//get Cancellation Rate
|
560 |
+
function pmpro_getCancellationRate($period, $levels = 'all')
|
561 |
+
{
|
562 |
+
//check for a transient
|
563 |
+
$cache = get_transient("pmpro_report_cancellation_rate");
|
564 |
+
if(!empty($cache) && !empty($cache[$period]) && !empty($cache[$period][$levels]))
|
565 |
+
return $cache[$period][$levels];
|
566 |
+
|
567 |
+
$signups = pmpro_getSignups($period, $levels);
|
568 |
+
$cancellations = pmpro_getCancellations($period, $levels);
|
569 |
+
|
570 |
+
if(empty($signups))
|
571 |
+
return false;
|
572 |
+
|
573 |
+
$rate = number_format(($cancellations / $signups)*100, 2);
|
574 |
+
|
575 |
+
//save in cache
|
576 |
+
if(!empty($cache) && !empty($cache[$period]))
|
577 |
+
$cache[$period][$levels] = $rate;
|
578 |
+
elseif(!empty($cache))
|
579 |
+
$cache[$period] = array($levels => $rate);
|
580 |
+
else
|
581 |
+
$cache = array($period => array($levels => $rate));
|
582 |
+
|
583 |
+
set_transient("pmpro_report_cancellation_rate", $cache, 3600*24);
|
584 |
+
|
585 |
+
return $rate;
|
586 |
+
}
|
587 |
+
|
588 |
+
//get LTV
|
589 |
+
function pmpro_getLTV($period, $levels = 'all', $mrr = NULL, $signups = NULL, $cancellation_rate = NULL)
|
590 |
+
{
|
591 |
+
if(empty($mrr))
|
592 |
+
$mrr = pmpro_getMRR($period, $levels);
|
593 |
+
if(empty($signups))
|
594 |
+
$signups = pmpro_getSignups($period, $levels);
|
595 |
+
if(empty($cancellation_rate))
|
596 |
+
$cancellation_rate = pmpro_getCancellationRate($period, $levels);
|
597 |
+
|
598 |
+
//average monthly spend
|
599 |
+
if(empty($signups))
|
600 |
+
return false;
|
601 |
+
|
602 |
+
if($signups > 0)
|
603 |
+
$ams = $mrr / $signups;
|
604 |
+
else
|
605 |
+
$ams = 0;
|
606 |
+
|
607 |
+
if($cancellation_rate > 0)
|
608 |
+
$ltv = $ams * (1/$cancellation_rate);
|
609 |
+
else
|
610 |
+
$ltv = $ams;
|
611 |
+
|
612 |
+
return $ltv;
|
613 |
+
}
|
614 |
+
|
615 |
+
//delete transients when an order goes through
|
616 |
+
function pmpro_report_memberships_delete_transients()
|
617 |
+
{
|
618 |
+
delete_transient("pmpro_report_mrr");
|
619 |
+
delete_transient("pmpro_report_cancellation_rate");
|
620 |
+
delete_transient("pmpro_report_memberships_cancellations");
|
621 |
+
delete_transient("pmpro_report_memberships_signups");
|
622 |
+
}
|
623 |
+
add_action("pmpro_after_checkout", "pmpro_report_memberships_delete_transients");
|
624 |
+
add_action("pmpro_updated_order", "pmpro_report_memberships_delete_transients");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
adminpages/reports/sales.php
CHANGED
@@ -1,406 +1,415 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
PMPro Report
|
4 |
-
Title: Sales
|
5 |
-
Slug: sales
|
6 |
-
|
7 |
-
For each report, add a line like:
|
8 |
-
global $pmpro_reports;
|
9 |
-
$pmpro_reports['slug'] = 'Title';
|
10 |
-
|
11 |
-
For each report, also write two functions:
|
12 |
-
* pmpro_report_{slug}_widget() to show up on the report homepage.
|
13 |
-
* pmpro_report_{slug}_page() to show up when users click on the report page widget.
|
14 |
-
*/
|
15 |
-
global $pmpro_reports;
|
16 |
-
$gateway_environment = pmpro_getOption("gateway_environment");
|
17 |
-
if($gateway_environment == "sandbox")
|
18 |
-
$pmpro_reports['sales'] = __('Sales and Revenue (Testing/Sandbox)', 'pmpro');
|
19 |
-
else
|
20 |
-
$pmpro_reports['sales'] = __('Sales and Revenue', 'pmpro');
|
21 |
-
|
22 |
-
//queue Google Visualization JS on report page
|
23 |
-
function pmpro_report_sales_init()
|
24 |
-
{
|
25 |
-
if(is_admin() && isset($_REQUEST['report']) && $_REQUEST['report'] == "sales" && isset($_REQUEST['page']) && $_REQUEST['page'] == "pmpro-reports")
|
26 |
-
{
|
27 |
-
wp_enqueue_script("jsapi", "https://www.google.com/jsapi");
|
28 |
-
}
|
29 |
-
}
|
30 |
-
add_action("init", "pmpro_report_sales_init");
|
31 |
-
|
32 |
-
//widget
|
33 |
-
function pmpro_report_sales_widget()
|
34 |
-
{
|
35 |
-
global $wpdb;
|
36 |
-
?>
|
37 |
-
<style>
|
38 |
-
#pmpro_report_sales
|
39 |
-
|
40 |
-
|
41 |
-
<
|
42 |
-
<
|
43 |
-
<
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
<
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
<
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
<
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
$
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
$
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
$
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
if($
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
}
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
<
|
204 |
-
|
205 |
-
<?php
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
<?php
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
?>
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
?>
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
{
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
$
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
$cache
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
$
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
PMPro Report
|
4 |
+
Title: Sales
|
5 |
+
Slug: sales
|
6 |
+
|
7 |
+
For each report, add a line like:
|
8 |
+
global $pmpro_reports;
|
9 |
+
$pmpro_reports['slug'] = 'Title';
|
10 |
+
|
11 |
+
For each report, also write two functions:
|
12 |
+
* pmpro_report_{slug}_widget() to show up on the report homepage.
|
13 |
+
* pmpro_report_{slug}_page() to show up when users click on the report page widget.
|
14 |
+
*/
|
15 |
+
global $pmpro_reports;
|
16 |
+
$gateway_environment = pmpro_getOption("gateway_environment");
|
17 |
+
if($gateway_environment == "sandbox")
|
18 |
+
$pmpro_reports['sales'] = __('Sales and Revenue (Testing/Sandbox)', 'pmpro');
|
19 |
+
else
|
20 |
+
$pmpro_reports['sales'] = __('Sales and Revenue', 'pmpro');
|
21 |
+
|
22 |
+
//queue Google Visualization JS on report page
|
23 |
+
function pmpro_report_sales_init()
|
24 |
+
{
|
25 |
+
if(is_admin() && isset($_REQUEST['report']) && $_REQUEST['report'] == "sales" && isset($_REQUEST['page']) && $_REQUEST['page'] == "pmpro-reports")
|
26 |
+
{
|
27 |
+
wp_enqueue_script("jsapi", "https://www.google.com/jsapi");
|
28 |
+
}
|
29 |
+
}
|
30 |
+
add_action("init", "pmpro_report_sales_init");
|
31 |
+
|
32 |
+
//widget
|
33 |
+
function pmpro_report_sales_widget()
|
34 |
+
{
|
35 |
+
global $wpdb;
|
36 |
+
?>
|
37 |
+
<style>
|
38 |
+
#pmpro_report_sales tbody td:last-child {text-align: right; }
|
39 |
+
</style>
|
40 |
+
<span id="pmpro_report_sales">
|
41 |
+
<table class="wp-list-table widefat fixed striped">
|
42 |
+
<thead>
|
43 |
+
<tr>
|
44 |
+
<th scope="col"> </th>
|
45 |
+
<th scope="col"><?php _e('Sales','pmpro'); ?></th>
|
46 |
+
<th scope="col"><?php _e('Revenue','pmpro'); ?></th>
|
47 |
+
</tr>
|
48 |
+
</thead>
|
49 |
+
<tbody>
|
50 |
+
<tr>
|
51 |
+
<th scope="row"><?php _e('Today','pmpro'); ?></th>
|
52 |
+
<td><?php echo number_format_i18n(pmpro_getSales("today")); ?></td>
|
53 |
+
<td><?php echo pmpro_formatPrice(pmpro_getRevenue("today"));?></td>
|
54 |
+
</tr>
|
55 |
+
<tr>
|
56 |
+
<th scope="row"><?php _e('This Month','pmpro'); ?></th>
|
57 |
+
<td><?php echo number_format_i18n(pmpro_getSales("this month")); ?></td>
|
58 |
+
<td><?php echo pmpro_formatPrice(pmpro_getRevenue("this month"));?></td>
|
59 |
+
</tr>
|
60 |
+
<tr>
|
61 |
+
<th scope="row"><?php _e('This Year','pmpro'); ?></th>
|
62 |
+
<td><?php echo number_format_i18n(pmpro_getSales("this year")); ?></td>
|
63 |
+
<td><?php echo pmpro_formatPrice(pmpro_getRevenue("this year"));?></td>
|
64 |
+
</tr>
|
65 |
+
<tr>
|
66 |
+
<th scope="row"><?php _e('All Time','pmpro'); ?></th>
|
67 |
+
<td><?php echo number_format_i18n(pmpro_getSales("all time")); ?></td>
|
68 |
+
<td><?php echo pmpro_formatPrice(pmpro_getRevenue("all time"));?></td>
|
69 |
+
</tr>
|
70 |
+
</tbody>
|
71 |
+
</table>
|
72 |
+
</span>
|
73 |
+
<?php
|
74 |
+
}
|
75 |
+
|
76 |
+
function pmpro_report_sales_page()
|
77 |
+
{
|
78 |
+
global $wpdb, $pmpro_currency_symbol, $pmpro_currency, $pmpro_currencies;
|
79 |
+
|
80 |
+
//get values from form
|
81 |
+
if(isset($_REQUEST['type']))
|
82 |
+
$type = sanitize_text_field($_REQUEST['type']);
|
83 |
+
else
|
84 |
+
$type = "revenue";
|
85 |
+
|
86 |
+
if($type == "sales")
|
87 |
+
$type_function = "COUNT";
|
88 |
+
else
|
89 |
+
$type_function = "SUM";
|
90 |
+
|
91 |
+
if(isset($_REQUEST['period']))
|
92 |
+
$period = sanitize_text_field($_REQUEST['period']);
|
93 |
+
else
|
94 |
+
$period = "daily";
|
95 |
+
|
96 |
+
if(isset($_REQUEST['month']))
|
97 |
+
$month = intval($_REQUEST['month']);
|
98 |
+
else
|
99 |
+
$month = date("n", current_time('timestamp'));
|
100 |
+
|
101 |
+
$thisyear = date("Y", current_time('timestamp'));
|
102 |
+
if(isset($_REQUEST['year']))
|
103 |
+
$year = intval($_REQUEST['year']);
|
104 |
+
else
|
105 |
+
$year = $thisyear;
|
106 |
+
|
107 |
+
if(isset($_REQUEST['level']))
|
108 |
+
$l = intval($_REQUEST['level']);
|
109 |
+
else
|
110 |
+
$l = "";
|
111 |
+
|
112 |
+
//calculate start date and how to group dates returned from DB
|
113 |
+
if($period == "daily")
|
114 |
+
{
|
115 |
+
$startdate = $year . '-' . substr("0" . $month, strlen($month) - 1, 2) . '-01';
|
116 |
+
$enddate = $year . '-' . substr("0" . $month, strlen($month) - 1, 2) . '-32';
|
117 |
+
$date_function = 'DAY';
|
118 |
+
}
|
119 |
+
elseif($period == "monthly")
|
120 |
+
{
|
121 |
+
$startdate = $year . '-01-01';
|
122 |
+
$enddate = strval(intval($year)+1) . '-01-01';
|
123 |
+
$date_function = 'MONTH';
|
124 |
+
}
|
125 |
+
else
|
126 |
+
{
|
127 |
+
$startdate = '1960-01-01'; //all time
|
128 |
+
$date_function = 'YEAR';
|
129 |
+
}
|
130 |
+
|
131 |
+
//testing or live data
|
132 |
+
$gateway_environment = pmpro_getOption("gateway_environment");
|
133 |
+
|
134 |
+
//get data
|
135 |
+
$sqlQuery = "SELECT $date_function(timestamp) as date, $type_function(total) as value FROM $wpdb->pmpro_membership_orders WHERE timestamp >= '" . $startdate . "' AND status NOT IN('refunded', 'review', 'token', 'error') AND gateway_environment = '" . esc_sql($gateway_environment) . "' ";
|
136 |
+
|
137 |
+
if(!empty($enddate))
|
138 |
+
$sqlQuery .= "AND timestamp < '" . $enddate . "' ";
|
139 |
+
|
140 |
+
if(!empty($l))
|
141 |
+
$sqlQuery .= "AND membership_id IN(" . $l . ") ";
|
142 |
+
|
143 |
+
$sqlQuery .= " GROUP BY date ORDER BY date ";
|
144 |
+
|
145 |
+
$dates = $wpdb->get_results($sqlQuery);
|
146 |
+
|
147 |
+
//fill in blanks in dates
|
148 |
+
$cols = array();
|
149 |
+
if($period == "daily")
|
150 |
+
{
|
151 |
+
$lastday = date("t", strtotime($startdate, current_time("timestamp")));
|
152 |
+
|
153 |
+
for($i = 1; $i <= $lastday; $i++)
|
154 |
+
{
|
155 |
+
$cols[$i] = 0;
|
156 |
+
foreach($dates as $date)
|
157 |
+
{
|
158 |
+
if($date->date == $i)
|
159 |
+
$cols[$i] = $date->value;
|
160 |
+
}
|
161 |
+
}
|
162 |
+
}
|
163 |
+
elseif($period == "monthly")
|
164 |
+
{
|
165 |
+
for($i = 1; $i < 13; $i++)
|
166 |
+
{
|
167 |
+
$cols[$i] = 0;
|
168 |
+
foreach($dates as $date)
|
169 |
+
{
|
170 |
+
if($date->date == $i)
|
171 |
+
$cols[$i] = $date->value;
|
172 |
+
}
|
173 |
+
}
|
174 |
+
}
|
175 |
+
else //annual
|
176 |
+
{
|
177 |
+
//get min and max years
|
178 |
+
$min = 9999;
|
179 |
+
$max = 0;
|
180 |
+
foreach($dates as $date)
|
181 |
+
{
|
182 |
+
$min = min($min, $date->date);
|
183 |
+
$max = max($max, $date->date);
|
184 |
+
}
|
185 |
+
|
186 |
+
for($i = $min; $i <= $max; $i++)
|
187 |
+
{
|
188 |
+
foreach($dates as $date)
|
189 |
+
{
|
190 |
+
if($date->date == $i)
|
191 |
+
$cols[$i] = $date->value;
|
192 |
+
}
|
193 |
+
}
|
194 |
+
}
|
195 |
+
?>
|
196 |
+
<form id="posts-filter" method="get" action="">
|
197 |
+
<h2>
|
198 |
+
<?php _e('Sales and Revenue', 'pmpro');?>
|
199 |
+
</h2>
|
200 |
+
|
201 |
+
<div class="tablenav top">
|
202 |
+
<?php _ex('Show', 'Dropdown label, e.g. Show Daily Revenue for January', 'pmpro')?>
|
203 |
+
<select id="period" name="period">
|
204 |
+
<option value="daily" <?php selected($period, "daily");?>><?php _e('Daily', 'pmpro');?></option>
|
205 |
+
<option value="monthly" <?php selected($period, "monthly");?>><?php _e('Monthly', 'pmpro');?></option>
|
206 |
+
<option value="annual" <?php selected($period, "annual");?>><?php _e('Annual', 'pmpro');?></option>
|
207 |
+
</select>
|
208 |
+
<select name="type">
|
209 |
+
<option value="revenue" <?php selected($type, "revenue");?>><?php _e('Revenue', 'pmpro');?></option>
|
210 |
+
<option value="sales" <?php selected($type, "sales");?>><?php _e('Sales', 'pmpro');?></option>
|
211 |
+
</select>
|
212 |
+
<span id="for"><?php _ex('for', 'Dropdown label, e.g. Show Daily Revenue for January', 'pmpro')?></span>
|
213 |
+
<select id="month" name="month">
|
214 |
+
<?php for($i = 1; $i < 13; $i++) { ?>
|
215 |
+
<option value="<?php echo $i;?>" <?php selected($month, $i);?>><?php echo date("F", mktime(0, 0, 0, $i, 2));?></option>
|
216 |
+
<?php } ?>
|
217 |
+
</select>
|
218 |
+
<select id="year" name="year">
|
219 |
+
<?php for($i = $thisyear; $i > 2007; $i--) { ?>
|
220 |
+
<option value="<?php echo $i;?>" <?php selected($year, $i);?>><?php echo $i;?></option>
|
221 |
+
<?php } ?>
|
222 |
+
</select>
|
223 |
+
<span id="for"><?php _ex('for', 'Dropdown label, e.g. Show Daily Revenue for January', 'pmpro')?></span>
|
224 |
+
<select name="level">
|
225 |
+
<option value="" <?php if(!$l) { ?>selected="selected"<?php } ?>><?php _e('All Levels', 'pmpro');?></option>
|
226 |
+
<?php
|
227 |
+
$levels = $wpdb->get_results("SELECT id, name FROM $wpdb->pmpro_membership_levels ORDER BY name");
|
228 |
+
foreach($levels as $level)
|
229 |
+
{
|
230 |
+
?>
|
231 |
+
<option value="<?php echo $level->id?>" <?php if($l == $level->id) { ?>selected="selected"<?php } ?>><?php echo $level->name?></option>
|
232 |
+
<?php
|
233 |
+
}
|
234 |
+
?>
|
235 |
+
</select>
|
236 |
+
|
237 |
+
<input type="hidden" name="page" value="pmpro-reports" />
|
238 |
+
<input type="hidden" name="report" value="sales" />
|
239 |
+
<input type="submit" class="button action" value="<?php _ex('Generate Report', 'Submit button value.', 'pmpro');?>" />
|
240 |
+
</div>
|
241 |
+
|
242 |
+
<div id="chart_div" style="clear: both; width: 100%; height: 500px;"></div>
|
243 |
+
|
244 |
+
<script>
|
245 |
+
//update month/year when period dropdown is changed
|
246 |
+
jQuery(document).ready(function() {
|
247 |
+
jQuery('#period').change(function() {
|
248 |
+
pmpro_ShowMonthOrYear();
|
249 |
+
});
|
250 |
+
});
|
251 |
+
|
252 |
+
function pmpro_ShowMonthOrYear()
|
253 |
+
{
|
254 |
+
var period = jQuery('#period').val();
|
255 |
+
if(period == 'daily')
|
256 |
+
{
|
257 |
+
jQuery('#for').show();
|
258 |
+
jQuery('#month').show();
|
259 |
+
jQuery('#year').show();
|
260 |
+
}
|
261 |
+
else if(period == 'monthly')
|
262 |
+
{
|
263 |
+
jQuery('#for').show();
|
264 |
+
jQuery('#month').hide();
|
265 |
+
jQuery('#year').show();
|
266 |
+
}
|
267 |
+
else
|
268 |
+
{
|
269 |
+
jQuery('#for').hide();
|
270 |
+
jQuery('#month').hide();
|
271 |
+
jQuery('#year').hide();
|
272 |
+
}
|
273 |
+
}
|
274 |
+
|
275 |
+
pmpro_ShowMonthOrYear();
|
276 |
+
|
277 |
+
//draw the chart
|
278 |
+
google.load("visualization", "1", {packages:["corechart"]});
|
279 |
+
google.setOnLoadCallback(drawChart);
|
280 |
+
function drawChart() {
|
281 |
+
|
282 |
+
var data = google.visualization.arrayToDataTable([
|
283 |
+
['<?php echo $date_function;?>', '<?php echo ucwords($type);?>'],
|
284 |
+
<?php foreach($cols as $date => $value) { ?>
|
285 |
+
['<?php if($period == "monthly") echo date("M", mktime(0,0,0,$date,2)); else echo $date;?>', <?php echo $value;?>],
|
286 |
+
<?php } ?>
|
287 |
+
]);
|
288 |
+
|
289 |
+
var options = {
|
290 |
+
colors: ['#51a351', '#387038'],
|
291 |
+
hAxis: {title: '<?php echo $date_function;?>', titleTextStyle: {color: 'black'}, maxAlternation: 1},
|
292 |
+
vAxis: {color: 'green', titleTextStyle: {color: '#51a351'}},
|
293 |
+
};
|
294 |
+
|
295 |
+
<?php
|
296 |
+
if($type != "sales")
|
297 |
+
{
|
298 |
+
if(pmpro_getCurrencyPosition() == "right")
|
299 |
+
$position = "suffix";
|
300 |
+
else
|
301 |
+
$position = "prefix";
|
302 |
+
?>
|
303 |
+
var formatter = new google.visualization.NumberFormat({<?php echo $position;?>: '<?php echo html_entity_decode($pmpro_currency_symbol);?>'});
|
304 |
+
formatter.format(data, 1);
|
305 |
+
<?php
|
306 |
+
}
|
307 |
+
?>
|
308 |
+
|
309 |
+
var chart = new google.visualization.ColumnChart(document.getElementById('chart_div'));
|
310 |
+
chart.draw(data, options);
|
311 |
+
}
|
312 |
+
</script>
|
313 |
+
|
314 |
+
</form>
|
315 |
+
<?php
|
316 |
+
}
|
317 |
+
|
318 |
+
/*
|
319 |
+
Other code required for your reports. This file is loaded every time WP loads with PMPro enabled.
|
320 |
+
*/
|
321 |
+
|
322 |
+
//get sales
|
323 |
+
function pmpro_getSales($period, $levels = NULL)
|
324 |
+
{
|
325 |
+
//check for a transient
|
326 |
+
$cache = get_transient("pmpro_report_sales");
|
327 |
+
if(!empty($cache) && !empty($cache[$period]) && !empty($cache[$period][$levels]))
|
328 |
+
return $cache[$period][$levels];
|
329 |
+
|
330 |
+
//a sale is an order with status NOT IN('refunded', 'review', 'token', 'error')
|
331 |
+
if($period == "today")
|
332 |
+
$startdate = date("Y-m-d", current_time('timestamp'));
|
333 |
+
elseif($period == "this month")
|
334 |
+
$startdate = date("Y-m", current_time('timestamp')) . "-01";
|
335 |
+
elseif($period == "this year")
|
336 |
+
$startdate = date("Y", current_time('timestamp')) . "-01-01";
|
337 |
+
else
|
338 |
+
$startdate = "";
|
339 |
+
|
340 |
+
$gateway_environment = pmpro_getOption("gateway_environment");
|
341 |
+
|
342 |
+
//build query
|
343 |
+
global $wpdb;
|
344 |
+
$sqlQuery = "SELECT COUNT(*) FROM $wpdb->pmpro_membership_orders WHERE status NOT IN('refunded', 'review', 'token', 'error') AND timestamp >= '" . $startdate . "' AND gateway_environment = '" . esc_sql($gateway_environment) . "' ";
|
345 |
+
|
346 |
+
//restrict by level
|
347 |
+
if(!empty($levels))
|
348 |
+
$sqlQuery .= "AND membership_id IN(" . $levels . ") ";
|
349 |
+
|
350 |
+
$sales = $wpdb->get_var($sqlQuery);
|
351 |
+
|
352 |
+
//save in cache
|
353 |
+
if(!empty($cache) && !empty($cache[$period]))
|
354 |
+
$cache[$period][$levels] = $sales;
|
355 |
+
elseif(!empty($cache))
|
356 |
+
$cache[$period] = array($levels => $sales);
|
357 |
+
else
|
358 |
+
$cache = array($period => array($levels => $sales));
|
359 |
+
|
360 |
+
set_transient("pmpro_report_sales", $cache, 3600*24);
|
361 |
+
|
362 |
+
return $sales;
|
363 |
+
}
|
364 |
+
|
365 |
+
//get revenue
|
366 |
+
function pmpro_getRevenue($period, $levels = NULL)
|
367 |
+
{
|
368 |
+
//check for a transient
|
369 |
+
$cache = get_transient("pmpro_report_revenue");
|
370 |
+
if(!empty($cache) && !empty($cache[$period]) && !empty($cache[$period][$levels]))
|
371 |
+
return $cache[$period][$levels];
|
372 |
+
|
373 |
+
//a sale is an order with status NOT IN('refunded', 'review', 'token', 'error')
|
374 |
+
if($period == "today")
|
375 |
+
$startdate = date("Y-m-d", current_time('timestamp'));
|
376 |
+
elseif($period == "this month")
|
377 |
+
$startdate = date("Y-m", current_time('timestamp')) . "-01";
|
378 |
+
elseif($period == "this year")
|
379 |
+
$startdate = date("Y", current_time('timestamp')) . "-01-01";
|
380 |
+
else
|
381 |
+
$startdate = "";
|
382 |
+
|
383 |
+
$gateway_environment = pmpro_getOption("gateway_environment");
|
384 |
+
|
385 |
+
//build query
|
386 |
+
global $wpdb;
|
387 |
+
$sqlQuery = "SELECT SUM(total) FROM $wpdb->pmpro_membership_orders WHERE status NOT IN('refunded', 'review', 'token', 'error') AND timestamp >= '" . $startdate . "' AND gateway_environment = '" . esc_sql($gateway_environment) . "' ";
|
388 |
+
|
389 |
+
//restrict by level
|
390 |
+
if(!empty($levels))
|
391 |
+
$sqlQuery .= "AND membership_id IN(" . $levels . ") ";
|
392 |
+
|
393 |
+
$revenue = $wpdb->get_var($sqlQuery);
|
394 |
+
|
395 |
+
//save in cache
|
396 |
+
if(!empty($cache) && !empty($cache[$period]))
|
397 |
+
$cache[$period][$levels] = $revenue;
|
398 |
+
elseif(!empty($cache))
|
399 |
+
$cache[$period] = array($levels => $revenue);
|
400 |
+
else
|
401 |
+
$cache = array($period => array($levels => $revenue));
|
402 |
+
|
403 |
+
set_transient("pmpro_report_revenue", $cache, 3600*24);
|
404 |
+
|
405 |
+
return $revenue;
|
406 |
+
}
|
407 |
+
|
408 |
+
//delete transients when an order goes through
|
409 |
+
function pmpro_report_sales_delete_transients()
|
410 |
+
{
|
411 |
+
delete_transient("pmpro_report_sales");
|
412 |
+
delete_transient("pmpro_report_revenue");
|
413 |
+
}
|
414 |
+
add_action("pmpro_after_checkout", "pmpro_report_sales_delete_transients");
|
415 |
+
add_action("pmpro_updated_order", "pmpro_report_sales_delete_transients");
|
adminpages/templates/orders-email.php
ADDED
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Template for Email Invoices
|
4 |
+
*
|
5 |
+
* @since 1.8.6
|
6 |
+
*/
|
7 |
+
?>
|
8 |
+
<table style="width:600px;margin-left:auto;margin-right:auto;">
|
9 |
+
<thead>
|
10 |
+
<tr>
|
11 |
+
<td rowspan="2" style="width:80%;">
|
12 |
+
<h2><?php bloginfo( 'sitename' ); ?></h2>
|
13 |
+
</td>
|
14 |
+
<td><?php echo __('Invoice #: ', 'pmpro') . ' ' . $order->code; ?></td>
|
15 |
+
</tr>
|
16 |
+
<tr>
|
17 |
+
<td>
|
18 |
+
<?php echo __( 'Date:', 'pmpro' ) . ' ' . date( 'Y-m-d', $order->timestamp ) ?>
|
19 |
+
</td>
|
20 |
+
</tr>
|
21 |
+
<?php if(!empty($order->billing->name)): ?>
|
22 |
+
<tr>
|
23 |
+
<td>
|
24 |
+
<strong><?php _e( 'Bill to:', 'pmpro' ); ?></strong><br>
|
25 |
+
<?php
|
26 |
+
echo pmpro_formatAddress(
|
27 |
+
$order->billing->name,
|
28 |
+
$order->billing->street,
|
29 |
+
"",
|
30 |
+
$order->billing->city,
|
31 |
+
$order->billing->state,
|
32 |
+
$order->billing->zip,
|
33 |
+
$order->billing->country,
|
34 |
+
$order->billing->phone
|
35 |
+
);
|
36 |
+
?>
|
37 |
+
<?php endif; ?>
|
38 |
+
</td>
|
39 |
+
</tr>
|
40 |
+
</thead>
|
41 |
+
<tbody>
|
42 |
+
<tr>
|
43 |
+
<td colspan="2">
|
44 |
+
<table style="width:100%;border-width:1px;border-style:solid;border-collapse:collapse;">
|
45 |
+
<tr style="border-width:1px;border-style:solid;border-collapse:collapse;">
|
46 |
+
<th style="text-align:center;border-width:1px;border-style:solid;border-collapse:collapse;"><?php _e('ID', 'pmpro'); ?></th>
|
47 |
+
<th style="border-width:1px;border-style:solid;border-collapse:collapse;"><?php _e('Item', 'pmpro'); ?></th>
|
48 |
+
<th style="border-width:1px;border-style:solid;border-collapse:collapse;"><?php _e('Price', 'pmpro'); ?></th>
|
49 |
+
</tr>
|
50 |
+
<tr style="border-width:1px;border-style:solid;border-collapse:collapse;">
|
51 |
+
<td style="text-align:center;border-width:1px;border-style:solid;border-collapse:collapse;"><?php echo $level->id; ?></td>
|
52 |
+
<td style="border-width:1px;border-style:solid;border-collapse:collapse;"><?php echo $level->name; ?></td>
|
53 |
+
<td style="text-align:right;"><?php echo $order->subtotal; ?></td>
|
54 |
+
</tr>
|
55 |
+
<tr style="border-width:1px;border-style:solid;border-collapse:collapse;">
|
56 |
+
<th colspan="2" style="text-align:right;border-width:1px;border-style:solid;border-collapse:collapse;"><?php _e('Subtotal', 'pmpro'); ?></th>
|
57 |
+
<td style="text-align:right;border-width:1px;border-style:solid;border-collapse:collapse;"><?php echo $order->subtotal; ?></td>
|
58 |
+
</tr>
|
59 |
+
<tr style="border-width:1px;border-style:solid;border-collapse:collapse;">
|
60 |
+
<th colspan="2" style="text-align:right;border-width:1px;border-style:solid;border-collapse:collapse;"><?php _e('Tax', 'pmpro'); ?></th>
|
61 |
+
<td style="text-align:right;border-width:1px;border-style:solid;border-collapse:collapse;"><?php echo $order->tax; ?></td>
|
62 |
+
</tr>
|
63 |
+
<tr style="border-width:1px;border-style:solid;border-collapse:collapse;">
|
64 |
+
<th colspan="2" style="text-align:right;border-width:1px;border-style:solid;border-collapse:collapse;"><?php _e('Total', 'pmpro'); ?></th>
|
65 |
+
<th style="text-align:right;border-width:1px;border-style:solid;border-collapse:collapse;"><?php echo pmpro_formatPrice($order->total); ?></th>
|
66 |
+
</tr>
|
67 |
+
</table>
|
68 |
+
</td>
|
69 |
+
</tr>
|
70 |
+
</tbody>
|
71 |
+
</table>
|
adminpages/templates/orders-print.php
CHANGED
@@ -1,71 +1,99 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* Template for
|
4 |
*
|
5 |
* @since 1.8.6
|
6 |
*/
|
7 |
?>
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
<h2><?php bloginfo( 'sitename' ); ?></h2>
|
13 |
-
</
|
14 |
-
<
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
<?php echo __( 'Date:', 'pmpro' ) . ' ' . date( 'Y-m-d', $order->timestamp ) ?>
|
19 |
-
</td>
|
20 |
-
</tr>
|
21 |
-
<?php if(!empty($order->billing->name)): ?>
|
22 |
-
<tr>
|
23 |
-
<td>
|
24 |
-
<strong><?php _e( 'Bill to:', 'pmpro' ); ?></strong><br>
|
25 |
-
<?php
|
26 |
-
echo pmpro_formatAddress(
|
27 |
-
$order->billing->name,
|
28 |
-
$order->billing->street,
|
29 |
-
"",
|
30 |
-
$order->billing->city,
|
31 |
-
$order->billing->state,
|
32 |
-
$order->billing->zip,
|
33 |
-
$order->billing->country,
|
34 |
-
$order->billing->phone
|
35 |
-
);
|
36 |
-
?>
|
37 |
-
<?php endif; ?>
|
38 |
-
</td>
|
39 |
-
</tr>
|
40 |
-
</thead>
|
41 |
-
<tbody>
|
42 |
-
<tr>
|
43 |
-
<td colspan="2">
|
44 |
-
<table style="width:100%;border-width:1px;border-style:solid;border-collapse:collapse;">
|
45 |
-
<tr style="border-width:1px;border-style:solid;border-collapse:collapse;">
|
46 |
-
<th style="text-align:center;border-width:1px;border-style:solid;border-collapse:collapse;"><?php _e('ID', 'pmpro'); ?></th>
|
47 |
-
<th style="border-width:1px;border-style:solid;border-collapse:collapse;"><?php _e('Item', 'pmpro'); ?></th>
|
48 |
-
<th style="border-width:1px;border-style:solid;border-collapse:collapse;"><?php _e('Price', 'pmpro'); ?></th>
|
49 |
</tr>
|
50 |
-
<tr
|
51 |
-
<td
|
52 |
-
|
53 |
-
|
54 |
-
</tr>
|
55 |
-
<tr style="border-width:1px;border-style:solid;border-collapse:collapse;">
|
56 |
-
<th colspan="2" style="text-align:right;border-width:1px;border-style:solid;border-collapse:collapse;"><?php _e('Subtotal', 'pmpro'); ?></th>
|
57 |
-
<td style="text-align:right;border-width:1px;border-style:solid;border-collapse:collapse;"><?php echo $order->subtotal; ?></td>
|
58 |
-
</tr>
|
59 |
-
<tr style="border-width:1px;border-style:solid;border-collapse:collapse;">
|
60 |
-
<th colspan="2" style="text-align:right;border-width:1px;border-style:solid;border-collapse:collapse;"><?php _e('Tax', 'pmpro'); ?></th>
|
61 |
-
<td style="text-align:right;border-width:1px;border-style:solid;border-collapse:collapse;"><?php echo $order->tax; ?></td>
|
62 |
-
</tr>
|
63 |
-
<tr style="border-width:1px;border-style:solid;border-collapse:collapse;">
|
64 |
-
<th colspan="2" style="text-align:right;border-width:1px;border-style:solid;border-collapse:collapse;"><?php _e('Total', 'pmpro'); ?></th>
|
65 |
-
<th style="text-align:right;border-width:1px;border-style:solid;border-collapse:collapse;"><?php echo pmpro_formatPrice($order->total); ?></th>
|
66 |
</tr>
|
67 |
</table>
|
68 |
-
</
|
69 |
-
</
|
70 |
-
|
71 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Template for Print Invoices
|
4 |
*
|
5 |
* @since 1.8.6
|
6 |
*/
|
7 |
?>
|
8 |
+
<!doctype html>
|
9 |
+
<html lang="en">
|
10 |
+
<head>
|
11 |
+
<meta charset="UTF-8">
|
12 |
+
<style>
|
13 |
+
.main, .header {
|
14 |
+
display: block;
|
15 |
+
}
|
16 |
+
.right {
|
17 |
+
display: inline-block;
|
18 |
+
float: right;
|
19 |
+
}
|
20 |
+
.alignright {
|
21 |
+
text-align: right;
|
22 |
+
}
|
23 |
+
.aligncenter {
|
24 |
+
text-align: center;
|
25 |
+
}
|
26 |
+
.invoice, .invoice tr, .invoice th, .invoice td {
|
27 |
+
border: 1px solid;
|
28 |
+
border-collapse: collapse;
|
29 |
+
padding: 4px;
|
30 |
+
}
|
31 |
+
.invoice {
|
32 |
+
width: 100%;
|
33 |
+
}
|
34 |
+
@media screen {
|
35 |
+
body {
|
36 |
+
max-width: 50%;
|
37 |
+
margin: 0 auto;
|
38 |
+
}
|
39 |
+
}
|
40 |
+
</style>
|
41 |
+
</head>
|
42 |
+
<body>
|
43 |
+
<header class="header">
|
44 |
+
<div>
|
45 |
<h2><?php bloginfo( 'sitename' ); ?></h2>
|
46 |
+
</div>
|
47 |
+
<div class="right">
|
48 |
+
<table>
|
49 |
+
<tr>
|
50 |
+
<td><?php echo __('Invoice #: ', 'pmpro') . ' ' . $order->code; ?></td>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
</tr>
|
52 |
+
<tr>
|
53 |
+
<td>
|
54 |
+
<?php echo __( 'Date:', 'pmpro' ) . ' ' . date( 'Y-m-d', $order->timestamp ) ?>
|
55 |
+
</td>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
</tr>
|
57 |
</table>
|
58 |
+
</div>
|
59 |
+
</header>
|
60 |
+
<main class="main">
|
61 |
+
<p>
|
62 |
+
<?php echo pmpro_formatAddress(
|
63 |
+
$order->billing->name,
|
64 |
+
$order->billing->address1,
|
65 |
+
$order->billing->address2,
|
66 |
+
$order->billing->city,
|
67 |
+
$order->billing->state,
|
68 |
+
$order->billing->zip,
|
69 |
+
$order->billing->country,
|
70 |
+
$order->billing->phone
|
71 |
+
); ?>
|
72 |
+
</p>
|
73 |
+
<table class="invoice">
|
74 |
+
<tr>
|
75 |
+
<th><?php _e('ID', 'pmpro'); ?></th>
|
76 |
+
<th><?php _e('Item', 'pmpro'); ?></th>
|
77 |
+
<th><?php _e('Price', 'pmpro'); ?></th>
|
78 |
+
</tr>
|
79 |
+
<tr>
|
80 |
+
<td class="aligncenter"><?php echo $level->id; ?></td>
|
81 |
+
<td><?php echo $level->name; ?></td>
|
82 |
+
<td class="alignright"><?php echo $order->subtotal; ?></td>
|
83 |
+
</tr>
|
84 |
+
<tr>
|
85 |
+
<th colspan="2" class="alignright"><?php _e('Subtotal', 'pmpro'); ?></th>
|
86 |
+
<td class="alignright"><?php echo $order->subtotal; ?></td>
|
87 |
+
</tr>
|
88 |
+
<tr>
|
89 |
+
<th colspan="2" class="alignright"><?php _e('Tax', 'pmpro'); ?></th>
|
90 |
+
<td class="alignright"><?php echo $order->tax; ?></td>
|
91 |
+
</tr>
|
92 |
+
<tr>
|
93 |
+
<th colspan="2" class="alignright"><?php _e('Total', 'pmpro'); ?></th>
|
94 |
+
<th class="alignright"><?php echo pmpro_formatPrice( $order->total ); ?></th>
|
95 |
+
</tr>
|
96 |
+
</table>
|
97 |
+
</main>
|
98 |
+
</body>
|
99 |
+
</html>
|
classes/class.pmproemail.php
CHANGED
@@ -849,12 +849,12 @@
|
|
849 |
$this->template = "billable_invoice";
|
850 |
|
851 |
// Load invoice template
|
852 |
-
if ( file_exists( get_stylesheet_directory() . '/paid-memberships-pro/pages/orders-
|
853 |
-
$template = get_stylesheet_directory() . '/paid-memberships-pro/pages/orders-
|
854 |
-
} elseif ( file_exists( get_template_directory() . '/paid-memberships-pro/pages/orders-
|
855 |
-
$template = get_template_directory() . '/paid-memberships-pro/pages/orders-
|
856 |
} else {
|
857 |
-
$template = PMPRO_DIR . '/adminpages/templates/orders-
|
858 |
}
|
859 |
|
860 |
ob_start();
|
849 |
$this->template = "billable_invoice";
|
850 |
|
851 |
// Load invoice template
|
852 |
+
if ( file_exists( get_stylesheet_directory() . '/paid-memberships-pro/pages/orders-email.php' ) ) {
|
853 |
+
$template = get_stylesheet_directory() . '/paid-memberships-pro/pages/orders-email.php';
|
854 |
+
} elseif ( file_exists( get_template_directory() . '/paid-memberships-pro/pages/orders-email.php' ) ) {
|
855 |
+
$template = get_template_directory() . '/paid-memberships-pro/pages/orders-email.php';
|
856 |
} else {
|
857 |
+
$template = PMPRO_DIR . '/adminpages/templates/orders-email.php';
|
858 |
}
|
859 |
|
860 |
ob_start();
|
css/admin.css
CHANGED
@@ -1,118 +1,122 @@
|
|
1 |
-
/* icon */
|
2 |
-
#wp-admin-bar-paid-memberships-pro .ab-item .ab-icon:before {
|
3 |
-
font-family: "dashicons";
|
4 |
-
content: "\f307";
|
5 |
-
}
|
6 |
-
.pmpro_admin tr td .dashicons {padding-top: 5px; }
|
7 |
-
|
8 |
-
/* header/etc */
|
9 |
-
.pmpro_admin {background: url(../images/Paid-Memberships-Pro_watermark.png) bottom right no-repeat !important; padding: 1em 0 70px 0; }
|
10 |
-
|
11 |
-
.pmpro_admin .pmpro_banner h2 {float: left; }
|
12 |
-
.pmpro_admin .pmpro_banner .pmpro_meta {float: left; margin: 26px 0 0 0; font-size: 12px; }
|
13 |
-
.pmpro_admin .pmpro_banner .pmpro_meta .pmpro_tag-blue {margin: 0 0 0 5px; }
|
14 |
-
.pmpro_admin .pmpro_banner .pmpro_logo {float: left; margin: 0 1em 0 0; width: 350px; height: 75px; }
|
15 |
-
.pmpro_admin .pmpro_banner ul.pmpro_menu {clear: both; border: 1px solid #CCC; border-radius: 5px; -moz-border-radius: 5px; background: #FFF; }
|
16 |
-
.pmpro_admin .pmpro_banner ul.pmpro_menu li {display: inline-block; margin: 10px 0; padding: 0px 10px; border-right: 1px solid #CCC; }
|
17 |
-
.pmpro_admin .pmpro_banner ul.pmpro_menu li a, .pmpro_admin .pmpro_banner ul.pmpro_menu li a:link {color: #1e0741; text-decoration: none; }
|
18 |
-
.pmpro_admin .pmpro_banner ul.pmpro_menu li a:hover {text-decoration: underline; color: #412f5b; }
|
19 |
-
|
20 |
-
.pmpro_admin .pmpro_tag-grey {display: inline-block; font-size: 11px; font-weight: bold; position: relative; padding: 2px 5px; border: 1px solid #CCC; background: whiteSmoke; border-radius: 10px; -moz-border-radius: 10px; -webkit-border-radius: 10px; }
|
21 |
-
.pmpro_admin .pmpro_tag-blue {display: inline-block; font-size: 11px; font-weight: bold; position: relative; padding: 2px 5px; border: 1px solid #2997c8; border-radius: 10px; -moz-border-radius: 10px; -webkit-border-radius: 10px; background: #2997c8; color: #FFF; text-decoration: none; }
|
22 |
-
.pmpro_admin a.pmpro_tag-blue:hover {background: #77a02e; border: 1px solid #77a02e; }
|
23 |
-
|
24 |
-
.pmpro_admin .topborder {border-top: 1px solid #CCC; margin-top: 1em; padding-top: 1em; }
|
25 |
-
.pmpro_admin #editorcontainer #description {width: 100%; height: 180px; }
|
26 |
-
.pmpro_admin .widefat {margin-top: 1em; }
|
27 |
-
|
28 |
-
/* checkboxes */
|
29 |
-
.checkbox_box {width: 300px; background: #FFFFFF; border: 1px solid #CCC;}
|
30 |
-
.checkbox_box div {border-bottom: 1px solid #CCC; padding: 3px;}
|
31 |
-
.checkbox_box .clickable {cursor: pointer;}
|
32 |
-
.checkbox_box .clickable:hover {background: #FFC;}
|
33 |
-
|
34 |
-
/* levels */
|
35 |
-
tr.pmpro_gray td {color: #AAA;}
|
36 |
-
tr td.level_name a {font-size: 115%; font-weight: bold; }
|
37 |
-
.membership-levels tr {background: #fff;}
|
38 |
-
.membership-levels tr.alternate {background: #f9f9f9;}
|
39 |
-
.membership-levels tr.ui-sortable-helper {border: 1px solid #2997C8;}
|
40 |
-
tr.testclass {border: 3px solid #2997C8; background: #2997C8;}
|
41 |
-
|
42 |
-
/* settings */
|
43 |
-
tr.pmpro_settings_divider td {padding: 5px; margin: 0; color: #555; border-top: 1px solid #CCC; border-bottom: 1px solid #CCC;}
|
44 |
-
tr.pmpro_settings_divider td:before {content: "- ";}
|
45 |
-
tr.pmpro_settings_divider td:after {content: " -";}
|
46 |
-
|
47 |
-
/* messages */
|
48 |
-
.pmpro_message {background-color: #D5E4F7; background-image: url(../images/icon_information.gif); background-position: 3px 5px; background-repeat: no-repeat; margin: .5em 0; padding: 6px 6px 6px 25px; color: #345395; font-size: 11px; font-weight: bold; line-height: 1.3em; }
|
49 |
-
|
50 |
-
.pmpro_success {background-color: #CFEECA; background-image: url(../images/icon_success.gif); color: #208A1B; }
|
51 |
-
.pmpro_error {background-color: #F9D6CB; background-image: url(../images/icon_error.gif); color: #E36154; }
|
52 |
-
.pmpro_alert {background-color: #FFF6CC; background-image: url(../images/icon_alert.gif); color: #CF8516; }
|
53 |
-
|
54 |
-
.pmpro_message a {color: #345395; }
|
55 |
-
.pmpro_success a {color: #208A1B; }
|
56 |
-
.pmpro_error a {color: #E36154; }
|
57 |
-
.pmpro_alert a {color: #CF8516; }
|
58 |
-
|
59 |
-
/* highlighted trs */
|
60 |
-
tr.pmpro_message {background-image: none;}
|
61 |
-
tr.pmpro_success {background-image: none;}
|
62 |
-
tr.pmpro_error {background-image: none;}
|
63 |
-
tr.pmpro_alert {background-image: none;}
|
64 |
-
|
65 |
-
/* discount levels */
|
66 |
-
.pmpro_discount_levels {border: 1px solid #CCC;}
|
67 |
-
.pmpro_discount_levels div {padding: 5px; border: 1px solid #CCC;}
|
68 |
-
.pmpro_discount_levels div div {margin-top: 5px; background: #F5F5F5;}
|
69 |
-
|
70 |
-
/* pagination */
|
71 |
-
div.pmpro_pagination {padding: 3px; margin: 5px 0px 5px 0px; font-size: 10px; float: right; }
|
72 |
-
div.pmpro_pagination a {padding: 2px 5px 2px 5px; margin: 1px; border: 1px solid #666; text-decoration: none; /* no underline */ color: #666; background: #EEE; }
|
73 |
-
div.pmpro_pagination a:hover, div.pmpro_pagination a:active {background: #FFF; }
|
74 |
-
div.pmpro_pagination span.current {border: 1px solid #FFF; color: #FFF; background: #666; padding: 2px 5px 2px 5px; margin: 1px; font-weight: bold; }
|
75 |
-
div.pmpro_pagination span.disabled {padding: 2px 5px 2px 5px; margin: 2px; border: 1px solid #BBB; color: #BBB; background: #EFEFEF;}
|
76 |
-
|
77 |
-
p.pmpro_meta_notice {font-size: .8em; padding-top: 5px; border-top: 1px solid #CCC;}
|
78 |
-
|
79 |
-
/* add ons */
|
80 |
-
.pmpro_admin .widgets-holder-wrap {clear: both; margin-top: 20px; padding: 0 8px; }
|
81 |
-
.pmpro_admin .widgets-holder-wrap .widget {float: left; width: 32%; margin: 0 1% 1% 0; position: relative; }
|
82 |
-
.pmpro_admin .widgets-holder-wrap p.description {padding: 0; }
|
83 |
-
.pmpro_admin .widgets-holder-wrap .widget-top {height: auto; cursor: default; }
|
84 |
-
.pmpro_admin .widgets-holder-wrap .widget-inside {display: block; height: 130px; overflow: hidden; }
|
85 |
-
.pmpro_admin .widgets-holder-wrap .widget-inside p {height: 80px; overflow: hidden; }
|
86 |
-
.pmpro_admin #pmpro-gists.widgets-holder-wrap .widget-inside, .pmpro_admin #pmpro-gists.widgets-holder-wrap .widget-inside p {height: auto; }
|
87 |
-
.pmpro_admin .widgets-holder-wrap .widget-title { }
|
88 |
-
.pmpro_admin .widgets-holder-wrap .widget-title h4 { }
|
89 |
-
.pmpro_admin .widgets-holder-wrap .widget-title .status-label {display: block; float: left; margin: 0 5px 0 0; width: 10px;
|
90 |
-
height: 10px; overflow: hidden; border-radius: 10px; -moz-border-radius: 10px; -webkit-border-radius: 10px; border: 1px solid #DFDFDF; text-indent: -9999em; }
|
91 |
-
.pmpro_admin .widgets-holder-wrap .disabled .widget-title .status-label {background: #F00; }
|
92 |
-
.pmpro_admin .widgets-holder-wrap .enabled .widget-title .status-label {background: #0C0; }
|
93 |
-
|
94 |
-
.pmpro_admin .widgets-holder-wrap .widget-title .version {position: absolute; top: 13px; right: 10px; }
|
95 |
-
.pmpro_admin .widgets-holder-wrap .widget-inside .addon-thumb {width: 100px; height: 100px; float: right; margin: 10px 0 0 10px; border: 1px solid #DFDFDF; background: #FFF; padding: 2px;}
|
96 |
-
|
97 |
-
/*@media (min-width: 1200px) {
|
98 |
-
.auto-fold .pmpro_admin .widgets-holder-wrap .widget-inside, .auto-fold .pmpro_admin .widgets-holder-wrap .widget-inside p {height: auto; }
|
99 |
-
}
|
100 |
-
*/
|
101 |
-
@media (max-width:900px) {
|
102 |
-
.auto-fold .pmpro_admin .widgets-holder-wrap .widget {float: none; width: 100%; }
|
103 |
-
.auto-fold .pmpro_admin .widgets-holder-wrap .widget-inside, .auto-fold .pmpro_admin .widgets-holder-wrap .widget-inside p {height: auto; }
|
104 |
-
}
|
105 |
-
|
106 |
-
/* misc */
|
107 |
-
.pmpro_lite {color: #AAA;}
|
108 |
-
.pmpro_pad20 {padding: 20px !important;}
|
109 |
-
.pmpro_red {color: #CC0000;}
|
110 |
-
.pmpro_green {color: #00AA00;}
|
111 |
-
.ssp_description #description {width: 100%;}
|
112 |
-
.top0em {margin-top: 0;}
|
113 |
-
h2.nav-tab-wrapper {margin-bottom: 1em; }
|
114 |
-
|
115 |
-
/* reports */
|
116 |
-
.pmpro_reports-holder { }
|
117 |
-
.pmpro_clickable {cursor: pointer;}
|
118 |
-
.js .postbox.pmpro_clickable h3 {cursor: pointer;}
|
|
|
|
|
|
|
|
1 |
+
/* icon */
|
2 |
+
#wp-admin-bar-paid-memberships-pro .ab-item .ab-icon:before {
|
3 |
+
font-family: "dashicons";
|
4 |
+
content: "\f307";
|
5 |
+
}
|
6 |
+
.pmpro_admin tr td .dashicons {padding-top: 5px; }
|
7 |
+
|
8 |
+
/* header/etc */
|
9 |
+
.pmpro_admin {background: url(../images/Paid-Memberships-Pro_watermark.png) bottom right no-repeat !important; padding: 1em 0 70px 0; }
|
10 |
+
|
11 |
+
.pmpro_admin .pmpro_banner h2 {float: left; }
|
12 |
+
.pmpro_admin .pmpro_banner .pmpro_meta {float: left; margin: 26px 0 0 0; font-size: 12px; }
|
13 |
+
.pmpro_admin .pmpro_banner .pmpro_meta .pmpro_tag-blue {margin: 0 0 0 5px; }
|
14 |
+
.pmpro_admin .pmpro_banner .pmpro_logo {float: left; margin: 0 1em 0 0; width: 350px; height: 75px; }
|
15 |
+
.pmpro_admin .pmpro_banner ul.pmpro_menu {clear: both; border: 1px solid #CCC; border-radius: 5px; -moz-border-radius: 5px; background: #FFF; }
|
16 |
+
.pmpro_admin .pmpro_banner ul.pmpro_menu li {display: inline-block; margin: 10px 0; padding: 0px 10px; border-right: 1px solid #CCC; }
|
17 |
+
.pmpro_admin .pmpro_banner ul.pmpro_menu li a, .pmpro_admin .pmpro_banner ul.pmpro_menu li a:link {color: #1e0741; text-decoration: none; }
|
18 |
+
.pmpro_admin .pmpro_banner ul.pmpro_menu li a:hover {text-decoration: underline; color: #412f5b; }
|
19 |
+
|
20 |
+
.pmpro_admin .pmpro_tag-grey {display: inline-block; font-size: 11px; font-weight: bold; position: relative; padding: 2px 5px; border: 1px solid #CCC; background: whiteSmoke; border-radius: 10px; -moz-border-radius: 10px; -webkit-border-radius: 10px; }
|
21 |
+
.pmpro_admin .pmpro_tag-blue {display: inline-block; font-size: 11px; font-weight: bold; position: relative; padding: 2px 5px; border: 1px solid #2997c8; border-radius: 10px; -moz-border-radius: 10px; -webkit-border-radius: 10px; background: #2997c8; color: #FFF; text-decoration: none; }
|
22 |
+
.pmpro_admin a.pmpro_tag-blue:hover {background: #77a02e; border: 1px solid #77a02e; }
|
23 |
+
|
24 |
+
.pmpro_admin .topborder {border-top: 1px solid #CCC; margin-top: 1em; padding-top: 1em; }
|
25 |
+
.pmpro_admin #editorcontainer #description {width: 100%; height: 180px; }
|
26 |
+
.pmpro_admin .widefat {margin-top: 1em; }
|
27 |
+
|
28 |
+
/* checkboxes */
|
29 |
+
.checkbox_box {width: 300px; background: #FFFFFF; border: 1px solid #CCC;}
|
30 |
+
.checkbox_box div {border-bottom: 1px solid #CCC; padding: 3px;}
|
31 |
+
.checkbox_box .clickable {cursor: pointer;}
|
32 |
+
.checkbox_box .clickable:hover {background: #FFC;}
|
33 |
+
|
34 |
+
/* levels */
|
35 |
+
tr.pmpro_gray td {color: #AAA;}
|
36 |
+
tr td.level_name a {font-size: 115%; font-weight: bold; }
|
37 |
+
.membership-levels tr {background: #fff;}
|
38 |
+
.membership-levels tr.alternate {background: #f9f9f9;}
|
39 |
+
.membership-levels tr.ui-sortable-helper {border: 1px solid #2997C8;}
|
40 |
+
tr.testclass {border: 3px solid #2997C8; background: #2997C8;}
|
41 |
+
|
42 |
+
/* settings */
|
43 |
+
tr.pmpro_settings_divider td {padding: 5px; margin: 0; color: #555; border-top: 1px solid #CCC; border-bottom: 1px solid #CCC;}
|
44 |
+
tr.pmpro_settings_divider td:before {content: "- ";}
|
45 |
+
tr.pmpro_settings_divider td:after {content: " -";}
|
46 |
+
|
47 |
+
/* messages */
|
48 |
+
.pmpro_message {background-color: #D5E4F7; background-image: url(../images/icon_information.gif); background-position: 3px 5px; background-repeat: no-repeat; margin: .5em 0; padding: 6px 6px 6px 25px; color: #345395; font-size: 11px; font-weight: bold; line-height: 1.3em; }
|
49 |
+
|
50 |
+
.pmpro_success {background-color: #CFEECA; background-image: url(../images/icon_success.gif); color: #208A1B; }
|
51 |
+
.pmpro_error {background-color: #F9D6CB; background-image: url(../images/icon_error.gif); color: #E36154; }
|
52 |
+
.pmpro_alert {background-color: #FFF6CC; background-image: url(../images/icon_alert.gif); color: #CF8516; }
|
53 |
+
|
54 |
+
.pmpro_message a {color: #345395; }
|
55 |
+
.pmpro_success a {color: #208A1B; }
|
56 |
+
.pmpro_error a {color: #E36154; }
|
57 |
+
.pmpro_alert a {color: #CF8516; }
|
58 |
+
|
59 |
+
/* highlighted trs */
|
60 |
+
tr.pmpro_message {background-image: none;}
|
61 |
+
tr.pmpro_success {background-image: none;}
|
62 |
+
tr.pmpro_error {background-image: none;}
|
63 |
+
tr.pmpro_alert {background-image: none;}
|
64 |
+
|
65 |
+
/* discount levels */
|
66 |
+
.pmpro_discount_levels {border: 1px solid #CCC;}
|
67 |
+
.pmpro_discount_levels div {padding: 5px; border: 1px solid #CCC;}
|
68 |
+
.pmpro_discount_levels div div {margin-top: 5px; background: #F5F5F5;}
|
69 |
+
|
70 |
+
/* pagination */
|
71 |
+
div.pmpro_pagination {padding: 3px; margin: 5px 0px 5px 0px; font-size: 10px; float: right; }
|
72 |
+
div.pmpro_pagination a {padding: 2px 5px 2px 5px; margin: 1px; border: 1px solid #666; text-decoration: none; /* no underline */ color: #666; background: #EEE; }
|
73 |
+
div.pmpro_pagination a:hover, div.pmpro_pagination a:active {background: #FFF; }
|
74 |
+
div.pmpro_pagination span.current {border: 1px solid #FFF; color: #FFF; background: #666; padding: 2px 5px 2px 5px; margin: 1px; font-weight: bold; }
|
75 |
+
div.pmpro_pagination span.disabled {padding: 2px 5px 2px 5px; margin: 2px; border: 1px solid #BBB; color: #BBB; background: #EFEFEF;}
|
76 |
+
|
77 |
+
p.pmpro_meta_notice {font-size: .8em; padding-top: 5px; border-top: 1px solid #CCC;}
|
78 |
+
|
79 |
+
/* add ons */
|
80 |
+
.pmpro_admin .widgets-holder-wrap {clear: both; margin-top: 20px; padding: 0 8px; }
|
81 |
+
.pmpro_admin .widgets-holder-wrap .widget {float: left; width: 32%; margin: 0 1% 1% 0; position: relative; }
|
82 |
+
.pmpro_admin .widgets-holder-wrap p.description {padding: 0; }
|
83 |
+
.pmpro_admin .widgets-holder-wrap .widget-top {height: auto; cursor: default; }
|
84 |
+
.pmpro_admin .widgets-holder-wrap .widget-inside {display: block; height: 130px; overflow: hidden; }
|
85 |
+
.pmpro_admin .widgets-holder-wrap .widget-inside p {height: 80px; overflow: hidden; }
|
86 |
+
.pmpro_admin #pmpro-gists.widgets-holder-wrap .widget-inside, .pmpro_admin #pmpro-gists.widgets-holder-wrap .widget-inside p {height: auto; }
|
87 |
+
.pmpro_admin .widgets-holder-wrap .widget-title { }
|
88 |
+
.pmpro_admin .widgets-holder-wrap .widget-title h4 { }
|
89 |
+
.pmpro_admin .widgets-holder-wrap .widget-title .status-label {display: block; float: left; margin: 0 5px 0 0; width: 10px;
|
90 |
+
height: 10px; overflow: hidden; border-radius: 10px; -moz-border-radius: 10px; -webkit-border-radius: 10px; border: 1px solid #DFDFDF; text-indent: -9999em; }
|
91 |
+
.pmpro_admin .widgets-holder-wrap .disabled .widget-title .status-label {background: #F00; }
|
92 |
+
.pmpro_admin .widgets-holder-wrap .enabled .widget-title .status-label {background: #0C0; }
|
93 |
+
|
94 |
+
.pmpro_admin .widgets-holder-wrap .widget-title .version {position: absolute; top: 13px; right: 10px; }
|
95 |
+
.pmpro_admin .widgets-holder-wrap .widget-inside .addon-thumb {width: 100px; height: 100px; float: right; margin: 10px 0 0 10px; border: 1px solid #DFDFDF; background: #FFF; padding: 2px;}
|
96 |
+
|
97 |
+
/*@media (min-width: 1200px) {
|
98 |
+
.auto-fold .pmpro_admin .widgets-holder-wrap .widget-inside, .auto-fold .pmpro_admin .widgets-holder-wrap .widget-inside p {height: auto; }
|
99 |
+
}
|
100 |
+
*/
|
101 |
+
@media (max-width:900px) {
|
102 |
+
.auto-fold .pmpro_admin .widgets-holder-wrap .widget {float: none; width: 100%; }
|
103 |
+
.auto-fold .pmpro_admin .widgets-holder-wrap .widget-inside, .auto-fold .pmpro_admin .widgets-holder-wrap .widget-inside p {height: auto; }
|
104 |
+
}
|
105 |
+
|
106 |
+
/* misc */
|
107 |
+
.pmpro_lite {color: #AAA;}
|
108 |
+
.pmpro_pad20 {padding: 20px !important;}
|
109 |
+
.pmpro_red {color: #CC0000;}
|
110 |
+
.pmpro_green {color: #00AA00;}
|
111 |
+
.ssp_description #description {width: 100%;}
|
112 |
+
.top0em {margin-top: 0;}
|
113 |
+
h2.nav-tab-wrapper {margin-bottom: 1em; }
|
114 |
+
|
115 |
+
/* reports */
|
116 |
+
.pmpro_reports-holder { }
|
117 |
+
.pmpro_clickable {cursor: pointer;}
|
118 |
+
.js .postbox.pmpro_clickable h3 {cursor: pointer;}
|
119 |
+
.pmpro_reports-holder .wp-list-table tbody td {font-size: 1.2rem; font-weight: bold; }
|
120 |
+
@media screen and (max-width: 782px) {
|
121 |
+
.pmpro_reports-holder tr:not(.inline-edit-row):not(.no-items) td:not(.check-column) {display: table-cell; }
|
122 |
+
}
|
includes/content.php
CHANGED
@@ -323,7 +323,7 @@ function pmpro_membership_content_filter($content, $skipcheck = false)
|
|
323 |
$pmpro_content_message_post = '</div>';
|
324 |
|
325 |
$sr_search = array("!!levels!!", "!!referrer!!");
|
326 |
-
$sr_replace = array(pmpro_implodeToEnglish($post_membership_levels_names), $_SERVER['REQUEST_URI']);
|
327 |
|
328 |
//get the correct message to show at the bottom
|
329 |
if(is_feed())
|
@@ -472,10 +472,16 @@ add_action('wp', 'pmpro_hide_pages_redirect');
|
|
472 |
*
|
473 |
* @since 1.8.5.4
|
474 |
*/
|
475 |
-
function pmpro_post_classes( $classes ) {
|
476 |
-
|
|
|
|
|
|
|
|
|
|
|
477 |
$post_levels = array();
|
478 |
$post_levels = pmpro_has_membership_access($post->ID,NULL,true);
|
|
|
479 |
if(!empty($post_levels))
|
480 |
{
|
481 |
if(!empty($post_levels[1]))
|
@@ -489,4 +495,42 @@ function pmpro_post_classes( $classes ) {
|
|
489 |
}
|
490 |
return $classes;
|
491 |
}
|
492 |
-
add_filter( 'post_class', 'pmpro_post_classes' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
323 |
$pmpro_content_message_post = '</div>';
|
324 |
|
325 |
$sr_search = array("!!levels!!", "!!referrer!!");
|
326 |
+
$sr_replace = array(pmpro_implodeToEnglish($post_membership_levels_names), site_url($_SERVER['REQUEST_URI']));
|
327 |
|
328 |
//get the correct message to show at the bottom
|
329 |
if(is_feed())
|
472 |
*
|
473 |
* @since 1.8.5.4
|
474 |
*/
|
475 |
+
function pmpro_post_classes( $classes, $class, $post_id ) {
|
476 |
+
|
477 |
+
$post = get_post($post_id);
|
478 |
+
|
479 |
+
if(empty($post))
|
480 |
+
return $classes;
|
481 |
+
|
482 |
$post_levels = array();
|
483 |
$post_levels = pmpro_has_membership_access($post->ID,NULL,true);
|
484 |
+
|
485 |
if(!empty($post_levels))
|
486 |
{
|
487 |
if(!empty($post_levels[1]))
|
495 |
}
|
496 |
return $classes;
|
497 |
}
|
498 |
+
add_filter( 'post_class', 'pmpro_post_classes', 10, 3 );
|
499 |
+
|
500 |
+
/**
|
501 |
+
* Adds custom classes to the array of body classes.
|
502 |
+
* Same as the above, but acts on the "queried object" instead of the post global.
|
503 |
+
*
|
504 |
+
* pmpro-body-level-required = this post requires at least one level
|
505 |
+
* pmpro-body-level-1 = this post requires level 1
|
506 |
+
* pmpro-body-has-access = this post is usually locked, but the current user has access to this post
|
507 |
+
*
|
508 |
+
* @param array $classes Classes for the body element.
|
509 |
+
* @return array
|
510 |
+
*
|
511 |
+
* @since 1.8.6.1
|
512 |
+
*/
|
513 |
+
function pmpro_body_classes( $classes ) {
|
514 |
+
|
515 |
+
$post = get_queried_object();
|
516 |
+
|
517 |
+
if(empty($post) || !is_singular())
|
518 |
+
return $classes;
|
519 |
+
|
520 |
+
$post_levels = array();
|
521 |
+
$post_levels = pmpro_has_membership_access($post->ID,NULL,true);
|
522 |
+
|
523 |
+
if(!empty($post_levels))
|
524 |
+
{
|
525 |
+
if(!empty($post_levels[1]))
|
526 |
+
{
|
527 |
+
$classes[] = 'pmpro-body-level-required';
|
528 |
+
foreach($post_levels[1] as $post_level)
|
529 |
+
$classes[] = 'pmpro-body-level-' . $post_level[0];
|
530 |
+
}
|
531 |
+
if(!empty($post_levels[0]) && $post_levels[0] == true)
|
532 |
+
$classes[] = 'pmpro-body-has-access';
|
533 |
+
}
|
534 |
+
return $classes;
|
535 |
+
}
|
536 |
+
add_filter( 'body_class', 'pmpro_body_classes' );
|
includes/functions.php
CHANGED
@@ -1,2116 +1,2157 @@
|
|
1 |
-
<?php
|
2 |
-
/****************************************************************
|
3 |
-
|
4 |
-
IMPORTANT. PLEASE READ.
|
5 |
-
|
6 |
-
DO NOT EDIT THIS FILE or any other file in the /wp-content/plugins/paid-memberships-pro/ directory.
|
7 |
-
Doing so could break the PMPro plugin and/or keep you from upgrading this plugin in the future.
|
8 |
-
We regularly release updates to the plugin, including important security fixes and new features.
|
9 |
-
You want to be able to upgrade.
|
10 |
-
|
11 |
-
If you were asked to insert code into "your functions.php file", it was meant that you edit the functions.php
|
12 |
-
in the root folder of your active theme. e.g. /wp-content/themes/twentytwelve/functions.php
|
13 |
-
You can also create a custom plugin to place customization code into. Instructions are here:
|
14 |
-
http://www.paidmembershipspro.com/2012/08/create-a-plugin-for-pmpro-customizations/
|
15 |
-
|
16 |
-
Further documentation for customizing Paid Memberships Pro can be found here:
|
17 |
-
http://www.paidmembershipspro.com/documentation/
|
18 |
-
|
19 |
-
****************************************************************/
|
20 |
-
if(!function_exists("sornot"))
|
21 |
-
{
|
22 |
-
function sornot($t, $n)
|
23 |
-
{
|
24 |
-
if($n == 1)
|
25 |
-
return $t;
|
26 |
-
else
|
27 |
-
return $t . "s";
|
28 |
-
}
|
29 |
-
}
|
30 |
-
|
31 |
-
//set up wpdb for the tables we need
|
32 |
-
function pmpro_setDBTables()
|
33 |
-
{
|
34 |
-
global $wpdb;
|
35 |
-
$wpdb->hide_errors();
|
36 |
-
$wpdb->pmpro_membership_levels = $wpdb->prefix . 'pmpro_membership_levels';
|
37 |
-
$wpdb->pmpro_memberships_users = $wpdb->prefix . 'pmpro_memberships_users';
|
38 |
-
$wpdb->pmpro_memberships_categories = $wpdb->prefix . 'pmpro_memberships_categories';
|
39 |
-
$wpdb->pmpro_memberships_pages = $wpdb->prefix . 'pmpro_memberships_pages';
|
40 |
-
$wpdb->pmpro_membership_orders = $wpdb->prefix . 'pmpro_membership_orders';
|
41 |
-
$wpdb->pmpro_discount_codes = $wpdb->prefix . 'pmpro_discount_codes';
|
42 |
-
$wpdb->pmpro_discount_codes_levels = $wpdb->prefix . 'pmpro_discount_codes_levels';
|
43 |
-
$wpdb->pmpro_discount_codes_uses = $wpdb->prefix . 'pmpro_discount_codes_uses';
|
44 |
-
}
|
45 |
-
pmpro_setDBTables();
|
46 |
-
|
47 |
-
//from: http://stackoverflow.com/questions/5266945/wordpress-how-detect-if-current-page-is-the-login-page/5892694#5892694
|
48 |
-
function pmpro_is_login_page() {
|
49 |
-
return (in_array($GLOBALS['pagenow'], array('wp-login.php', 'wp-register.php')) || is_page("login"));
|
50 |
-
}
|
51 |
-
|
52 |
-
//thanks: http://wordpress.org/support/topic/is_plugin_active
|
53 |
-
function pmpro_is_plugin_active( $plugin ) {
|
54 |
-
return in_array( $plugin, (array) get_option( 'active_plugins', array() ) );
|
55 |
-
}
|
56 |
-
|
57 |
-
//scraping - override n if you have more than 1 group of matches and don't want the first group
|
58 |
-
function pmpro_getMatches($p, $s, $firstvalue = FALSE, $n = 1)
|
59 |
-
{
|
60 |
-
$ok = preg_match_all($p, $s, $matches);
|
61 |
-
|
62 |
-
if(!$ok)
|
63 |
-
return false;
|
64 |
-
else
|
65 |
-
{
|
66 |
-
if($firstvalue)
|
67 |
-
return $matches[$n][0];
|
68 |
-
else
|
69 |
-
return $matches[$n];
|
70 |
-
}
|
71 |
-
}
|
72 |
-
|
73 |
-
function pmpro_br2nl($text, $tags = "br")
|
74 |
-
{
|
75 |
-
if(!is_array($tags))
|
76 |
-
$tags = explode(" ", $tags);
|
77 |
-
|
78 |
-
foreach($tags as $tag)
|
79 |
-
{
|
80 |
-
$text = eregi_replace("<" . $tag . "[^>]*>", "\n", $text);
|
81 |
-
$text = eregi_replace("</" . $tag . "[^>]*>", "\n", $text);
|
82 |
-
}
|
83 |
-
|
84 |
-
return($text);
|
85 |
-
}
|
86 |
-
|
87 |
-
function pmpro_getOption($s, $force = false)
|
88 |
-
{
|
89 |
-
if(get_option("pmpro_" . $s))
|
90 |
-
return get_option("pmpro_" . $s);
|
91 |
-
else
|
92 |
-
return "";
|
93 |
-
}
|
94 |
-
|
95 |
-
function pmpro_setOption($s, $v = NULL)
|
96 |
-
{
|
97 |
-
//no value is given, set v to the p var
|
98 |
-
if($v === NULL && isset($_POST[$s]))
|
99 |
-
$v = $_POST[$s];
|
100 |
-
|
101 |
-
if(is_array($v))
|
102 |
-
$v = implode(",", $v);
|
103 |
-
else
|
104 |
-
$v = trim($v);
|
105 |
-
|
106 |
-
return update_option("pmpro_" . $s, $v);
|
107 |
-
}
|
108 |
-
|
109 |
-
function pmpro_get_slug($post_id)
|
110 |
-
{
|
111 |
-
global $pmpro_slugs, $wpdb;
|
112 |
-
|
113 |
-
//make sure post id is int for security
|
114 |
-
$post_id = intval($post_id);
|
115 |
-
|
116 |
-
if(!$pmpro_slugs[$post_id])
|
117 |
-
$pmpro_slugs[$post_id] = $wpdb->get_var("SELECT post_name FROM $wpdb->posts WHERE ID = '" . $post_id . "' LIMIT 1");
|
118 |
-
|
119 |
-
return $pmpro_slugs[$post_id];
|
120 |
-
}
|
121 |
-
|
122 |
-
function pmpro_url($page = NULL, $querystring = "", $scheme = NULL)
|
123 |
-
{
|
124 |
-
global $besecure;
|
125 |
-
$besecure = apply_filters("besecure", $besecure);
|
126 |
-
|
127 |
-
if(!$scheme && $besecure)
|
128 |
-
$scheme = "https";
|
129 |
-
elseif(!$scheme)
|
130 |
-
$scheme = "http";
|
131 |
-
|
132 |
-
if(!$page)
|
133 |
-
$page = "levels";
|
134 |
-
|
135 |
-
global $pmpro_pages;
|
136 |
-
|
137 |
-
//start with the permalink
|
138 |
-
$url = get_permalink($pmpro_pages[$page]);
|
139 |
-
|
140 |
-
//WPML/etc support
|
141 |
-
if(function_exists("icl_object_id") && defined("ICL_LANGUAGE_CODE"))
|
142 |
-
{
|
143 |
-
$trans_id = icl_object_id($pmpro_pages[$page], "page", false, ICL_LANGUAGE_CODE);
|
144 |
-
if(!empty($trans_id))
|
145 |
-
{
|
146 |
-
$url = get_permalink($trans_id);
|
147 |
-
}
|
148 |
-
}
|
149 |
-
|
150 |
-
//figure out querystring
|
151 |
-
if(strpos($url, "?"))
|
152 |
-
$querystring = str_replace("?", "&", $querystring);
|
153 |
-
$url .= $querystring;
|
154 |
-
|
155 |
-
//figure out scheme
|
156 |
-
if(is_ssl())
|
157 |
-
$url = str_replace("http:", "https:", $url);
|
158 |
-
|
159 |
-
return $url;
|
160 |
-
}
|
161 |
-
|
162 |
-
function pmpro_isLevelFree(&$level)
|
163 |
-
{
|
164 |
-
if(!empty($level) && $level->initial_payment <= 0 && $level->billing_amount <= 0 && $level->trial_amount <= 0)
|
165 |
-
return true;
|
166 |
-
else
|
167 |
-
return false;
|
168 |
-
}
|
169 |
-
|
170 |
-
function pmpro_isLevelRecurring(&$level)
|
171 |
-
{
|
172 |
-
if(!empty($level) && ($level->billing_amount > 0 || $level->trial_amount > 0))
|
173 |
-
return true;
|
174 |
-
else
|
175 |
-
return false;
|
176 |
-
}
|
177 |
-
|
178 |
-
function pmpro_isLevelTrial(&$level)
|
179 |
-
{
|
180 |
-
if($level->trial_limit > 0)
|
181 |
-
{
|
182 |
-
return true;
|
183 |
-
}
|
184 |
-
else
|
185 |
-
return false;
|
186 |
-
}
|
187 |
-
|
188 |
-
function pmpro_isLevelExpiring(&$level)
|
189 |
-
{
|
190 |
-
if($level->expiration_number > 0)
|
191 |
-
return true;
|
192 |
-
else
|
193 |
-
return false;
|
194 |
-
}
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
{
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
}
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
}
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
$r
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
}
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
}
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
}
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
{
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
if(
|
435 |
-
{
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
}
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
$
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
return
|
818 |
-
}
|
819 |
-
}
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
*
|
841 |
-
* $
|
842 |
-
*
|
843 |
-
*
|
844 |
-
*
|
845 |
-
*
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
}
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
*
|
881 |
-
* $
|
882 |
-
*
|
883 |
-
*
|
884 |
-
*
|
885 |
-
*
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
$
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
}
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
-
|
941 |
-
|
942 |
-
|
943 |
-
|
944 |
-
|
945 |
-
|
946 |
-
|
947 |
-
|
948 |
-
|
949 |
-
|
950 |
-
|
951 |
-
|
952 |
-
|
953 |
-
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
|
959 |
-
|
960 |
-
|
961 |
-
|
962 |
-
|
963 |
-
|
964 |
-
|
965 |
-
|
966 |
-
|
967 |
-
|
968 |
-
|
969 |
-
|
970 |
-
|
971 |
-
|
972 |
-
|
973 |
-
|
974 |
-
|
975 |
-
|
976 |
-
|
977 |
-
|
978 |
-
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
-
|
983 |
-
|
984 |
-
|
985 |
-
|
986 |
-
|
987 |
-
|
988 |
-
|
989 |
-
|
990 |
-
|
991 |
-
|
992 |
-
|
993 |
-
|
994 |
-
|
995 |
-
|
996 |
-
|
997 |
-
|
998 |
-
|
999 |
-
|
1000 |
-
|
1001 |
-
|
1002 |
-
|
1003 |
-
|
1004 |
-
|
1005 |
-
|
1006 |
-
|
1007 |
-
|
1008 |
-
|
1009 |
-
|
1010 |
-
|
1011 |
-
|
1012 |
-
|
1013 |
-
|
1014 |
-
|
1015 |
-
|
1016 |
-
|
1017 |
-
|
1018 |
-
|
1019 |
-
|
1020 |
-
|
1021 |
-
|
1022 |
-
|
1023 |
-
|
1024 |
-
|
1025 |
-
|
1026 |
-
|
1027 |
-
|
1028 |
-
|
1029 |
-
|
1030 |
-
|
1031 |
-
|
1032 |
-
|
1033 |
-
|
1034 |
-
$pagination .= "
|
1035 |
-
|
1036 |
-
|
1037 |
-
|
1038 |
-
|
1039 |
-
|
1040 |
-
|
1041 |
-
|
1042 |
-
|
1043 |
-
|
1044 |
-
|
1045 |
-
|
1046 |
-
|
1047 |
-
|
1048 |
-
|
1049 |
-
|
1050 |
-
|
1051 |
-
|
1052 |
-
|
1053 |
-
|
1054 |
-
|
1055 |
-
|
1056 |
-
|
1057 |
-
|
1058 |
-
|
1059 |
-
|
1060 |
-
|
1061 |
-
|
1062 |
-
|
1063 |
-
|
1064 |
-
|
1065 |
-
|
1066 |
-
|
1067 |
-
|
1068 |
-
|
1069 |
-
|
1070 |
-
|
1071 |
-
|
1072 |
-
|
1073 |
-
|
1074 |
-
|
1075 |
-
|
1076 |
-
|
1077 |
-
|
1078 |
-
|
1079 |
-
|
1080 |
-
|
1081 |
-
|
1082 |
-
|
1083 |
-
|
1084 |
-
|
1085 |
-
|
1086 |
-
|
1087 |
-
|
1088 |
-
|
1089 |
-
|
1090 |
-
|
1091 |
-
|
1092 |
-
|
1093 |
-
|
1094 |
-
|
1095 |
-
|
1096 |
-
|
1097 |
-
|
1098 |
-
|
1099 |
-
|
1100 |
-
|
1101 |
-
|
1102 |
-
|
1103 |
-
|
1104 |
-
|
1105 |
-
|
1106 |
-
|
1107 |
-
|
1108 |
-
|
1109 |
-
$
|
1110 |
-
|
1111 |
-
|
1112 |
-
|
1113 |
-
|
1114 |
-
|
1115 |
-
|
1116 |
-
|
1117 |
-
|
1118 |
-
|
1119 |
-
|
1120 |
-
|
1121 |
-
|
1122 |
-
|
1123 |
-
|
1124 |
-
|
1125 |
-
|
1126 |
-
|
1127 |
-
|
1128 |
-
|
1129 |
-
|
1130 |
-
|
1131 |
-
|
1132 |
-
|
1133 |
-
|
1134 |
-
|
1135 |
-
|
1136 |
-
|
1137 |
-
|
1138 |
-
|
1139 |
-
|
1140 |
-
|
1141 |
-
|
1142 |
-
|
1143 |
-
|
1144 |
-
|
1145 |
-
|
1146 |
-
if($
|
1147 |
-
{
|
1148 |
-
$
|
1149 |
-
|
1150 |
-
|
1151 |
-
|
1152 |
-
|
1153 |
-
|
1154 |
-
|
1155 |
-
|
1156 |
-
$
|
1157 |
-
|
1158 |
-
|
1159 |
-
|
1160 |
-
|
1161 |
-
|
1162 |
-
|
1163 |
-
|
1164 |
-
|
1165 |
-
|
1166 |
-
|
1167 |
-
|
1168 |
-
|
1169 |
-
|
1170 |
-
|
1171 |
-
|
1172 |
-
|
1173 |
-
|
1174 |
-
|
1175 |
-
|
1176 |
-
|
1177 |
-
$
|
1178 |
-
|
1179 |
-
|
1180 |
-
|
1181 |
-
|
1182 |
-
|
1183 |
-
|
1184 |
-
|
1185 |
-
|
1186 |
-
|
1187 |
-
|
1188 |
-
|
1189 |
-
|
1190 |
-
|
1191 |
-
|
1192 |
-
|
1193 |
-
|
1194 |
-
|
1195 |
-
|
1196 |
-
|
1197 |
-
|
1198 |
-
|
1199 |
-
|
1200 |
-
|
1201 |
-
|
1202 |
-
|
1203 |
-
|
1204 |
-
|
1205 |
-
|
1206 |
-
|
1207 |
-
|
1208 |
-
|
1209 |
-
|
1210 |
-
|
1211 |
-
|
1212 |
-
|
1213 |
-
|
1214 |
-
|
1215 |
-
|
1216 |
-
|
1217 |
-
|
1218 |
-
|
1219 |
-
$
|
1220 |
-
|
1221 |
-
|
1222 |
-
|
1223 |
-
|
1224 |
-
|
1225 |
-
|
1226 |
-
|
1227 |
-
|
1228 |
-
|
1229 |
-
|
1230 |
-
|
1231 |
-
$
|
1232 |
-
|
1233 |
-
|
1234 |
-
|
1235 |
-
|
1236 |
-
|
1237 |
-
|
1238 |
-
|
1239 |
-
|
1240 |
-
|
1241 |
-
|
1242 |
-
|
1243 |
-
|
1244 |
-
|
1245 |
-
|
1246 |
-
$
|
1247 |
-
|
1248 |
-
|
1249 |
-
|
1250 |
-
|
1251 |
-
|
1252 |
-
|
1253 |
-
|
1254 |
-
|
1255 |
-
|
1256 |
-
|
1257 |
-
|
1258 |
-
|
1259 |
-
|
1260 |
-
|
1261 |
-
|
1262 |
-
|
1263 |
-
|
1264 |
-
|
1265 |
-
|
1266 |
-
|
1267 |
-
|
1268 |
-
|
1269 |
-
|
1270 |
-
|
1271 |
-
|
1272 |
-
|
1273 |
-
|
1274 |
-
|
1275 |
-
if(
|
1276 |
-
|
1277 |
-
|
1278 |
-
|
1279 |
-
|
1280 |
-
|
1281 |
-
|
1282 |
-
|
1283 |
-
|
1284 |
-
|
1285 |
-
|
1286 |
-
|
1287 |
-
$
|
1288 |
-
|
1289 |
-
|
1290 |
-
|
1291 |
-
|
1292 |
-
|
1293 |
-
|
1294 |
-
if
|
1295 |
-
|
1296 |
-
|
1297 |
-
if(!empty($
|
1298 |
-
|
1299 |
-
|
1300 |
-
|
1301 |
-
|
1302 |
-
|
1303 |
-
{
|
1304 |
-
|
1305 |
-
|
1306 |
-
|
1307 |
-
|
1308 |
-
|
1309 |
-
|
1310 |
-
}
|
1311 |
-
|
1312 |
-
|
1313 |
-
|
1314 |
-
|
1315 |
-
|
1316 |
-
|
1317 |
-
|
1318 |
-
|
1319 |
-
|
1320 |
-
|
1321 |
-
|
1322 |
-
|
1323 |
-
|
1324 |
-
|
1325 |
-
|
1326 |
-
|
1327 |
-
|
1328 |
-
|
1329 |
-
|
1330 |
-
|
1331 |
-
|
1332 |
-
|
1333 |
-
|
1334 |
-
//
|
1335 |
-
|
1336 |
-
{
|
1337 |
-
|
1338 |
-
|
1339 |
-
|
1340 |
-
|
1341 |
-
|
1342 |
-
|
1343 |
-
|
1344 |
-
|
1345 |
-
|
1346 |
-
|
1347 |
-
|
1348 |
-
|
1349 |
-
|
1350 |
-
|
1351 |
-
|
1352 |
-
|
1353 |
-
function
|
1354 |
-
{
|
1355 |
-
|
1356 |
-
|
1357 |
-
|
1358 |
-
|
1359 |
-
|
1360 |
-
|
1361 |
-
|
1362 |
-
|
1363 |
-
return
|
1364 |
-
|
1365 |
-
|
1366 |
-
|
1367 |
-
|
1368 |
-
|
1369 |
-
|
1370 |
-
|
1371 |
-
|
1372 |
-
|
1373 |
-
|
1374 |
-
|
1375 |
-
|
1376 |
-
|
1377 |
-
|
1378 |
-
|
1379 |
-
|
1380 |
-
|
1381 |
-
|
1382 |
-
|
1383 |
-
|
1384 |
-
|
1385 |
-
|
1386 |
-
|
1387 |
-
|
1388 |
-
|
1389 |
-
|
1390 |
-
|
1391 |
-
|
1392 |
-
|
1393 |
-
|
1394 |
-
|
1395 |
-
|
1396 |
-
|
1397 |
-
|
1398 |
-
|
1399 |
-
|
1400 |
-
|
1401 |
-
|
1402 |
-
|
1403 |
-
|
1404 |
-
|
1405 |
-
|
1406 |
-
|
1407 |
-
|
1408 |
-
|
1409 |
-
|
1410 |
-
|
1411 |
-
|
1412 |
-
|
1413 |
-
|
1414 |
-
|
1415 |
-
|
1416 |
-
|
1417 |
-
|
1418 |
-
|
1419 |
-
|
1420 |
-
|
1421 |
-
|
1422 |
-
|
1423 |
-
|
1424 |
-
|
1425 |
-
|
1426 |
-
|
1427 |
-
|
1428 |
-
|
1429 |
-
|
1430 |
-
|
1431 |
-
|
1432 |
-
|
1433 |
-
|
1434 |
-
|
1435 |
-
|
1436 |
-
|
1437 |
-
|
1438 |
-
|
1439 |
-
|
1440 |
-
|
1441 |
-
|
1442 |
-
|
1443 |
-
|
1444 |
-
|
1445 |
-
|
1446 |
-
|
1447 |
-
|
1448 |
-
|
1449 |
-
|
1450 |
-
|
1451 |
-
|
1452 |
-
|
1453 |
-
|
1454 |
-
|
1455 |
-
|
1456 |
-
|
1457 |
-
|
1458 |
-
|
1459 |
-
|
1460 |
-
|
1461 |
-
|
1462 |
-
|
1463 |
-
|
1464 |
-
|
1465 |
-
|
1466 |
-
|
1467 |
-
|
1468 |
-
|
1469 |
-
|
1470 |
-
|
1471 |
-
|
1472 |
-
|
1473 |
-
|
1474 |
-
|
1475 |
-
|
1476 |
-
|
1477 |
-
|
1478 |
-
|
1479 |
-
|
1480 |
-
|
1481 |
-
|
1482 |
-
|
1483 |
-
|
1484 |
-
|
1485 |
-
|
1486 |
-
|
1487 |
-
|
1488 |
-
|
1489 |
-
|
1490 |
-
|
1491 |
-
|
1492 |
-
|
1493 |
-
|
1494 |
-
|
1495 |
-
|
1496 |
-
|
1497 |
-
|
1498 |
-
|
1499 |
-
|
1500 |
-
|
1501 |
-
|
1502 |
-
|
1503 |
-
|
1504 |
-
|
1505 |
-
|
1506 |
-
|
1507 |
-
|
1508 |
-
|
1509 |
-
|
1510 |
-
|
1511 |
-
|
1512 |
-
|
1513 |
-
|
1514 |
-
|
1515 |
-
|
1516 |
-
|
1517 |
-
|
1518 |
-
|
1519 |
-
|
1520 |
-
|
1521 |
-
|
1522 |
-
|
1523 |
-
|
1524 |
-
|
1525 |
-
|
1526 |
-
*/
|
1527 |
-
function
|
1528 |
-
{
|
1529 |
-
global $pmpro_levels
|
1530 |
-
|
1531 |
-
|
1532 |
-
|
1533 |
-
|
1534 |
-
|
1535 |
-
|
1536 |
-
|
1537 |
-
|
1538 |
-
$
|
1539 |
-
|
1540 |
-
|
1541 |
-
|
1542 |
-
|
1543 |
-
|
1544 |
-
|
1545 |
-
|
1546 |
-
|
1547 |
-
|
1548 |
-
}
|
1549 |
-
|
1550 |
-
|
1551 |
-
|
1552 |
-
|
1553 |
-
|
1554 |
-
|
1555 |
-
|
1556 |
-
|
1557 |
-
|
1558 |
-
|
1559 |
-
$
|
1560 |
-
|
1561 |
-
|
1562 |
-
|
1563 |
-
|
1564 |
-
|
1565 |
-
|
1566 |
-
|
1567 |
-
|
1568 |
-
|
1569 |
-
|
1570 |
-
|
1571 |
-
|
1572 |
-
|
1573 |
-
|
1574 |
-
|
1575 |
-
|
1576 |
-
|
1577 |
-
|
1578 |
-
|
1579 |
-
|
1580 |
-
|
1581 |
-
|
1582 |
-
|
1583 |
-
|
1584 |
-
|
1585 |
-
|
1586 |
-
|
1587 |
-
|
1588 |
-
|
1589 |
-
|
1590 |
-
|
1591 |
-
|
1592 |
-
|
1593 |
-
|
1594 |
-
|
1595 |
-
|
1596 |
-
|
1597 |
-
|
1598 |
-
|
1599 |
-
|
1600 |
-
|
1601 |
-
|
1602 |
-
if(
|
1603 |
-
|
1604 |
-
|
1605 |
-
|
1606 |
-
|
1607 |
-
|
1608 |
-
|
1609 |
-
|
1610 |
-
|
1611 |
-
|
1612 |
-
|
1613 |
-
|
1614 |
-
|
1615 |
-
|
1616 |
-
|
1617 |
-
|
1618 |
-
|
1619 |
-
|
1620 |
-
|
1621 |
-
|
1622 |
-
|
1623 |
-
|
1624 |
-
|
1625 |
-
|
1626 |
-
|
1627 |
-
|
1628 |
-
|
1629 |
-
|
1630 |
-
|
1631 |
-
|
1632 |
-
|
1633 |
-
|
1634 |
-
|
1635 |
-
|
1636 |
-
|
1637 |
-
|
1638 |
-
|
1639 |
-
|
1640 |
-
|
1641 |
-
|
1642 |
-
|
1643 |
-
|
1644 |
-
|
1645 |
-
|
1646 |
-
|
1647 |
-
|
1648 |
-
|
1649 |
-
|
1650 |
-
|
1651 |
-
|
1652 |
-
|
1653 |
-
|
1654 |
-
|
1655 |
-
|
1656 |
-
|
1657 |
-
|
1658 |
-
|
1659 |
-
|
1660 |
-
|
1661 |
-
|
1662 |
-
|
1663 |
-
|
1664 |
-
$
|
1665 |
-
}
|
1666 |
-
|
1667 |
-
|
1668 |
-
|
1669 |
-
|
1670 |
-
|
1671 |
-
|
1672 |
-
|
1673 |
-
|
1674 |
-
|
1675 |
-
|
1676 |
-
|
1677 |
-
|
1678 |
-
|
1679 |
-
|
1680 |
-
|
1681 |
-
|
1682 |
-
|
1683 |
-
|
1684 |
-
|
1685 |
-
|
1686 |
-
|
1687 |
-
|
1688 |
-
|
1689 |
-
|
1690 |
-
|
1691 |
-
|
1692 |
-
|
1693 |
-
|
1694 |
-
|
1695 |
-
|
1696 |
-
|
1697 |
-
|
1698 |
-
|
1699 |
-
|
1700 |
-
|
1701 |
-
|
1702 |
-
|
1703 |
-
|
1704 |
-
|
1705 |
-
|
1706 |
-
|
1707 |
-
|
1708 |
-
|
1709 |
-
|
1710 |
-
|
1711 |
-
|
1712 |
-
|
1713 |
-
|
1714 |
-
|
1715 |
-
|
1716 |
-
|
1717 |
-
|
1718 |
-
|
1719 |
-
|
1720 |
-
|
1721 |
-
|
1722 |
-
|
1723 |
-
|
1724 |
-
|
1725 |
-
|
1726 |
-
|
1727 |
-
|
1728 |
-
|
1729 |
-
|
1730 |
-
|
1731 |
-
|
1732 |
-
|
1733 |
-
|
1734 |
-
|
1735 |
-
|
1736 |
-
|
1737 |
-
|
1738 |
-
|
1739 |
-
|
1740 |
-
|
1741 |
-
|
1742 |
-
|
1743 |
-
|
1744 |
-
|
1745 |
-
|
1746 |
-
|
1747 |
-
|
1748 |
-
|
1749 |
-
|
1750 |
-
|
1751 |
-
|
1752 |
-
|
1753 |
-
|
1754 |
-
$
|
1755 |
-
|
1756 |
-
|
1757 |
-
|
1758 |
-
|
1759 |
-
|
1760 |
-
|
1761 |
-
|
1762 |
-
|
1763 |
-
|
1764 |
-
|
1765 |
-
|
1766 |
-
|
1767 |
-
|
1768 |
-
|
1769 |
-
|
1770 |
-
|
1771 |
-
|
1772 |
-
|
1773 |
-
|
1774 |
-
|
1775 |
-
|
1776 |
-
|
1777 |
-
|
1778 |
-
|
1779 |
-
|
1780 |
-
|
1781 |
-
|
1782 |
-
|
1783 |
-
|
1784 |
-
|
1785 |
-
|
1786 |
-
{
|
1787 |
-
|
1788 |
-
|
1789 |
-
|
1790 |
-
|
1791 |
-
|
1792 |
-
|
1793 |
-
|
1794 |
-
|
1795 |
-
|
1796 |
-
|
1797 |
-
|
1798 |
-
|
1799 |
-
|
1800 |
-
|
1801 |
-
|
1802 |
-
$
|
1803 |
-
|
1804 |
-
|
1805 |
-
|
1806 |
-
|
1807 |
-
if(!empty($
|
1808 |
-
|
1809 |
-
|
1810 |
-
|
1811 |
-
|
1812 |
-
|
1813 |
-
|
1814 |
-
|
1815 |
-
|
1816 |
-
|
1817 |
-
|
1818 |
-
|
1819 |
-
|
1820 |
-
|
1821 |
-
|
1822 |
-
|
1823 |
-
|
1824 |
-
|
1825 |
-
|
1826 |
-
|
1827 |
-
|
1828 |
-
|
1829 |
-
|
1830 |
-
}
|
1831 |
-
|
1832 |
-
|
1833 |
-
|
1834 |
-
|
1835 |
-
|
1836 |
-
|
1837 |
-
|
1838 |
-
|
1839 |
-
|
1840 |
-
$
|
1841 |
-
|
1842 |
-
|
1843 |
-
|
1844 |
-
|
1845 |
-
|
1846 |
-
|
1847 |
-
|
1848 |
-
|
1849 |
-
$
|
1850 |
-
|
1851 |
-
|
1852 |
-
{
|
1853 |
-
$
|
1854 |
-
|
1855 |
-
|
1856 |
-
|
1857 |
-
|
1858 |
-
|
1859 |
-
|
1860 |
-
|
1861 |
-
|
1862 |
-
|
1863 |
-
|
1864 |
-
|
1865 |
-
|
1866 |
-
|
1867 |
-
|
1868 |
-
|
1869 |
-
|
1870 |
-
|
1871 |
-
|
1872 |
-
|
1873 |
-
|
1874 |
-
|
1875 |
-
|
1876 |
-
|
1877 |
-
|
1878 |
-
|
1879 |
-
|
1880 |
-
|
1881 |
-
|
1882 |
-
|
1883 |
-
|
1884 |
-
|
1885 |
-
|
1886 |
-
|
1887 |
-
|
1888 |
-
|
1889 |
-
|
1890 |
-
|
1891 |
-
|
1892 |
-
|
1893 |
-
|
1894 |
-
|
1895 |
-
|
1896 |
-
|
1897 |
-
|
1898 |
-
|
1899 |
-
|
1900 |
-
|
1901 |
-
|
1902 |
-
|
1903 |
-
|
1904 |
-
|
1905 |
-
|
1906 |
-
|
1907 |
-
|
1908 |
-
|
1909 |
-
|
1910 |
-
|
1911 |
-
|
1912 |
-
|
1913 |
-
|
1914 |
-
|
1915 |
-
|
1916 |
-
|
1917 |
-
|
1918 |
-
|
1919 |
-
|
1920 |
-
|
1921 |
-
|
1922 |
-
|
1923 |
-
|
1924 |
-
|
1925 |
-
|
1926 |
-
|
1927 |
-
|
1928 |
-
|
1929 |
-
|
1930 |
-
$
|
1931 |
-
|
1932 |
-
|
1933 |
-
|
1934 |
-
|
1935 |
-
|
1936 |
-
|
1937 |
-
|
1938 |
-
|
1939 |
-
|
1940 |
-
|
1941 |
-
|
1942 |
-
|
1943 |
-
|
1944 |
-
|
1945 |
-
|
1946 |
-
|
1947 |
-
|
1948 |
-
|
1949 |
-
|
1950 |
-
|
1951 |
-
|
1952 |
-
|
1953 |
-
|
1954 |
-
|
1955 |
-
|
1956 |
-
|
1957 |
-
|
1958 |
-
|
1959 |
-
|
1960 |
-
|
1961 |
-
|
1962 |
-
|
1963 |
-
|
1964 |
-
|
1965 |
-
|
1966 |
-
|
1967 |
-
|
1968 |
-
|
1969 |
-
|
1970 |
-
|
1971 |
-
|
1972 |
-
|
1973 |
-
|
1974 |
-
|
1975 |
-
|
1976 |
-
|
1977 |
-
|
1978 |
-
|
1979 |
-
|
1980 |
-
|
1981 |
-
|
1982 |
-
|
1983 |
-
|
1984 |
-
|
1985 |
-
|
1986 |
-
|
1987 |
-
|
1988 |
-
|
1989 |
-
|
1990 |
-
|
1991 |
-
|
1992 |
-
|
1993 |
-
|
1994 |
-
|
1995 |
-
|
1996 |
-
|
1997 |
-
|
1998 |
-
|
1999 |
-
|
2000 |
-
|
2001 |
-
|
2002 |
-
|
2003 |
-
|
2004 |
-
|
2005 |
-
|
2006 |
-
|
2007 |
-
|
2008 |
-
|
2009 |
-
|
2010 |
-
|
2011 |
-
|
2012 |
-
|
2013 |
-
|
2014 |
-
|
2015 |
-
|
2016 |
-
|
2017 |
-
|
2018 |
-
|
2019 |
-
|
2020 |
-
|
2021 |
-
|
2022 |
-
|
2023 |
-
|
2024 |
-
|
2025 |
-
|
2026 |
-
|
2027 |
-
|
2028 |
-
|
2029 |
-
|
2030 |
-
|
2031 |
-
|
2032 |
-
|
2033 |
-
|
2034 |
-
|
2035 |
-
|
2036 |
-
|
2037 |
-
|
2038 |
-
|
2039 |
-
|
2040 |
-
|
2041 |
-
|
2042 |
-
|
2043 |
-
|
2044 |
-
|
2045 |
-
|
2046 |
-
|
2047 |
-
|
2048 |
-
|
2049 |
-
|
2050 |
-
|
2051 |
-
|
2052 |
-
|
2053 |
-
|
2054 |
-
|
2055 |
-
|
2056 |
-
|
2057 |
-
|
2058 |
-
|
2059 |
-
|
2060 |
-
|
2061 |
-
|
2062 |
-
|
2063 |
-
|
2064 |
-
|
2065 |
-
|
2066 |
-
|
2067 |
-
|
2068 |
-
|
2069 |
-
|
2070 |
-
|
2071 |
-
|
2072 |
-
|
2073 |
-
$
|
2074 |
-
|
2075 |
-
|
2076 |
-
|
2077 |
-
|
2078 |
-
|
2079 |
-
|
2080 |
-
|
2081 |
-
|
2082 |
-
|
2083 |
-
|
2084 |
-
|
2085 |
-
|
2086 |
-
|
2087 |
-
|
2088 |
-
|
2089 |
-
|
2090 |
-
|
2091 |
-
|
2092 |
-
|
2093 |
-
|
2094 |
-
|
2095 |
-
|
2096 |
-
|
2097 |
-
|
2098 |
-
|
2099 |
-
|
2100 |
-
|
2101 |
-
|
2102 |
-
|
2103 |
-
|
2104 |
-
|
2105 |
-
|
2106 |
-
|
2107 |
-
|
2108 |
-
|
2109 |
-
|
2110 |
-
|
2111 |
-
|
2112 |
-
|
2113 |
-
|
2114 |
-
|
2115 |
-
|
2116 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/****************************************************************
|
3 |
+
|
4 |
+
IMPORTANT. PLEASE READ.
|
5 |
+
|
6 |
+
DO NOT EDIT THIS FILE or any other file in the /wp-content/plugins/paid-memberships-pro/ directory.
|
7 |
+
Doing so could break the PMPro plugin and/or keep you from upgrading this plugin in the future.
|
8 |
+
We regularly release updates to the plugin, including important security fixes and new features.
|
9 |
+
You want to be able to upgrade.
|
10 |
+
|
11 |
+
If you were asked to insert code into "your functions.php file", it was meant that you edit the functions.php
|
12 |
+
in the root folder of your active theme. e.g. /wp-content/themes/twentytwelve/functions.php
|
13 |
+
You can also create a custom plugin to place customization code into. Instructions are here:
|
14 |
+
http://www.paidmembershipspro.com/2012/08/create-a-plugin-for-pmpro-customizations/
|
15 |
+
|
16 |
+
Further documentation for customizing Paid Memberships Pro can be found here:
|
17 |
+
http://www.paidmembershipspro.com/documentation/
|
18 |
+
|
19 |
+
****************************************************************/
|
20 |
+
if(!function_exists("sornot"))
|
21 |
+
{
|
22 |
+
function sornot($t, $n)
|
23 |
+
{
|
24 |
+
if($n == 1)
|
25 |
+
return $t;
|
26 |
+
else
|
27 |
+
return $t . "s";
|
28 |
+
}
|
29 |
+
}
|
30 |
+
|
31 |
+
//set up wpdb for the tables we need
|
32 |
+
function pmpro_setDBTables()
|
33 |
+
{
|
34 |
+
global $wpdb;
|
35 |
+
$wpdb->hide_errors();
|
36 |
+
$wpdb->pmpro_membership_levels = $wpdb->prefix . 'pmpro_membership_levels';
|
37 |
+
$wpdb->pmpro_memberships_users = $wpdb->prefix . 'pmpro_memberships_users';
|
38 |
+
$wpdb->pmpro_memberships_categories = $wpdb->prefix . 'pmpro_memberships_categories';
|
39 |
+
$wpdb->pmpro_memberships_pages = $wpdb->prefix . 'pmpro_memberships_pages';
|
40 |
+
$wpdb->pmpro_membership_orders = $wpdb->prefix . 'pmpro_membership_orders';
|
41 |
+
$wpdb->pmpro_discount_codes = $wpdb->prefix . 'pmpro_discount_codes';
|
42 |
+
$wpdb->pmpro_discount_codes_levels = $wpdb->prefix . 'pmpro_discount_codes_levels';
|
43 |
+
$wpdb->pmpro_discount_codes_uses = $wpdb->prefix . 'pmpro_discount_codes_uses';
|
44 |
+
}
|
45 |
+
pmpro_setDBTables();
|
46 |
+
|
47 |
+
//from: http://stackoverflow.com/questions/5266945/wordpress-how-detect-if-current-page-is-the-login-page/5892694#5892694
|
48 |
+
function pmpro_is_login_page() {
|
49 |
+
return (in_array($GLOBALS['pagenow'], array('wp-login.php', 'wp-register.php')) || is_page("login"));
|
50 |
+
}
|
51 |
+
|
52 |
+
//thanks: http://wordpress.org/support/topic/is_plugin_active
|
53 |
+
function pmpro_is_plugin_active( $plugin ) {
|
54 |
+
return in_array( $plugin, (array) get_option( 'active_plugins', array() ) );
|
55 |
+
}
|
56 |
+
|
57 |
+
//scraping - override n if you have more than 1 group of matches and don't want the first group
|
58 |
+
function pmpro_getMatches($p, $s, $firstvalue = FALSE, $n = 1)
|
59 |
+
{
|
60 |
+
$ok = preg_match_all($p, $s, $matches);
|
61 |
+
|
62 |
+
if(!$ok)
|
63 |
+
return false;
|
64 |
+
else
|
65 |
+
{
|
66 |
+
if($firstvalue)
|
67 |
+
return $matches[$n][0];
|
68 |
+
else
|
69 |
+
return $matches[$n];
|
70 |
+
}
|
71 |
+
}
|
72 |
+
|
73 |
+
function pmpro_br2nl($text, $tags = "br")
|
74 |
+
{
|
75 |
+
if(!is_array($tags))
|
76 |
+
$tags = explode(" ", $tags);
|
77 |
+
|
78 |
+
foreach($tags as $tag)
|
79 |
+
{
|
80 |
+
$text = eregi_replace("<" . $tag . "[^>]*>", "\n", $text);
|
81 |
+
$text = eregi_replace("</" . $tag . "[^>]*>", "\n", $text);
|
82 |
+
}
|
83 |
+
|
84 |
+
return($text);
|
85 |
+
}
|
86 |
+
|
87 |
+
function pmpro_getOption($s, $force = false)
|
88 |
+
{
|
89 |
+
if(get_option("pmpro_" . $s))
|
90 |
+
return get_option("pmpro_" . $s);
|
91 |
+
else
|
92 |
+
return "";
|
93 |
+
}
|
94 |
+
|
95 |
+
function pmpro_setOption($s, $v = NULL)
|
96 |
+
{
|
97 |
+
//no value is given, set v to the p var
|
98 |
+
if($v === NULL && isset($_POST[$s]))
|
99 |
+
$v = $_POST[$s];
|
100 |
+
|
101 |
+
if(is_array($v))
|
102 |
+
$v = implode(",", $v);
|
103 |
+
else
|
104 |
+
$v = trim($v);
|
105 |
+
|
106 |
+
return update_option("pmpro_" . $s, $v);
|
107 |
+
}
|
108 |
+
|
109 |
+
function pmpro_get_slug($post_id)
|
110 |
+
{
|
111 |
+
global $pmpro_slugs, $wpdb;
|
112 |
+
|
113 |
+
//make sure post id is int for security
|
114 |
+
$post_id = intval($post_id);
|
115 |
+
|
116 |
+
if(!$pmpro_slugs[$post_id])
|
117 |
+
$pmpro_slugs[$post_id] = $wpdb->get_var("SELECT post_name FROM $wpdb->posts WHERE ID = '" . $post_id . "' LIMIT 1");
|
118 |
+
|
119 |
+
return $pmpro_slugs[$post_id];
|
120 |
+
}
|
121 |
+
|
122 |
+
function pmpro_url($page = NULL, $querystring = "", $scheme = NULL)
|
123 |
+
{
|
124 |
+
global $besecure;
|
125 |
+
$besecure = apply_filters("besecure", $besecure);
|
126 |
+
|
127 |
+
if(!$scheme && $besecure)
|
128 |
+
$scheme = "https";
|
129 |
+
elseif(!$scheme)
|
130 |
+
$scheme = "http";
|
131 |
+
|
132 |
+
if(!$page)
|
133 |
+
$page = "levels";
|
134 |
+
|
135 |
+
global $pmpro_pages;
|
136 |
+
|
137 |
+
//start with the permalink
|
138 |
+
$url = get_permalink($pmpro_pages[$page]);
|
139 |
+
|
140 |
+
//WPML/etc support
|
141 |
+
if(function_exists("icl_object_id") && defined("ICL_LANGUAGE_CODE"))
|
142 |
+
{
|
143 |
+
$trans_id = icl_object_id($pmpro_pages[$page], "page", false, ICL_LANGUAGE_CODE);
|
144 |
+
if(!empty($trans_id))
|
145 |
+
{
|
146 |
+
$url = get_permalink($trans_id);
|
147 |
+
}
|
148 |
+
}
|
149 |
+
|
150 |
+
//figure out querystring
|
151 |
+
if(strpos($url, "?"))
|
152 |
+
$querystring = str_replace("?", "&", $querystring);
|
153 |
+
$url .= $querystring;
|
154 |
+
|
155 |
+
//figure out scheme
|
156 |
+
if(is_ssl())
|
157 |
+
$url = str_replace("http:", "https:", $url);
|
158 |
+
|
159 |
+
return $url;
|
160 |
+
}
|
161 |
+
|
162 |
+
function pmpro_isLevelFree(&$level)
|
163 |
+
{
|
164 |
+
if(!empty($level) && $level->initial_payment <= 0 && $level->billing_amount <= 0 && $level->trial_amount <= 0)
|
165 |
+
return true;
|
166 |
+
else
|
167 |
+
return false;
|
168 |
+
}
|
169 |
+
|
170 |
+
function pmpro_isLevelRecurring(&$level)
|
171 |
+
{
|
172 |
+
if(!empty($level) && ($level->billing_amount > 0 || $level->trial_amount > 0))
|
173 |
+
return true;
|
174 |
+
else
|
175 |
+
return false;
|
176 |
+
}
|
177 |
+
|
178 |
+
function pmpro_isLevelTrial(&$level)
|
179 |
+
{
|
180 |
+
if($level->trial_limit > 0)
|
181 |
+
{
|
182 |
+
return true;
|
183 |
+
}
|
184 |
+
else
|
185 |
+
return false;
|
186 |
+
}
|
187 |
+
|
188 |
+
function pmpro_isLevelExpiring(&$level)
|
189 |
+
{
|
190 |
+
if($level->expiration_number > 0)
|
191 |
+
return true;
|
192 |
+
else
|
193 |
+
return false;
|
194 |
+
}
|
195 |
+
|
196 |
+
/**
|
197 |
+
* Is this level expiring within one pay period
|
198 |
+
*
|
199 |
+
* @since 1.8.6.3
|
200 |
+
*
|
201 |
+
* @param object $level PMPro Level Object to test
|
202 |
+
*/
|
203 |
+
function pmpro_isLevelExpiringSoon( &$level ) {
|
204 |
+
if( !pmpro_isLevelExpiring( $level ) || empty( $level->enddate ) )
|
205 |
+
$r = false;
|
206 |
+
else {
|
207 |
+
//days til expiration for the standard level
|
208 |
+
$standard = pmpro_getLevel( $level->id );
|
209 |
+
|
210 |
+
if( !empty( $standard->expiration_number ) ){
|
211 |
+
if( $standard->expiration_period == 'Day' )
|
212 |
+
$days = $level->expiration_number;
|
213 |
+
elseif( $standard->expiration_period == 'Week' )
|
214 |
+
$days = $level->expiration_number * 7;
|
215 |
+
elseif( $standard->expiration_period == 'Month' )
|
216 |
+
$days = $level->expiration_number * 30;
|
217 |
+
elseif( $standard->expiration_period == 'Year' )
|
218 |
+
$days = $level->expiration_number * 365;
|
219 |
+
}
|
220 |
+
else
|
221 |
+
$days = 30;
|
222 |
+
|
223 |
+
//are we within the days til expiration?
|
224 |
+
$now = current_time('timestamp');
|
225 |
+
if( $now + ($days*3600*24) < strtotime( $level->enddate, $now ) )
|
226 |
+
$r = true;
|
227 |
+
else
|
228 |
+
$r = false;
|
229 |
+
}
|
230 |
+
|
231 |
+
//filter
|
232 |
+
$r = apply_filters('pmpro_is_level_expiring_soon', $r, $level);
|
233 |
+
|
234 |
+
return $r;
|
235 |
+
}
|
236 |
+
|
237 |
+
function pmpro_getLevelCost(&$level, $tags = true, $short = false)
|
238 |
+
{
|
239 |
+
//initial payment
|
240 |
+
if(!$short)
|
241 |
+
$r = sprintf(__('The price for membership is <strong>%s</strong> now', 'pmpro'), pmpro_formatPrice($level->initial_payment));
|
242 |
+
else
|
243 |
+
$r = sprintf(__('<strong>%s</strong> now', 'pmpro'), pmpro_formatPrice($level->initial_payment));
|
244 |
+
|
245 |
+
//recurring part
|
246 |
+
if($level->billing_amount != '0.00')
|
247 |
+
{
|
248 |
+
if($level->billing_limit > 1)
|
249 |
+
{
|
250 |
+
if($level->cycle_number == '1')
|
251 |
+
{
|
252 |
+
$r .= sprintf(__(' and then <strong>%s per %s for %d more %s</strong>.', 'pmpro'), pmpro_formatPrice($level->billing_amount), pmpro_translate_billing_period($level->cycle_period), $level->billing_limit, pmpro_translate_billing_period($level->cycle_period, $level->billing_limit));
|
253 |
+
}
|
254 |
+
else
|
255 |
+
{
|
256 |
+
$r .= sprintf(__(' and then <strong>%s every %d %s for %d more %s</strong>.', 'pmpro'), pmpro_formatPrice($level->billing_amount), $level->cycle_number, pmpro_translate_billing_period($level->cycle_period, $level->cycle_number), $level->billing_limit, pmpro_translate_billing_period($level->cycle_period, $level->billing_limit));
|
257 |
+
}
|
258 |
+
}
|
259 |
+
elseif($level->billing_limit == 1)
|
260 |
+
{
|
261 |
+
$r .= sprintf(__(' and then <strong>%s after %d %s</strong>.', 'pmpro'), pmpro_formatPrice($level->billing_amount), $level->cycle_number, pmpro_translate_billing_period($level->cycle_period, $level->cycle_number));
|
262 |
+
}
|
263 |
+
else
|
264 |
+
{
|
265 |
+
if( $level->billing_amount === $level->initial_payment ) {
|
266 |
+
if($level->cycle_number == '1')
|
267 |
+
{
|
268 |
+
if(!$short)
|
269 |
+
$r = sprintf(__('The price for membership is <strong>%s per %s</strong>.', 'pmpro'), pmpro_formatPrice($level->initial_payment), pmpro_translate_billing_period($level->cycle_period) );
|
270 |
+
else
|
271 |
+
$r = sprintf(__('<strong>%s per %s</strong>.', 'pmpro'), pmpro_formatPrice($level->initial_payment), pmpro_translate_billing_period($level->cycle_period) );
|
272 |
+
}
|
273 |
+
else
|
274 |
+
{
|
275 |
+
if(!$short)
|
276 |
+
$r = sprintf(__('The price for membership is <strong>%s every %d %s</strong>.', 'pmpro'), pmpro_formatPrice($level->initial_payment), $level->cycle_number, pmpro_translate_billing_period($level->cycle_period, $level->cycle_number) );
|
277 |
+
else
|
278 |
+
$r = sprintf(__('<strong>%s every %d %s</strong>.', 'pmpro'), pmpro_formatPrice($level->initial_payment), $level->cycle_number, pmpro_translate_billing_period($level->cycle_period, $level->cycle_number) );
|
279 |
+
}
|
280 |
+
} else {
|
281 |
+
if($level->cycle_number == '1')
|
282 |
+
{
|
283 |
+
$r .= sprintf(__(' and then <strong>%s per %s</strong>.', 'pmpro'), pmpro_formatPrice($level->billing_amount), pmpro_translate_billing_period($level->cycle_period));
|
284 |
+
}
|
285 |
+
else
|
286 |
+
{
|
287 |
+
$r .= sprintf(__(' and then <strong>%s every %d %s</strong>.', 'pmpro'), pmpro_formatPrice($level->billing_amount), $level->cycle_number, pmpro_translate_billing_period($level->cycle_period, $level->cycle_number));
|
288 |
+
}
|
289 |
+
}
|
290 |
+
}
|
291 |
+
}
|
292 |
+
else
|
293 |
+
$r .= '.';
|
294 |
+
|
295 |
+
//add a space
|
296 |
+
$r .= ' ';
|
297 |
+
|
298 |
+
//trial part
|
299 |
+
if($level->trial_limit)
|
300 |
+
{
|
301 |
+
if($level->trial_amount == '0.00')
|
302 |
+
{
|
303 |
+
if($level->trial_limit == '1')
|
304 |
+
{
|
305 |
+
$r .= ' ' . __('After your initial payment, your first payment is Free.', 'pmpro');
|
306 |
+
}
|
307 |
+
else
|
308 |
+
{
|
309 |
+
$r .= ' ' . sprintf(__('After your initial payment, your first %d payments are Free.', 'pmpro'), $level->trial_limit);
|
310 |
+
}
|
311 |
+
}
|
312 |
+
else
|
313 |
+
{
|
314 |
+
if($level->trial_limit == '1')
|
315 |
+
{
|
316 |
+
$r .= ' ' . sprintf(__('After your initial payment, your first payment will cost %s.', 'pmpro'), pmpro_formatPrice($level->trial_amount));
|
317 |
+
}
|
318 |
+
else
|
319 |
+
{
|
320 |
+
$r .= ' ' . sprintf(__('After your initial payment, your first %d payments will cost %s.', 'pmpro'), $level->trial_limit, pmpro_formatPrice($level->trial_amount));
|
321 |
+
}
|
322 |
+
}
|
323 |
+
}
|
324 |
+
|
325 |
+
//taxes part
|
326 |
+
$tax_state = pmpro_getOption("tax_state");
|
327 |
+
$tax_rate = pmpro_getOption("tax_rate");
|
328 |
+
|
329 |
+
if($tax_state && $tax_rate && !pmpro_isLevelFree($level))
|
330 |
+
{
|
331 |
+
$r .= sprintf(__('Customers in %s will be charged %s%% tax.', 'pmpro'), $tax_state, round($tax_rate * 100, 2));
|
332 |
+
}
|
333 |
+
|
334 |
+
if(!$tags)
|
335 |
+
$r = strip_tags($r);
|
336 |
+
|
337 |
+
$r = apply_filters("pmpro_level_cost_text", $r, $level, $tags, $short); //passing $tags and $short since v1.8
|
338 |
+
return $r;
|
339 |
+
}
|
340 |
+
|
341 |
+
function pmpro_getLevelExpiration(&$level)
|
342 |
+
{
|
343 |
+
if($level->expiration_number)
|
344 |
+
{
|
345 |
+
$expiration_text = sprintf(__("Membership expires after %d %s.", "pmpro"), $level->expiration_number, pmpro_translate_billing_period($level->expiration_period, $level->expiration_number));
|
346 |
+
}
|
347 |
+
else
|
348 |
+
$expiration_text = "";
|
349 |
+
|
350 |
+
$expiration_text = apply_filters("pmpro_level_expiration_text", $expiration_text, $level);
|
351 |
+
return $expiration_text;
|
352 |
+
}
|
353 |
+
|
354 |
+
function pmpro_hideAds()
|
355 |
+
{
|
356 |
+
global $pmpro_display_ads;
|
357 |
+
return !$pmpro_display_ads;
|
358 |
+
}
|
359 |
+
|
360 |
+
function pmpro_displayAds()
|
361 |
+
{
|
362 |
+
global $pmpro_display_ads;
|
363 |
+
return $pmpro_display_ads;
|
364 |
+
}
|
365 |
+
|
366 |
+
function pmpro_next_payment($user_id = NULL, $order_status = "success", $format = "timestamp")
|
367 |
+
{
|
368 |
+
global $wpdb, $current_user;
|
369 |
+
if(!$user_id)
|
370 |
+
$user_id = $current_user->ID;
|
371 |
+
|
372 |
+
if(!$user_id)
|
373 |
+
$r = false;
|
374 |
+
else
|
375 |
+
{
|
376 |
+
//get last order
|
377 |
+
$order = new MemberOrder();
|
378 |
+
$order->getLastMemberOrder($user_id, $order_status);
|
379 |
+
|
380 |
+
//get current membership level
|
381 |
+
$level = pmpro_getMembershipLevelForUser($user_id);
|
382 |
+
|
383 |
+
if(!empty($order) && !empty($order->id) && !empty($level) && !empty($level->id) && !empty($level->cycle_number))
|
384 |
+
{
|
385 |
+
//last payment date
|
386 |
+
$lastdate = date("Y-m-d", $order->timestamp);
|
387 |
+
|
388 |
+
//next payment date
|
389 |
+
$nextdate = $wpdb->get_var("SELECT UNIX_TIMESTAMP('" . $lastdate . "' + INTERVAL " . $level->cycle_number . " " . $level->cycle_period . ")");
|
390 |
+
|
391 |
+
$r = $nextdate;
|
392 |
+
}
|
393 |
+
else
|
394 |
+
{
|
395 |
+
//no order or level found, or level was not recurring
|
396 |
+
$r = false;
|
397 |
+
}
|
398 |
+
}
|
399 |
+
|
400 |
+
/**
|
401 |
+
* Filter the next payment date.
|
402 |
+
*
|
403 |
+
* @since 1.8.5
|
404 |
+
*
|
405 |
+
* @param mixed $r false or the next payment date timestamp
|
406 |
+
* @param int $user_id The user id to get the next payment date for
|
407 |
+
* @param string $order_status Status or array of statuses to find the last order based on.
|
408 |
+
*/
|
409 |
+
$r = apply_filters('pmpro_next_payment', $r, $user_id, $order_status);
|
410 |
+
|
411 |
+
//return in desired format
|
412 |
+
if($r === false)
|
413 |
+
return false; //always return false when no date found
|
414 |
+
elseif($format == "timestamp")
|
415 |
+
return $r;
|
416 |
+
elseif($format == "date_format")
|
417 |
+
return date(get_option('date_format'), $r);
|
418 |
+
else
|
419 |
+
return date($format, $r); //assume a PHP date format
|
420 |
+
}
|
421 |
+
|
422 |
+
if(!function_exists("last4"))
|
423 |
+
{
|
424 |
+
function last4($t)
|
425 |
+
{
|
426 |
+
return substr($t, strlen($t) - 4, 4);
|
427 |
+
}
|
428 |
+
}
|
429 |
+
|
430 |
+
if(!function_exists("hideCardNumber"))
|
431 |
+
{
|
432 |
+
function hideCardNumber($c, $dashes = true)
|
433 |
+
{
|
434 |
+
if($c)
|
435 |
+
{
|
436 |
+
if($dashes)
|
437 |
+
return "XXXX-XXXX-XXXX-" . substr($c, strlen($c) - 4, 4);
|
438 |
+
else
|
439 |
+
return "XXXXXXXXXXXX" . substr($c, strlen($c) - 4, 4);
|
440 |
+
}
|
441 |
+
else
|
442 |
+
{
|
443 |
+
return "";
|
444 |
+
}
|
445 |
+
}
|
446 |
+
}
|
447 |
+
|
448 |
+
//check for existing functions since we didn't use a prefix for this function
|
449 |
+
if(!function_exists("cleanPhone"))
|
450 |
+
{
|
451 |
+
/**
|
452 |
+
* Function to remove special characters from a phone number.
|
453 |
+
* NOTE: Could probably replace with preg_replace("[^0-9]", "", $phone)
|
454 |
+
*
|
455 |
+
* @since 1.0
|
456 |
+
*
|
457 |
+
* @param string $phone The phone number to clean.
|
458 |
+
*/
|
459 |
+
function cleanPhone($phone)
|
460 |
+
{
|
461 |
+
//if a + is passed, just pass it along
|
462 |
+
if(strpos($phone, "+") !== false)
|
463 |
+
return $phone;
|
464 |
+
//clean the phone
|
465 |
+
$phone = str_replace("-", "", $phone);
|
466 |
+
$phone = str_replace(".", "", $phone);
|
467 |
+
$phone = str_replace("(", "", $phone);
|
468 |
+
$phone = str_replace(")", "", $phone);
|
469 |
+
$phone = str_replace(" ", "", $phone);
|
470 |
+
return $phone;
|
471 |
+
}
|
472 |
+
}
|
473 |
+
|
474 |
+
//check for existing functions since we didn't use a prefix for this function
|
475 |
+
if(!function_exists("formatPhone"))
|
476 |
+
{
|
477 |
+
/**
|
478 |
+
* Function to format a phone number.
|
479 |
+
*
|
480 |
+
* @since 1.0
|
481 |
+
*
|
482 |
+
* @param string $phone The phone number to format.
|
483 |
+
*/
|
484 |
+
function formatPhone($phone)
|
485 |
+
{
|
486 |
+
$r = cleanPhone($phone);
|
487 |
+
|
488 |
+
if(strlen($r) == 11)
|
489 |
+
$r = substr($r, 0, 1) . " (" . substr($r, 1, 3) . ") " . substr($r, 4, 3) . "-" . substr($r, 7, 4);
|
490 |
+
elseif(strlen($r) == 10)
|
491 |
+
$r = "(" . substr($r, 0, 3) . ") " . substr($r, 3, 3) . "-" . substr($r, 6, 4);
|
492 |
+
elseif(strlen($r) == 7)
|
493 |
+
$r = substr($r, 0, 3) . "-" . substr($r, 3, 4);
|
494 |
+
|
495 |
+
/**
|
496 |
+
* Filter to do more or less cleaning of phone numbers.
|
497 |
+
*
|
498 |
+
* @since 1.8.4.4
|
499 |
+
*
|
500 |
+
* @param string $r The formatted phone number.
|
501 |
+
* @param string $phone The original phone number.
|
502 |
+
*/
|
503 |
+
return apply_filters('pmpro_format_phone', $r, $phone);
|
504 |
+
}
|
505 |
+
}
|
506 |
+
|
507 |
+
function pmpro_showRequiresMembershipMessage()
|
508 |
+
{
|
509 |
+
//TODO $current_user $post_membership_levels_names are undefined variables
|
510 |
+
//get the correct message
|
511 |
+
if(is_feed())
|
512 |
+
{
|
513 |
+
$content = pmpro_getOption("rsstext");
|
514 |
+
$content = str_replace("!!levels!!", implode(", ", $post_membership_levels_names), $content);
|
515 |
+
}
|
516 |
+
elseif($current_user->ID)
|
517 |
+
{
|
518 |
+
//not a member
|
519 |
+
$content = pmpro_getOption("nonmembertext");
|
520 |
+
$content = str_replace("!!levels!!", implode(", ", $post_membership_levels_names), $content);
|
521 |
+
}
|
522 |
+
else
|
523 |
+
{
|
524 |
+
//not logged in!
|
525 |
+
$content = pmpro_getOption("notloggedintext");
|
526 |
+
$content = str_replace("!!levels!!", implode(", ", $post_membership_levels_names), $content);
|
527 |
+
}
|
528 |
+
}
|
529 |
+
|
530 |
+
/**
|
531 |
+
* Function to check if a user has specified membership levels.
|
532 |
+
*
|
533 |
+
* pmpro_hasMembershipLevel() checks if the passed user is a member of the passed level
|
534 |
+
* $level may either be the ID or name of the desired membership_level. (or an array of such)
|
535 |
+
* If $user_id is omitted, the value will be retrieved from $current_user.
|
536 |
+
*
|
537 |
+
* Return values:
|
538 |
+
* * Success returns boolean true.
|
539 |
+
* * Failure returns a string containing the error message.
|
540 |
+
*
|
541 |
+
* @since 1.8.5 Added 'e' option for expired members.
|
542 |
+
* @since 1.0.0
|
543 |
+
*
|
544 |
+
* @param mixed $levels The levels to check.
|
545 |
+
* @param int $user_id The user ID to check.
|
546 |
+
*
|
547 |
+
* @return bool Result of membership query.
|
548 |
+
*/
|
549 |
+
function pmpro_hasMembershipLevel($levels = NULL, $user_id = NULL)
|
550 |
+
{
|
551 |
+
global $current_user, $wpdb;
|
552 |
+
|
553 |
+
$return = false;
|
554 |
+
|
555 |
+
if(empty($user_id)) //no user_id passed, check the current user
|
556 |
+
{
|
557 |
+
$user_id = $current_user->ID;
|
558 |
+
$membership_levels = $current_user->membership_levels;
|
559 |
+
}
|
560 |
+
elseif(is_numeric($user_id)) //get membership levels for given user
|
561 |
+
{
|
562 |
+
$membership_levels = pmpro_getMembershipLevelsForUser($user_id);
|
563 |
+
}
|
564 |
+
else
|
565 |
+
return false; //invalid user_id
|
566 |
+
|
567 |
+
if($levels === "0" || $levels === 0) //if 0 was passed, return true if they have no level and false if they have any
|
568 |
+
{
|
569 |
+
$return = empty($membership_levels);
|
570 |
+
}
|
571 |
+
elseif(empty($levels)) //if no level var was passed, we're just checking if they have any level
|
572 |
+
{
|
573 |
+
$return = !empty($membership_levels);
|
574 |
+
}
|
575 |
+
else
|
576 |
+
{
|
577 |
+
if(!is_array($levels)) //make an array out of a single element so we can use the same code
|
578 |
+
{
|
579 |
+
$levels = array($levels);
|
580 |
+
}
|
581 |
+
|
582 |
+
if(empty($membership_levels))
|
583 |
+
{
|
584 |
+
//user has no levels just check if 0, L, -1, or e was sent in one of the levels
|
585 |
+
if(in_array(0, $levels, true) || in_array("0", $levels))
|
586 |
+
$return = true;
|
587 |
+
elseif(in_array("L", $levels) || in_array("l", $levels))
|
588 |
+
$return = (!empty($user_id) && $user_id == $current_user->ID);
|
589 |
+
elseif(in_array("-L", $levels) || in_array("-l", $levels))
|
590 |
+
$return = (empty($user_id) || $user_id != $current_user->ID);
|
591 |
+
elseif(in_array("E", $levels) || in_array("e", $levels)) {
|
592 |
+
$sql = "SELECT id FROM $wpdb->pmpro_memberships_users WHERE user_id=$user_id AND status='expired' LIMIT 1";
|
593 |
+
$expired = $wpdb->get_var($sql);
|
594 |
+
return !empty($expired);
|
595 |
+
}
|
596 |
+
}
|
597 |
+
else
|
598 |
+
{
|
599 |
+
foreach($levels as $level)
|
600 |
+
{
|
601 |
+
if(strtoupper($level) == "L")
|
602 |
+
{
|
603 |
+
//checking if user is logged in
|
604 |
+
if(!empty($user_id) && $user_id == $current_user->ID)
|
605 |
+
$return = true;
|
606 |
+
}
|
607 |
+
elseif(strtoupper($level) == "-L")
|
608 |
+
{
|
609 |
+
//checking if user is logged out
|
610 |
+
if(empty($user_id) || $user_id != $current_user->ID)
|
611 |
+
$return = true;
|
612 |
+
}
|
613 |
+
elseif($level == "0" || strtoupper($level) == "E")
|
614 |
+
{
|
615 |
+
continue; //user with levels so not a "non-member" or expired
|
616 |
+
}
|
617 |
+
else
|
618 |
+
{
|
619 |
+
//checking a level id
|
620 |
+
$level_obj = pmpro_getLevel(is_numeric($level) ? abs(intval($level)) : $level); //make sure our level is in a proper format
|
621 |
+
if(empty($level_obj)){continue;} //invalid level
|
622 |
+
$found_level = false;
|
623 |
+
foreach($membership_levels as $membership_level)
|
624 |
+
{
|
625 |
+
if($membership_level->id == $level_obj->id) //found a match
|
626 |
+
{
|
627 |
+
$found_level = true;
|
628 |
+
}
|
629 |
+
}
|
630 |
+
|
631 |
+
if(is_numeric($level) && intval($level) < 0 && !$found_level) //checking for the absence of this level and they don't have it
|
632 |
+
{
|
633 |
+
$return = true;
|
634 |
+
}
|
635 |
+
elseif(is_numeric($level) && intval($level) > 0 && $found_level) //checking for the presence of this level and they have it
|
636 |
+
{
|
637 |
+
$return = true;
|
638 |
+
}
|
639 |
+
elseif(!is_numeric($level)) //if a level name was passed
|
640 |
+
$return = $found_level;
|
641 |
+
}
|
642 |
+
}
|
643 |
+
}
|
644 |
+
}
|
645 |
+
|
646 |
+
$return = apply_filters("pmpro_has_membership_level", $return, $user_id, $levels);
|
647 |
+
return $return;
|
648 |
+
}
|
649 |
+
|
650 |
+
/* pmpro_changeMembershipLevel() creates or updates the membership level of the given user to the given level.
|
651 |
+
*
|
652 |
+
* $level may either be the ID or name of the desired membership_level.
|
653 |
+
* If $user_id is omitted, the value will be retrieved from $current_user.
|
654 |
+
*
|
655 |
+
* Return values:
|
656 |
+
* Success returns boolean true.
|
657 |
+
* Failure returns boolean false.
|
658 |
+
*/
|
659 |
+
function pmpro_changeMembershipLevel($level, $user_id = NULL, $old_level_status = 'inactive')
|
660 |
+
{
|
661 |
+
global $wpdb;
|
662 |
+
global $current_user, $pmpro_error;
|
663 |
+
|
664 |
+
if(empty($user_id))
|
665 |
+
{
|
666 |
+
$user_id = $current_user->ID;
|
667 |
+
}
|
668 |
+
|
669 |
+
if(empty($user_id))
|
670 |
+
{
|
671 |
+
$pmpro_error = __("User ID not found.", "pmpro");
|
672 |
+
return false;
|
673 |
+
}
|
674 |
+
|
675 |
+
//make sure user id is int for security
|
676 |
+
$user_id = intval($user_id);
|
677 |
+
|
678 |
+
if(empty($level)) //cancelling membership
|
679 |
+
{
|
680 |
+
$level = 0;
|
681 |
+
}
|
682 |
+
else if(is_array($level))
|
683 |
+
{
|
684 |
+
//custom level
|
685 |
+
}
|
686 |
+
else
|
687 |
+
{
|
688 |
+
$level_obj = pmpro_getLevel($level);
|
689 |
+
if(empty($level_obj))
|
690 |
+
{
|
691 |
+
$pmpro_error = __("Invalid level.", "pmpro");
|
692 |
+
return false;
|
693 |
+
}
|
694 |
+
$level = $level_obj->id;
|
695 |
+
}
|
696 |
+
|
697 |
+
//if it's a custom level, they're changing
|
698 |
+
if(!is_array($level))
|
699 |
+
{
|
700 |
+
//are they even changing?
|
701 |
+
if(pmpro_hasMembershipLevel($level, $user_id)) {
|
702 |
+
$pmpro_error = __("not changing?", "pmpro");
|
703 |
+
return false; //not changing
|
704 |
+
}
|
705 |
+
}
|
706 |
+
|
707 |
+
//get all active membershipships for this user
|
708 |
+
$old_levels = pmpro_getMembershipLevelsForUser($user_id);
|
709 |
+
|
710 |
+
//deactivate old memberships based on the old_level_status passed in (updates pmpro_memberships_users table)
|
711 |
+
if($old_levels)
|
712 |
+
{
|
713 |
+
foreach($old_levels as $old_level) {
|
714 |
+
|
715 |
+
$sql = "UPDATE $wpdb->pmpro_memberships_users SET `status`='$old_level_status', `enddate`='" . current_time('mysql') . "' WHERE `id`=".$old_level->subscription_id;
|
716 |
+
|
717 |
+
if(!$wpdb->query($sql))
|
718 |
+
{
|
719 |
+
$pmpro_error = __("Error interacting with database", "pmpro") . ": ".(mysql_errno()?mysql_error():'unavailable');
|
720 |
+
|
721 |
+
return false;
|
722 |
+
}
|
723 |
+
}
|
724 |
+
}
|
725 |
+
|
726 |
+
//get level id
|
727 |
+
if(is_array($level))
|
728 |
+
$level_id = $level['membership_id']; //custom level
|
729 |
+
else
|
730 |
+
$level_id = $level; //just id
|
731 |
+
|
732 |
+
/**
|
733 |
+
* Action to run before the membership level changes.
|
734 |
+
*
|
735 |
+
* @param int $level_id ID of the level changed to.
|
736 |
+
* @param int $user_id ID of the user changed.
|
737 |
+
*/
|
738 |
+
do_action("pmpro_before_change_membership_level", $level_id, $user_id);
|
739 |
+
|
740 |
+
//should we cancel their gateway subscriptions?
|
741 |
+
$pmpro_cancel_previous_subscriptions = true;
|
742 |
+
if(isset($_REQUEST['cancel_membership']) && $_REQUEST['cancel_membership'] == false)
|
743 |
+
$pmpro_cancel_previous_subscriptions = false;
|
744 |
+
$pmpro_cancel_previous_subscriptions = apply_filters("pmpro_cancel_previous_subscriptions", $pmpro_cancel_previous_subscriptions);
|
745 |
+
|
746 |
+
//cancel any other subscriptions they have (updates pmpro_membership_orders table)
|
747 |
+
if($pmpro_cancel_previous_subscriptions)
|
748 |
+
{
|
749 |
+
$other_order_ids = $wpdb->get_col("SELECT id FROM $wpdb->pmpro_membership_orders WHERE user_id = '" . $user_id . "' AND status = 'success' ORDER BY id DESC");
|
750 |
+
|
751 |
+
foreach($other_order_ids as $order_id)
|
752 |
+
{
|
753 |
+
$c_order = new MemberOrder($order_id);
|
754 |
+
$c_order->cancel();
|
755 |
+
|
756 |
+
if(!empty($c_order->error))
|
757 |
+
$pmpro_error = $c_order->error;
|
758 |
+
}
|
759 |
+
}
|
760 |
+
|
761 |
+
//insert current membership
|
762 |
+
if(!empty($level)) //are we getting a new one or just cancelling the old ones
|
763 |
+
{
|
764 |
+
if(is_array($level))
|
765 |
+
{
|
766 |
+
//make sure the dates are in good formats
|
767 |
+
if($level['startdate'] != current_time('mysql') && $level['startdate'] != "NULL" && substr($level['startdate'], 0, 1) != "'")
|
768 |
+
$level['startdate'] = "'" . $level['startdate'] . "'";
|
769 |
+
|
770 |
+
if($level['enddate'] != current_time('mysql') && $level['enddate'] != "NULL" && substr($level['enddate'], 0, 1) != "'")
|
771 |
+
$level['enddate'] = "'" . $level['enddate'] . "'";
|
772 |
+
|
773 |
+
//Better support mySQL Strict Mode by passing a proper enum value for cycle_period
|
774 |
+
if ($level['cycle_period'] == '') $level['cycle_period'] = 0;
|
775 |
+
|
776 |
+
$sql = "INSERT INTO $wpdb->pmpro_memberships_users (user_id, membership_id, code_id, initial_payment, billing_amount, cycle_number, cycle_period, billing_limit, trial_amount, trial_limit, startdate, enddate)
|
777 |
+
VALUES('" . $level['user_id'] . "',
|
778 |
+
'" . $level['membership_id'] . "',
|
779 |
+
'" . intval($level['code_id']) . "',
|
780 |
+
'" . $level['initial_payment'] . "',
|
781 |
+
'" . $level['billing_amount'] . "',
|
782 |
+
'" . $level['cycle_number'] . "',
|
783 |
+
'" . $level['cycle_period'] . "',
|
784 |
+
'" . $level['billing_limit'] . "',
|
785 |
+
'" . $level['trial_amount'] . "',
|
786 |
+
'" . $level['trial_limit'] . "',
|
787 |
+
" . $level['startdate'] . ",
|
788 |
+
" . $level['enddate'] . ")";
|
789 |
+
|
790 |
+
if(!$wpdb->query($sql))
|
791 |
+
{
|
792 |
+
$pmpro_error = __("Error interacting with database", "pmpro") . ": ".(mysql_errno()?mysql_error():'unavailable');
|
793 |
+
return false;
|
794 |
+
}
|
795 |
+
}
|
796 |
+
else
|
797 |
+
{
|
798 |
+
$sql = "INSERT INTO $wpdb->pmpro_memberships_users (user_id, membership_id, code_id, initial_payment, billing_amount, cycle_number, cycle_period, billing_limit, trial_amount, trial_limit, startdate, enddate)
|
799 |
+
VALUES (
|
800 |
+
'" . $user_id . "',
|
801 |
+
'" . $level . "',
|
802 |
+
'0',
|
803 |
+
'0',
|
804 |
+
'0',
|
805 |
+
'0',
|
806 |
+
'0',
|
807 |
+
'0',
|
808 |
+
'0',
|
809 |
+
'0',
|
810 |
+
'" . current_time('mysql') . "',
|
811 |
+
'0000-00-00 00:00:00'
|
812 |
+
)";
|
813 |
+
|
814 |
+
if(!$wpdb->query($sql))
|
815 |
+
{
|
816 |
+
$pmpro_error = __("Error interacting with database", "pmpro") . ": ".(mysql_errno()?mysql_error():'unavailable');
|
817 |
+
return false;
|
818 |
+
}
|
819 |
+
}
|
820 |
+
}
|
821 |
+
|
822 |
+
//remove cached level
|
823 |
+
global $all_membership_levels;
|
824 |
+
unset($all_membership_levels[$user_id]);
|
825 |
+
|
826 |
+
//update user data and call action
|
827 |
+
pmpro_set_current_user();
|
828 |
+
|
829 |
+
/**
|
830 |
+
* Action to run after the membership level changes.
|
831 |
+
*
|
832 |
+
* @param int $level_id ID of the level changed to.
|
833 |
+
* @param int $user_id ID of the user changed.
|
834 |
+
*/
|
835 |
+
do_action("pmpro_after_change_membership_level", $level_id, $user_id);
|
836 |
+
return true;
|
837 |
+
}
|
838 |
+
|
839 |
+
/* pmpro_toggleMembershipCategory() creates or deletes a linking entry between the membership level and post category tables.
|
840 |
+
*
|
841 |
+
* $level may either be the ID or name of the desired membership_level.
|
842 |
+
* $category must be a valid post category ID.
|
843 |
+
*
|
844 |
+
* Return values:
|
845 |
+
* Success returns boolean true.
|
846 |
+
* Failure returns a string containing the error message.
|
847 |
+
*/
|
848 |
+
function pmpro_toggleMembershipCategory( $level, $category, $value )
|
849 |
+
{
|
850 |
+
global $wpdb;
|
851 |
+
$category = intval($category);
|
852 |
+
|
853 |
+
if ( ($level = intval($level)) <= 0 )
|
854 |
+
{
|
855 |
+
$safe = addslashes($level);
|
856 |
+
if ( ($level = intval($wpdb->get_var("SELECT id FROM {$wpdb->pmpro_membership_levels} WHERE name = '$safe' LIMIT 1"))) <= 0 )
|
857 |
+
{
|
858 |
+
return __("Membership level not found.", "pmpro");
|
859 |
+
}
|
860 |
+
}
|
861 |
+
|
862 |
+
if ( $value )
|
863 |
+
{
|
864 |
+
$sql = "REPLACE INTO {$wpdb->pmpro_memberships_categories} (`membership_id`,`category_id`) VALUES ('$level','$category')";
|
865 |
+
$wpdb->query($sql);
|
866 |
+
if(mysql_errno()) return mysql_error();
|
867 |
+
}
|
868 |
+
else
|
869 |
+
{
|
870 |
+
$sql = "DELETE FROM {$wpdb->pmpro_memberships_categories} WHERE `membership_id` = '$level' AND `category_id` = '$category' LIMIT 1";
|
871 |
+
$wpdb->query($sql);
|
872 |
+
if(mysql_errno()) return mysql_error();
|
873 |
+
}
|
874 |
+
|
875 |
+
return true;
|
876 |
+
}
|
877 |
+
|
878 |
+
/* pmpro_updateMembershipCategories() ensures that all those and only those categories given
|
879 |
+
* are associated with the given membership level.
|
880 |
+
*
|
881 |
+
* $level is a valid membership level ID or name
|
882 |
+
* $categories is an array of post category IDs
|
883 |
+
*
|
884 |
+
* Return values:
|
885 |
+
* Success returns boolean true.
|
886 |
+
* Failure returns a string containing the error message.
|
887 |
+
*/
|
888 |
+
function pmpro_updateMembershipCategories($level, $categories)
|
889 |
+
{
|
890 |
+
global $wpdb;
|
891 |
+
|
892 |
+
if(!is_numeric($level))
|
893 |
+
{
|
894 |
+
$level = $wpdb->get_var("SELECT id FROM $wpdb->pmpro_membership_levels WHERE name = '" . esc_sql($level) . "' LIMIT 1");
|
895 |
+
if(empty($level))
|
896 |
+
{
|
897 |
+
return __("Membership level not found.", "pmpro");
|
898 |
+
}
|
899 |
+
}
|
900 |
+
|
901 |
+
// remove all existing links...
|
902 |
+
$sqlQuery = "DELETE FROM $wpdb->pmpro_memberships_categories WHERE `membership_id` = '" . esc_sql($level) . "'";
|
903 |
+
$wpdb->query($sqlQuery);
|
904 |
+
if(mysql_errno()) return mysql_error();
|
905 |
+
|
906 |
+
// add the given links [back?] in...
|
907 |
+
foreach($categories as $cat)
|
908 |
+
{
|
909 |
+
if(is_string($r = pmpro_toggleMembershipCategory( $level, $cat, true)))
|
910 |
+
{
|
911 |
+
//uh oh, error
|
912 |
+
return $r;
|
913 |
+
}
|
914 |
+
}
|
915 |
+
|
916 |
+
//all good
|
917 |
+
return true;
|
918 |
+
}
|
919 |
+
|
920 |
+
/* pmpro_getMembershipCategories() returns the categories for a given level
|
921 |
+
*
|
922 |
+
* $level_id is a valid membership level ID
|
923 |
+
*
|
924 |
+
* Return values:
|
925 |
+
* Success returns boolean true.
|
926 |
+
* Failure returns boolean false.
|
927 |
+
*/
|
928 |
+
function pmpro_getMembershipCategories($level_id)
|
929 |
+
{
|
930 |
+
$level_id = intval($level_id);
|
931 |
+
|
932 |
+
global $wpdb;
|
933 |
+
$categories = $wpdb->get_col("SELECT c.category_id
|
934 |
+
FROM {$wpdb->pmpro_memberships_categories} AS c
|
935 |
+
WHERE c.membership_id = '" . $level_id . "'");
|
936 |
+
|
937 |
+
return $categories;
|
938 |
+
}
|
939 |
+
|
940 |
+
|
941 |
+
function pmpro_isAdmin($user_id = NULL)
|
942 |
+
{
|
943 |
+
global $current_user, $wpdb;
|
944 |
+
if(!$user_id)
|
945 |
+
$user_id = $current_user->ID;
|
946 |
+
|
947 |
+
if(!$user_id)
|
948 |
+
return false;
|
949 |
+
|
950 |
+
$admincap = user_can($user_id, "manage_options");
|
951 |
+
if($admincap)
|
952 |
+
return true;
|
953 |
+
else
|
954 |
+
return false;
|
955 |
+
}
|
956 |
+
|
957 |
+
function pmpro_replaceUserMeta($user_id, $meta_keys, $meta_values, $prev_values = NULL)
|
958 |
+
{
|
959 |
+
//expects all arrays for last 3 params or all strings
|
960 |
+
if(!is_array($meta_keys))
|
961 |
+
{
|
962 |
+
$meta_keys = array($meta_keys);
|
963 |
+
$meta_values = array($meta_values);
|
964 |
+
$prev_values = array($prev_values);
|
965 |
+
}
|
966 |
+
|
967 |
+
for($i = 0; $i < count($meta_values); $i++)
|
968 |
+
{
|
969 |
+
if($prev_values[$i])
|
970 |
+
{
|
971 |
+
update_user_meta($user_id, $meta_keys[$i], $meta_values[$i], $prev_values[$i]);
|
972 |
+
}
|
973 |
+
else
|
974 |
+
{
|
975 |
+
$old_value = get_user_meta($user_id, $meta_keys[$i], true);
|
976 |
+
if($old_value)
|
977 |
+
{
|
978 |
+
update_user_meta($user_id, $meta_keys[$i], $meta_values[$i], $old_value);
|
979 |
+
}
|
980 |
+
else
|
981 |
+
{
|
982 |
+
update_user_meta($user_id, $meta_keys[$i], $meta_values[$i]);
|
983 |
+
}
|
984 |
+
}
|
985 |
+
}
|
986 |
+
|
987 |
+
return $i;
|
988 |
+
}
|
989 |
+
|
990 |
+
function pmpro_getMetavalues($query)
|
991 |
+
{
|
992 |
+
global $wpdb;
|
993 |
+
|
994 |
+
$results = $wpdb->get_results($query);
|
995 |
+
$r = new stdClass();
|
996 |
+
foreach($results as $result)
|
997 |
+
{
|
998 |
+
if(!empty($r))
|
999 |
+
$r->{$result->key} = $result->value;
|
1000 |
+
}
|
1001 |
+
|
1002 |
+
return $r;
|
1003 |
+
}
|
1004 |
+
|
1005 |
+
//function to return the pagination string
|
1006 |
+
function pmpro_getPaginationString($page = 1, $totalitems, $limit = 15, $adjacents = 1, $targetpage = "/", $pagestring = "&pn=")
|
1007 |
+
{
|
1008 |
+
//defaults
|
1009 |
+
if(!$adjacents) $adjacents = 1;
|
1010 |
+
if(!$limit) $limit = 15;
|
1011 |
+
if(!$page) $page = 1;
|
1012 |
+
if(!$targetpage) $targetpage = "/";
|
1013 |
+
|
1014 |
+
//other vars
|
1015 |
+
$prev = $page - 1; //previous page is page - 1
|
1016 |
+
$next = $page + 1; //next page is page + 1
|
1017 |
+
$lastpage = ceil($totalitems / $limit); //lastpage is = total items / items per page, rounded up.
|
1018 |
+
$lpm1 = $lastpage - 1; //last page minus 1
|
1019 |
+
|
1020 |
+
/*
|
1021 |
+
Now we apply our rules and draw the pagination object.
|
1022 |
+
We're actually saving the code to a variable in case we want to draw it more than once.
|
1023 |
+
*/
|
1024 |
+
$pagination = "";
|
1025 |
+
if($lastpage > 1)
|
1026 |
+
{
|
1027 |
+
$pagination .= "<div class=\"pmpro_pagination\"";
|
1028 |
+
if(!empty($margin) || !empty($padding))
|
1029 |
+
{
|
1030 |
+
$pagination .= " style=\"";
|
1031 |
+
if($margin)
|
1032 |
+
$pagination .= "margin: $margin;";
|
1033 |
+
if($padding)
|
1034 |
+
$pagination .= "padding: $padding;";
|
1035 |
+
$pagination .= "\"";
|
1036 |
+
}
|
1037 |
+
$pagination .= ">";
|
1038 |
+
|
1039 |
+
//previous button
|
1040 |
+
if ($page > 1)
|
1041 |
+
$pagination .= "<a href=\"$targetpage$pagestring$prev\">« prev</a>";
|
1042 |
+
else
|
1043 |
+
$pagination .= "<span class=\"disabled\">« prev</span>";
|
1044 |
+
|
1045 |
+
//pages
|
1046 |
+
if ($lastpage < 7 + ($adjacents * 2)) //not enough pages to bother breaking it up
|
1047 |
+
{
|
1048 |
+
for ($counter = 1; $counter <= $lastpage; $counter++)
|
1049 |
+
{
|
1050 |
+
if ($counter == $page)
|
1051 |
+
$pagination .= "<span class=\"current\">$counter</span>";
|
1052 |
+
else
|
1053 |
+
$pagination .= "<a href=\"" . $targetpage . $pagestring . $counter . "\">$counter</a>";
|
1054 |
+
}
|
1055 |
+
}
|
1056 |
+
elseif($lastpage >= 7 + ($adjacents * 2)) //enough pages to hide some
|
1057 |
+
{
|
1058 |
+
//close to beginning; only hide later pages
|
1059 |
+
if($page < 1 + ($adjacents * 3))
|
1060 |
+
{
|
1061 |
+
for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++)
|
1062 |
+
{
|
1063 |
+
if ($counter == $page)
|
1064 |
+
$pagination .= "<span class=\"current\">$counter</span>";
|
1065 |
+
else
|
1066 |
+
$pagination .= "<a href=\"" . $targetpage . $pagestring . $counter . "\">$counter</a>";
|
1067 |
+
}
|
1068 |
+
$pagination .= "...";
|
1069 |
+
$pagination .= "<a href=\"" . $targetpage . $pagestring . $lpm1 . "\">$lpm1</a>";
|
1070 |
+
$pagination .= "<a href=\"" . $targetpage . $pagestring . $lastpage . "\">$lastpage</a>";
|
1071 |
+
}
|
1072 |
+
//in middle; hide some front and some back
|
1073 |
+
elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2))
|
1074 |
+
{
|
1075 |
+
$pagination .= "<a href=\"" . $targetpage . $pagestring . "1\">1</a>";
|
1076 |
+
$pagination .= "<a href=\"" . $targetpage . $pagestring . "2\">2</a>";
|
1077 |
+
$pagination .= "...";
|
1078 |
+
for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++)
|
1079 |
+
{
|
1080 |
+
if ($counter == $page)
|
1081 |
+
$pagination .= "<span class=\"current\">$counter</span>";
|
1082 |
+
else
|
1083 |
+
$pagination .= "<a href=\"" . $targetpage . $pagestring . $counter . "\">$counter</a>";
|
1084 |
+
}
|
1085 |
+
$pagination .= "...";
|
1086 |
+
$pagination .= "<a href=\"" . $targetpage . $pagestring . $lpm1 . "\">$lpm1</a>";
|
1087 |
+
$pagination .= "<a href=\"" . $targetpage . $pagestring . $lastpage . "\">$lastpage</a>";
|
1088 |
+
}
|
1089 |
+
//close to end; only hide early pages
|
1090 |
+
else
|
1091 |
+
{
|
1092 |
+
$pagination .= "<a href=\"" . $targetpage . $pagestring . "1\">1</a>";
|
1093 |
+
$pagination .= "<a href=\"" . $targetpage . $pagestring . "2\">2</a>";
|
1094 |
+
$pagination .= "...";
|
1095 |
+
for ($counter = $lastpage - (1 + ($adjacents * 3)); $counter <= $lastpage; $counter++)
|
1096 |
+
{
|
1097 |
+
if ($counter == $page)
|
1098 |
+
$pagination .= "<span class=\"current\">$counter</span>";
|
1099 |
+
else
|
1100 |
+
$pagination .= "<a href=\"" . $targetpage . $pagestring . $counter . "\">$counter</a>";
|
1101 |
+
}
|
1102 |
+
}
|
1103 |
+
}
|
1104 |
+
|
1105 |
+
//next button
|
1106 |
+
if ($page < $counter - 1)
|
1107 |
+
$pagination .= "<a href=\"" . $targetpage . $pagestring . $next . "\">next »</a>";
|
1108 |
+
else
|
1109 |
+
$pagination .= "<span class=\"disabled\">next »</span>";
|
1110 |
+
$pagination .= "</div>\n";
|
1111 |
+
}
|
1112 |
+
|
1113 |
+
return $pagination;
|
1114 |
+
|
1115 |
+
}
|
1116 |
+
|
1117 |
+
function pmpro_calculateInitialPaymentRevenue($s = NULL, $l = NULL)
|
1118 |
+
{
|
1119 |
+
global $wpdb;
|
1120 |
+
|
1121 |
+
//if we're limiting users by search
|
1122 |
+
if($s || $l)
|
1123 |
+
{
|
1124 |
+
$user_ids_query = "SELECT u.ID FROM $wpdb->users u LEFT JOIN $wpdb->usermeta um ON u.ID = um.user_id LEFT JOIN $wpdb->pmpro_memberships_users mu ON u.ID = mu.user_id WHERE mu.status = 'active' ";
|
1125 |
+
if($s)
|
1126 |
+
$user_ids_query .= "AND (u.user_login LIKE '%" . esc_sql($s) . "%' OR u.user_email LIKE '%" . esc_sql($s) . "%' OR um.meta_value LIKE '%$" . esc_sql(s) . "%') ";
|
1127 |
+
if($l)
|
1128 |
+
$user_ids_query .= "AND mu.membership_id = '" . esc_sql($l) . "' ";
|
1129 |
+
}
|
1130 |
+
|
1131 |
+
//query to sum initial payments
|
1132 |
+
$sqlQuery = "SELECT SUM(initial_payment) FROM $wpdb->pmpro_memberships_users WHERE `status` = 'active' ";
|
1133 |
+
if(!empty($user_ids_query))
|
1134 |
+
$sqlQuery .= "AND user_id IN(" . $user_ids_query . ") ";
|
1135 |
+
|
1136 |
+
$total = $wpdb->get_var($sqlQuery);
|
1137 |
+
|
1138 |
+
return (double)$total;
|
1139 |
+
}
|
1140 |
+
|
1141 |
+
function pmpro_calculateRecurringRevenue($s, $l)
|
1142 |
+
{
|
1143 |
+
global $wpdb;
|
1144 |
+
|
1145 |
+
//if we're limiting users by search
|
1146 |
+
if($s || $l)
|
1147 |
+
{
|
1148 |
+
$user_ids_query = "AND user_id IN(SELECT u.ID FROM $wpdb->users u LEFT JOIN $wpdb->usermeta um ON u.ID = um.user_id LEFT JOIN $wpdb->pmpro_memberships_users mu ON u.ID = mu.user_id WHERE mu.status = 'active' ";
|
1149 |
+
if($s)
|
1150 |
+
$user_ids_query .= "AND (u.user_login LIKE '%" . esc_sql($s) . "%' OR u.user_email LIKE '%" . esc_sql($s) . "%' OR um.meta_value LIKE '%" . esc_sql($s) . "%') ";
|
1151 |
+
if($l)
|
1152 |
+
$user_ids_query .= "AND mu.membership_id = '" . esc_sql($l) . "' ";
|
1153 |
+
$user_ids_query .= ")";
|
1154 |
+
}
|
1155 |
+
else
|
1156 |
+
$user_ids_query = "";
|
1157 |
+
|
1158 |
+
//4 queries to get annual earnings for each cycle period. currently ignoring trial periods and billing limits.
|
1159 |
+
$sqlQuery = "
|
1160 |
+
SELECT SUM((12/cycle_number)*billing_amount) FROM $wpdb->pmpro_memberships_users WHERE status = 'active' AND cycle_period = 'Month' AND cycle_number <> 12 $user_ids_query
|
1161 |
+
UNION
|
1162 |
+
SELECT SUM((365/cycle_number)*billing_amount) FROM $wpdb->pmpro_memberships_users WHERE status = 'active' AND cycle_period = 'Day' AND cycle_number <> 365 $user_ids_query
|
1163 |
+
UNION
|
1164 |
+
SELECT SUM((52/cycle_number)*billing_amount) FROM $wpdb->pmpro_memberships_users WHERE status = 'active' AND cycle_period = 'Week' AND cycle_number <> 52 $user_ids_query
|
1165 |
+
UNION
|
1166 |
+
SELECT SUM(billing_amount) FROM $wpdb->pmpro_memberships_users WHERE status = 'active' AND cycle_period = 'Year' $user_ids_query
|
1167 |
+
";
|
1168 |
+
|
1169 |
+
$annual_revenues = $wpdb->get_col($sqlQuery);
|
1170 |
+
|
1171 |
+
$total = 0;
|
1172 |
+
foreach($annual_revenues as $r)
|
1173 |
+
{
|
1174 |
+
$total += $r;
|
1175 |
+
}
|
1176 |
+
|
1177 |
+
return $total;
|
1178 |
+
}
|
1179 |
+
|
1180 |
+
function pmpro_generateUsername($firstname = "", $lastname = "", $email = "")
|
1181 |
+
{
|
1182 |
+
global $wpdb;
|
1183 |
+
|
1184 |
+
//try first initial + last name, firstname, lastname
|
1185 |
+
$firstname = preg_replace("/[^A-Za-z]/", "", $firstname);
|
1186 |
+
$lastname = preg_replace("/[^A-Za-z]/", "", $lastname);
|
1187 |
+
if($firstname && $lastname)
|
1188 |
+
{
|
1189 |
+
$username = substr($firstname, 0, 1) . $lastname;
|
1190 |
+
}
|
1191 |
+
elseif($firstname)
|
1192 |
+
{
|
1193 |
+
$username = $firstname;
|
1194 |
+
}
|
1195 |
+
elseif($lastname)
|
1196 |
+
{
|
1197 |
+
$username = $lastname;
|
1198 |
+
}
|
1199 |
+
|
1200 |
+
//is it taken?
|
1201 |
+
$taken = $wpdb->get_var("SELECT user_login FROM $wpdb->users WHERE user_login = '" . esc_sql($username) . "' LIMIT 1");
|
1202 |
+
|
1203 |
+
if(!$taken)
|
1204 |
+
return $username;
|
1205 |
+
|
1206 |
+
//try the beginning of the email address
|
1207 |
+
$emailparts = explode("@", $email);
|
1208 |
+
if(is_array($emailparts))
|
1209 |
+
$email = preg_replace("/[^A-Za-z]/", "", $emailparts[0]);
|
1210 |
+
|
1211 |
+
if(!empty($email))
|
1212 |
+
{
|
1213 |
+
$username = $email;
|
1214 |
+
}
|
1215 |
+
|
1216 |
+
//is this taken? if not, add numbers until it works
|
1217 |
+
$taken = true;
|
1218 |
+
$count = 0;
|
1219 |
+
while($taken)
|
1220 |
+
{
|
1221 |
+
//add a # to the end
|
1222 |
+
if($count)
|
1223 |
+
{
|
1224 |
+
$username = preg_replace("/[0-9]/", "", $username) . $count;
|
1225 |
+
}
|
1226 |
+
|
1227 |
+
//taken?
|
1228 |
+
$taken = $wpdb->get_var("SELECT user_login FROM $wpdb->users WHERE user_login = '" . esc_sql($username) . "' LIMIT 1");
|
1229 |
+
|
1230 |
+
//increment the number
|
1231 |
+
$count++;
|
1232 |
+
}
|
1233 |
+
|
1234 |
+
//must have a good username now
|
1235 |
+
return $username;
|
1236 |
+
}
|
1237 |
+
|
1238 |
+
//get a new random code for discount codes
|
1239 |
+
function pmpro_getDiscountCode($seed = NULL)
|
1240 |
+
{
|
1241 |
+
global $wpdb;
|
1242 |
+
|
1243 |
+
while(empty($code))
|
1244 |
+
{
|
1245 |
+
$scramble = md5(AUTH_KEY . current_time('timestamp') . $seed . SECURE_AUTH_KEY);
|
1246 |
+
$code = substr($scramble, 0, 10);
|
1247 |
+
$check = $wpdb->get_var("SELECT code FROM $wpdb->pmpro_discount_codes WHERE code = '" . esc_sql($code) . "' LIMIT 1");
|
1248 |
+
if($check || is_numeric($code))
|
1249 |
+
$code = NULL;
|
1250 |
+
}
|
1251 |
+
|
1252 |
+
return strtoupper($code);
|
1253 |
+
}
|
1254 |
+
|
1255 |
+
//is a discount code valid
|
1256 |
+
function pmpro_checkDiscountCode($code, $level_id = NULL, $return_errors = false)
|
1257 |
+
{
|
1258 |
+
global $wpdb;
|
1259 |
+
|
1260 |
+
$error = false;
|
1261 |
+
|
1262 |
+
//make sure level id is int for security
|
1263 |
+
$level_id = intval($level_id);
|
1264 |
+
|
1265 |
+
//no code, no code
|
1266 |
+
if(empty($code))
|
1267 |
+
$error = __("No code was given to check.", "pmpro");
|
1268 |
+
|
1269 |
+
//get code from db
|
1270 |
+
if(!$error)
|
1271 |
+
{
|
1272 |
+
$dbcode = $wpdb->get_row("SELECT *, UNIX_TIMESTAMP(starts) as starts, UNIX_TIMESTAMP(expires) as expires FROM $wpdb->pmpro_discount_codes WHERE code ='" . esc_sql($code) . "' LIMIT 1");
|
1273 |
+
|
1274 |
+
//did we find it?
|
1275 |
+
if(empty($dbcode->id))
|
1276 |
+
$error = __("The discount code could not be found.", "pmpro");
|
1277 |
+
}
|
1278 |
+
|
1279 |
+
//check if the code has started
|
1280 |
+
if(!$error)
|
1281 |
+
{
|
1282 |
+
//fix the date timestamps
|
1283 |
+
$dbcode->starts = strtotime(date("m/d/Y", $dbcode->starts));
|
1284 |
+
$dbcode->expires = strtotime(date("m/d/Y", $dbcode->expires));
|
1285 |
+
|
1286 |
+
//today
|
1287 |
+
$today = strtotime(date("m/d/Y 00:00:00", current_time("timestamp")));
|
1288 |
+
|
1289 |
+
//has this code started yet?
|
1290 |
+
if(!empty($dbcode->starts) && $dbcode->starts > $today)
|
1291 |
+
$error = sprintf(__("This discount code goes into effect on %s.", "pmpro"), date(get_option('date_format'), $dbcode->starts));
|
1292 |
+
}
|
1293 |
+
|
1294 |
+
//check if the code is expired
|
1295 |
+
if(!$error)
|
1296 |
+
{
|
1297 |
+
if(!empty($dbcode->expires) && $dbcode->expires < $today)
|
1298 |
+
$error = sprintf(__("This discount code expired on %s.", "pmpro"), date(get_option('date_format'), $dbcode->expires));
|
1299 |
+
}
|
1300 |
+
|
1301 |
+
//have we run out of uses?
|
1302 |
+
if(!$error)
|
1303 |
+
{
|
1304 |
+
if($dbcode->uses > 0)
|
1305 |
+
{
|
1306 |
+
$used = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->pmpro_discount_codes_uses WHERE code_id = '" . $dbcode->id . "'");
|
1307 |
+
if($used >= $dbcode->uses)
|
1308 |
+
$error = __("This discount code is no longer valid.", "pmpro");
|
1309 |
+
}
|
1310 |
+
}
|
1311 |
+
|
1312 |
+
//if a level was passed check if this code applies
|
1313 |
+
if(!$error)
|
1314 |
+
{
|
1315 |
+
$pmpro_check_discount_code_levels = apply_filters("pmpro_check_discount_code_levels", true, $dbcode->id);
|
1316 |
+
if(!empty($level_id) && $pmpro_check_discount_code_levels)
|
1317 |
+
{
|
1318 |
+
$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 = '" . $dbcode->id . "' AND cl.level_id = '" . $level_id . "' LIMIT 1");
|
1319 |
+
|
1320 |
+
if(empty($code_level))
|
1321 |
+
$error = __("This discount code does not apply to this membership level.", "pmpro");
|
1322 |
+
}
|
1323 |
+
}
|
1324 |
+
|
1325 |
+
//allow filter
|
1326 |
+
$pmpro_check_discount_code = apply_filters("pmpro_check_discount_code", !$error, $dbcode, $level_id, $code);
|
1327 |
+
if(is_string($pmpro_check_discount_code))
|
1328 |
+
$error = $pmpro_check_discount_code; //string returned, this is an error
|
1329 |
+
elseif(!$pmpro_check_discount_code && !$error)
|
1330 |
+
$error = true; //no error before, but filter returned error
|
1331 |
+
elseif($pmpro_check_discount_code)
|
1332 |
+
$error = false; //filter is true, so error false
|
1333 |
+
|
1334 |
+
//return
|
1335 |
+
if($error)
|
1336 |
+
{
|
1337 |
+
//there was an error
|
1338 |
+
if(!empty($return_errors))
|
1339 |
+
return array(false, $error);
|
1340 |
+
else
|
1341 |
+
return false;
|
1342 |
+
}
|
1343 |
+
else
|
1344 |
+
{
|
1345 |
+
//guess we're all good
|
1346 |
+
if(!empty($return_errors))
|
1347 |
+
return array(true, __("This discount code is okay.", "pmpro"));
|
1348 |
+
else
|
1349 |
+
return true;
|
1350 |
+
}
|
1351 |
+
}
|
1352 |
+
|
1353 |
+
function pmpro_no_quotes($s, $quotes = array("'", '"'))
|
1354 |
+
{
|
1355 |
+
return str_replace($quotes, "", $s);
|
1356 |
+
}
|
1357 |
+
|
1358 |
+
//from: http://www.php.net/manual/en/function.implode.php#86845
|
1359 |
+
function pmpro_implodeToEnglish($array)
|
1360 |
+
{
|
1361 |
+
// sanity check
|
1362 |
+
if (!$array || !count ($array))
|
1363 |
+
return '';
|
1364 |
+
|
1365 |
+
// get last element
|
1366 |
+
$last = array_pop ($array);
|
1367 |
+
|
1368 |
+
// if it was the only element - return it
|
1369 |
+
if (!count ($array))
|
1370 |
+
return $last;
|
1371 |
+
|
1372 |
+
return implode (', ', $array).' ' . __('and', 'pmpro') . ' '.$last;
|
1373 |
+
}
|
1374 |
+
|
1375 |
+
//from yoast wordpress seo
|
1376 |
+
function pmpro_text_limit( $text, $limit, $finish = '…')
|
1377 |
+
{
|
1378 |
+
if( strlen( $text ) > $limit ) {
|
1379 |
+
$text = substr( $text, 0, $limit );
|
1380 |
+
$text = substr( $text, 0, - ( strlen( strrchr( $text,' ') ) ) );
|
1381 |
+
$text .= $finish;
|
1382 |
+
}
|
1383 |
+
return $text;
|
1384 |
+
}
|
1385 |
+
|
1386 |
+
/* pmpro_getMembershipLevelForUser() returns the first active membership level for a user
|
1387 |
+
*
|
1388 |
+
* If $user_id is omitted, the value will be retrieved from $current_user.
|
1389 |
+
*
|
1390 |
+
* Return values:
|
1391 |
+
* Success returns the level object.
|
1392 |
+
* Failure returns false.
|
1393 |
+
*/
|
1394 |
+
function pmpro_getMembershipLevelForUser($user_id = NULL, $force = false)
|
1395 |
+
{
|
1396 |
+
if(empty($user_id))
|
1397 |
+
{
|
1398 |
+
global $current_user;
|
1399 |
+
$user_id = $current_user->ID;
|
1400 |
+
}
|
1401 |
+
|
1402 |
+
if(empty($user_id))
|
1403 |
+
{
|
1404 |
+
return false;
|
1405 |
+
}
|
1406 |
+
|
1407 |
+
//make sure user id is int for security
|
1408 |
+
$user_id = intval($user_id);
|
1409 |
+
|
1410 |
+
global $all_membership_levels;
|
1411 |
+
|
1412 |
+
if(isset($all_membership_levels[$user_id]) && !$force)
|
1413 |
+
{
|
1414 |
+
return $all_membership_levels[$user_id];
|
1415 |
+
}
|
1416 |
+
else
|
1417 |
+
{
|
1418 |
+
global $wpdb;
|
1419 |
+
$all_membership_levels[$user_id] = $wpdb->get_row("SELECT
|
1420 |
+
l.id AS ID,
|
1421 |
+
l.id as id,
|
1422 |
+
mu.id as subscription_id,
|
1423 |
+
l.name AS name,
|
1424 |
+
l.description,
|
1425 |
+
l.expiration_number,
|
1426 |
+
l.expiration_period,
|
1427 |
+
mu.initial_payment,
|
1428 |
+
mu.billing_amount,
|
1429 |
+
mu.cycle_number,
|
1430 |
+
mu.cycle_period,
|
1431 |
+
mu.billing_limit,
|
1432 |
+
mu.trial_amount,
|
1433 |
+
mu.trial_limit,
|
1434 |
+
mu.code_id as code_id,
|
1435 |
+
UNIX_TIMESTAMP(startdate) as startdate,
|
1436 |
+
UNIX_TIMESTAMP(enddate) as enddate
|
1437 |
+
FROM {$wpdb->pmpro_membership_levels} AS l
|
1438 |
+
JOIN {$wpdb->pmpro_memberships_users} AS mu ON (l.id = mu.membership_id)
|
1439 |
+
WHERE mu.user_id = $user_id AND mu.status = 'active'
|
1440 |
+
LIMIT 1");
|
1441 |
+
|
1442 |
+
/**
|
1443 |
+
* pmpro_get_membership_level_for_user filter.
|
1444 |
+
*
|
1445 |
+
* Filters the returned level.
|
1446 |
+
*
|
1447 |
+
* @since 1.8.5.4
|
1448 |
+
*
|
1449 |
+
* @param object $level Level object.
|
1450 |
+
*/
|
1451 |
+
$all_membership_levels[$user_id] = apply_filters('pmpro_get_membership_level_for_user', $all_membership_levels[$user_id]);
|
1452 |
+
|
1453 |
+
return $all_membership_levels[$user_id];
|
1454 |
+
}
|
1455 |
+
}
|
1456 |
+
|
1457 |
+
/* pmpro_getMembershipLevelsForUser() returns the membership levels for a user
|
1458 |
+
*
|
1459 |
+
* If $user_id is omitted, the value will be retrieved from $current_user.
|
1460 |
+
* By default it only includes actvie memberships.
|
1461 |
+
*
|
1462 |
+
* Return values:
|
1463 |
+
* Success returns an array of level objects.
|
1464 |
+
* Failure returns false.
|
1465 |
+
*/
|
1466 |
+
function pmpro_getMembershipLevelsForUser($user_id = NULL, $include_inactive = false)
|
1467 |
+
{
|
1468 |
+
if(empty($user_id))
|
1469 |
+
{
|
1470 |
+
global $current_user;
|
1471 |
+
$user_id = $current_user->ID;
|
1472 |
+
}
|
1473 |
+
|
1474 |
+
if(empty($user_id))
|
1475 |
+
{
|
1476 |
+
return false;
|
1477 |
+
}
|
1478 |
+
|
1479 |
+
//make sure user id is int for security
|
1480 |
+
$user_id = intval($user_id);
|
1481 |
+
|
1482 |
+
global $wpdb;
|
1483 |
+
|
1484 |
+
$levels = $wpdb->get_results("SELECT
|
1485 |
+
l.id AS ID,
|
1486 |
+
l.id as id,
|
1487 |
+
mu.id as subscription_id,
|
1488 |
+
l.name,
|
1489 |
+
l.description,
|
1490 |
+
l.expiration_number,
|
1491 |
+
l.expiration_period,
|
1492 |
+
mu.initial_payment,
|
1493 |
+
mu.billing_amount,
|
1494 |
+
mu.cycle_number,
|
1495 |
+
mu.cycle_period,
|
1496 |
+
mu.billing_limit,
|
1497 |
+
mu.trial_amount,
|
1498 |
+
mu.trial_limit,
|
1499 |
+
mu.code_id as code_id,
|
1500 |
+
UNIX_TIMESTAMP(startdate) as startdate,
|
1501 |
+
UNIX_TIMESTAMP(enddate) as enddate
|
1502 |
+
FROM {$wpdb->pmpro_membership_levels} AS l
|
1503 |
+
JOIN {$wpdb->pmpro_memberships_users} AS mu ON (l.id = mu.membership_id)
|
1504 |
+
WHERE mu.user_id = $user_id".($include_inactive?"":" AND mu.status = 'active'"));
|
1505 |
+
/**
|
1506 |
+
* pmpro_get_membership_levels_for_user filter.
|
1507 |
+
*
|
1508 |
+
* Filters the returned levels.
|
1509 |
+
*
|
1510 |
+
* @since 1.8.5.4
|
1511 |
+
*
|
1512 |
+
* @param array $levels Array of level objects.
|
1513 |
+
*/
|
1514 |
+
$levels = apply_filters('pmpro_get_membership_levels_for_user', $levels);
|
1515 |
+
|
1516 |
+
return $levels;
|
1517 |
+
}
|
1518 |
+
|
1519 |
+
/* pmpro_getLevel() returns the level object for a level
|
1520 |
+
*
|
1521 |
+
* $level may be the level id or name
|
1522 |
+
*
|
1523 |
+
* Return values:
|
1524 |
+
* Success returns the level object.
|
1525 |
+
* Failure returns false.
|
1526 |
+
*/
|
1527 |
+
function pmpro_getLevel($level)
|
1528 |
+
{
|
1529 |
+
global $pmpro_levels;
|
1530 |
+
|
1531 |
+
if(is_object($level) && !empty($level->id))
|
1532 |
+
$level = $level->id;
|
1533 |
+
|
1534 |
+
//was a name passed? (Todo: make sure level names have at least one non-numeric character.
|
1535 |
+
if(is_numeric($level))
|
1536 |
+
{
|
1537 |
+
$level_id = intval($level);
|
1538 |
+
if(isset($pmpro_levels[$level_id]))
|
1539 |
+
{
|
1540 |
+
return $pmpro_levels[$level_id];
|
1541 |
+
}
|
1542 |
+
else
|
1543 |
+
{
|
1544 |
+
global $wpdb;
|
1545 |
+
$pmpro_levels[$level_id] = $wpdb->get_row("SELECT * FROM $wpdb->pmpro_membership_levels WHERE id = '" . $level_id . "' LIMIT 1");
|
1546 |
+
return $pmpro_levels[$level_id];
|
1547 |
+
}
|
1548 |
+
}
|
1549 |
+
else
|
1550 |
+
{
|
1551 |
+
global $wpdb;
|
1552 |
+
$level_obj = $wpdb->get_row("SELECT * FROM $wpdb->pmpro_membership_levels WHERE name = '" . esc_sql($level) . "' LIMIT 1");
|
1553 |
+
|
1554 |
+
if(!empty($level_obj))
|
1555 |
+
$level_id = $level_obj->id;
|
1556 |
+
else
|
1557 |
+
return false;
|
1558 |
+
|
1559 |
+
$pmpro_levels[$level_id] = $level_obj;
|
1560 |
+
return $pmpro_levels[$level_id];
|
1561 |
+
}
|
1562 |
+
}
|
1563 |
+
|
1564 |
+
/*
|
1565 |
+
Function to populate pmpro_levels with all levels. We query the DB every time just to be sure we have the latest.
|
1566 |
+
This should be called if you want to be sure you get all levels as $pmpro_levels may only have a subset of levels.
|
1567 |
+
*/
|
1568 |
+
function pmpro_getAllLevels($include_hidden = false, $force = false)
|
1569 |
+
{
|
1570 |
+
global $pmpro_levels, $wpdb;
|
1571 |
+
|
1572 |
+
//just use what's cached (doesn't take into account include_hidden setting)
|
1573 |
+
if(!empty($pmpro_levels) && !$force)
|
1574 |
+
return $pmpro_levels;
|
1575 |
+
|
1576 |
+
//build query
|
1577 |
+
$sqlQuery = "SELECT * FROM $wpdb->pmpro_membership_levels ";
|
1578 |
+
if(!$include_hidden)
|
1579 |
+
$sqlQuery .= " WHERE allow_signups = 1 ORDER BY id";
|
1580 |
+
|
1581 |
+
//get levels from the DB
|
1582 |
+
$raw_levels = $wpdb->get_results($sqlQuery);
|
1583 |
+
|
1584 |
+
//lets put them into an array where the key is the id of the level
|
1585 |
+
$pmpro_levels = array();
|
1586 |
+
foreach($raw_levels as $raw_level)
|
1587 |
+
{
|
1588 |
+
$pmpro_levels[$raw_level->id] = $raw_level;
|
1589 |
+
}
|
1590 |
+
|
1591 |
+
return $pmpro_levels;
|
1592 |
+
}
|
1593 |
+
|
1594 |
+
function pmpro_getCheckoutButton($level_id, $button_text = NULL, $classes = NULL)
|
1595 |
+
{
|
1596 |
+
if(empty($button_text))
|
1597 |
+
$button_text = __("Sign Up for !!name!! Now", "pmpro");
|
1598 |
+
|
1599 |
+
if(empty($classes))
|
1600 |
+
$classes = "pmpro_btn";
|
1601 |
+
|
1602 |
+
if(empty($level_id))
|
1603 |
+
$r = __("Please specify a level id.", "pmpro");
|
1604 |
+
else
|
1605 |
+
{
|
1606 |
+
//get level
|
1607 |
+
$level = pmpro_getLevel($level_id);
|
1608 |
+
|
1609 |
+
//replace vars
|
1610 |
+
$replacements = array(
|
1611 |
+
"!!id!!" => $level->id,
|
1612 |
+
"!!name!!" => $level->name,
|
1613 |
+
"!!description!!" => $level->description,
|
1614 |
+
"!!confirmation!!" => $level->confirmation,
|
1615 |
+
"!!initial_payment!!" => $level->initial_payment,
|
1616 |
+
"!!billing_amount!!" => $level->billing_amount,
|
1617 |
+
"!!cycle_number!!" => $level->cycle_number,
|
1618 |
+
"!!cycle_period!!" => $level->cycle_period,
|
1619 |
+
"!!billing_limit!!" => $level->billing_limit,
|
1620 |
+
"!!trial_amount!!" => $level->trial_amount,
|
1621 |
+
"!!trial_limit!!" => $level->trial_limit,
|
1622 |
+
"!!expiration_number!!" => $level->expiration_number,
|
1623 |
+
"!!expiration_period!!" => $level->expiration_period
|
1624 |
+
);
|
1625 |
+
$button_text = str_replace(array_keys($replacements), $replacements, $button_text);
|
1626 |
+
|
1627 |
+
//button text
|
1628 |
+
$r = "<a href=\"" . pmpro_url("checkout", "?level=" . $level_id) . "\" class=\"" . $classes . "\">" . $button_text . "</a>";
|
1629 |
+
}
|
1630 |
+
return $r;
|
1631 |
+
}
|
1632 |
+
|
1633 |
+
/**
|
1634 |
+
* Get the "domain" from a URL. By domain, we mean the host name, minus any subdomains. So just the domain and TLD.
|
1635 |
+
*
|
1636 |
+
* @param string $url The URL to parse. (generally pass site_url() in WP)
|
1637 |
+
* @return string The domain.
|
1638 |
+
*/
|
1639 |
+
function pmpro_getDomainFromURL($url = NULL)
|
1640 |
+
{
|
1641 |
+
$domainparts = parse_url($url);
|
1642 |
+
$domainparts = explode(".", $domainparts['host']);
|
1643 |
+
if(count($domainparts) > 1)
|
1644 |
+
{
|
1645 |
+
//check for ips
|
1646 |
+
$isip = true;
|
1647 |
+
foreach($domainparts as $part)
|
1648 |
+
{
|
1649 |
+
if(!is_numeric($part))
|
1650 |
+
{
|
1651 |
+
$isip = false;
|
1652 |
+
break;
|
1653 |
+
}
|
1654 |
+
}
|
1655 |
+
|
1656 |
+
if($isip)
|
1657 |
+
{
|
1658 |
+
//ip, e.g. 127.1.1.1
|
1659 |
+
$domain = implode(".", $domainparts);
|
1660 |
+
}
|
1661 |
+
else
|
1662 |
+
{
|
1663 |
+
//www.something.com, etc.
|
1664 |
+
$domain = $domainparts[count($domainparts)-2] . "." . $domainparts[count($domainparts)-1];
|
1665 |
+
}
|
1666 |
+
}
|
1667 |
+
else
|
1668 |
+
{
|
1669 |
+
//localhost or another single word domain
|
1670 |
+
$domain = $domainparts[0];
|
1671 |
+
}
|
1672 |
+
|
1673 |
+
return $domain;
|
1674 |
+
}
|
1675 |
+
|
1676 |
+
/*
|
1677 |
+
Get a member's start date... either in general or for a specific level_id.
|
1678 |
+
*/
|
1679 |
+
if(!function_exists("pmpro_getMemberStartdate"))
|
1680 |
+
{
|
1681 |
+
function pmpro_getMemberStartdate($user_id = NULL, $level_id = 0)
|
1682 |
+
{
|
1683 |
+
if(empty($user_id))
|
1684 |
+
{
|
1685 |
+
global $current_user;
|
1686 |
+
$user_id = $current_user->ID;
|
1687 |
+
}
|
1688 |
+
|
1689 |
+
//make sure user and level id are int for security
|
1690 |
+
$user_id = intval($user_id);
|
1691 |
+
$level_id = intval($level_id);
|
1692 |
+
|
1693 |
+
global $pmpro_startdates; //for cache
|
1694 |
+
if(empty($pmpro_startdates[$user_id][$level_id]))
|
1695 |
+
{
|
1696 |
+
global $wpdb;
|
1697 |
+
|
1698 |
+
if(!empty($level_id))
|
1699 |
+
$sqlQuery = "SELECT UNIX_TIMESTAMP(startdate) FROM $wpdb->pmpro_memberships_users WHERE status = 'active' AND membership_id IN(" . esc_sql($level_id) . ") AND user_id = '" . $user_id . "' ORDER BY id LIMIT 1";
|
1700 |
+
else
|
1701 |
+
$sqlQuery = "SELECT UNIX_TIMESTAMP(startdate) FROM $wpdb->pmpro_memberships_users WHERE status = 'active' AND user_id = '" . $user_id . "' ORDER BY id LIMIT 1";
|
1702 |
+
|
1703 |
+
$startdate = apply_filters("pmpro_member_startdate", $wpdb->get_var($sqlQuery), $user_id, $level_id);
|
1704 |
+
|
1705 |
+
$pmpro_startdates[$user_id][$level_id] = $startdate;
|
1706 |
+
}
|
1707 |
+
|
1708 |
+
return $pmpro_startdates[$user_id][$level_id];
|
1709 |
+
}
|
1710 |
+
}
|
1711 |
+
|
1712 |
+
/*
|
1713 |
+
How long has this member been a member
|
1714 |
+
*/
|
1715 |
+
if(!function_exists("pmpro_getMemberDays"))
|
1716 |
+
{
|
1717 |
+
function pmpro_getMemberDays($user_id = NULL, $level_id = 0)
|
1718 |
+
{
|
1719 |
+
if(empty($user_id))
|
1720 |
+
{
|
1721 |
+
global $current_user;
|
1722 |
+
$user_id = $current_user->ID;
|
1723 |
+
}
|
1724 |
+
|
1725 |
+
global $pmpro_member_days;
|
1726 |
+
if(empty($pmpro_member_days[$user_id][$level_id]))
|
1727 |
+
{
|
1728 |
+
$startdate = pmpro_getMemberStartdate($user_id, $level_id);
|
1729 |
+
|
1730 |
+
//check that there was a startdate at all
|
1731 |
+
if(empty($startdate))
|
1732 |
+
$pmpro_member_days[$user_id][$level_id] = 0;
|
1733 |
+
else
|
1734 |
+
{
|
1735 |
+
$now = current_time('timestamp');
|
1736 |
+
$days = ($now - $startdate)/3600/24;
|
1737 |
+
|
1738 |
+
$pmpro_member_days[$user_id][$level_id] = $days;
|
1739 |
+
}
|
1740 |
+
}
|
1741 |
+
|
1742 |
+
return $pmpro_member_days[$user_id][$level_id];
|
1743 |
+
}
|
1744 |
+
}
|
1745 |
+
|
1746 |
+
//the start of a message handling script
|
1747 |
+
function pmpro_setMessage($message, $type, $force = false)
|
1748 |
+
{
|
1749 |
+
global $pmpro_msg, $pmpro_msgt;
|
1750 |
+
|
1751 |
+
//for now, we only show the first message generated
|
1752 |
+
if($force || empty($pmpro_msg))
|
1753 |
+
{
|
1754 |
+
$pmpro_msg = $message;
|
1755 |
+
$pmpro_msgt = $type;
|
1756 |
+
}
|
1757 |
+
}
|
1758 |
+
|
1759 |
+
/**
|
1760 |
+
* Show a a PMPro message set via pmpro_setMessage
|
1761 |
+
*
|
1762 |
+
* @since 1.8.5
|
1763 |
+
*/
|
1764 |
+
function pmpro_showMessage()
|
1765 |
+
{
|
1766 |
+
global $pmpro_msg, $pmpro_msgt;
|
1767 |
+
|
1768 |
+
if(!empty($pmpro_msg))
|
1769 |
+
{
|
1770 |
+
?>
|
1771 |
+
<div class="<?php echo $pmpro_msgt;?>">
|
1772 |
+
<p><?php echo $pmpro_msg;?></p>
|
1773 |
+
</div>
|
1774 |
+
<?php
|
1775 |
+
}
|
1776 |
+
}
|
1777 |
+
|
1778 |
+
//used in class definitions for input fields to see if there was an error
|
1779 |
+
function pmpro_getClassForField($field)
|
1780 |
+
{
|
1781 |
+
global $pmpro_error_fields, $pmpro_required_billing_fields, $pmpro_required_user_fields;
|
1782 |
+
$classes = array();
|
1783 |
+
|
1784 |
+
//error on this field?
|
1785 |
+
if(!empty($pmpro_error_fields) && in_array($field, $pmpro_error_fields))
|
1786 |
+
{
|
1787 |
+
$classes[] = "pmpro_error";
|
1788 |
+
}
|
1789 |
+
|
1790 |
+
if(is_array($pmpro_required_billing_fields) && is_array($pmpro_required_user_fields))
|
1791 |
+
$required_fields = array_merge(array_keys($pmpro_required_billing_fields), array_keys($pmpro_required_user_fields));
|
1792 |
+
elseif(is_array($pmpro_required_billing_fields))
|
1793 |
+
$required_fields = array_keys($pmpro_required_billing_fields);
|
1794 |
+
elseif(is_array($pmpro_required_user_fields))
|
1795 |
+
$required_fields = array_keys($pmpro_required_user_fields);
|
1796 |
+
else
|
1797 |
+
$required_fields = array();
|
1798 |
+
|
1799 |
+
//required?
|
1800 |
+
if(in_array($field, $required_fields))
|
1801 |
+
{
|
1802 |
+
$classes[] = "pmpro_required";
|
1803 |
+
}
|
1804 |
+
|
1805 |
+
$classes = apply_filters("pmpro_field_classes", $classes, $field);
|
1806 |
+
|
1807 |
+
if(!empty($classes))
|
1808 |
+
return implode(" ", $classes);
|
1809 |
+
else
|
1810 |
+
return "";
|
1811 |
+
}
|
1812 |
+
|
1813 |
+
//get a var from $_GET or $_POST
|
1814 |
+
function pmpro_getParam($index, $method = "REQUEST", $default = "")
|
1815 |
+
{
|
1816 |
+
if($method == "REQUEST")
|
1817 |
+
{
|
1818 |
+
if(!empty($_REQUEST[$index]))
|
1819 |
+
return $_REQUEST[$index];
|
1820 |
+
}
|
1821 |
+
elseif($method == "POST")
|
1822 |
+
{
|
1823 |
+
if(!empty($_POST[$index]))
|
1824 |
+
return $_POST[$index];
|
1825 |
+
}
|
1826 |
+
elseif($method == "GET")
|
1827 |
+
{
|
1828 |
+
if(!empty($_GET[$index]))
|
1829 |
+
return $_GET[$index];
|
1830 |
+
}
|
1831 |
+
|
1832 |
+
return $default;
|
1833 |
+
}
|
1834 |
+
|
1835 |
+
/*
|
1836 |
+
Format an address from address, city, state, zip, country, and phone
|
1837 |
+
*/
|
1838 |
+
function pmpro_formatAddress($name, $address1, $address2, $city, $state, $zip, $country, $phone, $nl2br = true)
|
1839 |
+
{
|
1840 |
+
$address = "";
|
1841 |
+
|
1842 |
+
if(!empty($name))
|
1843 |
+
$address .= $name . "\n";
|
1844 |
+
|
1845 |
+
if(!empty($address1))
|
1846 |
+
$address .= $address1 . "\n";
|
1847 |
+
|
1848 |
+
if(!empty($address2))
|
1849 |
+
$address .= $address2 . "\n";
|
1850 |
+
|
1851 |
+
if(!empty($city) && !empty($state))
|
1852 |
+
{
|
1853 |
+
$address .= $city . ", " . $state;
|
1854 |
+
|
1855 |
+
if(!empty($zip))
|
1856 |
+
$address .= " " . $zip;
|
1857 |
+
|
1858 |
+
$address .= "\n";
|
1859 |
+
}
|
1860 |
+
|
1861 |
+
if(!empty($country))
|
1862 |
+
$address .= $country . "\n";
|
1863 |
+
|
1864 |
+
if(!empty($phone))
|
1865 |
+
$address .= formatPhone($phone);
|
1866 |
+
|
1867 |
+
if($nl2br)
|
1868 |
+
$address = nl2br($address);
|
1869 |
+
|
1870 |
+
return $address;
|
1871 |
+
}
|
1872 |
+
|
1873 |
+
/*
|
1874 |
+
Checks if all required settings are set.
|
1875 |
+
*/
|
1876 |
+
function pmpro_is_ready()
|
1877 |
+
{
|
1878 |
+
global $wpdb, $pmpro_pages, $pmpro_level_ready, $pmpro_gateway_ready, $pmpro_pages_ready;
|
1879 |
+
|
1880 |
+
//check if there is at least one level
|
1881 |
+
$pmpro_level_ready = (bool)$wpdb->get_var("SELECT id FROM $wpdb->pmpro_membership_levels LIMIT 1");
|
1882 |
+
|
1883 |
+
//check if the gateway settings are good. first check if it's needed (is there paid membership level)
|
1884 |
+
$paid_membership_level = $wpdb->get_var("SELECT id FROM $wpdb->pmpro_membership_levels WHERE allow_signups = 1 AND (initial_payment > 0 OR billing_amount > 0 OR trial_amount > 0) LIMIT 1");
|
1885 |
+
$paid_user_subscription = $wpdb->get_var("SELECT user_id FROM $wpdb->pmpro_memberships_users WHERE initial_payment > 0 OR billing_amount > 0 OR trial_amount > 0 LIMIT 1");
|
1886 |
+
|
1887 |
+
if(empty($paid_membership_level) && empty($paid_user_subscription))
|
1888 |
+
{
|
1889 |
+
//no paid membership level now or attached to a user. we don't need the gateway setup
|
1890 |
+
$pmpro_gateway_ready = true;
|
1891 |
+
}
|
1892 |
+
else
|
1893 |
+
{
|
1894 |
+
$gateway = pmpro_getOption("gateway");
|
1895 |
+
if($gateway == "authorizenet")
|
1896 |
+
{
|
1897 |
+
if(pmpro_getOption("gateway_environment") && pmpro_getOption("loginname") && pmpro_getOption("transactionkey"))
|
1898 |
+
$pmpro_gateway_ready = true;
|
1899 |
+
else
|
1900 |
+
$pmpro_gateway_ready = false;
|
1901 |
+
}
|
1902 |
+
elseif($gateway == "paypal" || $gateway == "paypalexpress")
|
1903 |
+
{
|
1904 |
+
if(pmpro_getOption("gateway_environment") && pmpro_getOption("gateway_email") && pmpro_getOption("apiusername") && pmpro_getOption("apipassword") && pmpro_getOption("apisignature"))
|
1905 |
+
$pmpro_gateway_ready = true;
|
1906 |
+
else
|
1907 |
+
$pmpro_gateway_ready = false;
|
1908 |
+
}
|
1909 |
+
elseif($gateway == "paypalstandard")
|
1910 |
+
{
|
1911 |
+
if(pmpro_getOption("gateway_environment") && pmpro_getOption("gateway_email"))
|
1912 |
+
$pmpro_gateway_ready = true;
|
1913 |
+
else
|
1914 |
+
$pmpro_gateway_ready = false;
|
1915 |
+
}
|
1916 |
+
elseif($gateway == "payflowpro")
|
1917 |
+
{
|
1918 |
+
if(pmpro_getOption("payflow_partner") && pmpro_getOption("payflow_vendor") && pmpro_getOption("payflow_user") && pmpro_getOption("payflow_pwd"))
|
1919 |
+
$pmpro_gateway_ready = true;
|
1920 |
+
else
|
1921 |
+
$pmpro_gateway_ready = false;
|
1922 |
+
}
|
1923 |
+
elseif($gateway == "stripe")
|
1924 |
+
{
|
1925 |
+
if(pmpro_getOption("gateway_environment") && pmpro_getOption("stripe_secretkey") && pmpro_getOption("stripe_publishablekey"))
|
1926 |
+
$pmpro_gateway_ready = true;
|
1927 |
+
else
|
1928 |
+
$pmpro_gateway_ready = false;
|
1929 |
+
}
|
1930 |
+
elseif($gateway == "braintree")
|
1931 |
+
{
|
1932 |
+
if(pmpro_getOption("gateway_environment") && pmpro_getOption("braintree_merchantid") && pmpro_getOption("braintree_publickey") && pmpro_getOption("braintree_privatekey"))
|
1933 |
+
$pmpro_gateway_ready = true;
|
1934 |
+
else
|
1935 |
+
$pmpro_gateway_ready = false;
|
1936 |
+
}
|
1937 |
+
elseif($gateway == "twocheckout")
|
1938 |
+
{
|
1939 |
+
if(pmpro_getOption("gateway_environment") && pmpro_getOption("twocheckout_apiusername") && pmpro_getOption("twocheckout_apipassword"))
|
1940 |
+
$pmpro_gateway_ready = true;
|
1941 |
+
else
|
1942 |
+
$pmpro_gateway_ready = false;
|
1943 |
+
}
|
1944 |
+
elseif($gateway == "cybersource")
|
1945 |
+
{
|
1946 |
+
if(pmpro_getOption("gateway_environment") && pmpro_getOption("cybersource_merchantid") && pmpro_getOption("cybersource_securitykey"))
|
1947 |
+
$pmpro_gateway_ready = true;
|
1948 |
+
else
|
1949 |
+
$pmpro_gateway_ready = false;
|
1950 |
+
}
|
1951 |
+
elseif($gateway == "check")
|
1952 |
+
{
|
1953 |
+
$pmpro_gateway_ready = true;
|
1954 |
+
}
|
1955 |
+
else
|
1956 |
+
{
|
1957 |
+
$pmpro_gateway_ready = false;
|
1958 |
+
}
|
1959 |
+
}
|
1960 |
+
|
1961 |
+
//check if we have all pages
|
1962 |
+
if($pmpro_pages["account"] &&
|
1963 |
+
$pmpro_pages["billing"] &&
|
1964 |
+
$pmpro_pages["cancel"] &&
|
1965 |
+
$pmpro_pages["checkout"] &&
|
1966 |
+
$pmpro_pages["confirmation"] &&
|
1967 |
+
$pmpro_pages["invoice"] &&
|
1968 |
+
$pmpro_pages["levels"])
|
1969 |
+
$pmpro_pages_ready = true;
|
1970 |
+
else
|
1971 |
+
$pmpro_pages_ready = false;
|
1972 |
+
|
1973 |
+
//now check both
|
1974 |
+
if($pmpro_gateway_ready && $pmpro_pages_ready)
|
1975 |
+
$r = true;
|
1976 |
+
else
|
1977 |
+
$r = false;
|
1978 |
+
|
1979 |
+
/**
|
1980 |
+
* Filter to determine if PMPro setup is complete or
|
1981 |
+
* if notices or warnings need to be shown in the PMPro settings.
|
1982 |
+
*
|
1983 |
+
* Note: The filter should return true or false and also set
|
1984 |
+
* the $pmpro_level_ready, $pmpro_gateway_ready, $pmpro_pages_ready global variabls.
|
1985 |
+
*
|
1986 |
+
* @since 1.8.4.5
|
1987 |
+
*
|
1988 |
+
* @param bool $r ready?
|
1989 |
+
*/
|
1990 |
+
$r = apply_filters('pmpro_is_ready', $r);
|
1991 |
+
|
1992 |
+
return $r;
|
1993 |
+
}
|
1994 |
+
|
1995 |
+
/**
|
1996 |
+
* Format a price per the currency settings.
|
1997 |
+
*
|
1998 |
+
* @since 1.7.15
|
1999 |
+
*/
|
2000 |
+
function pmpro_formatPrice($price)
|
2001 |
+
{
|
2002 |
+
global $pmpro_currency, $pmpro_currency_symbol, $pmpro_currencies;
|
2003 |
+
|
2004 |
+
//start with the price formatted with two decimals
|
2005 |
+
$formatted = number_format($price, 2);
|
2006 |
+
|
2007 |
+
//settings stored in array?
|
2008 |
+
if(!empty($pmpro_currencies[$pmpro_currency]) && is_array($pmpro_currencies[$pmpro_currency]))
|
2009 |
+
{
|
2010 |
+
//format number do decimals, with decimal_separator and thousands_separator
|
2011 |
+
$formatted = number_format($price,
|
2012 |
+
(isset($pmpro_currencies[$pmpro_currency]['decimals']) ? (int)$pmpro_currencies[$pmpro_currency]['decimals'] : 2),
|
2013 |
+
(isset($pmpro_currencies[$pmpro_currency]['decimal_separator']) ? $pmpro_currencies[$pmpro_currency]['decimal_separator'] : '.'),
|
2014 |
+
(isset($pmpro_currencies[$pmpro_currency]['thousands_separator']) ? $pmpro_currencies[$pmpro_currency]['thousands_separator'] : ',')
|
2015 |
+
);
|
2016 |
+
|
2017 |
+
//which side is the symbol on?
|
2018 |
+
if(!empty($pmpro_currencies[$pmpro_currency]['position']) && $pmpro_currencies[$pmpro_currency]['position']== 'left')
|
2019 |
+
$formatted = $pmpro_currency_symbol . $formatted;
|
2020 |
+
else
|
2021 |
+
$formatted = $formatted . $pmpro_currency_symbol;
|
2022 |
+
}
|
2023 |
+
else
|
2024 |
+
$formatted = $pmpro_currency_symbol . $formatted; //default to symbol on the left
|
2025 |
+
|
2026 |
+
//filter
|
2027 |
+
return apply_filters('pmpro_format_price', $formatted, $price, $pmpro_currency, $pmpro_currency_symbol);
|
2028 |
+
}
|
2029 |
+
|
2030 |
+
/**
|
2031 |
+
* Which side does the currency symbol go on?
|
2032 |
+
*
|
2033 |
+
* @since 1.7.15
|
2034 |
+
*/
|
2035 |
+
function pmpro_getCurrencyPosition()
|
2036 |
+
{
|
2037 |
+
global $pmpro_currency, $pmpro_currencies;
|
2038 |
+
|
2039 |
+
if(!empty($pmpro_currencies[$pmpro_currency]) && is_array($pmpro_currencies[$pmpro_currency]) && !empty($pmpro_currencies[$pmpro_currency]['position']))
|
2040 |
+
return $pmpro_currencies[$pmpro_currency]['position'];
|
2041 |
+
else
|
2042 |
+
return "left";
|
2043 |
+
}
|
2044 |
+
|
2045 |
+
/*
|
2046 |
+
* What gateway should we be using?
|
2047 |
+
*
|
2048 |
+
* @since 1.8
|
2049 |
+
*/
|
2050 |
+
function pmpro_getGateway()
|
2051 |
+
{
|
2052 |
+
//grab from param or options
|
2053 |
+
if (!empty($_REQUEST['gateway']))
|
2054 |
+
$gateway = $_REQUEST['gateway']; //gateway passed as param
|
2055 |
+
elseif (!empty($_REQUEST['review']))
|
2056 |
+
$gateway = "paypalexpress"; //if review param assume paypalexpress
|
2057 |
+
else
|
2058 |
+
$gateway = pmpro_getOption("gateway"); //get from options
|
2059 |
+
|
2060 |
+
//set valid gateways - the active gateway in the settings and any gateway added through the filter will be allowed
|
2061 |
+
if(pmpro_getOption("gateway", true) == "paypal")
|
2062 |
+
$valid_gateways = apply_filters("pmpro_valid_gateways", array("paypal", "paypalexpress"));
|
2063 |
+
else
|
2064 |
+
$valid_gateways = apply_filters("pmpro_valid_gateways", array(pmpro_getOption("gateway", true)));
|
2065 |
+
|
2066 |
+
//make sure it's valid
|
2067 |
+
if(!in_array($gateway, $valid_gateways))
|
2068 |
+
$gateway = false;
|
2069 |
+
|
2070 |
+
//filter for good measure
|
2071 |
+
$gateway = apply_filters('pmpro_get_gateway', $gateway, $valid_gateways);
|
2072 |
+
|
2073 |
+
return $gateway;
|
2074 |
+
}
|
2075 |
+
|
2076 |
+
/*
|
2077 |
+
* Does the date provided fall in this month.
|
2078 |
+
* Used in logins/visits/views report.
|
2079 |
+
*
|
2080 |
+
* @since 1.8.3
|
2081 |
+
*/
|
2082 |
+
function pmpro_isDateThisMonth($str)
|
2083 |
+
{
|
2084 |
+
$now = current_time('timestamp');
|
2085 |
+
$this_month = intval(date("n", $now));
|
2086 |
+
$this_year = intval(date("Y", $now));
|
2087 |
+
|
2088 |
+
$date = strtotime($str, $now);
|
2089 |
+
$date_month = intval(date("n", $date));
|
2090 |
+
$date_year = intval(date("Y", $date));
|
2091 |
+
|
2092 |
+
if($date_month === $this_month && $date_year === $this_year)
|
2093 |
+
return true;
|
2094 |
+
else
|
2095 |
+
return false;
|
2096 |
+
}
|
2097 |
+
|
2098 |
+
/**
|
2099 |
+
* Function to generate PMPro front end pages.
|
2100 |
+
*
|
2101 |
+
* @param array $pages {
|
2102 |
+
* Formatted as array($name => $title) or array(array('title'=>'The Title', 'content'=>'The Content'))
|
2103 |
+
*
|
2104 |
+
* @type string $name Page name. (Letters, numbers, and underscores only.)
|
2105 |
+
* @type string $title Page title.
|
2106 |
+
* }
|
2107 |
+
* @return array $created_pages Created page IDs.
|
2108 |
+
* @since 1.8.5
|
2109 |
+
*/
|
2110 |
+
function pmpro_generatePages($pages) {
|
2111 |
+
|
2112 |
+
global $pmpro_pages;
|
2113 |
+
|
2114 |
+
$pages_created = array();
|
2115 |
+
|
2116 |
+
if(!empty($pages)) {
|
2117 |
+
foreach($pages as $name => $page) {
|
2118 |
+
|
2119 |
+
//does it already exist?
|
2120 |
+
if(!empty($pmpro_pages[$name]))
|
2121 |
+
continue;
|
2122 |
+
|
2123 |
+
//no id set. create an array to store the page info
|
2124 |
+
if(is_array($page)) {
|
2125 |
+
$title = $page['title'];
|
2126 |
+
$content = $page['content'];
|
2127 |
+
} else {
|
2128 |
+
$title = $page;
|
2129 |
+
$content = '[pmpro_' . $name . ']';
|
2130 |
+
}
|
2131 |
+
|
2132 |
+
$insert = array(
|
2133 |
+
'post_title' => $title,
|
2134 |
+
'post_status' => 'publish',
|
2135 |
+
'post_type' => 'page',
|
2136 |
+
'post_content' => $content,
|
2137 |
+
'comment_status' => 'closed',
|
2138 |
+
'ping_status' => 'closed'
|
2139 |
+
);
|
2140 |
+
|
2141 |
+
//make non-account pages a subpage of account
|
2142 |
+
if ($name != "account") {
|
2143 |
+
$insert['post_parent'] = $pmpro_pages['account'];
|
2144 |
+
}
|
2145 |
+
|
2146 |
+
//create the page
|
2147 |
+
$pmpro_pages[$name] = wp_insert_post($insert);
|
2148 |
+
|
2149 |
+
//update the option too
|
2150 |
+
pmpro_setOption($name . "_page_id", $pmpro_pages[$name]);
|
2151 |
+
$pages_created[] = $pmpro_pages[$name];
|
2152 |
+
}
|
2153 |
+
}
|
2154 |
+
|
2155 |
+
return $pages_created;
|
2156 |
+
}
|
2157 |
+
|
pages/levels.php
CHANGED
@@ -1,5 +1,27 @@
|
|
1 |
<?php
|
2 |
-
global $wpdb, $pmpro_msg, $pmpro_msgt, $
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
if($pmpro_msg)
|
4 |
{
|
5 |
?>
|
@@ -51,17 +73,14 @@ if($pmpro_msg)
|
|
51 |
|
52 |
<?php
|
53 |
//if it's a one-time-payment level, offer a link to renew
|
54 |
-
if(
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
?>
|
63 |
-
<a class="pmpro_btn disabled" href="<?php echo pmpro_url("account")?>"><?php _e('Your Level', 'pmpro');?></a>
|
64 |
-
<?php
|
65 |
}
|
66 |
?>
|
67 |
|
1 |
<?php
|
2 |
+
global $wpdb, $pmpro_msg, $pmpro_msgt, $current_user;
|
3 |
+
|
4 |
+
$pmpro_levels = pmpro_getAllLevels(false, true);
|
5 |
+
$pmpro_level_order = pmpro_getOption('level_order');
|
6 |
+
|
7 |
+
if(!empty($pmpro_level_order))
|
8 |
+
{
|
9 |
+
$order = explode(',',$pmpro_level_order);
|
10 |
+
|
11 |
+
//reorder array
|
12 |
+
$reordered_levels = array();
|
13 |
+
foreach($order as $level_id) {
|
14 |
+
foreach($pmpro_levels as $key=>$level) {
|
15 |
+
if($level_id == $level->id)
|
16 |
+
$reordered_levels[] = $pmpro_levels[$key];
|
17 |
+
}
|
18 |
+
}
|
19 |
+
|
20 |
+
$pmpro_levels = $reordered_levels;
|
21 |
+
}
|
22 |
+
|
23 |
+
$pmpro_levels = apply_filters("pmpro_levels_array", $pmpro_levels);
|
24 |
+
|
25 |
if($pmpro_msg)
|
26 |
{
|
27 |
?>
|
73 |
|
74 |
<?php
|
75 |
//if it's a one-time-payment level, offer a link to renew
|
76 |
+
if( pmpro_isLevelExpiringSoon( $current_user->membership_level) ) {
|
77 |
+
?>
|
78 |
+
<a class="pmpro_btn pmpro_btn-select" href="<?php echo pmpro_url("checkout", "?level=" . $level->id, "https")?>"><?php _e('Renew', 'pmpro');?></a>
|
79 |
+
<?php
|
80 |
+
} else {
|
81 |
+
?>
|
82 |
+
<a class="pmpro_btn disabled" href="<?php echo pmpro_url("account")?>"><?php _e('Your Level', 'pmpro');?></a>
|
83 |
+
<?php
|
|
|
|
|
|
|
84 |
}
|
85 |
?>
|
86 |
|
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.6.
|
7 |
Author: Stranger Studios
|
8 |
Author URI: http://www.strangerstudios.com
|
9 |
*/
|
@@ -13,7 +13,7 @@ Author URI: http://www.strangerstudios.com
|
|
13 |
*/
|
14 |
|
15 |
//version constant
|
16 |
-
define("PMPRO_VERSION", "1.8.6.
|
17 |
|
18 |
//if the session has been started yet, start it (ignore if running from command line)
|
19 |
if(defined('STDIN') )
|
3 |
Plugin Name: Paid Memberships Pro
|
4 |
Plugin URI: http://www.paidmembershipspro.com
|
5 |
Description: Plugin to Handle Memberships
|
6 |
+
Version: 1.8.6.3
|
7 |
Author: Stranger Studios
|
8 |
Author URI: http://www.strangerstudios.com
|
9 |
*/
|
13 |
*/
|
14 |
|
15 |
//version constant
|
16 |
+
define("PMPRO_VERSION", "1.8.6.3");
|
17 |
|
18 |
//if the session has been started yet, start it (ignore if running from command line)
|
19 |
if(defined('STDIN') )
|
preheaders/checkout.php
CHANGED
@@ -1,754 +1,764 @@
|
|
1 |
-
<?php
|
2 |
-
global $post, $gateway, $wpdb, $besecure, $discount_code, $discount_code_id, $pmpro_level, $pmpro_levels, $pmpro_msg, $pmpro_msgt, $pmpro_review, $skip_account_fields, $pmpro_paypal_token, $pmpro_show_discount_code, $pmpro_error_fields, $pmpro_required_billing_fields, $pmpro_required_user_fields, $wp_version, $current_user;
|
3 |
-
|
4 |
-
//make sure we know current user's membership level
|
5 |
-
if ($current_user->ID)
|
6 |
-
$current_user->membership_level = pmpro_getMembershipLevelForUser($current_user->ID);
|
7 |
-
|
8 |
-
//this var stores fields with errors so we can make them red on the frontend
|
9 |
-
$pmpro_error_fields = array();
|
10 |
-
|
11 |
-
//blank array for required fields, set below
|
12 |
-
$pmpro_required_billing_fields = array();
|
13 |
-
$pmpro_required_user_fields = array();
|
14 |
-
|
15 |
-
//was a gateway passed?
|
16 |
-
if (!empty($_REQUEST['gateway']))
|
17 |
-
$gateway = $_REQUEST['gateway'];
|
18 |
-
elseif (!empty($_REQUEST['review']))
|
19 |
-
$gateway = "paypalexpress";
|
20 |
-
else
|
21 |
-
$gateway = pmpro_getOption("gateway");
|
22 |
-
|
23 |
-
//set valid gateways - the active gateway in the settings and any gateway added through the filter will be allowed
|
24 |
-
if (pmpro_getOption("gateway", true) == "paypal")
|
25 |
-
$valid_gateways = apply_filters("pmpro_valid_gateways", array("paypal", "paypalexpress"));
|
26 |
-
else
|
27 |
-
$valid_gateways = apply_filters("pmpro_valid_gateways", array(pmpro_getOption("gateway", true)));
|
28 |
-
|
29 |
-
//let's add an error now, if an invalid gateway is set
|
30 |
-
if (!in_array($gateway, $valid_gateways))
|
31 |
-
{
|
32 |
-
$pmpro_msg = __("Invalid gateway.", 'pmpro');
|
33 |
-
$pmpro_msgt = "pmpro_error";
|
34 |
-
}
|
35 |
-
|
36 |
-
//what level are they purchasing? (discount code passed)
|
37 |
-
if (!empty($_REQUEST['level']) && !empty($_REQUEST['discount_code'])) {
|
38 |
-
$discount_code = preg_replace("/[^A-Za-z0-9\-]/", "", $_REQUEST['discount_code']);
|
39 |
-
$discount_code_id = $wpdb->get_var("SELECT id FROM $wpdb->pmpro_discount_codes WHERE code = '" . $discount_code . "' LIMIT 1");
|
40 |
-
|
41 |
-
//check code
|
42 |
-
$code_check = pmpro_checkDiscountCode($discount_code, (int)$_REQUEST['level'], true);
|
43 |
-
if ($code_check[0] == false) {
|
44 |
-
//error
|
45 |
-
$pmpro_msg = $code_check[1];
|
46 |
-
$pmpro_msgt = "pmpro_error";
|
47 |
-
|
48 |
-
//don't use this code
|
49 |
-
$use_discount_code = false;
|
50 |
-
} else {
|
51 |
-
$sqlQuery = "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 LEFT JOIN $wpdb->pmpro_discount_codes dc ON dc.id = cl.code_id WHERE dc.code = '" . $discount_code . "' AND cl.level_id = '" . (int)$_REQUEST['level'] . "' LIMIT 1";
|
52 |
-
$pmpro_level = $wpdb->get_row($sqlQuery);
|
53 |
-
|
54 |
-
//if the discount code doesn't adjust the level, let's just get the straight level
|
55 |
-
if (empty($pmpro_level))
|
56 |
-
$pmpro_level = $wpdb->get_row("SELECT * FROM $wpdb->pmpro_membership_levels WHERE id = '" . (int)$_REQUEST['level'] . "' LIMIT 1");
|
57 |
-
|
58 |
-
//filter adjustments to the level
|
59 |
-
$pmpro_level->code_id = $discount_code_id;
|
60 |
-
$pmpro_level = apply_filters("pmpro_discount_code_level", $pmpro_level, $discount_code_id);
|
61 |
-
|
62 |
-
$use_discount_code = true;
|
63 |
-
}
|
64 |
-
}
|
65 |
-
|
66 |
-
//what level are they purchasing? (no discount code)
|
67 |
-
if (empty($pmpro_level) && !empty($_REQUEST['level'])) {
|
68 |
-
$pmpro_level = $wpdb->get_row("SELECT * FROM $wpdb->pmpro_membership_levels WHERE id = '" . esc_sql($_REQUEST['level']) . "' AND allow_signups = 1 LIMIT 1");
|
69 |
-
} elseif (empty($pmpro_level)) {
|
70 |
-
//check if a level is defined in custom fields
|
71 |
-
$default_level = get_post_meta($post->ID, "pmpro_default_level", true);
|
72 |
-
if (!empty($default_level))
|
73 |
-
{
|
74 |
-
$pmpro_level = $wpdb->get_row("SELECT * FROM $wpdb->pmpro_membership_levels WHERE id = '" . esc_sql($default_level) . "' AND allow_signups = 1 LIMIT 1");
|
75 |
-
}
|
76 |
-
}
|
77 |
-
|
78 |
-
//filter the level (for upgrades, etc)
|
79 |
-
$pmpro_level = apply_filters("pmpro_checkout_level", $pmpro_level);
|
80 |
-
|
81 |
-
if (empty($pmpro_level->id))
|
82 |
-
{
|
83 |
-
wp_redirect(pmpro_url("levels"));
|
84 |
-
exit(0);
|
85 |
-
}
|
86 |
-
|
87 |
-
//enqueue some scripts
|
88 |
-
wp_enqueue_script('jquery.creditCardValidator', plugins_url('/js/jquery.creditCardValidator.js' , dirname(__FILE__ )), array( 'jquery' ));
|
89 |
-
|
90 |
-
global $wpdb, $current_user, $pmpro_requirebilling;
|
91 |
-
//unless we're submitting a form, let's try to figure out if https should be used
|
92 |
-
|
93 |
-
if (!pmpro_isLevelFree($pmpro_level)) {
|
94 |
-
//require billing and ssl
|
95 |
-
$pagetitle = __("Checkout: Payment Information", 'pmpro');
|
96 |
-
$pmpro_requirebilling = true;
|
97 |
-
$besecure = pmpro_getOption("use_ssl");
|
98 |
-
} else {
|
99 |
-
//no payment so we don't need ssl
|
100 |
-
$pagetitle = __("Set Up Your Account", 'pmpro');
|
101 |
-
$pmpro_requirebilling = false;
|
102 |
-
$besecure = false;
|
103 |
-
}
|
104 |
-
|
105 |
-
//in case a discount code was used or something else made the level free, but we're already over ssl
|
106 |
-
if (!$besecure && !empty($_REQUEST['submit-checkout']) && is_ssl())
|
107 |
-
$besecure = true; //be secure anyway since we're already checking out
|
108 |
-
|
109 |
-
//action to run extra code for gateways/etc
|
110 |
-
do_action('pmpro_checkout_preheader');
|
111 |
-
|
112 |
-
//get all levels in case we need them
|
113 |
-
global $pmpro_levels;
|
114 |
-
$pmpro_levels = pmpro_getAllLevels();
|
115 |
-
|
116 |
-
//should we show the discount code field?
|
117 |
-
if ($wpdb->get_var("SELECT id FROM $wpdb->pmpro_discount_codes LIMIT 1"))
|
118 |
-
$pmpro_show_discount_code = true;
|
119 |
-
else
|
120 |
-
$pmpro_show_discount_code = false;
|
121 |
-
$pmpro_show_discount_code = apply_filters("pmpro_show_discount_code", $pmpro_show_discount_code);
|
122 |
-
|
123 |
-
//by default we show the account fields if the user isn't logged in
|
124 |
-
if ($current_user->ID) {
|
125 |
-
$skip_account_fields = true;
|
126 |
-
} else {
|
127 |
-
$skip_account_fields = false;
|
128 |
-
}
|
129 |
-
//in case people want to have an account created automatically
|
130 |
-
$skip_account_fields = apply_filters("pmpro_skip_account_fields", $skip_account_fields, $current_user);
|
131 |
-
|
132 |
-
//some options
|
133 |
-
global $tospage;
|
134 |
-
$tospage = pmpro_getOption("tospage");
|
135 |
-
if ($tospage)
|
136 |
-
$tospage = get_post($tospage);
|
137 |
-
|
138 |
-
//load em up (other fields)
|
139 |
-
global $username, $password, $password2, $bfirstname, $blastname, $baddress1, $baddress2, $bcity, $bstate, $bzipcode, $bcountry, $bphone, $bemail, $bconfirmemail, $CardType, $AccountNumber, $ExpirationMonth, $ExpirationYear;
|
140 |
-
|
141 |
-
if (isset($_REQUEST['order_id']))
|
142 |
-
$order_id = intval($_REQUEST['order_id']);
|
143 |
-
else
|
144 |
-
$order_id = "";
|
145 |
-
if (isset($_REQUEST['bfirstname']))
|
146 |
-
$bfirstname = sanitize_text_field(stripslashes($_REQUEST['bfirstname']));
|
147 |
-
else
|
148 |
-
$bfirstname = "";
|
149 |
-
if (isset($_REQUEST['blastname']))
|
150 |
-
$blastname = sanitize_text_field(stripslashes($_REQUEST['blastname']));
|
151 |
-
else
|
152 |
-
$blastname = "";
|
153 |
-
if (isset($_REQUEST['fullname']))
|
154 |
-
$fullname = $_REQUEST['fullname']; //honeypot for spammers
|
155 |
-
if (isset($_REQUEST['baddress1']))
|
156 |
-
$baddress1 = sanitize_text_field(stripslashes($_REQUEST['baddress1']));
|
157 |
-
else
|
158 |
-
$baddress1 = "";
|
159 |
-
if (isset($_REQUEST['baddress2']))
|
160 |
-
$baddress2 = sanitize_text_field(stripslashes($_REQUEST['baddress2']));
|
161 |
-
else
|
162 |
-
$baddress2 = "";
|
163 |
-
if (isset($_REQUEST['bcity']))
|
164 |
-
$bcity = sanitize_text_field(stripslashes($_REQUEST['bcity']));
|
165 |
-
else
|
166 |
-
$bcity = "";
|
167 |
-
|
168 |
-
if (isset($_REQUEST['bstate']))
|
169 |
-
$bstate = sanitize_text_field(stripslashes($_REQUEST['bstate']));
|
170 |
-
else
|
171 |
-
$bstate = "";
|
172 |
-
|
173 |
-
//convert long state names to abbreviations
|
174 |
-
if (!empty($bstate))
|
175 |
-
{
|
176 |
-
global $pmpro_states;
|
177 |
-
foreach($pmpro_states as $abbr => $state)
|
178 |
-
{
|
179 |
-
if ($bstate == $state)
|
180 |
-
{
|
181 |
-
$bstate = $abbr;
|
182 |
-
break;
|
183 |
-
}
|
184 |
-
}
|
185 |
-
}
|
186 |
-
|
187 |
-
if (isset($_REQUEST['bzipcode']))
|
188 |
-
$bzipcode = sanitize_text_field(stripslashes($_REQUEST['bzipcode']));
|
189 |
-
else
|
190 |
-
$bzipcode = "";
|
191 |
-
if (isset($_REQUEST['bcountry']))
|
192 |
-
$bcountry = sanitize_text_field(stripslashes($_REQUEST['bcountry']));
|
193 |
-
else
|
194 |
-
$bcountry = "";
|
195 |
-
if (isset($_REQUEST['bphone']))
|
196 |
-
$bphone = sanitize_text_field(stripslashes($_REQUEST['bphone']));
|
197 |
-
else
|
198 |
-
$bphone = "";
|
199 |
-
if
|
200 |
-
$bemail = sanitize_email(stripslashes($_REQUEST['bemail']));
|
201 |
-
|
202 |
-
$bemail =
|
203 |
-
|
204 |
-
$
|
205 |
-
|
206 |
-
$bconfirmemail =
|
207 |
-
|
208 |
-
$bconfirmemail =
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
if (isset($_REQUEST['AccountNumber']))
|
215 |
-
$
|
216 |
-
else
|
217 |
-
$
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
if (isset($_REQUEST['
|
224 |
-
$
|
225 |
-
else
|
226 |
-
$
|
227 |
-
if (isset($_REQUEST['
|
228 |
-
$
|
229 |
-
else
|
230 |
-
$
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
if (isset($_REQUEST['
|
237 |
-
$
|
238 |
-
else
|
239 |
-
$
|
240 |
-
if (isset($_REQUEST['
|
241 |
-
$
|
242 |
-
else
|
243 |
-
$
|
244 |
-
if (isset($_REQUEST['
|
245 |
-
$
|
246 |
-
|
247 |
-
$
|
248 |
-
|
249 |
-
$password2 =
|
250 |
-
|
251 |
-
$
|
252 |
-
else
|
253 |
-
$
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
$
|
258 |
-
|
259 |
-
|
260 |
-
if (isset($submit)
|
261 |
-
$submit =
|
262 |
-
|
263 |
-
$submit =
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
"
|
272 |
-
"
|
273 |
-
"
|
274 |
-
"
|
275 |
-
"
|
276 |
-
"
|
277 |
-
"
|
278 |
-
"
|
279 |
-
"
|
280 |
-
"
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
"
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
"
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
$
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
}
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
$pmpro_error_fields[] = "
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
$pmpro_error_fields[] = "
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
$pmpro_error_fields[] = "
|
352 |
-
}
|
353 |
-
if (!
|
354 |
-
pmpro_setMessage(__("
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
if ($
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
$
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
$
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
$
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
$
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
}
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
$morder
|
439 |
-
$morder->
|
440 |
-
$morder->
|
441 |
-
$morder->
|
442 |
-
$morder->
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
$morder->
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
$morder->
|
460 |
-
$morder->
|
461 |
-
$morder->
|
462 |
-
|
463 |
-
|
464 |
-
$morder->
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
$morder->
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
$morder->
|
474 |
-
$morder->
|
475 |
-
|
476 |
-
|
477 |
-
$morder->billing
|
478 |
-
$morder->billing->
|
479 |
-
$morder->billing->
|
480 |
-
$morder->billing->
|
481 |
-
|
482 |
-
|
483 |
-
$morder->
|
484 |
-
$morder->
|
485 |
-
|
486 |
-
|
487 |
-
$morder->
|
488 |
-
$morder->
|
489 |
-
|
490 |
-
//
|
491 |
-
$morder->
|
492 |
-
$morder->
|
493 |
-
|
494 |
-
//
|
495 |
-
$morder =
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
$
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
//
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
if (
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
if (
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
"
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
$
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
$
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
$
|
620 |
-
'
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
'
|
629 |
-
'
|
630 |
-
'
|
631 |
-
'
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
//
|
644 |
-
if (
|
645 |
-
$morder
|
646 |
-
$morder->
|
647 |
-
$morder->
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
$
|
664 |
-
|
665 |
-
|
666 |
-
//
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
$
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
$
|
695 |
-
|
696 |
-
//
|
697 |
-
$
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
//
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
//
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
if
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
$
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
$
|
745 |
-
$
|
746 |
-
|
747 |
-
$
|
748 |
-
$
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
global $post, $gateway, $wpdb, $besecure, $discount_code, $discount_code_id, $pmpro_level, $pmpro_levels, $pmpro_msg, $pmpro_msgt, $pmpro_review, $skip_account_fields, $pmpro_paypal_token, $pmpro_show_discount_code, $pmpro_error_fields, $pmpro_required_billing_fields, $pmpro_required_user_fields, $wp_version, $current_user;
|
3 |
+
|
4 |
+
//make sure we know current user's membership level
|
5 |
+
if ($current_user->ID)
|
6 |
+
$current_user->membership_level = pmpro_getMembershipLevelForUser($current_user->ID);
|
7 |
+
|
8 |
+
//this var stores fields with errors so we can make them red on the frontend
|
9 |
+
$pmpro_error_fields = array();
|
10 |
+
|
11 |
+
//blank array for required fields, set below
|
12 |
+
$pmpro_required_billing_fields = array();
|
13 |
+
$pmpro_required_user_fields = array();
|
14 |
+
|
15 |
+
//was a gateway passed?
|
16 |
+
if (!empty($_REQUEST['gateway']))
|
17 |
+
$gateway = $_REQUEST['gateway'];
|
18 |
+
elseif (!empty($_REQUEST['review']))
|
19 |
+
$gateway = "paypalexpress";
|
20 |
+
else
|
21 |
+
$gateway = pmpro_getOption("gateway");
|
22 |
+
|
23 |
+
//set valid gateways - the active gateway in the settings and any gateway added through the filter will be allowed
|
24 |
+
if (pmpro_getOption("gateway", true) == "paypal")
|
25 |
+
$valid_gateways = apply_filters("pmpro_valid_gateways", array("paypal", "paypalexpress"));
|
26 |
+
else
|
27 |
+
$valid_gateways = apply_filters("pmpro_valid_gateways", array(pmpro_getOption("gateway", true)));
|
28 |
+
|
29 |
+
//let's add an error now, if an invalid gateway is set
|
30 |
+
if (!in_array($gateway, $valid_gateways))
|
31 |
+
{
|
32 |
+
$pmpro_msg = __("Invalid gateway.", 'pmpro');
|
33 |
+
$pmpro_msgt = "pmpro_error";
|
34 |
+
}
|
35 |
+
|
36 |
+
//what level are they purchasing? (discount code passed)
|
37 |
+
if (!empty($_REQUEST['level']) && !empty($_REQUEST['discount_code'])) {
|
38 |
+
$discount_code = preg_replace("/[^A-Za-z0-9\-]/", "", $_REQUEST['discount_code']);
|
39 |
+
$discount_code_id = $wpdb->get_var("SELECT id FROM $wpdb->pmpro_discount_codes WHERE code = '" . $discount_code . "' LIMIT 1");
|
40 |
+
|
41 |
+
//check code
|
42 |
+
$code_check = pmpro_checkDiscountCode($discount_code, (int)$_REQUEST['level'], true);
|
43 |
+
if ($code_check[0] == false) {
|
44 |
+
//error
|
45 |
+
$pmpro_msg = $code_check[1];
|
46 |
+
$pmpro_msgt = "pmpro_error";
|
47 |
+
|
48 |
+
//don't use this code
|
49 |
+
$use_discount_code = false;
|
50 |
+
} else {
|
51 |
+
$sqlQuery = "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 LEFT JOIN $wpdb->pmpro_discount_codes dc ON dc.id = cl.code_id WHERE dc.code = '" . $discount_code . "' AND cl.level_id = '" . (int)$_REQUEST['level'] . "' LIMIT 1";
|
52 |
+
$pmpro_level = $wpdb->get_row($sqlQuery);
|
53 |
+
|
54 |
+
//if the discount code doesn't adjust the level, let's just get the straight level
|
55 |
+
if (empty($pmpro_level))
|
56 |
+
$pmpro_level = $wpdb->get_row("SELECT * FROM $wpdb->pmpro_membership_levels WHERE id = '" . (int)$_REQUEST['level'] . "' LIMIT 1");
|
57 |
+
|
58 |
+
//filter adjustments to the level
|
59 |
+
$pmpro_level->code_id = $discount_code_id;
|
60 |
+
$pmpro_level = apply_filters("pmpro_discount_code_level", $pmpro_level, $discount_code_id);
|
61 |
+
|
62 |
+
$use_discount_code = true;
|
63 |
+
}
|
64 |
+
}
|
65 |
+
|
66 |
+
//what level are they purchasing? (no discount code)
|
67 |
+
if (empty($pmpro_level) && !empty($_REQUEST['level'])) {
|
68 |
+
$pmpro_level = $wpdb->get_row("SELECT * FROM $wpdb->pmpro_membership_levels WHERE id = '" . esc_sql($_REQUEST['level']) . "' AND allow_signups = 1 LIMIT 1");
|
69 |
+
} elseif (empty($pmpro_level)) {
|
70 |
+
//check if a level is defined in custom fields
|
71 |
+
$default_level = get_post_meta($post->ID, "pmpro_default_level", true);
|
72 |
+
if (!empty($default_level))
|
73 |
+
{
|
74 |
+
$pmpro_level = $wpdb->get_row("SELECT * FROM $wpdb->pmpro_membership_levels WHERE id = '" . esc_sql($default_level) . "' AND allow_signups = 1 LIMIT 1");
|
75 |
+
}
|
76 |
+
}
|
77 |
+
|
78 |
+
//filter the level (for upgrades, etc)
|
79 |
+
$pmpro_level = apply_filters("pmpro_checkout_level", $pmpro_level);
|
80 |
+
|
81 |
+
if (empty($pmpro_level->id))
|
82 |
+
{
|
83 |
+
wp_redirect(pmpro_url("levels"));
|
84 |
+
exit(0);
|
85 |
+
}
|
86 |
+
|
87 |
+
//enqueue some scripts
|
88 |
+
wp_enqueue_script('jquery.creditCardValidator', plugins_url('/js/jquery.creditCardValidator.js' , dirname(__FILE__ )), array( 'jquery' ));
|
89 |
+
|
90 |
+
global $wpdb, $current_user, $pmpro_requirebilling;
|
91 |
+
//unless we're submitting a form, let's try to figure out if https should be used
|
92 |
+
|
93 |
+
if (!pmpro_isLevelFree($pmpro_level)) {
|
94 |
+
//require billing and ssl
|
95 |
+
$pagetitle = __("Checkout: Payment Information", 'pmpro');
|
96 |
+
$pmpro_requirebilling = true;
|
97 |
+
$besecure = pmpro_getOption("use_ssl");
|
98 |
+
} else {
|
99 |
+
//no payment so we don't need ssl
|
100 |
+
$pagetitle = __("Set Up Your Account", 'pmpro');
|
101 |
+
$pmpro_requirebilling = false;
|
102 |
+
$besecure = false;
|
103 |
+
}
|
104 |
+
|
105 |
+
//in case a discount code was used or something else made the level free, but we're already over ssl
|
106 |
+
if (!$besecure && !empty($_REQUEST['submit-checkout']) && is_ssl())
|
107 |
+
$besecure = true; //be secure anyway since we're already checking out
|
108 |
+
|
109 |
+
//action to run extra code for gateways/etc
|
110 |
+
do_action('pmpro_checkout_preheader');
|
111 |
+
|
112 |
+
//get all levels in case we need them
|
113 |
+
global $pmpro_levels;
|
114 |
+
$pmpro_levels = pmpro_getAllLevels();
|
115 |
+
|
116 |
+
//should we show the discount code field?
|
117 |
+
if ($wpdb->get_var("SELECT id FROM $wpdb->pmpro_discount_codes LIMIT 1"))
|
118 |
+
$pmpro_show_discount_code = true;
|
119 |
+
else
|
120 |
+
$pmpro_show_discount_code = false;
|
121 |
+
$pmpro_show_discount_code = apply_filters("pmpro_show_discount_code", $pmpro_show_discount_code);
|
122 |
+
|
123 |
+
//by default we show the account fields if the user isn't logged in
|
124 |
+
if ($current_user->ID) {
|
125 |
+
$skip_account_fields = true;
|
126 |
+
} else {
|
127 |
+
$skip_account_fields = false;
|
128 |
+
}
|
129 |
+
//in case people want to have an account created automatically
|
130 |
+
$skip_account_fields = apply_filters("pmpro_skip_account_fields", $skip_account_fields, $current_user);
|
131 |
+
|
132 |
+
//some options
|
133 |
+
global $tospage;
|
134 |
+
$tospage = pmpro_getOption("tospage");
|
135 |
+
if ($tospage)
|
136 |
+
$tospage = get_post($tospage);
|
137 |
+
|
138 |
+
//load em up (other fields)
|
139 |
+
global $username, $password, $password2, $bfirstname, $blastname, $baddress1, $baddress2, $bcity, $bstate, $bzipcode, $bcountry, $bphone, $bemail, $bconfirmemail, $CardType, $AccountNumber, $ExpirationMonth, $ExpirationYear;
|
140 |
+
|
141 |
+
if (isset($_REQUEST['order_id']))
|
142 |
+
$order_id = intval($_REQUEST['order_id']);
|
143 |
+
else
|
144 |
+
$order_id = "";
|
145 |
+
if (isset($_REQUEST['bfirstname']))
|
146 |
+
$bfirstname = sanitize_text_field(stripslashes($_REQUEST['bfirstname']));
|
147 |
+
else
|
148 |
+
$bfirstname = "";
|
149 |
+
if (isset($_REQUEST['blastname']))
|
150 |
+
$blastname = sanitize_text_field(stripslashes($_REQUEST['blastname']));
|
151 |
+
else
|
152 |
+
$blastname = "";
|
153 |
+
if (isset($_REQUEST['fullname']))
|
154 |
+
$fullname = $_REQUEST['fullname']; //honeypot for spammers
|
155 |
+
if (isset($_REQUEST['baddress1']))
|
156 |
+
$baddress1 = sanitize_text_field(stripslashes($_REQUEST['baddress1']));
|
157 |
+
else
|
158 |
+
$baddress1 = "";
|
159 |
+
if (isset($_REQUEST['baddress2']))
|
160 |
+
$baddress2 = sanitize_text_field(stripslashes($_REQUEST['baddress2']));
|
161 |
+
else
|
162 |
+
$baddress2 = "";
|
163 |
+
if (isset($_REQUEST['bcity']))
|
164 |
+
$bcity = sanitize_text_field(stripslashes($_REQUEST['bcity']));
|
165 |
+
else
|
166 |
+
$bcity = "";
|
167 |
+
|
168 |
+
if (isset($_REQUEST['bstate']))
|
169 |
+
$bstate = sanitize_text_field(stripslashes($_REQUEST['bstate']));
|
170 |
+
else
|
171 |
+
$bstate = "";
|
172 |
+
|
173 |
+
//convert long state names to abbreviations
|
174 |
+
if (!empty($bstate))
|
175 |
+
{
|
176 |
+
global $pmpro_states;
|
177 |
+
foreach($pmpro_states as $abbr => $state)
|
178 |
+
{
|
179 |
+
if ($bstate == $state)
|
180 |
+
{
|
181 |
+
$bstate = $abbr;
|
182 |
+
break;
|
183 |
+
}
|
184 |
+
}
|
185 |
+
}
|
186 |
+
|
187 |
+
if (isset($_REQUEST['bzipcode']))
|
188 |
+
$bzipcode = sanitize_text_field(stripslashes($_REQUEST['bzipcode']));
|
189 |
+
else
|
190 |
+
$bzipcode = "";
|
191 |
+
if (isset($_REQUEST['bcountry']))
|
192 |
+
$bcountry = sanitize_text_field(stripslashes($_REQUEST['bcountry']));
|
193 |
+
else
|
194 |
+
$bcountry = "";
|
195 |
+
if (isset($_REQUEST['bphone']))
|
196 |
+
$bphone = sanitize_text_field(stripslashes($_REQUEST['bphone']));
|
197 |
+
else
|
198 |
+
$bphone = "";
|
199 |
+
if( isset ( $_REQUEST['bemail'] ) )
|
200 |
+
$bemail = sanitize_email(stripslashes($_REQUEST['bemail']));
|
201 |
+
elseif( is_user_logged_in() )
|
202 |
+
$bemail = $current_user->user_email;
|
203 |
+
else
|
204 |
+
$bemail = "";
|
205 |
+
if (isset($_REQUEST['bconfirmemail_copy']))
|
206 |
+
$bconfirmemail = $bemail;
|
207 |
+
elseif (isset($_REQUEST['bconfirmemail']))
|
208 |
+
$bconfirmemail = sanitize_email(stripslashes($_REQUEST['bconfirmemail']));
|
209 |
+
elseif( is_user_logged_in() )
|
210 |
+
$bconfirmemail = $current_user->user_email;
|
211 |
+
else
|
212 |
+
$bconfirmemail = "";
|
213 |
+
|
214 |
+
if (isset($_REQUEST['CardType']) && !empty($_REQUEST['AccountNumber']))
|
215 |
+
$CardType = sanitize_text_field($_REQUEST['CardType']);
|
216 |
+
else
|
217 |
+
$CardType = "";
|
218 |
+
if (isset($_REQUEST['AccountNumber']))
|
219 |
+
$AccountNumber = sanitize_text_field($_REQUEST['AccountNumber']);
|
220 |
+
else
|
221 |
+
$AccountNumber = "";
|
222 |
+
|
223 |
+
if (isset($_REQUEST['ExpirationMonth']))
|
224 |
+
$ExpirationMonth = sanitize_text_field($_REQUEST['ExpirationMonth']);
|
225 |
+
else
|
226 |
+
$ExpirationMonth = "";
|
227 |
+
if (isset($_REQUEST['ExpirationYear']))
|
228 |
+
$ExpirationYear = sanitize_text_field($_REQUEST['ExpirationYear']);
|
229 |
+
else
|
230 |
+
$ExpirationYear = "";
|
231 |
+
if (isset($_REQUEST['CVV']))
|
232 |
+
$CVV = sanitize_text_field($_REQUEST['CVV']);
|
233 |
+
else
|
234 |
+
$CVV = "";
|
235 |
+
|
236 |
+
if (isset($_REQUEST['discount_code']))
|
237 |
+
$discount_code = sanitize_text_field($_REQUEST['discount_code']);
|
238 |
+
else
|
239 |
+
$discount_code = "";
|
240 |
+
if (isset($_REQUEST['username']))
|
241 |
+
$username = sanitize_user($_REQUEST['username']);
|
242 |
+
else
|
243 |
+
$username = "";
|
244 |
+
if (isset($_REQUEST['password']))
|
245 |
+
$password = $_REQUEST['password'];
|
246 |
+
else
|
247 |
+
$password = "";
|
248 |
+
if (isset($_REQUEST['password2_copy']))
|
249 |
+
$password2 = $password;
|
250 |
+
elseif (isset($_REQUEST['password2']))
|
251 |
+
$password2 = $_REQUEST['password2'];
|
252 |
+
else
|
253 |
+
$password2 = "";
|
254 |
+
if (isset($_REQUEST['tos']))
|
255 |
+
$tos = intval($_REQUEST['tos']);
|
256 |
+
else
|
257 |
+
$tos = "";
|
258 |
+
|
259 |
+
//_x stuff in case they clicked on the image button with their mouse
|
260 |
+
if (isset($_REQUEST['submit-checkout']))
|
261 |
+
$submit = $_REQUEST['submit-checkout'];
|
262 |
+
if (empty($submit) && isset($_REQUEST['submit-checkout_x']) )
|
263 |
+
$submit = $_REQUEST['submit-checkout_x'];
|
264 |
+
if (isset($submit) && $submit === "0")
|
265 |
+
$submit = true;
|
266 |
+
elseif (!isset($submit))
|
267 |
+
$submit = false;
|
268 |
+
|
269 |
+
//require fields
|
270 |
+
$pmpro_required_billing_fields = array(
|
271 |
+
"bfirstname" => $bfirstname,
|
272 |
+
"blastname" => $blastname,
|
273 |
+
"baddress1" => $baddress1,
|
274 |
+
"bcity" => $bcity,
|
275 |
+
"bstate" => $bstate,
|
276 |
+
"bzipcode" => $bzipcode,
|
277 |
+
"bphone" => $bphone,
|
278 |
+
"bemail" => $bemail,
|
279 |
+
"bcountry" => $bcountry,
|
280 |
+
"CardType" => $CardType,
|
281 |
+
"AccountNumber" => $AccountNumber,
|
282 |
+
"ExpirationMonth" => $ExpirationMonth,
|
283 |
+
"ExpirationYear" => $ExpirationYear,
|
284 |
+
"CVV" => $CVV
|
285 |
+
);
|
286 |
+
$pmpro_required_billing_fields = apply_filters("pmpro_required_billing_fields", $pmpro_required_billing_fields);
|
287 |
+
$pmpro_required_user_fields = array(
|
288 |
+
"username" => $username,
|
289 |
+
"password" => $password,
|
290 |
+
"password2" => $password2,
|
291 |
+
"bemail" => $bemail,
|
292 |
+
"bconfirmemail" => $bconfirmemail
|
293 |
+
);
|
294 |
+
$pmpro_required_user_fields = apply_filters("pmpro_required_user_fields", $pmpro_required_user_fields);
|
295 |
+
|
296 |
+
//pmpro_confirmed is set to true later if payment goes through
|
297 |
+
$pmpro_confirmed = false;
|
298 |
+
|
299 |
+
//check their fields if they clicked continue
|
300 |
+
if ($submit && $pmpro_msgt != "pmpro_error") {
|
301 |
+
|
302 |
+
//make sure javascript is ok
|
303 |
+
if (apply_filters("pmpro_require_javascript_for_checkout", true) && !empty($_REQUEST['checkjavascript']) && empty($_REQUEST['javascriptok'])) {
|
304 |
+
pmpro_setMessage(__("There are JavaScript errors on the page. Please contact the webmaster.", "pmpro"), "pmpro_error");
|
305 |
+
}
|
306 |
+
|
307 |
+
//if we're skipping the account fields and there is no user, we need to create a username and password
|
308 |
+
if ($skip_account_fields && !$current_user->ID) {
|
309 |
+
$username = pmpro_generateUsername($bfirstname, $blastname, $bemail);
|
310 |
+
if (empty($username))
|
311 |
+
$username = pmpro_getDiscountCode();
|
312 |
+
$password = pmpro_getDiscountCode() . pmpro_getDiscountCode(); //using two random discount codes
|
313 |
+
$password2 = $password;
|
314 |
+
}
|
315 |
+
|
316 |
+
//check billing fields
|
317 |
+
if ($pmpro_requirebilling) {
|
318 |
+
//filter
|
319 |
+
foreach($pmpro_required_billing_fields as $key => $field) {
|
320 |
+
if (!$field) {
|
321 |
+
$pmpro_error_fields[] = $key;
|
322 |
+
}
|
323 |
+
}
|
324 |
+
}
|
325 |
+
|
326 |
+
//check user fields
|
327 |
+
if (empty($current_user->ID)) {
|
328 |
+
foreach($pmpro_required_user_fields as $key => $field) {
|
329 |
+
if (!$field) {
|
330 |
+
$pmpro_error_fields[] = $key;
|
331 |
+
}
|
332 |
+
}
|
333 |
+
}
|
334 |
+
|
335 |
+
if (!empty($pmpro_error_fields)) {
|
336 |
+
pmpro_setMessage(__("Please complete all required fields.", "pmpro"), "pmpro_error");
|
337 |
+
}
|
338 |
+
if (!empty($password) && $password != $password2) {
|
339 |
+
pmpro_setMessage(__("Your passwords do not match. Please try again.", "pmpro"), "pmpro_error");
|
340 |
+
$pmpro_error_fields[] = "password";
|
341 |
+
$pmpro_error_fields[] = "password2";
|
342 |
+
}
|
343 |
+
if (!empty($bemail) && $bemail != $bconfirmemail) {
|
344 |
+
pmpro_setMessage(__("Your email addresses do not match. Please try again.", "pmpro"), "pmpro_error");
|
345 |
+
$pmpro_error_fields[] = "bemail";
|
346 |
+
$pmpro_error_fields[] = "bconfirmemail";
|
347 |
+
}
|
348 |
+
if (!empty($bemail) && !is_email($bemail)) {
|
349 |
+
pmpro_setMessage(__("The email address entered is in an invalid format. Please try again.", "pmpro"), "pmpro_error");
|
350 |
+
$pmpro_error_fields[] = "bemail";
|
351 |
+
$pmpro_error_fields[] = "bconfirmemail";
|
352 |
+
}
|
353 |
+
if (!empty($tospage) && empty($tos)) {
|
354 |
+
pmpro_setMessage(sprintf(__("Please check the box to agree to the %s.", "pmpro"), $tospage->post_title), "pmpro_error");
|
355 |
+
$pmpro_error_fields[] = "tospage";
|
356 |
+
}
|
357 |
+
if (!in_array($gateway, $valid_gateways)) {
|
358 |
+
pmpro_setMessage(__("Invalid gateway.", "pmpro"), "pmpro_error");
|
359 |
+
}
|
360 |
+
if (!empty($fullname)) {
|
361 |
+
pmpro_setMessage(__("Are you a spammer?", "pmpro"), "pmpro_error");
|
362 |
+
}
|
363 |
+
|
364 |
+
if ($pmpro_msgt == "pmpro_error")
|
365 |
+
$pmpro_continue_registration = false;
|
366 |
+
else
|
367 |
+
$pmpro_continue_registration = true;
|
368 |
+
$pmpro_continue_registration = apply_filters("pmpro_registration_checks", $pmpro_continue_registration);
|
369 |
+
|
370 |
+
if ($pmpro_continue_registration) {
|
371 |
+
//if creating a new user, check that the email and username are available
|
372 |
+
if (empty($current_user->ID)) {
|
373 |
+
$oldusername = $wpdb->get_var("SELECT user_login FROM $wpdb->users WHERE user_login = '" . esc_sql($username) . "' LIMIT 1");
|
374 |
+
$oldemail = $wpdb->get_var("SELECT user_email FROM $wpdb->users WHERE user_email = '" . esc_sql($bemail) . "' LIMIT 1");
|
375 |
+
|
376 |
+
//this hook can be used to allow multiple accounts with the same email address
|
377 |
+
$oldemail = apply_filters("pmpro_checkout_oldemail", $oldemail);
|
378 |
+
}
|
379 |
+
|
380 |
+
if (!empty($oldusername)) {
|
381 |
+
pmpro_setMessage(__("That username is already taken. Please try another.", "pmpro"), "pmpro_error");
|
382 |
+
$pmpro_error_fields[] = "username";
|
383 |
+
}
|
384 |
+
|
385 |
+
if (!empty($oldemail)) {
|
386 |
+
pmpro_setMessage(__("That email address is already taken. Please try another.", "pmpro"), "pmpro_error");
|
387 |
+
$pmpro_error_fields[] = "bemail";
|
388 |
+
$pmpro_error_fields[] = "bconfirmemail";
|
389 |
+
}
|
390 |
+
|
391 |
+
//only continue if there are no other errors yet
|
392 |
+
if ($pmpro_msgt != "pmpro_error") {
|
393 |
+
//check recaptcha first
|
394 |
+
global $recaptcha;
|
395 |
+
if (!$skip_account_fields && ($recaptcha == 2 || ($recaptcha == 1 && pmpro_isLevelFree($pmpro_level)))) {
|
396 |
+
global $recaptcha_privatekey;
|
397 |
+
|
398 |
+
if(isset($_POST["recaptcha_challenge_field"]))
|
399 |
+
{
|
400 |
+
//using older recaptcha lib
|
401 |
+
$resp = recaptcha_check_answer($recaptcha_privatekey,
|
402 |
+
$_SERVER["REMOTE_ADDR"],
|
403 |
+
$_POST["recaptcha_challenge_field"],
|
404 |
+
$_POST["recaptcha_response_field"]);
|
405 |
+
|
406 |
+
$recaptcha_valid = $resp->is_valid;
|
407 |
+
$recaptcha_errors = $resp->error;
|
408 |
+
}
|
409 |
+
else
|
410 |
+
{
|
411 |
+
//using newer recaptcha lib
|
412 |
+
$reCaptcha = new pmpro_ReCaptcha($recaptcha_privatekey);
|
413 |
+
$resp = $reCaptcha->verifyResponse($_SERVER["REMOTE_ADDR"], $_POST["g-recaptcha-response"]);
|
414 |
+
|
415 |
+
$recaptcha_valid = $resp->success;
|
416 |
+
$recaptcha_errors = $resp->errorCodes;
|
417 |
+
}
|
418 |
+
|
419 |
+
if (!$recaptcha_valid) {
|
420 |
+
$pmpro_msg = sprintf(__("reCAPTCHA failed. (%s) Please try again.", "pmpro"), $recaptcha_errors);
|
421 |
+
$pmpro_msgt = "pmpro_error";
|
422 |
+
} else {
|
423 |
+
// Your code here to handle a successful verification
|
424 |
+
if ($pmpro_msgt != "pmpro_error")
|
425 |
+
$pmpro_msg = "All good!";
|
426 |
+
}
|
427 |
+
} else {
|
428 |
+
if ($pmpro_msgt != "pmpro_error")
|
429 |
+
$pmpro_msg = "All good!";
|
430 |
+
}
|
431 |
+
|
432 |
+
//no errors yet
|
433 |
+
if ($pmpro_msgt != "pmpro_error") {
|
434 |
+
do_action('pmpro_checkout_before_processing');
|
435 |
+
|
436 |
+
//process checkout if required
|
437 |
+
if ($pmpro_requirebilling) {
|
438 |
+
$morder = new MemberOrder();
|
439 |
+
$morder->membership_id = $pmpro_level->id;
|
440 |
+
$morder->membership_name = $pmpro_level->name;
|
441 |
+
$morder->discount_code = $discount_code;
|
442 |
+
$morder->InitialPayment = $pmpro_level->initial_payment;
|
443 |
+
$morder->PaymentAmount = $pmpro_level->billing_amount;
|
444 |
+
$morder->ProfileStartDate = date("Y-m-d", current_time("timestamp")) . "T0:0:0";
|
445 |
+
$morder->BillingPeriod = $pmpro_level->cycle_period;
|
446 |
+
$morder->BillingFrequency = $pmpro_level->cycle_number;
|
447 |
+
|
448 |
+
if ($pmpro_level->billing_limit)
|
449 |
+
$morder->TotalBillingCycles = $pmpro_level->billing_limit;
|
450 |
+
|
451 |
+
if (pmpro_isLevelTrial($pmpro_level)) {
|
452 |
+
$morder->TrialBillingPeriod = $pmpro_level->cycle_period;
|
453 |
+
$morder->TrialBillingFrequency = $pmpro_level->cycle_number;
|
454 |
+
$morder->TrialBillingCycles = $pmpro_level->trial_limit;
|
455 |
+
$morder->TrialAmount = $pmpro_level->trial_amount;
|
456 |
+
}
|
457 |
+
|
458 |
+
//credit card values
|
459 |
+
$morder->cardtype = $CardType;
|
460 |
+
$morder->accountnumber = $AccountNumber;
|
461 |
+
$morder->expirationmonth = $ExpirationMonth;
|
462 |
+
$morder->expirationyear = $ExpirationYear;
|
463 |
+
$morder->ExpirationDate = $ExpirationMonth . $ExpirationYear;
|
464 |
+
$morder->ExpirationDate_YdashM = $ExpirationYear . "-" . $ExpirationMonth;
|
465 |
+
$morder->CVV2 = $CVV;
|
466 |
+
|
467 |
+
//not saving email in order table, but the sites need it
|
468 |
+
$morder->Email = $bemail;
|
469 |
+
|
470 |
+
//sometimes we need these split up
|
471 |
+
$morder->FirstName = $bfirstname;
|
472 |
+
$morder->LastName = $blastname;
|
473 |
+
$morder->Address1 = $baddress1;
|
474 |
+
$morder->Address2 = $baddress2;
|
475 |
+
|
476 |
+
//other values
|
477 |
+
$morder->billing = new stdClass();
|
478 |
+
$morder->billing->name = $bfirstname . " " . $blastname;
|
479 |
+
$morder->billing->street = trim($baddress1 . " " . $baddress2);
|
480 |
+
$morder->billing->city = $bcity;
|
481 |
+
$morder->billing->state = $bstate;
|
482 |
+
$morder->billing->country = $bcountry;
|
483 |
+
$morder->billing->zip = $bzipcode;
|
484 |
+
$morder->billing->phone = $bphone;
|
485 |
+
|
486 |
+
//$gateway = pmpro_getOption("gateway");
|
487 |
+
$morder->gateway = $gateway;
|
488 |
+
$morder->setGateway();
|
489 |
+
|
490 |
+
//setup level var
|
491 |
+
$morder->getMembershipLevel();
|
492 |
+
$morder->membership_level = apply_filters("pmpro_checkout_level", $morder->membership_level);
|
493 |
+
|
494 |
+
//tax
|
495 |
+
$morder->subtotal = $morder->InitialPayment;
|
496 |
+
$morder->getTax();
|
497 |
+
|
498 |
+
//filter for order, since v1.8
|
499 |
+
$morder = apply_filters("pmpro_checkout_order", $morder);
|
500 |
+
|
501 |
+
$pmpro_processed = $morder->process();
|
502 |
+
|
503 |
+
if (!empty($pmpro_processed))
|
504 |
+
{
|
505 |
+
$pmpro_msg = __("Payment accepted.", "pmpro");
|
506 |
+
$pmpro_msgt = "pmpro_success";
|
507 |
+
$pmpro_confirmed = true;
|
508 |
+
}
|
509 |
+
else
|
510 |
+
{
|
511 |
+
$pmpro_msg = $morder->error;
|
512 |
+
if (empty($pmpro_msg))
|
513 |
+
$pmpro_msg = __("Unknown error generating account. Please contact us to set up your membership.", "pmpro");
|
514 |
+
$pmpro_msgt = "pmpro_error";
|
515 |
+
}
|
516 |
+
|
517 |
+
}
|
518 |
+
else // !$pmpro_requirebilling
|
519 |
+
{
|
520 |
+
//must have been a free membership, continue
|
521 |
+
$pmpro_confirmed = true;
|
522 |
+
}
|
523 |
+
}
|
524 |
+
}
|
525 |
+
} //endif ($pmpro_continue_registration)
|
526 |
+
}
|
527 |
+
|
528 |
+
//make sure we have at least an empty morder here to avoid a warning
|
529 |
+
if (empty($morder))
|
530 |
+
$morder = false;
|
531 |
+
|
532 |
+
//Hook to check payment confirmation or replace it. If we get an array back, pull the values (morder) out
|
533 |
+
$pmpro_confirmed = apply_filters('pmpro_checkout_confirmed', $pmpro_confirmed, $morder);
|
534 |
+
if (is_array($pmpro_confirmed))
|
535 |
+
extract($pmpro_confirmed);
|
536 |
+
|
537 |
+
//if payment was confirmed create/update the user.
|
538 |
+
if (!empty($pmpro_confirmed)) {
|
539 |
+
//just in case this hasn't been set yet
|
540 |
+
$submit = true;
|
541 |
+
|
542 |
+
//do we need to create a user account?
|
543 |
+
if (!$current_user->ID) {
|
544 |
+
/*
|
545 |
+
create user
|
546 |
+
*/
|
547 |
+
if (version_compare($wp_version, "3.1") < 0)
|
548 |
+
require_once( ABSPATH . WPINC . '/registration.php'); //need this for WP versions before 3.1
|
549 |
+
|
550 |
+
//first name
|
551 |
+
if (!empty($_REQUEST['first_name']))
|
552 |
+
$first_name = $_REQUEST['first_name'];
|
553 |
+
else
|
554 |
+
$first_name = $bfirstname;
|
555 |
+
//last name
|
556 |
+
if (!empty($_REQUEST['last_name']))
|
557 |
+
$last_name = $_REQUEST['last_name'];
|
558 |
+
else
|
559 |
+
$last_name = $blastname;
|
560 |
+
|
561 |
+
//insert user
|
562 |
+
$new_user_array = apply_filters('pmpro_checkout_new_user_array', array(
|
563 |
+
"user_login" => $username,
|
564 |
+
"user_pass" => $password,
|
565 |
+
"user_email" => $bemail,
|
566 |
+
"first_name" => $first_name,
|
567 |
+
"last_name" => $last_name)
|
568 |
+
);
|
569 |
+
|
570 |
+
$user_id = apply_filters('pmpro_new_user', '', $new_user_array);
|
571 |
+
if (!$user_id)
|
572 |
+
$user_id = wp_insert_user($new_user_array);
|
573 |
+
|
574 |
+
if (!$user_id || is_wp_error($user_id)) {
|
575 |
+
$pmpro_msg = __("Your payment was accepted, but there was an error setting up your account. Please contact us.", "pmpro");
|
576 |
+
$pmpro_msgt = "pmpro_error";
|
577 |
+
} elseif (apply_filters('pmpro_setup_new_user', true, $user_id, $new_user_array, $pmpro_level)) {
|
578 |
+
|
579 |
+
//check pmpro_wp_new_user_notification filter before sending the default WP email
|
580 |
+
if (apply_filters("pmpro_wp_new_user_notification", true, $user_id, $pmpro_level->id)) {
|
581 |
+
if (version_compare($wp_version, "4.3.0") >= 0)
|
582 |
+
wp_new_user_notification($user_id, null, 'both');
|
583 |
+
else
|
584 |
+
wp_new_user_notification($user_id, $new_user_array['user_pass']);
|
585 |
+
}
|
586 |
+
|
587 |
+
$wpuser = get_userdata($user_id);
|
588 |
+
|
589 |
+
//make the user a subscriber
|
590 |
+
$wpuser->set_role(get_option('default_role', 'subscriber'));
|
591 |
+
|
592 |
+
//okay, log them in to WP
|
593 |
+
$creds = array();
|
594 |
+
$creds['user_login'] = $new_user_array['user_login'];
|
595 |
+
$creds['user_password'] = $new_user_array['user_pass'];
|
596 |
+
$creds['remember'] = true;
|
597 |
+
$user = wp_signon( $creds, false );
|
598 |
+
|
599 |
+
//setting some cookies
|
600 |
+
wp_set_current_user($user_id, $username);
|
601 |
+
wp_set_auth_cookie($user_id, true, apply_filters('pmpro_checkout_signon_secure', (force_ssl_login() || force_ssl_admin())));
|
602 |
+
}
|
603 |
+
}
|
604 |
+
else
|
605 |
+
$user_id = $current_user->ID;
|
606 |
+
|
607 |
+
if ($user_id && !is_wp_error($user_id))
|
608 |
+
{
|
609 |
+
do_action('pmpro_checkout_before_change_membership_level', $user_id, $morder);
|
610 |
+
|
611 |
+
//calculate the end date
|
612 |
+
if (!empty($pmpro_level->expiration_number)) {
|
613 |
+
$enddate = "'" . date("Y-m-d", strtotime("+ " . $pmpro_level->expiration_number . " " . $pmpro_level->expiration_period, current_time("timestamp"))) . "'";
|
614 |
+
} else {
|
615 |
+
$enddate = "NULL";
|
616 |
+
}
|
617 |
+
|
618 |
+
//update membership_user table.
|
619 |
+
if (!empty($discount_code) && !empty($use_discount_code))
|
620 |
+
$discount_code_id = $wpdb->get_var("SELECT id FROM $wpdb->pmpro_discount_codes WHERE code = '" . $discount_code . "' LIMIT 1");
|
621 |
+
else
|
622 |
+
$discount_code_id = "";
|
623 |
+
|
624 |
+
//set the start date to NOW() but allow filters
|
625 |
+
$startdate = apply_filters("pmpro_checkout_start_date", "'" . current_time("mysql") . "'", $user_id, $pmpro_level);
|
626 |
+
|
627 |
+
$custom_level = array(
|
628 |
+
'user_id' => $user_id,
|
629 |
+
'membership_id' => $pmpro_level->id,
|
630 |
+
'code_id' => $discount_code_id,
|
631 |
+
'initial_payment' => $pmpro_level->initial_payment,
|
632 |
+
'billing_amount' => $pmpro_level->billing_amount,
|
633 |
+
'cycle_number' => $pmpro_level->cycle_number,
|
634 |
+
'cycle_period' => $pmpro_level->cycle_period,
|
635 |
+
'billing_limit' => $pmpro_level->billing_limit,
|
636 |
+
'trial_amount' => $pmpro_level->trial_amount,
|
637 |
+
'trial_limit' => $pmpro_level->trial_limit,
|
638 |
+
'startdate' => $startdate,
|
639 |
+
'enddate' => $enddate);
|
640 |
+
|
641 |
+
if (pmpro_changeMembershipLevel($custom_level, $user_id, 'changed')) {
|
642 |
+
//we're good
|
643 |
+
//blank order for free levels
|
644 |
+
if (empty($morder)) {
|
645 |
+
$morder = new MemberOrder();
|
646 |
+
$morder->InitialPayment = 0;
|
647 |
+
$morder->Email = $bemail;
|
648 |
+
$morder->gateway = "free";
|
649 |
+
|
650 |
+
$morder = apply_filters("pmpro_checkout_order_free", $morder);
|
651 |
+
}
|
652 |
+
|
653 |
+
//add an item to the history table, cancel old subscriptions
|
654 |
+
if (!empty($morder)) {
|
655 |
+
$morder->user_id = $user_id;
|
656 |
+
$morder->membership_id = $pmpro_level->id;
|
657 |
+
$morder->saveOrder();
|
658 |
+
}
|
659 |
+
|
660 |
+
//update the current user
|
661 |
+
global $current_user;
|
662 |
+
if (!$current_user->ID && $user->ID)
|
663 |
+
$current_user = $user; //in case the user just signed up
|
664 |
+
pmpro_set_current_user();
|
665 |
+
|
666 |
+
//add discount code use
|
667 |
+
if ($discount_code && $use_discount_code) {
|
668 |
+
if (!empty($morder->id))
|
669 |
+
$code_order_id = $morder->id;
|
670 |
+
else
|
671 |
+
$code_order_id = "";
|
672 |
+
|
673 |
+
$wpdb->query("INSERT INTO $wpdb->pmpro_discount_codes_uses (code_id, user_id, order_id, timestamp) VALUES('" . $discount_code_id . "', '" . $user_id . "', '" . intval($code_order_id) . "', '" . current_time("mysql") . "')");
|
674 |
+
}
|
675 |
+
|
676 |
+
//save billing info ect, as user meta
|
677 |
+
$meta_keys = array("pmpro_bfirstname", "pmpro_blastname", "pmpro_baddress1", "pmpro_baddress2", "pmpro_bcity", "pmpro_bstate", "pmpro_bzipcode", "pmpro_bcountry", "pmpro_bphone", "pmpro_bemail", "pmpro_CardType", "pmpro_AccountNumber", "pmpro_ExpirationMonth", "pmpro_ExpirationYear");
|
678 |
+
$meta_values = array($bfirstname, $blastname, $baddress1, $baddress2, $bcity, $bstate, $bzipcode, $bcountry, $bphone, $bemail, $CardType, hideCardNumber($AccountNumber), $ExpirationMonth, $ExpirationYear);
|
679 |
+
pmpro_replaceUserMeta($user_id, $meta_keys, $meta_values);
|
680 |
+
|
681 |
+
//save first and last name fields
|
682 |
+
if (!empty($bfirstname)) {
|
683 |
+
$old_firstname = get_user_meta($user_id, "first_name", true);
|
684 |
+
if (empty($old_firstname))
|
685 |
+
update_user_meta($user_id, "first_name", $bfirstname);
|
686 |
+
}
|
687 |
+
if (!empty($blastname)) {
|
688 |
+
$old_lastname = get_user_meta($user_id, "last_name", true);
|
689 |
+
if (empty($old_lastname))
|
690 |
+
update_user_meta($user_id, "last_name", $blastname);
|
691 |
+
}
|
692 |
+
|
693 |
+
//show the confirmation
|
694 |
+
$ordersaved = true;
|
695 |
+
|
696 |
+
//hook
|
697 |
+
do_action("pmpro_after_checkout", $user_id, $morder); //added $morder param in v2.0
|
698 |
+
|
699 |
+
//setup some values for the emails
|
700 |
+
if (!empty($morder))
|
701 |
+
$invoice = new MemberOrder($morder->id);
|
702 |
+
else
|
703 |
+
$invoice = NULL;
|
704 |
+
$current_user->membership_level = $pmpro_level; //make sure they have the right level info
|
705 |
+
|
706 |
+
//send email to member
|
707 |
+
$pmproemail = new PMProEmail();
|
708 |
+
$pmproemail->sendCheckoutEmail($current_user, $invoice);
|
709 |
+
|
710 |
+
//send email to admin
|
711 |
+
$pmproemail = new PMProEmail();
|
712 |
+
$pmproemail->sendCheckoutAdminEmail($current_user, $invoice);
|
713 |
+
|
714 |
+
//redirect to confirmation
|
715 |
+
$rurl = pmpro_url("confirmation", "?level=" . $pmpro_level->id);
|
716 |
+
$rurl = apply_filters("pmpro_confirmation_url", $rurl, $user_id, $pmpro_level);
|
717 |
+
wp_redirect($rurl);
|
718 |
+
exit;
|
719 |
+
} else {
|
720 |
+
//uh oh. we charged them then the membership creation failed
|
721 |
+
if (isset($morder) && $morder->cancel()) {
|
722 |
+
$pmpro_msg = __("IMPORTANT: Something went wrong during membership creation. Your credit card authorized, but we cancelled the order immediately. You should not try to submit this form again. Please contact the site owner to fix this issue.", "pmpro");
|
723 |
+
$morder = NULL;
|
724 |
+
} else {
|
725 |
+
$pmpro_msg = __("IMPORTANT: Something went wrong during membership creation. Your credit card was charged, but we couldn't assign your membership. You should not submit this form again. Please contact the site owner to fix this issue.", "pmpro");
|
726 |
+
}
|
727 |
+
}
|
728 |
+
}
|
729 |
+
}
|
730 |
+
|
731 |
+
//default values
|
732 |
+
if (empty($submit)) {
|
733 |
+
//show message if the payment gateway is not setup yet
|
734 |
+
if ($pmpro_requirebilling && !pmpro_getOption("gateway", true)) {
|
735 |
+
if (pmpro_isAdmin())
|
736 |
+
$pmpro_msg = sprintf(__('You must <a href="%s">set up a Payment Gateway</a> before any payments will be processed.', 'pmpro'), get_admin_url(NULL, '/admin.php?page=pmpro-membershiplevels&view=payment'));
|
737 |
+
else
|
738 |
+
$pmpro_msg = __("A Payment Gateway must be set up before any payments will be processed.", "pmpro");
|
739 |
+
$pmpro_msgt = "";
|
740 |
+
}
|
741 |
+
|
742 |
+
//default values from DB
|
743 |
+
if (!empty($current_user->ID)) {
|
744 |
+
$bfirstname = get_user_meta($current_user->ID, "pmpro_bfirstname", true);
|
745 |
+
$blastname = get_user_meta($current_user->ID, "pmpro_blastname", true);
|
746 |
+
$baddress1 = get_user_meta($current_user->ID, "pmpro_baddress1", true);
|
747 |
+
$baddress2 = get_user_meta($current_user->ID, "pmpro_baddress2", true);
|
748 |
+
$bcity = get_user_meta($current_user->ID, "pmpro_bcity", true);
|
749 |
+
$bstate = get_user_meta($current_user->ID, "pmpro_bstate", true);
|
750 |
+
$bzipcode = get_user_meta($current_user->ID, "pmpro_bzipcode", true);
|
751 |
+
$bcountry = get_user_meta($current_user->ID, "pmpro_bcountry", true);
|
752 |
+
$bphone = get_user_meta($current_user->ID, "pmpro_bphone", true);
|
753 |
+
$bemail = get_user_meta($current_user->ID, "pmpro_bemail", true);
|
754 |
+
$bconfirmemail = $bemail; //as of 1.7.5, just setting to bemail
|
755 |
+
$CardType = get_user_meta($current_user->ID, "pmpro_CardType", true);
|
756 |
+
//$AccountNumber = hideCardNumber(get_user_meta($current_user->ID, "pmpro_AccountNumber", true), false);
|
757 |
+
$ExpirationMonth = get_user_meta($current_user->ID, "pmpro_ExpirationMonth", true);
|
758 |
+
$ExpirationYear = get_user_meta($current_user->ID, "pmpro_ExpirationYear", true);
|
759 |
+
}
|
760 |
+
}
|
761 |
+
|
762 |
+
//clear out XXXX numbers (e.g. with Stripe)
|
763 |
+
if (!empty($AccountNumber) && strpos($AccountNumber, "XXXX") === 0)
|
764 |
+
$AccountNumber = "";
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ 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.3.1
|
6 |
-
Stable tag: 1.8.6.
|
7 |
|
8 |
A revenue-generating machine for membership sites. Unlimited levels with recurring payment, protected content and member management.
|
9 |
|
@@ -115,6 +115,23 @@ 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 |
= 1.8.6.1 =
|
119 |
* SECURITY: Removed debug code from the PayPal IPN Handler script that was causing invalid IPN requests to process as if they were valid. (Thanks, Francois Harvey)
|
120 |
|
@@ -844,340 +861,4 @@ useful for determining if/what discount code was applied to the level when proce
|
|
844 |
* Added hooks for changing the discount code page: pmpro_save_discount_code_level, pmpro_save_discount_code, pmpro_discount_code_after_settings, pmpro_discount_code_after_level_settings. Look them up in discountcodes.php to see how they work.
|
845 |
* Updated pmpro_send_html(), which filters emails, to use wpautop instead of nl2br. This will fix any extra double spacing you may have noticed in your emails.
|
846 |
* Added a stripslashes around the membership level confirmation text on the confirmation page. Extra slashes were breaking links, etc.
|
847 |
-
* Added membership level to
|
848 |
-
|
849 |
-
= 1.4.2 =
|
850 |
-
* Fixed bug that was added slashes into a level's description and confirmation when saving.
|
851 |
-
* Removed wp_editor use is the blog is running a version of WordPress < 3.3. (Note: We will only officially support the latest version of WordPress with each release.)
|
852 |
-
* Added the pmpro_pages_shortcode_{membership page} filter. This can be used to filter the content output by the pmpro_checkout and other page shortcodes. e.g. use pmpro_pages_shortcode_checkout to tweak the HTML output of the pmpro_checkout shortcode. The pages are "account", "billing", "cancel", "checkout", "confirmation", and "levels".
|
853 |
-
* Added a "use_ssl" option. For the PayPal Website Payments Pro and Authorize.net gateways, this must be on. For Stripe, this will default to on, but can be switched off. For PayPal Express and the test gateway, it will default to off but can be switched on. When on, the checkout and update billing pages will be forced to be served over SSL. If off, those pages will redirect to non-ssl versions. The previous hooks/filters for overriding this will still work.
|
854 |
-
* Added pmpro_save_membership_level and pmpro_membership_level_after_other_settings hooks to be able to add fields to the new/edit membership level page.
|
855 |
-
* Fixed some more warnings and notices.
|
856 |
-
* Updated checkout page to use pmpro_isLevelFree() in logic to display recaptcha or not.
|
857 |
-
|
858 |
-
= 1.4.1 =
|
859 |
-
* Fixed critical bugs with PayPal Express.
|
860 |
-
* When a PayPal cancellation returns error "11556" (The subscription must have status "active" or "suspended".) I am cancelling the membership without an error. Most likely the PayPal subscription was already cancelled on the PayPal side.
|
861 |
-
* No longer trying to cancel a subscription with the gateway if a membership/order doesn't have a subscription_transaction_id. (It was a initial payment only membership probably.)
|
862 |
-
|
863 |
-
= 1.4 =
|
864 |
-
* Rewrote how gateways are handled to make it easier to add and manage new gateway options.
|
865 |
-
* Added Stripe as a gateway option. (http://www.stripe.com)
|
866 |
-
* Added a "confirmation message" field to the level editor that is shown on the confirmation page after checking out. The message is added to the text that can be filtered using the pmpro_confirmation_message hook.
|
867 |
-
* Now applying "the_content" filters on the confirmation message on the confirmation page. e.g. wpautop will be run on the text to automatically add paragraphs.
|
868 |
-
* Now showing the level description on the checkout page. You can use this code to remove the description from the checkout page: https://gist.github.com/2323424
|
869 |
-
* The description and confirmation fields of the membership level editor now use WP Editor fields with full WYSIWYG support.
|
870 |
-
* Fixed the logic around setting the $pmpro_display_ads global, used by the pmpro_displayAds() and pmpro_hideAds() functions.
|
871 |
-
* Fixed bug with recaptcha logic.
|
872 |
-
* Updated /pages/checkout.php to use wp_login_url function for login link.
|
873 |
-
* Small changes to pmpro_changeMembershipLevel function to support deleting users when they cancel their account.
|
874 |
-
* Added the pmpro_member_links_top and pmpro_member_links_bottom hooks so you can add links to the "Member Links" list of the account page. Just output an a tag wrapped in a li tag. (May tweak this to build an array of links that can be filters, but this is good for now.)
|
875 |
-
* Fixed some more notices.
|
876 |
-
|
877 |
-
= 1.3.19 =
|
878 |
-
* Rewrote the pmpro_login_redirect function. It's cleaner now. Important: there was a pmpro_login_redirect hook in there that was fairly redundant with the core login_redirect hook. I've renamed the pmpro hook to pmpro_login_redirect_to because I had a hook with the same name (pmpro_login_redirect) used in a different place to control whether or not PMPro redirects the register page to the levels page. Having one hook for two things is a bad idea. It seems like more people were using the hook for controlling the registration redirect, so I left that one alone and renamed these.
|
879 |
-
* Changed PMPro page creation to set all membership pages as subpages of the membership account page. This results in nicer menus for themes that add all top level pages to the menu.
|
880 |
-
* Updated the checkout page to submit to "" (itself) instead of echoing the checkout page URL here. (Since we can have multiple checkout pages.) This also fixes from SSL conflicts that may crop up on the checkout page.
|
881 |
-
* Updated the priority of a few actions/hooks so the "besecure" https stuff gets run as soon as possible. Before it was possible that some URLs could be written out with http: on an HTTPS page before PMPro had a chance to fix things. You should have fewer SSL errors on the checkout page to deal with now.
|
882 |
-
* Added an option on the payment settings page to "nuke" http: links on all secure pages. This option can add time to your page loads, but will ensure that all http: links for your domain are replaced with https: links.
|
883 |
-
* Allowing multiple pages to use the [pmpro_checkout] shortcode so you can create multiple checkout pages. This is good if you want a separate templated checkout page for each membership level or product you have.
|
884 |
-
* You can now add a pmpro_default_level custom field, set to the id # of the level you want, that will be used if you navigate directly to a checkout page without setting a level.
|
885 |
-
* Added some stuff to support adding shipping fields via hooks. Add this plugin to your site, edit, and activate to add shipping to your checkout: https://gist.github.com/1894897
|
886 |
-
* Removed the price from the description sent to PayPal. The DESC field is limited to 127 characters and must match up across API calls. So there is a good chance the price would get truncated which could be confusing. This was a kind of hack anyway. PayPal should show the price data it has. Not sure why it won't. The price is still reviewed on the review page of your site though.
|
887 |
-
* The recaptcha code now checks for a previous error before changing pmpro_msg to "All Good".
|
888 |
-
* Fixed warning in pmpro_has_membership_access(). Fixed a bunch of other warnings here and there.
|
889 |
-
* Rewrote pmpro_updateMembershipCategories() just to be cleaner
|
890 |
-
* Added pmpro_state_dropdowns filter. If you return true, the state field will become a dropdown with US states. Use the pmpro_states and pmpro_states_abbreviations filters to change the array of states used.
|
891 |
-
|
892 |
-
= 1.3.18.1 =
|
893 |
-
* Added the new email .html templates to svn.
|
894 |
-
|
895 |
-
= 1.3.18 =
|
896 |
-
* Fixed some warnings: admin bar warning that showed up on admin pages; warning issued by pmpro_setOption(); warning in pmpro_hasMembershipLevel(); warning in billing update; warnings on the user edit page; warnings in the getTax method of the order class; warnings in save method of order class.
|
897 |
-
* Added a pmpro_checkout_confirm_email filter that can return false to hide and not require the "Confirm E-mail" field at checkout.
|
898 |
-
* Added a pmpro_checkout_confirm_password filter that can return false to hide and not require the "Confirm Password" field at checkout.
|
899 |
-
* If the PMPRO_DEFAULT_LEVEL constant is set, traffic on the levels page is redirected to the checkout page. This redirect no longer forces HTTPS.
|
900 |
-
* Moved the pmpro_paypalexpress_session_vars hook call so it will run even if existing users are checking out (upgrades, etc).
|
901 |
-
* Added some confirmation emails for admins: (1) for new user signups, (2) when an admin changes a member's level, (3) when a user cancel's their membership, and (4) when a user update's their billing information. New email templates (ending with "_admin.html") have been added to the /email/ folder of the plugin.
|
902 |
-
* Added new email settings to enable/disable the new admin emails. They will be enabled by default on install and upgrade to 1.3.18. The settings are on the email tab of the PMPro settings.
|
903 |
-
* Added a couple hooks to the checkout page to have more control over where you add fields, etc. pmpro_checkout_before_submit_button and pmpro_checkout_after_billing_fields.
|
904 |
-
|
905 |
-
= 1.3.17.1 =
|
906 |
-
* Fixing activation bug from 1.3.17.
|
907 |
-
|
908 |
-
= 1.3.17 =
|
909 |
-
* Updated pmpro_hasMembershipLevel() and [membership] shortcode to allow passing a level like "-5" which will return true if the user does NOT have level #5.
|
910 |
-
* Updated how PMPro notifications are retrieved and shown on the PMPro admin pages. We're using admin-ajax to call the pmpro_notifications function which uses WP's HTTP API to call the www.paidmembershipspro.com server. Only the PMPro version number is passed to check if a notification should be shown. This method shouldn't slow page load since the javascript is called using jQuery's ready function. If the PMPro server is unavailable, you'll get a JS error instead of a PHP one.
|
911 |
-
* Fixed warning on discount codes page. Fixed some other warnings.
|
912 |
-
* Updated expiration/trial crons to avoid blank ('') and zero ('0000-00-00 00:00:00') DB values in addition to NULLs. (Some backup programs will incorrectly export NULL dates as '' which could be interpretted as 1/1/1970... meaning the membership has expired.)
|
913 |
-
* Fixed bug where "Billing Information" was shown on the account page for some free levels.
|
914 |
-
|
915 |
-
= 1.3.16 =
|
916 |
-
* Moved the SSL Seal box lower on the payment settings page.
|
917 |
-
* Made dashboard menu and admin bar menus consistent.
|
918 |
-
* Fixed bug with selecting categories when adding a new level.
|
919 |
-
* Fixed bug where the user was sometimes redirected to the add level page after adding a level.
|
920 |
-
|
921 |
-
= 1.3.15 =
|
922 |
-
* Fixed SSL handling on the billing page for members without an order.
|
923 |
-
* Removed single quotes from shortcode examples on page settings page. Doh! (Thanks, Caps)
|
924 |
-
* Added Multisite/Network FAQ item.
|
925 |
-
* Updated the payments settings page to convert tax rates like 7 into 0.07. (Tax rates > 1 are divided by 100.)
|
926 |
-
|
927 |
-
= 1.3.14 =
|
928 |
-
* Added pmpro_show_cvv filter to hide the CVV from the checkout and billing information pages.
|
929 |
-
* Updated the billing page to use the pmpro_required_billing_fields like the checkout page does.
|
930 |
-
* Updated the Authorize.net integration to not pass an empty CVV if the value is empty. Authorize.net will still throw an error if you require CVV via your gateway settings. If you update your settings and PMpro to not require a CVV, you won't get an error.
|
931 |
-
* Passing the level cost to PayPal Express through the description.
|
932 |
-
* The billing page doesn't require SSL now if the gateway for the order was PayPal Express. A link to PayPal is shown instead of the form. (Be sure to remove the "becesure" custom field from your billing page if it has one and you don't want this page served over SSL.)
|
933 |
-
* Fixed bug where the membership level name wasn't being passed to Authorize.net in the description field for the order.
|
934 |
-
* Added a second paramter ($tags = true) to the pmpro_getLevelCost function. If this is false, strip_tags is run on the cost before returning it. (By default we wrap the prices in <strong> tags which is not good for passing to PayPal for example.)
|
935 |
-
* Some bug fixes for updating billing against Authorize.net.
|
936 |
-
|
937 |
-
= 1.3.13 =
|
938 |
-
* Fixed warning on checkout page. (Thanks Caps!)
|
939 |
-
* Fixed bug in PayPal Express checkout that resulted in trying to load the confirmation page over SSL (which would break on some servers). (Thanks Caps!)
|
940 |
-
* Updated getTaxFromPrice method of order class to allow for better filtering, by level, etc. The pmpro_tax filter now passes the $tax amount, $values (array with price passed and other values), and $this (the order object). It's a little clunky, but must be for backwards compatibility. Custom tax example here: http://www.paidmembershipspro.com/2012/02/custom-tax-structure-using-the-pmpro_tax-hook/
|
941 |
-
* Removed all TAXAMT NVP parameters in PayPal Express calls. Including these would sometimes introduce errors during checkout. The tax amount is still included in the total amounts passed. Not sure what impact dropping the TAXAMT property will have on reporting in PayPal. I don't believe their tax reporting is the best anyway. Maybe we can build a tax report into PMPro.
|
942 |
-
|
943 |
-
= 1.3.12 =
|
944 |
-
* Fixed bug in members list pagination on sites installed in a subdirectory.
|
945 |
-
* Now swapping out the PayPal Express checkout button if the level is free or becomes free with a discount code. (Thanks, Caps!)
|
946 |
-
|
947 |
-
= 1.3.11 =
|
948 |
-
* Fixed bug with cancelling a user's membership through the admin.
|
949 |
-
|
950 |
-
= 1.3.10 =
|
951 |
-
* Fixed the links in the discount code table.
|
952 |
-
* pmpro_hasMembershipLevel(0) and [membership level="0"] will once again return true for non-members. (This broke whent he pmpro_has_membership_level filter was added.)
|
953 |
-
* WP 3.3.1 testing. (Looks good!)
|
954 |
-
|
955 |
-
= 1.3.9 =
|
956 |
-
* Added a "pmpro_has_membership_level" filter ($r = apply_filters("pmpro_has_membership_level", $r, $user_id, $levels);) which can be used to override the default behavior here.
|
957 |
-
* Fixed the pmpro shortcodes to allow content above and below the shortcodes on the membership pages. (Thanks, Bluewind!)
|
958 |
-
* Now setting the user's first and last name to the billing first and last name after checkout.
|
959 |
-
* Added billing first/last name, billing address, and phone number to the members list screen and CSV export.
|
960 |
-
* Removed email header/footer code from email class because sometimes it was added twice. Now it is added by the pmpro_send_html function in paid-memberships-pro.php for all emails (WP or PMPro) if a header or footer file are found in your theme folder.
|
961 |
-
* Added a pmpro_after_phpmailer_init. (The old hook pmpro_after_pmpmailer_init had a typo -- pmpmailer instead of phpmailer.) I left the old hook in for backwards compatibility.
|
962 |
-
|
963 |
-
= 1.3.8 =
|
964 |
-
* Fixed a bug with canceling memberships. Important Note: User requested cancellations were not being forwarded to PayPal and Authorize.net in the past couple updates. Please double check your members lists with your payment gateway subscriptions. Sorry for the inconvenience.
|
965 |
-
* Fixed a bug in the billing update form.
|
966 |
-
* Wrapped some output on the billing update form in esc_attr.
|
967 |
-
* Now sorting countries alphabetically if international orders are turned on.
|
968 |
-
* Updated the membership-billing page to show country and long form fields if enabled via the hooks pmpro_international_addresses and pmpro_longform_address. (These were only showing up on the checkout form before.)
|
969 |
-
|
970 |
-
= 1.3.7 =
|
971 |
-
* Added "expiration" field to user profile page. Updated the email class to include information on expiration dates in the admin change emails.
|
972 |
-
* Added "pmpro_profile_show_membership_level" and "pmpro_profile_show_expiration" filters which will hide those fields from the edit profile screen if false is returned.
|
973 |
-
* Added a pmpro_getMembershipLevelForUser($user_id) function and replaced some redundant code in a few places where we query the DB for this. Maybe we'll have a membership level class as some point. Makes sense now.
|
974 |
-
* Fixed bug where the wrong price for levels was showing up on the edit profile page in the admin. (It would show the current user's level info instead of the edited user's info.)
|
975 |
-
* Cleaned up a few more warnings, etc.
|
976 |
-
|
977 |
-
= 1.3.6 =
|
978 |
-
* Changed a few split() calls to explode() to avoid warnings.
|
979 |
-
* Fixed a couple other warnings/notifices.
|
980 |
-
* Updated account page to hide the change billing info link if the user doesn't have an active subscription or signed up with PayPal Express.
|
981 |
-
* Added a filter pmpro_paypal_express_return_url_parameters which can be used to add parameters to the ReturnURL when checking out with PayPal Express. Return an array of key, value pairs. { return array("option" => "1"); }
|
982 |
-
|
983 |
-
= 1.3.5 =
|
984 |
-
* Important update to Authorize.net processing code to account for the "credit card expires before the start of this subscription" error that comes up. For levels/discount codes with no trials or only free trials/initial payments, the subscription setup with Authorize.net starts the day of checkout and a free trial is tacked on for 1 period vs. setting up the subscription one period out. One period is added to the billing limit as well, if applicable. Check the blog for more information.
|
985 |
-
* Important update for PayPal Website Payments Pro users. When using PayPal WPP, the user will have an option to checkout via PayPal Express as well. PayPal requires this and now we support it.
|
986 |
-
|
987 |
-
= 1.3.4 =
|
988 |
-
* Swapped the $ in the levels page code for $pmpro_currency_symbol.
|
989 |
-
* Changed the membership shortcode to apply the_content filters to the return value instead of just wpautop. This allows shortcodes within that shortcode and other filters to be run on the content. (Let me know if issues arrise from this.)
|
990 |
-
* Wrapped some post variables in checkout and billing preheaders with trim()
|
991 |
-
* Now voiding authorizations with Authorize.net. (The plugin will authorize $1 before setting up a subscription without an initial payment.)
|
992 |
-
* Now voiding an initial payment with Authorize.net if the subscription setup fails.
|
993 |
-
* Now refunding an intial payment with PayPal if the subscription setup fails.
|
994 |
-
* Added a "pmpro_checkout_after_level_cost" to add fields or arbitrary code after the level cost description on the checkout page.
|
995 |
-
* Added Diner's Club, EnRoute, and JCB as credit card options. Make sure you congiture your Gateway/Merchant account to accept these card types as well.
|
996 |
-
|
997 |
-
= 1.3.3 =
|
998 |
-
* Fixed bug where country field was resetting to default when there were errors with the checkout form submission. (If you templatized your checkout page and have international addresses enabled, you will need to add $bcountry to the globals setup at the top of your checkout template .php)
|
999 |
-
|
1000 |
-
= 1.3.2 =
|
1001 |
-
* Fixed issue introduced in 1.3.1 where checkout page would not redirect to HTTPS when it should have.
|
1002 |
-
* Fixing issues with slashes in addresses/etc in the checkout form.
|
1003 |
-
* Updated the PMProEmail class to use the wp_mail function instead of use PHPMailer directly. (Thanks VadaPrime: http://wordpress.org/support/topic/plugin-paid-memberships-pro-wp_mail?replies=6#post-2449672)
|
1004 |
-
* Fixed some more notices and warnings.
|
1005 |
-
|
1006 |
-
= 1.3.1 =
|
1007 |
-
* Fixed automatic page creation, which broke in the last update.
|
1008 |
-
* Added hook pmpro_checkout_level which allows you to tweak the $level object before checkout, e.g. to change pricing for upgrades.
|
1009 |
-
* Added hook pmpro_checkout_start_date which allows you to change the start date of a membership before checkout. (preheaders/checkout.php)
|
1010 |
-
* Added hook pmpro_profile_start_date which allows you to change the start date of a membership that is sent to the gateway. (classes/class.memberorder.php)
|
1011 |
-
* Cleaned up some notices and warnings. Will hopefully finish the remaining ones next update.
|
1012 |
-
* Removed some old tinyMCE code that wasn't in use anymore. FYI, WP 3.3 will have a way to include visual editors on other pages, so we may add it to the description field of the membership levels.
|
1013 |
-
* Updated order class to send phone and email to Authorize.net when creating subscriptions. The charge/authorize API support international phone numbers, but the ARB API does not. So if a customer enters an international phone number (or other phone number over 10 characters), the number will be sent for any initial payment/charge, but not for the subscription setup.
|
1014 |
-
* Fixed where !!discount_code!! was not being parsed out in emails.
|
1015 |
-
|
1016 |
-
= 1.3 =
|
1017 |
-
* Added a filter pmpro_login_redirect. You can return false to allow users to signup via the default WP login page.
|
1018 |
-
* Member CSV export no longer limiting to 15 members.
|
1019 |
-
* Correctly adding code_id to the pmpro_memberships_users table on signup. View here for retroactively updating your users tables in case you intend to use that value for advanced functionality.
|
1020 |
-
* Changed URL to send IPN checks for live PayPal instances from www.live.paypal.com to www.paypal.com.
|
1021 |
-
* Updated getfile.php to work when WP is installed in a subdomain.
|
1022 |
-
* Added links to individual settings tabs in the WP menu.
|
1023 |
-
* Changed the architecture of the settings pages which used to all be coded in the membershiplevels.php page. Each settings page has its own script now. I removed the pmpro-data.php service and have the pages submit to themselves now. This won't impact how things work, but will make it easier for me to develop going forward.
|
1024 |
-
|
1025 |
-
= 1.2.10 =
|
1026 |
-
* Added pmpro_confirmation_message hook to change the output on the confirmation page without having to templatize it. The filter passes the constructed html string with the confirmation message and a second parameter containing the order/invoice object if it is a paid membership.
|
1027 |
-
* Added a pmpro_checkout_boxes hook that can be used to output extra fields and other content in the middle of the checkout page.
|
1028 |
-
* Now showing 2 decimals places for the tax rate when showing a membership level's cost.
|
1029 |
-
|
1030 |
-
= 1.2.9 =
|
1031 |
-
* IMPORTANT fix so new user email addresses are properly captured when using PayPal Express.
|
1032 |
-
* rewrote the IPN handler to use the WordPress HTTP API for better compatibility.
|
1033 |
-
* added extra id to tables and fields for easier styling. (let me know if you have suggestions for small changes like these that can save you from having to templatize a page)
|
1034 |
-
* fixed query in readiness check function.
|
1035 |
-
* Authorize.net doesn't support international phone numbers, so we're not sending them to Authorize.net anymore.
|
1036 |
-
|
1037 |
-
= 1.2.8 =
|
1038 |
-
* Ordering levels by id (ascending) on the levels page now. Added a "pmpro_levels_array" filter that can be used to reorder the levels or alter the levels before displaying them on the levels page. The array of levels is the only parameter.
|
1039 |
-
* Added expiration date to the member list and export.
|
1040 |
-
* Showing a member count on the member list page.
|
1041 |
-
* Added filter to change subject lines for PMPro emails. (pmpro_email_subject) The filter's first paramter is the subject, the second parameter is an object containg all of the email information. There are also filters for pmpro_email_recipient, pmpro_email_sender, pmpro_email_sender_name, pmpro_email_template, amd pmpro_email_body.
|
1042 |
-
* Added an RSS feed from the PMPro blog to the dashboard.
|
1043 |
-
* Now only showing the discount code field at checkout if there are discount codes in the database. Can be overriden by the pmpro_show_discount_code filter.
|
1044 |
-
* Cancelling with PayPal now properly updates status to "cancelled".
|
1045 |
-
* No longer trying to unsubscribe from PayPal or Authorize.net if there is no subscription ID to check against (e.g. when the user was manually added to a membership level) or if the last order does not have "success" status (e.g. they already cancelled).
|
1046 |
-
* Removed PHP short tags (e.g., <?=$variable?>) for wider compatibility.
|
1047 |
-
|
1048 |
-
= 1.2.7 =
|
1049 |
-
* Fixed bug with non-USD currencies.
|
1050 |
-
* Fixed bug with phone number formatting.
|
1051 |
-
|
1052 |
-
= 1.2.6 =
|
1053 |
-
* Fixed bug with discount codes showing up in emails, confirmation pages, and invoices.
|
1054 |
-
* Added currency option to gateway settings.
|
1055 |
-
|
1056 |
-
= 1.2.5 =
|
1057 |
-
* PayPal Express support! PayPal Express requires just a verified PayPal Business account (no monthly fees from PayPal).
|
1058 |
-
* Fixed a bug when plans with a "cycle number"/billing frequency that was greater than 1 (e.g. every 4 months). Before the first payment was being scheduled 1 day/month ext out instead of e.g. 4 months out... resulting in an extra payment.
|
1059 |
-
* Added some hooks to support international orders: pmpro_international_addresses, pmpro_default_country, pmpro_countries, pmpro_required_billing_fields. Example code to support international credit cards: https://gist.github.com/1212479
|
1060 |
-
|
1061 |
-
= 1.2.4 =
|
1062 |
-
* VERY IMPORTANT BUG FIX: The getMembershipLevel function of the MemberOrder class had an error where the membership level object was not being created properly during signup and so * recurring subscriptions were not being created *. This update fixes the bug. Thanks to mvp29 for catching this.
|
1063 |
-
* Fixed another bug that was causing warnings on some setups, e.g. WAMP server for Windows.
|
1064 |
-
* Fixed a bug that would show warnings when visiting a login page over HTTPS.
|
1065 |
-
* Fixed membership pricing wording for certain cases, e.g. every 4 months for 4 more payments.
|
1066 |
-
* Fixed a bug in the email generation for order confirmations when discount codes were used. This will no longer freeze the screen.
|
1067 |
-
|
1068 |
-
= 1.2.3 =
|
1069 |
-
* Fixed an error in the DB upgrade code that was keeping the "enddate" from being added to new members' records.
|
1070 |
-
|
1071 |
-
= 1.2.2 =
|
1072 |
-
* Added pmpro_skip_account_fields hook. This value is used to determine if the username/password accounts fields should show up at checkout. By default, it is shown when the user is logged out and not shown when logged in. The hook allows you to return true or false to override this behavior. If the fields are skipped while no user is logged in a username and password will be automatically generated for the new user after checkout.
|
1073 |
-
* You can delete discount codes now from the admin.
|
1074 |
-
* Added a hook pmpro_level_cost_text to allow you to override how the cost is shown on the checkout page. Obviously don't abuse this by showing a different price than what will be charged. Be careful if you change your membership levels pricing to update your filter if needed. The hook passes the text generated by the pmpro_getLevelCost(&$level) function and also a level object which is prepopulated with levels pricing and expiration settings already adjusted for any discount codes that may be in affect.
|
1075 |
-
* Added expiration settings for levels. You can set an "expiration number" and "expiration period" for any level now. e.g. "6 months" or "180 days". You can also alter expiration settings via discount codes. Expirations will be useful for offering free trials which don't require a credit card... and other scenarios you guys have come up with. A script is run once a day using WP Cron that checks for any membership that has ended and then cancels that membership. The user will lose access and the subscription setup in your payment gateway will be canceled.
|
1076 |
-
* Users can "extend" a membership that is set to expire via the Membership Account page.
|
1077 |
-
* Added a hook pmpro_level_expiration_text to allow you to override how the expiration information is shown on the levels and checkout pages. Again don't abuse this by showing a different expiration than is real. Be careful if you change your expiration settings to update your filter if needed. The hook passes the text generated by the pmpro_getLevelExpiration(&$level) function and also a level object which is prepopulated with levels pricing and expiration settings already adjusted for any discount codes that may be in affect.
|
1078 |
-
* Added an error check if the MySQL insertion of the membership level fails. This happens after the user's credit card/etc has already been charged. The plugin tries to cancel the order just made, but might fail. The user is adviced to contact the site owner instead of trying again. I don't want to scare you. We test the checkout process a lot. So assuming that the code hasn't been tampered with and there isn't an internet outage in the microseconds between the order going through and the database being updates, you should never run into this. Still it's nice to have, just in case.
|
1079 |
-
* Fixed a bug that may have caused the billing amount to show up incorrectly on the Membership Account page.
|
1080 |
-
* Added the discount code used to the confirmation page, invoices, and invoice emails.
|
1081 |
-
* Now sending notification emails to members 1 week before their trial period ends (if applicable). A WP cron job is setup on plugin activation. You can disable the email via the pmpro_send_trial_ending_email hook.
|
1082 |
-
* Now sending notification emails to members 1 week before their membership expires (if applicable). A WP cron job is setup on plugin activation. You can disable the email via the pmpro_send_expiration_warning_email hook.
|
1083 |
-
* An email is sent when a membership expires. A WP cron job is setup on plugin activation. You can disable the email via the pmpro_send_expiration_email hook.
|
1084 |
-
* Note: Right now users cannot "extend" a membership that is about to expire without first canceling their current membership. I plan to add "membership extensions" for these cases, but it's a little complicated and I didn't want to hold up this release for them. So Real Soon Now.
|
1085 |
-
|
1086 |
-
= 1.2.1 =
|
1087 |
-
* Fixed bug where non-member admins would be redirected away from the "All Pages" page in the admin.
|
1088 |
-
|
1089 |
-
= 1.2 =
|
1090 |
-
* Fixing some wonkiness with the 1.1.15 update.
|
1091 |
-
* Fixed "warning" showing up on discount code pages.
|
1092 |
-
* Tweaked the admin pages a bit for consistency.
|
1093 |
-
* Added screenshots and FAQ to the readme.
|
1094 |
-
* Figured we were due for a bigger version step.
|
1095 |
-
|
1096 |
-
= 1.1.15 =
|
1097 |
-
* Discount Codes Added!
|
1098 |
-
* Removed some redundant files that slipped into the services folder.
|
1099 |
-
* Fixed the !!levels!! variable for message settings of the advanced tab.
|
1100 |
-
* Changing some ids columns in tables to unsigned.
|
1101 |
-
|
1102 |
-
= 1.1.14 =
|
1103 |
-
* Now encoding #'s when sending info via Authorize.net's API. This may prevent some address conflicts.
|
1104 |
-
|
1105 |
-
= 1.1.13 =
|
1106 |
-
* No longer adding "besecure" custom field to the billing and checkout pages. You can still add this manually to selectively require SSL on a page. If you are trying to do a free membership without SSL, you will have to make sure the besecure custom field is deleted from the Membership-Checkout page, especially if you are upgrading from an older version of PMPro.
|
1107 |
-
* Added a filter before sending the default WP welcome notification email. Return false for the "pmpro_wp_new_user_notification" hook/filter to skip sending the WP default welcome email (because in many cases they are already getting an email from PMPro as well).
|
1108 |
-
|
1109 |
-
= 1.1.12 =
|
1110 |
-
* Revenue report on members list page. (Rought estimate only that doesn't take into account trial periods and billing limits.)
|
1111 |
-
* Enabling weekly recurring payments for Authorize.net by converting week period to 7 days * # months.
|
1112 |
-
* Improved error handling on checkout page.
|
1113 |
-
* Now running "pmpro_after_change_membership_level" actions after the "pmpro_after_checkout" action. Previously this hook was only called when a membership level was changed via the WP admin.
|
1114 |
-
* Won't complain about setting up a Payment Gateway if you only have free membership levels.
|
1115 |
-
* The "besecure" custom field is not added to the billing or checkout by default anymore when you run the "create the pages for me" option in the settings. Whether or not to use HTTPS on a page is now handled in the preheader files for each page (see below).
|
1116 |
-
* The plugin won't force SSL on the checkout page anymore unless the membership level requires payment. If your checkout page is still running over HTTPS/SSL for free membership checkouts, make sure the "besecure" custom field has been deleted on your checkout page. You can use the "besecure" custom field or the "pmpro_besecure" filter to override the plugin's decision.
|
1117 |
-
* The plugin won't force SSL on the cancel page anymore. Again, you can override this using the "besecure" custom field or the "pmpro_besecure" filter.
|
1118 |
-
|
1119 |
-
= 1.1.11 =
|
1120 |
-
* Removed some debug code from the invoice page that might have shown on error.
|
1121 |
-
* Added check to recaptcha library code incase it is already installed. (Let's hope other plugin developers are doing the same.)
|
1122 |
-
* Removed the TinyMCE editor from the description field on the edit membership level page. It was a little buggy. Might bring it back later.
|
1123 |
-
|
1124 |
-
= 1.1.10 =
|
1125 |
-
* added a hook/filter "pmpro_rss_text_filter"
|
1126 |
-
* added a hook/filter "pmpro_non_member_text_filter"
|
1127 |
-
* added a hook/filter "pmpro_not_logged_in_text_filter"
|
1128 |
-
* adjusted the pmpro_has_membership_access() function
|
1129 |
-
* added a hook/filter "pmpro_has_membership_access_filter"
|
1130 |
-
* updated the hook/filter "pmpro_has_membership_access_filter_{post-type}"
|
1131 |
-
* removed the "pmpro_has_membership_access_action_{post-type}" hook/action
|
1132 |
-
* update invoice page to handle case where no invoice is found
|
1133 |
-
|
1134 |
-
= 1.1.9 =
|
1135 |
-
* You can now set individual posts to require membership without assigning them to a category.
|
1136 |
-
* Fixed bug with the confirmation email during signup.
|
1137 |
-
* Fixed a CSS bug on the cancel membership page.
|
1138 |
-
|
1139 |
-
= 1.1.8 =
|
1140 |
-
* Fix for login/registration URL rerouting.
|
1141 |
-
* Added members list to admin bar menu.
|
1142 |
-
* Added warning/error when trying to checkout before the payment gateway is setup.
|
1143 |
-
* Fixed some error handling in the order class.
|
1144 |
-
* Fixed a bug that occurred when processing amounts less than $1.
|
1145 |
-
|
1146 |
-
= 1.1.7 =
|
1147 |
-
* Fixed bugs with http to https redirects and visa versa.
|
1148 |
-
* Fixed redirect bugs for sites installed in a subdomain.
|
1149 |
-
|
1150 |
-
= 1.1.6 =
|
1151 |
-
* Fixed MySQL bug showing up on some users add membership level page.
|
1152 |
-
|
1153 |
-
= 1.1.5 =
|
1154 |
-
* Required fix for PayPal Website Payments Pro processing. Please update.
|
1155 |
-
* Fixed bug with pagination on members list.
|
1156 |
-
* Fixed bugs with errors thrown by MemberOrder class.
|
1157 |
-
* Updated login/registration URL rerouting.
|
1158 |
-
|
1159 |
-
= 1.1.4 =
|
1160 |
-
* Custom Post Types default to allowing access
|
1161 |
-
* Fixed login_redirect code.
|
1162 |
-
* Added pmpro_login_redirect filter for when members login.
|
1163 |
-
|
1164 |
-
= 1.1.3 =
|
1165 |
-
* Getting ready for the WP plugin repository
|
1166 |
-
* License text update.
|
1167 |
-
|
1168 |
-
= 1.1.2 =
|
1169 |
-
* Added hooks to checkout page for customizing registration fields.
|
1170 |
-
* Fixed bug in pmpro_getLevelCost();
|
1171 |
-
* Another CCV/CVV fix for Authorize.net.
|
1172 |
-
* License text update.
|
1173 |
-
* Admin notices are loaded via Ajax now.
|
1174 |
-
|
1175 |
-
= 1.1.1 =
|
1176 |
-
* Added honeypot to signup page.
|
1177 |
-
* Updated pmpro_add_pages to use capabilities instead of user levels
|
1178 |
-
* Fixed checkboxes in admin screens.
|
1179 |
-
* Now checking that passwords match on signup.
|
1180 |
-
* Properly sending CCV/CVV codes to Authorize.net.
|
1181 |
-
|
1182 |
-
= 1.0 =
|
1183 |
-
* This is the launch version. No changes yet.
|
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.3.1
|
6 |
+
Stable tag: 1.8.6.3
|
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.6.3 =
|
119 |
+
* SECURITY: No longer showing email addresses in output when cron jobs are processed by non-admins. (Thanks, Daniel Bachhuber)
|
120 |
+
* BUG: Better handling of errors when validating PayPal IPN requests. Added pmpro_ipn_validate filter. PayPal users should read the release notes here: http://www.paidmembershipspro.com/2015/10/pmpro-update-1-8-6-3/
|
121 |
+
* BUG: Fixed bug where both the return and first order INS would change membership and update the order twice, leading to unwanted cancellations and emails. (Thanks, Steffen Dressler)
|
122 |
+
* BUG: No longer using the $pmpro_levels global in pages/levels.php.
|
123 |
+
|
124 |
+
= 1.8.6.2 =
|
125 |
+
* BUG: Stripe supports daily recurring subscriptions. Fixed issue where PMPro was still throwing a warning in some cases.
|
126 |
+
* BUG: Removed warnings in the membership stats report.
|
127 |
+
* CODE: Changed a couple instances of "since v2.0" to "since v1.8".
|
128 |
+
* ENHANCEMENT: Added a hook for pmpro_checkout_order_free that functions like pmpro_checkout_order but fires for the blank order created for free checkouts.
|
129 |
+
* ENHANCEMENT: Using site_url to get full URL to for the redirect_to value generated by !!referrer!! in the non-member/logged-out text strings in the advanced settings page. This fixes issues with using !!referrer!! on multisite setups. (Thanks, Keith Hall)
|
130 |
+
* ENHANCEMENT: Updated pmpro_post_classes to work on the $post_id passed by the filter instead of the global $post variable.
|
131 |
+
* ENHANCEMENT: Added pmpro_body_classes to add classes like pmpro-body-level-required, pmpro-body-level-1, and pmpro-body-has-access to the body tag based on the queried object.
|
132 |
+
* ENHANCEMENT: Reformatted the PMPro Reports dashboard.
|
133 |
+
* ENHANCEMENT: Now using separate invoice templates for email and print.
|
134 |
+
|
135 |
= 1.8.6.1 =
|
136 |
* SECURITY: Removed debug code from the PayPal IPN Handler script that was causing invalid IPN requests to process as if they were valid. (Thanks, Francois Harvey)
|
137 |
|
861 |
* Added hooks for changing the discount code page: pmpro_save_discount_code_level, pmpro_save_discount_code, pmpro_discount_code_after_settings, pmpro_discount_code_after_level_settings. Look them up in discountcodes.php to see how they work.
|
862 |
* Updated pmpro_send_html(), which filters emails, to use wpautop instead of nl2br. This will fix any extra double spacing you may have noticed in your emails.
|
863 |
* Added a stripslashes around the membership level confirmation text on the confirmation page. Extra slashes were breaking links, etc.
|
864 |
+
* Added membership level to subj
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scheduled/crons.php
CHANGED
@@ -35,7 +35,10 @@ function pmpro_cron_expire_memberships()
|
|
35 |
$euser = get_userdata($e->user_id);
|
36 |
$pmproemail->sendMembershipExpiredEmail($euser);
|
37 |
|
38 |
-
|
|
|
|
|
|
|
39 |
}
|
40 |
}
|
41 |
}
|
@@ -81,7 +84,10 @@ function pmpro_cron_expiration_warnings()
|
|
81 |
$euser = get_userdata($e->user_id);
|
82 |
$pmproemail->sendMembershipExpiringEmail($euser);
|
83 |
|
84 |
-
|
|
|
|
|
|
|
85 |
}
|
86 |
|
87 |
//update user meta so we don't email them again
|
@@ -154,7 +160,10 @@ function pmpro_cron_credit_card_expiring_warnings()
|
|
154 |
$pmproemail = new PMProEmail();
|
155 |
$pmproemail->sendCreditCardExpiringEmail($euser,$last_order);
|
156 |
|
157 |
-
|
|
|
|
|
|
|
158 |
}
|
159 |
|
160 |
//update user meta so we don't email them again
|
@@ -207,7 +216,10 @@ function pmpro_cron_trial_ending_warnings()
|
|
207 |
$euser = get_userdata($e->user_id);
|
208 |
$pmproemail->sendTrialEndingEmail($euser);
|
209 |
|
210 |
-
|
|
|
|
|
|
|
211 |
}
|
212 |
|
213 |
//update user meta so we don't email them again
|
35 |
$euser = get_userdata($e->user_id);
|
36 |
$pmproemail->sendMembershipExpiredEmail($euser);
|
37 |
|
38 |
+
if(current_user_can('manage_options'))
|
39 |
+
printf(__("Membership expired email sent to %s. ", "pmpro"), $euser->user_email);
|
40 |
+
else
|
41 |
+
echo ". ";
|
42 |
}
|
43 |
}
|
44 |
}
|
84 |
$euser = get_userdata($e->user_id);
|
85 |
$pmproemail->sendMembershipExpiringEmail($euser);
|
86 |
|
87 |
+
if(current_user_can('manage_options'))
|
88 |
+
printf(__("Membership expiring email sent to %s. ", "pmpro"), $euser->user_email);
|
89 |
+
else
|
90 |
+
echo ". ";
|
91 |
}
|
92 |
|
93 |
//update user meta so we don't email them again
|
160 |
$pmproemail = new PMProEmail();
|
161 |
$pmproemail->sendCreditCardExpiringEmail($euser,$last_order);
|
162 |
|
163 |
+
if(current_user_can('manage_options'))
|
164 |
+
printf(__("Credit card expiring email sent to %s. ", "pmpro"), $euser->user_email);
|
165 |
+
else
|
166 |
+
echo ". ";
|
167 |
}
|
168 |
|
169 |
//update user meta so we don't email them again
|
216 |
$euser = get_userdata($e->user_id);
|
217 |
$pmproemail->sendTrialEndingEmail($euser);
|
218 |
|
219 |
+
if(current_user_can('manage_options'))
|
220 |
+
printf(__("Trial ending email sent to %s. ", "pmpro"), $euser->user_email);
|
221 |
+
else
|
222 |
+
echo ". ";
|
223 |
}
|
224 |
|
225 |
//update user meta so we don't email them again
|
services/ipnhandler.php
CHANGED
@@ -372,40 +372,66 @@
|
|
372 |
else
|
373 |
$fp = wp_remote_post('https://www.paypal.com?' . $req, array("httpversion"=>"1.1", "Host"=>"www.paypal.com", "Connection"=>"Close"));
|
374 |
|
375 |
-
//
|
376 |
-
if(!empty($fp->errors))
|
377 |
-
{
|
378 |
-
ipnlog("ERROR");
|
379 |
-
ipnlog("Error Info: " . print_r($fp->errors, true) . "\n");
|
380 |
-
}
|
381 |
-
|
382 |
-
//log post vars and PayPal object
|
383 |
ipnlog(print_r($_POST, true));
|
384 |
-
|
|
|
|
|
385 |
|
386 |
if(empty($fp))
|
387 |
{
|
388 |
//HTTP ERROR
|
389 |
ipnlog("HTTP ERROR");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
390 |
}
|
391 |
else
|
392 |
{
|
393 |
ipnlog("FP!");
|
394 |
|
|
|
|
|
|
|
395 |
$res = wp_remote_retrieve_body($fp);
|
|
|
|
|
|
|
396 |
if(strcmp($res, "VERIFIED") == 0)
|
397 |
{
|
398 |
//all good so far
|
399 |
ipnlog("VERIFIED");
|
400 |
-
|
401 |
}
|
402 |
else
|
403 |
{
|
404 |
//log for manual investigation
|
405 |
ipnlog("INAVLID");
|
406 |
-
|
407 |
}
|
408 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
409 |
}
|
410 |
|
411 |
/*
|
372 |
else
|
373 |
$fp = wp_remote_post('https://www.paypal.com?' . $req, array("httpversion"=>"1.1", "Host"=>"www.paypal.com", "Connection"=>"Close"));
|
374 |
|
375 |
+
//log post vars
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
376 |
ipnlog(print_r($_POST, true));
|
377 |
+
|
378 |
+
//assume invalid
|
379 |
+
$r = false;
|
380 |
|
381 |
if(empty($fp))
|
382 |
{
|
383 |
//HTTP ERROR
|
384 |
ipnlog("HTTP ERROR");
|
385 |
+
|
386 |
+
$r = false;
|
387 |
+
}
|
388 |
+
elseif(!empty($fp->errors))
|
389 |
+
{
|
390 |
+
//error from PayPal
|
391 |
+
ipnlog("ERROR");
|
392 |
+
ipnlog("Error Info: " . print_r($fp->errors, true) . "\n");
|
393 |
+
|
394 |
+
//log fb object
|
395 |
+
ipnlog(print_r($fp, true));
|
396 |
+
|
397 |
+
$r = false;
|
398 |
}
|
399 |
else
|
400 |
{
|
401 |
ipnlog("FP!");
|
402 |
|
403 |
+
//log fb object
|
404 |
+
ipnlog(print_r($fp, true));
|
405 |
+
|
406 |
$res = wp_remote_retrieve_body($fp);
|
407 |
+
|
408 |
+
ipnlog(print_r($res, true));
|
409 |
+
|
410 |
if(strcmp($res, "VERIFIED") == 0)
|
411 |
{
|
412 |
//all good so far
|
413 |
ipnlog("VERIFIED");
|
414 |
+
$r = true;
|
415 |
}
|
416 |
else
|
417 |
{
|
418 |
//log for manual investigation
|
419 |
ipnlog("INAVLID");
|
420 |
+
$r = false;
|
421 |
}
|
422 |
}
|
423 |
+
|
424 |
+
/**
|
425 |
+
* Filter if an ipn request is valid or not.
|
426 |
+
*
|
427 |
+
* @since 1.8.6.3
|
428 |
+
*
|
429 |
+
* @param bool $r true or false if the request is valid
|
430 |
+
* @param mixed $fp remote post object from request to PayPal
|
431 |
+
*/
|
432 |
+
$r = apply_filters('pmpro_ipn_validate', $r, $fp);
|
433 |
+
|
434 |
+
return $r;
|
435 |
}
|
436 |
|
437 |
/*
|
services/twocheckout-ins.php
CHANGED
@@ -21,7 +21,7 @@
|
|
21 |
$logstr = ""; //will put debug info here and write to inslog.txt
|
22 |
|
23 |
//validate?
|
24 |
-
if(
|
25 |
|
26 |
inslog("(!!FAILED VALIDATION!!)");
|
27 |
|
@@ -55,12 +55,15 @@
|
|
55 |
inslog("NO MESSAGE: ORDER: " . var_export($morder, true) . "\n---\n");
|
56 |
|
57 |
//update membership
|
58 |
-
if (
|
|
|
|
|
|
|
59 |
inslog( "Checkout processed (" . $morder->code . ") success!" );
|
60 |
}
|
61 |
else {
|
62 |
inslog( "ERROR: Couldn't change level for order (" . $morder->code . ")." );
|
63 |
-
}
|
64 |
|
65 |
pmpro_twocheckoutExit(pmpro_url("confirmation", "?level=" . $morder->membership_level->id));
|
66 |
}
|
@@ -75,12 +78,15 @@
|
|
75 |
inslog("ORDER_CREATED: ORDER: " . var_export($morder, true) . "\n---\n");
|
76 |
|
77 |
//update membership
|
78 |
-
if (
|
|
|
|
|
|
|
79 |
inslog( "Checkout processed (" . $morder->code . ") success!" );
|
80 |
}
|
81 |
else {
|
82 |
inslog( "ERROR: Couldn't change level for order (" . $morder->code . ")." );
|
83 |
-
}
|
84 |
|
85 |
pmpro_twocheckoutExit(pmpro_url("confirmation", "?level=" . $morder->membership_level->id));
|
86 |
}
|
@@ -227,6 +233,23 @@
|
|
227 |
else
|
228 |
$check = Twocheckout_Notification::check( $params, pmpro_getOption( 'twocheckout_secretword' ), 'array' );
|
229 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
230 |
return $check['response_code'] === 'Success';
|
231 |
}
|
232 |
|
21 |
$logstr = ""; //will put debug info here and write to inslog.txt
|
22 |
|
23 |
//validate?
|
24 |
+
if( ! pmpro_twocheckoutValidate() ) {
|
25 |
|
26 |
inslog("(!!FAILED VALIDATION!!)");
|
27 |
|
55 |
inslog("NO MESSAGE: ORDER: " . var_export($morder, true) . "\n---\n");
|
56 |
|
57 |
//update membership
|
58 |
+
if( ! empty ( $morder ) && ! empty ( $morder->status ) && $morder->status === 'success' ) {
|
59 |
+
inslog( "Checkout was already processed (" . $morder->code . "). Ignoring this request." );
|
60 |
+
}
|
61 |
+
elseif (pmpro_insChangeMembershipLevel( $_REQUEST['order_number'], $morder ) ) {
|
62 |
inslog( "Checkout processed (" . $morder->code . ") success!" );
|
63 |
}
|
64 |
else {
|
65 |
inslog( "ERROR: Couldn't change level for order (" . $morder->code . ")." );
|
66 |
+
}
|
67 |
|
68 |
pmpro_twocheckoutExit(pmpro_url("confirmation", "?level=" . $morder->membership_level->id));
|
69 |
}
|
78 |
inslog("ORDER_CREATED: ORDER: " . var_export($morder, true) . "\n---\n");
|
79 |
|
80 |
//update membership
|
81 |
+
if( ! empty ( $morder ) && ! empty ( $morder->status ) && $morder->status === 'success' ) {
|
82 |
+
inslog( "Checkout was already processed (" . $morder->code . "). Ignoring this request." );
|
83 |
+
}
|
84 |
+
elseif (pmpro_insChangeMembershipLevel( $txn_id, $morder ) ) {
|
85 |
inslog( "Checkout processed (" . $morder->code . ") success!" );
|
86 |
}
|
87 |
else {
|
88 |
inslog( "ERROR: Couldn't change level for order (" . $morder->code . ")." );
|
89 |
+
}
|
90 |
|
91 |
pmpro_twocheckoutExit(pmpro_url("confirmation", "?level=" . $morder->membership_level->id));
|
92 |
}
|
233 |
else
|
234 |
$check = Twocheckout_Notification::check( $params, pmpro_getOption( 'twocheckout_secretword' ), 'array' );
|
235 |
|
236 |
+
if( empty ( $check ) )
|
237 |
+
$r = false; //HTTP failure
|
238 |
+
else if( empty ( $check['response_code'] ) )
|
239 |
+
$r = false; //Invalid response
|
240 |
+
else
|
241 |
+
$r = $check['response_code'];
|
242 |
+
|
243 |
+
/**
|
244 |
+
* Filter if an twocheckout request is valid or not.
|
245 |
+
*
|
246 |
+
* @since 1.8.6.3
|
247 |
+
*
|
248 |
+
* @param bool $r true or false if the request is valid
|
249 |
+
* @param mixed $check remote post object from request to Twocheckout
|
250 |
+
*/
|
251 |
+
$r = apply_filters('pmpro_twocheckout_validate', $r, $check);
|
252 |
+
|
253 |
return $check['response_code'] === 'Success';
|
254 |
}
|
255 |
|
shortcodes/pmpro_account.php
CHANGED
@@ -56,8 +56,11 @@ function pmpro_shortcode_account($atts, $content=null, $code="")
|
|
56 |
<?php echo $current_user->membership_level->name?>
|
57 |
<div class="pmpro_actionlinks">
|
58 |
<?php do_action("pmpro_member_action_links_before"); ?>
|
59 |
-
<a href="<?php echo pmpro_url("checkout", "?level=" . $current_user->membership_level->id, "https")?>"><?php _e("Renew", "pmpro");?></a>
|
60 |
|
|
|
|
|
|
|
|
|
61 |
<?php if((isset($ssorder->status) && $ssorder->status == "success") && (isset($ssorder->gateway) && in_array($ssorder->gateway, array("authorizenet", "paypal", "stripe", "braintree", "payflow", "cybersource")))) { ?>
|
62 |
<a href="<?php echo pmpro_url("billing", "", "https")?>"><?php _e("Update Billing Info", "pmpro"); ?></a>
|
63 |
<?php } ?>
|
56 |
<?php echo $current_user->membership_level->name?>
|
57 |
<div class="pmpro_actionlinks">
|
58 |
<?php do_action("pmpro_member_action_links_before"); ?>
|
|
|
59 |
|
60 |
+
<?php if( pmpro_isLevelExpiringSoon( $current_user->membership_level) ) { ?>
|
61 |
+
<a href="<?php echo pmpro_url("checkout", "?level=" . $current_user->membership_level->id, "https")?>"><?php _e("Renew", "pmpro");?></a>
|
62 |
+
<?php } ?>
|
63 |
+
|
64 |
<?php if((isset($ssorder->status) && $ssorder->status == "success") && (isset($ssorder->gateway) && in_array($ssorder->gateway, array("authorizenet", "paypal", "stripe", "braintree", "payflow", "cybersource")))) { ?>
|
65 |
<a href="<?php echo pmpro_url("billing", "", "https")?>"><?php _e("Update Billing Info", "pmpro"); ?></a>
|
66 |
<?php } ?>
|