@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | */ |
12 | 12 | |
13 | 13 | // Exit if accessed directly. |
14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
14 | +if ( ! defined('ABSPATH')) { |
|
15 | 15 | exit; |
16 | 16 | } |
17 | 17 | |
@@ -80,104 +80,102 @@ discard block |
||
80 | 80 | */ |
81 | 81 | public function get_data() { |
82 | 82 | |
83 | - $totals = $this->get_stored_data( 'give_temp_recount_all_stats' ); |
|
84 | - $payment_items = $this->get_stored_data( 'give_temp_payment_items' ); |
|
85 | - $processed_payments = $this->get_stored_data( 'give_temp_processed_payments' ); |
|
86 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) ); |
|
83 | + $totals = $this->get_stored_data('give_temp_recount_all_stats'); |
|
84 | + $payment_items = $this->get_stored_data('give_temp_payment_items'); |
|
85 | + $processed_payments = $this->get_stored_data('give_temp_processed_payments'); |
|
86 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish')); |
|
87 | 87 | |
88 | - if ( false === $totals ) { |
|
88 | + if (false === $totals) { |
|
89 | 89 | $totals = array(); |
90 | 90 | } |
91 | 91 | |
92 | - if ( false === $payment_items ) { |
|
92 | + if (false === $payment_items) { |
|
93 | 93 | $payment_items = array(); |
94 | 94 | } |
95 | 95 | |
96 | - if ( false === $processed_payments ) { |
|
96 | + if (false === $processed_payments) { |
|
97 | 97 | $processed_payments = array(); |
98 | 98 | } |
99 | 99 | |
100 | - $all_forms = $this->get_stored_data( 'give_temp_form_ids' ); |
|
100 | + $all_forms = $this->get_stored_data('give_temp_form_ids'); |
|
101 | 101 | |
102 | - $payments = $this->get_stored_data( 'give_temp_all_payments_data' ); |
|
102 | + $payments = $this->get_stored_data('give_temp_all_payments_data'); |
|
103 | 103 | |
104 | - if ( false === $payments ) { |
|
105 | - $args = apply_filters( 'give_recount_form_stats_args', array( |
|
104 | + if (false === $payments) { |
|
105 | + $args = apply_filters('give_recount_form_stats_args', array( |
|
106 | 106 | 'post_parent__in' => $all_forms, |
107 | 107 | 'number' => $this->per_step, |
108 | 108 | 'status' => 'publish', |
109 | 109 | 'paged' => $this->step, |
110 | 110 | 'output' => 'payments', |
111 | - ) ); |
|
111 | + )); |
|
112 | 112 | |
113 | - $payments_query = new Give_Payments_Query( $args ); |
|
113 | + $payments_query = new Give_Payments_Query($args); |
|
114 | 114 | $payments = $payments_query->get_payments(); |
115 | 115 | } |
116 | 116 | |
117 | - if ( $payments ) { |
|
117 | + if ($payments) { |
|
118 | 118 | |
119 | 119 | //Loop through payments |
120 | - foreach ( $payments as $payment ) { |
|
120 | + foreach ($payments as $payment) { |
|
121 | 121 | |
122 | 122 | // Prevent payments that have all ready been retrieved from a previous sales log from counting again. |
123 | - if ( in_array( $payment->ID, $processed_payments ) ) { |
|
123 | + if (in_array($payment->ID, $processed_payments)) { |
|
124 | 124 | continue; |
125 | 125 | } |
126 | 126 | |
127 | 127 | // Verify accepted status |
128 | - if ( ! in_array( $payment->post_status, $accepted_statuses ) ) { |
|
128 | + if ( ! in_array($payment->post_status, $accepted_statuses)) { |
|
129 | 129 | $processed_payments[] = $payment->ID; |
130 | 130 | continue; |
131 | 131 | } |
132 | 132 | |
133 | - $payment_item = $payment_items[ $payment->ID ]; |
|
133 | + $payment_item = $payment_items[$payment->ID]; |
|
134 | 134 | |
135 | - $form_id = isset( $payment_item['id'] ) ? $payment_item['id'] : ''; |
|
135 | + $form_id = isset($payment_item['id']) ? $payment_item['id'] : ''; |
|
136 | 136 | |
137 | 137 | //Must have a form ID |
138 | - if ( empty( $form_id ) ) { |
|
138 | + if (empty($form_id)) { |
|
139 | 139 | continue; |
140 | 140 | } |
141 | 141 | |
142 | 142 | //Form ID must be within $all_forms array to be validated |
143 | - if ( ! in_array( $form_id, $all_forms ) ) { |
|
143 | + if ( ! in_array($form_id, $all_forms)) { |
|
144 | 144 | continue; |
145 | 145 | } |
146 | 146 | |
147 | 147 | // Set Sales count |
148 | - $totals[ $form_id ]['sales'] = isset( $totals[ $form_id ]['sales'] ) ? |
|
149 | - ++ $totals[ $form_id ]['sales'] : |
|
150 | - 1; |
|
148 | + $totals[$form_id]['sales'] = isset($totals[$form_id]['sales']) ? |
|
149 | + ++$totals[$form_id]['sales'] : 1; |
|
151 | 150 | |
152 | 151 | // Set Total Earnings |
153 | - $totals[ $form_id ]['earnings'] = isset( $totals[ $form_id ]['earnings'] ) ? |
|
154 | - ( $totals[ $form_id ]['earnings'] + $payment_item['price'] ) : |
|
155 | - $payment_item['price']; |
|
152 | + $totals[$form_id]['earnings'] = isset($totals[$form_id]['earnings']) ? |
|
153 | + ($totals[$form_id]['earnings'] + $payment_item['price']) : $payment_item['price']; |
|
156 | 154 | |
157 | 155 | $processed_payments[] = $payment->ID; |
158 | 156 | } |
159 | 157 | |
160 | 158 | // Get the list of form ids which does not contain any payment record. |
161 | - $remaining_form_ids = array_diff( $all_forms, array_keys( $totals ) ); |
|
162 | - foreach ( $remaining_form_ids as $form_id ) { |
|
159 | + $remaining_form_ids = array_diff($all_forms, array_keys($totals)); |
|
160 | + foreach ($remaining_form_ids as $form_id) { |
|
163 | 161 | //If array key doesn't exist, create it |
164 | - if ( ! array_key_exists( $form_id, $totals ) ) { |
|
165 | - $totals[ $form_id ] = array( |
|
162 | + if ( ! array_key_exists($form_id, $totals)) { |
|
163 | + $totals[$form_id] = array( |
|
166 | 164 | 'sales' => (int) 0, |
167 | 165 | 'earnings' => (float) 0, |
168 | 166 | ); |
169 | 167 | } |
170 | 168 | } |
171 | 169 | |
172 | - $this->store_data( 'give_temp_processed_payments', $processed_payments ); |
|
173 | - $this->store_data( 'give_temp_recount_all_stats', $totals ); |
|
170 | + $this->store_data('give_temp_processed_payments', $processed_payments); |
|
171 | + $this->store_data('give_temp_recount_all_stats', $totals); |
|
174 | 172 | |
175 | 173 | return true; |
176 | 174 | } |
177 | 175 | |
178 | - foreach ( $totals as $key => $stats ) { |
|
179 | - give_update_meta( $key, '_give_form_sales', $stats['sales'] ); |
|
180 | - give_update_meta( $key, '_give_form_earnings', give_sanitize_amount_for_db( $stats['earnings'] ) ); |
|
176 | + foreach ($totals as $key => $stats) { |
|
177 | + give_update_meta($key, '_give_form_sales', $stats['sales']); |
|
178 | + give_update_meta($key, '_give_form_earnings', give_sanitize_amount_for_db($stats['earnings'])); |
|
181 | 179 | } |
182 | 180 | |
183 | 181 | return false; |
@@ -192,20 +190,20 @@ discard block |
||
192 | 190 | */ |
193 | 191 | public function get_percentage_complete() { |
194 | 192 | |
195 | - $total = $this->get_stored_data( 'give_recount_all_total' ); |
|
193 | + $total = $this->get_stored_data('give_recount_all_total'); |
|
196 | 194 | |
197 | - if ( false === $total ) { |
|
195 | + if (false === $total) { |
|
198 | 196 | $this->pre_fetch(); |
199 | - $total = $this->get_stored_data( 'give_recount_all_total' ); |
|
197 | + $total = $this->get_stored_data('give_recount_all_total'); |
|
200 | 198 | } |
201 | 199 | |
202 | 200 | $percentage = 100; |
203 | 201 | |
204 | - if ( $total > 0 ) { |
|
205 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
202 | + if ($total > 0) { |
|
203 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
206 | 204 | } |
207 | 205 | |
208 | - if ( $percentage > 100 ) { |
|
206 | + if ($percentage > 100) { |
|
209 | 207 | $percentage = 100; |
210 | 208 | } |
211 | 209 | |
@@ -219,8 +217,8 @@ discard block |
||
219 | 217 | * |
220 | 218 | * @param array $request The Form Data passed into the batch processing |
221 | 219 | */ |
222 | - public function set_properties( $request ) { |
|
223 | - $this->form_id = isset( $request['form_id'] ) ? sanitize_text_field( $request['form_id'] ) : false; |
|
220 | + public function set_properties($request) { |
|
221 | + $this->form_id = isset($request['form_id']) ? sanitize_text_field($request['form_id']) : false; |
|
224 | 222 | } |
225 | 223 | |
226 | 224 | /** |
@@ -231,35 +229,35 @@ discard block |
||
231 | 229 | */ |
232 | 230 | public function process_step() { |
233 | 231 | |
234 | - if ( ! $this->can_export() ) { |
|
235 | - wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
232 | + if ( ! $this->can_export()) { |
|
233 | + wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
236 | 234 | } |
237 | 235 | |
238 | 236 | $had_data = $this->get_data(); |
239 | 237 | |
240 | - if ( $had_data ) { |
|
238 | + if ($had_data) { |
|
241 | 239 | $this->done = false; |
242 | 240 | |
243 | 241 | return true; |
244 | 242 | } else { |
245 | - $this->delete_data( 'give_recount_total_' . $this->form_id ); |
|
246 | - $this->delete_data( 'give_recount_all_total' ); |
|
247 | - $this->delete_data( 'give_temp_recount_all_stats' ); |
|
248 | - $this->delete_data( 'give_temp_payment_items' ); |
|
249 | - $this->delete_data( 'give_temp_form_ids' ); |
|
250 | - $this->delete_data( 'give_temp_processed_payments' ); |
|
243 | + $this->delete_data('give_recount_total_'.$this->form_id); |
|
244 | + $this->delete_data('give_recount_all_total'); |
|
245 | + $this->delete_data('give_temp_recount_all_stats'); |
|
246 | + $this->delete_data('give_temp_payment_items'); |
|
247 | + $this->delete_data('give_temp_form_ids'); |
|
248 | + $this->delete_data('give_temp_processed_payments'); |
|
251 | 249 | $this->done = true; |
252 | - $this->message = esc_html__( 'Donation form income amounts and donation counts stats successfully recounted.', 'give' ); |
|
250 | + $this->message = esc_html__('Donation form income amounts and donation counts stats successfully recounted.', 'give'); |
|
253 | 251 | |
254 | 252 | return false; |
255 | 253 | } |
256 | 254 | } |
257 | 255 | |
258 | 256 | public function headers() { |
259 | - ignore_user_abort( true ); |
|
257 | + ignore_user_abort(true); |
|
260 | 258 | |
261 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
262 | - set_time_limit( 0 ); |
|
259 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
260 | + set_time_limit(0); |
|
263 | 261 | } |
264 | 262 | } |
265 | 263 | |
@@ -286,69 +284,69 @@ discard block |
||
286 | 284 | */ |
287 | 285 | public function pre_fetch() { |
288 | 286 | |
289 | - if ( $this->step == 1 ) { |
|
290 | - $this->delete_data( 'give_temp_recount_all_total' ); |
|
291 | - $this->delete_data( 'give_temp_recount_all_stats' ); |
|
292 | - $this->delete_data( 'give_temp_payment_items' ); |
|
293 | - $this->delete_data( 'give_temp_processed_payments' ); |
|
294 | - $this->delete_data( 'give_temp_all_payments_data' ); |
|
287 | + if ($this->step == 1) { |
|
288 | + $this->delete_data('give_temp_recount_all_total'); |
|
289 | + $this->delete_data('give_temp_recount_all_stats'); |
|
290 | + $this->delete_data('give_temp_payment_items'); |
|
291 | + $this->delete_data('give_temp_processed_payments'); |
|
292 | + $this->delete_data('give_temp_all_payments_data'); |
|
295 | 293 | } |
296 | 294 | |
297 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) ); |
|
298 | - $total = $this->get_stored_data( 'give_temp_recount_all_total' ); |
|
295 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish')); |
|
296 | + $total = $this->get_stored_data('give_temp_recount_all_total'); |
|
299 | 297 | |
300 | - if ( false === $total ) { |
|
298 | + if (false === $total) { |
|
301 | 299 | $total = 0; |
302 | - $payment_items = $this->get_stored_data( 'give_temp_payment_items' ); |
|
300 | + $payment_items = $this->get_stored_data('give_temp_payment_items'); |
|
303 | 301 | |
304 | - if ( false === $payment_items ) { |
|
302 | + if (false === $payment_items) { |
|
305 | 303 | $payment_items = array(); |
306 | - $this->store_data( 'give_temp_payment_items', $payment_items ); |
|
304 | + $this->store_data('give_temp_payment_items', $payment_items); |
|
307 | 305 | } |
308 | 306 | |
309 | 307 | $args = array( |
310 | 308 | 'post_status' => 'publish', |
311 | 309 | 'post_type' => 'give_forms', |
312 | - 'posts_per_page' => - 1, |
|
310 | + 'posts_per_page' => -1, |
|
313 | 311 | 'fields' => 'ids', |
314 | 312 | ); |
315 | 313 | |
316 | - $all_forms = get_posts( $args ); |
|
317 | - $this->store_data( 'give_temp_form_ids', $all_forms ); |
|
314 | + $all_forms = get_posts($args); |
|
315 | + $this->store_data('give_temp_form_ids', $all_forms); |
|
318 | 316 | |
319 | - $args = apply_filters( 'give_recount_form_stats_total_args', array( |
|
317 | + $args = apply_filters('give_recount_form_stats_total_args', array( |
|
320 | 318 | 'post_parent__in' => $all_forms, |
321 | 319 | 'number' => $this->per_step, |
322 | 320 | 'status' => 'publish', |
323 | 321 | 'page' => $this->step, |
324 | 322 | 'output' => 'payments', |
325 | - ) ); |
|
323 | + )); |
|
326 | 324 | |
327 | - $payments_query = new Give_Payments_Query( $args ); |
|
325 | + $payments_query = new Give_Payments_Query($args); |
|
328 | 326 | $payments = $payments_query->get_payments(); |
329 | - $total = wp_count_posts( 'give_payment' )->publish; |
|
327 | + $total = wp_count_posts('give_payment')->publish; |
|
330 | 328 | |
331 | - $this->store_data( 'give_temp_all_payments_data', $payments ); |
|
329 | + $this->store_data('give_temp_all_payments_data', $payments); |
|
332 | 330 | |
333 | - if ( $payments ) { |
|
331 | + if ($payments) { |
|
334 | 332 | |
335 | - foreach ( $payments as $payment ) { |
|
333 | + foreach ($payments as $payment) { |
|
336 | 334 | |
337 | - $payment = new Give_Payment( $payment->ID ); |
|
335 | + $payment = new Give_Payment($payment->ID); |
|
338 | 336 | $form_id = $payment->form_id; |
339 | 337 | |
340 | 338 | //If for some reason somehow the form_ID isn't set check payment meta |
341 | - if ( empty( $payment->form_id ) ) { |
|
339 | + if (empty($payment->form_id)) { |
|
342 | 340 | $payment_meta = $payment->get_meta(); |
343 | - $form_id = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : 0; |
|
341 | + $form_id = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : 0; |
|
344 | 342 | } |
345 | 343 | |
346 | - if ( ! in_array( $payment->post_status, $accepted_statuses ) ) { |
|
344 | + if ( ! in_array($payment->post_status, $accepted_statuses)) { |
|
347 | 345 | continue; |
348 | 346 | } |
349 | 347 | |
350 | - if ( ! array_key_exists( $payment->ID, $payment_items ) ) { |
|
351 | - $payment_items[ $payment->ID ] = array( |
|
348 | + if ( ! array_key_exists($payment->ID, $payment_items)) { |
|
349 | + $payment_items[$payment->ID] = array( |
|
352 | 350 | 'id' => $form_id, |
353 | 351 | 'payment_id' => $payment->ID, |
354 | 352 | 'price' => $payment->total, |
@@ -359,8 +357,8 @@ discard block |
||
359 | 357 | |
360 | 358 | } |
361 | 359 | |
362 | - $this->store_data( 'give_temp_payment_items', $payment_items ); |
|
363 | - $this->store_data( 'give_recount_all_total', $total ); |
|
360 | + $this->store_data('give_temp_payment_items', $payment_items); |
|
361 | + $this->store_data('give_recount_all_total', $total); |
|
364 | 362 | } |
365 | 363 | |
366 | 364 | } |
@@ -374,17 +372,17 @@ discard block |
||
374 | 372 | * |
375 | 373 | * @return mixed Returns the data from the database |
376 | 374 | */ |
377 | - private function get_stored_data( $key ) { |
|
375 | + private function get_stored_data($key) { |
|
378 | 376 | global $wpdb; |
379 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
377 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
380 | 378 | |
381 | - if ( empty( $value ) ) { |
|
379 | + if (empty($value)) { |
|
382 | 380 | return false; |
383 | 381 | } |
384 | 382 | |
385 | - $maybe_json = json_decode( $value ); |
|
386 | - if ( ! is_null( $maybe_json ) ) { |
|
387 | - $value = json_decode( $value, true ); |
|
383 | + $maybe_json = json_decode($value); |
|
384 | + if ( ! is_null($maybe_json)) { |
|
385 | + $value = json_decode($value, true); |
|
388 | 386 | } |
389 | 387 | |
390 | 388 | return $value; |
@@ -400,10 +398,10 @@ discard block |
||
400 | 398 | * |
401 | 399 | * @return void |
402 | 400 | */ |
403 | - private function store_data( $key, $value ) { |
|
401 | + private function store_data($key, $value) { |
|
404 | 402 | global $wpdb; |
405 | 403 | |
406 | - $value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value ); |
|
404 | + $value = is_array($value) ? wp_json_encode($value) : esc_attr($value); |
|
407 | 405 | |
408 | 406 | $data = array( |
409 | 407 | 'option_name' => $key, |
@@ -417,7 +415,7 @@ discard block |
||
417 | 415 | '%s', |
418 | 416 | ); |
419 | 417 | |
420 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
418 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
421 | 419 | } |
422 | 420 | |
423 | 421 | /** |
@@ -429,9 +427,9 @@ discard block |
||
429 | 427 | * |
430 | 428 | * @return void |
431 | 429 | */ |
432 | - private function delete_data( $key ) { |
|
430 | + private function delete_data($key) { |
|
433 | 431 | global $wpdb; |
434 | - $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) ); |
|
432 | + $wpdb->delete($wpdb->options, array('option_name' => $key)); |
|
435 | 433 | } |
436 | 434 | |
437 | 435 | } |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | */ |
12 | 12 | |
13 | 13 | // Exit if accessed directly. |
14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
14 | +if ( ! defined('ABSPATH')) { |
|
15 | 15 | exit; |
16 | 16 | } |
17 | 17 | |
@@ -53,40 +53,40 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public function get_data() { |
55 | 55 | |
56 | - $donor = new Give_Donor( $this->customer_id ); |
|
57 | - $payments = $this->get_stored_data( 'give_recount_donor_payments_' . $donor->id ); |
|
56 | + $donor = new Give_Donor($this->customer_id); |
|
57 | + $payments = $this->get_stored_data('give_recount_donor_payments_'.$donor->id); |
|
58 | 58 | |
59 | - $offset = ( $this->step - 1 ) * $this->per_step; |
|
60 | - $step_items = array_slice( $payments, $offset, $this->per_step ); |
|
59 | + $offset = ($this->step - 1) * $this->per_step; |
|
60 | + $step_items = array_slice($payments, $offset, $this->per_step); |
|
61 | 61 | |
62 | - if ( count( $step_items ) > 0 ) { |
|
63 | - $pending_total = (float) $this->get_stored_data( 'give_stats_donor_pending_total' . $donor->id ); |
|
62 | + if (count($step_items) > 0) { |
|
63 | + $pending_total = (float) $this->get_stored_data('give_stats_donor_pending_total'.$donor->id); |
|
64 | 64 | $step_total = 0; |
65 | 65 | |
66 | - $found_payment_ids = $this->get_stored_data( 'give_stats_found_payments_' . $donor->id ); |
|
66 | + $found_payment_ids = $this->get_stored_data('give_stats_found_payments_'.$donor->id); |
|
67 | 67 | |
68 | - foreach ( $step_items as $payment ) { |
|
69 | - $payment = get_post( $payment->ID ); |
|
68 | + foreach ($step_items as $payment) { |
|
69 | + $payment = get_post($payment->ID); |
|
70 | 70 | |
71 | - if ( is_null( $payment ) || is_wp_error( $payment ) || 'give_payment' !== $payment->post_type ) { |
|
71 | + if (is_null($payment) || is_wp_error($payment) || 'give_payment' !== $payment->post_type) { |
|
72 | 72 | |
73 | - $missing_payments = $this->get_stored_data( 'give_stats_missing_payments' . $donor->id ); |
|
73 | + $missing_payments = $this->get_stored_data('give_stats_missing_payments'.$donor->id); |
|
74 | 74 | $missing_payments[] = $payment->ID; |
75 | - $this->store_data( 'give_stats_missing_payments' . $donor->id, $missing_payments ); |
|
75 | + $this->store_data('give_stats_missing_payments'.$donor->id, $missing_payments); |
|
76 | 76 | |
77 | 77 | continue; |
78 | 78 | } |
79 | 79 | |
80 | 80 | $should_process_payment = 'publish' == $payment->post_status ? true : false; |
81 | - $should_process_payment = apply_filters( 'give_donor_recount_should_process_donation', $should_process_payment, $payment ); |
|
81 | + $should_process_payment = apply_filters('give_donor_recount_should_process_donation', $should_process_payment, $payment); |
|
82 | 82 | |
83 | - if ( true === $should_process_payment ) { |
|
83 | + if (true === $should_process_payment) { |
|
84 | 84 | |
85 | 85 | $found_payment_ids[] = $payment->ID; |
86 | 86 | |
87 | - if ( apply_filters( 'give_donor_recount_should_increase_value', true, $payment ) ) { |
|
88 | - $payment_amount = give_get_payment_amount( $payment->ID ); |
|
89 | - $step_total += $payment_amount; |
|
87 | + if (apply_filters('give_donor_recount_should_increase_value', true, $payment)) { |
|
88 | + $payment_amount = give_get_payment_amount($payment->ID); |
|
89 | + $step_total += $payment_amount; |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | } |
@@ -94,8 +94,8 @@ discard block |
||
94 | 94 | } |
95 | 95 | |
96 | 96 | $updated_total = $pending_total + $step_total; |
97 | - $this->store_data( 'give_stats_donor_pending_total' . $donor->id, $updated_total ); |
|
98 | - $this->store_data( 'give_stats_found_payments_' . $donor->id, $found_payment_ids ); |
|
97 | + $this->store_data('give_stats_donor_pending_total'.$donor->id, $updated_total); |
|
98 | + $this->store_data('give_stats_found_payments_'.$donor->id, $found_payment_ids); |
|
99 | 99 | |
100 | 100 | return true; |
101 | 101 | } |
@@ -112,16 +112,16 @@ discard block |
||
112 | 112 | */ |
113 | 113 | public function get_percentage_complete() { |
114 | 114 | |
115 | - $payments = $this->get_stored_data( 'give_recount_donor_payments_' . $this->customer_id ); |
|
116 | - $total = count( $payments ); |
|
115 | + $payments = $this->get_stored_data('give_recount_donor_payments_'.$this->customer_id); |
|
116 | + $total = count($payments); |
|
117 | 117 | |
118 | 118 | $percentage = 100; |
119 | 119 | |
120 | - if ( $total > 0 ) { |
|
121 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
120 | + if ($total > 0) { |
|
121 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
122 | 122 | } |
123 | 123 | |
124 | - if ( $percentage > 100 ) { |
|
124 | + if ($percentage > 100) { |
|
125 | 125 | $percentage = 100; |
126 | 126 | } |
127 | 127 | |
@@ -135,8 +135,8 @@ discard block |
||
135 | 135 | * |
136 | 136 | * @param array $request The Form Data passed into the batch processing |
137 | 137 | */ |
138 | - public function set_properties( $request ) { |
|
139 | - $this->customer_id = isset( $request['customer_id'] ) ? sanitize_text_field( $request['customer_id'] ) : false; |
|
138 | + public function set_properties($request) { |
|
139 | + $this->customer_id = isset($request['customer_id']) ? sanitize_text_field($request['customer_id']) : false; |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | /** |
@@ -147,63 +147,63 @@ discard block |
||
147 | 147 | */ |
148 | 148 | public function process_step() { |
149 | 149 | |
150 | - if ( ! $this->can_export() ) { |
|
151 | - wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
150 | + if ( ! $this->can_export()) { |
|
151 | + wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | $had_data = $this->get_data(); |
155 | 155 | |
156 | - if ( $had_data ) { |
|
156 | + if ($had_data) { |
|
157 | 157 | $this->done = false; |
158 | 158 | |
159 | 159 | return true; |
160 | 160 | } else { |
161 | - $donor = new Give_Donor( $this->customer_id ); |
|
162 | - $payment_ids = get_option( 'give_stats_found_payments_' . $donor->id, array() ); |
|
163 | - $this->delete_data( 'give_stats_found_payments_' . $donor->id ); |
|
161 | + $donor = new Give_Donor($this->customer_id); |
|
162 | + $payment_ids = get_option('give_stats_found_payments_'.$donor->id, array()); |
|
163 | + $this->delete_data('give_stats_found_payments_'.$donor->id); |
|
164 | 164 | |
165 | - $removed_payments = array_unique( get_option( 'give_stats_missing_payments' . $donor->id, array() ) ); |
|
165 | + $removed_payments = array_unique(get_option('give_stats_missing_payments'.$donor->id, array())); |
|
166 | 166 | |
167 | 167 | // Find non-existing payments (deleted) and total up the donation count |
168 | 168 | $purchase_count = 0; |
169 | - foreach ( $payment_ids as $key => $payment_id ) { |
|
170 | - if ( in_array( $payment_id, $removed_payments ) ) { |
|
171 | - unset( $payment_ids[ $key ] ); |
|
169 | + foreach ($payment_ids as $key => $payment_id) { |
|
170 | + if (in_array($payment_id, $removed_payments)) { |
|
171 | + unset($payment_ids[$key]); |
|
172 | 172 | continue; |
173 | 173 | } |
174 | 174 | |
175 | - $payment = get_post( $payment_id ); |
|
176 | - if ( apply_filters( 'give_donor_recount_should_increase_count', true, $payment ) ) { |
|
177 | - $purchase_count ++; |
|
175 | + $payment = get_post($payment_id); |
|
176 | + if (apply_filters('give_donor_recount_should_increase_count', true, $payment)) { |
|
177 | + $purchase_count++; |
|
178 | 178 | } |
179 | 179 | } |
180 | 180 | |
181 | - $this->delete_data( 'give_stats_missing_payments' . $donor->id ); |
|
181 | + $this->delete_data('give_stats_missing_payments'.$donor->id); |
|
182 | 182 | |
183 | - $pending_total = $this->get_stored_data( 'give_stats_donor_pending_total' . $donor->id ); |
|
184 | - $this->delete_data( 'give_stats_donor_pending_total' . $donor->id ); |
|
185 | - $this->delete_data( 'give_recount_donor_stats_' . $donor->id ); |
|
186 | - $this->delete_data( 'give_recount_donor_payments_' . $this->customer_id ); |
|
183 | + $pending_total = $this->get_stored_data('give_stats_donor_pending_total'.$donor->id); |
|
184 | + $this->delete_data('give_stats_donor_pending_total'.$donor->id); |
|
185 | + $this->delete_data('give_recount_donor_stats_'.$donor->id); |
|
186 | + $this->delete_data('give_recount_donor_payments_'.$this->customer_id); |
|
187 | 187 | |
188 | - $payment_ids = implode( ',', $payment_ids ); |
|
189 | - $donor->update( array( |
|
188 | + $payment_ids = implode(',', $payment_ids); |
|
189 | + $donor->update(array( |
|
190 | 190 | 'payment_ids' => $payment_ids, |
191 | 191 | 'purchase_count' => $purchase_count, |
192 | 192 | 'purchase_value' => $pending_total, |
193 | - ) ); |
|
193 | + )); |
|
194 | 194 | |
195 | 195 | $this->done = true; |
196 | - $this->message = esc_html__( 'Donor stats have been successfully recounted.', 'give' ); |
|
196 | + $this->message = esc_html__('Donor stats have been successfully recounted.', 'give'); |
|
197 | 197 | |
198 | 198 | return false; |
199 | 199 | } |
200 | 200 | } |
201 | 201 | |
202 | 202 | public function headers() { |
203 | - ignore_user_abort( true ); |
|
203 | + ignore_user_abort(true); |
|
204 | 204 | |
205 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
206 | - set_time_limit( 0 ); |
|
205 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
206 | + set_time_limit(0); |
|
207 | 207 | } |
208 | 208 | } |
209 | 209 | |
@@ -230,26 +230,26 @@ discard block |
||
230 | 230 | * @return void |
231 | 231 | */ |
232 | 232 | public function pre_fetch() { |
233 | - if ( $this->step === 1 ) { |
|
234 | - $allowed_payment_status = apply_filters( 'give_recount_donors_donation_statuses', give_get_payment_status_keys() ); |
|
233 | + if ($this->step === 1) { |
|
234 | + $allowed_payment_status = apply_filters('give_recount_donors_donation_statuses', give_get_payment_status_keys()); |
|
235 | 235 | |
236 | 236 | // Before we start, let's zero out the customer's data |
237 | - $donor = new Give_Donor( $this->customer_id ); |
|
238 | - $donor->update( array( 'purchase_value' => give_format_amount( 0, array( 'sanitize' => false ) ), 'purchase_count' => 0 ) ); |
|
237 | + $donor = new Give_Donor($this->customer_id); |
|
238 | + $donor->update(array('purchase_value' => give_format_amount(0, array('sanitize' => false)), 'purchase_count' => 0)); |
|
239 | 239 | |
240 | - $attached_payment_ids = explode( ',', $donor->payment_ids ); |
|
240 | + $attached_payment_ids = explode(',', $donor->payment_ids); |
|
241 | 241 | |
242 | 242 | $attached_args = array( |
243 | 243 | 'post__in' => $attached_payment_ids, |
244 | - 'number' => - 1, |
|
244 | + 'number' => -1, |
|
245 | 245 | 'status' => $allowed_payment_status, |
246 | 246 | ); |
247 | 247 | |
248 | - $attached_payments = give_get_payments( $attached_args ); |
|
248 | + $attached_payments = give_get_payments($attached_args); |
|
249 | 249 | |
250 | 250 | $unattached_args = array( |
251 | 251 | 'post__not_in' => $attached_payment_ids, |
252 | - 'number' => - 1, |
|
252 | + 'number' => -1, |
|
253 | 253 | 'status' => $allowed_payment_status, |
254 | 254 | 'meta_query' => array( |
255 | 255 | array( |
@@ -259,11 +259,11 @@ discard block |
||
259 | 259 | ), |
260 | 260 | ); |
261 | 261 | |
262 | - $unattached_payments = give_get_payments( $unattached_args ); |
|
262 | + $unattached_payments = give_get_payments($unattached_args); |
|
263 | 263 | |
264 | - $payments = array_merge( $attached_payments, $unattached_payments ); |
|
264 | + $payments = array_merge($attached_payments, $unattached_payments); |
|
265 | 265 | |
266 | - $this->store_data( 'give_recount_donor_payments_' . $donor->id, $payments ); |
|
266 | + $this->store_data('give_recount_donor_payments_'.$donor->id, $payments); |
|
267 | 267 | } |
268 | 268 | } |
269 | 269 | |
@@ -276,17 +276,17 @@ discard block |
||
276 | 276 | * |
277 | 277 | * @return mixed Returns the data from the database |
278 | 278 | */ |
279 | - private function get_stored_data( $key ) { |
|
279 | + private function get_stored_data($key) { |
|
280 | 280 | global $wpdb; |
281 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
281 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
282 | 282 | |
283 | - if ( empty( $value ) ) { |
|
283 | + if (empty($value)) { |
|
284 | 284 | return false; |
285 | 285 | } |
286 | 286 | |
287 | - $maybe_json = json_decode( $value ); |
|
288 | - if ( ! is_null( $maybe_json ) ) { |
|
289 | - $value = json_decode( $value, true ); |
|
287 | + $maybe_json = json_decode($value); |
|
288 | + if ( ! is_null($maybe_json)) { |
|
289 | + $value = json_decode($value, true); |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | return $value; |
@@ -302,10 +302,10 @@ discard block |
||
302 | 302 | * |
303 | 303 | * @return void |
304 | 304 | */ |
305 | - private function store_data( $key, $value ) { |
|
305 | + private function store_data($key, $value) { |
|
306 | 306 | global $wpdb; |
307 | 307 | |
308 | - $value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value ); |
|
308 | + $value = is_array($value) ? wp_json_encode($value) : esc_attr($value); |
|
309 | 309 | |
310 | 310 | $data = array( |
311 | 311 | 'option_name' => $key, |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | '%s', |
320 | 320 | ); |
321 | 321 | |
322 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
322 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | /** |
@@ -331,9 +331,9 @@ discard block |
||
331 | 331 | * |
332 | 332 | * @return void |
333 | 333 | */ |
334 | - private function delete_data( $key ) { |
|
334 | + private function delete_data($key) { |
|
335 | 335 | global $wpdb; |
336 | - $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) ); |
|
336 | + $wpdb->delete($wpdb->options, array('option_name' => $key)); |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | } |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | */ |
12 | 12 | |
13 | 13 | // Exit if accessed directly. |
14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
14 | +if ( ! defined('ABSPATH')) { |
|
15 | 15 | exit; |
16 | 16 | } |
17 | 17 | |
@@ -59,58 +59,58 @@ discard block |
||
59 | 59 | * @return bool |
60 | 60 | */ |
61 | 61 | public function get_data() { |
62 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) ); |
|
62 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish')); |
|
63 | 63 | |
64 | - if ( $this->step == 1 ) { |
|
65 | - $this->delete_data( 'give_temp_recount_form_stats' ); |
|
64 | + if ($this->step == 1) { |
|
65 | + $this->delete_data('give_temp_recount_form_stats'); |
|
66 | 66 | } |
67 | 67 | |
68 | - $totals = $this->get_stored_data( 'give_temp_recount_form_stats' ); |
|
68 | + $totals = $this->get_stored_data('give_temp_recount_form_stats'); |
|
69 | 69 | |
70 | - if ( false === $totals ) { |
|
70 | + if (false === $totals) { |
|
71 | 71 | $totals = array( |
72 | 72 | 'earnings' => (float) 0, |
73 | 73 | 'sales' => 0, |
74 | 74 | ); |
75 | - $this->store_data( 'give_temp_recount_form_stats', $totals ); |
|
75 | + $this->store_data('give_temp_recount_form_stats', $totals); |
|
76 | 76 | } |
77 | 77 | |
78 | - $args = apply_filters( 'give_recount_form_stats_args', array( |
|
78 | + $args = apply_filters('give_recount_form_stats_args', array( |
|
79 | 79 | 'give_forms' => $this->form_id, |
80 | 80 | 'number' => $this->per_step, |
81 | 81 | 'status' => $accepted_statuses, |
82 | 82 | 'paged' => $this->step, |
83 | 83 | 'fields' => 'ids', |
84 | - ) ); |
|
84 | + )); |
|
85 | 85 | |
86 | - $payments = new Give_Payments_Query( $args ); |
|
86 | + $payments = new Give_Payments_Query($args); |
|
87 | 87 | $payments = $payments->get_payments(); |
88 | 88 | |
89 | - if ( $payments ) { |
|
90 | - foreach ( $payments as $payment ) { |
|
89 | + if ($payments) { |
|
90 | + foreach ($payments as $payment) { |
|
91 | 91 | //Ensure acceptible status only |
92 | - if ( ! in_array( $payment->post_status, $accepted_statuses ) ) { |
|
92 | + if ( ! in_array($payment->post_status, $accepted_statuses)) { |
|
93 | 93 | continue; |
94 | 94 | } |
95 | 95 | |
96 | 96 | //Ensure only payments for this form are counted |
97 | - if ( $payment->form_id != $this->form_id ) { |
|
97 | + if ($payment->form_id != $this->form_id) { |
|
98 | 98 | continue; |
99 | 99 | } |
100 | 100 | |
101 | - $totals['sales'] ++; |
|
101 | + $totals['sales']++; |
|
102 | 102 | $totals['earnings'] += $payment->total; |
103 | 103 | |
104 | 104 | } |
105 | 105 | |
106 | - $this->store_data( 'give_temp_recount_form_stats', $totals ); |
|
106 | + $this->store_data('give_temp_recount_form_stats', $totals); |
|
107 | 107 | |
108 | 108 | return true; |
109 | 109 | } |
110 | 110 | |
111 | 111 | |
112 | - give_update_meta( $this->form_id, '_give_form_sales', $totals['sales'] ); |
|
113 | - give_update_meta( $this->form_id, '_give_form_earnings', give_sanitize_amount_for_db( $totals['earnings'] ) ); |
|
112 | + give_update_meta($this->form_id, '_give_form_sales', $totals['sales']); |
|
113 | + give_update_meta($this->form_id, '_give_form_earnings', give_sanitize_amount_for_db($totals['earnings'])); |
|
114 | 114 | |
115 | 115 | return false; |
116 | 116 | } |
@@ -122,35 +122,35 @@ discard block |
||
122 | 122 | * @return int |
123 | 123 | */ |
124 | 124 | public function get_percentage_complete() { |
125 | - if ( $this->step == 1 ) { |
|
126 | - $this->delete_data( 'give_recount_total_' . $this->form_id ); |
|
125 | + if ($this->step == 1) { |
|
126 | + $this->delete_data('give_recount_total_'.$this->form_id); |
|
127 | 127 | } |
128 | 128 | |
129 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) ); |
|
130 | - $total = $this->get_stored_data( 'give_recount_total_' . $this->form_id ); |
|
129 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish')); |
|
130 | + $total = $this->get_stored_data('give_recount_total_'.$this->form_id); |
|
131 | 131 | |
132 | - if ( false === $total ) { |
|
132 | + if (false === $total) { |
|
133 | 133 | $total = 0; |
134 | - $args = apply_filters( 'give_recount_form_stats_total_args', array( |
|
134 | + $args = apply_filters('give_recount_form_stats_total_args', array( |
|
135 | 135 | 'give_forms' => $this->form_id, |
136 | - 'number' => - 1, |
|
136 | + 'number' => -1, |
|
137 | 137 | 'status' => $accepted_statuses, |
138 | 138 | 'fields' => 'ids', |
139 | - ) ); |
|
139 | + )); |
|
140 | 140 | |
141 | - $payments = new Give_Payments_Query( $args ); |
|
142 | - $total = count( $payments->get_payments() ); |
|
143 | - $this->store_data( 'give_recount_total_' . $this->form_id, $total ); |
|
141 | + $payments = new Give_Payments_Query($args); |
|
142 | + $total = count($payments->get_payments()); |
|
143 | + $this->store_data('give_recount_total_'.$this->form_id, $total); |
|
144 | 144 | |
145 | 145 | } |
146 | 146 | |
147 | 147 | $percentage = 100; |
148 | 148 | |
149 | - if ( $total > 0 ) { |
|
150 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
149 | + if ($total > 0) { |
|
150 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
151 | 151 | } |
152 | 152 | |
153 | - if ( $percentage > 100 ) { |
|
153 | + if ($percentage > 100) { |
|
154 | 154 | $percentage = 100; |
155 | 155 | } |
156 | 156 | |
@@ -164,8 +164,8 @@ discard block |
||
164 | 164 | * |
165 | 165 | * @param array $request The Form Data passed into the batch processing |
166 | 166 | */ |
167 | - public function set_properties( $request ) { |
|
168 | - $this->form_id = isset( $request['form_id'] ) ? sanitize_text_field( $request['form_id'] ) : false; |
|
167 | + public function set_properties($request) { |
|
168 | + $this->form_id = isset($request['form_id']) ? sanitize_text_field($request['form_id']) : false; |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
@@ -176,31 +176,31 @@ discard block |
||
176 | 176 | */ |
177 | 177 | public function process_step() { |
178 | 178 | |
179 | - if ( ! $this->can_export() ) { |
|
180 | - wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
179 | + if ( ! $this->can_export()) { |
|
180 | + wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | $had_data = $this->get_data(); |
184 | 184 | |
185 | - if ( $had_data ) { |
|
185 | + if ($had_data) { |
|
186 | 186 | $this->done = false; |
187 | 187 | |
188 | 188 | return true; |
189 | 189 | } else { |
190 | - $this->delete_data( 'give_recount_total_' . $this->form_id ); |
|
191 | - $this->delete_data( 'give_temp_recount_form_stats' ); |
|
190 | + $this->delete_data('give_recount_total_'.$this->form_id); |
|
191 | + $this->delete_data('give_temp_recount_form_stats'); |
|
192 | 192 | $this->done = true; |
193 | - $this->message = sprintf( esc_html__( 'Donation counts and income amount statistics successfully recounted for "%s".', 'give' ), get_the_title( $this->form_id ) ); |
|
193 | + $this->message = sprintf(esc_html__('Donation counts and income amount statistics successfully recounted for "%s".', 'give'), get_the_title($this->form_id)); |
|
194 | 194 | |
195 | 195 | return false; |
196 | 196 | } |
197 | 197 | } |
198 | 198 | |
199 | 199 | public function headers() { |
200 | - ignore_user_abort( true ); |
|
200 | + ignore_user_abort(true); |
|
201 | 201 | |
202 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
203 | - set_time_limit( 0 ); |
|
202 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
203 | + set_time_limit(0); |
|
204 | 204 | } |
205 | 205 | } |
206 | 206 | |
@@ -228,17 +228,17 @@ discard block |
||
228 | 228 | * |
229 | 229 | * @return mixed Returns the data from the database |
230 | 230 | */ |
231 | - private function get_stored_data( $key ) { |
|
231 | + private function get_stored_data($key) { |
|
232 | 232 | global $wpdb; |
233 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
233 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
234 | 234 | |
235 | - if ( empty( $value ) ) { |
|
235 | + if (empty($value)) { |
|
236 | 236 | return false; |
237 | 237 | } |
238 | 238 | |
239 | - $maybe_json = json_decode( $value ); |
|
240 | - if ( ! is_null( $maybe_json ) ) { |
|
241 | - $value = json_decode( $value, true ); |
|
239 | + $maybe_json = json_decode($value); |
|
240 | + if ( ! is_null($maybe_json)) { |
|
241 | + $value = json_decode($value, true); |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | return $value; |
@@ -254,10 +254,10 @@ discard block |
||
254 | 254 | * |
255 | 255 | * @return void |
256 | 256 | */ |
257 | - private function store_data( $key, $value ) { |
|
257 | + private function store_data($key, $value) { |
|
258 | 258 | global $wpdb; |
259 | 259 | |
260 | - $value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value ); |
|
260 | + $value = is_array($value) ? wp_json_encode($value) : esc_attr($value); |
|
261 | 261 | |
262 | 262 | $data = array( |
263 | 263 | 'option_name' => $key, |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | '%s', |
272 | 272 | ); |
273 | 273 | |
274 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
274 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
275 | 275 | } |
276 | 276 | |
277 | 277 | /** |
@@ -283,9 +283,9 @@ discard block |
||
283 | 283 | * |
284 | 284 | * @return void |
285 | 285 | */ |
286 | - private function delete_data( $key ) { |
|
286 | + private function delete_data($key) { |
|
287 | 287 | global $wpdb; |
288 | - $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) ); |
|
288 | + $wpdb->delete($wpdb->options, array('option_name' => $key)); |
|
289 | 289 | } |
290 | 290 | |
291 | 291 | } |
292 | 292 | \ No newline at end of file |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | */ |
12 | 12 | |
13 | 13 | // Exit if accessed directly. |
14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
14 | +if ( ! defined('ABSPATH')) { |
|
15 | 15 | exit; |
16 | 16 | } |
17 | 17 | |
@@ -58,16 +58,16 @@ discard block |
||
58 | 58 | public function get_data() { |
59 | 59 | global $wpdb; |
60 | 60 | |
61 | - $items = $this->get_stored_data( 'give_temp_reset_ids' ); |
|
61 | + $items = $this->get_stored_data('give_temp_reset_ids'); |
|
62 | 62 | |
63 | - if ( ! is_array( $items ) ) { |
|
63 | + if ( ! is_array($items)) { |
|
64 | 64 | return false; |
65 | 65 | } |
66 | 66 | |
67 | - $offset = ( $this->step - 1 ) * $this->per_step; |
|
68 | - $step_items = array_slice( $items, $offset, $this->per_step ); |
|
67 | + $offset = ($this->step - 1) * $this->per_step; |
|
68 | + $step_items = array_slice($items, $offset, $this->per_step); |
|
69 | 69 | |
70 | - if ( $step_items ) { |
|
70 | + if ($step_items) { |
|
71 | 71 | |
72 | 72 | $step_ids = array( |
73 | 73 | 'customers' => array(), |
@@ -75,9 +75,9 @@ discard block |
||
75 | 75 | 'other' => array(), |
76 | 76 | ); |
77 | 77 | |
78 | - foreach ( $step_items as $item ) { |
|
78 | + foreach ($step_items as $item) { |
|
79 | 79 | |
80 | - switch ( $item['type'] ) { |
|
80 | + switch ($item['type']) { |
|
81 | 81 | case 'customer': |
82 | 82 | $step_ids['customers'][] = $item['id']; |
83 | 83 | break; |
@@ -85,26 +85,26 @@ discard block |
||
85 | 85 | $step_ids['give_forms'][] = $item['id']; |
86 | 86 | break; |
87 | 87 | default: |
88 | - $item_type = apply_filters( 'give_reset_item_type', 'other', $item ); |
|
89 | - $step_ids[ $item_type ][] = $item['id']; |
|
88 | + $item_type = apply_filters('give_reset_item_type', 'other', $item); |
|
89 | + $step_ids[$item_type][] = $item['id']; |
|
90 | 90 | break; |
91 | 91 | } |
92 | 92 | } |
93 | 93 | |
94 | 94 | $sql = array(); |
95 | 95 | |
96 | - foreach ( $step_ids as $type => $ids ) { |
|
96 | + foreach ($step_ids as $type => $ids) { |
|
97 | 97 | |
98 | - if ( empty( $ids ) ) { |
|
98 | + if (empty($ids)) { |
|
99 | 99 | continue; |
100 | 100 | } |
101 | 101 | |
102 | - $ids = implode( ',', $ids ); |
|
102 | + $ids = implode(',', $ids); |
|
103 | 103 | |
104 | - switch ( $type ) { |
|
104 | + switch ($type) { |
|
105 | 105 | case 'customers': |
106 | - $table_name = $wpdb->prefix . 'give_customers'; |
|
107 | - $meta_table_name = $wpdb->prefix . 'give_customermeta'; |
|
106 | + $table_name = $wpdb->prefix.'give_customers'; |
|
107 | + $meta_table_name = $wpdb->prefix.'give_customermeta'; |
|
108 | 108 | $sql[] = "DELETE FROM $table_name WHERE id IN ($ids)"; |
109 | 109 | $sql[] = "DELETE FROM $meta_table_name WHERE customer_id IN ($ids)"; |
110 | 110 | break; |
@@ -120,16 +120,16 @@ discard block |
||
120 | 120 | break; |
121 | 121 | } |
122 | 122 | |
123 | - if ( ! in_array( $type, array( 'customers', 'forms', 'other' ) ) ) { |
|
123 | + if ( ! in_array($type, array('customers', 'forms', 'other'))) { |
|
124 | 124 | // Allows other types of custom post types to filter on their own post_type |
125 | 125 | // and add items to the query list, for the IDs found in their post type. |
126 | - $sql = apply_filters( "give_reset_add_queries_{$type}", $sql, $ids ); |
|
126 | + $sql = apply_filters("give_reset_add_queries_{$type}", $sql, $ids); |
|
127 | 127 | } |
128 | 128 | } |
129 | 129 | |
130 | - if ( ! empty( $sql ) ) { |
|
131 | - foreach ( $sql as $query ) { |
|
132 | - $wpdb->query( $query ); |
|
130 | + if ( ! empty($sql)) { |
|
131 | + foreach ($sql as $query) { |
|
132 | + $wpdb->query($query); |
|
133 | 133 | } |
134 | 134 | } |
135 | 135 | |
@@ -149,16 +149,16 @@ discard block |
||
149 | 149 | */ |
150 | 150 | public function get_percentage_complete() { |
151 | 151 | |
152 | - $items = $this->get_stored_data( 'give_temp_reset_ids' ); |
|
153 | - $total = count( $items ); |
|
152 | + $items = $this->get_stored_data('give_temp_reset_ids'); |
|
153 | + $total = count($items); |
|
154 | 154 | |
155 | 155 | $percentage = 100; |
156 | 156 | |
157 | - if ( $total > 0 ) { |
|
158 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
157 | + if ($total > 0) { |
|
158 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
159 | 159 | } |
160 | 160 | |
161 | - if ( $percentage > 100 ) { |
|
161 | + if ($percentage > 100) { |
|
162 | 162 | $percentage = 100; |
163 | 163 | } |
164 | 164 | |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | * |
173 | 173 | * @param array $request The Form Data passed into the batch processing. |
174 | 174 | */ |
175 | - public function set_properties( $request ) { |
|
175 | + public function set_properties($request) { |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | /** |
@@ -183,31 +183,31 @@ discard block |
||
183 | 183 | */ |
184 | 184 | public function process_step() { |
185 | 185 | |
186 | - if ( ! $this->can_export() ) { |
|
187 | - wp_die( esc_html__( 'You do not have permission to reset data.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
186 | + if ( ! $this->can_export()) { |
|
187 | + wp_die(esc_html__('You do not have permission to reset data.', 'give'), esc_html__('Error', 'give'), array( |
|
188 | 188 | 'response' => 403, |
189 | - ) ); |
|
189 | + )); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | $had_data = $this->get_data(); |
193 | 193 | |
194 | - if ( $had_data ) { |
|
194 | + if ($had_data) { |
|
195 | 195 | $this->done = false; |
196 | 196 | |
197 | 197 | return true; |
198 | 198 | } else { |
199 | - update_option( 'give_earnings_total', 0 ); |
|
200 | - Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) ); |
|
199 | + update_option('give_earnings_total', 0); |
|
200 | + Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats')); |
|
201 | 201 | |
202 | - $this->delete_data( 'give_temp_reset_ids' ); |
|
202 | + $this->delete_data('give_temp_reset_ids'); |
|
203 | 203 | |
204 | 204 | // Reset the sequential order numbers |
205 | - if ( give_get_option( 'enable_sequential' ) ) { |
|
206 | - delete_option( 'give_last_payment_number' ); |
|
205 | + if (give_get_option('enable_sequential')) { |
|
206 | + delete_option('give_last_payment_number'); |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | $this->done = true; |
210 | - $this->message = esc_html__( 'Donation forms, income, donations counts, and logs successfully reset.', 'give' ); |
|
210 | + $this->message = esc_html__('Donation forms, income, donations counts, and logs successfully reset.', 'give'); |
|
211 | 211 | |
212 | 212 | return false; |
213 | 213 | } |
@@ -217,10 +217,10 @@ discard block |
||
217 | 217 | * Headers |
218 | 218 | */ |
219 | 219 | public function headers() { |
220 | - ignore_user_abort( true ); |
|
220 | + ignore_user_abort(true); |
|
221 | 221 | |
222 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
223 | - set_time_limit( 0 ); |
|
222 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
223 | + set_time_limit(0); |
|
224 | 224 | } |
225 | 225 | } |
226 | 226 | |
@@ -244,26 +244,26 @@ discard block |
||
244 | 244 | */ |
245 | 245 | public function pre_fetch() { |
246 | 246 | |
247 | - if ( $this->step == 1 ) { |
|
248 | - $this->delete_data( 'give_temp_reset_ids' ); |
|
247 | + if ($this->step == 1) { |
|
248 | + $this->delete_data('give_temp_reset_ids'); |
|
249 | 249 | } |
250 | 250 | |
251 | - $items = get_option( 'give_temp_reset_ids', false ); |
|
251 | + $items = get_option('give_temp_reset_ids', false); |
|
252 | 252 | |
253 | - if ( false === $items ) { |
|
253 | + if (false === $items) { |
|
254 | 254 | $items = array(); |
255 | 255 | |
256 | - $give_types_for_reset = array( 'give_forms', 'give_payment' ); |
|
257 | - $give_types_for_reset = apply_filters( 'give_reset_store_post_types', $give_types_for_reset ); |
|
256 | + $give_types_for_reset = array('give_forms', 'give_payment'); |
|
257 | + $give_types_for_reset = apply_filters('give_reset_store_post_types', $give_types_for_reset); |
|
258 | 258 | |
259 | - $args = apply_filters( 'give_tools_reset_stats_total_args', array( |
|
259 | + $args = apply_filters('give_tools_reset_stats_total_args', array( |
|
260 | 260 | 'post_type' => $give_types_for_reset, |
261 | 261 | 'post_status' => 'any', |
262 | - 'posts_per_page' => - 1, |
|
263 | - ) ); |
|
262 | + 'posts_per_page' => -1, |
|
263 | + )); |
|
264 | 264 | |
265 | - $posts = get_posts( $args ); |
|
266 | - foreach ( $posts as $post ) { |
|
265 | + $posts = get_posts($args); |
|
266 | + foreach ($posts as $post) { |
|
267 | 267 | $items[] = array( |
268 | 268 | 'id' => (int) $post->ID, |
269 | 269 | 'type' => $post->post_type, |
@@ -271,10 +271,10 @@ discard block |
||
271 | 271 | } |
272 | 272 | |
273 | 273 | $donor_args = array( |
274 | - 'number' => - 1, |
|
274 | + 'number' => -1, |
|
275 | 275 | ); |
276 | - $donors = Give()->donors->get_donors( $donor_args ); |
|
277 | - foreach ( $donors as $donor ) { |
|
276 | + $donors = Give()->donors->get_donors($donor_args); |
|
277 | + foreach ($donors as $donor) { |
|
278 | 278 | $items[] = array( |
279 | 279 | 'id' => (int) $donor->id, |
280 | 280 | 'type' => 'customer', |
@@ -283,9 +283,9 @@ discard block |
||
283 | 283 | |
284 | 284 | // Allow filtering of items to remove with an unassociative array for each item |
285 | 285 | // The array contains the unique ID of the item, and a 'type' for you to use in the execution of the get_data method |
286 | - $items = apply_filters( 'give_reset_items', $items ); |
|
286 | + $items = apply_filters('give_reset_items', $items); |
|
287 | 287 | |
288 | - $this->store_data( 'give_temp_reset_ids', $items ); |
|
288 | + $this->store_data('give_temp_reset_ids', $items); |
|
289 | 289 | }// End if(). |
290 | 290 | |
291 | 291 | } |
@@ -299,17 +299,17 @@ discard block |
||
299 | 299 | * |
300 | 300 | * @return mixed Returns the data from the database. |
301 | 301 | */ |
302 | - private function get_stored_data( $key ) { |
|
302 | + private function get_stored_data($key) { |
|
303 | 303 | global $wpdb; |
304 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
304 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
305 | 305 | |
306 | - if ( empty( $value ) ) { |
|
306 | + if (empty($value)) { |
|
307 | 307 | return false; |
308 | 308 | } |
309 | 309 | |
310 | - $maybe_json = json_decode( $value ); |
|
311 | - if ( ! is_null( $maybe_json ) ) { |
|
312 | - $value = json_decode( $value, true ); |
|
310 | + $maybe_json = json_decode($value); |
|
311 | + if ( ! is_null($maybe_json)) { |
|
312 | + $value = json_decode($value, true); |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | return $value; |
@@ -325,10 +325,10 @@ discard block |
||
325 | 325 | * |
326 | 326 | * @return void |
327 | 327 | */ |
328 | - private function store_data( $key, $value ) { |
|
328 | + private function store_data($key, $value) { |
|
329 | 329 | global $wpdb; |
330 | 330 | |
331 | - $value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value ); |
|
331 | + $value = is_array($value) ? wp_json_encode($value) : esc_attr($value); |
|
332 | 332 | |
333 | 333 | $data = array( |
334 | 334 | 'option_name' => $key, |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | '%s', |
343 | 343 | ); |
344 | 344 | |
345 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
345 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
346 | 346 | } |
347 | 347 | |
348 | 348 | /** |
@@ -354,11 +354,11 @@ discard block |
||
354 | 354 | * |
355 | 355 | * @return void |
356 | 356 | */ |
357 | - private function delete_data( $key ) { |
|
357 | + private function delete_data($key) { |
|
358 | 358 | global $wpdb; |
359 | - $wpdb->delete( $wpdb->options, array( |
|
359 | + $wpdb->delete($wpdb->options, array( |
|
360 | 360 | 'option_name' => $key, |
361 | - ) ); |
|
361 | + )); |
|
362 | 362 | } |
363 | 363 | |
364 | 364 | } |
365 | 365 | \ No newline at end of file |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -20,10 +20,10 @@ discard block |
||
20 | 20 | * @since 1.5 |
21 | 21 | */ |
22 | 22 | function give_register_batch_recount_export_classes() { |
23 | - add_action( 'give_batch_export_class_include', 'give_include_batch_export_class', 10, 1 ); |
|
23 | + add_action('give_batch_export_class_include', 'give_include_batch_export_class', 10, 1); |
|
24 | 24 | } |
25 | 25 | |
26 | -add_action( 'give_register_batch_exporter', 'give_register_batch_recount_export_classes', 10 ); |
|
26 | +add_action('give_register_batch_exporter', 'give_register_batch_recount_export_classes', 10); |
|
27 | 27 | |
28 | 28 | |
29 | 29 | /** |
@@ -35,39 +35,39 @@ discard block |
||
35 | 35 | * |
36 | 36 | * @return void |
37 | 37 | */ |
38 | -function give_include_batch_export_class( $class ) { |
|
39 | - switch ( $class ) { |
|
38 | +function give_include_batch_export_class($class) { |
|
39 | + switch ($class) { |
|
40 | 40 | |
41 | 41 | case 'Give_Tools_Delete_Donors': |
42 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-delete-test-donors.php'; |
|
42 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-delete-test-donors.php'; |
|
43 | 43 | break; |
44 | 44 | |
45 | 45 | case 'Give_Tools_Import_Donors': |
46 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-delete-import-donors.php'; |
|
46 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-delete-import-donors.php'; |
|
47 | 47 | break; |
48 | 48 | |
49 | 49 | case 'Give_Tools_Delete_Test_Transactions': |
50 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-delete-test-transactions.php'; |
|
50 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-delete-test-transactions.php'; |
|
51 | 51 | break; |
52 | 52 | |
53 | 53 | case 'Give_Tools_Recount_Donor_Stats': |
54 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-recount-donor-stats.php'; |
|
54 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-recount-donor-stats.php'; |
|
55 | 55 | break; |
56 | 56 | |
57 | 57 | case 'Give_Tools_Reset_Stats': |
58 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-reset-stats.php'; |
|
58 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-reset-stats.php'; |
|
59 | 59 | break; |
60 | 60 | |
61 | 61 | case 'Give_Tools_Recount_All_Stats': |
62 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-recount-all-stats.php'; |
|
62 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-recount-all-stats.php'; |
|
63 | 63 | break; |
64 | 64 | |
65 | 65 | case 'Give_Tools_Recount_Form_Stats': |
66 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-recount-form-stats.php'; |
|
66 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-recount-form-stats.php'; |
|
67 | 67 | break; |
68 | 68 | |
69 | 69 | case 'Give_Tools_Recount_Income': |
70 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-recount-income.php'; |
|
70 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-recount-income.php'; |
|
71 | 71 | break; |
72 | 72 | } |
73 | 73 | } |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | */ |
12 | 12 | |
13 | 13 | // Exit if accessed directly. |
14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
14 | +if ( ! defined('ABSPATH')) { |
|
15 | 15 | exit; |
16 | 16 | } |
17 | 17 | |
@@ -55,22 +55,22 @@ discard block |
||
55 | 55 | public function get_data() { |
56 | 56 | global $wpdb; |
57 | 57 | |
58 | - $items = $this->get_stored_data( 'give_temp_delete_test_ids' ); |
|
58 | + $items = $this->get_stored_data('give_temp_delete_test_ids'); |
|
59 | 59 | |
60 | - if ( ! is_array( $items ) ) { |
|
60 | + if ( ! is_array($items)) { |
|
61 | 61 | return false; |
62 | 62 | } |
63 | 63 | |
64 | - $offset = ( $this->step - 1 ) * $this->per_step; |
|
65 | - $step_items = array_slice( $items, $offset, $this->per_step ); |
|
64 | + $offset = ($this->step - 1) * $this->per_step; |
|
65 | + $step_items = array_slice($items, $offset, $this->per_step); |
|
66 | 66 | |
67 | - if ( $step_items ) { |
|
67 | + if ($step_items) { |
|
68 | 68 | |
69 | 69 | $step_ids = array( |
70 | 70 | 'other' => array(), |
71 | 71 | ); |
72 | 72 | |
73 | - foreach ( $step_items as $item ) { |
|
73 | + foreach ($step_items as $item) { |
|
74 | 74 | |
75 | 75 | $step_ids['other'][] = $item['id']; |
76 | 76 | |
@@ -78,31 +78,31 @@ discard block |
||
78 | 78 | |
79 | 79 | $sql = array(); |
80 | 80 | |
81 | - foreach ( $step_ids as $type => $ids ) { |
|
81 | + foreach ($step_ids as $type => $ids) { |
|
82 | 82 | |
83 | - if ( empty( $ids ) ) { |
|
83 | + if (empty($ids)) { |
|
84 | 84 | continue; |
85 | 85 | } |
86 | 86 | |
87 | 87 | $parent_query = ''; |
88 | 88 | |
89 | - switch ( $type ) { |
|
89 | + switch ($type) { |
|
90 | 90 | case 'other': |
91 | 91 | |
92 | - $temp_ids = implode( ',', $ids ); |
|
92 | + $temp_ids = implode(',', $ids); |
|
93 | 93 | |
94 | 94 | // Get all the test logs of the donations ids. |
95 | 95 | $parent_query = "SELECT DISTINCT post_id as id FROM $wpdb->postmeta WHERE meta_key = '_give_log_payment_id' AND meta_value IN ( $temp_ids )"; |
96 | - $parent_ids = $wpdb->get_results( $parent_query, 'ARRAY_A' ); |
|
96 | + $parent_ids = $wpdb->get_results($parent_query, 'ARRAY_A'); |
|
97 | 97 | |
98 | 98 | // List of all test logs. |
99 | - if ( $parent_ids ) { |
|
100 | - foreach ( $parent_ids as $parent_id ) { |
|
99 | + if ($parent_ids) { |
|
100 | + foreach ($parent_ids as $parent_id) { |
|
101 | 101 | // Adding all the test log in post ids that are going to get deleted. |
102 | 102 | $ids[] = $parent_id['id']; |
103 | 103 | } |
104 | 104 | } |
105 | - $ids = implode( ',', $ids ); |
|
105 | + $ids = implode(',', $ids); |
|
106 | 106 | |
107 | 107 | $sql[] = "DELETE FROM $wpdb->posts WHERE id IN ($ids)"; |
108 | 108 | $sql[] = "DELETE FROM $wpdb->postmeta WHERE post_id IN ($ids)"; |
@@ -113,11 +113,11 @@ discard block |
||
113 | 113 | |
114 | 114 | } |
115 | 115 | |
116 | - if ( ! empty( $sql ) ) { |
|
117 | - foreach ( $sql as $query ) { |
|
118 | - $wpdb->query( $query ); |
|
116 | + if ( ! empty($sql)) { |
|
117 | + foreach ($sql as $query) { |
|
118 | + $wpdb->query($query); |
|
119 | 119 | } |
120 | - do_action( 'give_delete_log_cache' ); |
|
120 | + do_action('give_delete_log_cache'); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | return true; |
@@ -134,16 +134,16 @@ discard block |
||
134 | 134 | */ |
135 | 135 | public function get_percentage_complete() { |
136 | 136 | |
137 | - $items = $this->get_stored_data( 'give_temp_delete_test_ids', false ); |
|
138 | - $total = count( $items ); |
|
137 | + $items = $this->get_stored_data('give_temp_delete_test_ids', false); |
|
138 | + $total = count($items); |
|
139 | 139 | |
140 | 140 | $percentage = 100; |
141 | 141 | |
142 | - if ( $total > 0 ) { |
|
143 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
142 | + if ($total > 0) { |
|
143 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
144 | 144 | } |
145 | 145 | |
146 | - if ( $percentage > 100 ) { |
|
146 | + if ($percentage > 100) { |
|
147 | 147 | $percentage = 100; |
148 | 148 | } |
149 | 149 | |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | * |
158 | 158 | * @param array $request The Form Data passed into the batch processing |
159 | 159 | */ |
160 | - public function set_properties( $request ) { |
|
160 | + public function set_properties($request) { |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | /** |
@@ -168,29 +168,29 @@ discard block |
||
168 | 168 | */ |
169 | 169 | public function process_step() { |
170 | 170 | |
171 | - if ( ! $this->can_export() ) { |
|
172 | - wp_die( __( 'You do not have permission to delete test transactions.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
171 | + if ( ! $this->can_export()) { |
|
172 | + wp_die(__('You do not have permission to delete test transactions.', 'give'), __('Error', 'give'), array('response' => 403)); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | $had_data = $this->get_data(); |
176 | 176 | |
177 | - if ( $had_data ) { |
|
177 | + if ($had_data) { |
|
178 | 178 | $this->done = false; |
179 | 179 | |
180 | 180 | return true; |
181 | 181 | } else { |
182 | - update_option( 'give_earnings_total', give_get_total_earnings( true ) ); |
|
183 | - Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) ); |
|
182 | + update_option('give_earnings_total', give_get_total_earnings(true)); |
|
183 | + Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats')); |
|
184 | 184 | |
185 | - $this->delete_data( 'give_temp_delete_test_ids' ); |
|
185 | + $this->delete_data('give_temp_delete_test_ids'); |
|
186 | 186 | |
187 | 187 | // Reset the sequential order numbers |
188 | - if ( give_get_option( 'enable_sequential' ) ) { |
|
189 | - delete_option( 'give_last_payment_number' ); |
|
188 | + if (give_get_option('enable_sequential')) { |
|
189 | + delete_option('give_last_payment_number'); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | $this->done = true; |
193 | - $this->message = __( 'Test transactions successfully deleted.', 'give' ); |
|
193 | + $this->message = __('Test transactions successfully deleted.', 'give'); |
|
194 | 194 | |
195 | 195 | return false; |
196 | 196 | } |
@@ -200,10 +200,10 @@ discard block |
||
200 | 200 | * Headers |
201 | 201 | */ |
202 | 202 | public function headers() { |
203 | - ignore_user_abort( true ); |
|
203 | + ignore_user_abort(true); |
|
204 | 204 | |
205 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
206 | - set_time_limit( 0 ); |
|
205 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
206 | + set_time_limit(0); |
|
207 | 207 | } |
208 | 208 | } |
209 | 209 | |
@@ -227,27 +227,27 @@ discard block |
||
227 | 227 | */ |
228 | 228 | public function pre_fetch() { |
229 | 229 | |
230 | - if ( $this->step == 1 ) { |
|
231 | - $this->delete_data( 'give_temp_delete_test_ids' ); |
|
230 | + if ($this->step == 1) { |
|
231 | + $this->delete_data('give_temp_delete_test_ids'); |
|
232 | 232 | } |
233 | 233 | |
234 | - $items = get_option( 'give_temp_delete_test_ids', false ); |
|
234 | + $items = get_option('give_temp_delete_test_ids', false); |
|
235 | 235 | |
236 | - if ( false === $items ) { |
|
236 | + if (false === $items) { |
|
237 | 237 | $items = array(); |
238 | 238 | |
239 | - $args = apply_filters( 'give_tools_reset_stats_total_args', array( |
|
239 | + $args = apply_filters('give_tools_reset_stats_total_args', array( |
|
240 | 240 | 'post_status' => 'any', |
241 | - 'number' => - 1, |
|
241 | + 'number' => -1, |
|
242 | 242 | 'meta_key' => '_give_payment_mode', |
243 | 243 | 'meta_value' => 'test' |
244 | - ) ); |
|
244 | + )); |
|
245 | 245 | |
246 | - $posts = new Give_Payments_Query( $args ); |
|
246 | + $posts = new Give_Payments_Query($args); |
|
247 | 247 | $payments = $posts->get_payments(); |
248 | 248 | |
249 | 249 | /* @var Give_Payment $payment */ |
250 | - foreach ( $payments as $payment ) { |
|
250 | + foreach ($payments as $payment) { |
|
251 | 251 | $items[] = array( |
252 | 252 | 'id' => (int) $payment->ID, |
253 | 253 | 'type' => 'give_payment', |
@@ -256,9 +256,9 @@ discard block |
||
256 | 256 | |
257 | 257 | // Allow filtering of items to remove with an unassociative array for each item. |
258 | 258 | // The array contains the unique ID of the item, and a 'type' for you to use in the execution of the get_data method. |
259 | - $items = apply_filters( 'give_delete_test_items', $items ); |
|
259 | + $items = apply_filters('give_delete_test_items', $items); |
|
260 | 260 | |
261 | - $this->store_data( 'give_temp_delete_test_ids', $items ); |
|
261 | + $this->store_data('give_temp_delete_test_ids', $items); |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | } |
@@ -272,17 +272,17 @@ discard block |
||
272 | 272 | * |
273 | 273 | * @return mixed Returns the data from the database |
274 | 274 | */ |
275 | - private function get_stored_data( $key ) { |
|
275 | + private function get_stored_data($key) { |
|
276 | 276 | global $wpdb; |
277 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
277 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
278 | 278 | |
279 | - if ( empty( $value ) ) { |
|
279 | + if (empty($value)) { |
|
280 | 280 | return false; |
281 | 281 | } |
282 | 282 | |
283 | - $maybe_json = json_decode( $value ); |
|
284 | - if ( ! is_null( $maybe_json ) ) { |
|
285 | - $value = json_decode( $value, true ); |
|
283 | + $maybe_json = json_decode($value); |
|
284 | + if ( ! is_null($maybe_json)) { |
|
285 | + $value = json_decode($value, true); |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | return $value; |
@@ -298,10 +298,10 @@ discard block |
||
298 | 298 | * |
299 | 299 | * @return void |
300 | 300 | */ |
301 | - private function store_data( $key, $value ) { |
|
301 | + private function store_data($key, $value) { |
|
302 | 302 | global $wpdb; |
303 | 303 | |
304 | - $value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value ); |
|
304 | + $value = is_array($value) ? wp_json_encode($value) : esc_attr($value); |
|
305 | 305 | |
306 | 306 | $data = array( |
307 | 307 | 'option_name' => $key, |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | '%s', |
316 | 316 | ); |
317 | 317 | |
318 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
318 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
319 | 319 | } |
320 | 320 | |
321 | 321 | /** |
@@ -327,9 +327,9 @@ discard block |
||
327 | 327 | * |
328 | 328 | * @return void |
329 | 329 | */ |
330 | - private function delete_data( $key ) { |
|
330 | + private function delete_data($key) { |
|
331 | 331 | global $wpdb; |
332 | - $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) ); |
|
332 | + $wpdb->delete($wpdb->options, array('option_name' => $key)); |
|
333 | 333 | } |
334 | 334 | |
335 | 335 | } |
@@ -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,13 +216,13 @@ 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 | - foreach ( $payments as $payment ) { |
|
222 | - $gateway = give_get_payment_gateway( $payment ); |
|
221 | + foreach ($payments as $payment) { |
|
222 | + $gateway = give_get_payment_gateway($payment); |
|
223 | 223 | |
224 | 224 | // Skip payment gateways. |
225 | - if ( in_array( $gateway, $skip_payment_gateways ) ) { |
|
225 | + if (in_array($gateway, $skip_payment_gateways)) { |
|
226 | 226 | continue; |
227 | 227 | } |
228 | 228 | |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | } |
233 | 233 | } |
234 | 234 | |
235 | -Give_Cron::add_weekly_event( 'give_mark_abandoned_donations' ); |
|
235 | +Give_Cron::add_weekly_event('give_mark_abandoned_donations'); |
|
236 | 236 | |
237 | 237 | |
238 | 238 | /** |
@@ -244,15 +244,15 @@ discard block |
||
244 | 244 | * |
245 | 245 | * @return void |
246 | 246 | */ |
247 | -function give_refresh_thismonth_stat_transients( $payment_ID ) { |
|
247 | +function give_refresh_thismonth_stat_transients($payment_ID) { |
|
248 | 248 | // Monthly stats. |
249 | - Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) ); |
|
249 | + Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats')); |
|
250 | 250 | |
251 | 251 | // @todo: Refresh only range related stat cache |
252 | 252 | give_delete_donation_stats(); |
253 | 253 | } |
254 | 254 | |
255 | -add_action( 'save_post_give_payment', 'give_refresh_thismonth_stat_transients' ); |
|
255 | +add_action('save_post_give_payment', 'give_refresh_thismonth_stat_transients'); |
|
256 | 256 | |
257 | 257 | /* |
258 | 258 | * Add meta in payment that store page id and page url. |
@@ -264,18 +264,18 @@ discard block |
||
264 | 264 | * |
265 | 265 | * @param {integer} $payment_id Payment id for which the meta value should be updated. |
266 | 266 | */ |
267 | -function give_payment_save_page_data( $payment_id ) { |
|
268 | - $page_url = ( ! empty( $_REQUEST['give-current-url'] ) ? esc_url( $_REQUEST['give-current-url'] ) : false ); |
|
267 | +function give_payment_save_page_data($payment_id) { |
|
268 | + $page_url = ( ! empty($_REQUEST['give-current-url']) ? esc_url($_REQUEST['give-current-url']) : false); |
|
269 | 269 | // Check $page_url is not empty. |
270 | - if ( $page_url ) { |
|
271 | - update_post_meta( $payment_id, '_give_current_url', $page_url ); |
|
272 | - $page_id = url_to_postid( $page_url ); |
|
270 | + if ($page_url) { |
|
271 | + update_post_meta($payment_id, '_give_current_url', $page_url); |
|
272 | + $page_id = url_to_postid($page_url); |
|
273 | 273 | // Check $page_id is not empty. |
274 | - if ( $page_id ) { |
|
275 | - update_post_meta( $payment_id, '_give_current_page_id', $page_id ); |
|
274 | + if ($page_id) { |
|
275 | + update_post_meta($payment_id, '_give_current_page_id', $page_id); |
|
276 | 276 | } |
277 | 277 | } |
278 | 278 | } |
279 | 279 | |
280 | 280 | // Fire when payment is save. |
281 | -add_action( 'give_insert_payment', 'give_payment_save_page_data' ); |
|
282 | 281 | \ No newline at end of file |
282 | +add_action('give_insert_payment', 'give_payment_save_page_data'); |
|
283 | 283 | \ No newline at end of file |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * @return static |
52 | 52 | */ |
53 | 53 | public static function get_instance() { |
54 | - if ( null === static::$instance ) { |
|
54 | + if (null === static::$instance) { |
|
55 | 55 | self::$instance = new static(); |
56 | 56 | self::$instance->setup(); |
57 | 57 | } |
@@ -66,12 +66,12 @@ discard block |
||
66 | 66 | * @since 1.8.13 |
67 | 67 | */ |
68 | 68 | private function setup() { |
69 | - add_filter( 'cron_schedules', array( self::$instance, '__add_schedules' ) ); |
|
70 | - add_action( 'wp', array( self::$instance, '__schedule_events' ) ); |
|
69 | + add_filter('cron_schedules', array(self::$instance, '__add_schedules')); |
|
70 | + add_action('wp', array(self::$instance, '__schedule_events')); |
|
71 | 71 | |
72 | 72 | // Load async event only when cron is running. |
73 | - if( defined( 'DOING_CRON' ) && DOING_CRON ) { |
|
74 | - add_action( 'init', array( self::$instance, '__load_async_events' ) ); |
|
73 | + if (defined('DOING_CRON') && DOING_CRON) { |
|
74 | + add_action('init', array(self::$instance, '__load_async_events')); |
|
75 | 75 | } |
76 | 76 | } |
77 | 77 | |
@@ -82,23 +82,23 @@ discard block |
||
82 | 82 | * @since 1.8.13 |
83 | 83 | */ |
84 | 84 | public function __load_async_events() { |
85 | - $async_events = get_option( 'give_async_events', array() ); |
|
85 | + $async_events = get_option('give_async_events', array()); |
|
86 | 86 | |
87 | 87 | // Bailout. |
88 | - if ( empty( $async_events ) ) { |
|
88 | + if (empty($async_events)) { |
|
89 | 89 | return; |
90 | 90 | } |
91 | 91 | |
92 | - foreach ( $async_events as $index => $event ) { |
|
92 | + foreach ($async_events as $index => $event) { |
|
93 | 93 | // Set cron name. |
94 | 94 | $cron_name = "give_async_scheduled_events_{$index}"; |
95 | 95 | |
96 | 96 | // Setup cron. |
97 | - wp_schedule_single_event( current_time( 'timestamp', 1 ), $cron_name, $event['params'] ); |
|
97 | + wp_schedule_single_event(current_time('timestamp', 1), $cron_name, $event['params']); |
|
98 | 98 | |
99 | 99 | // Add cron action. |
100 | - add_action( $cron_name, $event['callback'], 10, count( $event['params'] ) ); |
|
101 | - add_action( $cron_name, array( $this, '__delete_async_events' ), 9999, 0 ); |
|
100 | + add_action($cron_name, $event['callback'], 10, count($event['params'])); |
|
101 | + add_action($cron_name, array($this, '__delete_async_events'), 9999, 0); |
|
102 | 102 | } |
103 | 103 | } |
104 | 104 | |
@@ -108,13 +108,13 @@ discard block |
||
108 | 108 | * @since 1.8.13 |
109 | 109 | */ |
110 | 110 | public function __delete_async_events() { |
111 | - $async_events = get_option( 'give_async_events', array() ); |
|
112 | - $cron_name_parts = explode( '_', current_action() ); |
|
113 | - $cron_id = end( $cron_name_parts ); |
|
111 | + $async_events = get_option('give_async_events', array()); |
|
112 | + $cron_name_parts = explode('_', current_action()); |
|
113 | + $cron_id = end($cron_name_parts); |
|
114 | 114 | |
115 | - if ( ! empty( $async_events[ $cron_id ] ) ) { |
|
116 | - unset( $async_events[ $cron_id ] ); |
|
117 | - update_option( 'give_async_events', $async_events ); |
|
115 | + if ( ! empty($async_events[$cron_id])) { |
|
116 | + unset($async_events[$cron_id]); |
|
117 | + update_option('give_async_events', $async_events); |
|
118 | 118 | } |
119 | 119 | } |
120 | 120 | |
@@ -128,11 +128,11 @@ discard block |
||
128 | 128 | * |
129 | 129 | * @return array An array of non-default cron schedules. |
130 | 130 | */ |
131 | - public function __add_schedules( $schedules = array() ) { |
|
131 | + public function __add_schedules($schedules = array()) { |
|
132 | 132 | // Adds once weekly to the existing schedules. |
133 | 133 | $schedules['weekly'] = array( |
134 | 134 | 'interval' => 604800, |
135 | - 'display' => __( 'Once Weekly', 'give' ), |
|
135 | + 'display' => __('Once Weekly', 'give'), |
|
136 | 136 | ); |
137 | 137 | |
138 | 138 | return $schedules; |
@@ -160,8 +160,8 @@ discard block |
||
160 | 160 | * @return void |
161 | 161 | */ |
162 | 162 | private function weekly_events() { |
163 | - if ( ! wp_next_scheduled( 'give_weekly_scheduled_events' ) ) { |
|
164 | - wp_schedule_event( current_time( 'timestamp' ), 'weekly', 'give_weekly_scheduled_events' ); |
|
163 | + if ( ! wp_next_scheduled('give_weekly_scheduled_events')) { |
|
164 | + wp_schedule_event(current_time('timestamp'), 'weekly', 'give_weekly_scheduled_events'); |
|
165 | 165 | } |
166 | 166 | } |
167 | 167 | |
@@ -174,8 +174,8 @@ discard block |
||
174 | 174 | * @return void |
175 | 175 | */ |
176 | 176 | private function daily_events() { |
177 | - if ( ! wp_next_scheduled( 'give_daily_scheduled_events' ) ) { |
|
178 | - wp_schedule_event( current_time( 'timestamp' ), 'daily', 'give_daily_scheduled_events' ); |
|
177 | + if ( ! wp_next_scheduled('give_daily_scheduled_events')) { |
|
178 | + wp_schedule_event(current_time('timestamp'), 'daily', 'give_daily_scheduled_events'); |
|
179 | 179 | } |
180 | 180 | } |
181 | 181 | |
@@ -189,8 +189,8 @@ discard block |
||
189 | 189 | * |
190 | 190 | * @return string |
191 | 191 | */ |
192 | - public static function get_cron_action( $type = 'weekly' ) { |
|
193 | - switch ( $type ) { |
|
192 | + public static function get_cron_action($type = 'weekly') { |
|
193 | + switch ($type) { |
|
194 | 194 | case 'daily': |
195 | 195 | $cron_action = 'give_daily_scheduled_events'; |
196 | 196 | break; |
@@ -212,9 +212,9 @@ discard block |
||
212 | 212 | * @param $action |
213 | 213 | * @param string $type |
214 | 214 | */ |
215 | - private static function add_event( $action, $type = 'weekly' ) { |
|
216 | - $cron_event = self::get_cron_action( $type ); |
|
217 | - add_action( $cron_event, $action ); |
|
215 | + private static function add_event($action, $type = 'weekly') { |
|
216 | + $cron_event = self::get_cron_action($type); |
|
217 | + add_action($cron_event, $action); |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | /** |
@@ -225,8 +225,8 @@ discard block |
||
225 | 225 | * |
226 | 226 | * @param $action |
227 | 227 | */ |
228 | - public static function add_weekly_event( $action ) { |
|
229 | - self::add_event( $action, 'weekly' ); |
|
228 | + public static function add_weekly_event($action) { |
|
229 | + self::add_event($action, 'weekly'); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | /** |
@@ -237,8 +237,8 @@ discard block |
||
237 | 237 | * |
238 | 238 | * @param $action |
239 | 239 | */ |
240 | - public static function add_daily_event( $action ) { |
|
241 | - self::add_event( $action, 'daily' ); |
|
240 | + public static function add_daily_event($action) { |
|
241 | + self::add_event($action, 'daily'); |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | /** |
@@ -251,17 +251,17 @@ discard block |
||
251 | 251 | * @param string $action |
252 | 252 | * @param array $args |
253 | 253 | */ |
254 | - public static function add_async_event( $action, $args = array() ) { |
|
254 | + public static function add_async_event($action, $args = array()) { |
|
255 | 255 | |
256 | 256 | // Cache async events. |
257 | - $async_events = get_option( 'give_async_events', array() ); |
|
258 | - $async_events[ uniqid() ] = array( |
|
257 | + $async_events = get_option('give_async_events', array()); |
|
258 | + $async_events[uniqid()] = array( |
|
259 | 259 | 'callback' => $action, |
260 | 260 | 'params' => $args, |
261 | 261 | ); |
262 | 262 | |
263 | 263 | |
264 | - update_option( 'give_async_events', $async_events ); |
|
264 | + update_option('give_async_events', $async_events); |
|
265 | 265 | } |
266 | 266 | } |
267 | 267 |
@@ -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 | |
@@ -62,50 +62,50 @@ discard block |
||
62 | 62 | * |
63 | 63 | * @return bool If the gravatar exists or not |
64 | 64 | */ |
65 | - public function validate_gravatar( $id_or_email ) { |
|
65 | + public function validate_gravatar($id_or_email) { |
|
66 | 66 | //id or email code borrowed from wp-includes/pluggable.php |
67 | 67 | $email = ''; |
68 | - if ( is_numeric( $id_or_email ) ) { |
|
68 | + if (is_numeric($id_or_email)) { |
|
69 | 69 | $id = (int) $id_or_email; |
70 | - $user = get_userdata( $id ); |
|
71 | - if ( $user ) { |
|
70 | + $user = get_userdata($id); |
|
71 | + if ($user) { |
|
72 | 72 | $email = $user->user_email; |
73 | 73 | } |
74 | - } elseif ( is_object( $id_or_email ) ) { |
|
74 | + } elseif (is_object($id_or_email)) { |
|
75 | 75 | // No avatar for pingbacks or trackbacks |
76 | - $allowed_comment_types = apply_filters( 'get_avatar_comment_types', array( 'comment' ) ); |
|
77 | - if ( ! empty( $id_or_email->comment_type ) && ! in_array( $id_or_email->comment_type, (array) $allowed_comment_types ) ) { |
|
76 | + $allowed_comment_types = apply_filters('get_avatar_comment_types', array('comment')); |
|
77 | + if ( ! empty($id_or_email->comment_type) && ! in_array($id_or_email->comment_type, (array) $allowed_comment_types)) { |
|
78 | 78 | return false; |
79 | 79 | } |
80 | 80 | |
81 | - if ( ! empty( $id_or_email->user_id ) ) { |
|
81 | + if ( ! empty($id_or_email->user_id)) { |
|
82 | 82 | $id = (int) $id_or_email->user_id; |
83 | - $user = get_userdata( $id ); |
|
84 | - if ( $user ) { |
|
83 | + $user = get_userdata($id); |
|
84 | + if ($user) { |
|
85 | 85 | $email = $user->user_email; |
86 | 86 | } |
87 | - } elseif ( ! empty( $id_or_email->comment_author_email ) ) { |
|
87 | + } elseif ( ! empty($id_or_email->comment_author_email)) { |
|
88 | 88 | $email = $id_or_email->comment_author_email; |
89 | 89 | } |
90 | 90 | } else { |
91 | 91 | $email = $id_or_email; |
92 | 92 | } |
93 | 93 | |
94 | - $hashkey = md5( strtolower( trim( $email ) ) ); |
|
95 | - $uri = 'http://www.gravatar.com/avatar/' . $hashkey . '?d=404'; |
|
94 | + $hashkey = md5(strtolower(trim($email))); |
|
95 | + $uri = 'http://www.gravatar.com/avatar/'.$hashkey.'?d=404'; |
|
96 | 96 | |
97 | - $data = wp_cache_get( $hashkey ); |
|
98 | - if ( false === $data ) { |
|
99 | - $response = wp_remote_head( $uri ); |
|
100 | - if ( is_wp_error( $response ) ) { |
|
97 | + $data = wp_cache_get($hashkey); |
|
98 | + if (false === $data) { |
|
99 | + $response = wp_remote_head($uri); |
|
100 | + if (is_wp_error($response)) { |
|
101 | 101 | $data = 'not200'; |
102 | 102 | } else { |
103 | 103 | $data = $response['response']['code']; |
104 | 104 | } |
105 | - wp_cache_set( $hashkey, $data, $group = '', $expire = 60 * 5 ); |
|
105 | + wp_cache_set($hashkey, $data, $group = '', $expire = 60 * 5); |
|
106 | 106 | |
107 | 107 | } |
108 | - if ( $data == '200' ) { |
|
108 | + if ($data == '200') { |
|
109 | 109 | return true; |
110 | 110 | } else { |
111 | 111 | return false; |
@@ -122,19 +122,19 @@ discard block |
||
122 | 122 | * |
123 | 123 | * @return array IDs if logs, false otherwise |
124 | 124 | */ |
125 | - public function get_log_ids( $form_id = '' ) { |
|
125 | + public function get_log_ids($form_id = '') { |
|
126 | 126 | |
127 | 127 | // get Give_Logging class |
128 | 128 | global $give_logs; |
129 | 129 | |
130 | 130 | // get log for this form |
131 | - $logs = $give_logs->get_logs( $form_id ); |
|
131 | + $logs = $give_logs->get_logs($form_id); |
|
132 | 132 | |
133 | - if ( $logs ) { |
|
133 | + if ($logs) { |
|
134 | 134 | $log_ids = array(); |
135 | 135 | |
136 | 136 | // make an array with all the donor IDs |
137 | - foreach ( $logs as $log ) { |
|
137 | + foreach ($logs as $log) { |
|
138 | 138 | $log_ids[] = $log->ID; |
139 | 139 | } |
140 | 140 | |
@@ -155,51 +155,51 @@ discard block |
||
155 | 155 | * |
156 | 156 | * @return mixed |
157 | 157 | */ |
158 | - public function get_payment_ids( $form_id = '' ) { |
|
158 | + public function get_payment_ids($form_id = '') { |
|
159 | 159 | |
160 | 160 | $give_options = give_get_settings(); |
161 | 161 | |
162 | - $log_ids = $this->get_log_ids( $form_id ); |
|
162 | + $log_ids = $this->get_log_ids($form_id); |
|
163 | 163 | |
164 | - if ( $log_ids ) { |
|
164 | + if ($log_ids) { |
|
165 | 165 | |
166 | 166 | $payment_ids = array(); |
167 | 167 | |
168 | - foreach ( $log_ids as $id ) { |
|
168 | + foreach ($log_ids as $id) { |
|
169 | 169 | // get the payment ID for each corresponding log ID |
170 | - $payment_ids[] = give_get_meta( $id, '_give_log_payment_id', true ); |
|
170 | + $payment_ids[] = give_get_meta($id, '_give_log_payment_id', true); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | // remove donors who have donated more than once so we can have unique avatars |
174 | 174 | $unique_emails = array(); |
175 | 175 | |
176 | - foreach ( $payment_ids as $key => $id ) { |
|
176 | + foreach ($payment_ids as $key => $id) { |
|
177 | 177 | |
178 | - $email = give_get_meta( $id, '_give_payment_user_email', true ); |
|
178 | + $email = give_get_meta($id, '_give_payment_user_email', true); |
|
179 | 179 | |
180 | - if ( isset ( $give_options['give_donors_gravatars_has_gravatar_account'] ) ) { |
|
181 | - if ( ! $this->validate_gravatar( $email ) ) { |
|
180 | + if (isset ($give_options['give_donors_gravatars_has_gravatar_account'])) { |
|
181 | + if ( ! $this->validate_gravatar($email)) { |
|
182 | 182 | continue; |
183 | 183 | } |
184 | 184 | } |
185 | 185 | |
186 | - $unique_emails[ $id ] = give_get_meta( $id, '_give_payment_user_email', true ); |
|
186 | + $unique_emails[$id] = give_get_meta($id, '_give_payment_user_email', true); |
|
187 | 187 | |
188 | 188 | } |
189 | 189 | |
190 | 190 | $unique_ids = array(); |
191 | 191 | |
192 | 192 | // strip duplicate emails |
193 | - $unique_emails = array_unique( $unique_emails ); |
|
193 | + $unique_emails = array_unique($unique_emails); |
|
194 | 194 | |
195 | 195 | // convert the unique IDs back into simple array |
196 | - foreach ( $unique_emails as $id => $email ) { |
|
196 | + foreach ($unique_emails as $id => $email) { |
|
197 | 197 | $unique_ids[] = $id; |
198 | 198 | } |
199 | 199 | |
200 | 200 | // randomize the payment IDs if enabled |
201 | - if ( isset( $give_options['give_donors_gravatars_random_gravatars'] ) ) { |
|
202 | - shuffle( $unique_ids ); |
|
201 | + if (isset($give_options['give_donors_gravatars_random_gravatars'])) { |
|
202 | + shuffle($unique_ids); |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | // return our unique IDs |
@@ -220,22 +220,22 @@ discard block |
||
220 | 220 | * |
221 | 221 | * @return string |
222 | 222 | */ |
223 | - public function gravatars( $form_id = false, $title = '' ) { |
|
223 | + public function gravatars($form_id = false, $title = '') { |
|
224 | 224 | |
225 | 225 | // unique $payment_ids |
226 | - $payment_ids = $this->get_payment_ids( $form_id ); |
|
226 | + $payment_ids = $this->get_payment_ids($form_id); |
|
227 | 227 | |
228 | 228 | $give_options = give_get_settings(); |
229 | 229 | |
230 | 230 | // return if no ID |
231 | - if ( ! $form_id ) { |
|
231 | + if ( ! $form_id) { |
|
232 | 232 | return; |
233 | 233 | } |
234 | 234 | |
235 | 235 | // minimum amount of donations before showing gravatars |
236 | 236 | // if the number of items in array is not greater or equal to the number specified, then exit |
237 | - if ( isset( $give_options['give_donors_gravatars_min_purchases_required'] ) && '' != $give_options['give_donors_gravatars_min_purchases_required'] ) { |
|
238 | - if ( ! ( count( $payment_ids ) >= $give_options['give_donors_gravatars_min_purchases_required'] ) ) { |
|
237 | + if (isset($give_options['give_donors_gravatars_min_purchases_required']) && '' != $give_options['give_donors_gravatars_min_purchases_required']) { |
|
238 | + if ( ! (count($payment_ids) >= $give_options['give_donors_gravatars_min_purchases_required'])) { |
|
239 | 239 | return; |
240 | 240 | } |
241 | 241 | } |
@@ -246,28 +246,28 @@ discard block |
||
246 | 246 | echo '<div id="give-purchase-gravatars">'; |
247 | 247 | |
248 | 248 | |
249 | - if ( isset ( $title ) ) { |
|
249 | + if (isset ($title)) { |
|
250 | 250 | |
251 | - if ( $title ) { |
|
252 | - echo apply_filters( 'give_donors_gravatars_title', '<h3 class="give-gravatars-title">' . esc_attr( $title ) . '</h3>' ); |
|
253 | - } elseif ( isset( $give_options['give_donors_gravatars_heading'] ) ) { |
|
254 | - echo apply_filters( 'give_donors_gravatars_title', '<h3 class="give-gravatars-title">' . esc_attr( $give_options['give_donors_gravatars_heading'] ) . '</h2>' ); |
|
251 | + if ($title) { |
|
252 | + echo apply_filters('give_donors_gravatars_title', '<h3 class="give-gravatars-title">'.esc_attr($title).'</h3>'); |
|
253 | + } elseif (isset($give_options['give_donors_gravatars_heading'])) { |
|
254 | + echo apply_filters('give_donors_gravatars_title', '<h3 class="give-gravatars-title">'.esc_attr($give_options['give_donors_gravatars_heading']).'</h2>'); |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | } |
258 | 258 | echo '<ul class="give-purchase-gravatars-list">'; |
259 | 259 | $i = 0; |
260 | 260 | |
261 | - if ( $payment_ids ) { |
|
262 | - foreach ( $payment_ids as $id ) { |
|
261 | + if ($payment_ids) { |
|
262 | + foreach ($payment_ids as $id) { |
|
263 | 263 | |
264 | 264 | // Give saves a blank option even when the control is turned off, hence the extra check |
265 | - if ( isset( $give_options['give_donors_gravatars_maximum_number'] ) && '' != $give_options['give_donors_gravatars_maximum_number'] && $i == $give_options['give_donors_gravatars_maximum_number'] ) { |
|
265 | + if (isset($give_options['give_donors_gravatars_maximum_number']) && '' != $give_options['give_donors_gravatars_maximum_number'] && $i == $give_options['give_donors_gravatars_maximum_number']) { |
|
266 | 266 | continue; |
267 | 267 | } |
268 | 268 | |
269 | 269 | // get the payment meta |
270 | - $payment_meta = give_get_meta( $id, '_give_payment_meta', true ); |
|
270 | + $payment_meta = give_get_meta($id, '_give_payment_meta', true); |
|
271 | 271 | |
272 | 272 | $user_info = $payment_meta['user_info']; |
273 | 273 | |
@@ -275,21 +275,21 @@ discard block |
||
275 | 275 | $name = $user_info['first_name']; |
276 | 276 | |
277 | 277 | // get donor's email |
278 | - $email = give_get_meta( $id, '_give_payment_user_email', true ); |
|
278 | + $email = give_get_meta($id, '_give_payment_user_email', true); |
|
279 | 279 | |
280 | 280 | // set gravatar size and provide filter |
281 | - $size = isset( $give_options['give_donors_gravatars_gravatar_size'] ) ? apply_filters( 'give_donors_gravatars_gravatar_size', $give_options['give_donors_gravatars_gravatar_size'] ) : ''; |
|
281 | + $size = isset($give_options['give_donors_gravatars_gravatar_size']) ? apply_filters('give_donors_gravatars_gravatar_size', $give_options['give_donors_gravatars_gravatar_size']) : ''; |
|
282 | 282 | |
283 | 283 | // default image |
284 | - $default_image = apply_filters( 'give_donors_gravatars_gravatar_default_image', false ); |
|
284 | + $default_image = apply_filters('give_donors_gravatars_gravatar_default_image', false); |
|
285 | 285 | |
286 | 286 | // assemble output |
287 | 287 | $output .= '<li>'; |
288 | 288 | |
289 | - $output .= get_avatar( $email, $size, $default_image, $name ); |
|
289 | + $output .= get_avatar($email, $size, $default_image, $name); |
|
290 | 290 | $output .= '</li>'; |
291 | 291 | |
292 | - $i ++; |
|
292 | + $i++; |
|
293 | 293 | |
294 | 294 | } // end foreach |
295 | 295 | } |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | echo '</ul>'; |
299 | 299 | echo '</div>'; |
300 | 300 | |
301 | - return apply_filters( 'give_donors_gravatars', ob_get_clean() ); |
|
301 | + return apply_filters('give_donors_gravatars', ob_get_clean()); |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | /** |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | * @return void |
311 | 311 | */ |
312 | 312 | public function register_widget() { |
313 | - register_widget( 'Give_Donors_Gravatars_Widget' ); |
|
313 | + register_widget('Give_Donors_Gravatars_Widget'); |
|
314 | 314 | } |
315 | 315 | |
316 | 316 | /** |
@@ -324,19 +324,19 @@ discard block |
||
324 | 324 | * |
325 | 325 | * @return string |
326 | 326 | */ |
327 | - public function shortcode( $atts, $content = null ) { |
|
327 | + public function shortcode($atts, $content = null) { |
|
328 | 328 | |
329 | - $atts = shortcode_atts( array( |
|
329 | + $atts = shortcode_atts(array( |
|
330 | 330 | 'id' => '', |
331 | 331 | 'title' => '' |
332 | - ), $atts, 'give_donors_gravatars' ); |
|
332 | + ), $atts, 'give_donors_gravatars'); |
|
333 | 333 | |
334 | 334 | // if no ID is passed on single give_forms pages, get the correct ID |
335 | - if ( is_singular( 'give_forms' ) ) { |
|
335 | + if (is_singular('give_forms')) { |
|
336 | 336 | $id = get_the_ID(); |
337 | 337 | } |
338 | 338 | |
339 | - $content = $this->gravatars( $atts['id'], $atts['title'] ); |
|
339 | + $content = $this->gravatars($atts['id'], $atts['title']); |
|
340 | 340 | |
341 | 341 | return $content; |
342 | 342 | |
@@ -352,56 +352,56 @@ discard block |
||
352 | 352 | * |
353 | 353 | * @return array Gravatar settings. |
354 | 354 | */ |
355 | - public function settings( $settings ) { |
|
355 | + public function settings($settings) { |
|
356 | 356 | |
357 | 357 | $give_gravatar_settings = array( |
358 | 358 | array( |
359 | - 'name' => esc_html__( 'Donator Gravatars', 'give' ), |
|
359 | + 'name' => esc_html__('Donator Gravatars', 'give'), |
|
360 | 360 | 'desc' => '<hr>', |
361 | 361 | 'id' => 'give_title', |
362 | 362 | 'type' => 'give_title' |
363 | 363 | ), |
364 | 364 | array( |
365 | - 'name' => esc_html__( 'Heading', 'give' ), |
|
366 | - 'desc' => esc_html__( 'The heading to display above the Gravatars.', 'give' ), |
|
365 | + 'name' => esc_html__('Heading', 'give'), |
|
366 | + 'desc' => esc_html__('The heading to display above the Gravatars.', 'give'), |
|
367 | 367 | 'type' => 'text', |
368 | 368 | 'id' => 'give_donors_gravatars_heading' |
369 | 369 | ), |
370 | 370 | array( |
371 | - 'name' => esc_html__( 'Gravatar Size', 'give' ), |
|
372 | - 'desc' => esc_html__( 'The size of each Gravatar in pixels (512px maximum).', 'give' ), |
|
371 | + 'name' => esc_html__('Gravatar Size', 'give'), |
|
372 | + 'desc' => esc_html__('The size of each Gravatar in pixels (512px maximum).', 'give'), |
|
373 | 373 | 'type' => 'text_small', |
374 | 374 | 'id' => 'give_donors_gravatars_gravatar_size', |
375 | 375 | 'default' => '64' |
376 | 376 | ), |
377 | 377 | array( |
378 | - 'name' => esc_html__( 'Minimum Unique Donations Required', 'give' ), |
|
379 | - 'desc' => esc_html__( 'The minimum number of unique donations a form must have before the Gravatars are shown. Leave blank for no minimum.', 'give' ), |
|
378 | + 'name' => esc_html__('Minimum Unique Donations Required', 'give'), |
|
379 | + 'desc' => esc_html__('The minimum number of unique donations a form must have before the Gravatars are shown. Leave blank for no minimum.', 'give'), |
|
380 | 380 | 'type' => 'text_small', |
381 | 381 | 'id' => 'give_donors_gravatars_min_purchases_required', |
382 | 382 | ), |
383 | 383 | array( |
384 | - 'name' => esc_html__( 'Maximum Gravatars To Show', 'give' ), |
|
385 | - 'desc' => esc_html__( 'The maximum number of gravatars to show. Leave blank for no limit.', 'give' ), |
|
384 | + 'name' => esc_html__('Maximum Gravatars To Show', 'give'), |
|
385 | + 'desc' => esc_html__('The maximum number of gravatars to show. Leave blank for no limit.', 'give'), |
|
386 | 386 | 'type' => 'text', |
387 | 387 | 'id' => 'give_donors_gravatars_maximum_number', |
388 | 388 | 'default' => '20', |
389 | 389 | ), |
390 | 390 | array( |
391 | - 'name' => esc_html__( 'Gravatar Visibility', 'give' ), |
|
392 | - 'desc' => esc_html__( 'Show only donors with a Gravatar account.', 'give' ), |
|
391 | + 'name' => esc_html__('Gravatar Visibility', 'give'), |
|
392 | + 'desc' => esc_html__('Show only donors with a Gravatar account.', 'give'), |
|
393 | 393 | 'id' => 'give_donors_gravatars_has_gravatar_account', |
394 | 394 | 'type' => 'checkbox', |
395 | 395 | ), |
396 | 396 | array( |
397 | - 'name' => esc_html__( 'Randomize Gravatars', 'give' ), |
|
398 | - 'desc' => esc_html__( 'Randomize the Gravatars.', 'give' ), |
|
397 | + 'name' => esc_html__('Randomize Gravatars', 'give'), |
|
398 | + 'desc' => esc_html__('Randomize the Gravatars.', 'give'), |
|
399 | 399 | 'id' => 'give_donors_gravatars_random_gravatars', |
400 | 400 | 'type' => 'checkbox', |
401 | 401 | ), |
402 | 402 | ); |
403 | 403 | |
404 | - return array_merge( $settings, $give_gravatar_settings ); |
|
404 | + return array_merge($settings, $give_gravatar_settings); |
|
405 | 405 | } |
406 | 406 | |
407 | 407 | } |
@@ -427,7 +427,7 @@ discard block |
||
427 | 427 | // widget settings |
428 | 428 | $widget_ops = array( |
429 | 429 | 'classname' => 'give-donors-gravatars', |
430 | - 'description' => esc_html__( 'Displays gravatars of people who have donated using your your form. Will only show on the single form page.', 'give' ), |
|
430 | + 'description' => esc_html__('Displays gravatars of people who have donated using your your form. Will only show on the single form page.', 'give'), |
|
431 | 431 | ); |
432 | 432 | |
433 | 433 | // widget control settings |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | // create the widget |
441 | 441 | parent::__construct( |
442 | 442 | 'give_donors_gravatars_widget', |
443 | - esc_html__( 'Give Donors Gravatars', 'give' ), |
|
443 | + esc_html__('Give Donors Gravatars', 'give'), |
|
444 | 444 | $widget_ops, |
445 | 445 | $control_ops |
446 | 446 | ); |
@@ -460,29 +460,29 @@ discard block |
||
460 | 460 | * |
461 | 461 | * @return void |
462 | 462 | */ |
463 | - public function widget( $args, $instance ) { |
|
463 | + public function widget($args, $instance) { |
|
464 | 464 | |
465 | 465 | //@TODO: Don't extract it!!! |
466 | - extract( $args ); |
|
466 | + extract($args); |
|
467 | 467 | |
468 | - if ( ! is_singular( 'give_forms' ) ) { |
|
468 | + if ( ! is_singular('give_forms')) { |
|
469 | 469 | return; |
470 | 470 | } |
471 | 471 | |
472 | 472 | // Variables from widget settings |
473 | - $title = apply_filters( 'widget_title', $instance['title'] ); |
|
473 | + $title = apply_filters('widget_title', $instance['title']); |
|
474 | 474 | |
475 | 475 | // Used by themes. Opens the widget |
476 | 476 | echo $before_widget; |
477 | 477 | |
478 | 478 | // Display the widget title |
479 | - if ( $title ) { |
|
480 | - echo $before_title . $title . $after_title; |
|
479 | + if ($title) { |
|
480 | + echo $before_title.$title.$after_title; |
|
481 | 481 | } |
482 | 482 | |
483 | 483 | $gravatars = new Give_Donors_Gravatars(); |
484 | 484 | |
485 | - echo $gravatars->gravatars( get_the_ID(), null ); // remove title |
|
485 | + echo $gravatars->gravatars(get_the_ID(), null); // remove title |
|
486 | 486 | |
487 | 487 | // Used by themes. Closes the widget |
488 | 488 | echo $after_widget; |
@@ -502,11 +502,11 @@ discard block |
||
502 | 502 | * |
503 | 503 | * @return array Updated settings to save. |
504 | 504 | */ |
505 | - public function update( $new_instance, $old_instance ) { |
|
505 | + public function update($new_instance, $old_instance) { |
|
506 | 506 | |
507 | 507 | $instance = $old_instance; |
508 | 508 | |
509 | - $instance['title'] = strip_tags( $new_instance['title'] ); |
|
509 | + $instance['title'] = strip_tags($new_instance['title']); |
|
510 | 510 | |
511 | 511 | return $instance; |
512 | 512 | |
@@ -524,19 +524,19 @@ discard block |
||
524 | 524 | * |
525 | 525 | * @return void |
526 | 526 | */ |
527 | - public function form( $instance ) { |
|
527 | + public function form($instance) { |
|
528 | 528 | |
529 | 529 | // Set up some default widget settings. |
530 | 530 | $defaults = array( |
531 | 531 | 'title' => '', |
532 | 532 | ); |
533 | 533 | |
534 | - $instance = wp_parse_args( (array) $instance, $defaults ); ?> |
|
534 | + $instance = wp_parse_args((array) $instance, $defaults); ?> |
|
535 | 535 | |
536 | 536 | <!-- Title --> |
537 | 537 | <p> |
538 | - <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php esc_html_e( 'Title:', 'give' ) ?></label> |
|
539 | - <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo $instance['title']; ?>" /> |
|
538 | + <label for="<?php echo $this->get_field_id('title'); ?>"><?php esc_html_e('Title:', 'give') ?></label> |
|
539 | + <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $instance['title']; ?>" /> |
|
540 | 540 | </p> |
541 | 541 | |
542 | 542 | <?php |