@@ -50,7 +50,7 @@ |
||
50 | 50 | * @since 1.5 |
51 | 51 | * @global object $wpdb Used to query the database using the WordPress |
52 | 52 | * Database API |
53 | - * @return array $data The data for the CSV file |
|
53 | + * @return boolean $data The data for the CSV file |
|
54 | 54 | */ |
55 | 55 | public function get_data() { |
56 | 56 | global $wpdb; |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | */ |
12 | 12 | |
13 | 13 | // Exit if accessed directly |
14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
14 | +if ( ! defined('ABSPATH')) { |
|
15 | 15 | exit; |
16 | 16 | } |
17 | 17 | |
@@ -55,26 +55,26 @@ discard block |
||
55 | 55 | public function get_data() { |
56 | 56 | global $give_logs, $wpdb; |
57 | 57 | |
58 | - $totals = $this->get_stored_data( 'give_temp_recount_all_stats' ); |
|
59 | - $payment_items = $this->get_stored_data( 'give_temp_payment_items' ); |
|
60 | - $processed_payments = $this->get_stored_data( 'give_temp_processed_payments' ); |
|
61 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish', 'revoked' ) ); |
|
58 | + $totals = $this->get_stored_data('give_temp_recount_all_stats'); |
|
59 | + $payment_items = $this->get_stored_data('give_temp_payment_items'); |
|
60 | + $processed_payments = $this->get_stored_data('give_temp_processed_payments'); |
|
61 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish', 'revoked')); |
|
62 | 62 | |
63 | - if ( false === $totals ) { |
|
63 | + if (false === $totals) { |
|
64 | 64 | $totals = array(); |
65 | 65 | } |
66 | 66 | |
67 | - if ( false === $payment_items ) { |
|
67 | + if (false === $payment_items) { |
|
68 | 68 | $payment_items = array(); |
69 | 69 | } |
70 | 70 | |
71 | - if ( false === $processed_payments ) { |
|
71 | + if (false === $processed_payments) { |
|
72 | 72 | $processed_payments = array(); |
73 | 73 | } |
74 | 74 | |
75 | - $all_forms = $this->get_stored_data( 'give_temp_form_ids' ); |
|
75 | + $all_forms = $this->get_stored_data('give_temp_form_ids'); |
|
76 | 76 | |
77 | - $args = apply_filters( 'give_recount_form_stats_args', array( |
|
77 | + $args = apply_filters('give_recount_form_stats_args', array( |
|
78 | 78 | 'post_parent__in' => $all_forms, |
79 | 79 | 'post_type' => 'give_log', |
80 | 80 | 'posts_per_page' => $this->per_step, |
@@ -82,73 +82,73 @@ discard block |
||
82 | 82 | 'paged' => $this->step, |
83 | 83 | 'log_type' => 'sale', |
84 | 84 | 'fields' => 'ids', |
85 | - ) ); |
|
85 | + )); |
|
86 | 86 | |
87 | - $log_ids = $give_logs->get_connected_logs( $args, 'sale' ); |
|
87 | + $log_ids = $give_logs->get_connected_logs($args, 'sale'); |
|
88 | 88 | |
89 | - if ( $log_ids ) { |
|
90 | - $log_ids = implode( ',', $log_ids ); |
|
89 | + if ($log_ids) { |
|
90 | + $log_ids = implode(',', $log_ids); |
|
91 | 91 | |
92 | - $payment_ids = $wpdb->get_col( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids)" ); |
|
93 | - unset( $log_ids ); |
|
92 | + $payment_ids = $wpdb->get_col("SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids)"); |
|
93 | + unset($log_ids); |
|
94 | 94 | |
95 | - $payment_ids = implode( ',', $payment_ids ); |
|
96 | - $payments = $wpdb->get_results( "SELECT ID, post_status FROM $wpdb->posts WHERE ID IN (" . $payment_ids . ")" ); |
|
97 | - unset( $payment_ids ); |
|
95 | + $payment_ids = implode(',', $payment_ids); |
|
96 | + $payments = $wpdb->get_results("SELECT ID, post_status FROM $wpdb->posts WHERE ID IN (".$payment_ids.")"); |
|
97 | + unset($payment_ids); |
|
98 | 98 | |
99 | 99 | //Loop through payments |
100 | - foreach ( $payments as $payment ) { |
|
100 | + foreach ($payments as $payment) { |
|
101 | 101 | |
102 | 102 | // Prevent payments that have all ready been retrieved from a previous sales log from counting again. |
103 | - if ( in_array( $payment->ID, $processed_payments ) ) { |
|
103 | + if (in_array($payment->ID, $processed_payments)) { |
|
104 | 104 | continue; |
105 | 105 | } |
106 | 106 | |
107 | 107 | //Verify accepted status' |
108 | - if ( ! in_array( $payment->post_status, $accepted_statuses ) ) { |
|
108 | + if ( ! in_array($payment->post_status, $accepted_statuses)) { |
|
109 | 109 | $processed_payments[] = $payment->ID; |
110 | 110 | continue; |
111 | 111 | } |
112 | 112 | |
113 | - $payment_item = $payment_items[ $payment->ID ]; |
|
113 | + $payment_item = $payment_items[$payment->ID]; |
|
114 | 114 | |
115 | 115 | |
116 | - $form_id = isset( $payment_item['id'] ) ? $payment_item['id'] : ''; |
|
116 | + $form_id = isset($payment_item['id']) ? $payment_item['id'] : ''; |
|
117 | 117 | |
118 | 118 | //Must have a form ID |
119 | - if ( empty( $form_id ) ) { |
|
119 | + if (empty($form_id)) { |
|
120 | 120 | continue; |
121 | 121 | } |
122 | 122 | |
123 | 123 | //Form ID must be within $all_forms array to be validated |
124 | - if ( ! in_array( $form_id, $all_forms ) ) { |
|
124 | + if ( ! in_array($form_id, $all_forms)) { |
|
125 | 125 | continue; |
126 | 126 | } |
127 | 127 | |
128 | 128 | //If array key doesn't exist, create it |
129 | - if ( ! array_key_exists( $form_id, $totals ) ) { |
|
130 | - $totals[ $form_id ] = array( |
|
129 | + if ( ! array_key_exists($form_id, $totals)) { |
|
130 | + $totals[$form_id] = array( |
|
131 | 131 | 'sales' => (int) 0, |
132 | 132 | 'earnings' => (float) 0, |
133 | 133 | ); |
134 | 134 | } |
135 | 135 | |
136 | - $totals[ $form_id ]['sales'] ++; |
|
137 | - $totals[ $form_id ]['earnings'] += $payment_item['price']; |
|
136 | + $totals[$form_id]['sales']++; |
|
137 | + $totals[$form_id]['earnings'] += $payment_item['price']; |
|
138 | 138 | |
139 | 139 | $processed_payments[] = $payment->ID; |
140 | 140 | |
141 | 141 | } |
142 | 142 | |
143 | - $this->store_data( 'give_temp_processed_payments', $processed_payments ); |
|
144 | - $this->store_data( 'give_temp_recount_all_stats', $totals ); |
|
143 | + $this->store_data('give_temp_processed_payments', $processed_payments); |
|
144 | + $this->store_data('give_temp_recount_all_stats', $totals); |
|
145 | 145 | |
146 | 146 | return true; |
147 | 147 | } |
148 | 148 | |
149 | - foreach ( $totals as $key => $stats ) { |
|
150 | - update_post_meta( $key, '_give_form_sales', $stats['sales'] ); |
|
151 | - update_post_meta( $key, '_give_form_earnings', $stats['earnings'] ); |
|
149 | + foreach ($totals as $key => $stats) { |
|
150 | + update_post_meta($key, '_give_form_sales', $stats['sales']); |
|
151 | + update_post_meta($key, '_give_form_earnings', $stats['earnings']); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | return false; |
@@ -163,20 +163,20 @@ discard block |
||
163 | 163 | */ |
164 | 164 | public function get_percentage_complete() { |
165 | 165 | |
166 | - $total = $this->get_stored_data( 'give_recount_all_total', false ); |
|
166 | + $total = $this->get_stored_data('give_recount_all_total', false); |
|
167 | 167 | |
168 | - if ( false === $total ) { |
|
168 | + if (false === $total) { |
|
169 | 169 | $this->pre_fetch(); |
170 | - $total = $this->get_stored_data( 'give_recount_all_total', 0 ); |
|
170 | + $total = $this->get_stored_data('give_recount_all_total', 0); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | $percentage = 100; |
174 | 174 | |
175 | - if ( $total > 0 ) { |
|
176 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
175 | + if ($total > 0) { |
|
176 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
177 | 177 | } |
178 | 178 | |
179 | - if ( $percentage > 100 ) { |
|
179 | + if ($percentage > 100) { |
|
180 | 180 | $percentage = 100; |
181 | 181 | } |
182 | 182 | |
@@ -190,8 +190,8 @@ discard block |
||
190 | 190 | * |
191 | 191 | * @param array $request The Form Data passed into the batch processing |
192 | 192 | */ |
193 | - public function set_properties( $request ) { |
|
194 | - $this->form_id = isset( $request['form_id'] ) ? sanitize_text_field( $request['form_id'] ) : false; |
|
193 | + public function set_properties($request) { |
|
194 | + $this->form_id = isset($request['form_id']) ? sanitize_text_field($request['form_id']) : false; |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | /** |
@@ -202,34 +202,34 @@ discard block |
||
202 | 202 | */ |
203 | 203 | public function process_step() { |
204 | 204 | |
205 | - if ( ! $this->can_export() ) { |
|
206 | - wp_die( __( 'You do not have permission to recount stats.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
205 | + if ( ! $this->can_export()) { |
|
206 | + wp_die(__('You do not have permission to recount stats.', 'give'), __('Error', 'give'), array('response' => 403)); |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | $had_data = $this->get_data(); |
210 | 210 | |
211 | - if ( $had_data ) { |
|
211 | + if ($had_data) { |
|
212 | 212 | $this->done = false; |
213 | 213 | |
214 | 214 | return true; |
215 | 215 | } else { |
216 | - $this->delete_data( 'give_recount_all_total' ); |
|
217 | - $this->delete_data( 'give_temp_recount_all_stats' ); |
|
218 | - $this->delete_data( 'give_temp_payment_items' ); |
|
219 | - $this->delete_data( 'give_temp_form_ids' ); |
|
220 | - $this->delete_data( 'give_temp_processed_payments' ); |
|
216 | + $this->delete_data('give_recount_all_total'); |
|
217 | + $this->delete_data('give_temp_recount_all_stats'); |
|
218 | + $this->delete_data('give_temp_payment_items'); |
|
219 | + $this->delete_data('give_temp_form_ids'); |
|
220 | + $this->delete_data('give_temp_processed_payments'); |
|
221 | 221 | $this->done = true; |
222 | - $this->message = __( 'Donation form income amounts and donation counts stats successfully recounted.', 'give' ); |
|
222 | + $this->message = __('Donation form income amounts and donation counts stats successfully recounted.', 'give'); |
|
223 | 223 | |
224 | 224 | return false; |
225 | 225 | } |
226 | 226 | } |
227 | 227 | |
228 | 228 | public function headers() { |
229 | - ignore_user_abort( true ); |
|
229 | + ignore_user_abort(true); |
|
230 | 230 | |
231 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
232 | - set_time_limit( 0 ); |
|
231 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
232 | + set_time_limit(0); |
|
233 | 233 | } |
234 | 234 | } |
235 | 235 | |
@@ -258,76 +258,76 @@ discard block |
||
258 | 258 | |
259 | 259 | global $give_logs, $wpdb; |
260 | 260 | |
261 | - if ( $this->step == 1 ) { |
|
262 | - $this->delete_data( 'give_temp_recount_all_total' ); |
|
263 | - $this->delete_data( 'give_temp_recount_all_stats' ); |
|
264 | - $this->delete_data( 'give_temp_payment_items' ); |
|
265 | - $this->delete_data( 'give_temp_processed_payments' ); |
|
261 | + if ($this->step == 1) { |
|
262 | + $this->delete_data('give_temp_recount_all_total'); |
|
263 | + $this->delete_data('give_temp_recount_all_stats'); |
|
264 | + $this->delete_data('give_temp_payment_items'); |
|
265 | + $this->delete_data('give_temp_processed_payments'); |
|
266 | 266 | } |
267 | 267 | |
268 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish', 'revoked' ) ); |
|
269 | - $total = $this->get_stored_data( 'give_temp_recount_all_total' ); |
|
268 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish', 'revoked')); |
|
269 | + $total = $this->get_stored_data('give_temp_recount_all_total'); |
|
270 | 270 | |
271 | - if ( false === $total ) { |
|
271 | + if (false === $total) { |
|
272 | 272 | $total = 0; |
273 | - $payment_items = $this->get_stored_data( 'give_temp_payment_items' ); |
|
273 | + $payment_items = $this->get_stored_data('give_temp_payment_items'); |
|
274 | 274 | |
275 | - if ( false === $payment_items ) { |
|
275 | + if (false === $payment_items) { |
|
276 | 276 | $payment_items = array(); |
277 | - $this->store_data( 'give_temp_payment_items', $payment_items ); |
|
277 | + $this->store_data('give_temp_payment_items', $payment_items); |
|
278 | 278 | } |
279 | 279 | |
280 | - $all_forms = $this->get_stored_data( 'give_temp_form_ids' ); |
|
280 | + $all_forms = $this->get_stored_data('give_temp_form_ids'); |
|
281 | 281 | |
282 | - if ( false === $all_forms ) { |
|
282 | + if (false === $all_forms) { |
|
283 | 283 | $args = array( |
284 | 284 | 'post_status' => 'any', |
285 | 285 | 'post_type' => 'give_forms', |
286 | - 'posts_per_page' => - 1, |
|
286 | + 'posts_per_page' => -1, |
|
287 | 287 | 'fields' => 'ids', |
288 | 288 | ); |
289 | 289 | |
290 | - $all_forms = get_posts( $args ); |
|
291 | - $this->store_data( 'give_temp_form_ids', $all_forms ); |
|
290 | + $all_forms = get_posts($args); |
|
291 | + $this->store_data('give_temp_form_ids', $all_forms); |
|
292 | 292 | } |
293 | 293 | |
294 | - $args = apply_filters( 'give_recount_form_stats_total_args', array( |
|
294 | + $args = apply_filters('give_recount_form_stats_total_args', array( |
|
295 | 295 | 'post_parent__in' => $all_forms, |
296 | 296 | 'post_type' => 'give_log', |
297 | 297 | 'post_status' => 'publish', |
298 | 298 | 'log_type' => 'sale', |
299 | 299 | 'fields' => 'ids', |
300 | 300 | 'nopaging' => true, |
301 | - ) ); |
|
301 | + )); |
|
302 | 302 | |
303 | - $all_logs = $give_logs->get_connected_logs( $args, 'sale' ); |
|
303 | + $all_logs = $give_logs->get_connected_logs($args, 'sale'); |
|
304 | 304 | |
305 | - if ( $all_logs ) { |
|
306 | - $log_ids = implode( ',', $all_logs ); |
|
307 | - $payment_ids = $wpdb->get_col( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids)" ); |
|
308 | - unset( $log_ids ); |
|
305 | + if ($all_logs) { |
|
306 | + $log_ids = implode(',', $all_logs); |
|
307 | + $payment_ids = $wpdb->get_col("SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids)"); |
|
308 | + unset($log_ids); |
|
309 | 309 | |
310 | - $payment_ids = implode( ',', $payment_ids ); |
|
311 | - $payments = $wpdb->get_results( "SELECT ID, post_status FROM $wpdb->posts WHERE ID IN (" . $payment_ids . ")" ); |
|
312 | - unset( $payment_ids ); |
|
310 | + $payment_ids = implode(',', $payment_ids); |
|
311 | + $payments = $wpdb->get_results("SELECT ID, post_status FROM $wpdb->posts WHERE ID IN (".$payment_ids.")"); |
|
312 | + unset($payment_ids); |
|
313 | 313 | |
314 | - foreach ( $payments as $payment ) { |
|
314 | + foreach ($payments as $payment) { |
|
315 | 315 | |
316 | - $payment = new Give_Payment( $payment->ID ); |
|
316 | + $payment = new Give_Payment($payment->ID); |
|
317 | 317 | $form_id = $payment->form_id; |
318 | 318 | |
319 | 319 | //If for some reason somehow the form_ID isn't set check payment meta |
320 | - if ( empty( $payment->form_id ) ) { |
|
320 | + if (empty($payment->form_id)) { |
|
321 | 321 | $payment_meta = $payment->get_meta(); |
322 | - $form_id = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : 0; |
|
322 | + $form_id = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : 0; |
|
323 | 323 | } |
324 | 324 | |
325 | - if ( ! in_array( $payment->post_status, $accepted_statuses ) ) { |
|
325 | + if ( ! in_array($payment->post_status, $accepted_statuses)) { |
|
326 | 326 | continue; |
327 | 327 | } |
328 | 328 | |
329 | - if ( ! array_key_exists( $payment->ID, $payment_items ) ) { |
|
330 | - $payment_items[ $payment->ID ] = array( |
|
329 | + if ( ! array_key_exists($payment->ID, $payment_items)) { |
|
330 | + $payment_items[$payment->ID] = array( |
|
331 | 331 | 'id' => $form_id, |
332 | 332 | 'payment_id' => $payment->ID, |
333 | 333 | 'price' => $payment->total |
@@ -336,11 +336,11 @@ discard block |
||
336 | 336 | |
337 | 337 | } |
338 | 338 | |
339 | - $total = count( $all_logs ); |
|
339 | + $total = count($all_logs); |
|
340 | 340 | } |
341 | 341 | |
342 | - $this->store_data( 'give_temp_payment_items', $payment_items ); |
|
343 | - $this->store_data( 'give_recount_all_total', $total ); |
|
342 | + $this->store_data('give_temp_payment_items', $payment_items); |
|
343 | + $this->store_data('give_recount_all_total', $total); |
|
344 | 344 | } |
345 | 345 | |
346 | 346 | } |
@@ -354,11 +354,11 @@ discard block |
||
354 | 354 | * |
355 | 355 | * @return mixed Returns the data from the database |
356 | 356 | */ |
357 | - private function get_stored_data( $key ) { |
|
357 | + private function get_stored_data($key) { |
|
358 | 358 | global $wpdb; |
359 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
359 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
360 | 360 | |
361 | - return empty( $value ) ? false : maybe_unserialize( $value ); |
|
361 | + return empty($value) ? false : maybe_unserialize($value); |
|
362 | 362 | } |
363 | 363 | |
364 | 364 | /** |
@@ -371,10 +371,10 @@ discard block |
||
371 | 371 | * |
372 | 372 | * @return void |
373 | 373 | */ |
374 | - private function store_data( $key, $value ) { |
|
374 | + private function store_data($key, $value) { |
|
375 | 375 | global $wpdb; |
376 | 376 | |
377 | - $value = maybe_serialize( $value ); |
|
377 | + $value = maybe_serialize($value); |
|
378 | 378 | |
379 | 379 | $data = array( |
380 | 380 | 'option_name' => $key, |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | '%s', |
389 | 389 | ); |
390 | 390 | |
391 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
391 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
392 | 392 | } |
393 | 393 | |
394 | 394 | /** |
@@ -400,9 +400,9 @@ discard block |
||
400 | 400 | * |
401 | 401 | * @return void |
402 | 402 | */ |
403 | - private function delete_data( $key ) { |
|
403 | + private function delete_data($key) { |
|
404 | 404 | global $wpdb; |
405 | - $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) ); |
|
405 | + $wpdb->delete($wpdb->options, array('option_name' => $key)); |
|
406 | 406 | } |
407 | 407 | |
408 | 408 | } |
@@ -50,7 +50,7 @@ |
||
50 | 50 | * @since 1.5 |
51 | 51 | * @global object $wpdb Used to query the database using the WordPress |
52 | 52 | * Database API |
53 | - * @return array $data The data for the CSV file |
|
53 | + * @return boolean $data The data for the CSV file |
|
54 | 54 | */ |
55 | 55 | public function get_data() { |
56 | 56 | global $wpdb; |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | */ |
12 | 12 | |
13 | 13 | // Exit if accessed directly |
14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
14 | +if ( ! defined('ABSPATH')) { |
|
15 | 15 | exit; |
16 | 16 | } |
17 | 17 | |
@@ -62,23 +62,23 @@ discard block |
||
62 | 62 | public function get_data() { |
63 | 63 | global $give_logs, $wpdb; |
64 | 64 | |
65 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish', 'revoked' ) ); |
|
65 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish', 'revoked')); |
|
66 | 66 | |
67 | - if ( $this->step == 1 ) { |
|
68 | - $this->delete_data( 'give_temp_recount_form_stats' ); |
|
67 | + if ($this->step == 1) { |
|
68 | + $this->delete_data('give_temp_recount_form_stats'); |
|
69 | 69 | } |
70 | 70 | |
71 | - $totals = $this->get_stored_data( 'give_temp_recount_form_stats' ); |
|
71 | + $totals = $this->get_stored_data('give_temp_recount_form_stats'); |
|
72 | 72 | |
73 | - if ( false === $totals ) { |
|
73 | + if (false === $totals) { |
|
74 | 74 | $totals = array( |
75 | 75 | 'earnings' => (float) 0, |
76 | 76 | 'sales' => 0, |
77 | 77 | ); |
78 | - $this->store_data( 'give_temp_recount_form_stats', $totals ); |
|
78 | + $this->store_data('give_temp_recount_form_stats', $totals); |
|
79 | 79 | } |
80 | 80 | |
81 | - $args = apply_filters( 'give_recount_form_stats_args', array( |
|
81 | + $args = apply_filters('give_recount_form_stats_args', array( |
|
82 | 82 | 'post_parent' => $this->form_id, |
83 | 83 | 'post_type' => 'give_log', |
84 | 84 | 'posts_per_page' => $this->per_step, |
@@ -86,49 +86,49 @@ discard block |
||
86 | 86 | 'paged' => $this->step, |
87 | 87 | 'log_type' => 'sale', |
88 | 88 | 'fields' => 'ids', |
89 | - ) ); |
|
89 | + )); |
|
90 | 90 | |
91 | - $log_ids = $give_logs->get_connected_logs( $args, 'sale' ); |
|
91 | + $log_ids = $give_logs->get_connected_logs($args, 'sale'); |
|
92 | 92 | $this->_log_ids_debug = array(); |
93 | 93 | |
94 | - if ( $log_ids ) { |
|
95 | - $log_ids = implode( ',', $log_ids ); |
|
96 | - $payment_ids = $wpdb->get_col( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids)" ); |
|
97 | - unset( $log_ids ); |
|
94 | + if ($log_ids) { |
|
95 | + $log_ids = implode(',', $log_ids); |
|
96 | + $payment_ids = $wpdb->get_col("SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids)"); |
|
97 | + unset($log_ids); |
|
98 | 98 | |
99 | - $payment_ids = implode( ',', $payment_ids ); |
|
100 | - $payments = $wpdb->get_results( "SELECT ID, post_status FROM $wpdb->posts WHERE ID IN (" . $payment_ids . ")" ); |
|
101 | - unset( $payment_ids ); |
|
99 | + $payment_ids = implode(',', $payment_ids); |
|
100 | + $payments = $wpdb->get_results("SELECT ID, post_status FROM $wpdb->posts WHERE ID IN (".$payment_ids.")"); |
|
101 | + unset($payment_ids); |
|
102 | 102 | |
103 | - foreach ( $payments as $payment ) { |
|
103 | + foreach ($payments as $payment) { |
|
104 | 104 | |
105 | - $payment = new Give_Payment( $payment->ID ); |
|
105 | + $payment = new Give_Payment($payment->ID); |
|
106 | 106 | |
107 | 107 | //Ensure acceptible status only |
108 | - if ( ! in_array( $payment->post_status, $accepted_statuses ) ) { |
|
108 | + if ( ! in_array($payment->post_status, $accepted_statuses)) { |
|
109 | 109 | continue; |
110 | 110 | } |
111 | 111 | |
112 | 112 | //Ensure only payments for this form are counted |
113 | - if ( $payment->form_id != $this->form_id ) { |
|
113 | + if ($payment->form_id != $this->form_id) { |
|
114 | 114 | continue; |
115 | 115 | } |
116 | 116 | |
117 | 117 | $this->_log_ids_debug[] = $payment->ID; |
118 | 118 | |
119 | - $totals['sales'] ++; |
|
119 | + $totals['sales']++; |
|
120 | 120 | $totals['earnings'] += $payment->total; |
121 | 121 | |
122 | 122 | } |
123 | 123 | |
124 | - $this->store_data( 'give_temp_recount_form_stats', $totals ); |
|
124 | + $this->store_data('give_temp_recount_form_stats', $totals); |
|
125 | 125 | |
126 | 126 | return true; |
127 | 127 | } |
128 | 128 | |
129 | 129 | |
130 | - update_post_meta( $this->form_id, '_give_form_sales', $totals['sales'] ); |
|
131 | - update_post_meta( $this->form_id, '_give_form_earnings', $totals['earnings'] ); |
|
130 | + update_post_meta($this->form_id, '_give_form_sales', $totals['sales']); |
|
131 | + update_post_meta($this->form_id, '_give_form_earnings', $totals['earnings']); |
|
132 | 132 | |
133 | 133 | return false; |
134 | 134 | |
@@ -143,54 +143,54 @@ discard block |
||
143 | 143 | public function get_percentage_complete() { |
144 | 144 | global $give_logs, $wpdb; |
145 | 145 | |
146 | - if ( $this->step == 1 ) { |
|
147 | - $this->delete_data( 'give_recount_total_' . $this->form_id ); |
|
146 | + if ($this->step == 1) { |
|
147 | + $this->delete_data('give_recount_total_'.$this->form_id); |
|
148 | 148 | } |
149 | 149 | |
150 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish', 'revoked' ) ); |
|
151 | - $total = $this->get_stored_data( 'give_recount_total_' . $this->form_id ); |
|
150 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish', 'revoked')); |
|
151 | + $total = $this->get_stored_data('give_recount_total_'.$this->form_id); |
|
152 | 152 | |
153 | - if ( false === $total ) { |
|
153 | + if (false === $total) { |
|
154 | 154 | $total = 0; |
155 | - $args = apply_filters( 'give_recount_form_stats_total_args', array( |
|
155 | + $args = apply_filters('give_recount_form_stats_total_args', array( |
|
156 | 156 | 'post_parent' => $this->form_id, |
157 | 157 | 'post_type' => 'give_log', |
158 | 158 | 'post_status' => 'publish', |
159 | 159 | 'log_type' => 'sale', |
160 | 160 | 'fields' => 'ids', |
161 | 161 | 'nopaging' => true, |
162 | - ) ); |
|
162 | + )); |
|
163 | 163 | |
164 | - $log_ids = $give_logs->get_connected_logs( $args, 'sale' ); |
|
164 | + $log_ids = $give_logs->get_connected_logs($args, 'sale'); |
|
165 | 165 | |
166 | - if ( $log_ids ) { |
|
167 | - $log_ids = implode( ',', $log_ids ); |
|
168 | - $payment_ids = $wpdb->get_col( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids)" ); |
|
169 | - unset( $log_ids ); |
|
166 | + if ($log_ids) { |
|
167 | + $log_ids = implode(',', $log_ids); |
|
168 | + $payment_ids = $wpdb->get_col("SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids)"); |
|
169 | + unset($log_ids); |
|
170 | 170 | |
171 | - $payment_ids = implode( ',', $payment_ids ); |
|
172 | - $payments = $wpdb->get_results( "SELECT ID, post_status FROM $wpdb->posts WHERE ID IN (" . $payment_ids . ")" ); |
|
173 | - unset( $payment_ids ); |
|
171 | + $payment_ids = implode(',', $payment_ids); |
|
172 | + $payments = $wpdb->get_results("SELECT ID, post_status FROM $wpdb->posts WHERE ID IN (".$payment_ids.")"); |
|
173 | + unset($payment_ids); |
|
174 | 174 | |
175 | - foreach ( $payments as $payment ) { |
|
176 | - if ( in_array( $payment->post_status, $accepted_statuses ) ) { |
|
175 | + foreach ($payments as $payment) { |
|
176 | + if (in_array($payment->post_status, $accepted_statuses)) { |
|
177 | 177 | continue; |
178 | 178 | } |
179 | 179 | |
180 | - $total ++; |
|
180 | + $total++; |
|
181 | 181 | } |
182 | 182 | } |
183 | 183 | |
184 | - $this->store_data( 'give_recount_total_' . $this->form_id, $total ); |
|
184 | + $this->store_data('give_recount_total_'.$this->form_id, $total); |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | $percentage = 100; |
188 | 188 | |
189 | - if ( $total > 0 ) { |
|
190 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
189 | + if ($total > 0) { |
|
190 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
191 | 191 | } |
192 | 192 | |
193 | - if ( $percentage > 100 ) { |
|
193 | + if ($percentage > 100) { |
|
194 | 194 | $percentage = 100; |
195 | 195 | } |
196 | 196 | |
@@ -204,8 +204,8 @@ discard block |
||
204 | 204 | * |
205 | 205 | * @param array $request The Form Data passed into the batch processing |
206 | 206 | */ |
207 | - public function set_properties( $request ) { |
|
208 | - $this->form_id = isset( $request['form_id'] ) ? sanitize_text_field( $request['form_id'] ) : false; |
|
207 | + public function set_properties($request) { |
|
208 | + $this->form_id = isset($request['form_id']) ? sanitize_text_field($request['form_id']) : false; |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | /** |
@@ -216,31 +216,31 @@ discard block |
||
216 | 216 | */ |
217 | 217 | public function process_step() { |
218 | 218 | |
219 | - if ( ! $this->can_export() ) { |
|
220 | - wp_die( __( 'You do not have permission to recount stats.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
219 | + if ( ! $this->can_export()) { |
|
220 | + wp_die(__('You do not have permission to recount stats.', 'give'), __('Error', 'give'), array('response' => 403)); |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | $had_data = $this->get_data(); |
224 | 224 | |
225 | - if ( $had_data ) { |
|
225 | + if ($had_data) { |
|
226 | 226 | $this->done = false; |
227 | 227 | |
228 | 228 | return true; |
229 | 229 | } else { |
230 | - $this->delete_data( 'give_recount_total_' . $this->form_id ); |
|
231 | - $this->delete_data( 'give_temp_recount_form_stats' ); |
|
230 | + $this->delete_data('give_recount_total_'.$this->form_id); |
|
231 | + $this->delete_data('give_temp_recount_form_stats'); |
|
232 | 232 | $this->done = true; |
233 | - $this->message = sprintf( __( 'Donation counts and income amount statistics successfully recounted for "%s".', 'give' ), get_the_title( $this->form_id ) ); |
|
233 | + $this->message = sprintf(__('Donation counts and income amount statistics successfully recounted for "%s".', 'give'), get_the_title($this->form_id)); |
|
234 | 234 | |
235 | 235 | return false; |
236 | 236 | } |
237 | 237 | } |
238 | 238 | |
239 | 239 | public function headers() { |
240 | - ignore_user_abort( true ); |
|
240 | + ignore_user_abort(true); |
|
241 | 241 | |
242 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
243 | - set_time_limit( 0 ); |
|
242 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
243 | + set_time_limit(0); |
|
244 | 244 | } |
245 | 245 | } |
246 | 246 | |
@@ -268,11 +268,11 @@ discard block |
||
268 | 268 | * |
269 | 269 | * @return mixed Returns the data from the database |
270 | 270 | */ |
271 | - private function get_stored_data( $key ) { |
|
271 | + private function get_stored_data($key) { |
|
272 | 272 | global $wpdb; |
273 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
273 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
274 | 274 | |
275 | - return empty( $value ) ? false : maybe_unserialize( $value ); |
|
275 | + return empty($value) ? false : maybe_unserialize($value); |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | /** |
@@ -285,10 +285,10 @@ discard block |
||
285 | 285 | * |
286 | 286 | * @return void |
287 | 287 | */ |
288 | - private function store_data( $key, $value ) { |
|
288 | + private function store_data($key, $value) { |
|
289 | 289 | global $wpdb; |
290 | 290 | |
291 | - $value = maybe_serialize( $value ); |
|
291 | + $value = maybe_serialize($value); |
|
292 | 292 | |
293 | 293 | $data = array( |
294 | 294 | 'option_name' => $key, |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | '%s', |
303 | 303 | ); |
304 | 304 | |
305 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
305 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | /** |
@@ -314,9 +314,9 @@ discard block |
||
314 | 314 | * |
315 | 315 | * @return void |
316 | 316 | */ |
317 | - private function delete_data( $key ) { |
|
317 | + private function delete_data($key) { |
|
318 | 318 | global $wpdb; |
319 | - $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) ); |
|
319 | + $wpdb->delete($wpdb->options, array('option_name' => $key)); |
|
320 | 320 | } |
321 | 321 | |
322 | 322 | } |
@@ -50,7 +50,7 @@ |
||
50 | 50 | * @since 1.5 |
51 | 51 | * @global object $wpdb Used to query the database using the WordPress |
52 | 52 | * Database API |
53 | - * @return array $data The data for the CSV file |
|
53 | + * @return boolean $data The data for the CSV file |
|
54 | 54 | */ |
55 | 55 | public function get_data() { |
56 | 56 | global $wpdb; |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | */ |
12 | 12 | |
13 | 13 | // Exit if accessed directly |
14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
14 | +if ( ! defined('ABSPATH')) { |
|
15 | 15 | exit; |
16 | 16 | } |
17 | 17 | |
@@ -54,50 +54,50 @@ discard block |
||
54 | 54 | */ |
55 | 55 | public function get_data() { |
56 | 56 | |
57 | - if ( $this->step == 1 ) { |
|
58 | - $this->delete_data( 'give_temp_recount_income' ); |
|
57 | + if ($this->step == 1) { |
|
58 | + $this->delete_data('give_temp_recount_income'); |
|
59 | 59 | } |
60 | 60 | |
61 | - $total = get_option( 'give_temp_recount_income', false ); |
|
61 | + $total = get_option('give_temp_recount_income', false); |
|
62 | 62 | |
63 | - if ( false === $total ) { |
|
63 | + if (false === $total) { |
|
64 | 64 | $total = (float) 0; |
65 | - $this->store_data( 'give_temp_recount_income', $total ); |
|
65 | + $this->store_data('give_temp_recount_income', $total); |
|
66 | 66 | } |
67 | 67 | |
68 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish', 'revoked' ) ); |
|
68 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish', 'revoked')); |
|
69 | 69 | |
70 | - $args = apply_filters( 'give_recount_income_args', array( |
|
70 | + $args = apply_filters('give_recount_income_args', array( |
|
71 | 71 | 'number' => $this->per_step, |
72 | 72 | 'page' => $this->step, |
73 | 73 | 'status' => $accepted_statuses, |
74 | 74 | 'fields' => 'ids' |
75 | - ) ); |
|
75 | + )); |
|
76 | 76 | |
77 | - $payments = give_get_payments( $args ); |
|
77 | + $payments = give_get_payments($args); |
|
78 | 78 | |
79 | - if ( ! empty( $payments ) ) { |
|
79 | + if ( ! empty($payments)) { |
|
80 | 80 | |
81 | - foreach ( $payments as $payment ) { |
|
81 | + foreach ($payments as $payment) { |
|
82 | 82 | |
83 | - $total += give_get_payment_amount( $payment ); |
|
83 | + $total += give_get_payment_amount($payment); |
|
84 | 84 | |
85 | 85 | } |
86 | 86 | |
87 | - if ( $total < 0 ) { |
|
87 | + if ($total < 0) { |
|
88 | 88 | $totals = 0; |
89 | 89 | } |
90 | 90 | |
91 | - $total = round( $total, give_currency_decimal_filter() ); |
|
91 | + $total = round($total, give_currency_decimal_filter()); |
|
92 | 92 | |
93 | - $this->store_data( 'give_temp_recount_income', $total ); |
|
93 | + $this->store_data('give_temp_recount_income', $total); |
|
94 | 94 | |
95 | 95 | return true; |
96 | 96 | |
97 | 97 | } |
98 | 98 | |
99 | - update_option( 'give_income_total', $total ); |
|
100 | - set_transient( 'give_income_total', $total, 86400 ); |
|
99 | + update_option('give_income_total', $total); |
|
100 | + set_transient('give_income_total', $total, 86400); |
|
101 | 101 | |
102 | 102 | return false; |
103 | 103 | |
@@ -111,25 +111,25 @@ discard block |
||
111 | 111 | */ |
112 | 112 | public function get_percentage_complete() { |
113 | 113 | |
114 | - $total = $this->get_stored_data( 'give_recount_income_total' ); |
|
114 | + $total = $this->get_stored_data('give_recount_income_total'); |
|
115 | 115 | |
116 | - if ( false === $total ) { |
|
117 | - $args = apply_filters( 'give_recount_income_total_args', array() ); |
|
116 | + if (false === $total) { |
|
117 | + $args = apply_filters('give_recount_income_total_args', array()); |
|
118 | 118 | |
119 | - $counts = give_count_payments( $args ); |
|
120 | - $total = absint( $counts->publish ) + absint( $counts->revoked ); |
|
121 | - $total = apply_filters( 'give_recount_store_income_total', $total ); |
|
119 | + $counts = give_count_payments($args); |
|
120 | + $total = absint($counts->publish) + absint($counts->revoked); |
|
121 | + $total = apply_filters('give_recount_store_income_total', $total); |
|
122 | 122 | |
123 | - $this->store_data( 'give_recount_income_total', $total ); |
|
123 | + $this->store_data('give_recount_income_total', $total); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | $percentage = 100; |
127 | 127 | |
128 | - if ( $total > 0 ) { |
|
129 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
128 | + if ($total > 0) { |
|
129 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
130 | 130 | } |
131 | 131 | |
132 | - if ( $percentage > 100 ) { |
|
132 | + if ($percentage > 100) { |
|
133 | 133 | $percentage = 100; |
134 | 134 | } |
135 | 135 | |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | * |
144 | 144 | * @param array $request The Form Data passed into the batch processing |
145 | 145 | */ |
146 | - public function set_properties( $request ) { |
|
146 | + public function set_properties($request) { |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | /** |
@@ -154,31 +154,31 @@ discard block |
||
154 | 154 | */ |
155 | 155 | public function process_step() { |
156 | 156 | |
157 | - if ( ! $this->can_export() ) { |
|
158 | - wp_die( __( 'You do not have permission to recount stats.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
157 | + if ( ! $this->can_export()) { |
|
158 | + wp_die(__('You do not have permission to recount stats.', 'give'), __('Error', 'give'), array('response' => 403)); |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | $had_data = $this->get_data(); |
162 | 162 | |
163 | - if ( $had_data ) { |
|
163 | + if ($had_data) { |
|
164 | 164 | $this->done = false; |
165 | 165 | |
166 | 166 | return true; |
167 | 167 | } else { |
168 | - $this->delete_data( 'give_recount_income_total' ); |
|
169 | - $this->delete_data( 'give_temp_recount_income' ); |
|
168 | + $this->delete_data('give_recount_income_total'); |
|
169 | + $this->delete_data('give_temp_recount_income'); |
|
170 | 170 | $this->done = true; |
171 | - $this->message = __( 'Give income successfully recounted.', 'give' ); |
|
171 | + $this->message = __('Give income successfully recounted.', 'give'); |
|
172 | 172 | |
173 | 173 | return false; |
174 | 174 | } |
175 | 175 | } |
176 | 176 | |
177 | 177 | public function headers() { |
178 | - ignore_user_abort( true ); |
|
178 | + ignore_user_abort(true); |
|
179 | 179 | |
180 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
181 | - set_time_limit( 0 ); |
|
180 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
181 | + set_time_limit(0); |
|
182 | 182 | } |
183 | 183 | } |
184 | 184 | |
@@ -206,11 +206,11 @@ discard block |
||
206 | 206 | * |
207 | 207 | * @return mixed Returns the data from the database |
208 | 208 | */ |
209 | - private function get_stored_data( $key ) { |
|
209 | + private function get_stored_data($key) { |
|
210 | 210 | global $wpdb; |
211 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
211 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
212 | 212 | |
213 | - return empty( $value ) ? false : maybe_unserialize( $value ); |
|
213 | + return empty($value) ? false : maybe_unserialize($value); |
|
214 | 214 | } |
215 | 215 | |
216 | 216 | /** |
@@ -223,10 +223,10 @@ discard block |
||
223 | 223 | * |
224 | 224 | * @return void |
225 | 225 | */ |
226 | - private function store_data( $key, $value ) { |
|
226 | + private function store_data($key, $value) { |
|
227 | 227 | global $wpdb; |
228 | 228 | |
229 | - $value = maybe_serialize( $value ); |
|
229 | + $value = maybe_serialize($value); |
|
230 | 230 | |
231 | 231 | $data = array( |
232 | 232 | 'option_name' => $key, |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | '%s', |
241 | 241 | ); |
242 | 242 | |
243 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
243 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | /** |
@@ -252,9 +252,9 @@ discard block |
||
252 | 252 | * |
253 | 253 | * @return void |
254 | 254 | */ |
255 | - private function delete_data( $key ) { |
|
255 | + private function delete_data($key) { |
|
256 | 256 | global $wpdb; |
257 | - $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) ); |
|
257 | + $wpdb->delete($wpdb->options, array('option_name' => $key)); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -28,94 +28,94 @@ discard block |
||
28 | 28 | |
29 | 29 | global $give_options; |
30 | 30 | |
31 | - $js_dir = GIVE_PLUGIN_URL . 'assets/js/frontend/'; |
|
32 | - $js_plugins = GIVE_PLUGIN_URL . 'assets/js/plugins/'; |
|
33 | - $scripts_footer = ( give_get_option( 'scripts_footer' ) == 'on' ) ? true : false; |
|
31 | + $js_dir = GIVE_PLUGIN_URL.'assets/js/frontend/'; |
|
32 | + $js_plugins = GIVE_PLUGIN_URL.'assets/js/plugins/'; |
|
33 | + $scripts_footer = (give_get_option('scripts_footer') == 'on') ? true : false; |
|
34 | 34 | |
35 | 35 | // Use minified libraries if SCRIPT_DEBUG is turned off |
36 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
36 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
37 | 37 | |
38 | 38 | //Localize / PHP to AJAX vars |
39 | - $localize_give_checkout = apply_filters( 'give_global_script_vars', array( |
|
39 | + $localize_give_checkout = apply_filters('give_global_script_vars', array( |
|
40 | 40 | 'ajaxurl' => give_get_ajax_url(), |
41 | - 'checkout_nonce' => wp_create_nonce( 'give_checkout_nonce' ), |
|
42 | - 'currency_sign' => give_currency_filter( '' ), |
|
41 | + 'checkout_nonce' => wp_create_nonce('give_checkout_nonce'), |
|
42 | + 'currency_sign' => give_currency_filter(''), |
|
43 | 43 | 'currency_pos' => give_get_currency_position(), |
44 | - 'thousands_separator' => isset( $give_options['thousands_separator'] ) ? $give_options['thousands_separator'] : ',', |
|
45 | - 'decimal_separator' => isset( $give_options['decimal_separator'] ) ? $give_options['decimal_separator'] : '.', |
|
46 | - 'no_gateway' => __( 'Please select a payment method', 'give' ), |
|
47 | - 'bad_minimum' => __( 'The minimum donation amount for this form is', 'give' ), |
|
48 | - 'general_loading' => __( 'Loading...', 'give' ), |
|
49 | - 'purchase_loading' => __( 'Please Wait...', 'give' ), |
|
50 | - 'number_decimals' => apply_filters( 'give_format_amount_decimals', 2 ), |
|
44 | + 'thousands_separator' => isset($give_options['thousands_separator']) ? $give_options['thousands_separator'] : ',', |
|
45 | + 'decimal_separator' => isset($give_options['decimal_separator']) ? $give_options['decimal_separator'] : '.', |
|
46 | + 'no_gateway' => __('Please select a payment method', 'give'), |
|
47 | + 'bad_minimum' => __('The minimum donation amount for this form is', 'give'), |
|
48 | + 'general_loading' => __('Loading...', 'give'), |
|
49 | + 'purchase_loading' => __('Please Wait...', 'give'), |
|
50 | + 'number_decimals' => apply_filters('give_format_amount_decimals', 2), |
|
51 | 51 | 'give_version' => GIVE_VERSION |
52 | - ) ); |
|
53 | - $localize_give_ajax = apply_filters( 'give_global_ajax_vars', array( |
|
52 | + )); |
|
53 | + $localize_give_ajax = apply_filters('give_global_ajax_vars', array( |
|
54 | 54 | 'ajaxurl' => give_get_ajax_url(), |
55 | - 'loading' => __( 'Loading', 'give' ), |
|
55 | + 'loading' => __('Loading', 'give'), |
|
56 | 56 | // General loading message |
57 | - 'select_option' => __( 'Please select an option', 'give' ), |
|
57 | + 'select_option' => __('Please select an option', 'give'), |
|
58 | 58 | // Variable pricing error with multi-purchase option enabled |
59 | - 'default_gateway' => give_get_default_gateway( null ), |
|
60 | - 'permalinks' => get_option( 'permalink_structure' ) ? '1' : '0', |
|
61 | - 'number_decimals' => apply_filters( 'give_format_amount_decimals', 2 ) |
|
62 | - ) ); |
|
59 | + 'default_gateway' => give_get_default_gateway(null), |
|
60 | + 'permalinks' => get_option('permalink_structure') ? '1' : '0', |
|
61 | + 'number_decimals' => apply_filters('give_format_amount_decimals', 2) |
|
62 | + )); |
|
63 | 63 | |
64 | 64 | //DEBUG is On |
65 | - if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) { |
|
65 | + if (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) { |
|
66 | 66 | |
67 | - if ( give_is_cc_verify_enabled() ) { |
|
68 | - wp_register_script( 'give-cc-validator', $js_plugins . 'jquery.payment' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
69 | - wp_enqueue_script( 'give-cc-validator' ); |
|
67 | + if (give_is_cc_verify_enabled()) { |
|
68 | + wp_register_script('give-cc-validator', $js_plugins.'jquery.payment'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
69 | + wp_enqueue_script('give-cc-validator'); |
|
70 | 70 | } |
71 | 71 | |
72 | - wp_register_script( 'give-float-labels', $js_plugins . 'float-labels' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
73 | - wp_enqueue_script( 'give-float-labels' ); |
|
72 | + wp_register_script('give-float-labels', $js_plugins.'float-labels'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
73 | + wp_enqueue_script('give-float-labels'); |
|
74 | 74 | |
75 | - wp_register_script( 'give-blockui', $js_plugins . 'jquery.blockUI' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
76 | - wp_enqueue_script( 'give-blockui' ); |
|
75 | + wp_register_script('give-blockui', $js_plugins.'jquery.blockUI'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
76 | + wp_enqueue_script('give-blockui'); |
|
77 | 77 | |
78 | - wp_register_script( 'give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
79 | - wp_enqueue_script( 'give-qtip' ); |
|
78 | + wp_register_script('give-qtip', $js_plugins.'jquery.qtip'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
79 | + wp_enqueue_script('give-qtip'); |
|
80 | 80 | |
81 | - wp_register_script( 'give-accounting', $js_plugins . 'accounting' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
82 | - wp_enqueue_script( 'give-accounting' ); |
|
81 | + wp_register_script('give-accounting', $js_plugins.'accounting'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
82 | + wp_enqueue_script('give-accounting'); |
|
83 | 83 | |
84 | - wp_register_script( 'give-magnific', $js_plugins . 'jquery.magnific-popup' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
85 | - wp_enqueue_script( 'give-magnific' ); |
|
84 | + wp_register_script('give-magnific', $js_plugins.'jquery.magnific-popup'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
85 | + wp_enqueue_script('give-magnific'); |
|
86 | 86 | |
87 | - wp_register_script( 'give-checkout-global', $js_dir . 'give-checkout-global' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
88 | - wp_enqueue_script( 'give-checkout-global' ); |
|
87 | + wp_register_script('give-checkout-global', $js_dir.'give-checkout-global'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
88 | + wp_enqueue_script('give-checkout-global'); |
|
89 | 89 | |
90 | 90 | //General scripts |
91 | - wp_register_script( 'give-scripts', $js_dir . 'give' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
92 | - wp_enqueue_script( 'give-scripts' ); |
|
91 | + wp_register_script('give-scripts', $js_dir.'give'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
92 | + wp_enqueue_script('give-scripts'); |
|
93 | 93 | |
94 | 94 | // Load AJAX scripts, if enabled |
95 | - wp_register_script( 'give-ajax', $js_dir . 'give-ajax' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
96 | - wp_enqueue_script( 'give-ajax' ); |
|
95 | + wp_register_script('give-ajax', $js_dir.'give-ajax'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
96 | + wp_enqueue_script('give-ajax'); |
|
97 | 97 | |
98 | 98 | //Localize / Pass AJAX vars from PHP |
99 | - wp_localize_script( 'give-checkout-global', 'give_global_vars', $localize_give_checkout ); |
|
100 | - wp_localize_script( 'give-ajax', 'give_scripts', $localize_give_ajax ); |
|
99 | + wp_localize_script('give-checkout-global', 'give_global_vars', $localize_give_checkout); |
|
100 | + wp_localize_script('give-ajax', 'give_scripts', $localize_give_ajax); |
|
101 | 101 | |
102 | 102 | |
103 | 103 | } else { |
104 | 104 | |
105 | 105 | //DEBUG is OFF (one JS file to rule them all!) |
106 | - wp_register_script( 'give', $js_dir . 'give.all.min.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
107 | - wp_enqueue_script( 'give' ); |
|
106 | + wp_register_script('give', $js_dir.'give.all.min.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
107 | + wp_enqueue_script('give'); |
|
108 | 108 | |
109 | 109 | //Localize / Pass AJAX vars from PHP |
110 | - wp_localize_script( 'give', 'give_global_vars', $localize_give_checkout ); |
|
111 | - wp_localize_script( 'give', 'give_scripts', $localize_give_ajax ); |
|
110 | + wp_localize_script('give', 'give_global_vars', $localize_give_checkout); |
|
111 | + wp_localize_script('give', 'give_scripts', $localize_give_ajax); |
|
112 | 112 | |
113 | 113 | } |
114 | 114 | |
115 | 115 | |
116 | 116 | } |
117 | 117 | |
118 | -add_action( 'wp_enqueue_scripts', 'give_load_scripts' ); |
|
118 | +add_action('wp_enqueue_scripts', 'give_load_scripts'); |
|
119 | 119 | |
120 | 120 | /** |
121 | 121 | * Register Styles |
@@ -127,47 +127,47 @@ discard block |
||
127 | 127 | */ |
128 | 128 | function give_register_styles() { |
129 | 129 | |
130 | - if ( give_get_option( 'disable_css', false ) ) { |
|
130 | + if (give_get_option('disable_css', false)) { |
|
131 | 131 | return; |
132 | 132 | } |
133 | 133 | |
134 | 134 | // Use minified libraries if SCRIPT_DEBUG is turned off |
135 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
135 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
136 | 136 | |
137 | - $file = 'give' . $suffix . '.css'; |
|
137 | + $file = 'give'.$suffix.'.css'; |
|
138 | 138 | $templates_dir = give_get_theme_template_dir_name(); |
139 | 139 | |
140 | - $child_theme_style_sheet = trailingslashit( get_stylesheet_directory() ) . $templates_dir . $file; |
|
141 | - $child_theme_style_sheet_2 = trailingslashit( get_stylesheet_directory() ) . $templates_dir . 'give.css'; |
|
142 | - $parent_theme_style_sheet = trailingslashit( get_template_directory() ) . $templates_dir . $file; |
|
143 | - $parent_theme_style_sheet_2 = trailingslashit( get_template_directory() ) . $templates_dir . 'give.css'; |
|
144 | - $give_plugin_style_sheet = trailingslashit( give_get_templates_dir() ) . $file; |
|
140 | + $child_theme_style_sheet = trailingslashit(get_stylesheet_directory()).$templates_dir.$file; |
|
141 | + $child_theme_style_sheet_2 = trailingslashit(get_stylesheet_directory()).$templates_dir.'give.css'; |
|
142 | + $parent_theme_style_sheet = trailingslashit(get_template_directory()).$templates_dir.$file; |
|
143 | + $parent_theme_style_sheet_2 = trailingslashit(get_template_directory()).$templates_dir.'give.css'; |
|
144 | + $give_plugin_style_sheet = trailingslashit(give_get_templates_dir()).$file; |
|
145 | 145 | |
146 | 146 | // Look in the child theme directory first, followed by the parent theme, followed by the Give core templates directory |
147 | 147 | // Also look for the min version first, followed by non minified version, even if SCRIPT_DEBUG is not enabled. |
148 | 148 | // This allows users to copy just give.css to their theme |
149 | - if ( file_exists( $child_theme_style_sheet ) || ( ! empty( $suffix ) && ( $nonmin = file_exists( $child_theme_style_sheet_2 ) ) ) ) { |
|
150 | - if ( ! empty( $nonmin ) ) { |
|
151 | - $url = trailingslashit( get_stylesheet_directory_uri() ) . $templates_dir . 'give.css'; |
|
149 | + if (file_exists($child_theme_style_sheet) || ( ! empty($suffix) && ($nonmin = file_exists($child_theme_style_sheet_2)))) { |
|
150 | + if ( ! empty($nonmin)) { |
|
151 | + $url = trailingslashit(get_stylesheet_directory_uri()).$templates_dir.'give.css'; |
|
152 | 152 | } else { |
153 | - $url = trailingslashit( get_stylesheet_directory_uri() ) . $templates_dir . $file; |
|
153 | + $url = trailingslashit(get_stylesheet_directory_uri()).$templates_dir.$file; |
|
154 | 154 | } |
155 | - } elseif ( file_exists( $parent_theme_style_sheet ) || ( ! empty( $suffix ) && ( $nonmin = file_exists( $parent_theme_style_sheet_2 ) ) ) ) { |
|
156 | - if ( ! empty( $nonmin ) ) { |
|
157 | - $url = trailingslashit( get_template_directory_uri() ) . $templates_dir . 'give.css'; |
|
155 | + } elseif (file_exists($parent_theme_style_sheet) || ( ! empty($suffix) && ($nonmin = file_exists($parent_theme_style_sheet_2)))) { |
|
156 | + if ( ! empty($nonmin)) { |
|
157 | + $url = trailingslashit(get_template_directory_uri()).$templates_dir.'give.css'; |
|
158 | 158 | } else { |
159 | - $url = trailingslashit( get_template_directory_uri() ) . $templates_dir . $file; |
|
159 | + $url = trailingslashit(get_template_directory_uri()).$templates_dir.$file; |
|
160 | 160 | } |
161 | - } elseif ( file_exists( $give_plugin_style_sheet ) || file_exists( $give_plugin_style_sheet ) ) { |
|
162 | - $url = trailingslashit( give_get_templates_url() ) . $file; |
|
161 | + } elseif (file_exists($give_plugin_style_sheet) || file_exists($give_plugin_style_sheet)) { |
|
162 | + $url = trailingslashit(give_get_templates_url()).$file; |
|
163 | 163 | } |
164 | 164 | |
165 | - wp_register_style( 'give-styles', $url, array(), GIVE_VERSION, 'all' ); |
|
166 | - wp_enqueue_style( 'give-styles' ); |
|
165 | + wp_register_style('give-styles', $url, array(), GIVE_VERSION, 'all'); |
|
166 | + wp_enqueue_style('give-styles'); |
|
167 | 167 | |
168 | 168 | } |
169 | 169 | |
170 | -add_action( 'wp_enqueue_scripts', 'give_register_styles' ); |
|
170 | +add_action('wp_enqueue_scripts', 'give_register_styles'); |
|
171 | 171 | |
172 | 172 | /** |
173 | 173 | * Load Admin Scripts |
@@ -181,102 +181,102 @@ discard block |
||
181 | 181 | * |
182 | 182 | * @return void |
183 | 183 | */ |
184 | -function give_load_admin_scripts( $hook ) { |
|
184 | +function give_load_admin_scripts($hook) { |
|
185 | 185 | |
186 | 186 | global $wp_version, $post, $post_type; |
187 | 187 | |
188 | 188 | //Directories of assets |
189 | - $js_dir = GIVE_PLUGIN_URL . 'assets/js/admin/'; |
|
190 | - $js_plugins = GIVE_PLUGIN_URL . 'assets/js/plugins/'; |
|
191 | - $css_dir = GIVE_PLUGIN_URL . 'assets/css/'; |
|
189 | + $js_dir = GIVE_PLUGIN_URL.'assets/js/admin/'; |
|
190 | + $js_plugins = GIVE_PLUGIN_URL.'assets/js/plugins/'; |
|
191 | + $css_dir = GIVE_PLUGIN_URL.'assets/css/'; |
|
192 | 192 | |
193 | 193 | // Use minified libraries if SCRIPT_DEBUG is turned off |
194 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
194 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
195 | 195 | |
196 | 196 | //Global Admin: |
197 | - wp_register_style( 'give-admin-bar-notification', $css_dir . 'adminbar-style.css' ); |
|
198 | - wp_enqueue_style( 'give-admin-bar-notification' ); |
|
197 | + wp_register_style('give-admin-bar-notification', $css_dir.'adminbar-style.css'); |
|
198 | + wp_enqueue_style('give-admin-bar-notification'); |
|
199 | 199 | |
200 | 200 | //Give Admin Only: |
201 | - if ( ! apply_filters( 'give_load_admin_scripts', give_is_admin_page(), $hook ) ) { |
|
201 | + if ( ! apply_filters('give_load_admin_scripts', give_is_admin_page(), $hook)) { |
|
202 | 202 | return; |
203 | 203 | } |
204 | 204 | |
205 | 205 | //CSS |
206 | - wp_register_style( 'jquery-ui-css', $css_dir . 'jquery-ui-fresh' . $suffix . '.css' ); |
|
207 | - wp_enqueue_style( 'jquery-ui-css' ); |
|
208 | - wp_register_style( 'give-admin', $css_dir . 'give-admin' . $suffix . '.css', GIVE_VERSION ); |
|
209 | - wp_enqueue_style( 'give-admin' ); |
|
210 | - wp_register_style( 'jquery-chosen', $css_dir . 'chosen' . $suffix . '.css', array(), GIVE_VERSION ); |
|
211 | - wp_enqueue_style( 'jquery-chosen' ); |
|
212 | - wp_enqueue_style( 'thickbox' ); |
|
206 | + wp_register_style('jquery-ui-css', $css_dir.'jquery-ui-fresh'.$suffix.'.css'); |
|
207 | + wp_enqueue_style('jquery-ui-css'); |
|
208 | + wp_register_style('give-admin', $css_dir.'give-admin'.$suffix.'.css', GIVE_VERSION); |
|
209 | + wp_enqueue_style('give-admin'); |
|
210 | + wp_register_style('jquery-chosen', $css_dir.'chosen'.$suffix.'.css', array(), GIVE_VERSION); |
|
211 | + wp_enqueue_style('jquery-chosen'); |
|
212 | + wp_enqueue_style('thickbox'); |
|
213 | 213 | |
214 | 214 | //JS |
215 | - wp_register_script( 'jquery-chosen', $js_plugins . 'chosen.jquery' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION ); |
|
216 | - wp_enqueue_script( 'jquery-chosen' ); |
|
215 | + wp_register_script('jquery-chosen', $js_plugins.'chosen.jquery'.$suffix.'.js', array('jquery'), GIVE_VERSION); |
|
216 | + wp_enqueue_script('jquery-chosen'); |
|
217 | 217 | |
218 | - wp_register_script( 'give-admin-scripts', $js_dir . 'admin-scripts' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
219 | - wp_enqueue_script( 'give-admin-scripts' ); |
|
218 | + wp_register_script('give-admin-scripts', $js_dir.'admin-scripts'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
219 | + wp_enqueue_script('give-admin-scripts'); |
|
220 | 220 | |
221 | - wp_register_script( 'jquery-flot', $js_plugins . 'jquery.flot' . $suffix . '.js' ); |
|
222 | - wp_enqueue_script( 'jquery-flot' ); |
|
221 | + wp_register_script('jquery-flot', $js_plugins.'jquery.flot'.$suffix.'.js'); |
|
222 | + wp_enqueue_script('jquery-flot'); |
|
223 | 223 | |
224 | - wp_register_script( 'give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
225 | - wp_enqueue_script( 'give-qtip' ); |
|
224 | + wp_register_script('give-qtip', $js_plugins.'jquery.qtip'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
225 | + wp_enqueue_script('give-qtip'); |
|
226 | 226 | |
227 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
228 | - wp_enqueue_script( 'thickbox' ); |
|
227 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
228 | + wp_enqueue_script('thickbox'); |
|
229 | 229 | |
230 | 230 | //Forms CPT Script |
231 | - if ( $post_type === 'give_forms' ) { |
|
232 | - wp_register_script( 'give-admin-forms-scripts', $js_dir . 'admin-forms' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
233 | - wp_enqueue_script( 'give-admin-forms-scripts' ); |
|
231 | + if ($post_type === 'give_forms') { |
|
232 | + wp_register_script('give-admin-forms-scripts', $js_dir.'admin-forms'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
233 | + wp_enqueue_script('give-admin-forms-scripts'); |
|
234 | 234 | } |
235 | 235 | |
236 | 236 | //Settings Scripts |
237 | - if (isset($_GET['page']) && $_GET['page'] == 'give-settings' ) { |
|
238 | - wp_register_script( 'give-admin-settings-scripts', $js_dir . 'admin-settings' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
239 | - wp_enqueue_script( 'give-admin-settings-scripts' ); |
|
237 | + if (isset($_GET['page']) && $_GET['page'] == 'give-settings') { |
|
238 | + wp_register_script('give-admin-settings-scripts', $js_dir.'admin-settings'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
239 | + wp_enqueue_script('give-admin-settings-scripts'); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | //Localize strings & variables for JS |
243 | - wp_localize_script( 'give-admin-scripts', 'give_vars', array( |
|
244 | - 'post_id' => isset( $post->ID ) ? $post->ID : null, |
|
243 | + wp_localize_script('give-admin-scripts', 'give_vars', array( |
|
244 | + 'post_id' => isset($post->ID) ? $post->ID : null, |
|
245 | 245 | 'give_version' => GIVE_VERSION, |
246 | - 'quick_edit_warning' => __( 'Sorry, not available for variable priced forms.', 'give' ), |
|
247 | - 'delete_payment' => __( 'Are you sure you wish to delete this payment?', 'give' ), |
|
248 | - 'delete_payment_note' => __( 'Are you sure you wish to delete this note?', 'give' ), |
|
249 | - 'revoke_api_key' => __( 'Are you sure you wish to revoke this API key?', 'give' ), |
|
250 | - 'regenerate_api_key' => __( 'Are you sure you wish to regenerate this API key?', 'give' ), |
|
251 | - 'resend_receipt' => __( 'Are you sure you wish to resend the donation receipt?', 'give' ), |
|
252 | - 'copy_download_link_text' => __( 'Copy these links to your clipboard and give them to your donor', 'give' ), |
|
253 | - 'delete_payment_download' => sprintf( __( 'Are you sure you wish to delete this %s?', 'give' ), give_get_forms_label_singular() ), |
|
254 | - 'one_price_min' => __( 'You must have at least one price', 'give' ), |
|
255 | - 'one_file_min' => __( 'You must have at least one file', 'give' ), |
|
256 | - 'one_field_min' => __( 'You must have at least one field', 'give' ), |
|
257 | - 'one_option' => sprintf( __( 'Choose a %s', 'give' ), give_get_forms_label_singular() ), |
|
258 | - 'one_or_more_option' => sprintf( __( 'Choose one or more %s', 'give' ), give_get_forms_label_plural() ), |
|
259 | - 'numeric_item_price' => __( 'Item price must be numeric', 'give' ), |
|
260 | - 'numeric_quantity' => __( 'Quantity must be numeric', 'give' ), |
|
261 | - 'currency_sign' => give_currency_filter( '' ), |
|
262 | - 'currency_pos' => isset( $give_options['currency_position'] ) ? $give_options['currency_position'] : 'before', |
|
246 | + 'quick_edit_warning' => __('Sorry, not available for variable priced forms.', 'give'), |
|
247 | + 'delete_payment' => __('Are you sure you wish to delete this payment?', 'give'), |
|
248 | + 'delete_payment_note' => __('Are you sure you wish to delete this note?', 'give'), |
|
249 | + 'revoke_api_key' => __('Are you sure you wish to revoke this API key?', 'give'), |
|
250 | + 'regenerate_api_key' => __('Are you sure you wish to regenerate this API key?', 'give'), |
|
251 | + 'resend_receipt' => __('Are you sure you wish to resend the donation receipt?', 'give'), |
|
252 | + 'copy_download_link_text' => __('Copy these links to your clipboard and give them to your donor', 'give'), |
|
253 | + 'delete_payment_download' => sprintf(__('Are you sure you wish to delete this %s?', 'give'), give_get_forms_label_singular()), |
|
254 | + 'one_price_min' => __('You must have at least one price', 'give'), |
|
255 | + 'one_file_min' => __('You must have at least one file', 'give'), |
|
256 | + 'one_field_min' => __('You must have at least one field', 'give'), |
|
257 | + 'one_option' => sprintf(__('Choose a %s', 'give'), give_get_forms_label_singular()), |
|
258 | + 'one_or_more_option' => sprintf(__('Choose one or more %s', 'give'), give_get_forms_label_plural()), |
|
259 | + 'numeric_item_price' => __('Item price must be numeric', 'give'), |
|
260 | + 'numeric_quantity' => __('Quantity must be numeric', 'give'), |
|
261 | + 'currency_sign' => give_currency_filter(''), |
|
262 | + 'currency_pos' => isset($give_options['currency_position']) ? $give_options['currency_position'] : 'before', |
|
263 | 263 | 'currency_decimals' => give_currency_decimal_filter(), |
264 | - 'new_media_ui' => apply_filters( 'give_use_35_media_ui', 1 ), |
|
265 | - 'remove_text' => __( 'Remove', 'give' ), |
|
266 | - 'type_to_search' => sprintf( __( 'Type to search %s', 'give' ), give_get_forms_label_plural() ), |
|
267 | - 'batch_export_no_class' => __( 'You must choose a method.', 'give' ), |
|
268 | - 'batch_export_no_reqs' => __( 'Required fields not completed.', 'give' ), |
|
269 | - 'reset_stats_warn' => __( 'Are you sure you want to reset Give? This process is <strong><em>not reversible</em></strong> and will delete all data regardless of test or live mode. Please be sure you have a recent backup before proceeding.', 'give' ), |
|
270 | - ) ); |
|
271 | - |
|
272 | - if ( function_exists( 'wp_enqueue_media' ) && version_compare( $wp_version, '3.5', '>=' ) ) { |
|
264 | + 'new_media_ui' => apply_filters('give_use_35_media_ui', 1), |
|
265 | + 'remove_text' => __('Remove', 'give'), |
|
266 | + 'type_to_search' => sprintf(__('Type to search %s', 'give'), give_get_forms_label_plural()), |
|
267 | + 'batch_export_no_class' => __('You must choose a method.', 'give'), |
|
268 | + 'batch_export_no_reqs' => __('Required fields not completed.', 'give'), |
|
269 | + 'reset_stats_warn' => __('Are you sure you want to reset Give? This process is <strong><em>not reversible</em></strong> and will delete all data regardless of test or live mode. Please be sure you have a recent backup before proceeding.', 'give'), |
|
270 | + )); |
|
271 | + |
|
272 | + if (function_exists('wp_enqueue_media') && version_compare($wp_version, '3.5', '>=')) { |
|
273 | 273 | //call for new media manager |
274 | 274 | wp_enqueue_media(); |
275 | 275 | } |
276 | 276 | |
277 | 277 | } |
278 | 278 | |
279 | -add_action( 'admin_enqueue_scripts', 'give_load_admin_scripts', 100 ); |
|
279 | +add_action('admin_enqueue_scripts', 'give_load_admin_scripts', 100); |
|
280 | 280 | |
281 | 281 | /** |
282 | 282 | * Admin Give Icon |
@@ -293,14 +293,14 @@ discard block |
||
293 | 293 | ?> |
294 | 294 | <style type="text/css" media="screen"> |
295 | 295 | |
296 | - <?php if( version_compare( $wp_version, '3.8-RC', '>=' ) || version_compare( $wp_version, '3.8', '>=' ) ) { ?> |
|
296 | + <?php if (version_compare($wp_version, '3.8-RC', '>=') || version_compare($wp_version, '3.8', '>=')) { ?> |
|
297 | 297 | @font-face { |
298 | 298 | font-family: 'give-icomoon'; |
299 | - src: url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.eot?-ngjl88'; ?>'); |
|
300 | - src: url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.eot?#iefix-ngjl88'?>') format('embedded-opentype'), |
|
301 | - url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.woff?-ngjl88'; ?>') format('woff'), |
|
302 | - url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.ttf?-ngjl88'; ?>') format('truetype'), |
|
303 | - url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.svg?-ngjl88#icomoon'; ?>') format('svg'); |
|
299 | + src: url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.eot?-ngjl88'; ?>'); |
|
300 | + src: url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.eot?#iefix-ngjl88'?>') format('embedded-opentype'), |
|
301 | + url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.woff?-ngjl88'; ?>') format('woff'), |
|
302 | + url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.ttf?-ngjl88'; ?>') format('truetype'), |
|
303 | + url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.svg?-ngjl88#icomoon'; ?>') format('svg'); |
|
304 | 304 | font-weight: normal; |
305 | 305 | font-style: normal; |
306 | 306 | } |
@@ -319,4 +319,4 @@ discard block |
||
319 | 319 | <?php |
320 | 320 | } |
321 | 321 | |
322 | -add_action( 'admin_head', 'give_admin_icon' ); |
|
322 | +add_action('admin_head', 'give_admin_icon'); |
@@ -49,26 +49,26 @@ discard block |
||
49 | 49 | */ |
50 | 50 | public function __construct() { |
51 | 51 | |
52 | - add_action( 'admin_init', array( $this, 'init' ) ); |
|
52 | + add_action('admin_init', array($this, 'init')); |
|
53 | 53 | |
54 | 54 | //Customize CMB2 URL |
55 | - add_filter( 'cmb2_meta_box_url', array( $this, 'give_update_cmb_meta_box_url' ) ); |
|
55 | + add_filter('cmb2_meta_box_url', array($this, 'give_update_cmb_meta_box_url')); |
|
56 | 56 | |
57 | 57 | //Custom CMB2 Settings Fields |
58 | - add_action( 'cmb2_render_give_title', 'give_title_callback', 10, 5 ); |
|
59 | - add_action( 'cmb2_render_give_description', 'give_description_callback', 10, 5 ); |
|
60 | - add_action( 'cmb2_render_enabled_gateways', 'give_enabled_gateways_callback', 10, 5 ); |
|
61 | - add_action( 'cmb2_render_default_gateway', 'give_default_gateway_callback', 10, 5 ); |
|
62 | - add_action( 'cmb2_render_email_preview_buttons', 'give_email_preview_buttons_callback', 10, 5 ); |
|
63 | - add_action( 'cmb2_render_system_info', 'give_system_info_callback', 10, 5 ); |
|
64 | - add_action( 'cmb2_render_api', 'give_api_callback', 10, 5 ); |
|
65 | - add_action( 'cmb2_render_license_key', 'give_license_key_callback', 10, 5 ); |
|
66 | - add_action( 'admin_notices', array( $this, 'settings_notices' ) ); |
|
58 | + add_action('cmb2_render_give_title', 'give_title_callback', 10, 5); |
|
59 | + add_action('cmb2_render_give_description', 'give_description_callback', 10, 5); |
|
60 | + add_action('cmb2_render_enabled_gateways', 'give_enabled_gateways_callback', 10, 5); |
|
61 | + add_action('cmb2_render_default_gateway', 'give_default_gateway_callback', 10, 5); |
|
62 | + add_action('cmb2_render_email_preview_buttons', 'give_email_preview_buttons_callback', 10, 5); |
|
63 | + add_action('cmb2_render_system_info', 'give_system_info_callback', 10, 5); |
|
64 | + add_action('cmb2_render_api', 'give_api_callback', 10, 5); |
|
65 | + add_action('cmb2_render_license_key', 'give_license_key_callback', 10, 5); |
|
66 | + add_action('admin_notices', array($this, 'settings_notices')); |
|
67 | 67 | |
68 | 68 | // Include CMB CSS in the head to avoid FOUC |
69 | - add_action( 'admin_print_styles-give_forms_page_give-settings', array( 'CMB2_hookup', 'enqueue_cmb_css' ) ); |
|
69 | + add_action('admin_print_styles-give_forms_page_give-settings', array('CMB2_hookup', 'enqueue_cmb_css')); |
|
70 | 70 | |
71 | - add_filter( 'cmb2_get_metabox_form_format', array( $this, 'give_modify_cmb2_form_output' ), 10, 3 ); |
|
71 | + add_filter('cmb2_get_metabox_form_format', array($this, 'give_modify_cmb2_form_output'), 10, 3); |
|
72 | 72 | |
73 | 73 | } |
74 | 74 | |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * @since 1.0 |
79 | 79 | */ |
80 | 80 | public function init() { |
81 | - register_setting( $this->key, $this->key ); |
|
81 | + register_setting($this->key, $this->key); |
|
82 | 82 | |
83 | 83 | } |
84 | 84 | |
@@ -92,9 +92,9 @@ discard block |
||
92 | 92 | * |
93 | 93 | * @return mixed |
94 | 94 | */ |
95 | - public function give_update_cmb_meta_box_url( $url ) { |
|
95 | + public function give_update_cmb_meta_box_url($url) { |
|
96 | 96 | //Path to Give's CMB |
97 | - return GIVE_PLUGIN_URL . '/includes/libraries/cmb2'; |
|
97 | + return GIVE_PLUGIN_URL.'/includes/libraries/cmb2'; |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | |
@@ -106,27 +106,27 @@ discard block |
||
106 | 106 | */ |
107 | 107 | public function give_get_settings_tabs() { |
108 | 108 | |
109 | - $settings = $this->give_settings( null ); |
|
109 | + $settings = $this->give_settings(null); |
|
110 | 110 | |
111 | 111 | $tabs = array(); |
112 | - $tabs['general'] = __( 'General', 'give' ); |
|
113 | - $tabs['gateways'] = __( 'Payment Gateways', 'give' ); |
|
114 | - $tabs['display'] = __( 'Display Options', 'give' ); |
|
115 | - $tabs['emails'] = __( 'Emails', 'give' ); |
|
112 | + $tabs['general'] = __('General', 'give'); |
|
113 | + $tabs['gateways'] = __('Payment Gateways', 'give'); |
|
114 | + $tabs['display'] = __('Display Options', 'give'); |
|
115 | + $tabs['emails'] = __('Emails', 'give'); |
|
116 | 116 | |
117 | - if ( ! empty( $settings['addons']['fields'] ) ) { |
|
118 | - $tabs['addons'] = __( 'Add-ons', 'give' ); |
|
117 | + if ( ! empty($settings['addons']['fields'])) { |
|
118 | + $tabs['addons'] = __('Add-ons', 'give'); |
|
119 | 119 | } |
120 | 120 | |
121 | - if ( ! empty( $settings['licenses']['fields'] ) ) { |
|
122 | - $tabs['licenses'] = __( 'Licenses', 'give' ); |
|
121 | + if ( ! empty($settings['licenses']['fields'])) { |
|
122 | + $tabs['licenses'] = __('Licenses', 'give'); |
|
123 | 123 | } |
124 | 124 | |
125 | - $tabs['advanced'] = __( 'Advanced', 'give' ); |
|
126 | - $tabs['api'] = __( 'API', 'give' ); |
|
127 | - $tabs['system_info'] = __( 'System Info', 'give' ); |
|
125 | + $tabs['advanced'] = __('Advanced', 'give'); |
|
126 | + $tabs['api'] = __('API', 'give'); |
|
127 | + $tabs['system_info'] = __('System Info', 'give'); |
|
128 | 128 | |
129 | - return apply_filters( 'give_settings_tabs', $tabs ); |
|
129 | + return apply_filters('give_settings_tabs', $tabs); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | */ |
137 | 137 | public function admin_page_display() { |
138 | 138 | |
139 | - $active_tab = isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $this->give_get_settings_tabs() ) ? $_GET['tab'] : 'general'; |
|
139 | + $active_tab = isset($_GET['tab']) && array_key_exists($_GET['tab'], $this->give_get_settings_tabs()) ? $_GET['tab'] : 'general'; |
|
140 | 140 | |
141 | 141 | ?> |
142 | 142 | |
@@ -144,20 +144,20 @@ discard block |
||
144 | 144 | |
145 | 145 | <h1 class="nav-tab-wrapper"> |
146 | 146 | <?php |
147 | - foreach ( $this->give_get_settings_tabs() as $tab_id => $tab_name ) { |
|
147 | + foreach ($this->give_get_settings_tabs() as $tab_id => $tab_name) { |
|
148 | 148 | |
149 | 149 | //Support legacy tab creation conditions based off $_GET parameter |
150 | 150 | //We pass the $_GET['tab'] to conditions executed later |
151 | 151 | $_GET['tab'] = $tab_id; |
152 | 152 | |
153 | - $tab_url = esc_url( add_query_arg( array( |
|
153 | + $tab_url = esc_url(add_query_arg(array( |
|
154 | 154 | 'settings-updated' => false, |
155 | 155 | 'tab' => $tab_id |
156 | - ) ) ); |
|
156 | + ))); |
|
157 | 157 | |
158 | - $active = $active_tab == $tab_id ? ' nav-tab-active' : ''; |
|
158 | + $active = $active_tab == $tab_id ? ' nav-tab-active' : ''; |
|
159 | 159 | |
160 | - echo '<a href="' . esc_url( $tab_url ) . '" title="' . esc_attr( $tab_name ) . '" class="nav-tab' . $active . '" id="tab-' . $tab_id . '">' . esc_html( $tab_name ) . '</a>'; |
|
160 | + echo '<a href="'.esc_url($tab_url).'" title="'.esc_attr($tab_name).'" class="nav-tab'.$active.'" id="tab-'.$tab_id.'">'.esc_html($tab_name).'</a>'; |
|
161 | 161 | |
162 | 162 | } |
163 | 163 | ?> |
@@ -165,20 +165,20 @@ discard block |
||
165 | 165 | |
166 | 166 | <?php |
167 | 167 | //Loop through and output settings |
168 | - foreach ( $this->give_get_settings_tabs() as $tab_id => $tab_name ) { |
|
168 | + foreach ($this->give_get_settings_tabs() as $tab_id => $tab_name) { |
|
169 | 169 | |
170 | 170 | //Support legacy tab creation conditions based off $_GET parameter |
171 | 171 | //We 'trick' the conditions into thinking this is the tab |
172 | 172 | $_GET['tab'] = $tab_id; |
173 | 173 | |
174 | - $tab_settings = $this->give_settings( $tab_id ); |
|
174 | + $tab_settings = $this->give_settings($tab_id); |
|
175 | 175 | |
176 | 176 | //Pass active tab within $tab_settings so we can hide with CSS via PHP |
177 | - if ( $active_tab == $tab_id ) { |
|
177 | + if ($active_tab == $tab_id) { |
|
178 | 178 | $tab_settings['active_tab'] = true; |
179 | 179 | } |
180 | 180 | |
181 | - cmb2_metabox_form( $tab_settings, $this->key ); |
|
181 | + cmb2_metabox_form($tab_settings, $this->key); |
|
182 | 182 | |
183 | 183 | } ?> |
184 | 184 | |
@@ -196,34 +196,34 @@ discard block |
||
196 | 196 | * @since 1.5 Modified to CSS hide non-active tabs |
197 | 197 | * @since 1.0 |
198 | 198 | */ |
199 | - function give_modify_cmb2_form_output( $form_format, $object_id, $cmb ) { |
|
199 | + function give_modify_cmb2_form_output($form_format, $object_id, $cmb) { |
|
200 | 200 | |
201 | 201 | |
202 | - $pagenow = isset( $_GET['page'] ) ? $_GET['page'] : ''; |
|
202 | + $pagenow = isset($_GET['page']) ? $_GET['page'] : ''; |
|
203 | 203 | |
204 | 204 | //only modify the give settings form |
205 | - if ( 'give_settings' == $object_id && $pagenow == 'give-settings' ) { |
|
205 | + if ('give_settings' == $object_id && $pagenow == 'give-settings') { |
|
206 | 206 | |
207 | 207 | $style = ''; |
208 | - if ( ! isset( $cmb->meta_box['active_tab'] ) ) { |
|
208 | + if ( ! isset($cmb->meta_box['active_tab'])) { |
|
209 | 209 | $style = 'style="display:none;"'; |
210 | 210 | } |
211 | 211 | |
212 | 212 | //Set ID based off tab name - protects backwards compatibility |
213 | - $tab_id = isset( $_GET['tab'] ) ? $_GET['tab'] : $cmb->meta_box['id']; |
|
213 | + $tab_id = isset($_GET['tab']) ? $_GET['tab'] : $cmb->meta_box['id']; |
|
214 | 214 | |
215 | - $save_button = apply_filters( 'give_save_button_markup', '<div class="give-submit-wrap"><input type="submit" name="submit-cmb" value="' . __( 'Save Settings', 'give' ) . '" class="button-primary"></div>' ); |
|
215 | + $save_button = apply_filters('give_save_button_markup', '<div class="give-submit-wrap"><input type="submit" name="submit-cmb" value="'.__('Save Settings', 'give').'" class="button-primary"></div>'); |
|
216 | 216 | |
217 | 217 | //Filter so some tabs won't have save settings |
218 | - $no_save_button = apply_filters( 'give_settings_no_save_output', array( |
|
218 | + $no_save_button = apply_filters('give_settings_no_save_output', array( |
|
219 | 219 | 'system_info' |
220 | - ) ); |
|
220 | + )); |
|
221 | 221 | |
222 | - if ( in_array( $tab_id, $no_save_button ) ) { |
|
222 | + if (in_array($tab_id, $no_save_button)) { |
|
223 | 223 | $save_button = ''; |
224 | 224 | } |
225 | 225 | |
226 | - $form_format = '<form class="cmb-form" method="post" id="%1$s" enctype="multipart/form-data" encoding="multipart/form-data" ' . $style . ' data-tab="' . $tab_id . '"><input type="hidden" name="give_settings_saved" value="true"><input type="hidden" name="object_id" value="%2$s">%3$s' . $save_button . '</form>'; |
|
226 | + $form_format = '<form class="cmb-form" method="post" id="%1$s" enctype="multipart/form-data" encoding="multipart/form-data" '.$style.' data-tab="'.$tab_id.'"><input type="hidden" name="give_settings_saved" value="true"><input type="hidden" name="object_id" value="%2$s">%3$s'.$save_button.'</form>'; |
|
227 | 227 | |
228 | 228 | } |
229 | 229 | |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | * |
241 | 241 | * @return array |
242 | 242 | */ |
243 | - public function give_settings( $active_tab ) { |
|
243 | + public function give_settings($active_tab) { |
|
244 | 244 | |
245 | 245 | $give_settings = array( |
246 | 246 | /** |
@@ -248,60 +248,60 @@ discard block |
||
248 | 248 | */ |
249 | 249 | 'general' => array( |
250 | 250 | 'id' => 'general_settings', |
251 | - 'give_title' => __( 'General Settings', 'give' ), |
|
252 | - 'show_on' => array( 'key' => 'options-page', 'value' => array( $this->key, ), ), |
|
253 | - 'fields' => apply_filters( 'give_settings_general', array( |
|
251 | + 'give_title' => __('General Settings', 'give'), |
|
252 | + 'show_on' => array('key' => 'options-page', 'value' => array($this->key,),), |
|
253 | + 'fields' => apply_filters('give_settings_general', array( |
|
254 | 254 | array( |
255 | - 'name' => __( 'General Settings', 'give' ), |
|
255 | + 'name' => __('General Settings', 'give'), |
|
256 | 256 | 'desc' => '', |
257 | 257 | 'type' => 'give_title', |
258 | 258 | 'id' => 'give_title_general_settings_1' |
259 | 259 | ), |
260 | 260 | array( |
261 | - 'name' => __( 'Success Page', 'give' ), |
|
262 | - 'desc' => sprintf( __( 'This is the page donors are sent to after completing their donations. The %1$s[give_receipt]%2$s shortcode should be on this page.', 'give' ), '<code>', '</code>' ), |
|
261 | + 'name' => __('Success Page', 'give'), |
|
262 | + 'desc' => sprintf(__('This is the page donors are sent to after completing their donations. The %1$s[give_receipt]%2$s shortcode should be on this page.', 'give'), '<code>', '</code>'), |
|
263 | 263 | 'id' => 'success_page', |
264 | 264 | 'type' => 'select', |
265 | - 'options' => give_cmb2_get_post_options( array( |
|
265 | + 'options' => give_cmb2_get_post_options(array( |
|
266 | 266 | 'post_type' => 'page', |
267 | - 'numberposts' => - 1 |
|
268 | - ) ), |
|
267 | + 'numberposts' => -1 |
|
268 | + )), |
|
269 | 269 | ), |
270 | 270 | array( |
271 | - 'name' => __( 'Failed Transaction Page', 'give' ), |
|
272 | - 'desc' => __( 'This is the page donors are sent to if their transaction is cancelled or fails.', 'give' ), |
|
271 | + 'name' => __('Failed Transaction Page', 'give'), |
|
272 | + 'desc' => __('This is the page donors are sent to if their transaction is cancelled or fails.', 'give'), |
|
273 | 273 | 'id' => 'failure_page', |
274 | 274 | 'type' => 'select', |
275 | - 'options' => give_cmb2_get_post_options( array( |
|
275 | + 'options' => give_cmb2_get_post_options(array( |
|
276 | 276 | 'post_type' => 'page', |
277 | - 'numberposts' => - 1 |
|
278 | - ) ), |
|
277 | + 'numberposts' => -1 |
|
278 | + )), |
|
279 | 279 | ), |
280 | 280 | array( |
281 | - 'name' => __( 'Donation History Page', 'give' ), |
|
282 | - 'desc' => sprintf( __( 'This page shows a complete donation history for the current user. The %1$s[donation_history]%2$s shortcode should be on this page.', 'give' ), '<code>', '</code>' ), |
|
281 | + 'name' => __('Donation History Page', 'give'), |
|
282 | + 'desc' => sprintf(__('This page shows a complete donation history for the current user. The %1$s[donation_history]%2$s shortcode should be on this page.', 'give'), '<code>', '</code>'), |
|
283 | 283 | 'id' => 'history_page', |
284 | 284 | 'type' => 'select', |
285 | - 'options' => give_cmb2_get_post_options( array( |
|
285 | + 'options' => give_cmb2_get_post_options(array( |
|
286 | 286 | 'post_type' => 'page', |
287 | - 'numberposts' => - 1 |
|
288 | - ) ), |
|
287 | + 'numberposts' => -1 |
|
288 | + )), |
|
289 | 289 | ), |
290 | 290 | array( |
291 | - 'name' => __( 'Base Country', 'give' ), |
|
292 | - 'desc' => __( 'Where does your site operate from?', 'give' ), |
|
291 | + 'name' => __('Base Country', 'give'), |
|
292 | + 'desc' => __('Where does your site operate from?', 'give'), |
|
293 | 293 | 'id' => 'base_country', |
294 | 294 | 'type' => 'select', |
295 | 295 | 'options' => give_get_country_list(), |
296 | 296 | ), |
297 | 297 | array( |
298 | - 'name' => __( 'Currency Settings', 'give' ), |
|
298 | + 'name' => __('Currency Settings', 'give'), |
|
299 | 299 | 'desc' => '', |
300 | 300 | 'type' => 'give_title', |
301 | 301 | 'id' => 'give_title_general_settings_2' |
302 | 302 | ), |
303 | 303 | array( |
304 | - 'name' => __( 'Currency', 'give' ), |
|
304 | + 'name' => __('Currency', 'give'), |
|
305 | 305 | 'desc' => 'Choose your currency. Note that some payment gateways have currency restrictions.', |
306 | 306 | 'id' => 'currency', |
307 | 307 | 'type' => 'select', |
@@ -309,26 +309,26 @@ discard block |
||
309 | 309 | 'default' => 'USD', |
310 | 310 | ), |
311 | 311 | array( |
312 | - 'name' => __( 'Currency Position', 'give' ), |
|
312 | + 'name' => __('Currency Position', 'give'), |
|
313 | 313 | 'desc' => 'Choose the position of the currency sign.', |
314 | 314 | 'id' => 'currency_position', |
315 | 315 | 'type' => 'select', |
316 | 316 | 'options' => array( |
317 | - 'before' => sprintf( __( 'Before - %1$s10', 'give' ), give_currency_symbol( give_get_currency() ) ), |
|
318 | - 'after' => sprintf( __( 'After - 10%1$s', 'give' ), give_currency_symbol( give_get_currency() ) ) |
|
317 | + 'before' => sprintf(__('Before - %1$s10', 'give'), give_currency_symbol(give_get_currency())), |
|
318 | + 'after' => sprintf(__('After - 10%1$s', 'give'), give_currency_symbol(give_get_currency())) |
|
319 | 319 | ), |
320 | 320 | 'default' => 'before', |
321 | 321 | ), |
322 | 322 | array( |
323 | - 'name' => __( 'Thousands Separator', 'give' ), |
|
324 | - 'desc' => __( 'The symbol (typically , or .) to separate thousands', 'give' ), |
|
323 | + 'name' => __('Thousands Separator', 'give'), |
|
324 | + 'desc' => __('The symbol (typically , or .) to separate thousands', 'give'), |
|
325 | 325 | 'id' => 'thousands_separator', |
326 | 326 | 'type' => 'text_small', |
327 | 327 | 'default' => ',', |
328 | 328 | ), |
329 | 329 | array( |
330 | - 'name' => __( 'Decimal Separator', 'give' ), |
|
331 | - 'desc' => __( 'The symbol (usually , or .) to separate decimal points', 'give' ), |
|
330 | + 'name' => __('Decimal Separator', 'give'), |
|
331 | + 'desc' => __('The symbol (usually , or .) to separate decimal points', 'give'), |
|
332 | 332 | 'id' => 'decimal_separator', |
333 | 333 | 'type' => 'text_small', |
334 | 334 | 'default' => '.', |
@@ -341,83 +341,83 @@ discard block |
||
341 | 341 | */ |
342 | 342 | 'gateways' => array( |
343 | 343 | 'id' => 'payment_gateways', |
344 | - 'give_title' => __( 'Payment Gateways', 'give' ), |
|
345 | - 'show_on' => array( 'key' => 'options-page', 'value' => array( $this->key, ), ), |
|
346 | - 'fields' => apply_filters( 'give_settings_gateways', array( |
|
344 | + 'give_title' => __('Payment Gateways', 'give'), |
|
345 | + 'show_on' => array('key' => 'options-page', 'value' => array($this->key,),), |
|
346 | + 'fields' => apply_filters('give_settings_gateways', array( |
|
347 | 347 | array( |
348 | - 'name' => __( 'Gateways Settings', 'give' ), |
|
348 | + 'name' => __('Gateways Settings', 'give'), |
|
349 | 349 | 'desc' => '', |
350 | 350 | 'id' => 'give_title_gateway_settings_1', |
351 | 351 | 'type' => 'give_title' |
352 | 352 | ), |
353 | 353 | array( |
354 | - 'name' => __( 'Test Mode', 'give' ), |
|
355 | - 'desc' => __( 'While in test mode no live transactions are processed. To fully use test mode, you must have a sandbox (test) account for the payment gateway you are testing.', 'give' ), |
|
354 | + 'name' => __('Test Mode', 'give'), |
|
355 | + 'desc' => __('While in test mode no live transactions are processed. To fully use test mode, you must have a sandbox (test) account for the payment gateway you are testing.', 'give'), |
|
356 | 356 | 'id' => 'test_mode', |
357 | 357 | 'type' => 'checkbox' |
358 | 358 | ), |
359 | 359 | array( |
360 | - 'name' => __( 'Enabled Gateways', 'give' ), |
|
361 | - 'desc' => __( 'Choose the payment gateways you would like enabled.', 'give' ), |
|
360 | + 'name' => __('Enabled Gateways', 'give'), |
|
361 | + 'desc' => __('Choose the payment gateways you would like enabled.', 'give'), |
|
362 | 362 | 'id' => 'gateways', |
363 | 363 | 'type' => 'enabled_gateways' |
364 | 364 | ), |
365 | 365 | array( |
366 | - 'name' => __( 'Default Gateway', 'give' ), |
|
367 | - 'desc' => __( 'This is the gateway that will be selected by default.', 'give' ), |
|
366 | + 'name' => __('Default Gateway', 'give'), |
|
367 | + 'desc' => __('This is the gateway that will be selected by default.', 'give'), |
|
368 | 368 | 'id' => 'default_gateway', |
369 | 369 | 'type' => 'default_gateway' |
370 | 370 | ), |
371 | 371 | array( |
372 | - 'name' => __( 'PayPal Standard', 'give' ), |
|
372 | + 'name' => __('PayPal Standard', 'give'), |
|
373 | 373 | 'desc' => '', |
374 | 374 | 'type' => 'give_title', |
375 | 375 | 'id' => 'give_title_gateway_settings_2', |
376 | 376 | ), |
377 | 377 | array( |
378 | - 'name' => __( 'PayPal Email', 'give' ), |
|
379 | - 'desc' => __( 'Enter your PayPal account\'s email', 'give' ), |
|
378 | + 'name' => __('PayPal Email', 'give'), |
|
379 | + 'desc' => __('Enter your PayPal account\'s email', 'give'), |
|
380 | 380 | 'id' => 'paypal_email', |
381 | 381 | 'type' => 'text_email', |
382 | 382 | ), |
383 | 383 | array( |
384 | - 'name' => __( 'PayPal Page Style', 'give' ), |
|
385 | - 'desc' => __( 'Enter the name of the page style to use, or leave blank to use the default', 'give' ), |
|
384 | + 'name' => __('PayPal Page Style', 'give'), |
|
385 | + 'desc' => __('Enter the name of the page style to use, or leave blank to use the default', 'give'), |
|
386 | 386 | 'id' => 'paypal_page_style', |
387 | 387 | 'type' => 'text', |
388 | 388 | ), |
389 | 389 | array( |
390 | - 'name' => __( 'PayPal Transaction Type', 'give' ), |
|
391 | - 'desc' => __( 'Nonprofits must verify their status to withdraw donations they receive via PayPal. PayPal users that are not verified nonprofits must demonstrate how their donations will be used, once they raise more than $10,000. By default, Give transactions are sent to PayPal as donations. You may change the transaction type using this option if you feel you may not meet PayPal\'s donation requirements.', 'give' ), |
|
390 | + 'name' => __('PayPal Transaction Type', 'give'), |
|
391 | + 'desc' => __('Nonprofits must verify their status to withdraw donations they receive via PayPal. PayPal users that are not verified nonprofits must demonstrate how their donations will be used, once they raise more than $10,000. By default, Give transactions are sent to PayPal as donations. You may change the transaction type using this option if you feel you may not meet PayPal\'s donation requirements.', 'give'), |
|
392 | 392 | 'id' => 'paypal_button_type', |
393 | 393 | 'type' => 'radio_inline', |
394 | 394 | 'options' => array( |
395 | - 'donation' => __( 'Donation', 'give' ), |
|
396 | - 'standard' => __( 'Standard Transaction', 'give' ) |
|
395 | + 'donation' => __('Donation', 'give'), |
|
396 | + 'standard' => __('Standard Transaction', 'give') |
|
397 | 397 | ), |
398 | 398 | 'default' => 'donation', |
399 | 399 | ), |
400 | 400 | array( |
401 | - 'name' => __( 'Disable PayPal IPN Verification', 'give' ), |
|
402 | - 'desc' => __( 'If donations are not getting marked as complete, then check this box. This forces the site to use a slightly less secure method of verifying donations.', 'give' ), |
|
401 | + 'name' => __('Disable PayPal IPN Verification', 'give'), |
|
402 | + 'desc' => __('If donations are not getting marked as complete, then check this box. This forces the site to use a slightly less secure method of verifying donations.', 'give'), |
|
403 | 403 | 'id' => 'disable_paypal_verification', |
404 | 404 | 'type' => 'checkbox' |
405 | 405 | ), |
406 | 406 | array( |
407 | - 'name' => __( 'Offline Donations', 'give' ), |
|
407 | + 'name' => __('Offline Donations', 'give'), |
|
408 | 408 | 'desc' => '', |
409 | 409 | 'type' => 'give_title', |
410 | 410 | 'id' => 'give_title_gateway_settings_3', |
411 | 411 | ), |
412 | 412 | array( |
413 | - 'name' => __( 'Collect Billing Details', 'give' ), |
|
414 | - 'desc' => __( 'This option will enable the billing details section for offline donations. The fieldset will appear above the offline donation instructions. Note: You may customize this option per form as needed.', 'give' ), |
|
413 | + 'name' => __('Collect Billing Details', 'give'), |
|
414 | + 'desc' => __('This option will enable the billing details section for offline donations. The fieldset will appear above the offline donation instructions. Note: You may customize this option per form as needed.', 'give'), |
|
415 | 415 | 'id' => 'give_offline_donation_enable_billing_fields', |
416 | 416 | 'type' => 'checkbox' |
417 | 417 | ), |
418 | 418 | array( |
419 | - 'name' => __( 'Offline Donation Instructions', 'give' ), |
|
420 | - 'desc' => __( 'The following content will appear for all forms when the user selects the offline donation payment option. Note: You may customize the content per form as needed.', 'give' ), |
|
419 | + 'name' => __('Offline Donation Instructions', 'give'), |
|
420 | + 'desc' => __('The following content will appear for all forms when the user selects the offline donation payment option. Note: You may customize the content per form as needed.', 'give'), |
|
421 | 421 | 'id' => 'global_offline_donation_content', |
422 | 422 | 'default' => give_get_default_offline_donation_content(), |
423 | 423 | 'type' => 'wysiwyg', |
@@ -426,15 +426,15 @@ discard block |
||
426 | 426 | ) |
427 | 427 | ), |
428 | 428 | array( |
429 | - 'name' => __( 'Offline Donation Email Instructions Subject', 'give' ), |
|
430 | - 'desc' => __( 'Enter the subject line for the donation receipt email.', 'give' ), |
|
429 | + 'name' => __('Offline Donation Email Instructions Subject', 'give'), |
|
430 | + 'desc' => __('Enter the subject line for the donation receipt email.', 'give'), |
|
431 | 431 | 'id' => 'offline_donation_subject', |
432 | - 'default' => __( '{donation} - Offline Donation Instructions', 'give' ), |
|
432 | + 'default' => __('{donation} - Offline Donation Instructions', 'give'), |
|
433 | 433 | 'type' => 'text' |
434 | 434 | ), |
435 | 435 | array( |
436 | - 'name' => __( 'Offline Donation Email Instructions', 'give' ), |
|
437 | - 'desc' => __( 'Enter the instructions you want emailed to the donor after they have submitted the donation form. Most likely this would include important information like mailing address and who to make the check out to.', 'give' ), |
|
436 | + 'name' => __('Offline Donation Email Instructions', 'give'), |
|
437 | + 'desc' => __('Enter the instructions you want emailed to the donor after they have submitted the donation form. Most likely this would include important information like mailing address and who to make the check out to.', 'give'), |
|
438 | 438 | 'id' => 'global_offline_donation_email', |
439 | 439 | 'default' => give_get_default_offline_donation_email_content(), |
440 | 440 | 'type' => 'wysiwyg', |
@@ -448,93 +448,93 @@ discard block |
||
448 | 448 | /** Display Settings */ |
449 | 449 | 'display' => array( |
450 | 450 | 'id' => 'display_settings', |
451 | - 'give_title' => __( 'Display Settings', 'give' ), |
|
452 | - 'show_on' => array( 'key' => 'options-page', 'value' => array( $this->key, ), ), |
|
453 | - 'fields' => apply_filters( 'give_settings_display', array( |
|
451 | + 'give_title' => __('Display Settings', 'give'), |
|
452 | + 'show_on' => array('key' => 'options-page', 'value' => array($this->key,),), |
|
453 | + 'fields' => apply_filters('give_settings_display', array( |
|
454 | 454 | array( |
455 | - 'name' => __( 'Display Settings', 'give' ), |
|
455 | + 'name' => __('Display Settings', 'give'), |
|
456 | 456 | 'desc' => '', |
457 | 457 | 'id' => 'give_title_display_settings_1', |
458 | 458 | 'type' => 'give_title' |
459 | 459 | ), |
460 | 460 | array( |
461 | - 'name' => __( 'Disable CSS', 'give' ), |
|
462 | - 'desc' => __( 'Enable this option if you would like to disable all of Give\'s included CSS stylesheets.', 'give' ), |
|
461 | + 'name' => __('Disable CSS', 'give'), |
|
462 | + 'desc' => __('Enable this option if you would like to disable all of Give\'s included CSS stylesheets.', 'give'), |
|
463 | 463 | 'id' => 'disable_css', |
464 | 464 | 'type' => 'checkbox' |
465 | 465 | ), |
466 | 466 | array( |
467 | - 'name' => __( 'Enable Floating Labels', 'give' ), |
|
468 | - 'desc' => sprintf( esc_html__( 'Enable this option if you would like to enable %1$sfloating labels%2$s in Give\'s donation forms. %3$sBe aware that if you have the "Disable CSS" option enabled, you will need to style the floating labels yourself.', 'give' ), '<a href="' . esc_url( "http://bradfrost.com/blog/post/float-label-pattern/" ) . '" target="_blank">', '</a>', '<br />' ), |
|
467 | + 'name' => __('Enable Floating Labels', 'give'), |
|
468 | + 'desc' => sprintf(esc_html__('Enable this option if you would like to enable %1$sfloating labels%2$s in Give\'s donation forms. %3$sBe aware that if you have the "Disable CSS" option enabled, you will need to style the floating labels yourself.', 'give'), '<a href="'.esc_url("http://bradfrost.com/blog/post/float-label-pattern/").'" target="_blank">', '</a>', '<br />'), |
|
469 | 469 | 'id' => 'enable_floatlabels', |
470 | 470 | 'type' => 'checkbox' |
471 | 471 | ), |
472 | 472 | array( |
473 | - 'name' => __( 'Disable Welcome Screen', 'give' ), |
|
474 | - 'desc' => sprintf( esc_html__( 'Enable this option if you would like to disable the Give Welcome screen every time Give is activated and/or updated. You can always access the Welcome Screen %1$shere%2$s if you want in the future.', 'give' ), '<a href="' . esc_url( admin_url( 'index.php?page=give-about' ) ) . '">', '</a>' ), |
|
473 | + 'name' => __('Disable Welcome Screen', 'give'), |
|
474 | + 'desc' => sprintf(esc_html__('Enable this option if you would like to disable the Give Welcome screen every time Give is activated and/or updated. You can always access the Welcome Screen %1$shere%2$s if you want in the future.', 'give'), '<a href="'.esc_url(admin_url('index.php?page=give-about')).'">', '</a>'), |
|
475 | 475 | 'id' => 'disable_welcome', |
476 | 476 | 'type' => 'checkbox' |
477 | 477 | ), |
478 | 478 | array( |
479 | - 'name' => __( 'Post Types', 'give' ), |
|
479 | + 'name' => __('Post Types', 'give'), |
|
480 | 480 | 'desc' => '', |
481 | 481 | 'id' => 'give_title_display_settings_2', |
482 | 482 | 'type' => 'give_title' |
483 | 483 | ), |
484 | 484 | array( |
485 | - 'name' => __( 'Disable Form Single Views', 'give' ), |
|
486 | - 'desc' => __( 'By default, all forms have single views enabled which create a specific URL on your website for that form. This option disables the singular and archive views from being publicly viewable. Note: you will need to embed forms using a shortcode or widget if enabled.', 'give' ), |
|
485 | + 'name' => __('Disable Form Single Views', 'give'), |
|
486 | + 'desc' => __('By default, all forms have single views enabled which create a specific URL on your website for that form. This option disables the singular and archive views from being publicly viewable. Note: you will need to embed forms using a shortcode or widget if enabled.', 'give'), |
|
487 | 487 | 'id' => 'disable_forms_singular', |
488 | 488 | 'type' => 'checkbox' |
489 | 489 | ), |
490 | 490 | array( |
491 | - 'name' => __( 'Disable Form Archives', 'give' ), |
|
492 | - 'desc' => __( 'Archives pages list all the forms you have created. This option will disable only the form\'s archive page(s). The single form\'s view will remain in place. Note: you will need to refresh your permalinks after this option has been enabled.', 'give' ), |
|
491 | + 'name' => __('Disable Form Archives', 'give'), |
|
492 | + 'desc' => __('Archives pages list all the forms you have created. This option will disable only the form\'s archive page(s). The single form\'s view will remain in place. Note: you will need to refresh your permalinks after this option has been enabled.', 'give'), |
|
493 | 493 | 'id' => 'disable_forms_archives', |
494 | 494 | 'type' => 'checkbox' |
495 | 495 | ), |
496 | 496 | array( |
497 | - 'name' => __( 'Disable Form Excerpts', 'give' ), |
|
498 | - 'desc' => __( 'The excerpt is an optional summary or description of a donation form; in short, a summary as to why the user should give.', 'give' ), |
|
497 | + 'name' => __('Disable Form Excerpts', 'give'), |
|
498 | + 'desc' => __('The excerpt is an optional summary or description of a donation form; in short, a summary as to why the user should give.', 'give'), |
|
499 | 499 | 'id' => 'disable_forms_excerpt', |
500 | 500 | 'type' => 'checkbox' |
501 | 501 | ), |
502 | 502 | |
503 | 503 | array( |
504 | - 'name' => __( 'Featured Image Size', 'give' ), |
|
505 | - 'desc' => __( 'The Featured Image is an image that is chosen as the representative image for a donation form. Some themes may have custom featured image sizes. Please select the size you would like to display for your single donation forms\' featured image.', 'give' ), |
|
504 | + 'name' => __('Featured Image Size', 'give'), |
|
505 | + 'desc' => __('The Featured Image is an image that is chosen as the representative image for a donation form. Some themes may have custom featured image sizes. Please select the size you would like to display for your single donation forms\' featured image.', 'give'), |
|
506 | 506 | 'id' => 'featured_image_size', |
507 | 507 | 'type' => 'select', |
508 | 508 | 'default' => 'large', |
509 | 509 | 'options' => give_get_featured_image_sizes() |
510 | 510 | ), |
511 | 511 | array( |
512 | - 'name' => __( 'Disable Form Featured Image', 'give' ), |
|
513 | - 'desc' => __( 'If you do not wish to use the featured image functionality you can disable it using this option and it will not be displayed for single donation forms.', 'give' ), |
|
512 | + 'name' => __('Disable Form Featured Image', 'give'), |
|
513 | + 'desc' => __('If you do not wish to use the featured image functionality you can disable it using this option and it will not be displayed for single donation forms.', 'give'), |
|
514 | 514 | 'id' => 'disable_form_featured_img', |
515 | 515 | 'type' => 'checkbox' |
516 | 516 | ), |
517 | 517 | array( |
518 | - 'name' => __( 'Disable Single Form Sidebar', 'give' ), |
|
519 | - 'desc' => __( 'The sidebar allows you to add additional widget to the Give single form view. If you don\'t plan on using the sidebar you may disable it with this option.', 'give' ), |
|
518 | + 'name' => __('Disable Single Form Sidebar', 'give'), |
|
519 | + 'desc' => __('The sidebar allows you to add additional widget to the Give single form view. If you don\'t plan on using the sidebar you may disable it with this option.', 'give'), |
|
520 | 520 | 'id' => 'disable_form_sidebar', |
521 | 521 | 'type' => 'checkbox' |
522 | 522 | ), |
523 | 523 | array( |
524 | - 'name' => __( 'Taxonomies', 'give' ), |
|
524 | + 'name' => __('Taxonomies', 'give'), |
|
525 | 525 | 'desc' => '', |
526 | 526 | 'id' => 'give_title_display_settings_3', |
527 | 527 | 'type' => 'give_title' |
528 | 528 | ), |
529 | 529 | array( |
530 | - 'name' => __( 'Enable Form Categories', 'give' ), |
|
531 | - 'desc' => __( 'Check this option if you would like to categorize your donation forms. This option enables the form\'s category taxonomy.', 'give' ), |
|
530 | + 'name' => __('Enable Form Categories', 'give'), |
|
531 | + 'desc' => __('Check this option if you would like to categorize your donation forms. This option enables the form\'s category taxonomy.', 'give'), |
|
532 | 532 | 'id' => 'enable_categories', |
533 | 533 | 'type' => 'checkbox' |
534 | 534 | ), |
535 | 535 | array( |
536 | - 'name' => __( 'Enable Form Tags', 'give' ), |
|
537 | - 'desc' => __( 'Check this option if you would like to tag your donation forms. This option enables the form\'s tag taxonomy.', 'give' ), |
|
536 | + 'name' => __('Enable Form Tags', 'give'), |
|
537 | + 'desc' => __('Check this option if you would like to tag your donation forms. This option enables the form\'s tag taxonomy.', 'give'), |
|
538 | 538 | 'id' => 'enable_tags', |
539 | 539 | 'type' => 'checkbox' |
540 | 540 | ), |
@@ -547,93 +547,93 @@ discard block |
||
547 | 547 | */ |
548 | 548 | 'emails' => array( |
549 | 549 | 'id' => 'email_settings', |
550 | - 'give_title' => __( 'Email Settings', 'give' ), |
|
551 | - 'show_on' => array( 'key' => 'options-page', 'value' => array( $this->key, ), ), |
|
552 | - 'fields' => apply_filters( 'give_settings_emails', array( |
|
550 | + 'give_title' => __('Email Settings', 'give'), |
|
551 | + 'show_on' => array('key' => 'options-page', 'value' => array($this->key,),), |
|
552 | + 'fields' => apply_filters('give_settings_emails', array( |
|
553 | 553 | array( |
554 | - 'name' => __( 'Email Settings', 'give' ), |
|
554 | + 'name' => __('Email Settings', 'give'), |
|
555 | 555 | 'desc' => '', |
556 | 556 | 'id' => 'give_title_email_settings_1', |
557 | 557 | 'type' => 'give_title' |
558 | 558 | ), |
559 | 559 | array( |
560 | 560 | 'id' => 'email_template', |
561 | - 'name' => __( 'Email Template', 'give' ), |
|
562 | - 'desc' => __( 'Choose a template. Click "Save Changes" then "Preview Donation Receipt" to see the new template.', 'give' ), |
|
561 | + 'name' => __('Email Template', 'give'), |
|
562 | + 'desc' => __('Choose a template. Click "Save Changes" then "Preview Donation Receipt" to see the new template.', 'give'), |
|
563 | 563 | 'type' => 'select', |
564 | 564 | 'options' => give_get_email_templates() |
565 | 565 | ), |
566 | 566 | array( |
567 | 567 | 'id' => 'email_logo', |
568 | - 'name' => __( 'Logo', 'give' ), |
|
569 | - 'desc' => __( 'Upload or choose a logo to be displayed at the top of the donation receipt emails. Displayed on HTML emails only.', 'give' ), |
|
568 | + 'name' => __('Logo', 'give'), |
|
569 | + 'desc' => __('Upload or choose a logo to be displayed at the top of the donation receipt emails. Displayed on HTML emails only.', 'give'), |
|
570 | 570 | 'type' => 'file' |
571 | 571 | ), |
572 | 572 | array( |
573 | 573 | 'id' => 'from_name', |
574 | - 'name' => __( 'From Name', 'give' ), |
|
575 | - 'desc' => __( 'The name donation receipts are said to come from. This should probably be your site or shop name.', 'give' ), |
|
576 | - 'default' => get_bloginfo( 'name' ), |
|
574 | + 'name' => __('From Name', 'give'), |
|
575 | + 'desc' => __('The name donation receipts are said to come from. This should probably be your site or shop name.', 'give'), |
|
576 | + 'default' => get_bloginfo('name'), |
|
577 | 577 | 'type' => 'text' |
578 | 578 | ), |
579 | 579 | array( |
580 | 580 | 'id' => 'from_email', |
581 | - 'name' => __( 'From Email', 'give' ), |
|
582 | - 'desc' => __( 'Email to send donation receipts from. This will act as the "from" and "reply-to" address.', 'give' ), |
|
583 | - 'default' => get_bloginfo( 'admin_email' ), |
|
581 | + 'name' => __('From Email', 'give'), |
|
582 | + 'desc' => __('Email to send donation receipts from. This will act as the "from" and "reply-to" address.', 'give'), |
|
583 | + 'default' => get_bloginfo('admin_email'), |
|
584 | 584 | 'type' => 'text' |
585 | 585 | ), |
586 | 586 | array( |
587 | - 'name' => __( 'Donation Receipt', 'give' ), |
|
587 | + 'name' => __('Donation Receipt', 'give'), |
|
588 | 588 | 'desc' => '', |
589 | 589 | 'id' => 'give_title_email_settings_2', |
590 | 590 | 'type' => 'give_title' |
591 | 591 | ), |
592 | 592 | array( |
593 | 593 | 'id' => 'donation_subject', |
594 | - 'name' => __( 'Donation Email Subject', 'give' ), |
|
595 | - 'desc' => __( 'Enter the subject line for the donation receipt email', 'give' ), |
|
596 | - 'default' => __( 'Donation Receipt', 'give' ), |
|
594 | + 'name' => __('Donation Email Subject', 'give'), |
|
595 | + 'desc' => __('Enter the subject line for the donation receipt email', 'give'), |
|
596 | + 'default' => __('Donation Receipt', 'give'), |
|
597 | 597 | 'type' => 'text' |
598 | 598 | ), |
599 | 599 | array( |
600 | 600 | 'id' => 'donation_receipt', |
601 | - 'name' => __( 'Donation Receipt', 'give' ), |
|
602 | - 'desc' => __( 'Enter the email that is sent to users after completing a successful donation. HTML is accepted. Available template tags:', 'give' ) . '<br/>' . give_get_emails_tags_list(), |
|
601 | + 'name' => __('Donation Receipt', 'give'), |
|
602 | + 'desc' => __('Enter the email that is sent to users after completing a successful donation. HTML is accepted. Available template tags:', 'give').'<br/>'.give_get_emails_tags_list(), |
|
603 | 603 | 'type' => 'wysiwyg', |
604 | 604 | 'default' => give_get_default_donation_receipt_email() |
605 | 605 | ), |
606 | 606 | array( |
607 | - 'name' => __( 'New Donation Notification', 'give' ), |
|
607 | + 'name' => __('New Donation Notification', 'give'), |
|
608 | 608 | 'desc' => '', |
609 | 609 | 'id' => 'give_title_email_settings_3', |
610 | 610 | 'type' => 'give_title' |
611 | 611 | ), |
612 | 612 | array( |
613 | 613 | 'id' => 'donation_notification_subject', |
614 | - 'name' => __( 'Donation Notification Subject', 'give' ), |
|
615 | - 'desc' => __( 'Enter the subject line for the donation notification email', 'give' ), |
|
614 | + 'name' => __('Donation Notification Subject', 'give'), |
|
615 | + 'desc' => __('Enter the subject line for the donation notification email', 'give'), |
|
616 | 616 | 'type' => 'text', |
617 | - 'default' => __( 'New Donation - #{payment_id}', 'give' ) |
|
617 | + 'default' => __('New Donation - #{payment_id}', 'give') |
|
618 | 618 | ), |
619 | 619 | array( |
620 | 620 | 'id' => 'donation_notification', |
621 | - 'name' => __( 'Donation Notification', 'give' ), |
|
622 | - 'desc' => __( 'Enter the email that is sent to donation notification emails after completion of a donation. HTML is accepted. Available template tags:', 'give' ) . '<br/>' . give_get_emails_tags_list(), |
|
621 | + 'name' => __('Donation Notification', 'give'), |
|
622 | + 'desc' => __('Enter the email that is sent to donation notification emails after completion of a donation. HTML is accepted. Available template tags:', 'give').'<br/>'.give_get_emails_tags_list(), |
|
623 | 623 | 'type' => 'wysiwyg', |
624 | 624 | 'default' => give_get_default_donation_notification_email() |
625 | 625 | ), |
626 | 626 | array( |
627 | 627 | 'id' => 'admin_notice_emails', |
628 | - 'name' => __( 'Donation Notification Emails', 'give' ), |
|
629 | - 'desc' => sprintf( __( 'Enter the email address(es) that should receive a notification anytime a donation is made, please only enter %1$sone email address per line%2$s and not separated by commas.', 'give' ), '<span class="give-underline">', '</span>' ), |
|
628 | + 'name' => __('Donation Notification Emails', 'give'), |
|
629 | + 'desc' => sprintf(__('Enter the email address(es) that should receive a notification anytime a donation is made, please only enter %1$sone email address per line%2$s and not separated by commas.', 'give'), '<span class="give-underline">', '</span>'), |
|
630 | 630 | 'type' => 'textarea', |
631 | - 'default' => get_bloginfo( 'admin_email' ) |
|
631 | + 'default' => get_bloginfo('admin_email') |
|
632 | 632 | ), |
633 | 633 | array( |
634 | 634 | 'id' => 'disable_admin_notices', |
635 | - 'name' => __( 'Disable Admin Notifications', 'give' ), |
|
636 | - 'desc' => __( 'Check this box if you do not want to receive emails when new donations are made.', 'give' ), |
|
635 | + 'name' => __('Disable Admin Notifications', 'give'), |
|
636 | + 'desc' => __('Check this box if you do not want to receive emails when new donations are made.', 'give'), |
|
637 | 637 | 'type' => 'checkbox' |
638 | 638 | ) |
639 | 639 | ) |
@@ -642,96 +642,96 @@ discard block |
||
642 | 642 | /** Extension Settings */ |
643 | 643 | 'addons' => array( |
644 | 644 | 'id' => 'addons', |
645 | - 'give_title' => __( 'Give Add-ons Settings', 'give' ), |
|
646 | - 'show_on' => array( 'key' => 'options-page', 'value' => array( $this->key, ), ), |
|
647 | - 'fields' => apply_filters( 'give_settings_addons', array() |
|
645 | + 'give_title' => __('Give Add-ons Settings', 'give'), |
|
646 | + 'show_on' => array('key' => 'options-page', 'value' => array($this->key,),), |
|
647 | + 'fields' => apply_filters('give_settings_addons', array() |
|
648 | 648 | ) |
649 | 649 | ), |
650 | 650 | /** Licenses Settings */ |
651 | 651 | 'licenses' => array( |
652 | 652 | 'id' => 'licenses', |
653 | - 'give_title' => __( 'Give Licenses', 'give' ), |
|
654 | - 'show_on' => array( 'key' => 'options-page', 'value' => array( $this->key, ), ), |
|
655 | - 'fields' => apply_filters( 'give_settings_licenses', array() |
|
653 | + 'give_title' => __('Give Licenses', 'give'), |
|
654 | + 'show_on' => array('key' => 'options-page', 'value' => array($this->key,),), |
|
655 | + 'fields' => apply_filters('give_settings_licenses', array() |
|
656 | 656 | ) |
657 | 657 | ), |
658 | 658 | /** Advanced Options */ |
659 | 659 | 'advanced' => array( |
660 | 660 | 'id' => 'advanced_options', |
661 | - 'give_title' => __( 'Advanced Options', 'give' ), |
|
662 | - 'show_on' => array( 'key' => 'options-page', 'value' => array( $this->key, ), ), |
|
663 | - 'fields' => apply_filters( 'give_settings_advanced', array( |
|
661 | + 'give_title' => __('Advanced Options', 'give'), |
|
662 | + 'show_on' => array('key' => 'options-page', 'value' => array($this->key,),), |
|
663 | + 'fields' => apply_filters('give_settings_advanced', array( |
|
664 | 664 | array( |
665 | - 'name' => __( 'Access Control', 'give' ), |
|
665 | + 'name' => __('Access Control', 'give'), |
|
666 | 666 | 'desc' => '', |
667 | 667 | 'id' => 'give_title_session_control_1', |
668 | 668 | 'type' => 'give_title' |
669 | 669 | ), |
670 | 670 | array( |
671 | 671 | 'id' => 'session_lifetime', |
672 | - 'name' => __( 'Session Lifetime', 'give' ), |
|
673 | - 'desc' => __( 'Give will start a new session per user once they have donated. This option controls the lifetime a user\'s session is kept alive. An active session allows users to view donation receipts on your site without having to be logged in as long as they are using the same browser they used when donating.', 'give' ), |
|
672 | + 'name' => __('Session Lifetime', 'give'), |
|
673 | + 'desc' => __('Give will start a new session per user once they have donated. This option controls the lifetime a user\'s session is kept alive. An active session allows users to view donation receipts on your site without having to be logged in as long as they are using the same browser they used when donating.', 'give'), |
|
674 | 674 | 'type' => 'select', |
675 | 675 | 'options' => array( |
676 | - '86400' => __( '24 Hours', 'give' ), |
|
677 | - '172800' => __( '48 Hours', 'give' ), |
|
678 | - '259200' => __( '72 Hours', 'give' ), |
|
679 | - '604800' => __( '1 Week', 'give' ), |
|
676 | + '86400' => __('24 Hours', 'give'), |
|
677 | + '172800' => __('48 Hours', 'give'), |
|
678 | + '259200' => __('72 Hours', 'give'), |
|
679 | + '604800' => __('1 Week', 'give'), |
|
680 | 680 | ) |
681 | 681 | ), |
682 | 682 | array( |
683 | - 'name' => __( 'Email Access', 'give' ), |
|
684 | - 'desc' => __( 'Would you like your donors to be able to access their donation history using only email? Donors whose sessions have expired and do not have an account may still access their donation history via a temporary email access link.', 'give' ), |
|
683 | + 'name' => __('Email Access', 'give'), |
|
684 | + 'desc' => __('Would you like your donors to be able to access their donation history using only email? Donors whose sessions have expired and do not have an account may still access their donation history via a temporary email access link.', 'give'), |
|
685 | 685 | 'id' => 'email_access', |
686 | 686 | 'type' => 'checkbox', |
687 | 687 | ), |
688 | 688 | array( |
689 | 689 | 'id' => 'recaptcha_key', |
690 | - 'name' => __( 'reCAPTCHA Site Key', 'give' ), |
|
691 | - 'desc' => sprintf( __( 'If you would like to prevent spam on the email access form navigate to %1$sthe reCAPTCHA website%2$s and sign up for an API key. The reCAPTCHA uses Google\'s user-friendly single click verification method.', 'give' ), '<a href="https://www.google.com/recaptcha/" target="_blank">', '</a>' ), |
|
690 | + 'name' => __('reCAPTCHA Site Key', 'give'), |
|
691 | + 'desc' => sprintf(__('If you would like to prevent spam on the email access form navigate to %1$sthe reCAPTCHA website%2$s and sign up for an API key. The reCAPTCHA uses Google\'s user-friendly single click verification method.', 'give'), '<a href="https://www.google.com/recaptcha/" target="_blank">', '</a>'), |
|
692 | 692 | 'default' => '', |
693 | 693 | 'type' => 'text' |
694 | 694 | ), |
695 | 695 | array( |
696 | 696 | 'id' => 'recaptcha_secret', |
697 | - 'name' => __( 'reCAPTCHA Secret Key', 'give' ), |
|
698 | - 'desc' => __( 'Please paste the reCAPTCHA secret key here from your manage reCAPTCHA API Keys panel.', 'give' ), |
|
697 | + 'name' => __('reCAPTCHA Secret Key', 'give'), |
|
698 | + 'desc' => __('Please paste the reCAPTCHA secret key here from your manage reCAPTCHA API Keys panel.', 'give'), |
|
699 | 699 | 'default' => '', |
700 | 700 | 'type' => 'text' |
701 | 701 | ), |
702 | 702 | array( |
703 | - 'name' => __( 'Data Control', 'give' ), |
|
703 | + 'name' => __('Data Control', 'give'), |
|
704 | 704 | 'desc' => '', |
705 | 705 | 'id' => 'give_title_data_control_2', |
706 | 706 | 'type' => 'give_title' |
707 | 707 | ), |
708 | 708 | array( |
709 | - 'name' => __( 'Remove All Data on Uninstall?', 'give' ), |
|
710 | - 'desc' => __( 'Check this box if you would like Give to completely remove all of its data when the plugin is deleted.', 'give' ), |
|
709 | + 'name' => __('Remove All Data on Uninstall?', 'give'), |
|
710 | + 'desc' => __('Check this box if you would like Give to completely remove all of its data when the plugin is deleted.', 'give'), |
|
711 | 711 | 'id' => 'uninstall_on_delete', |
712 | 712 | 'type' => 'checkbox' |
713 | 713 | ), |
714 | 714 | array( |
715 | - 'name' => __( 'Filter Control', 'give' ), |
|
715 | + 'name' => __('Filter Control', 'give'), |
|
716 | 716 | 'desc' => '', |
717 | 717 | 'id' => 'give_title_filter_control', |
718 | 718 | 'type' => 'give_title' |
719 | 719 | ), |
720 | 720 | array( |
721 | - 'name' => __( 'Disable <code>the_content</code> filter', 'give' ), |
|
722 | - 'desc' => sprintf( __( 'If you are seeing extra social buttons, related posts, or other unwanted elements appearing within your forms then you can disable WordPress\' content filter. <a href="%s" target="_blank">Learn more</a> about the_content filter.', 'give' ), esc_url( 'https://codex.wordpress.org/Plugin_API/Filter_Reference/the_content' ) ), |
|
721 | + 'name' => __('Disable <code>the_content</code> filter', 'give'), |
|
722 | + 'desc' => sprintf(__('If you are seeing extra social buttons, related posts, or other unwanted elements appearing within your forms then you can disable WordPress\' content filter. <a href="%s" target="_blank">Learn more</a> about the_content filter.', 'give'), esc_url('https://codex.wordpress.org/Plugin_API/Filter_Reference/the_content')), |
|
723 | 723 | 'id' => 'disable_the_content_filter', |
724 | 724 | 'type' => 'checkbox' |
725 | 725 | ), |
726 | 726 | array( |
727 | - 'name' => __( 'Script Loading', 'give' ), |
|
727 | + 'name' => __('Script Loading', 'give'), |
|
728 | 728 | 'desc' => '', |
729 | 729 | 'id' => 'give_title_script_control', |
730 | 730 | 'type' => 'give_title' |
731 | 731 | ), |
732 | 732 | array( |
733 | - 'name' => __( 'Load Scripts in Footer?', 'give' ), |
|
734 | - 'desc' => __( 'Check this box if you would like Give to load all frontend JavaScript files in the footer.', 'give' ), |
|
733 | + 'name' => __('Load Scripts in Footer?', 'give'), |
|
734 | + 'desc' => __('Check this box if you would like Give to load all frontend JavaScript files in the footer.', 'give'), |
|
735 | 735 | 'id' => 'scripts_footer', |
736 | 736 | 'type' => 'checkbox' |
737 | 737 | ) |
@@ -741,13 +741,13 @@ discard block |
||
741 | 741 | /** API Settings */ |
742 | 742 | 'api' => array( |
743 | 743 | 'id' => 'api', |
744 | - 'give_title' => __( 'API', 'give' ), |
|
745 | - 'show_on' => array( 'key' => 'options-page', 'value' => array( $this->key, ), ), |
|
744 | + 'give_title' => __('API', 'give'), |
|
745 | + 'show_on' => array('key' => 'options-page', 'value' => array($this->key,),), |
|
746 | 746 | 'show_names' => false, // Hide field names on the left |
747 | - 'fields' => apply_filters( 'give_settings_system', array( |
|
747 | + 'fields' => apply_filters('give_settings_system', array( |
|
748 | 748 | array( |
749 | 749 | 'id' => 'api', |
750 | - 'name' => __( 'API', 'give' ), |
|
750 | + 'name' => __('API', 'give'), |
|
751 | 751 | 'type' => 'api' |
752 | 752 | ) |
753 | 753 | ) |
@@ -756,13 +756,13 @@ discard block |
||
756 | 756 | /** Licenses Settings */ |
757 | 757 | 'system_info' => array( |
758 | 758 | 'id' => 'system_info', |
759 | - 'give_title' => __( 'System Info', 'give' ), |
|
760 | - 'show_on' => array( 'key' => 'options-page', 'value' => array( $this->key, ), ), |
|
761 | - 'fields' => apply_filters( 'give_settings_system', array( |
|
759 | + 'give_title' => __('System Info', 'give'), |
|
760 | + 'show_on' => array('key' => 'options-page', 'value' => array($this->key,),), |
|
761 | + 'fields' => apply_filters('give_settings_system', array( |
|
762 | 762 | array( |
763 | 763 | 'id' => 'system_info', |
764 | - 'name' => __( 'System Info', 'give' ), |
|
765 | - 'desc' => __( 'Please copy and paste this information in your ticket when contacting support.', 'give' ), |
|
764 | + 'name' => __('System Info', 'give'), |
|
765 | + 'desc' => __('Please copy and paste this information in your ticket when contacting support.', 'give'), |
|
766 | 766 | 'type' => 'system_info' |
767 | 767 | ) |
768 | 768 | ) |
@@ -771,15 +771,15 @@ discard block |
||
771 | 771 | ); |
772 | 772 | |
773 | 773 | //Return all settings array if no active tab |
774 | - if ( $active_tab === null || ! isset( $give_settings[ $active_tab ] ) ) { |
|
774 | + if ($active_tab === null || ! isset($give_settings[$active_tab])) { |
|
775 | 775 | |
776 | - return apply_filters( 'give_registered_settings', $give_settings ); |
|
776 | + return apply_filters('give_registered_settings', $give_settings); |
|
777 | 777 | |
778 | 778 | } |
779 | 779 | |
780 | 780 | |
781 | 781 | // Add other tabs and settings fields as needed |
782 | - return apply_filters( 'give_registered_settings', $give_settings[ $active_tab ] ); |
|
782 | + return apply_filters('give_registered_settings', $give_settings[$active_tab]); |
|
783 | 783 | |
784 | 784 | } |
785 | 785 | |
@@ -788,11 +788,11 @@ discard block |
||
788 | 788 | */ |
789 | 789 | public function settings_notices() { |
790 | 790 | |
791 | - if ( ! isset( $_POST['give_settings_saved'] ) ) { |
|
791 | + if ( ! isset($_POST['give_settings_saved'])) { |
|
792 | 792 | return; |
793 | 793 | } |
794 | 794 | |
795 | - add_settings_error( 'give-notices', 'global-settings-updated', __( 'Settings updated.', 'give' ), 'updated' ); |
|
795 | + add_settings_error('give-notices', 'global-settings-updated', __('Settings updated.', 'give'), 'updated'); |
|
796 | 796 | |
797 | 797 | } |
798 | 798 | |
@@ -806,17 +806,17 @@ discard block |
||
806 | 806 | * |
807 | 807 | * @return mixed Field value or exception is thrown |
808 | 808 | */ |
809 | - public function __get( $field ) { |
|
809 | + public function __get($field) { |
|
810 | 810 | |
811 | 811 | // Allowed fields to retrieve |
812 | - if ( in_array( $field, array( 'key', 'fields', 'give_title', 'options_page' ), true ) ) { |
|
812 | + if (in_array($field, array('key', 'fields', 'give_title', 'options_page'), true)) { |
|
813 | 813 | return $this->{$field}; |
814 | 814 | } |
815 | - if ( 'option_metabox' === $field ) { |
|
815 | + if ('option_metabox' === $field) { |
|
816 | 816 | return $this->option_metabox(); |
817 | 817 | } |
818 | 818 | |
819 | - throw new Exception( 'Invalid property: ' . $field ); |
|
819 | + throw new Exception('Invalid property: '.$field); |
|
820 | 820 | } |
821 | 821 | |
822 | 822 | |
@@ -833,12 +833,12 @@ discard block |
||
833 | 833 | * |
834 | 834 | * @return mixed Option value |
835 | 835 | */ |
836 | -function give_get_option( $key = '', $default = false ) { |
|
836 | +function give_get_option($key = '', $default = false) { |
|
837 | 837 | global $give_options; |
838 | - $value = ! empty( $give_options[ $key ] ) ? $give_options[ $key ] : $default; |
|
839 | - $value = apply_filters( 'give_get_option', $value, $key, $default ); |
|
838 | + $value = ! empty($give_options[$key]) ? $give_options[$key] : $default; |
|
839 | + $value = apply_filters('give_get_option', $value, $key, $default); |
|
840 | 840 | |
841 | - return apply_filters( 'give_get_option_' . $key, $value, $key, $default ); |
|
841 | + return apply_filters('give_get_option_'.$key, $value, $key, $default); |
|
842 | 842 | } |
843 | 843 | |
844 | 844 | |
@@ -856,33 +856,33 @@ discard block |
||
856 | 856 | * |
857 | 857 | * @return boolean True if updated, false if not. |
858 | 858 | */ |
859 | -function give_update_option( $key = '', $value = false ) { |
|
859 | +function give_update_option($key = '', $value = false) { |
|
860 | 860 | |
861 | 861 | // If no key, exit |
862 | - if ( empty( $key ) ) { |
|
862 | + if (empty($key)) { |
|
863 | 863 | return false; |
864 | 864 | } |
865 | 865 | |
866 | - if ( empty( $value ) ) { |
|
867 | - $remove_option = give_delete_option( $key ); |
|
866 | + if (empty($value)) { |
|
867 | + $remove_option = give_delete_option($key); |
|
868 | 868 | |
869 | 869 | return $remove_option; |
870 | 870 | } |
871 | 871 | |
872 | 872 | // First let's grab the current settings |
873 | - $options = get_option( 'give_settings' ); |
|
873 | + $options = get_option('give_settings'); |
|
874 | 874 | |
875 | 875 | // Let's let devs alter that value coming in |
876 | - $value = apply_filters( 'give_update_option', $value, $key ); |
|
876 | + $value = apply_filters('give_update_option', $value, $key); |
|
877 | 877 | |
878 | 878 | // Next let's try to update the value |
879 | - $options[ $key ] = $value; |
|
880 | - $did_update = update_option( 'give_settings', $options ); |
|
879 | + $options[$key] = $value; |
|
880 | + $did_update = update_option('give_settings', $options); |
|
881 | 881 | |
882 | 882 | // If it updated, let's update the global variable |
883 | - if ( $did_update ) { |
|
883 | + if ($did_update) { |
|
884 | 884 | global $give_options; |
885 | - $give_options[ $key ] = $value; |
|
885 | + $give_options[$key] = $value; |
|
886 | 886 | } |
887 | 887 | |
888 | 888 | return $did_update; |
@@ -899,27 +899,27 @@ discard block |
||
899 | 899 | * |
900 | 900 | * @return boolean True if updated, false if not. |
901 | 901 | */ |
902 | -function give_delete_option( $key = '' ) { |
|
902 | +function give_delete_option($key = '') { |
|
903 | 903 | |
904 | 904 | // If no key, exit |
905 | - if ( empty( $key ) ) { |
|
905 | + if (empty($key)) { |
|
906 | 906 | return false; |
907 | 907 | } |
908 | 908 | |
909 | 909 | // First let's grab the current settings |
910 | - $options = get_option( 'give_settings' ); |
|
910 | + $options = get_option('give_settings'); |
|
911 | 911 | |
912 | 912 | // Next let's try to update the value |
913 | - if ( isset( $options[ $key ] ) ) { |
|
913 | + if (isset($options[$key])) { |
|
914 | 914 | |
915 | - unset( $options[ $key ] ); |
|
915 | + unset($options[$key]); |
|
916 | 916 | |
917 | 917 | } |
918 | 918 | |
919 | - $did_update = update_option( 'give_settings', $options ); |
|
919 | + $did_update = update_option('give_settings', $options); |
|
920 | 920 | |
921 | 921 | // If it updated, let's update the global variable |
922 | - if ( $did_update ) { |
|
922 | + if ($did_update) { |
|
923 | 923 | global $give_options; |
924 | 924 | $give_options = $options; |
925 | 925 | } |
@@ -938,9 +938,9 @@ discard block |
||
938 | 938 | */ |
939 | 939 | function give_get_settings() { |
940 | 940 | |
941 | - $settings = get_option( 'give_settings' ); |
|
941 | + $settings = get_option('give_settings'); |
|
942 | 942 | |
943 | - return (array) apply_filters( 'give_get_settings', $settings ); |
|
943 | + return (array) apply_filters('give_get_settings', $settings); |
|
944 | 944 | |
945 | 945 | } |
946 | 946 | |
@@ -958,25 +958,25 @@ discard block |
||
958 | 958 | * |
959 | 959 | * @return array |
960 | 960 | */ |
961 | -function give_settings_array_insert( $array, $position, $insert ) { |
|
962 | - if ( is_int( $position ) ) { |
|
963 | - array_splice( $array, $position, 0, $insert ); |
|
961 | +function give_settings_array_insert($array, $position, $insert) { |
|
962 | + if (is_int($position)) { |
|
963 | + array_splice($array, $position, 0, $insert); |
|
964 | 964 | } else { |
965 | 965 | |
966 | - foreach ( $array as $index => $subarray ) { |
|
967 | - if ( isset( $subarray['id'] ) && $subarray['id'] == $position ) { |
|
966 | + foreach ($array as $index => $subarray) { |
|
967 | + if (isset($subarray['id']) && $subarray['id'] == $position) { |
|
968 | 968 | $pos = $index; |
969 | 969 | } |
970 | 970 | } |
971 | 971 | |
972 | - if ( ! isset( $pos ) ) { |
|
972 | + if ( ! isset($pos)) { |
|
973 | 973 | return $array; |
974 | 974 | } |
975 | 975 | |
976 | 976 | $array = array_merge( |
977 | - array_slice( $array, 0, $pos ), |
|
977 | + array_slice($array, 0, $pos), |
|
978 | 978 | $insert, |
979 | - array_slice( $array, $pos ) |
|
979 | + array_slice($array, $pos) |
|
980 | 980 | ); |
981 | 981 | } |
982 | 982 | |
@@ -999,7 +999,7 @@ discard block |
||
999 | 999 | * |
1000 | 1000 | * @return void |
1001 | 1001 | */ |
1002 | -function give_enabled_gateways_callback( $field_object, $escaped_value, $object_id, $object_type, $field_type_object ) { |
|
1002 | +function give_enabled_gateways_callback($field_object, $escaped_value, $object_id, $object_type, $field_type_object) { |
|
1003 | 1003 | |
1004 | 1004 | $id = $field_type_object->field->args['id']; |
1005 | 1005 | $field_description = $field_type_object->field->args['desc']; |
@@ -1007,21 +1007,21 @@ discard block |
||
1007 | 1007 | |
1008 | 1008 | echo '<ul class="cmb2-checkbox-list cmb2-list">'; |
1009 | 1009 | |
1010 | - foreach ( $gateways as $key => $option ) : |
|
1010 | + foreach ($gateways as $key => $option) : |
|
1011 | 1011 | |
1012 | - if ( is_array( $escaped_value ) && array_key_exists( $key, $escaped_value ) ) { |
|
1012 | + if (is_array($escaped_value) && array_key_exists($key, $escaped_value)) { |
|
1013 | 1013 | $enabled = '1'; |
1014 | 1014 | } else { |
1015 | 1015 | $enabled = null; |
1016 | 1016 | } |
1017 | 1017 | |
1018 | - echo '<li><input name="' . $id . '[' . $key . ']" id="' . $id . '[' . $key . ']" type="checkbox" value="1" ' . checked( '1', $enabled, false ) . '/> '; |
|
1019 | - echo '<label for="' . $id . '[' . $key . ']">' . $option['admin_label'] . '</label></li>'; |
|
1018 | + echo '<li><input name="'.$id.'['.$key.']" id="'.$id.'['.$key.']" type="checkbox" value="1" '.checked('1', $enabled, false).'/> '; |
|
1019 | + echo '<label for="'.$id.'['.$key.']">'.$option['admin_label'].'</label></li>'; |
|
1020 | 1020 | |
1021 | 1021 | endforeach; |
1022 | 1022 | |
1023 | - if ( $field_description ) { |
|
1024 | - echo '<p class="cmb2-metabox-description">' . $field_description . '</p>'; |
|
1023 | + if ($field_description) { |
|
1024 | + echo '<p class="cmb2-metabox-description">'.$field_description.'</p>'; |
|
1025 | 1025 | } |
1026 | 1026 | |
1027 | 1027 | echo '</ul>'; |
@@ -1040,31 +1040,31 @@ discard block |
||
1040 | 1040 | * |
1041 | 1041 | * @return void |
1042 | 1042 | */ |
1043 | -function give_default_gateway_callback( $field_object, $escaped_value, $object_id, $object_type, $field_type_object ) { |
|
1043 | +function give_default_gateway_callback($field_object, $escaped_value, $object_id, $object_type, $field_type_object) { |
|
1044 | 1044 | |
1045 | 1045 | $id = $field_type_object->field->args['id']; |
1046 | 1046 | $field_description = $field_type_object->field->args['desc']; |
1047 | 1047 | $gateways = give_get_enabled_payment_gateways(); |
1048 | 1048 | |
1049 | - echo '<select class="cmb2_select" name="' . $id . '" id="' . $id . '">'; |
|
1049 | + echo '<select class="cmb2_select" name="'.$id.'" id="'.$id.'">'; |
|
1050 | 1050 | |
1051 | 1051 | //Add a field to the Give Form admin single post view of this field |
1052 | - if ( $field_type_object->field->object_type === 'post' ) { |
|
1053 | - echo '<option value="global">' . __( 'Global Default', 'give' ) . '</option>'; |
|
1052 | + if ($field_type_object->field->object_type === 'post') { |
|
1053 | + echo '<option value="global">'.__('Global Default', 'give').'</option>'; |
|
1054 | 1054 | } |
1055 | 1055 | |
1056 | - foreach ( $gateways as $key => $option ) : |
|
1056 | + foreach ($gateways as $key => $option) : |
|
1057 | 1057 | |
1058 | - $selected = isset( $escaped_value ) ? selected( $key, $escaped_value, false ) : ''; |
|
1058 | + $selected = isset($escaped_value) ? selected($key, $escaped_value, false) : ''; |
|
1059 | 1059 | |
1060 | 1060 | |
1061 | - echo '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
1061 | + echo '<option value="'.esc_attr($key).'"'.$selected.'>'.esc_html($option['admin_label']).'</option>'; |
|
1062 | 1062 | |
1063 | 1063 | endforeach; |
1064 | 1064 | |
1065 | 1065 | echo '</select>'; |
1066 | 1066 | |
1067 | - echo '<p class="cmb2-metabox-description">' . $field_description . '</p>'; |
|
1067 | + echo '<p class="cmb2-metabox-description">'.$field_description.'</p>'; |
|
1068 | 1068 | |
1069 | 1069 | } |
1070 | 1070 | |
@@ -1079,13 +1079,13 @@ discard block |
||
1079 | 1079 | * |
1080 | 1080 | * @return void |
1081 | 1081 | */ |
1082 | -function give_title_callback( $field_object, $escaped_value, $object_id, $object_type, $field_type_object ) { |
|
1082 | +function give_title_callback($field_object, $escaped_value, $object_id, $object_type, $field_type_object) { |
|
1083 | 1083 | |
1084 | 1084 | $id = $field_type_object->field->args['id']; |
1085 | 1085 | $title = $field_type_object->field->args['name']; |
1086 | 1086 | $field_description = $field_type_object->field->args['desc']; |
1087 | 1087 | |
1088 | - echo '<hr>' . $field_description; |
|
1088 | + echo '<hr>'.$field_description; |
|
1089 | 1089 | |
1090 | 1090 | } |
1091 | 1091 | |
@@ -1100,7 +1100,7 @@ discard block |
||
1100 | 1100 | * |
1101 | 1101 | * @return void |
1102 | 1102 | */ |
1103 | -function give_description_callback( $field_object, $escaped_value, $object_id, $object_type, $field_type_object ) { |
|
1103 | +function give_description_callback($field_object, $escaped_value, $object_id, $object_type, $field_type_object) { |
|
1104 | 1104 | |
1105 | 1105 | $id = $field_type_object->field->args['id']; |
1106 | 1106 | $title = $field_type_object->field->args['name']; |
@@ -1120,25 +1120,25 @@ discard block |
||
1120 | 1120 | * @see: https://github.com/WebDevStudios/CMB2/wiki/Adding-your-own-field-types |
1121 | 1121 | * @return array An array of options that matches the CMB2 options array |
1122 | 1122 | */ |
1123 | -function give_cmb2_get_post_options( $query_args, $force = false ) { |
|
1123 | +function give_cmb2_get_post_options($query_args, $force = false) { |
|
1124 | 1124 | |
1125 | - $post_options = array( '' => '' ); // Blank option |
|
1125 | + $post_options = array('' => ''); // Blank option |
|
1126 | 1126 | |
1127 | - if ( ( ! isset( $_GET['page'] ) || 'give-settings' != $_GET['page'] ) && ! $force ) { |
|
1127 | + if (( ! isset($_GET['page']) || 'give-settings' != $_GET['page']) && ! $force) { |
|
1128 | 1128 | return $post_options; |
1129 | 1129 | } |
1130 | 1130 | |
1131 | - $args = wp_parse_args( $query_args, array( |
|
1131 | + $args = wp_parse_args($query_args, array( |
|
1132 | 1132 | 'post_type' => 'page', |
1133 | 1133 | 'numberposts' => 10, |
1134 | - ) ); |
|
1134 | + )); |
|
1135 | 1135 | |
1136 | - $posts = get_posts( $args ); |
|
1136 | + $posts = get_posts($args); |
|
1137 | 1137 | |
1138 | - if ( $posts ) { |
|
1139 | - foreach ( $posts as $post ) { |
|
1138 | + if ($posts) { |
|
1139 | + foreach ($posts as $post) { |
|
1140 | 1140 | |
1141 | - $post_options[ $post->ID ] = $post->post_title; |
|
1141 | + $post_options[$post->ID] = $post->post_title; |
|
1142 | 1142 | |
1143 | 1143 | } |
1144 | 1144 | } |
@@ -1158,17 +1158,17 @@ discard block |
||
1158 | 1158 | global $_wp_additional_image_sizes; |
1159 | 1159 | $sizes = array(); |
1160 | 1160 | |
1161 | - foreach ( get_intermediate_image_sizes() as $_size ) { |
|
1161 | + foreach (get_intermediate_image_sizes() as $_size) { |
|
1162 | 1162 | |
1163 | - if ( in_array( $_size, array( 'thumbnail', 'medium', 'medium_large', 'large' ) ) ) { |
|
1164 | - $sizes[ $_size ] = $_size . ' - ' . get_option( "{$_size}_size_w" ) . 'x' . get_option( "{$_size}_size_h" ); |
|
1165 | - } elseif ( isset( $_wp_additional_image_sizes[ $_size ] ) ) { |
|
1166 | - $sizes[ $_size ] = $_size . ' - ' . $_wp_additional_image_sizes[ $_size ]['width'] . 'x' . $_wp_additional_image_sizes[ $_size ]['height']; |
|
1163 | + if (in_array($_size, array('thumbnail', 'medium', 'medium_large', 'large'))) { |
|
1164 | + $sizes[$_size] = $_size.' - '.get_option("{$_size}_size_w").'x'.get_option("{$_size}_size_h"); |
|
1165 | + } elseif (isset($_wp_additional_image_sizes[$_size])) { |
|
1166 | + $sizes[$_size] = $_size.' - '.$_wp_additional_image_sizes[$_size]['width'].'x'.$_wp_additional_image_sizes[$_size]['height']; |
|
1167 | 1167 | } |
1168 | 1168 | |
1169 | 1169 | } |
1170 | 1170 | |
1171 | - return apply_filters( 'give_get_featured_image_sizes', $sizes ); |
|
1171 | + return apply_filters('give_get_featured_image_sizes', $sizes); |
|
1172 | 1172 | } |
1173 | 1173 | |
1174 | 1174 | |
@@ -1182,34 +1182,34 @@ discard block |
||
1182 | 1182 | * |
1183 | 1183 | * @return void |
1184 | 1184 | */ |
1185 | -function give_license_key_callback( $field_object, $escaped_value, $object_id, $object_type, $field_type_object ) { |
|
1185 | +function give_license_key_callback($field_object, $escaped_value, $object_id, $object_type, $field_type_object) { |
|
1186 | 1186 | |
1187 | 1187 | $id = $field_type_object->field->args['id']; |
1188 | 1188 | $field_description = $field_type_object->field->args['desc']; |
1189 | - $license_status = get_option( $field_type_object->field->args['options']['is_valid_license_option'] ); |
|
1189 | + $license_status = get_option($field_type_object->field->args['options']['is_valid_license_option']); |
|
1190 | 1190 | $field_classes = 'regular-text give-license-field'; |
1191 | - $type = empty( $escaped_value ) ? 'text' : 'password'; |
|
1191 | + $type = empty($escaped_value) ? 'text' : 'password'; |
|
1192 | 1192 | |
1193 | - if ( $license_status === 'valid' ) { |
|
1193 | + if ($license_status === 'valid') { |
|
1194 | 1194 | $field_classes .= ' give-license-active'; |
1195 | 1195 | } |
1196 | 1196 | |
1197 | - $html = $field_type_object->input( array( |
|
1197 | + $html = $field_type_object->input(array( |
|
1198 | 1198 | 'class' => $field_classes, |
1199 | 1199 | 'type' => $type |
1200 | - ) ); |
|
1200 | + )); |
|
1201 | 1201 | |
1202 | 1202 | //License is active so show deactivate button |
1203 | - if ( $license_status === 'valid' ) { |
|
1204 | - $html .= '<input type="submit" class="button-secondary give-license-deactivate" name="' . $id . '_deactivate" value="' . __( 'Deactivate License', 'give' ) . '"/>'; |
|
1203 | + if ($license_status === 'valid') { |
|
1204 | + $html .= '<input type="submit" class="button-secondary give-license-deactivate" name="'.$id.'_deactivate" value="'.__('Deactivate License', 'give').'"/>'; |
|
1205 | 1205 | } else { |
1206 | 1206 | //This license is not valid so delete it |
1207 | - give_delete_option( $id ); |
|
1207 | + give_delete_option($id); |
|
1208 | 1208 | } |
1209 | 1209 | |
1210 | - $html .= '<label for="give_settings[' . $id . ']"> ' . $field_description . '</label>'; |
|
1210 | + $html .= '<label for="give_settings['.$id.']"> '.$field_description.'</label>'; |
|
1211 | 1211 | |
1212 | - wp_nonce_field( $id . '-nonce', $id . '-nonce' ); |
|
1212 | + wp_nonce_field($id.'-nonce', $id.'-nonce'); |
|
1213 | 1213 | |
1214 | 1214 | echo $html; |
1215 | 1215 | } |
@@ -1223,13 +1223,13 @@ discard block |
||
1223 | 1223 | */ |
1224 | 1224 | function give_api_callback() { |
1225 | 1225 | |
1226 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
1226 | + if ( ! current_user_can('manage_give_settings')) { |
|
1227 | 1227 | return; |
1228 | 1228 | } |
1229 | 1229 | |
1230 | - do_action( 'give_tools_api_keys_before' ); |
|
1230 | + do_action('give_tools_api_keys_before'); |
|
1231 | 1231 | |
1232 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-api-keys-table.php'; |
|
1232 | + require_once GIVE_PLUGIN_DIR.'includes/admin/class-api-keys-table.php'; |
|
1233 | 1233 | |
1234 | 1234 | $api_keys_table = new Give_API_Keys_Table(); |
1235 | 1235 | $api_keys_table->prepare_items(); |
@@ -1237,7 +1237,7 @@ discard block |
||
1237 | 1237 | ?> |
1238 | 1238 | <p> |
1239 | 1239 | <?php printf( |
1240 | - __( 'API keys allow users to use the <a href="%s">Give REST API</a> to retrieve donation data in JSON or XML for external applications or devices, such as <a href="%s">Zapier</a>.', 'give' ), |
|
1240 | + __('API keys allow users to use the <a href="%s">Give REST API</a> to retrieve donation data in JSON or XML for external applications or devices, such as <a href="%s">Zapier</a>.', 'give'), |
|
1241 | 1241 | 'https://givewp.com/documentation/give-api-reference/', |
1242 | 1242 | 'https://givewp.com/addons/zapier/' |
1243 | 1243 | ); ?> |
@@ -1245,10 +1245,10 @@ discard block |
||
1245 | 1245 | |
1246 | 1246 | <?php |
1247 | 1247 | |
1248 | - do_action( 'give_tools_api_keys_after' ); |
|
1248 | + do_action('give_tools_api_keys_after'); |
|
1249 | 1249 | } |
1250 | 1250 | |
1251 | -add_action( 'give_settings_tab_api_keys', 'give_api_callback' ); |
|
1251 | +add_action('give_settings_tab_api_keys', 'give_api_callback'); |
|
1252 | 1252 | |
1253 | 1253 | /** |
1254 | 1254 | * Hook Callback |
@@ -1261,8 +1261,8 @@ discard block |
||
1261 | 1261 | * |
1262 | 1262 | * @return void |
1263 | 1263 | */ |
1264 | -function give_hook_callback( $args ) { |
|
1265 | - do_action( 'give_' . $args['id'] ); |
|
1264 | +function give_hook_callback($args) { |
|
1265 | + do_action('give_'.$args['id']); |
|
1266 | 1266 | } |
1267 | 1267 | |
1268 | 1268 | /** |
@@ -1272,10 +1272,10 @@ discard block |
||
1272 | 1272 | * |
1273 | 1273 | */ |
1274 | 1274 | |
1275 | -if ( file_exists( WP_PLUGIN_DIR . '/cmb2/init.php' ) && ! defined( 'CMB2_LOADED' ) ) { |
|
1276 | - require_once WP_PLUGIN_DIR . '/cmb2/init.php'; |
|
1277 | -} elseif ( file_exists( GIVE_PLUGIN_DIR . '/includes/libraries/cmb2/init.php' ) && ! defined( 'CMB2_LOADED' ) ) { |
|
1278 | - require_once GIVE_PLUGIN_DIR . '/includes/libraries/cmb2/init.php'; |
|
1279 | -} elseif ( file_exists( GIVE_PLUGIN_DIR . '/includes/libraries/CMB2/init.php' ) && ! defined( 'CMB2_LOADED' ) ) { |
|
1280 | - require_once GIVE_PLUGIN_DIR . '/includes/libraries/CMB2/init.php'; |
|
1275 | +if (file_exists(WP_PLUGIN_DIR.'/cmb2/init.php') && ! defined('CMB2_LOADED')) { |
|
1276 | + require_once WP_PLUGIN_DIR.'/cmb2/init.php'; |
|
1277 | +} elseif (file_exists(GIVE_PLUGIN_DIR.'/includes/libraries/cmb2/init.php') && ! defined('CMB2_LOADED')) { |
|
1278 | + require_once GIVE_PLUGIN_DIR.'/includes/libraries/cmb2/init.php'; |
|
1279 | +} elseif (file_exists(GIVE_PLUGIN_DIR.'/includes/libraries/CMB2/init.php') && ! defined('CMB2_LOADED')) { |
|
1280 | + require_once GIVE_PLUGIN_DIR.'/includes/libraries/CMB2/init.php'; |
|
1281 | 1281 | } |
1282 | 1282 | \ No newline at end of file |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -25,27 +25,27 @@ discard block |
||
25 | 25 | */ |
26 | 26 | function give_process_purchase_form() { |
27 | 27 | |
28 | - do_action( 'give_pre_process_purchase' ); |
|
28 | + do_action('give_pre_process_purchase'); |
|
29 | 29 | |
30 | 30 | // Validate the form $_POST data |
31 | 31 | $valid_data = give_purchase_form_validate_fields(); |
32 | 32 | |
33 | 33 | // Allow themes and plugins to hook to errors |
34 | - do_action( 'give_checkout_error_checks', $valid_data, $_POST ); |
|
34 | + do_action('give_checkout_error_checks', $valid_data, $_POST); |
|
35 | 35 | |
36 | - $is_ajax = isset( $_POST['give_ajax'] ); |
|
36 | + $is_ajax = isset($_POST['give_ajax']); |
|
37 | 37 | |
38 | 38 | // Process the login form |
39 | - if ( isset( $_POST['give_login_submit'] ) ) { |
|
39 | + if (isset($_POST['give_login_submit'])) { |
|
40 | 40 | give_process_form_login(); |
41 | 41 | } |
42 | 42 | |
43 | 43 | // Validate the user |
44 | - $user = give_get_purchase_form_user( $valid_data ); |
|
44 | + $user = give_get_purchase_form_user($valid_data); |
|
45 | 45 | |
46 | - if ( false === $valid_data || give_get_errors() || ! $user ) { |
|
47 | - if ( $is_ajax ) { |
|
48 | - do_action( 'give_ajax_checkout_errors' ); |
|
46 | + if (false === $valid_data || give_get_errors() || ! $user) { |
|
47 | + if ($is_ajax) { |
|
48 | + do_action('give_ajax_checkout_errors'); |
|
49 | 49 | give_die(); |
50 | 50 | } else { |
51 | 51 | return false; |
@@ -53,17 +53,17 @@ discard block |
||
53 | 53 | } |
54 | 54 | |
55 | 55 | //If AJAX send back success to proceed with form submission |
56 | - if ( $is_ajax ) { |
|
56 | + if ($is_ajax) { |
|
57 | 57 | echo 'success'; |
58 | 58 | give_die(); |
59 | 59 | } |
60 | 60 | |
61 | 61 | //After AJAX: Setup session if not using php_sessions |
62 | - if ( ! Give()->session->use_php_sessions() ) { |
|
62 | + if ( ! Give()->session->use_php_sessions()) { |
|
63 | 63 | //Double-check that set_cookie is publicly accessible; |
64 | 64 | // we're using a slightly modified class-wp-sessions.php |
65 | - $session_reflection = new ReflectionMethod( 'WP_Session', 'set_cookie' ); |
|
66 | - if ( $session_reflection->isPublic() ) { |
|
65 | + $session_reflection = new ReflectionMethod('WP_Session', 'set_cookie'); |
|
66 | + if ($session_reflection->isPublic()) { |
|
67 | 67 | // Manually set the cookie. |
68 | 68 | Give()->session->init()->set_cookie(); |
69 | 69 | } |
@@ -78,18 +78,18 @@ discard block |
||
78 | 78 | 'address' => $user['address'] |
79 | 79 | ); |
80 | 80 | |
81 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
81 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
82 | 82 | |
83 | - $price = isset( $_POST['give-amount'] ) ? (float) apply_filters( 'give_donation_total', give_sanitize_amount( give_format_amount( $_POST['give-amount'] ) ) ) : '0.00'; |
|
84 | - $purchase_key = strtolower( md5( $user['user_email'] . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'give', true ) ) ); |
|
83 | + $price = isset($_POST['give-amount']) ? (float) apply_filters('give_donation_total', give_sanitize_amount(give_format_amount($_POST['give-amount']))) : '0.00'; |
|
84 | + $purchase_key = strtolower(md5($user['user_email'].date('Y-m-d H:i:s').$auth_key.uniqid('give', true))); |
|
85 | 85 | |
86 | 86 | // Setup purchase information |
87 | 87 | $purchase_data = array( |
88 | 88 | 'price' => $price, |
89 | 89 | 'purchase_key' => $purchase_key, |
90 | 90 | 'user_email' => $user['user_email'], |
91 | - 'date' => date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ), |
|
92 | - 'user_info' => stripslashes_deep( $user_info ), |
|
91 | + 'date' => date('Y-m-d H:i:s', current_time('timestamp')), |
|
92 | + 'user_info' => stripslashes_deep($user_info), |
|
93 | 93 | 'post_data' => $_POST, |
94 | 94 | 'gateway' => $valid_data['gateway'], |
95 | 95 | 'card_info' => $valid_data['cc_info'] |
@@ -99,37 +99,37 @@ discard block |
||
99 | 99 | $valid_data['user'] = $user; |
100 | 100 | |
101 | 101 | // Allow themes and plugins to hook before the gateway |
102 | - do_action( 'give_checkout_before_gateway', $_POST, $user_info, $valid_data ); |
|
102 | + do_action('give_checkout_before_gateway', $_POST, $user_info, $valid_data); |
|
103 | 103 | |
104 | 104 | //Sanity check for price |
105 | - if ( ! $purchase_data['price'] ) { |
|
105 | + if ( ! $purchase_data['price']) { |
|
106 | 106 | // Revert to manual |
107 | 107 | $purchase_data['gateway'] = 'manual'; |
108 | 108 | $_POST['give-gateway'] = 'manual'; |
109 | 109 | } |
110 | 110 | |
111 | 111 | // Allow the purchase data to be modified before it is sent to the gateway |
112 | - $purchase_data = apply_filters( 'give_purchase_data_before_gateway', $purchase_data, $valid_data ); |
|
112 | + $purchase_data = apply_filters('give_purchase_data_before_gateway', $purchase_data, $valid_data); |
|
113 | 113 | |
114 | 114 | // Setup the data we're storing in the purchase session |
115 | 115 | $session_data = $purchase_data; |
116 | 116 | |
117 | 117 | // Make sure credit card numbers are never stored in sessions |
118 | - unset( $session_data['card_info']['card_number'] ); |
|
119 | - unset( $session_data['post_data']['card_number'] ); |
|
118 | + unset($session_data['card_info']['card_number']); |
|
119 | + unset($session_data['post_data']['card_number']); |
|
120 | 120 | |
121 | 121 | // Used for showing data to non logged-in users after purchase, and for other plugins needing purchase data. |
122 | - give_set_purchase_session( $session_data ); |
|
122 | + give_set_purchase_session($session_data); |
|
123 | 123 | |
124 | 124 | // Send info to the gateway for payment processing |
125 | - give_send_to_gateway( $purchase_data['gateway'], $purchase_data ); |
|
125 | + give_send_to_gateway($purchase_data['gateway'], $purchase_data); |
|
126 | 126 | give_die(); |
127 | 127 | |
128 | 128 | } |
129 | 129 | |
130 | -add_action( 'give_purchase', 'give_process_purchase_form' ); |
|
131 | -add_action( 'wp_ajax_give_process_checkout', 'give_process_purchase_form' ); |
|
132 | -add_action( 'wp_ajax_nopriv_give_process_checkout', 'give_process_purchase_form' ); |
|
130 | +add_action('give_purchase', 'give_process_purchase_form'); |
|
131 | +add_action('wp_ajax_give_process_checkout', 'give_process_purchase_form'); |
|
132 | +add_action('wp_ajax_nopriv_give_process_checkout', 'give_process_purchase_form'); |
|
133 | 133 | |
134 | 134 | /** |
135 | 135 | * Process the checkout login form |
@@ -140,32 +140,32 @@ discard block |
||
140 | 140 | */ |
141 | 141 | function give_process_form_login() { |
142 | 142 | |
143 | - $is_ajax = isset( $_POST['give_ajax'] ); |
|
143 | + $is_ajax = isset($_POST['give_ajax']); |
|
144 | 144 | |
145 | 145 | $user_data = give_purchase_form_validate_user_login(); |
146 | 146 | |
147 | - if ( give_get_errors() || $user_data['user_id'] < 1 ) { |
|
148 | - if ( $is_ajax ) { |
|
149 | - do_action( 'give_ajax_checkout_errors' ); |
|
147 | + if (give_get_errors() || $user_data['user_id'] < 1) { |
|
148 | + if ($is_ajax) { |
|
149 | + do_action('give_ajax_checkout_errors'); |
|
150 | 150 | give_die(); |
151 | 151 | } else { |
152 | - wp_redirect( $_SERVER['HTTP_REFERER'] ); |
|
152 | + wp_redirect($_SERVER['HTTP_REFERER']); |
|
153 | 153 | exit; |
154 | 154 | } |
155 | 155 | } |
156 | 156 | |
157 | - give_log_user_in( $user_data['user_id'], $user_data['user_login'], $user_data['user_pass'] ); |
|
157 | + give_log_user_in($user_data['user_id'], $user_data['user_login'], $user_data['user_pass']); |
|
158 | 158 | |
159 | - if ( $is_ajax ) { |
|
159 | + if ($is_ajax) { |
|
160 | 160 | echo 'success'; |
161 | 161 | give_die(); |
162 | 162 | } else { |
163 | - wp_redirect( $_SERVER['HTTP_REFERER'] ); |
|
163 | + wp_redirect($_SERVER['HTTP_REFERER']); |
|
164 | 164 | } |
165 | 165 | } |
166 | 166 | |
167 | -add_action( 'wp_ajax_give_process_checkout_login', 'give_process_form_login' ); |
|
168 | -add_action( 'wp_ajax_nopriv_give_process_checkout_login', 'give_process_form_login' ); |
|
167 | +add_action('wp_ajax_give_process_checkout_login', 'give_process_form_login'); |
|
168 | +add_action('wp_ajax_nopriv_give_process_checkout_login', 'give_process_form_login'); |
|
169 | 169 | |
170 | 170 | /** |
171 | 171 | * Purchase Form Validate Fields |
@@ -177,40 +177,40 @@ discard block |
||
177 | 177 | function give_purchase_form_validate_fields() { |
178 | 178 | |
179 | 179 | // Check if there is $_POST |
180 | - if ( empty( $_POST ) ) { |
|
180 | + if (empty($_POST)) { |
|
181 | 181 | return false; |
182 | 182 | } |
183 | 183 | |
184 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
184 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
185 | 185 | |
186 | 186 | // Start an array to collect valid data |
187 | 187 | $valid_data = array( |
188 | 188 | 'gateway' => give_purchase_form_validate_gateway(), // Gateway fallback (amount is validated here) |
189 | - 'need_new_user' => false, // New user flag |
|
190 | - 'need_user_login' => false, // Login user flag |
|
191 | - 'logged_user_data' => array(), // Logged user collected data |
|
192 | - 'new_user_data' => array(), // New user collected data |
|
193 | - 'login_user_data' => array(), // Login user collected data |
|
194 | - 'guest_user_data' => array(), // Guest user collected data |
|
189 | + 'need_new_user' => false, // New user flag |
|
190 | + 'need_user_login' => false, // Login user flag |
|
191 | + 'logged_user_data' => array(), // Logged user collected data |
|
192 | + 'new_user_data' => array(), // New user collected data |
|
193 | + 'login_user_data' => array(), // Login user collected data |
|
194 | + 'guest_user_data' => array(), // Guest user collected data |
|
195 | 195 | 'cc_info' => give_purchase_form_validate_cc() // Credit card info |
196 | 196 | ); |
197 | 197 | |
198 | 198 | // Validate agree to terms |
199 | - $terms_option = get_post_meta( $form_id, '_give_terms_option', true ); |
|
200 | - if ( isset( $terms_option ) && $terms_option === 'yes' ) { |
|
199 | + $terms_option = get_post_meta($form_id, '_give_terms_option', true); |
|
200 | + if (isset($terms_option) && $terms_option === 'yes') { |
|
201 | 201 | give_purchase_form_validate_agree_to_terms(); |
202 | 202 | } |
203 | 203 | |
204 | - if ( is_user_logged_in() ) { |
|
204 | + if (is_user_logged_in()) { |
|
205 | 205 | // Collect logged in user data |
206 | 206 | $valid_data['logged_in_user'] = give_purchase_form_validate_logged_in_user(); |
207 | - } else if ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-register' ) { |
|
207 | + } else if (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-register') { |
|
208 | 208 | // Set new user registration as required |
209 | 209 | $valid_data['need_new_user'] = true; |
210 | 210 | // Validate new user data |
211 | 211 | $valid_data['new_user_data'] = give_purchase_form_validate_new_user(); |
212 | 212 | // Check if login validation is needed |
213 | - } else if ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-login' ) { |
|
213 | + } else if (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-login') { |
|
214 | 214 | // Set user login as required |
215 | 215 | $valid_data['need_user_login'] = true; |
216 | 216 | // Validate users login info |
@@ -235,37 +235,37 @@ discard block |
||
235 | 235 | */ |
236 | 236 | function give_purchase_form_validate_gateway() { |
237 | 237 | |
238 | - $form_id = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0; |
|
239 | - $amount = isset( $_REQUEST['give-amount'] ) ? give_sanitize_amount( $_REQUEST['give-amount'] ) : 0; |
|
240 | - $gateway = give_get_default_gateway( $form_id ); |
|
238 | + $form_id = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0; |
|
239 | + $amount = isset($_REQUEST['give-amount']) ? give_sanitize_amount($_REQUEST['give-amount']) : 0; |
|
240 | + $gateway = give_get_default_gateway($form_id); |
|
241 | 241 | |
242 | 242 | // Check if a gateway value is present |
243 | - if ( ! empty( $_REQUEST['give-gateway'] ) ) { |
|
243 | + if ( ! empty($_REQUEST['give-gateway'])) { |
|
244 | 244 | |
245 | - $gateway = sanitize_text_field( $_REQUEST['give-gateway'] ); |
|
245 | + $gateway = sanitize_text_field($_REQUEST['give-gateway']); |
|
246 | 246 | |
247 | 247 | //Is amount being donated in LIVE mode 0.00? If so, error: |
248 | - if ( $amount == 0 && ! give_is_test_mode() ) { |
|
248 | + if ($amount == 0 && ! give_is_test_mode()) { |
|
249 | 249 | |
250 | - give_set_error( 'invalid_donation_amount', __( 'Please insert a valid donation amount.', 'give' ) ); |
|
250 | + give_set_error('invalid_donation_amount', __('Please insert a valid donation amount.', 'give')); |
|
251 | 251 | |
252 | 252 | } //Check for a minimum custom amount |
253 | - elseif ( ! give_verify_minimum_price() ) { |
|
253 | + elseif ( ! give_verify_minimum_price()) { |
|
254 | 254 | |
255 | - $minimum = give_currency_filter( give_format_amount( give_get_form_minimum_price( $form_id ) ) ); |
|
256 | - $error_message = __( 'This form has a minimum donation amount of %s', 'give' ); |
|
255 | + $minimum = give_currency_filter(give_format_amount(give_get_form_minimum_price($form_id))); |
|
256 | + $error_message = __('This form has a minimum donation amount of %s', 'give'); |
|
257 | 257 | |
258 | - give_set_error( 'invalid_donation_minimum', sprintf( $error_message, $minimum ) ); |
|
258 | + give_set_error('invalid_donation_minimum', sprintf($error_message, $minimum)); |
|
259 | 259 | |
260 | 260 | } //Is this test mode zero donation? Let it through but set to manual gateway |
261 | - elseif ( $amount == 0 && give_is_test_mode() ) { |
|
261 | + elseif ($amount == 0 && give_is_test_mode()) { |
|
262 | 262 | |
263 | 263 | $gateway = 'manual'; |
264 | 264 | |
265 | 265 | } //Check if this gateway is active |
266 | - elseif ( ! give_is_gateway_active( $gateway ) ) { |
|
266 | + elseif ( ! give_is_gateway_active($gateway)) { |
|
267 | 267 | |
268 | - give_set_error( 'invalid_gateway', __( 'The selected payment gateway is not enabled', 'give' ) ); |
|
268 | + give_set_error('invalid_gateway', __('The selected payment gateway is not enabled', 'give')); |
|
269 | 269 | |
270 | 270 | } |
271 | 271 | |
@@ -284,23 +284,23 @@ discard block |
||
284 | 284 | */ |
285 | 285 | function give_verify_minimum_price() { |
286 | 286 | |
287 | - $amount = give_sanitize_amount( $_REQUEST['give-amount'] ); |
|
288 | - $form_id = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0; |
|
289 | - $price_id = isset( $_REQUEST['give-price-id'] ) ? $_REQUEST['give-price-id'] : 0; |
|
290 | - $variable_prices = give_has_variable_prices( $form_id ); |
|
287 | + $amount = give_sanitize_amount($_REQUEST['give-amount']); |
|
288 | + $form_id = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0; |
|
289 | + $price_id = isset($_REQUEST['give-price-id']) ? $_REQUEST['give-price-id'] : 0; |
|
290 | + $variable_prices = give_has_variable_prices($form_id); |
|
291 | 291 | |
292 | - if ( $variable_prices && ! empty( $price_id ) ) { |
|
292 | + if ($variable_prices && ! empty($price_id)) { |
|
293 | 293 | |
294 | - $price_level_amount = give_get_price_option_amount( $form_id, $price_id ); |
|
294 | + $price_level_amount = give_get_price_option_amount($form_id, $price_id); |
|
295 | 295 | |
296 | - if ( $price_level_amount == $amount ) { |
|
296 | + if ($price_level_amount == $amount) { |
|
297 | 297 | return true; |
298 | 298 | } |
299 | 299 | } |
300 | 300 | |
301 | - $minimum = give_get_form_minimum_price( $form_id ); |
|
301 | + $minimum = give_get_form_minimum_price($form_id); |
|
302 | 302 | |
303 | - if ( $minimum > $amount ) { |
|
303 | + if ($minimum > $amount) { |
|
304 | 304 | return false; |
305 | 305 | } |
306 | 306 | |
@@ -316,9 +316,9 @@ discard block |
||
316 | 316 | */ |
317 | 317 | function give_purchase_form_validate_agree_to_terms() { |
318 | 318 | // Validate agree to terms |
319 | - if ( ! isset( $_POST['give_agree_to_terms'] ) || $_POST['give_agree_to_terms'] != 1 ) { |
|
319 | + if ( ! isset($_POST['give_agree_to_terms']) || $_POST['give_agree_to_terms'] != 1) { |
|
320 | 320 | // User did not agree |
321 | - give_set_error( 'agree_to_terms', apply_filters( 'give_agree_to_terms_text', __( 'You must agree to the terms of use', 'give' ) ) ); |
|
321 | + give_set_error('agree_to_terms', apply_filters('give_agree_to_terms_text', __('You must agree to the terms of use', 'give'))); |
|
322 | 322 | } |
323 | 323 | } |
324 | 324 | |
@@ -332,47 +332,47 @@ discard block |
||
332 | 332 | * |
333 | 333 | * @return array |
334 | 334 | */ |
335 | -function give_purchase_form_required_fields( $form_id ) { |
|
335 | +function give_purchase_form_required_fields($form_id) { |
|
336 | 336 | |
337 | - $payment_mode = give_get_chosen_gateway( $form_id ); |
|
337 | + $payment_mode = give_get_chosen_gateway($form_id); |
|
338 | 338 | |
339 | 339 | $required_fields = array( |
340 | 340 | 'give_email' => array( |
341 | 341 | 'error_id' => 'invalid_email', |
342 | - 'error_message' => __( 'Please enter a valid email address', 'give' ) |
|
342 | + 'error_message' => __('Please enter a valid email address', 'give') |
|
343 | 343 | ), |
344 | 344 | 'give_first' => array( |
345 | 345 | 'error_id' => 'invalid_first_name', |
346 | - 'error_message' => __( 'Please enter your first name', 'give' ) |
|
346 | + 'error_message' => __('Please enter your first name', 'give') |
|
347 | 347 | ) |
348 | 348 | ); |
349 | 349 | |
350 | - $require_address = give_require_billing_address( $payment_mode ); |
|
350 | + $require_address = give_require_billing_address($payment_mode); |
|
351 | 351 | |
352 | - if ( $require_address ) { |
|
353 | - $required_fields['card_address'] = array( |
|
352 | + if ($require_address) { |
|
353 | + $required_fields['card_address'] = array( |
|
354 | 354 | 'error_id' => 'invalid_card_address', |
355 | - 'error_message' => __( 'Please enter your primary billing address', 'give' ) |
|
355 | + 'error_message' => __('Please enter your primary billing address', 'give') |
|
356 | 356 | ); |
357 | - $required_fields['card_zip'] = array( |
|
357 | + $required_fields['card_zip'] = array( |
|
358 | 358 | 'error_id' => 'invalid_zip_code', |
359 | - 'error_message' => __( 'Please enter your zip / postal code', 'give' ) |
|
359 | + 'error_message' => __('Please enter your zip / postal code', 'give') |
|
360 | 360 | ); |
361 | - $required_fields['card_city'] = array( |
|
361 | + $required_fields['card_city'] = array( |
|
362 | 362 | 'error_id' => 'invalid_city', |
363 | - 'error_message' => __( 'Please enter your billing city', 'give' ) |
|
363 | + 'error_message' => __('Please enter your billing city', 'give') |
|
364 | 364 | ); |
365 | 365 | $required_fields['billing_country'] = array( |
366 | 366 | 'error_id' => 'invalid_country', |
367 | - 'error_message' => __( 'Please select your billing country', 'give' ) |
|
367 | + 'error_message' => __('Please select your billing country', 'give') |
|
368 | 368 | ); |
369 | - $required_fields['card_state'] = array( |
|
369 | + $required_fields['card_state'] = array( |
|
370 | 370 | 'error_id' => 'invalid_state', |
371 | - 'error_message' => __( 'Please enter billing state / province', 'give' ) |
|
371 | + 'error_message' => __('Please enter billing state / province', 'give') |
|
372 | 372 | ); |
373 | 373 | } |
374 | 374 | |
375 | - return apply_filters( 'give_purchase_form_required_fields', $required_fields, $form_id ); |
|
375 | + return apply_filters('give_purchase_form_required_fields', $required_fields, $form_id); |
|
376 | 376 | |
377 | 377 | } |
378 | 378 | |
@@ -385,16 +385,16 @@ discard block |
||
385 | 385 | * |
386 | 386 | * @return mixed|void |
387 | 387 | */ |
388 | -function give_require_billing_address( $payment_mode ) { |
|
388 | +function give_require_billing_address($payment_mode) { |
|
389 | 389 | |
390 | 390 | $return = false; |
391 | 391 | |
392 | - if ( isset( $_POST['billing_country'] ) || did_action( "give_{$payment_mode}_cc_form" ) || did_action( 'give_cc_form' ) ) { |
|
392 | + if (isset($_POST['billing_country']) || did_action("give_{$payment_mode}_cc_form") || did_action('give_cc_form')) { |
|
393 | 393 | $return = true; |
394 | 394 | } |
395 | 395 | |
396 | 396 | // Let payment gateways and other extensions determine if address fields should be required |
397 | - return apply_filters( 'give_require_billing_address', $return ); |
|
397 | + return apply_filters('give_require_billing_address', $return); |
|
398 | 398 | |
399 | 399 | } |
400 | 400 | |
@@ -408,43 +408,43 @@ discard block |
||
408 | 408 | function give_purchase_form_validate_logged_in_user() { |
409 | 409 | global $user_ID; |
410 | 410 | |
411 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
411 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
412 | 412 | |
413 | 413 | // Start empty array to collect valid user data |
414 | 414 | $valid_user_data = array( |
415 | 415 | // Assume there will be errors |
416 | - 'user_id' => - 1 |
|
416 | + 'user_id' => -1 |
|
417 | 417 | ); |
418 | 418 | |
419 | 419 | // Verify there is a user_ID |
420 | - if ( $user_ID > 0 ) { |
|
420 | + if ($user_ID > 0) { |
|
421 | 421 | // Get the logged in user data |
422 | - $user_data = get_userdata( $user_ID ); |
|
422 | + $user_data = get_userdata($user_ID); |
|
423 | 423 | |
424 | 424 | // Loop through required fields and show error messages |
425 | - foreach ( give_purchase_form_required_fields( $form_id ) as $field_name => $value ) { |
|
426 | - if ( in_array( $value, give_purchase_form_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { |
|
427 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
425 | + foreach (give_purchase_form_required_fields($form_id) as $field_name => $value) { |
|
426 | + if (in_array($value, give_purchase_form_required_fields($form_id)) && empty($_POST[$field_name])) { |
|
427 | + give_set_error($value['error_id'], $value['error_message']); |
|
428 | 428 | } |
429 | 429 | } |
430 | 430 | |
431 | 431 | // Verify data |
432 | - if ( $user_data ) { |
|
432 | + if ($user_data) { |
|
433 | 433 | // Collected logged in user data |
434 | 434 | $valid_user_data = array( |
435 | 435 | 'user_id' => $user_ID, |
436 | - 'user_email' => isset( $_POST['give_email'] ) ? sanitize_email( $_POST['give_email'] ) : $user_data->user_email, |
|
437 | - 'user_first' => isset( $_POST['give_first'] ) && ! empty( $_POST['give_first'] ) ? sanitize_text_field( $_POST['give_first'] ) : $user_data->first_name, |
|
438 | - 'user_last' => isset( $_POST['give_last'] ) && ! empty( $_POST['give_last'] ) ? sanitize_text_field( $_POST['give_last'] ) : $user_data->last_name, |
|
436 | + 'user_email' => isset($_POST['give_email']) ? sanitize_email($_POST['give_email']) : $user_data->user_email, |
|
437 | + 'user_first' => isset($_POST['give_first']) && ! empty($_POST['give_first']) ? sanitize_text_field($_POST['give_first']) : $user_data->first_name, |
|
438 | + 'user_last' => isset($_POST['give_last']) && ! empty($_POST['give_last']) ? sanitize_text_field($_POST['give_last']) : $user_data->last_name, |
|
439 | 439 | ); |
440 | 440 | |
441 | - if ( ! is_email( $valid_user_data['user_email'] ) ) { |
|
442 | - give_set_error( 'email_invalid', __( 'Invalid email', 'give' ) ); |
|
441 | + if ( ! is_email($valid_user_data['user_email'])) { |
|
442 | + give_set_error('email_invalid', __('Invalid email', 'give')); |
|
443 | 443 | } |
444 | 444 | |
445 | 445 | } else { |
446 | 446 | // Set invalid user error |
447 | - give_set_error( 'invalid_user', __( 'The user information is invalid', 'give' ) ); |
|
447 | + give_set_error('invalid_user', __('The user information is invalid', 'give')); |
|
448 | 448 | } |
449 | 449 | } |
450 | 450 | |
@@ -462,90 +462,90 @@ discard block |
||
462 | 462 | function give_purchase_form_validate_new_user() { |
463 | 463 | |
464 | 464 | $registering_new_user = false; |
465 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
465 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
466 | 466 | |
467 | 467 | // Start an empty array to collect valid user data |
468 | 468 | $valid_user_data = array( |
469 | 469 | // Assume there will be errors |
470 | - 'user_id' => - 1, |
|
470 | + 'user_id' => -1, |
|
471 | 471 | // Get first name |
472 | - 'user_first' => isset( $_POST['give_first'] ) ? sanitize_text_field( $_POST['give_first'] ) : '', |
|
472 | + 'user_first' => isset($_POST['give_first']) ? sanitize_text_field($_POST['give_first']) : '', |
|
473 | 473 | // Get last name |
474 | - 'user_last' => isset( $_POST['give_last'] ) ? sanitize_text_field( $_POST['give_last'] ) : '', |
|
474 | + 'user_last' => isset($_POST['give_last']) ? sanitize_text_field($_POST['give_last']) : '', |
|
475 | 475 | ); |
476 | 476 | |
477 | 477 | // Check the new user's credentials against existing ones |
478 | - $user_login = isset( $_POST['give_user_login'] ) ? trim( $_POST['give_user_login'] ) : false; |
|
479 | - $user_email = isset( $_POST['give_email'] ) ? trim( $_POST['give_email'] ) : false; |
|
480 | - $user_pass = isset( $_POST['give_user_pass'] ) ? trim( $_POST['give_user_pass'] ) : false; |
|
481 | - $pass_confirm = isset( $_POST['give_user_pass_confirm'] ) ? trim( $_POST['give_user_pass_confirm'] ) : false; |
|
478 | + $user_login = isset($_POST['give_user_login']) ? trim($_POST['give_user_login']) : false; |
|
479 | + $user_email = isset($_POST['give_email']) ? trim($_POST['give_email']) : false; |
|
480 | + $user_pass = isset($_POST['give_user_pass']) ? trim($_POST['give_user_pass']) : false; |
|
481 | + $pass_confirm = isset($_POST['give_user_pass_confirm']) ? trim($_POST['give_user_pass_confirm']) : false; |
|
482 | 482 | |
483 | 483 | // Loop through required fields and show error messages |
484 | - foreach ( give_purchase_form_required_fields( $form_id ) as $field_name => $value ) { |
|
485 | - if ( in_array( $value, give_purchase_form_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { |
|
486 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
484 | + foreach (give_purchase_form_required_fields($form_id) as $field_name => $value) { |
|
485 | + if (in_array($value, give_purchase_form_required_fields($form_id)) && empty($_POST[$field_name])) { |
|
486 | + give_set_error($value['error_id'], $value['error_message']); |
|
487 | 487 | } |
488 | 488 | } |
489 | 489 | |
490 | 490 | // Check if we have an username to register |
491 | - if ( $user_login && strlen( $user_login ) > 0 ) { |
|
491 | + if ($user_login && strlen($user_login) > 0) { |
|
492 | 492 | $registering_new_user = true; |
493 | 493 | |
494 | 494 | // We have an user name, check if it already exists |
495 | - if ( username_exists( $user_login ) ) { |
|
495 | + if (username_exists($user_login)) { |
|
496 | 496 | // Username already registered |
497 | - give_set_error( 'username_unavailable', __( 'Username already taken', 'give' ) ); |
|
497 | + give_set_error('username_unavailable', __('Username already taken', 'give')); |
|
498 | 498 | // Check if it's valid |
499 | - } else if ( ! give_validate_username( $user_login ) ) { |
|
499 | + } else if ( ! give_validate_username($user_login)) { |
|
500 | 500 | // Invalid username |
501 | - if ( is_multisite() ) { |
|
502 | - give_set_error( 'username_invalid', __( 'Invalid username. Only lowercase letters (a-z) and numbers are allowed', 'give' ) ); |
|
501 | + if (is_multisite()) { |
|
502 | + give_set_error('username_invalid', __('Invalid username. Only lowercase letters (a-z) and numbers are allowed', 'give')); |
|
503 | 503 | } else { |
504 | - give_set_error( 'username_invalid', __( 'Invalid username', 'give' ) ); |
|
504 | + give_set_error('username_invalid', __('Invalid username', 'give')); |
|
505 | 505 | } |
506 | 506 | } else { |
507 | 507 | // All the checks have run and it's good to go |
508 | 508 | $valid_user_data['user_login'] = $user_login; |
509 | 509 | } |
510 | - } elseif ( give_logged_in_only( $form_id ) ) { |
|
511 | - give_set_error( 'registration_required', esc_html__( 'You must register or login to complete your donation', 'give' ) ); |
|
510 | + } elseif (give_logged_in_only($form_id)) { |
|
511 | + give_set_error('registration_required', esc_html__('You must register or login to complete your donation', 'give')); |
|
512 | 512 | } |
513 | 513 | |
514 | 514 | // Check if we have an email to verify |
515 | - if ( $user_email && strlen( $user_email ) > 0 ) { |
|
515 | + if ($user_email && strlen($user_email) > 0) { |
|
516 | 516 | // Validate email |
517 | - if ( ! is_email( $user_email ) ) { |
|
518 | - give_set_error( 'email_invalid', __( 'Sorry, that email is invalid', 'give' ) ); |
|
517 | + if ( ! is_email($user_email)) { |
|
518 | + give_set_error('email_invalid', __('Sorry, that email is invalid', 'give')); |
|
519 | 519 | // Check if email exists |
520 | - } else if ( email_exists( $user_email ) && $registering_new_user ) { |
|
521 | - give_set_error( 'email_used', __( 'Sorry, that email already active for another user', 'give' ) ); |
|
520 | + } else if (email_exists($user_email) && $registering_new_user) { |
|
521 | + give_set_error('email_used', __('Sorry, that email already active for another user', 'give')); |
|
522 | 522 | } else { |
523 | 523 | // All the checks have run and it's good to go |
524 | 524 | $valid_user_data['user_email'] = $user_email; |
525 | 525 | } |
526 | 526 | } else { |
527 | 527 | // No email |
528 | - give_set_error( 'email_empty', __( 'Enter an email', 'give' ) ); |
|
528 | + give_set_error('email_empty', __('Enter an email', 'give')); |
|
529 | 529 | } |
530 | 530 | |
531 | 531 | // Check password |
532 | - if ( $user_pass && $pass_confirm ) { |
|
532 | + if ($user_pass && $pass_confirm) { |
|
533 | 533 | // Verify confirmation matches |
534 | - if ( $user_pass != $pass_confirm ) { |
|
534 | + if ($user_pass != $pass_confirm) { |
|
535 | 535 | // Passwords do not match |
536 | - give_set_error( 'password_mismatch', __( 'Passwords don\'t match', 'give' ) ); |
|
536 | + give_set_error('password_mismatch', __('Passwords don\'t match', 'give')); |
|
537 | 537 | } else { |
538 | 538 | // All is good to go |
539 | 539 | $valid_user_data['user_pass'] = $user_pass; |
540 | 540 | } |
541 | 541 | } else { |
542 | 542 | // Password or confirmation missing |
543 | - if ( ! $user_pass && $registering_new_user ) { |
|
543 | + if ( ! $user_pass && $registering_new_user) { |
|
544 | 544 | // The password is invalid |
545 | - give_set_error( 'password_empty', __( 'Enter a password', 'give' ) ); |
|
546 | - } else if ( ! $pass_confirm && $registering_new_user ) { |
|
545 | + give_set_error('password_empty', __('Enter a password', 'give')); |
|
546 | + } else if ( ! $pass_confirm && $registering_new_user) { |
|
547 | 547 | // Confirmation password is invalid |
548 | - give_set_error( 'confirmation_empty', __( 'Enter the password confirmation', 'give' ) ); |
|
548 | + give_set_error('confirmation_empty', __('Enter the password confirmation', 'give')); |
|
549 | 549 | } |
550 | 550 | } |
551 | 551 | |
@@ -564,34 +564,34 @@ discard block |
||
564 | 564 | // Start an array to collect valid user data |
565 | 565 | $valid_user_data = array( |
566 | 566 | // Assume there will be errors |
567 | - 'user_id' => - 1 |
|
567 | + 'user_id' => -1 |
|
568 | 568 | ); |
569 | 569 | |
570 | 570 | // Username |
571 | - if ( ! isset( $_POST['give_user_login'] ) || $_POST['give_user_login'] == '' ) { |
|
572 | - give_set_error( 'must_log_in', __( 'You must login or register to complete your donation', 'give' ) ); |
|
571 | + if ( ! isset($_POST['give_user_login']) || $_POST['give_user_login'] == '') { |
|
572 | + give_set_error('must_log_in', __('You must login or register to complete your donation', 'give')); |
|
573 | 573 | |
574 | 574 | return $valid_user_data; |
575 | 575 | } |
576 | 576 | |
577 | 577 | // Get the user by login |
578 | - $user_data = get_user_by( 'login', strip_tags( $_POST['give_user_login'] ) ); |
|
578 | + $user_data = get_user_by('login', strip_tags($_POST['give_user_login'])); |
|
579 | 579 | |
580 | 580 | // Check if user exists |
581 | - if ( $user_data ) { |
|
581 | + if ($user_data) { |
|
582 | 582 | // Get password |
583 | - $user_pass = isset( $_POST['give_user_pass'] ) ? $_POST['give_user_pass'] : false; |
|
583 | + $user_pass = isset($_POST['give_user_pass']) ? $_POST['give_user_pass'] : false; |
|
584 | 584 | |
585 | 585 | // Check user_pass |
586 | - if ( $user_pass ) { |
|
586 | + if ($user_pass) { |
|
587 | 587 | // Check if password is valid |
588 | - if ( ! wp_check_password( $user_pass, $user_data->user_pass, $user_data->ID ) ) { |
|
588 | + if ( ! wp_check_password($user_pass, $user_data->user_pass, $user_data->ID)) { |
|
589 | 589 | // Incorrect password |
590 | 590 | give_set_error( |
591 | 591 | 'password_incorrect', |
592 | 592 | sprintf( |
593 | - __( 'The password you entered is incorrect. %sReset Password%s', 'give' ), |
|
594 | - '<a href="' . wp_lostpassword_url( "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]" ) . '" title="' . __( 'Lost Password', 'give' ) . '">', |
|
593 | + __('The password you entered is incorrect. %sReset Password%s', 'give'), |
|
594 | + '<a href="'.wp_lostpassword_url("http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]").'" title="'.__('Lost Password', 'give').'">', |
|
595 | 595 | '</a>' |
596 | 596 | ) |
597 | 597 | ); |
@@ -609,11 +609,11 @@ discard block |
||
609 | 609 | } |
610 | 610 | } else { |
611 | 611 | // Empty password |
612 | - give_set_error( 'password_empty', __( 'Enter a password', 'give' ) ); |
|
612 | + give_set_error('password_empty', __('Enter a password', 'give')); |
|
613 | 613 | } |
614 | 614 | } else { |
615 | 615 | // no username |
616 | - give_set_error( 'username_incorrect', __( 'The username you entered does not exist', 'give' ) ); |
|
616 | + give_set_error('username_incorrect', __('The username you entered does not exist', 'give')); |
|
617 | 617 | } |
618 | 618 | |
619 | 619 | return $valid_user_data; |
@@ -628,7 +628,7 @@ discard block |
||
628 | 628 | */ |
629 | 629 | function give_purchase_form_validate_guest_user() { |
630 | 630 | |
631 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
631 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
632 | 632 | |
633 | 633 | // Start an array to collect valid user data |
634 | 634 | $valid_user_data = array( |
@@ -637,32 +637,32 @@ discard block |
||
637 | 637 | ); |
638 | 638 | |
639 | 639 | // Show error message if user must be logged in |
640 | - if ( give_logged_in_only( $form_id ) ) { |
|
641 | - give_set_error( 'logged_in_only', __( 'You must be logged into to donate', 'give' ) ); |
|
640 | + if (give_logged_in_only($form_id)) { |
|
641 | + give_set_error('logged_in_only', __('You must be logged into to donate', 'give')); |
|
642 | 642 | } |
643 | 643 | |
644 | 644 | // Get the guest email |
645 | - $guest_email = isset( $_POST['give_email'] ) ? $_POST['give_email'] : false; |
|
645 | + $guest_email = isset($_POST['give_email']) ? $_POST['give_email'] : false; |
|
646 | 646 | |
647 | 647 | // Check email |
648 | - if ( $guest_email && strlen( $guest_email ) > 0 ) { |
|
648 | + if ($guest_email && strlen($guest_email) > 0) { |
|
649 | 649 | // Validate email |
650 | - if ( ! is_email( $guest_email ) ) { |
|
650 | + if ( ! is_email($guest_email)) { |
|
651 | 651 | // Invalid email |
652 | - give_set_error( 'email_invalid', __( 'Invalid email', 'give' ) ); |
|
652 | + give_set_error('email_invalid', __('Invalid email', 'give')); |
|
653 | 653 | } else { |
654 | 654 | // All is good to go |
655 | 655 | $valid_user_data['user_email'] = $guest_email; |
656 | 656 | } |
657 | 657 | } else { |
658 | 658 | // No email |
659 | - give_set_error( 'email_empty', __( 'Enter an email', 'give' ) ); |
|
659 | + give_set_error('email_empty', __('Enter an email', 'give')); |
|
660 | 660 | } |
661 | 661 | |
662 | 662 | // Loop through required fields and show error messages |
663 | - foreach ( give_purchase_form_required_fields( $form_id ) as $field_name => $value ) { |
|
664 | - if ( in_array( $value, give_purchase_form_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { |
|
665 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
663 | + foreach (give_purchase_form_required_fields($form_id) as $field_name => $value) { |
|
664 | + if (in_array($value, give_purchase_form_required_fields($form_id)) && empty($_POST[$field_name])) { |
|
665 | + give_set_error($value['error_id'], $value['error_message']); |
|
666 | 666 | } |
667 | 667 | } |
668 | 668 | |
@@ -678,42 +678,42 @@ discard block |
||
678 | 678 | * @since 1.0 |
679 | 679 | * @return integer |
680 | 680 | */ |
681 | -function give_register_and_login_new_user( $user_data = array() ) { |
|
681 | +function give_register_and_login_new_user($user_data = array()) { |
|
682 | 682 | // Verify the array |
683 | - if ( empty( $user_data ) ) { |
|
684 | - return - 1; |
|
683 | + if (empty($user_data)) { |
|
684 | + return -1; |
|
685 | 685 | } |
686 | 686 | |
687 | - if ( give_get_errors() ) { |
|
688 | - return - 1; |
|
687 | + if (give_get_errors()) { |
|
688 | + return -1; |
|
689 | 689 | } |
690 | 690 | |
691 | - $user_args = apply_filters( 'give_insert_user_args', array( |
|
692 | - 'user_login' => isset( $user_data['user_login'] ) ? $user_data['user_login'] : '', |
|
693 | - 'user_pass' => isset( $user_data['user_pass'] ) ? $user_data['user_pass'] : '', |
|
694 | - 'user_email' => isset( $user_data['user_email'] ) ? $user_data['user_email'] : '', |
|
695 | - 'first_name' => isset( $user_data['user_first'] ) ? $user_data['user_first'] : '', |
|
696 | - 'last_name' => isset( $user_data['user_last'] ) ? $user_data['user_last'] : '', |
|
697 | - 'user_registered' => date( 'Y-m-d H:i:s' ), |
|
698 | - 'role' => get_option( 'default_role' ) |
|
699 | - ), $user_data ); |
|
691 | + $user_args = apply_filters('give_insert_user_args', array( |
|
692 | + 'user_login' => isset($user_data['user_login']) ? $user_data['user_login'] : '', |
|
693 | + 'user_pass' => isset($user_data['user_pass']) ? $user_data['user_pass'] : '', |
|
694 | + 'user_email' => isset($user_data['user_email']) ? $user_data['user_email'] : '', |
|
695 | + 'first_name' => isset($user_data['user_first']) ? $user_data['user_first'] : '', |
|
696 | + 'last_name' => isset($user_data['user_last']) ? $user_data['user_last'] : '', |
|
697 | + 'user_registered' => date('Y-m-d H:i:s'), |
|
698 | + 'role' => get_option('default_role') |
|
699 | + ), $user_data); |
|
700 | 700 | |
701 | 701 | // Insert new user |
702 | - $user_id = wp_insert_user( $user_args ); |
|
702 | + $user_id = wp_insert_user($user_args); |
|
703 | 703 | |
704 | 704 | // Validate inserted user |
705 | - if ( is_wp_error( $user_id ) ) { |
|
706 | - return - 1; |
|
705 | + if (is_wp_error($user_id)) { |
|
706 | + return -1; |
|
707 | 707 | } |
708 | 708 | |
709 | 709 | // Allow themes and plugins to filter the user data |
710 | - $user_data = apply_filters( 'give_insert_user_data', $user_data, $user_args ); |
|
710 | + $user_data = apply_filters('give_insert_user_data', $user_data, $user_args); |
|
711 | 711 | |
712 | 712 | // Allow themes and plugins to hook |
713 | - do_action( 'give_insert_user', $user_id, $user_data ); |
|
713 | + do_action('give_insert_user', $user_id, $user_data); |
|
714 | 714 | |
715 | 715 | // Login new user |
716 | - give_log_user_in( $user_id, $user_data['user_login'], $user_data['user_pass'] ); |
|
716 | + give_log_user_in($user_id, $user_data['user_login'], $user_data['user_pass']); |
|
717 | 717 | |
718 | 718 | // Return user id |
719 | 719 | return $user_id; |
@@ -728,27 +728,27 @@ discard block |
||
728 | 728 | * @since 1.0 |
729 | 729 | * @return array |
730 | 730 | */ |
731 | -function give_get_purchase_form_user( $valid_data = array() ) { |
|
731 | +function give_get_purchase_form_user($valid_data = array()) { |
|
732 | 732 | |
733 | 733 | // Initialize user |
734 | 734 | $user = false; |
735 | - $is_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX; |
|
735 | + $is_ajax = defined('DOING_AJAX') && DOING_AJAX; |
|
736 | 736 | |
737 | - if ( $is_ajax ) { |
|
737 | + if ($is_ajax) { |
|
738 | 738 | // Do not create or login the user during the ajax submission (check for errors only) |
739 | 739 | return true; |
740 | - } else if ( is_user_logged_in() ) { |
|
740 | + } else if (is_user_logged_in()) { |
|
741 | 741 | // Set the valid user as the logged in collected data |
742 | 742 | $user = $valid_data['logged_in_user']; |
743 | - } else if ( $valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true ) { |
|
743 | + } else if ($valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true) { |
|
744 | 744 | // New user registration |
745 | - if ( $valid_data['need_new_user'] === true ) { |
|
745 | + if ($valid_data['need_new_user'] === true) { |
|
746 | 746 | // Set user |
747 | 747 | $user = $valid_data['new_user_data']; |
748 | 748 | // Register and login new user |
749 | - $user['user_id'] = give_register_and_login_new_user( $user ); |
|
749 | + $user['user_id'] = give_register_and_login_new_user($user); |
|
750 | 750 | // User login |
751 | - } else if ( $valid_data['need_user_login'] === true && ! $is_ajax ) { |
|
751 | + } else if ($valid_data['need_user_login'] === true && ! $is_ajax) { |
|
752 | 752 | |
753 | 753 | /* |
754 | 754 | * The login form is now processed in the give_process_purchase_login() function. |
@@ -763,48 +763,48 @@ discard block |
||
763 | 763 | // Set user |
764 | 764 | $user = $valid_data['login_user_data']; |
765 | 765 | // Login user |
766 | - give_log_user_in( $user['user_id'], $user['user_login'], $user['user_pass'] ); |
|
766 | + give_log_user_in($user['user_id'], $user['user_login'], $user['user_pass']); |
|
767 | 767 | } |
768 | 768 | } |
769 | 769 | |
770 | 770 | // Check guest checkout |
771 | - if ( false === $user && false === give_logged_in_only( $_POST['give-form-id'] ) ) { |
|
771 | + if (false === $user && false === give_logged_in_only($_POST['give-form-id'])) { |
|
772 | 772 | // Set user |
773 | 773 | $user = $valid_data['guest_user_data']; |
774 | 774 | } |
775 | 775 | |
776 | 776 | // Verify we have an user |
777 | - if ( false === $user || empty( $user ) ) { |
|
777 | + if (false === $user || empty($user)) { |
|
778 | 778 | // Return false |
779 | 779 | return false; |
780 | 780 | } |
781 | 781 | |
782 | 782 | // Get user first name |
783 | - if ( ! isset( $user['user_first'] ) || strlen( trim( $user['user_first'] ) ) < 1 ) { |
|
784 | - $user['user_first'] = isset( $_POST['give_first'] ) ? strip_tags( trim( $_POST['give_first'] ) ) : ''; |
|
783 | + if ( ! isset($user['user_first']) || strlen(trim($user['user_first'])) < 1) { |
|
784 | + $user['user_first'] = isset($_POST['give_first']) ? strip_tags(trim($_POST['give_first'])) : ''; |
|
785 | 785 | } |
786 | 786 | |
787 | 787 | // Get user last name |
788 | - if ( ! isset( $user['user_last'] ) || strlen( trim( $user['user_last'] ) ) < 1 ) { |
|
789 | - $user['user_last'] = isset( $_POST['give_last'] ) ? strip_tags( trim( $_POST['give_last'] ) ) : ''; |
|
788 | + if ( ! isset($user['user_last']) || strlen(trim($user['user_last'])) < 1) { |
|
789 | + $user['user_last'] = isset($_POST['give_last']) ? strip_tags(trim($_POST['give_last'])) : ''; |
|
790 | 790 | } |
791 | 791 | |
792 | 792 | // Get the user's billing address details |
793 | 793 | $user['address'] = array(); |
794 | - $user['address']['line1'] = ! empty( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : false; |
|
795 | - $user['address']['line2'] = ! empty( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : false; |
|
796 | - $user['address']['city'] = ! empty( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : false; |
|
797 | - $user['address']['state'] = ! empty( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : false; |
|
798 | - $user['address']['country'] = ! empty( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : false; |
|
799 | - $user['address']['zip'] = ! empty( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : false; |
|
800 | - |
|
801 | - if ( empty( $user['address']['country'] ) ) { |
|
794 | + $user['address']['line1'] = ! empty($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : false; |
|
795 | + $user['address']['line2'] = ! empty($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : false; |
|
796 | + $user['address']['city'] = ! empty($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : false; |
|
797 | + $user['address']['state'] = ! empty($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : false; |
|
798 | + $user['address']['country'] = ! empty($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : false; |
|
799 | + $user['address']['zip'] = ! empty($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : false; |
|
800 | + |
|
801 | + if (empty($user['address']['country'])) { |
|
802 | 802 | $user['address'] = false; |
803 | 803 | } // Country will always be set if address fields are present |
804 | 804 | |
805 | - if ( ! empty( $user['user_id'] ) && $user['user_id'] > 0 && ! empty( $user['address'] ) ) { |
|
805 | + if ( ! empty($user['user_id']) && $user['user_id'] > 0 && ! empty($user['address'])) { |
|
806 | 806 | // Store the address in the user's meta so the donation form can be pre-populated with it on return purchases |
807 | - update_user_meta( $user['user_id'], '_give_user_address', $user['address'] ); |
|
807 | + update_user_meta($user['user_id'], '_give_user_address', $user['address']); |
|
808 | 808 | } |
809 | 809 | |
810 | 810 | // Return valid user |
@@ -823,16 +823,16 @@ discard block |
||
823 | 823 | $card_data = give_get_purchase_cc_info(); |
824 | 824 | |
825 | 825 | // Validate the card zip |
826 | - if ( ! empty( $card_data['card_zip'] ) ) { |
|
827 | - if ( ! give_purchase_form_validate_cc_zip( $card_data['card_zip'], $card_data['card_country'] ) ) { |
|
828 | - give_set_error( 'invalid_cc_zip', __( 'The zip / postal code you entered for your billing address is invalid', 'give' ) ); |
|
826 | + if ( ! empty($card_data['card_zip'])) { |
|
827 | + if ( ! give_purchase_form_validate_cc_zip($card_data['card_zip'], $card_data['card_country'])) { |
|
828 | + give_set_error('invalid_cc_zip', __('The zip / postal code you entered for your billing address is invalid', 'give')); |
|
829 | 829 | } |
830 | 830 | } |
831 | 831 | |
832 | 832 | //Ensure no spaces |
833 | - if ( ! empty( $card_data['card_number'] ) ) { |
|
834 | - $card_data['card_number'] = str_replace( '+', '', $card_data['card_number'] ); //no "+" signs |
|
835 | - $card_data['card_number'] = str_replace( ' ', '', $card_data['card_number'] ); // No spaces |
|
833 | + if ( ! empty($card_data['card_number'])) { |
|
834 | + $card_data['card_number'] = str_replace('+', '', $card_data['card_number']); //no "+" signs |
|
835 | + $card_data['card_number'] = str_replace(' ', '', $card_data['card_number']); // No spaces |
|
836 | 836 | } |
837 | 837 | |
838 | 838 | // This should validate card numbers at some point too |
@@ -848,17 +848,17 @@ discard block |
||
848 | 848 | */ |
849 | 849 | function give_get_purchase_cc_info() { |
850 | 850 | $cc_info = array(); |
851 | - $cc_info['card_name'] = isset( $_POST['card_name'] ) ? sanitize_text_field( $_POST['card_name'] ) : ''; |
|
852 | - $cc_info['card_number'] = isset( $_POST['card_number'] ) ? sanitize_text_field( $_POST['card_number'] ) : ''; |
|
853 | - $cc_info['card_cvc'] = isset( $_POST['card_cvc'] ) ? sanitize_text_field( $_POST['card_cvc'] ) : ''; |
|
854 | - $cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] ) ? sanitize_text_field( $_POST['card_exp_month'] ) : ''; |
|
855 | - $cc_info['card_exp_year'] = isset( $_POST['card_exp_year'] ) ? sanitize_text_field( $_POST['card_exp_year'] ) : ''; |
|
856 | - $cc_info['card_address'] = isset( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : ''; |
|
857 | - $cc_info['card_address_2'] = isset( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : ''; |
|
858 | - $cc_info['card_city'] = isset( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : ''; |
|
859 | - $cc_info['card_state'] = isset( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : ''; |
|
860 | - $cc_info['card_country'] = isset( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : ''; |
|
861 | - $cc_info['card_zip'] = isset( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : ''; |
|
851 | + $cc_info['card_name'] = isset($_POST['card_name']) ? sanitize_text_field($_POST['card_name']) : ''; |
|
852 | + $cc_info['card_number'] = isset($_POST['card_number']) ? sanitize_text_field($_POST['card_number']) : ''; |
|
853 | + $cc_info['card_cvc'] = isset($_POST['card_cvc']) ? sanitize_text_field($_POST['card_cvc']) : ''; |
|
854 | + $cc_info['card_exp_month'] = isset($_POST['card_exp_month']) ? sanitize_text_field($_POST['card_exp_month']) : ''; |
|
855 | + $cc_info['card_exp_year'] = isset($_POST['card_exp_year']) ? sanitize_text_field($_POST['card_exp_year']) : ''; |
|
856 | + $cc_info['card_address'] = isset($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : ''; |
|
857 | + $cc_info['card_address_2'] = isset($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : ''; |
|
858 | + $cc_info['card_city'] = isset($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : ''; |
|
859 | + $cc_info['card_state'] = isset($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : ''; |
|
860 | + $cc_info['card_country'] = isset($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : ''; |
|
861 | + $cc_info['card_zip'] = isset($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : ''; |
|
862 | 862 | |
863 | 863 | // Return cc info |
864 | 864 | return $cc_info; |
@@ -874,14 +874,14 @@ discard block |
||
874 | 874 | * |
875 | 875 | * @return bool|mixed|void |
876 | 876 | */ |
877 | -function give_purchase_form_validate_cc_zip( $zip = 0, $country_code = '' ) { |
|
877 | +function give_purchase_form_validate_cc_zip($zip = 0, $country_code = '') { |
|
878 | 878 | $ret = false; |
879 | 879 | |
880 | - if ( empty( $zip ) || empty( $country_code ) ) { |
|
880 | + if (empty($zip) || empty($country_code)) { |
|
881 | 881 | return $ret; |
882 | 882 | } |
883 | 883 | |
884 | - $country_code = strtoupper( $country_code ); |
|
884 | + $country_code = strtoupper($country_code); |
|
885 | 885 | |
886 | 886 | $zip_regex = array( |
887 | 887 | "AD" => "AD\d{3}", |
@@ -1041,9 +1041,9 @@ discard block |
||
1041 | 1041 | "ZM" => "\d{5}" |
1042 | 1042 | ); |
1043 | 1043 | |
1044 | - if ( ! isset ( $zip_regex[ $country_code ] ) || preg_match( "/" . $zip_regex[ $country_code ] . "/i", $zip ) ) { |
|
1044 | + if ( ! isset ($zip_regex[$country_code]) || preg_match("/".$zip_regex[$country_code]."/i", $zip)) { |
|
1045 | 1045 | $ret = true; |
1046 | 1046 | } |
1047 | 1047 | |
1048 | - return apply_filters( 'give_is_zip_valid', $ret, $zip, $country_code ); |
|
1048 | + return apply_filters('give_is_zip_valid', $ret, $zip, $country_code); |
|
1049 | 1049 | } |
1050 | 1050 | \ No newline at end of file |
@@ -40,11 +40,11 @@ discard block |
||
40 | 40 | */ |
41 | 41 | |
42 | 42 | // Exit if accessed directly |
43 | -if ( ! defined( 'ABSPATH' ) ) { |
|
43 | +if ( ! defined('ABSPATH')) { |
|
44 | 44 | exit; |
45 | 45 | } |
46 | 46 | |
47 | -if ( ! class_exists( 'Give' ) ) : |
|
47 | +if ( ! class_exists('Give')) : |
|
48 | 48 | /** |
49 | 49 | * Main Give Class |
50 | 50 | * |
@@ -159,11 +159,11 @@ discard block |
||
159 | 159 | * @return Give |
160 | 160 | */ |
161 | 161 | public static function instance() { |
162 | - if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Give ) ) { |
|
162 | + if ( ! isset(self::$instance) && ! (self::$instance instanceof Give)) { |
|
163 | 163 | self::$instance = new Give; |
164 | 164 | self::$instance->setup_constants(); |
165 | 165 | |
166 | - add_action( 'plugins_loaded', array( self::$instance, 'load_textdomain' ) ); |
|
166 | + add_action('plugins_loaded', array(self::$instance, 'load_textdomain')); |
|
167 | 167 | |
168 | 168 | self::$instance->includes(); |
169 | 169 | self::$instance->roles = new Give_Roles(); |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | */ |
196 | 196 | public function __clone() { |
197 | 197 | // Cloning instances of the class is forbidden |
198 | - _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'give' ), '1.0' ); |
|
198 | + _doing_it_wrong(__FUNCTION__, __('Cheatin’ huh?', 'give'), '1.0'); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | /** |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | */ |
208 | 208 | public function __wakeup() { |
209 | 209 | // Unserializing instances of the class is forbidden |
210 | - _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'give' ), '1.0' ); |
|
210 | + _doing_it_wrong(__FUNCTION__, __('Cheatin’ huh?', 'give'), '1.0'); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | /** |
@@ -220,33 +220,33 @@ discard block |
||
220 | 220 | private function setup_constants() { |
221 | 221 | |
222 | 222 | // Plugin version |
223 | - if ( ! defined( 'GIVE_VERSION' ) ) { |
|
224 | - define( 'GIVE_VERSION', '1.4.5' ); |
|
223 | + if ( ! defined('GIVE_VERSION')) { |
|
224 | + define('GIVE_VERSION', '1.4.5'); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | // Plugin Folder Path |
228 | - if ( ! defined( 'GIVE_PLUGIN_DIR' ) ) { |
|
229 | - define( 'GIVE_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); |
|
228 | + if ( ! defined('GIVE_PLUGIN_DIR')) { |
|
229 | + define('GIVE_PLUGIN_DIR', plugin_dir_path(__FILE__)); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | // Plugin Folder URL |
233 | - if ( ! defined( 'GIVE_PLUGIN_URL' ) ) { |
|
234 | - define( 'GIVE_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); |
|
233 | + if ( ! defined('GIVE_PLUGIN_URL')) { |
|
234 | + define('GIVE_PLUGIN_URL', plugin_dir_url(__FILE__)); |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | // Plugin Basename aka: "give/give.php" |
238 | - if ( ! defined( 'GIVE_PLUGIN_BASENAME' ) ) { |
|
239 | - define( 'GIVE_PLUGIN_BASENAME', plugin_basename( __FILE__ ) ); |
|
238 | + if ( ! defined('GIVE_PLUGIN_BASENAME')) { |
|
239 | + define('GIVE_PLUGIN_BASENAME', plugin_basename(__FILE__)); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | // Plugin Root File |
243 | - if ( ! defined( 'GIVE_PLUGIN_FILE' ) ) { |
|
244 | - define( 'GIVE_PLUGIN_FILE', __FILE__ ); |
|
243 | + if ( ! defined('GIVE_PLUGIN_FILE')) { |
|
244 | + define('GIVE_PLUGIN_FILE', __FILE__); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | // Make sure CAL_GREGORIAN is defined |
248 | - if ( ! defined( 'CAL_GREGORIAN' ) ) { |
|
249 | - define( 'CAL_GREGORIAN', 1 ); |
|
248 | + if ( ! defined('CAL_GREGORIAN')) { |
|
249 | + define('CAL_GREGORIAN', 1); |
|
250 | 250 | } |
251 | 251 | } |
252 | 252 | |
@@ -260,109 +260,109 @@ discard block |
||
260 | 260 | private function includes() { |
261 | 261 | global $give_options; |
262 | 262 | |
263 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-give-settings.php'; |
|
263 | + require_once GIVE_PLUGIN_DIR.'includes/admin/class-give-settings.php'; |
|
264 | 264 | $give_options = give_get_settings(); |
265 | 265 | |
266 | - require_once GIVE_PLUGIN_DIR . 'includes/post-types.php'; |
|
267 | - require_once GIVE_PLUGIN_DIR . 'includes/scripts.php'; |
|
268 | - require_once GIVE_PLUGIN_DIR . 'includes/ajax-functions.php'; |
|
269 | - require_once GIVE_PLUGIN_DIR . 'includes/actions.php'; |
|
270 | - require_once GIVE_PLUGIN_DIR . 'includes/api/class-give-api.php'; |
|
271 | - |
|
272 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-roles.php'; |
|
273 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-template-loader.php'; |
|
274 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-donate-form.php'; |
|
275 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-db.php'; |
|
276 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-customers.php'; |
|
277 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-customer.php'; |
|
278 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-stats.php'; |
|
279 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-session.php'; |
|
280 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-html-elements.php'; |
|
281 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-logging.php'; |
|
282 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-license-handler.php'; |
|
283 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-cron.php'; |
|
284 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-email-access.php'; |
|
285 | - |
|
286 | - require_once GIVE_PLUGIN_DIR . 'includes/country-functions.php'; |
|
287 | - require_once GIVE_PLUGIN_DIR . 'includes/template-functions.php'; |
|
288 | - require_once GIVE_PLUGIN_DIR . 'includes/misc-functions.php'; |
|
289 | - require_once GIVE_PLUGIN_DIR . 'includes/forms/functions.php'; |
|
290 | - require_once GIVE_PLUGIN_DIR . 'includes/forms/template.php'; |
|
291 | - require_once GIVE_PLUGIN_DIR . 'includes/forms/widget.php'; |
|
292 | - require_once GIVE_PLUGIN_DIR . 'includes/shortcodes.php'; |
|
293 | - require_once GIVE_PLUGIN_DIR . 'includes/formatting.php'; |
|
294 | - require_once GIVE_PLUGIN_DIR . 'includes/price-functions.php'; |
|
295 | - require_once GIVE_PLUGIN_DIR . 'includes/error-tracking.php'; |
|
296 | - require_once GIVE_PLUGIN_DIR . 'includes/process-purchase.php'; |
|
297 | - require_once GIVE_PLUGIN_DIR . 'includes/login-register.php'; |
|
298 | - require_once GIVE_PLUGIN_DIR . 'includes/user-functions.php'; |
|
299 | - require_once GIVE_PLUGIN_DIR . 'includes/plugin-compatibility.php'; |
|
300 | - require_once GIVE_PLUGIN_DIR . 'includes/deprecated-functions.php'; |
|
301 | - |
|
302 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/functions.php'; |
|
303 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/actions.php'; |
|
304 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/class-payment-stats.php'; |
|
305 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/class-payments-query.php'; |
|
306 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/class-give-payment.php'; |
|
307 | - |
|
308 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/functions.php'; |
|
309 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/actions.php'; |
|
310 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/paypal-standard.php'; |
|
311 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/offline-donations.php'; |
|
312 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/manual.php'; |
|
313 | - |
|
314 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/class-give-emails.php'; |
|
315 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/class-give-email-tags.php'; |
|
316 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/functions.php'; |
|
317 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/template.php'; |
|
318 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/actions.php'; |
|
319 | - |
|
320 | - if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
|
321 | - |
|
322 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-footer.php'; |
|
323 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/welcome.php'; |
|
324 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-pages.php'; |
|
325 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-admin-notices.php'; |
|
326 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-api-keys-table.php'; |
|
327 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-actions.php'; |
|
328 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/system-info.php'; |
|
329 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/add-ons.php'; |
|
330 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/plugins.php'; |
|
331 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/dashboard-widgets.php'; |
|
332 | - |
|
333 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/actions.php'; |
|
334 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/payments-history.php'; |
|
335 | - |
|
336 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/customers/customers.php'; |
|
337 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/customers/customer-functions.php'; |
|
338 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/customers/customer-actions.php'; |
|
339 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/metabox.php'; |
|
340 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/dashboard-columns.php'; |
|
341 | - |
|
342 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/export-functions.php'; |
|
343 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/reports.php'; |
|
344 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/tools.php'; |
|
345 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/tools/tools-actions.php'; |
|
346 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/pdf-reports.php'; |
|
347 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/class-give-graph.php'; |
|
348 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/graphing.php'; |
|
349 | - |
|
350 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/abstract-shortcode-generator.php'; |
|
351 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/class-shortcode-button.php'; |
|
352 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-form.php'; |
|
353 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-goal.php'; |
|
354 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-login.php'; |
|
355 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-register.php'; |
|
356 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-profile-editor.php'; |
|
357 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-donation-history.php'; |
|
358 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-receipt.php'; |
|
359 | - |
|
360 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php'; |
|
361 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrades.php'; |
|
266 | + require_once GIVE_PLUGIN_DIR.'includes/post-types.php'; |
|
267 | + require_once GIVE_PLUGIN_DIR.'includes/scripts.php'; |
|
268 | + require_once GIVE_PLUGIN_DIR.'includes/ajax-functions.php'; |
|
269 | + require_once GIVE_PLUGIN_DIR.'includes/actions.php'; |
|
270 | + require_once GIVE_PLUGIN_DIR.'includes/api/class-give-api.php'; |
|
271 | + |
|
272 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-roles.php'; |
|
273 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-template-loader.php'; |
|
274 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-donate-form.php'; |
|
275 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-db.php'; |
|
276 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-db-customers.php'; |
|
277 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-customer.php'; |
|
278 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-stats.php'; |
|
279 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-session.php'; |
|
280 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-html-elements.php'; |
|
281 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-logging.php'; |
|
282 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-license-handler.php'; |
|
283 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-cron.php'; |
|
284 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-email-access.php'; |
|
285 | + |
|
286 | + require_once GIVE_PLUGIN_DIR.'includes/country-functions.php'; |
|
287 | + require_once GIVE_PLUGIN_DIR.'includes/template-functions.php'; |
|
288 | + require_once GIVE_PLUGIN_DIR.'includes/misc-functions.php'; |
|
289 | + require_once GIVE_PLUGIN_DIR.'includes/forms/functions.php'; |
|
290 | + require_once GIVE_PLUGIN_DIR.'includes/forms/template.php'; |
|
291 | + require_once GIVE_PLUGIN_DIR.'includes/forms/widget.php'; |
|
292 | + require_once GIVE_PLUGIN_DIR.'includes/shortcodes.php'; |
|
293 | + require_once GIVE_PLUGIN_DIR.'includes/formatting.php'; |
|
294 | + require_once GIVE_PLUGIN_DIR.'includes/price-functions.php'; |
|
295 | + require_once GIVE_PLUGIN_DIR.'includes/error-tracking.php'; |
|
296 | + require_once GIVE_PLUGIN_DIR.'includes/process-purchase.php'; |
|
297 | + require_once GIVE_PLUGIN_DIR.'includes/login-register.php'; |
|
298 | + require_once GIVE_PLUGIN_DIR.'includes/user-functions.php'; |
|
299 | + require_once GIVE_PLUGIN_DIR.'includes/plugin-compatibility.php'; |
|
300 | + require_once GIVE_PLUGIN_DIR.'includes/deprecated-functions.php'; |
|
301 | + |
|
302 | + require_once GIVE_PLUGIN_DIR.'includes/payments/functions.php'; |
|
303 | + require_once GIVE_PLUGIN_DIR.'includes/payments/actions.php'; |
|
304 | + require_once GIVE_PLUGIN_DIR.'includes/payments/class-payment-stats.php'; |
|
305 | + require_once GIVE_PLUGIN_DIR.'includes/payments/class-payments-query.php'; |
|
306 | + require_once GIVE_PLUGIN_DIR.'includes/payments/class-give-payment.php'; |
|
307 | + |
|
308 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/functions.php'; |
|
309 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/actions.php'; |
|
310 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/paypal-standard.php'; |
|
311 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/offline-donations.php'; |
|
312 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/manual.php'; |
|
313 | + |
|
314 | + require_once GIVE_PLUGIN_DIR.'includes/emails/class-give-emails.php'; |
|
315 | + require_once GIVE_PLUGIN_DIR.'includes/emails/class-give-email-tags.php'; |
|
316 | + require_once GIVE_PLUGIN_DIR.'includes/emails/functions.php'; |
|
317 | + require_once GIVE_PLUGIN_DIR.'includes/emails/template.php'; |
|
318 | + require_once GIVE_PLUGIN_DIR.'includes/emails/actions.php'; |
|
319 | + |
|
320 | + if (is_admin() || (defined('WP_CLI') && WP_CLI)) { |
|
321 | + |
|
322 | + require_once GIVE_PLUGIN_DIR.'includes/admin/admin-footer.php'; |
|
323 | + require_once GIVE_PLUGIN_DIR.'includes/admin/welcome.php'; |
|
324 | + require_once GIVE_PLUGIN_DIR.'includes/admin/admin-pages.php'; |
|
325 | + require_once GIVE_PLUGIN_DIR.'includes/admin/class-admin-notices.php'; |
|
326 | + require_once GIVE_PLUGIN_DIR.'includes/admin/class-api-keys-table.php'; |
|
327 | + require_once GIVE_PLUGIN_DIR.'includes/admin/admin-actions.php'; |
|
328 | + require_once GIVE_PLUGIN_DIR.'includes/admin/system-info.php'; |
|
329 | + require_once GIVE_PLUGIN_DIR.'includes/admin/add-ons.php'; |
|
330 | + require_once GIVE_PLUGIN_DIR.'includes/admin/plugins.php'; |
|
331 | + require_once GIVE_PLUGIN_DIR.'includes/admin/dashboard-widgets.php'; |
|
332 | + |
|
333 | + require_once GIVE_PLUGIN_DIR.'includes/admin/payments/actions.php'; |
|
334 | + require_once GIVE_PLUGIN_DIR.'includes/admin/payments/payments-history.php'; |
|
335 | + |
|
336 | + require_once GIVE_PLUGIN_DIR.'includes/admin/customers/customers.php'; |
|
337 | + require_once GIVE_PLUGIN_DIR.'includes/admin/customers/customer-functions.php'; |
|
338 | + require_once GIVE_PLUGIN_DIR.'includes/admin/customers/customer-actions.php'; |
|
339 | + require_once GIVE_PLUGIN_DIR.'includes/admin/forms/metabox.php'; |
|
340 | + require_once GIVE_PLUGIN_DIR.'includes/admin/forms/dashboard-columns.php'; |
|
341 | + |
|
342 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/export-functions.php'; |
|
343 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/reports.php'; |
|
344 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/tools.php'; |
|
345 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/tools/tools-actions.php'; |
|
346 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/pdf-reports.php'; |
|
347 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/class-give-graph.php'; |
|
348 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/graphing.php'; |
|
349 | + |
|
350 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/abstract-shortcode-generator.php'; |
|
351 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/class-shortcode-button.php'; |
|
352 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-form.php'; |
|
353 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-goal.php'; |
|
354 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-login.php'; |
|
355 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-register.php'; |
|
356 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-profile-editor.php'; |
|
357 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-donation-history.php'; |
|
358 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-receipt.php'; |
|
359 | + |
|
360 | + require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrade-functions.php'; |
|
361 | + require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrades.php'; |
|
362 | 362 | |
363 | 363 | } |
364 | 364 | |
365 | - require_once GIVE_PLUGIN_DIR . 'includes/install.php'; |
|
365 | + require_once GIVE_PLUGIN_DIR.'includes/install.php'; |
|
366 | 366 | |
367 | 367 | } |
368 | 368 | |
@@ -375,26 +375,26 @@ discard block |
||
375 | 375 | */ |
376 | 376 | public function load_textdomain() { |
377 | 377 | // Set filter for Give's languages directory |
378 | - $give_lang_dir = dirname( plugin_basename( GIVE_PLUGIN_FILE ) ) . '/languages/'; |
|
379 | - $give_lang_dir = apply_filters( 'give_languages_directory', $give_lang_dir ); |
|
378 | + $give_lang_dir = dirname(plugin_basename(GIVE_PLUGIN_FILE)).'/languages/'; |
|
379 | + $give_lang_dir = apply_filters('give_languages_directory', $give_lang_dir); |
|
380 | 380 | |
381 | 381 | // Traditional WordPress plugin locale filter |
382 | - $locale = apply_filters( 'plugin_locale', get_locale(), 'give' ); |
|
383 | - $mofile = sprintf( '%1$s-%2$s.mo', 'give', $locale ); |
|
382 | + $locale = apply_filters('plugin_locale', get_locale(), 'give'); |
|
383 | + $mofile = sprintf('%1$s-%2$s.mo', 'give', $locale); |
|
384 | 384 | |
385 | 385 | // Setup paths to current locale file |
386 | - $mofile_local = $give_lang_dir . $mofile; |
|
387 | - $mofile_global = WP_LANG_DIR . '/give/' . $mofile; |
|
386 | + $mofile_local = $give_lang_dir.$mofile; |
|
387 | + $mofile_global = WP_LANG_DIR.'/give/'.$mofile; |
|
388 | 388 | |
389 | - if ( file_exists( $mofile_global ) ) { |
|
389 | + if (file_exists($mofile_global)) { |
|
390 | 390 | // Look in global /wp-content/languages/give folder |
391 | - load_textdomain( 'give', $mofile_global ); |
|
392 | - } elseif ( file_exists( $mofile_local ) ) { |
|
391 | + load_textdomain('give', $mofile_global); |
|
392 | + } elseif (file_exists($mofile_local)) { |
|
393 | 393 | // Look in local location from filter `give_languages_directory` |
394 | - load_textdomain( 'give', $mofile_local ); |
|
394 | + load_textdomain('give', $mofile_local); |
|
395 | 395 | } else { |
396 | 396 | // Load the default language files packaged up w/ Give |
397 | - load_plugin_textdomain( 'give', false, $give_lang_dir ); |
|
397 | + load_plugin_textdomain('give', false, $give_lang_dir); |
|
398 | 398 | } |
399 | 399 | } |
400 | 400 | } |
@@ -206,6 +206,7 @@ |
||
206 | 206 | * Set Donor Data |
207 | 207 | * |
208 | 208 | * @param $donor |
209 | + * @param integer $i |
|
209 | 210 | */ |
210 | 211 | private function set_donor_data( $i, $data, $donor ) { |
211 | 212 |
@@ -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 | |
@@ -46,16 +46,16 @@ discard block |
||
46 | 46 | * |
47 | 47 | * @param array $request The Form Data passed into the batch processing |
48 | 48 | */ |
49 | - public function set_properties( $request ) { |
|
49 | + public function set_properties($request) { |
|
50 | 50 | |
51 | 51 | //Set data from form submission |
52 | - if ( isset( $_POST['form'] ) ) { |
|
53 | - parse_str( $_POST['form'], $this->data ); |
|
52 | + if (isset($_POST['form'])) { |
|
53 | + parse_str($_POST['form'], $this->data); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | $this->form = $this->data['forms']; |
57 | 57 | |
58 | - $this->price_id = ! empty( $request['give_price_option'] ) && 0 !== $request['give_price_option'] ? absint( $request['give_price_option'] ) : null; |
|
58 | + $this->price_id = ! empty($request['give_price_option']) && 0 !== $request['give_price_option'] ? absint($request['give_price_option']) : null; |
|
59 | 59 | |
60 | 60 | } |
61 | 61 | |
@@ -70,36 +70,36 @@ discard block |
||
70 | 70 | |
71 | 71 | $cols = array(); |
72 | 72 | |
73 | - $columns = isset( $this->data['give_export_option'] ) ? $this->data['give_export_option'] : array(); |
|
73 | + $columns = isset($this->data['give_export_option']) ? $this->data['give_export_option'] : array(); |
|
74 | 74 | |
75 | - if ( empty( $columns ) ) { |
|
75 | + if (empty($columns)) { |
|
76 | 76 | return false; |
77 | 77 | } |
78 | - if ( ! empty( $columns['full_name'] ) ) { |
|
79 | - $cols['full_name'] = __( 'Full Name', 'give' ); |
|
78 | + if ( ! empty($columns['full_name'])) { |
|
79 | + $cols['full_name'] = __('Full Name', 'give'); |
|
80 | 80 | } |
81 | - if ( ! empty( $columns['email'] ) ) { |
|
82 | - $cols['email'] = __( 'Email Address', 'give' ); |
|
81 | + if ( ! empty($columns['email'])) { |
|
82 | + $cols['email'] = __('Email Address', 'give'); |
|
83 | 83 | } |
84 | - if ( ! empty( $columns['address'] ) ) { |
|
85 | - $cols['address_line1'] = __( 'Address', 'give' ); |
|
86 | - $cols['address_line2'] = __( 'Address (Line 2)', 'give' ); |
|
87 | - $cols['address_city'] = __( 'City', 'give' ); |
|
88 | - $cols['address_state'] = __( 'State', 'give' ); |
|
89 | - $cols['address_zip'] = __( 'Zip', 'give' ); |
|
90 | - $cols['address_country'] = __( 'Country', 'give' ); |
|
84 | + if ( ! empty($columns['address'])) { |
|
85 | + $cols['address_line1'] = __('Address', 'give'); |
|
86 | + $cols['address_line2'] = __('Address (Line 2)', 'give'); |
|
87 | + $cols['address_city'] = __('City', 'give'); |
|
88 | + $cols['address_state'] = __('State', 'give'); |
|
89 | + $cols['address_zip'] = __('Zip', 'give'); |
|
90 | + $cols['address_country'] = __('Country', 'give'); |
|
91 | 91 | } |
92 | - if ( ! empty( $columns['userid'] ) ) { |
|
93 | - $cols['userid'] = __( 'User ID', 'give' ); |
|
92 | + if ( ! empty($columns['userid'])) { |
|
93 | + $cols['userid'] = __('User ID', 'give'); |
|
94 | 94 | } |
95 | - if ( ! empty( $columns['date_first_donated'] ) ) { |
|
96 | - $cols['date_first_donated'] = __( 'First Donation Date', 'give' ); |
|
95 | + if ( ! empty($columns['date_first_donated'])) { |
|
96 | + $cols['date_first_donated'] = __('First Donation Date', 'give'); |
|
97 | 97 | } |
98 | - if ( ! empty( $columns['donations'] ) ) { |
|
99 | - $cols['donations'] = __( 'Number of Donations', 'give' ); |
|
98 | + if ( ! empty($columns['donations'])) { |
|
99 | + $cols['donations'] = __('Number of Donations', 'give'); |
|
100 | 100 | } |
101 | - if ( ! empty( $columns['donation_sum'] ) ) { |
|
102 | - $cols['donation_sum'] = __( 'Sum of Donations', 'give' ); |
|
101 | + if ( ! empty($columns['donation_sum'])) { |
|
102 | + $cols['donation_sum'] = __('Sum of Donations', 'give'); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | return $cols; |
@@ -119,20 +119,20 @@ discard block |
||
119 | 119 | |
120 | 120 | $i = 0; |
121 | 121 | |
122 | - if ( ! empty( $this->form ) ) { |
|
122 | + if ( ! empty($this->form)) { |
|
123 | 123 | |
124 | 124 | // Export donors of a specific product |
125 | 125 | global $give_logs; |
126 | 126 | |
127 | 127 | $args = array( |
128 | - 'post_parent' => absint( $this->form ), |
|
128 | + 'post_parent' => absint($this->form), |
|
129 | 129 | 'log_type' => 'sale', |
130 | 130 | 'posts_per_page' => 30, |
131 | 131 | 'paged' => $this->step |
132 | 132 | ); |
133 | 133 | |
134 | 134 | //Check for price option |
135 | - if ( null !== $this->price_id ) { |
|
135 | + if (null !== $this->price_id) { |
|
136 | 136 | $args['meta_query'] = array( |
137 | 137 | array( |
138 | 138 | 'key' => '_give_log_price_id', |
@@ -141,33 +141,33 @@ discard block |
||
141 | 141 | ); |
142 | 142 | } |
143 | 143 | |
144 | - $logs = $give_logs->get_connected_logs( $args ); |
|
144 | + $logs = $give_logs->get_connected_logs($args); |
|
145 | 145 | |
146 | - if ( $logs ) { |
|
147 | - foreach ( $logs as $log ) { |
|
148 | - $payment_id = get_post_meta( $log->ID, '_give_log_payment_id', true ); |
|
149 | - $payment = new Give_Payment( $payment_id ); |
|
150 | - $donor = Give()->customers->get_customer_by( 'id', $payment->customer_id ); |
|
151 | - $data[] = $this->set_donor_data( $i, $data, $donor ); |
|
152 | - $i ++; |
|
146 | + if ($logs) { |
|
147 | + foreach ($logs as $log) { |
|
148 | + $payment_id = get_post_meta($log->ID, '_give_log_payment_id', true); |
|
149 | + $payment = new Give_Payment($payment_id); |
|
150 | + $donor = Give()->customers->get_customer_by('id', $payment->customer_id); |
|
151 | + $data[] = $this->set_donor_data($i, $data, $donor); |
|
152 | + $i++; |
|
153 | 153 | } |
154 | 154 | } |
155 | 155 | |
156 | 156 | } else { |
157 | 157 | |
158 | 158 | // Export all customers |
159 | - $offset = 30 * ( $this->step - 1 ); |
|
160 | - $donors = Give()->customers->get_customers( array( 'number' => 30, 'offset' => $offset ) ); |
|
159 | + $offset = 30 * ($this->step - 1); |
|
160 | + $donors = Give()->customers->get_customers(array('number' => 30, 'offset' => $offset)); |
|
161 | 161 | |
162 | - foreach ( $donors as $donor ) { |
|
162 | + foreach ($donors as $donor) { |
|
163 | 163 | |
164 | - $data[] = $this->set_donor_data( $i, $data, $donor ); |
|
165 | - $i ++; |
|
164 | + $data[] = $this->set_donor_data($i, $data, $donor); |
|
165 | + $i++; |
|
166 | 166 | } |
167 | 167 | } |
168 | 168 | |
169 | - $data = apply_filters( 'give_export_get_data', $data ); |
|
170 | - $data = apply_filters( 'give_export_get_data_' . $this->export_type, $data ); |
|
169 | + $data = apply_filters('give_export_get_data', $data); |
|
170 | + $data = apply_filters('give_export_get_data_'.$this->export_type, $data); |
|
171 | 171 | |
172 | 172 | return $data; |
173 | 173 | } |
@@ -183,19 +183,19 @@ discard block |
||
183 | 183 | $percentage = 0; |
184 | 184 | |
185 | 185 | // We can't count the number when getting them for a specific form |
186 | - if ( empty( $this->form ) ) { |
|
186 | + if (empty($this->form)) { |
|
187 | 187 | |
188 | 188 | $total = Give()->customers->count(); |
189 | 189 | |
190 | - if ( $total > 0 ) { |
|
190 | + if ($total > 0) { |
|
191 | 191 | |
192 | - $percentage = ( ( 30 * $this->step ) / $total ) * 100; |
|
192 | + $percentage = ((30 * $this->step) / $total) * 100; |
|
193 | 193 | |
194 | 194 | } |
195 | 195 | |
196 | 196 | } |
197 | 197 | |
198 | - if ( $percentage > 100 ) { |
|
198 | + if ($percentage > 100) { |
|
199 | 199 | $percentage = 100; |
200 | 200 | } |
201 | 201 | |
@@ -207,46 +207,46 @@ discard block |
||
207 | 207 | * |
208 | 208 | * @param $donor |
209 | 209 | */ |
210 | - private function set_donor_data( $i, $data, $donor ) { |
|
210 | + private function set_donor_data($i, $data, $donor) { |
|
211 | 211 | |
212 | 212 | $columns = $this->csv_cols(); |
213 | 213 | |
214 | 214 | //Set address variable |
215 | 215 | $address = ''; |
216 | - if ( isset( $donor->user_id ) && $donor->user_id > 0 ) { |
|
217 | - $address = give_get_donor_address( $donor->user_id ); |
|
216 | + if (isset($donor->user_id) && $donor->user_id > 0) { |
|
217 | + $address = give_get_donor_address($donor->user_id); |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | //Set columns |
221 | - if ( ! empty( $columns['full_name'] ) ) { |
|
222 | - $data[ $i ]['full_name'] = $donor->name; |
|
221 | + if ( ! empty($columns['full_name'])) { |
|
222 | + $data[$i]['full_name'] = $donor->name; |
|
223 | 223 | } |
224 | - if ( ! empty( $columns['email'] ) ) { |
|
225 | - $data[ $i ]['email'] = $donor->email; |
|
224 | + if ( ! empty($columns['email'])) { |
|
225 | + $data[$i]['email'] = $donor->email; |
|
226 | 226 | } |
227 | - if ( ! empty( $columns['address_line1'] ) ) { |
|
227 | + if ( ! empty($columns['address_line1'])) { |
|
228 | 228 | |
229 | - $data[ $i ]['address_line1'] = isset( $address['line1'] ) ? $address['line1'] : ''; |
|
230 | - $data[ $i ]['address_line2'] = isset( $address['line2'] ) ? $address['line2'] : ''; |
|
231 | - $data[ $i ]['address_city'] = isset( $address['city'] ) ? $address['city'] : ''; |
|
232 | - $data[ $i ]['address_state'] = isset( $address['state'] ) ? $address['state'] : ''; |
|
233 | - $data[ $i ]['address_zip'] = isset( $address['zip'] ) ? $address['zip'] : ''; |
|
234 | - $data[ $i ]['address_country'] = isset( $address['country'] ) ? $address['country'] : ''; |
|
229 | + $data[$i]['address_line1'] = isset($address['line1']) ? $address['line1'] : ''; |
|
230 | + $data[$i]['address_line2'] = isset($address['line2']) ? $address['line2'] : ''; |
|
231 | + $data[$i]['address_city'] = isset($address['city']) ? $address['city'] : ''; |
|
232 | + $data[$i]['address_state'] = isset($address['state']) ? $address['state'] : ''; |
|
233 | + $data[$i]['address_zip'] = isset($address['zip']) ? $address['zip'] : ''; |
|
234 | + $data[$i]['address_country'] = isset($address['country']) ? $address['country'] : ''; |
|
235 | 235 | } |
236 | - if ( ! empty( $columns['userid'] ) ) { |
|
237 | - $data[ $i ]['userid'] = ! empty( $donor->user_id ) ? $donor->user_id : ''; |
|
236 | + if ( ! empty($columns['userid'])) { |
|
237 | + $data[$i]['userid'] = ! empty($donor->user_id) ? $donor->user_id : ''; |
|
238 | 238 | } |
239 | - if ( ! empty( $columns['date_first_donated'] ) ) { |
|
240 | - $data[ $i ]['date_first_donated'] = date_i18n( get_option( 'date_format' ), strtotime( $donor->date_created ) ); |
|
239 | + if ( ! empty($columns['date_first_donated'])) { |
|
240 | + $data[$i]['date_first_donated'] = date_i18n(get_option('date_format'), strtotime($donor->date_created)); |
|
241 | 241 | } |
242 | - if ( ! empty( $columns['donations'] ) ) { |
|
243 | - $data[ $i ]['donations'] = $donor->purchase_count; |
|
242 | + if ( ! empty($columns['donations'])) { |
|
243 | + $data[$i]['donations'] = $donor->purchase_count; |
|
244 | 244 | } |
245 | - if ( ! empty( $columns['donation_sum'] ) ) { |
|
246 | - $data[ $i ]['donation_sum'] = give_format_amount( $donor->purchase_value ); |
|
245 | + if ( ! empty($columns['donation_sum'])) { |
|
246 | + $data[$i]['donation_sum'] = give_format_amount($donor->purchase_value); |
|
247 | 247 | } |
248 | 248 | |
249 | - return $data[ $i ]; |
|
249 | + return $data[$i]; |
|
250 | 250 | |
251 | 251 | } |
252 | 252 |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | */ |
24 | 24 | |
25 | 25 | // Exit if accessed directly |
26 | -if ( ! defined( 'ABSPATH' ) ) { |
|
26 | +if ( ! defined('ABSPATH')) { |
|
27 | 27 | exit; |
28 | 28 | } |
29 | 29 | |
@@ -54,9 +54,9 @@ discard block |
||
54 | 54 | * @param string $tag Email tag to be replace in email |
55 | 55 | * @param callable $func Hook to run when email tag is found |
56 | 56 | */ |
57 | - public function add( $tag, $description, $func ) { |
|
58 | - if ( is_callable( $func ) ) { |
|
59 | - $this->tags[ $tag ] = array( |
|
57 | + public function add($tag, $description, $func) { |
|
58 | + if (is_callable($func)) { |
|
59 | + $this->tags[$tag] = array( |
|
60 | 60 | 'tag' => $tag, |
61 | 61 | 'description' => $description, |
62 | 62 | 'func' => $func |
@@ -71,8 +71,8 @@ discard block |
||
71 | 71 | * |
72 | 72 | * @param string $tag Email tag to remove hook from |
73 | 73 | */ |
74 | - public function remove( $tag ) { |
|
75 | - unset( $this->tags[ $tag ] ); |
|
74 | + public function remove($tag) { |
|
75 | + unset($this->tags[$tag]); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
@@ -84,8 +84,8 @@ discard block |
||
84 | 84 | * |
85 | 85 | * @return bool |
86 | 86 | */ |
87 | - public function email_tag_exists( $tag ) { |
|
88 | - return array_key_exists( $tag, $this->tags ); |
|
87 | + public function email_tag_exists($tag) { |
|
88 | + return array_key_exists($tag, $this->tags); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | /** |
@@ -109,16 +109,16 @@ discard block |
||
109 | 109 | * |
110 | 110 | * @return string Content with email tags filtered out. |
111 | 111 | */ |
112 | - public function do_tags( $content, $payment_id ) { |
|
112 | + public function do_tags($content, $payment_id) { |
|
113 | 113 | |
114 | 114 | // Check if there is atleast one tag added |
115 | - if ( empty( $this->tags ) || ! is_array( $this->tags ) ) { |
|
115 | + if (empty($this->tags) || ! is_array($this->tags)) { |
|
116 | 116 | return $content; |
117 | 117 | } |
118 | 118 | |
119 | 119 | $this->payment_id = $payment_id; |
120 | 120 | |
121 | - $new_content = preg_replace_callback( "/{([A-z0-9\-\_]+)}/s", array( $this, 'do_tag' ), $content ); |
|
121 | + $new_content = preg_replace_callback("/{([A-z0-9\-\_]+)}/s", array($this, 'do_tag'), $content); |
|
122 | 122 | |
123 | 123 | $this->payment_id = null; |
124 | 124 | |
@@ -134,17 +134,17 @@ discard block |
||
134 | 134 | * |
135 | 135 | * @return mixed |
136 | 136 | */ |
137 | - public function do_tag( $m ) { |
|
137 | + public function do_tag($m) { |
|
138 | 138 | |
139 | 139 | // Get tag |
140 | 140 | $tag = $m[1]; |
141 | 141 | |
142 | 142 | // Return tag if tag not set |
143 | - if ( ! $this->email_tag_exists( $tag ) ) { |
|
143 | + if ( ! $this->email_tag_exists($tag)) { |
|
144 | 144 | return $m[0]; |
145 | 145 | } |
146 | 146 | |
147 | - return call_user_func( $this->tags[ $tag ]['func'], $this->payment_id, $tag ); |
|
147 | + return call_user_func($this->tags[$tag]['func'], $this->payment_id, $tag); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | } |
@@ -158,8 +158,8 @@ discard block |
||
158 | 158 | * @param string $description Description of the email tag added |
159 | 159 | * @param callable $func Hook to run when email tag is found |
160 | 160 | */ |
161 | -function give_add_email_tag( $tag, $description, $func ) { |
|
162 | - Give()->email_tags->add( $tag, $description, $func ); |
|
161 | +function give_add_email_tag($tag, $description, $func) { |
|
162 | + Give()->email_tags->add($tag, $description, $func); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | /** |
@@ -169,8 +169,8 @@ discard block |
||
169 | 169 | * |
170 | 170 | * @param string $tag Email tag to remove hook from |
171 | 171 | */ |
172 | -function give_remove_email_tag( $tag ) { |
|
173 | - Give()->email_tags->remove( $tag ); |
|
172 | +function give_remove_email_tag($tag) { |
|
173 | + Give()->email_tags->remove($tag); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | /** |
@@ -182,8 +182,8 @@ discard block |
||
182 | 182 | * |
183 | 183 | * @return bool |
184 | 184 | */ |
185 | -function give_email_tag_exists( $tag ) { |
|
186 | - return Give()->email_tags->email_tag_exists( $tag ); |
|
185 | +function give_email_tag_exists($tag) { |
|
186 | + return Give()->email_tags->email_tag_exists($tag); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | /** |
@@ -212,13 +212,13 @@ discard block |
||
212 | 212 | $email_tags = give_get_email_tags(); |
213 | 213 | |
214 | 214 | // Check |
215 | - if ( count( $email_tags ) > 0 ) { |
|
215 | + if (count($email_tags) > 0) { |
|
216 | 216 | |
217 | 217 | // Loop |
218 | - foreach ( $email_tags as $email_tag ) { |
|
218 | + foreach ($email_tags as $email_tag) { |
|
219 | 219 | |
220 | 220 | // Add email tag to list |
221 | - $list .= '<code>{' . $email_tag['tag'] . '}</code> - ' . $email_tag['description'] . '<br/>'; |
|
221 | + $list .= '<code>{'.$email_tag['tag'].'}</code> - '.$email_tag['description'].'<br/>'; |
|
222 | 222 | |
223 | 223 | } |
224 | 224 | |
@@ -238,13 +238,13 @@ discard block |
||
238 | 238 | * |
239 | 239 | * @return string Content with email tags filtered out. |
240 | 240 | */ |
241 | -function give_do_email_tags( $content, $payment_id ) { |
|
241 | +function give_do_email_tags($content, $payment_id) { |
|
242 | 242 | |
243 | 243 | // Replace all tags |
244 | - $content = Give()->email_tags->do_tags( $content, $payment_id ); |
|
244 | + $content = Give()->email_tags->do_tags($content, $payment_id); |
|
245 | 245 | |
246 | 246 | // Maintaining backwards compatibility |
247 | - $content = apply_filters( 'give_email_template_tags', $content, give_get_payment_meta( $payment_id ), $payment_id ); |
|
247 | + $content = apply_filters('give_email_template_tags', $content, give_get_payment_meta($payment_id), $payment_id); |
|
248 | 248 | |
249 | 249 | // Return content |
250 | 250 | return $content; |
@@ -256,10 +256,10 @@ discard block |
||
256 | 256 | * @since 1.0 |
257 | 257 | */ |
258 | 258 | function give_load_email_tags() { |
259 | - do_action( 'give_add_email_tags' ); |
|
259 | + do_action('give_add_email_tags'); |
|
260 | 260 | } |
261 | 261 | |
262 | -add_action( 'init', 'give_load_email_tags', - 999 ); |
|
262 | +add_action('init', 'give_load_email_tags', - 999); |
|
263 | 263 | |
264 | 264 | /** |
265 | 265 | * Add default Give email template tags |
@@ -272,82 +272,82 @@ discard block |
||
272 | 272 | $email_tags = array( |
273 | 273 | array( |
274 | 274 | 'tag' => 'donation', |
275 | - 'description' => __( 'The name of completed donation form and the donation level chosen if applicable.', 'give' ), |
|
275 | + 'description' => __('The name of completed donation form and the donation level chosen if applicable.', 'give'), |
|
276 | 276 | 'function' => 'give_email_tag_donation' |
277 | 277 | ), |
278 | 278 | array( |
279 | 279 | 'tag' => 'name', |
280 | - 'description' => __( 'The donor\'s first name', 'give' ), |
|
280 | + 'description' => __('The donor\'s first name', 'give'), |
|
281 | 281 | 'function' => 'give_email_tag_first_name' |
282 | 282 | ), |
283 | 283 | array( |
284 | 284 | 'tag' => 'fullname', |
285 | - 'description' => __( 'The donor\'s full name, first and last', 'give' ), |
|
285 | + 'description' => __('The donor\'s full name, first and last', 'give'), |
|
286 | 286 | 'function' => 'give_email_tag_fullname' |
287 | 287 | ), |
288 | 288 | array( |
289 | 289 | 'tag' => 'username', |
290 | - 'description' => __( 'The donor\'s user name on the site, if they registered an account', 'give' ), |
|
290 | + 'description' => __('The donor\'s user name on the site, if they registered an account', 'give'), |
|
291 | 291 | 'function' => 'give_email_tag_username' |
292 | 292 | ), |
293 | 293 | array( |
294 | 294 | 'tag' => 'user_email', |
295 | - 'description' => __( 'The donor\'s email address', 'give' ), |
|
295 | + 'description' => __('The donor\'s email address', 'give'), |
|
296 | 296 | 'function' => 'give_email_tag_user_email' |
297 | 297 | ), |
298 | 298 | array( |
299 | 299 | 'tag' => 'billing_address', |
300 | - 'description' => __( 'The donor\'s billing address', 'give' ), |
|
300 | + 'description' => __('The donor\'s billing address', 'give'), |
|
301 | 301 | 'function' => 'give_email_tag_billing_address' |
302 | 302 | ), |
303 | 303 | array( |
304 | 304 | 'tag' => 'date', |
305 | - 'description' => __( 'The date of the donation', 'give' ), |
|
305 | + 'description' => __('The date of the donation', 'give'), |
|
306 | 306 | 'function' => 'give_email_tag_date' |
307 | 307 | ), |
308 | 308 | array( |
309 | 309 | 'tag' => 'price', |
310 | - 'description' => __( 'The total price of the donation', 'give' ), |
|
310 | + 'description' => __('The total price of the donation', 'give'), |
|
311 | 311 | 'function' => 'give_email_tag_price' |
312 | 312 | ), |
313 | 313 | array( |
314 | 314 | 'tag' => 'payment_id', |
315 | - 'description' => __( 'The unique ID number for this donation', 'give' ), |
|
315 | + 'description' => __('The unique ID number for this donation', 'give'), |
|
316 | 316 | 'function' => 'give_email_tag_payment_id' |
317 | 317 | ), |
318 | 318 | array( |
319 | 319 | 'tag' => 'receipt_id', |
320 | - 'description' => __( 'The unique ID number for this donation receipt', 'give' ), |
|
320 | + 'description' => __('The unique ID number for this donation receipt', 'give'), |
|
321 | 321 | 'function' => 'give_email_tag_receipt_id' |
322 | 322 | ), |
323 | 323 | array( |
324 | 324 | 'tag' => 'payment_method', |
325 | - 'description' => __( 'The method of payment used for this donation', 'give' ), |
|
325 | + 'description' => __('The method of payment used for this donation', 'give'), |
|
326 | 326 | 'function' => 'give_email_tag_payment_method' |
327 | 327 | ), |
328 | 328 | array( |
329 | 329 | 'tag' => 'sitename', |
330 | - 'description' => __( 'Your site name', 'give' ), |
|
330 | + 'description' => __('Your site name', 'give'), |
|
331 | 331 | 'function' => 'give_email_tag_sitename' |
332 | 332 | ), |
333 | 333 | array( |
334 | 334 | 'tag' => 'receipt_link', |
335 | - 'description' => __( 'Adds a link so users can view their receipt directly on your website if they are unable to view it in the browser correctly.', 'give' ), |
|
335 | + 'description' => __('Adds a link so users can view their receipt directly on your website if they are unable to view it in the browser correctly.', 'give'), |
|
336 | 336 | 'function' => 'give_email_tag_receipt_link' |
337 | 337 | ), |
338 | 338 | ); |
339 | 339 | |
340 | 340 | // Apply give_email_tags filter |
341 | - $email_tags = apply_filters( 'give_email_tags', $email_tags ); |
|
341 | + $email_tags = apply_filters('give_email_tags', $email_tags); |
|
342 | 342 | |
343 | 343 | // Add email tags |
344 | - foreach ( $email_tags as $email_tag ) { |
|
345 | - give_add_email_tag( $email_tag['tag'], $email_tag['description'], $email_tag['function'] ); |
|
344 | + foreach ($email_tags as $email_tag) { |
|
345 | + give_add_email_tag($email_tag['tag'], $email_tag['description'], $email_tag['function']); |
|
346 | 346 | } |
347 | 347 | |
348 | 348 | } |
349 | 349 | |
350 | -add_action( 'give_add_email_tags', 'give_setup_email_tags' ); |
|
350 | +add_action('give_add_email_tags', 'give_setup_email_tags'); |
|
351 | 351 | |
352 | 352 | |
353 | 353 | /** |
@@ -358,15 +358,15 @@ discard block |
||
358 | 358 | * |
359 | 359 | * @return string name |
360 | 360 | */ |
361 | -function give_email_tag_first_name( $payment_id ) { |
|
362 | - $payment = new Give_Payment( $payment_id ); |
|
361 | +function give_email_tag_first_name($payment_id) { |
|
362 | + $payment = new Give_Payment($payment_id); |
|
363 | 363 | $user_info = $payment->user_info; |
364 | 364 | |
365 | - if ( empty( $user_info ) ) { |
|
365 | + if (empty($user_info)) { |
|
366 | 366 | return ''; |
367 | 367 | } |
368 | 368 | |
369 | - $email_name = give_get_email_names( $user_info ); |
|
369 | + $email_name = give_get_email_names($user_info); |
|
370 | 370 | |
371 | 371 | return $email_name['name']; |
372 | 372 | } |
@@ -379,15 +379,15 @@ discard block |
||
379 | 379 | * |
380 | 380 | * @return string fullname |
381 | 381 | */ |
382 | -function give_email_tag_fullname( $payment_id ) { |
|
383 | - $payment = new Give_Payment( $payment_id ); |
|
382 | +function give_email_tag_fullname($payment_id) { |
|
383 | + $payment = new Give_Payment($payment_id); |
|
384 | 384 | $user_info = $payment->user_info; |
385 | 385 | |
386 | - if ( empty( $user_info ) ) { |
|
386 | + if (empty($user_info)) { |
|
387 | 387 | return ''; |
388 | 388 | } |
389 | 389 | |
390 | - $email_name = give_get_email_names( $user_info ); |
|
390 | + $email_name = give_get_email_names($user_info); |
|
391 | 391 | |
392 | 392 | return $email_name['fullname']; |
393 | 393 | } |
@@ -400,15 +400,15 @@ discard block |
||
400 | 400 | * |
401 | 401 | * @return string username |
402 | 402 | */ |
403 | -function give_email_tag_username( $payment_id ) { |
|
404 | - $payment = new Give_Payment( $payment_id ); |
|
403 | +function give_email_tag_username($payment_id) { |
|
404 | + $payment = new Give_Payment($payment_id); |
|
405 | 405 | $user_info = $payment->user_info; |
406 | 406 | |
407 | - if ( empty( $user_info ) ) { |
|
407 | + if (empty($user_info)) { |
|
408 | 408 | return ''; |
409 | 409 | } |
410 | 410 | |
411 | - $email_name = give_get_email_names( $user_info ); |
|
411 | + $email_name = give_get_email_names($user_info); |
|
412 | 412 | |
413 | 413 | return $email_name['username']; |
414 | 414 | } |
@@ -421,8 +421,8 @@ discard block |
||
421 | 421 | * |
422 | 422 | * @return string user_email |
423 | 423 | */ |
424 | -function give_email_tag_user_email( $payment_id ) { |
|
425 | - $payment = new Give_Payment( $payment_id ); |
|
424 | +function give_email_tag_user_email($payment_id) { |
|
425 | + $payment = new Give_Payment($payment_id); |
|
426 | 426 | |
427 | 427 | return $payment->email; |
428 | 428 | } |
@@ -435,10 +435,10 @@ discard block |
||
435 | 435 | * |
436 | 436 | * @return string billing_address |
437 | 437 | */ |
438 | -function give_email_tag_billing_address( $payment_id ) { |
|
438 | +function give_email_tag_billing_address($payment_id) { |
|
439 | 439 | |
440 | - $user_info = give_get_payment_meta_user_info( $payment_id ); |
|
441 | - $user_address = ! empty( $user_info['address'] ) ? $user_info['address'] : array( |
|
440 | + $user_info = give_get_payment_meta_user_info($payment_id); |
|
441 | + $user_address = ! empty($user_info['address']) ? $user_info['address'] : array( |
|
442 | 442 | 'line1' => '', |
443 | 443 | 'line2' => '', |
444 | 444 | 'city' => '', |
@@ -447,11 +447,11 @@ discard block |
||
447 | 447 | 'zip' => '' |
448 | 448 | ); |
449 | 449 | |
450 | - $return = $user_address['line1'] . "\n"; |
|
451 | - if ( ! empty( $user_address['line2'] ) ) { |
|
452 | - $return .= $user_address['line2'] . "\n"; |
|
450 | + $return = $user_address['line1']."\n"; |
|
451 | + if ( ! empty($user_address['line2'])) { |
|
452 | + $return .= $user_address['line2']."\n"; |
|
453 | 453 | } |
454 | - $return .= $user_address['city'] . ' ' . $user_address['zip'] . ' ' . $user_address['state'] . "\n"; |
|
454 | + $return .= $user_address['city'].' '.$user_address['zip'].' '.$user_address['state']."\n"; |
|
455 | 455 | $return .= $user_address['country']; |
456 | 456 | |
457 | 457 | return $return; |
@@ -465,10 +465,10 @@ discard block |
||
465 | 465 | * |
466 | 466 | * @return string date |
467 | 467 | */ |
468 | -function give_email_tag_date( $payment_id ) { |
|
469 | - $payment = new Give_Payment( $payment_id ); |
|
468 | +function give_email_tag_date($payment_id) { |
|
469 | + $payment = new Give_Payment($payment_id); |
|
470 | 470 | |
471 | - return date_i18n( get_option( 'date_format' ), strtotime( $payment->date ) ); |
|
471 | + return date_i18n(get_option('date_format'), strtotime($payment->date)); |
|
472 | 472 | } |
473 | 473 | |
474 | 474 | /** |
@@ -479,11 +479,11 @@ discard block |
||
479 | 479 | * |
480 | 480 | * @return string price |
481 | 481 | */ |
482 | -function give_email_tag_price( $payment_id ) { |
|
483 | - $payment = new Give_Payment( $payment_id ); |
|
484 | - $price = give_currency_filter( give_format_amount( $payment->total ), $payment->currency ); |
|
482 | +function give_email_tag_price($payment_id) { |
|
483 | + $payment = new Give_Payment($payment_id); |
|
484 | + $price = give_currency_filter(give_format_amount($payment->total), $payment->currency); |
|
485 | 485 | |
486 | - return html_entity_decode( $price, ENT_COMPAT, 'UTF-8' ); |
|
486 | + return html_entity_decode($price, ENT_COMPAT, 'UTF-8'); |
|
487 | 487 | } |
488 | 488 | |
489 | 489 | /** |
@@ -494,8 +494,8 @@ discard block |
||
494 | 494 | * |
495 | 495 | * @return int payment_id |
496 | 496 | */ |
497 | -function give_email_tag_payment_id( $payment_id ) { |
|
498 | - $payment = new Give_Payment( $payment_id ); |
|
497 | +function give_email_tag_payment_id($payment_id) { |
|
498 | + $payment = new Give_Payment($payment_id); |
|
499 | 499 | |
500 | 500 | return $payment->number; |
501 | 501 | } |
@@ -508,8 +508,8 @@ discard block |
||
508 | 508 | * |
509 | 509 | * @return string receipt_id |
510 | 510 | */ |
511 | -function give_email_tag_receipt_id( $payment_id ) { |
|
512 | - $payment = new Give_Payment( $payment_id ); |
|
511 | +function give_email_tag_receipt_id($payment_id) { |
|
512 | + $payment = new Give_Payment($payment_id); |
|
513 | 513 | |
514 | 514 | return $payment->key; |
515 | 515 | } |
@@ -523,11 +523,11 @@ discard block |
||
523 | 523 | * |
524 | 524 | * @return string $form_title |
525 | 525 | */ |
526 | -function give_email_tag_donation( $payment_id ) { |
|
527 | - $payment = new Give_Payment( $payment_id ); |
|
528 | - $form_title = give_get_payment_form_title( $payment->meta, false, '-' ); |
|
526 | +function give_email_tag_donation($payment_id) { |
|
527 | + $payment = new Give_Payment($payment_id); |
|
528 | + $form_title = give_get_payment_form_title($payment->meta, false, '-'); |
|
529 | 529 | |
530 | - return ! empty( $form_title ) ? $form_title : __( 'There was an error retrieving this donation title', 'give' ); |
|
530 | + return ! empty($form_title) ? $form_title : __('There was an error retrieving this donation title', 'give'); |
|
531 | 531 | |
532 | 532 | } |
533 | 533 | |
@@ -539,10 +539,10 @@ discard block |
||
539 | 539 | * |
540 | 540 | * @return string gateway |
541 | 541 | */ |
542 | -function give_email_tag_payment_method( $payment_id ) { |
|
543 | - $payment = new Give_Payment( $payment_id ); |
|
542 | +function give_email_tag_payment_method($payment_id) { |
|
543 | + $payment = new Give_Payment($payment_id); |
|
544 | 544 | |
545 | - return give_get_gateway_checkout_label( $payment->gateway ); |
|
545 | + return give_get_gateway_checkout_label($payment->gateway); |
|
546 | 546 | } |
547 | 547 | |
548 | 548 | /** |
@@ -553,8 +553,8 @@ discard block |
||
553 | 553 | * |
554 | 554 | * @return string sitename |
555 | 555 | */ |
556 | -function give_email_tag_sitename( $payment_id ) { |
|
557 | - return wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ); |
|
556 | +function give_email_tag_sitename($payment_id) { |
|
557 | + return wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES); |
|
558 | 558 | } |
559 | 559 | |
560 | 560 | /** |
@@ -566,15 +566,15 @@ discard block |
||
566 | 566 | * |
567 | 567 | * @return string receipt_link |
568 | 568 | */ |
569 | -function give_email_tag_receipt_link( $payment_id ) { |
|
569 | +function give_email_tag_receipt_link($payment_id) { |
|
570 | 570 | |
571 | - $receipt_url = esc_url( add_query_arg( array( |
|
572 | - 'payment_key' => give_get_payment_key( $payment_id ), |
|
571 | + $receipt_url = esc_url(add_query_arg(array( |
|
572 | + 'payment_key' => give_get_payment_key($payment_id), |
|
573 | 573 | 'give_action' => 'view_receipt' |
574 | - ), home_url() ) ); |
|
575 | - $formatted = sprintf( __( '%1$sView it in your browser %2$s', 'give' ), '<a href="' . $receipt_url . '">', '»</a>' ); |
|
574 | + ), home_url())); |
|
575 | + $formatted = sprintf(__('%1$sView it in your browser %2$s', 'give'), '<a href="'.$receipt_url.'">', '»</a>'); |
|
576 | 576 | |
577 | - if ( give_get_option( 'email_template' ) !== 'none' ) { |
|
577 | + if (give_get_option('email_template') !== 'none') { |
|
578 | 578 | return $formatted; |
579 | 579 | } else { |
580 | 580 | return $receipt_url; |