@@ -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 | /** |
@@ -120,37 +120,37 @@ discard block |
||
120 | 120 | global $status, $page; |
121 | 121 | |
122 | 122 | // Set parent defaults |
123 | - parent::__construct( array( |
|
124 | - 'singular' => give_get_forms_label_singular(), // Singular name of the listed records |
|
125 | - 'plural' => give_get_forms_label_plural(), // Plural name of the listed records |
|
123 | + parent::__construct(array( |
|
124 | + 'singular' => give_get_forms_label_singular(), // Singular name of the listed records |
|
125 | + 'plural' => give_get_forms_label_plural(), // Plural name of the listed records |
|
126 | 126 | 'ajax' => false // Does this table support ajax? |
127 | - ) ); |
|
127 | + )); |
|
128 | 128 | |
129 | 129 | $this->get_payment_counts(); |
130 | 130 | $this->process_bulk_action(); |
131 | - $this->base_url = admin_url( 'edit.php?post_type=give_forms&page=give-payment-history' ); |
|
131 | + $this->base_url = admin_url('edit.php?post_type=give_forms&page=give-payment-history'); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | public function advanced_filters() { |
135 | - $start_date = isset( $_GET['start-date'] ) ? sanitize_text_field( $_GET['start-date'] ) : null; |
|
136 | - $end_date = isset( $_GET['end-date'] ) ? sanitize_text_field( $_GET['end-date'] ) : null; |
|
137 | - $status = isset( $_GET['status'] ) ? $_GET['status'] : ''; |
|
135 | + $start_date = isset($_GET['start-date']) ? sanitize_text_field($_GET['start-date']) : null; |
|
136 | + $end_date = isset($_GET['end-date']) ? sanitize_text_field($_GET['end-date']) : null; |
|
137 | + $status = isset($_GET['status']) ? $_GET['status'] : ''; |
|
138 | 138 | ?> |
139 | 139 | <div id="give-payment-filters"> |
140 | 140 | <span id="give-payment-date-filters"> |
141 | - <label for="start-date" class="give-start-date-label"><?php _e( 'Start Date:', 'give' ); ?></label> |
|
141 | + <label for="start-date" class="give-start-date-label"><?php _e('Start Date:', 'give'); ?></label> |
|
142 | 142 | <input type="text" id="start-date" name="start-date" class="give_datepicker" value="<?php echo $start_date; ?>" placeholder="mm/dd/yyyy"/> |
143 | - <label for="end-date" class="give-end-date-label"><?php _e( 'End Date:', 'give' ); ?></label> |
|
143 | + <label for="end-date" class="give-end-date-label"><?php _e('End Date:', 'give'); ?></label> |
|
144 | 144 | <input type="text" id="end-date" name="end-date" class="give_datepicker" value="<?php echo $end_date; ?>" placeholder="mm/dd/yyyy"/> |
145 | - <input type="submit" class="button-secondary" value="<?php _e( 'Apply', 'give' ); ?>"/> |
|
145 | + <input type="submit" class="button-secondary" value="<?php _e('Apply', 'give'); ?>"/> |
|
146 | 146 | </span> |
147 | - <?php if ( ! empty( $status ) ) : ?> |
|
148 | - <input type="hidden" name="status" value="<?php echo esc_attr( $status ); ?>"/> |
|
147 | + <?php if ( ! empty($status)) : ?> |
|
148 | + <input type="hidden" name="status" value="<?php echo esc_attr($status); ?>"/> |
|
149 | 149 | <?php endif; ?> |
150 | - <?php if ( ! empty( $start_date ) || ! empty( $end_date ) ) : ?> |
|
151 | - <a href="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-payment-history' ); ?>" class="button-secondary"><?php _e( 'Clear Filter', 'give' ); ?></a> |
|
150 | + <?php if ( ! empty($start_date) || ! empty($end_date)) : ?> |
|
151 | + <a href="<?php echo admin_url('edit.php?post_type=give_forms&page=give-payment-history'); ?>" class="button-secondary"><?php _e('Clear Filter', 'give'); ?></a> |
|
152 | 152 | <?php endif; ?> |
153 | - <?php $this->search_box( __( 'Search', 'give' ), 'give-payments' ); ?> |
|
153 | + <?php $this->search_box(__('Search', 'give'), 'give-payments'); ?> |
|
154 | 154 | </div> |
155 | 155 | |
156 | 156 | <?php |
@@ -167,25 +167,25 @@ discard block |
||
167 | 167 | * |
168 | 168 | * @return void |
169 | 169 | */ |
170 | - public function search_box( $text, $input_id ) { |
|
171 | - if ( empty( $_REQUEST['s'] ) && ! $this->has_items() ) { |
|
170 | + public function search_box($text, $input_id) { |
|
171 | + if (empty($_REQUEST['s']) && ! $this->has_items()) { |
|
172 | 172 | return; |
173 | 173 | } |
174 | 174 | |
175 | - $input_id = $input_id . '-search-input'; |
|
175 | + $input_id = $input_id.'-search-input'; |
|
176 | 176 | |
177 | - if ( ! empty( $_REQUEST['orderby'] ) ) { |
|
178 | - echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />'; |
|
177 | + if ( ! empty($_REQUEST['orderby'])) { |
|
178 | + echo '<input type="hidden" name="orderby" value="'.esc_attr($_REQUEST['orderby']).'" />'; |
|
179 | 179 | } |
180 | - if ( ! empty( $_REQUEST['order'] ) ) { |
|
181 | - echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />'; |
|
180 | + if ( ! empty($_REQUEST['order'])) { |
|
181 | + echo '<input type="hidden" name="order" value="'.esc_attr($_REQUEST['order']).'" />'; |
|
182 | 182 | } |
183 | 183 | ?> |
184 | 184 | <p class="search-box"> |
185 | - <?php do_action( 'give_payment_history_search' ); ?> |
|
185 | + <?php do_action('give_payment_history_search'); ?> |
|
186 | 186 | <label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label> |
187 | 187 | <input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>"/> |
188 | - <?php submit_button( $text, 'button', false, false, array( 'ID' => 'search-submit' ) ); ?><br/> |
|
188 | + <?php submit_button($text, 'button', false, false, array('ID' => 'search-submit')); ?><br/> |
|
189 | 189 | </p> |
190 | 190 | <?php |
191 | 191 | } |
@@ -199,52 +199,52 @@ discard block |
||
199 | 199 | */ |
200 | 200 | public function get_views() { |
201 | 201 | |
202 | - $current = isset( $_GET['status'] ) ? $_GET['status'] : ''; |
|
203 | - $total_count = ' <span class="count">(' . $this->total_count . ')</span>'; |
|
204 | - $complete_count = ' <span class="count">(' . $this->complete_count . ')</span>'; |
|
205 | - $cancelled_count = ' <span class="count">(' . $this->cancelled_count . ')</span>'; |
|
206 | - $pending_count = ' <span class="count">(' . $this->pending_count . ')</span>'; |
|
207 | - $refunded_count = ' <span class="count">(' . $this->refunded_count . ')</span>'; |
|
208 | - $failed_count = ' <span class="count">(' . $this->failed_count . ')</span>'; |
|
209 | - $abandoned_count = ' <span class="count">(' . $this->abandoned_count . ')</span>'; |
|
210 | - $revoked_count = ' <span class="count">(' . $this->revoked_count . ')</span>'; |
|
202 | + $current = isset($_GET['status']) ? $_GET['status'] : ''; |
|
203 | + $total_count = ' <span class="count">('.$this->total_count.')</span>'; |
|
204 | + $complete_count = ' <span class="count">('.$this->complete_count.')</span>'; |
|
205 | + $cancelled_count = ' <span class="count">('.$this->cancelled_count.')</span>'; |
|
206 | + $pending_count = ' <span class="count">('.$this->pending_count.')</span>'; |
|
207 | + $refunded_count = ' <span class="count">('.$this->refunded_count.')</span>'; |
|
208 | + $failed_count = ' <span class="count">('.$this->failed_count.')</span>'; |
|
209 | + $abandoned_count = ' <span class="count">('.$this->abandoned_count.')</span>'; |
|
210 | + $revoked_count = ' <span class="count">('.$this->revoked_count.')</span>'; |
|
211 | 211 | |
212 | 212 | $views = array( |
213 | - 'all' => sprintf( '<a href="%s"%s>%s</a>', remove_query_arg( array( |
|
213 | + 'all' => sprintf('<a href="%s"%s>%s</a>', remove_query_arg(array( |
|
214 | 214 | 'status', |
215 | 215 | 'paged' |
216 | - ) ), $current === 'all' || $current == '' ? ' class="current"' : '', __( 'All', 'give' ) . $total_count ), |
|
217 | - 'publish' => sprintf( '<a href="%s"%s>%s</a>', esc_url( add_query_arg( array( |
|
216 | + )), $current === 'all' || $current == '' ? ' class="current"' : '', __('All', 'give').$total_count), |
|
217 | + 'publish' => sprintf('<a href="%s"%s>%s</a>', esc_url(add_query_arg(array( |
|
218 | 218 | 'status' => 'publish', |
219 | 219 | 'paged' => false |
220 | - ) ) ), $current === 'publish' ? ' class="current"' : '', __( 'Completed', 'give' ) . $complete_count ), |
|
221 | - 'pending' => sprintf( '<a href="%s"%s>%s</a>', esc_url( add_query_arg( array( |
|
220 | + ))), $current === 'publish' ? ' class="current"' : '', __('Completed', 'give').$complete_count), |
|
221 | + 'pending' => sprintf('<a href="%s"%s>%s</a>', esc_url(add_query_arg(array( |
|
222 | 222 | 'status' => 'pending', |
223 | 223 | 'paged' => false |
224 | - ) ) ), $current === 'pending' ? ' class="current"' : '', __( 'Pending', 'give' ) . $pending_count ), |
|
225 | - 'refunded' => sprintf( '<a href="%s"%s>%s</a>', esc_url( add_query_arg( array( |
|
224 | + ))), $current === 'pending' ? ' class="current"' : '', __('Pending', 'give').$pending_count), |
|
225 | + 'refunded' => sprintf('<a href="%s"%s>%s</a>', esc_url(add_query_arg(array( |
|
226 | 226 | 'status' => 'refunded', |
227 | 227 | 'paged' => false |
228 | - ) ) ), $current === 'refunded' ? ' class="current"' : '', __( 'Refunded', 'give' ) . $refunded_count ), |
|
229 | - 'revoked' => sprintf( '<a href="%s"%s>%s</a>', esc_url( add_query_arg( array( |
|
228 | + ))), $current === 'refunded' ? ' class="current"' : '', __('Refunded', 'give').$refunded_count), |
|
229 | + 'revoked' => sprintf('<a href="%s"%s>%s</a>', esc_url(add_query_arg(array( |
|
230 | 230 | 'status' => 'revoked', |
231 | 231 | 'paged' => false |
232 | - ) ) ), $current === 'revoked' ? ' class="current"' : '', __( 'Revoked', 'give' ) . $revoked_count ), |
|
233 | - 'failed' => sprintf( '<a href="%s"%s>%s</a>', esc_url( add_query_arg( array( |
|
232 | + ))), $current === 'revoked' ? ' class="current"' : '', __('Revoked', 'give').$revoked_count), |
|
233 | + 'failed' => sprintf('<a href="%s"%s>%s</a>', esc_url(add_query_arg(array( |
|
234 | 234 | 'status' => 'failed', |
235 | 235 | 'paged' => false |
236 | - ) ) ), $current === 'failed' ? ' class="current"' : '', __( 'Failed', 'give' ) . $failed_count ), |
|
237 | - 'cancelled' => sprintf( '<a href="%s"%s>%s</a>', esc_url( add_query_arg( array( |
|
236 | + ))), $current === 'failed' ? ' class="current"' : '', __('Failed', 'give').$failed_count), |
|
237 | + 'cancelled' => sprintf('<a href="%s"%s>%s</a>', esc_url(add_query_arg(array( |
|
238 | 238 | 'status' => 'cancelled', |
239 | 239 | 'paged' => false |
240 | - ) ) ), $current === 'cancelled' ? ' class="current"' : '', __( 'Cancelled', 'give' ) . $cancelled_count ), |
|
241 | - 'abandoned' => sprintf( '<a href="%s"%s>%s</a>', esc_url( add_query_arg( array( |
|
240 | + ))), $current === 'cancelled' ? ' class="current"' : '', __('Cancelled', 'give').$cancelled_count), |
|
241 | + 'abandoned' => sprintf('<a href="%s"%s>%s</a>', esc_url(add_query_arg(array( |
|
242 | 242 | 'status' => 'abandoned', |
243 | 243 | 'paged' => false |
244 | - ) ) ), $current === 'abandoned' ? ' class="current"' : '', __( 'Abandoned', 'give' ) . $abandoned_count ) |
|
244 | + ))), $current === 'abandoned' ? ' class="current"' : '', __('Abandoned', 'give').$abandoned_count) |
|
245 | 245 | ); |
246 | 246 | |
247 | - return apply_filters( 'give_payments_table_views', $views ); |
|
247 | + return apply_filters('give_payments_table_views', $views); |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | /** |
@@ -257,17 +257,17 @@ discard block |
||
257 | 257 | public function get_columns() { |
258 | 258 | $columns = array( |
259 | 259 | 'cb' => '<input type="checkbox" />', //Render a checkbox instead of text |
260 | - 'email' => __( 'Email', 'give' ), |
|
261 | - 'details' => __( 'Details', 'give' ), |
|
262 | - 'amount' => __( 'Amount', 'give' ), |
|
263 | - 'donation' => __( 'Donation', 'give' ), |
|
264 | - 'status' => __( 'Status', 'give' ), |
|
265 | - 'date' => __( 'Date', 'give' ), |
|
266 | - 'donor' => __( 'Donor', 'give' ), |
|
267 | - 'ID' => __( 'ID', 'give' ), |
|
260 | + 'email' => __('Email', 'give'), |
|
261 | + 'details' => __('Details', 'give'), |
|
262 | + 'amount' => __('Amount', 'give'), |
|
263 | + 'donation' => __('Donation', 'give'), |
|
264 | + 'status' => __('Status', 'give'), |
|
265 | + 'date' => __('Date', 'give'), |
|
266 | + 'donor' => __('Donor', 'give'), |
|
267 | + 'ID' => __('ID', 'give'), |
|
268 | 268 | ); |
269 | 269 | |
270 | - return apply_filters( 'give_payments_table_columns', $columns ); |
|
270 | + return apply_filters('give_payments_table_columns', $columns); |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | /** |
@@ -279,12 +279,12 @@ discard block |
||
279 | 279 | */ |
280 | 280 | public function get_sortable_columns() { |
281 | 281 | $columns = array( |
282 | - 'ID' => array( 'ID', true ), |
|
283 | - 'amount' => array( 'amount', false ), |
|
284 | - 'date' => array( 'date', false ) |
|
282 | + 'ID' => array('ID', true), |
|
283 | + 'amount' => array('amount', false), |
|
284 | + 'date' => array('date', false) |
|
285 | 285 | ); |
286 | 286 | |
287 | - return apply_filters( 'give_payments_table_sortable_columns', $columns ); |
|
287 | + return apply_filters('give_payments_table_sortable_columns', $columns); |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | /** |
@@ -310,41 +310,41 @@ discard block |
||
310 | 310 | * |
311 | 311 | * @return string Column Name |
312 | 312 | */ |
313 | - public function column_default( $payment, $column_name ) { |
|
314 | - switch ( $column_name ) { |
|
313 | + public function column_default($payment, $column_name) { |
|
314 | + switch ($column_name) { |
|
315 | 315 | case 'amount' : |
316 | - $amount = ! empty( $payment->total ) ? $payment->total : 0; |
|
317 | - $value = give_currency_filter( give_format_amount( $amount ), give_get_payment_currency_code( $payment->ID ) ); |
|
316 | + $amount = ! empty($payment->total) ? $payment->total : 0; |
|
317 | + $value = give_currency_filter(give_format_amount($amount), give_get_payment_currency_code($payment->ID)); |
|
318 | 318 | break; |
319 | 319 | case 'donation' : |
320 | - $value = '<a href="' . get_permalink( $payment->form_id ) . '">' . $payment->form_title . '</a>'; |
|
321 | - $level = give_get_payment_form_title( $payment->meta, true ); |
|
320 | + $value = '<a href="'.get_permalink($payment->form_id).'">'.$payment->form_title.'</a>'; |
|
321 | + $level = give_get_payment_form_title($payment->meta, true); |
|
322 | 322 | |
323 | - if ( ! empty( $level ) ) { |
|
323 | + if ( ! empty($level)) { |
|
324 | 324 | $value .= $level; |
325 | 325 | } |
326 | 326 | |
327 | 327 | break; |
328 | 328 | case 'date' : |
329 | - $date = strtotime( $payment->date ); |
|
330 | - $value = date_i18n( get_option( 'date_format' ), $date ); |
|
329 | + $date = strtotime($payment->date); |
|
330 | + $value = date_i18n(get_option('date_format'), $date); |
|
331 | 331 | break; |
332 | 332 | case 'status' : |
333 | - $value = '<div class="give-donation-status status-' . sanitize_title( give_get_payment_status( $payment, true ) ) . '"><span class="give-donation-status-icon"></span> ' . give_get_payment_status( $payment, true ) . '</div>'; |
|
334 | - if ( $payment->mode == 'test' ) { |
|
335 | - $value .= ' <span class="give-item-label give-item-label-orange give-test-mode-transactions-label" data-tooltip="' . __( 'This payment was made in test mode', 'give' ) . '">' . __( 'Test', 'give' ) . '</span>'; |
|
333 | + $value = '<div class="give-donation-status status-'.sanitize_title(give_get_payment_status($payment, true)).'"><span class="give-donation-status-icon"></span> '.give_get_payment_status($payment, true).'</div>'; |
|
334 | + if ($payment->mode == 'test') { |
|
335 | + $value .= ' <span class="give-item-label give-item-label-orange give-test-mode-transactions-label" data-tooltip="'.__('This payment was made in test mode', 'give').'">'.__('Test', 'give').'</span>'; |
|
336 | 336 | } |
337 | 337 | break; |
338 | 338 | case 'details' : |
339 | - $value = '<div class="give-payment-details-link-wrap"><a href="' . esc_url( add_query_arg( 'id', $payment->ID, admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details' ) ) ) . '" class="give-payment-details-link button button-small">' . __( 'View Details', 'give' ) . '</a></div>'; |
|
339 | + $value = '<div class="give-payment-details-link-wrap"><a href="'.esc_url(add_query_arg('id', $payment->ID, admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details'))).'" class="give-payment-details-link button button-small">'.__('View Details', 'give').'</a></div>'; |
|
340 | 340 | break; |
341 | 341 | default: |
342 | - $value = isset( $payment->$column_name ) ? $payment->$column_name : ''; |
|
342 | + $value = isset($payment->$column_name) ? $payment->$column_name : ''; |
|
343 | 343 | break; |
344 | 344 | |
345 | 345 | } |
346 | 346 | |
347 | - return apply_filters( 'give_payments_table_column', $value, $payment->ID, $column_name ); |
|
347 | + return apply_filters('give_payments_table_column', $value, $payment->ID, $column_name); |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | /** |
@@ -357,40 +357,40 @@ discard block |
||
357 | 357 | * |
358 | 358 | * @return string Data shown in the Email column |
359 | 359 | */ |
360 | - public function column_email( $payment ) { |
|
360 | + public function column_email($payment) { |
|
361 | 361 | |
362 | 362 | $row_actions = array(); |
363 | 363 | |
364 | - $email = give_get_payment_user_email( $payment->ID ); |
|
364 | + $email = give_get_payment_user_email($payment->ID); |
|
365 | 365 | |
366 | 366 | // Add search term string back to base URL |
367 | - $search_terms = ( isset( $_GET['s'] ) ? trim( $_GET['s'] ) : '' ); |
|
368 | - if ( ! empty( $search_terms ) ) { |
|
369 | - $this->base_url = add_query_arg( 's', $search_terms, $this->base_url ); |
|
367 | + $search_terms = (isset($_GET['s']) ? trim($_GET['s']) : ''); |
|
368 | + if ( ! empty($search_terms)) { |
|
369 | + $this->base_url = add_query_arg('s', $search_terms, $this->base_url); |
|
370 | 370 | } |
371 | 371 | |
372 | - if ( give_is_payment_complete( $payment->ID ) && ! empty( $email ) ) { |
|
373 | - $row_actions['email_links'] = '<a href="' . add_query_arg( array( |
|
372 | + if (give_is_payment_complete($payment->ID) && ! empty($email)) { |
|
373 | + $row_actions['email_links'] = '<a href="'.add_query_arg(array( |
|
374 | 374 | 'give-action' => 'email_links', |
375 | 375 | 'purchase_id' => $payment->ID |
376 | - ), $this->base_url ) . '">' . __( 'Resend Donation Receipt', 'give' ) . '</a>'; |
|
376 | + ), $this->base_url).'">'.__('Resend Donation Receipt', 'give').'</a>'; |
|
377 | 377 | |
378 | 378 | } |
379 | 379 | |
380 | - $row_actions['delete'] = '<a href="' . wp_nonce_url( add_query_arg( array( |
|
380 | + $row_actions['delete'] = '<a href="'.wp_nonce_url(add_query_arg(array( |
|
381 | 381 | 'give-action' => 'delete_payment', |
382 | 382 | 'purchase_id' => $payment->ID |
383 | - ), $this->base_url ), 'give_payment_nonce' ) . '">' . __( 'Delete', 'give' ) . '</a>'; |
|
383 | + ), $this->base_url), 'give_payment_nonce').'">'.__('Delete', 'give').'</a>'; |
|
384 | 384 | |
385 | - $row_actions = apply_filters( 'give_payment_row_actions', $row_actions, $payment ); |
|
385 | + $row_actions = apply_filters('give_payment_row_actions', $row_actions, $payment); |
|
386 | 386 | |
387 | - if ( empty( $email ) ) { |
|
388 | - $email = __( '(unknown)', 'give' ); |
|
387 | + if (empty($email)) { |
|
388 | + $email = __('(unknown)', 'give'); |
|
389 | 389 | } |
390 | 390 | |
391 | - $value = '<span class="give-email-column-value">' . $email . '</span>' . $this->row_actions( $row_actions ); |
|
391 | + $value = '<span class="give-email-column-value">'.$email.'</span>'.$this->row_actions($row_actions); |
|
392 | 392 | |
393 | - return apply_filters( 'give_payments_table_column', $value, $payment->ID, 'email' ); |
|
393 | + return apply_filters('give_payments_table_column', $value, $payment->ID, 'email'); |
|
394 | 394 | } |
395 | 395 | |
396 | 396 | /** |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | * |
404 | 404 | * @return string Displays a checkbox |
405 | 405 | */ |
406 | - public function column_cb( $payment ) { |
|
406 | + public function column_cb($payment) { |
|
407 | 407 | return sprintf( |
408 | 408 | '<input type="checkbox" name="%1$s[]" value="%2$s" />', |
409 | 409 | 'payment', |
@@ -421,8 +421,8 @@ discard block |
||
421 | 421 | * |
422 | 422 | * @return string Displays a checkbox |
423 | 423 | */ |
424 | - public function column_ID( $payment ) { |
|
425 | - return '<span class="give-payment-id">' . give_get_payment_number( $payment->ID ) . '</span>'; |
|
424 | + public function column_ID($payment) { |
|
425 | + return '<span class="give-payment-id">'.give_get_payment_number($payment->ID).'</span>'; |
|
426 | 426 | } |
427 | 427 | |
428 | 428 | /** |
@@ -435,19 +435,19 @@ discard block |
||
435 | 435 | * |
436 | 436 | * @return string Data shown in the User column |
437 | 437 | */ |
438 | - public function column_donor( $payment ) { |
|
438 | + public function column_donor($payment) { |
|
439 | 439 | |
440 | - $customer_id = give_get_payment_customer_id( $payment->ID ); |
|
440 | + $customer_id = give_get_payment_customer_id($payment->ID); |
|
441 | 441 | |
442 | - if ( ! empty( $customer_id ) ) { |
|
443 | - $customer = new Give_Customer( $customer_id ); |
|
444 | - $value = '<a href="' . esc_url( admin_url( "edit.php?post_type=give_forms&page=give-donors&view=overview&id=$customer_id" ) ) . '">' . $customer->name . '</a>'; |
|
442 | + if ( ! empty($customer_id)) { |
|
443 | + $customer = new Give_Customer($customer_id); |
|
444 | + $value = '<a href="'.esc_url(admin_url("edit.php?post_type=give_forms&page=give-donors&view=overview&id=$customer_id")).'">'.$customer->name.'</a>'; |
|
445 | 445 | } else { |
446 | - $email = give_get_payment_user_email( $payment->ID ); |
|
447 | - $value = '<a href="' . esc_url( admin_url( "edit.php?post_type=give_forms&page=give-payment-history&s=$email" ) ) . '">' . __( '(donor missing)', 'give' ) . '</a>'; |
|
446 | + $email = give_get_payment_user_email($payment->ID); |
|
447 | + $value = '<a href="'.esc_url(admin_url("edit.php?post_type=give_forms&page=give-payment-history&s=$email")).'">'.__('(donor missing)', 'give').'</a>'; |
|
448 | 448 | } |
449 | 449 | |
450 | - return apply_filters( 'give_payments_table_column', $value, $payment->ID, 'donor' ); |
|
450 | + return apply_filters('give_payments_table_column', $value, $payment->ID, 'donor'); |
|
451 | 451 | } |
452 | 452 | |
453 | 453 | /** |
@@ -459,18 +459,18 @@ discard block |
||
459 | 459 | */ |
460 | 460 | public function get_bulk_actions() { |
461 | 461 | $actions = array( |
462 | - 'delete' => __( 'Delete', 'give' ), |
|
463 | - 'set-status-publish' => __( 'Set To Completed', 'give' ), |
|
464 | - 'set-status-pending' => __( 'Set To Pending', 'give' ), |
|
465 | - 'set-status-refunded' => __( 'Set To Refunded', 'give' ), |
|
466 | - 'set-status-revoked' => __( 'Set To Revoked', 'give' ), |
|
467 | - 'set-status-failed' => __( 'Set To Failed', 'give' ), |
|
468 | - 'set-status-cancelled' => __( 'Set To Cancelled', 'give' ), |
|
469 | - 'set-status-abandoned' => __( 'Set To Abandoned', 'give' ), |
|
470 | - 'resend-receipt' => __( 'Resend Email Receipts', 'give' ) |
|
462 | + 'delete' => __('Delete', 'give'), |
|
463 | + 'set-status-publish' => __('Set To Completed', 'give'), |
|
464 | + 'set-status-pending' => __('Set To Pending', 'give'), |
|
465 | + 'set-status-refunded' => __('Set To Refunded', 'give'), |
|
466 | + 'set-status-revoked' => __('Set To Revoked', 'give'), |
|
467 | + 'set-status-failed' => __('Set To Failed', 'give'), |
|
468 | + 'set-status-cancelled' => __('Set To Cancelled', 'give'), |
|
469 | + 'set-status-abandoned' => __('Set To Abandoned', 'give'), |
|
470 | + 'resend-receipt' => __('Resend Email Receipts', 'give') |
|
471 | 471 | ); |
472 | 472 | |
473 | - return apply_filters( 'give_payments_table_bulk_actions', $actions ); |
|
473 | + return apply_filters('give_payments_table_bulk_actions', $actions); |
|
474 | 474 | } |
475 | 475 | |
476 | 476 | /** |
@@ -481,61 +481,61 @@ discard block |
||
481 | 481 | * @return void |
482 | 482 | */ |
483 | 483 | public function process_bulk_action() { |
484 | - $ids = isset( $_GET['payment'] ) ? $_GET['payment'] : false; |
|
484 | + $ids = isset($_GET['payment']) ? $_GET['payment'] : false; |
|
485 | 485 | $action = $this->current_action(); |
486 | 486 | |
487 | - if ( ! is_array( $ids ) ) { |
|
488 | - $ids = array( $ids ); |
|
487 | + if ( ! is_array($ids)) { |
|
488 | + $ids = array($ids); |
|
489 | 489 | } |
490 | 490 | |
491 | - if ( empty( $action ) ) { |
|
491 | + if (empty($action)) { |
|
492 | 492 | return; |
493 | 493 | } |
494 | 494 | |
495 | - foreach ( $ids as $id ) { |
|
495 | + foreach ($ids as $id) { |
|
496 | 496 | |
497 | 497 | // Detect when a bulk action is being triggered... |
498 | - if ( 'delete' === $this->current_action() ) { |
|
499 | - give_delete_purchase( $id ); |
|
498 | + if ('delete' === $this->current_action()) { |
|
499 | + give_delete_purchase($id); |
|
500 | 500 | } |
501 | 501 | |
502 | - if ( 'set-status-publish' === $this->current_action() ) { |
|
503 | - give_update_payment_status( $id, 'publish' ); |
|
502 | + if ('set-status-publish' === $this->current_action()) { |
|
503 | + give_update_payment_status($id, 'publish'); |
|
504 | 504 | } |
505 | 505 | |
506 | - if ( 'set-status-pending' === $this->current_action() ) { |
|
507 | - give_update_payment_status( $id, 'pending' ); |
|
506 | + if ('set-status-pending' === $this->current_action()) { |
|
507 | + give_update_payment_status($id, 'pending'); |
|
508 | 508 | } |
509 | 509 | |
510 | - if ( 'set-status-refunded' === $this->current_action() ) { |
|
511 | - give_update_payment_status( $id, 'refunded' ); |
|
510 | + if ('set-status-refunded' === $this->current_action()) { |
|
511 | + give_update_payment_status($id, 'refunded'); |
|
512 | 512 | } |
513 | 513 | |
514 | - if ( 'set-status-revoked' === $this->current_action() ) { |
|
515 | - give_update_payment_status( $id, 'revoked' ); |
|
514 | + if ('set-status-revoked' === $this->current_action()) { |
|
515 | + give_update_payment_status($id, 'revoked'); |
|
516 | 516 | } |
517 | 517 | |
518 | - if ( 'set-status-failed' === $this->current_action() ) { |
|
519 | - give_update_payment_status( $id, 'failed' ); |
|
518 | + if ('set-status-failed' === $this->current_action()) { |
|
519 | + give_update_payment_status($id, 'failed'); |
|
520 | 520 | } |
521 | 521 | |
522 | - if ( 'set-status-cancelled' === $this->current_action() ) { |
|
523 | - give_update_payment_status( $id, 'cancelled' ); |
|
522 | + if ('set-status-cancelled' === $this->current_action()) { |
|
523 | + give_update_payment_status($id, 'cancelled'); |
|
524 | 524 | } |
525 | 525 | |
526 | - if ( 'set-status-abandoned' === $this->current_action() ) { |
|
527 | - give_update_payment_status( $id, 'abandoned' ); |
|
526 | + if ('set-status-abandoned' === $this->current_action()) { |
|
527 | + give_update_payment_status($id, 'abandoned'); |
|
528 | 528 | } |
529 | 529 | |
530 | - if ( 'set-status-preapproval' === $this->current_action() ) { |
|
531 | - give_update_payment_status( $id, 'preapproval' ); |
|
530 | + if ('set-status-preapproval' === $this->current_action()) { |
|
531 | + give_update_payment_status($id, 'preapproval'); |
|
532 | 532 | } |
533 | 533 | |
534 | - if ( 'resend-receipt' === $this->current_action() ) { |
|
535 | - give_email_donation_receipt( $id, false ); |
|
534 | + if ('resend-receipt' === $this->current_action()) { |
|
535 | + give_email_donation_receipt($id, false); |
|
536 | 536 | } |
537 | 537 | |
538 | - do_action( 'give_payments_table_do_bulk_action', $id, $this->current_action() ); |
|
538 | + do_action('give_payments_table_do_bulk_action', $id, $this->current_action()); |
|
539 | 539 | } |
540 | 540 | |
541 | 541 | } |
@@ -553,27 +553,27 @@ discard block |
||
553 | 553 | |
554 | 554 | $args = array(); |
555 | 555 | |
556 | - if ( isset( $_GET['user'] ) ) { |
|
557 | - $args['user'] = urldecode( $_GET['user'] ); |
|
558 | - } elseif ( isset( $_GET['s'] ) ) { |
|
559 | - $is_user = strpos( $_GET['s'], strtolower( 'user:' ) ) !== false; |
|
560 | - if ( $is_user ) { |
|
561 | - $args['user'] = absint( trim( str_replace( 'user:', '', strtolower( $_GET['s'] ) ) ) ); |
|
562 | - unset( $args['s'] ); |
|
556 | + if (isset($_GET['user'])) { |
|
557 | + $args['user'] = urldecode($_GET['user']); |
|
558 | + } elseif (isset($_GET['s'])) { |
|
559 | + $is_user = strpos($_GET['s'], strtolower('user:')) !== false; |
|
560 | + if ($is_user) { |
|
561 | + $args['user'] = absint(trim(str_replace('user:', '', strtolower($_GET['s'])))); |
|
562 | + unset($args['s']); |
|
563 | 563 | } else { |
564 | - $args['s'] = sanitize_text_field( $_GET['s'] ); |
|
564 | + $args['s'] = sanitize_text_field($_GET['s']); |
|
565 | 565 | } |
566 | 566 | } |
567 | 567 | |
568 | - if ( ! empty( $_GET['start-date'] ) ) { |
|
569 | - $args['start-date'] = urldecode( $_GET['start-date'] ); |
|
568 | + if ( ! empty($_GET['start-date'])) { |
|
569 | + $args['start-date'] = urldecode($_GET['start-date']); |
|
570 | 570 | } |
571 | 571 | |
572 | - if ( ! empty( $_GET['end-date'] ) ) { |
|
573 | - $args['end-date'] = urldecode( $_GET['end-date'] ); |
|
572 | + if ( ! empty($_GET['end-date'])) { |
|
573 | + $args['end-date'] = urldecode($_GET['end-date']); |
|
574 | 574 | } |
575 | 575 | |
576 | - $payment_count = give_count_payments( $args ); |
|
576 | + $payment_count = give_count_payments($args); |
|
577 | 577 | $this->complete_count = $payment_count->publish; |
578 | 578 | $this->pending_count = $payment_count->pending; |
579 | 579 | $this->refunded_count = $payment_count->refunded; |
@@ -582,7 +582,7 @@ discard block |
||
582 | 582 | $this->cancelled_count = $payment_count->cancelled; |
583 | 583 | $this->abandoned_count = $payment_count->abandoned; |
584 | 584 | |
585 | - foreach ( $payment_count as $count ) { |
|
585 | + foreach ($payment_count as $count) { |
|
586 | 586 | $this->total_count += $count; |
587 | 587 | } |
588 | 588 | } |
@@ -597,26 +597,26 @@ discard block |
||
597 | 597 | public function payments_data() { |
598 | 598 | |
599 | 599 | $per_page = $this->per_page; |
600 | - $orderby = isset( $_GET['orderby'] ) ? urldecode( $_GET['orderby'] ) : 'ID'; |
|
601 | - $order = isset( $_GET['order'] ) ? $_GET['order'] : 'DESC'; |
|
602 | - $user = isset( $_GET['user'] ) ? $_GET['user'] : null; |
|
603 | - $status = isset( $_GET['status'] ) ? $_GET['status'] : give_get_payment_status_keys(); |
|
604 | - $meta_key = isset( $_GET['meta_key'] ) ? $_GET['meta_key'] : null; |
|
605 | - $year = isset( $_GET['year'] ) ? $_GET['year'] : null; |
|
606 | - $month = isset( $_GET['m'] ) ? $_GET['m'] : null; |
|
607 | - $day = isset( $_GET['day'] ) ? $_GET['day'] : null; |
|
608 | - $search = isset( $_GET['s'] ) ? sanitize_text_field( $_GET['s'] ) : null; |
|
609 | - $start_date = isset( $_GET['start-date'] ) ? sanitize_text_field( $_GET['start-date'] ) : null; |
|
610 | - $end_date = isset( $_GET['end-date'] ) ? sanitize_text_field( $_GET['end-date'] ) : $start_date; |
|
611 | - |
|
612 | - if ( ! empty( $search ) ) { |
|
600 | + $orderby = isset($_GET['orderby']) ? urldecode($_GET['orderby']) : 'ID'; |
|
601 | + $order = isset($_GET['order']) ? $_GET['order'] : 'DESC'; |
|
602 | + $user = isset($_GET['user']) ? $_GET['user'] : null; |
|
603 | + $status = isset($_GET['status']) ? $_GET['status'] : give_get_payment_status_keys(); |
|
604 | + $meta_key = isset($_GET['meta_key']) ? $_GET['meta_key'] : null; |
|
605 | + $year = isset($_GET['year']) ? $_GET['year'] : null; |
|
606 | + $month = isset($_GET['m']) ? $_GET['m'] : null; |
|
607 | + $day = isset($_GET['day']) ? $_GET['day'] : null; |
|
608 | + $search = isset($_GET['s']) ? sanitize_text_field($_GET['s']) : null; |
|
609 | + $start_date = isset($_GET['start-date']) ? sanitize_text_field($_GET['start-date']) : null; |
|
610 | + $end_date = isset($_GET['end-date']) ? sanitize_text_field($_GET['end-date']) : $start_date; |
|
611 | + |
|
612 | + if ( ! empty($search)) { |
|
613 | 613 | $status = 'any'; // Force all payment statuses when searching |
614 | 614 | } |
615 | 615 | |
616 | 616 | $args = array( |
617 | 617 | 'output' => 'payments', |
618 | 618 | 'number' => $per_page, |
619 | - 'page' => isset( $_GET['paged'] ) ? $_GET['paged'] : null, |
|
619 | + 'page' => isset($_GET['paged']) ? $_GET['paged'] : null, |
|
620 | 620 | 'orderby' => $orderby, |
621 | 621 | 'order' => $order, |
622 | 622 | 'user' => $user, |
@@ -630,14 +630,14 @@ discard block |
||
630 | 630 | 'end_date' => $end_date, |
631 | 631 | ); |
632 | 632 | |
633 | - if ( is_string( $search ) && false !== strpos( $search, 'txn:' ) ) { |
|
633 | + if (is_string($search) && false !== strpos($search, 'txn:')) { |
|
634 | 634 | |
635 | 635 | $args['search_in_notes'] = true; |
636 | - $args['s'] = trim( str_replace( 'txn:', '', $args['s'] ) ); |
|
636 | + $args['s'] = trim(str_replace('txn:', '', $args['s'])); |
|
637 | 637 | |
638 | 638 | } |
639 | 639 | |
640 | - $p_query = new Give_Payments_Query( $args ); |
|
640 | + $p_query = new Give_Payments_Query($args); |
|
641 | 641 | |
642 | 642 | return $p_query->get_payments(); |
643 | 643 | |
@@ -657,17 +657,17 @@ discard block |
||
657 | 657 | */ |
658 | 658 | public function prepare_items() { |
659 | 659 | |
660 | - wp_reset_vars( array( 'action', 'payment', 'orderby', 'order', 's' ) ); |
|
660 | + wp_reset_vars(array('action', 'payment', 'orderby', 'order', 's')); |
|
661 | 661 | |
662 | 662 | $columns = $this->get_columns(); |
663 | 663 | $hidden = array(); // No hidden columns |
664 | 664 | $sortable = $this->get_sortable_columns(); |
665 | 665 | $data = $this->payments_data(); |
666 | - $status = isset( $_GET['status'] ) ? $_GET['status'] : 'any'; |
|
666 | + $status = isset($_GET['status']) ? $_GET['status'] : 'any'; |
|
667 | 667 | |
668 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
668 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
669 | 669 | |
670 | - switch ( $status ) { |
|
670 | + switch ($status) { |
|
671 | 671 | case 'publish': |
672 | 672 | $total_items = $this->complete_count; |
673 | 673 | break; |
@@ -694,18 +694,18 @@ discard block |
||
694 | 694 | break; |
695 | 695 | default: |
696 | 696 | // Retrieve the count of the non-default-Give status |
697 | - $count = wp_count_posts( 'give_payment' ); |
|
697 | + $count = wp_count_posts('give_payment'); |
|
698 | 698 | $total_items = $count->{$status}; |
699 | 699 | } |
700 | 700 | |
701 | 701 | $this->items = $data; |
702 | 702 | |
703 | - $this->set_pagination_args( array( |
|
703 | + $this->set_pagination_args(array( |
|
704 | 704 | 'total_items' => $total_items, |
705 | 705 | // WE have to calculate the total number of items |
706 | 706 | 'per_page' => $this->per_page, |
707 | 707 | // WE have to determine how many items to show on a page |
708 | - 'total_pages' => ceil( $total_items / $this->per_page ) |
|
708 | + 'total_pages' => ceil($total_items / $this->per_page) |
|
709 | 709 | // WE have to calculate the total number of pages |
710 | 710 | ) |
711 | 711 | ); |