@@ -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 | |
@@ -73,8 +73,8 @@ discard block |
||
73 | 73 | /** |
74 | 74 | * Constructor. |
75 | 75 | */ |
76 | - public function __construct( $_step = 1 ) { |
|
77 | - parent::__construct( $_step ); |
|
76 | + public function __construct($_step = 1) { |
|
77 | + parent::__construct($_step); |
|
78 | 78 | |
79 | 79 | $this->is_writable = true; |
80 | 80 | } |
@@ -89,108 +89,106 @@ discard block |
||
89 | 89 | */ |
90 | 90 | public function get_data() { |
91 | 91 | |
92 | - $totals = $this->get_stored_data( 'give_temp_recount_all_stats' ); |
|
93 | - $payment_items = $this->get_stored_data( 'give_temp_payment_items' ); |
|
94 | - $processed_payments = $this->get_stored_data( 'give_temp_processed_payments' ); |
|
95 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) ); |
|
92 | + $totals = $this->get_stored_data('give_temp_recount_all_stats'); |
|
93 | + $payment_items = $this->get_stored_data('give_temp_payment_items'); |
|
94 | + $processed_payments = $this->get_stored_data('give_temp_processed_payments'); |
|
95 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish')); |
|
96 | 96 | |
97 | - if ( false === $totals ) { |
|
97 | + if (false === $totals) { |
|
98 | 98 | $totals = array(); |
99 | 99 | } |
100 | 100 | |
101 | - if ( false === $payment_items ) { |
|
101 | + if (false === $payment_items) { |
|
102 | 102 | $payment_items = array(); |
103 | 103 | } |
104 | 104 | |
105 | - if ( false === $processed_payments ) { |
|
105 | + if (false === $processed_payments) { |
|
106 | 106 | $processed_payments = array(); |
107 | 107 | } |
108 | 108 | |
109 | - $all_forms = $this->get_stored_data( 'give_temp_form_ids' ); |
|
109 | + $all_forms = $this->get_stored_data('give_temp_form_ids'); |
|
110 | 110 | |
111 | - $payments = $this->get_stored_data( 'give_temp_all_payments_data' ); |
|
111 | + $payments = $this->get_stored_data('give_temp_all_payments_data'); |
|
112 | 112 | |
113 | - if ( empty( $payments ) ) { |
|
114 | - $args = apply_filters( 'give_recount_form_stats_args', array( |
|
113 | + if (empty($payments)) { |
|
114 | + $args = apply_filters('give_recount_form_stats_args', array( |
|
115 | 115 | 'give_forms' => $all_forms, |
116 | 116 | 'number' => $this->per_step, |
117 | 117 | 'status' => $accepted_statuses, |
118 | 118 | 'paged' => $this->step, |
119 | 119 | 'output' => 'give_payments', |
120 | - ) ); |
|
120 | + )); |
|
121 | 121 | |
122 | - $payments_query = new Give_Payments_Query( $args ); |
|
122 | + $payments_query = new Give_Payments_Query($args); |
|
123 | 123 | $payments = $payments_query->get_payments(); |
124 | 124 | } |
125 | 125 | |
126 | - if ( ! empty( $payments ) ) { |
|
126 | + if ( ! empty($payments)) { |
|
127 | 127 | |
128 | 128 | //Loop through payments |
129 | - foreach ( $payments as $payment ) { |
|
129 | + foreach ($payments as $payment) { |
|
130 | 130 | |
131 | - $payment_id = ( ! empty( $payment['ID'] ) ? absint( $payment['ID'] ) : ( ! empty( $payment->ID ) ? absint( $payment->ID ) : false ) ); |
|
132 | - $payment = new Give_Payment( $payment_id ); |
|
131 | + $payment_id = ( ! empty($payment['ID']) ? absint($payment['ID']) : ( ! empty($payment->ID) ? absint($payment->ID) : false)); |
|
132 | + $payment = new Give_Payment($payment_id); |
|
133 | 133 | |
134 | 134 | // Prevent payments that have all ready been retrieved from a previous sales log from counting again. |
135 | - if ( in_array( $payment->ID, $processed_payments ) ) { |
|
135 | + if (in_array($payment->ID, $processed_payments)) { |
|
136 | 136 | continue; |
137 | 137 | } |
138 | 138 | |
139 | 139 | // Verify accepted status. |
140 | - if ( ! in_array( $payment->post_status, $accepted_statuses ) ) { |
|
140 | + if ( ! in_array($payment->post_status, $accepted_statuses)) { |
|
141 | 141 | $processed_payments[] = $payment->ID; |
142 | 142 | continue; |
143 | 143 | } |
144 | 144 | |
145 | - $payment_item = $payment_items[ $payment->ID ]; |
|
145 | + $payment_item = $payment_items[$payment->ID]; |
|
146 | 146 | |
147 | - $form_id = isset( $payment_item['id'] ) ? $payment_item['id'] : ''; |
|
147 | + $form_id = isset($payment_item['id']) ? $payment_item['id'] : ''; |
|
148 | 148 | |
149 | 149 | // Must have a form ID. |
150 | - if ( empty( $form_id ) ) { |
|
150 | + if (empty($form_id)) { |
|
151 | 151 | continue; |
152 | 152 | } |
153 | 153 | |
154 | 154 | // Form ID must be within $all_forms array to be validated. |
155 | - if ( ! in_array( $form_id, $all_forms ) ) { |
|
155 | + if ( ! in_array($form_id, $all_forms)) { |
|
156 | 156 | continue; |
157 | 157 | } |
158 | 158 | |
159 | 159 | // Set Sales count |
160 | - $totals[ $form_id ]['sales'] = isset( $totals[ $form_id ]['sales'] ) ? |
|
161 | - ++ $totals[ $form_id ]['sales'] : |
|
162 | - 1; |
|
160 | + $totals[$form_id]['sales'] = isset($totals[$form_id]['sales']) ? |
|
161 | + ++$totals[$form_id]['sales'] : 1; |
|
163 | 162 | |
164 | 163 | // Set Total Earnings |
165 | - $totals[ $form_id ]['earnings'] = isset( $totals[ $form_id ]['earnings'] ) ? |
|
166 | - ( $totals[ $form_id ]['earnings'] + $payment_item['price'] ) : |
|
167 | - $payment_item['price']; |
|
164 | + $totals[$form_id]['earnings'] = isset($totals[$form_id]['earnings']) ? |
|
165 | + ($totals[$form_id]['earnings'] + $payment_item['price']) : $payment_item['price']; |
|
168 | 166 | |
169 | 167 | $processed_payments[] = $payment->ID; |
170 | 168 | } |
171 | 169 | |
172 | 170 | // Get the list of form ids which does not contain any payment record. |
173 | - $remaining_form_ids = array_diff( $all_forms, array_keys( $totals ) ); |
|
174 | - foreach ( $remaining_form_ids as $form_id ) { |
|
171 | + $remaining_form_ids = array_diff($all_forms, array_keys($totals)); |
|
172 | + foreach ($remaining_form_ids as $form_id) { |
|
175 | 173 | //If array key doesn't exist, create it |
176 | - if ( ! array_key_exists( $form_id, $totals ) ) { |
|
177 | - $totals[ $form_id ] = array( |
|
174 | + if ( ! array_key_exists($form_id, $totals)) { |
|
175 | + $totals[$form_id] = array( |
|
178 | 176 | 'sales' => (int) 0, |
179 | 177 | 'earnings' => (float) 0, |
180 | 178 | ); |
181 | 179 | } |
182 | 180 | } |
183 | 181 | |
184 | - $this->store_data( 'give_temp_processed_payments', $processed_payments ); |
|
185 | - $this->store_data( 'give_temp_recount_all_stats', $totals ); |
|
182 | + $this->store_data('give_temp_processed_payments', $processed_payments); |
|
183 | + $this->store_data('give_temp_recount_all_stats', $totals); |
|
186 | 184 | |
187 | 185 | return true; |
188 | 186 | } |
189 | 187 | |
190 | 188 | |
191 | - foreach ( $totals as $key => $stats ) { |
|
192 | - give_update_meta( $key, '_give_form_sales', $stats['sales'] ); |
|
193 | - give_update_meta( $key, '_give_form_earnings', give_sanitize_amount_for_db( $stats['earnings'] ) ); |
|
189 | + foreach ($totals as $key => $stats) { |
|
190 | + give_update_meta($key, '_give_form_sales', $stats['sales']); |
|
191 | + give_update_meta($key, '_give_form_earnings', give_sanitize_amount_for_db($stats['earnings'])); |
|
194 | 192 | } |
195 | 193 | |
196 | 194 | return false; |
@@ -205,20 +203,20 @@ discard block |
||
205 | 203 | */ |
206 | 204 | public function get_percentage_complete() { |
207 | 205 | |
208 | - $total = $this->get_stored_data( 'give_recount_all_total' ); |
|
206 | + $total = $this->get_stored_data('give_recount_all_total'); |
|
209 | 207 | |
210 | - if ( false === $total ) { |
|
208 | + if (false === $total) { |
|
211 | 209 | $this->pre_fetch(); |
212 | - $total = $this->get_stored_data( 'give_recount_all_total' ); |
|
210 | + $total = $this->get_stored_data('give_recount_all_total'); |
|
213 | 211 | } |
214 | 212 | |
215 | 213 | $percentage = 100; |
216 | 214 | |
217 | - if ( $total > 0 ) { |
|
218 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
215 | + if ($total > 0) { |
|
216 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
219 | 217 | } |
220 | 218 | |
221 | - if ( $percentage > 100 ) { |
|
219 | + if ($percentage > 100) { |
|
222 | 220 | $percentage = 100; |
223 | 221 | } |
224 | 222 | |
@@ -232,8 +230,8 @@ discard block |
||
232 | 230 | * |
233 | 231 | * @param array $request The Form Data passed into the batch processing |
234 | 232 | */ |
235 | - public function set_properties( $request ) { |
|
236 | - $this->form_id = isset( $request['form_id'] ) ? sanitize_text_field( $request['form_id'] ) : false; |
|
233 | + public function set_properties($request) { |
|
234 | + $this->form_id = isset($request['form_id']) ? sanitize_text_field($request['form_id']) : false; |
|
237 | 235 | } |
238 | 236 | |
239 | 237 | /** |
@@ -244,25 +242,25 @@ discard block |
||
244 | 242 | */ |
245 | 243 | public function process_step() { |
246 | 244 | |
247 | - if ( ! $this->can_export() ) { |
|
248 | - wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
245 | + if ( ! $this->can_export()) { |
|
246 | + wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
249 | 247 | } |
250 | 248 | |
251 | 249 | $had_data = $this->get_data(); |
252 | 250 | |
253 | - if ( $had_data ) { |
|
251 | + if ($had_data) { |
|
254 | 252 | $this->done = false; |
255 | 253 | |
256 | 254 | return true; |
257 | 255 | } else { |
258 | - $this->delete_data( 'give_recount_total_' . $this->form_id ); |
|
259 | - $this->delete_data( 'give_recount_all_total' ); |
|
260 | - $this->delete_data( 'give_temp_recount_all_stats' ); |
|
261 | - $this->delete_data( 'give_temp_payment_items' ); |
|
262 | - $this->delete_data( 'give_temp_form_ids' ); |
|
263 | - $this->delete_data( 'give_temp_processed_payments' ); |
|
256 | + $this->delete_data('give_recount_total_'.$this->form_id); |
|
257 | + $this->delete_data('give_recount_all_total'); |
|
258 | + $this->delete_data('give_temp_recount_all_stats'); |
|
259 | + $this->delete_data('give_temp_payment_items'); |
|
260 | + $this->delete_data('give_temp_form_ids'); |
|
261 | + $this->delete_data('give_temp_processed_payments'); |
|
264 | 262 | $this->done = true; |
265 | - $this->message = esc_html__( 'Donation form income amounts and donation counts stats successfully recounted.', 'give' ); |
|
263 | + $this->message = esc_html__('Donation form income amounts and donation counts stats successfully recounted.', 'give'); |
|
266 | 264 | |
267 | 265 | return false; |
268 | 266 | } |
@@ -298,69 +296,69 @@ discard block |
||
298 | 296 | */ |
299 | 297 | public function pre_fetch() { |
300 | 298 | |
301 | - if ( 1 == $this->step ) { |
|
302 | - $this->delete_data( 'give_temp_recount_all_total' ); |
|
303 | - $this->delete_data( 'give_temp_recount_all_stats' ); |
|
304 | - $this->delete_data( 'give_temp_payment_items' ); |
|
305 | - $this->delete_data( 'give_temp_processed_payments' ); |
|
306 | - $this->delete_data( 'give_temp_all_payments_data' ); |
|
299 | + if (1 == $this->step) { |
|
300 | + $this->delete_data('give_temp_recount_all_total'); |
|
301 | + $this->delete_data('give_temp_recount_all_stats'); |
|
302 | + $this->delete_data('give_temp_payment_items'); |
|
303 | + $this->delete_data('give_temp_processed_payments'); |
|
304 | + $this->delete_data('give_temp_all_payments_data'); |
|
307 | 305 | } |
308 | 306 | |
309 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) ); |
|
310 | - $total = $this->get_stored_data( 'give_temp_recount_all_total' ); |
|
307 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish')); |
|
308 | + $total = $this->get_stored_data('give_temp_recount_all_total'); |
|
311 | 309 | |
312 | - if ( false === $total ) { |
|
310 | + if (false === $total) { |
|
313 | 311 | |
314 | - $payment_items = $this->get_stored_data( 'give_temp_payment_items' ); |
|
312 | + $payment_items = $this->get_stored_data('give_temp_payment_items'); |
|
315 | 313 | |
316 | - if ( false === $payment_items ) { |
|
314 | + if (false === $payment_items) { |
|
317 | 315 | $payment_items = array(); |
318 | - $this->store_data( 'give_temp_payment_items', $payment_items ); |
|
316 | + $this->store_data('give_temp_payment_items', $payment_items); |
|
319 | 317 | } |
320 | 318 | |
321 | 319 | $args = array( |
322 | 320 | 'post_status' => 'publish', |
323 | 321 | 'post_type' => 'give_forms', |
324 | - 'posts_per_page' => - 1, |
|
322 | + 'posts_per_page' => -1, |
|
325 | 323 | 'fields' => 'ids', |
326 | 324 | ); |
327 | 325 | |
328 | - $all_forms = get_posts( $args ); |
|
326 | + $all_forms = get_posts($args); |
|
329 | 327 | |
330 | - $this->store_data( 'give_temp_form_ids', $all_forms ); |
|
328 | + $this->store_data('give_temp_form_ids', $all_forms); |
|
331 | 329 | |
332 | - $args = apply_filters( 'give_recount_form_stats_total_args', array( |
|
330 | + $args = apply_filters('give_recount_form_stats_total_args', array( |
|
333 | 331 | 'give_forms' => $all_forms, |
334 | 332 | 'number' => $this->per_step, |
335 | 333 | 'status' => $accepted_statuses, |
336 | 334 | 'page' => $this->step, |
337 | 335 | 'output' => 'payments', |
338 | - ) ); |
|
336 | + )); |
|
339 | 337 | |
340 | - $payments_query = new Give_Payments_Query( $args ); |
|
338 | + $payments_query = new Give_Payments_Query($args); |
|
341 | 339 | $payments = $payments_query->get_payments(); |
342 | 340 | |
343 | - $total = wp_count_posts( 'give_payment' )->publish; |
|
341 | + $total = wp_count_posts('give_payment')->publish; |
|
344 | 342 | |
345 | - $this->store_data( 'give_temp_all_payments_data', $payments ); |
|
343 | + $this->store_data('give_temp_all_payments_data', $payments); |
|
346 | 344 | |
347 | - if ( $payments ) { |
|
345 | + if ($payments) { |
|
348 | 346 | |
349 | - foreach ( $payments as $payment ) { |
|
347 | + foreach ($payments as $payment) { |
|
350 | 348 | |
351 | 349 | $form_id = $payment->form_id; |
352 | 350 | |
353 | 351 | //If for some reason somehow the form_ID isn't set check payment meta |
354 | - if ( empty( $payment->form_id ) ) { |
|
352 | + if (empty($payment->form_id)) { |
|
355 | 353 | $payment_meta = $payment->get_meta(); |
356 | - $form_id = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : 0; |
|
354 | + $form_id = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : 0; |
|
357 | 355 | } |
358 | 356 | |
359 | - if ( ! in_array( $payment->post_status, $accepted_statuses ) ) { |
|
357 | + if ( ! in_array($payment->post_status, $accepted_statuses)) { |
|
360 | 358 | continue; |
361 | 359 | } |
362 | 360 | |
363 | - if ( ! array_key_exists( $payment->ID, $payment_items ) ) { |
|
361 | + if ( ! array_key_exists($payment->ID, $payment_items)) { |
|
364 | 362 | |
365 | 363 | /** |
366 | 364 | * Filter the payment amount. |
@@ -369,22 +367,22 @@ discard block |
||
369 | 367 | */ |
370 | 368 | $payment_total = apply_filters( |
371 | 369 | 'give_donation_amount', |
372 | - give_format_amount( $payment->total, array( 'donation_id' => $payment->ID ) ), |
|
370 | + give_format_amount($payment->total, array('donation_id' => $payment->ID)), |
|
373 | 371 | $payment->total, |
374 | 372 | $payment->ID, |
375 | - array( 'type' => 'stats', 'currency' => false, 'amount' => false ) |
|
373 | + array('type' => 'stats', 'currency' => false, 'amount' => false) |
|
376 | 374 | ); |
377 | 375 | |
378 | - $payment_items[ $payment->ID ] = array( |
|
376 | + $payment_items[$payment->ID] = array( |
|
379 | 377 | 'id' => $form_id, |
380 | 378 | 'payment_id' => $payment->ID, |
381 | - 'price' => (float) give_maybe_sanitize_amount( $payment_total ), |
|
379 | + 'price' => (float) give_maybe_sanitize_amount($payment_total), |
|
382 | 380 | ); |
383 | 381 | } |
384 | 382 | } |
385 | 383 | } |
386 | - $this->store_data( 'give_temp_payment_items', $payment_items ); |
|
387 | - $this->store_data( 'give_recount_all_total', $total ); |
|
384 | + $this->store_data('give_temp_payment_items', $payment_items); |
|
385 | + $this->store_data('give_recount_all_total', $total); |
|
388 | 386 | } |
389 | 387 | |
390 | 388 | } |
@@ -398,17 +396,17 @@ discard block |
||
398 | 396 | * |
399 | 397 | * @return mixed Returns the data from the database |
400 | 398 | */ |
401 | - private function get_stored_data( $key ) { |
|
399 | + private function get_stored_data($key) { |
|
402 | 400 | global $wpdb; |
403 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
404 | - if ( empty( $value ) ) { |
|
401 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
402 | + if (empty($value)) { |
|
405 | 403 | return false; |
406 | 404 | } |
407 | 405 | |
408 | - $maybe_json = json_decode( $value ); |
|
406 | + $maybe_json = json_decode($value); |
|
409 | 407 | |
410 | - if ( ! is_null( $maybe_json ) ) { |
|
411 | - $value = json_decode( $value, true ); |
|
408 | + if ( ! is_null($maybe_json)) { |
|
409 | + $value = json_decode($value, true); |
|
412 | 410 | } |
413 | 411 | |
414 | 412 | return $value; |
@@ -424,10 +422,10 @@ discard block |
||
424 | 422 | * |
425 | 423 | * @return void |
426 | 424 | */ |
427 | - private function store_data( $key, $value ) { |
|
425 | + private function store_data($key, $value) { |
|
428 | 426 | global $wpdb; |
429 | 427 | |
430 | - $value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value ); |
|
428 | + $value = is_array($value) ? wp_json_encode($value) : esc_attr($value); |
|
431 | 429 | |
432 | 430 | $data = array( |
433 | 431 | 'option_name' => $key, |
@@ -441,7 +439,7 @@ discard block |
||
441 | 439 | '%s', |
442 | 440 | ); |
443 | 441 | |
444 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
442 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
445 | 443 | } |
446 | 444 | |
447 | 445 | /** |
@@ -453,9 +451,9 @@ discard block |
||
453 | 451 | * |
454 | 452 | * @return void |
455 | 453 | */ |
456 | - private function delete_data( $key ) { |
|
454 | + private function delete_data($key) { |
|
457 | 455 | global $wpdb; |
458 | - $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) ); |
|
456 | + $wpdb->delete($wpdb->options, array('option_name' => $key)); |
|
459 | 457 | } |
460 | 458 | |
461 | 459 | } |
@@ -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 | |
@@ -46,8 +46,8 @@ discard block |
||
46 | 46 | /** |
47 | 47 | * Constructor. |
48 | 48 | */ |
49 | - public function __construct( $_step = 1 ) { |
|
50 | - parent::__construct( $_step ); |
|
49 | + public function __construct($_step = 1) { |
|
50 | + parent::__construct($_step); |
|
51 | 51 | |
52 | 52 | $this->is_writable = true; |
53 | 53 | } |
@@ -61,33 +61,33 @@ discard block |
||
61 | 61 | */ |
62 | 62 | public function get_data() { |
63 | 63 | |
64 | - if ( $this->step == 1 ) { |
|
65 | - $this->delete_data( 'give_temp_recount_earnings' ); |
|
64 | + if ($this->step == 1) { |
|
65 | + $this->delete_data('give_temp_recount_earnings'); |
|
66 | 66 | } |
67 | 67 | |
68 | - $total = get_option( 'give_temp_recount_earnings', false ); |
|
68 | + $total = get_option('give_temp_recount_earnings', false); |
|
69 | 69 | |
70 | - if ( false === $total ) { |
|
70 | + if (false === $total) { |
|
71 | 71 | $total = (float) 0; |
72 | - $this->store_data( 'give_temp_recount_earnings', $total ); |
|
72 | + $this->store_data('give_temp_recount_earnings', $total); |
|
73 | 73 | } |
74 | 74 | |
75 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) ); |
|
75 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish')); |
|
76 | 76 | |
77 | - $args = apply_filters( 'give_recount_earnings_args', array( |
|
77 | + $args = apply_filters('give_recount_earnings_args', array( |
|
78 | 78 | 'number' => $this->per_step, |
79 | 79 | 'page' => $this->step, |
80 | 80 | 'status' => $accepted_statuses, |
81 | 81 | 'fields' => 'ids' |
82 | - ) ); |
|
82 | + )); |
|
83 | 83 | |
84 | - $payments = give_get_payments( $args ); |
|
84 | + $payments = give_get_payments($args); |
|
85 | 85 | |
86 | - if ( ! empty( $payments ) ) { |
|
86 | + if ( ! empty($payments)) { |
|
87 | 87 | |
88 | - foreach ( $payments as $payment ) { |
|
88 | + foreach ($payments as $payment) { |
|
89 | 89 | // Get the payment amount. |
90 | - $payment_amount = give_get_meta( $payment->ID, '_give_payment_total', true ); |
|
90 | + $payment_amount = give_get_meta($payment->ID, '_give_payment_total', true); |
|
91 | 91 | |
92 | 92 | /** |
93 | 93 | * Filter the payment amount. |
@@ -96,28 +96,28 @@ discard block |
||
96 | 96 | */ |
97 | 97 | $donation_amount = apply_filters( |
98 | 98 | 'give_donation_amount', |
99 | - give_format_amount( $payment_amount, array( 'donation_id' => $payment->ID ) ), |
|
99 | + give_format_amount($payment_amount, array('donation_id' => $payment->ID)), |
|
100 | 100 | $payment->total, |
101 | 101 | $payment->ID, |
102 | - array( 'type' => 'stats', 'currency' => false, 'amount' => false ) |
|
102 | + array('type' => 'stats', 'currency' => false, 'amount' => false) |
|
103 | 103 | ); |
104 | 104 | |
105 | - $total += (float) give_maybe_sanitize_amount( $donation_amount ); |
|
105 | + $total += (float) give_maybe_sanitize_amount($donation_amount); |
|
106 | 106 | } |
107 | 107 | |
108 | - if ( $total < 0 ) { |
|
108 | + if ($total < 0) { |
|
109 | 109 | $totals = 0; |
110 | 110 | } |
111 | 111 | |
112 | - $total = round( $total, give_get_price_decimals() ); |
|
112 | + $total = round($total, give_get_price_decimals()); |
|
113 | 113 | |
114 | - $this->store_data( 'give_temp_recount_earnings', $total ); |
|
114 | + $this->store_data('give_temp_recount_earnings', $total); |
|
115 | 115 | |
116 | 116 | return true; |
117 | 117 | |
118 | 118 | } |
119 | 119 | |
120 | - update_option( 'give_earnings_total', $total ); |
|
120 | + update_option('give_earnings_total', $total); |
|
121 | 121 | |
122 | 122 | return false; |
123 | 123 | |
@@ -131,25 +131,25 @@ discard block |
||
131 | 131 | */ |
132 | 132 | public function get_percentage_complete() { |
133 | 133 | |
134 | - $total = $this->get_stored_data( 'give_recount_earnings_total' ); |
|
134 | + $total = $this->get_stored_data('give_recount_earnings_total'); |
|
135 | 135 | |
136 | - if ( false === $total ) { |
|
137 | - $args = apply_filters( 'give_recount_earnings_total_args', array() ); |
|
136 | + if (false === $total) { |
|
137 | + $args = apply_filters('give_recount_earnings_total_args', array()); |
|
138 | 138 | |
139 | - $counts = give_count_payments( $args ); |
|
140 | - $total = absint( $counts->publish ); |
|
141 | - $total = apply_filters( 'give_recount_store_earnings_total', $total ); |
|
139 | + $counts = give_count_payments($args); |
|
140 | + $total = absint($counts->publish); |
|
141 | + $total = apply_filters('give_recount_store_earnings_total', $total); |
|
142 | 142 | |
143 | - $this->store_data( 'give_recount_earnings_total', $total ); |
|
143 | + $this->store_data('give_recount_earnings_total', $total); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | $percentage = 100; |
147 | 147 | |
148 | - if ( $total > 0 ) { |
|
149 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
148 | + if ($total > 0) { |
|
149 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
150 | 150 | } |
151 | 151 | |
152 | - if ( $percentage > 100 ) { |
|
152 | + if ($percentage > 100) { |
|
153 | 153 | $percentage = 100; |
154 | 154 | } |
155 | 155 | |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | * |
164 | 164 | * @param array $request The Form Data passed into the batch processing |
165 | 165 | */ |
166 | - public function set_properties( $request ) { |
|
166 | + public function set_properties($request) { |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | /** |
@@ -174,21 +174,21 @@ discard block |
||
174 | 174 | */ |
175 | 175 | public function process_step() { |
176 | 176 | |
177 | - if ( ! $this->can_export() ) { |
|
178 | - wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
177 | + if ( ! $this->can_export()) { |
|
178 | + wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | $had_data = $this->get_data(); |
182 | 182 | |
183 | - if ( $had_data ) { |
|
183 | + if ($had_data) { |
|
184 | 184 | $this->done = false; |
185 | 185 | |
186 | 186 | return true; |
187 | 187 | } else { |
188 | - $this->delete_data( 'give_recount_earnings_total' ); |
|
189 | - $this->delete_data( 'give_temp_recount_earnings' ); |
|
188 | + $this->delete_data('give_recount_earnings_total'); |
|
189 | + $this->delete_data('give_temp_recount_earnings'); |
|
190 | 190 | $this->done = true; |
191 | - $this->message = esc_html__( 'Income stats have been successfully recounted.', 'give' ); |
|
191 | + $this->message = esc_html__('Income stats have been successfully recounted.', 'give'); |
|
192 | 192 | |
193 | 193 | return false; |
194 | 194 | } |
@@ -225,17 +225,17 @@ discard block |
||
225 | 225 | * |
226 | 226 | * @return mixed Returns the data from the database |
227 | 227 | */ |
228 | - private function get_stored_data( $key ) { |
|
228 | + private function get_stored_data($key) { |
|
229 | 229 | global $wpdb; |
230 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
230 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
231 | 231 | |
232 | - if ( empty( $value ) ) { |
|
232 | + if (empty($value)) { |
|
233 | 233 | return false; |
234 | 234 | } |
235 | 235 | |
236 | - $maybe_json = json_decode( $value ); |
|
237 | - if ( ! is_null( $maybe_json ) ) { |
|
238 | - $value = json_decode( $value, true ); |
|
236 | + $maybe_json = json_decode($value); |
|
237 | + if ( ! is_null($maybe_json)) { |
|
238 | + $value = json_decode($value, true); |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | return $value; |
@@ -251,10 +251,10 @@ discard block |
||
251 | 251 | * |
252 | 252 | * @return void |
253 | 253 | */ |
254 | - private function store_data( $key, $value ) { |
|
254 | + private function store_data($key, $value) { |
|
255 | 255 | global $wpdb; |
256 | 256 | |
257 | - $value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value ); |
|
257 | + $value = is_array($value) ? wp_json_encode($value) : esc_attr($value); |
|
258 | 258 | |
259 | 259 | $data = array( |
260 | 260 | 'option_name' => $key, |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | '%s', |
269 | 269 | ); |
270 | 270 | |
271 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
271 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | /** |
@@ -280,9 +280,9 @@ discard block |
||
280 | 280 | * |
281 | 281 | * @return void |
282 | 282 | */ |
283 | - private function delete_data( $key ) { |
|
283 | + private function delete_data($key) { |
|
284 | 284 | global $wpdb; |
285 | - $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) ); |
|
285 | + $wpdb->delete($wpdb->options, array('option_name' => $key)); |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | } |
@@ -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 | |
@@ -46,8 +46,8 @@ discard block |
||
46 | 46 | /** |
47 | 47 | * Constructor. |
48 | 48 | */ |
49 | - public function __construct( $_step = 1 ) { |
|
50 | - parent::__construct( $_step ); |
|
49 | + public function __construct($_step = 1) { |
|
50 | + parent::__construct($_step); |
|
51 | 51 | |
52 | 52 | $this->is_writable = true; |
53 | 53 | } |
@@ -62,20 +62,20 @@ discard block |
||
62 | 62 | * @return array|bool $data The data for the CSV file |
63 | 63 | */ |
64 | 64 | public function get_data() { |
65 | - $items = $this->get_stored_data( 'give_temp_delete_test_ids' ); |
|
65 | + $items = $this->get_stored_data('give_temp_delete_test_ids'); |
|
66 | 66 | |
67 | - if ( ! is_array( $items ) ) { |
|
67 | + if ( ! is_array($items)) { |
|
68 | 68 | return false; |
69 | 69 | } |
70 | 70 | |
71 | - $offset = ( $this->step - 1 ) * $this->per_step; |
|
72 | - $step_items = array_slice( $items, $offset, $this->per_step ); |
|
73 | - $meta_table = __give_v20_bc_table_details( 'payment' ); |
|
71 | + $offset = ($this->step - 1) * $this->per_step; |
|
72 | + $step_items = array_slice($items, $offset, $this->per_step); |
|
73 | + $meta_table = __give_v20_bc_table_details('payment'); |
|
74 | 74 | |
75 | - if ( $step_items ) { |
|
76 | - foreach ( $step_items as $item ) { |
|
75 | + if ($step_items) { |
|
76 | + foreach ($step_items as $item) { |
|
77 | 77 | // Delete the main payment. |
78 | - give_delete_donation( absint( $item['id'] ) ); |
|
78 | + give_delete_donation(absint($item['id'])); |
|
79 | 79 | } |
80 | 80 | return true; |
81 | 81 | } |
@@ -91,16 +91,16 @@ discard block |
||
91 | 91 | */ |
92 | 92 | public function get_percentage_complete() { |
93 | 93 | |
94 | - $items = $this->get_stored_data( 'give_temp_delete_test_ids', false ); |
|
95 | - $total = count( $items ); |
|
94 | + $items = $this->get_stored_data('give_temp_delete_test_ids', false); |
|
95 | + $total = count($items); |
|
96 | 96 | |
97 | 97 | $percentage = 100; |
98 | 98 | |
99 | - if ( $total > 0 ) { |
|
100 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
99 | + if ($total > 0) { |
|
100 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
101 | 101 | } |
102 | 102 | |
103 | - if ( $percentage > 100 ) { |
|
103 | + if ($percentage > 100) { |
|
104 | 104 | $percentage = 100; |
105 | 105 | } |
106 | 106 | |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | * |
115 | 115 | * @param array $request The Form Data passed into the batch processing |
116 | 116 | */ |
117 | - public function set_properties( $request ) { |
|
117 | + public function set_properties($request) { |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | /** |
@@ -125,24 +125,24 @@ discard block |
||
125 | 125 | */ |
126 | 126 | public function process_step() { |
127 | 127 | |
128 | - if ( ! $this->can_export() ) { |
|
129 | - wp_die( __( 'You do not have permission to delete test transactions.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
128 | + if ( ! $this->can_export()) { |
|
129 | + wp_die(__('You do not have permission to delete test transactions.', 'give'), __('Error', 'give'), array('response' => 403)); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | $had_data = $this->get_data(); |
133 | 133 | |
134 | - if ( $had_data ) { |
|
134 | + if ($had_data) { |
|
135 | 135 | $this->done = false; |
136 | 136 | |
137 | 137 | return true; |
138 | 138 | } else { |
139 | - update_option( 'give_earnings_total', give_get_total_earnings( true ) ); |
|
140 | - Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) ); |
|
139 | + update_option('give_earnings_total', give_get_total_earnings(true)); |
|
140 | + Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats')); |
|
141 | 141 | |
142 | - $this->delete_data( 'give_temp_delete_test_ids' ); |
|
142 | + $this->delete_data('give_temp_delete_test_ids'); |
|
143 | 143 | |
144 | 144 | $this->done = true; |
145 | - $this->message = __( 'Test transactions successfully deleted.', 'give' ); |
|
145 | + $this->message = __('Test transactions successfully deleted.', 'give'); |
|
146 | 146 | |
147 | 147 | return false; |
148 | 148 | } |
@@ -175,27 +175,27 @@ discard block |
||
175 | 175 | */ |
176 | 176 | public function pre_fetch() { |
177 | 177 | |
178 | - if ( $this->step == 1 ) { |
|
179 | - $this->delete_data( 'give_temp_delete_test_ids' ); |
|
178 | + if ($this->step == 1) { |
|
179 | + $this->delete_data('give_temp_delete_test_ids'); |
|
180 | 180 | } |
181 | 181 | |
182 | - $items = get_option( 'give_temp_delete_test_ids', false ); |
|
182 | + $items = get_option('give_temp_delete_test_ids', false); |
|
183 | 183 | |
184 | - if ( false === $items ) { |
|
184 | + if (false === $items) { |
|
185 | 185 | $items = array(); |
186 | 186 | |
187 | - $args = apply_filters( 'give_tools_reset_stats_total_args', array( |
|
187 | + $args = apply_filters('give_tools_reset_stats_total_args', array( |
|
188 | 188 | 'post_status' => 'any', |
189 | - 'number' => - 1, |
|
189 | + 'number' => -1, |
|
190 | 190 | 'meta_key' => '_give_payment_mode', |
191 | 191 | 'meta_value' => 'test' |
192 | - ) ); |
|
192 | + )); |
|
193 | 193 | |
194 | - $posts = new Give_Payments_Query( $args ); |
|
194 | + $posts = new Give_Payments_Query($args); |
|
195 | 195 | $payments = $posts->get_payments(); |
196 | 196 | |
197 | 197 | /* @var Give_Payment $payment */ |
198 | - foreach ( $payments as $payment ) { |
|
198 | + foreach ($payments as $payment) { |
|
199 | 199 | $items[] = array( |
200 | 200 | 'id' => (int) $payment->ID, |
201 | 201 | 'type' => 'give_payment', |
@@ -204,9 +204,9 @@ discard block |
||
204 | 204 | |
205 | 205 | // Allow filtering of items to remove with an unassociative array for each item. |
206 | 206 | // The array contains the unique ID of the item, and a 'type' for you to use in the execution of the get_data method. |
207 | - $items = apply_filters( 'give_delete_test_items', $items ); |
|
207 | + $items = apply_filters('give_delete_test_items', $items); |
|
208 | 208 | |
209 | - $this->store_data( 'give_temp_delete_test_ids', $items ); |
|
209 | + $this->store_data('give_temp_delete_test_ids', $items); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | } |
@@ -220,17 +220,17 @@ discard block |
||
220 | 220 | * |
221 | 221 | * @return mixed Returns the data from the database |
222 | 222 | */ |
223 | - private function get_stored_data( $key ) { |
|
223 | + private function get_stored_data($key) { |
|
224 | 224 | global $wpdb; |
225 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
225 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
226 | 226 | |
227 | - if ( empty( $value ) ) { |
|
227 | + if (empty($value)) { |
|
228 | 228 | return false; |
229 | 229 | } |
230 | 230 | |
231 | - $maybe_json = json_decode( $value ); |
|
232 | - if ( ! is_null( $maybe_json ) ) { |
|
233 | - $value = json_decode( $value, true ); |
|
231 | + $maybe_json = json_decode($value); |
|
232 | + if ( ! is_null($maybe_json)) { |
|
233 | + $value = json_decode($value, true); |
|
234 | 234 | } |
235 | 235 | |
236 | 236 | return $value; |
@@ -246,10 +246,10 @@ discard block |
||
246 | 246 | * |
247 | 247 | * @return void |
248 | 248 | */ |
249 | - private function store_data( $key, $value ) { |
|
249 | + private function store_data($key, $value) { |
|
250 | 250 | global $wpdb; |
251 | 251 | |
252 | - $value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value ); |
|
252 | + $value = is_array($value) ? wp_json_encode($value) : esc_attr($value); |
|
253 | 253 | |
254 | 254 | $data = array( |
255 | 255 | 'option_name' => $key, |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | '%s', |
264 | 264 | ); |
265 | 265 | |
266 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
266 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | /** |
@@ -275,9 +275,9 @@ discard block |
||
275 | 275 | * |
276 | 276 | * @return void |
277 | 277 | */ |
278 | - private function delete_data( $key ) { |
|
278 | + private function delete_data($key) { |
|
279 | 279 | global $wpdb; |
280 | - $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) ); |
|
280 | + $wpdb->delete($wpdb->options, array('option_name' => $key)); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | } |
@@ -10,13 +10,13 @@ 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 | |
17 | 17 | // Load WP_List_Table if not loaded |
18 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
19 | - require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
18 | +if ( ! class_exists('WP_List_Table')) { |
|
19 | + require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php'; |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | /** |
@@ -45,11 +45,11 @@ discard block |
||
45 | 45 | global $status, $page; |
46 | 46 | |
47 | 47 | // Set parent defaults |
48 | - parent::__construct( array( |
|
49 | - 'singular' => give_get_forms_label_singular(), // Singular name of the listed records |
|
50 | - 'plural' => give_get_forms_label_plural(), // Plural name of the listed records |
|
48 | + parent::__construct(array( |
|
49 | + 'singular' => give_get_forms_label_singular(), // Singular name of the listed records |
|
50 | + 'plural' => give_get_forms_label_plural(), // Plural name of the listed records |
|
51 | 51 | 'ajax' => false, // Does this table support ajax? |
52 | - ) ); |
|
52 | + )); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * |
64 | 64 | * @return void |
65 | 65 | */ |
66 | - public function search_box( $text, $input_id ) { |
|
66 | + public function search_box($text, $input_id) { |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
@@ -76,9 +76,9 @@ discard block |
||
76 | 76 | */ |
77 | 77 | public function get_columns() { |
78 | 78 | $columns = array( |
79 | - 'ID' => __( 'Log ID', 'give' ), |
|
80 | - 'date' => __( 'Date', 'give' ), |
|
81 | - 'details' => __( 'Process Details', 'give' ), |
|
79 | + 'ID' => __('Log ID', 'give'), |
|
80 | + 'date' => __('Date', 'give'), |
|
81 | + 'details' => __('Process Details', 'give'), |
|
82 | 82 | ); |
83 | 83 | |
84 | 84 | return $columns; |
@@ -95,17 +95,17 @@ discard block |
||
95 | 95 | * |
96 | 96 | * @return string Column Name |
97 | 97 | */ |
98 | - public function column_default( $item, $column_name ) { |
|
99 | - switch ( $column_name ) { |
|
98 | + public function column_default($item, $column_name) { |
|
99 | + switch ($column_name) { |
|
100 | 100 | case 'ID': |
101 | 101 | return sprintf( |
102 | 102 | '<span class="give-item-label give-item-label-gray">%1$s</span> %2$s', |
103 | - esc_attr( $item[ $column_name ] ), |
|
104 | - esc_attr( $item['title'] ) |
|
103 | + esc_attr($item[$column_name]), |
|
104 | + esc_attr($item['title']) |
|
105 | 105 | ); |
106 | 106 | |
107 | 107 | default: |
108 | - return esc_attr( $item[ $column_name ] ); |
|
108 | + return esc_attr($item[$column_name]); |
|
109 | 109 | } |
110 | 110 | } |
111 | 111 | |
@@ -119,24 +119,24 @@ discard block |
||
119 | 119 | * |
120 | 120 | * @return void |
121 | 121 | */ |
122 | - public function column_details( $item ) { |
|
123 | - echo wp_kses_post( Give()->tooltips->render_link( array( |
|
124 | - 'label' => __( 'View Update Log', 'give' ), |
|
122 | + public function column_details($item) { |
|
123 | + echo wp_kses_post(Give()->tooltips->render_link(array( |
|
124 | + 'label' => __('View Update Log', 'give'), |
|
125 | 125 | 'tag_content' => '<span class="dashicons dashicons-visibility"></span>', |
126 | 126 | 'link' => "#TB_inline?width=640&inlineId=log-details-{$item['ID']}", |
127 | 127 | 'attributes' => array( |
128 | 128 | 'class' => 'thickbox give-error-log-details-link button button-small', |
129 | 129 | ), |
130 | - ) ) ); |
|
130 | + ))); |
|
131 | 131 | ?> |
132 | - <div id="log-details-<?php echo esc_attr( $item['ID'] ); ?>" style="display:none;"> |
|
132 | + <div id="log-details-<?php echo esc_attr($item['ID']); ?>" style="display:none;"> |
|
133 | 133 | <?php |
134 | 134 | |
135 | 135 | // Print Log Content, if not empty. |
136 | - if ( ! empty( $item['log_content'] ) ) { |
|
136 | + if ( ! empty($item['log_content'])) { |
|
137 | 137 | echo sprintf( |
138 | 138 | '<p><pre>%1$s</pre></div>', |
139 | - esc_html( $item['log_content'] ) |
|
139 | + esc_html($item['log_content']) |
|
140 | 140 | ); |
141 | 141 | } |
142 | 142 | ?> |
@@ -157,19 +157,19 @@ discard block |
||
157 | 157 | * |
158 | 158 | * @param string $which |
159 | 159 | */ |
160 | - protected function display_tablenav( $which ) { |
|
161 | - if ( 'top' === $which ) { |
|
162 | - wp_nonce_field( 'bulk-' . $this->_args['plural'] ); |
|
160 | + protected function display_tablenav($which) { |
|
161 | + if ('top' === $which) { |
|
162 | + wp_nonce_field('bulk-'.$this->_args['plural']); |
|
163 | 163 | } |
164 | 164 | ?> |
165 | - <div class="tablenav <?php echo esc_attr( $which ); ?>"> |
|
165 | + <div class="tablenav <?php echo esc_attr($which); ?>"> |
|
166 | 166 | |
167 | 167 | <div class="alignleft actions bulkactions"> |
168 | - <?php $this->bulk_actions( $which ); ?> |
|
168 | + <?php $this->bulk_actions($which); ?> |
|
169 | 169 | </div> |
170 | 170 | <?php |
171 | - $this->extra_tablenav( $which ); |
|
172 | - $this->pagination( $which ); |
|
171 | + $this->extra_tablenav($which); |
|
172 | + $this->pagination($which); |
|
173 | 173 | ?> |
174 | 174 | |
175 | 175 | <br class="clear"/> |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | * @return int Current page number |
187 | 187 | */ |
188 | 188 | public function get_paged() { |
189 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
189 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | /** |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | * |
200 | 200 | * @return void |
201 | 201 | */ |
202 | - function bulk_actions( $which = '' ) { |
|
202 | + function bulk_actions($which = '') { |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | /** |
@@ -219,10 +219,10 @@ discard block |
||
219 | 219 | 'posts_per_page' => $this->per_page, |
220 | 220 | ); |
221 | 221 | |
222 | - $logs = Give()->logs->get_connected_logs( $log_query ); |
|
222 | + $logs = Give()->logs->get_connected_logs($log_query); |
|
223 | 223 | |
224 | - if ( $logs ) { |
|
225 | - foreach ( $logs as $log ) { |
|
224 | + if ($logs) { |
|
225 | + foreach ($logs as $log) { |
|
226 | 226 | |
227 | 227 | $logs_data[] = array( |
228 | 228 | 'ID' => $log->ID, |
@@ -254,14 +254,14 @@ discard block |
||
254 | 254 | $columns = $this->get_columns(); |
255 | 255 | $hidden = array(); // No hidden columns |
256 | 256 | $sortable = $this->get_sortable_columns(); |
257 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
257 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
258 | 258 | $this->items = $this->get_logs(); |
259 | - $total_items = Give()->logs->get_log_count( 0, 'update' ); |
|
259 | + $total_items = Give()->logs->get_log_count(0, 'update'); |
|
260 | 260 | |
261 | - $this->set_pagination_args( array( |
|
261 | + $this->set_pagination_args(array( |
|
262 | 262 | 'total_items' => $total_items, |
263 | 263 | 'per_page' => $this->per_page, |
264 | - 'total_pages' => ceil( $total_items / $this->per_page ), |
|
265 | - ) ); |
|
264 | + 'total_pages' => ceil($total_items / $this->per_page), |
|
265 | + )); |
|
266 | 266 | } |
267 | 267 | } |
@@ -9,11 +9,11 @@ discard block |
||
9 | 9 | * @since 1.8 |
10 | 10 | */ |
11 | 11 | |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; // Exit if accessed directly |
14 | 14 | } |
15 | 15 | |
16 | -if ( ! class_exists( 'Give_Settings_Export' ) ) : |
|
16 | +if ( ! class_exists('Give_Settings_Export')) : |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Give_Settings_Export. |
@@ -34,19 +34,19 @@ discard block |
||
34 | 34 | */ |
35 | 35 | public function __construct() { |
36 | 36 | $this->id = 'export'; |
37 | - $this->label = __( 'Export', 'give' ); |
|
37 | + $this->label = __('Export', 'give'); |
|
38 | 38 | |
39 | 39 | parent::__construct(); |
40 | 40 | |
41 | - add_action( 'give_admin_field_tools_export', array( 'Give_Settings_Export', 'render_export_field' ), 10, 2 ); |
|
41 | + add_action('give_admin_field_tools_export', array('Give_Settings_Export', 'render_export_field'), 10, 2); |
|
42 | 42 | |
43 | 43 | // Do not use main donor for this tab. |
44 | - if( give_get_current_setting_tab() === $this->id ) { |
|
45 | - add_action( 'give-tools_open_form', '__return_empty_string' ); |
|
46 | - add_action( 'give-tools_close_form', '__return_empty_string' ); |
|
44 | + if (give_get_current_setting_tab() === $this->id) { |
|
45 | + add_action('give-tools_open_form', '__return_empty_string'); |
|
46 | + add_action('give-tools_close_form', '__return_empty_string'); |
|
47 | 47 | |
48 | 48 | |
49 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/class-give-export-donations.php'; |
|
49 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/class-give-export-donations.php'; |
|
50 | 50 | } |
51 | 51 | } |
52 | 52 | |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | * @param array $settings |
65 | 65 | */ |
66 | 66 | $settings = apply_filters( |
67 | - 'give_get_settings_' . $this->id, |
|
67 | + 'give_get_settings_'.$this->id, |
|
68 | 68 | array( |
69 | 69 | array( |
70 | 70 | 'id' => 'give_tools_export', |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | ), |
74 | 74 | array( |
75 | 75 | 'id' => 'export', |
76 | - 'name' => __( 'Export', 'give' ), |
|
76 | + 'name' => __('Export', 'give'), |
|
77 | 77 | 'type' => 'tools_export', |
78 | 78 | ), |
79 | 79 | array( |
@@ -97,8 +97,8 @@ discard block |
||
97 | 97 | * @param $field |
98 | 98 | * @param $option_value |
99 | 99 | */ |
100 | - public static function render_export_field( $field, $option_value ) { |
|
101 | - include_once( 'views/html-admin-page-exports.php' ); |
|
100 | + public static function render_export_field($field, $option_value) { |
|
101 | + include_once('views/html-admin-page-exports.php'); |
|
102 | 102 | } |
103 | 103 | } |
104 | 104 |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | * @license https://opensource.org/licenses/gpl-license GNU Public License |
11 | 11 | */ |
12 | 12 | |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -22,13 +22,13 @@ discard block |
||
22 | 22 | */ |
23 | 23 | function give_process_batch_export_form() { |
24 | 24 | |
25 | - if ( ! wp_verify_nonce( $_REQUEST['nonce'], 'give-batch-export' ) ) { |
|
26 | - wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
25 | + if ( ! wp_verify_nonce($_REQUEST['nonce'], 'give-batch-export')) { |
|
26 | + wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array( |
|
27 | 27 | 'response' => 403, |
28 | - ) ); |
|
28 | + )); |
|
29 | 29 | } |
30 | 30 | |
31 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/class-batch-export.php'; |
|
31 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/class-batch-export.php'; |
|
32 | 32 | |
33 | 33 | /** |
34 | 34 | * Fires before batch export. |
@@ -37,14 +37,14 @@ discard block |
||
37 | 37 | * |
38 | 38 | * @param string $class Export class. |
39 | 39 | */ |
40 | - do_action( 'give_batch_export_class_include', $_REQUEST['class'] ); |
|
40 | + do_action('give_batch_export_class_include', $_REQUEST['class']); |
|
41 | 41 | |
42 | 42 | $export = new $_REQUEST['class']; |
43 | 43 | $export->export(); |
44 | 44 | |
45 | 45 | } |
46 | 46 | |
47 | -add_action( 'give_form_batch_export', 'give_process_batch_export_form' ); |
|
47 | +add_action('give_form_batch_export', 'give_process_batch_export_form'); |
|
48 | 48 | |
49 | 49 | /** |
50 | 50 | * Exports earnings for a specified time period. |
@@ -55,14 +55,14 @@ discard block |
||
55 | 55 | * @return void |
56 | 56 | */ |
57 | 57 | function give_export_earnings() { |
58 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/class-export-earnings.php'; |
|
58 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/class-export-earnings.php'; |
|
59 | 59 | |
60 | 60 | $earnings_export = new Give_Earnings_Export(); |
61 | 61 | |
62 | 62 | $earnings_export->export(); |
63 | 63 | } |
64 | 64 | |
65 | -add_action( 'give_earnings_export', 'give_export_earnings' ); |
|
65 | +add_action('give_earnings_export', 'give_export_earnings'); |
|
66 | 66 | |
67 | 67 | /** |
68 | 68 | * Exports Give's core settings. |
@@ -73,14 +73,14 @@ discard block |
||
73 | 73 | * @return void |
74 | 74 | */ |
75 | 75 | function give_core_settings_export() { |
76 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/class-core-settings-export.php'; |
|
76 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/class-core-settings-export.php'; |
|
77 | 77 | |
78 | 78 | $core_settings = new Give_Core_Settings_Export(); |
79 | 79 | |
80 | 80 | $core_settings->export(); |
81 | 81 | } |
82 | 82 | |
83 | -add_action( 'give_core_settings_export', 'give_core_settings_export' ); |
|
83 | +add_action('give_core_settings_export', 'give_core_settings_export'); |
|
84 | 84 | |
85 | 85 | |
86 | 86 | /** |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * @return void |
91 | 91 | */ |
92 | 92 | function give_register_batch_exporters() { |
93 | - if ( is_admin() ) { |
|
93 | + if (is_admin()) { |
|
94 | 94 | /** |
95 | 95 | * Fires in the admin, while plugins loaded. |
96 | 96 | * |
@@ -100,11 +100,11 @@ discard block |
||
100 | 100 | * |
101 | 101 | * @param string $class Export class. |
102 | 102 | */ |
103 | - do_action( 'give_register_batch_exporter' ); |
|
103 | + do_action('give_register_batch_exporter'); |
|
104 | 104 | } |
105 | 105 | } |
106 | 106 | |
107 | -add_action( 'plugins_loaded', 'give_register_batch_exporters' ); |
|
107 | +add_action('plugins_loaded', 'give_register_batch_exporters'); |
|
108 | 108 | |
109 | 109 | /** |
110 | 110 | * Register the donors batch exporter. |
@@ -112,10 +112,10 @@ discard block |
||
112 | 112 | * @since 1.5.2 |
113 | 113 | */ |
114 | 114 | function give_register_donors_batch_export() { |
115 | - add_action( 'give_batch_export_class_include', 'give_include_donors_batch_processor', 10, 1 ); |
|
115 | + add_action('give_batch_export_class_include', 'give_include_donors_batch_processor', 10, 1); |
|
116 | 116 | } |
117 | 117 | |
118 | -add_action( 'give_register_batch_exporter', 'give_register_donors_batch_export', 10 ); |
|
118 | +add_action('give_register_batch_exporter', 'give_register_donors_batch_export', 10); |
|
119 | 119 | |
120 | 120 | /** |
121 | 121 | * Loads the donors batch process if needed. |
@@ -126,10 +126,10 @@ discard block |
||
126 | 126 | * |
127 | 127 | * @return void |
128 | 128 | */ |
129 | -function give_include_donors_batch_processor( $class ) { |
|
129 | +function give_include_donors_batch_processor($class) { |
|
130 | 130 | |
131 | - if ( 'Give_Batch_Donors_Export' === $class ) { |
|
132 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/class-batch-export-donors.php'; |
|
131 | + if ('Give_Batch_Donors_Export' === $class) { |
|
132 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/class-batch-export-donors.php'; |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | } |
@@ -140,10 +140,10 @@ discard block |
||
140 | 140 | * @since 1.5 |
141 | 141 | */ |
142 | 142 | function give_register_forms_batch_export() { |
143 | - add_action( 'give_batch_export_class_include', 'give_include_forms_batch_processor', 10, 1 ); |
|
143 | + add_action('give_batch_export_class_include', 'give_include_forms_batch_processor', 10, 1); |
|
144 | 144 | } |
145 | 145 | |
146 | -add_action( 'give_register_batch_exporter', 'give_register_forms_batch_export', 10 ); |
|
146 | +add_action('give_register_batch_exporter', 'give_register_forms_batch_export', 10); |
|
147 | 147 | |
148 | 148 | /** |
149 | 149 | * Loads the file downloads batch process if needed |
@@ -154,10 +154,10 @@ discard block |
||
154 | 154 | * |
155 | 155 | * @return void |
156 | 156 | */ |
157 | -function give_include_forms_batch_processor( $class ) { |
|
157 | +function give_include_forms_batch_processor($class) { |
|
158 | 158 | |
159 | - if ( 'Give_Batch_Forms_Export' === $class ) { |
|
160 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/class-batch-export-forms.php'; |
|
159 | + if ('Give_Batch_Forms_Export' === $class) { |
|
160 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/class-batch-export-forms.php'; |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | } |
@@ -9,11 +9,11 @@ discard block |
||
9 | 9 | * @since 2.1 |
10 | 10 | */ |
11 | 11 | |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; // Exit if accessed directly |
14 | 14 | } |
15 | 15 | |
16 | -if ( ! class_exists( 'Give_Export_Donations' ) ) { |
|
16 | +if ( ! class_exists('Give_Export_Donations')) { |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Give_Settings_CSV. |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * @return static |
58 | 58 | */ |
59 | 59 | public static function get_instance() { |
60 | - if ( null === static::$instance ) { |
|
60 | + if (null === static::$instance) { |
|
61 | 61 | self::$instance = new static(); |
62 | 62 | } |
63 | 63 | |
@@ -84,21 +84,21 @@ discard block |
||
84 | 84 | * @return void |
85 | 85 | */ |
86 | 86 | private function setup_hooks() { |
87 | - if ( ! $this->is_donations_export_page() ) { |
|
87 | + if ( ! $this->is_donations_export_page()) { |
|
88 | 88 | return; |
89 | 89 | } |
90 | 90 | |
91 | 91 | // Do not render main export tools page. |
92 | - remove_action( 'give_admin_field_tools_export', array( |
|
92 | + remove_action('give_admin_field_tools_export', array( |
|
93 | 93 | 'Give_Settings_Export', |
94 | 94 | 'render_export_field' |
95 | - ), 10 ); |
|
95 | + ), 10); |
|
96 | 96 | |
97 | 97 | // Render donation export page |
98 | - add_action( 'give_admin_field_tools_export', array( $this, 'render_page' ) ); |
|
98 | + add_action('give_admin_field_tools_export', array($this, 'render_page')); |
|
99 | 99 | |
100 | 100 | // Print the HTML. |
101 | - add_action( 'give_tools_export_donations_form_start', array( $this, 'html' ) ); |
|
101 | + add_action('give_tools_export_donations_form_start', array($this, 'html')); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | * |
111 | 111 | * @return array args for Taxonomy |
112 | 112 | */ |
113 | - function give_forms_taxonomy_dropdown( $args ) { |
|
113 | + function give_forms_taxonomy_dropdown($args) { |
|
114 | 114 | $args['number'] = 30; |
115 | 115 | |
116 | 116 | return $args; |
@@ -128,19 +128,19 @@ discard block |
||
128 | 128 | <tbody> |
129 | 129 | <tr class="top"> |
130 | 130 | <td colspan="2"> |
131 | - <h2 id="give-export-title"><?php _e( 'Export Donation History and Custom Fields to CSV', 'give' ) ?></h2> |
|
132 | - <p class="give-field-description"><?php _e( 'Download an export of donors for specific donation forms with the option to include custom fields.', 'give' ) ?></p> |
|
131 | + <h2 id="give-export-title"><?php _e('Export Donation History and Custom Fields to CSV', 'give') ?></h2> |
|
132 | + <p class="give-field-description"><?php _e('Download an export of donors for specific donation forms with the option to include custom fields.', 'give') ?></p> |
|
133 | 133 | </td> |
134 | 134 | </tr> |
135 | 135 | |
136 | 136 | <?php |
137 | - if ( give_is_setting_enabled( give_get_option( 'categories' ) ) ) { |
|
138 | - add_filter( 'give_forms_category_dropdown', array( $this, 'give_forms_taxonomy_dropdown' ) ); |
|
137 | + if (give_is_setting_enabled(give_get_option('categories'))) { |
|
138 | + add_filter('give_forms_category_dropdown', array($this, 'give_forms_taxonomy_dropdown')); |
|
139 | 139 | ?> |
140 | 140 | <tr> |
141 | 141 | <td scope="row" class="row-title"> |
142 | 142 | <label |
143 | - for="give_forms_categories"><?php _e( 'Filter by Categories:', 'give' ); ?></label> |
|
143 | + for="give_forms_categories"><?php _e('Filter by Categories:', 'give'); ?></label> |
|
144 | 144 | </td> |
145 | 145 | <td class="give-field-wrap"> |
146 | 146 | <div class="give-clearfix"> |
@@ -155,8 +155,8 @@ discard block |
||
155 | 155 | 'multiple' => true, |
156 | 156 | 'selected' => array(), |
157 | 157 | 'show_option_all' => false, |
158 | - 'placeholder' => __( 'Choose one or more from categories', 'give' ), |
|
159 | - 'data' => array( 'search-type' => 'categories' ), |
|
158 | + 'placeholder' => __('Choose one or more from categories', 'give'), |
|
159 | + 'data' => array('search-type' => 'categories'), |
|
160 | 160 | ) |
161 | 161 | ); |
162 | 162 | ?> |
@@ -164,16 +164,16 @@ discard block |
||
164 | 164 | </td> |
165 | 165 | </tr> |
166 | 166 | <?php |
167 | - remove_filter( 'give_forms_category_dropdown', array( $this, 'give_forms_taxonomy_dropdown' ) ); |
|
167 | + remove_filter('give_forms_category_dropdown', array($this, 'give_forms_taxonomy_dropdown')); |
|
168 | 168 | } |
169 | 169 | |
170 | - if ( give_is_setting_enabled( give_get_option( 'tags' ) ) ) { |
|
171 | - add_filter( 'give_forms_tag_dropdown', array( $this, 'give_forms_taxonomy_dropdown' ) ); |
|
170 | + if (give_is_setting_enabled(give_get_option('tags'))) { |
|
171 | + add_filter('give_forms_tag_dropdown', array($this, 'give_forms_taxonomy_dropdown')); |
|
172 | 172 | ?> |
173 | 173 | <tr> |
174 | 174 | <td scope="row" class="row-title"> |
175 | 175 | <label |
176 | - for="give_forms_tags"><?php _e( 'Filter by Tags:', 'give' ); ?></label> |
|
176 | + for="give_forms_tags"><?php _e('Filter by Tags:', 'give'); ?></label> |
|
177 | 177 | </td> |
178 | 178 | <td class="give-field-wrap"> |
179 | 179 | <div class="give-clearfix"> |
@@ -188,8 +188,8 @@ discard block |
||
188 | 188 | 'multiple' => true, |
189 | 189 | 'selected' => array(), |
190 | 190 | 'show_option_all' => false, |
191 | - 'placeholder' => __( 'Choose one or more from tags', 'give' ), |
|
192 | - 'data' => array( 'search-type' => 'tags' ), |
|
191 | + 'placeholder' => __('Choose one or more from tags', 'give'), |
|
192 | + 'data' => array('search-type' => 'tags'), |
|
193 | 193 | ) |
194 | 194 | ); |
195 | 195 | ?> |
@@ -197,14 +197,14 @@ discard block |
||
197 | 197 | </td> |
198 | 198 | </tr> |
199 | 199 | <?php |
200 | - remove_filter( 'give_forms_tag_dropdown', array( $this, 'give_forms_taxonomy_dropdown' ) ); |
|
200 | + remove_filter('give_forms_tag_dropdown', array($this, 'give_forms_taxonomy_dropdown')); |
|
201 | 201 | } |
202 | 202 | ?> |
203 | 203 | |
204 | 204 | <tr class="give-export-donation-form"> |
205 | 205 | <td scope="row" class="row-title"> |
206 | 206 | <label |
207 | - for="give_payment_form_select"><?php _e( 'Filter by Donation Form:', 'give' ); ?></label> |
|
207 | + for="give_payment_form_select"><?php _e('Filter by Donation Form:', 'give'); ?></label> |
|
208 | 208 | </td> |
209 | 209 | <td class="give-field-wrap"> |
210 | 210 | <div class="give-clearfix"> |
@@ -213,10 +213,10 @@ discard block |
||
213 | 213 | 'name' => 'forms', |
214 | 214 | 'id' => 'give-payment-form-select', |
215 | 215 | 'chosen' => true, |
216 | - 'placeholder' => __( 'All Forms', 'give' ), |
|
217 | - 'data' => array( 'no-form' => __( 'No donation forms found', 'give' ), ), |
|
216 | + 'placeholder' => __('All Forms', 'give'), |
|
217 | + 'data' => array('no-form' => __('No donation forms found', 'give'),), |
|
218 | 218 | ); |
219 | - echo Give()->html->forms_dropdown( $args ); |
|
219 | + echo Give()->html->forms_dropdown($args); |
|
220 | 220 | ?> |
221 | 221 | |
222 | 222 | <input type="hidden" name="form_ids" class="form_ids" /> |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | |
227 | 227 | <tr> |
228 | 228 | <td scope="row" class="row-title"> |
229 | - <label for="give-payment-export-start"><?php _e( 'Filter by Date:', 'give' ); ?></label> |
|
229 | + <label for="give-payment-export-start"><?php _e('Filter by Date:', 'give'); ?></label> |
|
230 | 230 | </td> |
231 | 231 | <td class="give-field-wrap"> |
232 | 232 | <div class="give-clearfix"> |
@@ -234,16 +234,16 @@ discard block |
||
234 | 234 | $args = array( |
235 | 235 | 'id' => 'give-payment-export-start', |
236 | 236 | 'name' => 'start', |
237 | - 'placeholder' => __( 'Start date', 'give' ), |
|
237 | + 'placeholder' => __('Start date', 'give'), |
|
238 | 238 | ); |
239 | - echo Give()->html->date_field( $args ); ?> |
|
239 | + echo Give()->html->date_field($args); ?> |
|
240 | 240 | <?php |
241 | 241 | $args = array( |
242 | 242 | 'id' => 'give-payment-export-end', |
243 | 243 | 'name' => 'end', |
244 | - 'placeholder' => __( 'End date', 'give' ), |
|
244 | + 'placeholder' => __('End date', 'give'), |
|
245 | 245 | ); |
246 | - echo Give()->html->date_field( $args ); ?> |
|
246 | + echo Give()->html->date_field($args); ?> |
|
247 | 247 | </div> |
248 | 248 | </td> |
249 | 249 | </tr> |
@@ -251,16 +251,16 @@ discard block |
||
251 | 251 | <tr> |
252 | 252 | <td scope="row" class="row-title"> |
253 | 253 | <label |
254 | - for="give-export-donations-status"><?php _e( 'Filter by Status:', 'give' ); ?></label> |
|
254 | + for="give-export-donations-status"><?php _e('Filter by Status:', 'give'); ?></label> |
|
255 | 255 | </td> |
256 | 256 | <td> |
257 | 257 | <div class="give-clearfix"> |
258 | 258 | <select name="status" id="give-export-donations-status"> |
259 | - <option value="any"><?php _e( 'All Statuses', 'give' ); ?></option> |
|
259 | + <option value="any"><?php _e('All Statuses', 'give'); ?></option> |
|
260 | 260 | <?php |
261 | 261 | $statuses = give_get_payment_statuses(); |
262 | - foreach ( $statuses as $status => $label ) { |
|
263 | - echo '<option value="' . $status . '">' . $label . '</option>'; |
|
262 | + foreach ($statuses as $status => $label) { |
|
263 | + echo '<option value="'.$status.'">'.$label.'</option>'; |
|
264 | 264 | } |
265 | 265 | ?> |
266 | 266 | </select> |
@@ -274,16 +274,16 @@ discard block |
||
274 | 274 | * |
275 | 275 | * @since 2.1 |
276 | 276 | */ |
277 | - do_action( 'give_export_donation_fields' ); |
|
277 | + do_action('give_export_donation_fields'); |
|
278 | 278 | ?> |
279 | 279 | |
280 | 280 | <tr class="end"> |
281 | 281 | <td> |
282 | 282 | </td> |
283 | 283 | <td> |
284 | - <?php wp_nonce_field( 'give_ajax_export', 'give_ajax_export' ); ?> |
|
284 | + <?php wp_nonce_field('give_ajax_export', 'give_ajax_export'); ?> |
|
285 | 285 | <input type="hidden" name="give-export-class" value="Give_Export_Donations_CSV"/> |
286 | - <input type="submit" value="<?php _e( 'Generate CSV', 'give' ) ?>" class="give-export-donation-button button button-primary"> |
|
286 | + <input type="submit" value="<?php _e('Generate CSV', 'give') ?>" class="give-export-donation-button button button-primary"> |
|
287 | 287 | <div class="add-notices"></div> |
288 | 288 | </td> |
289 | 289 | </tr> |
@@ -304,11 +304,11 @@ discard block |
||
304 | 304 | * |
305 | 305 | * @since 2.1 |
306 | 306 | */ |
307 | - do_action( 'give_tools_export_donations_main_before' ); |
|
307 | + do_action('give_tools_export_donations_main_before'); |
|
308 | 308 | ?> |
309 | 309 | <div id="poststuff"> |
310 | 310 | <div class="postbox"> |
311 | - <h1 class="give-export-h1" align="center"><?php _e( 'Export Donations', 'give' ); ?></h1> |
|
311 | + <h1 class="give-export-h1" align="center"><?php _e('Export Donations', 'give'); ?></h1> |
|
312 | 312 | <div class="inside give-tools-setting-page-export give-export_donations"> |
313 | 313 | <?php |
314 | 314 | /** |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | * |
317 | 317 | * @since 2.1 |
318 | 318 | */ |
319 | - do_action( 'give_tools_export_donations_form_before_start' ); |
|
319 | + do_action('give_tools_export_donations_form_before_start'); |
|
320 | 320 | ?> |
321 | 321 | <form method="post" id="give-export_donations-form" |
322 | 322 | class="give-export-form tools-setting-page-export tools-setting-page-export" |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | * |
329 | 329 | * @since 2.1 |
330 | 330 | */ |
331 | - do_action( 'give_tools_export_donations_form_start' ); |
|
331 | + do_action('give_tools_export_donations_form_start'); |
|
332 | 332 | ?> |
333 | 333 | |
334 | 334 | <?php |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | * |
338 | 338 | * @since 2.1 |
339 | 339 | */ |
340 | - do_action( 'give_tools_export_donations_form_end' ); |
|
340 | + do_action('give_tools_export_donations_form_end'); |
|
341 | 341 | ?> |
342 | 342 | </form> |
343 | 343 | <?php |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | * |
347 | 347 | * @since 2.1 |
348 | 348 | */ |
349 | - do_action( 'give_tools_iexport_donations_form_after_end' ); |
|
349 | + do_action('give_tools_iexport_donations_form_after_end'); |
|
350 | 350 | ?> |
351 | 351 | </div><!-- .inside --> |
352 | 352 | </div><!-- .postbox --> |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | * |
358 | 358 | * @since 2.1 |
359 | 359 | */ |
360 | - do_action( 'give_tools_export_donations_main_after' ); |
|
360 | + do_action('give_tools_export_donations_main_after'); |
|
361 | 361 | } |
362 | 362 | |
363 | 363 | /** |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | * @return bool |
369 | 369 | */ |
370 | 370 | private function is_donations_export_page() { |
371 | - return 'export' === give_get_current_setting_tab() && isset( $_GET['type'] ) && $this->exporter_type === give_clean( $_GET['type'] ); |
|
371 | + return 'export' === give_get_current_setting_tab() && isset($_GET['type']) && $this->exporter_type === give_clean($_GET['type']); |
|
372 | 372 | } |
373 | 373 | } |
374 | 374 |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly.. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -25,135 +25,135 @@ discard block |
||
25 | 25 | * |
26 | 26 | * @uses give_pdf |
27 | 27 | */ |
28 | -function give_generate_pdf( $data ) { |
|
28 | +function give_generate_pdf($data) { |
|
29 | 29 | |
30 | - if ( ! current_user_can( 'view_give_reports' ) ) { |
|
31 | - wp_die( __( 'You do not have permission to generate PDF sales reports.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
30 | + if ( ! current_user_can('view_give_reports')) { |
|
31 | + wp_die(__('You do not have permission to generate PDF sales reports.', 'give'), __('Error', 'give'), array('response' => 403)); |
|
32 | 32 | } |
33 | 33 | |
34 | - if ( ! wp_verify_nonce( $_GET['_wpnonce'], 'give_generate_pdf' ) ) { |
|
35 | - wp_die( __( 'Nonce verification failed.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
34 | + if ( ! wp_verify_nonce($_GET['_wpnonce'], 'give_generate_pdf')) { |
|
35 | + wp_die(__('Nonce verification failed.', 'give'), __('Error', 'give'), array('response' => 403)); |
|
36 | 36 | } |
37 | 37 | |
38 | - if ( ! file_exists( GIVE_PLUGIN_DIR . '/includes/libraries/give-pdf.php' ) ) { |
|
39 | - wp_die( __( 'Dependency missing.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
38 | + if ( ! file_exists(GIVE_PLUGIN_DIR.'/includes/libraries/give-pdf.php')) { |
|
39 | + wp_die(__('Dependency missing.', 'give'), __('Error', 'give'), array('response' => 403)); |
|
40 | 40 | } |
41 | 41 | |
42 | - require_once GIVE_PLUGIN_DIR . '/includes/libraries/give-pdf.php'; |
|
42 | + require_once GIVE_PLUGIN_DIR.'/includes/libraries/give-pdf.php'; |
|
43 | 43 | |
44 | 44 | $daterange = utf8_decode( |
45 | 45 | sprintf( |
46 | 46 | /* translators: 1: start date 2: end date */ |
47 | - __( '%1$s to %2$s', 'give' ), |
|
48 | - date_i18n( give_date_format(), mktime( 0, 0, 0, 1, 1, date( 'Y' ) ) ), |
|
49 | - date_i18n( give_date_format() ) |
|
47 | + __('%1$s to %2$s', 'give'), |
|
48 | + date_i18n(give_date_format(), mktime(0, 0, 0, 1, 1, date('Y'))), |
|
49 | + date_i18n(give_date_format()) |
|
50 | 50 | ) |
51 | 51 | ); |
52 | 52 | |
53 | - $categories_enabled = give_is_setting_enabled( give_get_option( 'categories', 'disabled' ) ); |
|
54 | - $tags_enabled = give_is_setting_enabled( give_get_option( 'tags', 'disabled' ) ); |
|
53 | + $categories_enabled = give_is_setting_enabled(give_get_option('categories', 'disabled')); |
|
54 | + $tags_enabled = give_is_setting_enabled(give_get_option('tags', 'disabled')); |
|
55 | 55 | |
56 | - $pdf = new Give_PDF( 'L', 'mm', 'A', true, 'UTF-8', false ); |
|
57 | - $default_font = apply_filters( 'give_pdf_default_font', 'Helvetica' ); |
|
56 | + $pdf = new Give_PDF('L', 'mm', 'A', true, 'UTF-8', false); |
|
57 | + $default_font = apply_filters('give_pdf_default_font', 'Helvetica'); |
|
58 | 58 | $custom_font = 'dejavusans'; |
59 | 59 | $font_style = ''; |
60 | 60 | |
61 | 61 | if ( |
62 | - file_exists( GIVE_PLUGIN_DIR . '/includes/libraries/tcpdf/fonts/CODE2000.TTF' ) && |
|
62 | + file_exists(GIVE_PLUGIN_DIR.'/includes/libraries/tcpdf/fonts/CODE2000.TTF') && |
|
63 | 63 | |
64 | 64 | // RIAL exist for backward compatibility. |
65 | - in_array( give_get_currency(), array( 'RIAL', 'RUB', 'IRR' ) ) |
|
65 | + in_array(give_get_currency(), array('RIAL', 'RUB', 'IRR')) |
|
66 | 66 | ) { |
67 | - TCPDF_FONTS::addTTFfont( GIVE_PLUGIN_DIR . '/includes/libraries/tcpdf/fonts/CODE2000.TTF', '' ); |
|
67 | + TCPDF_FONTS::addTTFfont(GIVE_PLUGIN_DIR.'/includes/libraries/tcpdf/fonts/CODE2000.TTF', ''); |
|
68 | 68 | $custom_font = 'CODE2000'; |
69 | 69 | $font_style = 'B'; |
70 | 70 | } |
71 | 71 | |
72 | - $pdf->AddPage( 'L', 'A4' ); |
|
73 | - $pdf->setImageScale( 1.5 ); |
|
74 | - $pdf->SetTitle( utf8_decode( __( 'Donation report for the current year for all forms', 'give' ) ) ); |
|
75 | - $pdf->SetAuthor( utf8_decode( __( 'Give - Democratizing Generosity', 'give' ) ) ); |
|
76 | - $pdf->SetCreator( utf8_decode( __( 'Give - Democratizing Generosity', 'give' ) ) ); |
|
72 | + $pdf->AddPage('L', 'A4'); |
|
73 | + $pdf->setImageScale(1.5); |
|
74 | + $pdf->SetTitle(utf8_decode(__('Donation report for the current year for all forms', 'give'))); |
|
75 | + $pdf->SetAuthor(utf8_decode(__('Give - Democratizing Generosity', 'give'))); |
|
76 | + $pdf->SetCreator(utf8_decode(__('Give - Democratizing Generosity', 'give'))); |
|
77 | 77 | |
78 | 78 | // Image URL should have absolute path. @see https://tcpdf.org/examples/example_009/. |
79 | - $pdf->Image( apply_filters( 'give_pdf_export_logo', GIVE_PLUGIN_DIR . 'assets/dist/images/give-logo-small.png' ), 247, 8 ); |
|
79 | + $pdf->Image(apply_filters('give_pdf_export_logo', GIVE_PLUGIN_DIR.'assets/dist/images/give-logo-small.png'), 247, 8); |
|
80 | 80 | |
81 | - $pdf->SetMargins( 8, 8, 8 ); |
|
82 | - $pdf->SetX( 8 ); |
|
81 | + $pdf->SetMargins(8, 8, 8); |
|
82 | + $pdf->SetX(8); |
|
83 | 83 | |
84 | - $pdf->SetFont( $default_font, '', 16 ); |
|
85 | - $pdf->SetTextColor( 50, 50, 50 ); |
|
86 | - $pdf->Cell( 0, 3, utf8_decode( __( 'Donation report for the current year for all forms', 'give' ) ), 0, 2, 'L', false ); |
|
84 | + $pdf->SetFont($default_font, '', 16); |
|
85 | + $pdf->SetTextColor(50, 50, 50); |
|
86 | + $pdf->Cell(0, 3, utf8_decode(__('Donation report for the current year for all forms', 'give')), 0, 2, 'L', false); |
|
87 | 87 | |
88 | - $pdf->SetFont( $default_font, '', 13 ); |
|
89 | - $pdf->SetTextColor( 150, 150, 150 ); |
|
90 | - $pdf->Ln( 1 ); |
|
91 | - $pdf->Cell( 0, 6, utf8_decode( __( 'Date Range: ', 'give' ) ) . $daterange, 0, 2, 'L', false ); |
|
88 | + $pdf->SetFont($default_font, '', 13); |
|
89 | + $pdf->SetTextColor(150, 150, 150); |
|
90 | + $pdf->Ln(1); |
|
91 | + $pdf->Cell(0, 6, utf8_decode(__('Date Range: ', 'give')).$daterange, 0, 2, 'L', false); |
|
92 | 92 | $pdf->Ln(); |
93 | - $pdf->SetTextColor( 50, 50, 50 ); |
|
94 | - $pdf->SetFont( $default_font, '', 14 ); |
|
95 | - $pdf->Cell( 0, 10, utf8_decode( __( 'Table View', 'give' ) ), 0, 2, 'L', false ); |
|
96 | - $pdf->SetFont( $default_font, '', 12 ); |
|
93 | + $pdf->SetTextColor(50, 50, 50); |
|
94 | + $pdf->SetFont($default_font, '', 14); |
|
95 | + $pdf->Cell(0, 10, utf8_decode(__('Table View', 'give')), 0, 2, 'L', false); |
|
96 | + $pdf->SetFont($default_font, '', 12); |
|
97 | 97 | |
98 | - $pdf->SetFillColor( 238, 238, 238 ); |
|
99 | - $pdf->SetTextColor( 0, 0, 0, 100 ); // Set Black color. |
|
100 | - $pdf->Cell( 50, 6, utf8_decode( __( 'Form Name', 'give' ) ), 1, 0, 'L', true ); |
|
101 | - $pdf->Cell( 50, 6, utf8_decode( __( 'Price', 'give' ) ), 1, 0, 'L', true ); |
|
98 | + $pdf->SetFillColor(238, 238, 238); |
|
99 | + $pdf->SetTextColor(0, 0, 0, 100); // Set Black color. |
|
100 | + $pdf->Cell(50, 6, utf8_decode(__('Form Name', 'give')), 1, 0, 'L', true); |
|
101 | + $pdf->Cell(50, 6, utf8_decode(__('Price', 'give')), 1, 0, 'L', true); |
|
102 | 102 | |
103 | 103 | // Display Categories Heading only, if user has opted for it. |
104 | - if ( $categories_enabled ) { |
|
105 | - $pdf->Cell( 45, 6, utf8_decode( __( 'Categories', 'give' ) ), 1, 0, 'L', true ); |
|
104 | + if ($categories_enabled) { |
|
105 | + $pdf->Cell(45, 6, utf8_decode(__('Categories', 'give')), 1, 0, 'L', true); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | // Display Tags Heading only, if user has opted for it. |
109 | - if ( $tags_enabled ) { |
|
110 | - $pdf->Cell( 45, 6, utf8_decode( __( 'Tags', 'give' ) ), 1, 0, 'L', true ); |
|
109 | + if ($tags_enabled) { |
|
110 | + $pdf->Cell(45, 6, utf8_decode(__('Tags', 'give')), 1, 0, 'L', true); |
|
111 | 111 | } |
112 | 112 | |
113 | - $pdf->Cell( 45, 6, utf8_decode( __( 'Number of Donations', 'give' ) ), 1, 0, 'L', true ); |
|
114 | - $pdf->Cell( 45, 6, utf8_decode( __( 'Income to Date', 'give' ) ), 1, 1, 'L', true ); |
|
113 | + $pdf->Cell(45, 6, utf8_decode(__('Number of Donations', 'give')), 1, 0, 'L', true); |
|
114 | + $pdf->Cell(45, 6, utf8_decode(__('Income to Date', 'give')), 1, 1, 'L', true); |
|
115 | 115 | |
116 | 116 | // Set Custom Font to support various currencies. |
117 | - $pdf->SetFont( apply_filters( 'give_pdf_custom_font', $custom_font ), $font_style, 12 ); |
|
117 | + $pdf->SetFont(apply_filters('give_pdf_custom_font', $custom_font), $font_style, 12); |
|
118 | 118 | |
119 | - $year = date( 'Y' ); |
|
120 | - $give_forms = get_posts( array( |
|
119 | + $year = date('Y'); |
|
120 | + $give_forms = get_posts(array( |
|
121 | 121 | 'post_type' => 'give_forms', |
122 | 122 | 'year' => $year, |
123 | - 'posts_per_page' => - 1, |
|
123 | + 'posts_per_page' => -1, |
|
124 | 124 | 'supply_filter' => false, |
125 | - ) ); |
|
125 | + )); |
|
126 | 126 | |
127 | - if ( $give_forms ) { |
|
128 | - $pdf->SetWidths( array( 50, 50, 45, 45, 45, 45 ) ); |
|
127 | + if ($give_forms) { |
|
128 | + $pdf->SetWidths(array(50, 50, 45, 45, 45, 45)); |
|
129 | 129 | |
130 | - foreach ( $give_forms as $form ): |
|
131 | - $pdf->SetFillColor( 255, 255, 255 ); |
|
130 | + foreach ($give_forms as $form): |
|
131 | + $pdf->SetFillColor(255, 255, 255); |
|
132 | 132 | |
133 | 133 | $title = $form->post_title; |
134 | 134 | |
135 | - if ( give_has_variable_prices( $form->ID ) ) { |
|
136 | - $price = html_entity_decode( give_price_range( $form->ID, false ), ENT_COMPAT, 'UTF-8' ); |
|
135 | + if (give_has_variable_prices($form->ID)) { |
|
136 | + $price = html_entity_decode(give_price_range($form->ID, false), ENT_COMPAT, 'UTF-8'); |
|
137 | 137 | } else { |
138 | - $price = give_currency_filter( give_get_form_price( $form->ID ), array( 'decode_currency' => true ) ); |
|
138 | + $price = give_currency_filter(give_get_form_price($form->ID), array('decode_currency' => true)); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | // Display Categories Data only, if user has opted for it. |
142 | 142 | $categories = array(); |
143 | - if ( $categories_enabled ) { |
|
144 | - $categories = get_the_term_list( $form->ID, 'give_forms_category', '', ', ', '' ); |
|
145 | - $categories = ! is_wp_error( $categories ) ? strip_tags( $categories ) : ''; |
|
143 | + if ($categories_enabled) { |
|
144 | + $categories = get_the_term_list($form->ID, 'give_forms_category', '', ', ', ''); |
|
145 | + $categories = ! is_wp_error($categories) ? strip_tags($categories) : ''; |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | // Display Tags Data only, if user has opted for it. |
149 | 149 | $tags = array(); |
150 | - if ( $tags_enabled ) { |
|
151 | - $tags = get_the_term_list( $form->ID, 'give_forms_tag', '', ', ', '' ); |
|
152 | - $tags = ! is_wp_error( $tags ) ? strip_tags( $tags ) : ''; |
|
150 | + if ($tags_enabled) { |
|
151 | + $tags = get_the_term_list($form->ID, 'give_forms_tag', '', ', ', ''); |
|
152 | + $tags = ! is_wp_error($tags) ? strip_tags($tags) : ''; |
|
153 | 153 | } |
154 | 154 | |
155 | - $sales = give_get_form_sales_stats( $form->ID ); |
|
156 | - $earnings = give_currency_filter( give_format_amount( give_get_form_earnings_stats( $form->ID ), array( 'sanitize' => false, ) ), array( 'decode_currency' => true ) ); |
|
155 | + $sales = give_get_form_sales_stats($form->ID); |
|
156 | + $earnings = give_currency_filter(give_format_amount(give_get_form_earnings_stats($form->ID), array('sanitize' => false,)), array('decode_currency' => true)); |
|
157 | 157 | |
158 | 158 | // This will help filter data before appending it to PDF Receipt. |
159 | 159 | $prepare_pdf_data = array(); |
@@ -161,54 +161,54 @@ discard block |
||
161 | 161 | $prepare_pdf_data[] = $price; |
162 | 162 | |
163 | 163 | // Append Categories Data only, if user has opted for it. |
164 | - if ( $categories_enabled ) { |
|
164 | + if ($categories_enabled) { |
|
165 | 165 | $prepare_pdf_data[] = $categories; |
166 | 166 | } |
167 | 167 | |
168 | 168 | // Append Tags Data only, if user has opted for it. |
169 | - if ( $tags_enabled ) { |
|
169 | + if ($tags_enabled) { |
|
170 | 170 | $prepare_pdf_data[] = $tags; |
171 | 171 | } |
172 | 172 | |
173 | 173 | $prepare_pdf_data[] = $sales; |
174 | 174 | $prepare_pdf_data[] = $earnings; |
175 | 175 | |
176 | - $pdf->Row( $prepare_pdf_data ); |
|
176 | + $pdf->Row($prepare_pdf_data); |
|
177 | 177 | |
178 | 178 | endforeach; |
179 | 179 | } else { |
180 | 180 | |
181 | 181 | // Fix: Minor Styling Alignment Issue for PDF. |
182 | - if ( $categories_enabled && $tags_enabled ) { |
|
182 | + if ($categories_enabled && $tags_enabled) { |
|
183 | 183 | $no_found_width = 280; |
184 | - } elseif ( $categories_enabled || $tags_enabled ) { |
|
184 | + } elseif ($categories_enabled || $tags_enabled) { |
|
185 | 185 | $no_found_width = 235; |
186 | 186 | } else { |
187 | 187 | $no_found_width = 190; |
188 | 188 | } |
189 | - $title = utf8_decode( __( 'No forms found.', 'give' ) ); |
|
190 | - $pdf->MultiCell( $no_found_width, 5, $title, 1, 'C', false, 1, '', '', true, 0, false, true, 0, 'T', false ); |
|
189 | + $title = utf8_decode(__('No forms found.', 'give')); |
|
190 | + $pdf->MultiCell($no_found_width, 5, $title, 1, 'C', false, 1, '', '', true, 0, false, true, 0, 'T', false); |
|
191 | 191 | }// End if(). |
192 | 192 | $pdf->Ln(); |
193 | - $pdf->SetTextColor( 50, 50, 50 ); |
|
194 | - $pdf->SetFont( $default_font, '', 14 ); |
|
193 | + $pdf->SetTextColor(50, 50, 50); |
|
194 | + $pdf->SetFont($default_font, '', 14); |
|
195 | 195 | |
196 | 196 | // Output Graph on a new page. |
197 | - $pdf->AddPage( 'L', 'A4' ); |
|
198 | - $pdf->Cell( 0, 10, utf8_decode( __( 'Graph View', 'give' ) ), 0, 2, 'L', false ); |
|
199 | - $pdf->SetFont( $default_font, '', 12 ); |
|
197 | + $pdf->AddPage('L', 'A4'); |
|
198 | + $pdf->Cell(0, 10, utf8_decode(__('Graph View', 'give')), 0, 2, 'L', false); |
|
199 | + $pdf->SetFont($default_font, '', 12); |
|
200 | 200 | |
201 | - $image = html_entity_decode( urldecode( give_draw_chart_image() ) ); |
|
202 | - $image = str_replace( ' ', '%20', $image ); |
|
201 | + $image = html_entity_decode(urldecode(give_draw_chart_image())); |
|
202 | + $image = str_replace(' ', '%20', $image); |
|
203 | 203 | |
204 | - $pdf->SetX( 25 ); |
|
205 | - $pdf->Image( $image . '&file=.png' ); |
|
206 | - $pdf->Ln( 7 ); |
|
207 | - $pdf->Output( apply_filters( 'give_sales_earnings_pdf_export_filename', 'give-report-' . date_i18n( 'Y-m-d' ) ) . '.pdf', 'D' ); |
|
204 | + $pdf->SetX(25); |
|
205 | + $pdf->Image($image.'&file=.png'); |
|
206 | + $pdf->Ln(7); |
|
207 | + $pdf->Output(apply_filters('give_sales_earnings_pdf_export_filename', 'give-report-'.date_i18n('Y-m-d')).'.pdf', 'D'); |
|
208 | 208 | exit(); |
209 | 209 | } |
210 | 210 | |
211 | -add_action( 'give_generate_pdf', 'give_generate_pdf' ); |
|
211 | +add_action('give_generate_pdf', 'give_generate_pdf'); |
|
212 | 212 | |
213 | 213 | /** |
214 | 214 | * Draws Chart for PDF Report. |
@@ -225,38 +225,38 @@ discard block |
||
225 | 225 | * @return string $chart->getUrl() URL for the Google Chart |
226 | 226 | */ |
227 | 227 | function give_draw_chart_image() { |
228 | - require_once GIVE_PLUGIN_DIR . '/includes/libraries/googlechartlib/GoogleChart.php'; |
|
229 | - require_once GIVE_PLUGIN_DIR . '/includes/libraries/googlechartlib/markers/GoogleChartShapeMarker.php'; |
|
230 | - require_once GIVE_PLUGIN_DIR . '/includes/libraries/googlechartlib/markers/GoogleChartTextMarker.php'; |
|
228 | + require_once GIVE_PLUGIN_DIR.'/includes/libraries/googlechartlib/GoogleChart.php'; |
|
229 | + require_once GIVE_PLUGIN_DIR.'/includes/libraries/googlechartlib/markers/GoogleChartShapeMarker.php'; |
|
230 | + require_once GIVE_PLUGIN_DIR.'/includes/libraries/googlechartlib/markers/GoogleChartTextMarker.php'; |
|
231 | 231 | |
232 | - $chart = new GoogleChart( 'lc', 900, 330 ); |
|
232 | + $chart = new GoogleChart('lc', 900, 330); |
|
233 | 233 | |
234 | 234 | $i = 1; |
235 | 235 | $earnings = ""; |
236 | 236 | $sales = ""; |
237 | 237 | |
238 | - while ( $i <= 12 ) : |
|
239 | - $earnings .= give_get_earnings_by_date( null, $i, date( 'Y' ) ) . ","; |
|
240 | - $sales .= give_get_sales_by_date( null, $i, date( 'Y' ) ) . ","; |
|
241 | - $i ++; |
|
238 | + while ($i <= 12) : |
|
239 | + $earnings .= give_get_earnings_by_date(null, $i, date('Y')).","; |
|
240 | + $sales .= give_get_sales_by_date(null, $i, date('Y')).","; |
|
241 | + $i++; |
|
242 | 242 | endwhile; |
243 | 243 | |
244 | - $earnings_array = explode( ",", $earnings ); |
|
245 | - $sales_array = explode( ",", $sales ); |
|
244 | + $earnings_array = explode(",", $earnings); |
|
245 | + $sales_array = explode(",", $sales); |
|
246 | 246 | |
247 | 247 | $i = 0; |
248 | - while ( $i <= 11 ) { |
|
249 | - if ( empty( $sales_array[ $i ] ) ) { |
|
250 | - $sales_array[ $i ] = 0; |
|
248 | + while ($i <= 11) { |
|
249 | + if (empty($sales_array[$i])) { |
|
250 | + $sales_array[$i] = 0; |
|
251 | 251 | } |
252 | - $i ++; |
|
252 | + $i++; |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | $min_earnings = 0; |
256 | - $max_earnings = max( $earnings_array ); |
|
257 | - $earnings_scale = round( $max_earnings, - 1 ); |
|
256 | + $max_earnings = max($earnings_array); |
|
257 | + $earnings_scale = round($max_earnings, - 1); |
|
258 | 258 | |
259 | - $data = new GoogleChartData( array( |
|
259 | + $data = new GoogleChartData(array( |
|
260 | 260 | $earnings_array[0], |
261 | 261 | $earnings_array[1], |
262 | 262 | $earnings_array[2], |
@@ -269,25 +269,25 @@ discard block |
||
269 | 269 | $earnings_array[9], |
270 | 270 | $earnings_array[10], |
271 | 271 | $earnings_array[11], |
272 | - ) ); |
|
272 | + )); |
|
273 | 273 | |
274 | - $data->setLegend( __( 'Income', 'give' ) ); |
|
275 | - $data->setColor( '1b58a3' ); |
|
276 | - $chart->addData( $data ); |
|
274 | + $data->setLegend(__('Income', 'give')); |
|
275 | + $data->setColor('1b58a3'); |
|
276 | + $chart->addData($data); |
|
277 | 277 | |
278 | - $shape_marker = new GoogleChartShapeMarker( GoogleChartShapeMarker::CIRCLE ); |
|
279 | - $shape_marker->setColor( '000000' ); |
|
280 | - $shape_marker->setSize( 7 ); |
|
281 | - $shape_marker->setBorder( 2 ); |
|
282 | - $shape_marker->setData( $data ); |
|
283 | - $chart->addMarker( $shape_marker ); |
|
278 | + $shape_marker = new GoogleChartShapeMarker(GoogleChartShapeMarker::CIRCLE); |
|
279 | + $shape_marker->setColor('000000'); |
|
280 | + $shape_marker->setSize(7); |
|
281 | + $shape_marker->setBorder(2); |
|
282 | + $shape_marker->setData($data); |
|
283 | + $chart->addMarker($shape_marker); |
|
284 | 284 | |
285 | - $value_marker = new GoogleChartTextMarker( GoogleChartTextMarker::VALUE ); |
|
286 | - $value_marker->setColor( '000000' ); |
|
287 | - $value_marker->setData( $data ); |
|
288 | - $chart->addMarker( $value_marker ); |
|
285 | + $value_marker = new GoogleChartTextMarker(GoogleChartTextMarker::VALUE); |
|
286 | + $value_marker->setColor('000000'); |
|
287 | + $value_marker->setData($data); |
|
288 | + $chart->addMarker($value_marker); |
|
289 | 289 | |
290 | - $data = new GoogleChartData( array( |
|
290 | + $data = new GoogleChartData(array( |
|
291 | 291 | $sales_array[0], |
292 | 292 | $sales_array[1], |
293 | 293 | $sales_array[2], |
@@ -300,46 +300,46 @@ discard block |
||
300 | 300 | $sales_array[9], |
301 | 301 | $sales_array[10], |
302 | 302 | $sales_array[11], |
303 | - ) ); |
|
304 | - $data->setLegend( __( 'Donations', 'give' ) ); |
|
305 | - $data->setColor( 'ff6c1c' ); |
|
306 | - $chart->addData( $data ); |
|
307 | - |
|
308 | - $chart->setTitle( __( 'Donations by Month for all Give Forms', 'give' ), '336699', 18 ); |
|
309 | - |
|
310 | - $chart->setScale( 0, $max_earnings ); |
|
311 | - |
|
312 | - $y_axis = new GoogleChartAxis( 'y' ); |
|
313 | - $y_axis->setDrawTickMarks( true )->setLabels( array( 0, $max_earnings ) ); |
|
314 | - $chart->addAxis( $y_axis ); |
|
315 | - |
|
316 | - $x_axis = new GoogleChartAxis( 'x' ); |
|
317 | - $x_axis->setTickMarks( 5 ); |
|
318 | - $x_axis->setLabels( array( |
|
319 | - __( 'Jan', 'give' ), |
|
320 | - __( 'Feb', 'give' ), |
|
321 | - __( 'Mar', 'give' ), |
|
322 | - __( 'Apr', 'give' ), |
|
323 | - __( 'May', 'give' ), |
|
324 | - __( 'June', 'give' ), |
|
325 | - __( 'July', 'give' ), |
|
326 | - __( 'Aug', 'give' ), |
|
327 | - __( 'Sept', 'give' ), |
|
328 | - __( 'Oct', 'give' ), |
|
329 | - __( 'Nov', 'give' ), |
|
330 | - __( 'Dec', 'give' ), |
|
331 | - ) ); |
|
332 | - $chart->addAxis( $x_axis ); |
|
333 | - |
|
334 | - $shape_marker = new GoogleChartShapeMarker( GoogleChartShapeMarker::CIRCLE ); |
|
335 | - $shape_marker->setSize( 6 ); |
|
336 | - $shape_marker->setBorder( 2 ); |
|
337 | - $shape_marker->setData( $data ); |
|
338 | - $chart->addMarker( $shape_marker ); |
|
339 | - |
|
340 | - $value_marker = new GoogleChartTextMarker( GoogleChartTextMarker::VALUE ); |
|
341 | - $value_marker->setData( $data ); |
|
342 | - $chart->addMarker( $value_marker ); |
|
303 | + )); |
|
304 | + $data->setLegend(__('Donations', 'give')); |
|
305 | + $data->setColor('ff6c1c'); |
|
306 | + $chart->addData($data); |
|
307 | + |
|
308 | + $chart->setTitle(__('Donations by Month for all Give Forms', 'give'), '336699', 18); |
|
309 | + |
|
310 | + $chart->setScale(0, $max_earnings); |
|
311 | + |
|
312 | + $y_axis = new GoogleChartAxis('y'); |
|
313 | + $y_axis->setDrawTickMarks(true)->setLabels(array(0, $max_earnings)); |
|
314 | + $chart->addAxis($y_axis); |
|
315 | + |
|
316 | + $x_axis = new GoogleChartAxis('x'); |
|
317 | + $x_axis->setTickMarks(5); |
|
318 | + $x_axis->setLabels(array( |
|
319 | + __('Jan', 'give'), |
|
320 | + __('Feb', 'give'), |
|
321 | + __('Mar', 'give'), |
|
322 | + __('Apr', 'give'), |
|
323 | + __('May', 'give'), |
|
324 | + __('June', 'give'), |
|
325 | + __('July', 'give'), |
|
326 | + __('Aug', 'give'), |
|
327 | + __('Sept', 'give'), |
|
328 | + __('Oct', 'give'), |
|
329 | + __('Nov', 'give'), |
|
330 | + __('Dec', 'give'), |
|
331 | + )); |
|
332 | + $chart->addAxis($x_axis); |
|
333 | + |
|
334 | + $shape_marker = new GoogleChartShapeMarker(GoogleChartShapeMarker::CIRCLE); |
|
335 | + $shape_marker->setSize(6); |
|
336 | + $shape_marker->setBorder(2); |
|
337 | + $shape_marker->setData($data); |
|
338 | + $chart->addMarker($shape_marker); |
|
339 | + |
|
340 | + $value_marker = new GoogleChartTextMarker(GoogleChartTextMarker::VALUE); |
|
341 | + $value_marker->setData($data); |
|
342 | + $chart->addMarker($value_marker); |
|
343 | 343 | |
344 | 344 | return $chart->getUrl(); |
345 | 345 | } |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly. |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
@@ -85,21 +85,21 @@ discard block |
||
85 | 85 | * |
86 | 86 | * @param array $request The Form Data passed into the batch processing. |
87 | 87 | */ |
88 | - public function set_properties( $request ) { |
|
88 | + public function set_properties($request) { |
|
89 | 89 | |
90 | 90 | // Set data from form submission |
91 | - if ( isset( $_POST['form'] ) ) { |
|
92 | - parse_str( $_POST['form'], $this->data ); |
|
91 | + if (isset($_POST['form'])) { |
|
92 | + parse_str($_POST['form'], $this->data); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | $this->form = $this->data['forms']; |
96 | - $this->categories = ! empty( $request['give_forms_categories'] ) ? (array) $request['give_forms_categories'] : array(); |
|
97 | - $this->tags = ! empty( $request['give_forms_tags'] ) ? (array) $request['give_forms_tags'] : array(); |
|
98 | - $this->form_id = $this->get_form_ids( $request ); |
|
99 | - $this->price_id = isset( $request['give_price_option'] ) && ( 'all' !== $request['give_price_option'] && '' !== $request['give_price_option'] ) ? absint( $request['give_price_option'] ) : null; |
|
100 | - $this->start = isset( $request['start'] ) ? sanitize_text_field( $request['start'] ) : ''; |
|
101 | - $this->end = isset( $request['end'] ) ? sanitize_text_field( $request['end'] ) : ''; |
|
102 | - $this->status = isset( $request['status'] ) ? sanitize_text_field( $request['status'] ) : 'complete'; |
|
96 | + $this->categories = ! empty($request['give_forms_categories']) ? (array) $request['give_forms_categories'] : array(); |
|
97 | + $this->tags = ! empty($request['give_forms_tags']) ? (array) $request['give_forms_tags'] : array(); |
|
98 | + $this->form_id = $this->get_form_ids($request); |
|
99 | + $this->price_id = isset($request['give_price_option']) && ('all' !== $request['give_price_option'] && '' !== $request['give_price_option']) ? absint($request['give_price_option']) : null; |
|
100 | + $this->start = isset($request['start']) ? sanitize_text_field($request['start']) : ''; |
|
101 | + $this->end = isset($request['end']) ? sanitize_text_field($request['end']) : ''; |
|
102 | + $this->status = isset($request['status']) ? sanitize_text_field($request['status']) : 'complete'; |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | /** |
@@ -111,13 +111,13 @@ discard block |
||
111 | 111 | * |
112 | 112 | * @return array|boolean|null $form get all the donation id that need to be exported |
113 | 113 | */ |
114 | - public function get_form_ids( $request = array() ) { |
|
115 | - $form = ! empty( $request['forms'] ) && 0 !== $request['forms'] ? absint( $request['forms'] ) : null; |
|
114 | + public function get_form_ids($request = array()) { |
|
115 | + $form = ! empty($request['forms']) && 0 !== $request['forms'] ? absint($request['forms']) : null; |
|
116 | 116 | |
117 | - $form_ids = ! empty( $request['form_ids'] ) ? sanitize_text_field( $request['form_ids'] ) : null; |
|
117 | + $form_ids = ! empty($request['form_ids']) ? sanitize_text_field($request['form_ids']) : null; |
|
118 | 118 | |
119 | - if ( empty( $form ) && ! empty( $form_ids ) && ( ! empty( $this->categories ) || ! empty( $this->tags ) ) ) { |
|
120 | - $form = explode( ',', $form_ids ); |
|
119 | + if (empty($form) && ! empty($form_ids) && ( ! empty($this->categories) || ! empty($this->tags))) { |
|
120 | + $form = explode(',', $form_ids); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | return $form; |
@@ -134,14 +134,14 @@ discard block |
||
134 | 134 | */ |
135 | 135 | public function csv_cols() { |
136 | 136 | |
137 | - $columns = isset( $this->data['give_give_donations_export_option'] ) ? $this->data['give_give_donations_export_option'] : array(); |
|
137 | + $columns = isset($this->data['give_give_donations_export_option']) ? $this->data['give_give_donations_export_option'] : array(); |
|
138 | 138 | |
139 | 139 | // We need columns. |
140 | - if ( empty( $columns ) ) { |
|
140 | + if (empty($columns)) { |
|
141 | 141 | return false; |
142 | 142 | } |
143 | 143 | |
144 | - $this->cols = $this->get_cols( $columns ); |
|
144 | + $this->cols = $this->get_cols($columns); |
|
145 | 145 | |
146 | 146 | return $this->cols; |
147 | 147 | } |
@@ -156,83 +156,83 @@ discard block |
||
156 | 156 | * |
157 | 157 | * @return array |
158 | 158 | */ |
159 | - private function get_cols( $columns ) { |
|
159 | + private function get_cols($columns) { |
|
160 | 160 | |
161 | 161 | $cols = array(); |
162 | 162 | |
163 | - foreach ( $columns as $key => $value ) { |
|
163 | + foreach ($columns as $key => $value) { |
|
164 | 164 | |
165 | - switch ( $key ) { |
|
165 | + switch ($key) { |
|
166 | 166 | case 'donation_id' : |
167 | - $cols['donation_id'] = __( 'Donation ID', 'give' ); |
|
167 | + $cols['donation_id'] = __('Donation ID', 'give'); |
|
168 | 168 | break; |
169 | 169 | case 'seq_id' : |
170 | - $cols['seq_id'] = __( 'Donation Number', 'give' ); |
|
170 | + $cols['seq_id'] = __('Donation Number', 'give'); |
|
171 | 171 | break; |
172 | 172 | case 'first_name' : |
173 | - $cols['first_name'] = __( 'First Name', 'give' ); |
|
173 | + $cols['first_name'] = __('First Name', 'give'); |
|
174 | 174 | break; |
175 | 175 | case 'last_name' : |
176 | - $cols['last_name'] = __( 'Last Name', 'give' ); |
|
176 | + $cols['last_name'] = __('Last Name', 'give'); |
|
177 | 177 | break; |
178 | 178 | case 'email' : |
179 | - $cols['email'] = __( 'Email Address', 'give' ); |
|
179 | + $cols['email'] = __('Email Address', 'give'); |
|
180 | 180 | break; |
181 | 181 | case 'company' : |
182 | - $cols['company'] = __( 'Company Name', 'give' ); |
|
182 | + $cols['company'] = __('Company Name', 'give'); |
|
183 | 183 | break; |
184 | 184 | case 'address' : |
185 | - $cols['address_line1'] = __( 'Address 1', 'give' ); |
|
186 | - $cols['address_line2'] = __( 'Address 2', 'give' ); |
|
187 | - $cols['address_city'] = __( 'City', 'give' ); |
|
188 | - $cols['address_state'] = __( 'State', 'give' ); |
|
189 | - $cols['address_zip'] = __( 'Zip', 'give' ); |
|
190 | - $cols['address_country'] = __( 'Country', 'give' ); |
|
185 | + $cols['address_line1'] = __('Address 1', 'give'); |
|
186 | + $cols['address_line2'] = __('Address 2', 'give'); |
|
187 | + $cols['address_city'] = __('City', 'give'); |
|
188 | + $cols['address_state'] = __('State', 'give'); |
|
189 | + $cols['address_zip'] = __('Zip', 'give'); |
|
190 | + $cols['address_country'] = __('Country', 'give'); |
|
191 | 191 | break; |
192 | 192 | case 'donation_total' : |
193 | - $cols['donation_total'] = __( 'Donation Total', 'give' ); |
|
193 | + $cols['donation_total'] = __('Donation Total', 'give'); |
|
194 | 194 | break; |
195 | 195 | case 'currency_code' : |
196 | - $cols['currency_code'] = __( 'Currency Code', 'give' ); |
|
196 | + $cols['currency_code'] = __('Currency Code', 'give'); |
|
197 | 197 | break; |
198 | 198 | case 'currency_symbol' : |
199 | - $cols['currency_symbol'] = __( 'Currency Symbol', 'give' ); |
|
199 | + $cols['currency_symbol'] = __('Currency Symbol', 'give'); |
|
200 | 200 | break; |
201 | 201 | case 'donation_status' : |
202 | - $cols['donation_status'] = __( 'Donation Status', 'give' ); |
|
202 | + $cols['donation_status'] = __('Donation Status', 'give'); |
|
203 | 203 | break; |
204 | 204 | case 'payment_gateway' : |
205 | - $cols['payment_gateway'] = __( 'Payment Gateway', 'give' ); |
|
205 | + $cols['payment_gateway'] = __('Payment Gateway', 'give'); |
|
206 | 206 | break; |
207 | 207 | case 'form_id' : |
208 | - $cols['form_id'] = __( 'Form ID', 'give' ); |
|
208 | + $cols['form_id'] = __('Form ID', 'give'); |
|
209 | 209 | break; |
210 | 210 | case 'form_title' : |
211 | - $cols['form_title'] = __( 'Form Title', 'give' ); |
|
211 | + $cols['form_title'] = __('Form Title', 'give'); |
|
212 | 212 | break; |
213 | 213 | case 'form_level_id' : |
214 | - $cols['form_level_id'] = __( 'Level ID', 'give' ); |
|
214 | + $cols['form_level_id'] = __('Level ID', 'give'); |
|
215 | 215 | break; |
216 | 216 | case 'form_level_title' : |
217 | - $cols['form_level_title'] = __( 'Level Title', 'give' ); |
|
217 | + $cols['form_level_title'] = __('Level Title', 'give'); |
|
218 | 218 | break; |
219 | 219 | case 'donation_date' : |
220 | - $cols['donation_date'] = __( 'Donation Date', 'give' ); |
|
220 | + $cols['donation_date'] = __('Donation Date', 'give'); |
|
221 | 221 | break; |
222 | 222 | case 'donation_time' : |
223 | - $cols['donation_time'] = __( 'Donation Time', 'give' ); |
|
223 | + $cols['donation_time'] = __('Donation Time', 'give'); |
|
224 | 224 | break; |
225 | 225 | case 'userid' : |
226 | - $cols['userid'] = __( 'User ID', 'give' ); |
|
226 | + $cols['userid'] = __('User ID', 'give'); |
|
227 | 227 | break; |
228 | 228 | case 'donorid' : |
229 | - $cols['donorid'] = __( 'Donor ID', 'give' ); |
|
229 | + $cols['donorid'] = __('Donor ID', 'give'); |
|
230 | 230 | break; |
231 | 231 | case 'donor_ip' : |
232 | - $cols['donor_ip'] = __( 'Donor IP Address', 'give' ); |
|
232 | + $cols['donor_ip'] = __('Donor IP Address', 'give'); |
|
233 | 233 | break; |
234 | 234 | default: |
235 | - $cols[ $key ] = $key; |
|
235 | + $cols[$key] = $key; |
|
236 | 236 | |
237 | 237 | } |
238 | 238 | } |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | * @param array $cols columns name for CSV |
246 | 246 | * @param array $columns columns select by admin to export |
247 | 247 | */ |
248 | - return (array) apply_filters( 'give_export_donation_get_columns_name', $cols, $columns ); |
|
248 | + return (array) apply_filters('give_export_donation_get_columns_name', $cols, $columns); |
|
249 | 249 | } |
250 | 250 | |
251 | 251 | /** |
@@ -257,27 +257,27 @@ discard block |
||
257 | 257 | * |
258 | 258 | * @return array $args donation argument |
259 | 259 | */ |
260 | - public function get_donation_argument( $args = array() ) { |
|
260 | + public function get_donation_argument($args = array()) { |
|
261 | 261 | $defaults = array( |
262 | 262 | 'number' => 30, |
263 | 263 | 'page' => $this->step, |
264 | 264 | 'status' => $this->status, |
265 | 265 | ); |
266 | 266 | // Date query. |
267 | - if ( ! empty( $this->start ) || ! empty( $this->end ) ) { |
|
268 | - if ( ! empty( $this->start ) ) { |
|
269 | - $defaults['date_query'][0]['after'] = date( 'Y-n-d 00:00:00', strtotime( $this->start ) ); |
|
267 | + if ( ! empty($this->start) || ! empty($this->end)) { |
|
268 | + if ( ! empty($this->start)) { |
|
269 | + $defaults['date_query'][0]['after'] = date('Y-n-d 00:00:00', strtotime($this->start)); |
|
270 | 270 | } |
271 | - if ( ! empty( $this->end ) ) { |
|
272 | - $defaults['date_query'][0]['before'] = date( 'Y-n-d 00:00:00', strtotime( $this->end ) ); |
|
271 | + if ( ! empty($this->end)) { |
|
272 | + $defaults['date_query'][0]['before'] = date('Y-n-d 00:00:00', strtotime($this->end)); |
|
273 | 273 | } |
274 | 274 | } |
275 | 275 | |
276 | - if ( ! empty( $this->form_id ) ) { |
|
277 | - $defaults['give_forms'] = is_array( $this->form_id ) ? $this->form_id : array( $this->form_id ); |
|
276 | + if ( ! empty($this->form_id)) { |
|
277 | + $defaults['give_forms'] = is_array($this->form_id) ? $this->form_id : array($this->form_id); |
|
278 | 278 | } |
279 | 279 | |
280 | - return wp_parse_args( $args, $defaults ); |
|
280 | + return wp_parse_args($args, $defaults); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | /** |
@@ -297,119 +297,119 @@ discard block |
||
297 | 297 | $i = 0; |
298 | 298 | |
299 | 299 | // Payment query. |
300 | - $payments = give_get_payments( $this->get_donation_argument() ); |
|
300 | + $payments = give_get_payments($this->get_donation_argument()); |
|
301 | 301 | |
302 | - if ( $payments ) { |
|
302 | + if ($payments) { |
|
303 | 303 | |
304 | - foreach ( $payments as $payment ) { |
|
304 | + foreach ($payments as $payment) { |
|
305 | 305 | |
306 | 306 | $columns = $this->csv_cols(); |
307 | - $payment = new Give_Payment( $payment->ID ); |
|
307 | + $payment = new Give_Payment($payment->ID); |
|
308 | 308 | $payment_meta = $payment->payment_meta; |
309 | 309 | $address = $payment->address; |
310 | 310 | |
311 | 311 | // Set columns |
312 | - if ( ! empty( $columns['donation_id'] ) ) { |
|
313 | - $data[ $i ]['donation_id'] = $payment->ID; |
|
312 | + if ( ! empty($columns['donation_id'])) { |
|
313 | + $data[$i]['donation_id'] = $payment->ID; |
|
314 | 314 | } |
315 | 315 | |
316 | - if ( ! empty( $columns['seq_id'] ) ) { |
|
317 | - $data[ $i ]['seq_id'] = Give()->seq_donation_number->get_serial_code( $payment->ID ); |
|
316 | + if ( ! empty($columns['seq_id'])) { |
|
317 | + $data[$i]['seq_id'] = Give()->seq_donation_number->get_serial_code($payment->ID); |
|
318 | 318 | } |
319 | 319 | |
320 | - if ( ! empty( $columns['first_name'] ) ) { |
|
321 | - $data[ $i ]['first_name'] = isset( $payment->first_name ) ? $payment->first_name : ''; |
|
320 | + if ( ! empty($columns['first_name'])) { |
|
321 | + $data[$i]['first_name'] = isset($payment->first_name) ? $payment->first_name : ''; |
|
322 | 322 | } |
323 | 323 | |
324 | - if ( ! empty( $columns['last_name'] ) ) { |
|
325 | - $data[ $i ]['last_name'] = isset( $payment->last_name ) ? $payment->last_name : ''; |
|
324 | + if ( ! empty($columns['last_name'])) { |
|
325 | + $data[$i]['last_name'] = isset($payment->last_name) ? $payment->last_name : ''; |
|
326 | 326 | } |
327 | 327 | |
328 | - if ( ! empty( $columns['email'] ) ) { |
|
329 | - $data[ $i ]['email'] = $payment->email; |
|
328 | + if ( ! empty($columns['email'])) { |
|
329 | + $data[$i]['email'] = $payment->email; |
|
330 | 330 | } |
331 | 331 | |
332 | - if ( ! empty( $columns['company'] ) ) { |
|
333 | - $data[ $i ]['company'] = empty( $payment_meta['_give_donation_company'] ) ? '' : str_replace( "\'", "'", $payment_meta['_give_donation_company'] ); |
|
332 | + if ( ! empty($columns['company'])) { |
|
333 | + $data[$i]['company'] = empty($payment_meta['_give_donation_company']) ? '' : str_replace("\'", "'", $payment_meta['_give_donation_company']); |
|
334 | 334 | } |
335 | 335 | |
336 | - if ( ! empty( $columns['address_line1'] ) ) { |
|
337 | - $data[ $i ]['address_line1'] = isset( $address['line1'] ) ? $address['line1'] : ''; |
|
338 | - $data[ $i ]['address_line2'] = isset( $address['line2'] ) ? $address['line2'] : ''; |
|
339 | - $data[ $i ]['address_city'] = isset( $address['city'] ) ? $address['city'] : ''; |
|
340 | - $data[ $i ]['address_state'] = isset( $address['state'] ) ? $address['state'] : ''; |
|
341 | - $data[ $i ]['address_zip'] = isset( $address['zip'] ) ? $address['zip'] : ''; |
|
342 | - $data[ $i ]['address_country'] = isset( $address['country'] ) ? $address['country'] : ''; |
|
336 | + if ( ! empty($columns['address_line1'])) { |
|
337 | + $data[$i]['address_line1'] = isset($address['line1']) ? $address['line1'] : ''; |
|
338 | + $data[$i]['address_line2'] = isset($address['line2']) ? $address['line2'] : ''; |
|
339 | + $data[$i]['address_city'] = isset($address['city']) ? $address['city'] : ''; |
|
340 | + $data[$i]['address_state'] = isset($address['state']) ? $address['state'] : ''; |
|
341 | + $data[$i]['address_zip'] = isset($address['zip']) ? $address['zip'] : ''; |
|
342 | + $data[$i]['address_country'] = isset($address['country']) ? $address['country'] : ''; |
|
343 | 343 | } |
344 | 344 | |
345 | - if ( ! empty( $columns['donation_total'] ) ) { |
|
346 | - $data[ $i ]['donation_total'] = give_format_amount( give_donation_amount( $payment->ID ) ); |
|
345 | + if ( ! empty($columns['donation_total'])) { |
|
346 | + $data[$i]['donation_total'] = give_format_amount(give_donation_amount($payment->ID)); |
|
347 | 347 | } |
348 | 348 | |
349 | - if ( ! empty( $columns['currency_code'] ) ) { |
|
350 | - $data[ $i ]['currency_code'] = empty( $payment_meta['_give_payment_currency'] ) ? give_get_currency() : $payment_meta['_give_payment_currency']; |
|
349 | + if ( ! empty($columns['currency_code'])) { |
|
350 | + $data[$i]['currency_code'] = empty($payment_meta['_give_payment_currency']) ? give_get_currency() : $payment_meta['_give_payment_currency']; |
|
351 | 351 | } |
352 | 352 | |
353 | - if ( ! empty( $columns['currency_symbol'] ) ) { |
|
354 | - $currency_code = $data[ $i ]['currency_code']; |
|
355 | - $data[ $i ]['currency_symbol'] = give_currency_symbol( $currency_code, true ); |
|
353 | + if ( ! empty($columns['currency_symbol'])) { |
|
354 | + $currency_code = $data[$i]['currency_code']; |
|
355 | + $data[$i]['currency_symbol'] = give_currency_symbol($currency_code, true); |
|
356 | 356 | } |
357 | 357 | |
358 | - if ( ! empty( $columns['donation_status'] ) ) { |
|
359 | - $data[ $i ]['donation_status'] = give_get_payment_status( $payment, true ); |
|
358 | + if ( ! empty($columns['donation_status'])) { |
|
359 | + $data[$i]['donation_status'] = give_get_payment_status($payment, true); |
|
360 | 360 | } |
361 | 361 | |
362 | - if ( ! empty( $columns['payment_gateway'] ) ) { |
|
363 | - $data[ $i ]['payment_gateway'] = $payment->gateway; |
|
362 | + if ( ! empty($columns['payment_gateway'])) { |
|
363 | + $data[$i]['payment_gateway'] = $payment->gateway; |
|
364 | 364 | } |
365 | 365 | |
366 | - if ( ! empty( $columns['form_id'] ) ) { |
|
367 | - $data[ $i ]['form_id'] = $payment->form_id; |
|
366 | + if ( ! empty($columns['form_id'])) { |
|
367 | + $data[$i]['form_id'] = $payment->form_id; |
|
368 | 368 | } |
369 | 369 | |
370 | - if ( ! empty( $columns['form_title'] ) ) { |
|
371 | - $data[ $i ]['form_title'] = get_the_title( $payment->form_id ); |
|
370 | + if ( ! empty($columns['form_title'])) { |
|
371 | + $data[$i]['form_title'] = get_the_title($payment->form_id); |
|
372 | 372 | } |
373 | 373 | |
374 | - if ( ! empty( $columns['form_level_id'] ) ) { |
|
375 | - $data[ $i ]['form_level_id'] = $payment->price_id; |
|
374 | + if ( ! empty($columns['form_level_id'])) { |
|
375 | + $data[$i]['form_level_id'] = $payment->price_id; |
|
376 | 376 | } |
377 | 377 | |
378 | - if ( ! empty( $columns['form_level_title'] ) ) { |
|
379 | - $var_prices = give_has_variable_prices( $payment_meta['form_id'] ); |
|
380 | - if ( empty( $var_prices ) ) { |
|
381 | - $data[ $i ]['form_level_title'] = ''; |
|
378 | + if ( ! empty($columns['form_level_title'])) { |
|
379 | + $var_prices = give_has_variable_prices($payment_meta['form_id']); |
|
380 | + if (empty($var_prices)) { |
|
381 | + $data[$i]['form_level_title'] = ''; |
|
382 | 382 | } else { |
383 | 383 | $prices_atts = ''; |
384 | - if ( $variable_prices = give_get_variable_prices( $payment_meta['form_id'] ) ) { |
|
385 | - foreach ( $variable_prices as $variable_price ) { |
|
386 | - $prices_atts[ $variable_price['_give_id']['level_id'] ] = give_format_amount( $variable_price['_give_amount'] ); |
|
384 | + if ($variable_prices = give_get_variable_prices($payment_meta['form_id'])) { |
|
385 | + foreach ($variable_prices as $variable_price) { |
|
386 | + $prices_atts[$variable_price['_give_id']['level_id']] = give_format_amount($variable_price['_give_amount']); |
|
387 | 387 | } |
388 | 388 | } |
389 | - $data[ $i ]['form_level_title'] = give_get_price_option_name( $payment->form_id, $payment->price_id ); |
|
389 | + $data[$i]['form_level_title'] = give_get_price_option_name($payment->form_id, $payment->price_id); |
|
390 | 390 | } |
391 | 391 | } |
392 | 392 | |
393 | - if ( ! empty( $columns['donation_date'] ) ) { |
|
394 | - $payment_date = strtotime( $payment->date ); |
|
395 | - $data[ $i ]['donation_date'] = date( give_date_format(), $payment_date ); |
|
393 | + if ( ! empty($columns['donation_date'])) { |
|
394 | + $payment_date = strtotime($payment->date); |
|
395 | + $data[$i]['donation_date'] = date(give_date_format(), $payment_date); |
|
396 | 396 | } |
397 | 397 | |
398 | - if ( ! empty( $columns['donation_time'] ) ) { |
|
399 | - $payment_date = strtotime( $payment->date ); |
|
400 | - $data[ $i ]['donation_time'] = date_i18n( 'H', $payment_date ) . ':' . date( 'i', $payment_date ); |
|
398 | + if ( ! empty($columns['donation_time'])) { |
|
399 | + $payment_date = strtotime($payment->date); |
|
400 | + $data[$i]['donation_time'] = date_i18n('H', $payment_date).':'.date('i', $payment_date); |
|
401 | 401 | } |
402 | 402 | |
403 | - if ( ! empty( $columns['userid'] ) ) { |
|
404 | - $data[ $i ]['userid'] = $payment->user_id; |
|
403 | + if ( ! empty($columns['userid'])) { |
|
404 | + $data[$i]['userid'] = $payment->user_id; |
|
405 | 405 | } |
406 | 406 | |
407 | - if ( ! empty( $columns['donorid'] ) ) { |
|
408 | - $data[ $i ]['donorid'] = $payment->customer_id; |
|
407 | + if ( ! empty($columns['donorid'])) { |
|
408 | + $data[$i]['donorid'] = $payment->customer_id; |
|
409 | 409 | } |
410 | 410 | |
411 | - if ( ! empty( $columns['donor_ip'] ) ) { |
|
412 | - $data[ $i ]['donor_ip'] = give_get_payment_user_ip( $payment->ID ); |
|
411 | + if ( ! empty($columns['donor_ip'])) { |
|
412 | + $data[$i]['donor_ip'] = give_get_payment_user_ip($payment->ID); |
|
413 | 413 | } |
414 | 414 | |
415 | 415 | // Add custom field data. |
@@ -440,15 +440,15 @@ discard block |
||
440 | 440 | ); |
441 | 441 | |
442 | 442 | // Removing above keys... |
443 | - foreach ( $remove_keys as $key ) { |
|
444 | - unset( $columns[ $key ] ); |
|
443 | + foreach ($remove_keys as $key) { |
|
444 | + unset($columns[$key]); |
|
445 | 445 | } |
446 | 446 | |
447 | 447 | // Now loop through remaining meta fields. |
448 | - foreach ( $columns as $col ) { |
|
449 | - $field_data = get_post_meta( $payment->ID, $col, true ); |
|
450 | - $data[ $i ][ $col ] = $field_data; |
|
451 | - unset( $columns[ $col ] ); |
|
448 | + foreach ($columns as $col) { |
|
449 | + $field_data = get_post_meta($payment->ID, $col, true); |
|
450 | + $data[$i][$col] = $field_data; |
|
451 | + unset($columns[$col]); |
|
452 | 452 | } |
453 | 453 | |
454 | 454 | /** |
@@ -463,27 +463,27 @@ discard block |
||
463 | 463 | * |
464 | 464 | * @return array Donation data |
465 | 465 | */ |
466 | - $data[ $i ] = apply_filters( 'give_export_donation_data', $data[ $i ], $payment, $columns, $this ); |
|
466 | + $data[$i] = apply_filters('give_export_donation_data', $data[$i], $payment, $columns, $this); |
|
467 | 467 | |
468 | 468 | $new_data = array(); |
469 | - $old_data = $data[ $i ]; |
|
469 | + $old_data = $data[$i]; |
|
470 | 470 | |
471 | 471 | // sorting the columns bas on row |
472 | - foreach ( $this->csv_cols() as $key => $value ) { |
|
473 | - if ( array_key_exists( $key, $old_data ) ) { |
|
474 | - $new_data[ $key ] = $old_data[ $key ]; |
|
472 | + foreach ($this->csv_cols() as $key => $value) { |
|
473 | + if (array_key_exists($key, $old_data)) { |
|
474 | + $new_data[$key] = $old_data[$key]; |
|
475 | 475 | } |
476 | 476 | } |
477 | 477 | |
478 | - $data[ $i ] = $new_data; |
|
478 | + $data[$i] = $new_data; |
|
479 | 479 | |
480 | 480 | // Increment iterator. |
481 | - $i ++; |
|
481 | + $i++; |
|
482 | 482 | |
483 | 483 | } |
484 | 484 | |
485 | - $data = apply_filters( 'give_export_get_data', $data ); |
|
486 | - $data = apply_filters( "give_export_get_data_{$this->export_type}", $data ); |
|
485 | + $data = apply_filters('give_export_get_data', $data); |
|
486 | + $data = apply_filters("give_export_get_data_{$this->export_type}", $data); |
|
487 | 487 | |
488 | 488 | return $data; |
489 | 489 | |
@@ -501,17 +501,17 @@ discard block |
||
501 | 501 | * @return int |
502 | 502 | */ |
503 | 503 | public function get_percentage_complete() { |
504 | - $args = $this->get_donation_argument( array( 'number' => - 1 ) ); |
|
505 | - if ( isset( $args['page'] ) ) { |
|
506 | - unset( $args['page'] ); |
|
504 | + $args = $this->get_donation_argument(array('number' => -1)); |
|
505 | + if (isset($args['page'])) { |
|
506 | + unset($args['page']); |
|
507 | 507 | } |
508 | - $query = give_get_payments( $args ); |
|
509 | - $total = count( $query ); |
|
508 | + $query = give_get_payments($args); |
|
509 | + $total = count($query); |
|
510 | 510 | $percentage = 100; |
511 | - if ( $total > 0 ) { |
|
512 | - $percentage = ( ( 30 * $this->step ) / $total ) * 100; |
|
511 | + if ($total > 0) { |
|
512 | + $percentage = ((30 * $this->step) / $total) * 100; |
|
513 | 513 | } |
514 | - if ( $percentage > 100 ) { |
|
514 | + if ($percentage > 100) { |
|
515 | 515 | $percentage = 100; |
516 | 516 | } |
517 | 517 | |
@@ -533,23 +533,23 @@ discard block |
||
533 | 533 | $data = $this->get_data(); |
534 | 534 | $cols = $this->get_csv_cols(); |
535 | 535 | |
536 | - if ( $data ) { |
|
536 | + if ($data) { |
|
537 | 537 | |
538 | 538 | // Output each row |
539 | - foreach ( $data as $row ) { |
|
539 | + foreach ($data as $row) { |
|
540 | 540 | $i = 1; |
541 | - foreach ( $row as $col_id => $column ) { |
|
541 | + foreach ($row as $col_id => $column) { |
|
542 | 542 | // Make sure the column is valid |
543 | - if ( array_key_exists( $col_id, $cols ) ) { |
|
544 | - $row_data .= '"' . preg_replace( '/"/', "'", $column ) . '"'; |
|
545 | - $row_data .= $i == count( $cols ) ? '' : ','; |
|
546 | - $i ++; |
|
543 | + if (array_key_exists($col_id, $cols)) { |
|
544 | + $row_data .= '"'.preg_replace('/"/', "'", $column).'"'; |
|
545 | + $row_data .= $i == count($cols) ? '' : ','; |
|
546 | + $i++; |
|
547 | 547 | } |
548 | 548 | } |
549 | 549 | $row_data .= "\r\n"; |
550 | 550 | } |
551 | 551 | |
552 | - $this->stash_step_data( $row_data ); |
|
552 | + $this->stash_step_data($row_data); |
|
553 | 553 | |
554 | 554 | return $row_data; |
555 | 555 | } |