@@ -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,21 +28,21 @@ discard block |
||
28 | 28 | * |
29 | 29 | * @return void |
30 | 30 | */ |
31 | -function give_complete_purchase( $payment_id, $new_status, $old_status ) { |
|
31 | +function give_complete_purchase($payment_id, $new_status, $old_status) { |
|
32 | 32 | |
33 | 33 | // Make sure that payments are only completed once. |
34 | - if ( $old_status == 'publish' || $old_status == 'complete' ) { |
|
34 | + if ($old_status == 'publish' || $old_status == 'complete') { |
|
35 | 35 | return; |
36 | 36 | } |
37 | 37 | |
38 | 38 | // Make sure the payment completion is only processed when new status is complete. |
39 | - if ( $new_status != 'publish' && $new_status != 'complete' ) { |
|
39 | + if ($new_status != 'publish' && $new_status != 'complete') { |
|
40 | 40 | return; |
41 | 41 | } |
42 | 42 | |
43 | - $payment = new Give_Payment( $payment_id ); |
|
43 | + $payment = new Give_Payment($payment_id); |
|
44 | 44 | |
45 | - $creation_date = get_post_field( 'post_date', $payment_id, 'raw' ); |
|
45 | + $creation_date = get_post_field('post_date', $payment_id, 'raw'); |
|
46 | 46 | $payment_meta = $payment->payment_meta; |
47 | 47 | $completed_date = $payment->completed_date; |
48 | 48 | $user_info = $payment->user_info; |
@@ -58,12 +58,12 @@ discard block |
||
58 | 58 | * |
59 | 59 | * @param int $payment_id The ID of the payment. |
60 | 60 | */ |
61 | - do_action( 'give_pre_complete_donation', $payment_id ); |
|
61 | + do_action('give_pre_complete_donation', $payment_id); |
|
62 | 62 | |
63 | 63 | // Ensure these actions only run once, ever. |
64 | - if ( empty( $completed_date ) ) { |
|
64 | + if (empty($completed_date)) { |
|
65 | 65 | |
66 | - give_record_donation_in_log( $form_id, $payment_id, $price_id, $creation_date ); |
|
66 | + give_record_donation_in_log($form_id, $payment_id, $price_id, $creation_date); |
|
67 | 67 | |
68 | 68 | /** |
69 | 69 | * Fires after logging donation record. |
@@ -74,29 +74,29 @@ discard block |
||
74 | 74 | * @param int $payment_id The ID number of the payment. |
75 | 75 | * @param array $payment_meta The payment meta. |
76 | 76 | */ |
77 | - do_action( 'give_complete_form_donation', $form_id, $payment_id, $payment_meta ); |
|
77 | + do_action('give_complete_form_donation', $form_id, $payment_id, $payment_meta); |
|
78 | 78 | |
79 | 79 | } |
80 | 80 | |
81 | 81 | // Increase the earnings for this form ID. |
82 | - give_increase_earnings( $form_id, $amount ); |
|
83 | - give_increase_donation_count( $form_id ); |
|
82 | + give_increase_earnings($form_id, $amount); |
|
83 | + give_increase_donation_count($form_id); |
|
84 | 84 | |
85 | 85 | // @todo: Refresh only range related stat cache |
86 | 86 | give_delete_donation_stats(); |
87 | 87 | |
88 | 88 | // Increase the donor's donation stats. |
89 | - $donor = new Give_Donor( $donor_id ); |
|
89 | + $donor = new Give_Donor($donor_id); |
|
90 | 90 | $donor->increase_purchase_count(); |
91 | - $donor->increase_value( $amount ); |
|
91 | + $donor->increase_value($amount); |
|
92 | 92 | |
93 | - give_increase_total_earnings( $amount ); |
|
93 | + give_increase_total_earnings($amount); |
|
94 | 94 | |
95 | 95 | // Ensure this action only runs once ever. |
96 | - if ( empty( $completed_date ) ) { |
|
96 | + if (empty($completed_date)) { |
|
97 | 97 | |
98 | 98 | // Save the completed date. |
99 | - $payment->completed_date = current_time( 'mysql' ); |
|
99 | + $payment->completed_date = current_time('mysql'); |
|
100 | 100 | $payment->save(); |
101 | 101 | |
102 | 102 | /** |
@@ -106,12 +106,12 @@ discard block |
||
106 | 106 | * |
107 | 107 | * @param int $payment_id The ID of the payment. |
108 | 108 | */ |
109 | - do_action( 'give_complete_donation', $payment_id ); |
|
109 | + do_action('give_complete_donation', $payment_id); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | } |
113 | 113 | |
114 | -add_action( 'give_update_payment_status', 'give_complete_purchase', 100, 3 ); |
|
114 | +add_action('give_update_payment_status', 'give_complete_purchase', 100, 3); |
|
115 | 115 | |
116 | 116 | |
117 | 117 | /** |
@@ -125,20 +125,20 @@ discard block |
||
125 | 125 | * |
126 | 126 | * @return void |
127 | 127 | */ |
128 | -function give_record_status_change( $payment_id, $new_status, $old_status ) { |
|
128 | +function give_record_status_change($payment_id, $new_status, $old_status) { |
|
129 | 129 | |
130 | 130 | // Get the list of statuses so that status in the payment note can be translated. |
131 | 131 | $stati = give_get_payment_statuses(); |
132 | - $old_status = isset( $stati[ $old_status ] ) ? $stati[ $old_status ] : $old_status; |
|
133 | - $new_status = isset( $stati[ $new_status ] ) ? $stati[ $new_status ] : $new_status; |
|
132 | + $old_status = isset($stati[$old_status]) ? $stati[$old_status] : $old_status; |
|
133 | + $new_status = isset($stati[$new_status]) ? $stati[$new_status] : $new_status; |
|
134 | 134 | |
135 | 135 | // translators: 1: old status 2: new status. |
136 | - $status_change = sprintf( esc_html__( 'Status changed from %1$s to %2$s.', 'give' ), $old_status, $new_status ); |
|
136 | + $status_change = sprintf(esc_html__('Status changed from %1$s to %2$s.', 'give'), $old_status, $new_status); |
|
137 | 137 | |
138 | - give_insert_payment_note( $payment_id, $status_change ); |
|
138 | + give_insert_payment_note($payment_id, $status_change); |
|
139 | 139 | } |
140 | 140 | |
141 | -add_action( 'give_update_payment_status', 'give_record_status_change', 100, 3 ); |
|
141 | +add_action('give_update_payment_status', 'give_record_status_change', 100, 3); |
|
142 | 142 | |
143 | 143 | |
144 | 144 | /** |
@@ -154,25 +154,25 @@ discard block |
||
154 | 154 | * |
155 | 155 | * @return void |
156 | 156 | */ |
157 | -function give_update_old_payments_with_totals( $data ) { |
|
158 | - if ( ! wp_verify_nonce( $data['_wpnonce'], 'give_upgrade_payments_nonce' ) ) { |
|
157 | +function give_update_old_payments_with_totals($data) { |
|
158 | + if ( ! wp_verify_nonce($data['_wpnonce'], 'give_upgrade_payments_nonce')) { |
|
159 | 159 | return; |
160 | 160 | } |
161 | 161 | |
162 | - if ( get_option( 'give_payment_totals_upgraded' ) ) { |
|
162 | + if (get_option('give_payment_totals_upgraded')) { |
|
163 | 163 | return; |
164 | 164 | } |
165 | 165 | |
166 | - $payments = give_get_payments( array( |
|
166 | + $payments = give_get_payments(array( |
|
167 | 167 | 'offset' => 0, |
168 | - 'number' => - 1, |
|
168 | + 'number' => -1, |
|
169 | 169 | 'mode' => 'all', |
170 | - ) ); |
|
170 | + )); |
|
171 | 171 | |
172 | - if ( $payments ) { |
|
173 | - foreach ( $payments as $payment ) { |
|
172 | + if ($payments) { |
|
173 | + foreach ($payments as $payment) { |
|
174 | 174 | |
175 | - $payment = new Give_Payment( $payment->ID ); |
|
175 | + $payment = new Give_Payment($payment->ID); |
|
176 | 176 | $meta = $payment->get_meta(); |
177 | 177 | |
178 | 178 | $payment->total = $meta['amount']; |
@@ -181,10 +181,10 @@ discard block |
||
181 | 181 | } |
182 | 182 | } |
183 | 183 | |
184 | - add_option( 'give_payment_totals_upgraded', 1 ); |
|
184 | + add_option('give_payment_totals_upgraded', 1); |
|
185 | 185 | } |
186 | 186 | |
187 | -add_action( 'give_upgrade_payments', 'give_update_old_payments_with_totals' ); |
|
187 | +add_action('give_upgrade_payments', 'give_update_old_payments_with_totals'); |
|
188 | 188 | |
189 | 189 | /** |
190 | 190 | * Mark Abandoned Donations |
@@ -198,17 +198,17 @@ discard block |
||
198 | 198 | function give_mark_abandoned_donations() { |
199 | 199 | $args = array( |
200 | 200 | 'status' => 'pending', |
201 | - 'number' => - 1, |
|
201 | + 'number' => -1, |
|
202 | 202 | 'output' => 'give_payments', |
203 | 203 | ); |
204 | 204 | |
205 | - add_filter( 'posts_where', 'give_filter_where_older_than_week' ); |
|
205 | + add_filter('posts_where', 'give_filter_where_older_than_week'); |
|
206 | 206 | |
207 | - $payments = give_get_payments( $args ); |
|
207 | + $payments = give_get_payments($args); |
|
208 | 208 | |
209 | - remove_filter( 'posts_where', 'give_filter_where_older_than_week' ); |
|
209 | + remove_filter('posts_where', 'give_filter_where_older_than_week'); |
|
210 | 210 | |
211 | - if ( $payments ) { |
|
211 | + if ($payments) { |
|
212 | 212 | /** |
213 | 213 | * Filter payment gateways: Used to set payment gateways which can be skip while transferring pending payment to abandon. |
214 | 214 | * |
@@ -216,14 +216,14 @@ discard block |
||
216 | 216 | * |
217 | 217 | * @param array $skip_payment_gateways Array of payment gateways |
218 | 218 | */ |
219 | - $skip_payment_gateways = apply_filters( 'give_mark_abandoned_donation_gateways', array( 'offline' ) ); |
|
219 | + $skip_payment_gateways = apply_filters('give_mark_abandoned_donation_gateways', array('offline')); |
|
220 | 220 | |
221 | 221 | /* @var Give_Payment $payment */ |
222 | - foreach ( $payments as $payment ) { |
|
223 | - $gateway = give_get_payment_gateway( $payment->ID ); |
|
222 | + foreach ($payments as $payment) { |
|
223 | + $gateway = give_get_payment_gateway($payment->ID); |
|
224 | 224 | |
225 | 225 | // Skip payment gateways. |
226 | - if ( in_array( $gateway, $skip_payment_gateways ) ) { |
|
226 | + if (in_array($gateway, $skip_payment_gateways)) { |
|
227 | 227 | continue; |
228 | 228 | } |
229 | 229 | |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | } |
234 | 234 | } |
235 | 235 | |
236 | -Give_Cron::add_weekly_event( 'give_mark_abandoned_donations' ); |
|
236 | +Give_Cron::add_weekly_event('give_mark_abandoned_donations'); |
|
237 | 237 | |
238 | 238 | |
239 | 239 | /** |
@@ -245,15 +245,15 @@ discard block |
||
245 | 245 | * |
246 | 246 | * @return void |
247 | 247 | */ |
248 | -function give_refresh_thismonth_stat_transients( $payment_ID ) { |
|
248 | +function give_refresh_thismonth_stat_transients($payment_ID) { |
|
249 | 249 | // Monthly stats. |
250 | - Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) ); |
|
250 | + Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats')); |
|
251 | 251 | |
252 | 252 | // @todo: Refresh only range related stat cache |
253 | 253 | give_delete_donation_stats(); |
254 | 254 | } |
255 | 255 | |
256 | -add_action( 'save_post_give_payment', 'give_refresh_thismonth_stat_transients' ); |
|
256 | +add_action('save_post_give_payment', 'give_refresh_thismonth_stat_transients'); |
|
257 | 257 | |
258 | 258 | |
259 | 259 | /** |
@@ -269,12 +269,12 @@ discard block |
||
269 | 269 | * |
270 | 270 | * @return array |
271 | 271 | */ |
272 | -function give_bc_v20_get_payment_meta( $check, $object_id, $meta_key, $single ) { |
|
272 | +function give_bc_v20_get_payment_meta($check, $object_id, $meta_key, $single) { |
|
273 | 273 | // Bailout. |
274 | 274 | if ( |
275 | - 'give_payment' !== get_post_type( $object_id ) || |
|
275 | + 'give_payment' !== get_post_type($object_id) || |
|
276 | 276 | '_give_payment_meta' !== $meta_key || |
277 | - ! give_has_upgrade_completed( 'v20_upgrades_payment_metadata' ) |
|
277 | + ! give_has_upgrade_completed('v20_upgrades_payment_metadata') |
|
278 | 278 | ) { |
279 | 279 | return $check; |
280 | 280 | } |
@@ -282,73 +282,69 @@ discard block |
||
282 | 282 | $cache_key = "_give_payment_meta_{$object_id}"; |
283 | 283 | |
284 | 284 | // Get already calculate payment meta from cache. |
285 | - $payment_meta = Give_Cache::get_db_query( $cache_key ); |
|
285 | + $payment_meta = Give_Cache::get_db_query($cache_key); |
|
286 | 286 | |
287 | - if ( is_null( $payment_meta ) ) { |
|
287 | + if (is_null($payment_meta)) { |
|
288 | 288 | // Remove filter. |
289 | - remove_filter( 'get_post_metadata', 'give_bc_v20_get_payment_meta', 999 ); |
|
289 | + remove_filter('get_post_metadata', 'give_bc_v20_get_payment_meta', 999); |
|
290 | 290 | |
291 | - $donation = new Give_Payment( $object_id ); |
|
291 | + $donation = new Give_Payment($object_id); |
|
292 | 292 | |
293 | 293 | // Get all payment meta. |
294 | - $payment_meta = give_get_meta( $object_id ); |
|
294 | + $payment_meta = give_get_meta($object_id); |
|
295 | 295 | |
296 | 296 | // Set default value to array. |
297 | - if ( empty( $payment_meta ) ) { |
|
297 | + if (empty($payment_meta)) { |
|
298 | 298 | return $check; |
299 | 299 | } |
300 | 300 | |
301 | 301 | // Convert all meta key value to string instead of array |
302 | - array_walk( $payment_meta, function ( &$meta, $key ) { |
|
303 | - $meta = current( $meta ); |
|
302 | + array_walk($payment_meta, function(&$meta, $key) { |
|
303 | + $meta = current($meta); |
|
304 | 304 | } ); |
305 | 305 | |
306 | 306 | /** |
307 | 307 | * Add backward compatibility to old meta keys. |
308 | 308 | */ |
309 | 309 | // Donation key. |
310 | - $payment_meta['key'] = ! empty( $payment_meta['_give_payment_purchase_key'] ) ? $payment_meta['_give_payment_purchase_key'] : ''; |
|
310 | + $payment_meta['key'] = ! empty($payment_meta['_give_payment_purchase_key']) ? $payment_meta['_give_payment_purchase_key'] : ''; |
|
311 | 311 | |
312 | 312 | // Donation form. |
313 | - $payment_meta['form_title'] = ! empty( $payment_meta['_give_payment_form_title'] ) ? $payment_meta['_give_payment_form_title'] : ''; |
|
313 | + $payment_meta['form_title'] = ! empty($payment_meta['_give_payment_form_title']) ? $payment_meta['_give_payment_form_title'] : ''; |
|
314 | 314 | |
315 | 315 | // Donor email. |
316 | - $payment_meta['email'] = ! empty( $payment_meta['_give_payment_donor_email'] ) ? $payment_meta['_give_payment_donor_email'] : ''; |
|
317 | - $payment_meta['email'] = ! empty( $payment_meta['email'] ) ? |
|
318 | - $payment_meta['email'] : |
|
319 | - Give()->donors->get_column( 'email', $donation->donor_id ); |
|
316 | + $payment_meta['email'] = ! empty($payment_meta['_give_payment_donor_email']) ? $payment_meta['_give_payment_donor_email'] : ''; |
|
317 | + $payment_meta['email'] = ! empty($payment_meta['email']) ? |
|
318 | + $payment_meta['email'] : Give()->donors->get_column('email', $donation->donor_id); |
|
320 | 319 | |
321 | 320 | // Form id. |
322 | - $payment_meta['form_id'] = ! empty( $payment_meta['_give_payment_form_id'] ) ? $payment_meta['_give_payment_form_id'] : ''; |
|
321 | + $payment_meta['form_id'] = ! empty($payment_meta['_give_payment_form_id']) ? $payment_meta['_give_payment_form_id'] : ''; |
|
323 | 322 | |
324 | 323 | // Price id. |
325 | - $payment_meta['price_id'] = ! empty( $payment_meta['_give_payment_price_id'] ) ? $payment_meta['_give_payment_price_id'] : ''; |
|
324 | + $payment_meta['price_id'] = ! empty($payment_meta['_give_payment_price_id']) ? $payment_meta['_give_payment_price_id'] : ''; |
|
326 | 325 | |
327 | 326 | // Date. |
328 | - $payment_meta['date'] = ! empty( $payment_meta['_give_payment_date'] ) ? $payment_meta['_give_payment_date'] : ''; |
|
329 | - $payment_meta['date'] = ! empty( $payment_meta['date'] ) ? |
|
330 | - $payment_meta['date'] : |
|
331 | - get_post_field( 'post_date', $object_id ); |
|
327 | + $payment_meta['date'] = ! empty($payment_meta['_give_payment_date']) ? $payment_meta['_give_payment_date'] : ''; |
|
328 | + $payment_meta['date'] = ! empty($payment_meta['date']) ? |
|
329 | + $payment_meta['date'] : get_post_field('post_date', $object_id); |
|
332 | 330 | |
333 | 331 | |
334 | 332 | // Currency. |
335 | - $payment_meta['currency'] = ! empty( $payment_meta['_give_payment_currency'] ) ? $payment_meta['_give_payment_currency'] : ''; |
|
333 | + $payment_meta['currency'] = ! empty($payment_meta['_give_payment_currency']) ? $payment_meta['_give_payment_currency'] : ''; |
|
336 | 334 | |
337 | 335 | // Decode donor data. |
338 | - $donor_id = ! empty( $payment_meta['_give_payment_donor_id'] ) ? $payment_meta['_give_payment_donor_id'] : 0; |
|
339 | - $donor = new Give_Donor( $donor_id ); |
|
336 | + $donor_id = ! empty($payment_meta['_give_payment_donor_id']) ? $payment_meta['_give_payment_donor_id'] : 0; |
|
337 | + $donor = new Give_Donor($donor_id); |
|
340 | 338 | |
341 | 339 | // Donor first name. |
342 | - $donor_data['first_name'] = ! empty( $payment_meta['_give_donor_billing_first_name'] ) ? $payment_meta['_give_donor_billing_first_name'] : ''; |
|
343 | - $donor_data['first_name'] = ! empty( $donor_data['first_name'] ) ? |
|
344 | - $donor_data['first_name'] : |
|
345 | - $donor->get_first_name(); |
|
340 | + $donor_data['first_name'] = ! empty($payment_meta['_give_donor_billing_first_name']) ? $payment_meta['_give_donor_billing_first_name'] : ''; |
|
341 | + $donor_data['first_name'] = ! empty($donor_data['first_name']) ? |
|
342 | + $donor_data['first_name'] : $donor->get_first_name(); |
|
346 | 343 | |
347 | 344 | // Donor last name. |
348 | - $donor_data['last_name'] = ! empty( $payment_meta['_give_donor_billing_last_name'] ) ? $payment_meta['_give_donor_billing_last_name'] : ''; |
|
349 | - $donor_data['last_name'] = ! empty( $donor_data['last_name'] ) ? |
|
350 | - $donor_data['last_name'] : |
|
351 | - $donor->get_last_name(); |
|
345 | + $donor_data['last_name'] = ! empty($payment_meta['_give_donor_billing_last_name']) ? $payment_meta['_give_donor_billing_last_name'] : ''; |
|
346 | + $donor_data['last_name'] = ! empty($donor_data['last_name']) ? |
|
347 | + $donor_data['last_name'] : $donor->get_last_name(); |
|
352 | 348 | |
353 | 349 | // Donor email. |
354 | 350 | $donor_data['email'] = $payment_meta['email']; |
@@ -359,63 +355,63 @@ discard block |
||
359 | 355 | $donor_data['address'] = false; |
360 | 356 | |
361 | 357 | // Address1. |
362 | - $address1 = ! empty( $payment_meta['_give_donor_billing_address1'] ) ? $payment_meta['_give_donor_billing_address1'] : ''; |
|
363 | - if ( $address1 ) { |
|
358 | + $address1 = ! empty($payment_meta['_give_donor_billing_address1']) ? $payment_meta['_give_donor_billing_address1'] : ''; |
|
359 | + if ($address1) { |
|
364 | 360 | $donor_data['address']['line1'] = $address1; |
365 | 361 | } |
366 | 362 | |
367 | 363 | // Address2. |
368 | - $address2 = ! empty( $payment_meta['_give_donor_billing_address2'] ) ? $payment_meta['_give_donor_billing_address2'] : ''; |
|
369 | - if ( $address2 ) { |
|
364 | + $address2 = ! empty($payment_meta['_give_donor_billing_address2']) ? $payment_meta['_give_donor_billing_address2'] : ''; |
|
365 | + if ($address2) { |
|
370 | 366 | $donor_data['address']['line2'] = $address2; |
371 | 367 | } |
372 | 368 | |
373 | 369 | // City. |
374 | - $city = ! empty( $payment_meta['_give_donor_billing_city'] ) ? $payment_meta['_give_donor_billing_city'] : ''; |
|
375 | - if ( $city ) { |
|
370 | + $city = ! empty($payment_meta['_give_donor_billing_city']) ? $payment_meta['_give_donor_billing_city'] : ''; |
|
371 | + if ($city) { |
|
376 | 372 | $donor_data['address']['city'] = $city; |
377 | 373 | } |
378 | 374 | |
379 | 375 | // Zip. |
380 | - $zip = ! empty( $payment_meta['_give_donor_billing_zip'] ) ? $payment_meta['_give_donor_billing_zip'] : ''; |
|
381 | - if ( $zip ) { |
|
376 | + $zip = ! empty($payment_meta['_give_donor_billing_zip']) ? $payment_meta['_give_donor_billing_zip'] : ''; |
|
377 | + if ($zip) { |
|
382 | 378 | $donor_data['address']['zip'] = $zip; |
383 | 379 | } |
384 | 380 | |
385 | 381 | // State. |
386 | - $state = ! empty( $payment_meta['_give_donor_billing_state'] ) ? $payment_meta['_give_donor_billing_state'] : ''; |
|
387 | - if ( $state ) { |
|
382 | + $state = ! empty($payment_meta['_give_donor_billing_state']) ? $payment_meta['_give_donor_billing_state'] : ''; |
|
383 | + if ($state) { |
|
388 | 384 | $donor_data['address']['state'] = $state; |
389 | 385 | } |
390 | 386 | |
391 | 387 | // Country. |
392 | - $country = ! empty( $payment_meta['_give_donor_billing_country'] ) ? $payment_meta['_give_donor_billing_country'] : ''; |
|
393 | - if ( $country ) { |
|
388 | + $country = ! empty($payment_meta['_give_donor_billing_country']) ? $payment_meta['_give_donor_billing_country'] : ''; |
|
389 | + if ($country) { |
|
394 | 390 | $donor_data['address']['country'] = $country; |
395 | 391 | } |
396 | 392 | |
397 | 393 | $payment_meta['user_info'] = $donor_data; |
398 | 394 | |
399 | 395 | // Add filter |
400 | - add_filter( 'get_post_metadata', 'give_bc_v20_get_payment_meta', 999, 4 ); |
|
396 | + add_filter('get_post_metadata', 'give_bc_v20_get_payment_meta', 999, 4); |
|
401 | 397 | |
402 | 398 | // Set custom meta key into payment meta. |
403 | - if ( ! empty( $payment_meta['_give_payment_meta'] ) ) { |
|
404 | - $payment_meta = array_merge( maybe_unserialize( $payment_meta['_give_payment_meta'] ), $payment_meta ); |
|
399 | + if ( ! empty($payment_meta['_give_payment_meta'])) { |
|
400 | + $payment_meta = array_merge(maybe_unserialize($payment_meta['_give_payment_meta']), $payment_meta); |
|
405 | 401 | } |
406 | 402 | |
407 | 403 | // Set cache. |
408 | - Give_Cache::set_db_query( $cache_key, $payment_meta ); |
|
404 | + Give_Cache::set_db_query($cache_key, $payment_meta); |
|
409 | 405 | } |
410 | 406 | |
411 | - if ( $single ) { |
|
407 | + if ($single) { |
|
412 | 408 | /** |
413 | 409 | * Filter the payment meta |
414 | 410 | * Add custom meta key to payment meta |
415 | 411 | * |
416 | 412 | * @since 2.0 |
417 | 413 | */ |
418 | - $new_payment_meta[0] = apply_filters( 'give_get_payment_meta', $payment_meta, $object_id, $meta_key ); |
|
414 | + $new_payment_meta[0] = apply_filters('give_get_payment_meta', $payment_meta, $object_id, $meta_key); |
|
419 | 415 | |
420 | 416 | $payment_meta = $new_payment_meta; |
421 | 417 | } |
@@ -423,7 +419,7 @@ discard block |
||
423 | 419 | return $payment_meta; |
424 | 420 | } |
425 | 421 | |
426 | -add_filter( 'get_post_metadata', 'give_bc_v20_get_payment_meta', 999, 4 ); |
|
422 | +add_filter('get_post_metadata', 'give_bc_v20_get_payment_meta', 999, 4); |
|
427 | 423 | |
428 | 424 | /** |
429 | 425 | * Add meta in payment that store page id and page url. |
@@ -435,19 +431,19 @@ discard block |
||
435 | 431 | * |
436 | 432 | * @param int $payment_id Payment id for which the meta value should be updated. |
437 | 433 | */ |
438 | -function give_payment_save_page_data( $payment_id ) { |
|
439 | - $page_url = ( ! empty( $_REQUEST['give-current-url'] ) ? esc_url( $_REQUEST['give-current-url'] ) : false ); |
|
434 | +function give_payment_save_page_data($payment_id) { |
|
435 | + $page_url = ( ! empty($_REQUEST['give-current-url']) ? esc_url($_REQUEST['give-current-url']) : false); |
|
440 | 436 | |
441 | 437 | // Check $page_url is not empty. |
442 | - if ( $page_url ) { |
|
443 | - update_post_meta( $payment_id, '_give_current_url', $page_url ); |
|
444 | - $page_id = url_to_postid( $page_url ); |
|
438 | + if ($page_url) { |
|
439 | + update_post_meta($payment_id, '_give_current_url', $page_url); |
|
440 | + $page_id = url_to_postid($page_url); |
|
445 | 441 | // Check $page_id is not empty. |
446 | - if ( $page_id ) { |
|
447 | - update_post_meta( $payment_id, '_give_current_page_id', $page_id ); |
|
442 | + if ($page_id) { |
|
443 | + update_post_meta($payment_id, '_give_current_page_id', $page_id); |
|
448 | 444 | } |
449 | 445 | } |
450 | 446 | } |
451 | 447 | |
452 | 448 | // Fire when payment is save. |
453 | -add_action( 'give_insert_payment', 'give_payment_save_page_data' ); |
|
454 | 449 | \ No newline at end of file |
450 | +add_action('give_insert_payment', 'give_payment_save_page_data'); |
|
455 | 451 | \ No newline at end of file |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | */ |
24 | 24 | |
25 | 25 | // Exit if accessed directly. |
26 | -if ( ! defined( 'ABSPATH' ) ) { |
|
26 | +if ( ! defined('ABSPATH')) { |
|
27 | 27 | exit; |
28 | 28 | } |
29 | 29 | |
@@ -56,13 +56,13 @@ discard block |
||
56 | 56 | * @param callable $func Hook to run when email tag is found |
57 | 57 | * @param string $context Email tag category |
58 | 58 | */ |
59 | - public function add( $tag, $description, $func, $context = '' ) { |
|
60 | - if ( is_callable( $func ) ) { |
|
61 | - $this->tags[ $tag ] = array( |
|
59 | + public function add($tag, $description, $func, $context = '') { |
|
60 | + if (is_callable($func)) { |
|
61 | + $this->tags[$tag] = array( |
|
62 | 62 | 'tag' => $tag, |
63 | 63 | 'description' => $description, |
64 | 64 | 'func' => $func, |
65 | - 'context' => give_check_variable( $context, 'empty', 'general' ), |
|
65 | + 'context' => give_check_variable($context, 'empty', 'general'), |
|
66 | 66 | ); |
67 | 67 | } |
68 | 68 | } |
@@ -74,8 +74,8 @@ discard block |
||
74 | 74 | * |
75 | 75 | * @param string $tag Email tag to remove hook from |
76 | 76 | */ |
77 | - public function remove( $tag ) { |
|
78 | - unset( $this->tags[ $tag ] ); |
|
77 | + public function remove($tag) { |
|
78 | + unset($this->tags[$tag]); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
@@ -87,8 +87,8 @@ discard block |
||
87 | 87 | * |
88 | 88 | * @return bool |
89 | 89 | */ |
90 | - public function email_tag_exists( $tag ) { |
|
91 | - return array_key_exists( $tag, $this->tags ); |
|
90 | + public function email_tag_exists($tag) { |
|
91 | + return array_key_exists($tag, $this->tags); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | /** |
@@ -102,23 +102,23 @@ discard block |
||
102 | 102 | * |
103 | 103 | * @return array |
104 | 104 | */ |
105 | - public function get_tags( $context_type = 'all', $field = '' ) { |
|
105 | + public function get_tags($context_type = 'all', $field = '') { |
|
106 | 106 | $tags = $this->tags; |
107 | 107 | |
108 | - if ( 'all' !== $context_type ) { |
|
108 | + if ('all' !== $context_type) { |
|
109 | 109 | $tags = array(); |
110 | 110 | |
111 | - foreach ( $this->tags as $tag ) { |
|
112 | - if ( empty( $tag['context'] ) || $context_type !== $tag['context'] ) { |
|
111 | + foreach ($this->tags as $tag) { |
|
112 | + if (empty($tag['context']) || $context_type !== $tag['context']) { |
|
113 | 113 | continue; |
114 | 114 | } |
115 | 115 | |
116 | - $tags[ $tag['tag'] ] = $tag; |
|
116 | + $tags[$tag['tag']] = $tag; |
|
117 | 117 | } |
118 | 118 | } |
119 | 119 | |
120 | - if ( ! empty( $tags ) && ! empty( $field ) ) { |
|
121 | - $tags = wp_list_pluck( $tags, $field ); |
|
120 | + if ( ! empty($tags) && ! empty($field)) { |
|
121 | + $tags = wp_list_pluck($tags, $field); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | return $tags; |
@@ -136,16 +136,16 @@ discard block |
||
136 | 136 | * |
137 | 137 | * @return string Content with email tags filtered out. |
138 | 138 | */ |
139 | - public function do_tags( $content, $tag_args ) { |
|
139 | + public function do_tags($content, $tag_args) { |
|
140 | 140 | |
141 | 141 | // Check if there is at least one tag added. |
142 | - if ( empty( $this->tags ) || ! is_array( $this->tags ) ) { |
|
142 | + if (empty($this->tags) || ! is_array($this->tags)) { |
|
143 | 143 | return $content; |
144 | 144 | } |
145 | 145 | |
146 | 146 | $this->tag_args = $tag_args; |
147 | 147 | |
148 | - $new_content = preg_replace_callback( "/{([A-z0-9\-\_]+)}/s", array( $this, 'do_tag' ), $content ); |
|
148 | + $new_content = preg_replace_callback("/{([A-z0-9\-\_]+)}/s", array($this, 'do_tag'), $content); |
|
149 | 149 | |
150 | 150 | $this->tag_args = null; |
151 | 151 | |
@@ -161,17 +161,17 @@ discard block |
||
161 | 161 | * |
162 | 162 | * @return mixed |
163 | 163 | */ |
164 | - public function do_tag( $m ) { |
|
164 | + public function do_tag($m) { |
|
165 | 165 | |
166 | 166 | // Get tag |
167 | 167 | $tag = $m[1]; |
168 | 168 | |
169 | 169 | // Return tag if tag not set |
170 | - if ( ! $this->email_tag_exists( $tag ) ) { |
|
170 | + if ( ! $this->email_tag_exists($tag)) { |
|
171 | 171 | return $m[0]; |
172 | 172 | } |
173 | 173 | |
174 | - return call_user_func( $this->tags[ $tag ]['func'], $this->tag_args, $tag ); |
|
174 | + return call_user_func($this->tags[$tag]['func'], $this->tag_args, $tag); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | } |
@@ -186,8 +186,8 @@ discard block |
||
186 | 186 | * @param callable $func Hook to run when email tag is found |
187 | 187 | * @param string $context Email tag category |
188 | 188 | */ |
189 | -function give_add_email_tag( $tag, $description, $func, $context = '' ) { |
|
190 | - Give()->email_tags->add( $tag, $description, $func, $context ); |
|
189 | +function give_add_email_tag($tag, $description, $func, $context = '') { |
|
190 | + Give()->email_tags->add($tag, $description, $func, $context); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | /** |
@@ -197,8 +197,8 @@ discard block |
||
197 | 197 | * |
198 | 198 | * @param string $tag Email tag to remove hook from |
199 | 199 | */ |
200 | -function give_remove_email_tag( $tag ) { |
|
201 | - Give()->email_tags->remove( $tag ); |
|
200 | +function give_remove_email_tag($tag) { |
|
201 | + Give()->email_tags->remove($tag); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | /** |
@@ -210,8 +210,8 @@ discard block |
||
210 | 210 | * |
211 | 211 | * @return bool |
212 | 212 | */ |
213 | -function give_email_tag_exists( $tag ) { |
|
214 | - return Give()->email_tags->email_tag_exists( $tag ); |
|
213 | +function give_email_tag_exists($tag) { |
|
214 | + return Give()->email_tags->email_tag_exists($tag); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | /** |
@@ -238,9 +238,9 @@ discard block |
||
238 | 238 | $email_tags = give_get_email_tags(); |
239 | 239 | |
240 | 240 | ob_start(); |
241 | - if ( count( $email_tags ) > 0 ) : ?> |
|
241 | + if (count($email_tags) > 0) : ?> |
|
242 | 242 | <div class="give-email-tags-wrap"> |
243 | - <?php foreach ( $email_tags as $email_tag ) : ?> |
|
243 | + <?php foreach ($email_tags as $email_tag) : ?> |
|
244 | 244 | <span class="give_<?php echo $email_tag['tag']; ?>_tag"> |
245 | 245 | <code>{<?php echo $email_tag['tag']; ?>}</code> - <?php echo $email_tag['description']; ?> |
246 | 246 | </span> |
@@ -264,14 +264,14 @@ discard block |
||
264 | 264 | * |
265 | 265 | * @return string Content with email tags filtered out. |
266 | 266 | */ |
267 | -function give_do_email_tags( $content, $tag_args ) { |
|
267 | +function give_do_email_tags($content, $tag_args) { |
|
268 | 268 | // Backward compatibility < 2.0 |
269 | - if ( ! is_array( $tag_args ) ) { |
|
270 | - $tag_args = array( 'payment_id' => $tag_args ); |
|
269 | + if ( ! is_array($tag_args)) { |
|
270 | + $tag_args = array('payment_id' => $tag_args); |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | // Replace all tags |
274 | - $content = Give()->email_tags->do_tags( $content, $tag_args ); |
|
274 | + $content = Give()->email_tags->do_tags($content, $tag_args); |
|
275 | 275 | |
276 | 276 | /** |
277 | 277 | * Filter the filtered content text. |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | * @since 1.0 |
280 | 280 | * @since 2.0 $payment_meta, $payment_id removed and $tag_args added. |
281 | 281 | */ |
282 | - $content = apply_filters( 'give_email_template_tags', $content, $tag_args ); |
|
282 | + $content = apply_filters('give_email_template_tags', $content, $tag_args); |
|
283 | 283 | |
284 | 284 | // Return content |
285 | 285 | return $content; |
@@ -298,10 +298,10 @@ discard block |
||
298 | 298 | * |
299 | 299 | * @since 1.0 |
300 | 300 | */ |
301 | - do_action( 'give_add_email_tags' ); |
|
301 | + do_action('give_add_email_tags'); |
|
302 | 302 | } |
303 | 303 | |
304 | -add_action( 'init', 'give_load_email_tags', - 999 ); |
|
304 | +add_action('init', 'give_load_email_tags', - 999); |
|
305 | 305 | |
306 | 306 | |
307 | 307 | /** |
@@ -316,67 +316,67 @@ discard block |
||
316 | 316 | /* Donation Payment */ |
317 | 317 | array( |
318 | 318 | 'tag' => 'donation', |
319 | - 'description' => esc_html__( 'The donation form name, and the donation level (if applicable).', 'give' ), |
|
319 | + 'description' => esc_html__('The donation form name, and the donation level (if applicable).', 'give'), |
|
320 | 320 | 'function' => 'give_email_tag_donation', |
321 | 321 | 'context' => 'donation', |
322 | 322 | ), |
323 | 323 | array( |
324 | 324 | 'tag' => 'amount', |
325 | - 'description' => esc_html__( 'The total donation amount with currency sign.', 'give' ), |
|
325 | + 'description' => esc_html__('The total donation amount with currency sign.', 'give'), |
|
326 | 326 | 'function' => 'give_email_tag_amount', |
327 | 327 | 'context' => 'donation', |
328 | 328 | ), |
329 | 329 | array( |
330 | 330 | 'tag' => 'price', |
331 | - 'description' => esc_html__( 'The total donation amount with currency sign.', 'give' ), |
|
331 | + 'description' => esc_html__('The total donation amount with currency sign.', 'give'), |
|
332 | 332 | 'function' => 'give_email_tag_price', |
333 | 333 | 'context' => 'donation', |
334 | 334 | ), |
335 | 335 | array( |
336 | 336 | 'tag' => 'billing_address', |
337 | - 'description' => esc_html__( 'The donor\'s billing address.', 'give' ), |
|
337 | + 'description' => esc_html__('The donor\'s billing address.', 'give'), |
|
338 | 338 | 'function' => 'give_email_tag_billing_address', |
339 | 339 | 'context' => 'donation', |
340 | 340 | ), |
341 | 341 | array( |
342 | 342 | 'tag' => 'date', |
343 | - 'description' => esc_html__( 'The date of the donation.', 'give' ), |
|
343 | + 'description' => esc_html__('The date of the donation.', 'give'), |
|
344 | 344 | 'function' => 'give_email_tag_date', |
345 | 345 | 'context' => 'donation', |
346 | 346 | ), |
347 | 347 | array( |
348 | 348 | 'tag' => 'payment_id', |
349 | - 'description' => esc_html__( 'The unique ID number for this donation.', 'give' ), |
|
349 | + 'description' => esc_html__('The unique ID number for this donation.', 'give'), |
|
350 | 350 | 'function' => 'give_email_tag_payment_id', |
351 | 351 | 'context' => 'donation', |
352 | 352 | ), |
353 | 353 | array( |
354 | 354 | 'tag' => 'payment_method', |
355 | - 'description' => esc_html__( 'The method of payment used for this donation.', 'give' ), |
|
355 | + 'description' => esc_html__('The method of payment used for this donation.', 'give'), |
|
356 | 356 | 'function' => 'give_email_tag_payment_method', |
357 | 357 | 'context' => 'donation', |
358 | 358 | ), |
359 | 359 | array( |
360 | 360 | 'tag' => 'payment_total', |
361 | - 'description' => esc_html__( 'The payment total for this donation.', 'give' ), |
|
361 | + 'description' => esc_html__('The payment total for this donation.', 'give'), |
|
362 | 362 | 'function' => 'give_email_tag_payment_total', |
363 | 363 | 'context' => 'donation', |
364 | 364 | ), |
365 | 365 | array( |
366 | 366 | 'tag' => 'receipt_id', |
367 | - 'description' => esc_html__( 'The unique ID number for this donation receipt.', 'give' ), |
|
367 | + 'description' => esc_html__('The unique ID number for this donation receipt.', 'give'), |
|
368 | 368 | 'function' => 'give_email_tag_receipt_id', |
369 | 369 | 'context' => 'donation', |
370 | 370 | ), |
371 | 371 | array( |
372 | 372 | 'tag' => 'receipt_link', |
373 | - 'description' => esc_html__( 'The donation receipt direct link, to view the receipt on the website.', 'give' ), |
|
373 | + 'description' => esc_html__('The donation receipt direct link, to view the receipt on the website.', 'give'), |
|
374 | 374 | 'function' => 'give_email_tag_receipt_link', |
375 | 375 | 'context' => 'donation', |
376 | 376 | ), |
377 | 377 | array( |
378 | 378 | 'tag' => 'receipt_link_url', |
379 | - 'description' => esc_html__( 'The donation receipt direct URL, to view the receipt on the website.', 'give' ), |
|
379 | + 'description' => esc_html__('The donation receipt direct URL, to view the receipt on the website.', 'give'), |
|
380 | 380 | 'function' => 'give_email_tag_receipt_link_url', |
381 | 381 | 'context' => 'donation', |
382 | 382 | ), |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | /* Donation Form */ |
385 | 385 | array( |
386 | 386 | 'tag' => 'form_title', |
387 | - 'description' => esc_html__( 'The donation form name.', 'give' ), |
|
387 | + 'description' => esc_html__('The donation form name.', 'give'), |
|
388 | 388 | 'function' => 'give_email_tag_form_title', |
389 | 389 | 'context' => 'form', |
390 | 390 | ), |
@@ -392,31 +392,31 @@ discard block |
||
392 | 392 | /* Donor */ |
393 | 393 | array( |
394 | 394 | 'tag' => 'name', |
395 | - 'description' => esc_html__( 'The donor\'s first name.', 'give' ), |
|
395 | + 'description' => esc_html__('The donor\'s first name.', 'give'), |
|
396 | 396 | 'function' => 'give_email_tag_first_name', |
397 | 397 | 'context' => 'donor', |
398 | 398 | ), |
399 | 399 | array( |
400 | 400 | 'tag' => 'fullname', |
401 | - 'description' => esc_html__( 'The donor\'s full name, first and last.', 'give' ), |
|
401 | + 'description' => esc_html__('The donor\'s full name, first and last.', 'give'), |
|
402 | 402 | 'function' => 'give_email_tag_fullname', |
403 | 403 | 'context' => 'donor', |
404 | 404 | ), |
405 | 405 | array( |
406 | 406 | 'tag' => 'username', |
407 | - 'description' => esc_html__( 'The donor\'s user name on the site, if they registered an account.', 'give' ), |
|
407 | + 'description' => esc_html__('The donor\'s user name on the site, if they registered an account.', 'give'), |
|
408 | 408 | 'function' => 'give_email_tag_username', |
409 | 409 | 'context' => 'donor', |
410 | 410 | ), |
411 | 411 | array( |
412 | 412 | 'tag' => 'user_email', |
413 | - 'description' => esc_html__( 'The donor\'s email address.', 'give' ), |
|
413 | + 'description' => esc_html__('The donor\'s email address.', 'give'), |
|
414 | 414 | 'function' => 'give_email_tag_user_email', |
415 | 415 | 'context' => 'donor', |
416 | 416 | ), |
417 | 417 | array( |
418 | 418 | 'tag' => 'email_access_link', |
419 | - 'description' => esc_html__( 'The donor\'s email access link.', 'give' ), |
|
419 | + 'description' => esc_html__('The donor\'s email access link.', 'give'), |
|
420 | 420 | 'function' => 'give_email_tag_email_access_link', |
421 | 421 | 'context' => 'donor', |
422 | 422 | ), |
@@ -424,14 +424,14 @@ discard block |
||
424 | 424 | /* General */ |
425 | 425 | array( |
426 | 426 | 'tag' => 'sitename', |
427 | - 'description' => esc_html__( 'The name of your site.', 'give' ), |
|
427 | + 'description' => esc_html__('The name of your site.', 'give'), |
|
428 | 428 | 'function' => 'give_email_tag_sitename', |
429 | 429 | 'context' => 'general', |
430 | 430 | ), |
431 | 431 | |
432 | 432 | array( |
433 | 433 | 'tag' => 'reset_password_link', |
434 | - 'description' => esc_html__( 'The reset password link for user.', 'give' ), |
|
434 | + 'description' => esc_html__('The reset password link for user.', 'give'), |
|
435 | 435 | 'function' => 'give_email_tag_reset_password_link', |
436 | 436 | 'context' => 'general', |
437 | 437 | ), |
@@ -439,21 +439,21 @@ discard block |
||
439 | 439 | ); |
440 | 440 | |
441 | 441 | // Apply give_email_tags filter |
442 | - $email_tags = apply_filters( 'give_email_tags', $email_tags ); |
|
442 | + $email_tags = apply_filters('give_email_tags', $email_tags); |
|
443 | 443 | |
444 | 444 | // Add email tags |
445 | - foreach ( $email_tags as $email_tag ) { |
|
445 | + foreach ($email_tags as $email_tag) { |
|
446 | 446 | give_add_email_tag( |
447 | 447 | $email_tag['tag'], |
448 | 448 | $email_tag['description'], |
449 | 449 | $email_tag['function'], |
450 | - ( ! empty( $email_tag['context'] ) ? $email_tag['context'] : '' ) |
|
450 | + ( ! empty($email_tag['context']) ? $email_tag['context'] : '') |
|
451 | 451 | ); |
452 | 452 | } |
453 | 453 | |
454 | 454 | } |
455 | 455 | |
456 | -add_action( 'give_add_email_tags', 'give_setup_email_tags' ); |
|
456 | +add_action('give_add_email_tags', 'give_setup_email_tags'); |
|
457 | 457 | |
458 | 458 | |
459 | 459 | /** |
@@ -465,26 +465,26 @@ discard block |
||
465 | 465 | * |
466 | 466 | * @return string $firstname |
467 | 467 | */ |
468 | -function give_email_tag_first_name( $tag_args ) { |
|
468 | +function give_email_tag_first_name($tag_args) { |
|
469 | 469 | $user_info = array(); |
470 | 470 | $firstname = ''; |
471 | 471 | |
472 | 472 | // Backward compatibility. |
473 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
473 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
474 | 474 | |
475 | - switch ( true ) { |
|
476 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
477 | - $payment = new Give_Payment( $tag_args['payment_id'] ); |
|
475 | + switch (true) { |
|
476 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
477 | + $payment = new Give_Payment($tag_args['payment_id']); |
|
478 | 478 | |
479 | 479 | // Get firstname. |
480 | - if ( ! empty( $payment->user_info ) ) { |
|
481 | - $email_names = give_get_email_names( $payment->user_info ); |
|
480 | + if ( ! empty($payment->user_info)) { |
|
481 | + $email_names = give_get_email_names($payment->user_info); |
|
482 | 482 | $firstname = $email_names['name']; |
483 | 483 | } |
484 | 484 | break; |
485 | 485 | |
486 | - case give_check_variable( $tag_args, 'isset', 0, 'user_id' ): |
|
487 | - $donor = new Give_Donor( $tag_args['user_id'], true ); |
|
486 | + case give_check_variable($tag_args, 'isset', 0, 'user_id'): |
|
487 | + $donor = new Give_Donor($tag_args['user_id'], true); |
|
488 | 488 | $firstname = $donor->get_first_name(); |
489 | 489 | break; |
490 | 490 | |
@@ -493,8 +493,8 @@ discard block |
||
493 | 493 | * |
494 | 494 | * @since 2.0 |
495 | 495 | */ |
496 | - case give_check_variable( $tag_args, 'isset', 0, 'donor_id' ): |
|
497 | - $donor = new Give_Donor( $tag_args['donor_id'] ); |
|
496 | + case give_check_variable($tag_args, 'isset', 0, 'donor_id'): |
|
497 | + $donor = new Give_Donor($tag_args['donor_id']); |
|
498 | 498 | $firstname = $donor->get_first_name(); |
499 | 499 | break; |
500 | 500 | } |
@@ -507,7 +507,7 @@ discard block |
||
507 | 507 | * @param string $firstname |
508 | 508 | * @param array $tag_args |
509 | 509 | */ |
510 | - $firstname = apply_filters( 'give_email_tag_first_name', $firstname, $tag_args ); |
|
510 | + $firstname = apply_filters('give_email_tag_first_name', $firstname, $tag_args); |
|
511 | 511 | |
512 | 512 | return $firstname; |
513 | 513 | } |
@@ -521,26 +521,26 @@ discard block |
||
521 | 521 | * |
522 | 522 | * @return string $fullname |
523 | 523 | */ |
524 | -function give_email_tag_fullname( $tag_args ) { |
|
524 | +function give_email_tag_fullname($tag_args) { |
|
525 | 525 | $fullname = ''; |
526 | 526 | |
527 | 527 | // Backward compatibility. |
528 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
528 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
529 | 529 | |
530 | - switch ( true ) { |
|
531 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
532 | - $payment = new Give_Payment( $tag_args['payment_id'] ); |
|
530 | + switch (true) { |
|
531 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
532 | + $payment = new Give_Payment($tag_args['payment_id']); |
|
533 | 533 | |
534 | 534 | // Get fullname. |
535 | - if ( ! empty( $payment->user_info ) ) { |
|
536 | - $email_names = give_get_email_names( $payment->user_info ); |
|
535 | + if ( ! empty($payment->user_info)) { |
|
536 | + $email_names = give_get_email_names($payment->user_info); |
|
537 | 537 | $fullname = $email_names['fullname']; |
538 | 538 | } |
539 | 539 | break; |
540 | 540 | |
541 | - case give_check_variable( $tag_args, 'isset', 0, 'user_id' ): |
|
542 | - $donor = new Give_Donor( $tag_args['user_id'], true ); |
|
543 | - $fullname = trim( "{$donor->get_first_name()} {$donor->get_last_name()}" ); |
|
541 | + case give_check_variable($tag_args, 'isset', 0, 'user_id'): |
|
542 | + $donor = new Give_Donor($tag_args['user_id'], true); |
|
543 | + $fullname = trim("{$donor->get_first_name()} {$donor->get_last_name()}"); |
|
544 | 544 | break; |
545 | 545 | |
546 | 546 | /** |
@@ -548,8 +548,8 @@ discard block |
||
548 | 548 | * |
549 | 549 | * @since 2.0 |
550 | 550 | */ |
551 | - case give_check_variable( $tag_args, 'isset', 0, 'donor_id' ): |
|
552 | - $donor = new Give_Donor( $tag_args['donor_id'] ); |
|
551 | + case give_check_variable($tag_args, 'isset', 0, 'donor_id'): |
|
552 | + $donor = new Give_Donor($tag_args['donor_id']); |
|
553 | 553 | $fullname = $donor->name; |
554 | 554 | break; |
555 | 555 | } |
@@ -562,7 +562,7 @@ discard block |
||
562 | 562 | * @param string $fullname |
563 | 563 | * @param array $tag_args |
564 | 564 | */ |
565 | - $fullname = apply_filters( 'give_email_tag_fullname', $fullname, $tag_args ); |
|
565 | + $fullname = apply_filters('give_email_tag_fullname', $fullname, $tag_args); |
|
566 | 566 | |
567 | 567 | return $fullname; |
568 | 568 | } |
@@ -576,25 +576,25 @@ discard block |
||
576 | 576 | * |
577 | 577 | * @return string username. |
578 | 578 | */ |
579 | -function give_email_tag_username( $tag_args ) { |
|
579 | +function give_email_tag_username($tag_args) { |
|
580 | 580 | $username = ''; |
581 | 581 | |
582 | 582 | // Backward compatibility. |
583 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
583 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
584 | 584 | |
585 | - switch ( true ) { |
|
586 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
587 | - $payment = new Give_Payment( $tag_args['payment_id'] ); |
|
585 | + switch (true) { |
|
586 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
587 | + $payment = new Give_Payment($tag_args['payment_id']); |
|
588 | 588 | |
589 | 589 | // Get username. |
590 | - if ( ! empty( $payment->user_info ) ) { |
|
591 | - $email_names = give_get_email_names( $payment->user_info ); |
|
590 | + if ( ! empty($payment->user_info)) { |
|
591 | + $email_names = give_get_email_names($payment->user_info); |
|
592 | 592 | $username = $email_names['username']; |
593 | 593 | } |
594 | 594 | break; |
595 | 595 | |
596 | - case give_check_variable( $tag_args, 'isset', 0, 'user_id' ): |
|
597 | - $user_info = get_user_by( 'id', $tag_args['user_id'] ); |
|
596 | + case give_check_variable($tag_args, 'isset', 0, 'user_id'): |
|
597 | + $user_info = get_user_by('id', $tag_args['user_id']); |
|
598 | 598 | $username = $user_info->user_login; |
599 | 599 | break; |
600 | 600 | |
@@ -603,10 +603,10 @@ discard block |
||
603 | 603 | * |
604 | 604 | * @since 2.0 |
605 | 605 | */ |
606 | - case give_check_variable( $tag_args, 'isset', 0, 'donor_id' ): |
|
607 | - $donor = new Give_Donor( $tag_args['donor_id'] ); |
|
608 | - if ( ! empty( $donor->id ) && ! empty( $donor->user_id ) ) { |
|
609 | - $user_info = get_user_by( 'id', $donor->user_id ); |
|
606 | + case give_check_variable($tag_args, 'isset', 0, 'donor_id'): |
|
607 | + $donor = new Give_Donor($tag_args['donor_id']); |
|
608 | + if ( ! empty($donor->id) && ! empty($donor->user_id)) { |
|
609 | + $user_info = get_user_by('id', $donor->user_id); |
|
610 | 610 | $username = $user_info->user_login; |
611 | 611 | } |
612 | 612 | break; |
@@ -620,7 +620,7 @@ discard block |
||
620 | 620 | * @param string $username |
621 | 621 | * @param array $tag_args |
622 | 622 | */ |
623 | - $username = apply_filters( 'give_email_tag_username', $username, $tag_args ); |
|
623 | + $username = apply_filters('give_email_tag_username', $username, $tag_args); |
|
624 | 624 | |
625 | 625 | return $username; |
626 | 626 | } |
@@ -634,20 +634,20 @@ discard block |
||
634 | 634 | * |
635 | 635 | * @return string user_email |
636 | 636 | */ |
637 | -function give_email_tag_user_email( $tag_args ) { |
|
637 | +function give_email_tag_user_email($tag_args) { |
|
638 | 638 | $email = ''; |
639 | 639 | |
640 | 640 | // Backward compatibility. |
641 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
641 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
642 | 642 | |
643 | - switch ( true ) { |
|
644 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
645 | - $payment = new Give_Payment( $tag_args['payment_id'] ); |
|
643 | + switch (true) { |
|
644 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
645 | + $payment = new Give_Payment($tag_args['payment_id']); |
|
646 | 646 | $email = $payment->email; |
647 | 647 | break; |
648 | 648 | |
649 | - case give_check_variable( $tag_args, 'isset', 0, 'user_id' ): |
|
650 | - $user_info = get_user_by( 'id', $tag_args['user_id'] ); |
|
649 | + case give_check_variable($tag_args, 'isset', 0, 'user_id'): |
|
650 | + $user_info = get_user_by('id', $tag_args['user_id']); |
|
651 | 651 | $email = $user_info->user_email; |
652 | 652 | break; |
653 | 653 | |
@@ -656,9 +656,9 @@ discard block |
||
656 | 656 | * |
657 | 657 | * @since 2.0 |
658 | 658 | */ |
659 | - case give_check_variable( $tag_args, 'isset', 0, 'donor_id' ): |
|
660 | - $donor = new Give_Donor( $tag_args['donor_id'] ); |
|
661 | - $email = $donor->email; |
|
659 | + case give_check_variable($tag_args, 'isset', 0, 'donor_id'): |
|
660 | + $donor = new Give_Donor($tag_args['donor_id']); |
|
661 | + $email = $donor->email; |
|
662 | 662 | break; |
663 | 663 | } |
664 | 664 | |
@@ -670,7 +670,7 @@ discard block |
||
670 | 670 | * @param string $email |
671 | 671 | * @param array $tag_args |
672 | 672 | */ |
673 | - $email = apply_filters( 'give_email_tag_user_email', $email, $tag_args ); |
|
673 | + $email = apply_filters('give_email_tag_user_email', $email, $tag_args); |
|
674 | 674 | |
675 | 675 | return $email; |
676 | 676 | } |
@@ -684,22 +684,22 @@ discard block |
||
684 | 684 | * |
685 | 685 | * @return string billing_address |
686 | 686 | */ |
687 | -function give_email_tag_billing_address( $tag_args ) { |
|
687 | +function give_email_tag_billing_address($tag_args) { |
|
688 | 688 | $address = ''; |
689 | 689 | |
690 | 690 | // Backward compatibility. |
691 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
691 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
692 | 692 | |
693 | - switch ( true ) { |
|
694 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
695 | - $donation = new Give_Payment( $tag_args['payment_id'] ); |
|
696 | - $address = $donation->address['line1'] . "\n"; |
|
693 | + switch (true) { |
|
694 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
695 | + $donation = new Give_Payment($tag_args['payment_id']); |
|
696 | + $address = $donation->address['line1']."\n"; |
|
697 | 697 | |
698 | - if ( ! empty( $donation->address['line2'] ) ) { |
|
699 | - $address .= $donation->address['line2'] . "\n"; |
|
698 | + if ( ! empty($donation->address['line2'])) { |
|
699 | + $address .= $donation->address['line2']."\n"; |
|
700 | 700 | } |
701 | 701 | |
702 | - $address .= $donation->address['city'] . ' ' . $donation->address['zip'] . ' ' . $donation->address['state'] . "\n"; |
|
702 | + $address .= $donation->address['city'].' '.$donation->address['zip'].' '.$donation->address['state']."\n"; |
|
703 | 703 | $address .= $donation->address['country']; |
704 | 704 | break; |
705 | 705 | } |
@@ -712,7 +712,7 @@ discard block |
||
712 | 712 | * @param string $address |
713 | 713 | * @param array $tag_args |
714 | 714 | */ |
715 | - $address = apply_filters( 'give_email_tag_billing_address', $address, $tag_args ); |
|
715 | + $address = apply_filters('give_email_tag_billing_address', $address, $tag_args); |
|
716 | 716 | |
717 | 717 | return $address; |
718 | 718 | } |
@@ -726,16 +726,16 @@ discard block |
||
726 | 726 | * |
727 | 727 | * @return string date |
728 | 728 | */ |
729 | -function give_email_tag_date( $tag_args ) { |
|
729 | +function give_email_tag_date($tag_args) { |
|
730 | 730 | $date = ''; |
731 | 731 | |
732 | 732 | // Backward compatibility. |
733 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
733 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
734 | 734 | |
735 | - switch ( true ) { |
|
736 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
737 | - $payment = new Give_Payment( $tag_args['payment_id'] ); |
|
738 | - $date = date_i18n( give_date_format(), strtotime( $payment->date ) ); |
|
735 | + switch (true) { |
|
736 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
737 | + $payment = new Give_Payment($tag_args['payment_id']); |
|
738 | + $date = date_i18n(give_date_format(), strtotime($payment->date)); |
|
739 | 739 | break; |
740 | 740 | } |
741 | 741 | |
@@ -747,7 +747,7 @@ discard block |
||
747 | 747 | * @param string $date |
748 | 748 | * @param array $tag_args |
749 | 749 | */ |
750 | - $date = apply_filters( 'give_email_tag_date', $date, $tag_args ); |
|
750 | + $date = apply_filters('give_email_tag_date', $date, $tag_args); |
|
751 | 751 | |
752 | 752 | return $date; |
753 | 753 | } |
@@ -761,17 +761,17 @@ discard block |
||
761 | 761 | * |
762 | 762 | * @return string amount |
763 | 763 | */ |
764 | -function give_email_tag_amount( $tag_args ) { |
|
764 | +function give_email_tag_amount($tag_args) { |
|
765 | 765 | $amount = ''; |
766 | 766 | |
767 | 767 | // Backward compatibility. |
768 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
768 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
769 | 769 | |
770 | - switch ( true ) { |
|
771 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
772 | - $payment = new Give_Payment( $tag_args['payment_id'] ); |
|
773 | - $give_amount = give_currency_filter( give_format_amount( $payment->total, array( 'sanitize' => false ) ), array( 'currency_code' => $payment->currency ) ); |
|
774 | - $amount = html_entity_decode( $give_amount, ENT_COMPAT, 'UTF-8' ); |
|
770 | + switch (true) { |
|
771 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
772 | + $payment = new Give_Payment($tag_args['payment_id']); |
|
773 | + $give_amount = give_currency_filter(give_format_amount($payment->total, array('sanitize' => false)), array('currency_code' => $payment->currency)); |
|
774 | + $amount = html_entity_decode($give_amount, ENT_COMPAT, 'UTF-8'); |
|
775 | 775 | break; |
776 | 776 | } |
777 | 777 | |
@@ -783,7 +783,7 @@ discard block |
||
783 | 783 | * @param string $amount |
784 | 784 | * @param array $tag_args |
785 | 785 | */ |
786 | - $amount = apply_filters( 'give_email_tag_amount', $amount, $tag_args ); |
|
786 | + $amount = apply_filters('give_email_tag_amount', $amount, $tag_args); |
|
787 | 787 | |
788 | 788 | return $amount; |
789 | 789 | } |
@@ -797,8 +797,8 @@ discard block |
||
797 | 797 | * |
798 | 798 | * @return string price |
799 | 799 | */ |
800 | -function give_email_tag_price( $tag_args ) { |
|
801 | - return give_email_tag_amount( $tag_args ); |
|
800 | +function give_email_tag_price($tag_args) { |
|
801 | + return give_email_tag_amount($tag_args); |
|
802 | 802 | } |
803 | 803 | |
804 | 804 | /** |
@@ -810,15 +810,15 @@ discard block |
||
810 | 810 | * |
811 | 811 | * @return int payment_id |
812 | 812 | */ |
813 | -function give_email_tag_payment_id( $tag_args ) { |
|
813 | +function give_email_tag_payment_id($tag_args) { |
|
814 | 814 | $payment_id = ''; |
815 | 815 | |
816 | 816 | // Backward compatibility. |
817 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
817 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
818 | 818 | |
819 | - switch ( true ) { |
|
820 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
821 | - $payment = new Give_Payment( $tag_args['payment_id'] ); |
|
819 | + switch (true) { |
|
820 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
821 | + $payment = new Give_Payment($tag_args['payment_id']); |
|
822 | 822 | $payment_id = $payment->number; |
823 | 823 | break; |
824 | 824 | } |
@@ -831,7 +831,7 @@ discard block |
||
831 | 831 | * @param string $payment_id |
832 | 832 | * @param array $tag_args |
833 | 833 | */ |
834 | - return apply_filters( 'give_email_tag_payment_id', $payment_id, $tag_args ); |
|
834 | + return apply_filters('give_email_tag_payment_id', $payment_id, $tag_args); |
|
835 | 835 | } |
836 | 836 | |
837 | 837 | /** |
@@ -843,15 +843,15 @@ discard block |
||
843 | 843 | * |
844 | 844 | * @return string receipt_id |
845 | 845 | */ |
846 | -function give_email_tag_receipt_id( $tag_args ) { |
|
846 | +function give_email_tag_receipt_id($tag_args) { |
|
847 | 847 | $receipt_id = ''; |
848 | 848 | |
849 | 849 | // Backward compatibility. |
850 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
850 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
851 | 851 | |
852 | - switch ( true ) { |
|
853 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
854 | - $payment = new Give_Payment( $tag_args['payment_id'] ); |
|
852 | + switch (true) { |
|
853 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
854 | + $payment = new Give_Payment($tag_args['payment_id']); |
|
855 | 855 | $receipt_id = $payment->key; |
856 | 856 | break; |
857 | 857 | } |
@@ -864,7 +864,7 @@ discard block |
||
864 | 864 | * @param string $receipt_id |
865 | 865 | * @param array $tag_args |
866 | 866 | */ |
867 | - return apply_filters( 'give_email_tag_receipt_id', $receipt_id, $tag_args ); |
|
867 | + return apply_filters('give_email_tag_receipt_id', $receipt_id, $tag_args); |
|
868 | 868 | } |
869 | 869 | |
870 | 870 | /** |
@@ -876,23 +876,23 @@ discard block |
||
876 | 876 | * |
877 | 877 | * @return string $form_title |
878 | 878 | */ |
879 | -function give_email_tag_donation( $tag_args ) { |
|
879 | +function give_email_tag_donation($tag_args) { |
|
880 | 880 | $donation_form_title = ''; |
881 | 881 | |
882 | 882 | // Backward compatibility. |
883 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
883 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
884 | 884 | |
885 | - switch ( true ) { |
|
886 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
887 | - $payment = new Give_Payment( $tag_args['payment_id'] ); |
|
888 | - $level_title = give_has_variable_prices( $payment->form_id ); |
|
885 | + switch (true) { |
|
886 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
887 | + $payment = new Give_Payment($tag_args['payment_id']); |
|
888 | + $level_title = give_has_variable_prices($payment->form_id); |
|
889 | 889 | $separator = $level_title ? '-' : ''; |
890 | - $donation_form_title = strip_tags( give_check_variable( give_get_donation_form_title( |
|
890 | + $donation_form_title = strip_tags(give_check_variable(give_get_donation_form_title( |
|
891 | 891 | $payment, |
892 | 892 | array( |
893 | 893 | 'separator' => $separator, |
894 | 894 | ) |
895 | - ), 'empty', '' ) ); |
|
895 | + ), 'empty', '')); |
|
896 | 896 | break; |
897 | 897 | } |
898 | 898 | |
@@ -920,17 +920,17 @@ discard block |
||
920 | 920 | * |
921 | 921 | * @return string $form_title |
922 | 922 | */ |
923 | -function give_email_tag_form_title( $tag_args ) { |
|
923 | +function give_email_tag_form_title($tag_args) { |
|
924 | 924 | $donation_form_title = ''; |
925 | 925 | |
926 | 926 | // Backward compatibility. |
927 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
927 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
928 | 928 | |
929 | - switch ( true ) { |
|
930 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
931 | - $payment = new Give_Payment( $tag_args['payment_id'] ); |
|
929 | + switch (true) { |
|
930 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
931 | + $payment = new Give_Payment($tag_args['payment_id']); |
|
932 | 932 | $payment_meta = $payment->payment_meta; |
933 | - $donation_form_title = strip_tags( give_check_variable( $payment_meta, 'empty', '', 'form_title' ) ); |
|
933 | + $donation_form_title = strip_tags(give_check_variable($payment_meta, 'empty', '', 'form_title')); |
|
934 | 934 | break; |
935 | 935 | } |
936 | 936 | |
@@ -958,19 +958,19 @@ discard block |
||
958 | 958 | * |
959 | 959 | * @return string gateway |
960 | 960 | */ |
961 | -function give_email_tag_payment_method( $tag_args ) { |
|
961 | +function give_email_tag_payment_method($tag_args) { |
|
962 | 962 | $payment_method = ''; |
963 | 963 | |
964 | 964 | // Backward compatibility. |
965 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
965 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
966 | 966 | |
967 | 967 | // Backward compatibility. |
968 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
968 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
969 | 969 | |
970 | - switch ( true ) { |
|
971 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
972 | - $payment = new Give_Payment( $tag_args['payment_id'] ); |
|
973 | - $payment_method = give_get_gateway_checkout_label( $payment->gateway ); |
|
970 | + switch (true) { |
|
971 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
972 | + $payment = new Give_Payment($tag_args['payment_id']); |
|
973 | + $payment_method = give_get_gateway_checkout_label($payment->gateway); |
|
974 | 974 | break; |
975 | 975 | } |
976 | 976 | |
@@ -1001,16 +1001,16 @@ discard block |
||
1001 | 1001 | * |
1002 | 1002 | * @return string |
1003 | 1003 | */ |
1004 | -function give_email_tag_payment_total( $tag_args ) { |
|
1004 | +function give_email_tag_payment_total($tag_args) { |
|
1005 | 1005 | $payment_total = ''; |
1006 | 1006 | |
1007 | 1007 | // Backward compatibility. |
1008 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
1008 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
1009 | 1009 | |
1010 | - switch ( true ) { |
|
1011 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
1012 | - $payment = new Give_Payment( $tag_args['payment_id'] ); |
|
1013 | - $payment_total = give_currency_filter( $payment->total ); |
|
1010 | + switch (true) { |
|
1011 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
1012 | + $payment = new Give_Payment($tag_args['payment_id']); |
|
1013 | + $payment_total = give_currency_filter($payment->total); |
|
1014 | 1014 | break; |
1015 | 1015 | } |
1016 | 1016 | |
@@ -1038,11 +1038,11 @@ discard block |
||
1038 | 1038 | * |
1039 | 1039 | * @return string |
1040 | 1040 | */ |
1041 | -function give_email_tag_sitename( $tag_args = array() ) { |
|
1042 | - $sitename = wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ); |
|
1041 | +function give_email_tag_sitename($tag_args = array()) { |
|
1042 | + $sitename = wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES); |
|
1043 | 1043 | |
1044 | 1044 | // Backward compatibility. |
1045 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
1045 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
1046 | 1046 | |
1047 | 1047 | /** |
1048 | 1048 | * Filter the {sitename} email template tag output. |
@@ -1068,26 +1068,26 @@ discard block |
||
1068 | 1068 | * |
1069 | 1069 | * @return string receipt_link |
1070 | 1070 | */ |
1071 | -function give_email_tag_receipt_link( $tag_args ) { |
|
1071 | +function give_email_tag_receipt_link($tag_args) { |
|
1072 | 1072 | // Backward compatibility. |
1073 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
1073 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
1074 | 1074 | |
1075 | - $receipt_url = give_get_receipt_url( give_check_variable( $tag_args, 'empty', 0, 'payment_id' ) ); |
|
1075 | + $receipt_url = give_get_receipt_url(give_check_variable($tag_args, 'empty', 0, 'payment_id')); |
|
1076 | 1076 | |
1077 | 1077 | // Bailout. |
1078 | - if ( give_get_option( 'email_template' ) === 'none' ) { |
|
1078 | + if (give_get_option('email_template') === 'none') { |
|
1079 | 1079 | return $receipt_url; |
1080 | 1080 | } |
1081 | 1081 | |
1082 | 1082 | |
1083 | - $receipt_url = esc_url( add_query_arg( array( |
|
1084 | - 'payment_key' => give_get_payment_key( $tag_args['payment_id'] ), |
|
1085 | - ), give_get_history_page_uri() ) ); |
|
1083 | + $receipt_url = esc_url(add_query_arg(array( |
|
1084 | + 'payment_key' => give_get_payment_key($tag_args['payment_id']), |
|
1085 | + ), give_get_history_page_uri())); |
|
1086 | 1086 | |
1087 | - $formatted = sprintf( |
|
1087 | + $formatted = sprintf( |
|
1088 | 1088 | '<a href="%1$s">%2$s</a>', |
1089 | 1089 | $receipt_url, |
1090 | - __( 'View it in your browser »', 'give' ) |
|
1090 | + __('View it in your browser »', 'give') |
|
1091 | 1091 | ); |
1092 | 1092 | |
1093 | 1093 | /** |
@@ -1116,11 +1116,11 @@ discard block |
||
1116 | 1116 | * |
1117 | 1117 | * @return string receipt_url |
1118 | 1118 | */ |
1119 | -function give_email_tag_receipt_link_url( $tag_args ) { |
|
1119 | +function give_email_tag_receipt_link_url($tag_args) { |
|
1120 | 1120 | // Backward compatibility. |
1121 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
1121 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
1122 | 1122 | |
1123 | - $receipt_link_url = give_get_receipt_url( give_check_variable( $tag_args, 'empty', 0, 'payment_id' ) ); |
|
1123 | + $receipt_link_url = give_get_receipt_url(give_check_variable($tag_args, 'empty', 0, 'payment_id')); |
|
1124 | 1124 | |
1125 | 1125 | /** |
1126 | 1126 | * Filter the {receipt_link_url} email template tag output. |
@@ -1147,13 +1147,13 @@ discard block |
||
1147 | 1147 | * |
1148 | 1148 | * @return string |
1149 | 1149 | */ |
1150 | -function give_get_receipt_url( $payment_id ) { |
|
1150 | +function give_get_receipt_url($payment_id) { |
|
1151 | 1151 | $receipt_url = ''; |
1152 | 1152 | |
1153 | - if ( $payment_id ) { |
|
1154 | - $receipt_url = esc_url( add_query_arg( array( |
|
1155 | - 'payment_key' => give_get_payment_key( $payment_id ), |
|
1156 | - ), give_get_history_page_uri() ) ); |
|
1153 | + if ($payment_id) { |
|
1154 | + $receipt_url = esc_url(add_query_arg(array( |
|
1155 | + 'payment_key' => give_get_payment_key($payment_id), |
|
1156 | + ), give_get_history_page_uri())); |
|
1157 | 1157 | } |
1158 | 1158 | |
1159 | 1159 | return $receipt_url; |
@@ -1169,22 +1169,22 @@ discard block |
||
1169 | 1169 | * |
1170 | 1170 | * @return string |
1171 | 1171 | */ |
1172 | -function give_email_tag_email_access_link( $tag_args ) { |
|
1172 | +function give_email_tag_email_access_link($tag_args) { |
|
1173 | 1173 | $donor_id = 0; |
1174 | 1174 | $donor = array(); |
1175 | 1175 | $email_access_link = ''; |
1176 | 1176 | |
1177 | 1177 | // Backward compatibility. |
1178 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
1178 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
1179 | 1179 | |
1180 | - switch ( true ) { |
|
1181 | - case ! empty( $tag_args['donor_id'] ): |
|
1180 | + switch (true) { |
|
1181 | + case ! empty($tag_args['donor_id']): |
|
1182 | 1182 | $donor_id = $tag_args['donor_id']; |
1183 | - $donor = Give()->donors->get_by( 'id', $tag_args['donor_id'] ); |
|
1183 | + $donor = Give()->donors->get_by('id', $tag_args['donor_id']); |
|
1184 | 1184 | break; |
1185 | 1185 | |
1186 | - case ! empty( $tag_args['user_id'] ): |
|
1187 | - $donor = Give()->donors->get_by( 'user_id', $tag_args['user_id'] ); |
|
1186 | + case ! empty($tag_args['user_id']): |
|
1187 | + $donor = Give()->donors->get_by('user_id', $tag_args['user_id']); |
|
1188 | 1188 | $donor_id = $donor->id; |
1189 | 1189 | break; |
1190 | 1190 | |
@@ -1193,11 +1193,11 @@ discard block |
||
1193 | 1193 | } |
1194 | 1194 | |
1195 | 1195 | // Set email access link if donor exist. |
1196 | - if ( $donor_id ) { |
|
1197 | - $verify_key = wp_generate_password( 20, false ); |
|
1196 | + if ($donor_id) { |
|
1197 | + $verify_key = wp_generate_password(20, false); |
|
1198 | 1198 | |
1199 | 1199 | // Generate a new verify key |
1200 | - Give()->email_access->set_verify_key( $donor_id, $donor->email, $verify_key ); |
|
1200 | + Give()->email_access->set_verify_key($donor_id, $donor->email, $verify_key); |
|
1201 | 1201 | |
1202 | 1202 | $access_url = add_query_arg( |
1203 | 1203 | array( |
@@ -1207,28 +1207,28 @@ discard block |
||
1207 | 1207 | ); |
1208 | 1208 | |
1209 | 1209 | // Add Payment Key to email access url, if it exists. |
1210 | - if ( ! empty( $_GET['payment_key'] ) ) { |
|
1210 | + if ( ! empty($_GET['payment_key'])) { |
|
1211 | 1211 | $access_url = add_query_arg( |
1212 | 1212 | array( |
1213 | - 'payment_key' => give_clean( $_GET['payment_key'] ), |
|
1213 | + 'payment_key' => give_clean($_GET['payment_key']), |
|
1214 | 1214 | ), |
1215 | 1215 | $access_url |
1216 | 1216 | ); |
1217 | 1217 | } |
1218 | 1218 | |
1219 | - if ( empty( $tag_args['email_content_type'] ) || 'text/html' === $tag_args['email_content_type'] ) { |
|
1219 | + if (empty($tag_args['email_content_type']) || 'text/html' === $tag_args['email_content_type']) { |
|
1220 | 1220 | $email_access_link = sprintf( |
1221 | 1221 | '<a href="%1$s" target="_blank">%2$s</a>', |
1222 | - esc_url( $access_url ), |
|
1223 | - __( 'View your donation history »', 'give' ) |
|
1222 | + esc_url($access_url), |
|
1223 | + __('View your donation history »', 'give') |
|
1224 | 1224 | ); |
1225 | 1225 | |
1226 | 1226 | } else { |
1227 | 1227 | |
1228 | 1228 | $email_access_link = sprintf( |
1229 | 1229 | '%1$s: %2$s', |
1230 | - __( 'View your donation history', 'give' ), |
|
1231 | - esc_url( $access_url ) |
|
1230 | + __('View your donation history', 'give'), |
|
1231 | + esc_url($access_url) |
|
1232 | 1232 | ); |
1233 | 1233 | } |
1234 | 1234 | } |
@@ -1260,23 +1260,23 @@ discard block |
||
1260 | 1260 | * |
1261 | 1261 | * @return array |
1262 | 1262 | */ |
1263 | -function __give_20_bc_str_type_email_tag_param( $tag_args ) { |
|
1264 | - if ( ! is_array( $tag_args ) ) { |
|
1265 | - switch ( true ) { |
|
1266 | - case ( 'give_payment' === get_post_type( $tag_args ) ): |
|
1267 | - $tag_args = array( 'payment_id' => $tag_args ); |
|
1263 | +function __give_20_bc_str_type_email_tag_param($tag_args) { |
|
1264 | + if ( ! is_array($tag_args)) { |
|
1265 | + switch (true) { |
|
1266 | + case ('give_payment' === get_post_type($tag_args)): |
|
1267 | + $tag_args = array('payment_id' => $tag_args); |
|
1268 | 1268 | break; |
1269 | 1269 | |
1270 | - case ( ! is_wp_error( get_user_by( 'id', $tag_args ) ) ): |
|
1271 | - $tag_args = array( 'user_id' => $tag_args ); |
|
1270 | + case ( ! is_wp_error(get_user_by('id', $tag_args))): |
|
1271 | + $tag_args = array('user_id' => $tag_args); |
|
1272 | 1272 | break; |
1273 | 1273 | |
1274 | - case ( Give()->donors->get_by( 'id', $tag_args ) ): |
|
1275 | - $tag_args = array( 'donor_id' => $tag_args ); |
|
1274 | + case (Give()->donors->get_by('id', $tag_args)): |
|
1275 | + $tag_args = array('donor_id' => $tag_args); |
|
1276 | 1276 | break; |
1277 | 1277 | |
1278 | - case ( Give()->donors->get_by( 'user_id', $tag_args ) ): |
|
1279 | - $tag_args = array( 'user_id' => $tag_args ); |
|
1278 | + case (Give()->donors->get_by('user_id', $tag_args)): |
|
1279 | + $tag_args = array('user_id' => $tag_args); |
|
1280 | 1280 | break; |
1281 | 1281 | } |
1282 | 1282 | } |
@@ -1294,39 +1294,39 @@ discard block |
||
1294 | 1294 | * |
1295 | 1295 | * @return array |
1296 | 1296 | */ |
1297 | -function give_email_tag_reset_password_link( $tag_args, $payment_id ) { |
|
1297 | +function give_email_tag_reset_password_link($tag_args, $payment_id) { |
|
1298 | 1298 | |
1299 | 1299 | $reset_password_url = ''; |
1300 | 1300 | |
1301 | - switch ( true ) { |
|
1302 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
1303 | - $payment = new Give_Payment( $tag_args['payment_id'] ); |
|
1301 | + switch (true) { |
|
1302 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
1303 | + $payment = new Give_Payment($tag_args['payment_id']); |
|
1304 | 1304 | $payment_id = $payment->number; |
1305 | 1305 | break; |
1306 | 1306 | |
1307 | - case give_check_variable( $tag_args, 'isset', 0, 'user_id' ): |
|
1308 | - $reset_password_url = give_get_reset_password_url( $tag_args['user_id'] ); |
|
1307 | + case give_check_variable($tag_args, 'isset', 0, 'user_id'): |
|
1308 | + $reset_password_url = give_get_reset_password_url($tag_args['user_id']); |
|
1309 | 1309 | break; |
1310 | 1310 | |
1311 | - case give_check_variable( $tag_args, 'isset', 0, 'donor_id' ): |
|
1311 | + case give_check_variable($tag_args, 'isset', 0, 'donor_id'): |
|
1312 | 1312 | /* @var Give_Donor $donor */ |
1313 | - $donor = new Give_Donor( $tag_args['user_id'], true ); |
|
1314 | - $reset_password_url = give_get_reset_password_url( $donor->user_id ); |
|
1313 | + $donor = new Give_Donor($tag_args['user_id'], true); |
|
1314 | + $reset_password_url = give_get_reset_password_url($donor->user_id); |
|
1315 | 1315 | break; |
1316 | 1316 | } |
1317 | 1317 | |
1318 | - if( empty( $tag_args['email_content_type'] ) || 'text/html' === $tag_args['email_content_type'] ) { |
|
1318 | + if (empty($tag_args['email_content_type']) || 'text/html' === $tag_args['email_content_type']) { |
|
1319 | 1319 | // Generate link, if Email content type is html. |
1320 | 1320 | $reset_password_link = sprintf( |
1321 | 1321 | '<a href="%1$s" target="_blank">%2$s</a>', |
1322 | - esc_url( $reset_password_url ), |
|
1323 | - __( 'Reset your password »', 'give' ) |
|
1322 | + esc_url($reset_password_url), |
|
1323 | + __('Reset your password »', 'give') |
|
1324 | 1324 | ); |
1325 | - } else{ |
|
1325 | + } else { |
|
1326 | 1326 | $reset_password_link = sprintf( |
1327 | 1327 | '%1$s: %2$s', |
1328 | - __( 'Reset your password', 'give' ), |
|
1329 | - esc_url( $reset_password_url ) |
|
1328 | + __('Reset your password', 'give'), |
|
1329 | + esc_url($reset_password_url) |
|
1330 | 1330 | ); |
1331 | 1331 | } |
1332 | 1332 | |
@@ -1355,21 +1355,21 @@ discard block |
||
1355 | 1355 | * |
1356 | 1356 | * @return mixed|string |
1357 | 1357 | */ |
1358 | -function give_get_reset_password_url( $user_id ) { |
|
1358 | +function give_get_reset_password_url($user_id) { |
|
1359 | 1359 | $reset_password_url = ''; |
1360 | 1360 | |
1361 | 1361 | // Proceed further only, if user_id exists. |
1362 | - if ( $user_id ) { |
|
1362 | + if ($user_id) { |
|
1363 | 1363 | |
1364 | 1364 | // Get User Object Details. |
1365 | - $user = get_user_by( 'ID', $user_id ); |
|
1365 | + $user = get_user_by('ID', $user_id); |
|
1366 | 1366 | |
1367 | 1367 | // Prepare Reset Password URL. |
1368 | - $reset_password_url = esc_url( add_query_arg( array( |
|
1368 | + $reset_password_url = esc_url(add_query_arg(array( |
|
1369 | 1369 | 'action' => 'rp', |
1370 | - 'key' => get_password_reset_key( $user ), |
|
1370 | + 'key' => get_password_reset_key($user), |
|
1371 | 1371 | 'login' => $user->user_login, |
1372 | - ), wp_login_url() ) ); |
|
1372 | + ), wp_login_url())); |
|
1373 | 1373 | } |
1374 | 1374 | |
1375 | 1375 | return $reset_password_url; |
@@ -1388,91 +1388,91 @@ discard block |
||
1388 | 1388 | * |
1389 | 1389 | * @return mixed |
1390 | 1390 | */ |
1391 | -function __give_render_metadata_email_tag( $content, $tag_args ) { |
|
1392 | - preg_match_all( "/{meta_([A-z0-9\-\_\ ]+)}/s", $content, $matches ); |
|
1391 | +function __give_render_metadata_email_tag($content, $tag_args) { |
|
1392 | + preg_match_all("/{meta_([A-z0-9\-\_\ ]+)}/s", $content, $matches); |
|
1393 | 1393 | |
1394 | - if ( ! empty( $matches[0] ) ) { |
|
1394 | + if ( ! empty($matches[0])) { |
|
1395 | 1395 | $search = $replace = array(); |
1396 | - foreach ( $matches[0] as $index => $meta_tag ) { |
|
1397 | - if ( in_array( $meta_tag, $search ) ) { |
|
1396 | + foreach ($matches[0] as $index => $meta_tag) { |
|
1397 | + if (in_array($meta_tag, $search)) { |
|
1398 | 1398 | continue; |
1399 | 1399 | } |
1400 | 1400 | |
1401 | 1401 | $search[] = $meta_tag; |
1402 | 1402 | |
1403 | - $meta_tag = str_replace( array( '{', 'meta_', '}' ), '', $meta_tag ); |
|
1404 | - $meta_tag_arr = array_map( 'trim', explode( ' ', $meta_tag, 2 ) ); |
|
1405 | - $meta_tag = current( $meta_tag_arr ); |
|
1403 | + $meta_tag = str_replace(array('{', 'meta_', '}'), '', $meta_tag); |
|
1404 | + $meta_tag_arr = array_map('trim', explode(' ', $meta_tag, 2)); |
|
1405 | + $meta_tag = current($meta_tag_arr); |
|
1406 | 1406 | |
1407 | - $meta_tag = str_replace( array( '{', 'meta_', '}' ), '', $meta_tag ); |
|
1408 | - $type = current( explode( '_', $meta_tag, 2 ) ); |
|
1409 | - $meta_name = preg_replace( "/^{$type}_/", '', $meta_tag ); |
|
1407 | + $meta_tag = str_replace(array('{', 'meta_', '}'), '', $meta_tag); |
|
1408 | + $type = current(explode('_', $meta_tag, 2)); |
|
1409 | + $meta_name = preg_replace("/^{$type}_/", '', $meta_tag); |
|
1410 | 1410 | |
1411 | - switch ( $type ) { |
|
1411 | + switch ($type) { |
|
1412 | 1412 | case 'donation': |
1413 | 1413 | |
1414 | 1414 | //Bailout. |
1415 | - if ( ! isset( $tag_args['payment_id'] ) ) { |
|
1415 | + if ( ! isset($tag_args['payment_id'])) { |
|
1416 | 1416 | $replace[] = ''; |
1417 | 1417 | continue; |
1418 | 1418 | } |
1419 | 1419 | |
1420 | - $meta_data = give_get_meta( absint( $tag_args['payment_id'] ), $meta_name, true, '' ); |
|
1420 | + $meta_data = give_get_meta(absint($tag_args['payment_id']), $meta_name, true, ''); |
|
1421 | 1421 | |
1422 | - if ( ! isset( $meta_tag_arr[1] ) || ! is_array( $meta_data ) ) { |
|
1422 | + if ( ! isset($meta_tag_arr[1]) || ! is_array($meta_data)) { |
|
1423 | 1423 | $replace[] = $meta_data; |
1424 | - } elseif ( in_array( $meta_tag_arr[1], array_keys( $meta_data ) ) ) { |
|
1425 | - $replace[] = $meta_data[ $meta_tag_arr[1] ]; |
|
1424 | + } elseif (in_array($meta_tag_arr[1], array_keys($meta_data))) { |
|
1425 | + $replace[] = $meta_data[$meta_tag_arr[1]]; |
|
1426 | 1426 | } |
1427 | 1427 | |
1428 | 1428 | break; |
1429 | 1429 | |
1430 | 1430 | case 'form': |
1431 | - $form_id = isset( $tag_args['form_id'] ) ? absint( $tag_args['form_id'] ) : 0; |
|
1431 | + $form_id = isset($tag_args['form_id']) ? absint($tag_args['form_id']) : 0; |
|
1432 | 1432 | |
1433 | 1433 | // Bailout. |
1434 | - if ( ! $form_id && isset( $tag_args['payment_id'] ) ) { |
|
1435 | - $form_id = give_get_payment_form_id( $tag_args['payment_id'] ); |
|
1434 | + if ( ! $form_id && isset($tag_args['payment_id'])) { |
|
1435 | + $form_id = give_get_payment_form_id($tag_args['payment_id']); |
|
1436 | 1436 | } |
1437 | 1437 | |
1438 | - $meta_data = give_get_meta( $form_id, $meta_name, true, '' ); |
|
1439 | - if ( ! isset( $meta_tag_arr[1] ) || ! is_array( $meta_data ) ) { |
|
1438 | + $meta_data = give_get_meta($form_id, $meta_name, true, ''); |
|
1439 | + if ( ! isset($meta_tag_arr[1]) || ! is_array($meta_data)) { |
|
1440 | 1440 | $replace[] = $meta_data; |
1441 | - } elseif ( in_array( $meta_tag_arr[1], array_keys( $meta_data ) ) ) { |
|
1442 | - $replace[] = $meta_data[ $meta_tag_arr[1] ]; |
|
1441 | + } elseif (in_array($meta_tag_arr[1], array_keys($meta_data))) { |
|
1442 | + $replace[] = $meta_data[$meta_tag_arr[1]]; |
|
1443 | 1443 | } |
1444 | 1444 | break; |
1445 | 1445 | |
1446 | 1446 | case 'donor': |
1447 | - $donor_id = isset( $tag_args['donor_id'] ) ? absint( $tag_args['donor_id'] ) : 0; |
|
1447 | + $donor_id = isset($tag_args['donor_id']) ? absint($tag_args['donor_id']) : 0; |
|
1448 | 1448 | |
1449 | 1449 | // Bailout. |
1450 | - if ( ! $donor_id ) { |
|
1451 | - if ( isset( $tag_args['payment_id'] ) ) { |
|
1452 | - $donor_id = give_get_payment_donor_id( $tag_args['payment_id'] ); |
|
1453 | - } elseif ( isset( $tag_args['user_id'] ) ) { |
|
1454 | - $donor = new Give_Donor( $tag_args['user_id'], true ); |
|
1450 | + if ( ! $donor_id) { |
|
1451 | + if (isset($tag_args['payment_id'])) { |
|
1452 | + $donor_id = give_get_payment_donor_id($tag_args['payment_id']); |
|
1453 | + } elseif (isset($tag_args['user_id'])) { |
|
1454 | + $donor = new Give_Donor($tag_args['user_id'], true); |
|
1455 | 1455 | $donor_id = $donor->ID; |
1456 | 1456 | } |
1457 | 1457 | } |
1458 | 1458 | |
1459 | - $donor = new Give_Donor( $donor_id ); |
|
1460 | - $meta_data = $donor->get_meta( $meta_name ); |
|
1461 | - if ( ! isset( $meta_tag_arr[1] ) || ! is_array( $meta_data ) ) { |
|
1459 | + $donor = new Give_Donor($donor_id); |
|
1460 | + $meta_data = $donor->get_meta($meta_name); |
|
1461 | + if ( ! isset($meta_tag_arr[1]) || ! is_array($meta_data)) { |
|
1462 | 1462 | $replace[] = $meta_data; |
1463 | - } elseif ( in_array( $meta_tag_arr[1], array_keys( $meta_data ) ) ) { |
|
1464 | - $replace[] = $meta_data[ $meta_tag_arr[1] ]; |
|
1463 | + } elseif (in_array($meta_tag_arr[1], array_keys($meta_data))) { |
|
1464 | + $replace[] = $meta_data[$meta_tag_arr[1]]; |
|
1465 | 1465 | } |
1466 | 1466 | |
1467 | 1467 | break; |
1468 | 1468 | |
1469 | 1469 | default: |
1470 | - $replace[] = end( $search ); |
|
1470 | + $replace[] = end($search); |
|
1471 | 1471 | } |
1472 | 1472 | } |
1473 | 1473 | |
1474 | - if ( ! empty( $search ) && ! empty( $replace ) ) { |
|
1475 | - $content = str_replace( $search, $replace, $content ); |
|
1474 | + if ( ! empty($search) && ! empty($replace)) { |
|
1475 | + $content = str_replace($search, $replace, $content); |
|
1476 | 1476 | } |
1477 | 1477 | } |
1478 | 1478 | |
@@ -1480,4 +1480,4 @@ discard block |
||
1480 | 1480 | return $content; |
1481 | 1481 | } |
1482 | 1482 | |
1483 | -add_filter( 'give_email_template_tags', '__give_render_metadata_email_tag', 10, 2 ); |
|
1483 | +add_filter('give_email_template_tags', '__give_render_metadata_email_tag', 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 | |
@@ -26,16 +26,16 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @return void |
28 | 28 | */ |
29 | -function give_email_donation_receipt( $payment_id, $admin_notice = true ) { |
|
30 | - $payment = new Give_Payment( $payment_id ); |
|
29 | +function give_email_donation_receipt($payment_id, $admin_notice = true) { |
|
30 | + $payment = new Give_Payment($payment_id); |
|
31 | 31 | |
32 | 32 | /** |
33 | 33 | * Fire the action |
34 | 34 | */ |
35 | - do_action( 'give_donation-receipt_email_notification', $payment_id ); |
|
35 | + do_action('give_donation-receipt_email_notification', $payment_id); |
|
36 | 36 | |
37 | 37 | // If admin notifications are on, send the admin notice. |
38 | - if ( $admin_notice && give_is_setting_enabled( Give_Email_Notification::get_instance('new-donation' )->get_notification_status() ) ) { |
|
38 | + if ($admin_notice && give_is_setting_enabled(Give_Email_Notification::get_instance('new-donation')->get_notification_status())) { |
|
39 | 39 | /** |
40 | 40 | * Fires in the donation email receipt. |
41 | 41 | * |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * @param int $payment_id Payment id. |
47 | 47 | * @param mixed $payment_data Payment meta data. |
48 | 48 | */ |
49 | - do_action( 'give_new-donation_email_notification', $payment_id, $payment->payment_meta ); |
|
49 | + do_action('give_new-donation_email_notification', $payment_id, $payment->payment_meta); |
|
50 | 50 | } |
51 | 51 | } |
52 | 52 | |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * |
60 | 60 | * @return void |
61 | 61 | */ |
62 | -function give_admin_email_notice( $payment_id ) { |
|
62 | +function give_admin_email_notice($payment_id) { |
|
63 | 63 | /** |
64 | 64 | * Fires in the donation email receipt. |
65 | 65 | * |
@@ -70,10 +70,10 @@ discard block |
||
70 | 70 | * @param int $payment_id Payment id. |
71 | 71 | * @param mixed $payment_data Payment meta data. |
72 | 72 | */ |
73 | - do_action( 'give_new-donation_email_notification', $payment_id ); |
|
73 | + do_action('give_new-donation_email_notification', $payment_id); |
|
74 | 74 | } |
75 | 75 | |
76 | -add_action( 'give_admin_donation_email', 'give_admin_email_notice' ); |
|
76 | +add_action('give_admin_donation_email', 'give_admin_email_notice'); |
|
77 | 77 | |
78 | 78 | |
79 | 79 | /** |
@@ -86,16 +86,16 @@ discard block |
||
86 | 86 | */ |
87 | 87 | function give_get_default_donation_notification_email() { |
88 | 88 | |
89 | - $default_email_body = __( 'Hi there,', 'give' ) . "\n\n"; |
|
90 | - $default_email_body .= __( 'This email is to inform you that a new donation has been made on your website:', 'give' ) . ' <a href="' . get_bloginfo( 'url' ) . '" target="_blank">' . get_bloginfo( 'url' ) . '</a>' . ".\n\n"; |
|
91 | - $default_email_body .= '<strong>' . __( 'Donor:', 'give' ) . '</strong> {name}' . "\n"; |
|
92 | - $default_email_body .= '<strong>' . __( 'Donation:', 'give' ) . '</strong> {donation}' . "\n"; |
|
93 | - $default_email_body .= '<strong>' . __( 'Amount:', 'give' ) . '</strong> {amount}' . "\n"; |
|
94 | - $default_email_body .= '<strong>' . __( 'Payment Method:', 'give' ) . '</strong> {payment_method}' . "\n\n"; |
|
95 | - $default_email_body .= __( 'Thank you,', 'give' ) . "\n\n"; |
|
96 | - $default_email_body .= '{sitename}' . "\n"; |
|
89 | + $default_email_body = __('Hi there,', 'give')."\n\n"; |
|
90 | + $default_email_body .= __('This email is to inform you that a new donation has been made on your website:', 'give').' <a href="'.get_bloginfo('url').'" target="_blank">'.get_bloginfo('url').'</a>'.".\n\n"; |
|
91 | + $default_email_body .= '<strong>'.__('Donor:', 'give').'</strong> {name}'."\n"; |
|
92 | + $default_email_body .= '<strong>'.__('Donation:', 'give').'</strong> {donation}'."\n"; |
|
93 | + $default_email_body .= '<strong>'.__('Amount:', 'give').'</strong> {amount}'."\n"; |
|
94 | + $default_email_body .= '<strong>'.__('Payment Method:', 'give').'</strong> {payment_method}'."\n\n"; |
|
95 | + $default_email_body .= __('Thank you,', 'give')."\n\n"; |
|
96 | + $default_email_body .= '{sitename}'."\n"; |
|
97 | 97 | |
98 | - return apply_filters( 'give_default_donation_notification_email', $default_email_body ); |
|
98 | + return apply_filters('give_default_donation_notification_email', $default_email_body); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | |
@@ -109,21 +109,21 @@ discard block |
||
109 | 109 | */ |
110 | 110 | function give_get_default_donation_receipt_email() { |
111 | 111 | |
112 | - $default_email_body = __( 'Dear', 'give' ) . " {name},\n\n"; |
|
113 | - $default_email_body .= __( 'Thank you for your donation. Your generosity is appreciated! Here are the details of your donation:', 'give' ) . "\n\n"; |
|
114 | - $default_email_body .= '<strong>' . __( 'Donor:', 'give' ) . '</strong> {fullname}' . "\n"; |
|
115 | - $default_email_body .= '<strong>' . __( 'Donation:', 'give' ) . '</strong> {donation}' . "\n"; |
|
116 | - $default_email_body .= '<strong>' . __( 'Donation Date:', 'give' ) . '</strong> {date}' . "\n"; |
|
117 | - $default_email_body .= '<strong>' . __( 'Amount:', 'give' ) . '</strong> {amount}' . "\n"; |
|
118 | - $default_email_body .= '<strong>' . __( 'Payment Method:', 'give' ) . '</strong> {payment_method}' . "\n"; |
|
119 | - $default_email_body .= '<strong>' . __( 'Payment ID:', 'give' ) . '</strong> {payment_id}' . "\n"; |
|
120 | - $default_email_body .= '<strong>' . __( 'Receipt ID:', 'give' ) . '</strong> {receipt_id}' . "\n\n"; |
|
121 | - $default_email_body .= '{receipt_link}' . "\n\n"; |
|
112 | + $default_email_body = __('Dear', 'give')." {name},\n\n"; |
|
113 | + $default_email_body .= __('Thank you for your donation. Your generosity is appreciated! Here are the details of your donation:', 'give')."\n\n"; |
|
114 | + $default_email_body .= '<strong>'.__('Donor:', 'give').'</strong> {fullname}'."\n"; |
|
115 | + $default_email_body .= '<strong>'.__('Donation:', 'give').'</strong> {donation}'."\n"; |
|
116 | + $default_email_body .= '<strong>'.__('Donation Date:', 'give').'</strong> {date}'."\n"; |
|
117 | + $default_email_body .= '<strong>'.__('Amount:', 'give').'</strong> {amount}'."\n"; |
|
118 | + $default_email_body .= '<strong>'.__('Payment Method:', 'give').'</strong> {payment_method}'."\n"; |
|
119 | + $default_email_body .= '<strong>'.__('Payment ID:', 'give').'</strong> {payment_id}'."\n"; |
|
120 | + $default_email_body .= '<strong>'.__('Receipt ID:', 'give').'</strong> {receipt_id}'."\n\n"; |
|
121 | + $default_email_body .= '{receipt_link}'."\n\n"; |
|
122 | 122 | $default_email_body .= "\n\n"; |
123 | - $default_email_body .= __( 'Sincerely,', 'give' ) . "\n"; |
|
124 | - $default_email_body .= '{sitename}' . "\n"; |
|
123 | + $default_email_body .= __('Sincerely,', 'give')."\n"; |
|
124 | + $default_email_body .= '{sitename}'."\n"; |
|
125 | 125 | |
126 | - return apply_filters( 'give_default_donation_receipt_email', $default_email_body ); |
|
126 | + return apply_filters('give_default_donation_receipt_email', $default_email_body); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | /** |
@@ -136,22 +136,22 @@ discard block |
||
136 | 136 | * |
137 | 137 | * @return array $email_names |
138 | 138 | */ |
139 | -function give_get_email_names( $user_info, $payment = false ) { |
|
139 | +function give_get_email_names($user_info, $payment = false) { |
|
140 | 140 | $email_names = array(); |
141 | 141 | |
142 | - if ( is_a( $payment, 'Give_Payment' ) ) { |
|
142 | + if (is_a($payment, 'Give_Payment')) { |
|
143 | 143 | |
144 | - if ( $payment->user_id > 0 ) { |
|
144 | + if ($payment->user_id > 0) { |
|
145 | 145 | |
146 | - $user_data = get_userdata( $payment->user_id ); |
|
146 | + $user_data = get_userdata($payment->user_id); |
|
147 | 147 | $email_names['name'] = $payment->first_name; |
148 | - $email_names['fullname'] = trim( $payment->first_name . ' ' . $payment->last_name ); |
|
148 | + $email_names['fullname'] = trim($payment->first_name.' '.$payment->last_name); |
|
149 | 149 | $email_names['username'] = $user_data->user_login; |
150 | 150 | |
151 | - } elseif ( ! empty( $payment->first_name ) ) { |
|
151 | + } elseif ( ! empty($payment->first_name)) { |
|
152 | 152 | |
153 | 153 | $email_names['name'] = $payment->first_name; |
154 | - $email_names['fullname'] = trim( $payment->first_name . ' ' . $payment->last_name ); |
|
154 | + $email_names['fullname'] = trim($payment->first_name.' '.$payment->last_name); |
|
155 | 155 | $email_names['username'] = $payment->first_name; |
156 | 156 | |
157 | 157 | } else { |
@@ -164,30 +164,30 @@ discard block |
||
164 | 164 | } else { |
165 | 165 | |
166 | 166 | // Support for old serialized data. |
167 | - if ( is_serialized( $user_info ) ) { |
|
167 | + if (is_serialized($user_info)) { |
|
168 | 168 | |
169 | 169 | // Security check. |
170 | - preg_match( '/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $user_info, $matches ); |
|
171 | - if ( ! empty( $matches ) ) { |
|
170 | + preg_match('/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $user_info, $matches); |
|
171 | + if ( ! empty($matches)) { |
|
172 | 172 | return array( |
173 | 173 | 'name' => '', |
174 | 174 | 'fullname' => '', |
175 | 175 | 'username' => '', |
176 | 176 | ); |
177 | 177 | } else { |
178 | - $user_info = maybe_unserialize( $user_info ); |
|
178 | + $user_info = maybe_unserialize($user_info); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | } |
182 | 182 | |
183 | - if ( isset( $user_info['id'] ) && $user_info['id'] > 0 && isset( $user_info['first_name'] ) ) { |
|
184 | - $user_data = get_userdata( $user_info['id'] ); |
|
183 | + if (isset($user_info['id']) && $user_info['id'] > 0 && isset($user_info['first_name'])) { |
|
184 | + $user_data = get_userdata($user_info['id']); |
|
185 | 185 | $email_names['name'] = $user_info['first_name']; |
186 | - $email_names['fullname'] = $user_info['first_name'] . ' ' . $user_info['last_name']; |
|
186 | + $email_names['fullname'] = $user_info['first_name'].' '.$user_info['last_name']; |
|
187 | 187 | $email_names['username'] = $user_data->user_login; |
188 | - } elseif ( isset( $user_info['first_name'] ) ) { |
|
188 | + } elseif (isset($user_info['first_name'])) { |
|
189 | 189 | $email_names['name'] = $user_info['first_name']; |
190 | - $email_names['fullname'] = $user_info['first_name'] . ' ' . $user_info['last_name']; |
|
190 | + $email_names['fullname'] = $user_info['first_name'].' '.$user_info['last_name']; |
|
191 | 191 | $email_names['username'] = $user_info['first_name']; |
192 | 192 | } else { |
193 | 193 | $email_names['name'] = $user_info['email']; |
@@ -207,37 +207,37 @@ discard block |
||
207 | 207 | * |
208 | 208 | * @since 1.8.14 |
209 | 209 | */ |
210 | -function give_admin_email_user_donor_disconnection( $user_id, $donor_id ) { |
|
210 | +function give_admin_email_user_donor_disconnection($user_id, $donor_id) { |
|
211 | 211 | |
212 | - $user_id = absint( $user_id ); |
|
213 | - $donor_id = absint( $donor_id ); |
|
212 | + $user_id = absint($user_id); |
|
213 | + $donor_id = absint($donor_id); |
|
214 | 214 | |
215 | 215 | // Bail Out, if user id doesn't exists. |
216 | - if ( empty( $user_id ) ) { |
|
216 | + if (empty($user_id)) { |
|
217 | 217 | return; |
218 | 218 | } |
219 | 219 | |
220 | 220 | // Bail Out, if donor id doesn't exists. |
221 | - if ( empty( $donor_id ) ) { |
|
221 | + if (empty($donor_id)) { |
|
222 | 222 | return; |
223 | 223 | } |
224 | 224 | |
225 | - $from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) ); |
|
225 | + $from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)); |
|
226 | 226 | |
227 | - $from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) ); |
|
227 | + $from_email = give_get_option('from_email', get_bloginfo('admin_email')); |
|
228 | 228 | |
229 | 229 | /* translators: %s: payment id */ |
230 | - $subject = __( 'Attention: User tries to login whose Donor profile is disconnected!', 'give' ); |
|
230 | + $subject = __('Attention: User tries to login whose Donor profile is disconnected!', 'give'); |
|
231 | 231 | |
232 | 232 | /** |
233 | 233 | * Filters the Donor-User Disconnection notification subject. |
234 | 234 | * |
235 | 235 | * @since 1.8.14 |
236 | 236 | */ |
237 | - $subject = apply_filters( 'give_admin_donor_user_disconnection_notification_subject', wp_strip_all_tags( $subject ) ); |
|
237 | + $subject = apply_filters('give_admin_donor_user_disconnection_notification_subject', wp_strip_all_tags($subject)); |
|
238 | 238 | |
239 | - $headers = "From: " . stripslashes_deep( html_entity_decode( $from_name, ENT_COMPAT, 'UTF-8' ) ) . " <$from_email>\r\n"; |
|
240 | - $headers .= "Reply-To: " . $from_email . "\r\n"; |
|
239 | + $headers = "From: ".stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8'))." <$from_email>\r\n"; |
|
240 | + $headers .= "Reply-To: ".$from_email."\r\n"; |
|
241 | 241 | $headers .= "Content-Type: text/html; charset=utf-8\r\n"; |
242 | 242 | |
243 | 243 | /** |
@@ -245,25 +245,25 @@ discard block |
||
245 | 245 | * |
246 | 246 | * @since 1.8.14 |
247 | 247 | */ |
248 | - $headers = apply_filters( 'give_admin_donor_user_disconnection_notification_headers', $headers ); |
|
248 | + $headers = apply_filters('give_admin_donor_user_disconnection_notification_headers', $headers); |
|
249 | 249 | |
250 | - $message = __( 'Hi Admin,', 'give' ) . "\n\n"; |
|
251 | - $message .= __( 'This email is to inform you that a user has tried logging in. But, User was unable to login due to User-Donor profile disconnection.', 'give' ) . "\n\n"; |
|
252 | - $message .= __( 'Do you want to reconnect User and Donor profile again?', 'give' ) . "\n\n"; |
|
250 | + $message = __('Hi Admin,', 'give')."\n\n"; |
|
251 | + $message .= __('This email is to inform you that a user has tried logging in. But, User was unable to login due to User-Donor profile disconnection.', 'give')."\n\n"; |
|
252 | + $message .= __('Do you want to reconnect User and Donor profile again?', 'give')."\n\n"; |
|
253 | 253 | $message .= sprintf( |
254 | 254 | '<a href="%1$s">%2$s</a>', |
255 | - esc_url( admin_url() . 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor_id . '&user_id=' . $user_id . '&give-message=reconnect-user' ), |
|
256 | - __( 'Reconnect User', 'give' ) . "\n\n" |
|
255 | + esc_url(admin_url().'edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor_id.'&user_id='.$user_id.'&give-message=reconnect-user'), |
|
256 | + __('Reconnect User', 'give')."\n\n" |
|
257 | 257 | ); |
258 | - $message .= __( 'Thank you,', 'give' ) . "\n\n"; |
|
259 | - $message .= '{sitename}' . "\n"; |
|
258 | + $message .= __('Thank you,', 'give')."\n\n"; |
|
259 | + $message .= '{sitename}'."\n"; |
|
260 | 260 | |
261 | 261 | $emails = Give()->emails; |
262 | - $emails->__set( 'from_name', $from_name ); |
|
263 | - $emails->__set( 'from_email', $from_email ); |
|
264 | - $emails->__set( 'headers', $headers ); |
|
265 | - $emails->__set( 'heading', __( 'User - Donor Profile Disconnection', 'give' ) ); |
|
262 | + $emails->__set('from_name', $from_name); |
|
263 | + $emails->__set('from_email', $from_email); |
|
264 | + $emails->__set('headers', $headers); |
|
265 | + $emails->__set('heading', __('User - Donor Profile Disconnection', 'give')); |
|
266 | 266 | |
267 | - $emails->send( give_get_admin_notice_emails(), $subject, give_do_email_tags( $message ) ); |
|
267 | + $emails->send(give_get_admin_notice_emails(), $subject, give_do_email_tags($message)); |
|
268 | 268 | |
269 | 269 | } |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | */ |
14 | 14 | |
15 | 15 | // Exit if accessed directly. |
16 | -if ( ! defined( 'ABSPATH' ) ) { |
|
16 | +if ( ! defined('ABSPATH')) { |
|
17 | 17 | exit; |
18 | 18 | } |
19 | 19 | |
@@ -25,70 +25,70 @@ discard block |
||
25 | 25 | */ |
26 | 26 | function give_do_automatic_upgrades() { |
27 | 27 | $did_upgrade = false; |
28 | - $give_version = preg_replace( '/[^0-9.].*/', '', get_option( 'give_version' ) ); |
|
28 | + $give_version = preg_replace('/[^0-9.].*/', '', get_option('give_version')); |
|
29 | 29 | |
30 | - if ( ! $give_version ) { |
|
30 | + if ( ! $give_version) { |
|
31 | 31 | // 1.0 is the first version to use this option so we must add it. |
32 | 32 | $give_version = '1.0'; |
33 | 33 | } |
34 | 34 | |
35 | - switch ( true ) { |
|
35 | + switch (true) { |
|
36 | 36 | |
37 | - case version_compare( $give_version, '1.6', '<' ) : |
|
37 | + case version_compare($give_version, '1.6', '<') : |
|
38 | 38 | give_v16_upgrades(); |
39 | 39 | $did_upgrade = true; |
40 | 40 | |
41 | - case version_compare( $give_version, '1.7', '<' ) : |
|
41 | + case version_compare($give_version, '1.7', '<') : |
|
42 | 42 | give_v17_upgrades(); |
43 | 43 | $did_upgrade = true; |
44 | 44 | |
45 | - case version_compare( $give_version, '1.8', '<' ) : |
|
45 | + case version_compare($give_version, '1.8', '<') : |
|
46 | 46 | give_v18_upgrades(); |
47 | 47 | $did_upgrade = true; |
48 | 48 | |
49 | - case version_compare( $give_version, '1.8.7', '<' ) : |
|
49 | + case version_compare($give_version, '1.8.7', '<') : |
|
50 | 50 | give_v187_upgrades(); |
51 | 51 | $did_upgrade = true; |
52 | 52 | |
53 | - case version_compare( $give_version, '1.8.8', '<' ) : |
|
53 | + case version_compare($give_version, '1.8.8', '<') : |
|
54 | 54 | give_v188_upgrades(); |
55 | 55 | $did_upgrade = true; |
56 | 56 | |
57 | - case version_compare( $give_version, '1.8.9', '<' ) : |
|
57 | + case version_compare($give_version, '1.8.9', '<') : |
|
58 | 58 | give_v189_upgrades(); |
59 | 59 | $did_upgrade = true; |
60 | 60 | |
61 | - case version_compare( $give_version, '1.8.12', '<' ) : |
|
61 | + case version_compare($give_version, '1.8.12', '<') : |
|
62 | 62 | give_v1812_upgrades(); |
63 | 63 | $did_upgrade = true; |
64 | 64 | |
65 | - case version_compare( $give_version, '1.8.13', '<' ) : |
|
65 | + case version_compare($give_version, '1.8.13', '<') : |
|
66 | 66 | give_v1813_upgrades(); |
67 | 67 | $did_upgrade = true; |
68 | 68 | |
69 | - case version_compare( $give_version, '1.8.17', '<' ) : |
|
69 | + case version_compare($give_version, '1.8.17', '<') : |
|
70 | 70 | give_v1817_upgrades(); |
71 | 71 | $did_upgrade = true; |
72 | 72 | |
73 | - case version_compare( $give_version, '1.8.18', '<' ) : |
|
73 | + case version_compare($give_version, '1.8.18', '<') : |
|
74 | 74 | give_v1818_upgrades(); |
75 | 75 | $did_upgrade = true; |
76 | 76 | |
77 | - case version_compare( $give_version, '2.0', '<' ) : |
|
77 | + case version_compare($give_version, '2.0', '<') : |
|
78 | 78 | give_v20_upgrades(); |
79 | 79 | $did_upgrade = true; |
80 | 80 | |
81 | - case version_compare( $give_version, '2.0.1', '<' ) : |
|
81 | + case version_compare($give_version, '2.0.1', '<') : |
|
82 | 82 | // Do nothing on fresh install. |
83 | - if( ! doing_action( 'give_upgrades' ) ) { |
|
83 | + if ( ! doing_action('give_upgrades')) { |
|
84 | 84 | give_v201_create_tables(); |
85 | - Give_Updates::get_instance()->__health_background_update( Give_Updates::get_instance() ); |
|
85 | + Give_Updates::get_instance()->__health_background_update(Give_Updates::get_instance()); |
|
86 | 86 | Give_Updates::$background_updater->dispatch(); |
87 | 87 | } |
88 | 88 | |
89 | 89 | $did_upgrade = true; |
90 | 90 | |
91 | - case version_compare( $give_version, '2.0.2', '<' ) : |
|
91 | + case version_compare($give_version, '2.0.2', '<') : |
|
92 | 92 | // Remove 2.0.1 update to rerun on 2.0.2 |
93 | 93 | $completed_upgrades = give_get_completed_upgrades(); |
94 | 94 | $v201_updates = array( |
@@ -98,35 +98,35 @@ discard block |
||
98 | 98 | 'v201_logs_upgrades' |
99 | 99 | ); |
100 | 100 | |
101 | - foreach ( $v201_updates as $v201_update ) { |
|
102 | - if( in_array( $v201_update, $completed_upgrades ) ) { |
|
103 | - unset( $completed_upgrades[ array_search( $v201_update, $completed_upgrades )] ); |
|
101 | + foreach ($v201_updates as $v201_update) { |
|
102 | + if (in_array($v201_update, $completed_upgrades)) { |
|
103 | + unset($completed_upgrades[array_search($v201_update, $completed_upgrades)]); |
|
104 | 104 | } |
105 | 105 | } |
106 | 106 | |
107 | - update_option( 'give_completed_upgrades', $completed_upgrades ); |
|
107 | + update_option('give_completed_upgrades', $completed_upgrades); |
|
108 | 108 | |
109 | 109 | // Do nothing on fresh install. |
110 | - if( ! doing_action( 'give_upgrades' ) ) { |
|
110 | + if ( ! doing_action('give_upgrades')) { |
|
111 | 111 | give_v201_create_tables(); |
112 | - Give_Updates::get_instance()->__health_background_update( Give_Updates::get_instance() ); |
|
112 | + Give_Updates::get_instance()->__health_background_update(Give_Updates::get_instance()); |
|
113 | 113 | Give_Updates::$background_updater->dispatch(); |
114 | 114 | } |
115 | 115 | |
116 | 116 | $did_upgrade = true; |
117 | 117 | |
118 | - case version_compare( $give_version, '2.0.3', '<' ) : |
|
118 | + case version_compare($give_version, '2.0.3', '<') : |
|
119 | 119 | give_v203_upgrades(); |
120 | 120 | $did_upgrade = true; |
121 | 121 | } |
122 | 122 | |
123 | - if ( $did_upgrade ) { |
|
124 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
123 | + if ($did_upgrade) { |
|
124 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
125 | 125 | } |
126 | 126 | } |
127 | 127 | |
128 | -add_action( 'admin_init', 'give_do_automatic_upgrades' ); |
|
129 | -add_action( 'give_upgrades', 'give_do_automatic_upgrades' ); |
|
128 | +add_action('admin_init', 'give_do_automatic_upgrades'); |
|
129 | +add_action('give_upgrades', 'give_do_automatic_upgrades'); |
|
130 | 130 | |
131 | 131 | /** |
132 | 132 | * Display Upgrade Notices. |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | * |
141 | 141 | * @return void |
142 | 142 | */ |
143 | -function give_show_upgrade_notices( $give_updates ) { |
|
143 | +function give_show_upgrade_notices($give_updates) { |
|
144 | 144 | // v1.3.2 Upgrades |
145 | 145 | $give_updates->register( |
146 | 146 | array( |
@@ -206,32 +206,32 @@ discard block |
||
206 | 206 | ); |
207 | 207 | |
208 | 208 | // v1.8.17 Upgrades for donations. |
209 | - $give_updates->register( array( |
|
209 | + $give_updates->register(array( |
|
210 | 210 | 'id' => 'v1817_update_donation_iranian_currency_code', |
211 | 211 | 'version' => '1.8.17', |
212 | 212 | 'callback' => 'give_v1817_update_donation_iranian_currency_code', |
213 | - ) ); |
|
213 | + )); |
|
214 | 214 | |
215 | 215 | // v1.8.17 Upgrades for cleanup of user roles. |
216 | - $give_updates->register( array( |
|
216 | + $give_updates->register(array( |
|
217 | 217 | 'id' => 'v1817_cleanup_user_roles', |
218 | 218 | 'version' => '1.8.17', |
219 | 219 | 'callback' => 'give_v1817_cleanup_user_roles', |
220 | - ) ); |
|
220 | + )); |
|
221 | 221 | |
222 | 222 | // v1.8.18 Upgrades for assigning custom amount to existing set donations. |
223 | - $give_updates->register( array( |
|
223 | + $give_updates->register(array( |
|
224 | 224 | 'id' => 'v1818_assign_custom_amount_set_donation', |
225 | 225 | 'version' => '1.8.18', |
226 | 226 | 'callback' => 'give_v1818_assign_custom_amount_set_donation', |
227 | - ) ); |
|
227 | + )); |
|
228 | 228 | |
229 | 229 | // v1.8.18 Cleanup the Give Worker Role Caps. |
230 | - $give_updates->register( array( |
|
230 | + $give_updates->register(array( |
|
231 | 231 | 'id' => 'v1818_give_worker_role_cleanup', |
232 | 232 | 'version' => '1.8.18', |
233 | 233 | 'callback' => 'give_v1818_give_worker_role_cleanup', |
234 | - ) ); |
|
234 | + )); |
|
235 | 235 | |
236 | 236 | // v2.0.0 Upgrades |
237 | 237 | $give_updates->register( |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | 'id' => 'v20_move_metadata_into_new_table', |
286 | 286 | 'version' => '2.0.0', |
287 | 287 | 'callback' => 'give_v20_move_metadata_into_new_table_callback', |
288 | - 'depend' => array( 'v20_upgrades_payment_metadata', 'v20_upgrades_form_metadata' ), |
|
288 | + 'depend' => array('v20_upgrades_payment_metadata', 'v20_upgrades_form_metadata'), |
|
289 | 289 | ) |
290 | 290 | ); |
291 | 291 | |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | 'id' => 'v201_move_metadata_into_new_table', |
332 | 332 | 'version' => '2.0.1', |
333 | 333 | 'callback' => 'give_v201_move_metadata_into_new_table_callback', |
334 | - 'depend' => array( 'v201_upgrades_payment_metadata', 'v201_add_missing_donors' ), |
|
334 | + 'depend' => array('v201_upgrades_payment_metadata', 'v201_add_missing_donors'), |
|
335 | 335 | ) |
336 | 336 | ); |
337 | 337 | |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | ); |
347 | 347 | } |
348 | 348 | |
349 | -add_action( 'give_register_updates', 'give_show_upgrade_notices' ); |
|
349 | +add_action('give_register_updates', 'give_show_upgrade_notices'); |
|
350 | 350 | |
351 | 351 | /** |
352 | 352 | * Triggers all upgrade functions |
@@ -358,29 +358,29 @@ discard block |
||
358 | 358 | */ |
359 | 359 | function give_trigger_upgrades() { |
360 | 360 | |
361 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
362 | - wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
361 | + if ( ! current_user_can('manage_give_settings')) { |
|
362 | + wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array( |
|
363 | 363 | 'response' => 403, |
364 | - ) ); |
|
364 | + )); |
|
365 | 365 | } |
366 | 366 | |
367 | - $give_version = get_option( 'give_version' ); |
|
367 | + $give_version = get_option('give_version'); |
|
368 | 368 | |
369 | - if ( ! $give_version ) { |
|
369 | + if ( ! $give_version) { |
|
370 | 370 | // 1.0 is the first version to use this option so we must add it. |
371 | 371 | $give_version = '1.0'; |
372 | - add_option( 'give_version', $give_version ); |
|
372 | + add_option('give_version', $give_version); |
|
373 | 373 | } |
374 | 374 | |
375 | - update_option( 'give_version', GIVE_VERSION ); |
|
376 | - delete_option( 'give_doing_upgrade' ); |
|
375 | + update_option('give_version', GIVE_VERSION); |
|
376 | + delete_option('give_doing_upgrade'); |
|
377 | 377 | |
378 | - if ( DOING_AJAX ) { |
|
379 | - die( 'complete' ); |
|
378 | + if (DOING_AJAX) { |
|
379 | + die('complete'); |
|
380 | 380 | } // End if(). |
381 | 381 | } |
382 | 382 | |
383 | -add_action( 'wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades' ); |
|
383 | +add_action('wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades'); |
|
384 | 384 | |
385 | 385 | |
386 | 386 | /** |
@@ -398,10 +398,10 @@ discard block |
||
398 | 398 | |
399 | 399 | // UPDATE DB METAKEYS. |
400 | 400 | $sql = "UPDATE $wpdb->postmeta SET meta_key = '_give_payment_customer_id' WHERE meta_key = '_give_payment_donor_id'"; |
401 | - $query = $wpdb->query( $sql ); |
|
401 | + $query = $wpdb->query($sql); |
|
402 | 402 | |
403 | 403 | $give_updates->percentage = 100; |
404 | - give_set_upgrade_complete( 'upgrade_give_payment_customer_id' ); |
|
404 | + give_set_upgrade_complete('upgrade_give_payment_customer_id'); |
|
405 | 405 | } |
406 | 406 | |
407 | 407 | |
@@ -425,24 +425,24 @@ discard block |
||
425 | 425 | $where .= "AND ( p.post_status = 'abandoned' )"; |
426 | 426 | $where .= "AND ( m.meta_key = '_give_payment_gateway' AND m.meta_value = 'offline' )"; |
427 | 427 | |
428 | - $sql = $select . $join . $where; |
|
429 | - $found_payments = $wpdb->get_col( $sql ); |
|
428 | + $sql = $select.$join.$where; |
|
429 | + $found_payments = $wpdb->get_col($sql); |
|
430 | 430 | |
431 | - foreach ( $found_payments as $payment ) { |
|
431 | + foreach ($found_payments as $payment) { |
|
432 | 432 | |
433 | 433 | // Only change ones marked abandoned since our release last week because the admin may have marked some abandoned themselves. |
434 | - $modified_time = get_post_modified_time( 'U', false, $payment ); |
|
434 | + $modified_time = get_post_modified_time('U', false, $payment); |
|
435 | 435 | |
436 | 436 | // 1450124863 = 12/10/2015 20:42:25. |
437 | - if ( $modified_time >= 1450124863 ) { |
|
437 | + if ($modified_time >= 1450124863) { |
|
438 | 438 | |
439 | - give_update_payment_status( $payment, 'pending' ); |
|
439 | + give_update_payment_status($payment, 'pending'); |
|
440 | 440 | |
441 | 441 | } |
442 | 442 | } |
443 | 443 | |
444 | 444 | $give_updates->percentage = 100; |
445 | - give_set_upgrade_complete( 'upgrade_give_offline_status' ); |
|
445 | + give_set_upgrade_complete('upgrade_give_offline_status'); |
|
446 | 446 | } |
447 | 447 | |
448 | 448 | |
@@ -455,17 +455,17 @@ discard block |
||
455 | 455 | */ |
456 | 456 | function give_v152_cleanup_users() { |
457 | 457 | |
458 | - $give_version = get_option( 'give_version' ); |
|
458 | + $give_version = get_option('give_version'); |
|
459 | 459 | |
460 | - if ( ! $give_version ) { |
|
460 | + if ( ! $give_version) { |
|
461 | 461 | // 1.0 is the first version to use this option so we must add it. |
462 | 462 | $give_version = '1.0'; |
463 | 463 | } |
464 | 464 | |
465 | - $give_version = preg_replace( '/[^0-9.].*/', '', $give_version ); |
|
465 | + $give_version = preg_replace('/[^0-9.].*/', '', $give_version); |
|
466 | 466 | |
467 | 467 | // v1.5.2 Upgrades |
468 | - if ( version_compare( $give_version, '1.5.2', '<' ) || ! give_has_upgrade_completed( 'upgrade_give_user_caps_cleanup' ) ) { |
|
468 | + if (version_compare($give_version, '1.5.2', '<') || ! give_has_upgrade_completed('upgrade_give_user_caps_cleanup')) { |
|
469 | 469 | |
470 | 470 | // Delete all caps with "ss". |
471 | 471 | // Also delete all unused "campaign" roles. |
@@ -512,9 +512,9 @@ discard block |
||
512 | 512 | ); |
513 | 513 | |
514 | 514 | global $wp_roles; |
515 | - foreach ( $delete_caps as $cap ) { |
|
516 | - foreach ( array_keys( $wp_roles->roles ) as $role ) { |
|
517 | - $wp_roles->remove_cap( $role, $cap ); |
|
515 | + foreach ($delete_caps as $cap) { |
|
516 | + foreach (array_keys($wp_roles->roles) as $role) { |
|
517 | + $wp_roles->remove_cap($role, $cap); |
|
518 | 518 | } |
519 | 519 | } |
520 | 520 | |
@@ -524,15 +524,15 @@ discard block |
||
524 | 524 | $roles->add_caps(); |
525 | 525 | |
526 | 526 | // The Update Ran. |
527 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
528 | - give_set_upgrade_complete( 'upgrade_give_user_caps_cleanup' ); |
|
529 | - delete_option( 'give_doing_upgrade' ); |
|
527 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
528 | + give_set_upgrade_complete('upgrade_give_user_caps_cleanup'); |
|
529 | + delete_option('give_doing_upgrade'); |
|
530 | 530 | |
531 | 531 | }// End if(). |
532 | 532 | |
533 | 533 | } |
534 | 534 | |
535 | -add_action( 'admin_init', 'give_v152_cleanup_users' ); |
|
535 | +add_action('admin_init', 'give_v152_cleanup_users'); |
|
536 | 536 | |
537 | 537 | /** |
538 | 538 | * 1.6 Upgrade routine to create the customer meta table. |
@@ -575,53 +575,53 @@ discard block |
||
575 | 575 | |
576 | 576 | // Get addons license key. |
577 | 577 | $addons = array(); |
578 | - foreach ( $give_options as $key => $value ) { |
|
579 | - if ( false !== strpos( $key, '_license_key' ) ) { |
|
580 | - $addons[ $key ] = $value; |
|
578 | + foreach ($give_options as $key => $value) { |
|
579 | + if (false !== strpos($key, '_license_key')) { |
|
580 | + $addons[$key] = $value; |
|
581 | 581 | } |
582 | 582 | } |
583 | 583 | |
584 | 584 | // Bailout: We do not have any addon license data to upgrade. |
585 | - if ( empty( $addons ) ) { |
|
585 | + if (empty($addons)) { |
|
586 | 586 | return false; |
587 | 587 | } |
588 | 588 | |
589 | - foreach ( $addons as $key => $addon_license ) { |
|
589 | + foreach ($addons as $key => $addon_license) { |
|
590 | 590 | |
591 | 591 | // Get addon shortname. |
592 | - $shortname = str_replace( '_license_key', '', $key ); |
|
592 | + $shortname = str_replace('_license_key', '', $key); |
|
593 | 593 | |
594 | 594 | // Addon license option name. |
595 | - $addon_license_option_name = $shortname . '_license_active'; |
|
595 | + $addon_license_option_name = $shortname.'_license_active'; |
|
596 | 596 | |
597 | 597 | // bailout if license is empty. |
598 | - if ( empty( $addon_license ) ) { |
|
599 | - delete_option( $addon_license_option_name ); |
|
598 | + if (empty($addon_license)) { |
|
599 | + delete_option($addon_license_option_name); |
|
600 | 600 | continue; |
601 | 601 | } |
602 | 602 | |
603 | 603 | // Get addon name. |
604 | 604 | $addon_name = array(); |
605 | - $addon_name_parts = explode( '_', str_replace( 'give_', '', $shortname ) ); |
|
606 | - foreach ( $addon_name_parts as $name_part ) { |
|
605 | + $addon_name_parts = explode('_', str_replace('give_', '', $shortname)); |
|
606 | + foreach ($addon_name_parts as $name_part) { |
|
607 | 607 | |
608 | 608 | // Fix addon name |
609 | - switch ( $name_part ) { |
|
609 | + switch ($name_part) { |
|
610 | 610 | case 'authorizenet' : |
611 | 611 | $name_part = 'authorize.net'; |
612 | 612 | break; |
613 | 613 | } |
614 | 614 | |
615 | - $addon_name[] = ucfirst( $name_part ); |
|
615 | + $addon_name[] = ucfirst($name_part); |
|
616 | 616 | } |
617 | 617 | |
618 | - $addon_name = implode( ' ', $addon_name ); |
|
618 | + $addon_name = implode(' ', $addon_name); |
|
619 | 619 | |
620 | 620 | // Data to send to the API. |
621 | 621 | $api_params = array( |
622 | 622 | 'edd_action' => 'activate_license', // never change from "edd_" to "give_"! |
623 | 623 | 'license' => $addon_license, |
624 | - 'item_name' => urlencode( $addon_name ), |
|
624 | + 'item_name' => urlencode($addon_name), |
|
625 | 625 | 'url' => home_url(), |
626 | 626 | ); |
627 | 627 | |
@@ -636,17 +636,17 @@ discard block |
||
636 | 636 | ); |
637 | 637 | |
638 | 638 | // Make sure there are no errors. |
639 | - if ( is_wp_error( $response ) ) { |
|
640 | - delete_option( $addon_license_option_name ); |
|
639 | + if (is_wp_error($response)) { |
|
640 | + delete_option($addon_license_option_name); |
|
641 | 641 | continue; |
642 | 642 | } |
643 | 643 | |
644 | 644 | // Tell WordPress to look for updates. |
645 | - set_site_transient( 'update_plugins', null ); |
|
645 | + set_site_transient('update_plugins', null); |
|
646 | 646 | |
647 | 647 | // Decode license data. |
648 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
649 | - update_option( $addon_license_option_name, $license_data ); |
|
648 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
649 | + update_option($addon_license_option_name, $license_data); |
|
650 | 650 | }// End foreach(). |
651 | 651 | } |
652 | 652 | |
@@ -676,9 +676,9 @@ discard block |
||
676 | 676 | ); |
677 | 677 | |
678 | 678 | global $wp_roles; |
679 | - foreach ( $delete_caps as $cap ) { |
|
680 | - foreach ( array_keys( $wp_roles->roles ) as $role ) { |
|
681 | - $wp_roles->remove_cap( $role, $cap ); |
|
679 | + foreach ($delete_caps as $cap) { |
|
680 | + foreach (array_keys($wp_roles->roles) as $role) { |
|
681 | + $wp_roles->remove_cap($role, $cap); |
|
682 | 682 | } |
683 | 683 | } |
684 | 684 | |
@@ -712,7 +712,7 @@ discard block |
||
712 | 712 | function give_v18_upgrades_core_setting() { |
713 | 713 | // Core settings which changes from checkbox to radio. |
714 | 714 | $core_setting_names = array_merge( |
715 | - array_keys( give_v18_renamed_core_settings() ), |
|
715 | + array_keys(give_v18_renamed_core_settings()), |
|
716 | 716 | array( |
717 | 717 | 'uninstall_on_delete', |
718 | 718 | 'scripts_footer', |
@@ -724,48 +724,48 @@ discard block |
||
724 | 724 | ); |
725 | 725 | |
726 | 726 | // Bailout: If not any setting define. |
727 | - if ( $give_settings = get_option( 'give_settings' ) ) { |
|
727 | + if ($give_settings = get_option('give_settings')) { |
|
728 | 728 | |
729 | 729 | $setting_changed = false; |
730 | 730 | |
731 | 731 | // Loop: check each setting field. |
732 | - foreach ( $core_setting_names as $setting_name ) { |
|
732 | + foreach ($core_setting_names as $setting_name) { |
|
733 | 733 | // New setting name. |
734 | - $new_setting_name = preg_replace( '/^(enable_|disable_)/', '', $setting_name ); |
|
734 | + $new_setting_name = preg_replace('/^(enable_|disable_)/', '', $setting_name); |
|
735 | 735 | |
736 | 736 | // Continue: If setting already set. |
737 | 737 | if ( |
738 | - array_key_exists( $new_setting_name, $give_settings ) |
|
739 | - && in_array( $give_settings[ $new_setting_name ], array( 'enabled', 'disabled' ) ) |
|
738 | + array_key_exists($new_setting_name, $give_settings) |
|
739 | + && in_array($give_settings[$new_setting_name], array('enabled', 'disabled')) |
|
740 | 740 | ) { |
741 | 741 | continue; |
742 | 742 | } |
743 | 743 | |
744 | 744 | // Set checkbox value to radio value. |
745 | - $give_settings[ $setting_name ] = ( ! empty( $give_settings[ $setting_name ] ) && 'on' === $give_settings[ $setting_name ] ? 'enabled' : 'disabled' ); |
|
745 | + $give_settings[$setting_name] = ( ! empty($give_settings[$setting_name]) && 'on' === $give_settings[$setting_name] ? 'enabled' : 'disabled'); |
|
746 | 746 | |
747 | 747 | // @see https://github.com/WordImpress/Give/issues/1063. |
748 | - if ( false !== strpos( $setting_name, 'disable_' ) ) { |
|
748 | + if (false !== strpos($setting_name, 'disable_')) { |
|
749 | 749 | |
750 | - $give_settings[ $new_setting_name ] = ( give_is_setting_enabled( $give_settings[ $setting_name ] ) ? 'disabled' : 'enabled' ); |
|
751 | - } elseif ( false !== strpos( $setting_name, 'enable_' ) ) { |
|
750 | + $give_settings[$new_setting_name] = (give_is_setting_enabled($give_settings[$setting_name]) ? 'disabled' : 'enabled'); |
|
751 | + } elseif (false !== strpos($setting_name, 'enable_')) { |
|
752 | 752 | |
753 | - $give_settings[ $new_setting_name ] = ( give_is_setting_enabled( $give_settings[ $setting_name ] ) ? 'enabled' : 'disabled' ); |
|
753 | + $give_settings[$new_setting_name] = (give_is_setting_enabled($give_settings[$setting_name]) ? 'enabled' : 'disabled'); |
|
754 | 754 | } |
755 | 755 | |
756 | 756 | // Tell bot to update core setting to db. |
757 | - if ( ! $setting_changed ) { |
|
757 | + if ( ! $setting_changed) { |
|
758 | 758 | $setting_changed = true; |
759 | 759 | } |
760 | 760 | } |
761 | 761 | |
762 | 762 | // Update setting only if they changed. |
763 | - if ( $setting_changed ) { |
|
764 | - update_option( 'give_settings', $give_settings ); |
|
763 | + if ($setting_changed) { |
|
764 | + update_option('give_settings', $give_settings); |
|
765 | 765 | } |
766 | 766 | }// End if(). |
767 | 767 | |
768 | - give_set_upgrade_complete( 'v18_upgrades_core_setting' ); |
|
768 | + give_set_upgrade_complete('v18_upgrades_core_setting'); |
|
769 | 769 | } |
770 | 770 | |
771 | 771 | /** |
@@ -779,7 +779,7 @@ discard block |
||
779 | 779 | $give_updates = Give_Updates::get_instance(); |
780 | 780 | |
781 | 781 | // form query |
782 | - $forms = new WP_Query( array( |
|
782 | + $forms = new WP_Query(array( |
|
783 | 783 | 'paged' => $give_updates->step, |
784 | 784 | 'status' => 'any', |
785 | 785 | 'order' => 'ASC', |
@@ -788,41 +788,41 @@ discard block |
||
788 | 788 | ) |
789 | 789 | ); |
790 | 790 | |
791 | - if ( $forms->have_posts() ) { |
|
792 | - $give_updates->set_percentage( $forms->found_posts, ( $give_updates->step * 20 ) ); |
|
791 | + if ($forms->have_posts()) { |
|
792 | + $give_updates->set_percentage($forms->found_posts, ($give_updates->step * 20)); |
|
793 | 793 | |
794 | - while ( $forms->have_posts() ) { |
|
794 | + while ($forms->have_posts()) { |
|
795 | 795 | $forms->the_post(); |
796 | 796 | |
797 | 797 | // Form content. |
798 | 798 | // Note in version 1.8 display content setting split into display content and content placement setting. |
799 | 799 | // You can delete _give_content_option in future. |
800 | - $show_content = give_get_meta( get_the_ID(), '_give_content_option', true ); |
|
801 | - if ( $show_content && ! give_get_meta( get_the_ID(), '_give_display_content', true ) ) { |
|
802 | - $field_value = ( 'none' !== $show_content ? 'enabled' : 'disabled' ); |
|
803 | - give_update_meta( get_the_ID(), '_give_display_content', $field_value ); |
|
800 | + $show_content = give_get_meta(get_the_ID(), '_give_content_option', true); |
|
801 | + if ($show_content && ! give_get_meta(get_the_ID(), '_give_display_content', true)) { |
|
802 | + $field_value = ('none' !== $show_content ? 'enabled' : 'disabled'); |
|
803 | + give_update_meta(get_the_ID(), '_give_display_content', $field_value); |
|
804 | 804 | |
805 | - $field_value = ( 'none' !== $show_content ? $show_content : 'give_pre_form' ); |
|
806 | - give_update_meta( get_the_ID(), '_give_content_placement', $field_value ); |
|
805 | + $field_value = ('none' !== $show_content ? $show_content : 'give_pre_form'); |
|
806 | + give_update_meta(get_the_ID(), '_give_content_placement', $field_value); |
|
807 | 807 | } |
808 | 808 | |
809 | 809 | // "Disable" Guest Donation. Checkbox. |
810 | 810 | // See: https://github.com/WordImpress/Give/issues/1470. |
811 | - $guest_donation = give_get_meta( get_the_ID(), '_give_logged_in_only', true ); |
|
812 | - $guest_donation_newval = ( in_array( $guest_donation, array( 'yes', 'on' ) ) ? 'disabled' : 'enabled' ); |
|
813 | - give_update_meta( get_the_ID(), '_give_logged_in_only', $guest_donation_newval ); |
|
811 | + $guest_donation = give_get_meta(get_the_ID(), '_give_logged_in_only', true); |
|
812 | + $guest_donation_newval = (in_array($guest_donation, array('yes', 'on')) ? 'disabled' : 'enabled'); |
|
813 | + give_update_meta(get_the_ID(), '_give_logged_in_only', $guest_donation_newval); |
|
814 | 814 | |
815 | 815 | // Offline Donations. |
816 | 816 | // See: https://github.com/WordImpress/Give/issues/1579. |
817 | - $offline_donation = give_get_meta( get_the_ID(), '_give_customize_offline_donations', true ); |
|
818 | - if ( 'no' === $offline_donation ) { |
|
817 | + $offline_donation = give_get_meta(get_the_ID(), '_give_customize_offline_donations', true); |
|
818 | + if ('no' === $offline_donation) { |
|
819 | 819 | $offline_donation_newval = 'global'; |
820 | - } elseif ( 'yes' === $offline_donation ) { |
|
820 | + } elseif ('yes' === $offline_donation) { |
|
821 | 821 | $offline_donation_newval = 'enabled'; |
822 | 822 | } else { |
823 | 823 | $offline_donation_newval = 'disabled'; |
824 | 824 | } |
825 | - give_update_meta( get_the_ID(), '_give_customize_offline_donations', $offline_donation_newval ); |
|
825 | + give_update_meta(get_the_ID(), '_give_customize_offline_donations', $offline_donation_newval); |
|
826 | 826 | |
827 | 827 | // Convert yes/no setting field to enabled/disabled. |
828 | 828 | $form_radio_settings = array( |
@@ -842,15 +842,15 @@ discard block |
||
842 | 842 | '_give_offline_donation_enable_billing_fields_single', |
843 | 843 | ); |
844 | 844 | |
845 | - foreach ( $form_radio_settings as $meta_key ) { |
|
845 | + foreach ($form_radio_settings as $meta_key) { |
|
846 | 846 | // Get value. |
847 | - $field_value = give_get_meta( get_the_ID(), $meta_key, true ); |
|
847 | + $field_value = give_get_meta(get_the_ID(), $meta_key, true); |
|
848 | 848 | |
849 | 849 | // Convert meta value only if it is in yes/no/none. |
850 | - if ( in_array( $field_value, array( 'yes', 'on', 'no', 'none' ) ) ) { |
|
850 | + if (in_array($field_value, array('yes', 'on', 'no', 'none'))) { |
|
851 | 851 | |
852 | - $field_value = ( in_array( $field_value, array( 'yes', 'on' ) ) ? 'enabled' : 'disabled' ); |
|
853 | - give_update_meta( get_the_ID(), $meta_key, $field_value ); |
|
852 | + $field_value = (in_array($field_value, array('yes', 'on')) ? 'enabled' : 'disabled'); |
|
853 | + give_update_meta(get_the_ID(), $meta_key, $field_value); |
|
854 | 854 | } |
855 | 855 | } |
856 | 856 | }// End while(). |
@@ -859,7 +859,7 @@ discard block |
||
859 | 859 | |
860 | 860 | } else { |
861 | 861 | // No more forms found, finish up. |
862 | - give_set_upgrade_complete( 'v18_upgrades_form_metadata' ); |
|
862 | + give_set_upgrade_complete('v18_upgrades_form_metadata'); |
|
863 | 863 | } |
864 | 864 | } |
865 | 865 | |
@@ -926,7 +926,7 @@ discard block |
||
926 | 926 | '%_transient_give_stats_%', |
927 | 927 | 'give_cache%', |
928 | 928 | '%_transient_give_add_ons_feed%', |
929 | - '%_transient__give_ajax_works' . |
|
929 | + '%_transient__give_ajax_works'. |
|
930 | 930 | '%_transient_give_total_api_keys%', |
931 | 931 | '%_transient_give_i18n_give_promo_hide%', |
932 | 932 | '%_transient_give_contributors%', |
@@ -953,24 +953,24 @@ discard block |
||
953 | 953 | ARRAY_A |
954 | 954 | ); |
955 | 955 | |
956 | - if ( ! empty( $user_apikey_options ) ) { |
|
957 | - foreach ( $user_apikey_options as $user ) { |
|
958 | - $cached_options[] = '_transient_' . md5( 'give_api_user_' . $user['meta_key'] ); |
|
959 | - $cached_options[] = '_transient_' . md5( 'give_api_user_public_key' . $user['user_id'] ); |
|
960 | - $cached_options[] = '_transient_' . md5( 'give_api_user_secret_key' . $user['user_id'] ); |
|
956 | + if ( ! empty($user_apikey_options)) { |
|
957 | + foreach ($user_apikey_options as $user) { |
|
958 | + $cached_options[] = '_transient_'.md5('give_api_user_'.$user['meta_key']); |
|
959 | + $cached_options[] = '_transient_'.md5('give_api_user_public_key'.$user['user_id']); |
|
960 | + $cached_options[] = '_transient_'.md5('give_api_user_secret_key'.$user['user_id']); |
|
961 | 961 | } |
962 | 962 | } |
963 | 963 | |
964 | - if ( ! empty( $cached_options ) ) { |
|
965 | - foreach ( $cached_options as $option ) { |
|
966 | - switch ( true ) { |
|
967 | - case ( false !== strpos( $option, 'transient' ) ): |
|
968 | - $option = str_replace( '_transient_', '', $option ); |
|
969 | - delete_transient( $option ); |
|
964 | + if ( ! empty($cached_options)) { |
|
965 | + foreach ($cached_options as $option) { |
|
966 | + switch (true) { |
|
967 | + case (false !== strpos($option, 'transient')): |
|
968 | + $option = str_replace('_transient_', '', $option); |
|
969 | + delete_transient($option); |
|
970 | 970 | break; |
971 | 971 | |
972 | 972 | default: |
973 | - delete_option( $option ); |
|
973 | + delete_option($option); |
|
974 | 974 | } |
975 | 975 | } |
976 | 976 | } |
@@ -988,7 +988,7 @@ discard block |
||
988 | 988 | global $wp_roles; |
989 | 989 | |
990 | 990 | // Get the role object. |
991 | - $give_worker = get_role( 'give_worker' ); |
|
991 | + $give_worker = get_role('give_worker'); |
|
992 | 992 | |
993 | 993 | // A list of capabilities to add for give workers. |
994 | 994 | $caps_to_add = array( |
@@ -996,9 +996,9 @@ discard block |
||
996 | 996 | 'edit_pages', |
997 | 997 | ); |
998 | 998 | |
999 | - foreach ( $caps_to_add as $cap ) { |
|
999 | + foreach ($caps_to_add as $cap) { |
|
1000 | 1000 | // Add the capability. |
1001 | - $give_worker->add_cap( $cap ); |
|
1001 | + $give_worker->add_cap($cap); |
|
1002 | 1002 | } |
1003 | 1003 | |
1004 | 1004 | } |
@@ -1015,7 +1015,7 @@ discard block |
||
1015 | 1015 | $give_updates = Give_Updates::get_instance(); |
1016 | 1016 | |
1017 | 1017 | // form query. |
1018 | - $donation_forms = new WP_Query( array( |
|
1018 | + $donation_forms = new WP_Query(array( |
|
1019 | 1019 | 'paged' => $give_updates->step, |
1020 | 1020 | 'status' => 'any', |
1021 | 1021 | 'order' => 'ASC', |
@@ -1024,10 +1024,10 @@ discard block |
||
1024 | 1024 | ) |
1025 | 1025 | ); |
1026 | 1026 | |
1027 | - if ( $donation_forms->have_posts() ) { |
|
1028 | - $give_updates->set_percentage( $donation_forms->found_posts, ( $give_updates->step * 20 ) ); |
|
1027 | + if ($donation_forms->have_posts()) { |
|
1028 | + $give_updates->set_percentage($donation_forms->found_posts, ($give_updates->step * 20)); |
|
1029 | 1029 | |
1030 | - while ( $donation_forms->have_posts() ) { |
|
1030 | + while ($donation_forms->have_posts()) { |
|
1031 | 1031 | $donation_forms->the_post(); |
1032 | 1032 | $form_id = get_the_ID(); |
1033 | 1033 | |
@@ -1035,41 +1035,41 @@ discard block |
||
1035 | 1035 | update_post_meta( |
1036 | 1036 | $form_id, |
1037 | 1037 | '_give_set_price', |
1038 | - give_sanitize_amount( get_post_meta( $form_id, '_give_set_price', true ) ) |
|
1038 | + give_sanitize_amount(get_post_meta($form_id, '_give_set_price', true)) |
|
1039 | 1039 | ); |
1040 | 1040 | |
1041 | 1041 | // Remove formatting from _give_custom_amount_minimum. |
1042 | 1042 | update_post_meta( |
1043 | 1043 | $form_id, |
1044 | 1044 | '_give_custom_amount_minimum', |
1045 | - give_sanitize_amount( get_post_meta( $form_id, '_give_custom_amount_minimum', true ) ) |
|
1045 | + give_sanitize_amount(get_post_meta($form_id, '_give_custom_amount_minimum', true)) |
|
1046 | 1046 | ); |
1047 | 1047 | |
1048 | 1048 | // Bailout. |
1049 | - if ( 'set' === get_post_meta( $form_id, '_give_price_option', true ) ) { |
|
1049 | + if ('set' === get_post_meta($form_id, '_give_price_option', true)) { |
|
1050 | 1050 | continue; |
1051 | 1051 | } |
1052 | 1052 | |
1053 | - $donation_levels = get_post_meta( $form_id, '_give_donation_levels', true ); |
|
1053 | + $donation_levels = get_post_meta($form_id, '_give_donation_levels', true); |
|
1054 | 1054 | |
1055 | - if ( ! empty( $donation_levels ) ) { |
|
1055 | + if ( ! empty($donation_levels)) { |
|
1056 | 1056 | |
1057 | - foreach ( $donation_levels as $index => $donation_level ) { |
|
1058 | - if ( isset( $donation_level['_give_amount'] ) ) { |
|
1059 | - $donation_levels[ $index ]['_give_amount'] = give_sanitize_amount( $donation_level['_give_amount'] ); |
|
1057 | + foreach ($donation_levels as $index => $donation_level) { |
|
1058 | + if (isset($donation_level['_give_amount'])) { |
|
1059 | + $donation_levels[$index]['_give_amount'] = give_sanitize_amount($donation_level['_give_amount']); |
|
1060 | 1060 | } |
1061 | 1061 | } |
1062 | 1062 | |
1063 | - update_post_meta( $form_id, '_give_donation_levels', $donation_levels ); |
|
1063 | + update_post_meta($form_id, '_give_donation_levels', $donation_levels); |
|
1064 | 1064 | |
1065 | - $donation_levels_amounts = wp_list_pluck( $donation_levels, '_give_amount' ); |
|
1065 | + $donation_levels_amounts = wp_list_pluck($donation_levels, '_give_amount'); |
|
1066 | 1066 | |
1067 | - $min_amount = min( $donation_levels_amounts ); |
|
1068 | - $max_amount = max( $donation_levels_amounts ); |
|
1067 | + $min_amount = min($donation_levels_amounts); |
|
1068 | + $max_amount = max($donation_levels_amounts); |
|
1069 | 1069 | |
1070 | 1070 | // Set Minimum and Maximum amount for Multi Level Donation Forms |
1071 | - give_update_meta( $form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount( $min_amount ) : 0 ); |
|
1072 | - give_update_meta( $form_id, '_give_levels_maximum_amount', $max_amount ? give_sanitize_amount( $max_amount ) : 0 ); |
|
1071 | + give_update_meta($form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount($min_amount) : 0); |
|
1072 | + give_update_meta($form_id, '_give_levels_maximum_amount', $max_amount ? give_sanitize_amount($max_amount) : 0); |
|
1073 | 1073 | } |
1074 | 1074 | |
1075 | 1075 | } |
@@ -1078,7 +1078,7 @@ discard block |
||
1078 | 1078 | wp_reset_postdata(); |
1079 | 1079 | } else { |
1080 | 1080 | // The Update Ran. |
1081 | - give_set_upgrade_complete( 'v189_upgrades_levels_post_meta' ); |
|
1081 | + give_set_upgrade_complete('v189_upgrades_levels_post_meta'); |
|
1082 | 1082 | } |
1083 | 1083 | |
1084 | 1084 | } |
@@ -1128,7 +1128,7 @@ discard block |
||
1128 | 1128 | */ |
1129 | 1129 | function give_v20_upgrades() { |
1130 | 1130 | // Update cache setting. |
1131 | - give_update_option( 'cache', 'enabled' ); |
|
1131 | + give_update_option('cache', 'enabled'); |
|
1132 | 1132 | |
1133 | 1133 | // Upgrade email settings. |
1134 | 1134 | give_v20_upgrades_email_setting(); |
@@ -1147,7 +1147,7 @@ discard block |
||
1147 | 1147 | $all_setting = give_get_settings(); |
1148 | 1148 | |
1149 | 1149 | // Bailout on fresh install. |
1150 | - if ( empty( $all_setting ) ) { |
|
1150 | + if (empty($all_setting)) { |
|
1151 | 1151 | return; |
1152 | 1152 | } |
1153 | 1153 | |
@@ -1166,19 +1166,19 @@ discard block |
||
1166 | 1166 | 'admin_notices' => 'new-donation_notification', |
1167 | 1167 | ); |
1168 | 1168 | |
1169 | - foreach ( $settings as $old_setting => $new_setting ) { |
|
1169 | + foreach ($settings as $old_setting => $new_setting) { |
|
1170 | 1170 | // Do not update already modified |
1171 | - if ( ! is_array( $new_setting ) ) { |
|
1172 | - if ( array_key_exists( $new_setting, $all_setting ) || ! array_key_exists( $old_setting, $all_setting ) ) { |
|
1171 | + if ( ! is_array($new_setting)) { |
|
1172 | + if (array_key_exists($new_setting, $all_setting) || ! array_key_exists($old_setting, $all_setting)) { |
|
1173 | 1173 | continue; |
1174 | 1174 | } |
1175 | 1175 | } |
1176 | 1176 | |
1177 | - switch ( $old_setting ) { |
|
1177 | + switch ($old_setting) { |
|
1178 | 1178 | case 'admin_notices': |
1179 | - $notification_status = give_get_option( $old_setting, 'enabled' ); |
|
1179 | + $notification_status = give_get_option($old_setting, 'enabled'); |
|
1180 | 1180 | |
1181 | - give_update_option( $new_setting, $notification_status ); |
|
1181 | + give_update_option($new_setting, $notification_status); |
|
1182 | 1182 | |
1183 | 1183 | // @todo: Delete this option later ( version > 2.0 ), We need this for per form email addon. |
1184 | 1184 | // give_delete_option( $old_setting ); |
@@ -1189,19 +1189,19 @@ discard block |
||
1189 | 1189 | case 'admin_notice_emails': |
1190 | 1190 | $recipients = give_get_admin_notice_emails(); |
1191 | 1191 | |
1192 | - foreach ( $new_setting as $setting ) { |
|
1192 | + foreach ($new_setting as $setting) { |
|
1193 | 1193 | // bailout if setting already exist. |
1194 | - if ( array_key_exists( $setting, $all_setting ) ) { |
|
1194 | + if (array_key_exists($setting, $all_setting)) { |
|
1195 | 1195 | continue; |
1196 | 1196 | } |
1197 | 1197 | |
1198 | - give_update_option( $setting, $recipients ); |
|
1198 | + give_update_option($setting, $recipients); |
|
1199 | 1199 | } |
1200 | 1200 | break; |
1201 | 1201 | |
1202 | 1202 | default: |
1203 | - give_update_option( $new_setting, give_get_option( $old_setting ) ); |
|
1204 | - give_delete_option( $old_setting ); |
|
1203 | + give_update_option($new_setting, give_get_option($old_setting)); |
|
1204 | + give_delete_option($old_setting); |
|
1205 | 1205 | } |
1206 | 1206 | } |
1207 | 1207 | } |
@@ -1218,22 +1218,22 @@ discard block |
||
1218 | 1218 | $give_settings = give_get_settings(); |
1219 | 1219 | $give_setting_updated = false; |
1220 | 1220 | |
1221 | - if ( $give_settings['thousands_separator'] === $give_settings['decimal_separator'] ) { |
|
1221 | + if ($give_settings['thousands_separator'] === $give_settings['decimal_separator']) { |
|
1222 | 1222 | $give_settings['number_decimals'] = 0; |
1223 | 1223 | $give_settings['decimal_separator'] = ''; |
1224 | 1224 | $give_setting_updated = true; |
1225 | 1225 | |
1226 | - } elseif ( empty( $give_settings['decimal_separator'] ) ) { |
|
1226 | + } elseif (empty($give_settings['decimal_separator'])) { |
|
1227 | 1227 | $give_settings['number_decimals'] = 0; |
1228 | 1228 | $give_setting_updated = true; |
1229 | 1229 | |
1230 | - } elseif ( 6 < absint( $give_settings['number_decimals'] ) ) { |
|
1230 | + } elseif (6 < absint($give_settings['number_decimals'])) { |
|
1231 | 1231 | $give_settings['number_decimals'] = 5; |
1232 | 1232 | $give_setting_updated = true; |
1233 | 1233 | } |
1234 | 1234 | |
1235 | - if ( $give_setting_updated ) { |
|
1236 | - update_option( 'give_settings', $give_settings ); |
|
1235 | + if ($give_setting_updated) { |
|
1236 | + update_option('give_settings', $give_settings); |
|
1237 | 1237 | } |
1238 | 1238 | } |
1239 | 1239 | |
@@ -1252,69 +1252,69 @@ discard block |
||
1252 | 1252 | $give_updates = Give_Updates::get_instance(); |
1253 | 1253 | |
1254 | 1254 | // form query. |
1255 | - $donation_forms = new WP_Query( array( |
|
1255 | + $donation_forms = new WP_Query(array( |
|
1256 | 1256 | 'paged' => $give_updates->step, |
1257 | 1257 | 'status' => 'any', |
1258 | 1258 | 'order' => 'ASC', |
1259 | - 'post_type' => array( 'give_forms', 'give_payment' ), |
|
1259 | + 'post_type' => array('give_forms', 'give_payment'), |
|
1260 | 1260 | 'posts_per_page' => 20, |
1261 | 1261 | ) |
1262 | 1262 | ); |
1263 | - if ( $donation_forms->have_posts() ) { |
|
1264 | - $give_updates->set_percentage( $donation_forms->found_posts, ( $give_updates->step * 20 ) ); |
|
1263 | + if ($donation_forms->have_posts()) { |
|
1264 | + $give_updates->set_percentage($donation_forms->found_posts, ($give_updates->step * 20)); |
|
1265 | 1265 | |
1266 | - while ( $donation_forms->have_posts() ) { |
|
1266 | + while ($donation_forms->have_posts()) { |
|
1267 | 1267 | $donation_forms->the_post(); |
1268 | 1268 | global $post; |
1269 | 1269 | |
1270 | - $meta = get_post_meta( $post->ID ); |
|
1270 | + $meta = get_post_meta($post->ID); |
|
1271 | 1271 | |
1272 | - switch ( $post->post_type ) { |
|
1272 | + switch ($post->post_type) { |
|
1273 | 1273 | case 'give_forms': |
1274 | 1274 | // _give_set_price. |
1275 | - if ( ! empty( $meta['_give_set_price'][0] ) ) { |
|
1276 | - update_post_meta( $post->ID, '_give_set_price', give_sanitize_amount_for_db( $meta['_give_set_price'][0] ) ); |
|
1275 | + if ( ! empty($meta['_give_set_price'][0])) { |
|
1276 | + update_post_meta($post->ID, '_give_set_price', give_sanitize_amount_for_db($meta['_give_set_price'][0])); |
|
1277 | 1277 | } |
1278 | 1278 | |
1279 | 1279 | // _give_custom_amount_minimum. |
1280 | - if ( ! empty( $meta['_give_custom_amount_minimum'][0] ) ) { |
|
1281 | - update_post_meta( $post->ID, '_give_custom_amount_minimum', give_sanitize_amount_for_db( $meta['_give_custom_amount_minimum'][0] ) ); |
|
1280 | + if ( ! empty($meta['_give_custom_amount_minimum'][0])) { |
|
1281 | + update_post_meta($post->ID, '_give_custom_amount_minimum', give_sanitize_amount_for_db($meta['_give_custom_amount_minimum'][0])); |
|
1282 | 1282 | } |
1283 | 1283 | |
1284 | 1284 | // _give_levels_minimum_amount. |
1285 | - if ( ! empty( $meta['_give_levels_minimum_amount'][0] ) ) { |
|
1286 | - update_post_meta( $post->ID, '_give_levels_minimum_amount', give_sanitize_amount_for_db( $meta['_give_levels_minimum_amount'][0] ) ); |
|
1285 | + if ( ! empty($meta['_give_levels_minimum_amount'][0])) { |
|
1286 | + update_post_meta($post->ID, '_give_levels_minimum_amount', give_sanitize_amount_for_db($meta['_give_levels_minimum_amount'][0])); |
|
1287 | 1287 | } |
1288 | 1288 | |
1289 | 1289 | // _give_levels_maximum_amount. |
1290 | - if ( ! empty( $meta['_give_levels_maximum_amount'][0] ) ) { |
|
1291 | - update_post_meta( $post->ID, '_give_levels_maximum_amount', give_sanitize_amount_for_db( $meta['_give_levels_maximum_amount'][0] ) ); |
|
1290 | + if ( ! empty($meta['_give_levels_maximum_amount'][0])) { |
|
1291 | + update_post_meta($post->ID, '_give_levels_maximum_amount', give_sanitize_amount_for_db($meta['_give_levels_maximum_amount'][0])); |
|
1292 | 1292 | } |
1293 | 1293 | |
1294 | 1294 | // _give_set_goal. |
1295 | - if ( ! empty( $meta['_give_set_goal'][0] ) ) { |
|
1296 | - update_post_meta( $post->ID, '_give_set_goal', give_sanitize_amount_for_db( $meta['_give_set_goal'][0] ) ); |
|
1295 | + if ( ! empty($meta['_give_set_goal'][0])) { |
|
1296 | + update_post_meta($post->ID, '_give_set_goal', give_sanitize_amount_for_db($meta['_give_set_goal'][0])); |
|
1297 | 1297 | } |
1298 | 1298 | |
1299 | 1299 | // _give_form_earnings. |
1300 | - if ( ! empty( $meta['_give_form_earnings'][0] ) ) { |
|
1301 | - update_post_meta( $post->ID, '_give_form_earnings', give_sanitize_amount_for_db( $meta['_give_form_earnings'][0] ) ); |
|
1300 | + if ( ! empty($meta['_give_form_earnings'][0])) { |
|
1301 | + update_post_meta($post->ID, '_give_form_earnings', give_sanitize_amount_for_db($meta['_give_form_earnings'][0])); |
|
1302 | 1302 | } |
1303 | 1303 | |
1304 | 1304 | // _give_custom_amount_minimum. |
1305 | - if ( ! empty( $meta['_give_donation_levels'][0] ) ) { |
|
1306 | - $donation_levels = unserialize( $meta['_give_donation_levels'][0] ); |
|
1305 | + if ( ! empty($meta['_give_donation_levels'][0])) { |
|
1306 | + $donation_levels = unserialize($meta['_give_donation_levels'][0]); |
|
1307 | 1307 | |
1308 | - foreach ( $donation_levels as $index => $level ) { |
|
1309 | - if ( empty( $level['_give_amount'] ) ) { |
|
1308 | + foreach ($donation_levels as $index => $level) { |
|
1309 | + if (empty($level['_give_amount'])) { |
|
1310 | 1310 | continue; |
1311 | 1311 | } |
1312 | 1312 | |
1313 | - $donation_levels[ $index ]['_give_amount'] = give_sanitize_amount_for_db( $level['_give_amount'] ); |
|
1313 | + $donation_levels[$index]['_give_amount'] = give_sanitize_amount_for_db($level['_give_amount']); |
|
1314 | 1314 | } |
1315 | 1315 | |
1316 | 1316 | $meta['_give_donation_levels'] = $donation_levels; |
1317 | - update_post_meta( $post->ID, '_give_donation_levels', $meta['_give_donation_levels'] ); |
|
1317 | + update_post_meta($post->ID, '_give_donation_levels', $meta['_give_donation_levels']); |
|
1318 | 1318 | } |
1319 | 1319 | |
1320 | 1320 | |
@@ -1322,8 +1322,8 @@ discard block |
||
1322 | 1322 | |
1323 | 1323 | case 'give_payment': |
1324 | 1324 | // _give_payment_total. |
1325 | - if ( ! empty( $meta['_give_payment_total'][0] ) ) { |
|
1326 | - update_post_meta( $post->ID, '_give_payment_total', give_sanitize_amount_for_db( $meta['_give_payment_total'][0] ) ); |
|
1325 | + if ( ! empty($meta['_give_payment_total'][0])) { |
|
1326 | + update_post_meta($post->ID, '_give_payment_total', give_sanitize_amount_for_db($meta['_give_payment_total'][0])); |
|
1327 | 1327 | } |
1328 | 1328 | |
1329 | 1329 | break; |
@@ -1334,7 +1334,7 @@ discard block |
||
1334 | 1334 | wp_reset_postdata(); |
1335 | 1335 | } else { |
1336 | 1336 | // The Update Ran. |
1337 | - give_set_upgrade_complete( 'v1812_update_amount_values' ); |
|
1337 | + give_set_upgrade_complete('v1812_update_amount_values'); |
|
1338 | 1338 | } |
1339 | 1339 | } |
1340 | 1340 | |
@@ -1354,22 +1354,22 @@ discard block |
||
1354 | 1354 | $offset = 1 === $give_updates->step ? 0 : $give_updates->step * 20; |
1355 | 1355 | |
1356 | 1356 | // form query. |
1357 | - $donors = Give()->donors->get_donors( array( |
|
1357 | + $donors = Give()->donors->get_donors(array( |
|
1358 | 1358 | 'number' => 20, |
1359 | 1359 | 'offset' => $offset, |
1360 | 1360 | ) |
1361 | 1361 | ); |
1362 | 1362 | |
1363 | - if ( ! empty( $donors ) ) { |
|
1364 | - $give_updates->set_percentage( Give()->donors->count(), $offset ); |
|
1363 | + if ( ! empty($donors)) { |
|
1364 | + $give_updates->set_percentage(Give()->donors->count(), $offset); |
|
1365 | 1365 | |
1366 | 1366 | /* @var Object $donor */ |
1367 | - foreach ( $donors as $donor ) { |
|
1368 | - Give()->donors->update( $donor->id, array( 'purchase_value' => give_sanitize_amount_for_db( $donor->purchase_value ) ) ); |
|
1367 | + foreach ($donors as $donor) { |
|
1368 | + Give()->donors->update($donor->id, array('purchase_value' => give_sanitize_amount_for_db($donor->purchase_value))); |
|
1369 | 1369 | } |
1370 | 1370 | } else { |
1371 | 1371 | // The Update Ran. |
1372 | - give_set_upgrade_complete( 'v1812_update_donor_purchase_values' ); |
|
1372 | + give_set_upgrade_complete('v1812_update_donor_purchase_values'); |
|
1373 | 1373 | } |
1374 | 1374 | } |
1375 | 1375 | |
@@ -1384,25 +1384,25 @@ discard block |
||
1384 | 1384 | $offset = 1 === $give_updates->step ? 0 : $give_updates->step * 20; |
1385 | 1385 | |
1386 | 1386 | // Fetch all the existing donors. |
1387 | - $donors = Give()->donors->get_donors( array( |
|
1387 | + $donors = Give()->donors->get_donors(array( |
|
1388 | 1388 | 'number' => 20, |
1389 | 1389 | 'offset' => $offset, |
1390 | 1390 | ) |
1391 | 1391 | ); |
1392 | 1392 | |
1393 | - if ( ! empty( $donors ) ) { |
|
1394 | - $give_updates->set_percentage( Give()->donors->count(), ( $give_updates->step * 20 ) ); |
|
1393 | + if ( ! empty($donors)) { |
|
1394 | + $give_updates->set_percentage(Give()->donors->count(), ($give_updates->step * 20)); |
|
1395 | 1395 | |
1396 | 1396 | /* @var Object $donor */ |
1397 | - foreach ( $donors as $donor ) { |
|
1397 | + foreach ($donors as $donor) { |
|
1398 | 1398 | $user_id = $donor->user_id; |
1399 | 1399 | |
1400 | 1400 | // Proceed, if donor is attached with user. |
1401 | - if ( $user_id ) { |
|
1402 | - $user = get_userdata( $user_id ); |
|
1401 | + if ($user_id) { |
|
1402 | + $user = get_userdata($user_id); |
|
1403 | 1403 | |
1404 | 1404 | // Update user role, if user has subscriber role. |
1405 | - if ( is_array( $user->roles ) && in_array( 'subscriber', $user->roles ) ) { |
|
1405 | + if (is_array($user->roles) && in_array('subscriber', $user->roles)) { |
|
1406 | 1406 | wp_update_user( |
1407 | 1407 | array( |
1408 | 1408 | 'ID' => $user_id, |
@@ -1414,7 +1414,7 @@ discard block |
||
1414 | 1414 | } |
1415 | 1415 | } else { |
1416 | 1416 | // The Update Ran. |
1417 | - give_set_upgrade_complete( 'v1813_update_donor_user_roles' ); |
|
1417 | + give_set_upgrade_complete('v1813_update_donor_user_roles'); |
|
1418 | 1418 | } |
1419 | 1419 | } |
1420 | 1420 | |
@@ -1426,7 +1426,7 @@ discard block |
||
1426 | 1426 | */ |
1427 | 1427 | function give_v1813_upgrades() { |
1428 | 1428 | // Update admin setting. |
1429 | - give_update_option( 'donor_default_user_role', 'give_donor' ); |
|
1429 | + give_update_option('donor_default_user_role', 'give_donor'); |
|
1430 | 1430 | |
1431 | 1431 | // Update Give roles. |
1432 | 1432 | $roles = new Give_Roles(); |
@@ -1444,33 +1444,33 @@ discard block |
||
1444 | 1444 | $give_updates = Give_Updates::get_instance(); |
1445 | 1445 | |
1446 | 1446 | // form query. |
1447 | - $payments = new WP_Query( array( |
|
1447 | + $payments = new WP_Query(array( |
|
1448 | 1448 | 'paged' => $give_updates->step, |
1449 | 1449 | 'status' => 'any', |
1450 | 1450 | 'order' => 'ASC', |
1451 | - 'post_type' => array( 'give_payment' ), |
|
1451 | + 'post_type' => array('give_payment'), |
|
1452 | 1452 | 'posts_per_page' => 100, |
1453 | 1453 | ) |
1454 | 1454 | ); |
1455 | 1455 | |
1456 | - if ( $payments->have_posts() ) { |
|
1457 | - $give_updates->set_percentage( $payments->found_posts, ( $give_updates->step * 100 ) ); |
|
1456 | + if ($payments->have_posts()) { |
|
1457 | + $give_updates->set_percentage($payments->found_posts, ($give_updates->step * 100)); |
|
1458 | 1458 | |
1459 | - while ( $payments->have_posts() ) { |
|
1459 | + while ($payments->have_posts()) { |
|
1460 | 1460 | $payments->the_post(); |
1461 | 1461 | |
1462 | - $payment_meta = give_get_payment_meta( get_the_ID() ); |
|
1462 | + $payment_meta = give_get_payment_meta(get_the_ID()); |
|
1463 | 1463 | |
1464 | - if ( 'RIAL' === $payment_meta['currency'] ) { |
|
1464 | + if ('RIAL' === $payment_meta['currency']) { |
|
1465 | 1465 | $payment_meta['currency'] = 'IRR'; |
1466 | - give_update_meta( get_the_ID(), '_give_payment_meta', $payment_meta ); |
|
1466 | + give_update_meta(get_the_ID(), '_give_payment_meta', $payment_meta); |
|
1467 | 1467 | } |
1468 | 1468 | |
1469 | 1469 | } |
1470 | 1470 | |
1471 | 1471 | } else { |
1472 | 1472 | // The Update Ran. |
1473 | - give_set_upgrade_complete( 'v1817_update_donation_iranian_currency_code' ); |
|
1473 | + give_set_upgrade_complete('v1817_update_donation_iranian_currency_code'); |
|
1474 | 1474 | } |
1475 | 1475 | } |
1476 | 1476 | |
@@ -1483,9 +1483,9 @@ discard block |
||
1483 | 1483 | function give_v1817_upgrades() { |
1484 | 1484 | $give_settings = give_get_settings(); |
1485 | 1485 | |
1486 | - if ( 'RIAL' === $give_settings['currency'] ) { |
|
1486 | + if ('RIAL' === $give_settings['currency']) { |
|
1487 | 1487 | $give_settings['currency'] = 'IRR'; |
1488 | - update_option( 'give_settings', $give_settings ); |
|
1488 | + update_option('give_settings', $give_settings); |
|
1489 | 1489 | } |
1490 | 1490 | } |
1491 | 1491 | |
@@ -1498,7 +1498,7 @@ discard block |
||
1498 | 1498 | |
1499 | 1499 | global $wp_roles; |
1500 | 1500 | |
1501 | - if( ! ( $wp_roles instanceof WP_Roles ) ) { |
|
1501 | + if ( ! ($wp_roles instanceof WP_Roles)) { |
|
1502 | 1502 | return; |
1503 | 1503 | } |
1504 | 1504 | |
@@ -1522,15 +1522,15 @@ discard block |
||
1522 | 1522 | ), |
1523 | 1523 | ); |
1524 | 1524 | |
1525 | - foreach ( $add_caps as $role => $caps ) { |
|
1526 | - foreach ( $caps as $cap ) { |
|
1527 | - $wp_roles->add_cap( $role, $cap ); |
|
1525 | + foreach ($add_caps as $role => $caps) { |
|
1526 | + foreach ($caps as $cap) { |
|
1527 | + $wp_roles->add_cap($role, $cap); |
|
1528 | 1528 | } |
1529 | 1529 | } |
1530 | 1530 | |
1531 | - foreach ( $remove_caps as $role => $caps ) { |
|
1532 | - foreach ( $caps as $cap ) { |
|
1533 | - $wp_roles->remove_cap( $role, $cap ); |
|
1531 | + foreach ($remove_caps as $role => $caps) { |
|
1532 | + foreach ($caps as $cap) { |
|
1533 | + $wp_roles->remove_cap($role, $cap); |
|
1534 | 1534 | } |
1535 | 1535 | } |
1536 | 1536 | |
@@ -1554,7 +1554,7 @@ discard block |
||
1554 | 1554 | $roles->add_roles(); |
1555 | 1555 | $roles->add_caps(); |
1556 | 1556 | |
1557 | - give_set_upgrade_complete( 'v1817_cleanup_user_roles' ); |
|
1557 | + give_set_upgrade_complete('v1817_cleanup_user_roles'); |
|
1558 | 1558 | } |
1559 | 1559 | |
1560 | 1560 | /** |
@@ -1565,7 +1565,7 @@ discard block |
||
1565 | 1565 | function give_v1818_upgrades() { |
1566 | 1566 | |
1567 | 1567 | // Remove email_access_installed from give_settings. |
1568 | - give_delete_option( 'email_access_installed' ); |
|
1568 | + give_delete_option('email_access_installed'); |
|
1569 | 1569 | } |
1570 | 1570 | |
1571 | 1571 | /** |
@@ -1576,25 +1576,25 @@ discard block |
||
1576 | 1576 | function give_v1818_assign_custom_amount_set_donation() { |
1577 | 1577 | |
1578 | 1578 | /* @var Give_Updates $give_updates */ |
1579 | - $give_updates = Give_Updates::get_instance(); |
|
1579 | + $give_updates = Give_Updates::get_instance(); |
|
1580 | 1580 | |
1581 | - $donations = new WP_Query( array( |
|
1581 | + $donations = new WP_Query(array( |
|
1582 | 1582 | 'paged' => $give_updates->step, |
1583 | 1583 | 'status' => 'any', |
1584 | 1584 | 'order' => 'ASC', |
1585 | - 'post_type' => array( 'give_payment' ), |
|
1585 | + 'post_type' => array('give_payment'), |
|
1586 | 1586 | 'posts_per_page' => 100, |
1587 | 1587 | ) |
1588 | 1588 | ); |
1589 | 1589 | |
1590 | - if ( $donations->have_posts() ) { |
|
1591 | - $give_updates->set_percentage( $donations->found_posts, $give_updates->step * 100 ); |
|
1590 | + if ($donations->have_posts()) { |
|
1591 | + $give_updates->set_percentage($donations->found_posts, $give_updates->step * 100); |
|
1592 | 1592 | |
1593 | - while ( $donations->have_posts() ) { |
|
1593 | + while ($donations->have_posts()) { |
|
1594 | 1594 | $donations->the_post(); |
1595 | 1595 | |
1596 | - $form = new Give_Donate_Form( give_get_meta( get_the_ID(), '_give_payment_form_id', true ) ); |
|
1597 | - $donation_meta = give_get_payment_meta( get_the_ID() ); |
|
1596 | + $form = new Give_Donate_Form(give_get_meta(get_the_ID(), '_give_payment_form_id', true)); |
|
1597 | + $donation_meta = give_get_payment_meta(get_the_ID()); |
|
1598 | 1598 | |
1599 | 1599 | // Update Donation meta with price_id set as custom, only if it is: |
1600 | 1600 | // 1. Donation Type = Set Donation. |
@@ -1603,19 +1603,19 @@ discard block |
||
1603 | 1603 | if ( |
1604 | 1604 | $form->ID && |
1605 | 1605 | $form->is_set_type_donation_form() && |
1606 | - ( 'custom' !== $donation_meta['price_id'] ) && |
|
1607 | - $form->is_custom_price( give_get_meta( get_the_ID(), '_give_payment_total', true ) ) |
|
1606 | + ('custom' !== $donation_meta['price_id']) && |
|
1607 | + $form->is_custom_price(give_get_meta(get_the_ID(), '_give_payment_total', true)) |
|
1608 | 1608 | ) { |
1609 | 1609 | $donation_meta['price_id'] = 'custom'; |
1610 | - give_update_meta( get_the_ID(), '_give_payment_meta', $donation_meta ); |
|
1611 | - give_update_meta( get_the_ID(), '_give_payment_price_id', 'custom' ); |
|
1610 | + give_update_meta(get_the_ID(), '_give_payment_meta', $donation_meta); |
|
1611 | + give_update_meta(get_the_ID(), '_give_payment_price_id', 'custom'); |
|
1612 | 1612 | } |
1613 | 1613 | } |
1614 | 1614 | |
1615 | 1615 | wp_reset_postdata(); |
1616 | 1616 | } else { |
1617 | 1617 | // Update Ran Successfully. |
1618 | - give_set_upgrade_complete( 'v1818_assign_custom_amount_set_donation' ); |
|
1618 | + give_set_upgrade_complete('v1818_assign_custom_amount_set_donation'); |
|
1619 | 1619 | } |
1620 | 1620 | } |
1621 | 1621 | |
@@ -1626,14 +1626,14 @@ discard block |
||
1626 | 1626 | * |
1627 | 1627 | * @since 1.8.18 |
1628 | 1628 | */ |
1629 | -function give_v1818_give_worker_role_cleanup(){ |
|
1629 | +function give_v1818_give_worker_role_cleanup() { |
|
1630 | 1630 | |
1631 | 1631 | /* @var Give_Updates $give_updates */ |
1632 | 1632 | $give_updates = Give_Updates::get_instance(); |
1633 | 1633 | |
1634 | 1634 | global $wp_roles; |
1635 | 1635 | |
1636 | - if( ! ( $wp_roles instanceof WP_Roles ) ) { |
|
1636 | + if ( ! ($wp_roles instanceof WP_Roles)) { |
|
1637 | 1637 | return; |
1638 | 1638 | } |
1639 | 1639 | |
@@ -1651,9 +1651,9 @@ discard block |
||
1651 | 1651 | ), |
1652 | 1652 | ); |
1653 | 1653 | |
1654 | - foreach ( $remove_caps as $role => $caps ) { |
|
1655 | - foreach( $caps as $cap ) { |
|
1656 | - $wp_roles->remove_cap( $role, $cap ); |
|
1654 | + foreach ($remove_caps as $role => $caps) { |
|
1655 | + foreach ($caps as $cap) { |
|
1656 | + $wp_roles->remove_cap($role, $cap); |
|
1657 | 1657 | } |
1658 | 1658 | } |
1659 | 1659 | |
@@ -1664,7 +1664,7 @@ discard block |
||
1664 | 1664 | $roles->add_roles(); |
1665 | 1665 | $roles->add_caps(); |
1666 | 1666 | |
1667 | - give_set_upgrade_complete( 'v1818_give_worker_role_cleanup' ); |
|
1667 | + give_set_upgrade_complete('v1818_give_worker_role_cleanup'); |
|
1668 | 1668 | } |
1669 | 1669 | |
1670 | 1670 | /** |
@@ -1678,7 +1678,7 @@ discard block |
||
1678 | 1678 | $give_updates = Give_Updates::get_instance(); |
1679 | 1679 | |
1680 | 1680 | // form query |
1681 | - $forms = new WP_Query( array( |
|
1681 | + $forms = new WP_Query(array( |
|
1682 | 1682 | 'paged' => $give_updates->step, |
1683 | 1683 | 'status' => 'any', |
1684 | 1684 | 'order' => 'ASC', |
@@ -1687,22 +1687,22 @@ discard block |
||
1687 | 1687 | ) |
1688 | 1688 | ); |
1689 | 1689 | |
1690 | - if ( $forms->have_posts() ) { |
|
1691 | - $give_updates->set_percentage( $forms->found_posts, ( $give_updates->step * 100 ) ); |
|
1690 | + if ($forms->have_posts()) { |
|
1691 | + $give_updates->set_percentage($forms->found_posts, ($give_updates->step * 100)); |
|
1692 | 1692 | |
1693 | - while ( $forms->have_posts() ) { |
|
1693 | + while ($forms->have_posts()) { |
|
1694 | 1694 | $forms->the_post(); |
1695 | 1695 | global $post; |
1696 | 1696 | |
1697 | 1697 | // Update offline instruction email notification status. |
1698 | - $offline_instruction_notification_status = get_post_meta( get_the_ID(), '_give_customize_offline_donations', true ); |
|
1699 | - $offline_instruction_notification_status = give_is_setting_enabled( $offline_instruction_notification_status, array( |
|
1698 | + $offline_instruction_notification_status = get_post_meta(get_the_ID(), '_give_customize_offline_donations', true); |
|
1699 | + $offline_instruction_notification_status = give_is_setting_enabled($offline_instruction_notification_status, array( |
|
1700 | 1700 | 'enabled', |
1701 | 1701 | 'global', |
1702 | - ) ) |
|
1702 | + )) |
|
1703 | 1703 | ? $offline_instruction_notification_status |
1704 | 1704 | : 'global'; |
1705 | - update_post_meta( get_the_ID(), '_give_offline-donation-instruction_notification', $offline_instruction_notification_status ); |
|
1705 | + update_post_meta(get_the_ID(), '_give_offline-donation-instruction_notification', $offline_instruction_notification_status); |
|
1706 | 1706 | |
1707 | 1707 | // Update offline instruction email message. |
1708 | 1708 | update_post_meta( |
@@ -1734,7 +1734,7 @@ discard block |
||
1734 | 1734 | wp_reset_postdata(); |
1735 | 1735 | } else { |
1736 | 1736 | // No more forms found, finish up. |
1737 | - give_set_upgrade_complete( 'v20_upgrades_form_metadata' ); |
|
1737 | + give_set_upgrade_complete('v20_upgrades_form_metadata'); |
|
1738 | 1738 | } |
1739 | 1739 | } |
1740 | 1740 | |
@@ -1751,7 +1751,7 @@ discard block |
||
1751 | 1751 | $give_updates = Give_Updates::get_instance(); |
1752 | 1752 | |
1753 | 1753 | // form query |
1754 | - $forms = new WP_Query( array( |
|
1754 | + $forms = new WP_Query(array( |
|
1755 | 1755 | 'paged' => $give_updates->step, |
1756 | 1756 | 'status' => 'any', |
1757 | 1757 | 'order' => 'ASC', |
@@ -1760,19 +1760,19 @@ discard block |
||
1760 | 1760 | ) |
1761 | 1761 | ); |
1762 | 1762 | |
1763 | - if ( $forms->have_posts() ) { |
|
1764 | - $give_updates->set_percentage( $forms->found_posts, ( $give_updates->step * 100 ) ); |
|
1763 | + if ($forms->have_posts()) { |
|
1764 | + $give_updates->set_percentage($forms->found_posts, ($give_updates->step * 100)); |
|
1765 | 1765 | |
1766 | - while ( $forms->have_posts() ) { |
|
1766 | + while ($forms->have_posts()) { |
|
1767 | 1767 | $forms->the_post(); |
1768 | 1768 | global $post; |
1769 | 1769 | |
1770 | 1770 | // Split _give_payment_meta meta. |
1771 | 1771 | // @todo Remove _give_payment_meta after releases 2.0 |
1772 | - $payment_meta = give_get_meta( $post->ID, '_give_payment_meta', true ); |
|
1772 | + $payment_meta = give_get_meta($post->ID, '_give_payment_meta', true); |
|
1773 | 1773 | |
1774 | - if ( ! empty( $payment_meta ) ) { |
|
1775 | - _give_20_bc_split_and_save_give_payment_meta( $post->ID, $payment_meta ); |
|
1774 | + if ( ! empty($payment_meta)) { |
|
1775 | + _give_20_bc_split_and_save_give_payment_meta($post->ID, $payment_meta); |
|
1776 | 1776 | } |
1777 | 1777 | |
1778 | 1778 | $deprecated_meta_keys = array( |
@@ -1781,9 +1781,9 @@ discard block |
||
1781 | 1781 | '_give_payment_user_ip' => '_give_payment_donor_ip', |
1782 | 1782 | ); |
1783 | 1783 | |
1784 | - foreach ( $deprecated_meta_keys as $old_meta_key => $new_meta_key ) { |
|
1784 | + foreach ($deprecated_meta_keys as $old_meta_key => $new_meta_key) { |
|
1785 | 1785 | // Do not add new meta key if already exist. |
1786 | - if ( $wpdb->get_var( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id=%d AND meta_key=%s", $post->ID, $new_meta_key ) ) ) { |
|
1786 | + if ($wpdb->get_var($wpdb->prepare("SELECT meta_id FROM $wpdb->postmeta WHERE post_id=%d AND meta_key=%s", $post->ID, $new_meta_key))) { |
|
1787 | 1787 | continue; |
1788 | 1788 | } |
1789 | 1789 | |
@@ -1792,25 +1792,25 @@ discard block |
||
1792 | 1792 | array( |
1793 | 1793 | 'post_id' => $post->ID, |
1794 | 1794 | 'meta_key' => $new_meta_key, |
1795 | - 'meta_value' => give_get_meta( $post->ID, $old_meta_key, true ) |
|
1795 | + 'meta_value' => give_get_meta($post->ID, $old_meta_key, true) |
|
1796 | 1796 | ) |
1797 | 1797 | ); |
1798 | 1798 | } |
1799 | 1799 | |
1800 | 1800 | // Bailout |
1801 | - if ( $donor_id = give_get_meta( $post->ID, '_give_payment_donor_id', true ) ) { |
|
1801 | + if ($donor_id = give_get_meta($post->ID, '_give_payment_donor_id', true)) { |
|
1802 | 1802 | /* @var Give_Donor $donor */ |
1803 | - $donor = new Give_Donor( $donor_id ); |
|
1803 | + $donor = new Give_Donor($donor_id); |
|
1804 | 1804 | |
1805 | - $address['line1'] = give_get_meta( $post->ID, '_give_donor_billing_address1', true, '' ); |
|
1806 | - $address['line2'] = give_get_meta( $post->ID, '_give_donor_billing_address2', true, '' ); |
|
1807 | - $address['city'] = give_get_meta( $post->ID, '_give_donor_billing_city', true, '' ); |
|
1808 | - $address['state'] = give_get_meta( $post->ID, '_give_donor_billing_state', true, '' ); |
|
1809 | - $address['zip'] = give_get_meta( $post->ID, '_give_donor_billing_zip', true, '' ); |
|
1810 | - $address['country'] = give_get_meta( $post->ID, '_give_donor_billing_country', true, '' ); |
|
1805 | + $address['line1'] = give_get_meta($post->ID, '_give_donor_billing_address1', true, ''); |
|
1806 | + $address['line2'] = give_get_meta($post->ID, '_give_donor_billing_address2', true, ''); |
|
1807 | + $address['city'] = give_get_meta($post->ID, '_give_donor_billing_city', true, ''); |
|
1808 | + $address['state'] = give_get_meta($post->ID, '_give_donor_billing_state', true, ''); |
|
1809 | + $address['zip'] = give_get_meta($post->ID, '_give_donor_billing_zip', true, ''); |
|
1810 | + $address['country'] = give_get_meta($post->ID, '_give_donor_billing_country', true, ''); |
|
1811 | 1811 | |
1812 | 1812 | // Save address. |
1813 | - $donor->add_address( 'billing[]', $address ); |
|
1813 | + $donor->add_address('billing[]', $address); |
|
1814 | 1814 | } |
1815 | 1815 | |
1816 | 1816 | }// End while(). |
@@ -1821,7 +1821,7 @@ discard block |
||
1821 | 1821 | // $wpdb->get_var( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE meta_key=%s", '_give_payment_user_id' ) ); |
1822 | 1822 | |
1823 | 1823 | // No more forms found, finish up. |
1824 | - give_set_upgrade_complete( 'v20_upgrades_payment_metadata' ); |
|
1824 | + give_set_upgrade_complete('v20_upgrades_payment_metadata'); |
|
1825 | 1825 | } |
1826 | 1826 | } |
1827 | 1827 | |
@@ -1837,7 +1837,7 @@ discard block |
||
1837 | 1837 | $give_updates = Give_Updates::get_instance(); |
1838 | 1838 | |
1839 | 1839 | // form query |
1840 | - $forms = new WP_Query( array( |
|
1840 | + $forms = new WP_Query(array( |
|
1841 | 1841 | 'paged' => $give_updates->step, |
1842 | 1842 | 'order' => 'DESC', |
1843 | 1843 | 'post_type' => 'give_log', |
@@ -1846,20 +1846,20 @@ discard block |
||
1846 | 1846 | ) |
1847 | 1847 | ); |
1848 | 1848 | |
1849 | - if ( $forms->have_posts() ) { |
|
1850 | - $give_updates->set_percentage( $forms->found_posts, $give_updates->step * 100 ); |
|
1849 | + if ($forms->have_posts()) { |
|
1850 | + $give_updates->set_percentage($forms->found_posts, $give_updates->step * 100); |
|
1851 | 1851 | |
1852 | - while ( $forms->have_posts() ) { |
|
1852 | + while ($forms->have_posts()) { |
|
1853 | 1853 | $forms->the_post(); |
1854 | 1854 | global $post; |
1855 | 1855 | |
1856 | - if( $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_logs WHERE ID=%d", $post->ID ) ) ) { |
|
1856 | + if ($wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_logs WHERE ID=%d", $post->ID))) { |
|
1857 | 1857 | continue; |
1858 | 1858 | } |
1859 | 1859 | |
1860 | - $term = get_the_terms( $post->ID, 'give_log_type' ); |
|
1861 | - $term = ! is_wp_error( $term ) && ! empty( $term ) ? $term[0] : array(); |
|
1862 | - $term_name = ! empty( $term ) ? $term->slug : ''; |
|
1860 | + $term = get_the_terms($post->ID, 'give_log_type'); |
|
1861 | + $term = ! is_wp_error($term) && ! empty($term) ? $term[0] : array(); |
|
1862 | + $term_name = ! empty($term) ? $term->slug : ''; |
|
1863 | 1863 | |
1864 | 1864 | $log_data = array( |
1865 | 1865 | 'ID' => $post->ID, |
@@ -1872,29 +1872,29 @@ discard block |
||
1872 | 1872 | ); |
1873 | 1873 | $log_meta = array(); |
1874 | 1874 | |
1875 | - if ( $old_log_meta = get_post_meta( $post->ID ) ) { |
|
1876 | - foreach ( $old_log_meta as $meta_key => $meta_value ) { |
|
1877 | - switch ( $meta_key ) { |
|
1875 | + if ($old_log_meta = get_post_meta($post->ID)) { |
|
1876 | + foreach ($old_log_meta as $meta_key => $meta_value) { |
|
1877 | + switch ($meta_key) { |
|
1878 | 1878 | case '_give_log_payment_id': |
1879 | - $log_data['log_parent'] = current( $meta_value ); |
|
1879 | + $log_data['log_parent'] = current($meta_value); |
|
1880 | 1880 | $log_meta['_give_log_form_id'] = $post->post_parent; |
1881 | 1881 | break; |
1882 | 1882 | |
1883 | 1883 | default: |
1884 | - $log_meta[ $meta_key ] = current( $meta_value ); |
|
1884 | + $log_meta[$meta_key] = current($meta_value); |
|
1885 | 1885 | } |
1886 | 1886 | } |
1887 | 1887 | } |
1888 | 1888 | |
1889 | - if ( 'api_request' === $term_name ) { |
|
1889 | + if ('api_request' === $term_name) { |
|
1890 | 1890 | $log_meta['_give_log_api_query'] = $post->post_excerpt; |
1891 | 1891 | } |
1892 | 1892 | |
1893 | - $wpdb->insert( "{$wpdb->prefix}give_logs", $log_data ); |
|
1893 | + $wpdb->insert("{$wpdb->prefix}give_logs", $log_data); |
|
1894 | 1894 | |
1895 | - if ( ! empty( $log_meta ) ) { |
|
1896 | - foreach ( $log_meta as $meta_key => $meta_value ) { |
|
1897 | - Give()->logs->logmeta_db->update_meta( $post->ID, $meta_key, $meta_value ); |
|
1895 | + if ( ! empty($log_meta)) { |
|
1896 | + foreach ($log_meta as $meta_key => $meta_value) { |
|
1897 | + Give()->logs->logmeta_db->update_meta($post->ID, $meta_key, $meta_value); |
|
1898 | 1898 | } |
1899 | 1899 | } |
1900 | 1900 | |
@@ -1936,7 +1936,7 @@ discard block |
||
1936 | 1936 | Give()->logs->delete_cache(); |
1937 | 1937 | |
1938 | 1938 | // No more forms found, finish up. |
1939 | - give_set_upgrade_complete( 'v20_logs_upgrades' ); |
|
1939 | + give_set_upgrade_complete('v20_logs_upgrades'); |
|
1940 | 1940 | } |
1941 | 1941 | } |
1942 | 1942 | |
@@ -1952,19 +1952,19 @@ discard block |
||
1952 | 1952 | $give_updates = Give_Updates::get_instance(); |
1953 | 1953 | |
1954 | 1954 | // form query |
1955 | - $payments = new WP_Query( array( |
|
1955 | + $payments = new WP_Query(array( |
|
1956 | 1956 | 'paged' => $give_updates->step, |
1957 | 1957 | 'status' => 'any', |
1958 | 1958 | 'order' => 'ASC', |
1959 | - 'post_type' => array( 'give_forms', 'give_payment' ), |
|
1959 | + 'post_type' => array('give_forms', 'give_payment'), |
|
1960 | 1960 | 'posts_per_page' => 100, |
1961 | 1961 | ) |
1962 | 1962 | ); |
1963 | 1963 | |
1964 | - if ( $payments->have_posts() ) { |
|
1965 | - $give_updates->set_percentage( $payments->found_posts, $give_updates->step * 100 ); |
|
1964 | + if ($payments->have_posts()) { |
|
1965 | + $give_updates->set_percentage($payments->found_posts, $give_updates->step * 100); |
|
1966 | 1966 | |
1967 | - while ( $payments->have_posts() ) { |
|
1967 | + while ($payments->have_posts()) { |
|
1968 | 1968 | $payments->the_post(); |
1969 | 1969 | global $post; |
1970 | 1970 | |
@@ -1976,19 +1976,19 @@ discard block |
||
1976 | 1976 | ARRAY_A |
1977 | 1977 | ); |
1978 | 1978 | |
1979 | - if ( ! empty( $meta_data ) ) { |
|
1980 | - foreach ( $meta_data as $index => $data ) { |
|
1979 | + if ( ! empty($meta_data)) { |
|
1980 | + foreach ($meta_data as $index => $data) { |
|
1981 | 1981 | // Check for duplicate meta values. |
1982 | - if( $result = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM " . ( 'give_forms' === $post->post_type ? $wpdb->formmeta : $wpdb->paymentmeta ) . " WHERE meta_id=%d", $data['meta_id'] ), ARRAY_A ) ) { |
|
1982 | + if ($result = $wpdb->get_results($wpdb->prepare("SELECT * FROM ".('give_forms' === $post->post_type ? $wpdb->formmeta : $wpdb->paymentmeta)." WHERE meta_id=%d", $data['meta_id']), ARRAY_A)) { |
|
1983 | 1983 | continue; |
1984 | 1984 | } |
1985 | 1985 | |
1986 | - switch ( $post->post_type ) { |
|
1986 | + switch ($post->post_type) { |
|
1987 | 1987 | case 'give_forms': |
1988 | 1988 | $data['form_id'] = $data['post_id']; |
1989 | - unset( $data['post_id'] ); |
|
1989 | + unset($data['post_id']); |
|
1990 | 1990 | |
1991 | - Give()->form_meta->insert( $data ); |
|
1991 | + Give()->form_meta->insert($data); |
|
1992 | 1992 | // @todo: delete form meta from post meta table after releases 2.0. |
1993 | 1993 | /*delete_post_meta( get_the_ID(), $data['meta_key'] );*/ |
1994 | 1994 | |
@@ -1996,9 +1996,9 @@ discard block |
||
1996 | 1996 | |
1997 | 1997 | case 'give_payment': |
1998 | 1998 | $data['payment_id'] = $data['post_id']; |
1999 | - unset( $data['post_id'] ); |
|
1999 | + unset($data['post_id']); |
|
2000 | 2000 | |
2001 | - Give()->payment_meta->insert( $data ); |
|
2001 | + Give()->payment_meta->insert($data); |
|
2002 | 2002 | |
2003 | 2003 | // @todo: delete donation meta from post meta table after releases 2.0. |
2004 | 2004 | /*delete_post_meta( get_the_ID(), $data['meta_key'] );*/ |
@@ -2013,7 +2013,7 @@ discard block |
||
2013 | 2013 | wp_reset_postdata(); |
2014 | 2014 | } else { |
2015 | 2015 | // No more forms found, finish up. |
2016 | - give_set_upgrade_complete( 'v20_move_metadata_into_new_table' ); |
|
2016 | + give_set_upgrade_complete('v20_move_metadata_into_new_table'); |
|
2017 | 2017 | } |
2018 | 2018 | |
2019 | 2019 | } |
@@ -2029,44 +2029,44 @@ discard block |
||
2029 | 2029 | /* @var Give_Updates $give_updates */ |
2030 | 2030 | $give_updates = Give_Updates::get_instance(); |
2031 | 2031 | |
2032 | - $donors = Give()->donors->get_donors( array( |
|
2032 | + $donors = Give()->donors->get_donors(array( |
|
2033 | 2033 | 'paged' => $give_updates->step, |
2034 | 2034 | 'number' => 100, |
2035 | - ) ); |
|
2035 | + )); |
|
2036 | 2036 | |
2037 | - if ( $donors ) { |
|
2038 | - $give_updates->set_percentage( count( $donors ), $give_updates->step * 100 ); |
|
2037 | + if ($donors) { |
|
2038 | + $give_updates->set_percentage(count($donors), $give_updates->step * 100); |
|
2039 | 2039 | // Loop through Donors |
2040 | - foreach ( $donors as $donor ) { |
|
2040 | + foreach ($donors as $donor) { |
|
2041 | 2041 | |
2042 | - $donor_name = explode( ' ', $donor->name, 2 ); |
|
2043 | - $donor_first_name = Give()->donor_meta->get_meta( $donor->id, '_give_donor_first_name' ); |
|
2044 | - $donor_last_name = Give()->donor_meta->get_meta( $donor->id, '_give_donor_last_name' ); |
|
2042 | + $donor_name = explode(' ', $donor->name, 2); |
|
2043 | + $donor_first_name = Give()->donor_meta->get_meta($donor->id, '_give_donor_first_name'); |
|
2044 | + $donor_last_name = Give()->donor_meta->get_meta($donor->id, '_give_donor_last_name'); |
|
2045 | 2045 | |
2046 | 2046 | // If first name meta of donor is not created, then create it. |
2047 | - if ( ! $donor_first_name && isset( $donor_name[0] ) ) { |
|
2048 | - Give()->donor_meta->add_meta( $donor->id, '_give_donor_first_name', $donor_name[0] ); |
|
2047 | + if ( ! $donor_first_name && isset($donor_name[0])) { |
|
2048 | + Give()->donor_meta->add_meta($donor->id, '_give_donor_first_name', $donor_name[0]); |
|
2049 | 2049 | } |
2050 | 2050 | |
2051 | 2051 | // If last name meta of donor is not created, then create it. |
2052 | - if ( ! $donor_last_name && isset( $donor_name[1] ) ) { |
|
2053 | - Give()->donor_meta->add_meta( $donor->id, '_give_donor_last_name', $donor_name[1] ); |
|
2052 | + if ( ! $donor_last_name && isset($donor_name[1])) { |
|
2053 | + Give()->donor_meta->add_meta($donor->id, '_give_donor_last_name', $donor_name[1]); |
|
2054 | 2054 | } |
2055 | 2055 | |
2056 | 2056 | // If Donor is connected with WP User then update user meta. |
2057 | - if ( $donor->user_id ) { |
|
2058 | - if ( isset( $donor_name[0] ) ) { |
|
2059 | - update_user_meta( $donor->user_id, 'first_name', $donor_name[0] ); |
|
2057 | + if ($donor->user_id) { |
|
2058 | + if (isset($donor_name[0])) { |
|
2059 | + update_user_meta($donor->user_id, 'first_name', $donor_name[0]); |
|
2060 | 2060 | } |
2061 | - if ( isset( $donor_name[1] ) ) { |
|
2062 | - update_user_meta( $donor->user_id, 'last_name', $donor_name[1] ); |
|
2061 | + if (isset($donor_name[1])) { |
|
2062 | + update_user_meta($donor->user_id, 'last_name', $donor_name[1]); |
|
2063 | 2063 | } |
2064 | 2064 | } |
2065 | 2065 | } |
2066 | 2066 | |
2067 | 2067 | } else { |
2068 | 2068 | // The Update Ran. |
2069 | - give_set_upgrade_complete( 'v20_upgrades_donor_name' ); |
|
2069 | + give_set_upgrade_complete('v20_upgrades_donor_name'); |
|
2070 | 2070 | } |
2071 | 2071 | |
2072 | 2072 | } |
@@ -2095,15 +2095,15 @@ discard block |
||
2095 | 2095 | |
2096 | 2096 | $users = $user_query->get_results(); |
2097 | 2097 | |
2098 | - if ( $users ) { |
|
2099 | - $give_updates->set_percentage( $user_query->get_total(), $give_updates->step * 100 ); |
|
2098 | + if ($users) { |
|
2099 | + $give_updates->set_percentage($user_query->get_total(), $give_updates->step * 100); |
|
2100 | 2100 | |
2101 | 2101 | // Loop through Donors |
2102 | - foreach ( $users as $user ) { |
|
2102 | + foreach ($users as $user) { |
|
2103 | 2103 | /* @var Give_Donor $donor */ |
2104 | - $donor = new Give_Donor( $user->ID, true ); |
|
2104 | + $donor = new Give_Donor($user->ID, true); |
|
2105 | 2105 | |
2106 | - if ( ! $donor->id ) { |
|
2106 | + if ( ! $donor->id) { |
|
2107 | 2107 | continue; |
2108 | 2108 | } |
2109 | 2109 | |
@@ -2119,10 +2119,10 @@ discard block |
||
2119 | 2119 | ) |
2120 | 2120 | ); |
2121 | 2121 | |
2122 | - if ( ! empty( $address ) ) { |
|
2123 | - $address = maybe_unserialize( $address ); |
|
2124 | - $donor->add_address( 'personal', $address ); |
|
2125 | - $donor->add_address( 'billing[]', $address ); |
|
2122 | + if ( ! empty($address)) { |
|
2123 | + $address = maybe_unserialize($address); |
|
2124 | + $donor->add_address('personal', $address); |
|
2125 | + $donor->add_address('billing[]', $address); |
|
2126 | 2126 | |
2127 | 2127 | |
2128 | 2128 | // @todo: delete _give_user_address from user meta after releases 2.0. |
@@ -2132,7 +2132,7 @@ discard block |
||
2132 | 2132 | |
2133 | 2133 | } else { |
2134 | 2134 | // The Update Ran. |
2135 | - give_set_upgrade_complete( 'v20_upgrades_user_address' ); |
|
2135 | + give_set_upgrade_complete('v20_upgrades_user_address'); |
|
2136 | 2136 | } |
2137 | 2137 | |
2138 | 2138 | } |
@@ -2156,15 +2156,15 @@ discard block |
||
2156 | 2156 | ); |
2157 | 2157 | |
2158 | 2158 | // Alter customer table |
2159 | - foreach ( $tables as $old_table => $new_table ) { |
|
2159 | + foreach ($tables as $old_table => $new_table) { |
|
2160 | 2160 | if ( |
2161 | - $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", $old_table ) ) && |
|
2162 | - ! $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", $new_table ) ) |
|
2161 | + $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", $old_table)) && |
|
2162 | + ! $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", $new_table)) |
|
2163 | 2163 | ) { |
2164 | - $wpdb->query( "ALTER TABLE {$old_table} RENAME TO {$new_table}" ); |
|
2164 | + $wpdb->query("ALTER TABLE {$old_table} RENAME TO {$new_table}"); |
|
2165 | 2165 | |
2166 | - if ( "{$wpdb->prefix}give_donormeta" === $new_table ) { |
|
2167 | - $wpdb->query( "ALTER TABLE {$new_table} CHANGE COLUMN customer_id donor_id bigint(20)" ); |
|
2166 | + if ("{$wpdb->prefix}give_donormeta" === $new_table) { |
|
2167 | + $wpdb->query("ALTER TABLE {$new_table} CHANGE COLUMN customer_id donor_id bigint(20)"); |
|
2168 | 2168 | } |
2169 | 2169 | } |
2170 | 2170 | } |
@@ -2172,7 +2172,7 @@ discard block |
||
2172 | 2172 | $give_updates->percentage = 100; |
2173 | 2173 | |
2174 | 2174 | // No more forms found, finish up. |
2175 | - give_set_upgrade_complete( 'v20_rename_donor_tables' ); |
|
2175 | + give_set_upgrade_complete('v20_rename_donor_tables'); |
|
2176 | 2176 | |
2177 | 2177 | // Re initiate donor classes. |
2178 | 2178 | Give()->donors = new Give_DB_Donors(); |
@@ -2187,22 +2187,22 @@ discard block |
||
2187 | 2187 | * @global wpdb $wpdb |
2188 | 2188 | * @return void |
2189 | 2189 | */ |
2190 | -function give_v201_create_tables(){ |
|
2190 | +function give_v201_create_tables() { |
|
2191 | 2191 | global $wpdb; |
2192 | 2192 | |
2193 | - if ( ! $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", "{$wpdb->prefix}give_paymentmeta" ) ) ) { |
|
2193 | + if ( ! $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_paymentmeta"))) { |
|
2194 | 2194 | Give()->payment_meta->create_table(); |
2195 | 2195 | } |
2196 | 2196 | |
2197 | - if ( ! $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", "{$wpdb->prefix}give_formmeta" ) ) ) { |
|
2197 | + if ( ! $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_formmeta"))) { |
|
2198 | 2198 | Give()->form_meta->create_table(); |
2199 | 2199 | } |
2200 | 2200 | |
2201 | - if ( ! $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", "{$wpdb->prefix}give_logs" ) ) ) { |
|
2201 | + if ( ! $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_logs"))) { |
|
2202 | 2202 | Give()->logs->log_db->create_table(); |
2203 | 2203 | } |
2204 | 2204 | |
2205 | - if ( ! $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", "{$wpdb->prefix}give_logmeta" ) ) ) { |
|
2205 | + if ( ! $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_logmeta"))) { |
|
2206 | 2206 | Give()->logs->logmeta_db->create_table(); |
2207 | 2207 | } |
2208 | 2208 | } |
@@ -2227,31 +2227,31 @@ discard block |
||
2227 | 2227 | $wpdb->posts.post_date >= '2018-01-08 00:00:00' |
2228 | 2228 | ) |
2229 | 2229 | AND $wpdb->posts.post_type = 'give_payment' |
2230 | - AND {$wpdb->posts}.post_status IN ('" . implode( "','", array_keys( give_get_payment_statuses() ) ) . "') |
|
2230 | + AND {$wpdb->posts}.post_status IN ('".implode("','", array_keys(give_get_payment_statuses()))."') |
|
2231 | 2231 | ORDER BY $wpdb->posts.post_date ASC |
2232 | 2232 | LIMIT 100 |
2233 | - OFFSET " . ( 1 === $give_updates->step ? 0 : ( $give_updates->step * 100 ) ) |
|
2233 | + OFFSET ".(1 === $give_updates->step ? 0 : ($give_updates->step * 100)) |
|
2234 | 2234 | ); |
2235 | 2235 | |
2236 | - if ( ! empty( $payments ) ) { |
|
2237 | - $give_updates->set_percentage( give_get_total_post_type_count( 'give_payment' ), ( $give_updates->step * 100 ) ); |
|
2236 | + if ( ! empty($payments)) { |
|
2237 | + $give_updates->set_percentage(give_get_total_post_type_count('give_payment'), ($give_updates->step * 100)); |
|
2238 | 2238 | |
2239 | - foreach ( $payments as $payment_id ) { |
|
2240 | - $post = get_post( $payment_id ); |
|
2241 | - setup_postdata( $post ); |
|
2239 | + foreach ($payments as $payment_id) { |
|
2240 | + $post = get_post($payment_id); |
|
2241 | + setup_postdata($post); |
|
2242 | 2242 | |
2243 | 2243 | // Do not add new meta keys if already refactored. |
2244 | - if ( $wpdb->get_var( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id=%d AND meta_key=%s", $post->ID, '_give_payment_donor_id' ) ) ) { |
|
2244 | + if ($wpdb->get_var($wpdb->prepare("SELECT meta_id FROM $wpdb->postmeta WHERE post_id=%d AND meta_key=%s", $post->ID, '_give_payment_donor_id'))) { |
|
2245 | 2245 | continue; |
2246 | 2246 | } |
2247 | 2247 | |
2248 | 2248 | |
2249 | 2249 | // Split _give_payment_meta meta. |
2250 | 2250 | // @todo Remove _give_payment_meta after releases 2.0 |
2251 | - $payment_meta = give_get_meta( $post->ID, '_give_payment_meta', true ); |
|
2251 | + $payment_meta = give_get_meta($post->ID, '_give_payment_meta', true); |
|
2252 | 2252 | |
2253 | - if ( ! empty( $payment_meta ) ) { |
|
2254 | - _give_20_bc_split_and_save_give_payment_meta( $post->ID, $payment_meta ); |
|
2253 | + if ( ! empty($payment_meta)) { |
|
2254 | + _give_20_bc_split_and_save_give_payment_meta($post->ID, $payment_meta); |
|
2255 | 2255 | } |
2256 | 2256 | |
2257 | 2257 | $deprecated_meta_keys = array( |
@@ -2260,9 +2260,9 @@ discard block |
||
2260 | 2260 | '_give_payment_user_ip' => '_give_payment_donor_ip', |
2261 | 2261 | ); |
2262 | 2262 | |
2263 | - foreach ( $deprecated_meta_keys as $old_meta_key => $new_meta_key ) { |
|
2263 | + foreach ($deprecated_meta_keys as $old_meta_key => $new_meta_key) { |
|
2264 | 2264 | // Do not add new meta key if already exist. |
2265 | - if ( $wpdb->get_var( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id=%d AND meta_key=%s", $post->ID, $new_meta_key ) ) ) { |
|
2265 | + if ($wpdb->get_var($wpdb->prepare("SELECT meta_id FROM $wpdb->postmeta WHERE post_id=%d AND meta_key=%s", $post->ID, $new_meta_key))) { |
|
2266 | 2266 | continue; |
2267 | 2267 | } |
2268 | 2268 | |
@@ -2271,25 +2271,25 @@ discard block |
||
2271 | 2271 | array( |
2272 | 2272 | 'post_id' => $post->ID, |
2273 | 2273 | 'meta_key' => $new_meta_key, |
2274 | - 'meta_value' => give_get_meta( $post->ID, $old_meta_key, true ) |
|
2274 | + 'meta_value' => give_get_meta($post->ID, $old_meta_key, true) |
|
2275 | 2275 | ) |
2276 | 2276 | ); |
2277 | 2277 | } |
2278 | 2278 | |
2279 | 2279 | // Bailout |
2280 | - if ( $donor_id = give_get_meta( $post->ID, '_give_payment_donor_id', true ) ) { |
|
2280 | + if ($donor_id = give_get_meta($post->ID, '_give_payment_donor_id', true)) { |
|
2281 | 2281 | /* @var Give_Donor $donor */ |
2282 | - $donor = new Give_Donor( $donor_id ); |
|
2282 | + $donor = new Give_Donor($donor_id); |
|
2283 | 2283 | |
2284 | - $address['line1'] = give_get_meta( $post->ID, '_give_donor_billing_address1', true, '' ); |
|
2285 | - $address['line2'] = give_get_meta( $post->ID, '_give_donor_billing_address2', true, '' ); |
|
2286 | - $address['city'] = give_get_meta( $post->ID, '_give_donor_billing_city', true, '' ); |
|
2287 | - $address['state'] = give_get_meta( $post->ID, '_give_donor_billing_state', true, '' ); |
|
2288 | - $address['zip'] = give_get_meta( $post->ID, '_give_donor_billing_zip', true, '' ); |
|
2289 | - $address['country'] = give_get_meta( $post->ID, '_give_donor_billing_country', true, '' ); |
|
2284 | + $address['line1'] = give_get_meta($post->ID, '_give_donor_billing_address1', true, ''); |
|
2285 | + $address['line2'] = give_get_meta($post->ID, '_give_donor_billing_address2', true, ''); |
|
2286 | + $address['city'] = give_get_meta($post->ID, '_give_donor_billing_city', true, ''); |
|
2287 | + $address['state'] = give_get_meta($post->ID, '_give_donor_billing_state', true, ''); |
|
2288 | + $address['zip'] = give_get_meta($post->ID, '_give_donor_billing_zip', true, ''); |
|
2289 | + $address['country'] = give_get_meta($post->ID, '_give_donor_billing_country', true, ''); |
|
2290 | 2290 | |
2291 | 2291 | // Save address. |
2292 | - $donor->add_address( 'billing[]', $address ); |
|
2292 | + $donor->add_address('billing[]', $address); |
|
2293 | 2293 | } |
2294 | 2294 | |
2295 | 2295 | }// End while(). |
@@ -2300,7 +2300,7 @@ discard block |
||
2300 | 2300 | // $wpdb->get_var( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE meta_key=%s", '_give_payment_user_id' ) ); |
2301 | 2301 | |
2302 | 2302 | // No more forms found, finish up. |
2303 | - give_set_upgrade_complete( 'v201_upgrades_payment_metadata' ); |
|
2303 | + give_set_upgrade_complete('v201_upgrades_payment_metadata'); |
|
2304 | 2304 | } |
2305 | 2305 | } |
2306 | 2306 | |
@@ -2320,18 +2320,18 @@ discard block |
||
2320 | 2320 | SELECT ID FROM $wpdb->posts |
2321 | 2321 | WHERE 1=1 |
2322 | 2322 | AND ( $wpdb->posts.post_type = 'give_payment' OR $wpdb->posts.post_type = 'give_forms' ) |
2323 | - AND {$wpdb->posts}.post_status IN ('" . implode( "','", array_keys( give_get_payment_statuses() ) ) . "') |
|
2323 | + AND {$wpdb->posts}.post_status IN ('".implode("','", array_keys(give_get_payment_statuses()))."') |
|
2324 | 2324 | ORDER BY $wpdb->posts.post_date ASC |
2325 | 2325 | LIMIT 100 |
2326 | - OFFSET " . ( 1 === $give_updates->step ? 0 : ( $give_updates->step * 100 ) ) |
|
2326 | + OFFSET ".(1 === $give_updates->step ? 0 : ($give_updates->step * 100)) |
|
2327 | 2327 | ); |
2328 | 2328 | |
2329 | - if ( ! empty( $payments ) ) { |
|
2330 | - $give_updates->set_percentage( give_get_total_post_type_count( array( 'give_forms', 'give_payment' ) ), $give_updates->step * 100 ); |
|
2329 | + if ( ! empty($payments)) { |
|
2330 | + $give_updates->set_percentage(give_get_total_post_type_count(array('give_forms', 'give_payment')), $give_updates->step * 100); |
|
2331 | 2331 | |
2332 | - foreach ( $payments as $payment_id ) { |
|
2333 | - $post = get_post( $payment_id ); |
|
2334 | - setup_postdata( $post ); |
|
2332 | + foreach ($payments as $payment_id) { |
|
2333 | + $post = get_post($payment_id); |
|
2334 | + setup_postdata($post); |
|
2335 | 2335 | |
2336 | 2336 | $meta_data = $wpdb->get_results( |
2337 | 2337 | $wpdb->prepare( |
@@ -2341,19 +2341,19 @@ discard block |
||
2341 | 2341 | ARRAY_A |
2342 | 2342 | ); |
2343 | 2343 | |
2344 | - if ( ! empty( $meta_data ) ) { |
|
2345 | - foreach ( $meta_data as $index => $data ) { |
|
2344 | + if ( ! empty($meta_data)) { |
|
2345 | + foreach ($meta_data as $index => $data) { |
|
2346 | 2346 | // Check for duplicate meta values. |
2347 | - if( $result = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM " . ( 'give_forms' === $post->post_type ? $wpdb->formmeta : $wpdb->paymentmeta ) . " WHERE meta_id=%d", $data['meta_id'] ), ARRAY_A ) ) { |
|
2347 | + if ($result = $wpdb->get_results($wpdb->prepare("SELECT * FROM ".('give_forms' === $post->post_type ? $wpdb->formmeta : $wpdb->paymentmeta)." WHERE meta_id=%d", $data['meta_id']), ARRAY_A)) { |
|
2348 | 2348 | continue; |
2349 | 2349 | } |
2350 | 2350 | |
2351 | - switch ( $post->post_type ) { |
|
2351 | + switch ($post->post_type) { |
|
2352 | 2352 | case 'give_forms': |
2353 | 2353 | $data['form_id'] = $data['post_id']; |
2354 | - unset( $data['post_id'] ); |
|
2354 | + unset($data['post_id']); |
|
2355 | 2355 | |
2356 | - Give()->form_meta->insert( $data ); |
|
2356 | + Give()->form_meta->insert($data); |
|
2357 | 2357 | // @todo: delete form meta from post meta table after releases 2.0. |
2358 | 2358 | /*delete_post_meta( get_the_ID(), $data['meta_key'] );*/ |
2359 | 2359 | |
@@ -2361,9 +2361,9 @@ discard block |
||
2361 | 2361 | |
2362 | 2362 | case 'give_payment': |
2363 | 2363 | $data['payment_id'] = $data['post_id']; |
2364 | - unset( $data['post_id'] ); |
|
2364 | + unset($data['post_id']); |
|
2365 | 2365 | |
2366 | - Give()->payment_meta->insert( $data ); |
|
2366 | + Give()->payment_meta->insert($data); |
|
2367 | 2367 | |
2368 | 2368 | // @todo: delete donation meta from post meta table after releases 2.0. |
2369 | 2369 | /*delete_post_meta( get_the_ID(), $data['meta_key'] );*/ |
@@ -2378,7 +2378,7 @@ discard block |
||
2378 | 2378 | wp_reset_postdata(); |
2379 | 2379 | } else { |
2380 | 2380 | // No more forms found, finish up. |
2381 | - give_set_upgrade_complete( 'v201_move_metadata_into_new_table' ); |
|
2381 | + give_set_upgrade_complete('v201_move_metadata_into_new_table'); |
|
2382 | 2382 | } |
2383 | 2383 | |
2384 | 2384 | } |
@@ -2399,26 +2399,26 @@ discard block |
||
2399 | 2399 | SELECT ID FROM $wpdb->posts |
2400 | 2400 | WHERE 1=1 |
2401 | 2401 | AND $wpdb->posts.post_type = 'give_log' |
2402 | - AND {$wpdb->posts}.post_status IN ('" . implode( "','", array_keys( give_get_payment_statuses() ) ) . "') |
|
2402 | + AND {$wpdb->posts}.post_status IN ('".implode("','", array_keys(give_get_payment_statuses()))."') |
|
2403 | 2403 | ORDER BY $wpdb->posts.post_date ASC |
2404 | 2404 | LIMIT 100 |
2405 | - OFFSET " . ( 1 === $give_updates->step ? 0 : ( $give_updates->step * 100 ) ) |
|
2405 | + OFFSET ".(1 === $give_updates->step ? 0 : ($give_updates->step * 100)) |
|
2406 | 2406 | ); |
2407 | 2407 | |
2408 | - if ( ! empty( $logs ) ) { |
|
2409 | - $give_updates->set_percentage( give_get_total_post_type_count( 'give_log' ), $give_updates->step * 100 ); |
|
2408 | + if ( ! empty($logs)) { |
|
2409 | + $give_updates->set_percentage(give_get_total_post_type_count('give_log'), $give_updates->step * 100); |
|
2410 | 2410 | |
2411 | - foreach ( $logs as $log_id ) { |
|
2412 | - $post = get_post( $log_id ); |
|
2413 | - setup_postdata( $post ); |
|
2411 | + foreach ($logs as $log_id) { |
|
2412 | + $post = get_post($log_id); |
|
2413 | + setup_postdata($post); |
|
2414 | 2414 | |
2415 | - if( $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_logs WHERE ID=%d", $post->ID ) ) ) { |
|
2415 | + if ($wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_logs WHERE ID=%d", $post->ID))) { |
|
2416 | 2416 | continue; |
2417 | 2417 | } |
2418 | 2418 | |
2419 | - $term = get_the_terms( $post->ID, 'give_log_type' ); |
|
2420 | - $term = ! is_wp_error( $term ) && ! empty( $term ) ? $term[0] : array(); |
|
2421 | - $term_name = ! empty( $term ) ? $term->slug : ''; |
|
2419 | + $term = get_the_terms($post->ID, 'give_log_type'); |
|
2420 | + $term = ! is_wp_error($term) && ! empty($term) ? $term[0] : array(); |
|
2421 | + $term_name = ! empty($term) ? $term->slug : ''; |
|
2422 | 2422 | |
2423 | 2423 | $log_data = array( |
2424 | 2424 | 'ID' => $post->ID, |
@@ -2431,29 +2431,29 @@ discard block |
||
2431 | 2431 | ); |
2432 | 2432 | $log_meta = array(); |
2433 | 2433 | |
2434 | - if ( $old_log_meta = get_post_meta( $post->ID ) ) { |
|
2435 | - foreach ( $old_log_meta as $meta_key => $meta_value ) { |
|
2436 | - switch ( $meta_key ) { |
|
2434 | + if ($old_log_meta = get_post_meta($post->ID)) { |
|
2435 | + foreach ($old_log_meta as $meta_key => $meta_value) { |
|
2436 | + switch ($meta_key) { |
|
2437 | 2437 | case '_give_log_payment_id': |
2438 | - $log_data['log_parent'] = current( $meta_value ); |
|
2438 | + $log_data['log_parent'] = current($meta_value); |
|
2439 | 2439 | $log_meta['_give_log_form_id'] = $post->post_parent; |
2440 | 2440 | break; |
2441 | 2441 | |
2442 | 2442 | default: |
2443 | - $log_meta[ $meta_key ] = current( $meta_value ); |
|
2443 | + $log_meta[$meta_key] = current($meta_value); |
|
2444 | 2444 | } |
2445 | 2445 | } |
2446 | 2446 | } |
2447 | 2447 | |
2448 | - if ( 'api_request' === $term_name ) { |
|
2448 | + if ('api_request' === $term_name) { |
|
2449 | 2449 | $log_meta['_give_log_api_query'] = $post->post_excerpt; |
2450 | 2450 | } |
2451 | 2451 | |
2452 | - $wpdb->insert( "{$wpdb->prefix}give_logs", $log_data ); |
|
2452 | + $wpdb->insert("{$wpdb->prefix}give_logs", $log_data); |
|
2453 | 2453 | |
2454 | - if ( ! empty( $log_meta ) ) { |
|
2455 | - foreach ( $log_meta as $meta_key => $meta_value ) { |
|
2456 | - Give()->logs->logmeta_db->update_meta( $post->ID, $meta_key, $meta_value ); |
|
2454 | + if ( ! empty($log_meta)) { |
|
2455 | + foreach ($log_meta as $meta_key => $meta_value) { |
|
2456 | + Give()->logs->logmeta_db->update_meta($post->ID, $meta_key, $meta_value); |
|
2457 | 2457 | } |
2458 | 2458 | } |
2459 | 2459 | |
@@ -2466,7 +2466,7 @@ discard block |
||
2466 | 2466 | Give()->logs->delete_cache(); |
2467 | 2467 | |
2468 | 2468 | // No more forms found, finish up. |
2469 | - give_set_upgrade_complete( 'v201_logs_upgrades' ); |
|
2469 | + give_set_upgrade_complete('v201_logs_upgrades'); |
|
2470 | 2470 | } |
2471 | 2471 | } |
2472 | 2472 | |
@@ -2477,55 +2477,55 @@ discard block |
||
2477 | 2477 | * @since 2.0.1 |
2478 | 2478 | * @return void |
2479 | 2479 | */ |
2480 | -function give_v201_add_missing_donors_callback(){ |
|
2480 | +function give_v201_add_missing_donors_callback() { |
|
2481 | 2481 | global $wpdb; |
2482 | 2482 | give_v201_create_tables(); |
2483 | 2483 | |
2484 | - if ( $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", "{$wpdb->prefix}give_customers" ) ) ) { |
|
2485 | - $customers = wp_list_pluck( $wpdb->get_results( "SELECT id FROM {$wpdb->prefix}give_customers" ), 'id' ); |
|
2486 | - $donors = wp_list_pluck( $wpdb->get_results( "SELECT id FROM {$wpdb->prefix}give_donors" ), 'id' ); |
|
2484 | + if ($wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_customers"))) { |
|
2485 | + $customers = wp_list_pluck($wpdb->get_results("SELECT id FROM {$wpdb->prefix}give_customers"), 'id'); |
|
2486 | + $donors = wp_list_pluck($wpdb->get_results("SELECT id FROM {$wpdb->prefix}give_donors"), 'id'); |
|
2487 | 2487 | $donor_data = array(); |
2488 | 2488 | |
2489 | - if ( $missing_donors = array_diff( $customers, $donors ) ) { |
|
2490 | - foreach ( $missing_donors as $donor_id ) { |
|
2489 | + if ($missing_donors = array_diff($customers, $donors)) { |
|
2490 | + foreach ($missing_donors as $donor_id) { |
|
2491 | 2491 | $donor_data[] = array( |
2492 | - 'info' => $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_customers WHERE id=%d", $donor_id ) ), |
|
2493 | - 'meta' => $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_customermeta WHERE customer_id=%d", $donor_id ) ), |
|
2492 | + 'info' => $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_customers WHERE id=%d", $donor_id)), |
|
2493 | + 'meta' => $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_customermeta WHERE customer_id=%d", $donor_id)), |
|
2494 | 2494 | |
2495 | 2495 | ); |
2496 | 2496 | } |
2497 | 2497 | } |
2498 | 2498 | |
2499 | - if( ! empty( $donor_data ) ) { |
|
2499 | + if ( ! empty($donor_data)) { |
|
2500 | 2500 | $donor_table_name = Give()->donors->table_name; |
2501 | 2501 | $donor_meta_table_name = Give()->donor_meta->table_name; |
2502 | 2502 | |
2503 | 2503 | Give()->donors->table_name = "{$wpdb->prefix}give_donors"; |
2504 | 2504 | Give()->donor_meta->table_name = "{$wpdb->prefix}give_donormeta"; |
2505 | 2505 | |
2506 | - foreach ( $donor_data as $donor ) { |
|
2506 | + foreach ($donor_data as $donor) { |
|
2507 | 2507 | $donor['info'][0] = (array) $donor['info'][0]; |
2508 | 2508 | |
2509 | 2509 | // Prevent duplicate meta id issue. |
2510 | - if( $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_donors WHERE id=%d", $donor['info'][0]['id'] ) ) ){ |
|
2510 | + if ($wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_donors WHERE id=%d", $donor['info'][0]['id']))) { |
|
2511 | 2511 | continue; |
2512 | 2512 | } |
2513 | 2513 | |
2514 | - $donor_id = Give()->donors->add( $donor['info'][0] ); |
|
2514 | + $donor_id = Give()->donors->add($donor['info'][0]); |
|
2515 | 2515 | |
2516 | - if( ! empty( $donor['meta'] ) ) { |
|
2517 | - foreach ( $donor['meta'] as $donor_meta ) { |
|
2516 | + if ( ! empty($donor['meta'])) { |
|
2517 | + foreach ($donor['meta'] as $donor_meta) { |
|
2518 | 2518 | $donor_meta = (array) $donor_meta; |
2519 | 2519 | |
2520 | 2520 | // Prevent duplicate meta id issue. |
2521 | - if( $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_donormeta WHERE meta_id=%d", $donor_meta['meta_id'] ) ) ){ |
|
2522 | - unset( $donor_meta['meta_id'] ); |
|
2521 | + if ($wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_donormeta WHERE meta_id=%d", $donor_meta['meta_id']))) { |
|
2522 | + unset($donor_meta['meta_id']); |
|
2523 | 2523 | } |
2524 | 2524 | |
2525 | 2525 | $donor_meta['donor_id'] = $donor_meta['customer_id']; |
2526 | - unset( $donor_meta['customer_id'] ); |
|
2526 | + unset($donor_meta['customer_id']); |
|
2527 | 2527 | |
2528 | - Give()->donor_meta->insert( $donor_meta ); |
|
2528 | + Give()->donor_meta->insert($donor_meta); |
|
2529 | 2529 | } |
2530 | 2530 | } |
2531 | 2531 | |
@@ -2544,35 +2544,35 @@ discard block |
||
2544 | 2544 | ) |
2545 | 2545 | ); |
2546 | 2546 | |
2547 | - $donor = new Give_Donor( $donor_id ); |
|
2547 | + $donor = new Give_Donor($donor_id); |
|
2548 | 2548 | |
2549 | - if ( ! empty( $address ) ) { |
|
2550 | - $address = maybe_unserialize( $address ); |
|
2551 | - $donor->add_address( 'personal', $address ); |
|
2552 | - $donor->add_address( 'billing[]', $address ); |
|
2549 | + if ( ! empty($address)) { |
|
2550 | + $address = maybe_unserialize($address); |
|
2551 | + $donor->add_address('personal', $address); |
|
2552 | + $donor->add_address('billing[]', $address); |
|
2553 | 2553 | } |
2554 | 2554 | |
2555 | - $donor_name = explode( ' ', $donor->name, 2 ); |
|
2556 | - $donor_first_name = Give()->donor_meta->get_meta( $donor->id, '_give_donor_first_name' ); |
|
2557 | - $donor_last_name = Give()->donor_meta->get_meta( $donor->id, '_give_donor_last_name' ); |
|
2555 | + $donor_name = explode(' ', $donor->name, 2); |
|
2556 | + $donor_first_name = Give()->donor_meta->get_meta($donor->id, '_give_donor_first_name'); |
|
2557 | + $donor_last_name = Give()->donor_meta->get_meta($donor->id, '_give_donor_last_name'); |
|
2558 | 2558 | |
2559 | 2559 | // If first name meta of donor is not created, then create it. |
2560 | - if ( ! $donor_first_name && isset( $donor_name[0] ) ) { |
|
2561 | - Give()->donor_meta->add_meta( $donor->id, '_give_donor_first_name', $donor_name[0] ); |
|
2560 | + if ( ! $donor_first_name && isset($donor_name[0])) { |
|
2561 | + Give()->donor_meta->add_meta($donor->id, '_give_donor_first_name', $donor_name[0]); |
|
2562 | 2562 | } |
2563 | 2563 | |
2564 | 2564 | // If last name meta of donor is not created, then create it. |
2565 | - if ( ! $donor_last_name && isset( $donor_name[1] ) ) { |
|
2566 | - Give()->donor_meta->add_meta( $donor->id, '_give_donor_last_name', $donor_name[1] ); |
|
2565 | + if ( ! $donor_last_name && isset($donor_name[1])) { |
|
2566 | + Give()->donor_meta->add_meta($donor->id, '_give_donor_last_name', $donor_name[1]); |
|
2567 | 2567 | } |
2568 | 2568 | |
2569 | 2569 | // If Donor is connected with WP User then update user meta. |
2570 | - if ( $donor->user_id ) { |
|
2571 | - if ( isset( $donor_name[0] ) ) { |
|
2572 | - update_user_meta( $donor->user_id, 'first_name', $donor_name[0] ); |
|
2570 | + if ($donor->user_id) { |
|
2571 | + if (isset($donor_name[0])) { |
|
2572 | + update_user_meta($donor->user_id, 'first_name', $donor_name[0]); |
|
2573 | 2573 | } |
2574 | - if ( isset( $donor_name[1] ) ) { |
|
2575 | - update_user_meta( $donor->user_id, 'last_name', $donor_name[1] ); |
|
2574 | + if (isset($donor_name[1])) { |
|
2575 | + update_user_meta($donor->user_id, 'last_name', $donor_name[1]); |
|
2576 | 2576 | } |
2577 | 2577 | } |
2578 | 2578 | } |
@@ -2583,7 +2583,7 @@ discard block |
||
2583 | 2583 | } |
2584 | 2584 | |
2585 | 2585 | Give_Updates::get_instance()->percentage = 100; |
2586 | - give_set_upgrade_complete('v201_add_missing_donors' ); |
|
2586 | + give_set_upgrade_complete('v201_add_missing_donors'); |
|
2587 | 2587 | } |
2588 | 2588 | |
2589 | 2589 | |
@@ -2592,18 +2592,18 @@ discard block |
||
2592 | 2592 | * |
2593 | 2593 | * @since 2.0.3 |
2594 | 2594 | */ |
2595 | -function give_v203_upgrades(){ |
|
2595 | +function give_v203_upgrades() { |
|
2596 | 2596 | global $wpdb; |
2597 | 2597 | |
2598 | 2598 | // Do not auto load option. |
2599 | - $wpdb->update( $wpdb->options, array( 'autoload' => 'no' ), array( 'option_name' => 'give_completed_upgrades' ) ); |
|
2599 | + $wpdb->update($wpdb->options, array('autoload' => 'no'), array('option_name' => 'give_completed_upgrades')); |
|
2600 | 2600 | |
2601 | 2601 | // Remove from cache. |
2602 | 2602 | $all_options = wp_load_alloptions(); |
2603 | 2603 | |
2604 | - if( isset( $all_options['give_completed_upgrades'] ) ) { |
|
2605 | - unset( $all_options['give_completed_upgrades'] ); |
|
2606 | - wp_cache_set( 'alloptions', $all_options, 'options' ); |
|
2604 | + if (isset($all_options['give_completed_upgrades'])) { |
|
2605 | + unset($all_options['give_completed_upgrades']); |
|
2606 | + wp_cache_set('alloptions', $all_options, 'options'); |
|
2607 | 2607 | } |
2608 | 2608 | |
2609 | 2609 | } |
2610 | 2610 | \ No newline at end of file |
@@ -613,8 +613,11 @@ |
||
613 | 613 | return window.confirm('<?php echo esc_js( __( 'It is recommended that you backup your database before proceeding. Do you want to run the update now?', 'give' ) ); ?>'); // jshint ignore:line |
614 | 614 | }); |
615 | 615 | </script> |
616 | - <?php else: ?> |
|
617 | - <strong><?php _e( 'Database Update', 'give' ); ?></strong> |
|
616 | + <?php else { |
|
617 | + : ?> |
|
618 | + <strong><?php _e( 'Database Update', 'give' ); |
|
619 | +} |
|
620 | +?></strong> |
|
618 | 621 | – <?php _e( 'An unexpected issue occurred during the database update which caused it to stop automatically. Please contact support for assistance.', 'give' ); ?> |
619 | 622 | <?php |
620 | 623 | endif; |
@@ -80,34 +80,34 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @param array $args |
82 | 82 | */ |
83 | - public function register( $args ) { |
|
83 | + public function register($args) { |
|
84 | 84 | $args_default = array( |
85 | 85 | 'id' => '', |
86 | 86 | 'version' => '', |
87 | 87 | 'callback' => '', |
88 | 88 | ); |
89 | 89 | |
90 | - $args = wp_parse_args( $args, $args_default ); |
|
90 | + $args = wp_parse_args($args, $args_default); |
|
91 | 91 | |
92 | 92 | // You can only register database upgrade. |
93 | 93 | $args['type'] = 'database'; |
94 | 94 | |
95 | 95 | // Bailout. |
96 | 96 | if ( |
97 | - empty( $args['id'] ) || |
|
98 | - empty( $args['version'] ) || |
|
99 | - empty( $args['callback'] ) || |
|
100 | - ! is_callable( $args['callback'] ) |
|
97 | + empty($args['id']) || |
|
98 | + empty($args['version']) || |
|
99 | + empty($args['callback']) || |
|
100 | + ! is_callable($args['callback']) |
|
101 | 101 | ) { |
102 | 102 | return; |
103 | 103 | } |
104 | 104 | |
105 | 105 | // Change depend param to array. |
106 | - if ( isset( $args['depend'] ) && is_string( $args['depend'] ) ) { |
|
107 | - $args['depend'] = array( $args['depend'] ); |
|
106 | + if (isset($args['depend']) && is_string($args['depend'])) { |
|
107 | + $args['depend'] = array($args['depend']); |
|
108 | 108 | } |
109 | 109 | |
110 | - $this->updates[ $args['type'] ][] = $args; |
|
110 | + $this->updates[$args['type']][] = $args; |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | /** |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | * @return static |
119 | 119 | */ |
120 | 120 | static function get_instance() { |
121 | - if ( is_null( self::$instance ) ) { |
|
121 | + if (is_null(self::$instance)) { |
|
122 | 122 | self::$instance = new self(); |
123 | 123 | } |
124 | 124 | |
@@ -136,27 +136,27 @@ discard block |
||
136 | 136 | /** |
137 | 137 | * Load file |
138 | 138 | */ |
139 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-background-updater.php'; |
|
140 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php'; |
|
139 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-background-updater.php'; |
|
140 | + require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrade-functions.php'; |
|
141 | 141 | |
142 | 142 | self::$background_updater = new Give_Background_Updater(); |
143 | 143 | |
144 | 144 | /** |
145 | 145 | * Setup hooks. |
146 | 146 | */ |
147 | - add_action( 'init', array( $this, '__register_upgrade' ), 9999 ); |
|
148 | - add_action( 'give_set_upgrade_completed', array( $this, '__flush_resume_updates' ), 9999 ); |
|
149 | - add_action( 'wp_ajax_give_db_updates_info', array( $this, '__give_db_updates_info' ) ); |
|
150 | - add_action( 'wp_ajax_give_run_db_updates', array( $this, '__give_start_updating' ) ); |
|
151 | - add_action( 'admin_init', array( $this, '__redirect_admin' ) ); |
|
152 | - add_action( 'admin_init', array( $this, '__pause_db_update' ), - 1 ); |
|
153 | - add_action( 'admin_init', array( $this, '__restart_db_update' ), - 1 ); |
|
154 | - add_action( 'admin_notices', array( $this, '__show_notice' ) ); |
|
155 | - add_action( 'give_restart_db_upgrade', array( $this, '__health_background_update' ) ); |
|
156 | - |
|
157 | - if ( is_admin() ) { |
|
158 | - add_action( 'admin_init', array( $this, '__change_donations_label' ), 9999 ); |
|
159 | - add_action( 'admin_menu', array( $this, '__register_menu' ), 9999 ); |
|
147 | + add_action('init', array($this, '__register_upgrade'), 9999); |
|
148 | + add_action('give_set_upgrade_completed', array($this, '__flush_resume_updates'), 9999); |
|
149 | + add_action('wp_ajax_give_db_updates_info', array($this, '__give_db_updates_info')); |
|
150 | + add_action('wp_ajax_give_run_db_updates', array($this, '__give_start_updating')); |
|
151 | + add_action('admin_init', array($this, '__redirect_admin')); |
|
152 | + add_action('admin_init', array($this, '__pause_db_update'), - 1); |
|
153 | + add_action('admin_init', array($this, '__restart_db_update'), - 1); |
|
154 | + add_action('admin_notices', array($this, '__show_notice')); |
|
155 | + add_action('give_restart_db_upgrade', array($this, '__health_background_update')); |
|
156 | + |
|
157 | + if (is_admin()) { |
|
158 | + add_action('admin_init', array($this, '__change_donations_label'), 9999); |
|
159 | + add_action('admin_menu', array($this, '__register_menu'), 9999); |
|
160 | 160 | } |
161 | 161 | } |
162 | 162 | |
@@ -170,12 +170,12 @@ discard block |
||
170 | 170 | $addons = give_get_plugins(); |
171 | 171 | $plugin_updates = get_plugin_updates(); |
172 | 172 | |
173 | - foreach ( $addons as $key => $info ) { |
|
174 | - if ( 'active' != $info['Status'] || 'add-on' != $info['Type'] || empty( $plugin_updates[ $key ] ) ) { |
|
173 | + foreach ($addons as $key => $info) { |
|
174 | + if ('active' != $info['Status'] || 'add-on' != $info['Type'] || empty($plugin_updates[$key])) { |
|
175 | 175 | continue; |
176 | 176 | } |
177 | 177 | |
178 | - $this->updates['plugin'][] = array_merge( $info, (array) $plugin_updates[ $key ] ); |
|
178 | + $this->updates['plugin'][] = array_merge($info, (array) $plugin_updates[$key]); |
|
179 | 179 | } |
180 | 180 | } |
181 | 181 | |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | * @access public |
188 | 188 | */ |
189 | 189 | public function __register_upgrade() { |
190 | - if ( ! is_admin() ) { |
|
190 | + if ( ! is_admin()) { |
|
191 | 191 | return; |
192 | 192 | } |
193 | 193 | |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | * |
197 | 197 | * @since 1.8.12 |
198 | 198 | */ |
199 | - do_action( 'give_register_updates', $this ); |
|
199 | + do_action('give_register_updates', $this); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | /** |
@@ -209,23 +209,22 @@ discard block |
||
209 | 209 | global $menu; |
210 | 210 | |
211 | 211 | // Bailout. |
212 | - if ( empty( $menu ) || ! $this->get_total_update_count() ) { |
|
212 | + if (empty($menu) || ! $this->get_total_update_count()) { |
|
213 | 213 | return; |
214 | 214 | } |
215 | 215 | |
216 | - $is_update = ( $this->is_doing_updates() && ! self::$background_updater->is_paused_process() ); |
|
216 | + $is_update = ($this->is_doing_updates() && ! self::$background_updater->is_paused_process()); |
|
217 | 217 | |
218 | - foreach ( $menu as $index => $menu_item ) { |
|
219 | - if ( 'edit.php?post_type=give_forms' !== $menu_item[2] ) { |
|
218 | + foreach ($menu as $index => $menu_item) { |
|
219 | + if ('edit.php?post_type=give_forms' !== $menu_item[2]) { |
|
220 | 220 | continue; |
221 | 221 | } |
222 | 222 | |
223 | - $menu[ $index ][0] = sprintf( |
|
223 | + $menu[$index][0] = sprintf( |
|
224 | 224 | '%1$s <span class="update-plugins"><span class="plugin-count give-update-progress-count">%2$s%3$s</span></span>', |
225 | - __( 'Donations', 'give' ), |
|
225 | + __('Donations', 'give'), |
|
226 | 226 | $is_update ? |
227 | - $this->get_db_update_processing_percentage() : |
|
228 | - $this->get_total_update_count(), |
|
227 | + $this->get_db_update_processing_percentage() : $this->get_total_update_count(), |
|
229 | 228 | $is_update ? '%' : '' |
230 | 229 | ); |
231 | 230 | |
@@ -241,7 +240,7 @@ discard block |
||
241 | 240 | */ |
242 | 241 | public function __register_menu() { |
243 | 242 | // Bailout. |
244 | - if ( ! give_test_ajax_works() ) { |
|
243 | + if ( ! give_test_ajax_works()) { |
|
245 | 244 | return; |
246 | 245 | } |
247 | 246 | |
@@ -249,41 +248,40 @@ discard block |
||
249 | 248 | $this->__register_plugin_addon_updates(); |
250 | 249 | |
251 | 250 | // Bailout. |
252 | - if ( ! $this->get_total_update_count() ) { |
|
251 | + if ( ! $this->get_total_update_count()) { |
|
253 | 252 | // Show complete update message if still on update setting page. |
254 | - if ( isset( $_GET['page'] ) && 'give-updates' === $_GET['page'] ) { |
|
253 | + if (isset($_GET['page']) && 'give-updates' === $_GET['page']) { |
|
255 | 254 | // Upgrades |
256 | 255 | add_submenu_page( |
257 | 256 | 'edit.php?post_type=give_forms', |
258 | - esc_html__( 'Give Updates Complete', 'give' ), |
|
259 | - __( 'Updates', 'give' ), |
|
257 | + esc_html__('Give Updates Complete', 'give'), |
|
258 | + __('Updates', 'give'), |
|
260 | 259 | 'manage_give_settings', |
261 | 260 | 'give-updates', |
262 | - array( $this, 'render_complete_page' ) |
|
261 | + array($this, 'render_complete_page') |
|
263 | 262 | ); |
264 | 263 | } |
265 | 264 | |
266 | 265 | return; |
267 | 266 | } |
268 | 267 | |
269 | - $is_update = ( $this->is_doing_updates() && ! self::$background_updater->is_paused_process() ); |
|
268 | + $is_update = ($this->is_doing_updates() && ! self::$background_updater->is_paused_process()); |
|
270 | 269 | |
271 | 270 | // Upgrades |
272 | 271 | add_submenu_page( |
273 | 272 | 'edit.php?post_type=give_forms', |
274 | - esc_html__( 'Give Updates', 'give' ), |
|
273 | + esc_html__('Give Updates', 'give'), |
|
275 | 274 | sprintf( |
276 | 275 | '%1$s <span class="update-plugins"%2$s><span class="plugin-count give-update-progress-count">%3$s%4$s</span></span>', |
277 | - __( 'Updates', 'give' ), |
|
278 | - isset( $_GET['give-pause-db-upgrades'] ) ? ' style="display:none;"' : '', |
|
276 | + __('Updates', 'give'), |
|
277 | + isset($_GET['give-pause-db-upgrades']) ? ' style="display:none;"' : '', |
|
279 | 278 | $is_update ? |
280 | - $this->get_db_update_processing_percentage() : |
|
281 | - $this->get_total_update_count(), |
|
279 | + $this->get_db_update_processing_percentage() : $this->get_total_update_count(), |
|
282 | 280 | $is_update ? '%' : '' |
283 | 281 | ), |
284 | 282 | 'manage_give_settings', |
285 | 283 | 'give-updates', |
286 | - array( $this, 'render_page' ) |
|
284 | + array($this, 'render_page') |
|
287 | 285 | ); |
288 | 286 | } |
289 | 287 | |
@@ -298,13 +296,13 @@ discard block |
||
298 | 296 | // Show db upgrade completed notice. |
299 | 297 | if ( |
300 | 298 | ! wp_doing_ajax() && |
301 | - current_user_can( 'manage_give_settings' ) && |
|
302 | - get_option( 'give_show_db_upgrade_complete_notice' ) && |
|
303 | - ! isset( $_GET['give-db-update-completed'] ) |
|
299 | + current_user_can('manage_give_settings') && |
|
300 | + get_option('give_show_db_upgrade_complete_notice') && |
|
301 | + ! isset($_GET['give-db-update-completed']) |
|
304 | 302 | ) { |
305 | - delete_option( 'give_show_db_upgrade_complete_notice' ); |
|
303 | + delete_option('give_show_db_upgrade_complete_notice'); |
|
306 | 304 | |
307 | - wp_redirect( add_query_arg( array( 'give-db-update-completed' => 'give_db_upgrade_completed' ) ) ); |
|
305 | + wp_redirect(add_query_arg(array('give-db-update-completed' => 'give_db_upgrade_completed'))); |
|
308 | 306 | exit(); |
309 | 307 | } |
310 | 308 | } |
@@ -320,15 +318,15 @@ discard block |
||
320 | 318 | * |
321 | 319 | * @return bool |
322 | 320 | */ |
323 | - public function __pause_db_update( $force = false ) { |
|
321 | + public function __pause_db_update($force = false) { |
|
324 | 322 | // Bailout. |
325 | 323 | if ( |
326 | 324 | ! $force && |
327 | 325 | ( |
328 | 326 | wp_doing_ajax() || |
329 | - ! isset( $_GET['page'] ) || |
|
327 | + ! isset($_GET['page']) || |
|
330 | 328 | 'give-updates' !== $_GET['page'] || |
331 | - ! isset( $_GET['give-pause-db-upgrades'] ) || |
|
329 | + ! isset($_GET['give-pause-db-upgrades']) || |
|
332 | 330 | self::$background_updater->is_paused_process() |
333 | 331 | ) |
334 | 332 | |
@@ -336,13 +334,13 @@ discard block |
||
336 | 334 | return false; |
337 | 335 | } |
338 | 336 | |
339 | - delete_option( 'give_upgrade_error' ); |
|
337 | + delete_option('give_upgrade_error'); |
|
340 | 338 | |
341 | - $this->__health_background_update( $this ); |
|
339 | + $this->__health_background_update($this); |
|
342 | 340 | $batch = self::$background_updater->get_all_batch(); |
343 | 341 | |
344 | 342 | // Bailout: if batch is empty |
345 | - if ( empty( $batch->data ) ) { |
|
343 | + if (empty($batch->data)) { |
|
346 | 344 | return false; |
347 | 345 | } |
348 | 346 | |
@@ -351,25 +349,25 @@ discard block |
||
351 | 349 | |
352 | 350 | // Do not stop background process immediately if task running. |
353 | 351 | // @see Give_Background_Updater::lock_process |
354 | - if ( ! $force && self::$background_updater->is_process_running() ) { |
|
355 | - update_option( 'give_pause_upgrade', 1 ); |
|
352 | + if ( ! $force && self::$background_updater->is_process_running()) { |
|
353 | + update_option('give_pause_upgrade', 1); |
|
356 | 354 | |
357 | 355 | return true; |
358 | 356 | } |
359 | 357 | |
360 | - update_option( 'give_paused_batches', $batch, 'no' ); |
|
361 | - delete_option( $batch->key ); |
|
362 | - delete_site_transient( self::$background_updater->get_identifier() . '_process_lock' ); |
|
363 | - wp_clear_scheduled_hook( self::$background_updater->get_cron_identifier() ); |
|
358 | + update_option('give_paused_batches', $batch, 'no'); |
|
359 | + delete_option($batch->key); |
|
360 | + delete_site_transient(self::$background_updater->get_identifier().'_process_lock'); |
|
361 | + wp_clear_scheduled_hook(self::$background_updater->get_cron_identifier()); |
|
364 | 362 | |
365 | - Give()->logs->add( 'Update Pause', print_r( $batch, true ), 0, 'update' ); |
|
363 | + Give()->logs->add('Update Pause', print_r($batch, true), 0, 'update'); |
|
366 | 364 | |
367 | 365 | /** |
368 | 366 | * Fire action when pause db updates |
369 | 367 | * |
370 | 368 | * @since 2.0.1 |
371 | 369 | */ |
372 | - do_action( 'give_pause_db_upgrade', $this ); |
|
370 | + do_action('give_pause_db_upgrade', $this); |
|
373 | 371 | |
374 | 372 | return true; |
375 | 373 | } |
@@ -386,31 +384,31 @@ discard block |
||
386 | 384 | // Bailout. |
387 | 385 | if ( |
388 | 386 | wp_doing_ajax() || |
389 | - ! isset( $_GET['page'] ) || |
|
387 | + ! isset($_GET['page']) || |
|
390 | 388 | 'give-updates' !== $_GET['page'] || |
391 | - ! isset( $_GET['give-restart-db-upgrades'] ) || |
|
389 | + ! isset($_GET['give-restart-db-upgrades']) || |
|
392 | 390 | ! self::$background_updater->is_paused_process() |
393 | 391 | ) { |
394 | 392 | return false; |
395 | 393 | } |
396 | 394 | |
397 | 395 | Give_Background_Updater::flush_cache(); |
398 | - $batch = get_option( 'give_paused_batches' ); |
|
396 | + $batch = get_option('give_paused_batches'); |
|
399 | 397 | |
400 | - if ( ! empty( $batch ) ) { |
|
401 | - wp_cache_delete( $batch->key, 'options' ); |
|
402 | - update_option( $batch->key, $batch->data ); |
|
398 | + if ( ! empty($batch)) { |
|
399 | + wp_cache_delete($batch->key, 'options'); |
|
400 | + update_option($batch->key, $batch->data); |
|
403 | 401 | |
404 | - delete_option( 'give_paused_batches' ); |
|
402 | + delete_option('give_paused_batches'); |
|
405 | 403 | |
406 | - Give()->logs->add( 'Update Restart', print_r( $batch, true ), 0, 'update' ); |
|
404 | + Give()->logs->add('Update Restart', print_r($batch, true), 0, 'update'); |
|
407 | 405 | |
408 | 406 | |
409 | 407 | /** Fire action when restart db updates |
410 | 408 | * |
411 | 409 | * @since 2.0.1 |
412 | 410 | */ |
413 | - do_action( 'give_restart_db_upgrade', $this ); |
|
411 | + do_action('give_restart_db_upgrade', $this); |
|
414 | 412 | |
415 | 413 | self::$background_updater->dispatch(); |
416 | 414 | } |
@@ -426,53 +424,53 @@ discard block |
||
426 | 424 | * |
427 | 425 | * @param Give_Updates $give_updates |
428 | 426 | */ |
429 | - public function __health_background_update( $give_updates ) { |
|
430 | - if ( ! $this->is_doing_updates() ) { |
|
427 | + public function __health_background_update($give_updates) { |
|
428 | + if ( ! $this->is_doing_updates()) { |
|
431 | 429 | return; |
432 | 430 | } |
433 | 431 | |
434 | 432 | Give_Background_Updater::flush_cache(); |
435 | 433 | |
436 | 434 | $batch = Give_Updates::$background_updater->get_all_batch(); |
437 | - $batch_data_count = count( $batch->data ); |
|
438 | - $all_updates = $give_updates->get_updates( 'database', 'all' ); |
|
439 | - $all_update_ids = wp_list_pluck( $all_updates, 'id' ); |
|
440 | - $all_batch_update_ids = ! empty( $batch->data ) ? wp_list_pluck( $batch->data, 'id' ) : array(); |
|
435 | + $batch_data_count = count($batch->data); |
|
436 | + $all_updates = $give_updates->get_updates('database', 'all'); |
|
437 | + $all_update_ids = wp_list_pluck($all_updates, 'id'); |
|
438 | + $all_batch_update_ids = ! empty($batch->data) ? wp_list_pluck($batch->data, 'id') : array(); |
|
441 | 439 | $log_data = ''; |
442 | - $doing_upgrade_args = get_option( 'give_doing_upgrade' ); |
|
440 | + $doing_upgrade_args = get_option('give_doing_upgrade'); |
|
443 | 441 | |
444 | - if ( ! empty( $doing_upgrade_args ) ) { |
|
445 | - $log_data .= 'Doing update:' . "\n"; |
|
446 | - $log_data .= print_r( $doing_upgrade_args, true ) . "\n"; |
|
442 | + if ( ! empty($doing_upgrade_args)) { |
|
443 | + $log_data .= 'Doing update:'."\n"; |
|
444 | + $log_data .= print_r($doing_upgrade_args, true)."\n"; |
|
447 | 445 | } |
448 | 446 | |
449 | 447 | /** |
450 | 448 | * Add remove upgrade from batch |
451 | 449 | */ |
452 | - if ( ! empty( $batch->data ) ) { |
|
450 | + if ( ! empty($batch->data)) { |
|
453 | 451 | |
454 | - foreach ( $batch->data as $index => $update ) { |
|
455 | - $log_data = print_r( $update, true ) . "\n"; |
|
452 | + foreach ($batch->data as $index => $update) { |
|
453 | + $log_data = print_r($update, true)."\n"; |
|
456 | 454 | |
457 | - if ( ! is_callable( $update['callback'] ) ) { |
|
458 | - $log_data .= 'Removing missing callback update: ' . "{$update['id']}\n"; |
|
459 | - unset( $batch->data[ $index ] ); |
|
460 | - } elseif ( give_has_upgrade_completed( $update['id'] ) ) { |
|
461 | - $log_data .= 'Removing already completed update: ' . "{$update['id']}\n"; |
|
462 | - unset( $batch->data[ $index ] ); |
|
455 | + if ( ! is_callable($update['callback'])) { |
|
456 | + $log_data .= 'Removing missing callback update: '."{$update['id']}\n"; |
|
457 | + unset($batch->data[$index]); |
|
458 | + } elseif (give_has_upgrade_completed($update['id'])) { |
|
459 | + $log_data .= 'Removing already completed update: '."{$update['id']}\n"; |
|
460 | + unset($batch->data[$index]); |
|
463 | 461 | } |
464 | 462 | |
465 | - if ( ! empty( $update['depend'] ) ) { |
|
463 | + if ( ! empty($update['depend'])) { |
|
466 | 464 | |
467 | - foreach ( $update['depend'] as $depend ) { |
|
468 | - if ( give_has_upgrade_completed( $depend ) ) { |
|
469 | - $log_data .= 'Completed update: ' . "{$depend}\n"; |
|
465 | + foreach ($update['depend'] as $depend) { |
|
466 | + if (give_has_upgrade_completed($depend)) { |
|
467 | + $log_data .= 'Completed update: '."{$depend}\n"; |
|
470 | 468 | continue; |
471 | 469 | } |
472 | 470 | |
473 | - if ( in_array( $depend, $all_update_ids ) && ! in_array( $depend, $all_batch_update_ids ) ) { |
|
474 | - $log_data .= 'Adding missing update: ' . "{$depend}\n"; |
|
475 | - array_unshift( $batch->data, $all_updates[ array_search( $depend, $all_update_ids ) ] ); |
|
471 | + if (in_array($depend, $all_update_ids) && ! in_array($depend, $all_batch_update_ids)) { |
|
472 | + $log_data .= 'Adding missing update: '."{$depend}\n"; |
|
473 | + array_unshift($batch->data, $all_updates[array_search($depend, $all_update_ids)]); |
|
476 | 474 | } |
477 | 475 | } |
478 | 476 | } |
@@ -482,63 +480,63 @@ discard block |
||
482 | 480 | /** |
483 | 481 | * Add new upgrade to batch |
484 | 482 | */ |
485 | - if ( $new_updates = $this->get_updates( 'database', 'new' ) ) { |
|
486 | - $all_batch_update_ids = ! empty( $batch->data ) ? wp_list_pluck( $batch->data, 'id' ) : array(); |
|
483 | + if ($new_updates = $this->get_updates('database', 'new')) { |
|
484 | + $all_batch_update_ids = ! empty($batch->data) ? wp_list_pluck($batch->data, 'id') : array(); |
|
487 | 485 | |
488 | - foreach ( $new_updates as $index => $new_update ) { |
|
489 | - if ( give_has_upgrade_completed( $new_update['id'] ) || in_array( $new_update['id'], $all_batch_update_ids ) ) { |
|
490 | - unset( $new_updates[ $index ] ); |
|
486 | + foreach ($new_updates as $index => $new_update) { |
|
487 | + if (give_has_upgrade_completed($new_update['id']) || in_array($new_update['id'], $all_batch_update_ids)) { |
|
488 | + unset($new_updates[$index]); |
|
491 | 489 | } |
492 | 490 | } |
493 | 491 | |
494 | - if ( ! empty( $new_updates ) ) { |
|
495 | - $log_data .= 'Adding new update: ' . "\n"; |
|
496 | - $log_data .= print_r( $new_updates, true ) . "\n"; |
|
492 | + if ( ! empty($new_updates)) { |
|
493 | + $log_data .= 'Adding new update: '."\n"; |
|
494 | + $log_data .= print_r($new_updates, true)."\n"; |
|
497 | 495 | |
498 | - $batch->data = array_merge( (array) $batch->data, $new_updates ); |
|
499 | - update_option( 'give_db_update_count', ( absint( get_option( 'give_db_update_count' ) ) + count( $new_updates ) ) ); |
|
496 | + $batch->data = array_merge((array) $batch->data, $new_updates); |
|
497 | + update_option('give_db_update_count', (absint(get_option('give_db_update_count')) + count($new_updates))); |
|
500 | 498 | } |
501 | 499 | } |
502 | 500 | |
503 | 501 | /** |
504 | 502 | * Fix batch |
505 | 503 | */ |
506 | - if ( empty( $batch->data ) ) { |
|
504 | + if (empty($batch->data)) { |
|
507 | 505 | // Complete batch if do not have any data to process. |
508 | - self::$background_updater->delete( $batch->key ); |
|
506 | + self::$background_updater->delete($batch->key); |
|
509 | 507 | |
510 | - if ( self::$background_updater->has_queue() ) { |
|
511 | - $this->__health_background_update( $this ); |
|
508 | + if (self::$background_updater->has_queue()) { |
|
509 | + $this->__health_background_update($this); |
|
512 | 510 | } else { |
513 | - delete_site_transient( self::$background_updater->get_identifier() . '_process_lock' ); |
|
514 | - wp_clear_scheduled_hook( self::$background_updater->get_cron_identifier() ); |
|
511 | + delete_site_transient(self::$background_updater->get_identifier().'_process_lock'); |
|
512 | + wp_clear_scheduled_hook(self::$background_updater->get_cron_identifier()); |
|
515 | 513 | |
516 | 514 | self::$background_updater->complete(); |
517 | 515 | } |
518 | 516 | |
519 | - } elseif ( $batch_data_count !== count( $batch->data ) ) { |
|
517 | + } elseif ($batch_data_count !== count($batch->data)) { |
|
520 | 518 | |
521 | - $log_data .= 'Updating batch' . "\n"; |
|
522 | - $log_data .= print_r( $batch, true ); |
|
519 | + $log_data .= 'Updating batch'."\n"; |
|
520 | + $log_data .= print_r($batch, true); |
|
523 | 521 | |
524 | - $doing_upgrade_args['heading'] = sprintf( 'Update %s of %s', $doing_upgrade_args['update'], get_option( 'give_db_update_count' ) ); |
|
522 | + $doing_upgrade_args['heading'] = sprintf('Update %s of %s', $doing_upgrade_args['update'], get_option('give_db_update_count')); |
|
525 | 523 | $doing_upgrade_args['total_percentage'] = $this->get_db_update_processing_percentage(); |
526 | - update_option( 'give_doing_upgrade', $doing_upgrade_args ); |
|
524 | + update_option('give_doing_upgrade', $doing_upgrade_args); |
|
527 | 525 | |
528 | - if ( ! empty( $batch->key ) ) { |
|
529 | - wp_cache_delete( $batch->key, 'options' ); |
|
530 | - update_option( $batch->key, $batch->data ); |
|
526 | + if ( ! empty($batch->key)) { |
|
527 | + wp_cache_delete($batch->key, 'options'); |
|
528 | + update_option($batch->key, $batch->data); |
|
531 | 529 | } else { |
532 | 530 | |
533 | - update_option( 'give_db_update_count', count( $batch->data ) ); |
|
531 | + update_option('give_db_update_count', count($batch->data)); |
|
534 | 532 | |
535 | 533 | $doing_upgrade_args['update'] = $give_updates->update; |
536 | - $doing_upgrade_args['heading'] = sprintf( 'Update %s of %s', 1, count( $batch->data ) ); |
|
534 | + $doing_upgrade_args['heading'] = sprintf('Update %s of %s', 1, count($batch->data)); |
|
537 | 535 | |
538 | - update_option( 'give_doing_upgrade', $doing_upgrade_args ); |
|
536 | + update_option('give_doing_upgrade', $doing_upgrade_args); |
|
539 | 537 | |
540 | - foreach ( $batch->data as $data ) { |
|
541 | - Give_Updates::$background_updater->push_to_queue( $data ); |
|
538 | + foreach ($batch->data as $data) { |
|
539 | + Give_Updates::$background_updater->push_to_queue($data); |
|
542 | 540 | } |
543 | 541 | |
544 | 542 | Give_Updates::$background_updater->save(); |
@@ -550,27 +548,27 @@ discard block |
||
550 | 548 | * Fix give_doing_upgrade option |
551 | 549 | */ |
552 | 550 | $update_option = false; |
553 | - $fresh_new_db_count = $this->get_total_new_db_update_count( true ); |
|
554 | - if ( $fresh_new_db_count < $doing_upgrade_args['update'] ) { |
|
555 | - update_option( 'give_db_update_count', $fresh_new_db_count ); |
|
551 | + $fresh_new_db_count = $this->get_total_new_db_update_count(true); |
|
552 | + if ($fresh_new_db_count < $doing_upgrade_args['update']) { |
|
553 | + update_option('give_db_update_count', $fresh_new_db_count); |
|
556 | 554 | $doing_upgrade_args['update'] = 1; |
557 | - $doing_upgrade_args['heading'] = sprintf( 'Update %s of %s', 1, $fresh_new_db_count ); |
|
555 | + $doing_upgrade_args['heading'] = sprintf('Update %s of %s', 1, $fresh_new_db_count); |
|
558 | 556 | $update_option = true; |
559 | 557 | } |
560 | 558 | |
561 | - if ( 101 < $doing_upgrade_args['total_percentage'] ) { |
|
562 | - $doing_upgrade_args['total_percentage'] = $this->get_db_update_processing_percentage( true ); |
|
559 | + if (101 < $doing_upgrade_args['total_percentage']) { |
|
560 | + $doing_upgrade_args['total_percentage'] = $this->get_db_update_processing_percentage(true); |
|
563 | 561 | $update_option = true; |
564 | 562 | } |
565 | 563 | |
566 | - if ( $update_option ) { |
|
567 | - update_option( 'give_doing_upgrade', $doing_upgrade_args ); |
|
564 | + if ($update_option) { |
|
565 | + update_option('give_doing_upgrade', $doing_upgrade_args); |
|
568 | 566 | |
569 | - $log_data .= 'Updated doing update:' . "\n"; |
|
570 | - $log_data .= print_r( $doing_upgrade_args, true ) . "\n"; |
|
567 | + $log_data .= 'Updated doing update:'."\n"; |
|
568 | + $log_data .= print_r($doing_upgrade_args, true)."\n"; |
|
571 | 569 | } |
572 | 570 | |
573 | - Give()->logs->add( 'Update Health Check', $log_data, 0, 'update' ); |
|
571 | + Give()->logs->add('Update Health Check', $log_data, 0, 'update'); |
|
574 | 572 | } |
575 | 573 | |
576 | 574 | |
@@ -582,66 +580,66 @@ discard block |
||
582 | 580 | */ |
583 | 581 | public function __show_notice() { |
584 | 582 | // Bailout. |
585 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
583 | + if ( ! current_user_can('manage_give_settings')) { |
|
586 | 584 | return; |
587 | 585 | } |
588 | 586 | |
589 | 587 | // Run DB updates. |
590 | - if ( ! empty( $_GET['give-run-db-update'] ) ) { |
|
588 | + if ( ! empty($_GET['give-run-db-update'])) { |
|
591 | 589 | $this->run_db_update(); |
592 | 590 | } |
593 | 591 | |
594 | 592 | |
595 | 593 | // Bailout. |
596 | - if ( isset( $_GET['page'] ) && 'give-updates' === $_GET['page'] ) { |
|
594 | + if (isset($_GET['page']) && 'give-updates' === $_GET['page']) { |
|
597 | 595 | return; |
598 | 596 | } |
599 | 597 | |
600 | 598 | // Show notice if upgrade paused. |
601 | - if ( self::$background_updater->is_paused_process() ) { |
|
599 | + if (self::$background_updater->is_paused_process()) { |
|
602 | 600 | ob_start(); |
603 | 601 | |
604 | - $upgrade_error = get_option( 'give_upgrade_error' ); |
|
605 | - if ( ! $upgrade_error ) : ?> |
|
606 | - <strong><?php _e( 'Database Update', 'give' ); ?></strong> |
|
607 | - – <?php _e( 'GiveWP needs to update your database to the latest version. The following process will make updates to your site\'s database. Please create a backup before proceeding.', 'give' ); ?> |
|
602 | + $upgrade_error = get_option('give_upgrade_error'); |
|
603 | + if ( ! $upgrade_error) : ?> |
|
604 | + <strong><?php _e('Database Update', 'give'); ?></strong> |
|
605 | + – <?php _e('GiveWP needs to update your database to the latest version. The following process will make updates to your site\'s database. Please create a backup before proceeding.', 'give'); ?> |
|
608 | 606 | <br> |
609 | 607 | <br> |
610 | - <a href="<?php echo esc_url( add_query_arg( array( 'give-restart-db-upgrades' => 1 ), admin_url( 'edit.php?post_type=give_forms&page=give-updates' ) ) ); ?>" class="button button-primary give-restart-updater-btn"> |
|
611 | - <?php _e( 'Restart the updater', 'give' ); ?> |
|
608 | + <a href="<?php echo esc_url(add_query_arg(array('give-restart-db-upgrades' => 1), admin_url('edit.php?post_type=give_forms&page=give-updates'))); ?>" class="button button-primary give-restart-updater-btn"> |
|
609 | + <?php _e('Restart the updater', 'give'); ?> |
|
612 | 610 | </a> |
613 | 611 | <script type="text/javascript"> |
614 | 612 | jQuery('.give-restart-updater-btn').click('click', function () { |
615 | - return window.confirm('<?php echo esc_js( __( 'It is recommended that you backup your database before proceeding. Do you want to run the update now?', 'give' ) ); ?>'); // jshint ignore:line |
|
613 | + return window.confirm('<?php echo esc_js(__('It is recommended that you backup your database before proceeding. Do you want to run the update now?', 'give')); ?>'); // jshint ignore:line |
|
616 | 614 | }); |
617 | 615 | </script> |
618 | 616 | <?php else: ?> |
619 | - <strong><?php _e( 'Database Update', 'give' ); ?></strong> |
|
620 | - – <?php _e( 'An unexpected issue occurred during the database update which caused it to stop automatically. Please contact support for assistance.', 'give' ); ?> |
|
617 | + <strong><?php _e('Database Update', 'give'); ?></strong> |
|
618 | + – <?php _e('An unexpected issue occurred during the database update which caused it to stop automatically. Please contact support for assistance.', 'give'); ?> |
|
621 | 619 | <?php |
622 | 620 | endif; |
623 | 621 | $desc_html = ob_get_clean(); |
624 | 622 | |
625 | - Give()->notices->register_notice( array( |
|
623 | + Give()->notices->register_notice(array( |
|
626 | 624 | 'id' => 'give_upgrade_db', |
627 | 625 | 'type' => 'error', |
628 | 626 | 'dismissible' => false, |
629 | 627 | 'description' => $desc_html, |
630 | - ) ); |
|
628 | + )); |
|
631 | 629 | } |
632 | 630 | |
633 | 631 | // Bailout if doing upgrades. |
634 | - if ( $this->is_doing_updates() ) { |
|
632 | + if ($this->is_doing_updates()) { |
|
635 | 633 | return; |
636 | 634 | } |
637 | 635 | |
638 | 636 | // Show notice if ajax is not working. |
639 | - if ( ! give_test_ajax_works() ) { |
|
637 | + if ( ! give_test_ajax_works()) { |
|
640 | 638 | Give()->notices->register_notice( |
641 | 639 | array( |
642 | 640 | 'id' => 'give_db_upgrade_ajax_inaccessible', |
643 | 641 | 'type' => 'error', |
644 | - 'description' => sprintf( '%1$s <a href="%2$s" target="_blank">%3$s</a>', __( 'Give needs to upgrade the database but cannot because AJAX does not appear accessible. This could be because your website is password protected, in maintenance mode, or has a specific hosting configuration or plugin active that is preventing access.', 'give' ), 'http://docs.givewp.com/admin-ajax-error', __( 'Read More', 'give' ) . ' »' ), |
|
642 | + 'description' => sprintf('%1$s <a href="%2$s" target="_blank">%3$s</a>', __('Give needs to upgrade the database but cannot because AJAX does not appear accessible. This could be because your website is password protected, in maintenance mode, or has a specific hosting configuration or plugin active that is preventing access.', 'give'), 'http://docs.givewp.com/admin-ajax-error', __('Read More', 'give').' »'), |
|
645 | 643 | 'show' => true, |
646 | 644 | ) |
647 | 645 | ); |
@@ -650,45 +648,45 @@ discard block |
||
650 | 648 | } |
651 | 649 | |
652 | 650 | // Show db upgrade completed notice. |
653 | - if ( ! empty( $_GET['give-db-update-completed'] ) ) { |
|
654 | - Give()->notices->register_notice( array( |
|
651 | + if ( ! empty($_GET['give-db-update-completed'])) { |
|
652 | + Give()->notices->register_notice(array( |
|
655 | 653 | 'id' => 'give_db_upgrade_completed', |
656 | 654 | 'type' => 'updated', |
657 | - 'description' => __( 'Give database updates completed successfully. Thank you for updating to the latest version!', 'give' ), |
|
655 | + 'description' => __('Give database updates completed successfully. Thank you for updating to the latest version!', 'give'), |
|
658 | 656 | 'show' => true, |
659 | - ) ); |
|
657 | + )); |
|
660 | 658 | |
661 | 659 | // Start update. |
662 | - } elseif ( ! empty( $_GET['give-run-db-update'] ) ) { |
|
660 | + } elseif ( ! empty($_GET['give-run-db-update'])) { |
|
663 | 661 | $this->run_db_update(); |
664 | 662 | |
665 | 663 | // Show run the update notice. |
666 | - } elseif ( $this->get_total_new_db_update_count() ) { |
|
664 | + } elseif ($this->get_total_new_db_update_count()) { |
|
667 | 665 | ob_start(); |
668 | 666 | ?> |
669 | 667 | <p> |
670 | - <strong><?php _e( 'Database Update', 'give' ); ?></strong> |
|
671 | - – <?php _e( 'GiveWP needs to update your database to the latest version. The following process will make updates to your site\'s database. Please create a complete backup before proceeding.', 'give' ); ?> |
|
668 | + <strong><?php _e('Database Update', 'give'); ?></strong> |
|
669 | + – <?php _e('GiveWP needs to update your database to the latest version. The following process will make updates to your site\'s database. Please create a complete backup before proceeding.', 'give'); ?> |
|
672 | 670 | </p> |
673 | 671 | <p class="submit"> |
674 | - <a href="<?php echo esc_url( add_query_arg( array( 'give-run-db-update' => 1 ), admin_url( 'edit.php?post_type=give_forms&page=give-updates' ) ) ); ?>" class="button button-primary give-run-update-now"> |
|
675 | - <?php _e( 'Run the updater', 'give' ); ?> |
|
672 | + <a href="<?php echo esc_url(add_query_arg(array('give-run-db-update' => 1), admin_url('edit.php?post_type=give_forms&page=give-updates'))); ?>" class="button button-primary give-run-update-now"> |
|
673 | + <?php _e('Run the updater', 'give'); ?> |
|
676 | 674 | </a> |
677 | 675 | </p> |
678 | 676 | <script type="text/javascript"> |
679 | 677 | jQuery('.give-run-update-now').click('click', function () { |
680 | - return window.confirm('<?php echo esc_js( __( 'It is recommended that you backup your database before proceeding. Do you want to run the update now?', 'give' ) ); ?>'); // jshint ignore:line |
|
678 | + return window.confirm('<?php echo esc_js(__('It is recommended that you backup your database before proceeding. Do you want to run the update now?', 'give')); ?>'); // jshint ignore:line |
|
681 | 679 | }); |
682 | 680 | </script> |
683 | 681 | <?php |
684 | 682 | $desc_html = ob_get_clean(); |
685 | 683 | |
686 | - Give()->notices->register_notice( array( |
|
684 | + Give()->notices->register_notice(array( |
|
687 | 685 | 'id' => 'give_upgrade_db', |
688 | 686 | 'type' => 'updated', |
689 | 687 | 'dismissible' => false, |
690 | 688 | 'description' => $desc_html, |
691 | - ) ); |
|
689 | + )); |
|
692 | 690 | } |
693 | 691 | } |
694 | 692 | |
@@ -699,7 +697,7 @@ discard block |
||
699 | 697 | * @access public |
700 | 698 | */ |
701 | 699 | public function render_complete_page() { |
702 | - include_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/views/upgrades-complete.php'; |
|
700 | + include_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/views/upgrades-complete.php'; |
|
703 | 701 | } |
704 | 702 | |
705 | 703 | /** |
@@ -709,7 +707,7 @@ discard block |
||
709 | 707 | * @access public |
710 | 708 | */ |
711 | 709 | public function render_page() { |
712 | - include_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/views/upgrades.php'; |
|
710 | + include_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/views/upgrades.php'; |
|
713 | 711 | } |
714 | 712 | |
715 | 713 | /** |
@@ -720,26 +718,26 @@ discard block |
||
720 | 718 | */ |
721 | 719 | private function run_db_update() { |
722 | 720 | // Bailout. |
723 | - if ( $this->is_doing_updates() || ! $this->get_total_new_db_update_count() ) { |
|
721 | + if ($this->is_doing_updates() || ! $this->get_total_new_db_update_count()) { |
|
724 | 722 | return; |
725 | 723 | } |
726 | 724 | |
727 | - $updates = $this->get_updates( 'database', 'new' ); |
|
725 | + $updates = $this->get_updates('database', 'new'); |
|
728 | 726 | |
729 | - foreach ( $updates as $update ) { |
|
730 | - self::$background_updater->push_to_queue( $update ); |
|
727 | + foreach ($updates as $update) { |
|
728 | + self::$background_updater->push_to_queue($update); |
|
731 | 729 | } |
732 | 730 | |
733 | - add_option( 'give_db_update_count', count( $updates ), '', 'no' ); |
|
731 | + add_option('give_db_update_count', count($updates), '', 'no'); |
|
734 | 732 | |
735 | - add_option( 'give_doing_upgrade', array( |
|
733 | + add_option('give_doing_upgrade', array( |
|
736 | 734 | 'update_info' => $updates[0], |
737 | 735 | 'step' => 1, |
738 | 736 | 'update' => 1, |
739 | - 'heading' => sprintf( 'Update %s of %s', 1, count( $updates ) ), |
|
737 | + 'heading' => sprintf('Update %s of %s', 1, count($updates)), |
|
740 | 738 | 'percentage' => 0, |
741 | 739 | 'total_percentage' => 0, |
742 | - ), '', 'no' ); |
|
740 | + ), '', 'no'); |
|
743 | 741 | |
744 | 742 | self::$background_updater->save()->dispatch(); |
745 | 743 | } |
@@ -753,14 +751,13 @@ discard block |
||
753 | 751 | */ |
754 | 752 | public function __flush_resume_updates() { |
755 | 753 | //delete_option( 'give_doing_upgrade' ); |
756 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
754 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
757 | 755 | |
758 | 756 | // Reset counter. |
759 | 757 | $this->step = $this->percentage = 0; |
760 | 758 | |
761 | - $this->update = ( $this->get_total_db_update_count() > $this->update ) ? |
|
762 | - ( $this->update + 1 ) : |
|
763 | - $this->update; |
|
759 | + $this->update = ($this->get_total_db_update_count() > $this->update) ? |
|
760 | + ($this->update + 1) : $this->update; |
|
764 | 761 | } |
765 | 762 | |
766 | 763 | |
@@ -775,7 +772,7 @@ discard block |
||
775 | 772 | public function __give_start_updating() { |
776 | 773 | // Check permission. |
777 | 774 | if ( |
778 | - ! current_user_can( 'manage_give_settings' ) || |
|
775 | + ! current_user_can('manage_give_settings') || |
|
779 | 776 | $this->is_doing_updates() |
780 | 777 | ) { |
781 | 778 | wp_send_json_error(); |
@@ -783,7 +780,7 @@ discard block |
||
783 | 780 | |
784 | 781 | // @todo: validate nonce |
785 | 782 | // @todo: set http method to post |
786 | - if ( empty( $_POST['run_db_update'] ) ) { |
|
783 | + if (empty($_POST['run_db_update'])) { |
|
787 | 784 | wp_send_json_error(); |
788 | 785 | } |
789 | 786 | |
@@ -802,34 +799,34 @@ discard block |
||
802 | 799 | * @return string |
803 | 800 | */ |
804 | 801 | public function __give_db_updates_info() { |
805 | - $update_info = get_option( 'give_doing_upgrade' ); |
|
802 | + $update_info = get_option('give_doing_upgrade'); |
|
806 | 803 | $response_type = ''; |
807 | 804 | |
808 | - if ( self::$background_updater->is_paused_process() ) { |
|
805 | + if (self::$background_updater->is_paused_process()) { |
|
809 | 806 | $update_info = array( |
810 | - 'message' => __( 'The updates have been paused.', 'give' ), |
|
811 | - 'heading' => __( '', 'give' ), |
|
807 | + 'message' => __('The updates have been paused.', 'give'), |
|
808 | + 'heading' => __('', 'give'), |
|
812 | 809 | 'percentage' => 0, |
813 | 810 | ); |
814 | 811 | |
815 | - if ( get_option( 'give_upgrade_error' ) ) { |
|
816 | - $update_info['message'] = __( 'An unexpected issue occurred during the database update which caused it to stop automatically. Please contact support for assistance.', 'give' ); |
|
812 | + if (get_option('give_upgrade_error')) { |
|
813 | + $update_info['message'] = __('An unexpected issue occurred during the database update which caused it to stop automatically. Please contact support for assistance.', 'give'); |
|
817 | 814 | } |
818 | 815 | |
819 | 816 | $response_type = 'error'; |
820 | 817 | |
821 | - } elseif ( empty( $update_info ) ) { |
|
818 | + } elseif (empty($update_info)) { |
|
822 | 819 | $update_info = array( |
823 | - 'message' => __( 'Give database updates completed successfully. Thank you for updating to the latest version!', 'give' ), |
|
824 | - 'heading' => __( 'Updates Completed.', 'give' ), |
|
820 | + 'message' => __('Give database updates completed successfully. Thank you for updating to the latest version!', 'give'), |
|
821 | + 'heading' => __('Updates Completed.', 'give'), |
|
825 | 822 | 'percentage' => 0, |
826 | 823 | ); |
827 | 824 | $response_type = 'success'; |
828 | 825 | |
829 | - delete_option( 'give_show_db_upgrade_complete_notice' ); |
|
826 | + delete_option('give_show_db_upgrade_complete_notice'); |
|
830 | 827 | } |
831 | 828 | |
832 | - $this->send_ajax_response( $update_info, $response_type ); |
|
829 | + $this->send_ajax_response($update_info, $response_type); |
|
833 | 830 | } |
834 | 831 | |
835 | 832 | /** |
@@ -841,7 +838,7 @@ discard block |
||
841 | 838 | * @param $data |
842 | 839 | * @param string $type |
843 | 840 | */ |
844 | - public function send_ajax_response( $data, $type = '' ) { |
|
841 | + public function send_ajax_response($data, $type = '') { |
|
845 | 842 | $default = array( |
846 | 843 | 'message' => '', |
847 | 844 | 'heading' => '', |
@@ -851,24 +848,24 @@ discard block |
||
851 | 848 | ); |
852 | 849 | |
853 | 850 | // Set data. |
854 | - $data = wp_parse_args( $data, $default ); |
|
851 | + $data = wp_parse_args($data, $default); |
|
855 | 852 | |
856 | 853 | // Enable cache. |
857 | 854 | Give_Cache::enable(); |
858 | 855 | |
859 | - switch ( $type ) { |
|
856 | + switch ($type) { |
|
860 | 857 | case 'success': |
861 | - wp_send_json_success( $data ); |
|
858 | + wp_send_json_success($data); |
|
862 | 859 | break; |
863 | 860 | |
864 | 861 | case 'error': |
865 | - wp_send_json_error( $data ); |
|
862 | + wp_send_json_error($data); |
|
866 | 863 | break; |
867 | 864 | |
868 | 865 | default: |
869 | - wp_send_json( array( |
|
866 | + wp_send_json(array( |
|
870 | 867 | 'data' => $data, |
871 | - ) ); |
|
868 | + )); |
|
872 | 869 | break; |
873 | 870 | } |
874 | 871 | } |
@@ -882,12 +879,12 @@ discard block |
||
882 | 879 | * @param $total |
883 | 880 | * @param $current_total |
884 | 881 | */ |
885 | - public function set_percentage( $total, $current_total ) { |
|
882 | + public function set_percentage($total, $current_total) { |
|
886 | 883 | // Set percentage. |
887 | - $this->percentage = $total ? ( ( $current_total ) / $total ) * 100 : 0; |
|
884 | + $this->percentage = $total ? (($current_total) / $total) * 100 : 0; |
|
888 | 885 | |
889 | 886 | // Verify percentage. |
890 | - $this->percentage = ( 100 < $this->percentage ) ? 100 : $this->percentage; |
|
887 | + $this->percentage = (100 < $this->percentage) ? 100 : $this->percentage; |
|
891 | 888 | } |
892 | 889 | |
893 | 890 | /** |
@@ -900,22 +897,22 @@ discard block |
||
900 | 897 | * |
901 | 898 | * @return bool|null |
902 | 899 | */ |
903 | - public function is_parent_updates_completed( $update ) { |
|
900 | + public function is_parent_updates_completed($update) { |
|
904 | 901 | // Bailout. |
905 | - if ( empty( $update['depend'] ) ) { |
|
902 | + if (empty($update['depend'])) { |
|
906 | 903 | return true; |
907 | 904 | } |
908 | 905 | |
909 | 906 | // Check if dependency is valid or not. |
910 | - if ( ! $this->has_valid_dependency( $update ) ) { |
|
907 | + if ( ! $this->has_valid_dependency($update)) { |
|
911 | 908 | return null; |
912 | 909 | } |
913 | 910 | |
914 | 911 | $is_dependency_completed = true; |
915 | 912 | |
916 | - foreach ( $update['depend'] as $depend ) { |
|
913 | + foreach ($update['depend'] as $depend) { |
|
917 | 914 | |
918 | - if ( ! give_has_upgrade_completed( $depend ) ) { |
|
915 | + if ( ! give_has_upgrade_completed($depend)) { |
|
919 | 916 | $is_dependency_completed = false; |
920 | 917 | break; |
921 | 918 | } |
@@ -932,7 +929,7 @@ discard block |
||
932 | 929 | * @return bool |
933 | 930 | */ |
934 | 931 | public function is_doing_updates() { |
935 | - return (bool) get_option( 'give_doing_upgrade' ); |
|
932 | + return (bool) get_option('give_doing_upgrade'); |
|
936 | 933 | } |
937 | 934 | |
938 | 935 | |
@@ -946,7 +943,7 @@ discard block |
||
946 | 943 | * |
947 | 944 | * @return bool |
948 | 945 | */ |
949 | - public function has_valid_dependency( $update ) { |
|
946 | + public function has_valid_dependency($update) { |
|
950 | 947 | $is_valid_dependency = true; |
951 | 948 | // $update_ids = wp_list_pluck( $this->get_updates( 'database', 'all' ), 'id' ); |
952 | 949 | // |
@@ -972,33 +969,33 @@ discard block |
||
972 | 969 | * |
973 | 970 | * @return array |
974 | 971 | */ |
975 | - public function get_updates( $update_type = '', $status = 'all' ) { |
|
972 | + public function get_updates($update_type = '', $status = 'all') { |
|
976 | 973 | // return all updates. |
977 | - if ( empty( $update_type ) ) { |
|
974 | + if (empty($update_type)) { |
|
978 | 975 | return $this->updates; |
979 | 976 | } |
980 | 977 | |
981 | 978 | // Get specific update. |
982 | - $updates = ! empty( $this->updates[ $update_type ] ) ? $this->updates[ $update_type ] : array(); |
|
979 | + $updates = ! empty($this->updates[$update_type]) ? $this->updates[$update_type] : array(); |
|
983 | 980 | |
984 | 981 | // Bailout. |
985 | - if ( empty( $updates ) ) { |
|
982 | + if (empty($updates)) { |
|
986 | 983 | return $updates; |
987 | 984 | } |
988 | 985 | |
989 | - switch ( $status ) { |
|
986 | + switch ($status) { |
|
990 | 987 | case 'new': |
991 | 988 | // Remove already completed updates. |
992 | - wp_cache_delete( 'give_completed_upgrades', 'options' ); |
|
989 | + wp_cache_delete('give_completed_upgrades', 'options'); |
|
993 | 990 | $completed_updates = give_get_completed_upgrades(); |
994 | 991 | |
995 | - if ( ! empty( $completed_updates ) ) { |
|
996 | - foreach ( $updates as $index => $update ) { |
|
997 | - if ( in_array( $update['id'], $completed_updates ) ) { |
|
998 | - unset( $updates[ $index ] ); |
|
992 | + if ( ! empty($completed_updates)) { |
|
993 | + foreach ($updates as $index => $update) { |
|
994 | + if (in_array($update['id'], $completed_updates)) { |
|
995 | + unset($updates[$index]); |
|
999 | 996 | } |
1000 | 997 | } |
1001 | - $updates = array_values( $updates ); |
|
998 | + $updates = array_values($updates); |
|
1002 | 999 | } |
1003 | 1000 | |
1004 | 1001 | break; |
@@ -1015,7 +1012,7 @@ discard block |
||
1015 | 1012 | * @return int |
1016 | 1013 | */ |
1017 | 1014 | public function get_total_plugin_update_count() { |
1018 | - return count( $this->get_updates( 'plugin' ) ); |
|
1015 | + return count($this->get_updates('plugin')); |
|
1019 | 1016 | } |
1020 | 1017 | |
1021 | 1018 | /** |
@@ -1030,7 +1027,7 @@ discard block |
||
1030 | 1027 | $db_update_count = $this->get_pending_db_update_count(); |
1031 | 1028 | $plugin_update_count = $this->get_total_plugin_update_count(); |
1032 | 1029 | |
1033 | - return ( $db_update_count + $plugin_update_count ); |
|
1030 | + return ($db_update_count + $plugin_update_count); |
|
1034 | 1031 | } |
1035 | 1032 | |
1036 | 1033 | /** |
@@ -1042,7 +1039,7 @@ discard block |
||
1042 | 1039 | * @return int |
1043 | 1040 | */ |
1044 | 1041 | public function get_pending_db_update_count() { |
1045 | - return count( $this->get_updates( 'database', 'new' ) ); |
|
1042 | + return count($this->get_updates('database', 'new')); |
|
1046 | 1043 | } |
1047 | 1044 | |
1048 | 1045 | /** |
@@ -1054,7 +1051,7 @@ discard block |
||
1054 | 1051 | * @return int |
1055 | 1052 | */ |
1056 | 1053 | public function get_total_db_update_count() { |
1057 | - return count( $this->get_updates( 'database', 'all' ) ); |
|
1054 | + return count($this->get_updates('database', 'all')); |
|
1058 | 1055 | } |
1059 | 1056 | |
1060 | 1057 | /** |
@@ -1067,10 +1064,9 @@ discard block |
||
1067 | 1064 | * |
1068 | 1065 | * @return int |
1069 | 1066 | */ |
1070 | - public function get_total_new_db_update_count( $refresh = false ) { |
|
1067 | + public function get_total_new_db_update_count($refresh = false) { |
|
1071 | 1068 | $update_count = $this->is_doing_updates() && ! $refresh ? |
1072 | - get_option( 'give_db_update_count' ) : |
|
1073 | - $this->get_pending_db_update_count(); |
|
1069 | + get_option('give_db_update_count') : $this->get_pending_db_update_count(); |
|
1074 | 1070 | |
1075 | 1071 | return $update_count; |
1076 | 1072 | } |
@@ -1085,11 +1081,11 @@ discard block |
||
1085 | 1081 | * |
1086 | 1082 | * @return int |
1087 | 1083 | */ |
1088 | - public function get_running_db_update( $refresh = false ) { |
|
1084 | + public function get_running_db_update($refresh = false) { |
|
1089 | 1085 | $current_update = 1; |
1090 | 1086 | |
1091 | - if ( $this->is_doing_updates() && ! $refresh ) { |
|
1092 | - $current_update = get_option( 'give_doing_upgrade' ); |
|
1087 | + if ($this->is_doing_updates() && ! $refresh) { |
|
1088 | + $current_update = get_option('give_doing_upgrade'); |
|
1093 | 1089 | $current_update = $current_update['update']; |
1094 | 1090 | } |
1095 | 1091 | |
@@ -1106,25 +1102,23 @@ discard block |
||
1106 | 1102 | * |
1107 | 1103 | * @return float|int |
1108 | 1104 | */ |
1109 | - public function get_db_update_processing_percentage( $refresh = false ) { |
|
1105 | + public function get_db_update_processing_percentage($refresh = false) { |
|
1110 | 1106 | // Bailout. |
1111 | - if ( ! $this->get_total_new_db_update_count( $refresh ) ) { |
|
1107 | + if ( ! $this->get_total_new_db_update_count($refresh)) { |
|
1112 | 1108 | return 0; |
1113 | 1109 | } |
1114 | 1110 | |
1115 | - $resume_update = get_option( 'give_doing_upgrade' ); |
|
1116 | - $update_count_percentages = ( ( $this->get_running_db_update( $refresh ) - 1 ) / $this->get_total_new_db_update_count( $refresh ) ) * 100; |
|
1117 | - $update_percentage_share = ( 1 / $this->get_total_new_db_update_count() ) * 100; |
|
1118 | - $upgrade_percentage = ( ( $resume_update['percentage'] * $update_percentage_share ) / 100 ); |
|
1111 | + $resume_update = get_option('give_doing_upgrade'); |
|
1112 | + $update_count_percentages = (($this->get_running_db_update($refresh) - 1) / $this->get_total_new_db_update_count($refresh)) * 100; |
|
1113 | + $update_percentage_share = (1 / $this->get_total_new_db_update_count()) * 100; |
|
1114 | + $upgrade_percentage = (($resume_update['percentage'] * $update_percentage_share) / 100); |
|
1119 | 1115 | |
1120 | 1116 | $final_percentage = $update_count_percentages + $upgrade_percentage; |
1121 | 1117 | |
1122 | 1118 | return $this->is_doing_updates() ? |
1123 | - ( absint( $final_percentage ) ? |
|
1124 | - absint( $final_percentage ) : |
|
1125 | - round( $final_percentage, 2 ) |
|
1126 | - ) : |
|
1127 | - 0; |
|
1119 | + (absint($final_percentage) ? |
|
1120 | + absint($final_percentage) : round($final_percentage, 2) |
|
1121 | + ) : 0; |
|
1128 | 1122 | } |
1129 | 1123 | |
1130 | 1124 | |
@@ -1136,8 +1130,8 @@ discard block |
||
1136 | 1130 | * @return array |
1137 | 1131 | */ |
1138 | 1132 | public function get_update_ids() { |
1139 | - $all_updates = $this->get_updates( 'database', 'all' ); |
|
1140 | - $all_update_ids = wp_list_pluck( $all_updates, 'id' ); |
|
1133 | + $all_updates = $this->get_updates('database', 'all'); |
|
1134 | + $all_update_ids = wp_list_pluck($all_updates, 'id'); |
|
1141 | 1135 | |
1142 | 1136 | return $all_update_ids; |
1143 | 1137 | } |
@@ -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 | |
@@ -18,56 +18,55 @@ discard block |
||
18 | 18 | ?> |
19 | 19 | <div class="wrap" id="poststuff"> |
20 | 20 | <div id="give-updates"> |
21 | - <h1 id="give-updates-h1"><?php esc_html_e( 'Give - Updates', 'give' ); ?></h1> |
|
21 | + <h1 id="give-updates-h1"><?php esc_html_e('Give - Updates', 'give'); ?></h1> |
|
22 | 22 | <hr class="wp-header-end"> |
23 | 23 | |
24 | 24 | <div class="give-update-panel-content"> |
25 | - <p><?php printf( __( 'Give regularly receives new features, bug fixes, and enhancements. It is important to always stay up-to-date with latest version of Give core and its add-ons. Please create a backup of your site before updating. To update add-ons be sure your <a href="%1$s">license keys</a> are activated.', 'give' ), 'https://givewp.com/my-account/' ); ?></p> |
|
25 | + <p><?php printf(__('Give regularly receives new features, bug fixes, and enhancements. It is important to always stay up-to-date with latest version of Give core and its add-ons. Please create a backup of your site before updating. To update add-ons be sure your <a href="%1$s">license keys</a> are activated.', 'give'), 'https://givewp.com/my-account/'); ?></p> |
|
26 | 26 | </div> |
27 | 27 | |
28 | 28 | <?php $db_updates = $give_updates->get_pending_db_update_count(); ?> |
29 | - <?php if ( ! empty( $db_updates ) ) : ?> |
|
29 | + <?php if ( ! empty($db_updates)) : ?> |
|
30 | 30 | <?php |
31 | 31 | $is_doing_updates = $give_updates->is_doing_updates(); |
32 | - $db_update_url = add_query_arg( array( 'type' => 'database', ) ); |
|
33 | - $resume_updates = get_option( 'give_doing_upgrade' ); |
|
34 | - $width = ! empty( $resume_updates ) ? $resume_updates['percentage'] : 0; |
|
32 | + $db_update_url = add_query_arg(array('type' => 'database',)); |
|
33 | + $resume_updates = get_option('give_doing_upgrade'); |
|
34 | + $width = ! empty($resume_updates) ? $resume_updates['percentage'] : 0; |
|
35 | 35 | ?> |
36 | - <div id="give-db-updates" data-resume-update="<?php echo absint( $give_updates->is_doing_updates() ); ?>"> |
|
36 | + <div id="give-db-updates" data-resume-update="<?php echo absint($give_updates->is_doing_updates()); ?>"> |
|
37 | 37 | <div class="postbox-container"> |
38 | 38 | <div class="postbox"> |
39 | - <h2 class="hndle"><?php _e( 'Database Updates', 'give' ); ?></h2> |
|
39 | + <h2 class="hndle"><?php _e('Database Updates', 'give'); ?></h2> |
|
40 | 40 | <div class="inside"> |
41 | 41 | <div class="panel-content"> |
42 | 42 | <p class="give-update-button"> |
43 | - <span class="give-doing-update-text-p" <?php echo Give_Updates::$background_updater->is_paused_process() ? 'style="display:none;"' : ''; ?>> |
|
43 | + <span class="give-doing-update-text-p" <?php echo Give_Updates::$background_updater->is_paused_process() ? 'style="display:none;"' : ''; ?>> |
|
44 | 44 | <?php echo sprintf( |
45 | - __( '%1$s <a href="%2$s" class="give-update-now %3$s">%4$s</a>', 'give' ), |
|
45 | + __('%1$s <a href="%2$s" class="give-update-now %3$s">%4$s</a>', 'give'), |
|
46 | 46 | $is_doing_updates ? |
47 | - __( 'Give is currently updating the database in the background.', 'give' ) : |
|
48 | - __( 'Give needs to update the database.', 'give' ), |
|
47 | + __('Give is currently updating the database in the background.', 'give') : __('Give needs to update the database.', 'give'), |
|
49 | 48 | $db_update_url, |
50 | - ( $is_doing_updates ? 'give-hidden' : '' ), |
|
51 | - __( 'Update now', 'give' ) |
|
49 | + ($is_doing_updates ? 'give-hidden' : ''), |
|
50 | + __('Update now', 'give') |
|
52 | 51 | ); |
53 | 52 | ?> |
54 | 53 | </span> |
55 | - <span class="give-update-paused-text-p" <?php echo ! Give_Updates::$background_updater->is_paused_process() ? 'style="display:none;"' : ''; ?>> |
|
56 | - <?php if ( get_option( 'give_upgrade_error' ) ) : ?> |
|
57 | - <?php _e( 'An unexpected issue occurred during the database update which caused it to stop automatically. Please contact support for assistance.', 'give' ); ?> |
|
54 | + <span class="give-update-paused-text-p" <?php echo ! Give_Updates::$background_updater->is_paused_process() ? 'style="display:none;"' : ''; ?>> |
|
55 | + <?php if (get_option('give_upgrade_error')) : ?> |
|
56 | + <?php _e('An unexpected issue occurred during the database update which caused it to stop automatically. Please contact support for assistance.', 'give'); ?> |
|
58 | 57 | <?php else : ?> |
59 | - <?php _e( 'The updates have been paused.', 'give' ); ?> |
|
58 | + <?php _e('The updates have been paused.', 'give'); ?> |
|
60 | 59 | |
61 | 60 | <?php endif; ?> |
62 | 61 | </span> |
63 | 62 | |
64 | - <?php if ( Give_Updates::$background_updater->is_paused_process() ) : ?> |
|
65 | - <?php $is_disabled = isset( $_GET['give-restart-db-upgrades'] ) ? ' disabled' : ''; ?> |
|
66 | - <button id="give-restart-upgrades" class="button button-primary alignright" data-redirect-url="<?php echo esc_url( admin_url( '/edit.php?post_type=give_forms&page=give-updates&give-restart-db-upgrades=1' ) ); ?>"<?php echo $is_disabled; ?>><?php _e( 'Restart Upgrades', 'give' ); ?></button> |
|
67 | - <?php elseif( $give_updates->is_doing_updates() ): ?> |
|
68 | - <?php $is_disabled = isset( $_GET['give-pause-db-upgrades'] ) ? ' disabled' : ''; ?> |
|
69 | - <button id="give-pause-upgrades" class="button button-primary alignright" data-redirect-url="<?php echo esc_url( admin_url( '/edit.php?post_type=give_forms&page=give-updates&give-pause-db-upgrades=1' ) ); ?>"<?php echo $is_disabled; ?>> |
|
70 | - <?php _e( 'Pause Upgrades', 'give' ); ?> |
|
63 | + <?php if (Give_Updates::$background_updater->is_paused_process()) : ?> |
|
64 | + <?php $is_disabled = isset($_GET['give-restart-db-upgrades']) ? ' disabled' : ''; ?> |
|
65 | + <button id="give-restart-upgrades" class="button button-primary alignright" data-redirect-url="<?php echo esc_url(admin_url('/edit.php?post_type=give_forms&page=give-updates&give-restart-db-upgrades=1')); ?>"<?php echo $is_disabled; ?>><?php _e('Restart Upgrades', 'give'); ?></button> |
|
66 | + <?php elseif ($give_updates->is_doing_updates()): ?> |
|
67 | + <?php $is_disabled = isset($_GET['give-pause-db-upgrades']) ? ' disabled' : ''; ?> |
|
68 | + <button id="give-pause-upgrades" class="button button-primary alignright" data-redirect-url="<?php echo esc_url(admin_url('/edit.php?post_type=give_forms&page=give-updates&give-pause-db-upgrades=1')); ?>"<?php echo $is_disabled; ?>> |
|
69 | + <?php _e('Pause Upgrades', 'give'); ?> |
|
71 | 70 | </button> |
72 | 71 | <?php endif; ?> |
73 | 72 | |
@@ -76,7 +75,7 @@ discard block |
||
76 | 75 | e.preventDefault(); |
77 | 76 | jQuery('.give-doing-update-text-p').hide(); |
78 | 77 | jQuery('.give-update-paused-text-p').show(); |
79 | - if (window.confirm('<?php echo esc_js( __( 'Do you want to stop the update process now?', 'give' ) ); ?>')) { |
|
78 | + if (window.confirm('<?php echo esc_js(__('Do you want to stop the update process now?', 'give')); ?>')) { |
|
80 | 79 | window.location.assign(jQuery(this).data('redirect-url')); |
81 | 80 | } |
82 | 81 | }); |
@@ -84,7 +83,7 @@ discard block |
||
84 | 83 | e.preventDefault(); |
85 | 84 | jQuery('.give-doing-update-text-p').show(); |
86 | 85 | jQuery('.give-update-paused-text-p').hide(); |
87 | - if (window.confirm('<?php echo esc_js( __( 'Do you want to restart the update process?', 'give' ) ); ?>')) { |
|
86 | + if (window.confirm('<?php echo esc_js(__('Do you want to restart the update process?', 'give')); ?>')) { |
|
88 | 87 | window.location.assign(jQuery(this).data('redirect-url')); |
89 | 88 | } |
90 | 89 | }); |
@@ -96,7 +95,7 @@ discard block |
||
96 | 95 | <strong> |
97 | 96 | <?php |
98 | 97 | echo sprintf( |
99 | - __( 'Update %s of %s', 'give' ), |
|
98 | + __('Update %s of %s', 'give'), |
|
100 | 99 | $give_updates->get_running_db_update(), |
101 | 100 | $give_updates->get_total_new_db_update_count() |
102 | 101 | ); |
@@ -104,10 +103,10 @@ discard block |
||
104 | 103 | </strong> |
105 | 104 | </p> |
106 | 105 | <div class="progress-content"> |
107 | - <?php if ( $is_doing_updates ) : ?> |
|
106 | + <?php if ($is_doing_updates) : ?> |
|
108 | 107 | <div class="notice-wrap give-clearfix"> |
109 | 108 | |
110 | - <?php if ( ! Give_Updates::$background_updater->is_paused_process() ) : ?> |
|
109 | + <?php if ( ! Give_Updates::$background_updater->is_paused_process()) : ?> |
|
111 | 110 | <span class="spinner is-active"></span> |
112 | 111 | <?php endif; ?> |
113 | 112 | |
@@ -119,7 +118,7 @@ discard block |
||
119 | 118 | </div> |
120 | 119 | </div> |
121 | 120 | |
122 | - <?php if ( ! $is_doing_updates ) : ?> |
|
121 | + <?php if ( ! $is_doing_updates) : ?> |
|
123 | 122 | <div class="give-run-database-update"></div> |
124 | 123 | <?php endif; ?> |
125 | 124 | </div> |
@@ -130,17 +129,17 @@ discard block |
||
130 | 129 | <?php endif; ?> |
131 | 130 | |
132 | 131 | <?php $plugin_updates = $give_updates->get_total_plugin_update_count(); ?> |
133 | - <?php if ( ! empty( $plugin_updates ) ) : ?> |
|
134 | - <?php $plugin_update_url = add_query_arg( array( |
|
132 | + <?php if ( ! empty($plugin_updates)) : ?> |
|
133 | + <?php $plugin_update_url = add_query_arg(array( |
|
135 | 134 | 's' => 'Give', |
136 | - ), admin_url( '/plugins.php' ) ); ?> |
|
135 | + ), admin_url('/plugins.php')); ?> |
|
137 | 136 | <div id="give-plugin-updates"> |
138 | 137 | <div class="postbox-container"> |
139 | 138 | <div class="postbox"> |
140 | - <h2 class="hndle"><?php _e( 'Add-on Updates', 'give' ); ?></h2> |
|
139 | + <h2 class="hndle"><?php _e('Add-on Updates', 'give'); ?></h2> |
|
141 | 140 | <div class="inside"> |
142 | 141 | <div class="panel-content"> |
143 | - <p><?php echo sprintf( __( 'There %1$s %2$s Give %3$s that %4$s to be updated. <a href="%5$s">Update now</a>', 'give' ), _n( 'is', 'are', $plugin_updates, 'give' ), $plugin_updates, _n( 'add-on', 'add-ons', $plugin_updates, 'give' ), _n( 'needs', 'need', $plugin_updates, 'give' ), $plugin_update_url ); ?></p> |
|
142 | + <p><?php echo sprintf(__('There %1$s %2$s Give %3$s that %4$s to be updated. <a href="%5$s">Update now</a>', 'give'), _n('is', 'are', $plugin_updates, 'give'), $plugin_updates, _n('add-on', 'add-ons', $plugin_updates, 'give'), _n('needs', 'need', $plugin_updates, 'give'), $plugin_update_url); ?></p> |
|
144 | 143 | <?php include_once 'plugins-update-section.php'; ?> |
145 | 144 | </div> |
146 | 145 | </div> |
@@ -55,8 +55,11 @@ |
||
55 | 55 | <span class="give-update-paused-text-p" <?php echo ! Give_Updates::$background_updater->is_paused_process() ? 'style="display:none;"' : ''; ?>> |
56 | 56 | <?php if ( get_option( 'give_upgrade_error' ) ) : ?> |
57 | 57 | <?php _e( 'An unexpected issue occurred during the database update which caused it to stop automatically. Please contact support for assistance.', 'give' ); ?> |
58 | - <?php else : ?> |
|
59 | - <?php _e( 'The updates have been paused.', 'give' ); ?> |
|
58 | + <?php else { |
|
59 | + : ?> |
|
60 | + <?php _e( 'The updates have been paused.', 'give' ); |
|
61 | +} |
|
62 | +?> |
|
60 | 63 | |
61 | 64 | <?php endif; ?> |
62 | 65 | </span> |
@@ -9,11 +9,11 @@ discard block |
||
9 | 9 | * @since 1.8 |
10 | 10 | */ |
11 | 11 | |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; // Exit if accessed directly. |
14 | 14 | } |
15 | 15 | |
16 | -if ( ! class_exists( 'Give_Settings_General' ) ) : |
|
16 | +if ( ! class_exists('Give_Settings_General')) : |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Give_Settings_General. |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public function __construct() { |
29 | 29 | $this->id = 'general'; |
30 | - $this->label = __( 'General', 'give' ); |
|
30 | + $this->label = __('General', 'give'); |
|
31 | 31 | |
32 | 32 | $this->default_tab = 'general-settings'; |
33 | 33 | |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | $settings = array(); |
45 | 45 | $current_section = give_get_current_setting_section(); |
46 | 46 | |
47 | - switch ( $current_section ) { |
|
47 | + switch ($current_section) { |
|
48 | 48 | case 'access-control': |
49 | 49 | $settings = array( |
50 | 50 | // Section 3: Access control. |
@@ -54,20 +54,20 @@ discard block |
||
54 | 54 | ), |
55 | 55 | array( |
56 | 56 | 'id' => 'session_lifetime', |
57 | - 'name' => __( 'Session Lifetime', 'give' ), |
|
58 | - 'desc' => __( 'The length of time a user\'s session is kept alive. Give starts a new session per user upon donation. Sessions allow donors to view their donation receipts without being logged in.', 'give' ), |
|
57 | + 'name' => __('Session Lifetime', 'give'), |
|
58 | + 'desc' => __('The length of time a user\'s session is kept alive. Give starts a new session per user upon donation. Sessions allow donors to view their donation receipts without being logged in.', 'give'), |
|
59 | 59 | 'type' => 'select', |
60 | 60 | 'options' => array( |
61 | - '86400' => __( '24 Hours', 'give' ), |
|
62 | - '172800' => __( '48 Hours', 'give' ), |
|
63 | - '259200' => __( '72 Hours', 'give' ), |
|
64 | - '604800' => __( '1 Week', 'give' ), |
|
61 | + '86400' => __('24 Hours', 'give'), |
|
62 | + '172800' => __('48 Hours', 'give'), |
|
63 | + '259200' => __('72 Hours', 'give'), |
|
64 | + '604800' => __('1 Week', 'give'), |
|
65 | 65 | ), |
66 | 66 | ), |
67 | 67 | array( |
68 | 68 | 'id' => 'limit_display_donations', |
69 | - 'name' => __( 'Limit Donations Displayed', 'give' ), |
|
70 | - 'desc' => __( 'Adjusts the number of donations displayed to a non logged-in user when they attempt to access the Donation History page without an active session. For security reasons, it\'s best to leave this at 1-3 donations.', 'give' ), |
|
69 | + 'name' => __('Limit Donations Displayed', 'give'), |
|
70 | + 'desc' => __('Adjusts the number of donations displayed to a non logged-in user when they attempt to access the Donation History page without an active session. For security reasons, it\'s best to leave this at 1-3 donations.', 'give'), |
|
71 | 71 | 'default' => '1', |
72 | 72 | 'type' => 'number', |
73 | 73 | 'css' => 'width:50px;', |
@@ -77,47 +77,47 @@ discard block |
||
77 | 77 | ), |
78 | 78 | ), |
79 | 79 | array( |
80 | - 'name' => __( 'Email Access', 'give' ), |
|
81 | - 'desc' => __( 'Would you like your donors to be able to access their donation history using only email? Donors whose sessions have expired and do not have an account may still access their donation history via a temporary email access link.', 'give' ), |
|
80 | + 'name' => __('Email Access', 'give'), |
|
81 | + 'desc' => __('Would you like your donors to be able to access their donation history using only email? Donors whose sessions have expired and do not have an account may still access their donation history via a temporary email access link.', 'give'), |
|
82 | 82 | 'id' => 'email_access', |
83 | 83 | 'type' => 'radio_inline', |
84 | 84 | 'default' => 'disabled', |
85 | 85 | 'options' => array( |
86 | - 'enabled' => __( 'Enabled', 'give' ), |
|
87 | - 'disabled' => __( 'Disabled', 'give' ), |
|
86 | + 'enabled' => __('Enabled', 'give'), |
|
87 | + 'disabled' => __('Disabled', 'give'), |
|
88 | 88 | ), |
89 | 89 | ), |
90 | 90 | array( |
91 | - 'name' => __( 'Enable reCAPTCHA', 'give' ), |
|
92 | - 'desc' => __( 'Would you like to enable the reCAPTCHA feature?', 'give' ), |
|
91 | + 'name' => __('Enable reCAPTCHA', 'give'), |
|
92 | + 'desc' => __('Would you like to enable the reCAPTCHA feature?', 'give'), |
|
93 | 93 | 'id' => 'enable_recaptcha', |
94 | 94 | 'type' => 'radio_inline', |
95 | 95 | 'default' => 'disabled', |
96 | 96 | 'options' => array( |
97 | - 'enabled' => __( 'Enabled', 'give' ), |
|
98 | - 'disabled' => __( 'Disabled', 'give' ), |
|
97 | + 'enabled' => __('Enabled', 'give'), |
|
98 | + 'disabled' => __('Disabled', 'give'), |
|
99 | 99 | ), |
100 | 100 | ), |
101 | 101 | array( |
102 | 102 | 'id' => 'recaptcha_key', |
103 | - 'name' => __( 'reCAPTCHA Site Key', 'give' ), |
|
103 | + 'name' => __('reCAPTCHA Site Key', 'give'), |
|
104 | 104 | /* translators: %s: https://www.google.com/recaptcha/ */ |
105 | - 'desc' => sprintf( __( 'If you would like to prevent spam on the email access form navigate to <a href="%s" target="_blank">the reCAPTCHA website</a> and sign up for an API key and paste your reCAPTCHA site key here. The reCAPTCHA uses Google\'s user-friendly single click verification method.', 'give' ), esc_url( 'http://docs.givewp.com/recaptcha' ) ), |
|
105 | + 'desc' => sprintf(__('If you would like to prevent spam on the email access form navigate to <a href="%s" target="_blank">the reCAPTCHA website</a> and sign up for an API key and paste your reCAPTCHA site key here. The reCAPTCHA uses Google\'s user-friendly single click verification method.', 'give'), esc_url('http://docs.givewp.com/recaptcha')), |
|
106 | 106 | 'default' => '', |
107 | 107 | 'type' => 'text', |
108 | 108 | ), |
109 | 109 | array( |
110 | 110 | 'id' => 'recaptcha_secret', |
111 | - 'name' => __( 'reCAPTCHA Secret Key', 'give' ), |
|
112 | - 'desc' => __( 'Please paste the reCAPTCHA secret key here from your reCAPTCHA API Keys panel.', 'give' ), |
|
111 | + 'name' => __('reCAPTCHA Secret Key', 'give'), |
|
112 | + 'desc' => __('Please paste the reCAPTCHA secret key here from your reCAPTCHA API Keys panel.', 'give'), |
|
113 | 113 | 'default' => '', |
114 | 114 | 'type' => 'text', |
115 | 115 | ), |
116 | 116 | array( |
117 | - 'name' => __( 'Access Control Docs Link', 'give' ), |
|
117 | + 'name' => __('Access Control Docs Link', 'give'), |
|
118 | 118 | 'id' => 'access_control_docs_link', |
119 | - 'url' => esc_url( 'http://docs.givewp.com/settings-access-control' ), |
|
120 | - 'title' => __( 'Access Control', 'give' ), |
|
119 | + 'url' => esc_url('http://docs.givewp.com/settings-access-control'), |
|
120 | + 'title' => __('Access Control', 'give'), |
|
121 | 121 | 'type' => 'give_docs_link', |
122 | 122 | ), |
123 | 123 | array( |
@@ -128,8 +128,8 @@ discard block |
||
128 | 128 | break; |
129 | 129 | |
130 | 130 | case 'currency-settings' : |
131 | - $currency_position_before = __( 'Before - %s‎10', 'give' ); |
|
132 | - $currency_position_after = __( 'After - 10%s‏', 'give' ); |
|
131 | + $currency_position_before = __('Before - %s‎10', 'give'); |
|
132 | + $currency_position_after = __('After - 10%s‏', 'give'); |
|
133 | 133 | |
134 | 134 | $settings = array( |
135 | 135 | // Section 2: Currency |
@@ -138,14 +138,14 @@ discard block |
||
138 | 138 | 'id' => 'give_title_general_settings_2', |
139 | 139 | ), |
140 | 140 | array( |
141 | - 'name' => __( 'Currency Settings', 'give' ), |
|
141 | + 'name' => __('Currency Settings', 'give'), |
|
142 | 142 | 'desc' => '', |
143 | 143 | 'type' => 'give_title', |
144 | 144 | 'id' => 'give_title_general_settings_2', |
145 | 145 | ), |
146 | 146 | array( |
147 | - 'name' => __( 'Currency', 'give' ), |
|
148 | - 'desc' => __( 'The donation currency. Note that some payment gateways have currency restrictions.', 'give' ), |
|
147 | + 'name' => __('Currency', 'give'), |
|
148 | + 'desc' => __('The donation currency. Note that some payment gateways have currency restrictions.', 'give'), |
|
149 | 149 | 'id' => 'currency', |
150 | 150 | 'class' => 'give-select-chosen', |
151 | 151 | 'type' => 'select', |
@@ -153,51 +153,51 @@ discard block |
||
153 | 153 | 'default' => 'USD', |
154 | 154 | ), |
155 | 155 | array( |
156 | - 'name' => __( 'Currency Position', 'give' ), |
|
157 | - 'desc' => __( 'The position of the currency symbol.', 'give' ), |
|
156 | + 'name' => __('Currency Position', 'give'), |
|
157 | + 'desc' => __('The position of the currency symbol.', 'give'), |
|
158 | 158 | 'id' => 'currency_position', |
159 | 159 | 'type' => 'select', |
160 | 160 | 'options' => array( |
161 | 161 | /* translators: %s: currency symbol */ |
162 | - 'before' => sprintf( $currency_position_before, give_currency_symbol( give_get_currency() ) ), |
|
162 | + 'before' => sprintf($currency_position_before, give_currency_symbol(give_get_currency())), |
|
163 | 163 | /* translators: %s: currency symbol */ |
164 | - 'after' => sprintf( $currency_position_after, give_currency_symbol( give_get_currency() ) ), |
|
164 | + 'after' => sprintf($currency_position_after, give_currency_symbol(give_get_currency())), |
|
165 | 165 | ), |
166 | 166 | 'default' => 'before', |
167 | 167 | 'attributes' => array( |
168 | - 'data-before-template' => sprintf( $currency_position_before, '{currency_pos}' ), |
|
169 | - 'data-after-template' => sprintf( $currency_position_after, '{currency_pos}' ), |
|
168 | + 'data-before-template' => sprintf($currency_position_before, '{currency_pos}'), |
|
169 | + 'data-after-template' => sprintf($currency_position_after, '{currency_pos}'), |
|
170 | 170 | ), |
171 | 171 | ), |
172 | 172 | array( |
173 | - 'name' => __( 'Thousands Separator', 'give' ), |
|
174 | - 'desc' => __( 'The symbol (typically , or .) to separate thousands.', 'give' ), |
|
173 | + 'name' => __('Thousands Separator', 'give'), |
|
174 | + 'desc' => __('The symbol (typically , or .) to separate thousands.', 'give'), |
|
175 | 175 | 'id' => 'thousands_separator', |
176 | 176 | 'type' => 'text', |
177 | 177 | 'default' => ',', |
178 | 178 | 'css' => 'width:12em;', |
179 | 179 | ), |
180 | 180 | array( |
181 | - 'name' => __( 'Decimal Separator', 'give' ), |
|
182 | - 'desc' => __( 'The symbol (usually , or .) to separate decimal points.', 'give' ), |
|
181 | + 'name' => __('Decimal Separator', 'give'), |
|
182 | + 'desc' => __('The symbol (usually , or .) to separate decimal points.', 'give'), |
|
183 | 183 | 'id' => 'decimal_separator', |
184 | 184 | 'type' => 'text', |
185 | 185 | 'default' => '.', |
186 | 186 | 'css' => 'width:12em;', |
187 | 187 | ), |
188 | 188 | array( |
189 | - 'name' => __( 'Number of Decimals', 'give' ), |
|
190 | - 'desc' => __( 'The number of decimal points displayed in amounts.', 'give' ), |
|
189 | + 'name' => __('Number of Decimals', 'give'), |
|
190 | + 'desc' => __('The number of decimal points displayed in amounts.', 'give'), |
|
191 | 191 | 'id' => 'number_decimals', |
192 | 192 | 'type' => 'text', |
193 | 193 | 'default' => 2, |
194 | 194 | 'css' => 'width:12em;', |
195 | 195 | ), |
196 | 196 | array( |
197 | - 'name' => __( 'Currency Options Docs Link', 'give' ), |
|
197 | + 'name' => __('Currency Options Docs Link', 'give'), |
|
198 | 198 | 'id' => 'currency_settings_docs_link', |
199 | - 'url' => esc_url( 'http://docs.givewp.com/settings-currency' ), |
|
200 | - 'title' => __( 'Currency Settings', 'give' ), |
|
199 | + 'url' => esc_url('http://docs.givewp.com/settings-currency'), |
|
200 | + 'title' => __('Currency Settings', 'give'), |
|
201 | 201 | 'type' => 'give_docs_link', |
202 | 202 | ), |
203 | 203 | array( |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | $country = give_get_country(); |
214 | 214 | |
215 | 215 | // get the list of the states of which default country is selected. |
216 | - $states = give_get_states( $country ); |
|
216 | + $states = give_get_states($country); |
|
217 | 217 | |
218 | 218 | // Get the country list that does not have any states init. |
219 | 219 | $no_states_country = give_no_states_country_list(); |
@@ -225,46 +225,46 @@ discard block |
||
225 | 225 | 'id' => 'give_title_general_settings_1', |
226 | 226 | ), |
227 | 227 | array( |
228 | - 'name' => __( 'General Settings', 'give' ), |
|
228 | + 'name' => __('General Settings', 'give'), |
|
229 | 229 | 'desc' => '', |
230 | 230 | 'type' => 'give_title', |
231 | 231 | 'id' => 'give_title_general_settings_1', |
232 | 232 | ), |
233 | 233 | array( |
234 | - 'name' => __( 'Success Page', 'give' ), |
|
234 | + 'name' => __('Success Page', 'give'), |
|
235 | 235 | /* translators: %s: [give_receipt] */ |
236 | - 'desc' => sprintf( __( 'The page donors are sent to after completing their donations. The %s shortcode should be on this page.', 'give' ), '<code>[give_receipt]</code>' ), |
|
236 | + 'desc' => sprintf(__('The page donors are sent to after completing their donations. The %s shortcode should be on this page.', 'give'), '<code>[give_receipt]</code>'), |
|
237 | 237 | 'id' => 'success_page', |
238 | 238 | 'type' => 'select', |
239 | - 'options' => give_cmb2_get_post_options( array( |
|
239 | + 'options' => give_cmb2_get_post_options(array( |
|
240 | 240 | 'post_type' => 'page', |
241 | 241 | 'numberposts' => 999, |
242 | - ) ), |
|
242 | + )), |
|
243 | 243 | ), |
244 | 244 | array( |
245 | - 'name' => __( 'Failed Donation Page', 'give' ), |
|
246 | - 'desc' => __( 'The page donors are sent to if their donation is cancelled or fails.', 'give' ), |
|
245 | + 'name' => __('Failed Donation Page', 'give'), |
|
246 | + 'desc' => __('The page donors are sent to if their donation is cancelled or fails.', 'give'), |
|
247 | 247 | 'id' => 'failure_page', |
248 | 248 | 'type' => 'select', |
249 | - 'options' => give_cmb2_get_post_options( array( |
|
249 | + 'options' => give_cmb2_get_post_options(array( |
|
250 | 250 | 'post_type' => 'page', |
251 | 251 | 'numberposts' => 999, |
252 | - ) ), |
|
252 | + )), |
|
253 | 253 | ), |
254 | 254 | array( |
255 | - 'name' => __( 'Donation History Page', 'give' ), |
|
255 | + 'name' => __('Donation History Page', 'give'), |
|
256 | 256 | /* translators: %s: [donation_history] */ |
257 | - 'desc' => sprintf( __( 'The page showing a complete donation history for the current user. The %s shortcode should be on this page.', 'give' ), '<code>[donation_history]</code>' ), |
|
257 | + 'desc' => sprintf(__('The page showing a complete donation history for the current user. The %s shortcode should be on this page.', 'give'), '<code>[donation_history]</code>'), |
|
258 | 258 | 'id' => 'history_page', |
259 | 259 | 'type' => 'select', |
260 | - 'options' => give_cmb2_get_post_options( array( |
|
260 | + 'options' => give_cmb2_get_post_options(array( |
|
261 | 261 | 'post_type' => 'page', |
262 | 262 | 'numberposts' => 999, |
263 | - ) ), |
|
263 | + )), |
|
264 | 264 | ), |
265 | 265 | array( |
266 | - 'name' => __( 'Base Country', 'give' ), |
|
267 | - 'desc' => __( 'The country your site operates from.', 'give' ), |
|
266 | + 'name' => __('Base Country', 'give'), |
|
267 | + 'desc' => __('The country your site operates from.', 'give'), |
|
268 | 268 | 'id' => 'base_country', |
269 | 269 | 'type' => 'select', |
270 | 270 | 'options' => give_get_country_list(), |
@@ -275,18 +275,18 @@ discard block |
||
275 | 275 | * @since 1.8.14 |
276 | 276 | */ |
277 | 277 | array( |
278 | - 'wrapper_class' => ( array_key_exists( $country, $no_states_country ) ? 'give-hidden' : '' ), |
|
279 | - 'name' => __( 'Base State/Province', 'give' ), |
|
280 | - 'desc' => __( 'The state/province your site operates from.', 'give' ), |
|
278 | + 'wrapper_class' => (array_key_exists($country, $no_states_country) ? 'give-hidden' : ''), |
|
279 | + 'name' => __('Base State/Province', 'give'), |
|
280 | + 'desc' => __('The state/province your site operates from.', 'give'), |
|
281 | 281 | 'id' => 'base_state', |
282 | - 'type' => ( empty( $states ) ? 'text' : 'select' ), |
|
282 | + 'type' => (empty($states) ? 'text' : 'select'), |
|
283 | 283 | 'options' => $states, |
284 | 284 | ), |
285 | 285 | array( |
286 | - 'name' => __( 'General Options Docs Link', 'give' ), |
|
286 | + 'name' => __('General Options Docs Link', 'give'), |
|
287 | 287 | 'id' => 'general_options_docs_link', |
288 | - 'url' => esc_url( 'http://docs.givewp.com/settings-general' ), |
|
289 | - 'title' => __( 'General Options', 'give' ), |
|
288 | + 'url' => esc_url('http://docs.givewp.com/settings-general'), |
|
289 | + 'title' => __('General Options', 'give'), |
|
290 | 290 | 'type' => 'give_docs_link', |
291 | 291 | ), |
292 | 292 | array( |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | * Filter the general settings. |
302 | 302 | * Backward compatibility: Please do not use this filter. This filter is deprecated in 1.8 |
303 | 303 | */ |
304 | - $settings = apply_filters( 'give_settings_general', $settings ); |
|
304 | + $settings = apply_filters('give_settings_general', $settings); |
|
305 | 305 | |
306 | 306 | /** |
307 | 307 | * Filter the settings. |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | * |
311 | 311 | * @param array $settings |
312 | 312 | */ |
313 | - $settings = apply_filters( 'give_get_settings_' . $this->id, $settings ); |
|
313 | + $settings = apply_filters('give_get_settings_'.$this->id, $settings); |
|
314 | 314 | |
315 | 315 | // Output. |
316 | 316 | return $settings; |
@@ -324,12 +324,12 @@ discard block |
||
324 | 324 | */ |
325 | 325 | public function get_sections() { |
326 | 326 | $sections = array( |
327 | - 'general-settings' => __( 'General', 'give' ), |
|
328 | - 'currency-settings' => __( 'Currency', 'give' ), |
|
329 | - 'access-control' => __( 'Access Control', 'give' ), |
|
327 | + 'general-settings' => __('General', 'give'), |
|
328 | + 'currency-settings' => __('Currency', 'give'), |
|
329 | + 'access-control' => __('Access Control', 'give'), |
|
330 | 330 | ); |
331 | 331 | |
332 | - return apply_filters( 'give_get_sections_' . $this->id, $sections ); |
|
332 | + return apply_filters('give_get_sections_'.$this->id, $sections); |
|
333 | 333 | } |
334 | 334 | } |
335 | 335 |
@@ -21,33 +21,33 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @return array |
23 | 23 | */ |
24 | - public static function get_setting_fields( Give_Email_Notification $email, $form_id = null ) { |
|
25 | - $setting_fields = self::get_default_setting_fields( $email, $form_id ); |
|
24 | + public static function get_setting_fields(Give_Email_Notification $email, $form_id = null) { |
|
25 | + $setting_fields = self::get_default_setting_fields($email, $form_id); |
|
26 | 26 | |
27 | 27 | // Recipient field. |
28 | - if ( Give_Email_Notification_Util::has_recipient_field( $email ) ) { |
|
29 | - $setting_fields[] = self::get_recipient_setting_field( $email, $form_id ); |
|
28 | + if (Give_Email_Notification_Util::has_recipient_field($email)) { |
|
29 | + $setting_fields[] = self::get_recipient_setting_field($email, $form_id); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | |
33 | 33 | // Add extra setting field. |
34 | - if ( $extra_setting_field = $email->get_extra_setting_fields( $form_id ) ) { |
|
35 | - $setting_fields = array_merge( $setting_fields, $extra_setting_field ); |
|
34 | + if ($extra_setting_field = $email->get_extra_setting_fields($form_id)) { |
|
35 | + $setting_fields = array_merge($setting_fields, $extra_setting_field); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | // Preview field. |
39 | - if ( Give_Email_Notification_Util::has_preview( $email ) ) { |
|
40 | - $setting_fields[] = self::get_preview_setting_field( $email, $form_id ); |
|
39 | + if (Give_Email_Notification_Util::has_preview($email)) { |
|
40 | + $setting_fields[] = self::get_preview_setting_field($email, $form_id); |
|
41 | 41 | } |
42 | 42 | |
43 | - $setting_fields = self::add_section_end( $email, $setting_fields ); |
|
43 | + $setting_fields = self::add_section_end($email, $setting_fields); |
|
44 | 44 | |
45 | 45 | /** |
46 | 46 | * Filter the email notification settings. |
47 | 47 | * |
48 | 48 | * @since 2.0 |
49 | 49 | */ |
50 | - return apply_filters( 'give_email_notification_setting_fields', $setting_fields, $email, $form_id ); |
|
50 | + return apply_filters('give_email_notification_setting_fields', $setting_fields, $email, $form_id); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | |
@@ -61,11 +61,11 @@ discard block |
||
61 | 61 | * |
62 | 62 | * @return bool |
63 | 63 | */ |
64 | - public static function has_section_end( $setting ) { |
|
65 | - $last_field = end( $setting ); |
|
64 | + public static function has_section_end($setting) { |
|
65 | + $last_field = end($setting); |
|
66 | 66 | $has_section_end = false; |
67 | 67 | |
68 | - if ( 'sectionend' === $last_field['type'] ) { |
|
68 | + if ('sectionend' === $last_field['type']) { |
|
69 | 69 | $has_section_end = true; |
70 | 70 | } |
71 | 71 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | * |
84 | 84 | * @return array |
85 | 85 | */ |
86 | - public static function get_section_start( Give_Email_Notification $email, $form_id = null ) { |
|
86 | + public static function get_section_start(Give_Email_Notification $email, $form_id = null) { |
|
87 | 87 | // Add section end field. |
88 | 88 | $setting = array( |
89 | 89 | 'id' => "give_title_email_settings_{$email->config['id']}", |
@@ -105,8 +105,8 @@ discard block |
||
105 | 105 | * |
106 | 106 | * @return array |
107 | 107 | */ |
108 | - public static function add_section_end( Give_Email_Notification $email, $setting ) { |
|
109 | - if ( ! self::has_section_end( $setting ) ) { |
|
108 | + public static function add_section_end(Give_Email_Notification $email, $setting) { |
|
109 | + if ( ! self::has_section_end($setting)) { |
|
110 | 110 | // Add section end field. |
111 | 111 | $setting[] = array( |
112 | 112 | 'id' => "give_title_email_settings_{$email->config['id']}", |
@@ -128,25 +128,25 @@ discard block |
||
128 | 128 | * |
129 | 129 | * @return array |
130 | 130 | */ |
131 | - public static function get_default_setting_fields( Give_Email_Notification $email, $form_id = null ) { |
|
132 | - $settings[] = self::get_section_start( $email, $form_id ); |
|
133 | - $settings[] = self::get_notification_status_field( $email, $form_id ); |
|
131 | + public static function get_default_setting_fields(Give_Email_Notification $email, $form_id = null) { |
|
132 | + $settings[] = self::get_section_start($email, $form_id); |
|
133 | + $settings[] = self::get_notification_status_field($email, $form_id); |
|
134 | 134 | |
135 | - if ( ! Give_Email_Notification_Util::is_notification_status_editable( $email ) ) { |
|
136 | - if( $form_id || give_is_add_new_form_page() ){ |
|
135 | + if ( ! Give_Email_Notification_Util::is_notification_status_editable($email)) { |
|
136 | + if ($form_id || give_is_add_new_form_page()) { |
|
137 | 137 | // Do not allow admin to disable notification on perform basis. |
138 | - unset( $settings[1]['options']['disabled'] ); |
|
139 | - } else{ |
|
138 | + unset($settings[1]['options']['disabled']); |
|
139 | + } else { |
|
140 | 140 | // Do not allow admin to edit notification status globally. |
141 | - unset( $settings[1] ); |
|
141 | + unset($settings[1]); |
|
142 | 142 | } |
143 | 143 | } |
144 | 144 | |
145 | - $settings[] = self::get_email_subject_field( $email, $form_id ); |
|
146 | - $settings[] = self::get_email_message_field( $email, $form_id ); |
|
145 | + $settings[] = self::get_email_subject_field($email, $form_id); |
|
146 | + $settings[] = self::get_email_message_field($email, $form_id); |
|
147 | 147 | |
148 | - if( Give_Email_Notification_Util::is_content_type_editable( $email ) ) { |
|
149 | - $settings[] = self::get_email_content_type_field( $email, $form_id ); |
|
148 | + if (Give_Email_Notification_Util::is_content_type_editable($email)) { |
|
149 | + $settings[] = self::get_email_content_type_field($email, $form_id); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | return $settings; |
@@ -163,31 +163,31 @@ discard block |
||
163 | 163 | * |
164 | 164 | * @return array |
165 | 165 | */ |
166 | - public static function get_notification_status_field( Give_Email_Notification $email, $form_id = null ) { |
|
166 | + public static function get_notification_status_field(Give_Email_Notification $email, $form_id = null) { |
|
167 | 167 | $option = array( |
168 | - 'enabled' => __( 'Enabled', 'give' ), |
|
169 | - 'disabled' => __( 'Disabled', 'give' ), |
|
168 | + 'enabled' => __('Enabled', 'give'), |
|
169 | + 'disabled' => __('Disabled', 'give'), |
|
170 | 170 | ); |
171 | 171 | |
172 | 172 | $default_value = $email->get_notification_status(); |
173 | 173 | |
174 | 174 | // Add global options. |
175 | - if ( $form_id || give_is_add_new_form_page() ) { |
|
175 | + if ($form_id || give_is_add_new_form_page()) { |
|
176 | 176 | $option = array( |
177 | - 'global' => __( 'Global Options' ), |
|
178 | - 'enabled' => __( 'Customize', 'give' ), |
|
179 | - 'disabled' => __( 'Disabled', 'give' ), |
|
177 | + 'global' => __('Global Options'), |
|
178 | + 'enabled' => __('Customize', 'give'), |
|
179 | + 'disabled' => __('Disabled', 'give'), |
|
180 | 180 | ); |
181 | 181 | |
182 | 182 | $default_value = 'global'; |
183 | 183 | } |
184 | 184 | |
185 | - $description = isset($_GET['page']) && 'give-settings' === $_GET['page'] ? __('Choose whether you want this email enabled or not.', 'give') : sprintf( __( 'Global Options are set <a href="%s">in Give settings</a>. You may override them for this form here.', 'give' ), admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=emails' ) ); |
|
185 | + $description = isset($_GET['page']) && 'give-settings' === $_GET['page'] ? __('Choose whether you want this email enabled or not.', 'give') : sprintf(__('Global Options are set <a href="%s">in Give settings</a>. You may override them for this form here.', 'give'), admin_url('edit.php?post_type=give_forms&page=give-settings&tab=emails')); |
|
186 | 186 | |
187 | 187 | return array( |
188 | - 'name' => esc_html__( 'Notification', 'give' ), |
|
188 | + 'name' => esc_html__('Notification', 'give'), |
|
189 | 189 | 'desc' => $description, |
190 | - 'id' => self::get_prefix( $email, $form_id ) . 'notification', |
|
190 | + 'id' => self::get_prefix($email, $form_id).'notification', |
|
191 | 191 | 'type' => 'radio_inline', |
192 | 192 | 'default' => $default_value, |
193 | 193 | 'options' => $option, |
@@ -206,11 +206,11 @@ discard block |
||
206 | 206 | * |
207 | 207 | * @return array |
208 | 208 | */ |
209 | - public static function get_email_subject_field( Give_Email_Notification $email, $form_id = null ) { |
|
209 | + public static function get_email_subject_field(Give_Email_Notification $email, $form_id = null) { |
|
210 | 210 | return array( |
211 | - 'id' => self::get_prefix( $email, $form_id ) . 'email_subject', |
|
212 | - 'name' => esc_html__( 'Email Subject', 'give' ), |
|
213 | - 'desc' => esc_html__( 'Enter the email subject line.', 'give' ), |
|
211 | + 'id' => self::get_prefix($email, $form_id).'email_subject', |
|
212 | + 'name' => esc_html__('Email Subject', 'give'), |
|
213 | + 'desc' => esc_html__('Enter the email subject line.', 'give'), |
|
214 | 214 | 'default' => $email->config['default_email_subject'], |
215 | 215 | 'type' => 'text', |
216 | 216 | ); |
@@ -227,28 +227,28 @@ discard block |
||
227 | 227 | * |
228 | 228 | * @return array |
229 | 229 | */ |
230 | - public static function get_email_message_field( Give_Email_Notification $email, $form_id = null ) { |
|
231 | - $desc = esc_html__( 'Enter the email message.', 'give' ); |
|
230 | + public static function get_email_message_field(Give_Email_Notification $email, $form_id = null) { |
|
231 | + $desc = esc_html__('Enter the email message.', 'give'); |
|
232 | 232 | |
233 | - if ( $email_tag_list = $email->get_allowed_email_tags( true ) ) { |
|
233 | + if ($email_tag_list = $email->get_allowed_email_tags(true)) { |
|
234 | 234 | $desc = sprintf( |
235 | 235 | '%1$s <br> %2$s: %3$s %4$s', |
236 | - __( 'The email that is sent to users after completing a successful donation. HTML is accepted.', 'give' ), |
|
237 | - __( 'Available template tags', 'give' ), |
|
236 | + __('The email that is sent to users after completing a successful donation. HTML is accepted.', 'give'), |
|
237 | + __('Available template tags', 'give'), |
|
238 | 238 | $email_tag_list, |
239 | 239 | sprintf( |
240 | 240 | '<br><a href="%1$s" target="_blank">%2$s</a> %3$s', |
241 | 241 | esc_url('http://docs.givewp.com/meta-email-tags'), |
242 | - __( 'See our documentation', 'give' ), |
|
243 | - __( 'for examples of how to use custom meta email tags to output additional donor or donation information in your Give emails.', 'give' ) |
|
242 | + __('See our documentation', 'give'), |
|
243 | + __('for examples of how to use custom meta email tags to output additional donor or donation information in your Give emails.', 'give') |
|
244 | 244 | ) |
245 | 245 | ); |
246 | 246 | |
247 | 247 | } |
248 | 248 | |
249 | 249 | return array( |
250 | - 'id' => self::get_prefix( $email, $form_id ) . 'email_message', |
|
251 | - 'name' => esc_html__( 'Email message', 'give' ), |
|
250 | + 'id' => self::get_prefix($email, $form_id).'email_message', |
|
251 | + 'name' => esc_html__('Email message', 'give'), |
|
252 | 252 | 'desc' => $desc, |
253 | 253 | 'type' => 'wysiwyg', |
254 | 254 | 'default' => $email->config['default_email_message'], |
@@ -266,15 +266,15 @@ discard block |
||
266 | 266 | * |
267 | 267 | * @return array |
268 | 268 | */ |
269 | - public static function get_email_content_type_field( Give_Email_Notification $email, $form_id = null ) { |
|
269 | + public static function get_email_content_type_field(Give_Email_Notification $email, $form_id = null) { |
|
270 | 270 | return array( |
271 | - 'id' => self::get_prefix( $email, $form_id ) . 'email_content_type', |
|
272 | - 'name' => esc_html__( 'Email Content Type', 'give' ), |
|
273 | - 'desc' => __( 'Choose email type.', 'give' ), |
|
271 | + 'id' => self::get_prefix($email, $form_id).'email_content_type', |
|
272 | + 'name' => esc_html__('Email Content Type', 'give'), |
|
273 | + 'desc' => __('Choose email type.', 'give'), |
|
274 | 274 | 'type' => 'select', |
275 | 275 | 'options' => array( |
276 | - 'text/html' => Give_Email_Notification_Util::get_formatted_email_type( 'text/html' ), |
|
277 | - 'text/plain' => Give_Email_Notification_Util::get_formatted_email_type( 'text/plain' ), |
|
276 | + 'text/html' => Give_Email_Notification_Util::get_formatted_email_type('text/html'), |
|
277 | + 'text/plain' => Give_Email_Notification_Util::get_formatted_email_type('text/plain'), |
|
278 | 278 | ), |
279 | 279 | 'default' => $email->config['content_type'], |
280 | 280 | ); |
@@ -293,29 +293,29 @@ discard block |
||
293 | 293 | * |
294 | 294 | * @return array |
295 | 295 | */ |
296 | - public static function get_recipient_setting_field( Give_Email_Notification $email, $form_id = null ) { |
|
297 | - $recipient = array( |
|
298 | - 'id' => self::get_prefix( $email, $form_id ) . 'recipient', |
|
299 | - 'name' => esc_html__( 'Email Recipients', 'give' ), |
|
300 | - 'desc' => __( 'Enter the email address(es) that should receive a notification.', 'give' ), |
|
296 | + public static function get_recipient_setting_field(Give_Email_Notification $email, $form_id = null) { |
|
297 | + $recipient = array( |
|
298 | + 'id' => self::get_prefix($email, $form_id).'recipient', |
|
299 | + 'name' => esc_html__('Email Recipients', 'give'), |
|
300 | + 'desc' => __('Enter the email address(es) that should receive a notification.', 'give'), |
|
301 | 301 | 'type' => 'email', |
302 | - 'default' => get_bloginfo( 'admin_email' ), |
|
302 | + 'default' => get_bloginfo('admin_email'), |
|
303 | 303 | 'repeat' => true, |
304 | - 'repeat_btn_title' => esc_html__( 'Add Recipient', 'give' ), |
|
304 | + 'repeat_btn_title' => esc_html__('Add Recipient', 'give'), |
|
305 | 305 | ); |
306 | 306 | |
307 | - if ( $form_id || give_is_add_new_form_page() ) { |
|
308 | - $recipient['name'] = __( 'Email', 'give' ); |
|
307 | + if ($form_id || give_is_add_new_form_page()) { |
|
308 | + $recipient['name'] = __('Email', 'give'); |
|
309 | 309 | $recipient['default'] = ''; |
310 | 310 | $recipient['id'] = 'email'; |
311 | - $recipient['desc'] = __( 'Enter the email address that should receive a notification.', 'give' ); |
|
311 | + $recipient['desc'] = __('Enter the email address that should receive a notification.', 'give'); |
|
312 | 312 | |
313 | 313 | $recipient = array( |
314 | - 'id' => self::get_prefix( $email, $form_id ) . 'recipient', |
|
314 | + 'id' => self::get_prefix($email, $form_id).'recipient', |
|
315 | 315 | 'type' => 'group', |
316 | 316 | 'options' => array( |
317 | - 'add_button' => __( 'Add Email', 'give' ), |
|
318 | - 'header_title' => __( 'Email Recipient', 'give' ), |
|
317 | + 'add_button' => __('Add Email', 'give'), |
|
318 | + 'header_title' => __('Email Recipient', 'give'), |
|
319 | 319 | 'remove_button' => '<span class="dashicons dashicons-no"></span>', |
320 | 320 | ), |
321 | 321 | 'fields' => array( |
@@ -338,12 +338,12 @@ discard block |
||
338 | 338 | * |
339 | 339 | * @return array |
340 | 340 | */ |
341 | - public static function get_preview_setting_field( Give_Email_Notification $email, $form_id = null ) { |
|
341 | + public static function get_preview_setting_field(Give_Email_Notification $email, $form_id = null) { |
|
342 | 342 | return array( |
343 | - 'name' => __( 'Preview Email', 'give' ), |
|
344 | - 'desc' => __( 'Click the "Preview Email" button to preview the email in your browser. Click the "Send Test Email" button to send a test email directly to your inbox.', |
|
345 | - 'give' ), |
|
346 | - 'id' => self::get_prefix( $email, $form_id ) . 'preview_buttons', |
|
343 | + 'name' => __('Preview Email', 'give'), |
|
344 | + 'desc' => __('Click the "Preview Email" button to preview the email in your browser. Click the "Send Test Email" button to send a test email directly to your inbox.', |
|
345 | + 'give'), |
|
346 | + 'id' => self::get_prefix($email, $form_id).'preview_buttons', |
|
347 | 347 | 'type' => 'email_preview_buttons', |
348 | 348 | ); |
349 | 349 | } |
@@ -360,10 +360,10 @@ discard block |
||
360 | 360 | * |
361 | 361 | * @return string |
362 | 362 | */ |
363 | - public static function get_prefix( Give_Email_Notification $email, $form_id = null ) { |
|
363 | + public static function get_prefix(Give_Email_Notification $email, $form_id = null) { |
|
364 | 364 | $meta_key = "{$email->config['id']}_"; |
365 | 365 | |
366 | - if( $form_id || give_is_add_new_form_page() ) { |
|
366 | + if ($form_id || give_is_add_new_form_page()) { |
|
367 | 367 | $meta_key = "_give_{$email->config['id']}_"; |
368 | 368 | } |
369 | 369 |
@@ -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 | |
@@ -21,12 +21,12 @@ discard block |
||
21 | 21 | * @return void |
22 | 22 | */ |
23 | 23 | function give_register_dashboard_widgets() { |
24 | - if ( current_user_can( apply_filters( 'give_dashboard_stats_cap', 'view_give_reports' ) ) ) { |
|
25 | - wp_add_dashboard_widget( 'give_dashboard_sales', __( 'Give: Donation Statistics', 'give' ), 'give_dashboard_sales_widget' ); |
|
24 | + if (current_user_can(apply_filters('give_dashboard_stats_cap', 'view_give_reports'))) { |
|
25 | + wp_add_dashboard_widget('give_dashboard_sales', __('Give: Donation Statistics', 'give'), 'give_dashboard_sales_widget'); |
|
26 | 26 | } |
27 | 27 | } |
28 | 28 | |
29 | -add_action( 'wp_dashboard_setup', 'give_register_dashboard_widgets', 10 ); |
|
29 | +add_action('wp_dashboard_setup', 'give_register_dashboard_widgets', 10); |
|
30 | 30 | |
31 | 31 | /** |
32 | 32 | * Sales Summary Dashboard Widget |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | */ |
39 | 39 | function give_dashboard_sales_widget() { |
40 | 40 | |
41 | - if ( ! current_user_can( apply_filters( 'give_dashboard_stats_cap', 'view_give_reports' ) ) ) { |
|
41 | + if ( ! current_user_can(apply_filters('give_dashboard_stats_cap', 'view_give_reports'))) { |
|
42 | 42 | return; |
43 | 43 | } |
44 | 44 | $stats = new Give_Payment_Stats(); ?> |
@@ -46,27 +46,27 @@ discard block |
||
46 | 46 | <div class="give-dashboard-widget"> |
47 | 47 | |
48 | 48 | <div class="give-dashboard-today give-clearfix"> |
49 | - <h3 class="give-dashboard-date-today"><?php echo date_i18n( _x( 'F j, Y', 'dashboard widget', 'give' ) ); ?></h3> |
|
49 | + <h3 class="give-dashboard-date-today"><?php echo date_i18n(_x('F j, Y', 'dashboard widget', 'give')); ?></h3> |
|
50 | 50 | |
51 | 51 | <p class="give-dashboard-happy-day"><?php |
52 | 52 | printf( |
53 | 53 | /* translators: %s: day of the week */ |
54 | - __( 'Happy %s!', 'give' ), |
|
55 | - date_i18n( 'l', current_time( 'timestamp' ) ) |
|
54 | + __('Happy %s!', 'give'), |
|
55 | + date_i18n('l', current_time('timestamp')) |
|
56 | 56 | ); |
57 | 57 | ?></p> |
58 | 58 | |
59 | 59 | <p class="give-dashboard-today-earnings"><?php |
60 | - $earnings_today = $stats->get_earnings( 0, 'today', false ); |
|
61 | - echo give_currency_filter( give_format_amount( $earnings_today, array( 'sanitize' => false ) ) ); |
|
60 | + $earnings_today = $stats->get_earnings(0, 'today', false); |
|
61 | + echo give_currency_filter(give_format_amount($earnings_today, array('sanitize' => false))); |
|
62 | 62 | ?></p> |
63 | 63 | |
64 | 64 | <p class="give-donations-today"><?php |
65 | - $donations_today = $stats->get_sales( 0, 'today', false ); |
|
65 | + $donations_today = $stats->get_sales(0, 'today', false); |
|
66 | 66 | printf( |
67 | 67 | /* translators: %s: daily donation count */ |
68 | - __( '%s donations today', 'give' ), |
|
69 | - give_format_amount( $donations_today, array( 'decimal' => false, 'sanitize' => false ) ) |
|
68 | + __('%s donations today', 'give'), |
|
69 | + give_format_amount($donations_today, array('decimal' => false, 'sanitize' => false)) |
|
70 | 70 | ); |
71 | 71 | ?></p> |
72 | 72 | |
@@ -76,34 +76,34 @@ discard block |
||
76 | 76 | <table class="give-table-stats"> |
77 | 77 | <thead style="display: none;"> |
78 | 78 | <tr> |
79 | - <th><?php _e( 'This Week', 'give' ); ?></th> |
|
80 | - <th><?php _e( 'This Month', 'give' ); ?></th> |
|
81 | - <th><?php _e( 'Past 30 Days', 'give' ); ?></th> |
|
79 | + <th><?php _e('This Week', 'give'); ?></th> |
|
80 | + <th><?php _e('This Month', 'give'); ?></th> |
|
81 | + <th><?php _e('Past 30 Days', 'give'); ?></th> |
|
82 | 82 | </tr> |
83 | 83 | </thead> |
84 | 84 | <tbody> |
85 | 85 | <tr id="give-table-stats-tr-1"> |
86 | 86 | <td> |
87 | - <p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( $stats->get_earnings( 0, 'this_week' ), array( 'sanitize' => false ) ) ); ?></p> |
|
87 | + <p class="give-dashboard-stat-total"><?php echo give_currency_filter(give_format_amount($stats->get_earnings(0, 'this_week'), array('sanitize' => false))); ?></p> |
|
88 | 88 | |
89 | - <p class="give-dashboard-stat-total-label"><?php _e( 'This Week', 'give' ); ?></p> |
|
89 | + <p class="give-dashboard-stat-total-label"><?php _e('This Week', 'give'); ?></p> |
|
90 | 90 | </td> |
91 | 91 | <td> |
92 | - <p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( $stats->get_earnings( 0, 'this_month' ), array( 'sanitize' => false ) ) ); ?></p> |
|
92 | + <p class="give-dashboard-stat-total"><?php echo give_currency_filter(give_format_amount($stats->get_earnings(0, 'this_month'), array('sanitize' => false))); ?></p> |
|
93 | 93 | |
94 | - <p class="give-dashboard-stat-total-label"><?php _e( 'This Month', 'give' ); ?></p> |
|
94 | + <p class="give-dashboard-stat-total-label"><?php _e('This Month', 'give'); ?></p> |
|
95 | 95 | </td> |
96 | 96 | </tr> |
97 | 97 | <tr id="give-table-stats-tr-2"> |
98 | 98 | <td> |
99 | - <p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( $stats->get_earnings( 0, 'last_month' ), array( 'sanitize' => false ) ) ) ?></p> |
|
99 | + <p class="give-dashboard-stat-total"><?php echo give_currency_filter(give_format_amount($stats->get_earnings(0, 'last_month'), array('sanitize' => false))) ?></p> |
|
100 | 100 | |
101 | - <p class="give-dashboard-stat-total-label"><?php _e( 'Last Month', 'give' ); ?></p> |
|
101 | + <p class="give-dashboard-stat-total-label"><?php _e('Last Month', 'give'); ?></p> |
|
102 | 102 | </td> |
103 | 103 | <td> |
104 | - <p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( give_get_total_earnings(), array( 'sanitize' => false ) ) ) ?></p> |
|
104 | + <p class="give-dashboard-stat-total"><?php echo give_currency_filter(give_format_amount(give_get_total_earnings(), array('sanitize' => false))) ?></p> |
|
105 | 105 | |
106 | - <p class="give-dashboard-stat-total-label"><?php _e( 'This Year', 'give' ); ?></p> |
|
106 | + <p class="give-dashboard-stat-total-label"><?php _e('This Year', 'give'); ?></p> |
|
107 | 107 | </td> |
108 | 108 | </tr> |
109 | 109 | </tbody> |
@@ -123,24 +123,24 @@ discard block |
||
123 | 123 | * |
124 | 124 | * @return array |
125 | 125 | */ |
126 | -function give_dashboard_at_a_glance_widget( $items ) { |
|
126 | +function give_dashboard_at_a_glance_widget($items) { |
|
127 | 127 | |
128 | - $num_posts = wp_count_posts( 'give_forms' ); |
|
128 | + $num_posts = wp_count_posts('give_forms'); |
|
129 | 129 | |
130 | - if ( $num_posts && $num_posts->publish ) { |
|
130 | + if ($num_posts && $num_posts->publish) { |
|
131 | 131 | |
132 | 132 | $text = sprintf( |
133 | 133 | /* translators: %s: number of posts published */ |
134 | - _n( '%s Give Form', '%s Give Forms', $num_posts->publish, 'give' ), |
|
134 | + _n('%s Give Form', '%s Give Forms', $num_posts->publish, 'give'), |
|
135 | 135 | $num_posts->publish |
136 | 136 | ); |
137 | 137 | |
138 | - $text = sprintf( $text, number_format_i18n( $num_posts->publish ) ); |
|
138 | + $text = sprintf($text, number_format_i18n($num_posts->publish)); |
|
139 | 139 | |
140 | - if ( current_user_can( 'edit_give_forms', get_current_user_id() ) ) { |
|
140 | + if (current_user_can('edit_give_forms', get_current_user_id())) { |
|
141 | 141 | $text = sprintf( |
142 | 142 | '<a class="give-forms-count" href="%1$s">%2$s</a>', |
143 | - admin_url( 'edit.php?post_type=give_forms' ), |
|
143 | + admin_url('edit.php?post_type=give_forms'), |
|
144 | 144 | $text |
145 | 145 | ); |
146 | 146 | } else { |
@@ -156,4 +156,4 @@ discard block |
||
156 | 156 | return $items; |
157 | 157 | } |
158 | 158 | |
159 | -add_filter( 'dashboard_glance_items', 'give_dashboard_at_a_glance_widget', 1, 1 ); |
|
159 | +add_filter('dashboard_glance_items', 'give_dashboard_at_a_glance_widget', 1, 1); |