Diff: STRATO-apps/wordpress_03/app/wp-content/plugins/paid-memberships-pro/js/pmpro-confirmation.js
Keine Baseline-Datei – Diff nur gegen leer.
1
-
1
+
jQuery( document ).ready( function( $ ) {
2
+
// Unbind the default click handler
3
+
$('.pmpro_btn-print').removeAttr('onclick');
4
+
5
+
// Bind a new click handler
6
+
$('.pmpro_btn-print').click(function() {
7
+
// Find the closest parent div with class "pmpro" and the previous sibling div with class "pmpro"
8
+
var membershipConfirmationText = $(this).closest('.pmpro').prev('.pmpro');
9
+
10
+
// Toggle the "pmpro_hide_print" class on the first section inside the previousPmproDiv
11
+
membershipConfirmationText.find('section').first().toggleClass('pmpro_hide_print');
12
+
13
+
// Print the page
14
+
window.print();
15
+
16
+
// Toggle the "pmpro_hide_print" class back to show the previous elements
17
+
membershipConfirmationText.find('section').first().toggleClass('pmpro_hide_print');
18
+
19
+
return false;
20
+
});
21
+
22
+
// Function to poll the server to see if the order has been completed.
23
+
// If so, refresh so the user can see the user can see their completed checkout.
24
+
function startPolling() {
25
+
var pollInterval = setInterval(function() {
26
+
jQuery.noConflict().ajax({
27
+
url: pmpro.restUrl + 'pmpro/v1/order',
28
+
beforeSend: function(xhr) {
29
+
xhr.setRequestHeader('X-WP-Nonce', pmpro.nonce);
30
+
},
31
+
dataType: 'json',
32
+
data: {
33
+
'code': pmpro.code
34
+
},
35
+
success: function(response) {
36
+
if (response.status == 'success') {
37
+
// Order is complete.
38
+
clearInterval(pollInterval);
39
+
window.location.reload();
40
+
}
41
+
}
42
+
});
43
+
}, 5000); // Poll every 5 seconds.
44
+
}
45
+
46
+
// Initial check to see if the order is pending or in a token state so we can trigger the polling.
47
+
jQuery.noConflict().ajax({
48
+
url: pmpro.restUrl + 'pmpro/v1/order',
49
+
beforeSend: function ( xhr ) {
50
+
xhr.setRequestHeader( 'X-WP-Nonce', pmpro.nonce );
51
+
},
52
+
dataType: 'json',
53
+
data: {
54
+
'code': pmpro.code
55
+
},
56
+
url: pmpro.restUrl + 'pmpro/v1/order',
57
+
beforeSend: function(xhr) {
58
+
xhr.setRequestHeader('X-WP-Nonce', pmpro.nonce);
59
+
},
60
+
dataType: 'json',
61
+
data: {
62
+
'code': pmpro.code
63
+
},
64
+
success: function(response) {
65
+
if (response.status == 'pending' || response.status == 'token') {
66
+
// Order is not complete, start polling.
67
+
startPolling();
68
+
}
69
+
}
70
+
});
71
+
72
+
});