@@ -97,10 +97,10 @@ |
||
97 | 97 | |
98 | 98 | //Single Form settings varies compared to the Global default settings |
99 | 99 | if ( ! empty( $form_default ) && |
100 | - $form_id !== null && |
|
101 | - $default !== $form_default && |
|
102 | - $form_default !== 'global' && |
|
103 | - give_is_gateway_active( $form_default ) |
|
100 | + $form_id !== null && |
|
101 | + $default !== $form_default && |
|
102 | + $form_default !== 'global' && |
|
103 | + give_is_gateway_active( $form_default ) |
|
104 | 104 | ) { |
105 | 105 | $default = $form_default; |
106 | 106 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -24,17 +24,17 @@ discard block |
||
24 | 24 | // Default, built-in gateways |
25 | 25 | $gateways = array( |
26 | 26 | 'paypal' => array( |
27 | - 'admin_label' => __( 'PayPal Standard', 'give' ), |
|
28 | - 'checkout_label' => __( 'PayPal', 'give' ), |
|
29 | - 'supports' => array( 'buy_now' ) |
|
27 | + 'admin_label' => __('PayPal Standard', 'give'), |
|
28 | + 'checkout_label' => __('PayPal', 'give'), |
|
29 | + 'supports' => array('buy_now') |
|
30 | 30 | ), |
31 | 31 | 'manual' => array( |
32 | - 'admin_label' => __( 'Test Payment', 'give' ), |
|
33 | - 'checkout_label' => __( 'Test Payment', 'give' ) |
|
32 | + 'admin_label' => __('Test Payment', 'give'), |
|
33 | + 'checkout_label' => __('Test Payment', 'give') |
|
34 | 34 | ), |
35 | 35 | ); |
36 | 36 | |
37 | - return apply_filters( 'give_payment_gateways', $gateways ); |
|
37 | + return apply_filters('give_payment_gateways', $gateways); |
|
38 | 38 | |
39 | 39 | } |
40 | 40 | |
@@ -48,17 +48,17 @@ discard block |
||
48 | 48 | global $give_options; |
49 | 49 | |
50 | 50 | $gateways = give_get_payment_gateways(); |
51 | - $enabled = isset( $give_options['gateways'] ) ? $give_options['gateways'] : false; |
|
51 | + $enabled = isset($give_options['gateways']) ? $give_options['gateways'] : false; |
|
52 | 52 | |
53 | 53 | $gateway_list = array(); |
54 | 54 | |
55 | - foreach ( $gateways as $key => $gateway ) { |
|
56 | - if ( isset( $enabled[ $key ] ) && $enabled[ $key ] == 1 ) { |
|
57 | - $gateway_list[ $key ] = $gateway; |
|
55 | + foreach ($gateways as $key => $gateway) { |
|
56 | + if (isset($enabled[$key]) && $enabled[$key] == 1) { |
|
57 | + $gateway_list[$key] = $gateway; |
|
58 | 58 | } |
59 | 59 | } |
60 | 60 | |
61 | - return apply_filters( 'give_enabled_payment_gateways', $gateway_list ); |
|
61 | + return apply_filters('give_enabled_payment_gateways', $gateway_list); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -70,12 +70,12 @@ discard block |
||
70 | 70 | * |
71 | 71 | * @return boolean true if enabled, false otherwise |
72 | 72 | */ |
73 | -function give_is_gateway_active( $gateway ) { |
|
73 | +function give_is_gateway_active($gateway) { |
|
74 | 74 | $gateways = give_get_enabled_payment_gateways(); |
75 | 75 | |
76 | - $ret = array_key_exists( $gateway, $gateways ); |
|
76 | + $ret = array_key_exists($gateway, $gateways); |
|
77 | 77 | |
78 | - return apply_filters( 'give_is_gateway_active', $ret, $gateway, $gateways ); |
|
78 | + return apply_filters('give_is_gateway_active', $ret, $gateway, $gateways); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
@@ -88,24 +88,24 @@ discard block |
||
88 | 88 | * |
89 | 89 | * @return string Gateway ID |
90 | 90 | */ |
91 | -function give_get_default_gateway( $form_id ) { |
|
91 | +function give_get_default_gateway($form_id) { |
|
92 | 92 | |
93 | 93 | global $give_options; |
94 | 94 | |
95 | - $default = isset( $give_options['default_gateway'] ) && give_is_gateway_active( $give_options['default_gateway'] ) ? $give_options['default_gateway'] : 'paypal'; |
|
96 | - $form_default = get_post_meta( $form_id, '_give_default_gateway', true ); |
|
95 | + $default = isset($give_options['default_gateway']) && give_is_gateway_active($give_options['default_gateway']) ? $give_options['default_gateway'] : 'paypal'; |
|
96 | + $form_default = get_post_meta($form_id, '_give_default_gateway', true); |
|
97 | 97 | |
98 | 98 | //Single Form settings varies compared to the Global default settings |
99 | - if ( ! empty( $form_default ) && |
|
99 | + if ( ! empty($form_default) && |
|
100 | 100 | $form_id !== null && |
101 | 101 | $default !== $form_default && |
102 | 102 | $form_default !== 'global' && |
103 | - give_is_gateway_active( $form_default ) |
|
103 | + give_is_gateway_active($form_default) |
|
104 | 104 | ) { |
105 | 105 | $default = $form_default; |
106 | 106 | } |
107 | 107 | |
108 | - return apply_filters( 'give_default_gateway', $default ); |
|
108 | + return apply_filters('give_default_gateway', $default); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
@@ -117,18 +117,18 @@ discard block |
||
117 | 117 | * |
118 | 118 | * @return string Gateway admin label |
119 | 119 | */ |
120 | -function give_get_gateway_admin_label( $gateway ) { |
|
120 | +function give_get_gateway_admin_label($gateway) { |
|
121 | 121 | $gateways = give_get_enabled_payment_gateways(); |
122 | - $label = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['admin_label'] : $gateway; |
|
123 | - $payment = isset( $_GET['id'] ) ? absint( $_GET['id'] ) : false; |
|
122 | + $label = isset($gateways[$gateway]) ? $gateways[$gateway]['admin_label'] : $gateway; |
|
123 | + $payment = isset($_GET['id']) ? absint($_GET['id']) : false; |
|
124 | 124 | |
125 | - if ( $gateway == 'manual' && $payment ) { |
|
126 | - if ( give_get_payment_amount( $payment ) == 0 ) { |
|
127 | - $label = __( 'Test Donation', 'give' ); |
|
125 | + if ($gateway == 'manual' && $payment) { |
|
126 | + if (give_get_payment_amount($payment) == 0) { |
|
127 | + $label = __('Test Donation', 'give'); |
|
128 | 128 | } |
129 | 129 | } |
130 | 130 | |
131 | - return apply_filters( 'give_gateway_admin_label', $label, $gateway ); |
|
131 | + return apply_filters('give_gateway_admin_label', $label, $gateway); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | /** |
@@ -140,15 +140,15 @@ discard block |
||
140 | 140 | * |
141 | 141 | * @return string Checkout label for the gateway |
142 | 142 | */ |
143 | -function give_get_gateway_checkout_label( $gateway ) { |
|
143 | +function give_get_gateway_checkout_label($gateway) { |
|
144 | 144 | $gateways = give_get_enabled_payment_gateways(); |
145 | - $label = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['checkout_label'] : $gateway; |
|
145 | + $label = isset($gateways[$gateway]) ? $gateways[$gateway]['checkout_label'] : $gateway; |
|
146 | 146 | |
147 | - if ( $gateway == 'manual' ) { |
|
148 | - $label = __( 'Test Donation', 'give' ); |
|
147 | + if ($gateway == 'manual') { |
|
148 | + $label = __('Test Donation', 'give'); |
|
149 | 149 | } |
150 | 150 | |
151 | - return apply_filters( 'give_gateway_checkout_label', $label, $gateway ); |
|
151 | + return apply_filters('give_gateway_checkout_label', $label, $gateway); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | /** |
@@ -160,11 +160,11 @@ discard block |
||
160 | 160 | * |
161 | 161 | * @return array Options the gateway supports |
162 | 162 | */ |
163 | -function give_get_gateway_supports( $gateway ) { |
|
163 | +function give_get_gateway_supports($gateway) { |
|
164 | 164 | $gateways = give_get_enabled_payment_gateways(); |
165 | - $supports = isset( $gateways[ $gateway ]['supports'] ) ? $gateways[ $gateway ]['supports'] : array(); |
|
165 | + $supports = isset($gateways[$gateway]['supports']) ? $gateways[$gateway]['supports'] : array(); |
|
166 | 166 | |
167 | - return apply_filters( 'give_gateway_supports', $supports, $gateway ); |
|
167 | + return apply_filters('give_gateway_supports', $supports, $gateway); |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | /** |
@@ -176,11 +176,11 @@ discard block |
||
176 | 176 | * |
177 | 177 | * @return bool |
178 | 178 | */ |
179 | -function give_gateway_supports_buy_now( $gateway ) { |
|
180 | - $supports = give_get_gateway_supports( $gateway ); |
|
181 | - $ret = in_array( 'buy_now', $supports ); |
|
179 | +function give_gateway_supports_buy_now($gateway) { |
|
180 | + $supports = give_get_gateway_supports($gateway); |
|
181 | + $ret = in_array('buy_now', $supports); |
|
182 | 182 | |
183 | - return apply_filters( 'give_gateway_supports_buy_now', $ret, $gateway ); |
|
183 | + return apply_filters('give_gateway_supports_buy_now', $ret, $gateway); |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | /** |
@@ -193,16 +193,16 @@ discard block |
||
193 | 193 | $gateways = give_get_enabled_payment_gateways(); |
194 | 194 | $ret = false; |
195 | 195 | |
196 | - if ( $gateways ) { |
|
197 | - foreach ( $gateways as $gateway_id => $gateway ) { |
|
198 | - if ( give_gateway_supports_buy_now( $gateway_id ) ) { |
|
196 | + if ($gateways) { |
|
197 | + foreach ($gateways as $gateway_id => $gateway) { |
|
198 | + if (give_gateway_supports_buy_now($gateway_id)) { |
|
199 | 199 | $ret = true; |
200 | 200 | break; |
201 | 201 | } |
202 | 202 | } |
203 | 203 | } |
204 | 204 | |
205 | - return apply_filters( 'give_give_supports_buy_now', $ret ); |
|
205 | + return apply_filters('give_give_supports_buy_now', $ret); |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | /** |
@@ -215,12 +215,12 @@ discard block |
||
215 | 215 | * |
216 | 216 | * @return void |
217 | 217 | */ |
218 | -function give_send_to_gateway( $gateway, $payment_data ) { |
|
218 | +function give_send_to_gateway($gateway, $payment_data) { |
|
219 | 219 | |
220 | - $payment_data['gateway_nonce'] = wp_create_nonce( 'give-gateway' ); |
|
220 | + $payment_data['gateway_nonce'] = wp_create_nonce('give-gateway'); |
|
221 | 221 | |
222 | 222 | // $gateway must match the ID used when registering the gateway |
223 | - do_action( 'give_gateway_' . $gateway, $payment_data ); |
|
223 | + do_action('give_gateway_'.$gateway, $payment_data); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | |
@@ -237,32 +237,32 @@ discard block |
||
237 | 237 | * |
238 | 238 | * @return string $enabled_gateway The slug of the gateway |
239 | 239 | */ |
240 | -function give_get_chosen_gateway( $form_id ) { |
|
240 | +function give_get_chosen_gateway($form_id) { |
|
241 | 241 | $gateways = give_get_enabled_payment_gateways(); |
242 | - $request_form_id = isset( $_REQUEST['give_form_id'] ) ? $_REQUEST['give_form_id'] : 0; |
|
243 | - if ( empty( $request_form_id ) ) { |
|
244 | - $request_form_id = isset( $_REQUEST['form-id'] ) ? $_REQUEST['form-id'] : 0; |
|
242 | + $request_form_id = isset($_REQUEST['give_form_id']) ? $_REQUEST['give_form_id'] : 0; |
|
243 | + if (empty($request_form_id)) { |
|
244 | + $request_form_id = isset($_REQUEST['form-id']) ? $_REQUEST['form-id'] : 0; |
|
245 | 245 | } |
246 | - $chosen = give_get_default_gateway( $form_id ); |
|
246 | + $chosen = give_get_default_gateway($form_id); |
|
247 | 247 | $enabled_gateway = ''; |
248 | 248 | |
249 | 249 | //Take into account request Form ID args |
250 | - if ( ! empty( $request_form_id ) && $form_id == $request_form_id ) { |
|
250 | + if ( ! empty($request_form_id) && $form_id == $request_form_id) { |
|
251 | 251 | $chosen = $_REQUEST['payment-mode']; |
252 | 252 | } |
253 | 253 | |
254 | - if ( $chosen ) { |
|
255 | - $enabled_gateway = urldecode( $chosen ); |
|
256 | - } else if ( count( $gateways ) >= 1 && ! $chosen ) { |
|
257 | - foreach ( $gateways as $gateway_id => $gateway ): |
|
254 | + if ($chosen) { |
|
255 | + $enabled_gateway = urldecode($chosen); |
|
256 | + } else if (count($gateways) >= 1 && ! $chosen) { |
|
257 | + foreach ($gateways as $gateway_id => $gateway): |
|
258 | 258 | $enabled_gateway = $gateway_id; |
259 | 259 | endforeach; |
260 | 260 | } else { |
261 | - $enabled_gateway = give_get_default_gateway( $form_id ); |
|
261 | + $enabled_gateway = give_get_default_gateway($form_id); |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | |
265 | - return apply_filters( 'give_chosen_gateway', $enabled_gateway ); |
|
265 | + return apply_filters('give_chosen_gateway', $enabled_gateway); |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | /** |
@@ -279,8 +279,8 @@ discard block |
||
279 | 279 | * |
280 | 280 | * @return int ID of the new log entry |
281 | 281 | */ |
282 | -function give_record_gateway_error( $title = '', $message = '', $parent = 0 ) { |
|
283 | - return give_record_log( $title, $message, $parent, 'gateway_error' ); |
|
282 | +function give_record_gateway_error($title = '', $message = '', $parent = 0) { |
|
283 | + return give_record_log($title, $message, $parent, 'gateway_error'); |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | /** |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | * |
294 | 294 | * @return int |
295 | 295 | */ |
296 | -function give_count_sales_by_gateway( $gateway_id = 'paypal', $status = 'publish' ) { |
|
296 | +function give_count_sales_by_gateway($gateway_id = 'paypal', $status = 'publish') { |
|
297 | 297 | |
298 | 298 | $ret = 0; |
299 | 299 | $args = array( |
@@ -305,9 +305,9 @@ discard block |
||
305 | 305 | 'fields' => 'ids' |
306 | 306 | ); |
307 | 307 | |
308 | - $payments = new WP_Query( $args ); |
|
308 | + $payments = new WP_Query($args); |
|
309 | 309 | |
310 | - if ( $payments ) { |
|
310 | + if ($payments) { |
|
311 | 311 | $ret = $payments->post_count; |
312 | 312 | } |
313 | 313 |
@@ -1,13 +1,13 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Manual Gateway |
|
4 | - * |
|
5 | - * @package Give |
|
6 | - * @subpackage Gateways |
|
7 | - * @copyright Copyright (c) 2015, WordImpress |
|
8 | - * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
|
9 | - * @since 1.0 |
|
10 | - */ |
|
3 | + * Manual Gateway |
|
4 | + * |
|
5 | + * @package Give |
|
6 | + * @subpackage Gateways |
|
7 | + * @copyright Copyright (c) 2015, WordImpress |
|
8 | + * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
|
9 | + * @since 1.0 |
|
10 | + */ |
|
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | 13 | if ( ! defined( 'ABSPATH' ) ) { |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * @since 1.0 |
21 | 21 | * @return void |
22 | 22 | */ |
23 | -add_action( 'give_manual_cc_form', '__return_false' ); |
|
23 | +add_action('give_manual_cc_form', '__return_false'); |
|
24 | 24 | |
25 | 25 | /** |
26 | 26 | * Processes the purchase data and uses the Manual Payment gateway to record |
@@ -33,12 +33,12 @@ discard block |
||
33 | 33 | * |
34 | 34 | * @return void |
35 | 35 | */ |
36 | -function give_manual_payment( $purchase_data ) { |
|
36 | +function give_manual_payment($purchase_data) { |
|
37 | 37 | |
38 | 38 | global $give_options; |
39 | 39 | |
40 | - if ( ! wp_verify_nonce( $purchase_data['gateway_nonce'], 'give-gateway' ) ) { |
|
41 | - wp_die( __( 'Nonce verification has failed', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
40 | + if ( ! wp_verify_nonce($purchase_data['gateway_nonce'], 'give-gateway')) { |
|
41 | + wp_die(__('Nonce verification has failed', 'give'), __('Error', 'give'), array('response' => 403)); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /* |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | $payment_data = array( |
48 | 48 | 'price' => $purchase_data['price'], |
49 | 49 | 'give_form_title' => $purchase_data['post_data']['give-form-title'], |
50 | - 'give_form_id' => intval( $purchase_data['post_data']['give-form-id'] ), |
|
50 | + 'give_form_id' => intval($purchase_data['post_data']['give-form-id']), |
|
51 | 51 | 'date' => $purchase_data['date'], |
52 | 52 | 'user_email' => $purchase_data['user_email'], |
53 | 53 | 'purchase_key' => $purchase_data['purchase_key'], |
@@ -56,16 +56,16 @@ discard block |
||
56 | 56 | 'status' => 'pending' |
57 | 57 | ); |
58 | 58 | // Record the pending payment |
59 | - $payment = give_insert_payment( $payment_data ); |
|
59 | + $payment = give_insert_payment($payment_data); |
|
60 | 60 | |
61 | - if ( $payment ) { |
|
62 | - give_update_payment_status( $payment, 'publish' ); |
|
61 | + if ($payment) { |
|
62 | + give_update_payment_status($payment, 'publish'); |
|
63 | 63 | give_send_to_success_page(); |
64 | 64 | } else { |
65 | - give_record_gateway_error( __( 'Payment Error', 'give' ), sprintf( __( 'Payment creation failed while processing a manual (free or test) purchase. Payment data: %s', 'give' ), json_encode( $payment_data ) ), $payment ); |
|
65 | + give_record_gateway_error(__('Payment Error', 'give'), sprintf(__('Payment creation failed while processing a manual (free or test) purchase. Payment data: %s', 'give'), json_encode($payment_data)), $payment); |
|
66 | 66 | // If errors are present, send the user back to the purchase page so they can be corrected |
67 | - give_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['give-gateway'] ); |
|
67 | + give_send_back_to_checkout('?payment-mode='.$purchase_data['post_data']['give-gateway']); |
|
68 | 68 | } |
69 | 69 | } |
70 | 70 | |
71 | -add_action( 'give_gateway_manual', 'give_manual_payment' ); |
|
71 | +add_action('give_gateway_manual', 'give_manual_payment'); |
@@ -18,17 +18,17 @@ discard block |
||
18 | 18 | * |
19 | 19 | * @return array |
20 | 20 | */ |
21 | -function give_offline_register_gateway( $gateways ) { |
|
21 | +function give_offline_register_gateway($gateways) { |
|
22 | 22 | // Format: ID => Name |
23 | 23 | $gateways['offline'] = array( |
24 | 24 | 'admin_label' => 'Offline Donation', |
25 | - 'checkout_label' => __( 'Offline Donation', 'give' ) |
|
25 | + 'checkout_label' => __('Offline Donation', 'give') |
|
26 | 26 | ); |
27 | 27 | |
28 | 28 | return $gateways; |
29 | 29 | } |
30 | 30 | |
31 | -add_filter( 'give_payment_gateways', 'give_offline_register_gateway', 1 ); |
|
31 | +add_filter('give_payment_gateways', 'give_offline_register_gateway', 1); |
|
32 | 32 | |
33 | 33 | |
34 | 34 | /** |
@@ -39,10 +39,10 @@ discard block |
||
39 | 39 | * @return void |
40 | 40 | */ |
41 | 41 | function give_offline_disable_abandoned_orders() { |
42 | - remove_action( 'give_weekly_scheduled_events', 'give_mark_abandoned_orders' ); |
|
42 | + remove_action('give_weekly_scheduled_events', 'give_mark_abandoned_orders'); |
|
43 | 43 | } |
44 | 44 | |
45 | -add_action( 'plugins_loaded', 'give_offline_disable_abandoned_orders' ); |
|
45 | +add_action('plugins_loaded', 'give_offline_disable_abandoned_orders'); |
|
46 | 46 | |
47 | 47 | |
48 | 48 | /** |
@@ -54,48 +54,48 @@ discard block |
||
54 | 54 | * |
55 | 55 | * @return void |
56 | 56 | */ |
57 | -function give_offline_payment_cc_form( $form_id ) { |
|
57 | +function give_offline_payment_cc_form($form_id) { |
|
58 | 58 | |
59 | - $post_offline_customization_option = get_post_meta( $form_id, '_give_customize_offline_donations', true ); |
|
60 | - $post_offline_instructions = get_post_meta( $form_id, '_give_offline_checkout_notes', true ); |
|
61 | - $global_offline_instruction = give_get_option( 'global_offline_donation_content' ); |
|
59 | + $post_offline_customization_option = get_post_meta($form_id, '_give_customize_offline_donations', true); |
|
60 | + $post_offline_instructions = get_post_meta($form_id, '_give_offline_checkout_notes', true); |
|
61 | + $global_offline_instruction = give_get_option('global_offline_donation_content'); |
|
62 | 62 | $offline_instructions = $global_offline_instruction; |
63 | 63 | |
64 | - if ( $post_offline_customization_option == 'yes' ) { |
|
64 | + if ($post_offline_customization_option == 'yes') { |
|
65 | 65 | $offline_instructions = $post_offline_instructions; |
66 | 66 | } |
67 | 67 | |
68 | 68 | |
69 | 69 | ob_start(); ?> |
70 | - <?php do_action( 'give_before_offline_info_fields', $form_id ); ?> |
|
70 | + <?php do_action('give_before_offline_info_fields', $form_id); ?> |
|
71 | 71 | <fieldset id="give_offline_payment_info"> |
72 | 72 | <?php |
73 | - $settings_url = admin_url( 'post.php?post=' . $form_id . '&action=edit&message=1' ); |
|
74 | - $offline_instructions = ! empty( $offline_instructions ) ? $offline_instructions : sprintf( __( 'Please enter offline donation instructions in the %s.', 'give' ), '<a href="' . $settings_url . '">' . __( 'this form\'s settings', 'give' ) . '</a>' ); |
|
75 | - echo wpautop( stripslashes( $offline_instructions ) ); |
|
73 | + $settings_url = admin_url('post.php?post='.$form_id.'&action=edit&message=1'); |
|
74 | + $offline_instructions = ! empty($offline_instructions) ? $offline_instructions : sprintf(__('Please enter offline donation instructions in the %s.', 'give'), '<a href="'.$settings_url.'">'.__('this form\'s settings', 'give').'</a>'); |
|
75 | + echo wpautop(stripslashes($offline_instructions)); |
|
76 | 76 | ?> |
77 | 77 | </fieldset> |
78 | - <?php do_action( 'give_after_offline_info_fields', $form_id ); ?> |
|
78 | + <?php do_action('give_after_offline_info_fields', $form_id); ?> |
|
79 | 79 | <?php |
80 | 80 | echo ob_get_clean(); |
81 | 81 | } |
82 | 82 | |
83 | -add_action( 'give_offline_cc_form', 'give_offline_payment_cc_form' ); |
|
83 | +add_action('give_offline_cc_form', 'give_offline_payment_cc_form'); |
|
84 | 84 | |
85 | 85 | |
86 | 86 | |
87 | -function give_offline_billing_fields($form_id){ |
|
87 | +function give_offline_billing_fields($form_id) { |
|
88 | 88 | //Enable Default CC fields (billing info) |
89 | - $post_offline_cc_fields = get_post_meta( $form_id, '_give_offline_donation_enable_billing_fields_single', true ); |
|
90 | - $global_offline_cc_fields = give_get_option( 'give_offline_donation_enable_billing_fields' ); |
|
89 | + $post_offline_cc_fields = get_post_meta($form_id, '_give_offline_donation_enable_billing_fields_single', true); |
|
90 | + $global_offline_cc_fields = give_get_option('give_offline_donation_enable_billing_fields'); |
|
91 | 91 | |
92 | 92 | |
93 | - if ( $global_offline_cc_fields == 'on' || $post_offline_cc_fields == 'on' ) { |
|
94 | - give_default_cc_address_fields( $form_id ); |
|
93 | + if ($global_offline_cc_fields == 'on' || $post_offline_cc_fields == 'on') { |
|
94 | + give_default_cc_address_fields($form_id); |
|
95 | 95 | } |
96 | 96 | } |
97 | 97 | |
98 | -add_action('give_before_offline_info_fields', 'give_offline_billing_fields', 10, 1 ); |
|
98 | +add_action('give_before_offline_info_fields', 'give_offline_billing_fields', 10, 1); |
|
99 | 99 | |
100 | 100 | /** |
101 | 101 | * Process the payment |
@@ -103,15 +103,15 @@ discard block |
||
103 | 103 | * @since 1.0 |
104 | 104 | * @return void |
105 | 105 | */ |
106 | -function give_offline_process_payment( $purchase_data ) { |
|
106 | +function give_offline_process_payment($purchase_data) { |
|
107 | 107 | |
108 | - $purchase_summary = give_get_purchase_summary( $purchase_data ); |
|
108 | + $purchase_summary = give_get_purchase_summary($purchase_data); |
|
109 | 109 | |
110 | 110 | // setup the payment details |
111 | 111 | $payment_data = array( |
112 | 112 | 'price' => $purchase_data['price'], |
113 | 113 | 'give_form_title' => $purchase_data['post_data']['give-form-title'], |
114 | - 'give_form_id' => intval( $purchase_data['post_data']['give-form-id'] ), |
|
114 | + 'give_form_id' => intval($purchase_data['post_data']['give-form-id']), |
|
115 | 115 | 'date' => $purchase_data['date'], |
116 | 116 | 'user_email' => $purchase_data['user_email'], |
117 | 117 | 'purchase_key' => $purchase_data['purchase_key'], |
@@ -123,20 +123,20 @@ discard block |
||
123 | 123 | |
124 | 124 | |
125 | 125 | // record the pending payment |
126 | - $payment = give_insert_payment( $payment_data ); |
|
126 | + $payment = give_insert_payment($payment_data); |
|
127 | 127 | |
128 | - if ( $payment ) { |
|
129 | - give_offline_send_admin_notice( $payment ); |
|
130 | - give_offline_send_donor_instructions( $payment ); |
|
128 | + if ($payment) { |
|
129 | + give_offline_send_admin_notice($payment); |
|
130 | + give_offline_send_donor_instructions($payment); |
|
131 | 131 | give_send_to_success_page(); |
132 | 132 | } else { |
133 | 133 | // if errors are present, send the user back to the donation form so they can be corrected |
134 | - give_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['give-gateway'] ); |
|
134 | + give_send_back_to_checkout('?payment-mode='.$purchase_data['post_data']['give-gateway']); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | } |
138 | 138 | |
139 | -add_action( 'give_gateway_offline', 'give_offline_process_payment' ); |
|
139 | +add_action('give_gateway_offline', 'give_offline_process_payment'); |
|
140 | 140 | |
141 | 141 | |
142 | 142 | /** |
@@ -149,47 +149,47 @@ discard block |
||
149 | 149 | * @since 1.0 |
150 | 150 | * @return void |
151 | 151 | */ |
152 | -function give_offline_send_donor_instructions( $payment_id = 0 ) { |
|
152 | +function give_offline_send_donor_instructions($payment_id = 0) { |
|
153 | 153 | |
154 | - $payment_data = give_get_payment_meta( $payment_id ); |
|
155 | - $post_offline_customization_option = get_post_meta( $payment_data['form_id'], '_give_customize_offline_donations', true ); |
|
154 | + $payment_data = give_get_payment_meta($payment_id); |
|
155 | + $post_offline_customization_option = get_post_meta($payment_data['form_id'], '_give_customize_offline_donations', true); |
|
156 | 156 | |
157 | 157 | //Customize email content depending on whether the single form has been customized |
158 | - $email_content = give_get_option( 'global_offline_donation_email' ); |
|
158 | + $email_content = give_get_option('global_offline_donation_email'); |
|
159 | 159 | |
160 | - if ( $post_offline_customization_option === 'yes' ) { |
|
161 | - $email_content = get_post_meta( $payment_data['form_id'], '_give_offline_donation_email', true ); |
|
160 | + if ($post_offline_customization_option === 'yes') { |
|
161 | + $email_content = get_post_meta($payment_data['form_id'], '_give_offline_donation_email', true); |
|
162 | 162 | } |
163 | 163 | |
164 | - $from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) ); |
|
165 | - $from_name = apply_filters( 'give_purchase_from_name', $from_name, $payment_id, $payment_data ); |
|
164 | + $from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)); |
|
165 | + $from_name = apply_filters('give_purchase_from_name', $from_name, $payment_id, $payment_data); |
|
166 | 166 | |
167 | - $from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) ); |
|
168 | - $from_email = apply_filters( 'give_purchase_from_address', $from_email, $payment_id, $payment_data ); |
|
167 | + $from_email = give_get_option('from_email', get_bloginfo('admin_email')); |
|
168 | + $from_email = apply_filters('give_purchase_from_address', $from_email, $payment_id, $payment_data); |
|
169 | 169 | |
170 | - $to_email = give_get_payment_user_email( $payment_id ); |
|
170 | + $to_email = give_get_payment_user_email($payment_id); |
|
171 | 171 | |
172 | - $subject = give_get_option( 'offline_donation_subject', __( 'Offline Donation Instructions', 'give' ) ); |
|
173 | - if ( $post_offline_customization_option === 'yes' ) { |
|
174 | - $subject = get_post_meta( $payment_data['form_id'], '_give_offline_donation_subject', true ); |
|
172 | + $subject = give_get_option('offline_donation_subject', __('Offline Donation Instructions', 'give')); |
|
173 | + if ($post_offline_customization_option === 'yes') { |
|
174 | + $subject = get_post_meta($payment_data['form_id'], '_give_offline_donation_subject', true); |
|
175 | 175 | } |
176 | 176 | |
177 | - $subject = apply_filters( 'give_offline_donation_subject', wp_strip_all_tags( $subject ), $payment_id ); |
|
178 | - $subject = give_do_email_tags( $subject, $payment_id ); |
|
177 | + $subject = apply_filters('give_offline_donation_subject', wp_strip_all_tags($subject), $payment_id); |
|
178 | + $subject = give_do_email_tags($subject, $payment_id); |
|
179 | 179 | |
180 | - $attachments = apply_filters( 'give_offline_donation_attachments', array(), $payment_id, $payment_data ); |
|
181 | - $message = give_do_email_tags( $email_content, $payment_id ); |
|
180 | + $attachments = apply_filters('give_offline_donation_attachments', array(), $payment_id, $payment_data); |
|
181 | + $message = give_do_email_tags($email_content, $payment_id); |
|
182 | 182 | |
183 | 183 | $emails = Give()->emails; |
184 | 184 | |
185 | - $emails->__set( 'from_name', $from_name ); |
|
186 | - $emails->__set( 'from_email', $from_email ); |
|
187 | - $emails->__set( 'heading', __( 'Offline Donation Instructions', 'give' ) ); |
|
185 | + $emails->__set('from_name', $from_name); |
|
186 | + $emails->__set('from_email', $from_email); |
|
187 | + $emails->__set('heading', __('Offline Donation Instructions', 'give')); |
|
188 | 188 | |
189 | - $headers = apply_filters( 'give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data ); |
|
190 | - $emails->__set( 'headers', $headers ); |
|
189 | + $headers = apply_filters('give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data); |
|
190 | + $emails->__set('headers', $headers); |
|
191 | 191 | |
192 | - $emails->send( $to_email, $subject, $message, $attachments ); |
|
192 | + $emails->send($to_email, $subject, $message, $attachments); |
|
193 | 193 | |
194 | 194 | } |
195 | 195 | |
@@ -206,37 +206,37 @@ discard block |
||
206 | 206 | * @return void |
207 | 207 | * |
208 | 208 | */ |
209 | -function give_offline_send_admin_notice( $payment_id = 0 ) { |
|
209 | +function give_offline_send_admin_notice($payment_id = 0) { |
|
210 | 210 | |
211 | 211 | /* Send an email notification to the admin */ |
212 | 212 | $admin_email = give_get_admin_notice_emails(); |
213 | - $user_info = give_get_payment_meta_user_info( $payment_id ); |
|
213 | + $user_info = give_get_payment_meta_user_info($payment_id); |
|
214 | 214 | |
215 | - if ( isset( $user_info['id'] ) && $user_info['id'] > 0 ) { |
|
216 | - $user_data = get_userdata( $user_info['id'] ); |
|
215 | + if (isset($user_info['id']) && $user_info['id'] > 0) { |
|
216 | + $user_data = get_userdata($user_info['id']); |
|
217 | 217 | $name = $user_data->display_name; |
218 | - } elseif ( isset( $user_info['first_name'] ) && isset( $user_info['last_name'] ) ) { |
|
219 | - $name = $user_info['first_name'] . ' ' . $user_info['last_name']; |
|
218 | + } elseif (isset($user_info['first_name']) && isset($user_info['last_name'])) { |
|
219 | + $name = $user_info['first_name'].' '.$user_info['last_name']; |
|
220 | 220 | } else { |
221 | 221 | $name = $user_info['email']; |
222 | 222 | } |
223 | 223 | |
224 | - $amount = give_currency_filter( give_format_amount( give_get_payment_amount( $payment_id ) ) ); |
|
224 | + $amount = give_currency_filter(give_format_amount(give_get_payment_amount($payment_id))); |
|
225 | 225 | |
226 | - $admin_subject = apply_filters( 'give_offline_admin_donation_notification_subject', __( 'New Pending Donation', 'give' ), $payment_id ); |
|
226 | + $admin_subject = apply_filters('give_offline_admin_donation_notification_subject', __('New Pending Donation', 'give'), $payment_id); |
|
227 | 227 | |
228 | - $admin_message = __( 'Dear Admin,', 'give' ) . "\n\n" . __( 'An offline donation has been made', 'give' ) . ".\n\n"; |
|
228 | + $admin_message = __('Dear Admin,', 'give')."\n\n".__('An offline donation has been made', 'give').".\n\n"; |
|
229 | 229 | |
230 | - $order_url = admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id=' . $payment_id ); |
|
231 | - $admin_message .= __( 'Donor: ', 'give' ) . " " . html_entity_decode( $name, ENT_COMPAT, 'UTF-8' ) . "\n"; |
|
232 | - $admin_message .= __( 'Amount: ', 'give' ) . " " . html_entity_decode( $amount, ENT_COMPAT, 'UTF-8' ) . "\n\n"; |
|
233 | - $admin_message .= __( 'This is a pending donation awaiting payment. Donation instructions have been emailed to the donor. Once you receive payment, be sure to mark the donation as complete using the link below.', 'give' ) . "\n\n"; |
|
234 | - $admin_message .= sprintf( __( 'View Donation Details: %s.', 'give' ), $order_url ) . "\n\n"; |
|
235 | - $admin_message = apply_filters( 'give_offline_admin_donation_notification', $admin_message, $payment_id ); |
|
236 | - $admin_headers = apply_filters( 'give_offline_admin_donation_notification_headers', array(), $payment_id ); |
|
237 | - $attachments = apply_filters( 'give_offline_admin_donation_notification_attachments', array(), $payment_id ); |
|
230 | + $order_url = admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id='.$payment_id); |
|
231 | + $admin_message .= __('Donor: ', 'give')." ".html_entity_decode($name, ENT_COMPAT, 'UTF-8')."\n"; |
|
232 | + $admin_message .= __('Amount: ', 'give')." ".html_entity_decode($amount, ENT_COMPAT, 'UTF-8')."\n\n"; |
|
233 | + $admin_message .= __('This is a pending donation awaiting payment. Donation instructions have been emailed to the donor. Once you receive payment, be sure to mark the donation as complete using the link below.', 'give')."\n\n"; |
|
234 | + $admin_message .= sprintf(__('View Donation Details: %s.', 'give'), $order_url)."\n\n"; |
|
235 | + $admin_message = apply_filters('give_offline_admin_donation_notification', $admin_message, $payment_id); |
|
236 | + $admin_headers = apply_filters('give_offline_admin_donation_notification_headers', array(), $payment_id); |
|
237 | + $attachments = apply_filters('give_offline_admin_donation_notification_attachments', array(), $payment_id); |
|
238 | 238 | |
239 | - wp_mail( $admin_email, $admin_subject, $admin_message, $admin_headers, $attachments ); |
|
239 | + wp_mail($admin_email, $admin_subject, $admin_message, $admin_headers, $attachments); |
|
240 | 240 | |
241 | 241 | } |
242 | 242 | |
@@ -247,15 +247,15 @@ discard block |
||
247 | 247 | * @since 1.0 |
248 | 248 | * @return array |
249 | 249 | */ |
250 | -function give_offline_add_settings( $settings ) { |
|
250 | +function give_offline_add_settings($settings) { |
|
251 | 251 | |
252 | 252 | //Vars |
253 | 253 | $prefix = '_give_'; |
254 | 254 | |
255 | - $is_gateway_active = give_is_gateway_active( 'offline' ); |
|
255 | + $is_gateway_active = give_is_gateway_active('offline'); |
|
256 | 256 | |
257 | 257 | //this gateway isn't active |
258 | - if ( ! $is_gateway_active ) { |
|
258 | + if ( ! $is_gateway_active) { |
|
259 | 259 | //return settings and bounce |
260 | 260 | return $settings; |
261 | 261 | } |
@@ -264,27 +264,27 @@ discard block |
||
264 | 264 | $check_settings = array( |
265 | 265 | |
266 | 266 | array( |
267 | - 'name' => __( 'Customize Offline Donations', 'give' ), |
|
268 | - 'desc' => __( 'If you would like to customize the donation instructions for this specific forms check this option.', 'give' ), |
|
269 | - 'id' => $prefix . 'customize_offline_donations', |
|
267 | + 'name' => __('Customize Offline Donations', 'give'), |
|
268 | + 'desc' => __('If you would like to customize the donation instructions for this specific forms check this option.', 'give'), |
|
269 | + 'id' => $prefix.'customize_offline_donations', |
|
270 | 270 | 'type' => 'radio_inline', |
271 | 271 | 'default' => 'no', |
272 | 272 | 'options' => array( |
273 | - 'yes' => __( 'Yes', 'give' ), |
|
274 | - 'no' => __( 'No', 'give' ), |
|
273 | + 'yes' => __('Yes', 'give'), |
|
274 | + 'no' => __('No', 'give'), |
|
275 | 275 | ), |
276 | 276 | ), |
277 | 277 | array( |
278 | - 'name' => __( 'Request Billing Information', 'give' ), |
|
279 | - 'desc' => __( 'This option will enable the billing details section for this form\'s offline donation payment gateway. The fieldset will appear above the offline donation instructions.', 'give' ), |
|
280 | - 'id' => $prefix . 'offline_donation_enable_billing_fields_single', |
|
278 | + 'name' => __('Request Billing Information', 'give'), |
|
279 | + 'desc' => __('This option will enable the billing details section for this form\'s offline donation payment gateway. The fieldset will appear above the offline donation instructions.', 'give'), |
|
280 | + 'id' => $prefix.'offline_donation_enable_billing_fields_single', |
|
281 | 281 | 'row_classes' => 'give-subfield', |
282 | 282 | 'type' => 'checkbox' |
283 | 283 | ), |
284 | 284 | array( |
285 | - 'id' => $prefix . 'offline_checkout_notes', |
|
286 | - 'name' => __( 'Offline Donation Instructions', 'give' ), |
|
287 | - 'desc' => __( 'Enter the instructions you want to display to the donor during the donation process. Most likely this would include important information like mailing address and who to make the check out to.', 'give' ), |
|
285 | + 'id' => $prefix.'offline_checkout_notes', |
|
286 | + 'name' => __('Offline Donation Instructions', 'give'), |
|
287 | + 'desc' => __('Enter the instructions you want to display to the donor during the donation process. Most likely this would include important information like mailing address and who to make the check out to.', 'give'), |
|
288 | 288 | 'default' => give_get_default_offline_donation_content(), |
289 | 289 | 'type' => 'wysiwyg', |
290 | 290 | 'row_classes' => 'give-subfield', |
@@ -293,17 +293,17 @@ discard block |
||
293 | 293 | ) |
294 | 294 | ), |
295 | 295 | array( |
296 | - 'id' => $prefix . 'offline_donation_subject', |
|
297 | - 'name' => __( 'Offline Donation Email Instructions Subject', 'give' ), |
|
298 | - 'desc' => __( 'Enter the subject line for the donation receipt email.', 'give' ), |
|
299 | - 'default' => __( '{donation} - Offline Donation Instructions', 'give' ), |
|
296 | + 'id' => $prefix.'offline_donation_subject', |
|
297 | + 'name' => __('Offline Donation Email Instructions Subject', 'give'), |
|
298 | + 'desc' => __('Enter the subject line for the donation receipt email.', 'give'), |
|
299 | + 'default' => __('{donation} - Offline Donation Instructions', 'give'), |
|
300 | 300 | 'row_classes' => 'give-subfield', |
301 | 301 | 'type' => 'text' |
302 | 302 | ), |
303 | 303 | array( |
304 | - 'id' => $prefix . 'offline_donation_email', |
|
305 | - 'name' => __( 'Offline Donation Email Instructions', 'give' ), |
|
306 | - 'desc' => __( 'Enter the instructions you want emailed to the donor after they have submitted the donation form. Most likely this would include important information like mailing address and who to make the check out to.', 'give' ), |
|
304 | + 'id' => $prefix.'offline_donation_email', |
|
305 | + 'name' => __('Offline Donation Email Instructions', 'give'), |
|
306 | + 'desc' => __('Enter the instructions you want emailed to the donor after they have submitted the donation form. Most likely this would include important information like mailing address and who to make the check out to.', 'give'), |
|
307 | 307 | 'default' => give_get_default_offline_donation_email_content(), |
308 | 308 | 'type' => 'wysiwyg', |
309 | 309 | 'row_classes' => 'give-subfield', |
@@ -313,10 +313,10 @@ discard block |
||
313 | 313 | ) |
314 | 314 | ); |
315 | 315 | |
316 | - return array_merge( $settings, $check_settings ); |
|
316 | + return array_merge($settings, $check_settings); |
|
317 | 317 | } |
318 | 318 | |
319 | -add_filter( 'give_forms_display_options_metabox_fields', 'give_offline_add_settings' ); |
|
319 | +add_filter('give_forms_display_options_metabox_fields', 'give_offline_add_settings'); |
|
320 | 320 | |
321 | 321 | |
322 | 322 | /** |
@@ -328,20 +328,20 @@ discard block |
||
328 | 328 | */ |
329 | 329 | function give_get_default_offline_donation_content() { |
330 | 330 | |
331 | - $sitename = get_bloginfo( 'sitename' ); |
|
331 | + $sitename = get_bloginfo('sitename'); |
|
332 | 332 | |
333 | - $default_text = '<p>' . __( 'In order to make an offline donation we ask that you please follow these instructions', 'give' ) . ': </p>'; |
|
333 | + $default_text = '<p>'.__('In order to make an offline donation we ask that you please follow these instructions', 'give').': </p>'; |
|
334 | 334 | $default_text .= '<ol>'; |
335 | - $default_text .= '<li>' . _x( 'Make a check payable to ', 'Step 1 for donating offline by check', 'give' ) . '"' . $sitename . '"' . '</li>'; |
|
336 | - $default_text .= '<li>' . _x( 'On the memo line of the check, please indicate that the donation is for ', 'Step 2 for donating by check; this explains who the check should be written to', 'give' ) . '"' . $sitename . '"' . '</li>'; |
|
337 | - $default_text .= '<li>' . _x( 'Please mail your check to:', 'Step 3; where to mail the check', 'give' ) . '</li>'; |
|
335 | + $default_text .= '<li>'._x('Make a check payable to ', 'Step 1 for donating offline by check', 'give').'"'.$sitename.'"'.'</li>'; |
|
336 | + $default_text .= '<li>'._x('On the memo line of the check, please indicate that the donation is for ', 'Step 2 for donating by check; this explains who the check should be written to', 'give').'"'.$sitename.'"'.'</li>'; |
|
337 | + $default_text .= '<li>'._x('Please mail your check to:', 'Step 3; where to mail the check', 'give').'</li>'; |
|
338 | 338 | $default_text .= '</ol>'; |
339 | - $default_text .= ' <em>' . $sitename . '</em><br>'; |
|
339 | + $default_text .= ' <em>'.$sitename.'</em><br>'; |
|
340 | 340 | $default_text .= ' <em>123 G Street </em><br>'; |
341 | 341 | $default_text .= ' <em>San Diego, CA 92101 </em><br>'; |
342 | - $default_text .= '<p>' . __( 'All contributions will be gratefully acknowledged and are tax deductible.', 'give' ) . '</p>'; |
|
342 | + $default_text .= '<p>'.__('All contributions will be gratefully acknowledged and are tax deductible.', 'give').'</p>'; |
|
343 | 343 | |
344 | - return apply_filters( 'give_default_offline_donation_content', $default_text ); |
|
344 | + return apply_filters('give_default_offline_donation_content', $default_text); |
|
345 | 345 | |
346 | 346 | } |
347 | 347 | |
@@ -354,21 +354,21 @@ discard block |
||
354 | 354 | */ |
355 | 355 | function give_get_default_offline_donation_email_content() { |
356 | 356 | |
357 | - $sitename = get_bloginfo( 'sitename' ); |
|
358 | - $default_text = '<p>' . __( 'Dear {name},', 'give' ) . '</p>'; |
|
359 | - $default_text .= '<p>' . __( 'Thank you for your offline donation request! Your generosity is greatly appreciated. In order to make an offline donation we ask that you please follow these instructions', 'give' ) . ': </p>'; |
|
357 | + $sitename = get_bloginfo('sitename'); |
|
358 | + $default_text = '<p>'.__('Dear {name},', 'give').'</p>'; |
|
359 | + $default_text .= '<p>'.__('Thank you for your offline donation request! Your generosity is greatly appreciated. In order to make an offline donation we ask that you please follow these instructions', 'give').': </p>'; |
|
360 | 360 | $default_text .= '<ol>'; |
361 | - $default_text .= '<li>' . _x( 'Make a check payable to ', 'Step 1 for donating offline by check', 'give' ) . '"' . $sitename . '"' . '</li>'; |
|
362 | - $default_text .= '<li>' . _x( 'On the memo line of the check, please indicate that the donation is for ', 'Step 2 for donating by check; this explains who the check should be written to', 'give' ) . '"' . $sitename . '"' . '</li>'; |
|
363 | - $default_text .= '<li>' . _x( 'Please mail your check to:', 'Step 3; where to mail the check', 'give' ) . '</li>'; |
|
361 | + $default_text .= '<li>'._x('Make a check payable to ', 'Step 1 for donating offline by check', 'give').'"'.$sitename.'"'.'</li>'; |
|
362 | + $default_text .= '<li>'._x('On the memo line of the check, please indicate that the donation is for ', 'Step 2 for donating by check; this explains who the check should be written to', 'give').'"'.$sitename.'"'.'</li>'; |
|
363 | + $default_text .= '<li>'._x('Please mail your check to:', 'Step 3; where to mail the check', 'give').'</li>'; |
|
364 | 364 | $default_text .= '</ol>'; |
365 | - $default_text .= ' <em>' . $sitename . '</em><br>'; |
|
365 | + $default_text .= ' <em>'.$sitename.'</em><br>'; |
|
366 | 366 | $default_text .= ' <em>123 G Street </em><br>'; |
367 | 367 | $default_text .= ' <em>San Diego, CA 92101 </em><br>'; |
368 | - $default_text .= '<p>' . __( 'Once your donation has been received we will mark it as complete and you will receive an email receipt for your records. Please contact us with any questions you may have!', 'give' ) . '</p>'; |
|
369 | - $default_text .= '<p>' . __( 'Sincerely,', 'give' ) . '</p>'; |
|
370 | - $default_text .= '<p>' . $sitename . '</p>'; |
|
368 | + $default_text .= '<p>'.__('Once your donation has been received we will mark it as complete and you will receive an email receipt for your records. Please contact us with any questions you may have!', 'give').'</p>'; |
|
369 | + $default_text .= '<p>'.__('Sincerely,', 'give').'</p>'; |
|
370 | + $default_text .= '<p>'.$sitename.'</p>'; |
|
371 | 371 | |
372 | - return apply_filters( 'give_default_offline_donation_content', $default_text ); |
|
372 | + return apply_filters('give_default_offline_donation_content', $default_text); |
|
373 | 373 | |
374 | 374 | } |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | * @since 1.0 |
10 | 10 | */ |
11 | 11 | |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; |
14 | 14 | } |
15 | 15 | |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * @access private |
22 | 22 | * @since 1.0 |
23 | 23 | */ |
24 | -add_action( 'give_paypal_cc_form', '__return_false' ); |
|
24 | +add_action('give_paypal_cc_form', '__return_false'); |
|
25 | 25 | |
26 | 26 | /** |
27 | 27 | * Process PayPal Purchase |
@@ -32,13 +32,13 @@ discard block |
||
32 | 32 | * |
33 | 33 | * @return void |
34 | 34 | */ |
35 | -function give_process_paypal_purchase( $purchase_data ) { |
|
35 | +function give_process_paypal_purchase($purchase_data) { |
|
36 | 36 | |
37 | - if ( ! wp_verify_nonce( $purchase_data['gateway_nonce'], 'give-gateway' ) ) { |
|
38 | - wp_die( __( 'Nonce verification has failed', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
37 | + if ( ! wp_verify_nonce($purchase_data['gateway_nonce'], 'give-gateway')) { |
|
38 | + wp_die(__('Nonce verification has failed', 'give'), __('Error', 'give'), array('response' => 403)); |
|
39 | 39 | } |
40 | 40 | |
41 | - $form_id = intval( $purchase_data['post_data']['give-form-id'] ); |
|
41 | + $form_id = intval($purchase_data['post_data']['give-form-id']); |
|
42 | 42 | |
43 | 43 | // Collect payment data |
44 | 44 | $payment_data = array( |
@@ -55,59 +55,59 @@ discard block |
||
55 | 55 | ); |
56 | 56 | |
57 | 57 | // Record the pending payment |
58 | - $payment = give_insert_payment( $payment_data ); |
|
58 | + $payment = give_insert_payment($payment_data); |
|
59 | 59 | |
60 | 60 | // Check payment |
61 | - if ( ! $payment ) { |
|
61 | + if ( ! $payment) { |
|
62 | 62 | // Record the error |
63 | - give_record_gateway_error( __( 'Payment Error', 'give' ), sprintf( __( 'Payment creation failed before sending buyer to PayPal. Payment data: %s', 'give' ), json_encode( $payment_data ) ), $payment ); |
|
63 | + give_record_gateway_error(__('Payment Error', 'give'), sprintf(__('Payment creation failed before sending buyer to PayPal. Payment data: %s', 'give'), json_encode($payment_data)), $payment); |
|
64 | 64 | // Problems? send back |
65 | - give_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['give-gateway'] ); |
|
65 | + give_send_back_to_checkout('?payment-mode='.$purchase_data['post_data']['give-gateway']); |
|
66 | 66 | } else { |
67 | 67 | // Only send to PayPal if the pending payment is created successfully |
68 | - $listener_url = add_query_arg( 'give-listener', 'IPN', home_url( 'index.php' ) ); |
|
68 | + $listener_url = add_query_arg('give-listener', 'IPN', home_url('index.php')); |
|
69 | 69 | |
70 | 70 | // Get the success url |
71 | - $return_url = add_query_arg( array( |
|
71 | + $return_url = add_query_arg(array( |
|
72 | 72 | 'payment-confirmation' => 'paypal', |
73 | 73 | 'payment-id' => $payment |
74 | 74 | |
75 | - ), get_permalink( give_get_option( 'success_page' ) ) ); |
|
75 | + ), get_permalink(give_get_option('success_page'))); |
|
76 | 76 | |
77 | 77 | // Get the PayPal redirect uri |
78 | - $paypal_redirect = trailingslashit( give_get_paypal_redirect() ) . '?'; |
|
78 | + $paypal_redirect = trailingslashit(give_get_paypal_redirect()).'?'; |
|
79 | 79 | |
80 | 80 | //Item name - pass level name if variable priced |
81 | 81 | $item_name = $purchase_data['post_data']['give-form-title']; |
82 | 82 | |
83 | 83 | //Verify has variable prices |
84 | - if ( give_has_variable_prices( $form_id ) && isset( $purchase_data['post_data']['give-price-id'] ) ) { |
|
84 | + if (give_has_variable_prices($form_id) && isset($purchase_data['post_data']['give-price-id'])) { |
|
85 | 85 | |
86 | - $item_price_level_text = give_get_price_option_name( $form_id, $purchase_data['post_data']['give-price-id'] ); |
|
86 | + $item_price_level_text = give_get_price_option_name($form_id, $purchase_data['post_data']['give-price-id']); |
|
87 | 87 | |
88 | - $price_level_amount = give_get_price_option_amount( $form_id, $purchase_data['post_data']['give-price-id'] ); |
|
88 | + $price_level_amount = give_get_price_option_amount($form_id, $purchase_data['post_data']['give-price-id']); |
|
89 | 89 | |
90 | 90 | //Donation given doesn't match selected level (must be a custom amount) |
91 | - if ( $price_level_amount != give_sanitize_amount( $purchase_data['price'] ) ) { |
|
92 | - $custom_amount_text = get_post_meta( $form_id, '_give_custom_amount_text', true ); |
|
91 | + if ($price_level_amount != give_sanitize_amount($purchase_data['price'])) { |
|
92 | + $custom_amount_text = get_post_meta($form_id, '_give_custom_amount_text', true); |
|
93 | 93 | //user custom amount text if any, fallback to default if not |
94 | - $item_name .= ' - ' . (! empty( $custom_amount_text ) ? $custom_amount_text : __( 'Custom Amount', 'give' )); |
|
94 | + $item_name .= ' - '.( ! empty($custom_amount_text) ? $custom_amount_text : __('Custom Amount', 'give')); |
|
95 | 95 | |
96 | 96 | } //Is there any donation level text? |
97 | - elseif ( ! empty( $item_price_level_text ) ) { |
|
98 | - $item_name .= ' - ' . $item_price_level_text; |
|
97 | + elseif ( ! empty($item_price_level_text)) { |
|
98 | + $item_name .= ' - '.$item_price_level_text; |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | } //Single donation: Custom Amount |
102 | - elseif ( give_get_form_price( $form_id ) !== give_sanitize_amount( $purchase_data['price'] ) ) { |
|
103 | - $custom_amount_text = get_post_meta( $form_id, '_give_custom_amount_text', true ); |
|
102 | + elseif (give_get_form_price($form_id) !== give_sanitize_amount($purchase_data['price'])) { |
|
103 | + $custom_amount_text = get_post_meta($form_id, '_give_custom_amount_text', true); |
|
104 | 104 | //user custom amount text if any, fallback to default if not |
105 | - $item_name .= ' - ' . (! empty( $custom_amount_text ) ? $custom_amount_text : __( 'Custom Amount', 'give' )); |
|
105 | + $item_name .= ' - '.( ! empty($custom_amount_text) ? $custom_amount_text : __('Custom Amount', 'give')); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | // Setup PayPal arguments |
109 | 109 | $paypal_args = array( |
110 | - 'business' => give_get_option( 'paypal_email', false ), |
|
110 | + 'business' => give_get_option('paypal_email', false), |
|
111 | 111 | 'email' => $purchase_data['user_email'], |
112 | 112 | 'invoice' => $purchase_data['purchase_key'], |
113 | 113 | 'amount' => $purchase_data['price'], |
@@ -118,25 +118,25 @@ discard block |
||
118 | 118 | 'shipping' => '0', |
119 | 119 | 'no_note' => '1', |
120 | 120 | 'currency_code' => give_get_currency(), |
121 | - 'charset' => get_bloginfo( 'charset' ), |
|
121 | + 'charset' => get_bloginfo('charset'), |
|
122 | 122 | 'custom' => $payment, |
123 | 123 | 'rm' => '2', |
124 | 124 | 'return' => $return_url, |
125 | - 'cancel_return' => give_get_failed_transaction_uri( '?payment-id=' . $payment ), |
|
125 | + 'cancel_return' => give_get_failed_transaction_uri('?payment-id='.$payment), |
|
126 | 126 | 'notify_url' => $listener_url, |
127 | 127 | 'page_style' => give_get_paypal_page_style(), |
128 | - 'cbt' => get_bloginfo( 'name' ), |
|
128 | + 'cbt' => get_bloginfo('name'), |
|
129 | 129 | 'bn' => 'givewp_SP' |
130 | 130 | ); |
131 | 131 | |
132 | - if ( ! empty( $purchase_data['user_info']['address'] ) ) { |
|
132 | + if ( ! empty($purchase_data['user_info']['address'])) { |
|
133 | 133 | $paypal_args['address1'] = $purchase_data['user_info']['address']['line1']; |
134 | 134 | $paypal_args['address2'] = $purchase_data['user_info']['address']['line2']; |
135 | 135 | $paypal_args['city'] = $purchase_data['user_info']['address']['city']; |
136 | 136 | $paypal_args['country'] = $purchase_data['user_info']['address']['country']; |
137 | 137 | } |
138 | 138 | |
139 | - if ( give_get_option( 'paypal_button_type' ) === 'standard' ) { |
|
139 | + if (give_get_option('paypal_button_type') === 'standard') { |
|
140 | 140 | $paypal_extra_args = array( |
141 | 141 | 'cmd' => '_xclick', |
142 | 142 | ); |
@@ -146,25 +146,25 @@ discard block |
||
146 | 146 | ); |
147 | 147 | } |
148 | 148 | |
149 | - $paypal_args = array_merge( $paypal_extra_args, $paypal_args ); |
|
149 | + $paypal_args = array_merge($paypal_extra_args, $paypal_args); |
|
150 | 150 | |
151 | 151 | |
152 | - $paypal_args = apply_filters( 'give_paypal_redirect_args', $paypal_args, $purchase_data ); |
|
152 | + $paypal_args = apply_filters('give_paypal_redirect_args', $paypal_args, $purchase_data); |
|
153 | 153 | |
154 | 154 | // Build query |
155 | - $paypal_redirect .= http_build_query( $paypal_args ); |
|
155 | + $paypal_redirect .= http_build_query($paypal_args); |
|
156 | 156 | |
157 | 157 | // Fix for some sites that encode the entities |
158 | - $paypal_redirect = str_replace( '&', '&', $paypal_redirect ); |
|
158 | + $paypal_redirect = str_replace('&', '&', $paypal_redirect); |
|
159 | 159 | |
160 | 160 | // Redirect to PayPal |
161 | - wp_redirect( $paypal_redirect ); |
|
161 | + wp_redirect($paypal_redirect); |
|
162 | 162 | exit; |
163 | 163 | } |
164 | 164 | |
165 | 165 | } |
166 | 166 | |
167 | -add_action( 'give_gateway_paypal', 'give_process_paypal_purchase' ); |
|
167 | +add_action('give_gateway_paypal', 'give_process_paypal_purchase'); |
|
168 | 168 | |
169 | 169 | /** |
170 | 170 | * Listens for a PayPal IPN requests and then sends to the processing function |
@@ -174,12 +174,12 @@ discard block |
||
174 | 174 | */ |
175 | 175 | function give_listen_for_paypal_ipn() { |
176 | 176 | // Regular PayPal IPN |
177 | - if ( isset( $_GET['give-listener'] ) && $_GET['give-listener'] == 'IPN' ) { |
|
178 | - do_action( 'give_verify_paypal_ipn' ); |
|
177 | + if (isset($_GET['give-listener']) && $_GET['give-listener'] == 'IPN') { |
|
178 | + do_action('give_verify_paypal_ipn'); |
|
179 | 179 | } |
180 | 180 | } |
181 | 181 | |
182 | -add_action( 'init', 'give_listen_for_paypal_ipn' ); |
|
182 | +add_action('init', 'give_listen_for_paypal_ipn'); |
|
183 | 183 | |
184 | 184 | /** |
185 | 185 | * Process PayPal IPN |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | function give_process_paypal_ipn() { |
191 | 191 | |
192 | 192 | // Check the request method is POST |
193 | - if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] != 'POST' ) { |
|
193 | + if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'POST') { |
|
194 | 194 | return; |
195 | 195 | } |
196 | 196 | |
@@ -198,11 +198,11 @@ discard block |
||
198 | 198 | $post_data = ''; |
199 | 199 | |
200 | 200 | // Fallback just in case post_max_size is lower than needed |
201 | - if ( ini_get( 'allow_url_fopen' ) ) { |
|
202 | - $post_data = file_get_contents( 'php://input' ); |
|
201 | + if (ini_get('allow_url_fopen')) { |
|
202 | + $post_data = file_get_contents('php://input'); |
|
203 | 203 | } else { |
204 | 204 | // If allow_url_fopen is not enabled, then make sure that post_max_size is large enough |
205 | - ini_set( 'post_max_size', '12M' ); |
|
205 | + ini_set('post_max_size', '12M'); |
|
206 | 206 | } |
207 | 207 | // Start the encoded data collection with notification command |
208 | 208 | $encoded_data = 'cmd=_notify-validate'; |
@@ -211,27 +211,27 @@ discard block |
||
211 | 211 | $arg_separator = give_get_php_arg_separator_output(); |
212 | 212 | |
213 | 213 | // Verify there is a post_data |
214 | - if ( $post_data || strlen( $post_data ) > 0 ) { |
|
214 | + if ($post_data || strlen($post_data) > 0) { |
|
215 | 215 | // Append the data |
216 | - $encoded_data .= $arg_separator . $post_data; |
|
216 | + $encoded_data .= $arg_separator.$post_data; |
|
217 | 217 | } else { |
218 | 218 | // Check if POST is empty |
219 | - if ( empty( $_POST ) ) { |
|
219 | + if (empty($_POST)) { |
|
220 | 220 | // Nothing to do |
221 | 221 | return; |
222 | 222 | } else { |
223 | 223 | // Loop through each POST |
224 | - foreach ( $_POST as $key => $value ) { |
|
224 | + foreach ($_POST as $key => $value) { |
|
225 | 225 | // Encode the value and append the data |
226 | - $encoded_data .= $arg_separator . "$key=" . urlencode( $value ); |
|
226 | + $encoded_data .= $arg_separator."$key=".urlencode($value); |
|
227 | 227 | } |
228 | 228 | } |
229 | 229 | } |
230 | 230 | |
231 | 231 | // Convert collected post data to an array |
232 | - parse_str( $encoded_data, $encoded_data_array ); |
|
232 | + parse_str($encoded_data, $encoded_data_array); |
|
233 | 233 | |
234 | - if ( ! give_get_option( 'disable_paypal_verification' ) ) { |
|
234 | + if ( ! give_get_option('disable_paypal_verification')) { |
|
235 | 235 | |
236 | 236 | // Validate the IPN |
237 | 237 | |
@@ -253,16 +253,16 @@ discard block |
||
253 | 253 | ); |
254 | 254 | |
255 | 255 | // Get response |
256 | - $api_response = wp_remote_post( give_get_paypal_redirect(), $remote_post_vars ); |
|
256 | + $api_response = wp_remote_post(give_get_paypal_redirect(), $remote_post_vars); |
|
257 | 257 | |
258 | - if ( is_wp_error( $api_response ) ) { |
|
259 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( __( 'Invalid IPN verification response. IPN data: %s', 'give' ), json_encode( $api_response ) ) ); |
|
258 | + if (is_wp_error($api_response)) { |
|
259 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf(__('Invalid IPN verification response. IPN data: %s', 'give'), json_encode($api_response))); |
|
260 | 260 | |
261 | 261 | return; // Something went wrong |
262 | 262 | } |
263 | 263 | |
264 | - if ( $api_response['body'] !== 'VERIFIED' && give_get_option( 'disable_paypal_verification', false ) ) { |
|
265 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( __( 'Invalid IPN verification response. IPN data: %s', 'give' ), json_encode( $api_response ) ) ); |
|
264 | + if ($api_response['body'] !== 'VERIFIED' && give_get_option('disable_paypal_verification', false)) { |
|
265 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf(__('Invalid IPN verification response. IPN data: %s', 'give'), json_encode($api_response))); |
|
266 | 266 | |
267 | 267 | return; // Response not okay |
268 | 268 | } |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | } |
271 | 271 | |
272 | 272 | // Check if $post_data_array has been populated |
273 | - if ( ! is_array( $encoded_data_array ) && ! empty( $encoded_data_array ) ) { |
|
273 | + if ( ! is_array($encoded_data_array) && ! empty($encoded_data_array)) { |
|
274 | 274 | return; |
275 | 275 | } |
276 | 276 | |
@@ -279,21 +279,21 @@ discard block |
||
279 | 279 | 'payment_status' => '' |
280 | 280 | ); |
281 | 281 | |
282 | - $encoded_data_array = wp_parse_args( $encoded_data_array, $defaults ); |
|
282 | + $encoded_data_array = wp_parse_args($encoded_data_array, $defaults); |
|
283 | 283 | |
284 | - $payment_id = isset( $encoded_data_array['custom'] ) ? absint( $encoded_data_array['custom'] ) : 0; |
|
284 | + $payment_id = isset($encoded_data_array['custom']) ? absint($encoded_data_array['custom']) : 0; |
|
285 | 285 | |
286 | - if ( has_action( 'give_paypal_' . $encoded_data_array['txn_type'] ) ) { |
|
286 | + if (has_action('give_paypal_'.$encoded_data_array['txn_type'])) { |
|
287 | 287 | // Allow PayPal IPN types to be processed separately |
288 | - do_action( 'give_paypal_' . $encoded_data_array['txn_type'], $encoded_data_array, $payment_id ); |
|
288 | + do_action('give_paypal_'.$encoded_data_array['txn_type'], $encoded_data_array, $payment_id); |
|
289 | 289 | } else { |
290 | 290 | // Fallback to web accept just in case the txn_type isn't present |
291 | - do_action( 'give_paypal_web_accept', $encoded_data_array, $payment_id ); |
|
291 | + do_action('give_paypal_web_accept', $encoded_data_array, $payment_id); |
|
292 | 292 | } |
293 | 293 | exit; |
294 | 294 | } |
295 | 295 | |
296 | -add_action( 'give_verify_paypal_ipn', 'give_process_paypal_ipn' ); |
|
296 | +add_action('give_verify_paypal_ipn', 'give_process_paypal_ipn'); |
|
297 | 297 | |
298 | 298 | /** |
299 | 299 | * Process web accept (one time) payment IPNs |
@@ -304,185 +304,185 @@ discard block |
||
304 | 304 | * |
305 | 305 | * @return void |
306 | 306 | */ |
307 | -function give_process_paypal_web_accept_and_cart( $data, $payment_id ) { |
|
307 | +function give_process_paypal_web_accept_and_cart($data, $payment_id) { |
|
308 | 308 | |
309 | - if ( $data['txn_type'] != 'web_accept' && $data['txn_type'] != 'cart' && $data['payment_status'] != 'Refunded' ) { |
|
309 | + if ($data['txn_type'] != 'web_accept' && $data['txn_type'] != 'cart' && $data['payment_status'] != 'Refunded') { |
|
310 | 310 | return; |
311 | 311 | } |
312 | 312 | |
313 | - if ( empty( $payment_id ) ) { |
|
313 | + if (empty($payment_id)) { |
|
314 | 314 | return; |
315 | 315 | } |
316 | 316 | |
317 | 317 | // Collect payment details |
318 | - $purchase_key = isset( $data['invoice'] ) ? $data['invoice'] : $data['item_number']; |
|
318 | + $purchase_key = isset($data['invoice']) ? $data['invoice'] : $data['item_number']; |
|
319 | 319 | $paypal_amount = $data['mc_gross']; |
320 | - $payment_status = strtolower( $data['payment_status'] ); |
|
321 | - $currency_code = strtolower( $data['mc_currency'] ); |
|
322 | - $business_email = isset( $data['business'] ) && is_email( $data['business'] ) ? trim( $data['business'] ) : trim( $data['receiver_email'] ); |
|
323 | - $payment_meta = give_get_payment_meta( $payment_id ); |
|
320 | + $payment_status = strtolower($data['payment_status']); |
|
321 | + $currency_code = strtolower($data['mc_currency']); |
|
322 | + $business_email = isset($data['business']) && is_email($data['business']) ? trim($data['business']) : trim($data['receiver_email']); |
|
323 | + $payment_meta = give_get_payment_meta($payment_id); |
|
324 | 324 | |
325 | 325 | |
326 | - if ( give_get_payment_gateway( $payment_id ) != 'paypal' ) { |
|
326 | + if (give_get_payment_gateway($payment_id) != 'paypal') { |
|
327 | 327 | return; // this isn't a PayPal standard IPN |
328 | 328 | } |
329 | 329 | |
330 | 330 | // Verify payment recipient |
331 | - if ( strcasecmp( $business_email, trim( give_get_option( 'paypal_email' ) ) ) != 0 ) { |
|
331 | + if (strcasecmp($business_email, trim(give_get_option('paypal_email'))) != 0) { |
|
332 | 332 | |
333 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( __( 'Invalid business email in IPN response. IPN data: %s', 'give' ), json_encode( $data ) ), $payment_id ); |
|
334 | - give_update_payment_status( $payment_id, 'failed' ); |
|
335 | - give_insert_payment_note( $payment_id, __( 'Payment failed due to invalid PayPal business email.', 'give' ) ); |
|
333 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf(__('Invalid business email in IPN response. IPN data: %s', 'give'), json_encode($data)), $payment_id); |
|
334 | + give_update_payment_status($payment_id, 'failed'); |
|
335 | + give_insert_payment_note($payment_id, __('Payment failed due to invalid PayPal business email.', 'give')); |
|
336 | 336 | |
337 | 337 | return; |
338 | 338 | } |
339 | 339 | |
340 | 340 | // Verify payment currency |
341 | - if ( $currency_code != strtolower( $payment_meta['currency'] ) ) { |
|
341 | + if ($currency_code != strtolower($payment_meta['currency'])) { |
|
342 | 342 | |
343 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( __( 'Invalid currency in IPN response. IPN data: %s', 'give' ), json_encode( $data ) ), $payment_id ); |
|
344 | - give_update_payment_status( $payment_id, 'failed' ); |
|
345 | - give_insert_payment_note( $payment_id, __( 'Payment failed due to invalid currency in PayPal IPN.', 'give' ) ); |
|
343 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf(__('Invalid currency in IPN response. IPN data: %s', 'give'), json_encode($data)), $payment_id); |
|
344 | + give_update_payment_status($payment_id, 'failed'); |
|
345 | + give_insert_payment_note($payment_id, __('Payment failed due to invalid currency in PayPal IPN.', 'give')); |
|
346 | 346 | |
347 | 347 | return; |
348 | 348 | } |
349 | 349 | |
350 | - if ( ! give_get_payment_user_email( $payment_id ) ) { |
|
350 | + if ( ! give_get_payment_user_email($payment_id)) { |
|
351 | 351 | |
352 | 352 | // No email associated with purchase, so store from PayPal |
353 | - give_update_payment_meta( $payment_id, '_give_payment_user_email', $data['payer_email'] ); |
|
353 | + give_update_payment_meta($payment_id, '_give_payment_user_email', $data['payer_email']); |
|
354 | 354 | |
355 | 355 | // Setup and store the donors's details |
356 | 356 | $address = array(); |
357 | - $address['line1'] = ! empty( $data['address_street'] ) ? sanitize_text_field( $data['address_street'] ) : false; |
|
358 | - $address['city'] = ! empty( $data['address_city'] ) ? sanitize_text_field( $data['address_city'] ) : false; |
|
359 | - $address['state'] = ! empty( $data['address_state'] ) ? sanitize_text_field( $data['address_state'] ) : false; |
|
360 | - $address['country'] = ! empty( $data['address_country_code'] ) ? sanitize_text_field( $data['address_country_code'] ) : false; |
|
361 | - $address['zip'] = ! empty( $data['address_zip'] ) ? sanitize_text_field( $data['address_zip'] ) : false; |
|
357 | + $address['line1'] = ! empty($data['address_street']) ? sanitize_text_field($data['address_street']) : false; |
|
358 | + $address['city'] = ! empty($data['address_city']) ? sanitize_text_field($data['address_city']) : false; |
|
359 | + $address['state'] = ! empty($data['address_state']) ? sanitize_text_field($data['address_state']) : false; |
|
360 | + $address['country'] = ! empty($data['address_country_code']) ? sanitize_text_field($data['address_country_code']) : false; |
|
361 | + $address['zip'] = ! empty($data['address_zip']) ? sanitize_text_field($data['address_zip']) : false; |
|
362 | 362 | |
363 | 363 | $user_info = array( |
364 | 364 | 'id' => '-1', |
365 | - 'email' => sanitize_text_field( $data['payer_email'] ), |
|
366 | - 'first_name' => sanitize_text_field( $data['first_name'] ), |
|
367 | - 'last_name' => sanitize_text_field( $data['last_name'] ), |
|
365 | + 'email' => sanitize_text_field($data['payer_email']), |
|
366 | + 'first_name' => sanitize_text_field($data['first_name']), |
|
367 | + 'last_name' => sanitize_text_field($data['last_name']), |
|
368 | 368 | 'discount' => '', |
369 | 369 | 'address' => $address |
370 | 370 | ); |
371 | 371 | |
372 | 372 | $payment_meta['user_info'] = $user_info; |
373 | - give_update_payment_meta( $payment_id, '_give_payment_meta', $payment_meta ); |
|
373 | + give_update_payment_meta($payment_id, '_give_payment_meta', $payment_meta); |
|
374 | 374 | } |
375 | 375 | |
376 | - if ( $payment_status == 'refunded' || $payment_status == 'reversed' ) { |
|
376 | + if ($payment_status == 'refunded' || $payment_status == 'reversed') { |
|
377 | 377 | |
378 | 378 | // Process a refund |
379 | - give_process_paypal_refund( $data, $payment_id ); |
|
379 | + give_process_paypal_refund($data, $payment_id); |
|
380 | 380 | |
381 | 381 | } else { |
382 | 382 | |
383 | - if ( get_post_status( $payment_id ) == 'publish' ) { |
|
383 | + if (get_post_status($payment_id) == 'publish') { |
|
384 | 384 | return; // Only complete payments once |
385 | 385 | } |
386 | 386 | |
387 | 387 | // Retrieve the total purchase amount (before PayPal) |
388 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
388 | + $payment_amount = give_get_payment_amount($payment_id); |
|
389 | 389 | |
390 | - if ( number_format( (float) $paypal_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) { |
|
390 | + if (number_format((float) $paypal_amount, 2) < number_format((float) $payment_amount, 2)) { |
|
391 | 391 | // The prices don't match |
392 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( __( 'Invalid payment amount in IPN response. IPN data: %s', 'give' ), json_encode( $data ) ), $payment_id ); |
|
393 | - give_update_payment_status( $payment_id, 'failed' ); |
|
394 | - give_insert_payment_note( $payment_id, __( 'Payment failed due to invalid amount in PayPal IPN.', 'give' ) ); |
|
392 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf(__('Invalid payment amount in IPN response. IPN data: %s', 'give'), json_encode($data)), $payment_id); |
|
393 | + give_update_payment_status($payment_id, 'failed'); |
|
394 | + give_insert_payment_note($payment_id, __('Payment failed due to invalid amount in PayPal IPN.', 'give')); |
|
395 | 395 | |
396 | 396 | return; |
397 | 397 | } |
398 | - if ( $purchase_key != give_get_payment_key( $payment_id ) ) { |
|
398 | + if ($purchase_key != give_get_payment_key($payment_id)) { |
|
399 | 399 | // Purchase keys don't match |
400 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( __( 'Invalid purchase key in IPN response. IPN data: %s', 'give' ), json_encode( $data ) ), $payment_id ); |
|
401 | - give_update_payment_status( $payment_id, 'failed' ); |
|
402 | - give_insert_payment_note( $payment_id, __( 'Payment failed due to invalid purchase key in PayPal IPN.', 'give' ) ); |
|
400 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf(__('Invalid purchase key in IPN response. IPN data: %s', 'give'), json_encode($data)), $payment_id); |
|
401 | + give_update_payment_status($payment_id, 'failed'); |
|
402 | + give_insert_payment_note($payment_id, __('Payment failed due to invalid purchase key in PayPal IPN.', 'give')); |
|
403 | 403 | |
404 | 404 | return; |
405 | 405 | } |
406 | 406 | |
407 | - if ( $payment_status == 'completed' || give_is_test_mode() ) { |
|
408 | - give_insert_payment_note( $payment_id, sprintf( __( 'PayPal Transaction ID: %s', 'give' ), $data['txn_id'] ) ); |
|
409 | - give_set_payment_transaction_id( $payment_id, $data['txn_id'] ); |
|
410 | - give_update_payment_status( $payment_id, 'publish' ); |
|
411 | - } else if ( 'pending' == $payment_status && isset( $data['pending_reason'] ) ) { |
|
407 | + if ($payment_status == 'completed' || give_is_test_mode()) { |
|
408 | + give_insert_payment_note($payment_id, sprintf(__('PayPal Transaction ID: %s', 'give'), $data['txn_id'])); |
|
409 | + give_set_payment_transaction_id($payment_id, $data['txn_id']); |
|
410 | + give_update_payment_status($payment_id, 'publish'); |
|
411 | + } else if ('pending' == $payment_status && isset($data['pending_reason'])) { |
|
412 | 412 | |
413 | 413 | // Look for possible pending reasons, such as an echeck |
414 | 414 | |
415 | 415 | $note = ''; |
416 | 416 | |
417 | - switch ( strtolower( $data['pending_reason'] ) ) { |
|
417 | + switch (strtolower($data['pending_reason'])) { |
|
418 | 418 | |
419 | 419 | case 'echeck' : |
420 | 420 | |
421 | - $note = __( 'Payment made via eCheck and will clear automatically in 5-8 days', 'give' ); |
|
421 | + $note = __('Payment made via eCheck and will clear automatically in 5-8 days', 'give'); |
|
422 | 422 | |
423 | 423 | break; |
424 | 424 | |
425 | 425 | case 'address' : |
426 | 426 | |
427 | - $note = __( 'Payment requires a confirmed donor address and must be accepted manually through PayPal', 'give' ); |
|
427 | + $note = __('Payment requires a confirmed donor address and must be accepted manually through PayPal', 'give'); |
|
428 | 428 | |
429 | 429 | break; |
430 | 430 | |
431 | 431 | case 'intl' : |
432 | 432 | |
433 | - $note = __( 'Payment must be accepted manually through PayPal due to international account regulations', 'give' ); |
|
433 | + $note = __('Payment must be accepted manually through PayPal due to international account regulations', 'give'); |
|
434 | 434 | |
435 | 435 | break; |
436 | 436 | |
437 | 437 | case 'multi-currency' : |
438 | 438 | |
439 | - $note = __( 'Payment received in non-shop currency and must be accepted manually through PayPal', 'give' ); |
|
439 | + $note = __('Payment received in non-shop currency and must be accepted manually through PayPal', 'give'); |
|
440 | 440 | |
441 | 441 | break; |
442 | 442 | |
443 | 443 | case 'paymentreview' : |
444 | 444 | case 'regulatory_review' : |
445 | 445 | |
446 | - $note = __( 'Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations', 'give' ); |
|
446 | + $note = __('Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations', 'give'); |
|
447 | 447 | |
448 | 448 | break; |
449 | 449 | |
450 | 450 | case 'unilateral' : |
451 | 451 | |
452 | - $note = __( 'Payment was sent to non-confirmed or non-registered email address.', 'give' ); |
|
452 | + $note = __('Payment was sent to non-confirmed or non-registered email address.', 'give'); |
|
453 | 453 | |
454 | 454 | break; |
455 | 455 | |
456 | 456 | case 'upgrade' : |
457 | 457 | |
458 | - $note = __( 'PayPal account must be upgraded before this payment can be accepted', 'give' ); |
|
458 | + $note = __('PayPal account must be upgraded before this payment can be accepted', 'give'); |
|
459 | 459 | |
460 | 460 | break; |
461 | 461 | |
462 | 462 | case 'verify' : |
463 | 463 | |
464 | - $note = __( 'PayPal account is not verified. Verify account in order to accept this payment', 'give' ); |
|
464 | + $note = __('PayPal account is not verified. Verify account in order to accept this payment', 'give'); |
|
465 | 465 | |
466 | 466 | break; |
467 | 467 | |
468 | 468 | case 'other' : |
469 | 469 | |
470 | - $note = __( 'Payment is pending for unknown reasons. Contact PayPal support for assistance', 'give' ); |
|
470 | + $note = __('Payment is pending for unknown reasons. Contact PayPal support for assistance', 'give'); |
|
471 | 471 | |
472 | 472 | break; |
473 | 473 | |
474 | 474 | } |
475 | 475 | |
476 | - if ( ! empty( $note ) ) { |
|
476 | + if ( ! empty($note)) { |
|
477 | 477 | |
478 | - give_insert_payment_note( $payment_id, $note ); |
|
478 | + give_insert_payment_note($payment_id, $note); |
|
479 | 479 | |
480 | 480 | } |
481 | 481 | } |
482 | 482 | } |
483 | 483 | } |
484 | 484 | |
485 | -add_action( 'give_paypal_web_accept', 'give_process_paypal_web_accept_and_cart', 10, 2 ); |
|
485 | +add_action('give_paypal_web_accept', 'give_process_paypal_web_accept_and_cart', 10, 2); |
|
486 | 486 | |
487 | 487 | /** |
488 | 488 | * Process PayPal IPN Refunds |
@@ -493,32 +493,32 @@ discard block |
||
493 | 493 | * |
494 | 494 | * @return void |
495 | 495 | */ |
496 | -function give_process_paypal_refund( $data, $payment_id = 0 ) { |
|
496 | +function give_process_paypal_refund($data, $payment_id = 0) { |
|
497 | 497 | |
498 | 498 | // Collect payment details |
499 | 499 | |
500 | - if ( empty( $payment_id ) ) { |
|
500 | + if (empty($payment_id)) { |
|
501 | 501 | return; |
502 | 502 | } |
503 | 503 | |
504 | - if ( get_post_status( $payment_id ) == 'refunded' ) { |
|
504 | + if (get_post_status($payment_id) == 'refunded') { |
|
505 | 505 | return; // Only refund payments once |
506 | 506 | } |
507 | 507 | |
508 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
508 | + $payment_amount = give_get_payment_amount($payment_id); |
|
509 | 509 | $refund_amount = $data['payment_gross'] * - 1; |
510 | 510 | |
511 | - if ( number_format( (float) $refund_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) { |
|
511 | + if (number_format((float) $refund_amount, 2) < number_format((float) $payment_amount, 2)) { |
|
512 | 512 | |
513 | - give_insert_payment_note( $payment_id, sprintf( __( 'Partial PayPal refund processed: %s', 'give' ), $data['parent_txn_id'] ) ); |
|
513 | + give_insert_payment_note($payment_id, sprintf(__('Partial PayPal refund processed: %s', 'give'), $data['parent_txn_id'])); |
|
514 | 514 | |
515 | 515 | return; // This is a partial refund |
516 | 516 | |
517 | 517 | } |
518 | 518 | |
519 | - give_insert_payment_note( $payment_id, sprintf( __( 'PayPal Payment #%s Refunded for reason: %s', 'give' ), $data['parent_txn_id'], $data['reason_code'] ) ); |
|
520 | - give_insert_payment_note( $payment_id, sprintf( __( 'PayPal Refund Transaction ID: %s', 'give' ), $data['txn_id'] ) ); |
|
521 | - give_update_payment_status( $payment_id, 'refunded' ); |
|
519 | + give_insert_payment_note($payment_id, sprintf(__('PayPal Payment #%s Refunded for reason: %s', 'give'), $data['parent_txn_id'], $data['reason_code'])); |
|
520 | + give_insert_payment_note($payment_id, sprintf(__('PayPal Refund Transaction ID: %s', 'give'), $data['txn_id'])); |
|
521 | + give_update_payment_status($payment_id, 'refunded'); |
|
522 | 522 | } |
523 | 523 | |
524 | 524 | /** |
@@ -530,24 +530,24 @@ discard block |
||
530 | 530 | * |
531 | 531 | * @return string |
532 | 532 | */ |
533 | -function give_get_paypal_redirect( $ssl_check = false ) { |
|
533 | +function give_get_paypal_redirect($ssl_check = false) { |
|
534 | 534 | |
535 | - if ( is_ssl() || ! $ssl_check ) { |
|
535 | + if (is_ssl() || ! $ssl_check) { |
|
536 | 536 | $protocal = 'https://'; |
537 | 537 | } else { |
538 | 538 | $protocal = 'http://'; |
539 | 539 | } |
540 | 540 | |
541 | 541 | // Check the current payment mode |
542 | - if ( give_is_test_mode() ) { |
|
542 | + if (give_is_test_mode()) { |
|
543 | 543 | // Test mode |
544 | - $paypal_uri = $protocal . 'www.sandbox.paypal.com/cgi-bin/webscr'; |
|
544 | + $paypal_uri = $protocal.'www.sandbox.paypal.com/cgi-bin/webscr'; |
|
545 | 545 | } else { |
546 | 546 | // Live mode |
547 | - $paypal_uri = $protocal . 'www.paypal.com/cgi-bin/webscr'; |
|
547 | + $paypal_uri = $protocal.'www.paypal.com/cgi-bin/webscr'; |
|
548 | 548 | } |
549 | 549 | |
550 | - return apply_filters( 'give_paypal_uri', $paypal_uri ); |
|
550 | + return apply_filters('give_paypal_uri', $paypal_uri); |
|
551 | 551 | } |
552 | 552 | |
553 | 553 | /** |
@@ -558,9 +558,9 @@ discard block |
||
558 | 558 | */ |
559 | 559 | function give_get_paypal_page_style() { |
560 | 560 | |
561 | - $page_style = trim( give_get_option( 'paypal_page_style', 'PayPal' ) ); |
|
561 | + $page_style = trim(give_get_option('paypal_page_style', 'PayPal')); |
|
562 | 562 | |
563 | - return apply_filters( 'give_paypal_page_style', $page_style ); |
|
563 | + return apply_filters('give_paypal_page_style', $page_style); |
|
564 | 564 | } |
565 | 565 | |
566 | 566 | /** |
@@ -571,27 +571,27 @@ discard block |
||
571 | 571 | * @since 1.0 |
572 | 572 | * @return string |
573 | 573 | */ |
574 | -function give_paypal_success_page_content( $content ) { |
|
574 | +function give_paypal_success_page_content($content) { |
|
575 | 575 | |
576 | - if ( ! isset( $_GET['payment-id'] ) && ! give_get_purchase_session() ) { |
|
576 | + if ( ! isset($_GET['payment-id']) && ! give_get_purchase_session()) { |
|
577 | 577 | return $content; |
578 | 578 | } |
579 | 579 | |
580 | - $payment_id = isset( $_GET['payment-id'] ) ? absint( $_GET['payment-id'] ) : false; |
|
580 | + $payment_id = isset($_GET['payment-id']) ? absint($_GET['payment-id']) : false; |
|
581 | 581 | |
582 | - if ( ! $payment_id ) { |
|
582 | + if ( ! $payment_id) { |
|
583 | 583 | $session = give_get_purchase_session(); |
584 | - $payment_id = give_get_purchase_id_by_key( $session['purchase_key'] ); |
|
584 | + $payment_id = give_get_purchase_id_by_key($session['purchase_key']); |
|
585 | 585 | } |
586 | 586 | |
587 | - $payment = get_post( $payment_id ); |
|
587 | + $payment = get_post($payment_id); |
|
588 | 588 | |
589 | - if ( $payment && 'pending' == $payment->post_status ) { |
|
589 | + if ($payment && 'pending' == $payment->post_status) { |
|
590 | 590 | |
591 | 591 | // Payment is still pending so show processing indicator to fix the Race Condition, issue # |
592 | 592 | ob_start(); |
593 | 593 | |
594 | - give_get_template_part( 'payment', 'processing' ); |
|
594 | + give_get_template_part('payment', 'processing'); |
|
595 | 595 | |
596 | 596 | $content = ob_get_clean(); |
597 | 597 | |
@@ -601,7 +601,7 @@ discard block |
||
601 | 601 | |
602 | 602 | } |
603 | 603 | |
604 | -add_filter( 'give_payment_confirm_paypal', 'give_paypal_success_page_content' ); |
|
604 | +add_filter('give_payment_confirm_paypal', 'give_paypal_success_page_content'); |
|
605 | 605 | |
606 | 606 | /** |
607 | 607 | * Given a Payment ID, extract the transaction ID |
@@ -612,22 +612,22 @@ discard block |
||
612 | 612 | * |
613 | 613 | * @return string Transaction ID |
614 | 614 | */ |
615 | -function give_paypal_get_payment_transaction_id( $payment_id ) { |
|
615 | +function give_paypal_get_payment_transaction_id($payment_id) { |
|
616 | 616 | |
617 | 617 | $transaction_id = ''; |
618 | - $notes = give_get_payment_notes( $payment_id ); |
|
618 | + $notes = give_get_payment_notes($payment_id); |
|
619 | 619 | |
620 | - foreach ( $notes as $note ) { |
|
621 | - if ( preg_match( '/^PayPal Transaction ID: ([^\s]+)/', $note->comment_content, $match ) ) { |
|
620 | + foreach ($notes as $note) { |
|
621 | + if (preg_match('/^PayPal Transaction ID: ([^\s]+)/', $note->comment_content, $match)) { |
|
622 | 622 | $transaction_id = $match[1]; |
623 | 623 | continue; |
624 | 624 | } |
625 | 625 | } |
626 | 626 | |
627 | - return apply_filters( 'give_paypal_set_payment_transaction_id', $transaction_id, $payment_id ); |
|
627 | + return apply_filters('give_paypal_set_payment_transaction_id', $transaction_id, $payment_id); |
|
628 | 628 | } |
629 | 629 | |
630 | -add_filter( 'give_get_payment_transaction_id-paypal', 'give_paypal_get_payment_transaction_id', 10, 1 ); |
|
630 | +add_filter('give_get_payment_transaction_id-paypal', 'give_paypal_get_payment_transaction_id', 10, 1); |
|
631 | 631 | |
632 | 632 | /** |
633 | 633 | * Given a transaction ID, generate a link to the PayPal transaction ID details |
@@ -639,13 +639,13 @@ discard block |
||
639 | 639 | * |
640 | 640 | * @return string A link to the PayPal transaction details |
641 | 641 | */ |
642 | -function give_paypal_link_transaction_id( $transaction_id, $payment_id ) { |
|
642 | +function give_paypal_link_transaction_id($transaction_id, $payment_id) { |
|
643 | 643 | |
644 | 644 | $paypal_base_url = 'https://history.paypal.com/cgi-bin/webscr?cmd=_history-details-from-hub&id='; |
645 | - $transaction_url = '<a href="' . esc_url( $paypal_base_url . $transaction_id ) . '" target="_blank">' . $transaction_id . '</a>'; |
|
645 | + $transaction_url = '<a href="'.esc_url($paypal_base_url.$transaction_id).'" target="_blank">'.$transaction_id.'</a>'; |
|
646 | 646 | |
647 | - return apply_filters( 'give_paypal_link_payment_details_transaction_id', $transaction_url ); |
|
647 | + return apply_filters('give_paypal_link_payment_details_transaction_id', $transaction_url); |
|
648 | 648 | |
649 | 649 | } |
650 | 650 | |
651 | -add_filter( 'give_payment_details_transaction_id-paypal', 'give_paypal_link_transaction_id', 10, 2 ); |
|
651 | +add_filter('give_payment_details_transaction_id-paypal', 'give_paypal_link_transaction_id', 10, 2); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -32,25 +32,25 @@ discard block |
||
32 | 32 | give_setup_post_types(); |
33 | 33 | |
34 | 34 | // Clear the permalinks |
35 | - flush_rewrite_rules( false ); |
|
35 | + flush_rewrite_rules(false); |
|
36 | 36 | |
37 | 37 | // Add Upgraded From Option |
38 | - $current_version = get_option( 'give_version' ); |
|
39 | - if ( $current_version ) { |
|
40 | - update_option( 'give_version_upgraded_from', $current_version ); |
|
38 | + $current_version = get_option('give_version'); |
|
39 | + if ($current_version) { |
|
40 | + update_option('give_version_upgraded_from', $current_version); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | // Setup some default options |
44 | 44 | $options = array(); |
45 | 45 | |
46 | 46 | // Checks if the Success Page option exists AND that the page exists |
47 | - if ( ! get_post( give_get_option( 'success_page' ) ) ) { |
|
47 | + if ( ! get_post(give_get_option('success_page'))) { |
|
48 | 48 | |
49 | 49 | // Purchase Confirmation (Success) Page |
50 | 50 | $success = wp_insert_post( |
51 | 51 | array( |
52 | - 'post_title' => __( 'Donation Confirmation', 'give' ), |
|
53 | - 'post_content' => __( 'Thank you for your donation! [give_receipt]', 'give' ), |
|
52 | + 'post_title' => __('Donation Confirmation', 'give'), |
|
53 | + 'post_content' => __('Thank you for your donation! [give_receipt]', 'give'), |
|
54 | 54 | 'post_status' => 'publish', |
55 | 55 | 'post_author' => 1, |
56 | 56 | 'post_type' => 'page', |
@@ -63,13 +63,13 @@ discard block |
||
63 | 63 | } |
64 | 64 | |
65 | 65 | // Checks if the Failure Page option exists AND that the page exists |
66 | - if ( ! get_post( give_get_option( 'failure_page' ) ) ) { |
|
66 | + if ( ! get_post(give_get_option('failure_page'))) { |
|
67 | 67 | |
68 | 68 | // Failed Purchase Page |
69 | 69 | $failed = wp_insert_post( |
70 | 70 | array( |
71 | - 'post_title' => __( 'Transaction Failed', 'give' ), |
|
72 | - 'post_content' => __( 'Your transaction failed, please try again or contact site support.', 'give' ), |
|
71 | + 'post_title' => __('Transaction Failed', 'give'), |
|
72 | + 'post_content' => __('Your transaction failed, please try again or contact site support.', 'give'), |
|
73 | 73 | 'post_status' => 'publish', |
74 | 74 | 'post_author' => 1, |
75 | 75 | 'post_type' => 'page', |
@@ -81,11 +81,11 @@ discard block |
||
81 | 81 | } |
82 | 82 | |
83 | 83 | // Checks if the History Page option exists AND that the page exists |
84 | - if ( ! get_post( give_get_option( 'history_page' ) ) ) { |
|
84 | + if ( ! get_post(give_get_option('history_page'))) { |
|
85 | 85 | // Purchase History (History) Page |
86 | 86 | $history = wp_insert_post( |
87 | 87 | array( |
88 | - 'post_title' => __( 'Donation History', 'give' ), |
|
88 | + 'post_title' => __('Donation History', 'give'), |
|
89 | 89 | 'post_content' => '[donation_history]', |
90 | 90 | 'post_status' => 'publish', |
91 | 91 | 'post_author' => 1, |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | } |
99 | 99 | |
100 | 100 | //Fresh Install? Setup Test Mode, Base Country (US), Test Gateway, Currency |
101 | - if ( empty( $current_version ) ) { |
|
101 | + if (empty($current_version)) { |
|
102 | 102 | $options['base_country'] = 'US'; |
103 | 103 | $options['test_mode'] = 1; |
104 | 104 | $options['currency'] = 'USD'; |
@@ -115,12 +115,12 @@ discard block |
||
115 | 115 | } |
116 | 116 | |
117 | 117 | // Populate some default values |
118 | - update_option( 'give_settings', array_merge( $give_options, $options ) ); |
|
119 | - update_option( 'give_version', GIVE_VERSION ); |
|
118 | + update_option('give_settings', array_merge($give_options, $options)); |
|
119 | + update_option('give_version', GIVE_VERSION); |
|
120 | 120 | |
121 | 121 | //Update Version Number |
122 | - if ( $current_version ) { |
|
123 | - update_option( 'give_version_upgraded_from', $current_version ); |
|
122 | + if ($current_version) { |
|
123 | + update_option('give_version_upgraded_from', $current_version); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | // Create Give roles |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | $roles->add_caps(); |
130 | 130 | |
131 | 131 | $api = new Give_API(); |
132 | - update_option( 'give_default_api_version', 'v' . $api->get_version() ); |
|
132 | + update_option('give_default_api_version', 'v'.$api->get_version()); |
|
133 | 133 | |
134 | 134 | // Create the customers database |
135 | 135 | @Give()->customers->create_table(); |
@@ -138,32 +138,32 @@ discard block |
||
138 | 138 | Give()->session->use_php_sessions(); |
139 | 139 | |
140 | 140 | // Add a temporary option to note that Give pages have been created |
141 | - set_transient( '_give_installed', $options, 30 ); |
|
141 | + set_transient('_give_installed', $options, 30); |
|
142 | 142 | |
143 | 143 | // Bail if activating from network, or bulk |
144 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
144 | + if (is_network_admin() || isset($_GET['activate-multi'])) { |
|
145 | 145 | return; |
146 | 146 | } |
147 | 147 | |
148 | - if ( ! $current_version ) { |
|
149 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php'; |
|
148 | + if ( ! $current_version) { |
|
149 | + require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrade-functions.php'; |
|
150 | 150 | |
151 | 151 | // When new upgrade routines are added, mark them as complete on fresh install |
152 | 152 | $upgrade_routines = array( |
153 | 153 | 'upgrade_donor_payments_association' |
154 | 154 | ); |
155 | 155 | |
156 | - foreach ( $upgrade_routines as $upgrade ) { |
|
157 | - give_set_upgrade_complete( $upgrade ); |
|
156 | + foreach ($upgrade_routines as $upgrade) { |
|
157 | + give_set_upgrade_complete($upgrade); |
|
158 | 158 | } |
159 | 159 | } |
160 | 160 | |
161 | 161 | // Add the transient to redirect |
162 | - set_transient( '_give_activation_redirect', true, 30 ); |
|
162 | + set_transient('_give_activation_redirect', true, 30); |
|
163 | 163 | |
164 | 164 | } |
165 | 165 | |
166 | -register_activation_hook( GIVE_PLUGIN_FILE, 'give_install' ); |
|
166 | +register_activation_hook(GIVE_PLUGIN_FILE, 'give_install'); |
|
167 | 167 | |
168 | 168 | /** |
169 | 169 | * Post-installation |
@@ -175,14 +175,14 @@ discard block |
||
175 | 175 | */ |
176 | 176 | function give_after_install() { |
177 | 177 | |
178 | - if ( ! is_admin() ) { |
|
178 | + if ( ! is_admin()) { |
|
179 | 179 | return; |
180 | 180 | } |
181 | 181 | |
182 | - $give_options = get_transient( '_give_installed' ); |
|
182 | + $give_options = get_transient('_give_installed'); |
|
183 | 183 | |
184 | 184 | // Exit if not in admin or the transient doesn't exist |
185 | - if ( false === $give_options ) { |
|
185 | + if (false === $give_options) { |
|
186 | 186 | return; |
187 | 187 | } |
188 | 188 | |
@@ -190,13 +190,13 @@ discard block |
||
190 | 190 | @Give()->customers->create_table(); |
191 | 191 | |
192 | 192 | // Delete the transient |
193 | - delete_transient( '_give_installed' ); |
|
193 | + delete_transient('_give_installed'); |
|
194 | 194 | |
195 | - do_action( 'give_after_install', $give_options ); |
|
195 | + do_action('give_after_install', $give_options); |
|
196 | 196 | |
197 | 197 | } |
198 | 198 | |
199 | -add_action( 'admin_init', 'give_after_install' ); |
|
199 | +add_action('admin_init', 'give_after_install'); |
|
200 | 200 | |
201 | 201 | |
202 | 202 | /** |
@@ -211,11 +211,11 @@ discard block |
||
211 | 211 | |
212 | 212 | global $wp_roles; |
213 | 213 | |
214 | - if ( ! is_object( $wp_roles ) ) { |
|
214 | + if ( ! is_object($wp_roles)) { |
|
215 | 215 | return; |
216 | 216 | } |
217 | 217 | |
218 | - if ( ! array_key_exists( 'give_manager', $wp_roles->roles ) ) { |
|
218 | + if ( ! array_key_exists('give_manager', $wp_roles->roles)) { |
|
219 | 219 | |
220 | 220 | // Create Give shop roles |
221 | 221 | $roles = new Give_Roles; |
@@ -226,4 +226,4 @@ discard block |
||
226 | 226 | |
227 | 227 | } |
228 | 228 | |
229 | -add_action( 'admin_init', 'give_install_roles_on_network' ); |
|
229 | +add_action('admin_init', 'give_install_roles_on_network'); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -25,10 +25,10 @@ discard block |
||
25 | 25 | * |
26 | 26 | * @return string Login form |
27 | 27 | */ |
28 | -function give_login_form( $redirect = '' ) { |
|
28 | +function give_login_form($redirect = '') { |
|
29 | 29 | global $give_options, $give_login_redirect; |
30 | 30 | |
31 | - if ( empty( $redirect ) ) { |
|
31 | + if (empty($redirect)) { |
|
32 | 32 | $redirect = give_get_current_page_url(); |
33 | 33 | } |
34 | 34 | |
@@ -36,9 +36,9 @@ discard block |
||
36 | 36 | |
37 | 37 | ob_start(); |
38 | 38 | |
39 | - give_get_template_part( 'shortcode', 'login' ); |
|
39 | + give_get_template_part('shortcode', 'login'); |
|
40 | 40 | |
41 | - return apply_filters( 'give_login_form', ob_get_clean() ); |
|
41 | + return apply_filters('give_login_form', ob_get_clean()); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -52,10 +52,10 @@ discard block |
||
52 | 52 | * |
53 | 53 | * @return string Register form |
54 | 54 | */ |
55 | -function give_register_form( $redirect = '' ) { |
|
55 | +function give_register_form($redirect = '') { |
|
56 | 56 | global $give_options, $give_register_redirect; |
57 | 57 | |
58 | - if ( empty( $redirect ) ) { |
|
58 | + if (empty($redirect)) { |
|
59 | 59 | $redirect = give_get_current_page_url(); |
60 | 60 | } |
61 | 61 | |
@@ -63,11 +63,11 @@ discard block |
||
63 | 63 | |
64 | 64 | ob_start(); |
65 | 65 | |
66 | - if ( ! is_user_logged_in() ) { |
|
67 | - give_get_template_part( 'shortcode', 'register' ); |
|
66 | + if ( ! is_user_logged_in()) { |
|
67 | + give_get_template_part('shortcode', 'register'); |
|
68 | 68 | } |
69 | 69 | |
70 | - return apply_filters( 'give_register_form', ob_get_clean() ); |
|
70 | + return apply_filters('give_register_form', ob_get_clean()); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -79,34 +79,34 @@ discard block |
||
79 | 79 | * |
80 | 80 | * @return void |
81 | 81 | */ |
82 | -function give_process_login_form( $data ) { |
|
83 | - if ( wp_verify_nonce( $data['give_login_nonce'], 'give-login-nonce' ) ) { |
|
84 | - $user_data = get_user_by( 'login', $data['give_user_login'] ); |
|
85 | - if ( ! $user_data ) { |
|
86 | - $user_data = get_user_by( 'email', $data['give_user_login'] ); |
|
82 | +function give_process_login_form($data) { |
|
83 | + if (wp_verify_nonce($data['give_login_nonce'], 'give-login-nonce')) { |
|
84 | + $user_data = get_user_by('login', $data['give_user_login']); |
|
85 | + if ( ! $user_data) { |
|
86 | + $user_data = get_user_by('email', $data['give_user_login']); |
|
87 | 87 | } |
88 | - if ( $user_data ) { |
|
88 | + if ($user_data) { |
|
89 | 89 | $user_ID = $user_data->ID; |
90 | 90 | $user_email = $user_data->user_email; |
91 | - if ( wp_check_password( $data['give_user_pass'], $user_data->user_pass, $user_data->ID ) ) { |
|
92 | - give_log_user_in( $user_data->ID, $data['give_user_login'], $data['give_user_pass'] ); |
|
91 | + if (wp_check_password($data['give_user_pass'], $user_data->user_pass, $user_data->ID)) { |
|
92 | + give_log_user_in($user_data->ID, $data['give_user_login'], $data['give_user_pass']); |
|
93 | 93 | } else { |
94 | - give_set_error( 'password_incorrect', __( 'The password you entered is incorrect', 'give' ) ); |
|
94 | + give_set_error('password_incorrect', __('The password you entered is incorrect', 'give')); |
|
95 | 95 | } |
96 | 96 | } else { |
97 | - give_set_error( 'username_incorrect', __( 'The username you entered does not exist', 'give' ) ); |
|
97 | + give_set_error('username_incorrect', __('The username you entered does not exist', 'give')); |
|
98 | 98 | } |
99 | 99 | // Check for errors and redirect if none present |
100 | 100 | $errors = give_get_errors(); |
101 | - if ( ! $errors ) { |
|
102 | - $redirect = apply_filters( 'give_login_redirect', $data['give_redirect'], $user_ID ); |
|
103 | - wp_redirect( $redirect ); |
|
101 | + if ( ! $errors) { |
|
102 | + $redirect = apply_filters('give_login_redirect', $data['give_redirect'], $user_ID); |
|
103 | + wp_redirect($redirect); |
|
104 | 104 | give_die(); |
105 | 105 | } |
106 | 106 | } |
107 | 107 | } |
108 | 108 | |
109 | -add_action( 'give_user_login', 'give_process_login_form' ); |
|
109 | +add_action('give_user_login', 'give_process_login_form'); |
|
110 | 110 | |
111 | 111 | /** |
112 | 112 | * Log User In |
@@ -119,15 +119,15 @@ discard block |
||
119 | 119 | * |
120 | 120 | * @return void |
121 | 121 | */ |
122 | -function give_log_user_in( $user_id, $user_login, $user_pass ) { |
|
123 | - if ( $user_id < 1 ) { |
|
122 | +function give_log_user_in($user_id, $user_login, $user_pass) { |
|
123 | + if ($user_id < 1) { |
|
124 | 124 | return; |
125 | 125 | } |
126 | 126 | |
127 | - wp_set_auth_cookie( $user_id ); |
|
128 | - wp_set_current_user( $user_id, $user_login ); |
|
129 | - do_action( 'wp_login', $user_login, get_userdata( $user_id ) ); |
|
130 | - do_action( 'give_log_user_in', $user_id, $user_login, $user_pass ); |
|
127 | + wp_set_auth_cookie($user_id); |
|
128 | + wp_set_current_user($user_id, $user_login); |
|
129 | + do_action('wp_login', $user_login, get_userdata($user_id)); |
|
130 | + do_action('give_log_user_in', $user_id, $user_login, $user_pass); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | |
@@ -140,70 +140,70 @@ discard block |
||
140 | 140 | * |
141 | 141 | * @return void |
142 | 142 | */ |
143 | -function give_process_register_form( $data ) { |
|
143 | +function give_process_register_form($data) { |
|
144 | 144 | |
145 | - if ( is_user_logged_in() ) { |
|
145 | + if (is_user_logged_in()) { |
|
146 | 146 | return; |
147 | 147 | } |
148 | 148 | |
149 | - if ( empty( $_POST['give_register_submit'] ) ) { |
|
149 | + if (empty($_POST['give_register_submit'])) { |
|
150 | 150 | return; |
151 | 151 | } |
152 | 152 | |
153 | - do_action( 'give_pre_process_register_form' ); |
|
153 | + do_action('give_pre_process_register_form'); |
|
154 | 154 | |
155 | - if ( empty( $data['give_user_login'] ) ) { |
|
156 | - give_set_error( 'empty_username', __( 'Invalid username', 'give' ) ); |
|
155 | + if (empty($data['give_user_login'])) { |
|
156 | + give_set_error('empty_username', __('Invalid username', 'give')); |
|
157 | 157 | } |
158 | 158 | |
159 | - if ( username_exists( $data['give_user_login'] ) ) { |
|
160 | - give_set_error( 'username_unavailable', __( 'Username already taken', 'give' ) ); |
|
159 | + if (username_exists($data['give_user_login'])) { |
|
160 | + give_set_error('username_unavailable', __('Username already taken', 'give')); |
|
161 | 161 | } |
162 | 162 | |
163 | - if ( ! validate_username( $data['give_user_login'] ) ) { |
|
164 | - give_set_error( 'username_invalid', __( 'Invalid username', 'give' ) ); |
|
163 | + if ( ! validate_username($data['give_user_login'])) { |
|
164 | + give_set_error('username_invalid', __('Invalid username', 'give')); |
|
165 | 165 | } |
166 | 166 | |
167 | - if ( email_exists( $data['give_user_email'] ) ) { |
|
168 | - give_set_error( 'email_unavailable', __( 'Email address already taken', 'give' ) ); |
|
167 | + if (email_exists($data['give_user_email'])) { |
|
168 | + give_set_error('email_unavailable', __('Email address already taken', 'give')); |
|
169 | 169 | } |
170 | 170 | |
171 | - if ( empty( $data['give_user_email'] ) || ! is_email( $data['give_user_email'] ) ) { |
|
172 | - give_set_error( 'email_invalid', __( 'Invalid email', 'give' ) ); |
|
171 | + if (empty($data['give_user_email']) || ! is_email($data['give_user_email'])) { |
|
172 | + give_set_error('email_invalid', __('Invalid email', 'give')); |
|
173 | 173 | } |
174 | 174 | |
175 | - if ( ! empty( $data['give_payment_email'] ) && $data['give_payment_email'] != $data['give_user_email'] && ! is_email( $data['give_payment_email'] ) ) { |
|
176 | - give_set_error( 'payment_email_invalid', __( 'Invalid payment email', 'give' ) ); |
|
175 | + if ( ! empty($data['give_payment_email']) && $data['give_payment_email'] != $data['give_user_email'] && ! is_email($data['give_payment_email'])) { |
|
176 | + give_set_error('payment_email_invalid', __('Invalid payment email', 'give')); |
|
177 | 177 | } |
178 | 178 | |
179 | - if ( empty( $_POST['give_user_pass'] ) ) { |
|
180 | - give_set_error( 'empty_password', __( 'Please enter a password', 'give' ) ); |
|
179 | + if (empty($_POST['give_user_pass'])) { |
|
180 | + give_set_error('empty_password', __('Please enter a password', 'give')); |
|
181 | 181 | } |
182 | 182 | |
183 | - if ( ( ! empty( $_POST['give_user_pass'] ) && empty( $_POST['give_user_pass2'] ) ) || ( $_POST['give_user_pass'] !== $_POST['give_user_pass2'] ) ) { |
|
184 | - give_set_error( 'password_mismatch', __( 'Passwords do not match', 'give' ) ); |
|
183 | + if (( ! empty($_POST['give_user_pass']) && empty($_POST['give_user_pass2'])) || ($_POST['give_user_pass'] !== $_POST['give_user_pass2'])) { |
|
184 | + give_set_error('password_mismatch', __('Passwords do not match', 'give')); |
|
185 | 185 | } |
186 | 186 | |
187 | - do_action( 'give_process_register_form' ); |
|
187 | + do_action('give_process_register_form'); |
|
188 | 188 | |
189 | 189 | // Check for errors and redirect if none present |
190 | 190 | $errors = give_get_errors(); |
191 | 191 | |
192 | - if ( empty( $errors ) ) { |
|
192 | + if (empty($errors)) { |
|
193 | 193 | |
194 | - $redirect = apply_filters( 'give_register_redirect', $data['give_redirect'] ); |
|
194 | + $redirect = apply_filters('give_register_redirect', $data['give_redirect']); |
|
195 | 195 | |
196 | - give_register_and_login_new_user( array( |
|
196 | + give_register_and_login_new_user(array( |
|
197 | 197 | 'user_login' => $data['give_user_login'], |
198 | 198 | 'user_pass' => $data['give_user_pass'], |
199 | 199 | 'user_email' => $data['give_user_email'], |
200 | - 'user_registered' => date( 'Y-m-d H:i:s' ), |
|
201 | - 'role' => get_option( 'default_role' ) |
|
202 | - ) ); |
|
200 | + 'user_registered' => date('Y-m-d H:i:s'), |
|
201 | + 'role' => get_option('default_role') |
|
202 | + )); |
|
203 | 203 | |
204 | - wp_redirect( $redirect ); |
|
204 | + wp_redirect($redirect); |
|
205 | 205 | give_die(); |
206 | 206 | } |
207 | 207 | } |
208 | 208 | |
209 | -add_action( 'give_user_register', 'give_process_register_form' ); |
|
210 | 209 | \ No newline at end of file |
210 | +add_action('give_user_register', 'give_process_register_form'); |
|
211 | 211 | \ No newline at end of file |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -28,66 +28,66 @@ discard block |
||
28 | 28 | * |
29 | 29 | * @return void |
30 | 30 | */ |
31 | -function give_complete_purchase( $payment_id, $new_status, $old_status ) { |
|
32 | - if ( $old_status == 'publish' || $old_status == 'complete' ) { |
|
31 | +function give_complete_purchase($payment_id, $new_status, $old_status) { |
|
32 | + if ($old_status == 'publish' || $old_status == 'complete') { |
|
33 | 33 | return; |
34 | 34 | } // Make sure that payments are only completed once |
35 | 35 | |
36 | 36 | // Make sure the payment completion is only processed when new status is complete |
37 | - if ( $new_status != 'publish' && $new_status != 'complete' ) { |
|
37 | + if ($new_status != 'publish' && $new_status != 'complete') { |
|
38 | 38 | return; |
39 | 39 | } |
40 | 40 | |
41 | - $payment_meta = give_get_payment_meta( $payment_id ); |
|
42 | - $creation_date = get_post_field( 'post_date', $payment_id, 'raw' ); |
|
43 | - $completed_date = give_get_payment_completed_date( $payment_id ); |
|
44 | - $user_info = give_get_payment_meta_user_info( $payment_id ); |
|
45 | - $donor_id = give_get_payment_customer_id( $payment_id ); |
|
46 | - $amount = give_get_payment_amount( $payment_id ); |
|
41 | + $payment_meta = give_get_payment_meta($payment_id); |
|
42 | + $creation_date = get_post_field('post_date', $payment_id, 'raw'); |
|
43 | + $completed_date = give_get_payment_completed_date($payment_id); |
|
44 | + $user_info = give_get_payment_meta_user_info($payment_id); |
|
45 | + $donor_id = give_get_payment_customer_id($payment_id); |
|
46 | + $amount = give_get_payment_amount($payment_id); |
|
47 | 47 | |
48 | - do_action( 'give_pre_complete_purchase', $payment_id ); |
|
48 | + do_action('give_pre_complete_purchase', $payment_id); |
|
49 | 49 | |
50 | - $price_id = isset( $_POST['give-price-id'] ) ? (int) $_POST['give-price-id'] : false; |
|
50 | + $price_id = isset($_POST['give-price-id']) ? (int) $_POST['give-price-id'] : false; |
|
51 | 51 | |
52 | 52 | // Ensure these actions only run once, ever |
53 | - if ( empty( $completed_date ) ) { |
|
53 | + if (empty($completed_date)) { |
|
54 | 54 | |
55 | - if ( ! give_is_test_mode() || apply_filters( 'give_log_test_payment_stats', false ) ) { |
|
55 | + if ( ! give_is_test_mode() || apply_filters('give_log_test_payment_stats', false)) { |
|
56 | 56 | |
57 | - give_record_sale_in_log( $payment_meta['form_id'], $payment_id, $price_id, $creation_date ); |
|
58 | - give_increase_purchase_count( $payment_meta['form_id'] ); |
|
59 | - give_increase_earnings( $payment_meta['form_id'], $amount ); |
|
57 | + give_record_sale_in_log($payment_meta['form_id'], $payment_id, $price_id, $creation_date); |
|
58 | + give_increase_purchase_count($payment_meta['form_id']); |
|
59 | + give_increase_earnings($payment_meta['form_id'], $amount); |
|
60 | 60 | |
61 | 61 | } |
62 | 62 | |
63 | - do_action( 'give_complete_form_donation', $payment_meta['form_id'], $payment_id, $payment_meta ); |
|
63 | + do_action('give_complete_form_donation', $payment_meta['form_id'], $payment_id, $payment_meta); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | |
67 | 67 | // Clear the total earnings cache |
68 | - delete_transient( 'give_earnings_total' ); |
|
68 | + delete_transient('give_earnings_total'); |
|
69 | 69 | // Clear the This Month earnings (this_monththis_month is NOT a typo) |
70 | - delete_transient( md5( 'give_earnings_this_monththis_month' ) ); |
|
71 | - delete_transient( md5( 'give_earnings_todaytoday' ) ); |
|
70 | + delete_transient(md5('give_earnings_this_monththis_month')); |
|
71 | + delete_transient(md5('give_earnings_todaytoday')); |
|
72 | 72 | |
73 | 73 | |
74 | 74 | // Increase the donor's purchase stats |
75 | - Give()->customers->increment_stats( $donor_id, $amount ); |
|
75 | + Give()->customers->increment_stats($donor_id, $amount); |
|
76 | 76 | |
77 | - give_increase_total_earnings( $amount ); |
|
77 | + give_increase_total_earnings($amount); |
|
78 | 78 | |
79 | 79 | // Ensure this action only runs once ever |
80 | - if ( empty( $completed_date ) ) { |
|
80 | + if (empty($completed_date)) { |
|
81 | 81 | |
82 | 82 | // Save the completed date |
83 | - give_update_payment_meta( $payment_id, '_give_completed_date', current_time( 'mysql' ) ); |
|
83 | + give_update_payment_meta($payment_id, '_give_completed_date', current_time('mysql')); |
|
84 | 84 | |
85 | - do_action( 'give_complete_purchase', $payment_id ); |
|
85 | + do_action('give_complete_purchase', $payment_id); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | } |
89 | 89 | |
90 | -add_action( 'give_update_payment_status', 'give_complete_purchase', 100, 3 ); |
|
90 | +add_action('give_update_payment_status', 'give_complete_purchase', 100, 3); |
|
91 | 91 | |
92 | 92 | |
93 | 93 | /** |
@@ -101,19 +101,19 @@ discard block |
||
101 | 101 | * |
102 | 102 | * @return void |
103 | 103 | */ |
104 | -function give_record_status_change( $payment_id, $new_status, $old_status ) { |
|
104 | +function give_record_status_change($payment_id, $new_status, $old_status) { |
|
105 | 105 | |
106 | 106 | // Get the list of statuses so that status in the payment note can be translated |
107 | 107 | $stati = give_get_payment_statuses(); |
108 | - $old_status = isset( $stati[ $old_status ] ) ? $stati[ $old_status ] : $old_status; |
|
109 | - $new_status = isset( $stati[ $new_status ] ) ? $stati[ $new_status ] : $new_status; |
|
108 | + $old_status = isset($stati[$old_status]) ? $stati[$old_status] : $old_status; |
|
109 | + $new_status = isset($stati[$new_status]) ? $stati[$new_status] : $new_status; |
|
110 | 110 | |
111 | - $status_change = sprintf( __( 'Status changed from %s to %s', 'give' ), $old_status, $new_status ); |
|
111 | + $status_change = sprintf(__('Status changed from %s to %s', 'give'), $old_status, $new_status); |
|
112 | 112 | |
113 | - give_insert_payment_note( $payment_id, $status_change ); |
|
113 | + give_insert_payment_note($payment_id, $status_change); |
|
114 | 114 | } |
115 | 115 | |
116 | -add_action( 'give_update_payment_status', 'give_record_status_change', 100, 3 ); |
|
116 | +add_action('give_update_payment_status', 'give_record_status_change', 100, 3); |
|
117 | 117 | |
118 | 118 | /** |
119 | 119 | * Reduces earnings and donation stats when a donation is refunded |
@@ -126,40 +126,40 @@ discard block |
||
126 | 126 | * |
127 | 127 | * @return void |
128 | 128 | */ |
129 | -function give_undo_donation_on_refund( $payment_id, $new_status, $old_status ) { |
|
129 | +function give_undo_donation_on_refund($payment_id, $new_status, $old_status) { |
|
130 | 130 | |
131 | - if ( 'publish' != $old_status && 'revoked' != $old_status ) { |
|
131 | + if ('publish' != $old_status && 'revoked' != $old_status) { |
|
132 | 132 | return; |
133 | 133 | } |
134 | 134 | |
135 | - if ( 'refunded' != $new_status ) { |
|
135 | + if ('refunded' != $new_status) { |
|
136 | 136 | return; |
137 | 137 | } |
138 | 138 | |
139 | 139 | // Set necessary vars |
140 | - $payment_meta = give_get_payment_meta( $payment_id ); |
|
141 | - $amount = give_get_payment_amount( $payment_id ); |
|
140 | + $payment_meta = give_get_payment_meta($payment_id); |
|
141 | + $amount = give_get_payment_amount($payment_id); |
|
142 | 142 | |
143 | 143 | // Undo this purchase |
144 | - give_undo_purchase( $payment_meta['form_id'], $payment_id ); |
|
144 | + give_undo_purchase($payment_meta['form_id'], $payment_id); |
|
145 | 145 | |
146 | 146 | // Decrease total earnings |
147 | - give_decrease_total_earnings( $amount ); |
|
147 | + give_decrease_total_earnings($amount); |
|
148 | 148 | |
149 | 149 | // Decrement the stats for the donor |
150 | - $donor_id = give_get_payment_customer_id( $payment_id ); |
|
150 | + $donor_id = give_get_payment_customer_id($payment_id); |
|
151 | 151 | |
152 | - if ( $donor_id ) { |
|
152 | + if ($donor_id) { |
|
153 | 153 | |
154 | - Give()->customers->decrement_stats( $donor_id, $amount ); |
|
154 | + Give()->customers->decrement_stats($donor_id, $amount); |
|
155 | 155 | |
156 | 156 | } |
157 | 157 | |
158 | 158 | // Clear the This Month earnings (this_monththis_month is NOT a typo) |
159 | - delete_transient( md5( 'give_earnings_this_monththis_month' ) ); |
|
159 | + delete_transient(md5('give_earnings_this_monththis_month')); |
|
160 | 160 | } |
161 | 161 | |
162 | -add_action( 'give_update_payment_status', 'give_undo_donation_on_refund', 100, 3 ); |
|
162 | +add_action('give_update_payment_status', 'give_undo_donation_on_refund', 100, 3); |
|
163 | 163 | |
164 | 164 | |
165 | 165 | /** |
@@ -172,13 +172,13 @@ discard block |
||
172 | 172 | * @param $new_status the status of the payment, probably "publish" |
173 | 173 | * @param $old_status the status of the payment prior to being marked as "complete", probably "pending" |
174 | 174 | */ |
175 | -function give_clear_user_history_cache( $payment_id, $new_status, $old_status ) { |
|
176 | - $user_info = give_get_payment_meta_user_info( $payment_id ); |
|
175 | +function give_clear_user_history_cache($payment_id, $new_status, $old_status) { |
|
176 | + $user_info = give_get_payment_meta_user_info($payment_id); |
|
177 | 177 | |
178 | - delete_transient( 'give_user_' . $user_info['id'] . '_purchases' ); |
|
178 | + delete_transient('give_user_'.$user_info['id'].'_purchases'); |
|
179 | 179 | } |
180 | 180 | |
181 | -add_action( 'give_update_payment_status', 'give_clear_user_history_cache', 10, 3 ); |
|
181 | +add_action('give_update_payment_status', 'give_clear_user_history_cache', 10, 3); |
|
182 | 182 | |
183 | 183 | /** |
184 | 184 | * Updates all old payments, prior to 1.2, with new |
@@ -192,32 +192,32 @@ discard block |
||
192 | 192 | * |
193 | 193 | * @return void |
194 | 194 | */ |
195 | -function give_update_old_payments_with_totals( $data ) { |
|
196 | - if ( ! wp_verify_nonce( $data['_wpnonce'], 'give_upgrade_payments_nonce' ) ) { |
|
195 | +function give_update_old_payments_with_totals($data) { |
|
196 | + if ( ! wp_verify_nonce($data['_wpnonce'], 'give_upgrade_payments_nonce')) { |
|
197 | 197 | return; |
198 | 198 | } |
199 | 199 | |
200 | - if ( get_option( 'give_payment_totals_upgraded' ) ) { |
|
200 | + if (get_option('give_payment_totals_upgraded')) { |
|
201 | 201 | return; |
202 | 202 | } |
203 | 203 | |
204 | - $payments = give_get_payments( array( |
|
204 | + $payments = give_get_payments(array( |
|
205 | 205 | 'offset' => 0, |
206 | - 'number' => - 1, |
|
206 | + 'number' => -1, |
|
207 | 207 | 'mode' => 'all' |
208 | - ) ); |
|
208 | + )); |
|
209 | 209 | |
210 | - if ( $payments ) { |
|
211 | - foreach ( $payments as $payment ) { |
|
212 | - $meta = give_get_payment_meta( $payment->ID ); |
|
213 | - give_update_payment_meta( $payment->ID, '_give_payment_total', $meta['amount'] ); |
|
210 | + if ($payments) { |
|
211 | + foreach ($payments as $payment) { |
|
212 | + $meta = give_get_payment_meta($payment->ID); |
|
213 | + give_update_payment_meta($payment->ID, '_give_payment_total', $meta['amount']); |
|
214 | 214 | } |
215 | 215 | } |
216 | 216 | |
217 | - add_option( 'give_payment_totals_upgraded', 1 ); |
|
217 | + add_option('give_payment_totals_upgraded', 1); |
|
218 | 218 | } |
219 | 219 | |
220 | -add_action( 'give_upgrade_payments', 'give_update_old_payments_with_totals' ); |
|
220 | +add_action('give_upgrade_payments', 'give_update_old_payments_with_totals'); |
|
221 | 221 | |
222 | 222 | /** |
223 | 223 | * Updates week-old+ 'pending' orders to 'abandoned' |
@@ -228,21 +228,21 @@ discard block |
||
228 | 228 | function give_mark_abandoned_orders() { |
229 | 229 | $args = array( |
230 | 230 | 'status' => 'pending', |
231 | - 'number' => - 1, |
|
231 | + 'number' => -1, |
|
232 | 232 | 'fields' => 'ids' |
233 | 233 | ); |
234 | 234 | |
235 | - add_filter( 'posts_where', 'give_filter_where_older_than_week' ); |
|
235 | + add_filter('posts_where', 'give_filter_where_older_than_week'); |
|
236 | 236 | |
237 | - $payments = give_get_payments( $args ); |
|
237 | + $payments = give_get_payments($args); |
|
238 | 238 | |
239 | - remove_filter( 'posts_where', 'give_filter_where_older_than_week' ); |
|
239 | + remove_filter('posts_where', 'give_filter_where_older_than_week'); |
|
240 | 240 | |
241 | - if ( $payments ) { |
|
242 | - foreach ( $payments as $payment ) { |
|
243 | - give_update_payment_status( $payment, 'abandoned' ); |
|
241 | + if ($payments) { |
|
242 | + foreach ($payments as $payment) { |
|
243 | + give_update_payment_status($payment, 'abandoned'); |
|
244 | 244 | } |
245 | 245 | } |
246 | 246 | } |
247 | 247 | |
248 | -add_action( 'give_weekly_scheduled_events', 'give_mark_abandoned_orders' ); |
|
248 | +add_action('give_weekly_scheduled_events', 'give_mark_abandoned_orders'); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -50,50 +50,50 @@ discard block |
||
50 | 50 | */ |
51 | 51 | |
52 | 52 | // https://gist.github.com/justinph/5197810 |
53 | - function validate_gravatar( $id_or_email ) { |
|
53 | + function validate_gravatar($id_or_email) { |
|
54 | 54 | //id or email code borrowed from wp-includes/pluggable.php |
55 | 55 | $email = ''; |
56 | - if ( is_numeric( $id_or_email ) ) { |
|
56 | + if (is_numeric($id_or_email)) { |
|
57 | 57 | $id = (int) $id_or_email; |
58 | - $user = get_userdata( $id ); |
|
59 | - if ( $user ) { |
|
58 | + $user = get_userdata($id); |
|
59 | + if ($user) { |
|
60 | 60 | $email = $user->user_email; |
61 | 61 | } |
62 | - } elseif ( is_object( $id_or_email ) ) { |
|
62 | + } elseif (is_object($id_or_email)) { |
|
63 | 63 | // No avatar for pingbacks or trackbacks |
64 | - $allowed_comment_types = apply_filters( 'get_avatar_comment_types', array( 'comment' ) ); |
|
65 | - if ( ! empty( $id_or_email->comment_type ) && ! in_array( $id_or_email->comment_type, (array) $allowed_comment_types ) ) { |
|
64 | + $allowed_comment_types = apply_filters('get_avatar_comment_types', array('comment')); |
|
65 | + if ( ! empty($id_or_email->comment_type) && ! in_array($id_or_email->comment_type, (array) $allowed_comment_types)) { |
|
66 | 66 | return false; |
67 | 67 | } |
68 | 68 | |
69 | - if ( ! empty( $id_or_email->user_id ) ) { |
|
69 | + if ( ! empty($id_or_email->user_id)) { |
|
70 | 70 | $id = (int) $id_or_email->user_id; |
71 | - $user = get_userdata( $id ); |
|
72 | - if ( $user ) { |
|
71 | + $user = get_userdata($id); |
|
72 | + if ($user) { |
|
73 | 73 | $email = $user->user_email; |
74 | 74 | } |
75 | - } elseif ( ! empty( $id_or_email->comment_author_email ) ) { |
|
75 | + } elseif ( ! empty($id_or_email->comment_author_email)) { |
|
76 | 76 | $email = $id_or_email->comment_author_email; |
77 | 77 | } |
78 | 78 | } else { |
79 | 79 | $email = $id_or_email; |
80 | 80 | } |
81 | 81 | |
82 | - $hashkey = md5( strtolower( trim( $email ) ) ); |
|
83 | - $uri = 'http://www.gravatar.com/avatar/' . $hashkey . '?d=404'; |
|
82 | + $hashkey = md5(strtolower(trim($email))); |
|
83 | + $uri = 'http://www.gravatar.com/avatar/'.$hashkey.'?d=404'; |
|
84 | 84 | |
85 | - $data = wp_cache_get( $hashkey ); |
|
86 | - if ( false === $data ) { |
|
87 | - $response = wp_remote_head( $uri ); |
|
88 | - if ( is_wp_error( $response ) ) { |
|
85 | + $data = wp_cache_get($hashkey); |
|
86 | + if (false === $data) { |
|
87 | + $response = wp_remote_head($uri); |
|
88 | + if (is_wp_error($response)) { |
|
89 | 89 | $data = 'not200'; |
90 | 90 | } else { |
91 | 91 | $data = $response['response']['code']; |
92 | 92 | } |
93 | - wp_cache_set( $hashkey, $data, $group = '', $expire = 60 * 5 ); |
|
93 | + wp_cache_set($hashkey, $data, $group = '', $expire = 60 * 5); |
|
94 | 94 | |
95 | 95 | } |
96 | - if ( $data == '200' ) { |
|
96 | + if ($data == '200') { |
|
97 | 97 | return true; |
98 | 98 | } else { |
99 | 99 | return false; |
@@ -108,17 +108,17 @@ discard block |
||
108 | 108 | * |
109 | 109 | * @param int $form_id |
110 | 110 | */ |
111 | - function get_log_ids( $form_id = '' ) { |
|
111 | + function get_log_ids($form_id = '') { |
|
112 | 112 | |
113 | 113 | // get Give_Logging class |
114 | 114 | global $give_logs; |
115 | 115 | |
116 | 116 | // get log for this form |
117 | - $logs = $give_logs->get_logs( $form_id ); |
|
117 | + $logs = $give_logs->get_logs($form_id); |
|
118 | 118 | |
119 | - if ( $logs ) { |
|
119 | + if ($logs) { |
|
120 | 120 | // make an array with all the donor IDs |
121 | - foreach ( $logs as $log ) { |
|
121 | + foreach ($logs as $log) { |
|
122 | 122 | $log_ids[] = $log->ID; |
123 | 123 | } |
124 | 124 | |
@@ -135,49 +135,49 @@ discard block |
||
135 | 135 | * |
136 | 136 | * @since 1.0 |
137 | 137 | */ |
138 | - function get_payment_ids( $form_id = '' ) { |
|
138 | + function get_payment_ids($form_id = '') { |
|
139 | 139 | |
140 | 140 | global $give_options; |
141 | 141 | |
142 | - $log_ids = $this->get_log_ids( $form_id ); |
|
142 | + $log_ids = $this->get_log_ids($form_id); |
|
143 | 143 | |
144 | - if ( $log_ids ) { |
|
144 | + if ($log_ids) { |
|
145 | 145 | |
146 | 146 | $payment_ids = array(); |
147 | 147 | |
148 | - foreach ( $log_ids as $id ) { |
|
148 | + foreach ($log_ids as $id) { |
|
149 | 149 | // get the payment ID for each corresponding log ID |
150 | - $payment_ids[] = get_post_meta( $id, '_give_log_payment_id', true ); |
|
150 | + $payment_ids[] = get_post_meta($id, '_give_log_payment_id', true); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | // remove donors who have purchased more than once so we can have unique avatars |
154 | 154 | $unique_emails = array(); |
155 | 155 | |
156 | - foreach ( $payment_ids as $key => $id ) { |
|
156 | + foreach ($payment_ids as $key => $id) { |
|
157 | 157 | |
158 | - $email = get_post_meta( $id, '_give_payment_user_email', true ); |
|
158 | + $email = get_post_meta($id, '_give_payment_user_email', true); |
|
159 | 159 | |
160 | - if ( isset ( $give_options['give_donators_gravatars_has_gravatar_account'] ) ) { |
|
161 | - if ( ! $this->validate_gravatar( $email ) ) { |
|
160 | + if (isset ($give_options['give_donators_gravatars_has_gravatar_account'])) { |
|
161 | + if ( ! $this->validate_gravatar($email)) { |
|
162 | 162 | continue; |
163 | 163 | } |
164 | 164 | } |
165 | 165 | |
166 | - $unique_emails[ $id ] = get_post_meta( $id, '_give_payment_user_email', true ); |
|
166 | + $unique_emails[$id] = get_post_meta($id, '_give_payment_user_email', true); |
|
167 | 167 | |
168 | 168 | } |
169 | 169 | |
170 | 170 | // strip duplicate emails |
171 | - $unique_emails = array_unique( $unique_emails ); |
|
171 | + $unique_emails = array_unique($unique_emails); |
|
172 | 172 | |
173 | 173 | // convert the unique IDs back into simple array |
174 | - foreach ( $unique_emails as $id => $email ) { |
|
174 | + foreach ($unique_emails as $id => $email) { |
|
175 | 175 | $unique_ids[] = $id; |
176 | 176 | } |
177 | 177 | |
178 | 178 | // randomize the payment IDs if enabled |
179 | - if ( isset( $give_options['give_donators_gravatars_random_gravatars'] ) ) { |
|
180 | - shuffle( $unique_ids ); |
|
179 | + if (isset($give_options['give_donators_gravatars_random_gravatars'])) { |
|
180 | + shuffle($unique_ids); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | // return our unique IDs |
@@ -193,10 +193,10 @@ discard block |
||
193 | 193 | * |
194 | 194 | * @since 1.0 |
195 | 195 | */ |
196 | - function gravatars( $form_id = false, $title = '' ) { |
|
196 | + function gravatars($form_id = false, $title = '') { |
|
197 | 197 | |
198 | 198 | // unique $payment_ids |
199 | - $payment_ids = $this->get_payment_ids( $form_id ); |
|
199 | + $payment_ids = $this->get_payment_ids($form_id); |
|
200 | 200 | |
201 | 201 | // var_dump( $payment_ids ); |
202 | 202 | // var_dump( $this->get_log_ids( get_the_ID() ) ); |
@@ -204,14 +204,14 @@ discard block |
||
204 | 204 | global $give_options; |
205 | 205 | |
206 | 206 | // return if no ID |
207 | - if ( ! $form_id ) { |
|
207 | + if ( ! $form_id) { |
|
208 | 208 | return; |
209 | 209 | } |
210 | 210 | |
211 | 211 | // minimum amount of purchases before showing gravatars |
212 | 212 | // if the number of items in array is not greater or equal to the number specified, then exit |
213 | - if ( isset( $give_options['give_donators_gravatars_min_purchases_required'] ) && '' != $give_options['give_donators_gravatars_min_purchases_required'] ) { |
|
214 | - if ( ! ( count( $payment_ids ) >= $give_options['give_donators_gravatars_min_purchases_required'] ) ) { |
|
213 | + if (isset($give_options['give_donators_gravatars_min_purchases_required']) && '' != $give_options['give_donators_gravatars_min_purchases_required']) { |
|
214 | + if ( ! (count($payment_ids) >= $give_options['give_donators_gravatars_min_purchases_required'])) { |
|
215 | 215 | return; |
216 | 216 | } |
217 | 217 | } |
@@ -222,51 +222,51 @@ discard block |
||
222 | 222 | echo '<div id="give-purchase-gravatars">'; |
223 | 223 | |
224 | 224 | |
225 | - if ( isset ( $title ) ) { |
|
225 | + if (isset ($title)) { |
|
226 | 226 | |
227 | - if ( $title ) { |
|
228 | - echo apply_filters( 'give_donators_gravatars_title', '<h3 class="give-gravatars-title">' . esc_attr( $title ) . '</h3>' ); |
|
229 | - } elseif ( isset( $give_options['give_donators_gravatars_heading'] ) ) { |
|
230 | - echo apply_filters( 'give_donators_gravatars_title', '<h3 class="give-gravatars-title">' . esc_attr( $give_options['give_donators_gravatars_heading'] ) . '</h2>' ); |
|
227 | + if ($title) { |
|
228 | + echo apply_filters('give_donators_gravatars_title', '<h3 class="give-gravatars-title">'.esc_attr($title).'</h3>'); |
|
229 | + } elseif (isset($give_options['give_donators_gravatars_heading'])) { |
|
230 | + echo apply_filters('give_donators_gravatars_title', '<h3 class="give-gravatars-title">'.esc_attr($give_options['give_donators_gravatars_heading']).'</h2>'); |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | } |
234 | 234 | echo '<ul class="give-purchase-gravatars-list">'; |
235 | 235 | $i = 0; |
236 | 236 | |
237 | - if ( $payment_ids ) { |
|
238 | - foreach ( $payment_ids as $id ) { |
|
237 | + if ($payment_ids) { |
|
238 | + foreach ($payment_ids as $id) { |
|
239 | 239 | |
240 | 240 | // Give saves a blank option even when the control is turned off, hence the extra check |
241 | - if ( isset( $give_options['give_donators_gravatars_maximum_number'] ) && '' != $give_options['give_donators_gravatars_maximum_number'] && $i == $give_options['give_donators_gravatars_maximum_number'] ) { |
|
241 | + if (isset($give_options['give_donators_gravatars_maximum_number']) && '' != $give_options['give_donators_gravatars_maximum_number'] && $i == $give_options['give_donators_gravatars_maximum_number']) { |
|
242 | 242 | continue; |
243 | 243 | } |
244 | 244 | |
245 | 245 | // get the payment meta |
246 | - $payment_meta = get_post_meta( $id, '_give_payment_meta', true ); |
|
246 | + $payment_meta = get_post_meta($id, '_give_payment_meta', true); |
|
247 | 247 | |
248 | 248 | // unserialize the payment meta |
249 | - $user_info = maybe_unserialize( $payment_meta['user_info'] ); |
|
249 | + $user_info = maybe_unserialize($payment_meta['user_info']); |
|
250 | 250 | |
251 | 251 | // get donor's first name |
252 | 252 | $name = $user_info['first_name']; |
253 | 253 | |
254 | 254 | // get donor's email |
255 | - $email = get_post_meta( $id, '_give_payment_user_email', true ); |
|
255 | + $email = get_post_meta($id, '_give_payment_user_email', true); |
|
256 | 256 | |
257 | 257 | // set gravatar size and provide filter |
258 | - $size = isset( $give_options['give_donators_gravatars_gravatar_size'] ) ? apply_filters( 'give_donators_gravatars_gravatar_size', $give_options['give_donators_gravatars_gravatar_size'] ) : ''; |
|
258 | + $size = isset($give_options['give_donators_gravatars_gravatar_size']) ? apply_filters('give_donators_gravatars_gravatar_size', $give_options['give_donators_gravatars_gravatar_size']) : ''; |
|
259 | 259 | |
260 | 260 | // default image |
261 | - $default_image = apply_filters( 'give_donators_gravatars_gravatar_default_image', false ); |
|
261 | + $default_image = apply_filters('give_donators_gravatars_gravatar_default_image', false); |
|
262 | 262 | |
263 | 263 | // assemble output |
264 | 264 | $output .= '<li>'; |
265 | 265 | |
266 | - $output .= get_avatar( $email, $size, $default_image, $name ); |
|
266 | + $output .= get_avatar($email, $size, $default_image, $name); |
|
267 | 267 | $output .= '</li>'; |
268 | 268 | |
269 | - $i ++; |
|
269 | + $i++; |
|
270 | 270 | |
271 | 271 | } // end foreach |
272 | 272 | } |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | echo '</ul>'; |
276 | 276 | echo '</div>'; |
277 | 277 | |
278 | - return apply_filters( 'give_donators_gravatars', ob_get_clean() ); |
|
278 | + return apply_filters('give_donators_gravatars', ob_get_clean()); |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | /** |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | * @since 1.0 |
285 | 285 | */ |
286 | 286 | function register_widget() { |
287 | - register_widget( 'Give_Donators_Gravatars_Widget' ); |
|
287 | + register_widget('Give_Donators_Gravatars_Widget'); |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | /** |
@@ -293,19 +293,19 @@ discard block |
||
293 | 293 | * @since 1.0 |
294 | 294 | * @todo set the ID to get_the_ID() if ID parameter is not passed through. Otherwise it will incorrectly get other gravatars |
295 | 295 | */ |
296 | - function shortcode( $atts, $content = null ) { |
|
296 | + function shortcode($atts, $content = null) { |
|
297 | 297 | |
298 | - $atts = shortcode_atts( array( |
|
298 | + $atts = shortcode_atts(array( |
|
299 | 299 | 'id' => '', |
300 | 300 | 'title' => '' |
301 | - ), $atts, 'give_donators_gravatars' ); |
|
301 | + ), $atts, 'give_donators_gravatars'); |
|
302 | 302 | |
303 | 303 | // if no ID is passed on single give_forms pages, get the correct ID |
304 | - if ( is_singular( 'give_forms' ) ) { |
|
304 | + if (is_singular('give_forms')) { |
|
305 | 305 | $id = get_the_ID(); |
306 | 306 | } |
307 | 307 | |
308 | - $content = $this->gravatars( $atts['id'], $atts['title'] ); |
|
308 | + $content = $this->gravatars($atts['id'], $atts['title']); |
|
309 | 309 | |
310 | 310 | return $content; |
311 | 311 | |
@@ -316,56 +316,56 @@ discard block |
||
316 | 316 | * |
317 | 317 | * @since 1.0 |
318 | 318 | */ |
319 | - function settings( $settings ) { |
|
319 | + function settings($settings) { |
|
320 | 320 | |
321 | 321 | $give_gravatar_settings = array( |
322 | 322 | array( |
323 | - 'name' => __( 'Donator Gravatars', 'give' ), |
|
323 | + 'name' => __('Donator Gravatars', 'give'), |
|
324 | 324 | 'desc' => '<hr>', |
325 | 325 | 'id' => 'give_title', |
326 | 326 | 'type' => 'give_title' |
327 | 327 | ), |
328 | 328 | array( |
329 | - 'name' => __( 'Heading', 'give' ), |
|
330 | - 'desc' => __( 'The heading to display above the Gravatars', 'give' ), |
|
329 | + 'name' => __('Heading', 'give'), |
|
330 | + 'desc' => __('The heading to display above the Gravatars', 'give'), |
|
331 | 331 | 'type' => 'text', |
332 | 332 | 'id' => 'give_donators_gravatars_heading' |
333 | 333 | ), |
334 | 334 | array( |
335 | - 'name' => __( 'Gravatar Size', 'give' ), |
|
336 | - 'desc' => __( 'The size of each Gravatar in pixels (512px maximum)', 'give' ), |
|
335 | + 'name' => __('Gravatar Size', 'give'), |
|
336 | + 'desc' => __('The size of each Gravatar in pixels (512px maximum)', 'give'), |
|
337 | 337 | 'type' => 'text_small', |
338 | 338 | 'id' => 'give_donators_gravatars_gravatar_size', |
339 | 339 | 'default' => '64' |
340 | 340 | ), |
341 | 341 | array( |
342 | - 'name' => __( 'Minimum Unique Purchases Required', 'give' ), |
|
343 | - 'desc' => sprintf( __( 'The minimum number of unique purchases a %s must have before the Gravatars are shown. Leave blank for no minimum.', 'give' ), strtolower( give_get_forms_label_singular() ) ), |
|
342 | + 'name' => __('Minimum Unique Purchases Required', 'give'), |
|
343 | + 'desc' => sprintf(__('The minimum number of unique purchases a %s must have before the Gravatars are shown. Leave blank for no minimum.', 'give'), strtolower(give_get_forms_label_singular())), |
|
344 | 344 | 'type' => 'text_small', |
345 | 345 | 'id' => 'give_donators_gravatars_min_purchases_required', |
346 | 346 | ), |
347 | 347 | array( |
348 | - 'name' => __( 'Maximum Gravatars To Show', 'give' ), |
|
349 | - 'desc' => __( 'The maximum number of gravatars to show. Leave blank for no limit.', 'give' ), |
|
348 | + 'name' => __('Maximum Gravatars To Show', 'give'), |
|
349 | + 'desc' => __('The maximum number of gravatars to show. Leave blank for no limit.', 'give'), |
|
350 | 350 | 'type' => 'text', |
351 | 351 | 'id' => 'give_donators_gravatars_maximum_number', |
352 | 352 | 'default' => '20', |
353 | 353 | ), |
354 | 354 | array( |
355 | - 'name' => __( 'Gravatar Visibility', 'give' ), |
|
356 | - 'desc' => __( 'Only show donators with a Gravatar account', 'give' ), |
|
355 | + 'name' => __('Gravatar Visibility', 'give'), |
|
356 | + 'desc' => __('Only show donators with a Gravatar account', 'give'), |
|
357 | 357 | 'id' => 'give_donators_gravatars_has_gravatar_account', |
358 | 358 | 'type' => 'checkbox', |
359 | 359 | ), |
360 | 360 | array( |
361 | - 'name' => __( 'Randomize Gravatars', 'give' ), |
|
362 | - 'desc' => __( 'Randomize the Gravatars', 'give' ), |
|
361 | + 'name' => __('Randomize Gravatars', 'give'), |
|
362 | + 'desc' => __('Randomize the Gravatars', 'give'), |
|
363 | 363 | 'id' => 'give_donators_gravatars_random_gravatars', |
364 | 364 | 'type' => 'checkbox', |
365 | 365 | ), |
366 | 366 | ); |
367 | 367 | |
368 | - return array_merge( $settings, $give_gravatar_settings ); |
|
368 | + return array_merge($settings, $give_gravatar_settings); |
|
369 | 369 | } |
370 | 370 | |
371 | 371 | } |
@@ -383,12 +383,12 @@ discard block |
||
383 | 383 | */ |
384 | 384 | function give_donators_gravatars_widget() { |
385 | 385 | |
386 | - $give_label_singular = function_exists( 'give_get_forms_label_singular' ) ? strtolower( give_get_forms_label_singular() ) : null; |
|
386 | + $give_label_singular = function_exists('give_get_forms_label_singular') ? strtolower(give_get_forms_label_singular()) : null; |
|
387 | 387 | |
388 | 388 | // widget settings |
389 | 389 | $widget_ops = array( |
390 | 390 | 'classname' => 'give-donators-gravatars', |
391 | - 'description' => sprintf( __( 'Displays gravatars of people who have donated using your your %s. Will only show on the single %s page.', 'give' ), $give_label_singular, $give_label_singular ) |
|
391 | + 'description' => sprintf(__('Displays gravatars of people who have donated using your your %s. Will only show on the single %s page.', 'give'), $give_label_singular, $give_label_singular) |
|
392 | 392 | ); |
393 | 393 | |
394 | 394 | // widget control settings |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | // create the widget |
402 | 402 | $this->WP_Widget( |
403 | 403 | 'give_donators_gravatars_widget', |
404 | - __( 'Give Donators Gravatars', 'give' ), |
|
404 | + __('Give Donators Gravatars', 'give'), |
|
405 | 405 | $widget_ops, |
406 | 406 | $control_ops |
407 | 407 | ); |
@@ -412,29 +412,29 @@ discard block |
||
412 | 412 | /* |
413 | 413 | * Outputs the content of the widget |
414 | 414 | */ |
415 | - function widget( $args, $instance ) { |
|
415 | + function widget($args, $instance) { |
|
416 | 416 | global $give_options; |
417 | 417 | |
418 | - extract( $args ); |
|
418 | + extract($args); |
|
419 | 419 | |
420 | - if ( ! is_singular( 'give_forms' ) ) { |
|
420 | + if ( ! is_singular('give_forms')) { |
|
421 | 421 | return; |
422 | 422 | } |
423 | 423 | |
424 | 424 | // Variables from widget settings |
425 | - $title = apply_filters( 'widget_title', $instance['title'] ); |
|
425 | + $title = apply_filters('widget_title', $instance['title']); |
|
426 | 426 | |
427 | 427 | // Used by themes. Opens the widget |
428 | 428 | echo $before_widget; |
429 | 429 | |
430 | 430 | // Display the widget title |
431 | - if ( $title ) { |
|
432 | - echo $before_title . $title . $after_title; |
|
431 | + if ($title) { |
|
432 | + echo $before_title.$title.$after_title; |
|
433 | 433 | } |
434 | 434 | |
435 | 435 | $gravatars = new Give_Donators_Gravatars(); |
436 | 436 | |
437 | - echo $gravatars->gravatars( get_the_ID(), null ); // remove title |
|
437 | + echo $gravatars->gravatars(get_the_ID(), null); // remove title |
|
438 | 438 | |
439 | 439 | // Used by themes. Closes the widget |
440 | 440 | echo $after_widget; |
@@ -444,11 +444,11 @@ discard block |
||
444 | 444 | /* |
445 | 445 | * Update function. Processes widget options to be saved |
446 | 446 | */ |
447 | - function update( $new_instance, $old_instance ) { |
|
447 | + function update($new_instance, $old_instance) { |
|
448 | 448 | |
449 | 449 | $instance = $old_instance; |
450 | 450 | |
451 | - $instance['title'] = strip_tags( $new_instance['title'] ); |
|
451 | + $instance['title'] = strip_tags($new_instance['title']); |
|
452 | 452 | |
453 | 453 | return $instance; |
454 | 454 | |
@@ -457,19 +457,19 @@ discard block |
||
457 | 457 | /* |
458 | 458 | * Form function. Displays the actual form on the widget page |
459 | 459 | */ |
460 | - function form( $instance ) { |
|
460 | + function form($instance) { |
|
461 | 461 | |
462 | 462 | // Set up some default widget settings. |
463 | 463 | $defaults = array( |
464 | 464 | 'title' => '', |
465 | 465 | ); |
466 | 466 | |
467 | - $instance = wp_parse_args( (array) $instance, $defaults ); ?> |
|
467 | + $instance = wp_parse_args((array) $instance, $defaults); ?> |
|
468 | 468 | |
469 | 469 | <!-- Title --> |
470 | 470 | <p> |
471 | - <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'give' ) ?></label> |
|
472 | - <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo $instance['title']; ?>" /> |
|
471 | + <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'give') ?></label> |
|
472 | + <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $instance['title']; ?>" /> |
|
473 | 473 | </p> |
474 | 474 | |
475 | 475 |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -39,46 +39,46 @@ discard block |
||
39 | 39 | * |
40 | 40 | * @return float|int |
41 | 41 | */ |
42 | - public function get_sales( $form_id = 0, $start_date = false, $end_date = false, $status = 'publish' ) { |
|
42 | + public function get_sales($form_id = 0, $start_date = false, $end_date = false, $status = 'publish') { |
|
43 | 43 | |
44 | - $this->setup_dates( $start_date, $end_date ); |
|
44 | + $this->setup_dates($start_date, $end_date); |
|
45 | 45 | |
46 | 46 | // Make sure start date is valid |
47 | - if ( is_wp_error( $this->start_date ) ) { |
|
47 | + if (is_wp_error($this->start_date)) { |
|
48 | 48 | return $this->start_date; |
49 | 49 | } |
50 | 50 | |
51 | 51 | // Make sure end date is valid |
52 | - if ( is_wp_error( $this->end_date ) ) { |
|
52 | + if (is_wp_error($this->end_date)) { |
|
53 | 53 | return $this->end_date; |
54 | 54 | } |
55 | 55 | |
56 | - if ( empty( $form_id ) ) { |
|
56 | + if (empty($form_id)) { |
|
57 | 57 | |
58 | 58 | // Global sale stats |
59 | - add_filter( 'give_count_payments_where', array( $this, 'count_where' ) ); |
|
59 | + add_filter('give_count_payments_where', array($this, 'count_where')); |
|
60 | 60 | |
61 | - if ( is_array( $status ) ) { |
|
61 | + if (is_array($status)) { |
|
62 | 62 | $count = 0; |
63 | - foreach ( $status as $payment_status ) { |
|
63 | + foreach ($status as $payment_status) { |
|
64 | 64 | $count += give_count_payments()->$payment_status; |
65 | 65 | } |
66 | 66 | } else { |
67 | 67 | $count = give_count_payments()->$status; |
68 | 68 | } |
69 | 69 | |
70 | - remove_filter( 'give_count_payments_where', array( $this, 'count_where' ) ); |
|
70 | + remove_filter('give_count_payments_where', array($this, 'count_where')); |
|
71 | 71 | |
72 | 72 | } else { |
73 | 73 | |
74 | 74 | // Product specific stats |
75 | 75 | global $give_logs; |
76 | 76 | |
77 | - add_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
77 | + add_filter('posts_where', array($this, 'payments_where')); |
|
78 | 78 | |
79 | - $count = $give_logs->get_log_count( $form_id, 'sale' ); |
|
79 | + $count = $give_logs->get_log_count($form_id, 'sale'); |
|
80 | 80 | |
81 | - remove_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
81 | + remove_filter('posts_where', array($this, 'payments_where')); |
|
82 | 82 | |
83 | 83 | } |
84 | 84 | |
@@ -99,31 +99,31 @@ discard block |
||
99 | 99 | * |
100 | 100 | * @return float|int |
101 | 101 | */ |
102 | - public function get_earnings( $form_id = 0, $start_date = false, $end_date = false ) { |
|
102 | + public function get_earnings($form_id = 0, $start_date = false, $end_date = false) { |
|
103 | 103 | |
104 | 104 | global $wpdb; |
105 | 105 | |
106 | - $this->setup_dates( $start_date, $end_date ); |
|
106 | + $this->setup_dates($start_date, $end_date); |
|
107 | 107 | |
108 | 108 | // Make sure start date is valid |
109 | - if ( is_wp_error( $this->start_date ) ) { |
|
109 | + if (is_wp_error($this->start_date)) { |
|
110 | 110 | return $this->start_date; |
111 | 111 | } |
112 | 112 | |
113 | 113 | // Make sure end date is valid |
114 | - if ( is_wp_error( $this->end_date ) ) { |
|
114 | + if (is_wp_error($this->end_date)) { |
|
115 | 115 | return $this->end_date; |
116 | 116 | } |
117 | 117 | |
118 | - add_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
118 | + add_filter('posts_where', array($this, 'payments_where')); |
|
119 | 119 | |
120 | - if ( empty( $form_id ) ) { |
|
120 | + if (empty($form_id)) { |
|
121 | 121 | |
122 | 122 | // Global earning stats |
123 | 123 | $args = array( |
124 | 124 | 'post_type' => 'give_payment', |
125 | 125 | 'nopaging' => true, |
126 | - 'post_status' => array( 'publish', 'revoked' ), |
|
126 | + 'post_status' => array('publish', 'revoked'), |
|
127 | 127 | 'fields' => 'ids', |
128 | 128 | 'update_post_term_cache' => false, |
129 | 129 | 'suppress_filters' => false, |
@@ -134,19 +134,19 @@ discard block |
||
134 | 134 | // This is not a valid query arg, but is used for cache keying |
135 | 135 | ); |
136 | 136 | |
137 | - $args = apply_filters( 'give_stats_earnings_args', $args ); |
|
138 | - $key = 'give_stats_' . substr( md5( serialize( $args ) ), 0, 15 ); |
|
137 | + $args = apply_filters('give_stats_earnings_args', $args); |
|
138 | + $key = 'give_stats_'.substr(md5(serialize($args)), 0, 15); |
|
139 | 139 | |
140 | - $earnings = get_transient( $key ); |
|
141 | - if ( false === $earnings ) { |
|
142 | - $sales = get_posts( $args ); |
|
140 | + $earnings = get_transient($key); |
|
141 | + if (false === $earnings) { |
|
142 | + $sales = get_posts($args); |
|
143 | 143 | $earnings = 0; |
144 | - if ( $sales ) { |
|
145 | - $sales = implode( ',', $sales ); |
|
146 | - $earnings += $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$sales})" ); |
|
144 | + if ($sales) { |
|
145 | + $sales = implode(',', $sales); |
|
146 | + $earnings += $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$sales})"); |
|
147 | 147 | } |
148 | 148 | // Cache the results for one hour |
149 | - set_transient( $key, $earnings, HOUR_IN_SECONDS ); |
|
149 | + set_transient($key, $earnings, HOUR_IN_SECONDS); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | } else { |
@@ -167,33 +167,33 @@ discard block |
||
167 | 167 | // This is not a valid query arg, but is used for cache keying |
168 | 168 | ); |
169 | 169 | |
170 | - $args = apply_filters( 'give_stats_earnings_args', $args ); |
|
171 | - $key = 'give_stats_' . substr( md5( serialize( $args ) ), 0, 15 ); |
|
170 | + $args = apply_filters('give_stats_earnings_args', $args); |
|
171 | + $key = 'give_stats_'.substr(md5(serialize($args)), 0, 15); |
|
172 | 172 | //Set transient for faster stats |
173 | - $earnings = get_transient( $key ); |
|
173 | + $earnings = get_transient($key); |
|
174 | 174 | |
175 | - if ( false === $earnings ) { |
|
175 | + if (false === $earnings) { |
|
176 | 176 | |
177 | - $log_ids = $give_logs->get_connected_logs( $args, 'sale' ); |
|
177 | + $log_ids = $give_logs->get_connected_logs($args, 'sale'); |
|
178 | 178 | $earnings = 0; |
179 | 179 | |
180 | - if ( $log_ids ) { |
|
181 | - $log_ids = implode( ',', $log_ids ); |
|
182 | - $payment_ids = $wpdb->get_col( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids);" ); |
|
183 | - foreach ( $payment_ids as $payment_id ) { |
|
180 | + if ($log_ids) { |
|
181 | + $log_ids = implode(',', $log_ids); |
|
182 | + $payment_ids = $wpdb->get_col("SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids);"); |
|
183 | + foreach ($payment_ids as $payment_id) { |
|
184 | 184 | $earnings += give_get_payment_amount($payment_id); |
185 | 185 | } |
186 | 186 | } |
187 | 187 | |
188 | 188 | // Cache the results for one hour |
189 | - set_transient( $key, $earnings, 60 * 60 ); |
|
189 | + set_transient($key, $earnings, 60 * 60); |
|
190 | 190 | } |
191 | 191 | } |
192 | 192 | |
193 | 193 | //remove our filter |
194 | - remove_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
194 | + remove_filter('posts_where', array($this, 'payments_where')); |
|
195 | 195 | //return earnings |
196 | - return round( $earnings, give_currency_decimal_filter() ); |
|
196 | + return round($earnings, give_currency_decimal_filter()); |
|
197 | 197 | |
198 | 198 | } |
199 | 199 | |
@@ -207,16 +207,16 @@ discard block |
||
207 | 207 | * |
208 | 208 | * @return array |
209 | 209 | */ |
210 | - public function get_best_selling( $number = 10 ) { |
|
210 | + public function get_best_selling($number = 10) { |
|
211 | 211 | |
212 | 212 | global $wpdb; |
213 | 213 | |
214 | - $give_forms = $wpdb->get_results( $wpdb->prepare( |
|
214 | + $give_forms = $wpdb->get_results($wpdb->prepare( |
|
215 | 215 | "SELECT post_id as form_id, max(meta_value) as sales |
216 | 216 | FROM $wpdb->postmeta WHERE meta_key='_give_form_sales' AND meta_value > 0 |
217 | 217 | GROUP BY meta_value+0 |
218 | 218 | DESC LIMIT %d;", $number |
219 | - ) ); |
|
219 | + )); |
|
220 | 220 | |
221 | 221 | return $give_forms; |
222 | 222 | } |