@@ -157,7 +157,7 @@ |
||
157 | 157 | * |
158 | 158 | * @access public |
159 | 159 | * @since 1.0 |
160 | - * @return string|bool string If search is present, false otherwise |
|
160 | + * @return string|false string If search is present, false otherwise |
|
161 | 161 | */ |
162 | 162 | public function get_search() { |
163 | 163 | return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false; |
@@ -9,13 +9,13 @@ discard block |
||
9 | 9 | */ |
10 | 10 | |
11 | 11 | // Exit if accessed directly. |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; |
14 | 14 | } |
15 | 15 | |
16 | 16 | // Load WP_List_Table if not loaded. |
17 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
18 | - require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
17 | +if ( ! class_exists('WP_List_Table')) { |
|
18 | + require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php'; |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | /** |
@@ -44,13 +44,13 @@ discard block |
||
44 | 44 | global $status, $page; |
45 | 45 | |
46 | 46 | // Set parent defaults |
47 | - parent::__construct( array( |
|
48 | - 'singular' => give_get_forms_label_singular(), // Singular name of the listed records |
|
49 | - 'plural' => give_get_forms_label_plural(), // Plural name of the listed records |
|
50 | - 'ajax' => false,// Does this table support ajax? |
|
51 | - ) ); |
|
47 | + parent::__construct(array( |
|
48 | + 'singular' => give_get_forms_label_singular(), // Singular name of the listed records |
|
49 | + 'plural' => give_get_forms_label_plural(), // Plural name of the listed records |
|
50 | + 'ajax' => false, // Does this table support ajax? |
|
51 | + )); |
|
52 | 52 | |
53 | - add_action( 'give_log_view_actions', array( $this, 'give_forms_filter' ) ); |
|
53 | + add_action('give_log_view_actions', array($this, 'give_forms_filter')); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
@@ -64,41 +64,41 @@ discard block |
||
64 | 64 | * |
65 | 65 | * @return string Column Name |
66 | 66 | */ |
67 | - public function column_default( $item, $column_name ) { |
|
67 | + public function column_default($item, $column_name) { |
|
68 | 68 | |
69 | - $payment = give_get_payment_by( 'id', $item['payment_id'] ); |
|
69 | + $payment = give_get_payment_by('id', $item['payment_id']); |
|
70 | 70 | |
71 | - switch ( $column_name ) { |
|
71 | + switch ($column_name) { |
|
72 | 72 | case 'form' : |
73 | - $form_title = get_the_title( $item[ $column_name ] ); |
|
74 | - $form_title = empty( $form_title ) ? sprintf( __( 'Untitled (#%s)', 'give' ), $item[ $column_name ] ) : $form_title; |
|
75 | - return '<a href="' . esc_url( add_query_arg( 'form', $item[ $column_name ] ) ) . '" >' . esc_html( $form_title ). '</a>'; |
|
73 | + $form_title = get_the_title($item[$column_name]); |
|
74 | + $form_title = empty($form_title) ? sprintf(__('Untitled (#%s)', 'give'), $item[$column_name]) : $form_title; |
|
75 | + return '<a href="'.esc_url(add_query_arg('form', $item[$column_name])).'" >'.esc_html($form_title).'</a>'; |
|
76 | 76 | |
77 | 77 | case 'donor_id' : |
78 | 78 | return sprintf( |
79 | 79 | '<a href="%s">%s</a>', |
80 | - admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&donor=' . absint( $item['donor_id'] ) ), |
|
80 | + admin_url('edit.php?post_type=give_forms&page=give-payment-history&donor='.absint($item['donor_id'])), |
|
81 | 81 | $item['donor_name'] |
82 | 82 | ); |
83 | 83 | |
84 | 84 | case 'amount' : |
85 | - return give_currency_filter( give_format_amount( $item['amount'], array( 'sanitize' => false, 'donation_id' => $item['payment_id'] ) ), give_get_payment_currency_code( $item['payment_id'] ) ); |
|
85 | + return give_currency_filter(give_format_amount($item['amount'], array('sanitize' => false, 'donation_id' => $item['payment_id'])), give_get_payment_currency_code($item['payment_id'])); |
|
86 | 86 | |
87 | 87 | case 'status' : |
88 | 88 | |
89 | - $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>'; |
|
89 | + $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>'; |
|
90 | 90 | |
91 | - if ( $payment->mode == 'test' ) { |
|
92 | - $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' ) . '">' . __( 'Test', 'give' ) . '</span>'; |
|
91 | + if ($payment->mode == 'test') { |
|
92 | + $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').'">'.__('Test', 'give').'</span>'; |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | return $value; |
96 | 96 | |
97 | 97 | case 'payment_id' : |
98 | - return '<a href="' . admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id=' . $item['payment_id'] ) . '">' . give_get_payment_number( $item['payment_id'] ) . '</a>'; |
|
98 | + return '<a href="'.admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id='.$item['payment_id']).'">'.give_get_payment_number($item['payment_id']).'</a>'; |
|
99 | 99 | |
100 | 100 | default: |
101 | - return $item[ $column_name ]; |
|
101 | + return $item[$column_name]; |
|
102 | 102 | } |
103 | 103 | } |
104 | 104 | |
@@ -111,13 +111,13 @@ discard block |
||
111 | 111 | */ |
112 | 112 | public function get_columns() { |
113 | 113 | $columns = array( |
114 | - 'ID' => __( 'Log ID', 'give' ), |
|
115 | - 'donor_id' => __( 'Donor', 'give' ), |
|
116 | - 'form' => __( 'Form', 'give' ), |
|
117 | - 'amount' => __( 'Donation Amount', 'give' ), |
|
118 | - 'status' => __( 'Status', 'give' ), |
|
119 | - 'payment_id' => __( 'Donation ID', 'give' ), |
|
120 | - 'date' => __( 'Date', 'give' ), |
|
114 | + 'ID' => __('Log ID', 'give'), |
|
115 | + 'donor_id' => __('Donor', 'give'), |
|
116 | + 'form' => __('Form', 'give'), |
|
117 | + 'amount' => __('Donation Amount', 'give'), |
|
118 | + 'status' => __('Status', 'give'), |
|
119 | + 'payment_id' => __('Donation ID', 'give'), |
|
120 | + 'date' => __('Date', 'give'), |
|
121 | 121 | ); |
122 | 122 | |
123 | 123 | return $columns; |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | * @return int Current page number |
132 | 132 | */ |
133 | 133 | public function get_paged() { |
134 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
134 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | * @return mixed int If User ID, string If Email/Login |
143 | 143 | */ |
144 | 144 | public function get_filtered_user() { |
145 | - return isset( $_GET['user'] ) ? absint( $_GET['user'] ) : false; |
|
145 | + return isset($_GET['user']) ? absint($_GET['user']) : false; |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | /** |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | * @return int Download ID |
154 | 154 | */ |
155 | 155 | public function get_filtered_give_form() { |
156 | - return ! empty( $_GET['form'] ) ? absint( $_GET['form'] ) : false; |
|
156 | + return ! empty($_GET['form']) ? absint($_GET['form']) : false; |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | /** |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | * @return string|bool string If search is present, false otherwise |
165 | 165 | */ |
166 | 166 | public function get_search() { |
167 | - return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false; |
|
167 | + return ! empty($_GET['s']) ? urldecode(trim($_GET['s'])) : false; |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | |
@@ -180,20 +180,20 @@ discard block |
||
180 | 180 | * |
181 | 181 | * @param string $which |
182 | 182 | */ |
183 | - protected function display_tablenav( $which ) { |
|
183 | + protected function display_tablenav($which) { |
|
184 | 184 | |
185 | - if ( 'top' === $which ) { |
|
186 | - wp_nonce_field( 'bulk-' . $this->_args['plural'] ); |
|
185 | + if ('top' === $which) { |
|
186 | + wp_nonce_field('bulk-'.$this->_args['plural']); |
|
187 | 187 | } |
188 | 188 | ?> |
189 | - <div class="tablenav <?php echo esc_attr( $which ); ?>"> |
|
189 | + <div class="tablenav <?php echo esc_attr($which); ?>"> |
|
190 | 190 | |
191 | 191 | <div class="alignleft actions bulkactions"> |
192 | - <?php $this->bulk_actions( $which ); ?> |
|
192 | + <?php $this->bulk_actions($which); ?> |
|
193 | 193 | </div> |
194 | 194 | <?php |
195 | - $this->extra_tablenav( $which ); |
|
196 | - $this->pagination( $which ); |
|
195 | + $this->extra_tablenav($which); |
|
196 | + $this->pagination($which); |
|
197 | 197 | ?> |
198 | 198 | |
199 | 199 | <br class="clear"/> |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | |
218 | 218 | $meta_query = array(); |
219 | 219 | |
220 | - if ( $user ) { |
|
220 | + if ($user) { |
|
221 | 221 | // Show only logs from a specific user. |
222 | 222 | $meta_query[] = array( |
223 | 223 | 'key' => '_give_log_user_id', |
@@ -226,8 +226,8 @@ discard block |
||
226 | 226 | } |
227 | 227 | |
228 | 228 | $search = $this->get_search(); |
229 | - if ( $search ) { |
|
230 | - if ( is_email( $search ) ) { |
|
229 | + if ($search) { |
|
230 | + if (is_email($search)) { |
|
231 | 231 | // This is an email search. We use this to ensure it works for guest users and logged-in users. |
232 | 232 | $key = '_give_log_user_info'; |
233 | 233 | $compare = 'LIKE'; |
@@ -236,32 +236,32 @@ discard block |
||
236 | 236 | $key = '_give_log_user_id'; |
237 | 237 | $compare = 'LIKE'; |
238 | 238 | |
239 | - if ( ! is_numeric( $search ) ) { |
|
239 | + if ( ! is_numeric($search)) { |
|
240 | 240 | // Searching for user by username |
241 | - $user = get_user_by( 'login', $search ); |
|
241 | + $user = get_user_by('login', $search); |
|
242 | 242 | |
243 | - if ( $user ) { |
|
243 | + if ($user) { |
|
244 | 244 | // Found one, set meta value to user's ID. |
245 | 245 | $search = $user->ID; |
246 | 246 | } else { |
247 | 247 | // No user found so let's do a real search query. |
248 | - $users = new WP_User_Query( array( |
|
248 | + $users = new WP_User_Query(array( |
|
249 | 249 | 'search' => $search, |
250 | - 'search_columns' => array( 'user_url', 'user_nicename' ), |
|
250 | + 'search_columns' => array('user_url', 'user_nicename'), |
|
251 | 251 | 'number' => 1, |
252 | 252 | 'fields' => 'ids', |
253 | - ) ); |
|
253 | + )); |
|
254 | 254 | |
255 | 255 | $found_user = $users->get_results(); |
256 | 256 | |
257 | - if ( $found_user ) { |
|
257 | + if ($found_user) { |
|
258 | 258 | $search = $found_user[0]; |
259 | 259 | } |
260 | 260 | } |
261 | 261 | } |
262 | 262 | } |
263 | 263 | |
264 | - if ( ! $this->file_search ) { |
|
264 | + if ( ! $this->file_search) { |
|
265 | 265 | // Meta query only works for non file name search. |
266 | 266 | $meta_query[] = array( |
267 | 267 | 'key' => $key, |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | * @since 1.0 |
283 | 283 | * @return void |
284 | 284 | */ |
285 | - function bulk_actions( $which = '' ) { |
|
285 | + function bulk_actions($which = '') { |
|
286 | 286 | give_log_views(); |
287 | 287 | } |
288 | 288 | |
@@ -294,24 +294,24 @@ discard block |
||
294 | 294 | * @return void |
295 | 295 | */ |
296 | 296 | public function give_forms_filter() { |
297 | - $give_forms = get_posts( array( |
|
297 | + $give_forms = get_posts(array( |
|
298 | 298 | 'post_type' => 'give_forms', |
299 | 299 | 'post_status' => 'any', |
300 | - 'posts_per_page' => - 1, |
|
300 | + 'posts_per_page' => -1, |
|
301 | 301 | 'orderby' => 'title', |
302 | 302 | 'order' => 'ASC', |
303 | 303 | 'fields' => 'ids', |
304 | 304 | 'update_post_meta_cache' => false, |
305 | 305 | 'update_post_term_cache' => false, |
306 | - ) ); |
|
306 | + )); |
|
307 | 307 | |
308 | - if ( $give_forms ) { |
|
308 | + if ($give_forms) { |
|
309 | 309 | echo '<select name="form" id="give-log-form-filter">'; |
310 | - echo '<option value="0">' . __( 'All', 'give' ) . '</option>'; |
|
311 | - foreach ( $give_forms as $form ) { |
|
312 | - $form_title = get_the_title( $form ); |
|
313 | - $form_title = empty( $form_title ) ? sprintf( __( 'Untitled (#%s)', 'give' ), $form ) : $form_title; |
|
314 | - echo '<option value="' . $form . '"' . selected( $form, $this->get_filtered_give_form() ) . '>' . esc_html( $form_title ) . '</option>'; |
|
310 | + echo '<option value="0">'.__('All', 'give').'</option>'; |
|
311 | + foreach ($give_forms as $form) { |
|
312 | + $form_title = get_the_title($form); |
|
313 | + $form_title = empty($form_title) ? sprintf(__('Untitled (#%s)', 'give'), $form) : $form_title; |
|
314 | + echo '<option value="'.$form.'"'.selected($form, $this->get_filtered_give_form()).'>'.esc_html($form_title).'</option>'; |
|
315 | 315 | } |
316 | 316 | echo '</select>'; |
317 | 317 | } |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | |
332 | 332 | $logs_data = array(); |
333 | 333 | $paged = $this->get_paged(); |
334 | - $give_form = empty( $_GET['s'] ) ? $this->get_filtered_give_form() : null; |
|
334 | + $give_form = empty($_GET['s']) ? $this->get_filtered_give_form() : null; |
|
335 | 335 | $user = $this->get_filtered_user(); |
336 | 336 | |
337 | 337 | $log_query = array( |
@@ -342,37 +342,37 @@ discard block |
||
342 | 342 | 'posts_per_page' => $this->per_page, |
343 | 343 | ); |
344 | 344 | |
345 | - $cache_key = Give_Cache::get_key( 'get_logs', $log_query ); |
|
345 | + $cache_key = Give_Cache::get_key('get_logs', $log_query); |
|
346 | 346 | |
347 | 347 | // Return result from cache if exist. |
348 | - if ( ! ( $logs_data = Give_Cache::get( $cache_key ) ) ) { |
|
349 | - $logs = $give_logs->get_connected_logs( $log_query ); |
|
348 | + if ( ! ($logs_data = Give_Cache::get($cache_key))) { |
|
349 | + $logs = $give_logs->get_connected_logs($log_query); |
|
350 | 350 | |
351 | - if ( $logs ) { |
|
352 | - foreach ( $logs as $log ) { |
|
353 | - $payment_id = give_get_meta( $log->ID, '_give_log_payment_id', true ); |
|
351 | + if ($logs) { |
|
352 | + foreach ($logs as $log) { |
|
353 | + $payment_id = give_get_meta($log->ID, '_give_log_payment_id', true); |
|
354 | 354 | |
355 | 355 | // Make sure this payment hasn't been deleted. |
356 | - if ( get_post( $payment_id ) ) : |
|
357 | - $user_info = give_get_payment_meta_user_info( $payment_id ); |
|
358 | - $payment_amount = give_donation_amount( $payment_id ); |
|
356 | + if (get_post($payment_id)) : |
|
357 | + $user_info = give_get_payment_meta_user_info($payment_id); |
|
358 | + $payment_amount = give_donation_amount($payment_id); |
|
359 | 359 | |
360 | 360 | $logs_data[] = array( |
361 | - 'ID' => '<span class="give-item-label give-item-label-gray">' . $log->ID . '</span>', |
|
361 | + 'ID' => '<span class="give-item-label give-item-label-gray">'.$log->ID.'</span>', |
|
362 | 362 | 'payment_id' => $payment_id, |
363 | 363 | 'form' => $log->post_parent, |
364 | 364 | 'amount' => $payment_amount, |
365 | - 'donor_id' => give_get_payment_donor_id( $payment_id ), |
|
366 | - 'donor_name' => trim( "{$user_info['first_name']} {$user_info['last_name']}" ), |
|
367 | - 'date' => get_post_field( 'post_date', $payment_id ), |
|
365 | + 'donor_id' => give_get_payment_donor_id($payment_id), |
|
366 | + 'donor_name' => trim("{$user_info['first_name']} {$user_info['last_name']}"), |
|
367 | + 'date' => get_post_field('post_date', $payment_id), |
|
368 | 368 | ); |
369 | 369 | |
370 | 370 | endif; |
371 | 371 | } |
372 | 372 | |
373 | 373 | // Cache results. |
374 | - if ( ! empty( $logs_data ) ) { |
|
375 | - Give_Cache::set( $cache_key, $logs_data ); |
|
374 | + if ( ! empty($logs_data)) { |
|
375 | + Give_Cache::set($cache_key, $logs_data); |
|
376 | 376 | } |
377 | 377 | } |
378 | 378 | } |
@@ -400,15 +400,15 @@ discard block |
||
400 | 400 | $columns = $this->get_columns(); |
401 | 401 | $hidden = array(); |
402 | 402 | $sortable = $this->get_sortable_columns(); |
403 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
403 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
404 | 404 | $current_page = $this->get_pagenum(); |
405 | 405 | $this->items = $this->get_logs(); |
406 | - $total_items = $give_logs->get_log_count( $this->get_filtered_give_form(), 'sale', $this->get_meta_query() ); |
|
406 | + $total_items = $give_logs->get_log_count($this->get_filtered_give_form(), 'sale', $this->get_meta_query()); |
|
407 | 407 | |
408 | - $this->set_pagination_args( array( |
|
408 | + $this->set_pagination_args(array( |
|
409 | 409 | 'total_items' => $total_items, |
410 | 410 | 'per_page' => $this->per_page, |
411 | - 'total_pages' => ceil( $total_items / $this->per_page ), |
|
411 | + 'total_pages' => ceil($total_items / $this->per_page), |
|
412 | 412 | ) |
413 | 413 | ); |
414 | 414 | } |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param array $args An array of form arguments. |
23 | 23 | * |
24 | - * @return string Donation form. |
|
24 | + * @return false|null Donation form. |
|
25 | 25 | */ |
26 | 26 | function give_get_donation_form( $args = array() ) { |
27 | 27 | |
@@ -1470,7 +1470,7 @@ discard block |
||
1470 | 1470 | * |
1471 | 1471 | * @param int $form_id The form ID. |
1472 | 1472 | * |
1473 | - * @return bool |
|
1473 | + * @return false|null |
|
1474 | 1474 | */ |
1475 | 1475 | function give_terms_agreement( $form_id ) { |
1476 | 1476 | $form_option = give_get_meta( $form_id, '_give_terms_option', true ); |
@@ -1647,7 +1647,7 @@ discard block |
||
1647 | 1647 | * @param int $form_id The form ID. |
1648 | 1648 | * @param array $args An array of form arguments. |
1649 | 1649 | * |
1650 | - * @return mixed |
|
1650 | + * @return boolean |
|
1651 | 1651 | */ |
1652 | 1652 | function give_show_goal_progress( $form_id, $args ) { |
1653 | 1653 | |
@@ -1667,7 +1667,7 @@ discard block |
||
1667 | 1667 | * |
1668 | 1668 | * @since 1.8 |
1669 | 1669 | * |
1670 | - * @param $form_id |
|
1670 | + * @param integer $form_id |
|
1671 | 1671 | * @param $args |
1672 | 1672 | * |
1673 | 1673 | * @return mixed|string |
@@ -1708,7 +1708,7 @@ discard block |
||
1708 | 1708 | * @param int $form_id The form ID. |
1709 | 1709 | * @param array $args An array of form arguments. |
1710 | 1710 | * |
1711 | - * @return void|bool |
|
1711 | + * @return false|null |
|
1712 | 1712 | */ |
1713 | 1713 | function give_form_content( $form_id, $args ) { |
1714 | 1714 |
@@ -1020,9 +1020,12 @@ |
||
1020 | 1020 | } |
1021 | 1021 | ?> |
1022 | 1022 | </select> |
1023 | - <?php else : ?> |
|
1023 | + <?php else { |
|
1024 | + : ?> |
|
1024 | 1025 | <input type="text" size="6" name="card_state" id="card_state" class="card_state give-input" |
1025 | - placeholder="<?php echo $label; ?>" value="<?php echo $selected_state; ?>"/> |
|
1026 | + placeholder="<?php echo $label; |
|
1027 | +} |
|
1028 | +?>" value="<?php echo $selected_state; ?>"/> |
|
1026 | 1029 | <?php endif; ?> |
1027 | 1030 | </p> |
1028 | 1031 |
@@ -941,10 +941,10 @@ discard block |
||
941 | 941 | <?php echo( give_field_is_required( 'billing_country', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
942 | 942 | > |
943 | 943 | <?php |
944 | - foreach ( $countries as $country_code => $country ) { |
|
945 | - echo '<option value="' . esc_attr( $country_code ) . '"' . selected( $country_code, $selected_country, false ) . '>' . $country . '</option>'; |
|
946 | - } |
|
947 | - ?> |
|
944 | + foreach ( $countries as $country_code => $country ) { |
|
945 | + echo '<option value="' . esc_attr( $country_code ) . '"' . selected( $country_code, $selected_country, false ) . '>' . $country . '</option>'; |
|
946 | + } |
|
947 | + ?> |
|
948 | 948 | </select> |
949 | 949 | </p> |
950 | 950 | |
@@ -952,7 +952,7 @@ discard block |
||
952 | 952 | <label for="card_address" class="give-label"> |
953 | 953 | <?php esc_html_e( 'Address 1', 'give' ); ?> |
954 | 954 | <?php |
955 | - if ( give_field_is_required( 'card_address', $form_id ) ) : ?> |
|
955 | + if ( give_field_is_required( 'card_address', $form_id ) ) : ?> |
|
956 | 956 | <span class="give-required-indicator">*</span> |
957 | 957 | <?php endif; ?> |
958 | 958 | <span class="give-tooltip give-icon give-icon-question" |
@@ -1016,7 +1016,7 @@ discard block |
||
1016 | 1016 | <label for="card_state" class="give-label"> |
1017 | 1017 | <span class="state-label-text"><?php echo $label; ?></span> |
1018 | 1018 | <?php if ( give_field_is_required( 'card_state', $form_id ) ) : |
1019 | - ?> |
|
1019 | + ?> |
|
1020 | 1020 | <span class="give-required-indicator <?php echo( array_key_exists( $selected_country, $states_not_required_country_list ) ? 'give-hidden' : '' ) ?> ">*</span> |
1021 | 1021 | <?php endif; ?> |
1022 | 1022 | <span class="give-tooltip give-icon give-icon-question" |
@@ -1024,17 +1024,17 @@ discard block |
||
1024 | 1024 | </label> |
1025 | 1025 | <?php |
1026 | 1026 | |
1027 | - if ( ! empty( $states ) ) : ?> |
|
1027 | + if ( ! empty( $states ) ) : ?> |
|
1028 | 1028 | <select |
1029 | 1029 | name="card_state" |
1030 | 1030 | id="card_state" |
1031 | 1031 | class="card_state give-select<?php echo( give_field_is_required( 'card_state', $form_id ) ? ' required' : '' ); ?>" |
1032 | 1032 | <?php echo( give_field_is_required( 'card_state', $form_id ) ? ' required aria-required="true" ' : '' ); ?>> |
1033 | 1033 | <?php |
1034 | - foreach ( $states as $state_code => $state ) { |
|
1035 | - echo '<option value="' . $state_code . '"' . selected( $state_code, $selected_state, false ) . '>' . $state . '</option>'; |
|
1036 | - } |
|
1037 | - ?> |
|
1034 | + foreach ( $states as $state_code => $state ) { |
|
1035 | + echo '<option value="' . $state_code . '"' . selected( $state_code, $selected_state, false ) . '>' . $state . '</option>'; |
|
1036 | + } |
|
1037 | + ?> |
|
1038 | 1038 | </select> |
1039 | 1039 | <?php else : ?> |
1040 | 1040 | <input type="text" size="6" name="card_state" id="card_state" class="card_state give-input" |
@@ -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 | |
@@ -23,50 +23,50 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @return string Donation form. |
25 | 25 | */ |
26 | -function give_get_donation_form( $args = array() ) { |
|
26 | +function give_get_donation_form($args = array()) { |
|
27 | 27 | |
28 | 28 | global $post; |
29 | 29 | |
30 | - $form_id = is_object( $post ) ? $post->ID : 0; |
|
30 | + $form_id = is_object($post) ? $post->ID : 0; |
|
31 | 31 | |
32 | - if ( isset( $args['id'] ) ) { |
|
32 | + if (isset($args['id'])) { |
|
33 | 33 | $form_id = $args['id']; |
34 | 34 | } |
35 | 35 | |
36 | - $defaults = apply_filters( 'give_form_args_defaults', array( |
|
36 | + $defaults = apply_filters('give_form_args_defaults', array( |
|
37 | 37 | 'form_id' => $form_id, |
38 | - ) ); |
|
38 | + )); |
|
39 | 39 | |
40 | - $args = wp_parse_args( $args, $defaults ); |
|
40 | + $args = wp_parse_args($args, $defaults); |
|
41 | 41 | |
42 | - $form = new Give_Donate_Form( $args['form_id'] ); |
|
42 | + $form = new Give_Donate_Form($args['form_id']); |
|
43 | 43 | |
44 | 44 | //bail if no form ID. |
45 | - if ( empty( $form->ID ) ) { |
|
45 | + if (empty($form->ID)) { |
|
46 | 46 | return false; |
47 | 47 | } |
48 | 48 | |
49 | - $payment_mode = give_get_chosen_gateway( $form->ID ); |
|
49 | + $payment_mode = give_get_chosen_gateway($form->ID); |
|
50 | 50 | |
51 | - $form_action = add_query_arg( apply_filters( 'give_form_action_args', array( |
|
51 | + $form_action = add_query_arg(apply_filters('give_form_action_args', array( |
|
52 | 52 | 'payment-mode' => $payment_mode, |
53 | - ) ), |
|
53 | + )), |
|
54 | 54 | give_get_current_page_url() |
55 | 55 | ); |
56 | 56 | |
57 | 57 | //Sanity Check: Donation form not published or user doesn't have permission to view drafts. |
58 | 58 | if ( |
59 | - ( 'publish' !== $form->post_status && ! current_user_can( 'edit_give_forms', $form->ID ) ) |
|
60 | - || ( 'trash' === $form->post_status ) |
|
59 | + ('publish' !== $form->post_status && ! current_user_can('edit_give_forms', $form->ID)) |
|
60 | + || ('trash' === $form->post_status) |
|
61 | 61 | ) { |
62 | 62 | return false; |
63 | 63 | } |
64 | 64 | |
65 | 65 | //Get the form wrap CSS classes. |
66 | - $form_wrap_classes = $form->get_form_wrap_classes( $args ); |
|
66 | + $form_wrap_classes = $form->get_form_wrap_classes($args); |
|
67 | 67 | |
68 | 68 | //Get the <form> tag wrap CSS classes. |
69 | - $form_classes = $form->get_form_classes( $args ); |
|
69 | + $form_classes = $form->get_form_classes($args); |
|
70 | 70 | |
71 | 71 | ob_start(); |
72 | 72 | |
@@ -78,19 +78,19 @@ discard block |
||
78 | 78 | * @param int $form_id The form ID. |
79 | 79 | * @param array $args An array of form arguments. |
80 | 80 | */ |
81 | - do_action( 'give_pre_form_output', $form->ID, $args, $form ); |
|
81 | + do_action('give_pre_form_output', $form->ID, $args, $form); |
|
82 | 82 | |
83 | 83 | ?> |
84 | 84 | <div id="give-form-<?php echo $form->ID; ?>-wrap" class="<?php echo $form_wrap_classes; ?>"> |
85 | 85 | |
86 | - <?php if ( $form->is_close_donation_form() ) { |
|
86 | + <?php if ($form->is_close_donation_form()) { |
|
87 | 87 | |
88 | 88 | // Get Goal thank you message. |
89 | - $goal_achieved_message = give_get_meta( $form->ID, '_give_form_goal_achieved_message', true ); |
|
90 | - $goal_achieved_message = ! empty( $goal_achieved_message ) ? apply_filters( 'the_content', $goal_achieved_message ) : ''; |
|
89 | + $goal_achieved_message = give_get_meta($form->ID, '_give_form_goal_achieved_message', true); |
|
90 | + $goal_achieved_message = ! empty($goal_achieved_message) ? apply_filters('the_content', $goal_achieved_message) : ''; |
|
91 | 91 | |
92 | 92 | // Print thank you message. |
93 | - echo apply_filters( 'give_goal_closed_output', $goal_achieved_message, $form->ID, $form ); |
|
93 | + echo apply_filters('give_goal_closed_output', $goal_achieved_message, $form->ID, $form); |
|
94 | 94 | |
95 | 95 | } else { |
96 | 96 | /** |
@@ -98,10 +98,10 @@ discard block |
||
98 | 98 | * 1. if show_title params set to true |
99 | 99 | * 2. if admin set form display_style to button |
100 | 100 | */ |
101 | - $form_title = apply_filters( 'give_form_title', '<h2 class="give-form-title">' . get_the_title( $form_id ) . '</h2>' ); |
|
101 | + $form_title = apply_filters('give_form_title', '<h2 class="give-form-title">'.get_the_title($form_id).'</h2>'); |
|
102 | 102 | if ( |
103 | - ( isset( $args['show_title'] ) && $args['show_title'] == true ) |
|
104 | - && ! doing_action( 'give_single_form_summary' ) |
|
103 | + (isset($args['show_title']) && $args['show_title'] == true) |
|
104 | + && ! doing_action('give_single_form_summary') |
|
105 | 105 | ) { |
106 | 106 | echo $form_title; |
107 | 107 | } |
@@ -115,13 +115,13 @@ discard block |
||
115 | 115 | * @param array $args An array of form arguments. |
116 | 116 | * @param Give_Donate_Form $form Form object. |
117 | 117 | */ |
118 | - do_action( 'give_pre_form', $form->ID, $args, $form ); |
|
118 | + do_action('give_pre_form', $form->ID, $args, $form); |
|
119 | 119 | |
120 | 120 | // Set form html tags. |
121 | 121 | $form_html_tags = array( |
122 | 122 | 'id' => "give-form-{$form_id}", |
123 | 123 | 'class' => $form_classes, |
124 | - 'action' => esc_url_raw( $form_action ), |
|
124 | + 'action' => esc_url_raw($form_action), |
|
125 | 125 | ); |
126 | 126 | |
127 | 127 | /** |
@@ -132,10 +132,10 @@ discard block |
||
132 | 132 | * @param array $form_html_tags Array of form html tags. |
133 | 133 | * @param Give_Donate_Form $form Form object. |
134 | 134 | */ |
135 | - $form_html_tags = apply_filters( 'give_form_html_tags', (array) $form_html_tags, $form ); |
|
135 | + $form_html_tags = apply_filters('give_form_html_tags', (array) $form_html_tags, $form); |
|
136 | 136 | ?> |
137 | 137 | |
138 | - <form <?php echo give_get_attribute_str( $form_html_tags ); ?> method="post"> |
|
138 | + <form <?php echo give_get_attribute_str($form_html_tags); ?> method="post"> |
|
139 | 139 | |
140 | 140 | <!-- The following field is for robots only, invisible to humans: --> |
141 | 141 | <span class="give-hidden" style="display: none !important;"> |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | * @param array $args An array of form arguments. |
156 | 156 | * @param Give_Donate_Form $form Form object. |
157 | 157 | */ |
158 | - do_action( 'give_donation_form_top', $form->ID, $args, $form ); |
|
158 | + do_action('give_donation_form_top', $form->ID, $args, $form); |
|
159 | 159 | |
160 | 160 | /** |
161 | 161 | * Fires while outputting donation form, for payment gateway fields. |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | * @param array $args An array of form arguments. |
167 | 167 | * @param Give_Donate_Form $form Form object. |
168 | 168 | */ |
169 | - do_action( 'give_payment_mode_select', $form->ID, $args, $form ); |
|
169 | + do_action('give_payment_mode_select', $form->ID, $args, $form); |
|
170 | 170 | |
171 | 171 | /** |
172 | 172 | * Fires while outputting donation form, after all other fields. |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | * @param array $args An array of form arguments. |
178 | 178 | * @param Give_Donate_Form $form Form object. |
179 | 179 | */ |
180 | - do_action( 'give_donation_form_bottom', $form->ID, $args, $form ); |
|
180 | + do_action('give_donation_form_bottom', $form->ID, $args, $form); |
|
181 | 181 | |
182 | 182 | ?> |
183 | 183 | </form> |
@@ -192,12 +192,12 @@ discard block |
||
192 | 192 | * @param array $args An array of form arguments. |
193 | 193 | * @param Give_Donate_Form $form Form object. |
194 | 194 | */ |
195 | - do_action( 'give_post_form', $form->ID, $args, $form ); |
|
195 | + do_action('give_post_form', $form->ID, $args, $form); |
|
196 | 196 | |
197 | 197 | } |
198 | 198 | ?> |
199 | 199 | |
200 | - </div><!--end #give-form-<?php echo absint( $form->ID ); ?>--> |
|
200 | + </div><!--end #give-form-<?php echo absint($form->ID); ?>--> |
|
201 | 201 | <?php |
202 | 202 | |
203 | 203 | /** |
@@ -208,11 +208,11 @@ discard block |
||
208 | 208 | * @param int $form_id The form ID. |
209 | 209 | * @param array $args An array of form arguments. |
210 | 210 | */ |
211 | - do_action( 'give_post_form_output', $form->ID, $args ); |
|
211 | + do_action('give_post_form_output', $form->ID, $args); |
|
212 | 212 | |
213 | 213 | $final_output = ob_get_clean(); |
214 | 214 | |
215 | - echo apply_filters( 'give_donate_form', $final_output, $args ); |
|
215 | + echo apply_filters('give_donate_form', $final_output, $args); |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | /** |
@@ -229,11 +229,11 @@ discard block |
||
229 | 229 | * |
230 | 230 | * @return string |
231 | 231 | */ |
232 | -function give_show_purchase_form( $form_id ) { |
|
232 | +function give_show_purchase_form($form_id) { |
|
233 | 233 | |
234 | - $payment_mode = give_get_chosen_gateway( $form_id ); |
|
234 | + $payment_mode = give_get_chosen_gateway($form_id); |
|
235 | 235 | |
236 | - if ( ! isset( $form_id ) && isset( $_POST['give_form_id'] ) ) { |
|
236 | + if ( ! isset($form_id) && isset($_POST['give_form_id'])) { |
|
237 | 237 | $form_id = $_POST['give_form_id']; |
238 | 238 | } |
239 | 239 | |
@@ -242,33 +242,33 @@ discard block |
||
242 | 242 | * |
243 | 243 | * @since 1.7 |
244 | 244 | */ |
245 | - do_action( 'give_payment_fields_top', $form_id ); |
|
245 | + do_action('give_payment_fields_top', $form_id); |
|
246 | 246 | |
247 | - if ( give_can_checkout() && isset( $form_id ) ) { |
|
247 | + if (give_can_checkout() && isset($form_id)) { |
|
248 | 248 | |
249 | 249 | /** |
250 | 250 | * Fires while displaying donation form, before registration login. |
251 | 251 | * |
252 | 252 | * @since 1.7 |
253 | 253 | */ |
254 | - do_action( 'give_donation_form_before_register_login', $form_id ); |
|
254 | + do_action('give_donation_form_before_register_login', $form_id); |
|
255 | 255 | |
256 | 256 | /** |
257 | 257 | * Fire when register/login form fields render. |
258 | 258 | * |
259 | 259 | * @since 1.7 |
260 | 260 | */ |
261 | - do_action( 'give_donation_form_register_login_fields', $form_id ); |
|
261 | + do_action('give_donation_form_register_login_fields', $form_id); |
|
262 | 262 | |
263 | 263 | /** |
264 | 264 | * Fire when credit card form fields render. |
265 | 265 | * |
266 | 266 | * @since 1.7 |
267 | 267 | */ |
268 | - do_action( 'give_donation_form_before_cc_form', $form_id ); |
|
268 | + do_action('give_donation_form_before_cc_form', $form_id); |
|
269 | 269 | |
270 | 270 | // Load the credit card form and allow gateways to load their own if they wish. |
271 | - if ( has_action( 'give_' . $payment_mode . '_cc_form' ) ) { |
|
271 | + if (has_action('give_'.$payment_mode.'_cc_form')) { |
|
272 | 272 | /** |
273 | 273 | * Fires while displaying donation form, credit card form fields for a given gateway. |
274 | 274 | * |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | * |
277 | 277 | * @param int $form_id The form ID. |
278 | 278 | */ |
279 | - do_action( "give_{$payment_mode}_cc_form", $form_id ); |
|
279 | + do_action("give_{$payment_mode}_cc_form", $form_id); |
|
280 | 280 | } else { |
281 | 281 | /** |
282 | 282 | * Fires while displaying donation form, credit card form fields. |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | * |
286 | 286 | * @param int $form_id The form ID. |
287 | 287 | */ |
288 | - do_action( 'give_cc_form', $form_id ); |
|
288 | + do_action('give_cc_form', $form_id); |
|
289 | 289 | } |
290 | 290 | |
291 | 291 | /** |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | * |
294 | 294 | * @since 1.7 |
295 | 295 | */ |
296 | - do_action( 'give_donation_form_after_cc_form', $form_id ); |
|
296 | + do_action('give_donation_form_after_cc_form', $form_id); |
|
297 | 297 | |
298 | 298 | } else { |
299 | 299 | /** |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | * |
302 | 302 | * @since 1.7 |
303 | 303 | */ |
304 | - do_action( 'give_donation_form_no_access', $form_id ); |
|
304 | + do_action('give_donation_form_no_access', $form_id); |
|
305 | 305 | |
306 | 306 | } |
307 | 307 | |
@@ -310,10 +310,10 @@ discard block |
||
310 | 310 | * |
311 | 311 | * @since 1.7 |
312 | 312 | */ |
313 | - do_action( 'give_payment_fields_bottom', $form_id ); |
|
313 | + do_action('give_payment_fields_bottom', $form_id); |
|
314 | 314 | } |
315 | 315 | |
316 | -add_action( 'give_donation_form', 'give_show_purchase_form' ); |
|
316 | +add_action('give_donation_form', 'give_show_purchase_form'); |
|
317 | 317 | |
318 | 318 | /** |
319 | 319 | * Give Show Login/Register Form Fields. |
@@ -324,11 +324,11 @@ discard block |
||
324 | 324 | * |
325 | 325 | * @return void |
326 | 326 | */ |
327 | -function give_show_register_login_fields( $form_id ) { |
|
327 | +function give_show_register_login_fields($form_id) { |
|
328 | 328 | |
329 | - $show_register_form = give_show_login_register_option( $form_id ); |
|
329 | + $show_register_form = give_show_login_register_option($form_id); |
|
330 | 330 | |
331 | - if ( ( $show_register_form === 'registration' || ( $show_register_form === 'both' && ! isset( $_GET['login'] ) ) ) && ! is_user_logged_in() ) : |
|
331 | + if (($show_register_form === 'registration' || ($show_register_form === 'both' && ! isset($_GET['login']))) && ! is_user_logged_in()) : |
|
332 | 332 | ?> |
333 | 333 | <div id="give-checkout-login-register-<?php echo $form_id; ?>"> |
334 | 334 | <?php |
@@ -337,11 +337,11 @@ discard block |
||
337 | 337 | * |
338 | 338 | * @since 1.7 |
339 | 339 | */ |
340 | - do_action( 'give_donation_form_register_fields', $form_id ); |
|
340 | + do_action('give_donation_form_register_fields', $form_id); |
|
341 | 341 | ?> |
342 | 342 | </div> |
343 | 343 | <?php |
344 | - elseif ( ( $show_register_form === 'login' || ( $show_register_form === 'both' && isset( $_GET['login'] ) ) ) && ! is_user_logged_in() ) : |
|
344 | + elseif (($show_register_form === 'login' || ($show_register_form === 'both' && isset($_GET['login']))) && ! is_user_logged_in()) : |
|
345 | 345 | ?> |
346 | 346 | <div id="give-checkout-login-register-<?php echo $form_id; ?>"> |
347 | 347 | <?php |
@@ -350,23 +350,23 @@ discard block |
||
350 | 350 | * |
351 | 351 | * @since 1.7 |
352 | 352 | */ |
353 | - do_action( 'give_donation_form_login_fields', $form_id ); |
|
353 | + do_action('give_donation_form_login_fields', $form_id); |
|
354 | 354 | ?> |
355 | 355 | </div> |
356 | 356 | <?php |
357 | 357 | endif; |
358 | 358 | |
359 | - if ( ( ! isset( $_GET['login'] ) && is_user_logged_in() ) || ! isset( $show_register_form ) || 'none' === $show_register_form || 'login' === $show_register_form ) { |
|
359 | + if (( ! isset($_GET['login']) && is_user_logged_in()) || ! isset($show_register_form) || 'none' === $show_register_form || 'login' === $show_register_form) { |
|
360 | 360 | /** |
361 | 361 | * Fire when user info render. |
362 | 362 | * |
363 | 363 | * @since 1.7 |
364 | 364 | */ |
365 | - do_action( 'give_donation_form_after_user_info', $form_id ); |
|
365 | + do_action('give_donation_form_after_user_info', $form_id); |
|
366 | 366 | } |
367 | 367 | } |
368 | 368 | |
369 | -add_action( 'give_donation_form_register_login_fields', 'give_show_register_login_fields' ); |
|
369 | +add_action('give_donation_form_register_login_fields', 'give_show_register_login_fields'); |
|
370 | 370 | |
371 | 371 | /** |
372 | 372 | * Donation Amount Field. |
@@ -381,16 +381,16 @@ discard block |
||
381 | 381 | * |
382 | 382 | * @return void |
383 | 383 | */ |
384 | -function give_output_donation_amount_top( $form_id = 0, $args = array() ) { |
|
384 | +function give_output_donation_amount_top($form_id = 0, $args = array()) { |
|
385 | 385 | |
386 | 386 | $give_options = give_get_settings(); |
387 | - $variable_pricing = give_has_variable_prices( $form_id ); |
|
388 | - $allow_custom_amount = give_get_meta( $form_id, '_give_custom_amount', true ); |
|
389 | - $currency_position = isset( $give_options['currency_position'] ) ? $give_options['currency_position'] : 'before'; |
|
390 | - $symbol = give_currency_symbol( give_get_currency( $form_id, $args ) ); |
|
391 | - $currency_output = '<span class="give-currency-symbol give-currency-position-' . $currency_position . '">' . $symbol . '</span>'; |
|
392 | - $default_amount = give_format_amount( give_get_default_form_amount( $form_id ), array( 'sanitize' => false, 'currency' => give_get_currency( $form_id ) ) ); |
|
393 | - $custom_amount_text = give_get_meta( $form_id, '_give_custom_amount_text', true ); |
|
387 | + $variable_pricing = give_has_variable_prices($form_id); |
|
388 | + $allow_custom_amount = give_get_meta($form_id, '_give_custom_amount', true); |
|
389 | + $currency_position = isset($give_options['currency_position']) ? $give_options['currency_position'] : 'before'; |
|
390 | + $symbol = give_currency_symbol(give_get_currency($form_id, $args)); |
|
391 | + $currency_output = '<span class="give-currency-symbol give-currency-position-'.$currency_position.'">'.$symbol.'</span>'; |
|
392 | + $default_amount = give_format_amount(give_get_default_form_amount($form_id), array('sanitize' => false, 'currency' => give_get_currency($form_id))); |
|
393 | + $custom_amount_text = give_get_meta($form_id, '_give_custom_amount_text', true); |
|
394 | 394 | |
395 | 395 | /** |
396 | 396 | * Fires while displaying donation form, before donation level fields. |
@@ -400,20 +400,20 @@ discard block |
||
400 | 400 | * @param int $form_id The form ID. |
401 | 401 | * @param array $args An array of form arguments. |
402 | 402 | */ |
403 | - do_action( 'give_before_donation_levels', $form_id, $args ); |
|
403 | + do_action('give_before_donation_levels', $form_id, $args); |
|
404 | 404 | |
405 | 405 | //Set Price, No Custom Amount Allowed means hidden price field |
406 | - if ( ! give_is_setting_enabled( $allow_custom_amount ) ) { |
|
406 | + if ( ! give_is_setting_enabled($allow_custom_amount)) { |
|
407 | 407 | ?> |
408 | - <label class="give-hidden" for="give-amount-hidden"><?php esc_html_e( 'Donation Amount:', 'give' ); ?></label> |
|
408 | + <label class="give-hidden" for="give-amount-hidden"><?php esc_html_e('Donation Amount:', 'give'); ?></label> |
|
409 | 409 | <input id="give-amount" class="give-amount-hidden" type="hidden" name="give-amount" |
410 | 410 | value="<?php echo $default_amount; ?>" required aria-required="true"/> |
411 | 411 | <div class="set-price give-donation-amount form-row-wide"> |
412 | - <?php if ( $currency_position == 'before' ) { |
|
412 | + <?php if ($currency_position == 'before') { |
|
413 | 413 | echo $currency_output; |
414 | 414 | } ?> |
415 | 415 | <span id="give-amount-text" class="give-text-input give-amount-top"><?php echo $default_amount; ?></span> |
416 | - <?php if ( $currency_position == 'after' ) { |
|
416 | + <?php if ($currency_position == 'after') { |
|
417 | 417 | echo $currency_output; |
418 | 418 | } ?> |
419 | 419 | </div> |
@@ -423,13 +423,13 @@ discard block |
||
423 | 423 | ?> |
424 | 424 | <div class="give-total-wrap"> |
425 | 425 | <div class="give-donation-amount form-row-wide"> |
426 | - <?php if ( $currency_position == 'before' ) { |
|
426 | + <?php if ($currency_position == 'before') { |
|
427 | 427 | echo $currency_output; |
428 | 428 | } ?> |
429 | - <label class="give-hidden" for="give-amount"><?php esc_html_e( 'Donation Amount:', 'give' ); ?></label> |
|
429 | + <label class="give-hidden" for="give-amount"><?php esc_html_e('Donation Amount:', 'give'); ?></label> |
|
430 | 430 | <input class="give-text-input give-amount-top" id="give-amount" name="give-amount" type="tel" |
431 | 431 | placeholder="" value="<?php echo $default_amount; ?>" autocomplete="off"> |
432 | - <?php if ( $currency_position == 'after' ) { |
|
432 | + <?php if ($currency_position == 'after') { |
|
433 | 433 | echo $currency_output; |
434 | 434 | } ?> |
435 | 435 | </div> |
@@ -444,16 +444,16 @@ discard block |
||
444 | 444 | * @param int $form_id The form ID. |
445 | 445 | * @param array $args An array of form arguments. |
446 | 446 | */ |
447 | - do_action( 'give_after_donation_amount', $form_id, $args ); |
|
447 | + do_action('give_after_donation_amount', $form_id, $args); |
|
448 | 448 | |
449 | 449 | //Custom Amount Text |
450 | - if ( ! $variable_pricing && give_is_setting_enabled( $allow_custom_amount ) && ! empty( $custom_amount_text ) ) { ?> |
|
450 | + if ( ! $variable_pricing && give_is_setting_enabled($allow_custom_amount) && ! empty($custom_amount_text)) { ?> |
|
451 | 451 | <p class="give-custom-amount-text"><?php echo $custom_amount_text; ?></p> |
452 | 452 | <?php } |
453 | 453 | |
454 | 454 | //Output Variable Pricing Levels. |
455 | - if ( $variable_pricing ) { |
|
456 | - give_output_levels( $form_id ); |
|
455 | + if ($variable_pricing) { |
|
456 | + give_output_levels($form_id); |
|
457 | 457 | } |
458 | 458 | |
459 | 459 | /** |
@@ -464,10 +464,10 @@ discard block |
||
464 | 464 | * @param int $form_id The form ID. |
465 | 465 | * @param array $args An array of form arguments. |
466 | 466 | */ |
467 | - do_action( 'give_after_donation_levels', $form_id, $args ); |
|
467 | + do_action('give_after_donation_levels', $form_id, $args); |
|
468 | 468 | } |
469 | 469 | |
470 | -add_action( 'give_donation_form_top', 'give_output_donation_amount_top', 10, 2 ); |
|
470 | +add_action('give_donation_form_top', 'give_output_donation_amount_top', 10, 2); |
|
471 | 471 | |
472 | 472 | /** |
473 | 473 | * Outputs the Donation Levels in various formats such as dropdown, radios, and buttons. |
@@ -478,30 +478,30 @@ discard block |
||
478 | 478 | * |
479 | 479 | * @return string Donation levels. |
480 | 480 | */ |
481 | -function give_output_levels( $form_id ) { |
|
481 | +function give_output_levels($form_id) { |
|
482 | 482 | |
483 | 483 | //Get variable pricing. |
484 | - $prices = apply_filters( 'give_form_variable_prices', give_get_variable_prices( $form_id ), $form_id ); |
|
485 | - $display_style = give_get_meta( $form_id, '_give_display_style', true ); |
|
486 | - $custom_amount = give_get_meta( $form_id, '_give_custom_amount', true ); |
|
487 | - $custom_amount_text = give_get_meta( $form_id, '_give_custom_amount_text', true ); |
|
488 | - if ( empty( $custom_amount_text ) ) { |
|
489 | - $custom_amount_text = esc_html__( 'Give a Custom Amount', 'give' ); |
|
484 | + $prices = apply_filters('give_form_variable_prices', give_get_variable_prices($form_id), $form_id); |
|
485 | + $display_style = give_get_meta($form_id, '_give_display_style', true); |
|
486 | + $custom_amount = give_get_meta($form_id, '_give_custom_amount', true); |
|
487 | + $custom_amount_text = give_get_meta($form_id, '_give_custom_amount_text', true); |
|
488 | + if (empty($custom_amount_text)) { |
|
489 | + $custom_amount_text = esc_html__('Give a Custom Amount', 'give'); |
|
490 | 490 | } |
491 | 491 | |
492 | 492 | $output = ''; |
493 | 493 | |
494 | - switch ( $display_style ) { |
|
494 | + switch ($display_style) { |
|
495 | 495 | case 'buttons': |
496 | 496 | |
497 | 497 | $output .= '<ul id="give-donation-level-button-wrap" class="give-donation-levels-wrap give-list-inline">'; |
498 | 498 | |
499 | - foreach ( $prices as $price ) { |
|
500 | - $level_text = apply_filters( 'give_form_level_text', ! empty( $price['_give_text'] ) ? $price['_give_text'] : give_currency_filter( give_format_amount( $price['_give_amount'], array( 'sanitize' => false ) ) ), $form_id, $price ); |
|
501 | - $level_classes = apply_filters( 'give_form_level_classes', 'give-donation-level-btn give-btn give-btn-level-' . $price['_give_id']['level_id'] . ' ' . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? 'give-default-level' : '' ), $form_id, $price ); |
|
499 | + foreach ($prices as $price) { |
|
500 | + $level_text = apply_filters('give_form_level_text', ! empty($price['_give_text']) ? $price['_give_text'] : give_currency_filter(give_format_amount($price['_give_amount'], array('sanitize' => false))), $form_id, $price); |
|
501 | + $level_classes = apply_filters('give_form_level_classes', 'give-donation-level-btn give-btn give-btn-level-'.$price['_give_id']['level_id'].' '.((isset($price['_give_default']) && $price['_give_default'] === 'default') ? 'give-default-level' : ''), $form_id, $price); |
|
502 | 502 | |
503 | 503 | $output .= '<li>'; |
504 | - $output .= '<button type="button" data-price-id="' . $price['_give_id']['level_id'] . '" class=" ' . $level_classes . '" value="' . give_format_amount( $price['_give_amount'], array( 'sanitize' => false ) ) . '">'; |
|
504 | + $output .= '<button type="button" data-price-id="'.$price['_give_id']['level_id'].'" class=" '.$level_classes.'" value="'.give_format_amount($price['_give_amount'], array('sanitize' => false)).'">'; |
|
505 | 505 | $output .= $level_text; |
506 | 506 | $output .= '</button>'; |
507 | 507 | $output .= '</li>'; |
@@ -509,7 +509,7 @@ discard block |
||
509 | 509 | } |
510 | 510 | |
511 | 511 | //Custom Amount. |
512 | - if ( give_is_setting_enabled( $custom_amount ) && ! empty( $custom_amount_text ) ) { |
|
512 | + if (give_is_setting_enabled($custom_amount) && ! empty($custom_amount_text)) { |
|
513 | 513 | $output .= '<li>'; |
514 | 514 | $output .= '<button type="button" data-price-id="custom" class="give-donation-level-btn give-btn give-btn-level-custom" value="custom">'; |
515 | 515 | $output .= $custom_amount_text; |
@@ -525,22 +525,22 @@ discard block |
||
525 | 525 | |
526 | 526 | $output .= '<ul id="give-donation-level-radio-list" class="give-donation-levels-wrap">'; |
527 | 527 | |
528 | - foreach ( $prices as $price ) { |
|
529 | - $level_text = apply_filters( 'give_form_level_text', ! empty( $price['_give_text'] ) ? $price['_give_text'] : give_currency_filter( give_format_amount( $price['_give_amount'], array( 'sanitize' => false ) ) ), $form_id, $price ); |
|
530 | - $level_classes = apply_filters( 'give_form_level_classes', 'give-radio-input give-radio-input-level give-radio-level-' . $price['_give_id']['level_id'] . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? ' give-default-level' : '' ), $form_id, $price ); |
|
528 | + foreach ($prices as $price) { |
|
529 | + $level_text = apply_filters('give_form_level_text', ! empty($price['_give_text']) ? $price['_give_text'] : give_currency_filter(give_format_amount($price['_give_amount'], array('sanitize' => false))), $form_id, $price); |
|
530 | + $level_classes = apply_filters('give_form_level_classes', 'give-radio-input give-radio-input-level give-radio-level-'.$price['_give_id']['level_id'].((isset($price['_give_default']) && $price['_give_default'] === 'default') ? ' give-default-level' : ''), $form_id, $price); |
|
531 | 531 | |
532 | 532 | $output .= '<li>'; |
533 | - $output .= '<input type="radio" data-price-id="' . $price['_give_id']['level_id'] . '" class="' . $level_classes . '" name="give-radio-donation-level" id="give-radio-level-' . $price['_give_id']['level_id'] . '" ' . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? 'checked="checked"' : '' ) . ' value="' . give_format_amount( $price['_give_amount'], array( 'sanitize' => false ) ) . '">'; |
|
534 | - $output .= '<label for="give-radio-level-' . $price['_give_id']['level_id'] . '">' . $level_text . '</label>'; |
|
533 | + $output .= '<input type="radio" data-price-id="'.$price['_give_id']['level_id'].'" class="'.$level_classes.'" name="give-radio-donation-level" id="give-radio-level-'.$price['_give_id']['level_id'].'" '.((isset($price['_give_default']) && $price['_give_default'] === 'default') ? 'checked="checked"' : '').' value="'.give_format_amount($price['_give_amount'], array('sanitize' => false)).'">'; |
|
534 | + $output .= '<label for="give-radio-level-'.$price['_give_id']['level_id'].'">'.$level_text.'</label>'; |
|
535 | 535 | $output .= '</li>'; |
536 | 536 | |
537 | 537 | } |
538 | 538 | |
539 | 539 | //Custom Amount. |
540 | - if ( give_is_setting_enabled( $custom_amount ) && ! empty( $custom_amount_text ) ) { |
|
540 | + if (give_is_setting_enabled($custom_amount) && ! empty($custom_amount_text)) { |
|
541 | 541 | $output .= '<li>'; |
542 | 542 | $output .= '<input type="radio" data-price-id="custom" class="give-radio-input give-radio-input-level give-radio-level-custom" name="give-radio-donation-level" id="give-radio-level-custom" value="custom">'; |
543 | - $output .= '<label for="give-radio-level-custom">' . $custom_amount_text . '</label>'; |
|
543 | + $output .= '<label for="give-radio-level-custom">'.$custom_amount_text.'</label>'; |
|
544 | 544 | $output .= '</li>'; |
545 | 545 | } |
546 | 546 | |
@@ -550,23 +550,23 @@ discard block |
||
550 | 550 | |
551 | 551 | case 'dropdown': |
552 | 552 | |
553 | - $output .= '<label for="give-donation-level-select-' . $form_id . '" class="give-hidden">' . esc_html__( 'Choose Your Donation Amount', 'give' ) . ':</label>'; |
|
554 | - $output .= '<select id="give-donation-level-select-' . $form_id . '" class="give-select give-select-level give-donation-levels-wrap">'; |
|
553 | + $output .= '<label for="give-donation-level-select-'.$form_id.'" class="give-hidden">'.esc_html__('Choose Your Donation Amount', 'give').':</label>'; |
|
554 | + $output .= '<select id="give-donation-level-select-'.$form_id.'" class="give-select give-select-level give-donation-levels-wrap">'; |
|
555 | 555 | |
556 | 556 | //first loop through prices. |
557 | - foreach ( $prices as $price ) { |
|
558 | - $level_text = apply_filters( 'give_form_level_text', ! empty( $price['_give_text'] ) ? $price['_give_text'] : give_currency_filter( give_format_amount( $price['_give_amount'], array( 'sanitize' => false ) ) ), $form_id, $price ); |
|
559 | - $level_classes = apply_filters( 'give_form_level_classes', 'give-donation-level-' . $price['_give_id']['level_id'] . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? ' give-default-level' : '' ), $form_id, $price ); |
|
557 | + foreach ($prices as $price) { |
|
558 | + $level_text = apply_filters('give_form_level_text', ! empty($price['_give_text']) ? $price['_give_text'] : give_currency_filter(give_format_amount($price['_give_amount'], array('sanitize' => false))), $form_id, $price); |
|
559 | + $level_classes = apply_filters('give_form_level_classes', 'give-donation-level-'.$price['_give_id']['level_id'].((isset($price['_give_default']) && $price['_give_default'] === 'default') ? ' give-default-level' : ''), $form_id, $price); |
|
560 | 560 | |
561 | - $output .= '<option data-price-id="' . $price['_give_id']['level_id'] . '" class="' . $level_classes . '" ' . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? 'selected="selected"' : '' ) . ' value="' . give_format_amount( $price['_give_amount'], array( 'sanitize' => false ) ) . '">'; |
|
561 | + $output .= '<option data-price-id="'.$price['_give_id']['level_id'].'" class="'.$level_classes.'" '.((isset($price['_give_default']) && $price['_give_default'] === 'default') ? 'selected="selected"' : '').' value="'.give_format_amount($price['_give_amount'], array('sanitize' => false)).'">'; |
|
562 | 562 | $output .= $level_text; |
563 | 563 | $output .= '</option>'; |
564 | 564 | |
565 | 565 | } |
566 | 566 | |
567 | 567 | //Custom Amount. |
568 | - if ( give_is_setting_enabled( $custom_amount ) && ! empty( $custom_amount_text ) ) { |
|
569 | - $output .= '<option data-price-id="custom" class="give-donation-level-custom" value="custom">' . $custom_amount_text . '</option>'; |
|
568 | + if (give_is_setting_enabled($custom_amount) && ! empty($custom_amount_text)) { |
|
569 | + $output .= '<option data-price-id="custom" class="give-donation-level-custom" value="custom">'.$custom_amount_text.'</option>'; |
|
570 | 570 | } |
571 | 571 | |
572 | 572 | $output .= '</select>'; |
@@ -574,7 +574,7 @@ discard block |
||
574 | 574 | break; |
575 | 575 | } |
576 | 576 | |
577 | - echo apply_filters( 'give_form_level_output', $output, $form_id ); |
|
577 | + echo apply_filters('give_form_level_output', $output, $form_id); |
|
578 | 578 | } |
579 | 579 | |
580 | 580 | /** |
@@ -589,27 +589,27 @@ discard block |
||
589 | 589 | * |
590 | 590 | * @return string Checkout button. |
591 | 591 | */ |
592 | -function give_display_checkout_button( $form_id, $args ) { |
|
592 | +function give_display_checkout_button($form_id, $args) { |
|
593 | 593 | |
594 | - $display_option = ( isset( $args['display_style'] ) && ! empty( $args['display_style'] ) ) |
|
594 | + $display_option = (isset($args['display_style']) && ! empty($args['display_style'])) |
|
595 | 595 | ? $args['display_style'] |
596 | - : give_get_meta( $form_id, '_give_payment_display', true ); |
|
596 | + : give_get_meta($form_id, '_give_payment_display', true); |
|
597 | 597 | |
598 | - if ( 'button' === $display_option ) { |
|
598 | + if ('button' === $display_option) { |
|
599 | 599 | $display_option = 'modal'; |
600 | - } elseif ( $display_option === 'onpage' ) { |
|
600 | + } elseif ($display_option === 'onpage') { |
|
601 | 601 | return ''; |
602 | 602 | } |
603 | 603 | |
604 | - $display_label_field = give_get_meta( $form_id, '_give_reveal_label', true ); |
|
605 | - $display_label = ! empty( $args['continue_button_title'] ) ? $args['continue_button_title'] : ( ! empty( $display_label_field ) ? $display_label_field : esc_html__( 'Donate Now', 'give' ) ); |
|
604 | + $display_label_field = give_get_meta($form_id, '_give_reveal_label', true); |
|
605 | + $display_label = ! empty($args['continue_button_title']) ? $args['continue_button_title'] : ( ! empty($display_label_field) ? $display_label_field : esc_html__('Donate Now', 'give')); |
|
606 | 606 | |
607 | - $output = '<button type="button" class="give-btn give-btn-' . $display_option . '">' . $display_label . '</button>'; |
|
607 | + $output = '<button type="button" class="give-btn give-btn-'.$display_option.'">'.$display_label.'</button>'; |
|
608 | 608 | |
609 | - echo apply_filters( 'give_display_checkout_button', $output ); |
|
609 | + echo apply_filters('give_display_checkout_button', $output); |
|
610 | 610 | } |
611 | 611 | |
612 | -add_action( 'give_after_donation_levels', 'give_display_checkout_button', 10, 2 ); |
|
612 | +add_action('give_after_donation_levels', 'give_display_checkout_button', 10, 2); |
|
613 | 613 | |
614 | 614 | /** |
615 | 615 | * Shows the User Info fields in the Personal Info box, more fields can be added via the hooks provided. |
@@ -620,57 +620,57 @@ discard block |
||
620 | 620 | * |
621 | 621 | * @return void |
622 | 622 | */ |
623 | -function give_user_info_fields( $form_id ) { |
|
623 | +function give_user_info_fields($form_id) { |
|
624 | 624 | // Get user info. |
625 | - $give_user_info = _give_get_prefill_form_field_values( $form_id ); |
|
625 | + $give_user_info = _give_get_prefill_form_field_values($form_id); |
|
626 | 626 | |
627 | 627 | /** |
628 | 628 | * Fire before user personal information fields |
629 | 629 | * |
630 | 630 | * @since 1.7 |
631 | 631 | */ |
632 | - do_action( 'give_donation_form_before_personal_info', $form_id ); |
|
632 | + do_action('give_donation_form_before_personal_info', $form_id); |
|
633 | 633 | ?> |
634 | 634 | <fieldset id="give_checkout_user_info"> |
635 | - <legend><?php echo apply_filters( 'give_checkout_personal_info_text', esc_html__( 'Personal Info', 'give' ) ); ?></legend> |
|
635 | + <legend><?php echo apply_filters('give_checkout_personal_info_text', esc_html__('Personal Info', 'give')); ?></legend> |
|
636 | 636 | <p id="give-first-name-wrap" class="form-row form-row-first form-row-responsive"> |
637 | 637 | <label class="give-label" for="give-first"> |
638 | - <?php esc_html_e( 'First Name', 'give' ); ?> |
|
639 | - <?php if ( give_field_is_required( 'give_first', $form_id ) ) : ?> |
|
638 | + <?php esc_html_e('First Name', 'give'); ?> |
|
639 | + <?php if (give_field_is_required('give_first', $form_id)) : ?> |
|
640 | 640 | <span class="give-required-indicator">*</span> |
641 | 641 | <?php endif ?> |
642 | 642 | <span class="give-tooltip give-icon give-icon-question" |
643 | - data-tooltip="<?php esc_attr_e( 'We will use this to personalize your account experience.', 'give' ); ?>"></span> |
|
643 | + data-tooltip="<?php esc_attr_e('We will use this to personalize your account experience.', 'give'); ?>"></span> |
|
644 | 644 | </label> |
645 | 645 | <input |
646 | 646 | class="give-input required" |
647 | 647 | type="text" |
648 | 648 | name="give_first" |
649 | - placeholder="<?php esc_attr_e( 'First Name', 'give' ); ?>" |
|
649 | + placeholder="<?php esc_attr_e('First Name', 'give'); ?>" |
|
650 | 650 | id="give-first" |
651 | - value="<?php echo isset( $give_user_info['give_first'] ) ? $give_user_info['give_first'] : ''; ?>" |
|
652 | - <?php echo( give_field_is_required( 'give_first', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
651 | + value="<?php echo isset($give_user_info['give_first']) ? $give_user_info['give_first'] : ''; ?>" |
|
652 | + <?php echo(give_field_is_required('give_first', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
653 | 653 | /> |
654 | 654 | </p> |
655 | 655 | |
656 | 656 | <p id="give-last-name-wrap" class="form-row form-row-last form-row-responsive"> |
657 | 657 | <label class="give-label" for="give-last"> |
658 | - <?php esc_html_e( 'Last Name', 'give' ); ?> |
|
659 | - <?php if ( give_field_is_required( 'give_last', $form_id ) ) : ?> |
|
658 | + <?php esc_html_e('Last Name', 'give'); ?> |
|
659 | + <?php if (give_field_is_required('give_last', $form_id)) : ?> |
|
660 | 660 | <span class="give-required-indicator">*</span> |
661 | 661 | <?php endif ?> |
662 | 662 | <span class="give-tooltip give-icon give-icon-question" |
663 | - data-tooltip="<?php esc_attr_e( 'We will use this as well to personalize your account experience.', 'give' ); ?>"></span> |
|
663 | + data-tooltip="<?php esc_attr_e('We will use this as well to personalize your account experience.', 'give'); ?>"></span> |
|
664 | 664 | </label> |
665 | 665 | |
666 | 666 | <input |
667 | - class="give-input<?php echo( give_field_is_required( 'give_last', $form_id ) ? ' required' : '' ); ?>" |
|
667 | + class="give-input<?php echo(give_field_is_required('give_last', $form_id) ? ' required' : ''); ?>" |
|
668 | 668 | type="text" |
669 | 669 | name="give_last" |
670 | 670 | id="give-last" |
671 | - placeholder="<?php esc_attr_e( 'Last Name', 'give' ); ?>" |
|
672 | - value="<?php echo isset( $give_user_info['give_last'] ) ? $give_user_info['give_last'] : ''; ?>" |
|
673 | - <?php echo( give_field_is_required( 'give_last', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
671 | + placeholder="<?php esc_attr_e('Last Name', 'give'); ?>" |
|
672 | + value="<?php echo isset($give_user_info['give_last']) ? $give_user_info['give_last'] : ''; ?>" |
|
673 | + <?php echo(give_field_is_required('give_last', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
674 | 674 | /> |
675 | 675 | </p> |
676 | 676 | |
@@ -680,26 +680,26 @@ discard block |
||
680 | 680 | * |
681 | 681 | * @since 1.7 |
682 | 682 | */ |
683 | - do_action( 'give_donation_form_before_email', $form_id ); |
|
683 | + do_action('give_donation_form_before_email', $form_id); |
|
684 | 684 | ?> |
685 | 685 | <p id="give-email-wrap" class="form-row form-row-wide"> |
686 | 686 | <label class="give-label" for="give-email"> |
687 | - <?php esc_html_e( 'Email Address', 'give' ); ?> |
|
688 | - <?php if ( give_field_is_required( 'give_email', $form_id ) ) { ?> |
|
687 | + <?php esc_html_e('Email Address', 'give'); ?> |
|
688 | + <?php if (give_field_is_required('give_email', $form_id)) { ?> |
|
689 | 689 | <span class="give-required-indicator">*</span> |
690 | 690 | <?php } ?> |
691 | 691 | <span class="give-tooltip give-icon give-icon-question" |
692 | - data-tooltip="<?php esc_attr_e( 'We will send the donation receipt to this address.', 'give' ); ?>"></span> |
|
692 | + data-tooltip="<?php esc_attr_e('We will send the donation receipt to this address.', 'give'); ?>"></span> |
|
693 | 693 | </label> |
694 | 694 | |
695 | 695 | <input |
696 | 696 | class="give-input required" |
697 | 697 | type="email" |
698 | 698 | name="give_email" |
699 | - placeholder="<?php esc_attr_e( 'Email Address', 'give' ); ?>" |
|
699 | + placeholder="<?php esc_attr_e('Email Address', 'give'); ?>" |
|
700 | 700 | id="give-email" |
701 | - value="<?php echo isset( $give_user_info['give_email'] ) ? $give_user_info['give_email'] : ''; ?>" |
|
702 | - <?php echo( give_field_is_required( 'give_email', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
701 | + value="<?php echo isset($give_user_info['give_email']) ? $give_user_info['give_email'] : ''; ?>" |
|
702 | + <?php echo(give_field_is_required('give_email', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
703 | 703 | /> |
704 | 704 | |
705 | 705 | </p> |
@@ -709,14 +709,14 @@ discard block |
||
709 | 709 | * |
710 | 710 | * @since 1.7 |
711 | 711 | */ |
712 | - do_action( 'give_donation_form_after_email', $form_id ); |
|
712 | + do_action('give_donation_form_after_email', $form_id); |
|
713 | 713 | |
714 | 714 | /** |
715 | 715 | * Fire after personal email field |
716 | 716 | * |
717 | 717 | * @since 1.7 |
718 | 718 | */ |
719 | - do_action( 'give_donation_form_user_info', $form_id ); |
|
719 | + do_action('give_donation_form_user_info', $form_id); |
|
720 | 720 | ?> |
721 | 721 | </fieldset> |
722 | 722 | <?php |
@@ -725,11 +725,11 @@ discard block |
||
725 | 725 | * |
726 | 726 | * @since 1.7 |
727 | 727 | */ |
728 | - do_action( 'give_donation_form_after_personal_info', $form_id ); |
|
728 | + do_action('give_donation_form_after_personal_info', $form_id); |
|
729 | 729 | } |
730 | 730 | |
731 | -add_action( 'give_donation_form_after_user_info', 'give_user_info_fields' ); |
|
732 | -add_action( 'give_register_fields_before', 'give_user_info_fields' ); |
|
731 | +add_action('give_donation_form_after_user_info', 'give_user_info_fields'); |
|
732 | +add_action('give_register_fields_before', 'give_user_info_fields'); |
|
733 | 733 | |
734 | 734 | /** |
735 | 735 | * Renders the credit card info form. |
@@ -740,7 +740,7 @@ discard block |
||
740 | 740 | * |
741 | 741 | * @return void |
742 | 742 | */ |
743 | -function give_get_cc_form( $form_id ) { |
|
743 | +function give_get_cc_form($form_id) { |
|
744 | 744 | |
745 | 745 | ob_start(); |
746 | 746 | |
@@ -751,53 +751,53 @@ discard block |
||
751 | 751 | * |
752 | 752 | * @param int $form_id The form ID. |
753 | 753 | */ |
754 | - do_action( 'give_before_cc_fields', $form_id ); |
|
754 | + do_action('give_before_cc_fields', $form_id); |
|
755 | 755 | ?> |
756 | 756 | <fieldset id="give_cc_fields-<?php echo $form_id ?>" class="give-do-validate"> |
757 | - <legend><?php echo apply_filters( 'give_credit_card_fieldset_heading', esc_html__( 'Credit Card Info', 'give' ) ); ?></legend> |
|
758 | - <?php if ( is_ssl() ) : ?> |
|
757 | + <legend><?php echo apply_filters('give_credit_card_fieldset_heading', esc_html__('Credit Card Info', 'give')); ?></legend> |
|
758 | + <?php if (is_ssl()) : ?> |
|
759 | 759 | <div id="give_secure_site_wrapper-<?php echo $form_id ?>"> |
760 | 760 | <span class="give-icon padlock"></span> |
761 | - <span><?php esc_html_e( 'This is a secure SSL encrypted payment.', 'give' ); ?></span> |
|
761 | + <span><?php esc_html_e('This is a secure SSL encrypted payment.', 'give'); ?></span> |
|
762 | 762 | </div> |
763 | 763 | <?php endif; ?> |
764 | 764 | <p id="give-card-number-wrap-<?php echo $form_id ?>" class="form-row form-row-two-thirds form-row-responsive"> |
765 | 765 | <label for="card_number-<?php echo $form_id ?>" class="give-label"> |
766 | - <?php esc_html_e( 'Card Number', 'give' ); ?> |
|
766 | + <?php esc_html_e('Card Number', 'give'); ?> |
|
767 | 767 | <span class="give-required-indicator">*</span> |
768 | 768 | <span class="give-tooltip give-icon give-icon-question" |
769 | - data-tooltip="<?php esc_attr_e( 'The (typically) 16 digits on the front of your credit card.', 'give' ); ?>"></span> |
|
769 | + data-tooltip="<?php esc_attr_e('The (typically) 16 digits on the front of your credit card.', 'give'); ?>"></span> |
|
770 | 770 | <span class="card-type"></span> |
771 | 771 | </label> |
772 | 772 | |
773 | 773 | <input type="tel" autocomplete="off" name="card_number" id="card_number-<?php echo $form_id ?>" |
774 | - class="card-number give-input required" placeholder="<?php esc_attr_e( 'Card number', 'give' ); ?>" |
|
774 | + class="card-number give-input required" placeholder="<?php esc_attr_e('Card number', 'give'); ?>" |
|
775 | 775 | required aria-required="true"/> |
776 | 776 | </p> |
777 | 777 | |
778 | 778 | <p id="give-card-cvc-wrap-<?php echo $form_id ?>" class="form-row form-row-one-third form-row-responsive"> |
779 | 779 | <label for="card_cvc-<?php echo $form_id ?>" class="give-label"> |
780 | - <?php esc_html_e( 'CVC', 'give' ); ?> |
|
780 | + <?php esc_html_e('CVC', 'give'); ?> |
|
781 | 781 | <span class="give-required-indicator">*</span> |
782 | 782 | <span class="give-tooltip give-icon give-icon-question" |
783 | - data-tooltip="<?php esc_attr_e( 'The 3 digit (back) or 4 digit (front) value on your card.', 'give' ); ?>"></span> |
|
783 | + data-tooltip="<?php esc_attr_e('The 3 digit (back) or 4 digit (front) value on your card.', 'give'); ?>"></span> |
|
784 | 784 | </label> |
785 | 785 | |
786 | 786 | <input type="tel" size="4" autocomplete="off" name="card_cvc" id="card_cvc-<?php echo $form_id ?>" |
787 | - class="card-cvc give-input required" placeholder="<?php esc_attr_e( 'Security code', 'give' ); ?>" |
|
787 | + class="card-cvc give-input required" placeholder="<?php esc_attr_e('Security code', 'give'); ?>" |
|
788 | 788 | required aria-required="true"/> |
789 | 789 | </p> |
790 | 790 | |
791 | 791 | <p id="give-card-name-wrap-<?php echo $form_id ?>" class="form-row form-row-two-thirds form-row-responsive"> |
792 | 792 | <label for="card_name-<?php echo $form_id ?>" class="give-label"> |
793 | - <?php esc_html_e( 'Name on the Card', 'give' ); ?> |
|
793 | + <?php esc_html_e('Name on the Card', 'give'); ?> |
|
794 | 794 | <span class="give-required-indicator">*</span> |
795 | 795 | <span class="give-tooltip give-icon give-icon-question" |
796 | - data-tooltip="<?php esc_attr_e( 'The name printed on the front of your credit card.', 'give' ); ?>"></span> |
|
796 | + data-tooltip="<?php esc_attr_e('The name printed on the front of your credit card.', 'give'); ?>"></span> |
|
797 | 797 | </label> |
798 | 798 | |
799 | 799 | <input type="text" autocomplete="off" name="card_name" id="card_name-<?php echo $form_id ?>" |
800 | - class="card-name give-input required" placeholder="<?php esc_attr_e( 'Card name', 'give' ); ?>" |
|
800 | + class="card-name give-input required" placeholder="<?php esc_attr_e('Card name', 'give'); ?>" |
|
801 | 801 | required aria-required="true"/> |
802 | 802 | </p> |
803 | 803 | <?php |
@@ -808,14 +808,14 @@ discard block |
||
808 | 808 | * |
809 | 809 | * @param int $form_id The form ID. |
810 | 810 | */ |
811 | - do_action( 'give_before_cc_expiration' ); |
|
811 | + do_action('give_before_cc_expiration'); |
|
812 | 812 | ?> |
813 | 813 | <p class="card-expiration form-row form-row-one-third form-row-responsive"> |
814 | 814 | <label for="card_expiry-<?php echo $form_id ?>" class="give-label"> |
815 | - <?php esc_html_e( 'Expiration', 'give' ); ?> |
|
815 | + <?php esc_html_e('Expiration', 'give'); ?> |
|
816 | 816 | <span class="give-required-indicator">*</span> |
817 | 817 | <span class="give-tooltip give-icon give-icon-question" |
818 | - data-tooltip="<?php esc_attr_e( 'The date your credit card expires, typically on the front of the card.', 'give' ); ?>"></span> |
|
818 | + data-tooltip="<?php esc_attr_e('The date your credit card expires, typically on the front of the card.', 'give'); ?>"></span> |
|
819 | 819 | </label> |
820 | 820 | |
821 | 821 | <input type="hidden" id="card_exp_month-<?php echo $form_id ?>" name="card_exp_month" |
@@ -824,7 +824,7 @@ discard block |
||
824 | 824 | class="card-expiry-year"/> |
825 | 825 | |
826 | 826 | <input type="tel" autocomplete="off" name="card_expiry" id="card_expiry-<?php echo $form_id ?>" |
827 | - class="card-expiry give-input required" placeholder="<?php esc_attr_e( 'MM / YY', 'give' ); ?>" |
|
827 | + class="card-expiry give-input required" placeholder="<?php esc_attr_e('MM / YY', 'give'); ?>" |
|
828 | 828 | required aria-required="true"/> |
829 | 829 | </p> |
830 | 830 | <?php |
@@ -835,7 +835,7 @@ discard block |
||
835 | 835 | * |
836 | 836 | * @param int $form_id The form ID. |
837 | 837 | */ |
838 | - do_action( 'give_after_cc_expiration', $form_id ); |
|
838 | + do_action('give_after_cc_expiration', $form_id); |
|
839 | 839 | ?> |
840 | 840 | </fieldset> |
841 | 841 | <?php |
@@ -846,12 +846,12 @@ discard block |
||
846 | 846 | * |
847 | 847 | * @param int $form_id The form ID. |
848 | 848 | */ |
849 | - do_action( 'give_after_cc_fields', $form_id ); |
|
849 | + do_action('give_after_cc_fields', $form_id); |
|
850 | 850 | |
851 | 851 | echo ob_get_clean(); |
852 | 852 | } |
853 | 853 | |
854 | -add_action( 'give_cc_form', 'give_get_cc_form' ); |
|
854 | +add_action('give_cc_form', 'give_get_cc_form'); |
|
855 | 855 | |
856 | 856 | /** |
857 | 857 | * Outputs the default credit card address fields. |
@@ -862,24 +862,24 @@ discard block |
||
862 | 862 | * |
863 | 863 | * @return void |
864 | 864 | */ |
865 | -function give_default_cc_address_fields( $form_id ) { |
|
865 | +function give_default_cc_address_fields($form_id) { |
|
866 | 866 | // Get user info. |
867 | - $give_user_info = _give_get_prefill_form_field_values( $form_id ); |
|
867 | + $give_user_info = _give_get_prefill_form_field_values($form_id); |
|
868 | 868 | |
869 | 869 | $logged_in = is_user_logged_in(); |
870 | 870 | |
871 | - if ( $logged_in ) { |
|
872 | - $user_address = get_user_meta( get_current_user_id(), '_give_user_address', true ); |
|
871 | + if ($logged_in) { |
|
872 | + $user_address = get_user_meta(get_current_user_id(), '_give_user_address', true); |
|
873 | 873 | } |
874 | - $line1 = $logged_in && ! empty( $user_address['line1'] ) ? $user_address['line1'] : ''; |
|
875 | - $line2 = $logged_in && ! empty( $user_address['line2'] ) ? $user_address['line2'] : ''; |
|
876 | - $city = $logged_in && ! empty( $user_address['city'] ) ? $user_address['city'] : ''; |
|
877 | - $zip = $logged_in && ! empty( $user_address['zip'] ) ? $user_address['zip'] : ''; |
|
874 | + $line1 = $logged_in && ! empty($user_address['line1']) ? $user_address['line1'] : ''; |
|
875 | + $line2 = $logged_in && ! empty($user_address['line2']) ? $user_address['line2'] : ''; |
|
876 | + $city = $logged_in && ! empty($user_address['city']) ? $user_address['city'] : ''; |
|
877 | + $zip = $logged_in && ! empty($user_address['zip']) ? $user_address['zip'] : ''; |
|
878 | 878 | |
879 | 879 | ob_start(); |
880 | 880 | ?> |
881 | 881 | <fieldset id="give_cc_address" class="cc-address"> |
882 | - <legend><?php echo apply_filters( 'give_billing_details_fieldset_heading', esc_html__( 'Billing Details', 'give' ) ); ?></legend> |
|
882 | + <legend><?php echo apply_filters('give_billing_details_fieldset_heading', esc_html__('Billing Details', 'give')); ?></legend> |
|
883 | 883 | <?php |
884 | 884 | /** |
885 | 885 | * Fires while rendering credit card billing form, before address fields. |
@@ -888,36 +888,36 @@ discard block |
||
888 | 888 | * |
889 | 889 | * @param int $form_id The form ID. |
890 | 890 | */ |
891 | - do_action( 'give_cc_billing_top' ); |
|
891 | + do_action('give_cc_billing_top'); |
|
892 | 892 | |
893 | 893 | // For Country. |
894 | 894 | $selected_country = give_get_country(); |
895 | - if ( ! empty( $give_user_info['billing_country'] ) && '*' !== $give_user_info['billing_country'] ) { |
|
895 | + if ( ! empty($give_user_info['billing_country']) && '*' !== $give_user_info['billing_country']) { |
|
896 | 896 | $selected_country = $give_user_info['billing_country']; |
897 | 897 | } |
898 | 898 | $countries = give_get_country_list(); |
899 | 899 | |
900 | 900 | // For state |
901 | 901 | $selected_state = ''; |
902 | - if ( $selected_country === give_get_country() ) { |
|
902 | + if ($selected_country === give_get_country()) { |
|
903 | 903 | // Get defalut selected state by admin. |
904 | 904 | $selected_state = give_get_state(); |
905 | 905 | } |
906 | 906 | // Get the last payment made by user states. |
907 | - if ( ! empty( $give_user_info['card_state'] ) && '*' !== $give_user_info['card_state'] ) { |
|
907 | + if ( ! empty($give_user_info['card_state']) && '*' !== $give_user_info['card_state']) { |
|
908 | 908 | $selected_state = $give_user_info['card_state']; |
909 | 909 | } |
910 | 910 | // Get the country code |
911 | - if ( ! empty( $give_user_info['billing_country'] ) && '*' !== $give_user_info['billing_country'] ) { |
|
911 | + if ( ! empty($give_user_info['billing_country']) && '*' !== $give_user_info['billing_country']) { |
|
912 | 912 | $selected_country = $give_user_info['billing_country']; |
913 | 913 | } |
914 | - $label = __( 'State', 'give' ); |
|
914 | + $label = __('State', 'give'); |
|
915 | 915 | $states_label = give_get_states_label(); |
916 | 916 | // Check if $country code exists in the array key for states label. |
917 | - if ( array_key_exists( $selected_country, $states_label ) ) { |
|
918 | - $label = $states_label[ $selected_country ]; |
|
917 | + if (array_key_exists($selected_country, $states_label)) { |
|
918 | + $label = $states_label[$selected_country]; |
|
919 | 919 | } |
920 | - $states = give_get_states( $selected_country ); |
|
920 | + $states = give_get_states($selected_country); |
|
921 | 921 | // Get the country list that do not have any states init. |
922 | 922 | $no_states_country = give_no_states_country_list(); |
923 | 923 | // Get the country list that does not require states. |
@@ -926,23 +926,23 @@ discard block |
||
926 | 926 | ?> |
927 | 927 | <p id="give-card-country-wrap" class="form-row form-row-wide"> |
928 | 928 | <label for="billing_country" class="give-label"> |
929 | - <?php esc_html_e( 'Country', 'give' ); ?> |
|
930 | - <?php if ( give_field_is_required( 'billing_country', $form_id ) ) : ?> |
|
929 | + <?php esc_html_e('Country', 'give'); ?> |
|
930 | + <?php if (give_field_is_required('billing_country', $form_id)) : ?> |
|
931 | 931 | <span class="give-required-indicator">*</span> |
932 | 932 | <?php endif; ?> |
933 | 933 | <span class="give-tooltip give-icon give-icon-question" |
934 | - data-tooltip="<?php esc_attr_e( 'The country for your billing address.', 'give' ); ?>"></span> |
|
934 | + data-tooltip="<?php esc_attr_e('The country for your billing address.', 'give'); ?>"></span> |
|
935 | 935 | </label> |
936 | 936 | |
937 | 937 | <select |
938 | 938 | name="billing_country" |
939 | 939 | id="billing_country" |
940 | - class="billing-country billing_country give-select<?php echo( give_field_is_required( 'billing_country', $form_id ) ? ' required' : '' ); ?>" |
|
941 | - <?php echo( give_field_is_required( 'billing_country', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
940 | + class="billing-country billing_country give-select<?php echo(give_field_is_required('billing_country', $form_id) ? ' required' : ''); ?>" |
|
941 | + <?php echo(give_field_is_required('billing_country', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
942 | 942 | > |
943 | 943 | <?php |
944 | - foreach ( $countries as $country_code => $country ) { |
|
945 | - echo '<option value="' . esc_attr( $country_code ) . '"' . selected( $country_code, $selected_country, false ) . '>' . $country . '</option>'; |
|
944 | + foreach ($countries as $country_code => $country) { |
|
945 | + echo '<option value="'.esc_attr($country_code).'"'.selected($country_code, $selected_country, false).'>'.$country.'</option>'; |
|
946 | 946 | } |
947 | 947 | ?> |
948 | 948 | </select> |
@@ -950,89 +950,89 @@ discard block |
||
950 | 950 | |
951 | 951 | <p id="give-card-address-wrap" class="form-row form-row-wide"> |
952 | 952 | <label for="card_address" class="give-label"> |
953 | - <?php esc_html_e( 'Address 1', 'give' ); ?> |
|
953 | + <?php esc_html_e('Address 1', 'give'); ?> |
|
954 | 954 | <?php |
955 | - if ( give_field_is_required( 'card_address', $form_id ) ) : ?> |
|
955 | + if (give_field_is_required('card_address', $form_id)) : ?> |
|
956 | 956 | <span class="give-required-indicator">*</span> |
957 | 957 | <?php endif; ?> |
958 | 958 | <span class="give-tooltip give-icon give-icon-question" |
959 | - data-tooltip="<?php esc_attr_e( 'The primary billing address for your credit card.', 'give' ); ?>"></span> |
|
959 | + data-tooltip="<?php esc_attr_e('The primary billing address for your credit card.', 'give'); ?>"></span> |
|
960 | 960 | </label> |
961 | 961 | |
962 | 962 | <input |
963 | 963 | type="text" |
964 | 964 | id="card_address" |
965 | 965 | name="card_address" |
966 | - class="card-address give-input<?php echo( give_field_is_required( 'card_address', $form_id ) ? ' required' : '' ); ?>" |
|
967 | - placeholder="<?php esc_attr_e( 'Address line 1', 'give' ); ?>" |
|
968 | - value="<?php echo isset( $give_user_info['card_address'] ) ? $give_user_info['card_address'] : ''; ?>" |
|
969 | - <?php echo( give_field_is_required( 'card_address', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
966 | + class="card-address give-input<?php echo(give_field_is_required('card_address', $form_id) ? ' required' : ''); ?>" |
|
967 | + placeholder="<?php esc_attr_e('Address line 1', 'give'); ?>" |
|
968 | + value="<?php echo isset($give_user_info['card_address']) ? $give_user_info['card_address'] : ''; ?>" |
|
969 | + <?php echo(give_field_is_required('card_address', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
970 | 970 | /> |
971 | 971 | </p> |
972 | 972 | |
973 | 973 | <p id="give-card-address-2-wrap" class="form-row form-row-wide"> |
974 | 974 | <label for="card_address_2" class="give-label"> |
975 | - <?php esc_html_e( 'Address 2', 'give' ); ?> |
|
976 | - <?php if ( give_field_is_required( 'card_address_2', $form_id ) ) : ?> |
|
975 | + <?php esc_html_e('Address 2', 'give'); ?> |
|
976 | + <?php if (give_field_is_required('card_address_2', $form_id)) : ?> |
|
977 | 977 | <span class="give-required-indicator">*</span> |
978 | 978 | <?php endif; ?> |
979 | 979 | <span class="give-tooltip give-icon give-icon-question" |
980 | - data-tooltip="<?php esc_attr_e( '(optional) The suite, apt no, PO box, etc, associated with your billing address.', 'give' ); ?>"></span> |
|
980 | + data-tooltip="<?php esc_attr_e('(optional) The suite, apt no, PO box, etc, associated with your billing address.', 'give'); ?>"></span> |
|
981 | 981 | </label> |
982 | 982 | |
983 | 983 | <input |
984 | 984 | type="text" |
985 | 985 | id="card_address_2" |
986 | 986 | name="card_address_2" |
987 | - class="card-address-2 give-input<?php echo( give_field_is_required( 'card_address_2', $form_id ) ? ' required' : '' ); ?>" |
|
988 | - placeholder="<?php esc_attr_e( 'Address line 2', 'give' ); ?>" |
|
989 | - value="<?php echo isset( $give_user_info['card_address_2'] ) ? $give_user_info['card_address_2'] : ''; ?>" |
|
990 | - <?php echo( give_field_is_required( 'card_address_2', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
987 | + class="card-address-2 give-input<?php echo(give_field_is_required('card_address_2', $form_id) ? ' required' : ''); ?>" |
|
988 | + placeholder="<?php esc_attr_e('Address line 2', 'give'); ?>" |
|
989 | + value="<?php echo isset($give_user_info['card_address_2']) ? $give_user_info['card_address_2'] : ''; ?>" |
|
990 | + <?php echo(give_field_is_required('card_address_2', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
991 | 991 | /> |
992 | 992 | </p> |
993 | 993 | |
994 | 994 | <p id="give-card-city-wrap" class="form-row form-row-wide"> |
995 | 995 | <label for="card_city" class="give-label"> |
996 | - <?php esc_html_e( 'City', 'give' ); ?> |
|
997 | - <?php if ( give_field_is_required( 'card_city', $form_id ) ) : ?> |
|
996 | + <?php esc_html_e('City', 'give'); ?> |
|
997 | + <?php if (give_field_is_required('card_city', $form_id)) : ?> |
|
998 | 998 | <span class="give-required-indicator">*</span> |
999 | 999 | <?php endif; ?> |
1000 | 1000 | <span class="give-tooltip give-icon give-icon-question" |
1001 | - data-tooltip="<?php esc_attr_e( 'The city for your billing address.', 'give' ); ?>"></span> |
|
1001 | + data-tooltip="<?php esc_attr_e('The city for your billing address.', 'give'); ?>"></span> |
|
1002 | 1002 | </label> |
1003 | 1003 | <input |
1004 | 1004 | type="text" |
1005 | 1005 | id="card_city" |
1006 | 1006 | name="card_city" |
1007 | - class="card-city give-input<?php echo( give_field_is_required( 'card_city', $form_id ) ? ' required' : '' ); ?>" |
|
1008 | - placeholder="<?php esc_attr_e( 'City', 'give' ); ?>" |
|
1009 | - value="<?php echo isset( $give_user_info['card_city'] ) ? $give_user_info['card_city'] : ''; ?>" |
|
1010 | - <?php echo( give_field_is_required( 'card_city', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
1007 | + class="card-city give-input<?php echo(give_field_is_required('card_city', $form_id) ? ' required' : ''); ?>" |
|
1008 | + placeholder="<?php esc_attr_e('City', 'give'); ?>" |
|
1009 | + value="<?php echo isset($give_user_info['card_city']) ? $give_user_info['card_city'] : ''; ?>" |
|
1010 | + <?php echo(give_field_is_required('card_city', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
1011 | 1011 | /> |
1012 | 1012 | </p> |
1013 | 1013 | |
1014 | 1014 | <p id="give-card-state-wrap" |
1015 | - class="form-row form-row-first form-row-responsive <?php echo ( ! empty( $selected_country ) && array_key_exists( $selected_country, $no_states_country ) ) ? 'give-hidden' : ''; ?>"> |
|
1015 | + class="form-row form-row-first form-row-responsive <?php echo ( ! empty($selected_country) && array_key_exists($selected_country, $no_states_country)) ? 'give-hidden' : ''; ?>"> |
|
1016 | 1016 | <label for="card_state" class="give-label"> |
1017 | 1017 | <span class="state-label-text"><?php echo $label; ?></span> |
1018 | - <?php if ( give_field_is_required( 'card_state', $form_id ) ) : |
|
1018 | + <?php if (give_field_is_required('card_state', $form_id)) : |
|
1019 | 1019 | ?> |
1020 | - <span class="give-required-indicator <?php echo( array_key_exists( $selected_country, $states_not_required_country_list ) ? 'give-hidden' : '' ) ?> ">*</span> |
|
1020 | + <span class="give-required-indicator <?php echo(array_key_exists($selected_country, $states_not_required_country_list) ? 'give-hidden' : '') ?> ">*</span> |
|
1021 | 1021 | <?php endif; ?> |
1022 | 1022 | <span class="give-tooltip give-icon give-icon-question" |
1023 | - data-tooltip="<?php esc_attr_e( 'The state, province, or county for your billing address.', 'give' ); ?>"></span> |
|
1023 | + data-tooltip="<?php esc_attr_e('The state, province, or county for your billing address.', 'give'); ?>"></span> |
|
1024 | 1024 | </label> |
1025 | 1025 | <?php |
1026 | 1026 | |
1027 | - if ( ! empty( $states ) ) : ?> |
|
1027 | + if ( ! empty($states)) : ?> |
|
1028 | 1028 | <select |
1029 | 1029 | name="card_state" |
1030 | 1030 | id="card_state" |
1031 | - class="card_state give-select<?php echo( give_field_is_required( 'card_state', $form_id ) ? ' required' : '' ); ?>" |
|
1032 | - <?php echo( give_field_is_required( 'card_state', $form_id ) ? ' required aria-required="true" ' : '' ); ?>> |
|
1031 | + class="card_state give-select<?php echo(give_field_is_required('card_state', $form_id) ? ' required' : ''); ?>" |
|
1032 | + <?php echo(give_field_is_required('card_state', $form_id) ? ' required aria-required="true" ' : ''); ?>> |
|
1033 | 1033 | <?php |
1034 | - foreach ( $states as $state_code => $state ) { |
|
1035 | - echo '<option value="' . $state_code . '"' . selected( $state_code, $selected_state, false ) . '>' . $state . '</option>'; |
|
1034 | + foreach ($states as $state_code => $state) { |
|
1035 | + echo '<option value="'.$state_code.'"'.selected($state_code, $selected_state, false).'>'.$state.'</option>'; |
|
1036 | 1036 | } |
1037 | 1037 | ?> |
1038 | 1038 | </select> |
@@ -1042,14 +1042,14 @@ discard block |
||
1042 | 1042 | <?php endif; ?> |
1043 | 1043 | </p> |
1044 | 1044 | |
1045 | - <p id="give-card-zip-wrap" class="form-row <?php echo ( ! empty( $selected_country ) && array_key_exists( $selected_country, $no_states_country ) ) ? 'form-row-wide' : 'form-row-last'; ?> form-row-responsive"> |
|
1045 | + <p id="give-card-zip-wrap" class="form-row <?php echo ( ! empty($selected_country) && array_key_exists($selected_country, $no_states_country)) ? 'form-row-wide' : 'form-row-last'; ?> form-row-responsive"> |
|
1046 | 1046 | <label for="card_zip" class="give-label"> |
1047 | - <?php esc_html_e( 'Zip / Postal Code', 'give' ); ?> |
|
1048 | - <?php if ( give_field_is_required( 'card_zip', $form_id ) ) : ?> |
|
1047 | + <?php esc_html_e('Zip / Postal Code', 'give'); ?> |
|
1048 | + <?php if (give_field_is_required('card_zip', $form_id)) : ?> |
|
1049 | 1049 | <span class="give-required-indicator">*</span> |
1050 | 1050 | <?php endif; ?> |
1051 | 1051 | <span class="give-tooltip give-icon give-icon-question" |
1052 | - data-tooltip="<?php esc_attr_e( 'The zip or postal code for your billing address.', 'give' ); ?>"></span> |
|
1052 | + data-tooltip="<?php esc_attr_e('The zip or postal code for your billing address.', 'give'); ?>"></span> |
|
1053 | 1053 | </label> |
1054 | 1054 | |
1055 | 1055 | <input |
@@ -1057,10 +1057,10 @@ discard block |
||
1057 | 1057 | size="4" |
1058 | 1058 | id="card_zip" |
1059 | 1059 | name="card_zip" |
1060 | - class="card-zip give-input<?php echo( give_field_is_required( 'card_zip', $form_id ) ? ' required' : '' ); ?>" |
|
1061 | - placeholder="<?php esc_attr_e( 'Zip / Postal Code', 'give' ); ?>" |
|
1062 | - value="<?php echo isset( $give_user_info['card_zip'] ) ? $give_user_info['card_zip'] : ''; ?>" |
|
1063 | - <?php echo( give_field_is_required( 'card_zip', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
1060 | + class="card-zip give-input<?php echo(give_field_is_required('card_zip', $form_id) ? ' required' : ''); ?>" |
|
1061 | + placeholder="<?php esc_attr_e('Zip / Postal Code', 'give'); ?>" |
|
1062 | + value="<?php echo isset($give_user_info['card_zip']) ? $give_user_info['card_zip'] : ''; ?>" |
|
1063 | + <?php echo(give_field_is_required('card_zip', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
1064 | 1064 | /> |
1065 | 1065 | </p> |
1066 | 1066 | |
@@ -1072,14 +1072,14 @@ discard block |
||
1072 | 1072 | * |
1073 | 1073 | * @param int $form_id The form ID. |
1074 | 1074 | */ |
1075 | - do_action( 'give_cc_billing_bottom' ); |
|
1075 | + do_action('give_cc_billing_bottom'); |
|
1076 | 1076 | ?> |
1077 | 1077 | </fieldset> |
1078 | 1078 | <?php |
1079 | 1079 | echo ob_get_clean(); |
1080 | 1080 | } |
1081 | 1081 | |
1082 | -add_action( 'give_after_cc_fields', 'give_default_cc_address_fields' ); |
|
1082 | +add_action('give_after_cc_fields', 'give_default_cc_address_fields'); |
|
1083 | 1083 | |
1084 | 1084 | |
1085 | 1085 | /** |
@@ -1092,24 +1092,24 @@ discard block |
||
1092 | 1092 | * |
1093 | 1093 | * @return string |
1094 | 1094 | */ |
1095 | -function give_get_register_fields( $form_id ) { |
|
1095 | +function give_get_register_fields($form_id) { |
|
1096 | 1096 | |
1097 | 1097 | global $user_ID; |
1098 | 1098 | |
1099 | - if ( is_user_logged_in() ) { |
|
1100 | - $user_data = get_userdata( $user_ID ); |
|
1099 | + if (is_user_logged_in()) { |
|
1100 | + $user_data = get_userdata($user_ID); |
|
1101 | 1101 | } |
1102 | 1102 | |
1103 | - $show_register_form = give_show_login_register_option( $form_id ); |
|
1103 | + $show_register_form = give_show_login_register_option($form_id); |
|
1104 | 1104 | |
1105 | 1105 | ob_start(); ?> |
1106 | 1106 | <fieldset id="give-register-fields-<?php echo $form_id; ?>"> |
1107 | 1107 | |
1108 | - <?php if ( $show_register_form == 'both' ) { ?> |
|
1108 | + <?php if ($show_register_form == 'both') { ?> |
|
1109 | 1109 | <div class="give-login-account-wrap"> |
1110 | - <p class="give-login-message"><?php esc_html_e( 'Already have an account?', 'give' ); ?> |
|
1111 | - <a href="<?php echo esc_url( add_query_arg( 'login', 1 ) ); ?>" class="give-checkout-login" |
|
1112 | - data-action="give_checkout_login"><?php esc_html_e( 'Login', 'give' ); ?></a> |
|
1110 | + <p class="give-login-message"><?php esc_html_e('Already have an account?', 'give'); ?> |
|
1111 | + <a href="<?php echo esc_url(add_query_arg('login', 1)); ?>" class="give-checkout-login" |
|
1112 | + data-action="give_checkout_login"><?php esc_html_e('Login', 'give'); ?></a> |
|
1113 | 1113 | </p> |
1114 | 1114 | <p class="give-loading-text"> |
1115 | 1115 | <span class="give-loading-animation"></span> |
@@ -1125,15 +1125,15 @@ discard block |
||
1125 | 1125 | * |
1126 | 1126 | * @param int $form_id The form ID. |
1127 | 1127 | */ |
1128 | - do_action( 'give_register_fields_before', $form_id ); |
|
1128 | + do_action('give_register_fields_before', $form_id); |
|
1129 | 1129 | ?> |
1130 | 1130 | |
1131 | 1131 | <fieldset id="give-register-account-fields-<?php echo $form_id; ?>"> |
1132 | 1132 | <legend> |
1133 | 1133 | <?php |
1134 | - echo apply_filters( 'give_create_account_fieldset_heading', esc_html__( 'Create an account', 'give' ) ); |
|
1135 | - if ( ! give_logged_in_only( $form_id ) ) { |
|
1136 | - echo ' <span class="sub-text">' . esc_html__( '(optional)', 'give' ) . '</span>'; |
|
1134 | + echo apply_filters('give_create_account_fieldset_heading', esc_html__('Create an account', 'give')); |
|
1135 | + if ( ! give_logged_in_only($form_id)) { |
|
1136 | + echo ' <span class="sub-text">'.esc_html__('(optional)', 'give').'</span>'; |
|
1137 | 1137 | } |
1138 | 1138 | ?> |
1139 | 1139 | </legend> |
@@ -1145,54 +1145,54 @@ discard block |
||
1145 | 1145 | * |
1146 | 1146 | * @param int $form_id The form ID. |
1147 | 1147 | */ |
1148 | - do_action( 'give_register_account_fields_before', $form_id ); |
|
1148 | + do_action('give_register_account_fields_before', $form_id); |
|
1149 | 1149 | ?> |
1150 | 1150 | <div id="give-user-login-wrap-<?php echo $form_id; ?>" |
1151 | 1151 | class="form-row form-row-one-third form-row-first form-row-responsive"> |
1152 | 1152 | <label for="give-user-login-<?php echo $form_id; ?>"> |
1153 | - <?php esc_html_e( 'Username', 'give' ); ?> |
|
1154 | - <?php if ( give_logged_in_only( $form_id ) ) { ?> |
|
1153 | + <?php esc_html_e('Username', 'give'); ?> |
|
1154 | + <?php if (give_logged_in_only($form_id)) { ?> |
|
1155 | 1155 | <span class="give-required-indicator">*</span> |
1156 | 1156 | <?php } ?> |
1157 | 1157 | <span class="give-tooltip give-icon give-icon-question" |
1158 | - data-tooltip="<?php esc_attr_e( 'The username you will use to log into your account.', 'give' ); ?>"></span> |
|
1158 | + data-tooltip="<?php esc_attr_e('The username you will use to log into your account.', 'give'); ?>"></span> |
|
1159 | 1159 | </label> |
1160 | 1160 | |
1161 | 1161 | <input name="give_user_login" id="give-user-login-<?php echo $form_id; ?>" class="give-input" |
1162 | 1162 | type="text" |
1163 | - placeholder="<?php esc_attr_e( 'Username', 'give' ); ?>"<?php echo ( give_logged_in_only( $form_id ) ) ? ' required aria-required="true" ' : ''; ?>/> |
|
1163 | + placeholder="<?php esc_attr_e('Username', 'give'); ?>"<?php echo (give_logged_in_only($form_id)) ? ' required aria-required="true" ' : ''; ?>/> |
|
1164 | 1164 | </div> |
1165 | 1165 | |
1166 | 1166 | <div id="give-user-pass-wrap-<?php echo $form_id; ?>" |
1167 | 1167 | class="form-row form-row-one-third form-row-responsive"> |
1168 | 1168 | <label for="give-user-pass-<?php echo $form_id; ?>"> |
1169 | - <?php esc_html_e( 'Password', 'give' ); ?> |
|
1170 | - <?php if ( give_logged_in_only( $form_id ) ) { ?> |
|
1169 | + <?php esc_html_e('Password', 'give'); ?> |
|
1170 | + <?php if (give_logged_in_only($form_id)) { ?> |
|
1171 | 1171 | <span class="give-required-indicator">*</span> |
1172 | 1172 | <?php } ?> |
1173 | 1173 | <span class="give-tooltip give-icon give-icon-question" |
1174 | - data-tooltip="<?php esc_attr_e( 'The password used to access your account.', 'give' ); ?>"></span> |
|
1174 | + data-tooltip="<?php esc_attr_e('The password used to access your account.', 'give'); ?>"></span> |
|
1175 | 1175 | </label> |
1176 | 1176 | |
1177 | 1177 | <input name="give_user_pass" id="give-user-pass-<?php echo $form_id; ?>" class="give-input" |
1178 | - placeholder="<?php esc_attr_e( 'Password', 'give' ); ?>" |
|
1179 | - type="password"<?php echo ( give_logged_in_only( $form_id ) ) ? ' required aria-required="true" ' : ''; ?>/> |
|
1178 | + placeholder="<?php esc_attr_e('Password', 'give'); ?>" |
|
1179 | + type="password"<?php echo (give_logged_in_only($form_id)) ? ' required aria-required="true" ' : ''; ?>/> |
|
1180 | 1180 | </div> |
1181 | 1181 | |
1182 | 1182 | <div id="give-user-pass-confirm-wrap-<?php echo $form_id; ?>" |
1183 | 1183 | class="give-register-password form-row form-row-one-third form-row-responsive"> |
1184 | 1184 | <label for="give-user-pass-confirm-<?php echo $form_id; ?>"> |
1185 | - <?php esc_html_e( 'Confirm PW', 'give' ); ?> |
|
1186 | - <?php if ( give_logged_in_only( $form_id ) ) { ?> |
|
1185 | + <?php esc_html_e('Confirm PW', 'give'); ?> |
|
1186 | + <?php if (give_logged_in_only($form_id)) { ?> |
|
1187 | 1187 | <span class="give-required-indicator">*</span> |
1188 | 1188 | <?php } ?> |
1189 | 1189 | <span class="give-tooltip give-icon give-icon-question" |
1190 | - data-tooltip="<?php esc_attr_e( 'Please retype your password to confirm.', 'give' ); ?>"></span> |
|
1190 | + data-tooltip="<?php esc_attr_e('Please retype your password to confirm.', 'give'); ?>"></span> |
|
1191 | 1191 | </label> |
1192 | 1192 | |
1193 | 1193 | <input name="give_user_pass_confirm" id="give-user-pass-confirm-<?php echo $form_id; ?>" |
1194 | - class="give-input" placeholder="<?php esc_attr_e( 'Confirm password', 'give' ); ?>" |
|
1195 | - type="password"<?php echo ( give_logged_in_only( $form_id ) ) ? ' required aria-required="true" ' : ''; ?>/> |
|
1194 | + class="give-input" placeholder="<?php esc_attr_e('Confirm password', 'give'); ?>" |
|
1195 | + type="password"<?php echo (give_logged_in_only($form_id)) ? ' required aria-required="true" ' : ''; ?>/> |
|
1196 | 1196 | </div> |
1197 | 1197 | <?php |
1198 | 1198 | /** |
@@ -1202,7 +1202,7 @@ discard block |
||
1202 | 1202 | * |
1203 | 1203 | * @param int $form_id The form ID. |
1204 | 1204 | */ |
1205 | - do_action( 'give_register_account_fields_after', $form_id ); |
|
1205 | + do_action('give_register_account_fields_after', $form_id); |
|
1206 | 1206 | ?> |
1207 | 1207 | </fieldset> |
1208 | 1208 | |
@@ -1214,7 +1214,7 @@ discard block |
||
1214 | 1214 | * |
1215 | 1215 | * @param int $form_id The form ID. |
1216 | 1216 | */ |
1217 | - do_action( 'give_register_fields_after', $form_id ); |
|
1217 | + do_action('give_register_fields_after', $form_id); |
|
1218 | 1218 | ?> |
1219 | 1219 | |
1220 | 1220 | <input type="hidden" name="give-purchase-var" value="needs-to-register"/> |
@@ -1225,7 +1225,7 @@ discard block |
||
1225 | 1225 | * |
1226 | 1226 | * @since 1.7 |
1227 | 1227 | */ |
1228 | - do_action( 'give_donation_form_user_info', $form_id ); |
|
1228 | + do_action('give_donation_form_user_info', $form_id); |
|
1229 | 1229 | ?> |
1230 | 1230 | |
1231 | 1231 | </fieldset> |
@@ -1233,7 +1233,7 @@ discard block |
||
1233 | 1233 | echo ob_get_clean(); |
1234 | 1234 | } |
1235 | 1235 | |
1236 | -add_action( 'give_donation_form_register_fields', 'give_get_register_fields' ); |
|
1236 | +add_action('give_donation_form_register_fields', 'give_get_register_fields'); |
|
1237 | 1237 | |
1238 | 1238 | /** |
1239 | 1239 | * Gets the login fields for the login form on the checkout. This function hooks |
@@ -1246,27 +1246,27 @@ discard block |
||
1246 | 1246 | * |
1247 | 1247 | * @return string |
1248 | 1248 | */ |
1249 | -function give_get_login_fields( $form_id ) { |
|
1249 | +function give_get_login_fields($form_id) { |
|
1250 | 1250 | |
1251 | - $form_id = isset( $_POST['form_id'] ) ? $_POST['form_id'] : $form_id; |
|
1252 | - $show_register_form = give_show_login_register_option( $form_id ); |
|
1251 | + $form_id = isset($_POST['form_id']) ? $_POST['form_id'] : $form_id; |
|
1252 | + $show_register_form = give_show_login_register_option($form_id); |
|
1253 | 1253 | |
1254 | 1254 | ob_start(); |
1255 | 1255 | ?> |
1256 | 1256 | <fieldset id="give-login-fields-<?php echo $form_id; ?>"> |
1257 | - <legend><?php echo apply_filters( 'give_account_login_fieldset_heading', esc_html__( 'Login to Your Account', 'give' ) ); |
|
1258 | - if ( ! give_logged_in_only( $form_id ) ) { |
|
1259 | - echo ' <span class="sub-text">' . esc_html__( '(optional)', 'give' ) . '</span>'; |
|
1257 | + <legend><?php echo apply_filters('give_account_login_fieldset_heading', esc_html__('Login to Your Account', 'give')); |
|
1258 | + if ( ! give_logged_in_only($form_id)) { |
|
1259 | + echo ' <span class="sub-text">'.esc_html__('(optional)', 'give').'</span>'; |
|
1260 | 1260 | } ?> |
1261 | 1261 | </legend> |
1262 | - <?php if ( $show_register_form == 'both' ) { ?> |
|
1262 | + <?php if ($show_register_form == 'both') { ?> |
|
1263 | 1263 | <p class="give-new-account-link"> |
1264 | - <?php esc_html_e( 'Need to create an account?', 'give' ); ?> |
|
1265 | - <a href="<?php echo remove_query_arg( 'login' ); ?>" class="give-checkout-register-cancel" |
|
1264 | + <?php esc_html_e('Need to create an account?', 'give'); ?> |
|
1265 | + <a href="<?php echo remove_query_arg('login'); ?>" class="give-checkout-register-cancel" |
|
1266 | 1266 | data-action="give_checkout_register"> |
1267 | - <?php esc_html_e( 'Register', 'give' ); |
|
1268 | - if ( ! give_logged_in_only( $form_id ) ) { |
|
1269 | - echo ' ' . esc_html__( 'and donate as a guest »', 'give' ); |
|
1267 | + <?php esc_html_e('Register', 'give'); |
|
1268 | + if ( ! give_logged_in_only($form_id)) { |
|
1269 | + echo ' '.esc_html__('and donate as a guest »', 'give'); |
|
1270 | 1270 | } ?> |
1271 | 1271 | </a> |
1272 | 1272 | </p> |
@@ -1282,49 +1282,49 @@ discard block |
||
1282 | 1282 | * |
1283 | 1283 | * @param int $form_id The form ID. |
1284 | 1284 | */ |
1285 | - do_action( 'give_checkout_login_fields_before', $form_id ); |
|
1285 | + do_action('give_checkout_login_fields_before', $form_id); |
|
1286 | 1286 | ?> |
1287 | 1287 | <div id="give-user-login-wrap-<?php echo $form_id; ?>" class="form-row form-row-first form-row-responsive"> |
1288 | 1288 | <label class="give-label" for="give-user-login-<?php echo $form_id; ?>"> |
1289 | - <?php esc_html_e( 'Username', 'give' ); ?> |
|
1290 | - <?php if ( give_logged_in_only( $form_id ) ) { ?> |
|
1289 | + <?php esc_html_e('Username', 'give'); ?> |
|
1290 | + <?php if (give_logged_in_only($form_id)) { ?> |
|
1291 | 1291 | <span class="give-required-indicator">*</span> |
1292 | 1292 | <?php } ?> |
1293 | 1293 | </label> |
1294 | 1294 | |
1295 | - <input class="give-input<?php echo ( give_logged_in_only( $form_id ) ) ? ' required' : ''; ?>" type="text" |
|
1295 | + <input class="give-input<?php echo (give_logged_in_only($form_id)) ? ' required' : ''; ?>" type="text" |
|
1296 | 1296 | name="give_user_login" id="give-user-login-<?php echo $form_id; ?>" value="" |
1297 | - placeholder="<?php esc_attr_e( 'Your username', 'give' ); ?>"<?php echo ( give_logged_in_only( $form_id ) ) ? ' required aria-required="true" ' : ''; ?>/> |
|
1297 | + placeholder="<?php esc_attr_e('Your username', 'give'); ?>"<?php echo (give_logged_in_only($form_id)) ? ' required aria-required="true" ' : ''; ?>/> |
|
1298 | 1298 | </div> |
1299 | 1299 | |
1300 | 1300 | <div id="give-user-pass-wrap-<?php echo $form_id; ?>" |
1301 | 1301 | class="give_login_password form-row form-row-last form-row-responsive"> |
1302 | 1302 | <label class="give-label" for="give-user-pass-<?php echo $form_id; ?>"> |
1303 | - <?php esc_html_e( 'Password', 'give' ); ?> |
|
1304 | - <?php if ( give_logged_in_only( $form_id ) ) { ?> |
|
1303 | + <?php esc_html_e('Password', 'give'); ?> |
|
1304 | + <?php if (give_logged_in_only($form_id)) { ?> |
|
1305 | 1305 | <span class="give-required-indicator">*</span> |
1306 | 1306 | <?php } ?> |
1307 | 1307 | </label> |
1308 | - <input class="give-input<?php echo ( give_logged_in_only( $form_id ) ) ? ' required' : ''; ?>" |
|
1308 | + <input class="give-input<?php echo (give_logged_in_only($form_id)) ? ' required' : ''; ?>" |
|
1309 | 1309 | type="password" name="give_user_pass" id="give-user-pass-<?php echo $form_id; ?>" |
1310 | - placeholder="<?php esc_attr_e( 'Your password', 'give' ); ?>"<?php echo ( give_logged_in_only( $form_id ) ) ? ' required aria-required="true" ' : ''; ?>/> |
|
1310 | + placeholder="<?php esc_attr_e('Your password', 'give'); ?>"<?php echo (give_logged_in_only($form_id)) ? ' required aria-required="true" ' : ''; ?>/> |
|
1311 | 1311 | <input type="hidden" name="give-purchase-var" value="needs-to-login"/> |
1312 | 1312 | </div> |
1313 | 1313 | |
1314 | 1314 | <div id="give-forgot-password-wrap-<?php echo $form_id; ?>" class="give_login_forgot_password"> |
1315 | 1315 | <span class="give-forgot-password "> |
1316 | 1316 | <a href="<?php echo wp_lostpassword_url() ?>" |
1317 | - target="_blank"><?php esc_html_e( 'Reset Password', 'give' ) ?></a> |
|
1317 | + target="_blank"><?php esc_html_e('Reset Password', 'give') ?></a> |
|
1318 | 1318 | </span> |
1319 | 1319 | </div> |
1320 | 1320 | |
1321 | 1321 | <div id="give-user-login-submit-<?php echo $form_id; ?>" class="give-clearfix"> |
1322 | 1322 | <input type="submit" class="give-submit give-btn button" name="give_login_submit" |
1323 | - value="<?php esc_attr_e( 'Login', 'give' ); ?>"/> |
|
1324 | - <?php if ( $show_register_form !== 'login' ) { ?> |
|
1323 | + value="<?php esc_attr_e('Login', 'give'); ?>"/> |
|
1324 | + <?php if ($show_register_form !== 'login') { ?> |
|
1325 | 1325 | <input type="button" data-action="give_cancel_login" |
1326 | 1326 | class="give-cancel-login give-checkout-register-cancel give-btn button" name="give_login_cancel" |
1327 | - value="<?php esc_attr_e( 'Cancel', 'give' ); ?>"/> |
|
1327 | + value="<?php esc_attr_e('Cancel', 'give'); ?>"/> |
|
1328 | 1328 | <?php } ?> |
1329 | 1329 | <span class="give-loading-animation"></span> |
1330 | 1330 | </div> |
@@ -1336,14 +1336,14 @@ discard block |
||
1336 | 1336 | * |
1337 | 1337 | * @param int $form_id The form ID. |
1338 | 1338 | */ |
1339 | - do_action( 'give_checkout_login_fields_after', $form_id ); |
|
1339 | + do_action('give_checkout_login_fields_after', $form_id); |
|
1340 | 1340 | ?> |
1341 | 1341 | </fieldset><!--end #give-login-fields--> |
1342 | 1342 | <?php |
1343 | 1343 | echo ob_get_clean(); |
1344 | 1344 | } |
1345 | 1345 | |
1346 | -add_action( 'give_donation_form_login_fields', 'give_get_login_fields', 10, 1 ); |
|
1346 | +add_action('give_donation_form_login_fields', 'give_get_login_fields', 10, 1); |
|
1347 | 1347 | |
1348 | 1348 | /** |
1349 | 1349 | * Payment Mode Select. |
@@ -1359,9 +1359,9 @@ discard block |
||
1359 | 1359 | * |
1360 | 1360 | * @return void |
1361 | 1361 | */ |
1362 | -function give_payment_mode_select( $form_id ) { |
|
1362 | +function give_payment_mode_select($form_id) { |
|
1363 | 1363 | |
1364 | - $gateways = give_get_enabled_payment_gateways( $form_id ); |
|
1364 | + $gateways = give_get_enabled_payment_gateways($form_id); |
|
1365 | 1365 | |
1366 | 1366 | /** |
1367 | 1367 | * Fires while selecting payment gateways, before the fields. |
@@ -1370,10 +1370,10 @@ discard block |
||
1370 | 1370 | * |
1371 | 1371 | * @param int $form_id The form ID. |
1372 | 1372 | */ |
1373 | - do_action( 'give_payment_mode_top', $form_id ); |
|
1373 | + do_action('give_payment_mode_top', $form_id); |
|
1374 | 1374 | ?> |
1375 | 1375 | |
1376 | - <fieldset id="give-payment-mode-select" <?php if ( count( $gateways ) <= 1 ) { |
|
1376 | + <fieldset id="give-payment-mode-select" <?php if (count($gateways) <= 1) { |
|
1377 | 1377 | echo 'style="display: none;"'; |
1378 | 1378 | } ?>> |
1379 | 1379 | <?php |
@@ -1384,10 +1384,10 @@ discard block |
||
1384 | 1384 | * |
1385 | 1385 | * @param int $form_id The form ID. |
1386 | 1386 | */ |
1387 | - do_action( 'give_payment_mode_before_gateways_wrap' ); |
|
1387 | + do_action('give_payment_mode_before_gateways_wrap'); |
|
1388 | 1388 | ?> |
1389 | 1389 | <legend |
1390 | - class="give-payment-mode-label"><?php echo apply_filters( 'give_checkout_payment_method_text', esc_html__( 'Select Payment Method', 'give' ) ); ?> |
|
1390 | + class="give-payment-mode-label"><?php echo apply_filters('give_checkout_payment_method_text', esc_html__('Select Payment Method', 'give')); ?> |
|
1391 | 1391 | <span class="give-loading-text"><span |
1392 | 1392 | class="give-loading-animation"></span> |
1393 | 1393 | </span> |
@@ -1400,26 +1400,26 @@ discard block |
||
1400 | 1400 | * |
1401 | 1401 | * @since 1.7 |
1402 | 1402 | */ |
1403 | - do_action( 'give_payment_mode_before_gateways' ) |
|
1403 | + do_action('give_payment_mode_before_gateways') |
|
1404 | 1404 | ?> |
1405 | 1405 | <ul id="give-gateway-radio-list"> |
1406 | 1406 | <?php |
1407 | 1407 | /** |
1408 | 1408 | * Loop through the active payment gateways. |
1409 | 1409 | */ |
1410 | - $selected_gateway = give_get_chosen_gateway( $form_id ); |
|
1410 | + $selected_gateway = give_get_chosen_gateway($form_id); |
|
1411 | 1411 | |
1412 | - foreach ( $gateways as $gateway_id => $gateway ) : |
|
1412 | + foreach ($gateways as $gateway_id => $gateway) : |
|
1413 | 1413 | //Determine the default gateway. |
1414 | - $checked = checked( $gateway_id, $selected_gateway, false ); |
|
1414 | + $checked = checked($gateway_id, $selected_gateway, false); |
|
1415 | 1415 | $checked_class = $checked ? ' class="give-gateway-option-selected"' : ''; ?> |
1416 | 1416 | <li<?php echo $checked_class ?>> |
1417 | 1417 | <input type="radio" name="payment-mode" class="give-gateway" |
1418 | - id="give-gateway-<?php echo esc_attr( $gateway_id ) . '-' . $form_id; ?>" |
|
1419 | - value="<?php echo esc_attr( $gateway_id ); ?>"<?php echo $checked; ?>> |
|
1420 | - <label for="give-gateway-<?php echo esc_attr( $gateway_id ) . '-' . $form_id; ?>" |
|
1418 | + id="give-gateway-<?php echo esc_attr($gateway_id).'-'.$form_id; ?>" |
|
1419 | + value="<?php echo esc_attr($gateway_id); ?>"<?php echo $checked; ?>> |
|
1420 | + <label for="give-gateway-<?php echo esc_attr($gateway_id).'-'.$form_id; ?>" |
|
1421 | 1421 | class="give-gateway-option" |
1422 | - id="give-gateway-option-<?php echo esc_attr( $gateway_id ); ?>"> <?php echo esc_html( $gateway['checkout_label'] ); ?></label> |
|
1422 | + id="give-gateway-option-<?php echo esc_attr($gateway_id); ?>"> <?php echo esc_html($gateway['checkout_label']); ?></label> |
|
1423 | 1423 | </li> |
1424 | 1424 | <?php |
1425 | 1425 | endforeach; |
@@ -1431,7 +1431,7 @@ discard block |
||
1431 | 1431 | * |
1432 | 1432 | * @since 1.7 |
1433 | 1433 | */ |
1434 | - do_action( 'give_payment_mode_after_gateways' ); |
|
1434 | + do_action('give_payment_mode_after_gateways'); |
|
1435 | 1435 | ?> |
1436 | 1436 | </div> |
1437 | 1437 | <?php |
@@ -1442,7 +1442,7 @@ discard block |
||
1442 | 1442 | * |
1443 | 1443 | * @param int $form_id The form ID. |
1444 | 1444 | */ |
1445 | - do_action( 'give_payment_mode_after_gateways_wrap' ); |
|
1445 | + do_action('give_payment_mode_after_gateways_wrap'); |
|
1446 | 1446 | ?> |
1447 | 1447 | </fieldset> |
1448 | 1448 | |
@@ -1454,7 +1454,7 @@ discard block |
||
1454 | 1454 | * |
1455 | 1455 | * @param int $form_id The form ID. |
1456 | 1456 | */ |
1457 | - do_action( 'give_payment_mode_bottom', $form_id ); |
|
1457 | + do_action('give_payment_mode_bottom', $form_id); |
|
1458 | 1458 | ?> |
1459 | 1459 | |
1460 | 1460 | <div id="give_purchase_form_wrap"> |
@@ -1465,7 +1465,7 @@ discard block |
||
1465 | 1465 | * |
1466 | 1466 | * @since 1.7 |
1467 | 1467 | */ |
1468 | - do_action( 'give_donation_form', $form_id ); |
|
1468 | + do_action('give_donation_form', $form_id); |
|
1469 | 1469 | ?> |
1470 | 1470 | |
1471 | 1471 | </div> |
@@ -1476,10 +1476,10 @@ discard block |
||
1476 | 1476 | * |
1477 | 1477 | * @since 1.7 |
1478 | 1478 | */ |
1479 | - do_action( 'give_donation_form_wrap_bottom', $form_id ); |
|
1479 | + do_action('give_donation_form_wrap_bottom', $form_id); |
|
1480 | 1480 | } |
1481 | 1481 | |
1482 | -add_action( 'give_payment_mode_select', 'give_payment_mode_select' ); |
|
1482 | +add_action('give_payment_mode_select', 'give_payment_mode_select'); |
|
1483 | 1483 | |
1484 | 1484 | /** |
1485 | 1485 | * Renders the Checkout Agree to Terms, this displays a checkbox for users to |
@@ -1492,31 +1492,31 @@ discard block |
||
1492 | 1492 | * |
1493 | 1493 | * @return bool |
1494 | 1494 | */ |
1495 | -function give_terms_agreement( $form_id ) { |
|
1496 | - $form_option = give_get_meta( $form_id, '_give_terms_option', true ); |
|
1495 | +function give_terms_agreement($form_id) { |
|
1496 | + $form_option = give_get_meta($form_id, '_give_terms_option', true); |
|
1497 | 1497 | |
1498 | 1498 | // Bailout if per form and global term and conditions is not setup. |
1499 | 1499 | if ( |
1500 | - give_is_setting_enabled( $form_option, 'global' ) |
|
1501 | - && give_is_setting_enabled( give_get_option( 'terms' ) ) |
|
1500 | + give_is_setting_enabled($form_option, 'global') |
|
1501 | + && give_is_setting_enabled(give_get_option('terms')) |
|
1502 | 1502 | ) { |
1503 | - $label = give_get_option( 'agree_to_terms_label', esc_html__( 'Agree to Terms?', 'give' ) ); |
|
1504 | - $terms = $terms = give_get_option( 'agreement_text', '' ); |
|
1505 | - $edit_term_url = admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=display§ion=term-and-conditions' ); |
|
1503 | + $label = give_get_option('agree_to_terms_label', esc_html__('Agree to Terms?', 'give')); |
|
1504 | + $terms = $terms = give_get_option('agreement_text', ''); |
|
1505 | + $edit_term_url = admin_url('edit.php?post_type=give_forms&page=give-settings&tab=display§ion=term-and-conditions'); |
|
1506 | 1506 | |
1507 | - } elseif ( give_is_setting_enabled( $form_option ) ) { |
|
1508 | - $label = ( $label = give_get_meta( $form_id, '_give_agree_label', true ) ) ? stripslashes( $label ) : esc_html__( 'Agree to Terms?', 'give' ); |
|
1509 | - $terms = give_get_meta( $form_id, '_give_agree_text', true ); |
|
1510 | - $edit_term_url = admin_url( 'post.php?post=' . $form_id . '&action=edit#form_terms_options' ); |
|
1507 | + } elseif (give_is_setting_enabled($form_option)) { |
|
1508 | + $label = ($label = give_get_meta($form_id, '_give_agree_label', true)) ? stripslashes($label) : esc_html__('Agree to Terms?', 'give'); |
|
1509 | + $terms = give_get_meta($form_id, '_give_agree_text', true); |
|
1510 | + $edit_term_url = admin_url('post.php?post='.$form_id.'&action=edit#form_terms_options'); |
|
1511 | 1511 | |
1512 | 1512 | } else { |
1513 | 1513 | return false; |
1514 | 1514 | } |
1515 | 1515 | |
1516 | 1516 | // Bailout: Check if term and conditions text is empty or not. |
1517 | - if ( empty( $terms ) ) { |
|
1518 | - if ( is_user_logged_in() && current_user_can( 'edit_give_forms' ) ) { |
|
1519 | - echo sprintf( __( 'Please enter valid terms and conditions in <a href="%s">this form\'s settings</a>.', 'give' ), $edit_term_url ); |
|
1517 | + if (empty($terms)) { |
|
1518 | + if (is_user_logged_in() && current_user_can('edit_give_forms')) { |
|
1519 | + echo sprintf(__('Please enter valid terms and conditions in <a href="%s">this form\'s settings</a>.', 'give'), $edit_term_url); |
|
1520 | 1520 | } |
1521 | 1521 | |
1522 | 1522 | return false; |
@@ -1524,7 +1524,7 @@ discard block |
||
1524 | 1524 | |
1525 | 1525 | ?> |
1526 | 1526 | <fieldset id="give_terms_agreement"> |
1527 | - <legend><?php echo apply_filters( 'give_terms_agreement_text', esc_html__( 'Terms', 'give' ) ); ?></legend> |
|
1527 | + <legend><?php echo apply_filters('give_terms_agreement_text', esc_html__('Terms', 'give')); ?></legend> |
|
1528 | 1528 | <div id="give_terms" class="give_terms-<?php echo $form_id; ?>" style="display:none;"> |
1529 | 1529 | <?php |
1530 | 1530 | /** |
@@ -1532,22 +1532,22 @@ discard block |
||
1532 | 1532 | * |
1533 | 1533 | * @since 1.0 |
1534 | 1534 | */ |
1535 | - do_action( 'give_before_terms' ); |
|
1535 | + do_action('give_before_terms'); |
|
1536 | 1536 | |
1537 | - echo wpautop( stripslashes( $terms ) ); |
|
1537 | + echo wpautop(stripslashes($terms)); |
|
1538 | 1538 | /** |
1539 | 1539 | * Fires while rendering terms of agreement, after the fields. |
1540 | 1540 | * |
1541 | 1541 | * @since 1.0 |
1542 | 1542 | */ |
1543 | - do_action( 'give_after_terms' ); |
|
1543 | + do_action('give_after_terms'); |
|
1544 | 1544 | ?> |
1545 | 1545 | </div> |
1546 | 1546 | <div id="give_show_terms"> |
1547 | 1547 | <a href="#" class="give_terms_links give_terms_links-<?php echo $form_id; ?>" role="button" |
1548 | - aria-controls="give_terms"><?php esc_html_e( 'Show Terms', 'give' ); ?></a> |
|
1548 | + aria-controls="give_terms"><?php esc_html_e('Show Terms', 'give'); ?></a> |
|
1549 | 1549 | <a href="#" class="give_terms_links give_terms_links-<?php echo $form_id; ?>" role="button" |
1550 | - aria-controls="give_terms" style="display:none;"><?php esc_html_e( 'Hide Terms', 'give' ); ?></a> |
|
1550 | + aria-controls="give_terms" style="display:none;"><?php esc_html_e('Hide Terms', 'give'); ?></a> |
|
1551 | 1551 | </div> |
1552 | 1552 | |
1553 | 1553 | <input name="give_agree_to_terms" class="required" type="checkbox" |
@@ -1558,7 +1558,7 @@ discard block |
||
1558 | 1558 | <?php |
1559 | 1559 | } |
1560 | 1560 | |
1561 | -add_action( 'give_donation_form_after_cc_form', 'give_terms_agreement', 8888, 1 ); |
|
1561 | +add_action('give_donation_form_after_cc_form', 'give_terms_agreement', 8888, 1); |
|
1562 | 1562 | |
1563 | 1563 | /** |
1564 | 1564 | * Checkout Final Total. |
@@ -1571,31 +1571,30 @@ discard block |
||
1571 | 1571 | * |
1572 | 1572 | * @return void |
1573 | 1573 | */ |
1574 | -function give_checkout_final_total( $form_id ) { |
|
1574 | +function give_checkout_final_total($form_id) { |
|
1575 | 1575 | |
1576 | - $total = isset( $_POST['give_total'] ) ? |
|
1577 | - apply_filters( 'give_donation_total', give_maybe_sanitize_amount( $_POST['give_total'] ) ) : |
|
1578 | - give_get_default_form_amount( $form_id ); |
|
1576 | + $total = isset($_POST['give_total']) ? |
|
1577 | + apply_filters('give_donation_total', give_maybe_sanitize_amount($_POST['give_total'])) : give_get_default_form_amount($form_id); |
|
1579 | 1578 | |
1580 | 1579 | |
1581 | 1580 | //Only proceed if give_total available. |
1582 | - if ( empty( $total ) ) { |
|
1581 | + if (empty($total)) { |
|
1583 | 1582 | return; |
1584 | 1583 | } |
1585 | 1584 | ?> |
1586 | 1585 | <p id="give-final-total-wrap" class="form-wrap "> |
1587 | 1586 | <span class="give-donation-total-label"> |
1588 | - <?php echo apply_filters( 'give_donation_total_label', esc_html__( 'Donation Total:', 'give' ) ); ?> |
|
1587 | + <?php echo apply_filters('give_donation_total_label', esc_html__('Donation Total:', 'give')); ?> |
|
1589 | 1588 | </span> |
1590 | 1589 | <span class="give-final-total-amount" |
1591 | - data-total="<?php echo give_format_amount( $total, array( 'sanitize' => false ) ); ?>"> |
|
1592 | - <?php echo give_currency_filter( give_format_amount( $total, array( 'sanitize' => false ) ), give_get_currency( $form_id ) ); ?> |
|
1590 | + data-total="<?php echo give_format_amount($total, array('sanitize' => false)); ?>"> |
|
1591 | + <?php echo give_currency_filter(give_format_amount($total, array('sanitize' => false)), give_get_currency($form_id)); ?> |
|
1593 | 1592 | </span> |
1594 | 1593 | </p> |
1595 | 1594 | <?php |
1596 | 1595 | } |
1597 | 1596 | |
1598 | -add_action( 'give_donation_form_before_submit', 'give_checkout_final_total', 999 ); |
|
1597 | +add_action('give_donation_form_before_submit', 'give_checkout_final_total', 999); |
|
1599 | 1598 | |
1600 | 1599 | /** |
1601 | 1600 | * Renders the Checkout Submit section. |
@@ -1606,7 +1605,7 @@ discard block |
||
1606 | 1605 | * |
1607 | 1606 | * @return void |
1608 | 1607 | */ |
1609 | -function give_checkout_submit( $form_id ) { |
|
1608 | +function give_checkout_submit($form_id) { |
|
1610 | 1609 | ?> |
1611 | 1610 | <fieldset id="give_purchase_submit"> |
1612 | 1611 | <?php |
@@ -1615,24 +1614,24 @@ discard block |
||
1615 | 1614 | * |
1616 | 1615 | * @since 1.7 |
1617 | 1616 | */ |
1618 | - do_action( 'give_donation_form_before_submit', $form_id ); |
|
1617 | + do_action('give_donation_form_before_submit', $form_id); |
|
1619 | 1618 | |
1620 | - give_checkout_hidden_fields( $form_id ); |
|
1619 | + give_checkout_hidden_fields($form_id); |
|
1621 | 1620 | |
1622 | - echo give_get_donation_form_submit_button( $form_id ); |
|
1621 | + echo give_get_donation_form_submit_button($form_id); |
|
1623 | 1622 | |
1624 | 1623 | /** |
1625 | 1624 | * Fire after donation form submit. |
1626 | 1625 | * |
1627 | 1626 | * @since 1.7 |
1628 | 1627 | */ |
1629 | - do_action( 'give_donation_form_after_submit', $form_id ); |
|
1628 | + do_action('give_donation_form_after_submit', $form_id); |
|
1630 | 1629 | ?> |
1631 | 1630 | </fieldset> |
1632 | 1631 | <?php |
1633 | 1632 | } |
1634 | 1633 | |
1635 | -add_action( 'give_donation_form_after_cc_form', 'give_checkout_submit', 9999 ); |
|
1634 | +add_action('give_donation_form_after_cc_form', 'give_checkout_submit', 9999); |
|
1636 | 1635 | |
1637 | 1636 | /** |
1638 | 1637 | * Give Donation form submit button. |
@@ -1643,10 +1642,10 @@ discard block |
||
1643 | 1642 | * |
1644 | 1643 | * @return string |
1645 | 1644 | */ |
1646 | -function give_get_donation_form_submit_button( $form_id ) { |
|
1645 | +function give_get_donation_form_submit_button($form_id) { |
|
1647 | 1646 | |
1648 | - $display_label_field = give_get_meta( $form_id, '_give_checkout_label', true ); |
|
1649 | - $display_label = ( ! empty( $display_label_field ) ? $display_label_field : esc_html__( 'Donate Now', 'give' ) ); |
|
1647 | + $display_label_field = give_get_meta($form_id, '_give_checkout_label', true); |
|
1648 | + $display_label = ( ! empty($display_label_field) ? $display_label_field : esc_html__('Donate Now', 'give')); |
|
1650 | 1649 | ob_start(); |
1651 | 1650 | ?> |
1652 | 1651 | <div class="give-submit-button-wrap give-clearfix"> |
@@ -1655,7 +1654,7 @@ discard block |
||
1655 | 1654 | <span class="give-loading-animation"></span> |
1656 | 1655 | </div> |
1657 | 1656 | <?php |
1658 | - return apply_filters( 'give_donation_form_submit_button', ob_get_clean(), $form_id ); |
|
1657 | + return apply_filters('give_donation_form_submit_button', ob_get_clean(), $form_id); |
|
1659 | 1658 | } |
1660 | 1659 | |
1661 | 1660 | /** |
@@ -1670,17 +1669,17 @@ discard block |
||
1670 | 1669 | * |
1671 | 1670 | * @return mixed |
1672 | 1671 | */ |
1673 | -function give_show_goal_progress( $form_id, $args ) { |
|
1672 | +function give_show_goal_progress($form_id, $args) { |
|
1674 | 1673 | |
1675 | 1674 | ob_start(); |
1676 | - give_get_template( 'shortcode-goal', array( 'form_id' => $form_id, 'args' => $args ) ); |
|
1675 | + give_get_template('shortcode-goal', array('form_id' => $form_id, 'args' => $args)); |
|
1677 | 1676 | |
1678 | - echo apply_filters( 'give_goal_output', ob_get_clean() ); |
|
1677 | + echo apply_filters('give_goal_output', ob_get_clean()); |
|
1679 | 1678 | |
1680 | 1679 | return true; |
1681 | 1680 | } |
1682 | 1681 | |
1683 | -add_action( 'give_pre_form', 'give_show_goal_progress', 10, 2 ); |
|
1682 | +add_action('give_pre_form', 'give_show_goal_progress', 10, 2); |
|
1684 | 1683 | |
1685 | 1684 | |
1686 | 1685 | /** |
@@ -1693,10 +1692,10 @@ discard block |
||
1693 | 1692 | * |
1694 | 1693 | * @return mixed|string |
1695 | 1694 | */ |
1696 | -function give_get_form_content_placement( $form_id, $args ) { |
|
1695 | +function give_get_form_content_placement($form_id, $args) { |
|
1697 | 1696 | $show_content = ''; |
1698 | 1697 | |
1699 | - if ( isset( $args['show_content'] ) && ! empty( $args['show_content'] ) ) { |
|
1698 | + if (isset($args['show_content']) && ! empty($args['show_content'])) { |
|
1700 | 1699 | // Content positions. |
1701 | 1700 | $content_placement = array( |
1702 | 1701 | 'above' => 'give_pre_form', |
@@ -1704,18 +1703,18 @@ discard block |
||
1704 | 1703 | ); |
1705 | 1704 | |
1706 | 1705 | // Check if content position already decoded. |
1707 | - if ( in_array( $args['show_content'], $content_placement ) ) { |
|
1706 | + if (in_array($args['show_content'], $content_placement)) { |
|
1708 | 1707 | return $args['show_content']; |
1709 | 1708 | } |
1710 | 1709 | |
1711 | - $show_content = ( 'none' !== $args['show_content'] ? $content_placement[ $args['show_content'] ] : '' ); |
|
1710 | + $show_content = ('none' !== $args['show_content'] ? $content_placement[$args['show_content']] : ''); |
|
1712 | 1711 | |
1713 | - } elseif ( give_is_setting_enabled( give_get_meta( $form_id, '_give_display_content', true ) ) ) { |
|
1714 | - $show_content = give_get_meta( $form_id, '_give_content_placement', true ); |
|
1712 | + } elseif (give_is_setting_enabled(give_get_meta($form_id, '_give_display_content', true))) { |
|
1713 | + $show_content = give_get_meta($form_id, '_give_content_placement', true); |
|
1715 | 1714 | |
1716 | - } elseif ( 'none' !== give_get_meta( $form_id, '_give_content_option', true ) ) { |
|
1715 | + } elseif ('none' !== give_get_meta($form_id, '_give_content_option', true)) { |
|
1717 | 1716 | // Backward compatibility for _give_content_option for v18. |
1718 | - $show_content = give_get_meta( $form_id, '_give_content_option', true ); |
|
1717 | + $show_content = give_get_meta($form_id, '_give_content_option', true); |
|
1719 | 1718 | } |
1720 | 1719 | |
1721 | 1720 | return $show_content; |
@@ -1731,20 +1730,20 @@ discard block |
||
1731 | 1730 | * |
1732 | 1731 | * @return void|bool |
1733 | 1732 | */ |
1734 | -function give_form_content( $form_id, $args ) { |
|
1733 | +function give_form_content($form_id, $args) { |
|
1735 | 1734 | |
1736 | - $show_content = give_get_form_content_placement( $form_id, $args ); |
|
1735 | + $show_content = give_get_form_content_placement($form_id, $args); |
|
1737 | 1736 | |
1738 | 1737 | // Bailout. |
1739 | - if ( empty( $show_content ) ) { |
|
1738 | + if (empty($show_content)) { |
|
1740 | 1739 | return false; |
1741 | 1740 | } |
1742 | 1741 | |
1743 | 1742 | // Add action according to value. |
1744 | - add_action( $show_content, 'give_form_display_content', 10, 2 ); |
|
1743 | + add_action($show_content, 'give_form_display_content', 10, 2); |
|
1745 | 1744 | } |
1746 | 1745 | |
1747 | -add_action( 'give_pre_form_output', 'give_form_content', 10, 2 ); |
|
1746 | +add_action('give_pre_form_output', 'give_form_content', 10, 2); |
|
1748 | 1747 | |
1749 | 1748 | /** |
1750 | 1749 | * Renders Post Form Content. |
@@ -1758,22 +1757,22 @@ discard block |
||
1758 | 1757 | * |
1759 | 1758 | * @return void |
1760 | 1759 | */ |
1761 | -function give_form_display_content( $form_id, $args ) { |
|
1760 | +function give_form_display_content($form_id, $args) { |
|
1762 | 1761 | |
1763 | - $content = wpautop( give_get_meta( $form_id, '_give_form_content', true ) ); |
|
1764 | - $show_content = give_get_form_content_placement( $form_id, $args ); |
|
1762 | + $content = wpautop(give_get_meta($form_id, '_give_form_content', true)); |
|
1763 | + $show_content = give_get_form_content_placement($form_id, $args); |
|
1765 | 1764 | |
1766 | - if ( give_is_setting_enabled( give_get_option( 'the_content_filter' ) ) ) { |
|
1767 | - $content = apply_filters( 'the_content', $content ); |
|
1765 | + if (give_is_setting_enabled(give_get_option('the_content_filter'))) { |
|
1766 | + $content = apply_filters('the_content', $content); |
|
1768 | 1767 | } |
1769 | 1768 | |
1770 | - $output = '<div id="give-form-content-' . $form_id . '" class="give-form-content-wrap ' . $show_content . '-content">' . $content . '</div>'; |
|
1769 | + $output = '<div id="give-form-content-'.$form_id.'" class="give-form-content-wrap '.$show_content.'-content">'.$content.'</div>'; |
|
1771 | 1770 | |
1772 | - echo apply_filters( 'give_form_content_output', $output ); |
|
1771 | + echo apply_filters('give_form_content_output', $output); |
|
1773 | 1772 | |
1774 | 1773 | //remove action to prevent content output on addition forms on page. |
1775 | 1774 | //@see: https://github.com/WordImpress/Give/issues/634. |
1776 | - remove_action( $show_content, 'give_form_display_content' ); |
|
1775 | + remove_action($show_content, 'give_form_display_content'); |
|
1777 | 1776 | } |
1778 | 1777 | |
1779 | 1778 | /** |
@@ -1785,7 +1784,7 @@ discard block |
||
1785 | 1784 | * |
1786 | 1785 | * @return void |
1787 | 1786 | */ |
1788 | -function give_checkout_hidden_fields( $form_id ) { |
|
1787 | +function give_checkout_hidden_fields($form_id) { |
|
1789 | 1788 | |
1790 | 1789 | /** |
1791 | 1790 | * Fires while rendering hidden checkout fields, before the fields. |
@@ -1794,13 +1793,13 @@ discard block |
||
1794 | 1793 | * |
1795 | 1794 | * @param int $form_id The form ID. |
1796 | 1795 | */ |
1797 | - do_action( 'give_hidden_fields_before', $form_id ); |
|
1796 | + do_action('give_hidden_fields_before', $form_id); |
|
1798 | 1797 | |
1799 | - if ( is_user_logged_in() ) { ?> |
|
1798 | + if (is_user_logged_in()) { ?> |
|
1800 | 1799 | <input type="hidden" name="give-user-id" value="<?php echo get_current_user_id(); ?>"/> |
1801 | 1800 | <?php } ?> |
1802 | 1801 | <input type="hidden" name="give_action" value="purchase"/> |
1803 | - <input type="hidden" name="give-gateway" value="<?php echo give_get_chosen_gateway( $form_id ); ?>"/> |
|
1802 | + <input type="hidden" name="give-gateway" value="<?php echo give_get_chosen_gateway($form_id); ?>"/> |
|
1804 | 1803 | <?php |
1805 | 1804 | /** |
1806 | 1805 | * Fires while rendering hidden checkout fields, after the fields. |
@@ -1809,7 +1808,7 @@ discard block |
||
1809 | 1808 | * |
1810 | 1809 | * @param int $form_id The form ID. |
1811 | 1810 | */ |
1812 | - do_action( 'give_hidden_fields_after', $form_id ); |
|
1811 | + do_action('give_hidden_fields_after', $form_id); |
|
1813 | 1812 | |
1814 | 1813 | } |
1815 | 1814 | |
@@ -1824,20 +1823,20 @@ discard block |
||
1824 | 1823 | * |
1825 | 1824 | * @return string $content Filtered content. |
1826 | 1825 | */ |
1827 | -function give_filter_success_page_content( $content ) { |
|
1826 | +function give_filter_success_page_content($content) { |
|
1828 | 1827 | |
1829 | 1828 | $give_options = give_get_settings(); |
1830 | 1829 | |
1831 | - if ( isset( $give_options['success_page'] ) && isset( $_GET['payment-confirmation'] ) && is_page( $give_options['success_page'] ) ) { |
|
1832 | - if ( has_filter( 'give_payment_confirm_' . $_GET['payment-confirmation'] ) ) { |
|
1833 | - $content = apply_filters( 'give_payment_confirm_' . $_GET['payment-confirmation'], $content ); |
|
1830 | + if (isset($give_options['success_page']) && isset($_GET['payment-confirmation']) && is_page($give_options['success_page'])) { |
|
1831 | + if (has_filter('give_payment_confirm_'.$_GET['payment-confirmation'])) { |
|
1832 | + $content = apply_filters('give_payment_confirm_'.$_GET['payment-confirmation'], $content); |
|
1834 | 1833 | } |
1835 | 1834 | } |
1836 | 1835 | |
1837 | 1836 | return $content; |
1838 | 1837 | } |
1839 | 1838 | |
1840 | -add_filter( 'the_content', 'give_filter_success_page_content' ); |
|
1839 | +add_filter('the_content', 'give_filter_success_page_content'); |
|
1841 | 1840 | |
1842 | 1841 | /** |
1843 | 1842 | * Test Mode Frontend Warning. |
@@ -1848,12 +1847,12 @@ discard block |
||
1848 | 1847 | */ |
1849 | 1848 | function give_test_mode_frontend_warning() { |
1850 | 1849 | |
1851 | - if ( give_is_test_mode() ) { |
|
1852 | - echo '<div class="give_error give_warning" id="give_error_test_mode"><p><strong>' . esc_html__( 'Notice:', 'give' ) . '</strong> ' . esc_html__( 'Test mode is enabled. While in test mode no live donations are processed.', 'give' ) . '</p></div>'; |
|
1850 | + if (give_is_test_mode()) { |
|
1851 | + echo '<div class="give_error give_warning" id="give_error_test_mode"><p><strong>'.esc_html__('Notice:', 'give').'</strong> '.esc_html__('Test mode is enabled. While in test mode no live donations are processed.', 'give').'</p></div>'; |
|
1853 | 1852 | } |
1854 | 1853 | } |
1855 | 1854 | |
1856 | -add_action( 'give_pre_form', 'give_test_mode_frontend_warning', 10 ); |
|
1855 | +add_action('give_pre_form', 'give_test_mode_frontend_warning', 10); |
|
1857 | 1856 | |
1858 | 1857 | /** |
1859 | 1858 | * Members-only Form. |
@@ -1867,21 +1866,21 @@ discard block |
||
1867 | 1866 | * |
1868 | 1867 | * @return string |
1869 | 1868 | */ |
1870 | -function give_members_only_form( $final_output, $args ) { |
|
1869 | +function give_members_only_form($final_output, $args) { |
|
1871 | 1870 | |
1872 | - $form_id = isset( $args['form_id'] ) ? $args['form_id'] : 0; |
|
1871 | + $form_id = isset($args['form_id']) ? $args['form_id'] : 0; |
|
1873 | 1872 | |
1874 | 1873 | //Sanity Check: Must have form_id & not be logged in. |
1875 | - if ( empty( $form_id ) || is_user_logged_in() ) { |
|
1874 | + if (empty($form_id) || is_user_logged_in()) { |
|
1876 | 1875 | return $final_output; |
1877 | 1876 | } |
1878 | 1877 | |
1879 | 1878 | //Logged in only and Register / Login set to none. |
1880 | - if ( give_logged_in_only( $form_id ) && give_show_login_register_option( $form_id ) == 'none' ) { |
|
1879 | + if (give_logged_in_only($form_id) && give_show_login_register_option($form_id) == 'none') { |
|
1881 | 1880 | |
1882 | - $final_output = Give()->notices->print_frontend_notice( esc_html__( 'Please log in in order to complete your donation.', 'give' ), false ); |
|
1881 | + $final_output = Give()->notices->print_frontend_notice(esc_html__('Please log in in order to complete your donation.', 'give'), false); |
|
1883 | 1882 | |
1884 | - return apply_filters( 'give_members_only_output', $final_output, $form_id ); |
|
1883 | + return apply_filters('give_members_only_output', $final_output, $form_id); |
|
1885 | 1884 | |
1886 | 1885 | } |
1887 | 1886 | |
@@ -1889,7 +1888,7 @@ discard block |
||
1889 | 1888 | |
1890 | 1889 | } |
1891 | 1890 | |
1892 | -add_filter( 'give_donate_form', 'give_members_only_form', 10, 2 ); |
|
1891 | +add_filter('give_donate_form', 'give_members_only_form', 10, 2); |
|
1893 | 1892 | |
1894 | 1893 | |
1895 | 1894 | /** |
@@ -1901,25 +1900,25 @@ discard block |
||
1901 | 1900 | * @param array $args |
1902 | 1901 | * @param Give_Donate_Form $form |
1903 | 1902 | */ |
1904 | -function __give_form_add_donation_hidden_field( $form_id, $args, $form ) { |
|
1903 | +function __give_form_add_donation_hidden_field($form_id, $args, $form) { |
|
1905 | 1904 | ?> |
1906 | 1905 | <input type="hidden" name="give-form-id" value="<?php echo $form_id; ?>"/> |
1907 | - <input type="hidden" name="give-form-title" value="<?php echo htmlentities( $form->post_title ); ?>"/> |
|
1906 | + <input type="hidden" name="give-form-title" value="<?php echo htmlentities($form->post_title); ?>"/> |
|
1908 | 1907 | <input type="hidden" name="give-current-url" |
1909 | - value="<?php echo htmlspecialchars( give_get_current_page_url() ); ?>"/> |
|
1910 | - <input type="hidden" name="give-form-url" value="<?php echo htmlspecialchars( give_get_current_page_url() ); ?>"/> |
|
1908 | + value="<?php echo htmlspecialchars(give_get_current_page_url()); ?>"/> |
|
1909 | + <input type="hidden" name="give-form-url" value="<?php echo htmlspecialchars(give_get_current_page_url()); ?>"/> |
|
1911 | 1910 | <input type="hidden" name="give-form-minimum" |
1912 | - value="<?php echo give_format_amount( give_get_form_minimum_price( $form_id ), array( 'sanitize' => false ) ); ?>"/> |
|
1911 | + value="<?php echo give_format_amount(give_get_form_minimum_price($form_id), array('sanitize' => false)); ?>"/> |
|
1913 | 1912 | <?php |
1914 | 1913 | |
1915 | 1914 | // Price ID hidden field for variable (multi-level) donation forms. |
1916 | - if ( give_has_variable_prices( $form_id ) ) { |
|
1915 | + if (give_has_variable_prices($form_id)) { |
|
1917 | 1916 | // Get default selected price ID. |
1918 | - $prices = apply_filters( 'give_form_variable_prices', give_get_variable_prices( $form_id ), $form_id ); |
|
1917 | + $prices = apply_filters('give_form_variable_prices', give_get_variable_prices($form_id), $form_id); |
|
1919 | 1918 | $price_id = 0; |
1920 | 1919 | //loop through prices. |
1921 | - foreach ( $prices as $price ) { |
|
1922 | - if ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) { |
|
1920 | + foreach ($prices as $price) { |
|
1921 | + if (isset($price['_give_default']) && $price['_give_default'] === 'default') { |
|
1923 | 1922 | $price_id = $price['_give_id']['level_id']; |
1924 | 1923 | }; |
1925 | 1924 | } |
@@ -1932,7 +1931,7 @@ discard block |
||
1932 | 1931 | } |
1933 | 1932 | } |
1934 | 1933 | |
1935 | -add_action( 'give_donation_form_top', '__give_form_add_donation_hidden_field', 0, 3 ); |
|
1934 | +add_action('give_donation_form_top', '__give_form_add_donation_hidden_field', 0, 3); |
|
1936 | 1935 | |
1937 | 1936 | /** |
1938 | 1937 | * Add currency settings on donation form. |
@@ -1944,20 +1943,20 @@ discard block |
||
1944 | 1943 | * |
1945 | 1944 | * @return array |
1946 | 1945 | */ |
1947 | -function __give_form_add_currency_settings( $form_html_tags, $form ) { |
|
1948 | - $form_currency = give_get_currency( $form->ID ); |
|
1949 | - $currency_settings = give_get_currency_formatting_settings( $form_currency ); |
|
1946 | +function __give_form_add_currency_settings($form_html_tags, $form) { |
|
1947 | + $form_currency = give_get_currency($form->ID); |
|
1948 | + $currency_settings = give_get_currency_formatting_settings($form_currency); |
|
1950 | 1949 | |
1951 | 1950 | // Check if currency exist. |
1952 | - if ( empty( $currency_settings ) ) { |
|
1951 | + if (empty($currency_settings)) { |
|
1953 | 1952 | return $form_html_tags; |
1954 | 1953 | } |
1955 | 1954 | |
1956 | - $form_html_tags['data-currency_symbol'] = give_currency_symbol( $form_currency ); |
|
1955 | + $form_html_tags['data-currency_symbol'] = give_currency_symbol($form_currency); |
|
1957 | 1956 | $form_html_tags['data-currency_code'] = $form_currency; |
1958 | 1957 | |
1959 | - if ( ! empty( $currency_settings ) ) { |
|
1960 | - foreach ( $currency_settings as $key => $value ) { |
|
1958 | + if ( ! empty($currency_settings)) { |
|
1959 | + foreach ($currency_settings as $key => $value) { |
|
1961 | 1960 | $form_html_tags["data-{$key}"] = $value; |
1962 | 1961 | } |
1963 | 1962 | } |
@@ -1965,4 +1964,4 @@ discard block |
||
1965 | 1964 | return $form_html_tags; |
1966 | 1965 | } |
1967 | 1966 | |
1968 | -add_filter( 'give_form_html_tags', '__give_form_add_currency_settings', 0, 2 ); |
|
1967 | +add_filter('give_form_html_tags', '__give_form_add_currency_settings', 0, 2); |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly. |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | * @return bool Whether we can export or not |
38 | 38 | */ |
39 | 39 | public function can_export() { |
40 | - return (bool) apply_filters( 'give_export_capability', current_user_can( 'export_give_reports' ) ); |
|
40 | + return (bool) apply_filters('give_export_capability', current_user_can('export_give_reports')); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
@@ -48,16 +48,16 @@ discard block |
||
48 | 48 | * @return void |
49 | 49 | */ |
50 | 50 | public function headers() { |
51 | - ignore_user_abort( true ); |
|
51 | + ignore_user_abort(true); |
|
52 | 52 | |
53 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
54 | - set_time_limit( 0 ); |
|
53 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
54 | + set_time_limit(0); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | nocache_headers(); |
58 | - header( 'Content-Type: text/csv; charset=utf-8' ); |
|
59 | - header( 'Content-Disposition: attachment; filename=give-export-' . $this->export_type . '-' . date( 'm-d-Y' ) . '.csv' ); |
|
60 | - header( "Expires: 0" ); |
|
58 | + header('Content-Type: text/csv; charset=utf-8'); |
|
59 | + header('Content-Disposition: attachment; filename=give-export-'.$this->export_type.'-'.date('m-d-Y').'.csv'); |
|
60 | + header("Expires: 0"); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
@@ -69,8 +69,8 @@ discard block |
||
69 | 69 | */ |
70 | 70 | public function csv_cols() { |
71 | 71 | $cols = array( |
72 | - 'id' => __( 'ID', 'give' ), |
|
73 | - 'date' => __( 'Date', 'give' ) |
|
72 | + 'id' => __('ID', 'give'), |
|
73 | + 'date' => __('Date', 'give') |
|
74 | 74 | ); |
75 | 75 | |
76 | 76 | return $cols; |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | public function get_csv_cols() { |
87 | 87 | $cols = $this->csv_cols(); |
88 | 88 | |
89 | - return apply_filters( "give_export_csv_cols_{$this->export_type}", $cols ); |
|
89 | + return apply_filters("give_export_csv_cols_{$this->export_type}", $cols); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
@@ -100,10 +100,10 @@ discard block |
||
100 | 100 | public function csv_cols_out() { |
101 | 101 | $cols = $this->get_csv_cols(); |
102 | 102 | $i = 1; |
103 | - foreach ( $cols as $col_id => $column ) { |
|
104 | - echo '"' . addslashes( $column ) . '"'; |
|
105 | - echo $i == count( $cols ) ? '' : ','; |
|
106 | - $i ++; |
|
103 | + foreach ($cols as $col_id => $column) { |
|
104 | + echo '"'.addslashes($column).'"'; |
|
105 | + echo $i == count($cols) ? '' : ','; |
|
106 | + $i++; |
|
107 | 107 | } |
108 | 108 | echo "\r\n"; |
109 | 109 | } |
@@ -120,16 +120,16 @@ discard block |
||
120 | 120 | $data = array( |
121 | 121 | 0 => array( |
122 | 122 | 'id' => '', |
123 | - 'data' => date( 'F j, Y' ) |
|
123 | + 'data' => date('F j, Y') |
|
124 | 124 | ), |
125 | 125 | 1 => array( |
126 | 126 | 'id' => '', |
127 | - 'data' => date( 'F j, Y' ) |
|
127 | + 'data' => date('F j, Y') |
|
128 | 128 | ) |
129 | 129 | ); |
130 | 130 | |
131 | - $data = apply_filters( 'give_export_get_data', $data ); |
|
132 | - $data = apply_filters( "give_export_get_data_{$this->export_type}", $data ); |
|
131 | + $data = apply_filters('give_export_get_data', $data); |
|
132 | + $data = apply_filters("give_export_get_data_{$this->export_type}", $data); |
|
133 | 133 | |
134 | 134 | return $data; |
135 | 135 | } |
@@ -147,14 +147,14 @@ discard block |
||
147 | 147 | $cols = $this->get_csv_cols(); |
148 | 148 | |
149 | 149 | // Output each row |
150 | - foreach ( $data as $row ) { |
|
150 | + foreach ($data as $row) { |
|
151 | 151 | $i = 1; |
152 | - foreach ( $row as $col_id => $column ) { |
|
152 | + foreach ($row as $col_id => $column) { |
|
153 | 153 | // Make sure the column is valid |
154 | - if ( array_key_exists( $col_id, $cols ) ) { |
|
155 | - echo '"' . addslashes( $column ) . '"'; |
|
156 | - echo $i == count( $cols ) ? '' : ','; |
|
157 | - $i ++; |
|
154 | + if (array_key_exists($col_id, $cols)) { |
|
155 | + echo '"'.addslashes($column).'"'; |
|
156 | + echo $i == count($cols) ? '' : ','; |
|
157 | + $i++; |
|
158 | 158 | } |
159 | 159 | } |
160 | 160 | echo "\r\n"; |
@@ -173,8 +173,8 @@ discard block |
||
173 | 173 | * @return void |
174 | 174 | */ |
175 | 175 | public function export() { |
176 | - if ( ! $this->can_export() ) { |
|
177 | - wp_die( __( 'You do not have permission to export data.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
176 | + if ( ! $this->can_export()) { |
|
177 | + wp_die(__('You do not have permission to export data.', 'give'), __('Error', 'give'), array('response' => 403)); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | // Set headers |
@@ -254,8 +254,8 @@ |
||
254 | 254 | $args = array( |
255 | 255 | 'id' => 'give-api-user-search', |
256 | 256 | 'name' => 'user_id', |
257 | - ); |
|
258 | - echo Give()->html->ajax_user_search($args); ?> |
|
257 | + ); |
|
258 | + echo Give()->html->ajax_user_search($args); ?> |
|
259 | 259 | <?php submit_button( esc_html__( 'Generate New API Keys', 'give' ), 'secondary', 'submit', false ); ?> |
260 | 260 | <?php |
261 | 261 | $give_api_is_bottom = true; |
@@ -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 | /** |
@@ -53,11 +53,11 @@ discard block |
||
53 | 53 | global $status, $page; |
54 | 54 | |
55 | 55 | // Set parent defaults |
56 | - parent::__construct( array( |
|
57 | - 'singular' => esc_html__( 'API Key', 'give' ), // Singular name of the listed records |
|
58 | - 'plural' => esc_html__( 'API Keys', 'give' ), // Plural name of the listed records |
|
59 | - 'ajax' => false,// Does this table support ajax? |
|
60 | - ) ); |
|
56 | + parent::__construct(array( |
|
57 | + 'singular' => esc_html__('API Key', 'give'), // Singular name of the listed records |
|
58 | + 'plural' => esc_html__('API Keys', 'give'), // Plural name of the listed records |
|
59 | + 'ajax' => false, // Does this table support ajax? |
|
60 | + )); |
|
61 | 61 | |
62 | 62 | $this->query(); |
63 | 63 | } |
@@ -73,8 +73,8 @@ discard block |
||
73 | 73 | * |
74 | 74 | * @return string Column Name |
75 | 75 | */ |
76 | - public function column_default( $item, $column_name ) { |
|
77 | - return $item[ $column_name ]; |
|
76 | + public function column_default($item, $column_name) { |
|
77 | + return $item[$column_name]; |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
@@ -87,8 +87,8 @@ discard block |
||
87 | 87 | * |
88 | 88 | * @return string Column Name |
89 | 89 | */ |
90 | - public function column_key( $item ) { |
|
91 | - return '<input onClick="this.setSelectionRange(0, this.value.length)" readonly="readonly" type="text" class="large-text" value="' . esc_attr( $item['key'] ) . '"/>'; |
|
90 | + public function column_key($item) { |
|
91 | + return '<input onClick="this.setSelectionRange(0, this.value.length)" readonly="readonly" type="text" class="large-text" value="'.esc_attr($item['key']).'"/>'; |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | /** |
@@ -101,8 +101,8 @@ discard block |
||
101 | 101 | * |
102 | 102 | * @return string Column Name |
103 | 103 | */ |
104 | - public function column_token( $item ) { |
|
105 | - return '<input onClick="this.setSelectionRange(0, this.value.length)" readonly="readonly" type="text" class="large-text" value="' . esc_attr( $item['token'] ) . '"/>'; |
|
104 | + public function column_token($item) { |
|
105 | + return '<input onClick="this.setSelectionRange(0, this.value.length)" readonly="readonly" type="text" class="large-text" value="'.esc_attr($item['token']).'"/>'; |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | /** |
@@ -115,8 +115,8 @@ discard block |
||
115 | 115 | * |
116 | 116 | * @return string Column Name |
117 | 117 | */ |
118 | - public function column_secret( $item ) { |
|
119 | - return '<input onClick="this.setSelectionRange(0, this.value.length)" readonly="readonly" type="text" class="large-text" value="' . esc_attr( $item['secret'] ) . '"/>'; |
|
118 | + public function column_secret($item) { |
|
119 | + return '<input onClick="this.setSelectionRange(0, this.value.length)" readonly="readonly" type="text" class="large-text" value="'.esc_attr($item['secret']).'"/>'; |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | /** |
@@ -126,46 +126,46 @@ discard block |
||
126 | 126 | * @since 1.1 |
127 | 127 | * @return string |
128 | 128 | */ |
129 | - public function column_user( $item ) { |
|
129 | + public function column_user($item) { |
|
130 | 130 | |
131 | 131 | $actions = array(); |
132 | 132 | |
133 | - if ( apply_filters( 'give_api_log_requests', true ) ) { |
|
133 | + if (apply_filters('give_api_log_requests', true)) { |
|
134 | 134 | $actions['view'] = sprintf( |
135 | 135 | '<a href="%s">%s</a>', |
136 | - esc_url( add_query_arg( array( |
|
136 | + esc_url(add_query_arg(array( |
|
137 | 137 | 'section' => 'api_requests', |
138 | 138 | 'post_type' => 'give_forms', |
139 | 139 | 'page' => 'give-tools', |
140 | 140 | 'tab' => 'logs', |
141 | 141 | 's' => $item['email'], |
142 | - ), 'edit.php' ) ), |
|
143 | - esc_html__( 'View API Log', 'give' ) |
|
142 | + ), 'edit.php')), |
|
143 | + esc_html__('View API Log', 'give') |
|
144 | 144 | ); |
145 | 145 | } |
146 | 146 | |
147 | 147 | $actions['reissue'] = sprintf( |
148 | 148 | '<a href="%s" class="give-regenerate-api-key">%s</a>', |
149 | - esc_url( wp_nonce_url( add_query_arg( array( |
|
149 | + esc_url(wp_nonce_url(add_query_arg(array( |
|
150 | 150 | 'user_id' => $item['id'], |
151 | 151 | 'give_action' => 'process_api_key', |
152 | 152 | 'give_api_process' => 'regenerate', |
153 | - ) ), 'give-api-nonce' ) ), |
|
154 | - esc_html__( 'Reissue', 'give' ) |
|
153 | + )), 'give-api-nonce')), |
|
154 | + esc_html__('Reissue', 'give') |
|
155 | 155 | ); |
156 | - $actions['revoke'] = sprintf( |
|
156 | + $actions['revoke'] = sprintf( |
|
157 | 157 | '<a href="%s" class="give-revoke-api-key give-delete">%s</a>', |
158 | - esc_url( wp_nonce_url( add_query_arg( array( |
|
158 | + esc_url(wp_nonce_url(add_query_arg(array( |
|
159 | 159 | 'user_id' => $item['id'], |
160 | 160 | 'give_action' => 'process_api_key', |
161 | 161 | 'give_api_process' => 'revoke', |
162 | - ) ), 'give-api-nonce' ) ), |
|
163 | - esc_html__( 'Revoke', 'give' ) |
|
162 | + )), 'give-api-nonce')), |
|
163 | + esc_html__('Revoke', 'give') |
|
164 | 164 | ); |
165 | 165 | |
166 | - $actions = apply_filters( 'give_api_row_actions', array_filter( $actions ) ); |
|
166 | + $actions = apply_filters('give_api_row_actions', array_filter($actions)); |
|
167 | 167 | |
168 | - return sprintf( '%1$s %2$s', $item['user'], $this->row_actions( $actions ) ); |
|
168 | + return sprintf('%1$s %2$s', $item['user'], $this->row_actions($actions)); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
@@ -189,10 +189,10 @@ discard block |
||
189 | 189 | */ |
190 | 190 | public function get_columns() { |
191 | 191 | $columns = array( |
192 | - 'user' => esc_html__( 'Username', 'give' ), |
|
193 | - 'key' => esc_html__( 'Public Key', 'give' ), |
|
194 | - 'token' => esc_html__( 'Token', 'give' ), |
|
195 | - 'secret' => esc_html__( 'Secret Key', 'give' ), |
|
192 | + 'user' => esc_html__('Username', 'give'), |
|
193 | + 'key' => esc_html__('Public Key', 'give'), |
|
194 | + 'token' => esc_html__('Token', 'give'), |
|
195 | + 'secret' => esc_html__('Secret Key', 'give'), |
|
196 | 196 | ); |
197 | 197 | |
198 | 198 | return $columns; |
@@ -206,20 +206,20 @@ discard block |
||
206 | 206 | * |
207 | 207 | * @param string $which |
208 | 208 | */ |
209 | - protected function display_tablenav( $which ) { |
|
210 | - if ( 'top' === $which ) { |
|
211 | - wp_nonce_field( 'bulk-' . $this->_args['plural'] ); |
|
209 | + protected function display_tablenav($which) { |
|
210 | + if ('top' === $which) { |
|
211 | + wp_nonce_field('bulk-'.$this->_args['plural']); |
|
212 | 212 | } |
213 | 213 | ?> |
214 | - <div class="tablenav <?php echo esc_attr( $which ); ?>"> |
|
214 | + <div class="tablenav <?php echo esc_attr($which); ?>"> |
|
215 | 215 | |
216 | 216 | <div class="alignleft actions bulkactions"> |
217 | - <?php $this->bulk_actions( $which ); ?> |
|
217 | + <?php $this->bulk_actions($which); ?> |
|
218 | 218 | </div> |
219 | 219 | |
220 | 220 | <?php |
221 | - $this->extra_tablenav( $which ); |
|
222 | - $this->pagination( $which ); |
|
221 | + $this->extra_tablenav($which); |
|
222 | + $this->pagination($which); |
|
223 | 223 | ?> |
224 | 224 | |
225 | 225 | <br class="clear"/> |
@@ -237,17 +237,17 @@ discard block |
||
237 | 237 | * |
238 | 238 | * @return void |
239 | 239 | */ |
240 | - function bulk_actions( $which = '' ) { |
|
240 | + function bulk_actions($which = '') { |
|
241 | 241 | // These aren't really bulk actions but this outputs the markup in the right place. |
242 | 242 | static $give_api_is_bottom; |
243 | 243 | |
244 | - if ( $give_api_is_bottom ) { |
|
244 | + if ($give_api_is_bottom) { |
|
245 | 245 | return; |
246 | 246 | } |
247 | 247 | ?> |
248 | 248 | <input type="hidden" name="give_action" value="process_api_key"/> |
249 | 249 | <input type="hidden" name="give_api_process" value="generate"/> |
250 | - <?php wp_nonce_field( 'give-api-nonce' ); |
|
250 | + <?php wp_nonce_field('give-api-nonce'); |
|
251 | 251 | /** |
252 | 252 | * API Key user search. |
253 | 253 | */ |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | 'name' => 'user_id', |
257 | 257 | ); |
258 | 258 | echo Give()->html->ajax_user_search($args); ?> |
259 | - <?php submit_button( esc_html__( 'Generate New API Keys', 'give' ), 'secondary', 'submit', false ); ?> |
|
259 | + <?php submit_button(esc_html__('Generate New API Keys', 'give'), 'secondary', 'submit', false); ?> |
|
260 | 260 | <?php |
261 | 261 | $give_api_is_bottom = true; |
262 | 262 | } |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | * @return int Current page number |
270 | 270 | */ |
271 | 271 | public function get_paged() { |
272 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
272 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
273 | 273 | } |
274 | 274 | |
275 | 275 | /** |
@@ -280,21 +280,21 @@ discard block |
||
280 | 280 | * @return array |
281 | 281 | */ |
282 | 282 | public function query() { |
283 | - $users = get_users( array( |
|
283 | + $users = get_users(array( |
|
284 | 284 | 'meta_value' => 'give_user_secret_key', |
285 | 285 | 'number' => $this->per_page, |
286 | - 'offset' => $this->per_page * ( $this->get_paged() - 1 ), |
|
287 | - ) ); |
|
288 | - $keys = array(); |
|
289 | - |
|
290 | - foreach ( $users as $user ) { |
|
291 | - $keys[ $user->ID ]['id'] = $user->ID; |
|
292 | - $keys[ $user->ID ]['email'] = $user->user_email; |
|
293 | - $keys[ $user->ID ]['user'] = '<a href="' . add_query_arg( 'user_id', $user->ID, 'user-edit.php' ) . '"><strong>' . $user->user_login . '</strong></a>'; |
|
294 | - |
|
295 | - $keys[ $user->ID ]['key'] = Give()->api->get_user_public_key( $user->ID ); |
|
296 | - $keys[ $user->ID ]['secret'] = Give()->api->get_user_secret_key( $user->ID ); |
|
297 | - $keys[ $user->ID ]['token'] = Give()->api->get_token( $user->ID ); |
|
286 | + 'offset' => $this->per_page * ($this->get_paged() - 1), |
|
287 | + )); |
|
288 | + $keys = array(); |
|
289 | + |
|
290 | + foreach ($users as $user) { |
|
291 | + $keys[$user->ID]['id'] = $user->ID; |
|
292 | + $keys[$user->ID]['email'] = $user->user_email; |
|
293 | + $keys[$user->ID]['user'] = '<a href="'.add_query_arg('user_id', $user->ID, 'user-edit.php').'"><strong>'.$user->user_login.'</strong></a>'; |
|
294 | + |
|
295 | + $keys[$user->ID]['key'] = Give()->api->get_user_public_key($user->ID); |
|
296 | + $keys[$user->ID]['secret'] = Give()->api->get_user_secret_key($user->ID); |
|
297 | + $keys[$user->ID]['token'] = Give()->api->get_token($user->ID); |
|
298 | 298 | } |
299 | 299 | |
300 | 300 | return $keys; |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | public function total_items() { |
312 | 312 | global $wpdb; |
313 | 313 | |
314 | - if ( ! ( $total_items = Give_Cache::get( 'give_total_api_keys', true ) ) ) { |
|
314 | + if ( ! ($total_items = Give_Cache::get('give_total_api_keys', true))) { |
|
315 | 315 | $total_items = $wpdb->get_var( |
316 | 316 | $wpdb->prepare( |
317 | 317 | "SELECT count(user_id) |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | ) |
321 | 321 | ); |
322 | 322 | |
323 | - Give_Cache::set( 'give_total_api_keys', $total_items, HOUR_IN_SECONDS, true ); |
|
323 | + Give_Cache::set('give_total_api_keys', $total_items, HOUR_IN_SECONDS, true); |
|
324 | 324 | } |
325 | 325 | |
326 | 326 | return $total_items; |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | $hidden = array(); // No hidden columns |
340 | 340 | $sortable = array(); // Not sortable... for now |
341 | 341 | |
342 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
342 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
343 | 343 | |
344 | 344 | $data = $this->query(); |
345 | 345 | |
@@ -347,10 +347,10 @@ discard block |
||
347 | 347 | |
348 | 348 | $this->items = $data; |
349 | 349 | |
350 | - $this->set_pagination_args( array( |
|
350 | + $this->set_pagination_args(array( |
|
351 | 351 | 'total_items' => $total_items, |
352 | 352 | 'per_page' => $this->per_page, |
353 | - 'total_pages' => ceil( $total_items / $this->per_page ), |
|
353 | + 'total_pages' => ceil($total_items / $this->per_page), |
|
354 | 354 | ) |
355 | 355 | ); |
356 | 356 | } |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly. |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
@@ -41,20 +41,20 @@ discard block |
||
41 | 41 | public function csv_cols() { |
42 | 42 | |
43 | 43 | $cols = array( |
44 | - 'ID' => __( 'ID', 'give' ), |
|
45 | - 'post_name' => __( 'Slug', 'give' ), |
|
46 | - 'post_title' => __( 'Name', 'give' ), |
|
47 | - 'post_date' => __( 'Date Created', 'give' ), |
|
48 | - 'post_author' => __( 'Author', 'give' ), |
|
49 | - 'post_content' => __( 'Description', 'give' ), |
|
50 | - 'post_excerpt' => __( 'Excerpt', 'give' ), |
|
51 | - 'post_status' => __( 'Status', 'give' ), |
|
52 | - 'categories' => __( 'Categories', 'give' ), |
|
53 | - 'tags' => __( 'Tags', 'give' ), |
|
54 | - 'give_price' => __( 'Price', 'give' ), |
|
55 | - '_thumbnail_id' => __( 'Featured Image', 'give' ), |
|
56 | - '_give_form_sales' => __( 'Donations', 'give' ), |
|
57 | - '_give_download_earnings' => __( 'Income', 'give' ), |
|
44 | + 'ID' => __('ID', 'give'), |
|
45 | + 'post_name' => __('Slug', 'give'), |
|
46 | + 'post_title' => __('Name', 'give'), |
|
47 | + 'post_date' => __('Date Created', 'give'), |
|
48 | + 'post_author' => __('Author', 'give'), |
|
49 | + 'post_content' => __('Description', 'give'), |
|
50 | + 'post_excerpt' => __('Excerpt', 'give'), |
|
51 | + 'post_status' => __('Status', 'give'), |
|
52 | + 'categories' => __('Categories', 'give'), |
|
53 | + 'tags' => __('Tags', 'give'), |
|
54 | + 'give_price' => __('Price', 'give'), |
|
55 | + '_thumbnail_id' => __('Featured Image', 'give'), |
|
56 | + '_give_form_sales' => __('Donations', 'give'), |
|
57 | + '_give_download_earnings' => __('Income', 'give'), |
|
58 | 58 | ); |
59 | 59 | |
60 | 60 | return $cols; |
@@ -84,43 +84,43 @@ discard block |
||
84 | 84 | 'paged' => $this->step |
85 | 85 | ); |
86 | 86 | |
87 | - $forms = new WP_Query( $args ); |
|
87 | + $forms = new WP_Query($args); |
|
88 | 88 | |
89 | - if ( $forms->posts ) { |
|
90 | - foreach ( $forms->posts as $form ) { |
|
89 | + if ($forms->posts) { |
|
90 | + foreach ($forms->posts as $form) { |
|
91 | 91 | |
92 | 92 | $row = []; |
93 | 93 | |
94 | - foreach ( $this->csv_cols() as $key => $value ) { |
|
94 | + foreach ($this->csv_cols() as $key => $value) { |
|
95 | 95 | |
96 | 96 | // Setup default value/ |
97 | - $row[ $key ] = ''; |
|
97 | + $row[$key] = ''; |
|
98 | 98 | |
99 | - if ( in_array( $key, $meta ) ) { |
|
99 | + if (in_array($key, $meta)) { |
|
100 | 100 | |
101 | - switch ( $key ) { |
|
101 | + switch ($key) { |
|
102 | 102 | |
103 | 103 | case '_thumbnail_id' : |
104 | 104 | |
105 | - $image_id = get_post_thumbnail_id( $form->ID ); |
|
106 | - $row[ $key ] = wp_get_attachment_url( $image_id ); |
|
105 | + $image_id = get_post_thumbnail_id($form->ID); |
|
106 | + $row[$key] = wp_get_attachment_url($image_id); |
|
107 | 107 | |
108 | 108 | break; |
109 | 109 | |
110 | 110 | case 'give_price' : |
111 | 111 | |
112 | - if ( give_has_variable_prices( $form->ID ) ) { |
|
112 | + if (give_has_variable_prices($form->ID)) { |
|
113 | 113 | |
114 | 114 | $prices = []; |
115 | - foreach ( give_get_variable_prices( $form->ID ) as $price ) { |
|
116 | - $prices[] = $price['name'] . ': ' . $price['amount']; |
|
115 | + foreach (give_get_variable_prices($form->ID) as $price) { |
|
116 | + $prices[] = $price['name'].': '.$price['amount']; |
|
117 | 117 | } |
118 | 118 | |
119 | - $row[ $key ] = implode( ' | ', $prices ); |
|
119 | + $row[$key] = implode(' | ', $prices); |
|
120 | 120 | |
121 | 121 | } else { |
122 | 122 | |
123 | - $row[ $key ] = give_get_form_price( $form->ID ); |
|
123 | + $row[$key] = give_get_form_price($form->ID); |
|
124 | 124 | |
125 | 125 | } |
126 | 126 | |
@@ -128,44 +128,44 @@ discard block |
||
128 | 128 | |
129 | 129 | default : |
130 | 130 | |
131 | - $row[ $key ] = give_get_meta( $form->ID, $key, TRUE ); |
|
131 | + $row[$key] = give_get_meta($form->ID, $key, TRUE); |
|
132 | 132 | |
133 | 133 | break; |
134 | 134 | |
135 | 135 | } |
136 | 136 | |
137 | - } elseif ( isset( $form->$key ) ) { |
|
137 | + } elseif (isset($form->$key)) { |
|
138 | 138 | |
139 | - switch ( $key ) { |
|
139 | + switch ($key) { |
|
140 | 140 | |
141 | 141 | case 'post_author' : |
142 | 142 | |
143 | - $row[ $key ] = get_the_author_meta( 'user_login', $form->post_author ); |
|
143 | + $row[$key] = get_the_author_meta('user_login', $form->post_author); |
|
144 | 144 | |
145 | 145 | break; |
146 | 146 | |
147 | 147 | default : |
148 | 148 | |
149 | - $row[ $key ] = $form->$key; |
|
149 | + $row[$key] = $form->$key; |
|
150 | 150 | |
151 | 151 | break; |
152 | 152 | } |
153 | 153 | |
154 | - } elseif ( 'tags' == $key ) { |
|
154 | + } elseif ('tags' == $key) { |
|
155 | 155 | |
156 | - $terms = get_the_terms( $form->ID, 'form_tag' ); |
|
157 | - if ( $terms ) { |
|
158 | - $terms = wp_list_pluck( $terms, 'name' ); |
|
159 | - $row[ $key ] = implode( ' | ', $terms ); |
|
156 | + $terms = get_the_terms($form->ID, 'form_tag'); |
|
157 | + if ($terms) { |
|
158 | + $terms = wp_list_pluck($terms, 'name'); |
|
159 | + $row[$key] = implode(' | ', $terms); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | |
163 | - } elseif ( 'categories' == $key ) { |
|
163 | + } elseif ('categories' == $key) { |
|
164 | 164 | |
165 | - $terms = get_the_terms( $form->ID, 'form_category' ); |
|
166 | - if ( $terms ) { |
|
167 | - $terms = wp_list_pluck( $terms, 'name' ); |
|
168 | - $row[ $key ] = implode( ' | ', $terms ); |
|
165 | + $terms = get_the_terms($form->ID, 'form_category'); |
|
166 | + if ($terms) { |
|
167 | + $terms = wp_list_pluck($terms, 'name'); |
|
168 | + $row[$key] = implode(' | ', $terms); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | } |
@@ -176,8 +176,8 @@ discard block |
||
176 | 176 | |
177 | 177 | } |
178 | 178 | |
179 | - $data = apply_filters( 'give_export_get_data', $data ); |
|
180 | - $data = apply_filters( "give_export_get_data_{$this->export_type}", $data ); |
|
179 | + $data = apply_filters('give_export_get_data', $data); |
|
180 | + $data = apply_filters("give_export_get_data_{$this->export_type}", $data); |
|
181 | 181 | |
182 | 182 | return $data; |
183 | 183 | |
@@ -197,20 +197,20 @@ discard block |
||
197 | 197 | |
198 | 198 | $args = array( |
199 | 199 | 'post_type' => 'give_forms', |
200 | - 'posts_per_page' => - 1, |
|
200 | + 'posts_per_page' => -1, |
|
201 | 201 | 'post_status' => 'any', |
202 | 202 | 'fields' => 'ids', |
203 | 203 | ); |
204 | 204 | |
205 | - $forms = new WP_Query( $args ); |
|
205 | + $forms = new WP_Query($args); |
|
206 | 206 | $total = (int) $forms->post_count; |
207 | 207 | $percentage = 100; |
208 | 208 | |
209 | - if ( $total > 0 ) { |
|
210 | - $percentage = ( ( 30 * $this->step ) / $total ) * 100; |
|
209 | + if ($total > 0) { |
|
210 | + $percentage = ((30 * $this->step) / $total) * 100; |
|
211 | 211 | } |
212 | 212 | |
213 | - if ( $percentage > 100 ) { |
|
213 | + if ($percentage > 100) { |
|
214 | 214 | $percentage = 100; |
215 | 215 | } |
216 | 216 |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | * |
217 | 217 | * @access public |
218 | 218 | * @since 1.1 |
219 | - * @return array |
|
219 | + * @return string |
|
220 | 220 | */ |
221 | 221 | public function get_versions() { |
222 | 222 | return $this->versions; |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | * @uses Give_API::invalid_key() |
303 | 303 | * @uses Give_API::invalid_auth() |
304 | 304 | * @since 1.1 |
305 | - * @return bool |
|
305 | + * @return false|null |
|
306 | 306 | */ |
307 | 307 | private function validate_request() { |
308 | 308 | global $wp_query; |
@@ -694,7 +694,7 @@ discard block |
||
694 | 694 | * |
695 | 695 | * @param array $args Arguments to override defaults |
696 | 696 | * |
697 | - * @return array $dates |
|
697 | + * @return integer|null $dates |
|
698 | 698 | */ |
699 | 699 | public function get_dates( $args = array() ) { |
700 | 700 | $dates = array(); |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly. |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
@@ -141,27 +141,27 @@ discard block |
||
141 | 141 | 'v1' => 'GIVE_API_V1', |
142 | 142 | ); |
143 | 143 | |
144 | - foreach ( $this->get_versions() as $version => $class ) { |
|
145 | - require_once GIVE_PLUGIN_DIR . 'includes/api/class-give-api-' . $version . '.php'; |
|
144 | + foreach ($this->get_versions() as $version => $class) { |
|
145 | + require_once GIVE_PLUGIN_DIR.'includes/api/class-give-api-'.$version.'.php'; |
|
146 | 146 | } |
147 | 147 | |
148 | - add_action( 'init', array( $this, 'add_endpoint' ) ); |
|
149 | - add_action( 'wp', array( $this, 'process_query' ), - 1 ); |
|
150 | - add_filter( 'query_vars', array( $this, 'query_vars' ) ); |
|
151 | - add_action( 'show_user_profile', array( $this, 'user_key_field' ) ); |
|
152 | - add_action( 'edit_user_profile', array( $this, 'user_key_field' ) ); |
|
153 | - add_action( 'personal_options_update', array( $this, 'generate_api_key' ) ); |
|
154 | - add_action( 'edit_user_profile_update', array( $this, 'generate_api_key' ) ); |
|
155 | - add_action( 'give_process_api_key', array( $this, 'process_api_key' ) ); |
|
148 | + add_action('init', array($this, 'add_endpoint')); |
|
149 | + add_action('wp', array($this, 'process_query'), - 1); |
|
150 | + add_filter('query_vars', array($this, 'query_vars')); |
|
151 | + add_action('show_user_profile', array($this, 'user_key_field')); |
|
152 | + add_action('edit_user_profile', array($this, 'user_key_field')); |
|
153 | + add_action('personal_options_update', array($this, 'generate_api_key')); |
|
154 | + add_action('edit_user_profile_update', array($this, 'generate_api_key')); |
|
155 | + add_action('give_process_api_key', array($this, 'process_api_key')); |
|
156 | 156 | |
157 | 157 | // Setup a backwards compatibility check for user API Keys |
158 | - add_filter( 'get_user_metadata', array( $this, 'api_key_backwards_compat' ), 10, 4 ); |
|
158 | + add_filter('get_user_metadata', array($this, 'api_key_backwards_compat'), 10, 4); |
|
159 | 159 | |
160 | 160 | // Determine if JSON_PRETTY_PRINT is available |
161 | - $this->pretty_print = defined( 'JSON_PRETTY_PRINT' ) ? JSON_PRETTY_PRINT : null; |
|
161 | + $this->pretty_print = defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : null; |
|
162 | 162 | |
163 | 163 | // Allow API request logging to be turned off |
164 | - $this->log_requests = apply_filters( 'give_api_log_requests', $this->log_requests ); |
|
164 | + $this->log_requests = apply_filters('give_api_log_requests', $this->log_requests); |
|
165 | 165 | |
166 | 166 | // Setup Give_Payment_Stats instance |
167 | 167 | $this->stats = new Give_Payment_Stats(); |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | * @since 1.1 |
177 | 177 | */ |
178 | 178 | public function add_endpoint() { |
179 | - add_rewrite_endpoint( 'give-api', EP_ALL ); |
|
179 | + add_rewrite_endpoint('give-api', EP_ALL); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | /** |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | * |
190 | 190 | * @return string[] $vars New query vars |
191 | 191 | */ |
192 | - public function query_vars( $vars ) { |
|
192 | + public function query_vars($vars) { |
|
193 | 193 | |
194 | 194 | $vars[] = 'token'; |
195 | 195 | $vars[] = 'key'; |
@@ -240,11 +240,11 @@ discard block |
||
240 | 240 | */ |
241 | 241 | public function get_default_version() { |
242 | 242 | |
243 | - $version = get_option( 'give_default_api_version' ); |
|
243 | + $version = get_option('give_default_api_version'); |
|
244 | 244 | |
245 | - if ( defined( 'GIVE_API_VERSION' ) ) { |
|
245 | + if (defined('GIVE_API_VERSION')) { |
|
246 | 246 | $version = GIVE_API_VERSION; |
247 | - } elseif ( ! $version ) { |
|
247 | + } elseif ( ! $version) { |
|
248 | 248 | $version = 'v1'; |
249 | 249 | } |
250 | 250 | |
@@ -265,14 +265,14 @@ discard block |
||
265 | 265 | |
266 | 266 | $version = $wp_query->query_vars['give-api']; |
267 | 267 | |
268 | - if ( strpos( $version, '/' ) ) { |
|
268 | + if (strpos($version, '/')) { |
|
269 | 269 | |
270 | - $version = explode( '/', $version ); |
|
271 | - $version = strtolower( $version[0] ); |
|
270 | + $version = explode('/', $version); |
|
271 | + $version = strtolower($version[0]); |
|
272 | 272 | |
273 | - $wp_query->query_vars['give-api'] = str_replace( $version . '/', '', $wp_query->query_vars['give-api'] ); |
|
273 | + $wp_query->query_vars['give-api'] = str_replace($version.'/', '', $wp_query->query_vars['give-api']); |
|
274 | 274 | |
275 | - if ( array_key_exists( $version, $this->versions ) ) { |
|
275 | + if (array_key_exists($version, $this->versions)) { |
|
276 | 276 | |
277 | 277 | $this->queried_version = $version; |
278 | 278 | |
@@ -308,16 +308,16 @@ discard block |
||
308 | 308 | $this->override = false; |
309 | 309 | |
310 | 310 | // Make sure we have both user and api key |
311 | - if ( ! empty( $wp_query->query_vars['give-api'] ) && ( $wp_query->query_vars['give-api'] !== 'forms' || ! empty( $wp_query->query_vars['token'] ) ) ) { |
|
311 | + if ( ! empty($wp_query->query_vars['give-api']) && ($wp_query->query_vars['give-api'] !== 'forms' || ! empty($wp_query->query_vars['token']))) { |
|
312 | 312 | |
313 | - if ( empty( $wp_query->query_vars['token'] ) || empty( $wp_query->query_vars['key'] ) ) { |
|
313 | + if (empty($wp_query->query_vars['token']) || empty($wp_query->query_vars['key'])) { |
|
314 | 314 | $this->missing_auth(); |
315 | 315 | |
316 | 316 | return false; |
317 | 317 | } |
318 | 318 | |
319 | 319 | // Retrieve the user by public API key and ensure they exist |
320 | - if ( ! ( $user = $this->get_user( $wp_query->query_vars['key'] ) ) ) { |
|
320 | + if ( ! ($user = $this->get_user($wp_query->query_vars['key']))) { |
|
321 | 321 | |
322 | 322 | $this->invalid_key(); |
323 | 323 | |
@@ -325,11 +325,11 @@ discard block |
||
325 | 325 | |
326 | 326 | } else { |
327 | 327 | |
328 | - $token = urldecode( $wp_query->query_vars['token'] ); |
|
329 | - $secret = $this->get_user_secret_key( $user ); |
|
330 | - $public = urldecode( $wp_query->query_vars['key'] ); |
|
328 | + $token = urldecode($wp_query->query_vars['token']); |
|
329 | + $secret = $this->get_user_secret_key($user); |
|
330 | + $public = urldecode($wp_query->query_vars['key']); |
|
331 | 331 | |
332 | - if ( hash_equals( md5( $secret . $public ), $token ) ) { |
|
332 | + if (hash_equals(md5($secret.$public), $token)) { |
|
333 | 333 | $this->is_valid_request = true; |
334 | 334 | } else { |
335 | 335 | $this->invalid_auth(); |
@@ -338,9 +338,9 @@ discard block |
||
338 | 338 | } |
339 | 339 | |
340 | 340 | } |
341 | - } elseif ( ! empty( $wp_query->query_vars['give-api'] ) && $wp_query->query_vars['give-api'] === 'forms' ) { |
|
341 | + } elseif ( ! empty($wp_query->query_vars['give-api']) && $wp_query->query_vars['give-api'] === 'forms') { |
|
342 | 342 | $this->is_valid_request = true; |
343 | - $wp_query->set( 'key', 'public' ); |
|
343 | + $wp_query->set('key', 'public'); |
|
344 | 344 | } |
345 | 345 | } |
346 | 346 | |
@@ -356,25 +356,25 @@ discard block |
||
356 | 356 | * |
357 | 357 | * @return bool if user ID is found, false otherwise |
358 | 358 | */ |
359 | - public function get_user( $key = '' ) { |
|
359 | + public function get_user($key = '') { |
|
360 | 360 | global $wpdb, $wp_query; |
361 | 361 | |
362 | - if ( empty( $key ) ) { |
|
363 | - $key = urldecode( $wp_query->query_vars['key'] ); |
|
362 | + if (empty($key)) { |
|
363 | + $key = urldecode($wp_query->query_vars['key']); |
|
364 | 364 | } |
365 | 365 | |
366 | - if ( empty( $key ) ) { |
|
366 | + if (empty($key)) { |
|
367 | 367 | return false; |
368 | 368 | } |
369 | 369 | |
370 | - $user = Give_Cache::get( md5( 'give_api_user_' . $key ), true ); |
|
370 | + $user = Give_Cache::get(md5('give_api_user_'.$key), true); |
|
371 | 371 | |
372 | - if ( false === $user ) { |
|
373 | - $user = $wpdb->get_var( $wpdb->prepare( "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s LIMIT 1", $key ) ); |
|
374 | - Give_Cache::set( md5( 'give_api_user_' . $key ), $user, DAY_IN_SECONDS, true ); |
|
372 | + if (false === $user) { |
|
373 | + $user = $wpdb->get_var($wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s LIMIT 1", $key)); |
|
374 | + Give_Cache::set(md5('give_api_user_'.$key), $user, DAY_IN_SECONDS, true); |
|
375 | 375 | } |
376 | 376 | |
377 | - if ( $user != null ) { |
|
377 | + if ($user != null) { |
|
378 | 378 | $this->user_id = $user; |
379 | 379 | |
380 | 380 | return $user; |
@@ -390,19 +390,19 @@ discard block |
||
390 | 390 | * |
391 | 391 | * @return mixed|null|string |
392 | 392 | */ |
393 | - public function get_user_public_key( $user_id = 0 ) { |
|
393 | + public function get_user_public_key($user_id = 0) { |
|
394 | 394 | global $wpdb; |
395 | 395 | |
396 | - if ( empty( $user_id ) ) { |
|
396 | + if (empty($user_id)) { |
|
397 | 397 | return ''; |
398 | 398 | } |
399 | 399 | |
400 | - $cache_key = md5( 'give_api_user_public_key' . $user_id ); |
|
401 | - $user_public_key = Give_Cache::get( $cache_key, true ); |
|
400 | + $cache_key = md5('give_api_user_public_key'.$user_id); |
|
401 | + $user_public_key = Give_Cache::get($cache_key, true); |
|
402 | 402 | |
403 | - if ( empty( $user_public_key ) ) { |
|
404 | - $user_public_key = $wpdb->get_var( $wpdb->prepare( "SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_public_key' AND user_id = %d", $user_id ) ); |
|
405 | - Give_Cache::set( $cache_key, $user_public_key, HOUR_IN_SECONDS, true ); |
|
403 | + if (empty($user_public_key)) { |
|
404 | + $user_public_key = $wpdb->get_var($wpdb->prepare("SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_public_key' AND user_id = %d", $user_id)); |
|
405 | + Give_Cache::set($cache_key, $user_public_key, HOUR_IN_SECONDS, true); |
|
406 | 406 | } |
407 | 407 | |
408 | 408 | return $user_public_key; |
@@ -415,19 +415,19 @@ discard block |
||
415 | 415 | * |
416 | 416 | * @return mixed|null|string |
417 | 417 | */ |
418 | - public function get_user_secret_key( $user_id = 0 ) { |
|
418 | + public function get_user_secret_key($user_id = 0) { |
|
419 | 419 | global $wpdb; |
420 | 420 | |
421 | - if ( empty( $user_id ) ) { |
|
421 | + if (empty($user_id)) { |
|
422 | 422 | return ''; |
423 | 423 | } |
424 | 424 | |
425 | - $cache_key = md5( 'give_api_user_secret_key' . $user_id ); |
|
426 | - $user_secret_key = Give_Cache::get( $cache_key, true ); |
|
425 | + $cache_key = md5('give_api_user_secret_key'.$user_id); |
|
426 | + $user_secret_key = Give_Cache::get($cache_key, true); |
|
427 | 427 | |
428 | - if ( empty( $user_secret_key ) ) { |
|
429 | - $user_secret_key = $wpdb->get_var( $wpdb->prepare( "SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_secret_key' AND user_id = %d", $user_id ) ); |
|
430 | - Give_Cache::set( $cache_key, $user_secret_key, HOUR_IN_SECONDS, true ); |
|
428 | + if (empty($user_secret_key)) { |
|
429 | + $user_secret_key = $wpdb->get_var($wpdb->prepare("SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_secret_key' AND user_id = %d", $user_id)); |
|
430 | + Give_Cache::set($cache_key, $user_secret_key, HOUR_IN_SECONDS, true); |
|
431 | 431 | } |
432 | 432 | |
433 | 433 | return $user_secret_key; |
@@ -443,10 +443,10 @@ discard block |
||
443 | 443 | */ |
444 | 444 | private function missing_auth() { |
445 | 445 | $error = array(); |
446 | - $error['error'] = __( 'You must specify both a token and API key.', 'give' ); |
|
446 | + $error['error'] = __('You must specify both a token and API key.', 'give'); |
|
447 | 447 | |
448 | 448 | $this->data = $error; |
449 | - $this->output( 401 ); |
|
449 | + $this->output(401); |
|
450 | 450 | } |
451 | 451 | |
452 | 452 | /** |
@@ -460,10 +460,10 @@ discard block |
||
460 | 460 | */ |
461 | 461 | private function invalid_auth() { |
462 | 462 | $error = array(); |
463 | - $error['error'] = __( 'Your request could not be authenticated.', 'give' ); |
|
463 | + $error['error'] = __('Your request could not be authenticated.', 'give'); |
|
464 | 464 | |
465 | 465 | $this->data = $error; |
466 | - $this->output( 403 ); |
|
466 | + $this->output(403); |
|
467 | 467 | } |
468 | 468 | |
469 | 469 | /** |
@@ -477,10 +477,10 @@ discard block |
||
477 | 477 | */ |
478 | 478 | private function invalid_key() { |
479 | 479 | $error = array(); |
480 | - $error['error'] = __( 'Invalid API key.', 'give' ); |
|
480 | + $error['error'] = __('Invalid API key.', 'give'); |
|
481 | 481 | |
482 | 482 | $this->data = $error; |
483 | - $this->output( 403 ); |
|
483 | + $this->output(403); |
|
484 | 484 | } |
485 | 485 | |
486 | 486 | /** |
@@ -493,10 +493,10 @@ discard block |
||
493 | 493 | */ |
494 | 494 | private function invalid_version() { |
495 | 495 | $error = array(); |
496 | - $error['error'] = __( 'Invalid API version.', 'give' ); |
|
496 | + $error['error'] = __('Invalid API version.', 'give'); |
|
497 | 497 | |
498 | 498 | $this->data = $error; |
499 | - $this->output( 404 ); |
|
499 | + $this->output(404); |
|
500 | 500 | } |
501 | 501 | |
502 | 502 | /** |
@@ -512,10 +512,10 @@ discard block |
||
512 | 512 | global $wp_query; |
513 | 513 | |
514 | 514 | // Start logging how long the request takes for logging |
515 | - $before = microtime( true ); |
|
515 | + $before = microtime(true); |
|
516 | 516 | |
517 | 517 | // Check for give-api var. Get out if not present |
518 | - if ( empty( $wp_query->query_vars['give-api'] ) ) { |
|
518 | + if (empty($wp_query->query_vars['give-api'])) { |
|
519 | 519 | return; |
520 | 520 | } |
521 | 521 | |
@@ -529,45 +529,45 @@ discard block |
||
529 | 529 | $this->validate_request(); |
530 | 530 | |
531 | 531 | // Only proceed if no errors have been noted |
532 | - if ( ! $this->is_valid_request ) { |
|
532 | + if ( ! $this->is_valid_request) { |
|
533 | 533 | return; |
534 | 534 | } |
535 | 535 | |
536 | - if ( ! defined( 'GIVE_DOING_API' ) ) { |
|
537 | - define( 'GIVE_DOING_API', true ); |
|
536 | + if ( ! defined('GIVE_DOING_API')) { |
|
537 | + define('GIVE_DOING_API', true); |
|
538 | 538 | } |
539 | 539 | |
540 | 540 | $data = array(); |
541 | 541 | $this->routes = new $this->versions[$this->get_queried_version()]; |
542 | 542 | $this->routes->validate_request(); |
543 | 543 | |
544 | - switch ( $this->endpoint ) : |
|
544 | + switch ($this->endpoint) : |
|
545 | 545 | |
546 | 546 | case 'stats' : |
547 | 547 | |
548 | - $data = $this->routes->get_stats( array( |
|
549 | - 'type' => isset( $wp_query->query_vars['type'] ) ? $wp_query->query_vars['type'] : null, |
|
550 | - 'form' => isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null, |
|
551 | - 'date' => isset( $wp_query->query_vars['date'] ) ? $wp_query->query_vars['date'] : null, |
|
552 | - 'startdate' => isset( $wp_query->query_vars['startdate'] ) ? $wp_query->query_vars['startdate'] : null, |
|
553 | - 'enddate' => isset( $wp_query->query_vars['enddate'] ) ? $wp_query->query_vars['enddate'] : null, |
|
554 | - ) ); |
|
548 | + $data = $this->routes->get_stats(array( |
|
549 | + 'type' => isset($wp_query->query_vars['type']) ? $wp_query->query_vars['type'] : null, |
|
550 | + 'form' => isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null, |
|
551 | + 'date' => isset($wp_query->query_vars['date']) ? $wp_query->query_vars['date'] : null, |
|
552 | + 'startdate' => isset($wp_query->query_vars['startdate']) ? $wp_query->query_vars['startdate'] : null, |
|
553 | + 'enddate' => isset($wp_query->query_vars['enddate']) ? $wp_query->query_vars['enddate'] : null, |
|
554 | + )); |
|
555 | 555 | |
556 | 556 | break; |
557 | 557 | |
558 | 558 | case 'forms' : |
559 | 559 | |
560 | - $form = isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null; |
|
560 | + $form = isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null; |
|
561 | 561 | |
562 | - $data = $this->routes->get_forms( $form ); |
|
562 | + $data = $this->routes->get_forms($form); |
|
563 | 563 | |
564 | 564 | break; |
565 | 565 | |
566 | 566 | case 'donors' : |
567 | 567 | |
568 | - $donor = isset( $wp_query->query_vars['donor'] ) ? $wp_query->query_vars['donor'] : null; |
|
568 | + $donor = isset($wp_query->query_vars['donor']) ? $wp_query->query_vars['donor'] : null; |
|
569 | 569 | |
570 | - $data = $this->routes->get_donors( $donor ); |
|
570 | + $data = $this->routes->get_donors($donor); |
|
571 | 571 | |
572 | 572 | break; |
573 | 573 | |
@@ -580,26 +580,26 @@ discard block |
||
580 | 580 | * @params date startdate | required when date = range and format to be YYYYMMDD (i.e. 20170524) |
581 | 581 | * @params date enddate | required when date = range and format to be YYYYMMDD (i.e. 20170524) |
582 | 582 | */ |
583 | - $data = $this->routes->get_recent_donations( array( |
|
584 | - 'id' => isset( $wp_query->query_vars['id'] ) ? $wp_query->query_vars['id'] : null, |
|
585 | - 'date' => isset( $wp_query->query_vars['date'] ) ? $wp_query->query_vars['date'] : null, |
|
586 | - 'startdate' => isset( $wp_query->query_vars['startdate'] ) ? $wp_query->query_vars['startdate'] : null, |
|
587 | - 'enddate' => isset( $wp_query->query_vars['enddate'] ) ? $wp_query->query_vars['enddate'] : null, |
|
588 | - ) ); |
|
583 | + $data = $this->routes->get_recent_donations(array( |
|
584 | + 'id' => isset($wp_query->query_vars['id']) ? $wp_query->query_vars['id'] : null, |
|
585 | + 'date' => isset($wp_query->query_vars['date']) ? $wp_query->query_vars['date'] : null, |
|
586 | + 'startdate' => isset($wp_query->query_vars['startdate']) ? $wp_query->query_vars['startdate'] : null, |
|
587 | + 'enddate' => isset($wp_query->query_vars['enddate']) ? $wp_query->query_vars['enddate'] : null, |
|
588 | + )); |
|
589 | 589 | |
590 | 590 | break; |
591 | 591 | |
592 | 592 | endswitch; |
593 | 593 | |
594 | 594 | // Allow extensions to setup their own return data |
595 | - $this->data = apply_filters( 'give_api_output_data', $data, $this->endpoint, $this ); |
|
595 | + $this->data = apply_filters('give_api_output_data', $data, $this->endpoint, $this); |
|
596 | 596 | |
597 | - $after = microtime( true ); |
|
598 | - $request_time = ( $after - $before ); |
|
597 | + $after = microtime(true); |
|
598 | + $request_time = ($after - $before); |
|
599 | 599 | $this->data['request_speed'] = $request_time; |
600 | 600 | |
601 | 601 | // Log this API request, if enabled. We log it here because we have access to errors. |
602 | - $this->log_request( $this->data ); |
|
602 | + $this->log_request($this->data); |
|
603 | 603 | |
604 | 604 | // Send out data to the output function |
605 | 605 | $this->output(); |
@@ -629,25 +629,25 @@ discard block |
||
629 | 629 | global $wp_query; |
630 | 630 | |
631 | 631 | // Whitelist our query options |
632 | - $accepted = apply_filters( 'give_api_valid_query_modes', array( |
|
632 | + $accepted = apply_filters('give_api_valid_query_modes', array( |
|
633 | 633 | 'stats', |
634 | 634 | 'forms', |
635 | 635 | 'donors', |
636 | 636 | 'donations', |
637 | - ) ); |
|
637 | + )); |
|
638 | 638 | |
639 | - $query = isset( $wp_query->query_vars['give-api'] ) ? $wp_query->query_vars['give-api'] : null; |
|
640 | - $query = str_replace( $this->queried_version . '/', '', $query ); |
|
639 | + $query = isset($wp_query->query_vars['give-api']) ? $wp_query->query_vars['give-api'] : null; |
|
640 | + $query = str_replace($this->queried_version.'/', '', $query); |
|
641 | 641 | |
642 | 642 | $error = array(); |
643 | 643 | |
644 | 644 | // Make sure our query is valid |
645 | - if ( ! in_array( $query, $accepted ) ) { |
|
646 | - $error['error'] = __( 'Invalid query.', 'give' ); |
|
645 | + if ( ! in_array($query, $accepted)) { |
|
646 | + $error['error'] = __('Invalid query.', 'give'); |
|
647 | 647 | |
648 | 648 | $this->data = $error; |
649 | 649 | // 400 is Bad Request |
650 | - $this->output( 400 ); |
|
650 | + $this->output(400); |
|
651 | 651 | } |
652 | 652 | |
653 | 653 | $this->endpoint = $query; |
@@ -664,7 +664,7 @@ discard block |
||
664 | 664 | public function get_paged() { |
665 | 665 | global $wp_query; |
666 | 666 | |
667 | - return isset( $wp_query->query_vars['page'] ) ? $wp_query->query_vars['page'] : 1; |
|
667 | + return isset($wp_query->query_vars['page']) ? $wp_query->query_vars['page'] : 1; |
|
668 | 668 | } |
669 | 669 | |
670 | 670 | |
@@ -679,13 +679,13 @@ discard block |
||
679 | 679 | public function per_page() { |
680 | 680 | global $wp_query; |
681 | 681 | |
682 | - $per_page = isset( $wp_query->query_vars['number'] ) ? $wp_query->query_vars['number'] : 10; |
|
682 | + $per_page = isset($wp_query->query_vars['number']) ? $wp_query->query_vars['number'] : 10; |
|
683 | 683 | |
684 | - if ( $per_page < 0 && $this->get_query_mode() == 'donors' ) { |
|
684 | + if ($per_page < 0 && $this->get_query_mode() == 'donors') { |
|
685 | 685 | $per_page = 99999999; |
686 | 686 | } // End if(). |
687 | 687 | |
688 | - return apply_filters( 'give_api_results_per_page', $per_page ); |
|
688 | + return apply_filters('give_api_results_per_page', $per_page); |
|
689 | 689 | } |
690 | 690 | |
691 | 691 | /** |
@@ -698,7 +698,7 @@ discard block |
||
698 | 698 | * |
699 | 699 | * @return array $dates |
700 | 700 | */ |
701 | - public function get_dates( $args = array() ) { |
|
701 | + public function get_dates($args = array()) { |
|
702 | 702 | $dates = array(); |
703 | 703 | |
704 | 704 | $defaults = array( |
@@ -709,60 +709,60 @@ discard block |
||
709 | 709 | 'enddate' => null, |
710 | 710 | ); |
711 | 711 | |
712 | - $args = wp_parse_args( $args, $defaults ); |
|
712 | + $args = wp_parse_args($args, $defaults); |
|
713 | 713 | |
714 | - $current_time = current_time( 'timestamp' ); |
|
714 | + $current_time = current_time('timestamp'); |
|
715 | 715 | |
716 | - if ( 'range' === $args['date'] ) { |
|
717 | - $startdate = strtotime( $args['startdate'] ); |
|
718 | - $enddate = strtotime( $args['enddate'] ); |
|
719 | - $dates['day_start'] = date( 'd', $startdate ); |
|
720 | - $dates['day_end'] = date( 'd', $enddate ); |
|
721 | - $dates['m_start'] = date( 'n', $startdate ); |
|
722 | - $dates['m_end'] = date( 'n', $enddate ); |
|
723 | - $dates['year'] = date( 'Y', $startdate ); |
|
724 | - $dates['year_end'] = date( 'Y', $enddate ); |
|
716 | + if ('range' === $args['date']) { |
|
717 | + $startdate = strtotime($args['startdate']); |
|
718 | + $enddate = strtotime($args['enddate']); |
|
719 | + $dates['day_start'] = date('d', $startdate); |
|
720 | + $dates['day_end'] = date('d', $enddate); |
|
721 | + $dates['m_start'] = date('n', $startdate); |
|
722 | + $dates['m_end'] = date('n', $enddate); |
|
723 | + $dates['year'] = date('Y', $startdate); |
|
724 | + $dates['year_end'] = date('Y', $enddate); |
|
725 | 725 | } else { |
726 | 726 | // Modify dates based on predefined ranges |
727 | - switch ( $args['date'] ) : |
|
727 | + switch ($args['date']) : |
|
728 | 728 | |
729 | 729 | case 'this_month' : |
730 | 730 | $dates['day'] = null; |
731 | - $dates['m_start'] = date( 'n', $current_time ); |
|
732 | - $dates['m_end'] = date( 'n', $current_time ); |
|
733 | - $dates['year'] = date( 'Y', $current_time ); |
|
731 | + $dates['m_start'] = date('n', $current_time); |
|
732 | + $dates['m_end'] = date('n', $current_time); |
|
733 | + $dates['year'] = date('Y', $current_time); |
|
734 | 734 | break; |
735 | 735 | |
736 | 736 | case 'last_month' : |
737 | 737 | $dates['day'] = null; |
738 | - $dates['m_start'] = date( 'n', $current_time ) == 1 ? 12 : date( 'n', $current_time ) - 1; |
|
738 | + $dates['m_start'] = date('n', $current_time) == 1 ? 12 : date('n', $current_time) - 1; |
|
739 | 739 | $dates['m_end'] = $dates['m_start']; |
740 | - $dates['year'] = date( 'n', $current_time ) == 1 ? date( 'Y', $current_time ) - 1 : date( 'Y', $current_time ); |
|
740 | + $dates['year'] = date('n', $current_time) == 1 ? date('Y', $current_time) - 1 : date('Y', $current_time); |
|
741 | 741 | break; |
742 | 742 | |
743 | 743 | case 'today' : |
744 | - $dates['day'] = date( 'd', $current_time ); |
|
745 | - $dates['m_start'] = date( 'n', $current_time ); |
|
746 | - $dates['m_end'] = date( 'n', $current_time ); |
|
747 | - $dates['year'] = date( 'Y', $current_time ); |
|
744 | + $dates['day'] = date('d', $current_time); |
|
745 | + $dates['m_start'] = date('n', $current_time); |
|
746 | + $dates['m_end'] = date('n', $current_time); |
|
747 | + $dates['year'] = date('Y', $current_time); |
|
748 | 748 | break; |
749 | 749 | |
750 | 750 | case 'yesterday' : |
751 | 751 | |
752 | - $year = date( 'Y', $current_time ); |
|
753 | - $month = date( 'n', $current_time ); |
|
754 | - $day = date( 'd', $current_time ); |
|
752 | + $year = date('Y', $current_time); |
|
753 | + $month = date('n', $current_time); |
|
754 | + $day = date('d', $current_time); |
|
755 | 755 | |
756 | - if ( $month == 1 && $day == 1 ) { |
|
756 | + if ($month == 1 && $day == 1) { |
|
757 | 757 | |
758 | - $year -= 1; |
|
758 | + $year -= 1; |
|
759 | 759 | $month = 12; |
760 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
760 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
761 | 761 | |
762 | - } elseif ( $month > 1 && $day == 1 ) { |
|
762 | + } elseif ($month > 1 && $day == 1) { |
|
763 | 763 | |
764 | 764 | $month -= 1; |
765 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
765 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
766 | 766 | |
767 | 767 | } else { |
768 | 768 | |
@@ -778,65 +778,65 @@ discard block |
||
778 | 778 | break; |
779 | 779 | |
780 | 780 | case 'this_quarter' : |
781 | - $month_now = date( 'n', $current_time ); |
|
781 | + $month_now = date('n', $current_time); |
|
782 | 782 | |
783 | 783 | $dates['day'] = null; |
784 | 784 | |
785 | - if ( $month_now <= 3 ) { |
|
785 | + if ($month_now <= 3) { |
|
786 | 786 | |
787 | 787 | $dates['m_start'] = 1; |
788 | 788 | $dates['m_end'] = 3; |
789 | - $dates['year'] = date( 'Y', $current_time ); |
|
789 | + $dates['year'] = date('Y', $current_time); |
|
790 | 790 | |
791 | - } elseif ( $month_now <= 6 ) { |
|
791 | + } elseif ($month_now <= 6) { |
|
792 | 792 | |
793 | 793 | $dates['m_start'] = 4; |
794 | 794 | $dates['m_end'] = 6; |
795 | - $dates['year'] = date( 'Y', $current_time ); |
|
795 | + $dates['year'] = date('Y', $current_time); |
|
796 | 796 | |
797 | - } elseif ( $month_now <= 9 ) { |
|
797 | + } elseif ($month_now <= 9) { |
|
798 | 798 | |
799 | 799 | $dates['m_start'] = 7; |
800 | 800 | $dates['m_end'] = 9; |
801 | - $dates['year'] = date( 'Y', $current_time ); |
|
801 | + $dates['year'] = date('Y', $current_time); |
|
802 | 802 | |
803 | 803 | } else { |
804 | 804 | |
805 | 805 | $dates['m_start'] = 10; |
806 | 806 | $dates['m_end'] = 12; |
807 | - $dates['year'] = date( 'Y', $current_time ); |
|
807 | + $dates['year'] = date('Y', $current_time); |
|
808 | 808 | |
809 | 809 | } |
810 | 810 | break; |
811 | 811 | |
812 | 812 | case 'last_quarter' : |
813 | - $month_now = date( 'n', $current_time ); |
|
813 | + $month_now = date('n', $current_time); |
|
814 | 814 | |
815 | 815 | $dates['day'] = null; |
816 | 816 | |
817 | - if ( $month_now <= 3 ) { |
|
817 | + if ($month_now <= 3) { |
|
818 | 818 | |
819 | 819 | $dates['m_start'] = 10; |
820 | 820 | $dates['m_end'] = 12; |
821 | - $dates['year'] = date( 'Y', $current_time ) - 1; // Previous year |
|
821 | + $dates['year'] = date('Y', $current_time) - 1; // Previous year |
|
822 | 822 | |
823 | - } elseif ( $month_now <= 6 ) { |
|
823 | + } elseif ($month_now <= 6) { |
|
824 | 824 | |
825 | 825 | $dates['m_start'] = 1; |
826 | 826 | $dates['m_end'] = 3; |
827 | - $dates['year'] = date( 'Y', $current_time ); |
|
827 | + $dates['year'] = date('Y', $current_time); |
|
828 | 828 | |
829 | - } elseif ( $month_now <= 9 ) { |
|
829 | + } elseif ($month_now <= 9) { |
|
830 | 830 | |
831 | 831 | $dates['m_start'] = 4; |
832 | 832 | $dates['m_end'] = 6; |
833 | - $dates['year'] = date( 'Y', $current_time ); |
|
833 | + $dates['year'] = date('Y', $current_time); |
|
834 | 834 | |
835 | 835 | } else { |
836 | 836 | |
837 | 837 | $dates['m_start'] = 7; |
838 | 838 | $dates['m_end'] = 9; |
839 | - $dates['year'] = date( 'Y', $current_time ); |
|
839 | + $dates['year'] = date('Y', $current_time); |
|
840 | 840 | |
841 | 841 | } |
842 | 842 | break; |
@@ -845,14 +845,14 @@ discard block |
||
845 | 845 | $dates['day'] = null; |
846 | 846 | $dates['m_start'] = null; |
847 | 847 | $dates['m_end'] = null; |
848 | - $dates['year'] = date( 'Y', $current_time ); |
|
848 | + $dates['year'] = date('Y', $current_time); |
|
849 | 849 | break; |
850 | 850 | |
851 | 851 | case 'last_year' : |
852 | 852 | $dates['day'] = null; |
853 | 853 | $dates['m_start'] = null; |
854 | 854 | $dates['m_end'] = null; |
855 | - $dates['year'] = date( 'Y', $current_time ) - 1; |
|
855 | + $dates['year'] = date('Y', $current_time) - 1; |
|
856 | 856 | break; |
857 | 857 | |
858 | 858 | endswitch; |
@@ -865,7 +865,7 @@ discard block |
||
865 | 865 | * |
866 | 866 | * @param array $dates The dates used for retrieving earnings. |
867 | 867 | */ |
868 | - return apply_filters( 'give_api_stat_dates', $dates ); |
|
868 | + return apply_filters('give_api_stat_dates', $dates); |
|
869 | 869 | } |
870 | 870 | |
871 | 871 | /** |
@@ -879,78 +879,78 @@ discard block |
||
879 | 879 | * |
880 | 880 | * @return array $donors Multidimensional array of the donors. |
881 | 881 | */ |
882 | - public function get_donors( $donor = null ) { |
|
882 | + public function get_donors($donor = null) { |
|
883 | 883 | |
884 | 884 | $donors = array(); |
885 | 885 | $error = array(); |
886 | - if ( ! user_can( $this->user_id, 'view_give_sensitive_data' ) && ! $this->override ) { |
|
886 | + if ( ! user_can($this->user_id, 'view_give_sensitive_data') && ! $this->override) { |
|
887 | 887 | return $donors; |
888 | 888 | } |
889 | 889 | |
890 | 890 | $paged = $this->get_paged(); |
891 | 891 | $per_page = $this->per_page(); |
892 | - $offset = $per_page * ( $paged - 1 ); |
|
892 | + $offset = $per_page * ($paged - 1); |
|
893 | 893 | |
894 | - if ( is_numeric( $donor ) ) { |
|
894 | + if (is_numeric($donor)) { |
|
895 | 895 | $field = 'id'; |
896 | 896 | } else { |
897 | 897 | $field = 'email'; |
898 | 898 | } |
899 | 899 | |
900 | - $donor_query = Give()->donors->get_donors( array( |
|
900 | + $donor_query = Give()->donors->get_donors(array( |
|
901 | 901 | 'number' => $per_page, |
902 | 902 | 'offset' => $offset, |
903 | 903 | $field => $donor, |
904 | - ) ); |
|
904 | + )); |
|
905 | 905 | $donor_count = 0; |
906 | 906 | |
907 | - if ( $donor_query ) { |
|
907 | + if ($donor_query) { |
|
908 | 908 | |
909 | - foreach ( $donor_query as $donor_obj ) { |
|
909 | + foreach ($donor_query as $donor_obj) { |
|
910 | 910 | |
911 | - $names = explode( ' ', $donor_obj->name ); |
|
912 | - $first_name = ! empty( $names[0] ) ? $names[0] : ''; |
|
911 | + $names = explode(' ', $donor_obj->name); |
|
912 | + $first_name = ! empty($names[0]) ? $names[0] : ''; |
|
913 | 913 | $last_name = ''; |
914 | - if ( ! empty( $names[1] ) ) { |
|
915 | - unset( $names[0] ); |
|
916 | - $last_name = implode( ' ', $names ); |
|
914 | + if ( ! empty($names[1])) { |
|
915 | + unset($names[0]); |
|
916 | + $last_name = implode(' ', $names); |
|
917 | 917 | } |
918 | 918 | |
919 | - $donors['donors'][ $donor_count ]['info']['user_id'] = ''; |
|
920 | - $donors['donors'][ $donor_count ]['info']['username'] = ''; |
|
921 | - $donors['donors'][ $donor_count ]['info']['display_name'] = ''; |
|
922 | - $donors['donors'][ $donor_count ]['info']['donor_id'] = $donor_obj->id; |
|
923 | - $donors['donors'][ $donor_count ]['info']['first_name'] = $first_name; |
|
924 | - $donors['donors'][ $donor_count ]['info']['last_name'] = $last_name; |
|
925 | - $donors['donors'][ $donor_count ]['info']['email'] = $donor_obj->email; |
|
919 | + $donors['donors'][$donor_count]['info']['user_id'] = ''; |
|
920 | + $donors['donors'][$donor_count]['info']['username'] = ''; |
|
921 | + $donors['donors'][$donor_count]['info']['display_name'] = ''; |
|
922 | + $donors['donors'][$donor_count]['info']['donor_id'] = $donor_obj->id; |
|
923 | + $donors['donors'][$donor_count]['info']['first_name'] = $first_name; |
|
924 | + $donors['donors'][$donor_count]['info']['last_name'] = $last_name; |
|
925 | + $donors['donors'][$donor_count]['info']['email'] = $donor_obj->email; |
|
926 | 926 | |
927 | - if ( ! empty( $donor_obj->user_id ) ) { |
|
927 | + if ( ! empty($donor_obj->user_id)) { |
|
928 | 928 | |
929 | - $user_data = get_userdata( $donor_obj->user_id ); |
|
929 | + $user_data = get_userdata($donor_obj->user_id); |
|
930 | 930 | |
931 | 931 | // Donor with registered account. |
932 | - $donors['donors'][ $donor_count ]['info']['user_id'] = $donor_obj->user_id; |
|
933 | - $donors['donors'][ $donor_count ]['info']['username'] = $user_data->user_login; |
|
934 | - $donors['donors'][ $donor_count ]['info']['display_name'] = $user_data->display_name; |
|
932 | + $donors['donors'][$donor_count]['info']['user_id'] = $donor_obj->user_id; |
|
933 | + $donors['donors'][$donor_count]['info']['username'] = $user_data->user_login; |
|
934 | + $donors['donors'][$donor_count]['info']['display_name'] = $user_data->display_name; |
|
935 | 935 | |
936 | 936 | } |
937 | 937 | |
938 | - $donors['donors'][ $donor_count ]['stats']['total_donations'] = $donor_obj->purchase_count; |
|
939 | - $donors['donors'][ $donor_count ]['stats']['total_spent'] = $donor_obj->purchase_value; |
|
938 | + $donors['donors'][$donor_count]['stats']['total_donations'] = $donor_obj->purchase_count; |
|
939 | + $donors['donors'][$donor_count]['stats']['total_spent'] = $donor_obj->purchase_value; |
|
940 | 940 | |
941 | - $donor_count ++; |
|
941 | + $donor_count++; |
|
942 | 942 | |
943 | 943 | } |
944 | - } elseif ( $donor ) { |
|
944 | + } elseif ($donor) { |
|
945 | 945 | |
946 | 946 | $error['error'] = sprintf( /* translators: %s: donor */ |
947 | - __( 'Donor %s not found.', 'give' ), $donor ); |
|
947 | + __('Donor %s not found.', 'give'), $donor ); |
|
948 | 948 | |
949 | 949 | return $error; |
950 | 950 | |
951 | 951 | } else { |
952 | 952 | |
953 | - $error['error'] = __( 'No donors found.', 'give' ); |
|
953 | + $error['error'] = __('No donors found.', 'give'); |
|
954 | 954 | |
955 | 955 | return $error; |
956 | 956 | |
@@ -969,37 +969,37 @@ discard block |
||
969 | 969 | * |
970 | 970 | * @return array $donors Multidimensional array of the forms. |
971 | 971 | */ |
972 | - public function get_forms( $form = null ) { |
|
972 | + public function get_forms($form = null) { |
|
973 | 973 | |
974 | 974 | $forms = array(); |
975 | 975 | $error = array(); |
976 | 976 | |
977 | - if ( $form == null ) { |
|
977 | + if ($form == null) { |
|
978 | 978 | $forms['forms'] = array(); |
979 | 979 | |
980 | - $form_list = get_posts( array( |
|
980 | + $form_list = get_posts(array( |
|
981 | 981 | 'post_type' => 'give_forms', |
982 | 982 | 'posts_per_page' => $this->per_page(), |
983 | 983 | 'suppress_filters' => true, |
984 | 984 | 'paged' => $this->get_paged(), |
985 | - ) ); |
|
985 | + )); |
|
986 | 986 | |
987 | - if ( $form_list ) { |
|
987 | + if ($form_list) { |
|
988 | 988 | $i = 0; |
989 | - foreach ( $form_list as $form_info ) { |
|
990 | - $forms['forms'][ $i ] = $this->get_form_data( $form_info ); |
|
991 | - $i ++; |
|
989 | + foreach ($form_list as $form_info) { |
|
990 | + $forms['forms'][$i] = $this->get_form_data($form_info); |
|
991 | + $i++; |
|
992 | 992 | } |
993 | 993 | } |
994 | 994 | } else { |
995 | - if ( get_post_type( $form ) == 'give_forms' ) { |
|
996 | - $form_info = get_post( $form ); |
|
995 | + if (get_post_type($form) == 'give_forms') { |
|
996 | + $form_info = get_post($form); |
|
997 | 997 | |
998 | - $forms['forms'][0] = $this->get_form_data( $form_info ); |
|
998 | + $forms['forms'][0] = $this->get_form_data($form_info); |
|
999 | 999 | |
1000 | 1000 | } else { |
1001 | 1001 | $error['error'] = sprintf( /* translators: %s: form */ |
1002 | - __( 'Form %s not found.', 'give' ), $form ); |
|
1002 | + __('Form %s not found.', 'give'), $form ); |
|
1003 | 1003 | |
1004 | 1004 | return $error; |
1005 | 1005 | } |
@@ -1017,7 +1017,7 @@ discard block |
||
1017 | 1017 | * |
1018 | 1018 | * @return array Array of post data to return back in the API. |
1019 | 1019 | */ |
1020 | - private function get_form_data( $form_info ) { |
|
1020 | + private function get_form_data($form_info) { |
|
1021 | 1021 | |
1022 | 1022 | $form = array(); |
1023 | 1023 | |
@@ -1027,60 +1027,60 @@ discard block |
||
1027 | 1027 | $form['info']['create_date'] = $form_info->post_date; |
1028 | 1028 | $form['info']['modified_date'] = $form_info->post_modified; |
1029 | 1029 | $form['info']['status'] = $form_info->post_status; |
1030 | - $form['info']['link'] = html_entity_decode( $form_info->guid ); |
|
1031 | - $form['info']['content'] = give_get_meta( $form_info->ID, '_give_form_content', true ); |
|
1032 | - $form['info']['thumbnail'] = wp_get_attachment_url( get_post_thumbnail_id( $form_info->ID ) ); |
|
1030 | + $form['info']['link'] = html_entity_decode($form_info->guid); |
|
1031 | + $form['info']['content'] = give_get_meta($form_info->ID, '_give_form_content', true); |
|
1032 | + $form['info']['thumbnail'] = wp_get_attachment_url(get_post_thumbnail_id($form_info->ID)); |
|
1033 | 1033 | |
1034 | - if ( give_is_setting_enabled( give_get_option( 'categories', 'disabled' ) ) ) { |
|
1035 | - $form['info']['category'] = get_the_terms( $form_info, 'give_forms_category' ); |
|
1036 | - $form['info']['tags'] = get_the_terms( $form_info, 'give_forms_tag' ); |
|
1034 | + if (give_is_setting_enabled(give_get_option('categories', 'disabled'))) { |
|
1035 | + $form['info']['category'] = get_the_terms($form_info, 'give_forms_category'); |
|
1036 | + $form['info']['tags'] = get_the_terms($form_info, 'give_forms_tag'); |
|
1037 | 1037 | } |
1038 | - if ( give_is_setting_enabled( give_get_option( 'tags', 'disabled' ) ) ) { |
|
1039 | - $form['info']['tags'] = get_the_terms( $form_info, 'give_forms_tag' ); |
|
1038 | + if (give_is_setting_enabled(give_get_option('tags', 'disabled'))) { |
|
1039 | + $form['info']['tags'] = get_the_terms($form_info, 'give_forms_tag'); |
|
1040 | 1040 | } |
1041 | 1041 | |
1042 | 1042 | // Check whether any goal is to be achieved for the donation form. |
1043 | - $goal_option = give_get_meta( $form_info->ID, '_give_goal_option', true ); |
|
1044 | - $goal_amount = give_get_meta( $form_info->ID, '_give_set_goal', true ); |
|
1045 | - if ( give_is_setting_enabled( $goal_option ) && $goal_amount ) { |
|
1046 | - $total_income = give_get_form_earnings_stats( $form_info->ID ); |
|
1047 | - $goal_percentage_completed = ( $total_income < $goal_amount ) ? round( ( $total_income / $goal_amount ) * 100, 2 ) : 100; |
|
1048 | - $form['goal']['amount'] = isset( $goal_amount ) ? $goal_amount : ''; |
|
1049 | - $form['goal']['percentage_completed'] = isset( $goal_percentage_completed ) ? $goal_percentage_completed : ''; |
|
1043 | + $goal_option = give_get_meta($form_info->ID, '_give_goal_option', true); |
|
1044 | + $goal_amount = give_get_meta($form_info->ID, '_give_set_goal', true); |
|
1045 | + if (give_is_setting_enabled($goal_option) && $goal_amount) { |
|
1046 | + $total_income = give_get_form_earnings_stats($form_info->ID); |
|
1047 | + $goal_percentage_completed = ($total_income < $goal_amount) ? round(($total_income / $goal_amount) * 100, 2) : 100; |
|
1048 | + $form['goal']['amount'] = isset($goal_amount) ? $goal_amount : ''; |
|
1049 | + $form['goal']['percentage_completed'] = isset($goal_percentage_completed) ? $goal_percentage_completed : ''; |
|
1050 | 1050 | } |
1051 | 1051 | |
1052 | - if ( user_can( $this->user_id, 'view_give_reports' ) || $this->override ) { |
|
1053 | - $form['stats']['total']['donations'] = give_get_form_sales_stats( $form_info->ID ); |
|
1054 | - $form['stats']['total']['earnings'] = give_get_form_earnings_stats( $form_info->ID ); |
|
1055 | - $form['stats']['monthly_average']['donations'] = give_get_average_monthly_form_sales( $form_info->ID ); |
|
1056 | - $form['stats']['monthly_average']['earnings'] = give_get_average_monthly_form_earnings( $form_info->ID ); |
|
1052 | + if (user_can($this->user_id, 'view_give_reports') || $this->override) { |
|
1053 | + $form['stats']['total']['donations'] = give_get_form_sales_stats($form_info->ID); |
|
1054 | + $form['stats']['total']['earnings'] = give_get_form_earnings_stats($form_info->ID); |
|
1055 | + $form['stats']['monthly_average']['donations'] = give_get_average_monthly_form_sales($form_info->ID); |
|
1056 | + $form['stats']['monthly_average']['earnings'] = give_get_average_monthly_form_earnings($form_info->ID); |
|
1057 | 1057 | } |
1058 | 1058 | |
1059 | 1059 | $counter = 0; |
1060 | - if ( give_has_variable_prices( $form_info->ID ) ) { |
|
1061 | - foreach ( give_get_variable_prices( $form_info->ID ) as $price ) { |
|
1062 | - $counter ++; |
|
1060 | + if (give_has_variable_prices($form_info->ID)) { |
|
1061 | + foreach (give_get_variable_prices($form_info->ID) as $price) { |
|
1062 | + $counter++; |
|
1063 | 1063 | // multi-level item |
1064 | - $level = isset( $price['_give_text'] ) ? $price['_give_text'] : 'level-' . $counter; |
|
1065 | - $form['pricing'][ sanitize_key( $level ) ] = $price['_give_amount']; |
|
1064 | + $level = isset($price['_give_text']) ? $price['_give_text'] : 'level-'.$counter; |
|
1065 | + $form['pricing'][sanitize_key($level)] = $price['_give_amount']; |
|
1066 | 1066 | |
1067 | 1067 | } |
1068 | 1068 | } else { |
1069 | - $form['pricing']['amount'] = give_get_form_price( $form_info->ID ); |
|
1069 | + $form['pricing']['amount'] = give_get_form_price($form_info->ID); |
|
1070 | 1070 | } |
1071 | 1071 | |
1072 | - if ( user_can( $this->user_id, 'view_give_sensitive_data' ) || $this->override ) { |
|
1072 | + if (user_can($this->user_id, 'view_give_sensitive_data') || $this->override) { |
|
1073 | 1073 | |
1074 | 1074 | /** |
1075 | 1075 | * Fires when generating API sensitive data. |
1076 | 1076 | * |
1077 | 1077 | * @since 1.1 |
1078 | 1078 | */ |
1079 | - do_action( 'give_api_sensitive_data' ); |
|
1079 | + do_action('give_api_sensitive_data'); |
|
1080 | 1080 | |
1081 | 1081 | } |
1082 | 1082 | |
1083 | - return apply_filters( 'give_api_forms_form', $form ); |
|
1083 | + return apply_filters('give_api_forms_form', $form); |
|
1084 | 1084 | |
1085 | 1085 | } |
1086 | 1086 | |
@@ -1095,7 +1095,7 @@ discard block |
||
1095 | 1095 | * |
1096 | 1096 | * @return array |
1097 | 1097 | */ |
1098 | - public function get_stats( $args = array() ) { |
|
1098 | + public function get_stats($args = array()) { |
|
1099 | 1099 | $defaults = array( |
1100 | 1100 | 'type' => null, |
1101 | 1101 | 'form' => null, |
@@ -1104,9 +1104,9 @@ discard block |
||
1104 | 1104 | 'enddate' => null, |
1105 | 1105 | ); |
1106 | 1106 | |
1107 | - $args = wp_parse_args( $args, $defaults ); |
|
1107 | + $args = wp_parse_args($args, $defaults); |
|
1108 | 1108 | |
1109 | - $dates = $this->get_dates( $args ); |
|
1109 | + $dates = $this->get_dates($args); |
|
1110 | 1110 | |
1111 | 1111 | $stats = array(); |
1112 | 1112 | $earnings = array( |
@@ -1117,40 +1117,40 @@ discard block |
||
1117 | 1117 | ); |
1118 | 1118 | $error = array(); |
1119 | 1119 | |
1120 | - if ( ! user_can( $this->user_id, 'view_give_reports' ) && ! $this->override ) { |
|
1120 | + if ( ! user_can($this->user_id, 'view_give_reports') && ! $this->override) { |
|
1121 | 1121 | return $stats; |
1122 | 1122 | } |
1123 | 1123 | |
1124 | - if ( $args['type'] == 'donations' ) { |
|
1124 | + if ($args['type'] == 'donations') { |
|
1125 | 1125 | |
1126 | - if ( $args['form'] == null ) { |
|
1127 | - if ( $args['date'] == null ) { |
|
1126 | + if ($args['form'] == null) { |
|
1127 | + if ($args['date'] == null) { |
|
1128 | 1128 | $donations = $this->get_default_sales_stats(); |
1129 | - } elseif ( $args['date'] === 'range' ) { |
|
1129 | + } elseif ($args['date'] === 'range') { |
|
1130 | 1130 | // Return donations for a date range. |
1131 | 1131 | // Ensure the end date is later than the start date. |
1132 | - if ( $args['enddate'] < $args['startdate'] ) { |
|
1133 | - $error['error'] = __( 'The end date must be later than the start date.', 'give' ); |
|
1132 | + if ($args['enddate'] < $args['startdate']) { |
|
1133 | + $error['error'] = __('The end date must be later than the start date.', 'give'); |
|
1134 | 1134 | } |
1135 | 1135 | |
1136 | 1136 | // Ensure both the start and end date are specified |
1137 | - if ( empty( $args['startdate'] ) || empty( $args['enddate'] ) ) { |
|
1138 | - $error['error'] = __( 'Invalid or no date range specified.', 'give' ); |
|
1137 | + if (empty($args['startdate']) || empty($args['enddate'])) { |
|
1138 | + $error['error'] = __('Invalid or no date range specified.', 'give'); |
|
1139 | 1139 | } |
1140 | 1140 | |
1141 | 1141 | $total = 0; |
1142 | 1142 | |
1143 | 1143 | // Loop through the years |
1144 | 1144 | $y = $dates['year']; |
1145 | - while ( $y <= $dates['year_end'] ) : |
|
1145 | + while ($y <= $dates['year_end']) : |
|
1146 | 1146 | |
1147 | - if ( $dates['year'] == $dates['year_end'] ) { |
|
1147 | + if ($dates['year'] == $dates['year_end']) { |
|
1148 | 1148 | $month_start = $dates['m_start']; |
1149 | 1149 | $month_end = $dates['m_end']; |
1150 | - } elseif ( $y == $dates['year'] && $dates['year_end'] > $dates['year'] ) { |
|
1150 | + } elseif ($y == $dates['year'] && $dates['year_end'] > $dates['year']) { |
|
1151 | 1151 | $month_start = $dates['m_start']; |
1152 | 1152 | $month_end = 12; |
1153 | - } elseif ( $y == $dates['year_end'] ) { |
|
1153 | + } elseif ($y == $dates['year_end']) { |
|
1154 | 1154 | $month_start = 1; |
1155 | 1155 | $month_end = $dates['m_end']; |
1156 | 1156 | } else { |
@@ -1159,116 +1159,116 @@ discard block |
||
1159 | 1159 | } |
1160 | 1160 | |
1161 | 1161 | $i = $month_start; |
1162 | - while ( $i <= $month_end ) : |
|
1162 | + while ($i <= $month_end) : |
|
1163 | 1163 | |
1164 | - if ( $i == $dates['m_start'] ) { |
|
1164 | + if ($i == $dates['m_start']) { |
|
1165 | 1165 | $d = $dates['day_start']; |
1166 | 1166 | } else { |
1167 | 1167 | $d = 1; |
1168 | 1168 | } |
1169 | 1169 | |
1170 | - if ( $i == $dates['m_end'] ) { |
|
1170 | + if ($i == $dates['m_end']) { |
|
1171 | 1171 | $num_of_days = $dates['day_end']; |
1172 | 1172 | } else { |
1173 | - $num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y ); |
|
1173 | + $num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y); |
|
1174 | 1174 | } |
1175 | 1175 | |
1176 | - while ( $d <= $num_of_days ) : |
|
1177 | - $sale_count = give_get_sales_by_date( $d, $i, $y ); |
|
1178 | - $date_key = date( 'Ymd', strtotime( $y . '/' . $i . '/' . $d ) ); |
|
1179 | - if ( ! isset( $donations['sales'][ $date_key ] ) ) { |
|
1180 | - $donations['sales'][ $date_key ] = 0; |
|
1176 | + while ($d <= $num_of_days) : |
|
1177 | + $sale_count = give_get_sales_by_date($d, $i, $y); |
|
1178 | + $date_key = date('Ymd', strtotime($y.'/'.$i.'/'.$d)); |
|
1179 | + if ( ! isset($donations['sales'][$date_key])) { |
|
1180 | + $donations['sales'][$date_key] = 0; |
|
1181 | 1181 | } |
1182 | - $donations['sales'][ $date_key ] += $sale_count; |
|
1182 | + $donations['sales'][$date_key] += $sale_count; |
|
1183 | 1183 | $total += $sale_count; |
1184 | - $d ++; |
|
1184 | + $d++; |
|
1185 | 1185 | endwhile; |
1186 | - $i ++; |
|
1186 | + $i++; |
|
1187 | 1187 | endwhile; |
1188 | 1188 | |
1189 | - $y ++; |
|
1189 | + $y++; |
|
1190 | 1190 | endwhile; |
1191 | 1191 | |
1192 | 1192 | $donations['totals'] = $total; |
1193 | 1193 | } else { |
1194 | - if ( $args['date'] == 'this_quarter' || $args['date'] == 'last_quarter' ) { |
|
1194 | + if ($args['date'] == 'this_quarter' || $args['date'] == 'last_quarter') { |
|
1195 | 1195 | $donations_count = 0; |
1196 | 1196 | |
1197 | 1197 | // Loop through the months |
1198 | 1198 | $month = $dates['m_start']; |
1199 | 1199 | |
1200 | - while ( $month <= $dates['m_end'] ) : |
|
1201 | - $donations_count += give_get_sales_by_date( null, $month, $dates['year'] ); |
|
1202 | - $month ++; |
|
1200 | + while ($month <= $dates['m_end']) : |
|
1201 | + $donations_count += give_get_sales_by_date(null, $month, $dates['year']); |
|
1202 | + $month++; |
|
1203 | 1203 | endwhile; |
1204 | 1204 | |
1205 | - $donations['donations'][ $args['date'] ] = $donations_count; |
|
1205 | + $donations['donations'][$args['date']] = $donations_count; |
|
1206 | 1206 | } else { |
1207 | - $donations['donations'][ $args['date'] ] = give_get_sales_by_date( $dates['day'], $dates['m_start'], $dates['year'] ); |
|
1207 | + $donations['donations'][$args['date']] = give_get_sales_by_date($dates['day'], $dates['m_start'], $dates['year']); |
|
1208 | 1208 | } |
1209 | 1209 | }// End if(). |
1210 | - } elseif ( $args['form'] == 'all' ) { |
|
1211 | - $forms = get_posts( array( |
|
1210 | + } elseif ($args['form'] == 'all') { |
|
1211 | + $forms = get_posts(array( |
|
1212 | 1212 | 'post_type' => 'give_forms', |
1213 | 1213 | 'nopaging' => true, |
1214 | - ) ); |
|
1215 | - $i = 0; |
|
1216 | - foreach ( $forms as $form_info ) { |
|
1217 | - $donations['donations'][ $i ] = array( |
|
1218 | - $form_info->post_name => give_get_form_sales_stats( $form_info->ID ), |
|
1214 | + )); |
|
1215 | + $i = 0; |
|
1216 | + foreach ($forms as $form_info) { |
|
1217 | + $donations['donations'][$i] = array( |
|
1218 | + $form_info->post_name => give_get_form_sales_stats($form_info->ID), |
|
1219 | 1219 | ); |
1220 | - $i ++; |
|
1220 | + $i++; |
|
1221 | 1221 | } |
1222 | 1222 | } else { |
1223 | - if ( get_post_type( $args['form'] ) == 'give_forms' ) { |
|
1224 | - $form_info = get_post( $args['form'] ); |
|
1223 | + if (get_post_type($args['form']) == 'give_forms') { |
|
1224 | + $form_info = get_post($args['form']); |
|
1225 | 1225 | $donations['donations'][0] = array( |
1226 | - $form_info->post_name => give_get_form_sales_stats( $args['form'] ), |
|
1226 | + $form_info->post_name => give_get_form_sales_stats($args['form']), |
|
1227 | 1227 | ); |
1228 | 1228 | } else { |
1229 | 1229 | $error['error'] = sprintf( /* translators: %s: form */ |
1230 | - __( 'Form %s not found.', 'give' ), $args['form'] ); |
|
1230 | + __('Form %s not found.', 'give'), $args['form'] ); |
|
1231 | 1231 | } |
1232 | 1232 | }// End if(). |
1233 | 1233 | |
1234 | - if ( ! empty( $error ) ) { |
|
1234 | + if ( ! empty($error)) { |
|
1235 | 1235 | return $error; |
1236 | 1236 | } |
1237 | 1237 | |
1238 | 1238 | return $donations; |
1239 | 1239 | |
1240 | - } elseif ( $args['type'] == 'earnings' ) { |
|
1241 | - if ( $args['form'] == null ) { |
|
1242 | - if ( $args['date'] == null ) { |
|
1240 | + } elseif ($args['type'] == 'earnings') { |
|
1241 | + if ($args['form'] == null) { |
|
1242 | + if ($args['date'] == null) { |
|
1243 | 1243 | $earnings = $this->get_default_earnings_stats(); |
1244 | - } elseif ( $args['date'] === 'range' ) { |
|
1244 | + } elseif ($args['date'] === 'range') { |
|
1245 | 1245 | // Return sales for a date range |
1246 | 1246 | // Ensure the end date is later than the start date |
1247 | - if ( $args['enddate'] < $args['startdate'] ) { |
|
1248 | - $error['error'] = __( 'The end date must be later than the start date.', 'give' ); |
|
1247 | + if ($args['enddate'] < $args['startdate']) { |
|
1248 | + $error['error'] = __('The end date must be later than the start date.', 'give'); |
|
1249 | 1249 | } |
1250 | 1250 | |
1251 | 1251 | // Ensure both the start and end date are specified |
1252 | - if ( empty( $args['startdate'] ) || empty( $args['enddate'] ) ) { |
|
1253 | - $error['error'] = __( 'Invalid or no date range specified.', 'give' ); |
|
1252 | + if (empty($args['startdate']) || empty($args['enddate'])) { |
|
1253 | + $error['error'] = __('Invalid or no date range specified.', 'give'); |
|
1254 | 1254 | } |
1255 | 1255 | |
1256 | 1256 | $total = (float) 0.00; |
1257 | 1257 | |
1258 | 1258 | // Loop through the years |
1259 | 1259 | $y = $dates['year']; |
1260 | - if ( ! isset( $earnings['earnings'] ) ) { |
|
1260 | + if ( ! isset($earnings['earnings'])) { |
|
1261 | 1261 | $earnings['earnings'] = array(); |
1262 | 1262 | } |
1263 | - while ( $y <= $dates['year_end'] ) : |
|
1263 | + while ($y <= $dates['year_end']) : |
|
1264 | 1264 | |
1265 | - if ( $dates['year'] == $dates['year_end'] ) { |
|
1265 | + if ($dates['year'] == $dates['year_end']) { |
|
1266 | 1266 | $month_start = $dates['m_start']; |
1267 | 1267 | $month_end = $dates['m_end']; |
1268 | - } elseif ( $y == $dates['year'] && $dates['year_end'] > $dates['year'] ) { |
|
1268 | + } elseif ($y == $dates['year'] && $dates['year_end'] > $dates['year']) { |
|
1269 | 1269 | $month_start = $dates['m_start']; |
1270 | 1270 | $month_end = 12; |
1271 | - } elseif ( $y == $dates['year_end'] ) { |
|
1271 | + } elseif ($y == $dates['year_end']) { |
|
1272 | 1272 | $month_start = 1; |
1273 | 1273 | $month_end = $dates['m_end']; |
1274 | 1274 | } else { |
@@ -1277,94 +1277,94 @@ discard block |
||
1277 | 1277 | } |
1278 | 1278 | |
1279 | 1279 | $i = $month_start; |
1280 | - while ( $i <= $month_end ) : |
|
1280 | + while ($i <= $month_end) : |
|
1281 | 1281 | |
1282 | - if ( $i == $dates['m_start'] ) { |
|
1282 | + if ($i == $dates['m_start']) { |
|
1283 | 1283 | $d = $dates['day_start']; |
1284 | 1284 | } else { |
1285 | 1285 | $d = 1; |
1286 | 1286 | } |
1287 | 1287 | |
1288 | - if ( $i == $dates['m_end'] ) { |
|
1288 | + if ($i == $dates['m_end']) { |
|
1289 | 1289 | $num_of_days = $dates['day_end']; |
1290 | 1290 | } else { |
1291 | - $num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y ); |
|
1291 | + $num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y); |
|
1292 | 1292 | } |
1293 | 1293 | |
1294 | - while ( $d <= $num_of_days ) : |
|
1295 | - $earnings_stat = give_get_earnings_by_date( $d, $i, $y ); |
|
1296 | - $date_key = date( 'Ymd', strtotime( $y . '/' . $i . '/' . $d ) ); |
|
1297 | - if ( ! isset( $earnings['earnings'][ $date_key ] ) ) { |
|
1298 | - $earnings['earnings'][ $date_key ] = 0; |
|
1294 | + while ($d <= $num_of_days) : |
|
1295 | + $earnings_stat = give_get_earnings_by_date($d, $i, $y); |
|
1296 | + $date_key = date('Ymd', strtotime($y.'/'.$i.'/'.$d)); |
|
1297 | + if ( ! isset($earnings['earnings'][$date_key])) { |
|
1298 | + $earnings['earnings'][$date_key] = 0; |
|
1299 | 1299 | } |
1300 | - $earnings['earnings'][ $date_key ] += $earnings_stat; |
|
1300 | + $earnings['earnings'][$date_key] += $earnings_stat; |
|
1301 | 1301 | $total += $earnings_stat; |
1302 | - $d ++; |
|
1302 | + $d++; |
|
1303 | 1303 | endwhile; |
1304 | 1304 | |
1305 | - $i ++; |
|
1305 | + $i++; |
|
1306 | 1306 | endwhile; |
1307 | 1307 | |
1308 | - $y ++; |
|
1308 | + $y++; |
|
1309 | 1309 | endwhile; |
1310 | 1310 | |
1311 | 1311 | $earnings['totals'] = $total; |
1312 | 1312 | } else { |
1313 | - if ( $args['date'] == 'this_quarter' || $args['date'] == 'last_quarter' ) { |
|
1313 | + if ($args['date'] == 'this_quarter' || $args['date'] == 'last_quarter') { |
|
1314 | 1314 | $earnings_count = (float) 0.00; |
1315 | 1315 | |
1316 | 1316 | // Loop through the months |
1317 | 1317 | $month = $dates['m_start']; |
1318 | 1318 | |
1319 | - while ( $month <= $dates['m_end'] ) : |
|
1320 | - $earnings_count += give_get_earnings_by_date( null, $month, $dates['year'] ); |
|
1321 | - $month ++; |
|
1319 | + while ($month <= $dates['m_end']) : |
|
1320 | + $earnings_count += give_get_earnings_by_date(null, $month, $dates['year']); |
|
1321 | + $month++; |
|
1322 | 1322 | endwhile; |
1323 | 1323 | |
1324 | - $earnings['earnings'][ $args['date'] ] = $earnings_count; |
|
1324 | + $earnings['earnings'][$args['date']] = $earnings_count; |
|
1325 | 1325 | } else { |
1326 | - $earnings['earnings'][ $args['date'] ] = give_get_earnings_by_date( $dates['day'], $dates['m_start'], $dates['year'] ); |
|
1326 | + $earnings['earnings'][$args['date']] = give_get_earnings_by_date($dates['day'], $dates['m_start'], $dates['year']); |
|
1327 | 1327 | } |
1328 | 1328 | }// End if(). |
1329 | - } elseif ( $args['form'] == 'all' ) { |
|
1330 | - $forms = get_posts( array( |
|
1329 | + } elseif ($args['form'] == 'all') { |
|
1330 | + $forms = get_posts(array( |
|
1331 | 1331 | 'post_type' => 'give_forms', |
1332 | 1332 | 'nopaging' => true, |
1333 | - ) ); |
|
1333 | + )); |
|
1334 | 1334 | |
1335 | 1335 | $i = 0; |
1336 | - foreach ( $forms as $form_info ) { |
|
1337 | - $earnings['earnings'][ $i ] = array( |
|
1338 | - $form_info->post_name => give_get_form_earnings_stats( $form_info->ID ), |
|
1336 | + foreach ($forms as $form_info) { |
|
1337 | + $earnings['earnings'][$i] = array( |
|
1338 | + $form_info->post_name => give_get_form_earnings_stats($form_info->ID), |
|
1339 | 1339 | ); |
1340 | - $i ++; |
|
1340 | + $i++; |
|
1341 | 1341 | } |
1342 | 1342 | } else { |
1343 | - if ( get_post_type( $args['form'] ) == 'give_forms' ) { |
|
1344 | - $form_info = get_post( $args['form'] ); |
|
1343 | + if (get_post_type($args['form']) == 'give_forms') { |
|
1344 | + $form_info = get_post($args['form']); |
|
1345 | 1345 | $earnings['earnings'][0] = array( |
1346 | - $form_info->post_name => give_get_form_earnings_stats( $args['form'] ), |
|
1346 | + $form_info->post_name => give_get_form_earnings_stats($args['form']), |
|
1347 | 1347 | ); |
1348 | 1348 | } else { |
1349 | 1349 | $error['error'] = sprintf( /* translators: %s: form */ |
1350 | - __( 'Form %s not found.', 'give' ), $args['form'] ); |
|
1350 | + __('Form %s not found.', 'give'), $args['form'] ); |
|
1351 | 1351 | } |
1352 | 1352 | }// End if(). |
1353 | 1353 | |
1354 | - if ( ! empty( $error ) ) { |
|
1354 | + if ( ! empty($error)) { |
|
1355 | 1355 | return $error; |
1356 | 1356 | } |
1357 | 1357 | |
1358 | 1358 | return $earnings; |
1359 | - } elseif ( $args['type'] == 'donors' ) { |
|
1359 | + } elseif ($args['type'] == 'donors') { |
|
1360 | 1360 | $donors = new Give_DB_Donors(); |
1361 | 1361 | $stats['donations']['total_donors'] = $donors->count(); |
1362 | 1362 | |
1363 | 1363 | return $stats; |
1364 | 1364 | |
1365 | - } elseif ( empty( $args['type'] ) ) { |
|
1366 | - $stats = array_merge( $stats, $this->get_default_sales_stats() ); |
|
1367 | - $stats = array_merge( $stats, $this->get_default_earnings_stats() ); |
|
1365 | + } elseif (empty($args['type'])) { |
|
1366 | + $stats = array_merge($stats, $this->get_default_sales_stats()); |
|
1367 | + $stats = array_merge($stats, $this->get_default_earnings_stats()); |
|
1368 | 1368 | |
1369 | 1369 | return array( |
1370 | 1370 | 'stats' => $stats, |
@@ -1382,7 +1382,7 @@ discard block |
||
1382 | 1382 | * |
1383 | 1383 | * @return array |
1384 | 1384 | */ |
1385 | - public function get_recent_donations( $args = array() ) { |
|
1385 | + public function get_recent_donations($args = array()) { |
|
1386 | 1386 | global $wp_query; |
1387 | 1387 | |
1388 | 1388 | $defaults = array( |
@@ -1392,33 +1392,33 @@ discard block |
||
1392 | 1392 | 'enddate' => null, |
1393 | 1393 | ); |
1394 | 1394 | |
1395 | - $args = wp_parse_args( $args, $defaults ); |
|
1395 | + $args = wp_parse_args($args, $defaults); |
|
1396 | 1396 | |
1397 | 1397 | $donations = array(); |
1398 | 1398 | |
1399 | - if ( ! user_can( $this->user_id, 'view_give_reports' ) && ! $this->override ) { |
|
1399 | + if ( ! user_can($this->user_id, 'view_give_reports') && ! $this->override) { |
|
1400 | 1400 | return $donations; |
1401 | 1401 | } |
1402 | 1402 | |
1403 | - if ( isset( $wp_query->query_vars['id'] ) ) { |
|
1403 | + if (isset($wp_query->query_vars['id'])) { |
|
1404 | 1404 | $query = array(); |
1405 | - $query[] = new Give_Payment( $wp_query->query_vars['id'] ); |
|
1406 | - } elseif ( isset( $wp_query->query_vars['purchasekey'] ) ) { |
|
1405 | + $query[] = new Give_Payment($wp_query->query_vars['id']); |
|
1406 | + } elseif (isset($wp_query->query_vars['purchasekey'])) { |
|
1407 | 1407 | $query = array(); |
1408 | - $query[] = give_get_payment_by( 'key', $wp_query->query_vars['purchasekey'] ); |
|
1409 | - } elseif ( isset( $wp_query->query_vars['email'] ) ) { |
|
1410 | - $args = array( |
|
1408 | + $query[] = give_get_payment_by('key', $wp_query->query_vars['purchasekey']); |
|
1409 | + } elseif (isset($wp_query->query_vars['email'])) { |
|
1410 | + $args = array( |
|
1411 | 1411 | 'fields' => 'ids', |
1412 | 1412 | 'meta_key' => '_give_payment_user_email', |
1413 | 1413 | 'meta_value' => $wp_query->query_vars['email'], |
1414 | 1414 | 'number' => $this->per_page(), |
1415 | 1415 | 'page' => $this->get_paged(), |
1416 | 1416 | ); |
1417 | - $query = give_get_payments( $args ); |
|
1418 | - } elseif ( isset( $wp_query->query_vars['date'] ) ) { |
|
1417 | + $query = give_get_payments($args); |
|
1418 | + } elseif (isset($wp_query->query_vars['date'])) { |
|
1419 | 1419 | |
1420 | - $current_time = current_time( 'timestamp' ); |
|
1421 | - $dates = $this->get_dates( $args ); |
|
1420 | + $current_time = current_time('timestamp'); |
|
1421 | + $dates = $this->get_dates($args); |
|
1422 | 1422 | $start_date = ''; |
1423 | 1423 | $end_date = ''; |
1424 | 1424 | |
@@ -1431,27 +1431,27 @@ discard block |
||
1431 | 1431 | * @params date startdate | required when date = range and format to be YYYYMMDD (i.e. 20170524) |
1432 | 1432 | * @params date enddate | required when date = range and format to be YYYYMMDD (i.e. 20170524) |
1433 | 1433 | */ |
1434 | - switch ( $wp_query->query_vars['date'] ) { |
|
1434 | + switch ($wp_query->query_vars['date']) { |
|
1435 | 1435 | |
1436 | 1436 | case 'today': |
1437 | 1437 | |
1438 | 1438 | // Set and Format Start and End Date to be date of today. |
1439 | - $start_date = $end_date = date( 'Y/m/d', $current_time ); |
|
1439 | + $start_date = $end_date = date('Y/m/d', $current_time); |
|
1440 | 1440 | |
1441 | 1441 | break; |
1442 | 1442 | |
1443 | 1443 | case 'yesterday': |
1444 | 1444 | |
1445 | 1445 | // Set and Format Start and End Date to be date of yesterday. |
1446 | - $start_date = $end_date = date( 'Y/m', $current_time ) . '/' . ( date( 'd', $current_time ) - 1 ); |
|
1446 | + $start_date = $end_date = date('Y/m', $current_time).'/'.(date('d', $current_time) - 1); |
|
1447 | 1447 | |
1448 | 1448 | break; |
1449 | 1449 | |
1450 | 1450 | case 'range': |
1451 | 1451 | |
1452 | 1452 | // Format Start Date and End Date for filtering payment based on date range. |
1453 | - $start_date = $dates['year'] . '/' . $dates['m_start'] . '/' . $dates['day_start']; |
|
1454 | - $end_date = $dates['year_end'] . '/' . $dates['m_end'] . '/' . $dates['day_end']; |
|
1453 | + $start_date = $dates['year'].'/'.$dates['m_start'].'/'.$dates['day_start']; |
|
1454 | + $end_date = $dates['year_end'].'/'.$dates['m_end'].'/'.$dates['day_end']; |
|
1455 | 1455 | |
1456 | 1456 | break; |
1457 | 1457 | |
@@ -1465,22 +1465,22 @@ discard block |
||
1465 | 1465 | 'page' => $this->get_paged(), |
1466 | 1466 | ); |
1467 | 1467 | |
1468 | - $query = give_get_payments( $args ); |
|
1468 | + $query = give_get_payments($args); |
|
1469 | 1469 | } else { |
1470 | 1470 | $args = array( |
1471 | 1471 | 'fields' => 'ids', |
1472 | 1472 | 'number' => $this->per_page(), |
1473 | 1473 | 'page' => $this->get_paged(), |
1474 | 1474 | ); |
1475 | - $query = give_get_payments( $args ); |
|
1475 | + $query = give_get_payments($args); |
|
1476 | 1476 | }// End if(). |
1477 | 1477 | |
1478 | - if ( $query ) { |
|
1478 | + if ($query) { |
|
1479 | 1479 | $i = 0; |
1480 | - foreach ( $query as $payment ) { |
|
1480 | + foreach ($query as $payment) { |
|
1481 | 1481 | |
1482 | - if ( is_numeric( $payment ) ) { |
|
1483 | - $payment = new Give_Payment( $payment ); |
|
1482 | + if (is_numeric($payment)) { |
|
1483 | + $payment = new Give_Payment($payment); |
|
1484 | 1484 | $payment_meta = $payment->get_meta(); |
1485 | 1485 | $user_info = $payment->user_info; |
1486 | 1486 | } |
@@ -1488,41 +1488,41 @@ discard block |
||
1488 | 1488 | $payment_meta = $payment->get_meta(); |
1489 | 1489 | $user_info = $payment->user_info; |
1490 | 1490 | |
1491 | - $first_name = isset( $user_info['first_name'] ) ? $user_info['first_name'] : ''; |
|
1492 | - $last_name = isset( $user_info['last_name'] ) ? $user_info['last_name'] : ''; |
|
1493 | - |
|
1494 | - $donations['donations'][ $i ]['ID'] = $payment->number; |
|
1495 | - $donations['donations'][ $i ]['transaction_id'] = $payment->transaction_id; |
|
1496 | - $donations['donations'][ $i ]['key'] = $payment->key; |
|
1497 | - $donations['donations'][ $i ]['total'] = $payment->total; |
|
1498 | - $donations['donations'][ $i ]['status'] = give_get_payment_status( $payment, true ); |
|
1499 | - $donations['donations'][ $i ]['gateway'] = $payment->gateway; |
|
1500 | - $donations['donations'][ $i ]['name'] = $first_name . ' ' . $last_name; |
|
1501 | - $donations['donations'][ $i ]['fname'] = $first_name; |
|
1502 | - $donations['donations'][ $i ]['lname'] = $last_name; |
|
1503 | - $donations['donations'][ $i ]['email'] = $payment->email; |
|
1504 | - $donations['donations'][ $i ]['date'] = $payment->date; |
|
1505 | - |
|
1506 | - $form_id = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : $payment_meta; |
|
1507 | - $price = isset( $payment_meta['form_id'] ) ? give_get_form_price( $payment_meta['form_id'] ) : false; |
|
1508 | - $price_id = isset( $payment_meta['price_id'] ) ? $payment_meta['price_id'] : null; |
|
1509 | - |
|
1510 | - $donations['donations'][ $i ]['form']['id'] = $form_id; |
|
1511 | - $donations['donations'][ $i ]['form']['name'] = get_the_title( $payment_meta['form_id'] ); |
|
1512 | - $donations['donations'][ $i ]['form']['price'] = $price; |
|
1513 | - |
|
1514 | - if ( give_has_variable_prices( $form_id ) ) { |
|
1515 | - if ( isset( $payment_meta['price_id'] ) ) { |
|
1516 | - $price_name = give_get_price_option_name( $form_id, $payment_meta['price_id'], $payment->ID ); |
|
1517 | - $donations['donations'][ $i ]['form']['price_name'] = $price_name; |
|
1518 | - $donations['donations'][ $i ]['form']['price_id'] = $price_id; |
|
1519 | - $donations['donations'][ $i ]['form']['price'] = give_get_price_option_amount( $form_id, $price_id ); |
|
1491 | + $first_name = isset($user_info['first_name']) ? $user_info['first_name'] : ''; |
|
1492 | + $last_name = isset($user_info['last_name']) ? $user_info['last_name'] : ''; |
|
1493 | + |
|
1494 | + $donations['donations'][$i]['ID'] = $payment->number; |
|
1495 | + $donations['donations'][$i]['transaction_id'] = $payment->transaction_id; |
|
1496 | + $donations['donations'][$i]['key'] = $payment->key; |
|
1497 | + $donations['donations'][$i]['total'] = $payment->total; |
|
1498 | + $donations['donations'][$i]['status'] = give_get_payment_status($payment, true); |
|
1499 | + $donations['donations'][$i]['gateway'] = $payment->gateway; |
|
1500 | + $donations['donations'][$i]['name'] = $first_name.' '.$last_name; |
|
1501 | + $donations['donations'][$i]['fname'] = $first_name; |
|
1502 | + $donations['donations'][$i]['lname'] = $last_name; |
|
1503 | + $donations['donations'][$i]['email'] = $payment->email; |
|
1504 | + $donations['donations'][$i]['date'] = $payment->date; |
|
1505 | + |
|
1506 | + $form_id = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : $payment_meta; |
|
1507 | + $price = isset($payment_meta['form_id']) ? give_get_form_price($payment_meta['form_id']) : false; |
|
1508 | + $price_id = isset($payment_meta['price_id']) ? $payment_meta['price_id'] : null; |
|
1509 | + |
|
1510 | + $donations['donations'][$i]['form']['id'] = $form_id; |
|
1511 | + $donations['donations'][$i]['form']['name'] = get_the_title($payment_meta['form_id']); |
|
1512 | + $donations['donations'][$i]['form']['price'] = $price; |
|
1513 | + |
|
1514 | + if (give_has_variable_prices($form_id)) { |
|
1515 | + if (isset($payment_meta['price_id'])) { |
|
1516 | + $price_name = give_get_price_option_name($form_id, $payment_meta['price_id'], $payment->ID); |
|
1517 | + $donations['donations'][$i]['form']['price_name'] = $price_name; |
|
1518 | + $donations['donations'][$i]['form']['price_id'] = $price_id; |
|
1519 | + $donations['donations'][$i]['form']['price'] = give_get_price_option_amount($form_id, $price_id); |
|
1520 | 1520 | |
1521 | 1521 | } |
1522 | 1522 | } |
1523 | 1523 | |
1524 | 1524 | // Add custom meta to API |
1525 | - foreach ( $payment_meta as $meta_key => $meta_value ) { |
|
1525 | + foreach ($payment_meta as $meta_key => $meta_value) { |
|
1526 | 1526 | |
1527 | 1527 | $exceptions = array( |
1528 | 1528 | 'form_title', |
@@ -1535,19 +1535,19 @@ discard block |
||
1535 | 1535 | ); |
1536 | 1536 | |
1537 | 1537 | // Don't clutter up results with dupes |
1538 | - if ( in_array( $meta_key, $exceptions ) ) { |
|
1538 | + if (in_array($meta_key, $exceptions)) { |
|
1539 | 1539 | continue; |
1540 | 1540 | } |
1541 | 1541 | |
1542 | - $donations['donations'][ $i ]['payment_meta'][ $meta_key ] = $meta_value; |
|
1542 | + $donations['donations'][$i]['payment_meta'][$meta_key] = $meta_value; |
|
1543 | 1543 | |
1544 | 1544 | } |
1545 | 1545 | |
1546 | - $i ++; |
|
1546 | + $i++; |
|
1547 | 1547 | }// End foreach(). |
1548 | 1548 | }// End if(). |
1549 | 1549 | |
1550 | - return apply_filters( 'give_api_donations_endpoint', $donations ); |
|
1550 | + return apply_filters('give_api_donations_endpoint', $donations); |
|
1551 | 1551 | } |
1552 | 1552 | |
1553 | 1553 | /** |
@@ -1563,9 +1563,9 @@ discard block |
||
1563 | 1563 | public function get_output_format() { |
1564 | 1564 | global $wp_query; |
1565 | 1565 | |
1566 | - $format = isset( $wp_query->query_vars['format'] ) ? $wp_query->query_vars['format'] : 'json'; |
|
1566 | + $format = isset($wp_query->query_vars['format']) ? $wp_query->query_vars['format'] : 'json'; |
|
1567 | 1567 | |
1568 | - return apply_filters( 'give_api_output_format', $format ); |
|
1568 | + return apply_filters('give_api_output_format', $format); |
|
1569 | 1569 | } |
1570 | 1570 | |
1571 | 1571 | |
@@ -1582,8 +1582,8 @@ discard block |
||
1582 | 1582 | * |
1583 | 1583 | * @return void |
1584 | 1584 | */ |
1585 | - private function log_request( $data = array() ) { |
|
1586 | - if ( ! $this->log_requests ) { |
|
1585 | + private function log_request($data = array()) { |
|
1586 | + if ( ! $this->log_requests) { |
|
1587 | 1587 | return; |
1588 | 1588 | } |
1589 | 1589 | |
@@ -1599,36 +1599,36 @@ discard block |
||
1599 | 1599 | |
1600 | 1600 | $query = array( |
1601 | 1601 | 'give-api' => $wp_query->query_vars['give-api'], |
1602 | - 'key' => isset( $wp_query->query_vars['key'] ) ? $wp_query->query_vars['key'] : null, |
|
1603 | - 'token' => isset( $wp_query->query_vars['token'] ) ? $wp_query->query_vars['token'] : null, |
|
1604 | - 'query' => isset( $wp_query->query_vars['query'] ) ? $wp_query->query_vars['query'] : null, |
|
1605 | - 'type' => isset( $wp_query->query_vars['type'] ) ? $wp_query->query_vars['type'] : null, |
|
1606 | - 'form' => isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null, |
|
1607 | - 'donor' => isset( $wp_query->query_vars['donor'] ) ? $wp_query->query_vars['donor'] : null, |
|
1608 | - 'date' => isset( $wp_query->query_vars['date'] ) ? $wp_query->query_vars['date'] : null, |
|
1609 | - 'startdate' => isset( $wp_query->query_vars['startdate'] ) ? $wp_query->query_vars['startdate'] : null, |
|
1610 | - 'enddate' => isset( $wp_query->query_vars['enddate'] ) ? $wp_query->query_vars['enddate'] : null, |
|
1611 | - 'id' => isset( $wp_query->query_vars['id'] ) ? $wp_query->query_vars['id'] : null, |
|
1612 | - 'purchasekey' => isset( $wp_query->query_vars['purchasekey'] ) ? $wp_query->query_vars['purchasekey'] : null, |
|
1613 | - 'email' => isset( $wp_query->query_vars['email'] ) ? $wp_query->query_vars['email'] : null, |
|
1602 | + 'key' => isset($wp_query->query_vars['key']) ? $wp_query->query_vars['key'] : null, |
|
1603 | + 'token' => isset($wp_query->query_vars['token']) ? $wp_query->query_vars['token'] : null, |
|
1604 | + 'query' => isset($wp_query->query_vars['query']) ? $wp_query->query_vars['query'] : null, |
|
1605 | + 'type' => isset($wp_query->query_vars['type']) ? $wp_query->query_vars['type'] : null, |
|
1606 | + 'form' => isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null, |
|
1607 | + 'donor' => isset($wp_query->query_vars['donor']) ? $wp_query->query_vars['donor'] : null, |
|
1608 | + 'date' => isset($wp_query->query_vars['date']) ? $wp_query->query_vars['date'] : null, |
|
1609 | + 'startdate' => isset($wp_query->query_vars['startdate']) ? $wp_query->query_vars['startdate'] : null, |
|
1610 | + 'enddate' => isset($wp_query->query_vars['enddate']) ? $wp_query->query_vars['enddate'] : null, |
|
1611 | + 'id' => isset($wp_query->query_vars['id']) ? $wp_query->query_vars['id'] : null, |
|
1612 | + 'purchasekey' => isset($wp_query->query_vars['purchasekey']) ? $wp_query->query_vars['purchasekey'] : null, |
|
1613 | + 'email' => isset($wp_query->query_vars['email']) ? $wp_query->query_vars['email'] : null, |
|
1614 | 1614 | ); |
1615 | 1615 | |
1616 | 1616 | $log_data = array( |
1617 | 1617 | 'log_type' => 'api_request', |
1618 | - 'post_excerpt' => http_build_query( $query ), |
|
1619 | - 'post_content' => ! empty( $data['error'] ) ? $data['error'] : '', |
|
1618 | + 'post_excerpt' => http_build_query($query), |
|
1619 | + 'post_content' => ! empty($data['error']) ? $data['error'] : '', |
|
1620 | 1620 | ); |
1621 | 1621 | |
1622 | 1622 | $log_meta = array( |
1623 | 1623 | 'request_ip' => give_get_ip(), |
1624 | 1624 | 'user' => $this->user_id, |
1625 | - 'key' => isset( $wp_query->query_vars['key'] ) ? $wp_query->query_vars['key'] : null, |
|
1626 | - 'token' => isset( $wp_query->query_vars['token'] ) ? $wp_query->query_vars['token'] : null, |
|
1625 | + 'key' => isset($wp_query->query_vars['key']) ? $wp_query->query_vars['key'] : null, |
|
1626 | + 'token' => isset($wp_query->query_vars['token']) ? $wp_query->query_vars['token'] : null, |
|
1627 | 1627 | 'time' => $data['request_speed'], |
1628 | 1628 | 'version' => $this->get_queried_version(), |
1629 | 1629 | ); |
1630 | 1630 | |
1631 | - $give_logs->insert_log( $log_data, $log_meta ); |
|
1631 | + $give_logs->insert_log($log_data, $log_meta); |
|
1632 | 1632 | } |
1633 | 1633 | |
1634 | 1634 | |
@@ -1652,11 +1652,11 @@ discard block |
||
1652 | 1652 | * |
1653 | 1653 | * @param int $status_code |
1654 | 1654 | */ |
1655 | - public function output( $status_code = 200 ) { |
|
1655 | + public function output($status_code = 200) { |
|
1656 | 1656 | |
1657 | 1657 | $format = $this->get_output_format(); |
1658 | 1658 | |
1659 | - status_header( $status_code ); |
|
1659 | + status_header($status_code); |
|
1660 | 1660 | |
1661 | 1661 | /** |
1662 | 1662 | * Fires before outputting the API. |
@@ -1667,25 +1667,25 @@ discard block |
||
1667 | 1667 | * @param Give_API $this The Give_API object. |
1668 | 1668 | * @param string $format Output format, XML or JSON. Default is JSON. |
1669 | 1669 | */ |
1670 | - do_action( 'give_api_output_before', $this->data, $this, $format ); |
|
1670 | + do_action('give_api_output_before', $this->data, $this, $format); |
|
1671 | 1671 | |
1672 | - switch ( $format ) : |
|
1672 | + switch ($format) : |
|
1673 | 1673 | |
1674 | 1674 | case 'xml' : |
1675 | 1675 | |
1676 | - require_once GIVE_PLUGIN_DIR . 'includes/libraries/array2xml.php'; |
|
1677 | - $xml = Array2XML::createXML( 'give', $this->data ); |
|
1676 | + require_once GIVE_PLUGIN_DIR.'includes/libraries/array2xml.php'; |
|
1677 | + $xml = Array2XML::createXML('give', $this->data); |
|
1678 | 1678 | echo $xml->saveXML(); |
1679 | 1679 | |
1680 | 1680 | break; |
1681 | 1681 | |
1682 | 1682 | case 'json' : |
1683 | 1683 | |
1684 | - header( 'Content-Type: application/json' ); |
|
1685 | - if ( ! empty( $this->pretty_print ) ) { |
|
1686 | - echo json_encode( $this->data, $this->pretty_print ); |
|
1684 | + header('Content-Type: application/json'); |
|
1685 | + if ( ! empty($this->pretty_print)) { |
|
1686 | + echo json_encode($this->data, $this->pretty_print); |
|
1687 | 1687 | } else { |
1688 | - echo json_encode( $this->data ); |
|
1688 | + echo json_encode($this->data); |
|
1689 | 1689 | } |
1690 | 1690 | |
1691 | 1691 | break; |
@@ -1700,7 +1700,7 @@ discard block |
||
1700 | 1700 | * @param array $data Response data to return. |
1701 | 1701 | * @param Give_API $this The Give_API object. |
1702 | 1702 | */ |
1703 | - do_action( "give_api_output_{$format}", $this->data, $this ); |
|
1703 | + do_action("give_api_output_{$format}", $this->data, $this); |
|
1704 | 1704 | |
1705 | 1705 | break; |
1706 | 1706 | |
@@ -1715,7 +1715,7 @@ discard block |
||
1715 | 1715 | * @param Give_API $this The Give_API object. |
1716 | 1716 | * @param string $format Output format, XML or JSON. Default is JSON. |
1717 | 1717 | */ |
1718 | - do_action( 'give_api_output_after', $this->data, $this, $format ); |
|
1718 | + do_action('give_api_output_after', $this->data, $this, $format); |
|
1719 | 1719 | |
1720 | 1720 | give_die(); |
1721 | 1721 | } |
@@ -1732,41 +1732,41 @@ discard block |
||
1732 | 1732 | * |
1733 | 1733 | * @return void |
1734 | 1734 | */ |
1735 | - function user_key_field( $user ) { |
|
1735 | + function user_key_field($user) { |
|
1736 | 1736 | |
1737 | - if ( ( give_get_option( 'api_allow_user_keys', false ) || current_user_can( 'manage_give_settings' ) ) && current_user_can( 'edit_user', $user->ID ) ) { |
|
1737 | + if ((give_get_option('api_allow_user_keys', false) || current_user_can('manage_give_settings')) && current_user_can('edit_user', $user->ID)) { |
|
1738 | 1738 | |
1739 | - $user = get_userdata( $user->ID ); |
|
1739 | + $user = get_userdata($user->ID); |
|
1740 | 1740 | ?> |
1741 | 1741 | <table class="form-table"> |
1742 | 1742 | <tbody> |
1743 | 1743 | <tr> |
1744 | 1744 | <th> |
1745 | - <?php _e( 'Give API Keys', 'give' ); ?> |
|
1745 | + <?php _e('Give API Keys', 'give'); ?> |
|
1746 | 1746 | </th> |
1747 | 1747 | <td> |
1748 | 1748 | <?php |
1749 | - $public_key = $this->get_user_public_key( $user->ID ); |
|
1750 | - $secret_key = $this->get_user_secret_key( $user->ID ); |
|
1749 | + $public_key = $this->get_user_public_key($user->ID); |
|
1750 | + $secret_key = $this->get_user_secret_key($user->ID); |
|
1751 | 1751 | ?> |
1752 | - <?php if ( empty( $user->give_user_public_key ) ) { ?> |
|
1752 | + <?php if (empty($user->give_user_public_key)) { ?> |
|
1753 | 1753 | <input name="give_set_api_key" type="checkbox" id="give_set_api_key" /> |
1754 | - <span class="description"><?php _e( 'Generate API Key', 'give' ); ?></span> |
|
1754 | + <span class="description"><?php _e('Generate API Key', 'give'); ?></span> |
|
1755 | 1755 | <?php } else { ?> |
1756 | - <strong style="display:inline-block; width: 125px;"><?php _e( 'Public key:', 'give' ); ?> |
|
1756 | + <strong style="display:inline-block; width: 125px;"><?php _e('Public key:', 'give'); ?> |
|
1757 | 1757 | </strong> |
1758 | - <input type="text" disabled="disabled" class="regular-text" id="publickey" value="<?php echo esc_attr( $public_key ); ?>" /> |
|
1758 | + <input type="text" disabled="disabled" class="regular-text" id="publickey" value="<?php echo esc_attr($public_key); ?>" /> |
|
1759 | 1759 | <br /> |
1760 | - <strong style="display:inline-block; width: 125px;"><?php _e( 'Secret key:', 'give' ); ?> |
|
1760 | + <strong style="display:inline-block; width: 125px;"><?php _e('Secret key:', 'give'); ?> |
|
1761 | 1761 | </strong> |
1762 | - <input type="text" disabled="disabled" class="regular-text" id="privatekey" value="<?php echo esc_attr( $secret_key ); ?>" /> |
|
1762 | + <input type="text" disabled="disabled" class="regular-text" id="privatekey" value="<?php echo esc_attr($secret_key); ?>" /> |
|
1763 | 1763 | <br /> |
1764 | - <strong style="display:inline-block; width: 125px;"><?php _e( 'Token:', 'give' ); ?> |
|
1764 | + <strong style="display:inline-block; width: 125px;"><?php _e('Token:', 'give'); ?> |
|
1765 | 1765 | </strong> |
1766 | - <input type="text" disabled="disabled" class="regular-text" id="token" value="<?php echo esc_attr( $this->get_token( $user->ID ) ); ?>" /> |
|
1766 | + <input type="text" disabled="disabled" class="regular-text" id="token" value="<?php echo esc_attr($this->get_token($user->ID)); ?>" /> |
|
1767 | 1767 | <br /> |
1768 | 1768 | <input name="give_revoke_api_key" type="checkbox" id="give_revoke_api_key" /> |
1769 | - <span class="description"><label for="give_revoke_api_key"><?php _e( 'Revoke API Keys', 'give' ); ?></label></span> |
|
1769 | + <span class="description"><label for="give_revoke_api_key"><?php _e('Revoke API Keys', 'give'); ?></label></span> |
|
1770 | 1770 | <?php } ?> |
1771 | 1771 | </td> |
1772 | 1772 | </tr> |
@@ -1785,61 +1785,61 @@ discard block |
||
1785 | 1785 | * |
1786 | 1786 | * @return void |
1787 | 1787 | */ |
1788 | - public function process_api_key( $args ) { |
|
1788 | + public function process_api_key($args) { |
|
1789 | 1789 | |
1790 | - if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'give-api-nonce' ) ) { |
|
1791 | - wp_die( __( 'Nonce verification failed.', 'give' ), __( 'Error', 'give' ), array( |
|
1790 | + if ( ! wp_verify_nonce($_REQUEST['_wpnonce'], 'give-api-nonce')) { |
|
1791 | + wp_die(__('Nonce verification failed.', 'give'), __('Error', 'give'), array( |
|
1792 | 1792 | 'response' => 403, |
1793 | - ) ); |
|
1793 | + )); |
|
1794 | 1794 | } |
1795 | 1795 | |
1796 | - if ( empty( $args['user_id'] ) ) { |
|
1797 | - wp_die( __( 'User ID Required.', 'give' ), __( 'Error', 'give' ), array( |
|
1796 | + if (empty($args['user_id'])) { |
|
1797 | + wp_die(__('User ID Required.', 'give'), __('Error', 'give'), array( |
|
1798 | 1798 | 'response' => 401, |
1799 | - ) ); |
|
1799 | + )); |
|
1800 | 1800 | } |
1801 | 1801 | |
1802 | - if ( is_numeric( $args['user_id'] ) ) { |
|
1803 | - $user_id = isset( $args['user_id'] ) ? absint( $args['user_id'] ) : get_current_user_id(); |
|
1802 | + if (is_numeric($args['user_id'])) { |
|
1803 | + $user_id = isset($args['user_id']) ? absint($args['user_id']) : get_current_user_id(); |
|
1804 | 1804 | } else { |
1805 | - $userdata = get_user_by( 'login', $args['user_id'] ); |
|
1805 | + $userdata = get_user_by('login', $args['user_id']); |
|
1806 | 1806 | $user_id = $userdata->ID; |
1807 | 1807 | } |
1808 | - $process = isset( $args['give_api_process'] ) ? strtolower( $args['give_api_process'] ) : false; |
|
1808 | + $process = isset($args['give_api_process']) ? strtolower($args['give_api_process']) : false; |
|
1809 | 1809 | |
1810 | - if ( $user_id == get_current_user_id() && ! give_get_option( 'allow_user_api_keys' ) && ! current_user_can( 'manage_give_settings' ) ) { |
|
1811 | - wp_die( sprintf( /* translators: %s: process */ |
|
1812 | - __( 'You do not have permission to %s API keys for this user.', 'give' ), $process ), __( 'Error', 'give' ), array( |
|
1810 | + if ($user_id == get_current_user_id() && ! give_get_option('allow_user_api_keys') && ! current_user_can('manage_give_settings')) { |
|
1811 | + wp_die(sprintf( /* translators: %s: process */ |
|
1812 | + __('You do not have permission to %s API keys for this user.', 'give'), $process ), __('Error', 'give'), array( |
|
1813 | 1813 | 'response' => 403, |
1814 | - ) ); |
|
1815 | - } elseif ( ! current_user_can( 'manage_give_settings' ) ) { |
|
1816 | - wp_die( sprintf( /* translators: %s: process */ |
|
1817 | - __( 'You do not have permission to %s API keys for this user.', 'give' ), $process ), __( 'Error', 'give' ), array( |
|
1814 | + )); |
|
1815 | + } elseif ( ! current_user_can('manage_give_settings')) { |
|
1816 | + wp_die(sprintf( /* translators: %s: process */ |
|
1817 | + __('You do not have permission to %s API keys for this user.', 'give'), $process ), __('Error', 'give'), array( |
|
1818 | 1818 | 'response' => 403, |
1819 | - ) ); |
|
1819 | + )); |
|
1820 | 1820 | } |
1821 | 1821 | |
1822 | - switch ( $process ) { |
|
1822 | + switch ($process) { |
|
1823 | 1823 | case 'generate': |
1824 | - if ( $this->generate_api_key( $user_id ) ) { |
|
1825 | - Give_Cache::delete( Give_Cache::get_key( 'give_total_api_keys' ) ); |
|
1826 | - wp_redirect( add_query_arg( 'give-message', 'api-key-generated', 'edit.php?post_type=give_forms&page=give-tools&tab=api' ) ); |
|
1824 | + if ($this->generate_api_key($user_id)) { |
|
1825 | + Give_Cache::delete(Give_Cache::get_key('give_total_api_keys')); |
|
1826 | + wp_redirect(add_query_arg('give-message', 'api-key-generated', 'edit.php?post_type=give_forms&page=give-tools&tab=api')); |
|
1827 | 1827 | exit(); |
1828 | 1828 | } else { |
1829 | - wp_redirect( add_query_arg( 'give-message', 'api-key-failed', 'edit.php?post_type=give_forms&page=give-tools&tab=api' ) ); |
|
1829 | + wp_redirect(add_query_arg('give-message', 'api-key-failed', 'edit.php?post_type=give_forms&page=give-tools&tab=api')); |
|
1830 | 1830 | exit(); |
1831 | 1831 | } |
1832 | 1832 | break; |
1833 | 1833 | case 'regenerate': |
1834 | - $this->generate_api_key( $user_id, true ); |
|
1835 | - Give_Cache::delete( Give_Cache::get_key( 'give_total_api_keys' ) ); |
|
1836 | - wp_redirect( add_query_arg( 'give-message', 'api-key-regenerated', 'edit.php?post_type=give_forms&page=give-tools&tab=api' ) ); |
|
1834 | + $this->generate_api_key($user_id, true); |
|
1835 | + Give_Cache::delete(Give_Cache::get_key('give_total_api_keys')); |
|
1836 | + wp_redirect(add_query_arg('give-message', 'api-key-regenerated', 'edit.php?post_type=give_forms&page=give-tools&tab=api')); |
|
1837 | 1837 | exit(); |
1838 | 1838 | break; |
1839 | 1839 | case 'revoke': |
1840 | - $this->revoke_api_key( $user_id ); |
|
1841 | - Give_Cache::delete( Give_Cache::get_key( 'give_total_api_keys' ) ); |
|
1842 | - wp_redirect( add_query_arg( 'give-message', 'api-key-revoked', 'edit.php?post_type=give_forms&page=give-tools&tab=api' ) ); |
|
1840 | + $this->revoke_api_key($user_id); |
|
1841 | + Give_Cache::delete(Give_Cache::get_key('give_total_api_keys')); |
|
1842 | + wp_redirect(add_query_arg('give-message', 'api-key-revoked', 'edit.php?post_type=give_forms&page=give-tools&tab=api')); |
|
1843 | 1843 | exit(); |
1844 | 1844 | break; |
1845 | 1845 | default; |
@@ -1858,59 +1858,59 @@ discard block |
||
1858 | 1858 | * |
1859 | 1859 | * @return boolean True if (re)generated successfully, false otherwise. |
1860 | 1860 | */ |
1861 | - public function generate_api_key( $user_id = 0, $regenerate = false ) { |
|
1861 | + public function generate_api_key($user_id = 0, $regenerate = false) { |
|
1862 | 1862 | |
1863 | 1863 | // Bail out, if user doesn't exists. |
1864 | - if ( empty( $user_id ) ) { |
|
1864 | + if (empty($user_id)) { |
|
1865 | 1865 | return false; |
1866 | 1866 | } |
1867 | 1867 | |
1868 | - $user = get_userdata( $user_id ); |
|
1868 | + $user = get_userdata($user_id); |
|
1869 | 1869 | |
1870 | 1870 | // Bail Out, if user object doesn't exists. |
1871 | - if ( ! $user ) { |
|
1871 | + if ( ! $user) { |
|
1872 | 1872 | return false; |
1873 | 1873 | } |
1874 | 1874 | |
1875 | 1875 | $new_public_key = ''; |
1876 | 1876 | $new_secret_key = ''; |
1877 | 1877 | |
1878 | - if( ! empty( $_POST['from'] ) && 'profile' === $_POST['from'] ) { |
|
1878 | + if ( ! empty($_POST['from']) && 'profile' === $_POST['from']) { |
|
1879 | 1879 | // For User Profile Page. |
1880 | - if( ! empty( $_POST['give_set_api_key'] ) ) { |
|
1880 | + if ( ! empty($_POST['give_set_api_key'])) { |
|
1881 | 1881 | // Generate API Key from User Profile page. |
1882 | - $new_public_key = $this->generate_public_key( $user->user_email ); |
|
1883 | - $new_secret_key = $this->generate_private_key( $user->ID ); |
|
1884 | - } elseif ( ! empty( $_POST['give_revoke_api_key'] ) ) { |
|
1882 | + $new_public_key = $this->generate_public_key($user->user_email); |
|
1883 | + $new_secret_key = $this->generate_private_key($user->ID); |
|
1884 | + } elseif ( ! empty($_POST['give_revoke_api_key'])) { |
|
1885 | 1885 | // Revoke API Key from User Profile page. |
1886 | - $this->revoke_api_key( $user->ID ); |
|
1886 | + $this->revoke_api_key($user->ID); |
|
1887 | 1887 | } else { |
1888 | 1888 | return false; |
1889 | 1889 | } |
1890 | 1890 | } else { |
1891 | 1891 | // For Tools > API page. |
1892 | - $public_key = $this->get_user_public_key( $user_id ); |
|
1892 | + $public_key = $this->get_user_public_key($user_id); |
|
1893 | 1893 | |
1894 | - if ( empty( $public_key ) && ! $regenerate ) { |
|
1894 | + if (empty($public_key) && ! $regenerate) { |
|
1895 | 1895 | // Generating API for first time. |
1896 | - $new_public_key = $this->generate_public_key( $user->user_email ); |
|
1897 | - $new_secret_key = $this->generate_private_key( $user->ID ); |
|
1898 | - } elseif ( $public_key && $regenerate ) { |
|
1896 | + $new_public_key = $this->generate_public_key($user->user_email); |
|
1897 | + $new_secret_key = $this->generate_private_key($user->ID); |
|
1898 | + } elseif ($public_key && $regenerate) { |
|
1899 | 1899 | // API Key already exists and Regenerating API Key. |
1900 | - $this->revoke_api_key( $user->ID ); |
|
1901 | - $new_public_key = $this->generate_public_key( $user->user_email ); |
|
1902 | - $new_secret_key = $this->generate_private_key( $user->ID ); |
|
1903 | - } elseif ( ! empty( $public_key ) && ! $regenerate ) { |
|
1900 | + $this->revoke_api_key($user->ID); |
|
1901 | + $new_public_key = $this->generate_public_key($user->user_email); |
|
1902 | + $new_secret_key = $this->generate_private_key($user->ID); |
|
1903 | + } elseif ( ! empty($public_key) && ! $regenerate) { |
|
1904 | 1904 | // Doing nothing, when API Key exists but still try to generate again instead of regenerating. |
1905 | 1905 | return false; |
1906 | 1906 | } else { |
1907 | 1907 | // Revoke API Key. |
1908 | - $this->revoke_api_key( $user->ID ); |
|
1908 | + $this->revoke_api_key($user->ID); |
|
1909 | 1909 | } |
1910 | 1910 | } |
1911 | 1911 | |
1912 | - update_user_meta( $user_id, $new_public_key, 'give_user_public_key' ); |
|
1913 | - update_user_meta( $user_id, $new_secret_key, 'give_user_secret_key' ); |
|
1912 | + update_user_meta($user_id, $new_public_key, 'give_user_public_key'); |
|
1913 | + update_user_meta($user_id, $new_secret_key, 'give_user_secret_key'); |
|
1914 | 1914 | |
1915 | 1915 | return true; |
1916 | 1916 | } |
@@ -1925,26 +1925,26 @@ discard block |
||
1925 | 1925 | * |
1926 | 1926 | * @return bool |
1927 | 1927 | */ |
1928 | - public function revoke_api_key( $user_id = 0 ) { |
|
1928 | + public function revoke_api_key($user_id = 0) { |
|
1929 | 1929 | |
1930 | - if ( empty( $user_id ) ) { |
|
1930 | + if (empty($user_id)) { |
|
1931 | 1931 | return false; |
1932 | 1932 | } |
1933 | 1933 | |
1934 | - $user = get_userdata( $user_id ); |
|
1934 | + $user = get_userdata($user_id); |
|
1935 | 1935 | |
1936 | - if ( ! $user ) { |
|
1936 | + if ( ! $user) { |
|
1937 | 1937 | return false; |
1938 | 1938 | } |
1939 | 1939 | |
1940 | - $public_key = $this->get_user_public_key( $user_id ); |
|
1941 | - $secret_key = $this->get_user_secret_key( $user_id ); |
|
1942 | - if ( ! empty( $public_key ) ) { |
|
1943 | - Give_Cache::delete( Give_Cache::get_key( md5( 'give_api_user_' . $public_key ) ) ); |
|
1944 | - Give_Cache::delete( Give_Cache::get_key( md5( 'give_api_user_public_key' . $user_id ) ) ); |
|
1945 | - Give_Cache::delete( Give_Cache::get_key( md5( 'give_api_user_secret_key' . $user_id ) ) ); |
|
1946 | - delete_user_meta( $user_id, $public_key ); |
|
1947 | - delete_user_meta( $user_id, $secret_key ); |
|
1940 | + $public_key = $this->get_user_public_key($user_id); |
|
1941 | + $secret_key = $this->get_user_secret_key($user_id); |
|
1942 | + if ( ! empty($public_key)) { |
|
1943 | + Give_Cache::delete(Give_Cache::get_key(md5('give_api_user_'.$public_key))); |
|
1944 | + Give_Cache::delete(Give_Cache::get_key(md5('give_api_user_public_key'.$user_id))); |
|
1945 | + Give_Cache::delete(Give_Cache::get_key(md5('give_api_user_secret_key'.$user_id))); |
|
1946 | + delete_user_meta($user_id, $public_key); |
|
1947 | + delete_user_meta($user_id, $secret_key); |
|
1948 | 1948 | } else { |
1949 | 1949 | return false; |
1950 | 1950 | } |
@@ -1966,9 +1966,9 @@ discard block |
||
1966 | 1966 | * |
1967 | 1967 | * @return string |
1968 | 1968 | */ |
1969 | - private function generate_public_key( $user_email = '' ) { |
|
1970 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
1971 | - $public = hash( 'md5', $user_email . $auth_key . date( 'U' ) ); |
|
1969 | + private function generate_public_key($user_email = '') { |
|
1970 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
1971 | + $public = hash('md5', $user_email.$auth_key.date('U')); |
|
1972 | 1972 | |
1973 | 1973 | return $public; |
1974 | 1974 | } |
@@ -1983,9 +1983,9 @@ discard block |
||
1983 | 1983 | * |
1984 | 1984 | * @return string |
1985 | 1985 | */ |
1986 | - private function generate_private_key( $user_id = 0 ) { |
|
1987 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
1988 | - $secret = hash( 'md5', $user_id . $auth_key . date( 'U' ) ); |
|
1986 | + private function generate_private_key($user_id = 0) { |
|
1987 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
1988 | + $secret = hash('md5', $user_id.$auth_key.date('U')); |
|
1989 | 1989 | |
1990 | 1990 | return $secret; |
1991 | 1991 | } |
@@ -2000,8 +2000,8 @@ discard block |
||
2000 | 2000 | * |
2001 | 2001 | * @return string |
2002 | 2002 | */ |
2003 | - public function get_token( $user_id = 0 ) { |
|
2004 | - return hash( 'md5', $this->get_user_secret_key( $user_id ) . $this->get_user_public_key( $user_id ) ); |
|
2003 | + public function get_token($user_id = 0) { |
|
2004 | + return hash('md5', $this->get_user_secret_key($user_id).$this->get_user_public_key($user_id)); |
|
2005 | 2005 | } |
2006 | 2006 | |
2007 | 2007 | /** |
@@ -2015,9 +2015,9 @@ discard block |
||
2015 | 2015 | |
2016 | 2016 | // Default sales return |
2017 | 2017 | $donations = array(); |
2018 | - $donations['donations']['today'] = $this->stats->get_sales( 0, 'today' ); |
|
2019 | - $donations['donations']['current_month'] = $this->stats->get_sales( 0, 'this_month' ); |
|
2020 | - $donations['donations']['last_month'] = $this->stats->get_sales( 0, 'last_month' ); |
|
2018 | + $donations['donations']['today'] = $this->stats->get_sales(0, 'today'); |
|
2019 | + $donations['donations']['current_month'] = $this->stats->get_sales(0, 'this_month'); |
|
2020 | + $donations['donations']['last_month'] = $this->stats->get_sales(0, 'last_month'); |
|
2021 | 2021 | $donations['donations']['totals'] = give_get_total_donations(); |
2022 | 2022 | |
2023 | 2023 | return $donations; |
@@ -2034,9 +2034,9 @@ discard block |
||
2034 | 2034 | |
2035 | 2035 | // Default earnings return |
2036 | 2036 | $earnings = array(); |
2037 | - $earnings['earnings']['today'] = $this->stats->get_earnings( 0, 'today' ); |
|
2038 | - $earnings['earnings']['current_month'] = $this->stats->get_earnings( 0, 'this_month' ); |
|
2039 | - $earnings['earnings']['last_month'] = $this->stats->get_earnings( 0, 'last_month' ); |
|
2037 | + $earnings['earnings']['today'] = $this->stats->get_earnings(0, 'today'); |
|
2038 | + $earnings['earnings']['current_month'] = $this->stats->get_earnings(0, 'this_month'); |
|
2039 | + $earnings['earnings']['last_month'] = $this->stats->get_earnings(0, 'last_month'); |
|
2040 | 2040 | $earnings['earnings']['totals'] = give_get_total_earnings(); |
2041 | 2041 | |
2042 | 2042 | return $earnings; |
@@ -2056,25 +2056,25 @@ discard block |
||
2056 | 2056 | * |
2057 | 2057 | * @return string The API key/secret for the user supplied |
2058 | 2058 | */ |
2059 | - public function api_key_backwards_compat( $check, $object_id, $meta_key, $single ) { |
|
2059 | + public function api_key_backwards_compat($check, $object_id, $meta_key, $single) { |
|
2060 | 2060 | |
2061 | - if ( $meta_key !== 'give_user_public_key' && $meta_key !== 'give_user_secret_key' ) { |
|
2061 | + if ($meta_key !== 'give_user_public_key' && $meta_key !== 'give_user_secret_key') { |
|
2062 | 2062 | return $check; |
2063 | 2063 | } |
2064 | 2064 | |
2065 | 2065 | $return = $check; |
2066 | 2066 | |
2067 | - switch ( $meta_key ) { |
|
2067 | + switch ($meta_key) { |
|
2068 | 2068 | case 'give_user_public_key': |
2069 | - $return = Give()->api->get_user_public_key( $object_id ); |
|
2069 | + $return = Give()->api->get_user_public_key($object_id); |
|
2070 | 2070 | break; |
2071 | 2071 | case 'give_user_secret_key': |
2072 | - $return = Give()->api->get_user_secret_key( $object_id ); |
|
2072 | + $return = Give()->api->get_user_secret_key($object_id); |
|
2073 | 2073 | break; |
2074 | 2074 | } |
2075 | 2075 | |
2076 | - if ( ! $single ) { |
|
2077 | - $return = array( $return ); |
|
2076 | + if ( ! $single) { |
|
2077 | + $return = array($return); |
|
2078 | 2078 | } |
2079 | 2079 | |
2080 | 2080 | return $return; |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | * @since 1.0 |
162 | 162 | * @access public |
163 | 163 | * |
164 | - * @param bool|string|int $_id_or_email |
|
164 | + * @param integer $_id_or_email |
|
165 | 165 | * |
166 | 166 | * @return bool|int |
167 | 167 | */ |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | * @param int $user_id User ID. |
317 | 317 | * @param WP_User|bool $old_user_data User data. |
318 | 318 | * |
319 | - * @return bool |
|
319 | + * @return false|null |
|
320 | 320 | */ |
321 | 321 | public function update_donor_email_on_user_update( $user_id = 0, $old_user_data = false ) { |
322 | 322 | |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | * @access public |
374 | 374 | * |
375 | 375 | * @param string $field ID or email. Default is 'id'. |
376 | - * @param mixed $value The Customer ID or email to search. Default is 0. |
|
376 | + * @param integer $value The Customer ID or email to search. Default is 0. |
|
377 | 377 | * |
378 | 378 | * @return mixed Upon success, an object of the donor. Upon failure, NULL |
379 | 379 | */ |
@@ -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,14 +35,14 @@ discard block |
||
35 | 35 | /* @var WPDB $wpdb */ |
36 | 36 | global $wpdb; |
37 | 37 | |
38 | - $this->table_name = $wpdb->prefix . 'give_customers'; |
|
38 | + $this->table_name = $wpdb->prefix.'give_customers'; |
|
39 | 39 | $this->primary_key = 'id'; |
40 | 40 | $this->version = '1.0'; |
41 | 41 | |
42 | 42 | // Set hooks and register table only if instance loading first time. |
43 | - if ( ! ( Give()->donors instanceof Give_DB_Donors ) ) { |
|
43 | + if ( ! (Give()->donors instanceof Give_DB_Donors)) { |
|
44 | 44 | // Setup hook. |
45 | - add_action( 'profile_update', array( $this, 'update_donor_email_on_user_update' ), 10, 2 ); |
|
45 | + add_action('profile_update', array($this, 'update_donor_email_on_user_update'), 10, 2); |
|
46 | 46 | |
47 | 47 | // Install table. |
48 | 48 | $this->register_table(); |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | 'purchase_value' => 0.00, |
90 | 90 | 'purchase_count' => 0, |
91 | 91 | 'notes' => '', |
92 | - 'date_created' => date( 'Y-m-d H:i:s' ), |
|
92 | + 'date_created' => date('Y-m-d H:i:s'), |
|
93 | 93 | ); |
94 | 94 | } |
95 | 95 | |
@@ -103,40 +103,40 @@ discard block |
||
103 | 103 | * |
104 | 104 | * @return int|bool |
105 | 105 | */ |
106 | - public function add( $data = array() ) { |
|
106 | + public function add($data = array()) { |
|
107 | 107 | |
108 | 108 | $defaults = array( |
109 | 109 | 'payment_ids' => '', |
110 | 110 | ); |
111 | 111 | |
112 | - $args = wp_parse_args( $data, $defaults ); |
|
112 | + $args = wp_parse_args($data, $defaults); |
|
113 | 113 | |
114 | - if ( empty( $args['email'] ) ) { |
|
114 | + if (empty($args['email'])) { |
|
115 | 115 | return false; |
116 | 116 | } |
117 | 117 | |
118 | - if ( ! empty( $args['payment_ids'] ) && is_array( $args['payment_ids'] ) ) { |
|
119 | - $args['payment_ids'] = implode( ',', array_unique( array_values( $args['payment_ids'] ) ) ); |
|
118 | + if ( ! empty($args['payment_ids']) && is_array($args['payment_ids'])) { |
|
119 | + $args['payment_ids'] = implode(',', array_unique(array_values($args['payment_ids']))); |
|
120 | 120 | } |
121 | 121 | |
122 | - $donor = $this->get_donor_by( 'email', $args['email'] ); |
|
122 | + $donor = $this->get_donor_by('email', $args['email']); |
|
123 | 123 | |
124 | 124 | // update an existing donor. |
125 | - if ( $donor ) { |
|
125 | + if ($donor) { |
|
126 | 126 | |
127 | 127 | // Update the payment IDs attached to the donor |
128 | - if ( ! empty( $args['payment_ids'] ) ) { |
|
128 | + if ( ! empty($args['payment_ids'])) { |
|
129 | 129 | |
130 | - if ( empty( $donor->payment_ids ) ) { |
|
130 | + if (empty($donor->payment_ids)) { |
|
131 | 131 | |
132 | 132 | $donor->payment_ids = $args['payment_ids']; |
133 | 133 | |
134 | 134 | } else { |
135 | 135 | |
136 | - $existing_ids = array_map( 'absint', explode( ',', $donor->payment_ids ) ); |
|
137 | - $payment_ids = array_map( 'absint', explode( ',', $args['payment_ids'] ) ); |
|
138 | - $payment_ids = array_merge( $payment_ids, $existing_ids ); |
|
139 | - $donor->payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) ); |
|
136 | + $existing_ids = array_map('absint', explode(',', $donor->payment_ids)); |
|
137 | + $payment_ids = array_map('absint', explode(',', $args['payment_ids'])); |
|
138 | + $payment_ids = array_merge($payment_ids, $existing_ids); |
|
139 | + $donor->payment_ids = implode(',', array_unique(array_values($payment_ids))); |
|
140 | 140 | |
141 | 141 | } |
142 | 142 | |
@@ -144,13 +144,13 @@ discard block |
||
144 | 144 | |
145 | 145 | } |
146 | 146 | |
147 | - $this->update( $donor->id, $args ); |
|
147 | + $this->update($donor->id, $args); |
|
148 | 148 | |
149 | 149 | return $donor->id; |
150 | 150 | |
151 | 151 | } else { |
152 | 152 | |
153 | - return $this->insert( $args, 'donor' ); |
|
153 | + return $this->insert($args, 'donor'); |
|
154 | 154 | |
155 | 155 | } |
156 | 156 | |
@@ -169,16 +169,16 @@ discard block |
||
169 | 169 | * |
170 | 170 | * @return bool|int |
171 | 171 | */ |
172 | - public function delete( $_id_or_email = false ) { |
|
172 | + public function delete($_id_or_email = false) { |
|
173 | 173 | |
174 | - if ( empty( $_id_or_email ) ) { |
|
174 | + if (empty($_id_or_email)) { |
|
175 | 175 | return false; |
176 | 176 | } |
177 | 177 | |
178 | - $column = is_email( $_id_or_email ) ? 'email' : 'id'; |
|
179 | - $donor = $this->get_donor_by( $column, $_id_or_email ); |
|
178 | + $column = is_email($_id_or_email) ? 'email' : 'id'; |
|
179 | + $donor = $this->get_donor_by($column, $_id_or_email); |
|
180 | 180 | |
181 | - if ( $donor->id > 0 ) { |
|
181 | + if ($donor->id > 0) { |
|
182 | 182 | |
183 | 183 | global $wpdb; |
184 | 184 | |
@@ -187,9 +187,9 @@ discard block |
||
187 | 187 | * |
188 | 188 | * @since 1.8.14 |
189 | 189 | */ |
190 | - Give()->donor_meta->delete_all_meta( $donor->id ); |
|
190 | + Give()->donor_meta->delete_all_meta($donor->id); |
|
191 | 191 | |
192 | - return $wpdb->delete( $this->table_name, array( 'id' => $donor->id ), array( '%d' ) ); |
|
192 | + return $wpdb->delete($this->table_name, array('id' => $donor->id), array('%d')); |
|
193 | 193 | |
194 | 194 | } else { |
195 | 195 | return false; |
@@ -210,9 +210,9 @@ discard block |
||
210 | 210 | * |
211 | 211 | * @return bool|int |
212 | 212 | */ |
213 | - public function delete_by_user_id( $user_id = false ) { |
|
213 | + public function delete_by_user_id($user_id = false) { |
|
214 | 214 | |
215 | - if ( empty( $user_id ) ) { |
|
215 | + if (empty($user_id)) { |
|
216 | 216 | return false; |
217 | 217 | } |
218 | 218 | |
@@ -221,14 +221,14 @@ discard block |
||
221 | 221 | * |
222 | 222 | * @since 1.8.14 |
223 | 223 | */ |
224 | - $donor = new Give_Donor( $user_id, true ); |
|
225 | - if ( ! empty( $donor->id ) ) { |
|
226 | - Give()->donor_meta->delete_all_meta( $donor->id ); |
|
224 | + $donor = new Give_Donor($user_id, true); |
|
225 | + if ( ! empty($donor->id)) { |
|
226 | + Give()->donor_meta->delete_all_meta($donor->id); |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | global $wpdb; |
230 | 230 | |
231 | - return $wpdb->delete( $this->table_name, array( 'user_id' => $user_id ), array( '%d' ) ); |
|
231 | + return $wpdb->delete($this->table_name, array('user_id' => $user_id), array('%d')); |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | /** |
@@ -242,14 +242,14 @@ discard block |
||
242 | 242 | * |
243 | 243 | * @return bool True is exists, false otherwise. |
244 | 244 | */ |
245 | - public function exists( $value = '', $field = 'email' ) { |
|
245 | + public function exists($value = '', $field = 'email') { |
|
246 | 246 | |
247 | 247 | $columns = $this->get_columns(); |
248 | - if ( ! array_key_exists( $field, $columns ) ) { |
|
248 | + if ( ! array_key_exists($field, $columns)) { |
|
249 | 249 | return false; |
250 | 250 | } |
251 | 251 | |
252 | - return (bool) $this->get_column_by( 'id', $field, $value ); |
|
252 | + return (bool) $this->get_column_by('id', $field, $value); |
|
253 | 253 | |
254 | 254 | } |
255 | 255 | |
@@ -264,16 +264,16 @@ discard block |
||
264 | 264 | * |
265 | 265 | * @return bool |
266 | 266 | */ |
267 | - public function attach_payment( $donor_id = 0, $payment_id = 0 ) { |
|
267 | + public function attach_payment($donor_id = 0, $payment_id = 0) { |
|
268 | 268 | |
269 | - $donor = new Give_Donor( $donor_id ); |
|
269 | + $donor = new Give_Donor($donor_id); |
|
270 | 270 | |
271 | - if ( empty( $donor->id ) ) { |
|
271 | + if (empty($donor->id)) { |
|
272 | 272 | return false; |
273 | 273 | } |
274 | 274 | |
275 | 275 | // Attach the payment, but don't increment stats, as this function previously did not |
276 | - return $donor->attach_payment( $payment_id, false ); |
|
276 | + return $donor->attach_payment($payment_id, false); |
|
277 | 277 | |
278 | 278 | } |
279 | 279 | |
@@ -288,16 +288,16 @@ discard block |
||
288 | 288 | * |
289 | 289 | * @return bool |
290 | 290 | */ |
291 | - public function remove_payment( $donor_id = 0, $payment_id = 0 ) { |
|
291 | + public function remove_payment($donor_id = 0, $payment_id = 0) { |
|
292 | 292 | |
293 | - $donor = new Give_Donor( $donor_id ); |
|
293 | + $donor = new Give_Donor($donor_id); |
|
294 | 294 | |
295 | - if ( ! $donor ) { |
|
295 | + if ( ! $donor) { |
|
296 | 296 | return false; |
297 | 297 | } |
298 | 298 | |
299 | 299 | // Remove the payment, but don't decrease stats, as this function previously did not |
300 | - return $donor->remove_payment( $payment_id, false ); |
|
300 | + return $donor->remove_payment($payment_id, false); |
|
301 | 301 | |
302 | 302 | } |
303 | 303 | |
@@ -311,18 +311,18 @@ discard block |
||
311 | 311 | * |
312 | 312 | * @return bool |
313 | 313 | */ |
314 | - public function increment_stats( $donor_id = 0, $amount = 0.00 ) { |
|
314 | + public function increment_stats($donor_id = 0, $amount = 0.00) { |
|
315 | 315 | |
316 | - $donor = new Give_Donor( $donor_id ); |
|
316 | + $donor = new Give_Donor($donor_id); |
|
317 | 317 | |
318 | - if ( empty( $donor->id ) ) { |
|
318 | + if (empty($donor->id)) { |
|
319 | 319 | return false; |
320 | 320 | } |
321 | 321 | |
322 | 322 | $increased_count = $donor->increase_purchase_count(); |
323 | - $increased_value = $donor->increase_value( $amount ); |
|
323 | + $increased_value = $donor->increase_value($amount); |
|
324 | 324 | |
325 | - return ( $increased_count && $increased_value ) ? true : false; |
|
325 | + return ($increased_count && $increased_value) ? true : false; |
|
326 | 326 | |
327 | 327 | } |
328 | 328 | |
@@ -337,18 +337,18 @@ discard block |
||
337 | 337 | * |
338 | 338 | * @return bool |
339 | 339 | */ |
340 | - public function decrement_stats( $donor_id = 0, $amount = 0.00 ) { |
|
340 | + public function decrement_stats($donor_id = 0, $amount = 0.00) { |
|
341 | 341 | |
342 | - $donor = new Give_Donor( $donor_id ); |
|
342 | + $donor = new Give_Donor($donor_id); |
|
343 | 343 | |
344 | - if ( ! $donor ) { |
|
344 | + if ( ! $donor) { |
|
345 | 345 | return false; |
346 | 346 | } |
347 | 347 | |
348 | 348 | $decreased_count = $donor->decrease_donation_count(); |
349 | - $decreased_value = $donor->decrease_value( $amount ); |
|
349 | + $decreased_value = $donor->decrease_value($amount); |
|
350 | 350 | |
351 | - return ( $decreased_count && $decreased_value ) ? true : false; |
|
351 | + return ($decreased_count && $decreased_value) ? true : false; |
|
352 | 352 | |
353 | 353 | } |
354 | 354 | |
@@ -363,31 +363,31 @@ discard block |
||
363 | 363 | * |
364 | 364 | * @return bool |
365 | 365 | */ |
366 | - public function update_donor_email_on_user_update( $user_id = 0, $old_user_data = false ) { |
|
366 | + public function update_donor_email_on_user_update($user_id = 0, $old_user_data = false) { |
|
367 | 367 | |
368 | - $donor = new Give_Donor( $user_id, true ); |
|
368 | + $donor = new Give_Donor($user_id, true); |
|
369 | 369 | |
370 | - if ( ! $donor ) { |
|
370 | + if ( ! $donor) { |
|
371 | 371 | return false; |
372 | 372 | } |
373 | 373 | |
374 | - $user = get_userdata( $user_id ); |
|
374 | + $user = get_userdata($user_id); |
|
375 | 375 | |
376 | - if ( ! empty( $user ) && $user->user_email !== $donor->email ) { |
|
376 | + if ( ! empty($user) && $user->user_email !== $donor->email) { |
|
377 | 377 | |
378 | - if ( ! $this->get_donor_by( 'email', $user->user_email ) ) { |
|
378 | + if ( ! $this->get_donor_by('email', $user->user_email)) { |
|
379 | 379 | |
380 | - $success = $this->update( $donor->id, array( 'email' => $user->user_email ) ); |
|
380 | + $success = $this->update($donor->id, array('email' => $user->user_email)); |
|
381 | 381 | |
382 | - if ( $success ) { |
|
382 | + if ($success) { |
|
383 | 383 | // Update some payment meta if we need to |
384 | - $payments_array = explode( ',', $donor->payment_ids ); |
|
384 | + $payments_array = explode(',', $donor->payment_ids); |
|
385 | 385 | |
386 | - if ( ! empty( $payments_array ) ) { |
|
386 | + if ( ! empty($payments_array)) { |
|
387 | 387 | |
388 | - foreach ( $payments_array as $payment_id ) { |
|
388 | + foreach ($payments_array as $payment_id) { |
|
389 | 389 | |
390 | - give_update_payment_meta( $payment_id, 'email', $user->user_email ); |
|
390 | + give_update_payment_meta($payment_id, 'email', $user->user_email); |
|
391 | 391 | |
392 | 392 | } |
393 | 393 | |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | * @param WP_User $user WordPress User object. |
402 | 402 | * @param Give_Donor $donor Give donor object. |
403 | 403 | */ |
404 | - do_action( 'give_update_donor_email_on_user_update', $user, $donor ); |
|
404 | + do_action('give_update_donor_email_on_user_update', $user, $donor); |
|
405 | 405 | |
406 | 406 | } |
407 | 407 | |
@@ -422,44 +422,44 @@ discard block |
||
422 | 422 | * |
423 | 423 | * @return mixed Upon success, an object of the donor. Upon failure, NULL |
424 | 424 | */ |
425 | - public function get_donor_by( $field = 'id', $value = 0 ) { |
|
426 | - $value = sanitize_text_field( $value ); |
|
425 | + public function get_donor_by($field = 'id', $value = 0) { |
|
426 | + $value = sanitize_text_field($value); |
|
427 | 427 | |
428 | 428 | // Bailout. |
429 | - if ( empty( $field ) || empty( $value ) ) { |
|
429 | + if (empty($field) || empty($value)) { |
|
430 | 430 | return null; |
431 | 431 | } |
432 | 432 | |
433 | 433 | // Verify values. |
434 | - if ( 'id' === $field || 'user_id' === $field ) { |
|
434 | + if ('id' === $field || 'user_id' === $field) { |
|
435 | 435 | // Make sure the value is numeric to avoid casting objects, for example, |
436 | 436 | // to int 1. |
437 | - if ( ! is_numeric( $value ) ) { |
|
437 | + if ( ! is_numeric($value)) { |
|
438 | 438 | return false; |
439 | 439 | } |
440 | 440 | |
441 | - $value = absint( $value ); |
|
441 | + $value = absint($value); |
|
442 | 442 | |
443 | - if ( $value < 1 ) { |
|
443 | + if ($value < 1) { |
|
444 | 444 | return false; |
445 | 445 | } |
446 | 446 | |
447 | - } elseif ( 'email' === $field ) { |
|
447 | + } elseif ('email' === $field) { |
|
448 | 448 | |
449 | - if ( ! is_email( $value ) ) { |
|
449 | + if ( ! is_email($value)) { |
|
450 | 450 | return false; |
451 | 451 | } |
452 | 452 | |
453 | - $value = trim( $value ); |
|
453 | + $value = trim($value); |
|
454 | 454 | } |
455 | 455 | |
456 | 456 | // Bailout |
457 | - if ( ! $value ) { |
|
457 | + if ( ! $value) { |
|
458 | 458 | return false; |
459 | 459 | } |
460 | 460 | |
461 | 461 | // Set query params. |
462 | - switch ( $field ) { |
|
462 | + switch ($field) { |
|
463 | 463 | case 'id': |
464 | 464 | $args['donor'] = $value; |
465 | 465 | break; |
@@ -474,9 +474,9 @@ discard block |
||
474 | 474 | } |
475 | 475 | |
476 | 476 | // Get donors. |
477 | - $donor = new Give_Donors_Query( $args ); |
|
477 | + $donor = new Give_Donors_Query($args); |
|
478 | 478 | |
479 | - if ( ! $donor = $donor->get_donors() ) { |
|
479 | + if ( ! $donor = $donor->get_donors()) { |
|
480 | 480 | // Look for donor from an additional email. |
481 | 481 | $args = array( |
482 | 482 | 'meta_query' => array( |
@@ -487,15 +487,15 @@ discard block |
||
487 | 487 | ), |
488 | 488 | ); |
489 | 489 | |
490 | - $donor = new Give_Donors_Query( $args ); |
|
490 | + $donor = new Give_Donors_Query($args); |
|
491 | 491 | $donor = $donor->get_donors(); |
492 | 492 | |
493 | - if ( empty( $donor ) ) { |
|
493 | + if (empty($donor)) { |
|
494 | 494 | return false; |
495 | 495 | } |
496 | 496 | } |
497 | 497 | |
498 | - return current( $donor ); |
|
498 | + return current($donor); |
|
499 | 499 | } |
500 | 500 | |
501 | 501 | /** |
@@ -508,18 +508,18 @@ discard block |
||
508 | 508 | * |
509 | 509 | * @return array|object|null Donors array or object. Null if not found. |
510 | 510 | */ |
511 | - public function get_donors( $args = array() ) { |
|
512 | - $this->bc_1814_params( $args ); |
|
511 | + public function get_donors($args = array()) { |
|
512 | + $this->bc_1814_params($args); |
|
513 | 513 | |
514 | - $cache_key = md5( 'give_donors_' . serialize( $args ) ); |
|
514 | + $cache_key = md5('give_donors_'.serialize($args)); |
|
515 | 515 | |
516 | - $donors = wp_cache_get( $cache_key, 'donors' ); |
|
516 | + $donors = wp_cache_get($cache_key, 'donors'); |
|
517 | 517 | |
518 | - if ( $donors === false ) { |
|
519 | - $donors = new Give_Donors_Query( $args ); |
|
518 | + if ($donors === false) { |
|
519 | + $donors = new Give_Donors_Query($args); |
|
520 | 520 | $donors = $donors->get_donors(); |
521 | 521 | |
522 | - wp_cache_set( $cache_key, $donors, 'donors', 3600 ); |
|
522 | + wp_cache_set($cache_key, $donors, 'donors', 3600); |
|
523 | 523 | } |
524 | 524 | |
525 | 525 | return $donors; |
@@ -537,21 +537,21 @@ discard block |
||
537 | 537 | * |
538 | 538 | * @return int Total number of donors. |
539 | 539 | */ |
540 | - public function count( $args = array() ) { |
|
541 | - $this->bc_1814_params( $args ); |
|
540 | + public function count($args = array()) { |
|
541 | + $this->bc_1814_params($args); |
|
542 | 542 | $args['count'] = true; |
543 | 543 | |
544 | - $cache_key = md5( 'give_donors_count' . serialize( $args ) ); |
|
545 | - $count = wp_cache_get( $cache_key, 'donors' ); |
|
544 | + $cache_key = md5('give_donors_count'.serialize($args)); |
|
545 | + $count = wp_cache_get($cache_key, 'donors'); |
|
546 | 546 | |
547 | - if ( $count === false ) { |
|
548 | - $donors = new Give_Donors_Query( $args ); |
|
547 | + if ($count === false) { |
|
548 | + $donors = new Give_Donors_Query($args); |
|
549 | 549 | $count = $donors->get_donors(); |
550 | 550 | |
551 | - wp_cache_set( $cache_key, $count, 'donors', 3600 ); |
|
551 | + wp_cache_set($cache_key, $count, 'donors', 3600); |
|
552 | 552 | } |
553 | 553 | |
554 | - return absint( $count ); |
|
554 | + return absint($count); |
|
555 | 555 | |
556 | 556 | } |
557 | 557 | |
@@ -565,9 +565,9 @@ discard block |
||
565 | 565 | */ |
566 | 566 | public function create_table() { |
567 | 567 | |
568 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
568 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
569 | 569 | |
570 | - $sql = "CREATE TABLE " . $this->table_name . " ( |
|
570 | + $sql = "CREATE TABLE ".$this->table_name." ( |
|
571 | 571 | id bigint(20) NOT NULL AUTO_INCREMENT, |
572 | 572 | user_id bigint(20) NOT NULL, |
573 | 573 | email varchar(50) NOT NULL, |
@@ -582,9 +582,9 @@ discard block |
||
582 | 582 | KEY user (user_id) |
583 | 583 | ) CHARACTER SET utf8 COLLATE utf8_general_ci;"; |
584 | 584 | |
585 | - dbDelta( $sql ); |
|
585 | + dbDelta($sql); |
|
586 | 586 | |
587 | - update_option( $this->table_name . '_db_version', $this->version ); |
|
587 | + update_option($this->table_name.'_db_version', $this->version); |
|
588 | 588 | } |
589 | 589 | |
590 | 590 | /** |
@@ -596,7 +596,7 @@ discard block |
||
596 | 596 | * @return bool Returns if the donors table was installed and upgrade routine run. |
597 | 597 | */ |
598 | 598 | public function installed() { |
599 | - return $this->table_exists( $this->table_name ); |
|
599 | + return $this->table_exists($this->table_name); |
|
600 | 600 | } |
601 | 601 | |
602 | 602 | /** |
@@ -607,41 +607,41 @@ discard block |
||
607 | 607 | * |
608 | 608 | * @param $args |
609 | 609 | */ |
610 | - private function bc_1814_params( &$args ) { |
|
610 | + private function bc_1814_params(&$args) { |
|
611 | 611 | // Backward compatibility: user_id |
612 | - if ( ! empty( $args['user_id'] ) ) { |
|
612 | + if ( ! empty($args['user_id'])) { |
|
613 | 613 | $args['user'] = $args['user_id']; |
614 | 614 | } |
615 | 615 | |
616 | 616 | // Backward compatibility: id |
617 | - if ( ! empty( $args['id'] ) ) { |
|
617 | + if ( ! empty($args['id'])) { |
|
618 | 618 | $args['donor'] = $args['id']; |
619 | 619 | } |
620 | 620 | |
621 | 621 | // Backward compatibility: name |
622 | - if ( ! empty( $args['name'] ) ) { |
|
622 | + if ( ! empty($args['name'])) { |
|
623 | 623 | $args['s'] = "name:{$args['name']}"; |
624 | 624 | } |
625 | 625 | |
626 | 626 | // Backward compatibility: date |
627 | 627 | // Donors created for a specific date or in a date range. |
628 | - if ( ! empty( $args['date'] ) ) { |
|
628 | + if ( ! empty($args['date'])) { |
|
629 | 629 | |
630 | - if ( is_array( $args['date'] ) ) { |
|
630 | + if (is_array($args['date'])) { |
|
631 | 631 | |
632 | - if ( ! empty( $args['date']['start'] ) ) { |
|
633 | - $args['date_query']['after'] = date( 'Y-m-d H:i:s', strtotime( $args['date']['start'] ) ); |
|
632 | + if ( ! empty($args['date']['start'])) { |
|
633 | + $args['date_query']['after'] = date('Y-m-d H:i:s', strtotime($args['date']['start'])); |
|
634 | 634 | } |
635 | 635 | |
636 | - if ( ! empty( $args['date']['end'] ) ) { |
|
637 | - $args['date_query']['before'] = date( 'Y-m-d H:i:s', strtotime( $args['date']['end'] ) ); |
|
636 | + if ( ! empty($args['date']['end'])) { |
|
637 | + $args['date_query']['before'] = date('Y-m-d H:i:s', strtotime($args['date']['end'])); |
|
638 | 638 | } |
639 | 639 | |
640 | 640 | } else { |
641 | 641 | |
642 | - $args['date_query']['year'] = date( 'Y', strtotime( $args['date'] ) ); |
|
643 | - $args['date_query']['month'] = date( 'm', strtotime( $args['date'] ) ); |
|
644 | - $args['date_query']['day'] = date( 'd', strtotime( $args['date'] ) ); |
|
642 | + $args['date_query']['year'] = date('Y', strtotime($args['date'])); |
|
643 | + $args['date_query']['month'] = date('m', strtotime($args['date'])); |
|
644 | + $args['date_query']['day'] = date('d', strtotime($args['date'])); |
|
645 | 645 | } |
646 | 646 | |
647 | 647 | } |
@@ -703,7 +703,7 @@ discard block |
||
703 | 703 | * @access private |
704 | 704 | * @since 1.7 |
705 | 705 | * |
706 | - * @return bool |
|
706 | + * @return false|null |
|
707 | 707 | */ |
708 | 708 | private function __remove_license_key_from_subscriptions() { |
709 | 709 | $subscriptions = get_option( 'give_subscriptions', array() ); |
@@ -736,7 +736,7 @@ discard block |
||
736 | 736 | * @param $plugin_data |
737 | 737 | * @param $status |
738 | 738 | * |
739 | - * @return bool |
|
739 | + * @return false|null |
|
740 | 740 | */ |
741 | 741 | public function plugin_page_notices( $plugin_file, $plugin_data, $status ) { |
742 | 742 | // Bailout. |
@@ -758,7 +758,7 @@ discard block |
||
758 | 758 | * |
759 | 759 | * @since 1.8.7 |
760 | 760 | * @access public |
761 | - * @return array |
|
761 | + * @return string |
|
762 | 762 | */ |
763 | 763 | public function license_state_message() { |
764 | 764 | $message_data = array(); |
@@ -10,11 +10,11 @@ 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 | -if ( ! class_exists( 'Give_License' ) ) : |
|
17 | +if ( ! class_exists('Give_License')) : |
|
18 | 18 | |
19 | 19 | /** |
20 | 20 | * Give_License Class |
@@ -143,27 +143,27 @@ discard block |
||
143 | 143 | * @param string $_checkout_url |
144 | 144 | * @param string $_account_url |
145 | 145 | */ |
146 | - public function __construct( $_file, $_item_name, $_version, $_author, $_optname = null, $_api_url = null, $_checkout_url = null, $_account_url = null ) { |
|
146 | + public function __construct($_file, $_item_name, $_version, $_author, $_optname = null, $_api_url = null, $_checkout_url = null, $_account_url = null) { |
|
147 | 147 | |
148 | 148 | $give_options = give_get_settings(); |
149 | 149 | |
150 | 150 | $this->file = $_file; |
151 | 151 | $this->item_name = $_item_name; |
152 | - $this->item_shortname = 'give_' . preg_replace( '/[^a-zA-Z0-9_\s]/', '', str_replace( ' ', '_', strtolower( $this->item_name ) ) ); |
|
152 | + $this->item_shortname = 'give_'.preg_replace('/[^a-zA-Z0-9_\s]/', '', str_replace(' ', '_', strtolower($this->item_name))); |
|
153 | 153 | $this->version = $_version; |
154 | - $this->license = isset( $give_options[ $this->item_shortname . '_license_key' ] ) ? trim( $give_options[ $this->item_shortname . '_license_key' ] ) : ''; |
|
155 | - $this->license_data = get_option( $this->item_shortname . '_license_active' ); |
|
154 | + $this->license = isset($give_options[$this->item_shortname.'_license_key']) ? trim($give_options[$this->item_shortname.'_license_key']) : ''; |
|
155 | + $this->license_data = get_option($this->item_shortname.'_license_active'); |
|
156 | 156 | $this->author = $_author; |
157 | - $this->api_url = is_null( $_api_url ) ? $this->api_url : $_api_url; |
|
158 | - $this->checkout_url = is_null( $_checkout_url ) ? $this->checkout_url : $_checkout_url; |
|
159 | - $this->account_url = is_null( $_account_url ) ? $this->account_url : $_account_url; |
|
157 | + $this->api_url = is_null($_api_url) ? $this->api_url : $_api_url; |
|
158 | + $this->checkout_url = is_null($_checkout_url) ? $this->checkout_url : $_checkout_url; |
|
159 | + $this->account_url = is_null($_account_url) ? $this->account_url : $_account_url; |
|
160 | 160 | $this->auto_updater_obj = null; |
161 | 161 | |
162 | 162 | // Add Setting for Give Add-on activation status. |
163 | - $is_addon_activated = get_option( 'give_is_addon_activated' ); |
|
164 | - if ( ! $is_addon_activated && is_object( $this ) && sizeof( $this ) > 0 ) { |
|
165 | - update_option( 'give_is_addon_activated', true ); |
|
166 | - Give_Cache::set( 'give_cache_hide_license_notice_after_activation', true, DAY_IN_SECONDS ); |
|
163 | + $is_addon_activated = get_option('give_is_addon_activated'); |
|
164 | + if ( ! $is_addon_activated && is_object($this) && sizeof($this) > 0) { |
|
165 | + update_option('give_is_addon_activated', true); |
|
166 | + Give_Cache::set('give_cache_hide_license_notice_after_activation', true, DAY_IN_SECONDS); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | // Setup hooks |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | */ |
185 | 185 | private function includes() { |
186 | 186 | |
187 | - if ( ! class_exists( 'EDD_SL_Plugin_Updater' ) ) { |
|
187 | + if ( ! class_exists('EDD_SL_Plugin_Updater')) { |
|
188 | 188 | require_once 'admin/EDD_SL_Plugin_Updater.php'; |
189 | 189 | } |
190 | 190 | } |
@@ -202,30 +202,30 @@ discard block |
||
202 | 202 | private function hooks() { |
203 | 203 | |
204 | 204 | // Register settings. |
205 | - add_filter( 'give_settings_licenses', array( $this, 'settings' ), 1 ); |
|
205 | + add_filter('give_settings_licenses', array($this, 'settings'), 1); |
|
206 | 206 | |
207 | 207 | // Activate license key on settings save. |
208 | - add_action( 'admin_init', array( $this, 'activate_license' ), 10 ); |
|
208 | + add_action('admin_init', array($this, 'activate_license'), 10); |
|
209 | 209 | |
210 | 210 | // Deactivate license key. |
211 | - add_action( 'admin_init', array( $this, 'deactivate_license' ), 11 ); |
|
211 | + add_action('admin_init', array($this, 'deactivate_license'), 11); |
|
212 | 212 | |
213 | 213 | // Updater. |
214 | - add_action( 'admin_init', array( $this, 'auto_updater' ), 0 ); |
|
215 | - add_action( 'admin_notices', array( $this, 'notices' ) ); |
|
214 | + add_action('admin_init', array($this, 'auto_updater'), 0); |
|
215 | + add_action('admin_notices', array($this, 'notices')); |
|
216 | 216 | |
217 | 217 | // Check license weekly. |
218 | - Give_Cron::add_weekly_event( array( $this, 'weekly_license_check' ) ); |
|
219 | - add_action( 'give_validate_license_when_site_migrated', array( $this, 'weekly_license_check' ) ); |
|
218 | + Give_Cron::add_weekly_event(array($this, 'weekly_license_check')); |
|
219 | + add_action('give_validate_license_when_site_migrated', array($this, 'weekly_license_check')); |
|
220 | 220 | |
221 | 221 | // Check subscription weekly. |
222 | - Give_Cron::add_weekly_event( array( $this, 'weekly_subscription_check' ) ); |
|
223 | - add_action( 'give_validate_license_when_site_migrated', array( $this, 'weekly_subscription_check' ) ); |
|
222 | + Give_Cron::add_weekly_event(array($this, 'weekly_subscription_check')); |
|
223 | + add_action('give_validate_license_when_site_migrated', array($this, 'weekly_subscription_check')); |
|
224 | 224 | |
225 | 225 | // Show addon notice on plugin page. |
226 | - $plugin_name = explode( 'plugins/', $this->file ); |
|
227 | - $plugin_name = end( $plugin_name ); |
|
228 | - add_action( "after_plugin_row_{$plugin_name}", array( $this, 'plugin_page_notices' ), 10, 3 ); |
|
226 | + $plugin_name = explode('plugins/', $this->file); |
|
227 | + $plugin_name = end($plugin_name); |
|
228 | + add_action("after_plugin_row_{$plugin_name}", array($this, 'plugin_page_notices'), 10, 3); |
|
229 | 229 | |
230 | 230 | } |
231 | 231 | |
@@ -265,16 +265,16 @@ discard block |
||
265 | 265 | * |
266 | 266 | * @return array License settings. |
267 | 267 | */ |
268 | - public function settings( $settings ) { |
|
268 | + public function settings($settings) { |
|
269 | 269 | |
270 | 270 | $give_license_settings = array( |
271 | 271 | array( |
272 | 272 | 'name' => $this->item_name, |
273 | - 'id' => $this->item_shortname . '_license_key', |
|
273 | + 'id' => $this->item_shortname.'_license_key', |
|
274 | 274 | 'desc' => '', |
275 | 275 | 'type' => 'license_key', |
276 | 276 | 'options' => array( |
277 | - 'license' => get_option( $this->item_shortname . '_license_active' ), |
|
277 | + 'license' => get_option($this->item_shortname.'_license_active'), |
|
278 | 278 | 'shortname' => $this->item_shortname, |
279 | 279 | 'item_name' => $this->item_name, |
280 | 280 | 'api_url' => $this->api_url, |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | ), |
286 | 286 | ); |
287 | 287 | |
288 | - return array_merge( $settings, $give_license_settings ); |
|
288 | + return array_merge($settings, $give_license_settings); |
|
289 | 289 | } |
290 | 290 | |
291 | 291 | /** |
@@ -300,18 +300,18 @@ discard block |
||
300 | 300 | * |
301 | 301 | * @return array License settings content. |
302 | 302 | */ |
303 | - public function license_settings_content( $settings ) { |
|
303 | + public function license_settings_content($settings) { |
|
304 | 304 | |
305 | 305 | $give_license_settings = array( |
306 | 306 | array( |
307 | - 'name' => __( 'Add-on Licenses', 'give' ), |
|
307 | + 'name' => __('Add-on Licenses', 'give'), |
|
308 | 308 | 'desc' => '<hr>', |
309 | 309 | 'type' => 'give_title', |
310 | 310 | 'id' => 'give_title', |
311 | 311 | ), |
312 | 312 | ); |
313 | 313 | |
314 | - return array_merge( $settings, $give_license_settings ); |
|
314 | + return array_merge($settings, $give_license_settings); |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | /** |
@@ -326,62 +326,62 @@ discard block |
||
326 | 326 | */ |
327 | 327 | public function activate_license() { |
328 | 328 | // Bailout. |
329 | - if ( ! $this->__is_user_can_edit_license() ) { |
|
329 | + if ( ! $this->__is_user_can_edit_license()) { |
|
330 | 330 | return; |
331 | 331 | } |
332 | 332 | |
333 | 333 | // Allow third party addon developers to handle license activation. |
334 | - if ( $this->__is_third_party_addon() ) { |
|
335 | - do_action( 'give_activate_license', $this ); |
|
334 | + if ($this->__is_third_party_addon()) { |
|
335 | + do_action('give_activate_license', $this); |
|
336 | 336 | |
337 | 337 | return; |
338 | 338 | } |
339 | 339 | |
340 | 340 | // Delete previous license setting if a empty license key submitted. |
341 | - if ( empty( $_POST["{$this->item_shortname}_license_key"] ) ) { |
|
341 | + if (empty($_POST["{$this->item_shortname}_license_key"])) { |
|
342 | 342 | $this->unset_license(); |
343 | 343 | |
344 | 344 | return; |
345 | 345 | } |
346 | 346 | |
347 | 347 | // Do not simultaneously activate add-ons if the user want to deactivate a specific add-on. |
348 | - if( $this->is_deactivating_license() ) { |
|
348 | + if ($this->is_deactivating_license()) { |
|
349 | 349 | return; |
350 | 350 | } |
351 | 351 | |
352 | 352 | // Check if plugin previously installed. |
353 | - if ( $this->is_valid_license() ) { |
|
353 | + if ($this->is_valid_license()) { |
|
354 | 354 | return; |
355 | 355 | } |
356 | 356 | |
357 | 357 | // Get license key. |
358 | - $this->license = sanitize_text_field( $_POST[ $this->item_shortname . '_license_key' ] ); |
|
358 | + $this->license = sanitize_text_field($_POST[$this->item_shortname.'_license_key']); |
|
359 | 359 | |
360 | 360 | // Delete previous license key from subscription if previously added. |
361 | 361 | $this->__remove_license_key_from_subscriptions(); |
362 | 362 | |
363 | 363 | // Make sure there are no api errors. |
364 | - if ( ! ( $license_data = $this->get_license_info( 'activate_license' ) ) ) { |
|
364 | + if ( ! ($license_data = $this->get_license_info('activate_license'))) { |
|
365 | 365 | return; |
366 | 366 | } |
367 | 367 | |
368 | 368 | // Make sure license is valid. |
369 | 369 | // return because admin will want to activate license again. |
370 | - if ( ! $this->is_license( $license_data ) ) { |
|
370 | + if ( ! $this->is_license($license_data)) { |
|
371 | 371 | // Add license key. |
372 | - give_update_option( "{$this->item_shortname}_license_key", $this->license ); |
|
372 | + give_update_option("{$this->item_shortname}_license_key", $this->license); |
|
373 | 373 | |
374 | 374 | return; |
375 | 375 | } |
376 | 376 | |
377 | 377 | // Tell WordPress to look for updates. |
378 | - set_site_transient( 'update_plugins', null ); |
|
378 | + set_site_transient('update_plugins', null); |
|
379 | 379 | |
380 | 380 | // Add license data. |
381 | - update_option( "{$this->item_shortname}_license_active", $license_data ); |
|
381 | + update_option("{$this->item_shortname}_license_active", $license_data); |
|
382 | 382 | |
383 | 383 | // Add license key. |
384 | - give_update_option( "{$this->item_shortname}_license_key", $this->license ); |
|
384 | + give_update_option("{$this->item_shortname}_license_key", $this->license); |
|
385 | 385 | |
386 | 386 | // Check subscription for license key and store this to db (if any). |
387 | 387 | $this->__single_subscription_check(); |
@@ -399,19 +399,19 @@ discard block |
||
399 | 399 | */ |
400 | 400 | public function deactivate_license() { |
401 | 401 | // Bailout. |
402 | - if ( ! $this->__is_user_can_edit_license() ) { |
|
402 | + if ( ! $this->__is_user_can_edit_license()) { |
|
403 | 403 | return; |
404 | 404 | } |
405 | 405 | |
406 | 406 | // Allow third party add-on developers to handle license deactivation. |
407 | - if ( $this->__is_third_party_addon() ) { |
|
408 | - do_action( 'give_deactivate_license', $this ); |
|
407 | + if ($this->__is_third_party_addon()) { |
|
408 | + do_action('give_deactivate_license', $this); |
|
409 | 409 | |
410 | 410 | return; |
411 | 411 | } |
412 | 412 | |
413 | 413 | // Run on deactivate button press. |
414 | - if ( isset( $_POST[ $this->item_shortname . '_license_key_deactivate' ] ) ) { |
|
414 | + if (isset($_POST[$this->item_shortname.'_license_key_deactivate'])) { |
|
415 | 415 | $this->unset_license(); |
416 | 416 | } |
417 | 417 | } |
@@ -427,30 +427,30 @@ discard block |
||
427 | 427 | public function weekly_license_check() { |
428 | 428 | |
429 | 429 | if ( |
430 | - ! empty( $_POST['give_settings'] ) || |
|
431 | - empty( $this->license ) |
|
430 | + ! empty($_POST['give_settings']) || |
|
431 | + empty($this->license) |
|
432 | 432 | ) { |
433 | 433 | return; |
434 | 434 | } |
435 | 435 | |
436 | 436 | // Allow third party add-on developers to handle their license check. |
437 | - if ( $this->__is_third_party_addon() ) { |
|
438 | - do_action( 'give_weekly_license_check', $this ); |
|
437 | + if ($this->__is_third_party_addon()) { |
|
438 | + do_action('give_weekly_license_check', $this); |
|
439 | 439 | |
440 | 440 | return; |
441 | 441 | } |
442 | 442 | |
443 | 443 | // Make sure there are no api errors. |
444 | - if ( ! ( $license_data = $this->get_license_info( 'check_license' ) ) ) { |
|
444 | + if ( ! ($license_data = $this->get_license_info('check_license'))) { |
|
445 | 445 | return; |
446 | 446 | } |
447 | 447 | |
448 | 448 | // Bailout. |
449 | - if ( ! $this->is_license( $license_data ) ) { |
|
449 | + if ( ! $this->is_license($license_data)) { |
|
450 | 450 | return; |
451 | 451 | } |
452 | 452 | |
453 | - update_option( $this->item_shortname . '_license_active', $license_data ); |
|
453 | + update_option($this->item_shortname.'_license_active', $license_data); |
|
454 | 454 | |
455 | 455 | return; |
456 | 456 | } |
@@ -466,21 +466,21 @@ discard block |
||
466 | 466 | public function weekly_subscription_check() { |
467 | 467 | // Bailout. |
468 | 468 | if ( |
469 | - ! empty( $_POST['give_settings'] ) || |
|
470 | - empty( $this->license ) |
|
469 | + ! empty($_POST['give_settings']) || |
|
470 | + empty($this->license) |
|
471 | 471 | ) { |
472 | 472 | return; |
473 | 473 | } |
474 | 474 | |
475 | 475 | // Remove old subscription data. |
476 | - if ( absint( get_option( '_give_subscriptions_edit_last', true ) ) < current_time( 'timestamp', 1 ) ) { |
|
477 | - delete_option( 'give_subscriptions' ); |
|
478 | - update_option( '_give_subscriptions_edit_last', strtotime( '+ 1 day', current_time( 'timestamp', 1 ) ) ); |
|
476 | + if (absint(get_option('_give_subscriptions_edit_last', true)) < current_time('timestamp', 1)) { |
|
477 | + delete_option('give_subscriptions'); |
|
478 | + update_option('_give_subscriptions_edit_last', strtotime('+ 1 day', current_time('timestamp', 1))); |
|
479 | 479 | } |
480 | 480 | |
481 | 481 | // Allow third party add-on developers to handle their subscription check. |
482 | - if ( $this->__is_third_party_addon() ) { |
|
483 | - do_action( 'give_weekly_subscription_check', $this ); |
|
482 | + if ($this->__is_third_party_addon()) { |
|
483 | + do_action('give_weekly_subscription_check', $this); |
|
484 | 484 | |
485 | 485 | return; |
486 | 486 | } |
@@ -497,7 +497,7 @@ discard block |
||
497 | 497 | * @return void |
498 | 498 | */ |
499 | 499 | private function __single_subscription_check() { |
500 | - if ( empty( $this->license ) ) { |
|
500 | + if (empty($this->license)) { |
|
501 | 501 | return; |
502 | 502 | } |
503 | 503 | |
@@ -508,26 +508,26 @@ discard block |
||
508 | 508 | * By default edd software licensing api does not have api to check subscription. |
509 | 509 | * This is a custom feature to check subscriptions. |
510 | 510 | */ |
511 | - $subscription_data = $this->get_license_info( 'check_subscription', true ); |
|
511 | + $subscription_data = $this->get_license_info('check_subscription', true); |
|
512 | 512 | |
513 | - if ( ! empty( $subscription_data['success'] ) && absint( $subscription_data['success'] ) ) { |
|
513 | + if ( ! empty($subscription_data['success']) && absint($subscription_data['success'])) { |
|
514 | 514 | |
515 | - $subscriptions = get_option( 'give_subscriptions', array() ); |
|
515 | + $subscriptions = get_option('give_subscriptions', array()); |
|
516 | 516 | |
517 | 517 | // Update subscription data only if subscription does not exist already. |
518 | - $subscriptions[ $subscription_data['id'] ] = $subscription_data; |
|
518 | + $subscriptions[$subscription_data['id']] = $subscription_data; |
|
519 | 519 | |
520 | 520 | // Initiate default set of license for subscription. |
521 | - if ( ! isset( $subscriptions[ $subscription_data['id'] ]['licenses'] ) ) { |
|
522 | - $subscriptions[ $subscription_data['id'] ]['licenses'] = array(); |
|
521 | + if ( ! isset($subscriptions[$subscription_data['id']]['licenses'])) { |
|
522 | + $subscriptions[$subscription_data['id']]['licenses'] = array(); |
|
523 | 523 | } |
524 | 524 | |
525 | 525 | // Store licenses for subscription. |
526 | - if ( ! in_array( $this->license, $subscriptions[ $subscription_data['id'] ]['licenses'] ) ) { |
|
527 | - $subscriptions[ $subscription_data['id'] ]['licenses'][] = $this->license; |
|
526 | + if ( ! in_array($this->license, $subscriptions[$subscription_data['id']]['licenses'])) { |
|
527 | + $subscriptions[$subscription_data['id']]['licenses'][] = $this->license; |
|
528 | 528 | } |
529 | 529 | |
530 | - update_option( 'give_subscriptions', $subscriptions ); |
|
530 | + update_option('give_subscriptions', $subscriptions); |
|
531 | 531 | } |
532 | 532 | } |
533 | 533 | |
@@ -541,12 +541,12 @@ discard block |
||
541 | 541 | */ |
542 | 542 | public function notices() { |
543 | 543 | |
544 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
544 | + if ( ! current_user_can('manage_give_settings')) { |
|
545 | 545 | return; |
546 | 546 | } |
547 | 547 | |
548 | 548 | // Do not show licenses notices on license tab. |
549 | - if ( 'licenses' === give_get_current_setting_tab() ) { |
|
549 | + if ('licenses' === give_get_current_setting_tab()) { |
|
550 | 550 | return; |
551 | 551 | } |
552 | 552 | |
@@ -555,118 +555,118 @@ discard block |
||
555 | 555 | static $addon_license_key_in_subscriptions; |
556 | 556 | |
557 | 557 | // Set default value. |
558 | - $addon_license_key_in_subscriptions = ! empty( $addon_license_key_in_subscriptions ) ? $addon_license_key_in_subscriptions : array(); |
|
558 | + $addon_license_key_in_subscriptions = ! empty($addon_license_key_in_subscriptions) ? $addon_license_key_in_subscriptions : array(); |
|
559 | 559 | $messages = array(); |
560 | 560 | |
561 | 561 | // Check whether admin has Give Add-on activated since 24 hours? |
562 | - $is_license_notice_hidden = Give_Cache::get( 'give_cache_hide_license_notice_after_activation' ); |
|
562 | + $is_license_notice_hidden = Give_Cache::get('give_cache_hide_license_notice_after_activation'); |
|
563 | 563 | |
564 | 564 | // Display Invalid License notice, if its more than 24 hours since first Give Add-on activation. |
565 | 565 | if ( |
566 | - empty( $this->license ) |
|
567 | - && empty( $showed_invalid_message ) |
|
568 | - && ( false === $is_license_notice_hidden ) |
|
566 | + empty($this->license) |
|
567 | + && empty($showed_invalid_message) |
|
568 | + && (false === $is_license_notice_hidden) |
|
569 | 569 | ) { |
570 | 570 | |
571 | - Give()->notices->register_notice( array( |
|
571 | + Give()->notices->register_notice(array( |
|
572 | 572 | 'id' => 'give-invalid-license', |
573 | 573 | 'type' => 'error', |
574 | 574 | 'description' => sprintf( |
575 | - __( 'You have invalid or expired license keys for one or more Give Add-ons. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give' ), |
|
576 | - admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=licenses' ) |
|
575 | + __('You have invalid or expired license keys for one or more Give Add-ons. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give'), |
|
576 | + admin_url('edit.php?post_type=give_forms&page=give-settings&tab=licenses') |
|
577 | 577 | ), |
578 | 578 | 'dismissible_type' => 'user', |
579 | 579 | 'dismiss_interval' => 'shortly', |
580 | - ) ); |
|
580 | + )); |
|
581 | 581 | |
582 | 582 | $showed_invalid_message = true; |
583 | 583 | |
584 | 584 | } |
585 | 585 | |
586 | 586 | // Get subscriptions. |
587 | - $subscriptions = get_option( 'give_subscriptions' ); |
|
587 | + $subscriptions = get_option('give_subscriptions'); |
|
588 | 588 | |
589 | 589 | // Show subscription messages. |
590 | - if ( ! empty( $subscriptions ) && ! $showed_subscriptions_message ) { |
|
590 | + if ( ! empty($subscriptions) && ! $showed_subscriptions_message) { |
|
591 | 591 | |
592 | - foreach ( $subscriptions as $subscription ) { |
|
592 | + foreach ($subscriptions as $subscription) { |
|
593 | 593 | // Subscription expires timestamp. |
594 | - $subscription_expires = strtotime( $subscription['expires'] ); |
|
594 | + $subscription_expires = strtotime($subscription['expires']); |
|
595 | 595 | |
596 | 596 | // Start showing subscriptions message before one week of renewal date. |
597 | - if ( strtotime( '- 7 days', $subscription_expires ) > current_time( 'timestamp', 1 ) ) { |
|
597 | + if (strtotime('- 7 days', $subscription_expires) > current_time('timestamp', 1)) { |
|
598 | 598 | continue; |
599 | 599 | } |
600 | 600 | |
601 | 601 | // Check if subscription message already exist in messages. |
602 | - if ( array_key_exists( $subscription['id'], $messages ) ) { |
|
602 | + if (array_key_exists($subscription['id'], $messages)) { |
|
603 | 603 | continue; |
604 | 604 | } |
605 | 605 | |
606 | 606 | // Check if license already expired. |
607 | - if ( strtotime( $subscription['expires'] ) < current_time( 'timestamp', 1 ) ) { |
|
608 | - Give()->notices->register_notice( array( |
|
607 | + if (strtotime($subscription['expires']) < current_time('timestamp', 1)) { |
|
608 | + Give()->notices->register_notice(array( |
|
609 | 609 | 'id' => "give-expired-subscription-{$subscription['id']}", |
610 | 610 | 'type' => 'error', |
611 | 611 | 'description' => sprintf( |
612 | - __( 'Your Give add-on license expired for payment <a href="%1$s" target="_blank">#%2$d</a>. <a href="%3$s" target="_blank">Click to renew an existing license</a> or %4$s.', 'give' ), |
|
613 | - urldecode( $subscription['invoice_url'] ), |
|
612 | + __('Your Give add-on license expired for payment <a href="%1$s" target="_blank">#%2$d</a>. <a href="%3$s" target="_blank">Click to renew an existing license</a> or %4$s.', 'give'), |
|
613 | + urldecode($subscription['invoice_url']), |
|
614 | 614 | $subscription['payment_id'], |
615 | 615 | "{$this->checkout_url}?edd_license_key={$subscription['license_key']}&utm_campaign=admin&utm_source=licenses&utm_medium=expired", |
616 | - Give()->notices->get_dismiss_link( array( |
|
617 | - 'title' => __( 'Click here if already renewed', 'give' ), |
|
616 | + Give()->notices->get_dismiss_link(array( |
|
617 | + 'title' => __('Click here if already renewed', 'give'), |
|
618 | 618 | 'dismissible_type' => 'user', |
619 | 619 | 'dismiss_interval' => 'permanent', |
620 | - ) ) |
|
620 | + )) |
|
621 | 621 | ), |
622 | 622 | 'dismissible_type' => 'user', |
623 | 623 | 'dismiss_interval' => 'shortly', |
624 | - ) ); |
|
624 | + )); |
|
625 | 625 | } else { |
626 | - Give()->notices->register_notice( array( |
|
626 | + Give()->notices->register_notice(array( |
|
627 | 627 | 'id' => "give-expires-subscription-{$subscription['id']}", |
628 | 628 | 'type' => 'error', |
629 | 629 | 'description' => sprintf( |
630 | - __( 'Your Give add-on license will expire in %1$s for payment <a href="%2$s" target="_blank">#%3$d</a>. <a href="%4$s" target="_blank">Click to renew an existing license</a> or %5$s.', 'give' ), |
|
631 | - human_time_diff( current_time( 'timestamp', 1 ), strtotime( $subscription['expires'] ) ), |
|
632 | - urldecode( $subscription['invoice_url'] ), |
|
630 | + __('Your Give add-on license will expire in %1$s for payment <a href="%2$s" target="_blank">#%3$d</a>. <a href="%4$s" target="_blank">Click to renew an existing license</a> or %5$s.', 'give'), |
|
631 | + human_time_diff(current_time('timestamp', 1), strtotime($subscription['expires'])), |
|
632 | + urldecode($subscription['invoice_url']), |
|
633 | 633 | $subscription['payment_id'], |
634 | 634 | "{$this->checkout_url}?edd_license_key={$subscription['license_key']}&utm_campaign=admin&utm_source=licenses&utm_medium=expired", |
635 | - Give()->notices->get_dismiss_link( array( |
|
636 | - 'title' => __( 'Click here if already renewed', 'give' ), |
|
635 | + Give()->notices->get_dismiss_link(array( |
|
636 | + 'title' => __('Click here if already renewed', 'give'), |
|
637 | 637 | 'dismissible_type' => 'user', |
638 | 638 | 'dismiss_interval' => 'permanent', |
639 | - ) ) |
|
639 | + )) |
|
640 | 640 | ), |
641 | 641 | 'dismissible_type' => 'user', |
642 | 642 | 'dismiss_interval' => 'shortly', |
643 | - ) ); |
|
643 | + )); |
|
644 | 644 | } |
645 | 645 | |
646 | 646 | // Stop validation for these license keys. |
647 | - $addon_license_key_in_subscriptions = array_merge( $addon_license_key_in_subscriptions, $subscription['licenses'] ); |
|
647 | + $addon_license_key_in_subscriptions = array_merge($addon_license_key_in_subscriptions, $subscription['licenses']); |
|
648 | 648 | }// End foreach(). |
649 | 649 | $showed_subscriptions_message = true; |
650 | 650 | }// End if(). |
651 | 651 | |
652 | 652 | // Show Non Subscription Give Add-on messages. |
653 | 653 | if ( |
654 | - ! in_array( $this->license, $addon_license_key_in_subscriptions ) |
|
655 | - && ! empty( $this->license ) |
|
656 | - && empty( $showed_invalid_message ) |
|
654 | + ! in_array($this->license, $addon_license_key_in_subscriptions) |
|
655 | + && ! empty($this->license) |
|
656 | + && empty($showed_invalid_message) |
|
657 | 657 | && ! $this->is_valid_license() |
658 | 658 | ) { |
659 | 659 | |
660 | - Give()->notices->register_notice( array( |
|
660 | + Give()->notices->register_notice(array( |
|
661 | 661 | 'id' => 'give-invalid-license', |
662 | 662 | 'type' => 'error', |
663 | 663 | 'description' => sprintf( |
664 | - __( 'You have invalid or expired license keys for one or more Give Add-ons. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give' ), |
|
665 | - admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=licenses' ) |
|
664 | + __('You have invalid or expired license keys for one or more Give Add-ons. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give'), |
|
665 | + admin_url('edit.php?post_type=give_forms&page=give-settings&tab=licenses') |
|
666 | 666 | ), |
667 | 667 | 'dismissible_type' => 'user', |
668 | 668 | 'dismiss_interval' => 'shortly', |
669 | - ) ); |
|
669 | + )); |
|
670 | 670 | |
671 | 671 | $showed_invalid_message = true; |
672 | 672 | |
@@ -683,10 +683,10 @@ discard block |
||
683 | 683 | * |
684 | 684 | * @return bool |
685 | 685 | */ |
686 | - public function is_valid_license( $licence_data = null ) { |
|
687 | - $license_data = empty( $licence_data ) ? $this->license_data : $licence_data; |
|
686 | + public function is_valid_license($licence_data = null) { |
|
687 | + $license_data = empty($licence_data) ? $this->license_data : $licence_data; |
|
688 | 688 | |
689 | - if ( apply_filters( 'give_is_valid_license', ( $this->is_license( $license_data ) && 'valid' === $license_data->license ) ) ) { |
|
689 | + if (apply_filters('give_is_valid_license', ($this->is_license($license_data) && 'valid' === $license_data->license))) { |
|
690 | 690 | return true; |
691 | 691 | } |
692 | 692 | |
@@ -704,10 +704,10 @@ discard block |
||
704 | 704 | * |
705 | 705 | * @return bool |
706 | 706 | */ |
707 | - public function is_license( $licence_data = null ) { |
|
708 | - $license_data = empty( $licence_data ) ? $this->license_data : $licence_data; |
|
707 | + public function is_license($licence_data = null) { |
|
708 | + $license_data = empty($licence_data) ? $this->license_data : $licence_data; |
|
709 | 709 | |
710 | - if ( apply_filters( 'give_is_license', ( is_object( $license_data ) && ! empty( $license_data ) && property_exists( $license_data, 'license' ) ) ) ) { |
|
710 | + if (apply_filters('give_is_license', (is_object($license_data) && ! empty($license_data) && property_exists($license_data, 'license')))) { |
|
711 | 711 | return true; |
712 | 712 | } |
713 | 713 | |
@@ -723,7 +723,7 @@ discard block |
||
723 | 723 | * @return bool |
724 | 724 | */ |
725 | 725 | private function __is_third_party_addon() { |
726 | - return ( false === strpos( $this->api_url, 'givewp.com/' ) ); |
|
726 | + return (false === strpos($this->api_url, 'givewp.com/')); |
|
727 | 727 | } |
728 | 728 | |
729 | 729 | /** |
@@ -738,25 +738,25 @@ discard block |
||
738 | 738 | * @return bool |
739 | 739 | */ |
740 | 740 | private function __remove_license_key_from_subscriptions() { |
741 | - $subscriptions = get_option( 'give_subscriptions', array() ); |
|
741 | + $subscriptions = get_option('give_subscriptions', array()); |
|
742 | 742 | |
743 | 743 | // Bailout. |
744 | - if ( empty( $this->license ) ) { |
|
744 | + if (empty($this->license)) { |
|
745 | 745 | return false; |
746 | 746 | } |
747 | 747 | |
748 | - if ( ! empty( $subscriptions ) ) { |
|
749 | - foreach ( $subscriptions as $subscription_id => $subscription ) { |
|
750 | - $license_index = array_search( $this->license, $subscription['licenses'] ); |
|
751 | - if ( false !== $license_index ) { |
|
748 | + if ( ! empty($subscriptions)) { |
|
749 | + foreach ($subscriptions as $subscription_id => $subscription) { |
|
750 | + $license_index = array_search($this->license, $subscription['licenses']); |
|
751 | + if (false !== $license_index) { |
|
752 | 752 | // Remove license key. |
753 | - unset( $subscriptions[ $subscription_id ]['licenses'][ $license_index ] ); |
|
753 | + unset($subscriptions[$subscription_id]['licenses'][$license_index]); |
|
754 | 754 | |
755 | 755 | // Rearrange license keys. |
756 | - $subscriptions[ $subscription_id ]['licenses'] = array_values( $subscriptions[ $subscription_id ]['licenses'] ); |
|
756 | + $subscriptions[$subscription_id]['licenses'] = array_values($subscriptions[$subscription_id]['licenses']); |
|
757 | 757 | |
758 | 758 | // Update subscription information. |
759 | - update_option( 'give_subscriptions', $subscriptions ); |
|
759 | + update_option('give_subscriptions', $subscriptions); |
|
760 | 760 | break; |
761 | 761 | } |
762 | 762 | } |
@@ -770,17 +770,17 @@ discard block |
||
770 | 770 | * |
771 | 771 | * @return bool |
772 | 772 | */ |
773 | - public function plugin_page_notices( $plugin_file, $plugin_data, $status ) { |
|
773 | + public function plugin_page_notices($plugin_file, $plugin_data, $status) { |
|
774 | 774 | // Bailout. |
775 | - if ( $this->is_valid_license() ) { |
|
775 | + if ($this->is_valid_license()) { |
|
776 | 776 | return false; |
777 | 777 | } |
778 | 778 | |
779 | 779 | $update_notice_wrap = '<tr class="give-addon-notice-tr active"><td colspan="3" class="colspanchange"><div class="notice inline notice-warning notice-alt give-invalid-license"><p><span class="dashicons dashicons-info"></span> %s</p></div></td></tr>'; |
780 | 780 | $message = $this->license_state_message(); |
781 | 781 | |
782 | - if ( ! empty( $message['message'] ) ) { |
|
783 | - echo sprintf( $update_notice_wrap, $message['message'] ); |
|
782 | + if ( ! empty($message['message'])) { |
|
783 | + echo sprintf($update_notice_wrap, $message['message']); |
|
784 | 784 | } |
785 | 785 | } |
786 | 786 | |
@@ -795,11 +795,11 @@ discard block |
||
795 | 795 | public function license_state_message() { |
796 | 796 | $message_data = array(); |
797 | 797 | |
798 | - if ( ! $this->is_valid_license() ) { |
|
798 | + if ( ! $this->is_valid_license()) { |
|
799 | 799 | |
800 | 800 | $message_data['message'] = sprintf( |
801 | 801 | 'Please <a href="%1$s">activate your license</a> to receive updates and support for the %2$s add-on.', |
802 | - esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=licenses' ) ), |
|
802 | + esc_url(admin_url('edit.php?post_type=give_forms&page=give-settings&tab=licenses')), |
|
803 | 803 | $this->item_name |
804 | 804 | ); |
805 | 805 | } |
@@ -818,7 +818,7 @@ discard block |
||
818 | 818 | // Bailout. |
819 | 819 | if ( |
820 | 820 | ! Give_Admin_Settings::verify_nonce() || |
821 | - ! current_user_can( 'manage_give_settings' ) || |
|
821 | + ! current_user_can('manage_give_settings') || |
|
822 | 822 | 'licenses' !== give_get_current_setting_tab() |
823 | 823 | ) { |
824 | 824 | return false; |
@@ -826,10 +826,10 @@ discard block |
||
826 | 826 | |
827 | 827 | // Security check. |
828 | 828 | if ( |
829 | - isset( $_POST[ $this->item_shortname . '_license_key-nonce' ] ) && |
|
830 | - ! wp_verify_nonce( $_REQUEST[ $this->item_shortname . '_license_key-nonce' ], $this->item_shortname . '_license_key-nonce' ) |
|
829 | + isset($_POST[$this->item_shortname.'_license_key-nonce']) && |
|
830 | + ! wp_verify_nonce($_REQUEST[$this->item_shortname.'_license_key-nonce'], $this->item_shortname.'_license_key-nonce') |
|
831 | 831 | ) { |
832 | - wp_die( __( 'Nonce verification failed.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
832 | + wp_die(__('Nonce verification failed.', 'give'), __('Error', 'give'), array('response' => 403)); |
|
833 | 833 | } |
834 | 834 | |
835 | 835 | return true; |
@@ -847,9 +847,9 @@ discard block |
||
847 | 847 | * |
848 | 848 | * @return mixed |
849 | 849 | */ |
850 | - public function get_license_info( $edd_action = '', $response_in_array = false ) { |
|
850 | + public function get_license_info($edd_action = '', $response_in_array = false) { |
|
851 | 851 | |
852 | - if ( empty( $edd_action ) ) { |
|
852 | + if (empty($edd_action)) { |
|
853 | 853 | return false; |
854 | 854 | } |
855 | 855 | |
@@ -857,7 +857,7 @@ discard block |
||
857 | 857 | $api_params = array( |
858 | 858 | 'edd_action' => $edd_action, // never change from "edd_" to "give_"! |
859 | 859 | 'license' => $this->license, |
860 | - 'item_name' => urlencode( $this->item_name ), |
|
860 | + 'item_name' => urlencode($this->item_name), |
|
861 | 861 | 'url' => home_url(), |
862 | 862 | ); |
863 | 863 | |
@@ -872,11 +872,11 @@ discard block |
||
872 | 872 | ); |
873 | 873 | |
874 | 874 | // Make sure there are no errors. |
875 | - if ( is_wp_error( $response ) ) { |
|
875 | + if (is_wp_error($response)) { |
|
876 | 876 | return false; |
877 | 877 | } |
878 | 878 | |
879 | - return json_decode( wp_remote_retrieve_body( $response ), $response_in_array ); |
|
879 | + return json_decode(wp_remote_retrieve_body($response), $response_in_array); |
|
880 | 880 | } |
881 | 881 | |
882 | 882 | |
@@ -892,9 +892,9 @@ discard block |
||
892 | 892 | $this->__remove_license_key_from_subscriptions(); |
893 | 893 | |
894 | 894 | // Remove license from database. |
895 | - delete_option( "{$this->item_shortname}_license_active" ); |
|
896 | - give_delete_option( "{$this->item_shortname}_license_key" ); |
|
897 | - unset( $_POST["{$this->item_shortname}_license_key"] ); |
|
895 | + delete_option("{$this->item_shortname}_license_active"); |
|
896 | + give_delete_option("{$this->item_shortname}_license_key"); |
|
897 | + unset($_POST["{$this->item_shortname}_license_key"]); |
|
898 | 898 | |
899 | 899 | // Unset license param. |
900 | 900 | $this->license = ''; |
@@ -912,8 +912,8 @@ discard block |
||
912 | 912 | private function is_deactivating_license() { |
913 | 913 | $status = false; |
914 | 914 | |
915 | - foreach ( $_POST as $key => $value ) { |
|
916 | - if ( false !== strpos( $key, 'license_key_deactivate' ) ) { |
|
915 | + foreach ($_POST as $key => $value) { |
|
916 | + if (false !== strpos($key, 'license_key_deactivate')) { |
|
917 | 917 | $status = true; |
918 | 918 | break; |
919 | 919 | } |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | * @param $end_date string|bool The end date for which we'd like to filter our sale stats. If false, we'll use the default end date of `this_month` |
37 | 37 | * @param $status string|array The sale status(es) to count. Only valid when retrieving global stats |
38 | 38 | * |
39 | - * @return float|int Total amount of donations based on the passed arguments. |
|
39 | + * @return string Total amount of donations based on the passed arguments. |
|
40 | 40 | */ |
41 | 41 | public function get_sales( $form_id = 0, $start_date = false, $end_date = false, $status = 'publish' ) { |
42 | 42 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | * @param $end_date string|bool The end date for which we'd like to filter the donations stats. If false, method will use the default end date of `this_month`. |
84 | 84 | * @param $gateway_id string|bool The gateway to get earnings for such as 'paypal' or 'stripe'. |
85 | 85 | * |
86 | - * @return float|int Total amount of donations based on the passed arguments. |
|
86 | + * @return string Total amount of donations based on the passed arguments. |
|
87 | 87 | */ |
88 | 88 | public function get_earnings( $form_id = 0, $start_date = false, $end_date = false, $gateway_id = false ) { |
89 | 89 | $this->setup_dates( $start_date, $end_date ); |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | * @param $end_date string|bool The end date for which we'd like to filter our sale stats. If false, we'll use the default end date of `this_month` |
169 | 169 | * @param $gateway_id string|bool The gateway to get earnings for such as 'paypal' or 'stripe' |
170 | 170 | * |
171 | - * @return float|int Total amount of donations based on the passed arguments. |
|
171 | + * @return string Total amount of donations based on the passed arguments. |
|
172 | 172 | */ |
173 | 173 | public function get_earnings_cache_key( $form_id = 0, $start_date = false, $end_date = false, $gateway_id = false ) { |
174 | 174 |
@@ -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 | |
@@ -38,17 +38,17 @@ discard block |
||
38 | 38 | * |
39 | 39 | * @return float|int Total amount of donations based on the passed arguments. |
40 | 40 | */ |
41 | - public function get_sales( $form_id = 0, $start_date = false, $end_date = false, $status = 'publish' ) { |
|
41 | + public function get_sales($form_id = 0, $start_date = false, $end_date = false, $status = 'publish') { |
|
42 | 42 | |
43 | - $this->setup_dates( $start_date, $end_date ); |
|
43 | + $this->setup_dates($start_date, $end_date); |
|
44 | 44 | |
45 | 45 | // Make sure start date is valid |
46 | - if ( is_wp_error( $this->start_date ) ) { |
|
46 | + if (is_wp_error($this->start_date)) { |
|
47 | 47 | return $this->start_date; |
48 | 48 | } |
49 | 49 | |
50 | 50 | // Make sure end date is valid |
51 | - if ( is_wp_error( $this->end_date ) ) { |
|
51 | + if (is_wp_error($this->end_date)) { |
|
52 | 52 | return $this->end_date; |
53 | 53 | } |
54 | 54 | |
@@ -57,18 +57,18 @@ discard block |
||
57 | 57 | 'start_date' => $this->start_date, |
58 | 58 | 'end_date' => $this->end_date, |
59 | 59 | 'fields' => 'ids', |
60 | - 'number' => - 1, |
|
60 | + 'number' => -1, |
|
61 | 61 | ); |
62 | 62 | |
63 | - if ( ! empty( $form_id ) ) { |
|
63 | + if ( ! empty($form_id)) { |
|
64 | 64 | $args['give_forms'] = $form_id; |
65 | 65 | } |
66 | 66 | |
67 | 67 | /* @var Give_Payments_Query $payments */ |
68 | - $payments = new Give_Payments_Query( $args ); |
|
68 | + $payments = new Give_Payments_Query($args); |
|
69 | 69 | $payments = $payments->get_payments(); |
70 | 70 | |
71 | - return count( $payments ); |
|
71 | + return count($payments); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | |
@@ -85,16 +85,16 @@ discard block |
||
85 | 85 | * |
86 | 86 | * @return float|int Total amount of donations based on the passed arguments. |
87 | 87 | */ |
88 | - public function get_earnings( $form_id = 0, $start_date = false, $end_date = false, $gateway_id = false ) { |
|
89 | - $this->setup_dates( $start_date, $end_date ); |
|
88 | + public function get_earnings($form_id = 0, $start_date = false, $end_date = false, $gateway_id = false) { |
|
89 | + $this->setup_dates($start_date, $end_date); |
|
90 | 90 | |
91 | 91 | // Make sure start date is valid |
92 | - if ( is_wp_error( $this->start_date ) ) { |
|
92 | + if (is_wp_error($this->start_date)) { |
|
93 | 93 | return $this->start_date; |
94 | 94 | } |
95 | 95 | |
96 | 96 | // Make sure end date is valid |
97 | - if ( is_wp_error( $this->end_date ) ) { |
|
97 | + if (is_wp_error($this->end_date)) { |
|
98 | 98 | return $this->end_date; |
99 | 99 | } |
100 | 100 | |
@@ -104,12 +104,12 @@ discard block |
||
104 | 104 | 'start_date' => $this->start_date, |
105 | 105 | 'end_date' => $this->end_date, |
106 | 106 | 'fields' => 'ids', |
107 | - 'number' => - 1, |
|
107 | + 'number' => -1, |
|
108 | 108 | ); |
109 | 109 | |
110 | 110 | |
111 | 111 | // Filter by Gateway ID meta_key |
112 | - if ( $gateway_id ) { |
|
112 | + if ($gateway_id) { |
|
113 | 113 | $args['meta_query'][] = array( |
114 | 114 | 'key' => '_give_payment_gateway', |
115 | 115 | 'value' => $gateway_id, |
@@ -117,39 +117,39 @@ discard block |
||
117 | 117 | } |
118 | 118 | |
119 | 119 | // Filter by Gateway ID meta_key |
120 | - if ( $form_id ) { |
|
120 | + if ($form_id) { |
|
121 | 121 | $args['meta_query'][] = array( |
122 | 122 | 'key' => '_give_payment_form_id', |
123 | 123 | 'value' => $form_id, |
124 | 124 | ); |
125 | 125 | } |
126 | 126 | |
127 | - if ( ! empty( $args['meta_query'] ) && 1 < count( $args['meta_query'] ) ) { |
|
127 | + if ( ! empty($args['meta_query']) && 1 < count($args['meta_query'])) { |
|
128 | 128 | $args['meta_query']['relation'] = 'AND'; |
129 | 129 | } |
130 | 130 | |
131 | - $args = apply_filters( 'give_stats_earnings_args', $args ); |
|
132 | - $key = Give_Cache::get_key( 'give_stats', $args ); |
|
131 | + $args = apply_filters('give_stats_earnings_args', $args); |
|
132 | + $key = Give_Cache::get_key('give_stats', $args); |
|
133 | 133 | |
134 | 134 | // Set transient for faster stats. |
135 | - $earnings = Give_Cache::get( $key ); |
|
135 | + $earnings = Give_Cache::get($key); |
|
136 | 136 | |
137 | - if ( false === $earnings ) { |
|
137 | + if (false === $earnings) { |
|
138 | 138 | |
139 | 139 | $this->timestamp = false; |
140 | - $payments = new Give_Payments_Query( $args ); |
|
140 | + $payments = new Give_Payments_Query($args); |
|
141 | 141 | $payments = $payments->get_payments(); |
142 | 142 | $earnings = 0; |
143 | 143 | |
144 | - if ( ! empty( $payments ) ) { |
|
145 | - foreach ( $payments as $payment ) { |
|
146 | - $earnings += give_donation_amount( $payment->ID ); |
|
144 | + if ( ! empty($payments)) { |
|
145 | + foreach ($payments as $payment) { |
|
146 | + $earnings += give_donation_amount($payment->ID); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | } |
150 | 150 | |
151 | 151 | // Cache the results for one hour. |
152 | - Give_Cache::set( $key, give_sanitize_amount_for_db( $earnings ), 60 * 60 ); |
|
152 | + Give_Cache::set($key, give_sanitize_amount_for_db($earnings), 60 * 60); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | /** |
@@ -163,10 +163,10 @@ discard block |
||
163 | 163 | * @param string|bool $end_date Earning end date. |
164 | 164 | * @param string|bool $gateway_id Payment gateway id. |
165 | 165 | */ |
166 | - $earnings = apply_filters( 'give_get_earnings', $earnings, $form_id, $start_date, $end_date, $gateway_id ); |
|
166 | + $earnings = apply_filters('give_get_earnings', $earnings, $form_id, $start_date, $end_date, $gateway_id); |
|
167 | 167 | |
168 | 168 | //return earnings |
169 | - return round( $earnings, give_get_price_decimals( $form_id ) ); |
|
169 | + return round($earnings, give_get_price_decimals($form_id)); |
|
170 | 170 | |
171 | 171 | } |
172 | 172 | |
@@ -183,17 +183,17 @@ discard block |
||
183 | 183 | * |
184 | 184 | * @return float|int Total amount of donations based on the passed arguments. |
185 | 185 | */ |
186 | - public function get_earnings_cache_key( $form_id = 0, $start_date = false, $end_date = false, $gateway_id = false ) { |
|
186 | + public function get_earnings_cache_key($form_id = 0, $start_date = false, $end_date = false, $gateway_id = false) { |
|
187 | 187 | |
188 | - $this->setup_dates( $start_date, $end_date ); |
|
188 | + $this->setup_dates($start_date, $end_date); |
|
189 | 189 | |
190 | 190 | // Make sure start date is valid |
191 | - if ( is_wp_error( $this->start_date ) ) { |
|
191 | + if (is_wp_error($this->start_date)) { |
|
192 | 192 | return $this->start_date; |
193 | 193 | } |
194 | 194 | |
195 | 195 | // Make sure end date is valid |
196 | - if ( is_wp_error( $this->end_date ) ) { |
|
196 | + if (is_wp_error($this->end_date)) { |
|
197 | 197 | return $this->end_date; |
198 | 198 | } |
199 | 199 | |
@@ -203,12 +203,12 @@ discard block |
||
203 | 203 | 'start_date' => $this->start_date, |
204 | 204 | 'end_date' => $this->end_date, |
205 | 205 | 'fields' => 'ids', |
206 | - 'number' => - 1, |
|
206 | + 'number' => -1, |
|
207 | 207 | ); |
208 | 208 | |
209 | 209 | |
210 | 210 | // Filter by Gateway ID meta_key |
211 | - if ( $gateway_id ) { |
|
211 | + if ($gateway_id) { |
|
212 | 212 | $args['meta_query'][] = array( |
213 | 213 | 'key' => '_give_payment_gateway', |
214 | 214 | 'value' => $gateway_id, |
@@ -216,19 +216,19 @@ discard block |
||
216 | 216 | } |
217 | 217 | |
218 | 218 | // Filter by Gateway ID meta_key |
219 | - if ( $form_id ) { |
|
219 | + if ($form_id) { |
|
220 | 220 | $args['meta_query'][] = array( |
221 | 221 | 'key' => '_give_payment_form_id', |
222 | 222 | 'value' => $form_id, |
223 | 223 | ); |
224 | 224 | } |
225 | 225 | |
226 | - if ( ! empty( $args['meta_query'] ) && 1 < count( $args['meta_query'] ) ) { |
|
226 | + if ( ! empty($args['meta_query']) && 1 < count($args['meta_query'])) { |
|
227 | 227 | $args['meta_query']['relation'] = 'AND'; |
228 | 228 | } |
229 | 229 | |
230 | - $args = apply_filters( 'give_stats_earnings_args', $args ); |
|
231 | - $key = Give_Cache::get_key( 'give_stats', $args ); |
|
230 | + $args = apply_filters('give_stats_earnings_args', $args); |
|
231 | + $key = Give_Cache::get_key('give_stats', $args); |
|
232 | 232 | |
233 | 233 | //return earnings |
234 | 234 | return $key; |
@@ -245,16 +245,16 @@ discard block |
||
245 | 245 | * |
246 | 246 | * @return array Best selling forms |
247 | 247 | */ |
248 | - public function get_best_selling( $number = 10 ) { |
|
248 | + public function get_best_selling($number = 10) { |
|
249 | 249 | |
250 | 250 | global $wpdb; |
251 | 251 | |
252 | - $give_forms = $wpdb->get_results( $wpdb->prepare( |
|
252 | + $give_forms = $wpdb->get_results($wpdb->prepare( |
|
253 | 253 | "SELECT post_id as form_id, max(meta_value) as sales |
254 | 254 | FROM $wpdb->postmeta WHERE meta_key='_give_form_sales' AND meta_value > 0 |
255 | 255 | GROUP BY meta_value+0 |
256 | 256 | DESC LIMIT %d;", $number |
257 | - ) ); |
|
257 | + )); |
|
258 | 258 | |
259 | 259 | return $give_forms; |
260 | 260 | } |