@@ -9,13 +9,13 @@ discard block |
||
9 | 9 | */ |
10 | 10 | |
11 | 11 | // Exit if accessed directly |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; |
14 | 14 | } |
15 | 15 | |
16 | 16 | // Load WP_List_Table if not loaded |
17 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
18 | - require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
17 | +if ( ! class_exists('WP_List_Table')) { |
|
18 | + require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php'; |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | /** |
@@ -44,13 +44,13 @@ discard block |
||
44 | 44 | global $status, $page; |
45 | 45 | |
46 | 46 | // Set parent defaults |
47 | - parent::__construct( array( |
|
48 | - 'singular' => give_get_forms_label_singular(), // Singular name of the listed records |
|
49 | - 'plural' => give_get_forms_label_plural(), // Plural name of the listed records |
|
47 | + parent::__construct(array( |
|
48 | + 'singular' => give_get_forms_label_singular(), // Singular name of the listed records |
|
49 | + 'plural' => give_get_forms_label_plural(), // Plural name of the listed records |
|
50 | 50 | 'ajax' => false // Does this table support ajax? |
51 | - ) ); |
|
51 | + )); |
|
52 | 52 | |
53 | - add_action( 'give_log_view_actions', array( $this, 'give_forms_filter' ) ); |
|
53 | + add_action('give_log_view_actions', array($this, 'give_forms_filter')); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
@@ -64,24 +64,24 @@ discard block |
||
64 | 64 | * |
65 | 65 | * @return string Column Name |
66 | 66 | */ |
67 | - public function column_default( $item, $column_name ) { |
|
68 | - switch ( $column_name ) { |
|
67 | + public function column_default($item, $column_name) { |
|
68 | + switch ($column_name) { |
|
69 | 69 | case 'form' : |
70 | - return '<a href="' . esc_url( add_query_arg( 'form', $item[ $column_name ] ) ) . '" >' . get_the_title( $item[ $column_name ] ) . '</a>'; |
|
70 | + return '<a href="'.esc_url(add_query_arg('form', $item[$column_name])).'" >'.get_the_title($item[$column_name]).'</a>'; |
|
71 | 71 | |
72 | 72 | case 'user_id' : |
73 | - return '<a href="' . |
|
74 | - admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&user=' . ( ! empty( $item['user_id'] ) ? urlencode( $item['user_id'] ) : give_get_payment_user_email( $item['payment_id'] ) ) ) . |
|
75 | - '">' . $item['user_name'] . '</a>'; |
|
73 | + return '<a href="'. |
|
74 | + admin_url('edit.php?post_type=give_forms&page=give-payment-history&user='.( ! empty($item['user_id']) ? urlencode($item['user_id']) : give_get_payment_user_email($item['payment_id']))). |
|
75 | + '">'.$item['user_name'].'</a>'; |
|
76 | 76 | |
77 | 77 | case 'amount' : |
78 | - return give_currency_filter( give_format_amount( $item['amount'] ) ); |
|
78 | + return give_currency_filter(give_format_amount($item['amount'])); |
|
79 | 79 | |
80 | 80 | case 'payment_id' : |
81 | - return '<a href="' . admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id=' . $item['payment_id'] ) . '">' . give_get_payment_number( $item['payment_id'] ) . '</a>'; |
|
81 | + return '<a href="'.admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id='.$item['payment_id']).'">'.give_get_payment_number($item['payment_id']).'</a>'; |
|
82 | 82 | |
83 | 83 | default: |
84 | - return $item[ $column_name ]; |
|
84 | + return $item[$column_name]; |
|
85 | 85 | } |
86 | 86 | } |
87 | 87 | |
@@ -94,12 +94,12 @@ discard block |
||
94 | 94 | */ |
95 | 95 | public function get_columns() { |
96 | 96 | $columns = array( |
97 | - 'ID' => __( 'Log ID', 'give' ), |
|
98 | - 'user_id' => __( 'Donor', 'give' ), |
|
97 | + 'ID' => __('Log ID', 'give'), |
|
98 | + 'user_id' => __('Donor', 'give'), |
|
99 | 99 | 'form' => give_get_forms_label_singular(), |
100 | - 'amount' => __( 'Donation Amount', 'give' ), |
|
101 | - 'payment_id' => __( 'Transaction ID', 'give' ), |
|
102 | - 'date' => __( 'Date', 'give' ) |
|
100 | + 'amount' => __('Donation Amount', 'give'), |
|
101 | + 'payment_id' => __('Transaction ID', 'give'), |
|
102 | + 'date' => __('Date', 'give') |
|
103 | 103 | ); |
104 | 104 | |
105 | 105 | return $columns; |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | * @return int Current page number |
114 | 114 | */ |
115 | 115 | public function get_paged() { |
116 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
116 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | /** |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | * @return mixed int If User ID, string If Email/Login |
125 | 125 | */ |
126 | 126 | public function get_filtered_user() { |
127 | - return isset( $_GET['user'] ) ? absint( $_GET['user'] ) : false; |
|
127 | + return isset($_GET['user']) ? absint($_GET['user']) : false; |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | * @return int Download ID |
136 | 136 | */ |
137 | 137 | public function get_filtered_give_form() { |
138 | - return ! empty( $_GET['form'] ) ? absint( $_GET['form'] ) : false; |
|
138 | + return ! empty($_GET['form']) ? absint($_GET['form']) : false; |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | /** |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | * @return mixed string If search is present, false otherwise |
147 | 147 | */ |
148 | 148 | public function get_search() { |
149 | - return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false; |
|
149 | + return ! empty($_GET['s']) ? urldecode(trim($_GET['s'])) : false; |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | |
@@ -162,20 +162,20 @@ discard block |
||
162 | 162 | * |
163 | 163 | * @param string $which |
164 | 164 | */ |
165 | - protected function display_tablenav( $which ) { |
|
165 | + protected function display_tablenav($which) { |
|
166 | 166 | |
167 | - if ( 'top' === $which ) { |
|
168 | - wp_nonce_field( 'bulk-' . $this->_args['plural'] ); |
|
167 | + if ('top' === $which) { |
|
168 | + wp_nonce_field('bulk-'.$this->_args['plural']); |
|
169 | 169 | } |
170 | 170 | ?> |
171 | - <div class="tablenav <?php echo esc_attr( $which ); ?>"> |
|
171 | + <div class="tablenav <?php echo esc_attr($which); ?>"> |
|
172 | 172 | |
173 | 173 | <div class="alignleft actions bulkactions"> |
174 | - <?php $this->bulk_actions( $which ); ?> |
|
174 | + <?php $this->bulk_actions($which); ?> |
|
175 | 175 | </div> |
176 | 176 | <?php |
177 | - $this->extra_tablenav( $which ); |
|
178 | - $this->pagination( $which ); |
|
177 | + $this->extra_tablenav($which); |
|
178 | + $this->pagination($which); |
|
179 | 179 | ?> |
180 | 180 | |
181 | 181 | <br class="clear"/> |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | |
199 | 199 | $meta_query = array(); |
200 | 200 | |
201 | - if ( $user ) { |
|
201 | + if ($user) { |
|
202 | 202 | // Show only logs from a specific user |
203 | 203 | $meta_query[] = array( |
204 | 204 | 'key' => '_give_log_user_id', |
@@ -207,8 +207,8 @@ discard block |
||
207 | 207 | } |
208 | 208 | |
209 | 209 | $search = $this->get_search(); |
210 | - if ( $search ) { |
|
211 | - if ( is_email( $search ) ) { |
|
210 | + if ($search) { |
|
211 | + if (is_email($search)) { |
|
212 | 212 | // This is an email search. We use this to ensure it works for guest users and logged-in users |
213 | 213 | $key = '_give_log_user_info'; |
214 | 214 | $compare = 'LIKE'; |
@@ -217,32 +217,32 @@ discard block |
||
217 | 217 | $key = '_give_log_user_id'; |
218 | 218 | $compare = 'LIKE'; |
219 | 219 | |
220 | - if ( ! is_numeric( $search ) ) { |
|
220 | + if ( ! is_numeric($search)) { |
|
221 | 221 | // Searching for user by username |
222 | - $user = get_user_by( 'login', $search ); |
|
222 | + $user = get_user_by('login', $search); |
|
223 | 223 | |
224 | - if ( $user ) { |
|
224 | + if ($user) { |
|
225 | 225 | // Found one, set meta value to user's ID |
226 | 226 | $search = $user->ID; |
227 | 227 | } else { |
228 | 228 | // No user found so let's do a real search query |
229 | - $users = new WP_User_Query( array( |
|
229 | + $users = new WP_User_Query(array( |
|
230 | 230 | 'search' => $search, |
231 | - 'search_columns' => array( 'user_url', 'user_nicename' ), |
|
231 | + 'search_columns' => array('user_url', 'user_nicename'), |
|
232 | 232 | 'number' => 1, |
233 | 233 | 'fields' => 'ids' |
234 | - ) ); |
|
234 | + )); |
|
235 | 235 | |
236 | 236 | $found_user = $users->get_results(); |
237 | 237 | |
238 | - if ( $found_user ) { |
|
238 | + if ($found_user) { |
|
239 | 239 | $search = $found_user[0]; |
240 | 240 | } |
241 | 241 | } |
242 | 242 | } |
243 | 243 | } |
244 | 244 | |
245 | - if ( ! $this->file_search ) { |
|
245 | + if ( ! $this->file_search) { |
|
246 | 246 | // Meta query only works for non file name searche |
247 | 247 | $meta_query[] = array( |
248 | 248 | 'key' => $key, |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | * @since 1.0 |
264 | 264 | * @return void |
265 | 265 | */ |
266 | - function bulk_actions( $which = '' ) { |
|
266 | + function bulk_actions($which = '') { |
|
267 | 267 | give_log_views(); |
268 | 268 | } |
269 | 269 | |
@@ -275,22 +275,22 @@ discard block |
||
275 | 275 | * @return void |
276 | 276 | */ |
277 | 277 | public function give_forms_filter() { |
278 | - $give_forms = get_posts( array( |
|
278 | + $give_forms = get_posts(array( |
|
279 | 279 | 'post_type' => 'give_forms', |
280 | 280 | 'post_status' => 'any', |
281 | - 'posts_per_page' => - 1, |
|
281 | + 'posts_per_page' => -1, |
|
282 | 282 | 'orderby' => 'title', |
283 | 283 | 'order' => 'ASC', |
284 | 284 | 'fields' => 'ids', |
285 | 285 | 'update_post_meta_cache' => false, |
286 | 286 | 'update_post_term_cache' => false |
287 | - ) ); |
|
287 | + )); |
|
288 | 288 | |
289 | - if ( $give_forms ) { |
|
289 | + if ($give_forms) { |
|
290 | 290 | echo '<select name="form" id="give-log-form-filter">'; |
291 | - echo '<option value="0">' . __( 'All', 'give' ) . '</option>'; |
|
292 | - foreach ( $give_forms as $form ) { |
|
293 | - echo '<option value="' . $form . '"' . selected( $form, $this->get_filtered_give_form() ) . '>' . esc_html( get_the_title( $form ) ) . '</option>'; |
|
291 | + echo '<option value="0">'.__('All', 'give').'</option>'; |
|
292 | + foreach ($give_forms as $form) { |
|
293 | + echo '<option value="'.$form.'"'.selected($form, $this->get_filtered_give_form()).'>'.esc_html(get_the_title($form)).'</option>'; |
|
294 | 294 | } |
295 | 295 | echo '</select>'; |
296 | 296 | } |
@@ -308,11 +308,11 @@ discard block |
||
308 | 308 | global $give_logs; |
309 | 309 | |
310 | 310 | // Prevent the queries from getting cached. Without this there are occasional memory issues for some installs |
311 | - wp_suspend_cache_addition( true ); |
|
311 | + wp_suspend_cache_addition(true); |
|
312 | 312 | |
313 | 313 | $logs_data = array(); |
314 | 314 | $paged = $this->get_paged(); |
315 | - $give_form = empty( $_GET['s'] ) ? $this->get_filtered_give_form() : null; |
|
315 | + $give_form = empty($_GET['s']) ? $this->get_filtered_give_form() : null; |
|
316 | 316 | $user = $this->get_filtered_user(); |
317 | 317 | |
318 | 318 | $log_query = array( |
@@ -322,26 +322,26 @@ discard block |
||
322 | 322 | 'meta_query' => $this->get_meta_query() |
323 | 323 | ); |
324 | 324 | |
325 | - $logs = $give_logs->get_connected_logs( $log_query ); |
|
325 | + $logs = $give_logs->get_connected_logs($log_query); |
|
326 | 326 | |
327 | - if ( $logs ) { |
|
328 | - foreach ( $logs as $log ) { |
|
329 | - $payment_id = get_post_meta( $log->ID, '_give_log_payment_id', true ); |
|
327 | + if ($logs) { |
|
328 | + foreach ($logs as $log) { |
|
329 | + $payment_id = get_post_meta($log->ID, '_give_log_payment_id', true); |
|
330 | 330 | |
331 | 331 | // Make sure this payment hasn't been deleted |
332 | - if ( get_post( $payment_id ) ) : |
|
333 | - $user_info = give_get_payment_meta_user_info( $payment_id ); |
|
334 | - $payment_meta = give_get_payment_meta( $payment_id ); |
|
335 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
332 | + if (get_post($payment_id)) : |
|
333 | + $user_info = give_get_payment_meta_user_info($payment_id); |
|
334 | + $payment_meta = give_get_payment_meta($payment_id); |
|
335 | + $payment_amount = give_get_payment_amount($payment_id); |
|
336 | 336 | |
337 | 337 | $logs_data[] = array( |
338 | - 'ID' => '<span class="give-item-label give-item-label-gray">' . $log->ID . '</span>', |
|
338 | + 'ID' => '<span class="give-item-label give-item-label-gray">'.$log->ID.'</span>', |
|
339 | 339 | 'payment_id' => $payment_id, |
340 | 340 | 'form' => $log->post_parent, |
341 | 341 | 'amount' => $payment_amount, |
342 | 342 | 'user_id' => $user_info['id'], |
343 | - 'user_name' => $user_info['first_name'] . ' ' . $user_info['last_name'], |
|
344 | - 'date' => get_post_field( 'post_date', $payment_id ) |
|
343 | + 'user_name' => $user_info['first_name'].' '.$user_info['last_name'], |
|
344 | + 'date' => get_post_field('post_date', $payment_id) |
|
345 | 345 | ); |
346 | 346 | |
347 | 347 | endif; |
@@ -370,15 +370,15 @@ discard block |
||
370 | 370 | $columns = $this->get_columns(); |
371 | 371 | $hidden = array(); |
372 | 372 | $sortable = $this->get_sortable_columns(); |
373 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
373 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
374 | 374 | $current_page = $this->get_pagenum(); |
375 | 375 | $this->items = $this->get_logs(); |
376 | - $total_items = $give_logs->get_log_count( $this->get_filtered_give_form(), 'sale', $this->get_meta_query() ); |
|
376 | + $total_items = $give_logs->get_log_count($this->get_filtered_give_form(), 'sale', $this->get_meta_query()); |
|
377 | 377 | |
378 | - $this->set_pagination_args( array( |
|
378 | + $this->set_pagination_args(array( |
|
379 | 379 | 'total_items' => $total_items, |
380 | 380 | 'per_page' => $this->per_page, |
381 | - 'total_pages' => ceil( $total_items / $this->per_page ) |
|
381 | + 'total_pages' => ceil($total_items / $this->per_page) |
|
382 | 382 | ) |
383 | 383 | ); |
384 | 384 | } |