@@ -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 | /** |
@@ -134,15 +134,15 @@ discard block |
||
134 | 134 | public function __construct() { |
135 | 135 | |
136 | 136 | // Set parent defaults. |
137 | - parent::__construct( array( |
|
138 | - 'singular' => give_get_forms_label_singular(), // Singular name of the listed records. |
|
139 | - 'plural' => give_get_forms_label_plural(), // Plural name of the listed records. |
|
140 | - 'ajax' => false, // Does this table support ajax? |
|
141 | - ) ); |
|
137 | + parent::__construct(array( |
|
138 | + 'singular' => give_get_forms_label_singular(), // Singular name of the listed records. |
|
139 | + 'plural' => give_get_forms_label_plural(), // Plural name of the listed records. |
|
140 | + 'ajax' => false, // Does this table support ajax? |
|
141 | + )); |
|
142 | 142 | |
143 | 143 | $this->process_bulk_action(); |
144 | 144 | $this->get_payment_counts(); |
145 | - $this->base_url = admin_url( 'edit.php?post_type=give_forms&page=give-payment-history' ); |
|
145 | + $this->base_url = admin_url('edit.php?post_type=give_forms&page=give-payment-history'); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | /** |
@@ -151,55 +151,55 @@ discard block |
||
151 | 151 | * @return void |
152 | 152 | */ |
153 | 153 | public function advanced_filters() { |
154 | - $start_date = isset( $_GET['start-date'] ) ? sanitize_text_field( $_GET['start-date'] ) : null; |
|
155 | - $end_date = isset( $_GET['end-date'] ) ? sanitize_text_field( $_GET['end-date'] ) : null; |
|
156 | - $status = isset( $_GET['status'] ) ? sanitize_text_field( $_GET['status'] ) : ''; |
|
157 | - $donor = isset( $_GET['donor'] ) ? sanitize_text_field( $_GET['donor'] ) : ''; |
|
158 | - $search = isset( $_GET['s'] ) ? sanitize_text_field( $_GET['s'] ) : ''; |
|
159 | - $form_id = ! empty( $_GET['form_id'] ) ? absint( $_GET['form_id'] ) : 0; |
|
154 | + $start_date = isset($_GET['start-date']) ? sanitize_text_field($_GET['start-date']) : null; |
|
155 | + $end_date = isset($_GET['end-date']) ? sanitize_text_field($_GET['end-date']) : null; |
|
156 | + $status = isset($_GET['status']) ? sanitize_text_field($_GET['status']) : ''; |
|
157 | + $donor = isset($_GET['donor']) ? sanitize_text_field($_GET['donor']) : ''; |
|
158 | + $search = isset($_GET['s']) ? sanitize_text_field($_GET['s']) : ''; |
|
159 | + $form_id = ! empty($_GET['form_id']) ? absint($_GET['form_id']) : 0; |
|
160 | 160 | ?> |
161 | 161 | <div id="give-payment-filters" class="give-filters"> |
162 | - <?php $this->search_box( esc_html__( 'Search', 'give' ), 'give-payments' ); ?> |
|
162 | + <?php $this->search_box(esc_html__('Search', 'give'), 'give-payments'); ?> |
|
163 | 163 | <div id="give-payment-date-filters"> |
164 | 164 | <div class="give-filter give-filter-half"> |
165 | 165 | <label for="start-date" |
166 | - class="give-start-date-label"><?php esc_html_e( 'Start Date', 'give' ); ?></label> |
|
166 | + class="give-start-date-label"><?php esc_html_e('Start Date', 'give'); ?></label> |
|
167 | 167 | <input type="text" id="start-date" name="start-date" class="give_datepicker" |
168 | 168 | value="<?php echo $start_date; ?>" placeholder="mm/dd/yyyy" /> |
169 | 169 | </div> |
170 | 170 | <div class="give-filter give-filter-half"> |
171 | - <label for="end-date" class="give-end-date-label"><?php esc_html_e( 'End Date', 'give' ); ?></label> |
|
171 | + <label for="end-date" class="give-end-date-label"><?php esc_html_e('End Date', 'give'); ?></label> |
|
172 | 172 | <input type="text" id="end-date" name="end-date" class="give_datepicker" |
173 | 173 | value="<?php echo $end_date; ?>" placeholder="mm/dd/yyyy" /> |
174 | 174 | </div> |
175 | 175 | </div> |
176 | 176 | <div id="give-payment-form-filter" class="give-filter"> |
177 | 177 | <label for="give-donation-forms-filter" |
178 | - class="give-donation-forms-filter-label"><?php esc_html_e( 'Form', 'give' ); ?></label> |
|
178 | + class="give-donation-forms-filter-label"><?php esc_html_e('Form', 'give'); ?></label> |
|
179 | 179 | <?php |
180 | 180 | // Filter Donations by Donation Forms. |
181 | - echo Give()->html->forms_dropdown( array( |
|
181 | + echo Give()->html->forms_dropdown(array( |
|
182 | 182 | 'name' => 'form_id', |
183 | 183 | 'id' => 'give-donation-forms-filter', |
184 | 184 | 'class' => 'give-donation-forms-filter', |
185 | 185 | 'selected' => $form_id, // Make sure to have $form_id set to 0, if there is no selection. |
186 | 186 | 'chosen' => true, |
187 | - 'number' => - 1, |
|
188 | - ) ); |
|
187 | + 'number' => -1, |
|
188 | + )); |
|
189 | 189 | ?> |
190 | 190 | </div> |
191 | 191 | |
192 | - <?php if ( ! empty( $status ) ) : ?> |
|
193 | - <input type="hidden" name="status" value="<?php echo esc_attr( $status ); ?>" /> |
|
192 | + <?php if ( ! empty($status)) : ?> |
|
193 | + <input type="hidden" name="status" value="<?php echo esc_attr($status); ?>" /> |
|
194 | 194 | <?php endif; ?> |
195 | 195 | |
196 | 196 | <div class="give-filter"> |
197 | - <?php submit_button( __( 'Apply', 'give' ), 'secondary', '', false ); ?> |
|
197 | + <?php submit_button(__('Apply', 'give'), 'secondary', '', false); ?> |
|
198 | 198 | <?php |
199 | 199 | // Clear active filters button. |
200 | - if ( ! empty( $start_date ) || ! empty( $end_date ) || ! empty( $donor ) || ! empty( $search ) || ! empty( $status ) || ! empty( $form_id ) ) : ?> |
|
201 | - <a href="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-payment-history' ); ?>" |
|
202 | - class="button give-clear-filters-button"><?php esc_html_e( 'Clear Filters', 'give' ); ?></a> |
|
200 | + if ( ! empty($start_date) || ! empty($end_date) || ! empty($donor) || ! empty($search) || ! empty($status) || ! empty($form_id)) : ?> |
|
201 | + <a href="<?php echo admin_url('edit.php?post_type=give_forms&page=give-payment-history'); ?>" |
|
202 | + class="button give-clear-filters-button"><?php esc_html_e('Clear Filters', 'give'); ?></a> |
|
203 | 203 | <?php endif; ?> |
204 | 204 | </div> |
205 | 205 | </div> |
@@ -218,18 +218,18 @@ discard block |
||
218 | 218 | * |
219 | 219 | * @return void |
220 | 220 | */ |
221 | - public function search_box( $text, $input_id ) { |
|
222 | - if ( empty( $_REQUEST['s'] ) && ! $this->has_items() ) { |
|
221 | + public function search_box($text, $input_id) { |
|
222 | + if (empty($_REQUEST['s']) && ! $this->has_items()) { |
|
223 | 223 | return; |
224 | 224 | } |
225 | 225 | |
226 | - $input_id = $input_id . '-search-input'; |
|
226 | + $input_id = $input_id.'-search-input'; |
|
227 | 227 | |
228 | - if ( ! empty( $_REQUEST['orderby'] ) ) { |
|
229 | - echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />'; |
|
228 | + if ( ! empty($_REQUEST['orderby'])) { |
|
229 | + echo '<input type="hidden" name="orderby" value="'.esc_attr($_REQUEST['orderby']).'" />'; |
|
230 | 230 | } |
231 | - if ( ! empty( $_REQUEST['order'] ) ) { |
|
232 | - echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />'; |
|
231 | + if ( ! empty($_REQUEST['order'])) { |
|
232 | + echo '<input type="hidden" name="order" value="'.esc_attr($_REQUEST['order']).'" />'; |
|
233 | 233 | } |
234 | 234 | ?> |
235 | 235 | <div class="give-filter give-filter-search" role="search"> |
@@ -241,13 +241,13 @@ discard block |
||
241 | 241 | * |
242 | 242 | * @since 1.7 |
243 | 243 | */ |
244 | - do_action( 'give_payment_history_search' ); |
|
244 | + do_action('give_payment_history_search'); |
|
245 | 245 | ?> |
246 | 246 | <label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label> |
247 | 247 | <input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>" /> |
248 | - <?php submit_button( $text, 'button', false, false, array( |
|
248 | + <?php submit_button($text, 'button', false, false, array( |
|
249 | 249 | 'ID' => 'search-submit', |
250 | - ) ); ?><br /> |
|
250 | + )); ?><br /> |
|
251 | 251 | </div> |
252 | 252 | <?php |
253 | 253 | } |
@@ -261,52 +261,52 @@ discard block |
||
261 | 261 | */ |
262 | 262 | public function get_views() { |
263 | 263 | |
264 | - $current = isset( $_GET['status'] ) ? $_GET['status'] : ''; |
|
264 | + $current = isset($_GET['status']) ? $_GET['status'] : ''; |
|
265 | 265 | $views = array(); |
266 | 266 | $tabs = array( |
267 | 267 | 'all' => array( |
268 | 268 | 'total_count', |
269 | - esc_html__( 'All', 'give' ), |
|
269 | + esc_html__('All', 'give'), |
|
270 | 270 | ), |
271 | 271 | 'publish' => array( |
272 | 272 | 'complete_count', |
273 | - esc_html__( 'Completed', 'give' ), |
|
273 | + esc_html__('Completed', 'give'), |
|
274 | 274 | ), |
275 | 275 | 'pending' => array( |
276 | 276 | 'pending_count', |
277 | - esc_html__( 'Pending', 'give' ), |
|
277 | + esc_html__('Pending', 'give'), |
|
278 | 278 | ), |
279 | 279 | 'processing' => array( |
280 | 280 | 'processing_count', |
281 | - esc_html__( 'Processing', 'give' ), |
|
281 | + esc_html__('Processing', 'give'), |
|
282 | 282 | ), |
283 | 283 | 'refunded' => array( |
284 | 284 | 'refunded_count', |
285 | - esc_html__( 'Refunded', 'give' ), |
|
285 | + esc_html__('Refunded', 'give'), |
|
286 | 286 | ), |
287 | 287 | 'revoked' => array( |
288 | 288 | 'revoked_count', |
289 | - esc_html__( 'Revoked', 'give' ), |
|
289 | + esc_html__('Revoked', 'give'), |
|
290 | 290 | ), |
291 | 291 | 'failed' => array( |
292 | 292 | 'failed_count', |
293 | - esc_html__( 'Failed', 'give' ), |
|
293 | + esc_html__('Failed', 'give'), |
|
294 | 294 | ), |
295 | 295 | 'cancelled' => array( |
296 | 296 | 'cancelled_count', |
297 | - esc_html__( 'Cancelled', 'give' ), |
|
297 | + esc_html__('Cancelled', 'give'), |
|
298 | 298 | ), |
299 | 299 | 'abandoned' => array( |
300 | 300 | 'abandoned_count', |
301 | - esc_html__( 'Abandoned', 'give' ), |
|
301 | + esc_html__('Abandoned', 'give'), |
|
302 | 302 | ), |
303 | 303 | 'preapproval' => array( |
304 | 304 | 'preapproval_count', |
305 | - esc_html__( 'Preapproval Pending', 'give' ), |
|
305 | + esc_html__('Preapproval Pending', 'give'), |
|
306 | 306 | ), |
307 | 307 | ); |
308 | 308 | |
309 | - foreach ( $tabs as $key => $tab ) { |
|
309 | + foreach ($tabs as $key => $tab) { |
|
310 | 310 | $count_key = $tab[0]; |
311 | 311 | $name = $tab[1]; |
312 | 312 | $count = $this->$count_key; |
@@ -321,19 +321,19 @@ discard block |
||
321 | 321 | * @param string $key Current view tab value. |
322 | 322 | * @param int $count Number of donation inside the tab. |
323 | 323 | */ |
324 | - if ( 'all' === $key || $key === $current || apply_filters( 'give_payments_table_show_all_status', 0 < $count, $key, $count ) ) { |
|
324 | + if ('all' === $key || $key === $current || apply_filters('give_payments_table_show_all_status', 0 < $count, $key, $count)) { |
|
325 | 325 | |
326 | - $views[ $key ] = sprintf( |
|
326 | + $views[$key] = sprintf( |
|
327 | 327 | '<a href="%s" %s >%s <span class="count">(%s)</span></a>', |
328 | - esc_url( ( 'all' === (string) $key ) ? remove_query_arg( array( 'status', 'paged' ) ) : add_query_arg( array( 'status' => $key, 'paged' => false ) ) ), |
|
329 | - ( ( 'all' === $key && empty( $current ) ) ) ? 'class="current"' : ( $current == $key ) ? 'class="current"' : '', |
|
328 | + esc_url(('all' === (string) $key) ? remove_query_arg(array('status', 'paged')) : add_query_arg(array('status' => $key, 'paged' => false))), |
|
329 | + (('all' === $key && empty($current))) ? 'class="current"' : ($current == $key) ? 'class="current"' : '', |
|
330 | 330 | $name, |
331 | 331 | $count |
332 | 332 | ); |
333 | 333 | } |
334 | 334 | } |
335 | 335 | |
336 | - return apply_filters( 'give_payments_table_views', $views ); |
|
336 | + return apply_filters('give_payments_table_views', $views); |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | /** |
@@ -346,15 +346,15 @@ discard block |
||
346 | 346 | public function get_columns() { |
347 | 347 | $columns = array( |
348 | 348 | 'cb' => '<input type="checkbox" />', // Render a checkbox instead of text. |
349 | - 'donation' => esc_html__( 'Donation', 'give' ), |
|
350 | - 'donation_form' => esc_html__( 'Donation Form', 'give' ), |
|
351 | - 'status' => esc_html__( 'Status', 'give' ), |
|
352 | - 'date' => esc_html__( 'Date', 'give' ), |
|
353 | - 'amount' => esc_html__( 'Amount', 'give' ), |
|
354 | - 'details' => esc_html__( 'Details', 'give' ), |
|
349 | + 'donation' => esc_html__('Donation', 'give'), |
|
350 | + 'donation_form' => esc_html__('Donation Form', 'give'), |
|
351 | + 'status' => esc_html__('Status', 'give'), |
|
352 | + 'date' => esc_html__('Date', 'give'), |
|
353 | + 'amount' => esc_html__('Amount', 'give'), |
|
354 | + 'details' => esc_html__('Details', 'give'), |
|
355 | 355 | ); |
356 | 356 | |
357 | - return apply_filters( 'give_payments_table_columns', $columns ); |
|
357 | + return apply_filters('give_payments_table_columns', $columns); |
|
358 | 358 | } |
359 | 359 | |
360 | 360 | /** |
@@ -366,14 +366,14 @@ discard block |
||
366 | 366 | */ |
367 | 367 | public function get_sortable_columns() { |
368 | 368 | $columns = array( |
369 | - 'donation' => array( 'ID', true ), |
|
370 | - 'donation_form' => array( 'donation_form', false ), |
|
371 | - 'status' => array( 'status', false ), |
|
372 | - 'amount' => array( 'amount', false ), |
|
373 | - 'date' => array( 'date', false ), |
|
369 | + 'donation' => array('ID', true), |
|
370 | + 'donation_form' => array('donation_form', false), |
|
371 | + 'status' => array('status', false), |
|
372 | + 'amount' => array('amount', false), |
|
373 | + 'date' => array('date', false), |
|
374 | 374 | ); |
375 | 375 | |
376 | - return apply_filters( 'give_payments_table_sortable_columns', $columns ); |
|
376 | + return apply_filters('give_payments_table_sortable_columns', $columns); |
|
377 | 377 | } |
378 | 378 | |
379 | 379 | /** |
@@ -399,55 +399,55 @@ discard block |
||
399 | 399 | * |
400 | 400 | * @return string Column Name |
401 | 401 | */ |
402 | - public function column_default( $payment, $column_name ) { |
|
402 | + public function column_default($payment, $column_name) { |
|
403 | 403 | |
404 | - $single_donation_url = esc_url( add_query_arg( 'id', $payment->ID, admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details' ) ) ); |
|
405 | - $row_actions = $this->get_row_actions( $payment ); |
|
404 | + $single_donation_url = esc_url(add_query_arg('id', $payment->ID, admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details'))); |
|
405 | + $row_actions = $this->get_row_actions($payment); |
|
406 | 406 | |
407 | - switch ( $column_name ) { |
|
407 | + switch ($column_name) { |
|
408 | 408 | case 'donation' : |
409 | - $value = sprintf( '<a href="%1$s" data-tooltip="%2$s">#%3$s</a> %4$s %5$s<br>', $single_donation_url, sprintf( esc_attr__( 'View Donation #%s', 'give' ), $payment->ID ), $payment->ID, esc_html__( 'by', 'give' ), $this->get_donor( $payment ) ); |
|
410 | - $value .= $this->get_donor_email( $payment ); |
|
411 | - $value .= $this->row_actions( $row_actions ); |
|
409 | + $value = sprintf('<a href="%1$s" data-tooltip="%2$s">#%3$s</a> %4$s %5$s<br>', $single_donation_url, sprintf(esc_attr__('View Donation #%s', 'give'), $payment->ID), $payment->ID, esc_html__('by', 'give'), $this->get_donor($payment)); |
|
410 | + $value .= $this->get_donor_email($payment); |
|
411 | + $value .= $this->row_actions($row_actions); |
|
412 | 412 | break; |
413 | 413 | |
414 | 414 | case 'amount' : |
415 | - $amount = ! empty( $payment->total ) ? $payment->total : 0; |
|
416 | - $value = give_currency_filter( give_format_amount( $amount, array( 'sanitize' => false ) ), give_get_payment_currency_code( $payment->ID ) ); |
|
417 | - $value .= sprintf( '<br><small>%1$s %2$s</small>', __( 'via', 'give' ), give_get_gateway_admin_label( $payment->gateway ) ); |
|
415 | + $amount = ! empty($payment->total) ? $payment->total : 0; |
|
416 | + $value = give_currency_filter(give_format_amount($amount, array('sanitize' => false)), give_get_payment_currency_code($payment->ID)); |
|
417 | + $value .= sprintf('<br><small>%1$s %2$s</small>', __('via', 'give'), give_get_gateway_admin_label($payment->gateway)); |
|
418 | 418 | break; |
419 | 419 | |
420 | 420 | case 'donation_form' : |
421 | - $form_title = empty( $payment->form_title ) ? sprintf( __( 'Untitled (#%s)', 'give' ), $payment->form_id ) : $payment->form_title; |
|
422 | - $value = '<a href="' . admin_url( 'post.php?post=' . $payment->form_id . '&action=edit' ) . '">' . $form_title . '</a>'; |
|
423 | - $level = give_get_payment_form_title( $payment->meta, true ); |
|
421 | + $form_title = empty($payment->form_title) ? sprintf(__('Untitled (#%s)', 'give'), $payment->form_id) : $payment->form_title; |
|
422 | + $value = '<a href="'.admin_url('post.php?post='.$payment->form_id.'&action=edit').'">'.$form_title.'</a>'; |
|
423 | + $level = give_get_payment_form_title($payment->meta, true); |
|
424 | 424 | |
425 | - if ( ! empty( $level ) ) { |
|
425 | + if ( ! empty($level)) { |
|
426 | 426 | $value .= $level; |
427 | 427 | } |
428 | 428 | |
429 | 429 | break; |
430 | 430 | |
431 | 431 | case 'date' : |
432 | - $date = strtotime( $payment->date ); |
|
433 | - $value = date_i18n( give_date_format(), $date ); |
|
432 | + $date = strtotime($payment->date); |
|
433 | + $value = date_i18n(give_date_format(), $date); |
|
434 | 434 | break; |
435 | 435 | |
436 | 436 | case 'status' : |
437 | - $value = $this->get_payment_status( $payment ); |
|
437 | + $value = $this->get_payment_status($payment); |
|
438 | 438 | break; |
439 | 439 | |
440 | 440 | case 'details' : |
441 | - $value = sprintf( '<div class="give-payment-details-link-wrap"><a href="%1$s" class="give-payment-details-link button button-small" data-tooltip="%2$s" aria-label="%2$s"><span class="dashicons dashicons-visibility"></span></a></div>', $single_donation_url, sprintf( esc_attr__( 'View Donation #%s', 'give' ), $payment->ID ) ); |
|
441 | + $value = sprintf('<div class="give-payment-details-link-wrap"><a href="%1$s" class="give-payment-details-link button button-small" data-tooltip="%2$s" aria-label="%2$s"><span class="dashicons dashicons-visibility"></span></a></div>', $single_donation_url, sprintf(esc_attr__('View Donation #%s', 'give'), $payment->ID)); |
|
442 | 442 | break; |
443 | 443 | |
444 | 444 | default: |
445 | - $value = isset( $payment->$column_name ) ? $payment->$column_name : ''; |
|
445 | + $value = isset($payment->$column_name) ? $payment->$column_name : ''; |
|
446 | 446 | break; |
447 | 447 | |
448 | 448 | }// End switch(). |
449 | 449 | |
450 | - return apply_filters( 'give_payments_table_column', $value, $payment->ID, $column_name ); |
|
450 | + return apply_filters('give_payments_table_column', $value, $payment->ID, $column_name); |
|
451 | 451 | } |
452 | 452 | |
453 | 453 | /** |
@@ -460,17 +460,17 @@ discard block |
||
460 | 460 | * |
461 | 461 | * @return string Data shown in the Email column |
462 | 462 | */ |
463 | - public function get_donor_email( $payment ) { |
|
463 | + public function get_donor_email($payment) { |
|
464 | 464 | |
465 | - $email = give_get_payment_user_email( $payment->ID ); |
|
465 | + $email = give_get_payment_user_email($payment->ID); |
|
466 | 466 | |
467 | - if ( empty( $email ) ) { |
|
468 | - $email = esc_html__( '(unknown)', 'give' ); |
|
467 | + if (empty($email)) { |
|
468 | + $email = esc_html__('(unknown)', 'give'); |
|
469 | 469 | } |
470 | 470 | |
471 | - $value = '<a href="mailto:' . $email . '" data-tooltip="' . esc_attr__( 'Email donor', 'give' ) . '">' . $email . '</a>'; |
|
471 | + $value = '<a href="mailto:'.$email.'" data-tooltip="'.esc_attr__('Email donor', 'give').'">'.$email.'</a>'; |
|
472 | 472 | |
473 | - return apply_filters( 'give_payments_table_column', $value, $payment->ID, 'email' ); |
|
473 | + return apply_filters('give_payments_table_column', $value, $payment->ID, 'email'); |
|
474 | 474 | } |
475 | 475 | |
476 | 476 | /** |
@@ -482,32 +482,32 @@ discard block |
||
482 | 482 | * |
483 | 483 | * @return array $actions |
484 | 484 | */ |
485 | - function get_row_actions( $payment ) { |
|
485 | + function get_row_actions($payment) { |
|
486 | 486 | |
487 | 487 | $actions = array(); |
488 | - $email = give_get_payment_user_email( $payment->ID ); |
|
488 | + $email = give_get_payment_user_email($payment->ID); |
|
489 | 489 | |
490 | 490 | // Add search term string back to base URL. |
491 | - $search_terms = ( isset( $_GET['s'] ) ? trim( $_GET['s'] ) : '' ); |
|
492 | - if ( ! empty( $search_terms ) ) { |
|
493 | - $this->base_url = add_query_arg( 's', $search_terms, $this->base_url ); |
|
491 | + $search_terms = (isset($_GET['s']) ? trim($_GET['s']) : ''); |
|
492 | + if ( ! empty($search_terms)) { |
|
493 | + $this->base_url = add_query_arg('s', $search_terms, $this->base_url); |
|
494 | 494 | } |
495 | 495 | |
496 | - if ( give_is_payment_complete( $payment->ID ) && ! empty( $email ) ) { |
|
496 | + if (give_is_payment_complete($payment->ID) && ! empty($email)) { |
|
497 | 497 | |
498 | - $actions['email_links'] = sprintf( '<a class="resend-single-donation-receipt" href="%1$s" aria-label="%2$s">%3$s</a>', wp_nonce_url( add_query_arg( array( |
|
498 | + $actions['email_links'] = sprintf('<a class="resend-single-donation-receipt" href="%1$s" aria-label="%2$s">%3$s</a>', wp_nonce_url(add_query_arg(array( |
|
499 | 499 | 'give-action' => 'email_links', |
500 | 500 | 'purchase_id' => $payment->ID, |
501 | - ), $this->base_url ), 'give_payment_nonce' ), sprintf( esc_attr__( 'Resend Donation %s Receipt', 'give' ), $payment->ID ), esc_html__( 'Resend Receipt', 'give' ) ); |
|
501 | + ), $this->base_url), 'give_payment_nonce'), sprintf(esc_attr__('Resend Donation %s Receipt', 'give'), $payment->ID), esc_html__('Resend Receipt', 'give')); |
|
502 | 502 | |
503 | 503 | } |
504 | 504 | |
505 | - $actions['delete'] = sprintf( '<a class="delete-single-donation" href="%1$s" aria-label="%2$s">%3$s</a>', wp_nonce_url( add_query_arg( array( |
|
505 | + $actions['delete'] = sprintf('<a class="delete-single-donation" href="%1$s" aria-label="%2$s">%3$s</a>', wp_nonce_url(add_query_arg(array( |
|
506 | 506 | 'give-action' => 'delete_payment', |
507 | 507 | 'purchase_id' => $payment->ID, |
508 | - ), $this->base_url ), 'give_donation_nonce' ), sprintf( esc_attr__( 'Delete Donation %s', 'give' ), $payment->ID ), esc_html__( 'Delete', 'give' ) ); |
|
508 | + ), $this->base_url), 'give_donation_nonce'), sprintf(esc_attr__('Delete Donation %s', 'give'), $payment->ID), esc_html__('Delete', 'give')); |
|
509 | 509 | |
510 | - return apply_filters( 'give_payment_row_actions', $actions, $payment ); |
|
510 | + return apply_filters('give_payment_row_actions', $actions, $payment); |
|
511 | 511 | } |
512 | 512 | |
513 | 513 | |
@@ -521,14 +521,14 @@ discard block |
||
521 | 521 | * |
522 | 522 | * @return string Data shown in the Email column |
523 | 523 | */ |
524 | - function get_payment_status( $payment ) { |
|
525 | - $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>'; |
|
526 | - if ( $payment->mode == 'test' ) { |
|
527 | - $value .= ' <span class="give-item-label give-item-label-orange give-test-mode-transactions-label" data-tooltip="' . esc_attr__( 'This donation was made in test mode.', 'give' ) . '">' . esc_html__( 'Test', 'give' ) . '</span>'; |
|
524 | + function get_payment_status($payment) { |
|
525 | + $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>'; |
|
526 | + if ($payment->mode == 'test') { |
|
527 | + $value .= ' <span class="give-item-label give-item-label-orange give-test-mode-transactions-label" data-tooltip="'.esc_attr__('This donation was made in test mode.', 'give').'">'.esc_html__('Test', 'give').'</span>'; |
|
528 | 528 | } |
529 | 529 | |
530 | - if ( true === $payment->import && true === (bool) apply_filters( 'give_payment_show_importer_label', false ) ) { |
|
531 | - $value .= ' <span class="give-item-label give-item-label-orange give-test-mode-transactions-label" data-tooltip="' . esc_attr__( 'This donation was imported.', 'give' ) . '">' . esc_html__( 'Import', 'give' ) . '</span>'; |
|
530 | + if (true === $payment->import && true === (bool) apply_filters('give_payment_show_importer_label', false)) { |
|
531 | + $value .= ' <span class="give-item-label give-item-label-orange give-test-mode-transactions-label" data-tooltip="'.esc_attr__('This donation was imported.', 'give').'">'.esc_html__('Import', 'give').'</span>'; |
|
532 | 532 | } |
533 | 533 | |
534 | 534 | return $value; |
@@ -544,8 +544,8 @@ discard block |
||
544 | 544 | * |
545 | 545 | * @return string Displays a checkbox. |
546 | 546 | */ |
547 | - public function column_cb( $payment ) { |
|
548 | - return sprintf( '<input type="checkbox" name="%1$s[]" value="%2$s" />', 'payment', $payment->ID ); |
|
547 | + public function column_cb($payment) { |
|
548 | + return sprintf('<input type="checkbox" name="%1$s[]" value="%2$s" />', 'payment', $payment->ID); |
|
549 | 549 | } |
550 | 550 | |
551 | 551 | /** |
@@ -558,8 +558,8 @@ discard block |
||
558 | 558 | * |
559 | 559 | * @return string Displays a checkbox. |
560 | 560 | */ |
561 | - public function get_payment_id( $payment ) { |
|
562 | - return '<span class="give-payment-id">' . give_get_payment_number( $payment->ID ) . '</span>'; |
|
561 | + public function get_payment_id($payment) { |
|
562 | + return '<span class="give-payment-id">'.give_get_payment_number($payment->ID).'</span>'; |
|
563 | 563 | } |
564 | 564 | |
565 | 565 | /** |
@@ -572,32 +572,32 @@ discard block |
||
572 | 572 | * |
573 | 573 | * @return string Data shown in the User column |
574 | 574 | */ |
575 | - public function get_donor( $payment ) { |
|
575 | + public function get_donor($payment) { |
|
576 | 576 | |
577 | - $donor_id = give_get_payment_donor_id( $payment->ID ); |
|
578 | - $donor_billing_name = give_get_donor_name_by( $payment->ID, 'donation' ); |
|
579 | - $donor_name = give_get_donor_name_by( $donor_id, 'donor' ); |
|
577 | + $donor_id = give_get_payment_donor_id($payment->ID); |
|
578 | + $donor_billing_name = give_get_donor_name_by($payment->ID, 'donation'); |
|
579 | + $donor_name = give_get_donor_name_by($donor_id, 'donor'); |
|
580 | 580 | |
581 | 581 | $value = ''; |
582 | - if ( ! empty( $donor_id ) ) { |
|
582 | + if ( ! empty($donor_id)) { |
|
583 | 583 | |
584 | 584 | // Check whether the donor name and WP_User name is same or not. |
585 | - if ( sanitize_title( $donor_billing_name ) != sanitize_title( $donor_name ) ) { |
|
586 | - $value .= $donor_billing_name . ' ('; |
|
585 | + if (sanitize_title($donor_billing_name) != sanitize_title($donor_name)) { |
|
586 | + $value .= $donor_billing_name.' ('; |
|
587 | 587 | } |
588 | 588 | |
589 | - $value .= '<a href="' . esc_url( admin_url( "edit.php?post_type=give_forms&page=give-donors&view=overview&id=$donor_id" ) ) . '">' . $donor_name . '</a>'; |
|
589 | + $value .= '<a href="'.esc_url(admin_url("edit.php?post_type=give_forms&page=give-donors&view=overview&id=$donor_id")).'">'.$donor_name.'</a>'; |
|
590 | 590 | |
591 | 591 | // Check whether the donor name and WP_User name is same or not. |
592 | - if ( sanitize_title( $donor_billing_name ) != sanitize_title( $donor_name ) ) { |
|
592 | + if (sanitize_title($donor_billing_name) != sanitize_title($donor_name)) { |
|
593 | 593 | $value .= ')'; |
594 | 594 | } |
595 | 595 | } else { |
596 | - $email = give_get_payment_user_email( $payment->ID ); |
|
597 | - $value .= '<a href="' . esc_url( admin_url( "edit.php?post_type=give_forms&page=give-payment-history&s=$email" ) ) . '">' . esc_html__( '(donor missing)', 'give' ) . '</a>'; |
|
596 | + $email = give_get_payment_user_email($payment->ID); |
|
597 | + $value .= '<a href="'.esc_url(admin_url("edit.php?post_type=give_forms&page=give-payment-history&s=$email")).'">'.esc_html__('(donor missing)', 'give').'</a>'; |
|
598 | 598 | } |
599 | 599 | |
600 | - return apply_filters( 'give_payments_table_column', $value, $payment->ID, 'donor' ); |
|
600 | + return apply_filters('give_payments_table_column', $value, $payment->ID, 'donor'); |
|
601 | 601 | } |
602 | 602 | |
603 | 603 | /** |
@@ -609,20 +609,20 @@ discard block |
||
609 | 609 | */ |
610 | 610 | public function get_bulk_actions() { |
611 | 611 | $actions = array( |
612 | - 'delete' => __( 'Delete', 'give' ), |
|
613 | - 'set-status-publish' => __( 'Set To Completed', 'give' ), |
|
614 | - 'set-status-pending' => __( 'Set To Pending', 'give' ), |
|
615 | - 'set-status-processing' => __( 'Set To Processing', 'give' ), |
|
616 | - 'set-status-refunded' => __( 'Set To Refunded', 'give' ), |
|
617 | - 'set-status-revoked' => __( 'Set To Revoked', 'give' ), |
|
618 | - 'set-status-failed' => __( 'Set To Failed', 'give' ), |
|
619 | - 'set-status-cancelled' => __( 'Set To Cancelled', 'give' ), |
|
620 | - 'set-status-abandoned' => __( 'Set To Abandoned', 'give' ), |
|
621 | - 'set-status-preapproval' => __( 'Set To Preapproval', 'give' ), |
|
622 | - 'resend-receipt' => __( 'Resend Email Receipts', 'give' ), |
|
612 | + 'delete' => __('Delete', 'give'), |
|
613 | + 'set-status-publish' => __('Set To Completed', 'give'), |
|
614 | + 'set-status-pending' => __('Set To Pending', 'give'), |
|
615 | + 'set-status-processing' => __('Set To Processing', 'give'), |
|
616 | + 'set-status-refunded' => __('Set To Refunded', 'give'), |
|
617 | + 'set-status-revoked' => __('Set To Revoked', 'give'), |
|
618 | + 'set-status-failed' => __('Set To Failed', 'give'), |
|
619 | + 'set-status-cancelled' => __('Set To Cancelled', 'give'), |
|
620 | + 'set-status-abandoned' => __('Set To Abandoned', 'give'), |
|
621 | + 'set-status-preapproval' => __('Set To Preapproval', 'give'), |
|
622 | + 'resend-receipt' => __('Resend Email Receipts', 'give'), |
|
623 | 623 | ); |
624 | 624 | |
625 | - return apply_filters( 'give_payments_table_bulk_actions', $actions ); |
|
625 | + return apply_filters('give_payments_table_bulk_actions', $actions); |
|
626 | 626 | } |
627 | 627 | |
628 | 628 | /** |
@@ -633,63 +633,63 @@ discard block |
||
633 | 633 | * @return void |
634 | 634 | */ |
635 | 635 | public function process_bulk_action() { |
636 | - $ids = isset( $_GET['payment'] ) ? $_GET['payment'] : false; |
|
636 | + $ids = isset($_GET['payment']) ? $_GET['payment'] : false; |
|
637 | 637 | $action = $this->current_action(); |
638 | 638 | |
639 | - if ( ! is_array( $ids ) ) { |
|
640 | - $ids = array( $ids ); |
|
639 | + if ( ! is_array($ids)) { |
|
640 | + $ids = array($ids); |
|
641 | 641 | } |
642 | 642 | |
643 | - if ( empty( $action ) ) { |
|
643 | + if (empty($action)) { |
|
644 | 644 | return; |
645 | 645 | } |
646 | 646 | |
647 | - foreach ( $ids as $id ) { |
|
647 | + foreach ($ids as $id) { |
|
648 | 648 | |
649 | 649 | // Detect when a bulk action is being triggered. |
650 | - switch ( $this->current_action() ) { |
|
650 | + switch ($this->current_action()) { |
|
651 | 651 | |
652 | 652 | case'delete': |
653 | - give_delete_donation( $id ); |
|
653 | + give_delete_donation($id); |
|
654 | 654 | break; |
655 | 655 | |
656 | 656 | case 'set-status-publish': |
657 | - give_update_payment_status( $id, 'publish' ); |
|
657 | + give_update_payment_status($id, 'publish'); |
|
658 | 658 | break; |
659 | 659 | |
660 | 660 | case 'set-status-pending': |
661 | - give_update_payment_status( $id, 'pending' ); |
|
661 | + give_update_payment_status($id, 'pending'); |
|
662 | 662 | break; |
663 | 663 | |
664 | 664 | case 'set-status-processing': |
665 | - give_update_payment_status( $id, 'processing' ); |
|
665 | + give_update_payment_status($id, 'processing'); |
|
666 | 666 | break; |
667 | 667 | |
668 | 668 | case 'set-status-refunded': |
669 | - give_update_payment_status( $id, 'refunded' ); |
|
669 | + give_update_payment_status($id, 'refunded'); |
|
670 | 670 | break; |
671 | 671 | case 'set-status-revoked': |
672 | - give_update_payment_status( $id, 'revoked' ); |
|
672 | + give_update_payment_status($id, 'revoked'); |
|
673 | 673 | break; |
674 | 674 | |
675 | 675 | case 'set-status-failed': |
676 | - give_update_payment_status( $id, 'failed' ); |
|
676 | + give_update_payment_status($id, 'failed'); |
|
677 | 677 | break; |
678 | 678 | |
679 | 679 | case 'set-status-cancelled': |
680 | - give_update_payment_status( $id, 'cancelled' ); |
|
680 | + give_update_payment_status($id, 'cancelled'); |
|
681 | 681 | break; |
682 | 682 | |
683 | 683 | case 'set-status-abandoned': |
684 | - give_update_payment_status( $id, 'abandoned' ); |
|
684 | + give_update_payment_status($id, 'abandoned'); |
|
685 | 685 | break; |
686 | 686 | |
687 | 687 | case 'set-status-preapproval': |
688 | - give_update_payment_status( $id, 'preapproval' ); |
|
688 | + give_update_payment_status($id, 'preapproval'); |
|
689 | 689 | break; |
690 | 690 | |
691 | 691 | case 'resend-receipt': |
692 | - give_email_donation_receipt( $id, false ); |
|
692 | + give_email_donation_receipt($id, false); |
|
693 | 693 | break; |
694 | 694 | }// End switch(). |
695 | 695 | |
@@ -701,7 +701,7 @@ discard block |
||
701 | 701 | * @param int $id The ID of the payment. |
702 | 702 | * @param string $current_action The action that is being triggered. |
703 | 703 | */ |
704 | - do_action( 'give_payments_table_do_bulk_action', $id, $this->current_action() ); |
|
704 | + do_action('give_payments_table_do_bulk_action', $id, $this->current_action()); |
|
705 | 705 | }// End foreach(). |
706 | 706 | |
707 | 707 | } |
@@ -717,31 +717,31 @@ discard block |
||
717 | 717 | |
718 | 718 | $args = array(); |
719 | 719 | |
720 | - if ( isset( $_GET['user'] ) ) { |
|
721 | - $args['user'] = urldecode( $_GET['user'] ); |
|
722 | - } elseif ( isset( $_GET['donor'] ) ) { |
|
723 | - $args['donor'] = absint( $_GET['donor'] ); |
|
724 | - } elseif ( isset( $_GET['s'] ) ) { |
|
725 | - $is_user = strpos( $_GET['s'], strtolower( 'user:' ) ) !== false; |
|
726 | - if ( $is_user ) { |
|
727 | - $args['user'] = absint( trim( str_replace( 'user:', '', strtolower( $_GET['s'] ) ) ) ); |
|
728 | - unset( $args['s'] ); |
|
720 | + if (isset($_GET['user'])) { |
|
721 | + $args['user'] = urldecode($_GET['user']); |
|
722 | + } elseif (isset($_GET['donor'])) { |
|
723 | + $args['donor'] = absint($_GET['donor']); |
|
724 | + } elseif (isset($_GET['s'])) { |
|
725 | + $is_user = strpos($_GET['s'], strtolower('user:')) !== false; |
|
726 | + if ($is_user) { |
|
727 | + $args['user'] = absint(trim(str_replace('user:', '', strtolower($_GET['s'])))); |
|
728 | + unset($args['s']); |
|
729 | 729 | } else { |
730 | - $args['s'] = sanitize_text_field( $_GET['s'] ); |
|
730 | + $args['s'] = sanitize_text_field($_GET['s']); |
|
731 | 731 | } |
732 | 732 | } |
733 | 733 | |
734 | - if ( ! empty( $_GET['start-date'] ) ) { |
|
735 | - $args['start-date'] = urldecode( $_GET['start-date'] ); |
|
734 | + if ( ! empty($_GET['start-date'])) { |
|
735 | + $args['start-date'] = urldecode($_GET['start-date']); |
|
736 | 736 | } |
737 | 737 | |
738 | - if ( ! empty( $_GET['end-date'] ) ) { |
|
739 | - $args['end-date'] = urldecode( $_GET['end-date'] ); |
|
738 | + if ( ! empty($_GET['end-date'])) { |
|
739 | + $args['end-date'] = urldecode($_GET['end-date']); |
|
740 | 740 | } |
741 | 741 | |
742 | - $args['form_id'] = ! empty( $_GET['form_id'] ) ? absint( $_GET['form_id'] ) : null; |
|
742 | + $args['form_id'] = ! empty($_GET['form_id']) ? absint($_GET['form_id']) : null; |
|
743 | 743 | |
744 | - $payment_count = give_count_payments( $args ); |
|
744 | + $payment_count = give_count_payments($args); |
|
745 | 745 | $this->complete_count = $payment_count->publish; |
746 | 746 | $this->pending_count = $payment_count->pending; |
747 | 747 | $this->processing_count = $payment_count->processing; |
@@ -752,7 +752,7 @@ discard block |
||
752 | 752 | $this->abandoned_count = $payment_count->abandoned; |
753 | 753 | $this->preapproval_count = $payment_count->preapproval; |
754 | 754 | |
755 | - foreach ( $payment_count as $count ) { |
|
755 | + foreach ($payment_count as $count) { |
|
756 | 756 | $this->total_count += $count; |
757 | 757 | } |
758 | 758 | } |
@@ -767,28 +767,28 @@ discard block |
||
767 | 767 | public function payments_data() { |
768 | 768 | |
769 | 769 | $per_page = $this->per_page; |
770 | - $orderby = isset( $_GET['orderby'] ) ? urldecode( $_GET['orderby'] ) : 'ID'; |
|
771 | - $order = isset( $_GET['order'] ) ? $_GET['order'] : 'DESC'; |
|
772 | - $user = isset( $_GET['user'] ) ? $_GET['user'] : null; |
|
773 | - $donor = isset( $_GET['donor'] ) ? $_GET['donor'] : null; |
|
774 | - $status = isset( $_GET['status'] ) ? $_GET['status'] : give_get_payment_status_keys(); |
|
775 | - $meta_key = isset( $_GET['meta_key'] ) ? $_GET['meta_key'] : null; |
|
776 | - $year = isset( $_GET['year'] ) ? $_GET['year'] : null; |
|
777 | - $month = isset( $_GET['m'] ) ? $_GET['m'] : null; |
|
778 | - $day = isset( $_GET['day'] ) ? $_GET['day'] : null; |
|
779 | - $search = isset( $_GET['s'] ) ? sanitize_text_field( $_GET['s'] ) : null; |
|
780 | - $start_date = isset( $_GET['start-date'] ) ? sanitize_text_field( $_GET['start-date'] ) : null; |
|
781 | - $end_date = isset( $_GET['end-date'] ) ? sanitize_text_field( $_GET['end-date'] ) : $start_date; |
|
782 | - $form_id = ! empty( $_GET['form_id'] ) ? absint( $_GET['form_id'] ) : null; |
|
783 | - |
|
784 | - if ( ! empty( $search ) ) { |
|
770 | + $orderby = isset($_GET['orderby']) ? urldecode($_GET['orderby']) : 'ID'; |
|
771 | + $order = isset($_GET['order']) ? $_GET['order'] : 'DESC'; |
|
772 | + $user = isset($_GET['user']) ? $_GET['user'] : null; |
|
773 | + $donor = isset($_GET['donor']) ? $_GET['donor'] : null; |
|
774 | + $status = isset($_GET['status']) ? $_GET['status'] : give_get_payment_status_keys(); |
|
775 | + $meta_key = isset($_GET['meta_key']) ? $_GET['meta_key'] : null; |
|
776 | + $year = isset($_GET['year']) ? $_GET['year'] : null; |
|
777 | + $month = isset($_GET['m']) ? $_GET['m'] : null; |
|
778 | + $day = isset($_GET['day']) ? $_GET['day'] : null; |
|
779 | + $search = isset($_GET['s']) ? sanitize_text_field($_GET['s']) : null; |
|
780 | + $start_date = isset($_GET['start-date']) ? sanitize_text_field($_GET['start-date']) : null; |
|
781 | + $end_date = isset($_GET['end-date']) ? sanitize_text_field($_GET['end-date']) : $start_date; |
|
782 | + $form_id = ! empty($_GET['form_id']) ? absint($_GET['form_id']) : null; |
|
783 | + |
|
784 | + if ( ! empty($search)) { |
|
785 | 785 | $status = 'any'; // Force all payment statuses when searching. |
786 | 786 | } |
787 | 787 | |
788 | 788 | $args = array( |
789 | 789 | 'output' => 'payments', |
790 | 790 | 'number' => $per_page, |
791 | - 'page' => isset( $_GET['paged'] ) ? $_GET['paged'] : null, |
|
791 | + 'page' => isset($_GET['paged']) ? $_GET['paged'] : null, |
|
792 | 792 | 'orderby' => $orderby, |
793 | 793 | 'order' => $order, |
794 | 794 | 'user' => $user, |
@@ -804,12 +804,12 @@ discard block |
||
804 | 804 | 'give_forms' => $form_id, |
805 | 805 | ); |
806 | 806 | |
807 | - if ( is_string( $search ) && false !== strpos( $search, 'txn:' ) ) { |
|
807 | + if (is_string($search) && false !== strpos($search, 'txn:')) { |
|
808 | 808 | $args['search_in_notes'] = true; |
809 | - $args['s'] = trim( str_replace( 'txn:', '', $args['s'] ) ); |
|
809 | + $args['s'] = trim(str_replace('txn:', '', $args['s'])); |
|
810 | 810 | } |
811 | 811 | |
812 | - $p_query = new Give_Payments_Query( $args ); |
|
812 | + $p_query = new Give_Payments_Query($args); |
|
813 | 813 | |
814 | 814 | return $p_query->get_payments(); |
815 | 815 | |
@@ -829,17 +829,17 @@ discard block |
||
829 | 829 | */ |
830 | 830 | public function prepare_items() { |
831 | 831 | |
832 | - wp_reset_vars( array( 'action', 'payment', 'orderby', 'order', 's' ) ); |
|
832 | + wp_reset_vars(array('action', 'payment', 'orderby', 'order', 's')); |
|
833 | 833 | |
834 | 834 | $columns = $this->get_columns(); |
835 | 835 | $hidden = array(); // No hidden columns. |
836 | 836 | $sortable = $this->get_sortable_columns(); |
837 | 837 | $data = $this->payments_data(); |
838 | - $status = isset( $_GET['status'] ) ? $_GET['status'] : 'any'; |
|
838 | + $status = isset($_GET['status']) ? $_GET['status'] : 'any'; |
|
839 | 839 | |
840 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
840 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
841 | 841 | |
842 | - switch ( $status ) { |
|
842 | + switch ($status) { |
|
843 | 843 | case 'publish': |
844 | 844 | $total_items = $this->complete_count; |
845 | 845 | break; |
@@ -872,20 +872,20 @@ discard block |
||
872 | 872 | break; |
873 | 873 | default: |
874 | 874 | // Retrieve the count of the non-default-Give status. |
875 | - $count = wp_count_posts( 'give_payment' ); |
|
876 | - $total_items = isset( $count->{$status} ) ? $count->{$status} : 0; |
|
875 | + $count = wp_count_posts('give_payment'); |
|
876 | + $total_items = isset($count->{$status} ) ? $count->{$status} : 0; |
|
877 | 877 | break; |
878 | 878 | } |
879 | 879 | |
880 | 880 | $this->items = $data; |
881 | 881 | |
882 | - $this->set_pagination_args( array( |
|
882 | + $this->set_pagination_args(array( |
|
883 | 883 | 'total_items' => $total_items, |
884 | 884 | // We have to calculate the total number of items. |
885 | 885 | 'per_page' => $this->per_page, |
886 | 886 | // We have to determine how many items to show on a page. |
887 | - 'total_pages' => ceil( $total_items / $this->per_page ), |
|
887 | + 'total_pages' => ceil($total_items / $this->per_page), |
|
888 | 888 | // We have to calculate the total number of pages. |
889 | - ) ); |
|
889 | + )); |
|
890 | 890 | } |
891 | 891 | } |
@@ -65,18 +65,18 @@ discard block |
||
65 | 65 | * |
66 | 66 | * @param $args |
67 | 67 | */ |
68 | - public function __construct( $args ) { |
|
68 | + public function __construct($args) { |
|
69 | 69 | |
70 | 70 | // Only for admins. |
71 | - if ( ! is_admin() ) { |
|
71 | + if ( ! is_admin()) { |
|
72 | 72 | return; |
73 | 73 | } |
74 | 74 | |
75 | - foreach ( $args as $key => $arg ) { |
|
75 | + foreach ($args as $key => $arg) { |
|
76 | 76 | $this->$key = $arg; |
77 | 77 | } |
78 | 78 | |
79 | - add_action( 'admin_init', array( $this, 'init' ) ); |
|
79 | + add_action('admin_init', array($this, 'init')); |
|
80 | 80 | |
81 | 81 | |
82 | 82 | } |
@@ -87,19 +87,19 @@ discard block |
||
87 | 87 | function init() { |
88 | 88 | |
89 | 89 | // First get user's locale (4.7+). |
90 | - $this->locale = function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale(); |
|
90 | + $this->locale = function_exists('get_user_locale') ? get_user_locale() : get_locale(); |
|
91 | 91 | |
92 | 92 | // This plugin is en_US native. |
93 | - if ( 'en_US' === $this->locale ) { |
|
93 | + if ('en_US' === $this->locale) { |
|
94 | 94 | return; |
95 | 95 | } |
96 | 96 | |
97 | 97 | if ( |
98 | 98 | ! $this->hide_promo() |
99 | - && ( ! empty( $_GET['post_type'] ) && 'give_forms' === $_GET['post_type'] ) |
|
100 | - && ( ! empty( $_GET['page'] ) && 'give-settings' === $_GET['page'] ) |
|
99 | + && ( ! empty($_GET['post_type']) && 'give_forms' === $_GET['post_type']) |
|
100 | + && ( ! empty($_GET['page']) && 'give-settings' === $_GET['page']) |
|
101 | 101 | ) { |
102 | - add_action( $this->hook, array( $this, 'promo' ) ); |
|
102 | + add_action($this->hook, array($this, 'promo')); |
|
103 | 103 | } |
104 | 104 | } |
105 | 105 | |
@@ -112,11 +112,11 @@ discard block |
||
112 | 112 | * @return bool |
113 | 113 | */ |
114 | 114 | private function hide_promo() { |
115 | - $hide_promo = Give_Cache::get( 'give_i18n_give_promo_hide', true ); |
|
116 | - if ( ! $hide_promo ) { |
|
117 | - if ( filter_input( INPUT_GET, 'remove_i18n_promo', FILTER_VALIDATE_INT ) === 1 ) { |
|
115 | + $hide_promo = Give_Cache::get('give_i18n_give_promo_hide', true); |
|
116 | + if ( ! $hide_promo) { |
|
117 | + if (filter_input(INPUT_GET, 'remove_i18n_promo', FILTER_VALIDATE_INT) === 1) { |
|
118 | 118 | // No expiration time, so this would normally not expire, but it wouldn't be copied to other sites etc. |
119 | - Give_Cache::set( 'give_i18n_give_promo_hide', true, null, true ); |
|
119 | + Give_Cache::set('give_i18n_give_promo_hide', true, null, true); |
|
120 | 120 | $hide_promo = true; |
121 | 121 | } |
122 | 122 | } |
@@ -135,20 +135,20 @@ discard block |
||
135 | 135 | $message = false; |
136 | 136 | |
137 | 137 | // Using a translation less than 90% complete. |
138 | - if ( $this->translation_exists && $this->translation_loaded && $this->percent_translated < 90 ) { |
|
139 | - $message = __( 'As you can see, there is a translation of this plugin in %1$s. This translation is currently %3$d%% complete. We need your help to make it complete and to fix any errors. Please register at %4$s to help %5$s to %1$s!', 'give' ); |
|
140 | - } elseif ( ! $this->translation_loaded && $this->translation_exists ) { |
|
141 | - $message = __( 'You\'re using WordPress in %1$s. While %2$s has been %3$d%% translated to %1$s, it has not been shipped with the plugin yet. You can help! Register at %4$s to help complete the translation to %1$s!', 'give' ); |
|
142 | - } elseif ( ! $this->translation_exists ) { |
|
143 | - $message = __( 'You\'re using WordPress in a language we don\'t support yet. We\'d love for %2$s to be translated in that language too, but unfortunately, it isn\'t right now. You can change that! Register at %4$s to help translate it!', 'give' ); |
|
138 | + if ($this->translation_exists && $this->translation_loaded && $this->percent_translated < 90) { |
|
139 | + $message = __('As you can see, there is a translation of this plugin in %1$s. This translation is currently %3$d%% complete. We need your help to make it complete and to fix any errors. Please register at %4$s to help %5$s to %1$s!', 'give'); |
|
140 | + } elseif ( ! $this->translation_loaded && $this->translation_exists) { |
|
141 | + $message = __('You\'re using WordPress in %1$s. While %2$s has been %3$d%% translated to %1$s, it has not been shipped with the plugin yet. You can help! Register at %4$s to help complete the translation to %1$s!', 'give'); |
|
142 | + } elseif ( ! $this->translation_exists) { |
|
143 | + $message = __('You\'re using WordPress in a language we don\'t support yet. We\'d love for %2$s to be translated in that language too, but unfortunately, it isn\'t right now. You can change that! Register at %4$s to help translate it!', 'give'); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | // Links. |
147 | - $registration_link = sprintf( '<a href="%1$s" target="_blank">%2$s</a>', 'https://wordpress.org/support/register.php', esc_html__( 'WordPress.org', 'give' ) ); |
|
148 | - $translations_link = sprintf( '<a href="%1$s" target="_blank">%2$s</a>', 'https://translate.wordpress.org/projects/wp-plugins/give', esc_html__( 'complete the translation', 'give' ) ); |
|
147 | + $registration_link = sprintf('<a href="%1$s" target="_blank">%2$s</a>', 'https://wordpress.org/support/register.php', esc_html__('WordPress.org', 'give')); |
|
148 | + $translations_link = sprintf('<a href="%1$s" target="_blank">%2$s</a>', 'https://translate.wordpress.org/projects/wp-plugins/give', esc_html__('complete the translation', 'give')); |
|
149 | 149 | |
150 | 150 | // Message. |
151 | - $message = sprintf( $message, $this->locale_name, 'Give', $this->percent_translated, $registration_link, $translations_link ); |
|
151 | + $message = sprintf($message, $this->locale_name, 'Give', $this->percent_translated, $registration_link, $translations_link); |
|
152 | 152 | |
153 | 153 | return $message; |
154 | 154 | |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | $this->translation_details(); |
163 | 163 | $message = $this->promo_message(); |
164 | 164 | |
165 | - if ( $message ) { ?> |
|
165 | + if ($message) { ?> |
|
166 | 166 | |
167 | 167 | <style> |
168 | 168 | /* Banner specific styles */ |
@@ -227,12 +227,12 @@ discard block |
||
227 | 227 | style="font-size: 110px; text-decoration: none;"></span></a> |
228 | 228 | |
229 | 229 | <div class="give-i18n-notice-content"> |
230 | - <a href="<?php echo esc_url( add_query_arg( array( 'remove_i18n_promo' => '1' ) ) ); ?>" class="dismiss"><span class="dashicons dashicons-dismiss"></span></a> |
|
230 | + <a href="<?php echo esc_url(add_query_arg(array('remove_i18n_promo' => '1'))); ?>" class="dismiss"><span class="dashicons dashicons-dismiss"></span></a> |
|
231 | 231 | |
232 | - <h2 style="margin: 10px 0;"><?php printf( esc_html__( 'Help Translate Give to %s', 'give' ), $this->locale_name ); ?></h2> |
|
232 | + <h2 style="margin: 10px 0;"><?php printf(esc_html__('Help Translate Give to %s', 'give'), $this->locale_name); ?></h2> |
|
233 | 233 | <p><?php echo $message; ?></p> |
234 | 234 | <p> |
235 | - <a href="https://wordpress.org/support/register.php" target="_blank"><?php _e( 'Register now »', 'give' ); ?></a> |
|
235 | + <a href="https://wordpress.org/support/register.php" target="_blank"><?php _e('Register now »', 'give'); ?></a> |
|
236 | 236 | </p> |
237 | 237 | </div> |
238 | 238 | </div> |
@@ -249,11 +249,11 @@ discard block |
||
249 | 249 | */ |
250 | 250 | private function find_or_initialize_translation_details() { |
251 | 251 | |
252 | - $set = Give_Cache::get( "give_i18n_give_{$this->locale}", true ); |
|
252 | + $set = Give_Cache::get("give_i18n_give_{$this->locale}", true); |
|
253 | 253 | |
254 | - if ( ! $set ) { |
|
254 | + if ( ! $set) { |
|
255 | 255 | $set = $this->retrieve_translation_details(); |
256 | - Give_Cache::set( "give_i18n_give_{$this->locale}", $set, DAY_IN_SECONDS, true ); |
|
256 | + Give_Cache::set("give_i18n_give_{$this->locale}", $set, DAY_IN_SECONDS, true); |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | return $set; |
@@ -267,10 +267,10 @@ discard block |
||
267 | 267 | private function translation_details() { |
268 | 268 | $set = $this->find_or_initialize_translation_details(); |
269 | 269 | |
270 | - $this->translation_exists = ! is_null( $set ); |
|
271 | - $this->translation_loaded = is_textdomain_loaded( 'give' ); |
|
270 | + $this->translation_exists = ! is_null($set); |
|
271 | + $this->translation_loaded = is_textdomain_loaded('give'); |
|
272 | 272 | |
273 | - $this->parse_translation_set( $set ); |
|
273 | + $this->parse_translation_set($set); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | /** |
@@ -282,26 +282,26 @@ discard block |
||
282 | 282 | */ |
283 | 283 | private function retrieve_translation_details() { |
284 | 284 | |
285 | - $api_url = trailingslashit( $this->glotpress_url ); |
|
285 | + $api_url = trailingslashit($this->glotpress_url); |
|
286 | 286 | |
287 | - $resp = wp_remote_get( $api_url ); |
|
287 | + $resp = wp_remote_get($api_url); |
|
288 | 288 | |
289 | - if ( is_wp_error( $resp ) || wp_remote_retrieve_response_code( $resp ) === '404' ) { |
|
289 | + if (is_wp_error($resp) || wp_remote_retrieve_response_code($resp) === '404') { |
|
290 | 290 | return null; |
291 | 291 | } |
292 | 292 | |
293 | - $body = wp_remote_retrieve_body( $resp ); |
|
294 | - unset( $resp ); |
|
293 | + $body = wp_remote_retrieve_body($resp); |
|
294 | + unset($resp); |
|
295 | 295 | |
296 | - if ( $body ) { |
|
297 | - $body = json_decode( $body ); |
|
296 | + if ($body) { |
|
297 | + $body = json_decode($body); |
|
298 | 298 | |
299 | - foreach ( $body->translation_sets as $set ) { |
|
300 | - if ( ! property_exists( $set, 'wp_locale' ) ) { |
|
299 | + foreach ($body->translation_sets as $set) { |
|
300 | + if ( ! property_exists($set, 'wp_locale')) { |
|
301 | 301 | continue; |
302 | 302 | } |
303 | 303 | |
304 | - if ( $this->locale == $set->wp_locale ) { |
|
304 | + if ($this->locale == $set->wp_locale) { |
|
305 | 305 | return $set; |
306 | 306 | } |
307 | 307 | } |
@@ -317,8 +317,8 @@ discard block |
||
317 | 317 | * |
318 | 318 | * @access private |
319 | 319 | */ |
320 | - private function parse_translation_set( $set ) { |
|
321 | - if ( $this->translation_exists && is_object( $set ) ) { |
|
320 | + private function parse_translation_set($set) { |
|
321 | + if ($this->translation_exists && is_object($set)) { |
|
322 | 322 | $this->locale_name = $set->name; |
323 | 323 | $this->percent_translated = $set->percent_translated; |
324 | 324 | } else { |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | } |
329 | 329 | } |
330 | 330 | |
331 | -$give_i18n = new Give_i18n_Banner( array( |
|
331 | +$give_i18n = new Give_i18n_Banner(array( |
|
332 | 332 | 'hook' => 'admin_notices', |
333 | 333 | 'glotpress_url' => 'https://translate.wordpress.org/api/projects/wp-plugins/give/stable/', |
334 | - ) ); |
|
334 | + )); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -28,21 +28,21 @@ discard block |
||
28 | 28 | * |
29 | 29 | * @return void |
30 | 30 | */ |
31 | -function give_complete_purchase( $payment_id, $new_status, $old_status ) { |
|
31 | +function give_complete_purchase($payment_id, $new_status, $old_status) { |
|
32 | 32 | |
33 | 33 | // Make sure that payments are only completed once. |
34 | - if ( $old_status == 'publish' || $old_status == 'complete' ) { |
|
34 | + if ($old_status == 'publish' || $old_status == 'complete') { |
|
35 | 35 | return; |
36 | 36 | } |
37 | 37 | |
38 | 38 | // Make sure the payment completion is only processed when new status is complete. |
39 | - if ( $new_status != 'publish' && $new_status != 'complete' ) { |
|
39 | + if ($new_status != 'publish' && $new_status != 'complete') { |
|
40 | 40 | return; |
41 | 41 | } |
42 | 42 | |
43 | - $payment = new Give_Payment( $payment_id ); |
|
43 | + $payment = new Give_Payment($payment_id); |
|
44 | 44 | |
45 | - $creation_date = get_post_field( 'post_date', $payment_id, 'raw' ); |
|
45 | + $creation_date = get_post_field('post_date', $payment_id, 'raw'); |
|
46 | 46 | $payment_meta = $payment->payment_meta; |
47 | 47 | $completed_date = $payment->completed_date; |
48 | 48 | $user_info = $payment->user_info; |
@@ -58,12 +58,12 @@ discard block |
||
58 | 58 | * |
59 | 59 | * @param int $payment_id The ID of the payment. |
60 | 60 | */ |
61 | - do_action( 'give_pre_complete_donation', $payment_id ); |
|
61 | + do_action('give_pre_complete_donation', $payment_id); |
|
62 | 62 | |
63 | 63 | // Ensure these actions only run once, ever. |
64 | - if ( empty( $completed_date ) ) { |
|
64 | + if (empty($completed_date)) { |
|
65 | 65 | |
66 | - give_record_donation_in_log( $form_id, $payment_id, $price_id, $creation_date ); |
|
66 | + give_record_donation_in_log($form_id, $payment_id, $price_id, $creation_date); |
|
67 | 67 | |
68 | 68 | /** |
69 | 69 | * Fires after logging donation record. |
@@ -74,29 +74,29 @@ discard block |
||
74 | 74 | * @param int $payment_id The ID number of the payment. |
75 | 75 | * @param array $payment_meta The payment meta. |
76 | 76 | */ |
77 | - do_action( 'give_complete_form_donation', $form_id, $payment_id, $payment_meta ); |
|
77 | + do_action('give_complete_form_donation', $form_id, $payment_id, $payment_meta); |
|
78 | 78 | |
79 | 79 | } |
80 | 80 | |
81 | 81 | // Increase the earnings for this form ID. |
82 | - give_increase_earnings( $form_id, $amount ); |
|
83 | - give_increase_donation_count( $form_id ); |
|
82 | + give_increase_earnings($form_id, $amount); |
|
83 | + give_increase_donation_count($form_id); |
|
84 | 84 | |
85 | 85 | // @todo: Refresh only range related stat cache |
86 | 86 | give_delete_donation_stats(); |
87 | 87 | |
88 | 88 | // Increase the donor's donation stats. |
89 | - $donor = new Give_Donor( $donor_id ); |
|
89 | + $donor = new Give_Donor($donor_id); |
|
90 | 90 | $donor->increase_purchase_count(); |
91 | - $donor->increase_value( $amount ); |
|
91 | + $donor->increase_value($amount); |
|
92 | 92 | |
93 | - give_increase_total_earnings( $amount ); |
|
93 | + give_increase_total_earnings($amount); |
|
94 | 94 | |
95 | 95 | // Ensure this action only runs once ever. |
96 | - if ( empty( $completed_date ) ) { |
|
96 | + if (empty($completed_date)) { |
|
97 | 97 | |
98 | 98 | // Save the completed date. |
99 | - $payment->completed_date = current_time( 'mysql' ); |
|
99 | + $payment->completed_date = current_time('mysql'); |
|
100 | 100 | $payment->save(); |
101 | 101 | |
102 | 102 | /** |
@@ -106,12 +106,12 @@ discard block |
||
106 | 106 | * |
107 | 107 | * @param int $payment_id The ID of the payment. |
108 | 108 | */ |
109 | - do_action( 'give_complete_donation', $payment_id ); |
|
109 | + do_action('give_complete_donation', $payment_id); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | } |
113 | 113 | |
114 | -add_action( 'give_update_payment_status', 'give_complete_purchase', 100, 3 ); |
|
114 | +add_action('give_update_payment_status', 'give_complete_purchase', 100, 3); |
|
115 | 115 | |
116 | 116 | |
117 | 117 | /** |
@@ -125,20 +125,20 @@ discard block |
||
125 | 125 | * |
126 | 126 | * @return void |
127 | 127 | */ |
128 | -function give_record_status_change( $payment_id, $new_status, $old_status ) { |
|
128 | +function give_record_status_change($payment_id, $new_status, $old_status) { |
|
129 | 129 | |
130 | 130 | // Get the list of statuses so that status in the payment note can be translated. |
131 | 131 | $stati = give_get_payment_statuses(); |
132 | - $old_status = isset( $stati[ $old_status ] ) ? $stati[ $old_status ] : $old_status; |
|
133 | - $new_status = isset( $stati[ $new_status ] ) ? $stati[ $new_status ] : $new_status; |
|
132 | + $old_status = isset($stati[$old_status]) ? $stati[$old_status] : $old_status; |
|
133 | + $new_status = isset($stati[$new_status]) ? $stati[$new_status] : $new_status; |
|
134 | 134 | |
135 | 135 | // translators: 1: old status 2: new status. |
136 | - $status_change = sprintf( esc_html__( 'Status changed from %1$s to %2$s.', 'give' ), $old_status, $new_status ); |
|
136 | + $status_change = sprintf(esc_html__('Status changed from %1$s to %2$s.', 'give'), $old_status, $new_status); |
|
137 | 137 | |
138 | - give_insert_payment_note( $payment_id, $status_change ); |
|
138 | + give_insert_payment_note($payment_id, $status_change); |
|
139 | 139 | } |
140 | 140 | |
141 | -add_action( 'give_update_payment_status', 'give_record_status_change', 100, 3 ); |
|
141 | +add_action('give_update_payment_status', 'give_record_status_change', 100, 3); |
|
142 | 142 | |
143 | 143 | |
144 | 144 | /** |
@@ -154,25 +154,25 @@ discard block |
||
154 | 154 | * |
155 | 155 | * @return void |
156 | 156 | */ |
157 | -function give_update_old_payments_with_totals( $data ) { |
|
158 | - if ( ! wp_verify_nonce( $data['_wpnonce'], 'give_upgrade_payments_nonce' ) ) { |
|
157 | +function give_update_old_payments_with_totals($data) { |
|
158 | + if ( ! wp_verify_nonce($data['_wpnonce'], 'give_upgrade_payments_nonce')) { |
|
159 | 159 | return; |
160 | 160 | } |
161 | 161 | |
162 | - if ( get_option( 'give_payment_totals_upgraded' ) ) { |
|
162 | + if (get_option('give_payment_totals_upgraded')) { |
|
163 | 163 | return; |
164 | 164 | } |
165 | 165 | |
166 | - $payments = give_get_payments( array( |
|
166 | + $payments = give_get_payments(array( |
|
167 | 167 | 'offset' => 0, |
168 | - 'number' => - 1, |
|
168 | + 'number' => -1, |
|
169 | 169 | 'mode' => 'all', |
170 | - ) ); |
|
170 | + )); |
|
171 | 171 | |
172 | - if ( $payments ) { |
|
173 | - foreach ( $payments as $payment ) { |
|
172 | + if ($payments) { |
|
173 | + foreach ($payments as $payment) { |
|
174 | 174 | |
175 | - $payment = new Give_Payment( $payment->ID ); |
|
175 | + $payment = new Give_Payment($payment->ID); |
|
176 | 176 | $meta = $payment->get_meta(); |
177 | 177 | |
178 | 178 | $payment->total = $meta['amount']; |
@@ -181,10 +181,10 @@ discard block |
||
181 | 181 | } |
182 | 182 | } |
183 | 183 | |
184 | - add_option( 'give_payment_totals_upgraded', 1 ); |
|
184 | + add_option('give_payment_totals_upgraded', 1); |
|
185 | 185 | } |
186 | 186 | |
187 | -add_action( 'give_upgrade_payments', 'give_update_old_payments_with_totals' ); |
|
187 | +add_action('give_upgrade_payments', 'give_update_old_payments_with_totals'); |
|
188 | 188 | |
189 | 189 | /** |
190 | 190 | * Mark Abandoned Donations |
@@ -198,17 +198,17 @@ discard block |
||
198 | 198 | function give_mark_abandoned_donations() { |
199 | 199 | $args = array( |
200 | 200 | 'status' => 'pending', |
201 | - 'number' => - 1, |
|
201 | + 'number' => -1, |
|
202 | 202 | 'output' => 'give_payments', |
203 | 203 | ); |
204 | 204 | |
205 | - add_filter( 'posts_where', 'give_filter_where_older_than_week' ); |
|
205 | + add_filter('posts_where', 'give_filter_where_older_than_week'); |
|
206 | 206 | |
207 | - $payments = give_get_payments( $args ); |
|
207 | + $payments = give_get_payments($args); |
|
208 | 208 | |
209 | - remove_filter( 'posts_where', 'give_filter_where_older_than_week' ); |
|
209 | + remove_filter('posts_where', 'give_filter_where_older_than_week'); |
|
210 | 210 | |
211 | - if ( $payments ) { |
|
211 | + if ($payments) { |
|
212 | 212 | /** |
213 | 213 | * Filter payment gateways: Used to set payment gateways which can be skip while transferring pending payment to abandon. |
214 | 214 | * |
@@ -216,13 +216,13 @@ discard block |
||
216 | 216 | * |
217 | 217 | * @param array $skip_payment_gateways Array of payment gateways |
218 | 218 | */ |
219 | - $skip_payment_gateways = apply_filters( 'give_mark_abandoned_donation_gateways', array( 'offline' ) ); |
|
219 | + $skip_payment_gateways = apply_filters('give_mark_abandoned_donation_gateways', array('offline')); |
|
220 | 220 | |
221 | - foreach ( $payments as $payment ) { |
|
222 | - $gateway = give_get_payment_gateway( $payment ); |
|
221 | + foreach ($payments as $payment) { |
|
222 | + $gateway = give_get_payment_gateway($payment); |
|
223 | 223 | |
224 | 224 | // Skip payment gateways. |
225 | - if ( in_array( $gateway, $skip_payment_gateways ) ) { |
|
225 | + if (in_array($gateway, $skip_payment_gateways)) { |
|
226 | 226 | continue; |
227 | 227 | } |
228 | 228 | |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | } |
233 | 233 | } |
234 | 234 | |
235 | -Give_Cron::add_weekly_event( 'give_mark_abandoned_donations' ); |
|
235 | +Give_Cron::add_weekly_event('give_mark_abandoned_donations'); |
|
236 | 236 | |
237 | 237 | |
238 | 238 | /** |
@@ -244,15 +244,15 @@ discard block |
||
244 | 244 | * |
245 | 245 | * @return void |
246 | 246 | */ |
247 | -function give_refresh_thismonth_stat_transients( $payment_ID ) { |
|
247 | +function give_refresh_thismonth_stat_transients($payment_ID) { |
|
248 | 248 | // Monthly stats. |
249 | - Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) ); |
|
249 | + Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats')); |
|
250 | 250 | |
251 | 251 | // @todo: Refresh only range related stat cache |
252 | 252 | give_delete_donation_stats(); |
253 | 253 | } |
254 | 254 | |
255 | -add_action( 'save_post_give_payment', 'give_refresh_thismonth_stat_transients' ); |
|
255 | +add_action('save_post_give_payment', 'give_refresh_thismonth_stat_transients'); |
|
256 | 256 | |
257 | 257 | /* |
258 | 258 | * Add meta in payment that store page id and page url. |
@@ -264,18 +264,18 @@ discard block |
||
264 | 264 | * |
265 | 265 | * @param {integer} $payment_id Payment id for which the meta value should be updated. |
266 | 266 | */ |
267 | -function give_payment_save_page_data( $payment_id ) { |
|
268 | - $page_url = ( ! empty( $_REQUEST['give-current-url'] ) ? esc_url( $_REQUEST['give-current-url'] ) : false ); |
|
267 | +function give_payment_save_page_data($payment_id) { |
|
268 | + $page_url = ( ! empty($_REQUEST['give-current-url']) ? esc_url($_REQUEST['give-current-url']) : false); |
|
269 | 269 | // Check $page_url is not empty. |
270 | - if ( $page_url ) { |
|
271 | - update_post_meta( $payment_id, '_give_current_url', $page_url ); |
|
272 | - $page_id = url_to_postid( $page_url ); |
|
270 | + if ($page_url) { |
|
271 | + update_post_meta($payment_id, '_give_current_url', $page_url); |
|
272 | + $page_id = url_to_postid($page_url); |
|
273 | 273 | // Check $page_id is not empty. |
274 | - if ( $page_id ) { |
|
275 | - update_post_meta( $payment_id, '_give_current_page_id', $page_id ); |
|
274 | + if ($page_id) { |
|
275 | + update_post_meta($payment_id, '_give_current_page_id', $page_id); |
|
276 | 276 | } |
277 | 277 | } |
278 | 278 | } |
279 | 279 | |
280 | 280 | // Fire when payment is save. |
281 | -add_action( 'give_insert_payment', 'give_payment_save_page_data' ); |
|
282 | 281 | \ No newline at end of file |
282 | +add_action('give_insert_payment', 'give_payment_save_page_data'); |
|
283 | 283 | \ No newline at end of file |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * @return static |
52 | 52 | */ |
53 | 53 | public static function get_instance() { |
54 | - if ( null === static::$instance ) { |
|
54 | + if (null === static::$instance) { |
|
55 | 55 | self::$instance = new static(); |
56 | 56 | self::$instance->setup(); |
57 | 57 | } |
@@ -66,12 +66,12 @@ discard block |
||
66 | 66 | * @since 1.8.13 |
67 | 67 | */ |
68 | 68 | private function setup() { |
69 | - add_filter( 'cron_schedules', array( self::$instance, '__add_schedules' ) ); |
|
70 | - add_action( 'wp', array( self::$instance, '__schedule_events' ) ); |
|
69 | + add_filter('cron_schedules', array(self::$instance, '__add_schedules')); |
|
70 | + add_action('wp', array(self::$instance, '__schedule_events')); |
|
71 | 71 | |
72 | 72 | // Load async event only when cron is running. |
73 | - if( defined( 'DOING_CRON' ) && DOING_CRON ) { |
|
74 | - add_action( 'init', array( self::$instance, '__load_async_events' ) ); |
|
73 | + if (defined('DOING_CRON') && DOING_CRON) { |
|
74 | + add_action('init', array(self::$instance, '__load_async_events')); |
|
75 | 75 | } |
76 | 76 | } |
77 | 77 | |
@@ -82,23 +82,23 @@ discard block |
||
82 | 82 | * @since 1.8.13 |
83 | 83 | */ |
84 | 84 | public function __load_async_events() { |
85 | - $async_events = get_option( 'give_async_events', array() ); |
|
85 | + $async_events = get_option('give_async_events', array()); |
|
86 | 86 | |
87 | 87 | // Bailout. |
88 | - if ( empty( $async_events ) ) { |
|
88 | + if (empty($async_events)) { |
|
89 | 89 | return; |
90 | 90 | } |
91 | 91 | |
92 | - foreach ( $async_events as $index => $event ) { |
|
92 | + foreach ($async_events as $index => $event) { |
|
93 | 93 | // Set cron name. |
94 | 94 | $cron_name = "give_async_scheduled_events_{$index}"; |
95 | 95 | |
96 | 96 | // Setup cron. |
97 | - wp_schedule_single_event( current_time( 'timestamp', 1 ), $cron_name, $event['params'] ); |
|
97 | + wp_schedule_single_event(current_time('timestamp', 1), $cron_name, $event['params']); |
|
98 | 98 | |
99 | 99 | // Add cron action. |
100 | - add_action( $cron_name, $event['callback'], 10, count( $event['params'] ) ); |
|
101 | - add_action( $cron_name, array( $this, '__delete_async_events' ), 9999, 0 ); |
|
100 | + add_action($cron_name, $event['callback'], 10, count($event['params'])); |
|
101 | + add_action($cron_name, array($this, '__delete_async_events'), 9999, 0); |
|
102 | 102 | } |
103 | 103 | } |
104 | 104 | |
@@ -108,13 +108,13 @@ discard block |
||
108 | 108 | * @since 1.8.13 |
109 | 109 | */ |
110 | 110 | public function __delete_async_events() { |
111 | - $async_events = get_option( 'give_async_events', array() ); |
|
112 | - $cron_name_parts = explode( '_', current_action() ); |
|
113 | - $cron_id = end( $cron_name_parts ); |
|
111 | + $async_events = get_option('give_async_events', array()); |
|
112 | + $cron_name_parts = explode('_', current_action()); |
|
113 | + $cron_id = end($cron_name_parts); |
|
114 | 114 | |
115 | - if ( ! empty( $async_events[ $cron_id ] ) ) { |
|
116 | - unset( $async_events[ $cron_id ] ); |
|
117 | - update_option( 'give_async_events', $async_events ); |
|
115 | + if ( ! empty($async_events[$cron_id])) { |
|
116 | + unset($async_events[$cron_id]); |
|
117 | + update_option('give_async_events', $async_events); |
|
118 | 118 | } |
119 | 119 | } |
120 | 120 | |
@@ -128,11 +128,11 @@ discard block |
||
128 | 128 | * |
129 | 129 | * @return array An array of non-default cron schedules. |
130 | 130 | */ |
131 | - public function __add_schedules( $schedules = array() ) { |
|
131 | + public function __add_schedules($schedules = array()) { |
|
132 | 132 | // Adds once weekly to the existing schedules. |
133 | 133 | $schedules['weekly'] = array( |
134 | 134 | 'interval' => 604800, |
135 | - 'display' => __( 'Once Weekly', 'give' ), |
|
135 | + 'display' => __('Once Weekly', 'give'), |
|
136 | 136 | ); |
137 | 137 | |
138 | 138 | return $schedules; |
@@ -160,8 +160,8 @@ discard block |
||
160 | 160 | * @return void |
161 | 161 | */ |
162 | 162 | private function weekly_events() { |
163 | - if ( ! wp_next_scheduled( 'give_weekly_scheduled_events' ) ) { |
|
164 | - wp_schedule_event( current_time( 'timestamp' ), 'weekly', 'give_weekly_scheduled_events' ); |
|
163 | + if ( ! wp_next_scheduled('give_weekly_scheduled_events')) { |
|
164 | + wp_schedule_event(current_time('timestamp'), 'weekly', 'give_weekly_scheduled_events'); |
|
165 | 165 | } |
166 | 166 | } |
167 | 167 | |
@@ -174,8 +174,8 @@ discard block |
||
174 | 174 | * @return void |
175 | 175 | */ |
176 | 176 | private function daily_events() { |
177 | - if ( ! wp_next_scheduled( 'give_daily_scheduled_events' ) ) { |
|
178 | - wp_schedule_event( current_time( 'timestamp' ), 'daily', 'give_daily_scheduled_events' ); |
|
177 | + if ( ! wp_next_scheduled('give_daily_scheduled_events')) { |
|
178 | + wp_schedule_event(current_time('timestamp'), 'daily', 'give_daily_scheduled_events'); |
|
179 | 179 | } |
180 | 180 | } |
181 | 181 | |
@@ -189,8 +189,8 @@ discard block |
||
189 | 189 | * |
190 | 190 | * @return string |
191 | 191 | */ |
192 | - public static function get_cron_action( $type = 'weekly' ) { |
|
193 | - switch ( $type ) { |
|
192 | + public static function get_cron_action($type = 'weekly') { |
|
193 | + switch ($type) { |
|
194 | 194 | case 'daily': |
195 | 195 | $cron_action = 'give_daily_scheduled_events'; |
196 | 196 | break; |
@@ -212,9 +212,9 @@ discard block |
||
212 | 212 | * @param $action |
213 | 213 | * @param string $type |
214 | 214 | */ |
215 | - private static function add_event( $action, $type = 'weekly' ) { |
|
216 | - $cron_event = self::get_cron_action( $type ); |
|
217 | - add_action( $cron_event, $action ); |
|
215 | + private static function add_event($action, $type = 'weekly') { |
|
216 | + $cron_event = self::get_cron_action($type); |
|
217 | + add_action($cron_event, $action); |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | /** |
@@ -225,8 +225,8 @@ discard block |
||
225 | 225 | * |
226 | 226 | * @param $action |
227 | 227 | */ |
228 | - public static function add_weekly_event( $action ) { |
|
229 | - self::add_event( $action, 'weekly' ); |
|
228 | + public static function add_weekly_event($action) { |
|
229 | + self::add_event($action, 'weekly'); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | /** |
@@ -237,8 +237,8 @@ discard block |
||
237 | 237 | * |
238 | 238 | * @param $action |
239 | 239 | */ |
240 | - public static function add_daily_event( $action ) { |
|
241 | - self::add_event( $action, 'daily' ); |
|
240 | + public static function add_daily_event($action) { |
|
241 | + self::add_event($action, 'daily'); |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | /** |
@@ -251,17 +251,17 @@ discard block |
||
251 | 251 | * @param string $action |
252 | 252 | * @param array $args |
253 | 253 | */ |
254 | - public static function add_async_event( $action, $args = array() ) { |
|
254 | + public static function add_async_event($action, $args = array()) { |
|
255 | 255 | |
256 | 256 | // Cache async events. |
257 | - $async_events = get_option( 'give_async_events', array() ); |
|
258 | - $async_events[ uniqid() ] = array( |
|
257 | + $async_events = get_option('give_async_events', array()); |
|
258 | + $async_events[uniqid()] = array( |
|
259 | 259 | 'callback' => $action, |
260 | 260 | 'params' => $args, |
261 | 261 | ); |
262 | 262 | |
263 | 263 | |
264 | - update_option( 'give_async_events', $async_events ); |
|
264 | + update_option('give_async_events', $async_events); |
|
265 | 265 | } |
266 | 266 | } |
267 | 267 |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -26,15 +26,15 @@ discard block |
||
26 | 26 | * @global $wpdb |
27 | 27 | * @return void |
28 | 28 | */ |
29 | -function give_install( $network_wide = false ) { |
|
29 | +function give_install($network_wide = false) { |
|
30 | 30 | |
31 | 31 | global $wpdb; |
32 | 32 | |
33 | - if ( is_multisite() && $network_wide ) { |
|
33 | + if (is_multisite() && $network_wide) { |
|
34 | 34 | |
35 | - foreach ( $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs LIMIT 100" ) as $blog_id ) { |
|
35 | + foreach ($wpdb->get_col("SELECT blog_id FROM $wpdb->blogs LIMIT 100") as $blog_id) { |
|
36 | 36 | |
37 | - switch_to_blog( $blog_id ); |
|
37 | + switch_to_blog($blog_id); |
|
38 | 38 | give_run_install(); |
39 | 39 | restore_current_blog(); |
40 | 40 | |
@@ -61,31 +61,31 @@ discard block |
||
61 | 61 | give_setup_post_types(); |
62 | 62 | |
63 | 63 | // Add Upgraded From Option. |
64 | - $current_version = get_option( 'give_version' ); |
|
65 | - if ( $current_version ) { |
|
66 | - update_option( 'give_version_upgraded_from', $current_version ); |
|
64 | + $current_version = get_option('give_version'); |
|
65 | + if ($current_version) { |
|
66 | + update_option('give_version_upgraded_from', $current_version); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | // Setup some default options. |
70 | 70 | $options = array(); |
71 | 71 | |
72 | 72 | //Fresh Install? Setup Test Mode, Base Country (US), Test Gateway, Currency. |
73 | - if ( empty( $current_version ) ) { |
|
74 | - $options = array_merge( $options, give_get_default_settings() ); |
|
73 | + if (empty($current_version)) { |
|
74 | + $options = array_merge($options, give_get_default_settings()); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | // Populate the default values. |
78 | - update_option( 'give_settings', array_merge( $give_options, $options ) ); |
|
78 | + update_option('give_settings', array_merge($give_options, $options)); |
|
79 | 79 | |
80 | 80 | /** |
81 | 81 | * Run plugin upgrades. |
82 | 82 | * |
83 | 83 | * @since 1.8 |
84 | 84 | */ |
85 | - do_action( 'give_upgrades' ); |
|
85 | + do_action('give_upgrades'); |
|
86 | 86 | |
87 | - if ( GIVE_VERSION !== get_option( 'give_version' ) ) { |
|
88 | - update_option( 'give_version', GIVE_VERSION ); |
|
87 | + if (GIVE_VERSION !== get_option('give_version')) { |
|
88 | + update_option('give_version', GIVE_VERSION); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | // Create Give roles. |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | // Set api version, end point and refresh permalink. |
97 | 97 | $api = new Give_API(); |
98 | 98 | $api->add_endpoint(); |
99 | - update_option( 'give_default_api_version', 'v' . $api->get_version() ); |
|
99 | + update_option('give_default_api_version', 'v'.$api->get_version()); |
|
100 | 100 | |
101 | 101 | flush_rewrite_rules(); |
102 | 102 | |
@@ -105,11 +105,11 @@ discard block |
||
105 | 105 | $give_sessions->use_php_sessions(); |
106 | 106 | |
107 | 107 | // Add a temporary option to note that Give pages have been created. |
108 | - Give_Cache::set( '_give_installed', $options, 30, true ); |
|
108 | + Give_Cache::set('_give_installed', $options, 30, true); |
|
109 | 109 | |
110 | - if ( ! $current_version ) { |
|
110 | + if ( ! $current_version) { |
|
111 | 111 | |
112 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php'; |
|
112 | + require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrade-functions.php'; |
|
113 | 113 | |
114 | 114 | // When new upgrade routines are added, mark them as complete on fresh install. |
115 | 115 | $upgrade_routines = array( |
@@ -125,18 +125,18 @@ discard block |
||
125 | 125 | 'v1813_update_donor_user_roles' |
126 | 126 | ); |
127 | 127 | |
128 | - foreach ( $upgrade_routines as $upgrade ) { |
|
129 | - give_set_upgrade_complete( $upgrade ); |
|
128 | + foreach ($upgrade_routines as $upgrade) { |
|
129 | + give_set_upgrade_complete($upgrade); |
|
130 | 130 | } |
131 | 131 | } |
132 | 132 | |
133 | 133 | // Bail if activating from network, or bulk. |
134 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
134 | + if (is_network_admin() || isset($_GET['activate-multi'])) { |
|
135 | 135 | return; |
136 | 136 | } |
137 | 137 | |
138 | 138 | // Add the transient to redirect. |
139 | - Give_Cache::set( '_give_activation_redirect', true, 30, true ); |
|
139 | + Give_Cache::set('_give_activation_redirect', true, 30, true); |
|
140 | 140 | |
141 | 141 | // Set 'Donation Form' meta box enabled by default. |
142 | 142 | give_nav_donation_metabox_enabled(); |
@@ -156,11 +156,11 @@ discard block |
||
156 | 156 | * @param int $site_id The Site ID. |
157 | 157 | * @param array $meta Blog Meta. |
158 | 158 | */ |
159 | -function give_on_create_blog( $blog_id, $user_id, $domain, $path, $site_id, $meta ) { |
|
159 | +function give_on_create_blog($blog_id, $user_id, $domain, $path, $site_id, $meta) { |
|
160 | 160 | |
161 | - if ( is_plugin_active_for_network( GIVE_PLUGIN_BASENAME ) ) { |
|
161 | + if (is_plugin_active_for_network(GIVE_PLUGIN_BASENAME)) { |
|
162 | 162 | |
163 | - switch_to_blog( $blog_id ); |
|
163 | + switch_to_blog($blog_id); |
|
164 | 164 | give_install(); |
165 | 165 | restore_current_blog(); |
166 | 166 | |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | |
169 | 169 | } |
170 | 170 | |
171 | -add_action( 'wpmu_new_blog', 'give_on_create_blog', 10, 6 ); |
|
171 | +add_action('wpmu_new_blog', 'give_on_create_blog', 10, 6); |
|
172 | 172 | |
173 | 173 | |
174 | 174 | /** |
@@ -181,13 +181,13 @@ discard block |
||
181 | 181 | * |
182 | 182 | * @return array The tables to drop. |
183 | 183 | */ |
184 | -function give_wpmu_drop_tables( $tables, $blog_id ) { |
|
184 | +function give_wpmu_drop_tables($tables, $blog_id) { |
|
185 | 185 | |
186 | - switch_to_blog( $blog_id ); |
|
186 | + switch_to_blog($blog_id); |
|
187 | 187 | $donors_db = new Give_DB_Donors(); |
188 | 188 | $donor_meta_db = new Give_DB_Donor_Meta(); |
189 | 189 | |
190 | - if ( $donors_db->installed() ) { |
|
190 | + if ($donors_db->installed()) { |
|
191 | 191 | $tables[] = $donors_db->table_name; |
192 | 192 | $tables[] = $donor_meta_db->table_name; |
193 | 193 | } |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | |
198 | 198 | } |
199 | 199 | |
200 | -add_filter( 'wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2 ); |
|
200 | +add_filter('wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2); |
|
201 | 201 | |
202 | 202 | /** |
203 | 203 | * Post-installation |
@@ -209,16 +209,16 @@ discard block |
||
209 | 209 | */ |
210 | 210 | function give_after_install() { |
211 | 211 | |
212 | - if ( ! is_admin() ) { |
|
212 | + if ( ! is_admin()) { |
|
213 | 213 | return; |
214 | 214 | } |
215 | 215 | |
216 | - $give_options = Give_Cache::get( '_give_installed', true ); |
|
217 | - $give_table_check = get_option( '_give_table_check', false ); |
|
216 | + $give_options = Give_Cache::get('_give_installed', true); |
|
217 | + $give_table_check = get_option('_give_table_check', false); |
|
218 | 218 | |
219 | - if ( false === $give_table_check || current_time( 'timestamp' ) > $give_table_check ) { |
|
219 | + if (false === $give_table_check || current_time('timestamp') > $give_table_check) { |
|
220 | 220 | |
221 | - if ( ! @Give()->donor_meta->installed() ) { |
|
221 | + if ( ! @Give()->donor_meta->installed()) { |
|
222 | 222 | |
223 | 223 | // Create the donor meta database. |
224 | 224 | // (this ensures it creates it on multisite instances where it is network activated). |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | |
227 | 227 | } |
228 | 228 | |
229 | - if ( ! @Give()->donors->installed() ) { |
|
229 | + if ( ! @Give()->donors->installed()) { |
|
230 | 230 | // Create the donor database. |
231 | 231 | // (this ensures it creates it on multisite instances where it is network activated). |
232 | 232 | @Give()->donors->create_table(); |
@@ -238,22 +238,22 @@ discard block |
||
238 | 238 | * |
239 | 239 | * @param array $give_options Give plugin options. |
240 | 240 | */ |
241 | - do_action( 'give_after_install', $give_options ); |
|
241 | + do_action('give_after_install', $give_options); |
|
242 | 242 | } |
243 | 243 | |
244 | - update_option( '_give_table_check', ( current_time( 'timestamp' ) + WEEK_IN_SECONDS ) ); |
|
244 | + update_option('_give_table_check', (current_time('timestamp') + WEEK_IN_SECONDS)); |
|
245 | 245 | |
246 | 246 | } |
247 | 247 | |
248 | 248 | // Delete the transient |
249 | - if ( false !== $give_options ) { |
|
250 | - Give_Cache::delete( Give_Cache::get_key( '_give_installed' ) ); |
|
249 | + if (false !== $give_options) { |
|
250 | + Give_Cache::delete(Give_Cache::get_key('_give_installed')); |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | |
254 | 254 | } |
255 | 255 | |
256 | -add_action( 'admin_init', 'give_after_install' ); |
|
256 | +add_action('admin_init', 'give_after_install'); |
|
257 | 257 | |
258 | 258 | |
259 | 259 | /** |
@@ -268,11 +268,11 @@ discard block |
||
268 | 268 | |
269 | 269 | global $wp_roles; |
270 | 270 | |
271 | - if ( ! is_object( $wp_roles ) ) { |
|
271 | + if ( ! is_object($wp_roles)) { |
|
272 | 272 | return; |
273 | 273 | } |
274 | 274 | |
275 | - if ( ! array_key_exists( 'give_manager', $wp_roles->roles ) ) { |
|
275 | + if ( ! array_key_exists('give_manager', $wp_roles->roles)) { |
|
276 | 276 | |
277 | 277 | // Create Give plugin roles |
278 | 278 | $roles = new Give_Roles(); |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | |
284 | 284 | } |
285 | 285 | |
286 | -add_action( 'admin_init', 'give_install_roles_on_network' ); |
|
286 | +add_action('admin_init', 'give_install_roles_on_network'); |
|
287 | 287 | |
288 | 288 | /** |
289 | 289 | * Default core setting values. |
@@ -321,14 +321,14 @@ discard block |
||
321 | 321 | 'uninstall_on_delete' => 'disabled', |
322 | 322 | 'the_content_filter' => 'enabled', |
323 | 323 | 'scripts_footer' => 'disabled', |
324 | - 'agree_to_terms_label' => __( 'Agree to Terms?', 'give' ), |
|
324 | + 'agree_to_terms_label' => __('Agree to Terms?', 'give'), |
|
325 | 325 | 'agreement_text' => give_get_default_agreement_text(), |
326 | 326 | |
327 | 327 | // Paypal IPN verification. |
328 | 328 | 'paypal_verification' => 'enabled', |
329 | 329 | |
330 | 330 | // Default is manual gateway. |
331 | - 'gateways' => array( 'manual' => 1, 'offline' => 1 ), |
|
331 | + 'gateways' => array('manual' => 1, 'offline' => 1), |
|
332 | 332 | 'default_gateway' => 'manual', |
333 | 333 | |
334 | 334 | // Offline gateway setup. |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | */ |
357 | 357 | function give_get_default_agreement_text() { |
358 | 358 | |
359 | - $org_name = get_bloginfo( 'name' ); |
|
359 | + $org_name = get_bloginfo('name'); |
|
360 | 360 | |
361 | 361 | $agreement = sprintf( |
362 | 362 | '<p>Acceptance of any contribution, gift or grant is at the discretion of the %1$s. The %1$s will not accept any gift unless it can be used or expended consistently with the purpose and mission of the %1$s.</p> |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | $org_name |
371 | 371 | ); |
372 | 372 | |
373 | - return apply_filters( 'give_get_default_agreement_text', $agreement, $org_name ); |
|
373 | + return apply_filters('give_get_default_agreement_text', $agreement, $org_name); |
|
374 | 374 | } |
375 | 375 | |
376 | 376 | |
@@ -379,22 +379,22 @@ discard block |
||
379 | 379 | * |
380 | 380 | * @since 1.8.11 |
381 | 381 | */ |
382 | -function give_create_pages(){ |
|
382 | +function give_create_pages() { |
|
383 | 383 | |
384 | 384 | // Bailout if pages already created. |
385 | - if( get_option( 'give_install_pages_created') ) { |
|
385 | + if (get_option('give_install_pages_created')) { |
|
386 | 386 | return false; |
387 | 387 | } |
388 | 388 | |
389 | 389 | $options = array(); |
390 | 390 | |
391 | 391 | // Checks if the Success Page option exists AND that the page exists. |
392 | - if ( ! get_post( give_get_option( 'success_page' ) ) ) { |
|
392 | + if ( ! get_post(give_get_option('success_page'))) { |
|
393 | 393 | |
394 | 394 | // Donation Confirmation (Success) Page |
395 | 395 | $success = wp_insert_post( |
396 | 396 | array( |
397 | - 'post_title' => esc_html__( 'Donation Confirmation', 'give' ), |
|
397 | + 'post_title' => esc_html__('Donation Confirmation', 'give'), |
|
398 | 398 | 'post_content' => '[give_receipt]', |
399 | 399 | 'post_status' => 'publish', |
400 | 400 | 'post_author' => 1, |
@@ -408,13 +408,13 @@ discard block |
||
408 | 408 | } |
409 | 409 | |
410 | 410 | // Checks if the Failure Page option exists AND that the page exists. |
411 | - if ( ! get_post( give_get_option( 'failure_page' ) ) ) { |
|
411 | + if ( ! get_post(give_get_option('failure_page'))) { |
|
412 | 412 | |
413 | 413 | // Failed Donation Page |
414 | 414 | $failed = wp_insert_post( |
415 | 415 | array( |
416 | - 'post_title' => esc_html__( 'Donation Failed', 'give' ), |
|
417 | - 'post_content' => esc_html__( 'We\'re sorry, your donation failed to process. Please try again or contact site support.', 'give' ), |
|
416 | + 'post_title' => esc_html__('Donation Failed', 'give'), |
|
417 | + 'post_content' => esc_html__('We\'re sorry, your donation failed to process. Please try again or contact site support.', 'give'), |
|
418 | 418 | 'post_status' => 'publish', |
419 | 419 | 'post_author' => 1, |
420 | 420 | 'post_type' => 'page', |
@@ -426,11 +426,11 @@ discard block |
||
426 | 426 | } |
427 | 427 | |
428 | 428 | // Checks if the History Page option exists AND that the page exists. |
429 | - if ( ! get_post( give_get_option( 'history_page' ) ) ) { |
|
429 | + if ( ! get_post(give_get_option('history_page'))) { |
|
430 | 430 | // Donation History Page |
431 | 431 | $history = wp_insert_post( |
432 | 432 | array( |
433 | - 'post_title' => esc_html__( 'Donation History', 'give' ), |
|
433 | + 'post_title' => esc_html__('Donation History', 'give'), |
|
434 | 434 | 'post_content' => '[donation_history]', |
435 | 435 | 'post_status' => 'publish', |
436 | 436 | 'post_author' => 1, |
@@ -442,10 +442,10 @@ discard block |
||
442 | 442 | $options['history_page'] = $history; |
443 | 443 | } |
444 | 444 | |
445 | - if( ! empty( $options ) ) { |
|
446 | - update_option( 'give_settings', array_merge( give_get_settings(), $options ) ); |
|
445 | + if ( ! empty($options)) { |
|
446 | + update_option('give_settings', array_merge(give_get_settings(), $options)); |
|
447 | 447 | } |
448 | 448 | |
449 | - add_option( 'give_install_pages_created', 1, '', 'no' ); |
|
449 | + add_option('give_install_pages_created', 1, '', 'no'); |
|
450 | 450 | } |
451 | -add_action( 'admin_init', 'give_create_pages', -1 ); |
|
451 | +add_action('admin_init', 'give_create_pages', -1); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -26,34 +26,34 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @return void |
28 | 28 | */ |
29 | -function give_set_settings_with_disable_prefix( $old_settings, $settings ) { |
|
29 | +function give_set_settings_with_disable_prefix($old_settings, $settings) { |
|
30 | 30 | // Bailout. |
31 | - if( ! function_exists( 'give_v18_renamed_core_settings' ) ) { |
|
31 | + if ( ! function_exists('give_v18_renamed_core_settings')) { |
|
32 | 32 | return; |
33 | 33 | } |
34 | 34 | |
35 | 35 | // Get old setting names. |
36 | - $old_settings = array_flip( give_v18_renamed_core_settings() ); |
|
36 | + $old_settings = array_flip(give_v18_renamed_core_settings()); |
|
37 | 37 | $update_setting = false; |
38 | 38 | |
39 | - foreach ( $settings as $key => $value ) { |
|
39 | + foreach ($settings as $key => $value) { |
|
40 | 40 | |
41 | 41 | // Check 1. Check if new option is really updated or not. |
42 | 42 | // Check 2. Continue if key is not renamed. |
43 | - if ( ! isset( $old_settings[ $key ] ) ) { |
|
43 | + if ( ! isset($old_settings[$key])) { |
|
44 | 44 | continue; |
45 | 45 | } |
46 | 46 | |
47 | 47 | // Set old setting. |
48 | - $settings[ $old_settings[ $key ] ] = 'on'; |
|
48 | + $settings[$old_settings[$key]] = 'on'; |
|
49 | 49 | |
50 | 50 | // Do not need to set old setting if new setting is not set. |
51 | 51 | if ( |
52 | - ( give_is_setting_enabled( $value ) && ( false !== strpos( $old_settings[ $key ], 'disable_' ) ) ) |
|
53 | - || ( ! give_is_setting_enabled( $value ) && ( false !== strpos( $old_settings[ $key ], 'enable_' ) ) ) |
|
52 | + (give_is_setting_enabled($value) && (false !== strpos($old_settings[$key], 'disable_'))) |
|
53 | + || ( ! give_is_setting_enabled($value) && (false !== strpos($old_settings[$key], 'enable_'))) |
|
54 | 54 | |
55 | 55 | ) { |
56 | - unset( $settings[ $old_settings[ $key ] ] ); |
|
56 | + unset($settings[$old_settings[$key]]); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | // Tell bot to update setting. |
@@ -61,8 +61,8 @@ discard block |
||
61 | 61 | } |
62 | 62 | |
63 | 63 | // Update setting if any old setting set. |
64 | - if ( $update_setting ) { |
|
65 | - update_option( 'give_settings', $settings ); |
|
64 | + if ($update_setting) { |
|
65 | + update_option('give_settings', $settings); |
|
66 | 66 | } |
67 | 67 | } |
68 | -add_action( 'update_option_give_settings', 'give_set_settings_with_disable_prefix', 10, 2 ); |
|
68 | +add_action('update_option_give_settings', 'give_set_settings_with_disable_prefix', 10, 2); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -62,50 +62,50 @@ discard block |
||
62 | 62 | * |
63 | 63 | * @return bool If the gravatar exists or not |
64 | 64 | */ |
65 | - public function validate_gravatar( $id_or_email ) { |
|
65 | + public function validate_gravatar($id_or_email) { |
|
66 | 66 | //id or email code borrowed from wp-includes/pluggable.php |
67 | 67 | $email = ''; |
68 | - if ( is_numeric( $id_or_email ) ) { |
|
68 | + if (is_numeric($id_or_email)) { |
|
69 | 69 | $id = (int) $id_or_email; |
70 | - $user = get_userdata( $id ); |
|
71 | - if ( $user ) { |
|
70 | + $user = get_userdata($id); |
|
71 | + if ($user) { |
|
72 | 72 | $email = $user->user_email; |
73 | 73 | } |
74 | - } elseif ( is_object( $id_or_email ) ) { |
|
74 | + } elseif (is_object($id_or_email)) { |
|
75 | 75 | // No avatar for pingbacks or trackbacks |
76 | - $allowed_comment_types = apply_filters( 'get_avatar_comment_types', array( 'comment' ) ); |
|
77 | - if ( ! empty( $id_or_email->comment_type ) && ! in_array( $id_or_email->comment_type, (array) $allowed_comment_types ) ) { |
|
76 | + $allowed_comment_types = apply_filters('get_avatar_comment_types', array('comment')); |
|
77 | + if ( ! empty($id_or_email->comment_type) && ! in_array($id_or_email->comment_type, (array) $allowed_comment_types)) { |
|
78 | 78 | return false; |
79 | 79 | } |
80 | 80 | |
81 | - if ( ! empty( $id_or_email->user_id ) ) { |
|
81 | + if ( ! empty($id_or_email->user_id)) { |
|
82 | 82 | $id = (int) $id_or_email->user_id; |
83 | - $user = get_userdata( $id ); |
|
84 | - if ( $user ) { |
|
83 | + $user = get_userdata($id); |
|
84 | + if ($user) { |
|
85 | 85 | $email = $user->user_email; |
86 | 86 | } |
87 | - } elseif ( ! empty( $id_or_email->comment_author_email ) ) { |
|
87 | + } elseif ( ! empty($id_or_email->comment_author_email)) { |
|
88 | 88 | $email = $id_or_email->comment_author_email; |
89 | 89 | } |
90 | 90 | } else { |
91 | 91 | $email = $id_or_email; |
92 | 92 | } |
93 | 93 | |
94 | - $hashkey = md5( strtolower( trim( $email ) ) ); |
|
95 | - $uri = 'http://www.gravatar.com/avatar/' . $hashkey . '?d=404'; |
|
94 | + $hashkey = md5(strtolower(trim($email))); |
|
95 | + $uri = 'http://www.gravatar.com/avatar/'.$hashkey.'?d=404'; |
|
96 | 96 | |
97 | - $data = wp_cache_get( $hashkey ); |
|
98 | - if ( false === $data ) { |
|
99 | - $response = wp_remote_head( $uri ); |
|
100 | - if ( is_wp_error( $response ) ) { |
|
97 | + $data = wp_cache_get($hashkey); |
|
98 | + if (false === $data) { |
|
99 | + $response = wp_remote_head($uri); |
|
100 | + if (is_wp_error($response)) { |
|
101 | 101 | $data = 'not200'; |
102 | 102 | } else { |
103 | 103 | $data = $response['response']['code']; |
104 | 104 | } |
105 | - wp_cache_set( $hashkey, $data, $group = '', $expire = 60 * 5 ); |
|
105 | + wp_cache_set($hashkey, $data, $group = '', $expire = 60 * 5); |
|
106 | 106 | |
107 | 107 | } |
108 | - if ( $data == '200' ) { |
|
108 | + if ($data == '200') { |
|
109 | 109 | return true; |
110 | 110 | } else { |
111 | 111 | return false; |
@@ -122,19 +122,19 @@ discard block |
||
122 | 122 | * |
123 | 123 | * @return array IDs if logs, false otherwise |
124 | 124 | */ |
125 | - public function get_log_ids( $form_id = '' ) { |
|
125 | + public function get_log_ids($form_id = '') { |
|
126 | 126 | |
127 | 127 | // get Give_Logging class |
128 | 128 | global $give_logs; |
129 | 129 | |
130 | 130 | // get log for this form |
131 | - $logs = $give_logs->get_logs( $form_id ); |
|
131 | + $logs = $give_logs->get_logs($form_id); |
|
132 | 132 | |
133 | - if ( $logs ) { |
|
133 | + if ($logs) { |
|
134 | 134 | $log_ids = array(); |
135 | 135 | |
136 | 136 | // make an array with all the donor IDs |
137 | - foreach ( $logs as $log ) { |
|
137 | + foreach ($logs as $log) { |
|
138 | 138 | $log_ids[] = $log->ID; |
139 | 139 | } |
140 | 140 | |
@@ -155,51 +155,51 @@ discard block |
||
155 | 155 | * |
156 | 156 | * @return mixed |
157 | 157 | */ |
158 | - public function get_payment_ids( $form_id = '' ) { |
|
158 | + public function get_payment_ids($form_id = '') { |
|
159 | 159 | |
160 | 160 | $give_options = give_get_settings(); |
161 | 161 | |
162 | - $log_ids = $this->get_log_ids( $form_id ); |
|
162 | + $log_ids = $this->get_log_ids($form_id); |
|
163 | 163 | |
164 | - if ( $log_ids ) { |
|
164 | + if ($log_ids) { |
|
165 | 165 | |
166 | 166 | $payment_ids = array(); |
167 | 167 | |
168 | - foreach ( $log_ids as $id ) { |
|
168 | + foreach ($log_ids as $id) { |
|
169 | 169 | // get the payment ID for each corresponding log ID |
170 | - $payment_ids[] = give_get_meta( $id, '_give_log_payment_id', true ); |
|
170 | + $payment_ids[] = give_get_meta($id, '_give_log_payment_id', true); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | // remove donors who have donated more than once so we can have unique avatars |
174 | 174 | $unique_emails = array(); |
175 | 175 | |
176 | - foreach ( $payment_ids as $key => $id ) { |
|
176 | + foreach ($payment_ids as $key => $id) { |
|
177 | 177 | |
178 | - $email = give_get_meta( $id, '_give_payment_user_email', true ); |
|
178 | + $email = give_get_meta($id, '_give_payment_user_email', true); |
|
179 | 179 | |
180 | - if ( isset ( $give_options['give_donors_gravatars_has_gravatar_account'] ) ) { |
|
181 | - if ( ! $this->validate_gravatar( $email ) ) { |
|
180 | + if (isset ($give_options['give_donors_gravatars_has_gravatar_account'])) { |
|
181 | + if ( ! $this->validate_gravatar($email)) { |
|
182 | 182 | continue; |
183 | 183 | } |
184 | 184 | } |
185 | 185 | |
186 | - $unique_emails[ $id ] = give_get_meta( $id, '_give_payment_user_email', true ); |
|
186 | + $unique_emails[$id] = give_get_meta($id, '_give_payment_user_email', true); |
|
187 | 187 | |
188 | 188 | } |
189 | 189 | |
190 | 190 | $unique_ids = array(); |
191 | 191 | |
192 | 192 | // strip duplicate emails |
193 | - $unique_emails = array_unique( $unique_emails ); |
|
193 | + $unique_emails = array_unique($unique_emails); |
|
194 | 194 | |
195 | 195 | // convert the unique IDs back into simple array |
196 | - foreach ( $unique_emails as $id => $email ) { |
|
196 | + foreach ($unique_emails as $id => $email) { |
|
197 | 197 | $unique_ids[] = $id; |
198 | 198 | } |
199 | 199 | |
200 | 200 | // randomize the payment IDs if enabled |
201 | - if ( isset( $give_options['give_donors_gravatars_random_gravatars'] ) ) { |
|
202 | - shuffle( $unique_ids ); |
|
201 | + if (isset($give_options['give_donors_gravatars_random_gravatars'])) { |
|
202 | + shuffle($unique_ids); |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | // return our unique IDs |
@@ -220,22 +220,22 @@ discard block |
||
220 | 220 | * |
221 | 221 | * @return string |
222 | 222 | */ |
223 | - public function gravatars( $form_id = false, $title = '' ) { |
|
223 | + public function gravatars($form_id = false, $title = '') { |
|
224 | 224 | |
225 | 225 | // unique $payment_ids |
226 | - $payment_ids = $this->get_payment_ids( $form_id ); |
|
226 | + $payment_ids = $this->get_payment_ids($form_id); |
|
227 | 227 | |
228 | 228 | $give_options = give_get_settings(); |
229 | 229 | |
230 | 230 | // return if no ID |
231 | - if ( ! $form_id ) { |
|
231 | + if ( ! $form_id) { |
|
232 | 232 | return; |
233 | 233 | } |
234 | 234 | |
235 | 235 | // minimum amount of donations before showing gravatars |
236 | 236 | // if the number of items in array is not greater or equal to the number specified, then exit |
237 | - if ( isset( $give_options['give_donors_gravatars_min_purchases_required'] ) && '' != $give_options['give_donors_gravatars_min_purchases_required'] ) { |
|
238 | - if ( ! ( count( $payment_ids ) >= $give_options['give_donors_gravatars_min_purchases_required'] ) ) { |
|
237 | + if (isset($give_options['give_donors_gravatars_min_purchases_required']) && '' != $give_options['give_donors_gravatars_min_purchases_required']) { |
|
238 | + if ( ! (count($payment_ids) >= $give_options['give_donors_gravatars_min_purchases_required'])) { |
|
239 | 239 | return; |
240 | 240 | } |
241 | 241 | } |
@@ -246,28 +246,28 @@ discard block |
||
246 | 246 | echo '<div id="give-purchase-gravatars">'; |
247 | 247 | |
248 | 248 | |
249 | - if ( isset ( $title ) ) { |
|
249 | + if (isset ($title)) { |
|
250 | 250 | |
251 | - if ( $title ) { |
|
252 | - echo apply_filters( 'give_donors_gravatars_title', '<h3 class="give-gravatars-title">' . esc_attr( $title ) . '</h3>' ); |
|
253 | - } elseif ( isset( $give_options['give_donors_gravatars_heading'] ) ) { |
|
254 | - echo apply_filters( 'give_donors_gravatars_title', '<h3 class="give-gravatars-title">' . esc_attr( $give_options['give_donors_gravatars_heading'] ) . '</h2>' ); |
|
251 | + if ($title) { |
|
252 | + echo apply_filters('give_donors_gravatars_title', '<h3 class="give-gravatars-title">'.esc_attr($title).'</h3>'); |
|
253 | + } elseif (isset($give_options['give_donors_gravatars_heading'])) { |
|
254 | + echo apply_filters('give_donors_gravatars_title', '<h3 class="give-gravatars-title">'.esc_attr($give_options['give_donors_gravatars_heading']).'</h2>'); |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | } |
258 | 258 | echo '<ul class="give-purchase-gravatars-list">'; |
259 | 259 | $i = 0; |
260 | 260 | |
261 | - if ( $payment_ids ) { |
|
262 | - foreach ( $payment_ids as $id ) { |
|
261 | + if ($payment_ids) { |
|
262 | + foreach ($payment_ids as $id) { |
|
263 | 263 | |
264 | 264 | // Give saves a blank option even when the control is turned off, hence the extra check |
265 | - if ( isset( $give_options['give_donors_gravatars_maximum_number'] ) && '' != $give_options['give_donors_gravatars_maximum_number'] && $i == $give_options['give_donors_gravatars_maximum_number'] ) { |
|
265 | + if (isset($give_options['give_donors_gravatars_maximum_number']) && '' != $give_options['give_donors_gravatars_maximum_number'] && $i == $give_options['give_donors_gravatars_maximum_number']) { |
|
266 | 266 | continue; |
267 | 267 | } |
268 | 268 | |
269 | 269 | // get the payment meta |
270 | - $payment_meta = give_get_meta( $id, '_give_payment_meta', true ); |
|
270 | + $payment_meta = give_get_meta($id, '_give_payment_meta', true); |
|
271 | 271 | |
272 | 272 | $user_info = $payment_meta['user_info']; |
273 | 273 | |
@@ -275,21 +275,21 @@ discard block |
||
275 | 275 | $name = $user_info['first_name']; |
276 | 276 | |
277 | 277 | // get donor's email |
278 | - $email = give_get_meta( $id, '_give_payment_user_email', true ); |
|
278 | + $email = give_get_meta($id, '_give_payment_user_email', true); |
|
279 | 279 | |
280 | 280 | // set gravatar size and provide filter |
281 | - $size = isset( $give_options['give_donors_gravatars_gravatar_size'] ) ? apply_filters( 'give_donors_gravatars_gravatar_size', $give_options['give_donors_gravatars_gravatar_size'] ) : ''; |
|
281 | + $size = isset($give_options['give_donors_gravatars_gravatar_size']) ? apply_filters('give_donors_gravatars_gravatar_size', $give_options['give_donors_gravatars_gravatar_size']) : ''; |
|
282 | 282 | |
283 | 283 | // default image |
284 | - $default_image = apply_filters( 'give_donors_gravatars_gravatar_default_image', false ); |
|
284 | + $default_image = apply_filters('give_donors_gravatars_gravatar_default_image', false); |
|
285 | 285 | |
286 | 286 | // assemble output |
287 | 287 | $output .= '<li>'; |
288 | 288 | |
289 | - $output .= get_avatar( $email, $size, $default_image, $name ); |
|
289 | + $output .= get_avatar($email, $size, $default_image, $name); |
|
290 | 290 | $output .= '</li>'; |
291 | 291 | |
292 | - $i ++; |
|
292 | + $i++; |
|
293 | 293 | |
294 | 294 | } // end foreach |
295 | 295 | } |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | echo '</ul>'; |
299 | 299 | echo '</div>'; |
300 | 300 | |
301 | - return apply_filters( 'give_donors_gravatars', ob_get_clean() ); |
|
301 | + return apply_filters('give_donors_gravatars', ob_get_clean()); |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | /** |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | * @return void |
311 | 311 | */ |
312 | 312 | public function register_widget() { |
313 | - register_widget( 'Give_Donors_Gravatars_Widget' ); |
|
313 | + register_widget('Give_Donors_Gravatars_Widget'); |
|
314 | 314 | } |
315 | 315 | |
316 | 316 | /** |
@@ -324,19 +324,19 @@ discard block |
||
324 | 324 | * |
325 | 325 | * @return string |
326 | 326 | */ |
327 | - public function shortcode( $atts, $content = null ) { |
|
327 | + public function shortcode($atts, $content = null) { |
|
328 | 328 | |
329 | - $atts = shortcode_atts( array( |
|
329 | + $atts = shortcode_atts(array( |
|
330 | 330 | 'id' => '', |
331 | 331 | 'title' => '' |
332 | - ), $atts, 'give_donors_gravatars' ); |
|
332 | + ), $atts, 'give_donors_gravatars'); |
|
333 | 333 | |
334 | 334 | // if no ID is passed on single give_forms pages, get the correct ID |
335 | - if ( is_singular( 'give_forms' ) ) { |
|
335 | + if (is_singular('give_forms')) { |
|
336 | 336 | $id = get_the_ID(); |
337 | 337 | } |
338 | 338 | |
339 | - $content = $this->gravatars( $atts['id'], $atts['title'] ); |
|
339 | + $content = $this->gravatars($atts['id'], $atts['title']); |
|
340 | 340 | |
341 | 341 | return $content; |
342 | 342 | |
@@ -352,56 +352,56 @@ discard block |
||
352 | 352 | * |
353 | 353 | * @return array Gravatar settings. |
354 | 354 | */ |
355 | - public function settings( $settings ) { |
|
355 | + public function settings($settings) { |
|
356 | 356 | |
357 | 357 | $give_gravatar_settings = array( |
358 | 358 | array( |
359 | - 'name' => esc_html__( 'Donator Gravatars', 'give' ), |
|
359 | + 'name' => esc_html__('Donator Gravatars', 'give'), |
|
360 | 360 | 'desc' => '<hr>', |
361 | 361 | 'id' => 'give_title', |
362 | 362 | 'type' => 'give_title' |
363 | 363 | ), |
364 | 364 | array( |
365 | - 'name' => esc_html__( 'Heading', 'give' ), |
|
366 | - 'desc' => esc_html__( 'The heading to display above the Gravatars.', 'give' ), |
|
365 | + 'name' => esc_html__('Heading', 'give'), |
|
366 | + 'desc' => esc_html__('The heading to display above the Gravatars.', 'give'), |
|
367 | 367 | 'type' => 'text', |
368 | 368 | 'id' => 'give_donors_gravatars_heading' |
369 | 369 | ), |
370 | 370 | array( |
371 | - 'name' => esc_html__( 'Gravatar Size', 'give' ), |
|
372 | - 'desc' => esc_html__( 'The size of each Gravatar in pixels (512px maximum).', 'give' ), |
|
371 | + 'name' => esc_html__('Gravatar Size', 'give'), |
|
372 | + 'desc' => esc_html__('The size of each Gravatar in pixels (512px maximum).', 'give'), |
|
373 | 373 | 'type' => 'text_small', |
374 | 374 | 'id' => 'give_donors_gravatars_gravatar_size', |
375 | 375 | 'default' => '64' |
376 | 376 | ), |
377 | 377 | array( |
378 | - 'name' => esc_html__( 'Minimum Unique Donations Required', 'give' ), |
|
379 | - 'desc' => esc_html__( 'The minimum number of unique donations a form must have before the Gravatars are shown. Leave blank for no minimum.', 'give' ), |
|
378 | + 'name' => esc_html__('Minimum Unique Donations Required', 'give'), |
|
379 | + 'desc' => esc_html__('The minimum number of unique donations a form must have before the Gravatars are shown. Leave blank for no minimum.', 'give'), |
|
380 | 380 | 'type' => 'text_small', |
381 | 381 | 'id' => 'give_donors_gravatars_min_purchases_required', |
382 | 382 | ), |
383 | 383 | array( |
384 | - 'name' => esc_html__( 'Maximum Gravatars To Show', 'give' ), |
|
385 | - 'desc' => esc_html__( 'The maximum number of gravatars to show. Leave blank for no limit.', 'give' ), |
|
384 | + 'name' => esc_html__('Maximum Gravatars To Show', 'give'), |
|
385 | + 'desc' => esc_html__('The maximum number of gravatars to show. Leave blank for no limit.', 'give'), |
|
386 | 386 | 'type' => 'text', |
387 | 387 | 'id' => 'give_donors_gravatars_maximum_number', |
388 | 388 | 'default' => '20', |
389 | 389 | ), |
390 | 390 | array( |
391 | - 'name' => esc_html__( 'Gravatar Visibility', 'give' ), |
|
392 | - 'desc' => esc_html__( 'Show only donors with a Gravatar account.', 'give' ), |
|
391 | + 'name' => esc_html__('Gravatar Visibility', 'give'), |
|
392 | + 'desc' => esc_html__('Show only donors with a Gravatar account.', 'give'), |
|
393 | 393 | 'id' => 'give_donors_gravatars_has_gravatar_account', |
394 | 394 | 'type' => 'checkbox', |
395 | 395 | ), |
396 | 396 | array( |
397 | - 'name' => esc_html__( 'Randomize Gravatars', 'give' ), |
|
398 | - 'desc' => esc_html__( 'Randomize the Gravatars.', 'give' ), |
|
397 | + 'name' => esc_html__('Randomize Gravatars', 'give'), |
|
398 | + 'desc' => esc_html__('Randomize the Gravatars.', 'give'), |
|
399 | 399 | 'id' => 'give_donors_gravatars_random_gravatars', |
400 | 400 | 'type' => 'checkbox', |
401 | 401 | ), |
402 | 402 | ); |
403 | 403 | |
404 | - return array_merge( $settings, $give_gravatar_settings ); |
|
404 | + return array_merge($settings, $give_gravatar_settings); |
|
405 | 405 | } |
406 | 406 | |
407 | 407 | } |
@@ -427,7 +427,7 @@ discard block |
||
427 | 427 | // widget settings |
428 | 428 | $widget_ops = array( |
429 | 429 | 'classname' => 'give-donors-gravatars', |
430 | - 'description' => esc_html__( 'Displays gravatars of people who have donated using your your form. Will only show on the single form page.', 'give' ), |
|
430 | + 'description' => esc_html__('Displays gravatars of people who have donated using your your form. Will only show on the single form page.', 'give'), |
|
431 | 431 | ); |
432 | 432 | |
433 | 433 | // widget control settings |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | // create the widget |
441 | 441 | parent::__construct( |
442 | 442 | 'give_donors_gravatars_widget', |
443 | - esc_html__( 'Give Donors Gravatars', 'give' ), |
|
443 | + esc_html__('Give Donors Gravatars', 'give'), |
|
444 | 444 | $widget_ops, |
445 | 445 | $control_ops |
446 | 446 | ); |
@@ -460,29 +460,29 @@ discard block |
||
460 | 460 | * |
461 | 461 | * @return void |
462 | 462 | */ |
463 | - public function widget( $args, $instance ) { |
|
463 | + public function widget($args, $instance) { |
|
464 | 464 | |
465 | 465 | //@TODO: Don't extract it!!! |
466 | - extract( $args ); |
|
466 | + extract($args); |
|
467 | 467 | |
468 | - if ( ! is_singular( 'give_forms' ) ) { |
|
468 | + if ( ! is_singular('give_forms')) { |
|
469 | 469 | return; |
470 | 470 | } |
471 | 471 | |
472 | 472 | // Variables from widget settings |
473 | - $title = apply_filters( 'widget_title', $instance['title'] ); |
|
473 | + $title = apply_filters('widget_title', $instance['title']); |
|
474 | 474 | |
475 | 475 | // Used by themes. Opens the widget |
476 | 476 | echo $before_widget; |
477 | 477 | |
478 | 478 | // Display the widget title |
479 | - if ( $title ) { |
|
480 | - echo $before_title . $title . $after_title; |
|
479 | + if ($title) { |
|
480 | + echo $before_title.$title.$after_title; |
|
481 | 481 | } |
482 | 482 | |
483 | 483 | $gravatars = new Give_Donors_Gravatars(); |
484 | 484 | |
485 | - echo $gravatars->gravatars( get_the_ID(), null ); // remove title |
|
485 | + echo $gravatars->gravatars(get_the_ID(), null); // remove title |
|
486 | 486 | |
487 | 487 | // Used by themes. Closes the widget |
488 | 488 | echo $after_widget; |
@@ -502,11 +502,11 @@ discard block |
||
502 | 502 | * |
503 | 503 | * @return array Updated settings to save. |
504 | 504 | */ |
505 | - public function update( $new_instance, $old_instance ) { |
|
505 | + public function update($new_instance, $old_instance) { |
|
506 | 506 | |
507 | 507 | $instance = $old_instance; |
508 | 508 | |
509 | - $instance['title'] = strip_tags( $new_instance['title'] ); |
|
509 | + $instance['title'] = strip_tags($new_instance['title']); |
|
510 | 510 | |
511 | 511 | return $instance; |
512 | 512 | |
@@ -524,19 +524,19 @@ discard block |
||
524 | 524 | * |
525 | 525 | * @return void |
526 | 526 | */ |
527 | - public function form( $instance ) { |
|
527 | + public function form($instance) { |
|
528 | 528 | |
529 | 529 | // Set up some default widget settings. |
530 | 530 | $defaults = array( |
531 | 531 | 'title' => '', |
532 | 532 | ); |
533 | 533 | |
534 | - $instance = wp_parse_args( (array) $instance, $defaults ); ?> |
|
534 | + $instance = wp_parse_args((array) $instance, $defaults); ?> |
|
535 | 535 | |
536 | 536 | <!-- Title --> |
537 | 537 | <p> |
538 | - <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php esc_html_e( 'Title:', 'give' ) ?></label> |
|
539 | - <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo $instance['title']; ?>" /> |
|
538 | + <label for="<?php echo $this->get_field_id('title'); ?>"><?php esc_html_e('Title:', 'give') ?></label> |
|
539 | + <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $instance['title']; ?>" /> |
|
540 | 540 | </p> |
541 | 541 | |
542 | 542 | <?php |
@@ -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 | |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | * @access public |
36 | 36 | */ |
37 | 37 | public function __construct() { |
38 | - add_filter( 'give_map_meta_cap', array( $this, 'meta_caps' ), 10, 4 ); |
|
38 | + add_filter('give_map_meta_cap', array($this, 'meta_caps'), 10, 4); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * @return void |
50 | 50 | */ |
51 | 51 | public function add_roles() { |
52 | - add_role( 'give_manager', __( 'Give Manager', 'give' ), array( |
|
52 | + add_role('give_manager', __('Give Manager', 'give'), array( |
|
53 | 53 | 'read' => true, |
54 | 54 | 'edit_posts' => true, |
55 | 55 | 'delete_posts' => true, |
@@ -78,25 +78,25 @@ discard block |
||
78 | 78 | 'publish_posts' => true, |
79 | 79 | 'read_private_pages' => true, |
80 | 80 | 'read_private_posts' => true, |
81 | - ) ); |
|
81 | + )); |
|
82 | 82 | |
83 | - add_role( 'give_accountant', __( 'Give Accountant', 'give' ), array( |
|
83 | + add_role('give_accountant', __('Give Accountant', 'give'), array( |
|
84 | 84 | 'read' => true, |
85 | 85 | 'edit_posts' => false, |
86 | 86 | 'delete_posts' => false |
87 | - ) ); |
|
87 | + )); |
|
88 | 88 | |
89 | - add_role( 'give_worker', __( 'Give Worker', 'give' ), array( |
|
89 | + add_role('give_worker', __('Give Worker', 'give'), array( |
|
90 | 90 | 'read' => true, |
91 | 91 | 'edit_posts' => true, |
92 | 92 | 'edit_pages' => true, |
93 | 93 | 'upload_files' => true, |
94 | 94 | 'delete_posts' => false, |
95 | - ) ); |
|
95 | + )); |
|
96 | 96 | |
97 | - add_role( 'give_donor', __( 'Give Donor', 'give' ), array( |
|
97 | + add_role('give_donor', __('Give Donor', 'give'), array( |
|
98 | 98 | 'read' => true, |
99 | - ) ); |
|
99 | + )); |
|
100 | 100 | |
101 | 101 | } |
102 | 102 | |
@@ -115,38 +115,38 @@ discard block |
||
115 | 115 | public function add_caps() { |
116 | 116 | global $wp_roles; |
117 | 117 | |
118 | - if ( class_exists( 'WP_Roles' ) ) { |
|
119 | - if ( ! isset( $wp_roles ) ) { |
|
118 | + if (class_exists('WP_Roles')) { |
|
119 | + if ( ! isset($wp_roles)) { |
|
120 | 120 | $wp_roles = new WP_Roles(); |
121 | 121 | } |
122 | 122 | } |
123 | 123 | |
124 | - if ( is_object( $wp_roles ) ) { |
|
125 | - $wp_roles->add_cap( 'give_manager', 'view_give_reports' ); |
|
126 | - $wp_roles->add_cap( 'give_manager', 'view_give_sensitive_data' ); |
|
127 | - $wp_roles->add_cap( 'give_manager', 'export_give_reports' ); |
|
128 | - $wp_roles->add_cap( 'give_manager', 'manage_give_settings' ); |
|
124 | + if (is_object($wp_roles)) { |
|
125 | + $wp_roles->add_cap('give_manager', 'view_give_reports'); |
|
126 | + $wp_roles->add_cap('give_manager', 'view_give_sensitive_data'); |
|
127 | + $wp_roles->add_cap('give_manager', 'export_give_reports'); |
|
128 | + $wp_roles->add_cap('give_manager', 'manage_give_settings'); |
|
129 | 129 | |
130 | - $wp_roles->add_cap( 'administrator', 'view_give_reports' ); |
|
131 | - $wp_roles->add_cap( 'administrator', 'view_give_sensitive_data' ); |
|
132 | - $wp_roles->add_cap( 'administrator', 'export_give_reports' ); |
|
133 | - $wp_roles->add_cap( 'administrator', 'manage_give_settings' ); |
|
130 | + $wp_roles->add_cap('administrator', 'view_give_reports'); |
|
131 | + $wp_roles->add_cap('administrator', 'view_give_sensitive_data'); |
|
132 | + $wp_roles->add_cap('administrator', 'export_give_reports'); |
|
133 | + $wp_roles->add_cap('administrator', 'manage_give_settings'); |
|
134 | 134 | |
135 | 135 | // Add the main post type capabilities. |
136 | 136 | $capabilities = $this->get_core_caps(); |
137 | - foreach ( $capabilities as $cap_group ) { |
|
138 | - foreach ( $cap_group as $cap ) { |
|
139 | - $wp_roles->add_cap( 'administrator', $cap ); |
|
140 | - $wp_roles->add_cap( 'give_manager', $cap ); |
|
141 | - $wp_roles->add_cap( 'give_worker', $cap ); |
|
137 | + foreach ($capabilities as $cap_group) { |
|
138 | + foreach ($cap_group as $cap) { |
|
139 | + $wp_roles->add_cap('administrator', $cap); |
|
140 | + $wp_roles->add_cap('give_manager', $cap); |
|
141 | + $wp_roles->add_cap('give_worker', $cap); |
|
142 | 142 | } |
143 | 143 | } |
144 | 144 | |
145 | - $wp_roles->add_cap( 'give_accountant', 'edit_give_forms' ); |
|
146 | - $wp_roles->add_cap( 'give_accountant', 'read_private_give_forms' ); |
|
147 | - $wp_roles->add_cap( 'give_accountant', 'view_give_reports' ); |
|
148 | - $wp_roles->add_cap( 'give_accountant', 'export_give_reports' ); |
|
149 | - $wp_roles->add_cap( 'give_accountant', 'edit_give_payments' ); |
|
145 | + $wp_roles->add_cap('give_accountant', 'edit_give_forms'); |
|
146 | + $wp_roles->add_cap('give_accountant', 'read_private_give_forms'); |
|
147 | + $wp_roles->add_cap('give_accountant', 'view_give_reports'); |
|
148 | + $wp_roles->add_cap('give_accountant', 'export_give_reports'); |
|
149 | + $wp_roles->add_cap('give_accountant', 'edit_give_payments'); |
|
150 | 150 | |
151 | 151 | } |
152 | 152 | } |
@@ -164,10 +164,10 @@ discard block |
||
164 | 164 | public function get_core_caps() { |
165 | 165 | $capabilities = array(); |
166 | 166 | |
167 | - $capability_types = array( 'give_form', 'give_payment' ); |
|
167 | + $capability_types = array('give_form', 'give_payment'); |
|
168 | 168 | |
169 | - foreach ( $capability_types as $capability_type ) { |
|
170 | - $capabilities[ $capability_type ] = array( |
|
169 | + foreach ($capability_types as $capability_type) { |
|
170 | + $capabilities[$capability_type] = array( |
|
171 | 171 | // Post type. |
172 | 172 | "edit_{$capability_type}", |
173 | 173 | "read_{$capability_type}", |
@@ -213,22 +213,22 @@ discard block |
||
213 | 213 | * |
214 | 214 | * @return array $caps Meta capabilities. |
215 | 215 | */ |
216 | - public function meta_caps( $caps, $cap, $user_id, $args ) { |
|
216 | + public function meta_caps($caps, $cap, $user_id, $args) { |
|
217 | 217 | |
218 | - switch ( $cap ) { |
|
218 | + switch ($cap) { |
|
219 | 219 | |
220 | 220 | case 'view_give_form_stats' : |
221 | 221 | |
222 | - if ( empty( $args[0] ) ) { |
|
222 | + if (empty($args[0])) { |
|
223 | 223 | break; |
224 | 224 | } |
225 | 225 | |
226 | - $form = get_post( $args[0] ); |
|
227 | - if ( empty( $form ) ) { |
|
226 | + $form = get_post($args[0]); |
|
227 | + if (empty($form)) { |
|
228 | 228 | break; |
229 | 229 | } |
230 | 230 | |
231 | - if ( user_can( $user_id, 'view_give_reports' ) || $user_id == $form->post_author ) { |
|
231 | + if (user_can($user_id, 'view_give_reports') || $user_id == $form->post_author) { |
|
232 | 232 | $caps = array(); |
233 | 233 | } |
234 | 234 | |
@@ -255,41 +255,41 @@ discard block |
||
255 | 255 | |
256 | 256 | global $wp_roles; |
257 | 257 | |
258 | - if ( class_exists( 'WP_Roles' ) ) { |
|
259 | - if ( ! isset( $wp_roles ) ) { |
|
258 | + if (class_exists('WP_Roles')) { |
|
259 | + if ( ! isset($wp_roles)) { |
|
260 | 260 | $wp_roles = new WP_Roles(); |
261 | 261 | } |
262 | 262 | } |
263 | 263 | |
264 | - if ( is_object( $wp_roles ) ) { |
|
264 | + if (is_object($wp_roles)) { |
|
265 | 265 | // Give Manager Capabilities. |
266 | - $wp_roles->remove_cap( 'give_manager', 'view_give_reports' ); |
|
267 | - $wp_roles->remove_cap( 'give_manager', 'view_give_sensitive_data' ); |
|
268 | - $wp_roles->remove_cap( 'give_manager', 'export_give_reports' ); |
|
269 | - $wp_roles->remove_cap( 'give_manager', 'manage_give_settings' ); |
|
266 | + $wp_roles->remove_cap('give_manager', 'view_give_reports'); |
|
267 | + $wp_roles->remove_cap('give_manager', 'view_give_sensitive_data'); |
|
268 | + $wp_roles->remove_cap('give_manager', 'export_give_reports'); |
|
269 | + $wp_roles->remove_cap('give_manager', 'manage_give_settings'); |
|
270 | 270 | |
271 | 271 | // Site Administrator Capabilities. |
272 | - $wp_roles->remove_cap( 'administrator', 'view_give_reports' ); |
|
273 | - $wp_roles->remove_cap( 'administrator', 'view_give_sensitive_data' ); |
|
274 | - $wp_roles->remove_cap( 'administrator', 'export_give_reports' ); |
|
275 | - $wp_roles->remove_cap( 'administrator', 'manage_give_settings' ); |
|
272 | + $wp_roles->remove_cap('administrator', 'view_give_reports'); |
|
273 | + $wp_roles->remove_cap('administrator', 'view_give_sensitive_data'); |
|
274 | + $wp_roles->remove_cap('administrator', 'export_give_reports'); |
|
275 | + $wp_roles->remove_cap('administrator', 'manage_give_settings'); |
|
276 | 276 | |
277 | 277 | // Remove the Main Post Type Capabilities. |
278 | 278 | $capabilities = $this->get_core_caps(); |
279 | 279 | |
280 | - foreach ( $capabilities as $cap_group ) { |
|
281 | - foreach ( $cap_group as $cap ) { |
|
282 | - $wp_roles->remove_cap( 'give_manager', $cap ); |
|
283 | - $wp_roles->remove_cap( 'administrator', $cap ); |
|
284 | - $wp_roles->remove_cap( 'give_worker', $cap ); |
|
280 | + foreach ($capabilities as $cap_group) { |
|
281 | + foreach ($cap_group as $cap) { |
|
282 | + $wp_roles->remove_cap('give_manager', $cap); |
|
283 | + $wp_roles->remove_cap('administrator', $cap); |
|
284 | + $wp_roles->remove_cap('give_worker', $cap); |
|
285 | 285 | } |
286 | 286 | } |
287 | 287 | |
288 | 288 | /** Give Accountant Capabilities */ |
289 | - $wp_roles->remove_cap( 'give_accountant', 'edit_give_forms' ); |
|
290 | - $wp_roles->remove_cap( 'give_accountant', 'read_private_give_forms' ); |
|
291 | - $wp_roles->remove_cap( 'give_accountant', 'view_give_reports' ); |
|
292 | - $wp_roles->remove_cap( 'give_accountant', 'export_give_reports' ); |
|
289 | + $wp_roles->remove_cap('give_accountant', 'edit_give_forms'); |
|
290 | + $wp_roles->remove_cap('give_accountant', 'read_private_give_forms'); |
|
291 | + $wp_roles->remove_cap('give_accountant', 'view_give_reports'); |
|
292 | + $wp_roles->remove_cap('give_accountant', 'export_give_reports'); |
|
293 | 293 | |
294 | 294 | } |
295 | 295 | } |
@@ -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 | |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | /* @var WPDB $wpdb */ |
34 | 34 | global $wpdb; |
35 | 35 | |
36 | - $wpdb->customermeta = $this->table_name = $wpdb->prefix . 'give_customermeta'; |
|
36 | + $wpdb->customermeta = $this->table_name = $wpdb->prefix.'give_customermeta'; |
|
37 | 37 | $this->primary_key = 'meta_id'; |
38 | 38 | $this->version = '1.0'; |
39 | 39 | |
@@ -71,13 +71,13 @@ discard block |
||
71 | 71 | * |
72 | 72 | * @return mixed Will be an array if $single is false. Will be value of meta data field if $single is true. |
73 | 73 | */ |
74 | - public function get_meta( $donor_id = 0, $meta_key = '', $single = false ) { |
|
75 | - $donor_id = $this->sanitize_donor_id( $donor_id ); |
|
76 | - if ( false === $donor_id ) { |
|
74 | + public function get_meta($donor_id = 0, $meta_key = '', $single = false) { |
|
75 | + $donor_id = $this->sanitize_donor_id($donor_id); |
|
76 | + if (false === $donor_id) { |
|
77 | 77 | return false; |
78 | 78 | } |
79 | 79 | |
80 | - return get_metadata( 'customer', $donor_id, $meta_key, $single ); |
|
80 | + return get_metadata('customer', $donor_id, $meta_key, $single); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | /** |
@@ -95,13 +95,13 @@ discard block |
||
95 | 95 | * |
96 | 96 | * @return bool False for failure. True for success. |
97 | 97 | */ |
98 | - public function add_meta( $donor_id = 0, $meta_key = '', $meta_value, $unique = false ) { |
|
99 | - $donor_id = $this->sanitize_donor_id( $donor_id ); |
|
100 | - if ( false === $donor_id ) { |
|
98 | + public function add_meta($donor_id = 0, $meta_key = '', $meta_value, $unique = false) { |
|
99 | + $donor_id = $this->sanitize_donor_id($donor_id); |
|
100 | + if (false === $donor_id) { |
|
101 | 101 | return false; |
102 | 102 | } |
103 | 103 | |
104 | - return add_metadata( 'customer', $donor_id, $meta_key, $meta_value, $unique ); |
|
104 | + return add_metadata('customer', $donor_id, $meta_key, $meta_value, $unique); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | /** |
@@ -124,13 +124,13 @@ discard block |
||
124 | 124 | * |
125 | 125 | * @return bool False on failure, true if success. |
126 | 126 | */ |
127 | - public function update_meta( $donor_id = 0, $meta_key = '', $meta_value, $prev_value = '' ) { |
|
128 | - $donor_id = $this->sanitize_donor_id( $donor_id ); |
|
129 | - if ( false === $donor_id ) { |
|
127 | + public function update_meta($donor_id = 0, $meta_key = '', $meta_value, $prev_value = '') { |
|
128 | + $donor_id = $this->sanitize_donor_id($donor_id); |
|
129 | + if (false === $donor_id) { |
|
130 | 130 | return false; |
131 | 131 | } |
132 | 132 | |
133 | - return update_metadata( 'customer', $donor_id, $meta_key, $meta_value, $prev_value ); |
|
133 | + return update_metadata('customer', $donor_id, $meta_key, $meta_value, $prev_value); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | /** |
@@ -151,8 +151,8 @@ discard block |
||
151 | 151 | * |
152 | 152 | * @return bool False for failure. True for success. |
153 | 153 | */ |
154 | - public function delete_meta( $donor_id = 0, $meta_key = '', $meta_value = '' ) { |
|
155 | - return delete_metadata( 'customer', $donor_id, $meta_key, $meta_value ); |
|
154 | + public function delete_meta($donor_id = 0, $meta_key = '', $meta_value = '') { |
|
155 | + return delete_metadata('customer', $donor_id, $meta_key, $meta_value); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | /** |
@@ -165,9 +165,9 @@ discard block |
||
165 | 165 | * |
166 | 166 | * @return bool False for failure. True for success. |
167 | 167 | */ |
168 | - public function delete_all_meta( $donor_id = 0 ) { |
|
168 | + public function delete_all_meta($donor_id = 0) { |
|
169 | 169 | global $wpdb; |
170 | - $wpdb->delete( $this->table_name, array( 'customer_id' => $donor_id ), array( '%d' ) ); |
|
170 | + $wpdb->delete($this->table_name, array('customer_id' => $donor_id), array('%d')); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | /** |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | */ |
181 | 181 | public function create_table() { |
182 | 182 | |
183 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
183 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
184 | 184 | |
185 | 185 | $sql = "CREATE TABLE {$this->table_name} ( |
186 | 186 | meta_id bigint(20) NOT NULL AUTO_INCREMENT, |
@@ -192,9 +192,9 @@ discard block |
||
192 | 192 | KEY meta_key (meta_key) |
193 | 193 | ) CHARACTER SET utf8 COLLATE utf8_general_ci;"; |
194 | 194 | |
195 | - dbDelta( $sql ); |
|
195 | + dbDelta($sql); |
|
196 | 196 | |
197 | - update_option( $this->table_name . '_db_version', $this->version ); |
|
197 | + update_option($this->table_name.'_db_version', $this->version); |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | /** |
@@ -207,23 +207,23 @@ discard block |
||
207 | 207 | * |
208 | 208 | * @return int|bool The normalized donor ID or false if it's found to not be valid. |
209 | 209 | */ |
210 | - private function sanitize_donor_id( $donor_id ) { |
|
211 | - if ( ! is_numeric( $donor_id ) ) { |
|
210 | + private function sanitize_donor_id($donor_id) { |
|
211 | + if ( ! is_numeric($donor_id)) { |
|
212 | 212 | return false; |
213 | 213 | } |
214 | 214 | |
215 | 215 | $donor_id = (int) $donor_id; |
216 | 216 | |
217 | 217 | // We were given a non positive number. |
218 | - if ( absint( $donor_id ) !== $donor_id ) { |
|
218 | + if (absint($donor_id) !== $donor_id) { |
|
219 | 219 | return false; |
220 | 220 | } |
221 | 221 | |
222 | - if ( empty( $donor_id ) ) { |
|
222 | + if (empty($donor_id)) { |
|
223 | 223 | return false; |
224 | 224 | } |
225 | 225 | |
226 | - return absint( $donor_id ); |
|
226 | + return absint($donor_id); |
|
227 | 227 | |
228 | 228 | } |
229 | 229 |