@@ -1,14 +1,14 @@ discard block |
||
1 | 1 | <div id="give-db-updates" data-resume-update="0"> |
2 | 2 | <div class="postbox-container"> |
3 | 3 | <div class="postbox"> |
4 | - <h2 class="hndle"><?php esc_html_e( 'Database Updates', 'give' ); ?></h2> |
|
4 | + <h2 class="hndle"><?php esc_html_e('Database Updates', 'give'); ?></h2> |
|
5 | 5 | <div class="inside"> |
6 | 6 | <div class="progress-container"> |
7 | - <p class="update-message"><strong><?php esc_html_e( 'Updates Completed.', 'give' ) ?></strong></p> |
|
7 | + <p class="update-message"><strong><?php esc_html_e('Updates Completed.', 'give') ?></strong></p> |
|
8 | 8 | <div class="progress-content"> |
9 | 9 | <div class="notice-wrap give-clearfix"> |
10 | 10 | <div class="notice notice-success is-dismissible inline"> |
11 | - <p><?php esc_html_e( 'Give database updates completed successfully. Thank you for updating to the latest version!', 'give' ) ?> |
|
11 | + <p><?php esc_html_e('Give database updates completed successfully. Thank you for updating to the latest version!', 'give') ?> |
|
12 | 12 | </p> |
13 | 13 | <button type="button" class="notice-dismiss"></button> |
14 | 14 | </div> |
@@ -20,4 +20,4 @@ discard block |
||
20 | 20 | </div><!-- .postbox --> |
21 | 21 | </div> |
22 | 22 | </div> |
23 | -<?php delete_option( 'give_show_db_upgrade_complete_notice' ); ?> |
|
24 | 23 | \ No newline at end of file |
24 | +<?php delete_option('give_show_db_upgrade_complete_notice'); ?> |
|
25 | 25 | \ 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 | |
@@ -93,19 +93,19 @@ discard block |
||
93 | 93 | */ |
94 | 94 | public function get_predefined_dates() { |
95 | 95 | $predefined = array( |
96 | - 'today' => esc_html__( 'Today', 'give' ), |
|
97 | - 'yesterday' => esc_html__( 'Yesterday', 'give' ), |
|
98 | - 'this_week' => esc_html__( 'This Week', 'give' ), |
|
99 | - 'last_week' => esc_html__( 'Last Week', 'give' ), |
|
100 | - 'this_month' => esc_html__( 'This Month', 'give' ), |
|
101 | - 'last_month' => esc_html__( 'Last Month', 'give' ), |
|
102 | - 'this_quarter' => esc_html__( 'This Quarter', 'give' ), |
|
103 | - 'last_quarter' => esc_html__( 'Last Quarter', 'give' ), |
|
104 | - 'this_year' => esc_html__( 'This Year', 'give' ), |
|
105 | - 'last_year' => esc_html__( 'Last Year', 'give' ), |
|
96 | + 'today' => esc_html__('Today', 'give'), |
|
97 | + 'yesterday' => esc_html__('Yesterday', 'give'), |
|
98 | + 'this_week' => esc_html__('This Week', 'give'), |
|
99 | + 'last_week' => esc_html__('Last Week', 'give'), |
|
100 | + 'this_month' => esc_html__('This Month', 'give'), |
|
101 | + 'last_month' => esc_html__('Last Month', 'give'), |
|
102 | + 'this_quarter' => esc_html__('This Quarter', 'give'), |
|
103 | + 'last_quarter' => esc_html__('Last Quarter', 'give'), |
|
104 | + 'this_year' => esc_html__('This Year', 'give'), |
|
105 | + 'last_year' => esc_html__('Last Year', 'give'), |
|
106 | 106 | ); |
107 | 107 | |
108 | - return apply_filters( 'give_stats_predefined_dates', $predefined ); |
|
108 | + return apply_filters('give_stats_predefined_dates', $predefined); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
@@ -121,18 +121,18 @@ discard block |
||
121 | 121 | * |
122 | 122 | * @return void |
123 | 123 | */ |
124 | - public function setup_dates( $_start_date = 'this_month', $_end_date = false ) { |
|
124 | + public function setup_dates($_start_date = 'this_month', $_end_date = false) { |
|
125 | 125 | |
126 | - if ( empty( $_start_date ) ) { |
|
126 | + if (empty($_start_date)) { |
|
127 | 127 | $_start_date = 'this_month'; |
128 | 128 | } |
129 | 129 | |
130 | - if ( empty( $_end_date ) ) { |
|
130 | + if (empty($_end_date)) { |
|
131 | 131 | $_end_date = $_start_date; |
132 | 132 | } |
133 | 133 | |
134 | - $this->start_date = $this->convert_date( $_start_date ); |
|
135 | - $this->end_date = $this->convert_date( $_end_date, true ); |
|
134 | + $this->start_date = $this->convert_date($_start_date); |
|
135 | + $this->end_date = $this->convert_date($_end_date, true); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
@@ -148,26 +148,26 @@ discard block |
||
148 | 148 | * |
149 | 149 | * @return array|WP_Error If the date is invalid, a WP_Error object will be returned. |
150 | 150 | */ |
151 | - public function convert_date( $date, $end_date = false ) { |
|
151 | + public function convert_date($date, $end_date = false) { |
|
152 | 152 | |
153 | 153 | $this->timestamp = false; |
154 | 154 | $second = $end_date ? 59 : 0; |
155 | 155 | $minute = $end_date ? 59 : 0; |
156 | 156 | $hour = $end_date ? 23 : 0; |
157 | 157 | $day = 1; |
158 | - $month = date( 'n', current_time( 'timestamp' ) ); |
|
159 | - $year = date( 'Y', current_time( 'timestamp' ) ); |
|
158 | + $month = date('n', current_time('timestamp')); |
|
159 | + $year = date('Y', current_time('timestamp')); |
|
160 | 160 | |
161 | - if ( array_key_exists( (string) $date, $this->get_predefined_dates() ) ) { |
|
161 | + if (array_key_exists((string) $date, $this->get_predefined_dates())) { |
|
162 | 162 | |
163 | 163 | // This is a predefined date rate, such as last_week |
164 | - switch ( $date ) { |
|
164 | + switch ($date) { |
|
165 | 165 | |
166 | 166 | case 'this_month' : |
167 | 167 | |
168 | - if ( $end_date ) { |
|
168 | + if ($end_date) { |
|
169 | 169 | |
170 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
170 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
171 | 171 | $hour = 23; |
172 | 172 | $minute = 59; |
173 | 173 | $second = 59; |
@@ -177,28 +177,28 @@ discard block |
||
177 | 177 | |
178 | 178 | case 'last_month' : |
179 | 179 | |
180 | - if ( $month == 1 ) { |
|
180 | + if ($month == 1) { |
|
181 | 181 | |
182 | 182 | $month = 12; |
183 | - $year --; |
|
183 | + $year--; |
|
184 | 184 | |
185 | 185 | } else { |
186 | 186 | |
187 | - $month --; |
|
187 | + $month--; |
|
188 | 188 | |
189 | 189 | } |
190 | 190 | |
191 | - if ( $end_date ) { |
|
192 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
191 | + if ($end_date) { |
|
192 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | break; |
196 | 196 | |
197 | 197 | case 'today' : |
198 | 198 | |
199 | - $day = date( 'd', current_time( 'timestamp' ) ); |
|
199 | + $day = date('d', current_time('timestamp')); |
|
200 | 200 | |
201 | - if ( $end_date ) { |
|
201 | + if ($end_date) { |
|
202 | 202 | $hour = 23; |
203 | 203 | $minute = 59; |
204 | 204 | $second = 59; |
@@ -208,23 +208,23 @@ discard block |
||
208 | 208 | |
209 | 209 | case 'yesterday' : |
210 | 210 | |
211 | - $day = date( 'd', current_time( 'timestamp' ) ) - 1; |
|
211 | + $day = date('d', current_time('timestamp')) - 1; |
|
212 | 212 | |
213 | 213 | // Check if Today is the first day of the month (meaning subtracting one will get us 0) |
214 | - if ( $day < 1 ) { |
|
214 | + if ($day < 1) { |
|
215 | 215 | |
216 | 216 | // If current month is 1 |
217 | - if ( 1 == $month ) { |
|
217 | + if (1 == $month) { |
|
218 | 218 | |
219 | 219 | $year -= 1; // Today is January 1, so skip back to last day of December |
220 | 220 | $month = 12; |
221 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
221 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
222 | 222 | |
223 | 223 | } else { |
224 | 224 | |
225 | 225 | // Go back one month and get the last day of the month |
226 | 226 | $month -= 1; |
227 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
227 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
228 | 228 | |
229 | 229 | } |
230 | 230 | } |
@@ -233,12 +233,12 @@ discard block |
||
233 | 233 | |
234 | 234 | case 'this_week' : |
235 | 235 | |
236 | - $days_to_week_start = ( date( 'w', current_time( 'timestamp' ) ) - 1 ) * 60 * 60 * 24; |
|
237 | - $today = date( 'j', current_time( 'timestamp' ) ) * 60 * 60 * 24; |
|
236 | + $days_to_week_start = (date('w', current_time('timestamp')) - 1) * 60 * 60 * 24; |
|
237 | + $today = date('j', current_time('timestamp')) * 60 * 60 * 24; |
|
238 | 238 | |
239 | - if ( $today <= $days_to_week_start ) { |
|
239 | + if ($today <= $days_to_week_start) { |
|
240 | 240 | |
241 | - if ( $month > 1 ) { |
|
241 | + if ($month > 1) { |
|
242 | 242 | $month -= 1; |
243 | 243 | } else { |
244 | 244 | $month = 12; |
@@ -246,19 +246,19 @@ discard block |
||
246 | 246 | |
247 | 247 | } |
248 | 248 | |
249 | - if ( ! $end_date ) { |
|
249 | + if ( ! $end_date) { |
|
250 | 250 | |
251 | 251 | // Getting the start day |
252 | 252 | |
253 | - $day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 1; |
|
254 | - $day += get_option( 'start_of_week' ); |
|
253 | + $day = date('d', current_time('timestamp') - $days_to_week_start) - 1; |
|
254 | + $day += get_option('start_of_week'); |
|
255 | 255 | |
256 | 256 | } else { |
257 | 257 | |
258 | 258 | // Getting the end day |
259 | 259 | |
260 | - $day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 1; |
|
261 | - $day += get_option( 'start_of_week' ) + 6; |
|
260 | + $day = date('d', current_time('timestamp') - $days_to_week_start) - 1; |
|
261 | + $day += get_option('start_of_week') + 6; |
|
262 | 262 | |
263 | 263 | } |
264 | 264 | |
@@ -266,12 +266,12 @@ discard block |
||
266 | 266 | |
267 | 267 | case 'last_week' : |
268 | 268 | |
269 | - $days_to_week_start = ( date( 'w', current_time( 'timestamp' ) ) - 1 ) * 60 * 60 * 24; |
|
270 | - $today = date( 'j', current_time( 'timestamp' ) ) * 60 * 60 * 24; |
|
269 | + $days_to_week_start = (date('w', current_time('timestamp')) - 1) * 60 * 60 * 24; |
|
270 | + $today = date('j', current_time('timestamp')) * 60 * 60 * 24; |
|
271 | 271 | |
272 | - if ( $today <= $days_to_week_start ) { |
|
272 | + if ($today <= $days_to_week_start) { |
|
273 | 273 | |
274 | - if ( $month > 1 ) { |
|
274 | + if ($month > 1) { |
|
275 | 275 | $month -= 1; |
276 | 276 | } else { |
277 | 277 | $month = 12; |
@@ -279,19 +279,19 @@ discard block |
||
279 | 279 | |
280 | 280 | } |
281 | 281 | |
282 | - if ( ! $end_date ) { |
|
282 | + if ( ! $end_date) { |
|
283 | 283 | |
284 | 284 | // Getting the start day |
285 | 285 | |
286 | - $day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 8; |
|
287 | - $day += get_option( 'start_of_week' ); |
|
286 | + $day = date('d', current_time('timestamp') - $days_to_week_start) - 8; |
|
287 | + $day += get_option('start_of_week'); |
|
288 | 288 | |
289 | 289 | } else { |
290 | 290 | |
291 | 291 | // Getting the end day |
292 | 292 | |
293 | - $day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 8; |
|
294 | - $day += get_option( 'start_of_week' ) + 6; |
|
293 | + $day = date('d', current_time('timestamp') - $days_to_week_start) - 8; |
|
294 | + $day += get_option('start_of_week') + 6; |
|
295 | 295 | |
296 | 296 | } |
297 | 297 | |
@@ -299,39 +299,39 @@ discard block |
||
299 | 299 | |
300 | 300 | case 'this_quarter' : |
301 | 301 | |
302 | - $month_now = date( 'n', current_time( 'timestamp' ) ); |
|
302 | + $month_now = date('n', current_time('timestamp')); |
|
303 | 303 | |
304 | - if ( $month_now <= 3 ) { |
|
304 | + if ($month_now <= 3) { |
|
305 | 305 | |
306 | - if ( ! $end_date ) { |
|
306 | + if ( ! $end_date) { |
|
307 | 307 | $month = 1; |
308 | 308 | } else { |
309 | 309 | $month = 3; |
310 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
310 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
311 | 311 | $hour = 23; |
312 | 312 | $minute = 59; |
313 | 313 | $second = 59; |
314 | 314 | } |
315 | 315 | |
316 | - } else if ( $month_now <= 6 ) { |
|
316 | + } else if ($month_now <= 6) { |
|
317 | 317 | |
318 | - if ( ! $end_date ) { |
|
318 | + if ( ! $end_date) { |
|
319 | 319 | $month = 4; |
320 | 320 | } else { |
321 | 321 | $month = 6; |
322 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
322 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
323 | 323 | $hour = 23; |
324 | 324 | $minute = 59; |
325 | 325 | $second = 59; |
326 | 326 | } |
327 | 327 | |
328 | - } else if ( $month_now <= 9 ) { |
|
328 | + } else if ($month_now <= 9) { |
|
329 | 329 | |
330 | - if ( ! $end_date ) { |
|
330 | + if ( ! $end_date) { |
|
331 | 331 | $month = 7; |
332 | 332 | } else { |
333 | 333 | $month = 9; |
334 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
334 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
335 | 335 | $hour = 23; |
336 | 336 | $minute = 59; |
337 | 337 | $second = 59; |
@@ -339,11 +339,11 @@ discard block |
||
339 | 339 | |
340 | 340 | } else { |
341 | 341 | |
342 | - if ( ! $end_date ) { |
|
342 | + if ( ! $end_date) { |
|
343 | 343 | $month = 10; |
344 | 344 | } else { |
345 | 345 | $month = 12; |
346 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
346 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
347 | 347 | $hour = 23; |
348 | 348 | $minute = 59; |
349 | 349 | $second = 59; |
@@ -355,40 +355,40 @@ discard block |
||
355 | 355 | |
356 | 356 | case 'last_quarter' : |
357 | 357 | |
358 | - $month_now = date( 'n', current_time( 'timestamp' ) ); |
|
358 | + $month_now = date('n', current_time('timestamp')); |
|
359 | 359 | |
360 | - if ( $month_now <= 3 ) { |
|
360 | + if ($month_now <= 3) { |
|
361 | 361 | |
362 | - if ( ! $end_date ) { |
|
362 | + if ( ! $end_date) { |
|
363 | 363 | $month = 10; |
364 | 364 | } else { |
365 | 365 | $year -= 1; |
366 | 366 | $month = 12; |
367 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
367 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
368 | 368 | $hour = 23; |
369 | 369 | $minute = 59; |
370 | 370 | $second = 59; |
371 | 371 | } |
372 | 372 | |
373 | - } else if ( $month_now <= 6 ) { |
|
373 | + } else if ($month_now <= 6) { |
|
374 | 374 | |
375 | - if ( ! $end_date ) { |
|
375 | + if ( ! $end_date) { |
|
376 | 376 | $month = 1; |
377 | 377 | } else { |
378 | 378 | $month = 3; |
379 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
379 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
380 | 380 | $hour = 23; |
381 | 381 | $minute = 59; |
382 | 382 | $second = 59; |
383 | 383 | } |
384 | 384 | |
385 | - } else if ( $month_now <= 9 ) { |
|
385 | + } else if ($month_now <= 9) { |
|
386 | 386 | |
387 | - if ( ! $end_date ) { |
|
387 | + if ( ! $end_date) { |
|
388 | 388 | $month = 4; |
389 | 389 | } else { |
390 | 390 | $month = 6; |
391 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
391 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
392 | 392 | $hour = 23; |
393 | 393 | $minute = 59; |
394 | 394 | $second = 59; |
@@ -396,11 +396,11 @@ discard block |
||
396 | 396 | |
397 | 397 | } else { |
398 | 398 | |
399 | - if ( ! $end_date ) { |
|
399 | + if ( ! $end_date) { |
|
400 | 400 | $month = 7; |
401 | 401 | } else { |
402 | 402 | $month = 9; |
403 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
403 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
404 | 404 | $hour = 23; |
405 | 405 | $minute = 59; |
406 | 406 | $second = 59; |
@@ -412,11 +412,11 @@ discard block |
||
412 | 412 | |
413 | 413 | case 'this_year' : |
414 | 414 | |
415 | - if ( ! $end_date ) { |
|
415 | + if ( ! $end_date) { |
|
416 | 416 | $month = 1; |
417 | 417 | } else { |
418 | 418 | $month = 12; |
419 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
419 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
420 | 420 | $hour = 23; |
421 | 421 | $minute = 59; |
422 | 422 | $second = 59; |
@@ -427,11 +427,11 @@ discard block |
||
427 | 427 | case 'last_year' : |
428 | 428 | |
429 | 429 | $year -= 1; |
430 | - if ( ! $end_date ) { |
|
430 | + if ( ! $end_date) { |
|
431 | 431 | $month = 1; |
432 | 432 | } else { |
433 | 433 | $month = 12; |
434 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
434 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
435 | 435 | $hour = 23; |
436 | 436 | $minute = 59; |
437 | 437 | $second = 59; |
@@ -442,30 +442,30 @@ discard block |
||
442 | 442 | } |
443 | 443 | |
444 | 444 | |
445 | - } else if ( is_numeric( $date ) ) { |
|
445 | + } else if (is_numeric($date)) { |
|
446 | 446 | |
447 | 447 | // return $date unchanged since it is a timestamp |
448 | 448 | $this->timestamp = true; |
449 | 449 | |
450 | - } else if ( false !== strtotime( $date ) ) { |
|
450 | + } else if (false !== strtotime($date)) { |
|
451 | 451 | |
452 | - $date = strtotime( $date, current_time( 'timestamp' ) ); |
|
453 | - $year = date( 'Y', $date ); |
|
454 | - $month = date( 'm', $date ); |
|
455 | - $day = date( 'd', $date ); |
|
452 | + $date = strtotime($date, current_time('timestamp')); |
|
453 | + $year = date('Y', $date); |
|
454 | + $month = date('m', $date); |
|
455 | + $day = date('d', $date); |
|
456 | 456 | |
457 | 457 | } else { |
458 | 458 | |
459 | - return new WP_Error( 'invalid_date', esc_html__( 'Improper date provided.', 'give' ) ); |
|
459 | + return new WP_Error('invalid_date', esc_html__('Improper date provided.', 'give')); |
|
460 | 460 | |
461 | 461 | } |
462 | 462 | |
463 | - if ( false === $this->timestamp ) { |
|
463 | + if (false === $this->timestamp) { |
|
464 | 464 | // Create an exact timestamp |
465 | - $date = mktime( $hour, $minute, $second, $month, $day, $year ); |
|
465 | + $date = mktime($hour, $minute, $second, $month, $day, $year); |
|
466 | 466 | } |
467 | 467 | |
468 | - return apply_filters( 'give_stats_date', $date, $end_date, $this ); |
|
468 | + return apply_filters('give_stats_date', $date, $end_date, $this); |
|
469 | 469 | |
470 | 470 | } |
471 | 471 | |
@@ -481,33 +481,33 @@ discard block |
||
481 | 481 | * |
482 | 482 | * @return string |
483 | 483 | */ |
484 | - public function count_where( $where = '' ) { |
|
484 | + public function count_where($where = '') { |
|
485 | 485 | // Only get payments in our date range |
486 | 486 | |
487 | 487 | $start_where = ''; |
488 | 488 | $end_where = ''; |
489 | 489 | |
490 | - if ( $this->start_date ) { |
|
490 | + if ($this->start_date) { |
|
491 | 491 | |
492 | - if ( $this->timestamp ) { |
|
492 | + if ($this->timestamp) { |
|
493 | 493 | $format = 'Y-m-d H:i:s'; |
494 | 494 | } else { |
495 | 495 | $format = 'Y-m-d 00:00:00'; |
496 | 496 | } |
497 | 497 | |
498 | - $start_date = date( $format, $this->start_date ); |
|
498 | + $start_date = date($format, $this->start_date); |
|
499 | 499 | $start_where = " AND p.post_date >= '{$start_date}'"; |
500 | 500 | } |
501 | 501 | |
502 | - if ( $this->end_date ) { |
|
502 | + if ($this->end_date) { |
|
503 | 503 | |
504 | - if ( $this->timestamp ) { |
|
504 | + if ($this->timestamp) { |
|
505 | 505 | $format = 'Y-m-d H:i:s'; |
506 | 506 | } else { |
507 | 507 | $format = 'Y-m-d 23:59:59'; |
508 | 508 | } |
509 | 509 | |
510 | - $end_date = date( $format, $this->end_date ); |
|
510 | + $end_date = date($format, $this->end_date); |
|
511 | 511 | |
512 | 512 | $end_where = " AND p.post_date <= '{$end_date}'"; |
513 | 513 | } |
@@ -529,34 +529,34 @@ discard block |
||
529 | 529 | * |
530 | 530 | * @return string |
531 | 531 | */ |
532 | - public function payments_where( $where = '' ) { |
|
532 | + public function payments_where($where = '') { |
|
533 | 533 | |
534 | 534 | global $wpdb; |
535 | 535 | |
536 | 536 | $start_where = ''; |
537 | 537 | $end_where = ''; |
538 | 538 | |
539 | - if ( ! is_wp_error( $this->start_date ) ) { |
|
539 | + if ( ! is_wp_error($this->start_date)) { |
|
540 | 540 | |
541 | - if ( $this->timestamp ) { |
|
541 | + if ($this->timestamp) { |
|
542 | 542 | $format = 'Y-m-d H:i:s'; |
543 | 543 | } else { |
544 | 544 | $format = 'Y-m-d 00:00:00'; |
545 | 545 | } |
546 | 546 | |
547 | - $start_date = date( $format, $this->start_date ); |
|
547 | + $start_date = date($format, $this->start_date); |
|
548 | 548 | $start_where = " AND $wpdb->posts.post_date >= '{$start_date}'"; |
549 | 549 | } |
550 | 550 | |
551 | - if ( ! is_wp_error( $this->end_date ) ) { |
|
551 | + if ( ! is_wp_error($this->end_date)) { |
|
552 | 552 | |
553 | - if ( $this->timestamp ) { |
|
553 | + if ($this->timestamp) { |
|
554 | 554 | $format = 'Y-m-d H:i:s'; |
555 | 555 | } else { |
556 | 556 | $format = 'Y-m-d 23:59:59'; |
557 | 557 | } |
558 | 558 | |
559 | - $end_date = date( $format, $this->end_date ); |
|
559 | + $end_date = date($format, $this->end_date); |
|
560 | 560 | |
561 | 561 | $end_where = " AND $wpdb->posts.post_date <= '{$end_date}'"; |
562 | 562 | } |
@@ -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 | |
@@ -348,11 +348,11 @@ discard block |
||
348 | 348 | * @param int|bool $_id Post id. Default is false. |
349 | 349 | * @param array $_args Arguments passed. |
350 | 350 | */ |
351 | - public function __construct( $_id = false, $_args = array() ) { |
|
351 | + public function __construct($_id = false, $_args = array()) { |
|
352 | 352 | |
353 | - $donation_form = WP_Post::get_instance( $_id ); |
|
353 | + $donation_form = WP_Post::get_instance($_id); |
|
354 | 354 | |
355 | - return $this->setup_donation_form( $donation_form ); |
|
355 | + return $this->setup_donation_form($donation_form); |
|
356 | 356 | } |
357 | 357 | |
358 | 358 | /** |
@@ -365,23 +365,23 @@ discard block |
||
365 | 365 | * |
366 | 366 | * @return bool If the setup was successful or not. |
367 | 367 | */ |
368 | - private function setup_donation_form( $donation_form ) { |
|
368 | + private function setup_donation_form($donation_form) { |
|
369 | 369 | |
370 | - if ( ! is_object( $donation_form ) ) { |
|
370 | + if ( ! is_object($donation_form)) { |
|
371 | 371 | return false; |
372 | 372 | } |
373 | 373 | |
374 | - if ( ! is_a( $donation_form, 'WP_Post' ) ) { |
|
374 | + if ( ! is_a($donation_form, 'WP_Post')) { |
|
375 | 375 | return false; |
376 | 376 | } |
377 | 377 | |
378 | - if ( 'give_forms' !== $donation_form->post_type ) { |
|
378 | + if ('give_forms' !== $donation_form->post_type) { |
|
379 | 379 | return false; |
380 | 380 | } |
381 | 381 | |
382 | - foreach ( $donation_form as $key => $value ) { |
|
382 | + foreach ($donation_form as $key => $value) { |
|
383 | 383 | |
384 | - switch ( $key ) { |
|
384 | + switch ($key) { |
|
385 | 385 | |
386 | 386 | default: |
387 | 387 | $this->$key = $value; |
@@ -405,16 +405,16 @@ discard block |
||
405 | 405 | * |
406 | 406 | * @return mixed |
407 | 407 | */ |
408 | - public function __get( $key ) { |
|
408 | + public function __get($key) { |
|
409 | 409 | |
410 | - if ( method_exists( $this, 'get_' . $key ) ) { |
|
410 | + if (method_exists($this, 'get_'.$key)) { |
|
411 | 411 | |
412 | - return call_user_func( array( $this, 'get_' . $key ) ); |
|
412 | + return call_user_func(array($this, 'get_'.$key)); |
|
413 | 413 | |
414 | 414 | } else { |
415 | 415 | |
416 | 416 | /* translators: %s: property key */ |
417 | - return new WP_Error( 'give-form-invalid-property', sprintf( esc_html__( 'Can\'t get property %s.', 'give' ), $key ) ); |
|
417 | + return new WP_Error('give-form-invalid-property', sprintf(esc_html__('Can\'t get property %s.', 'give'), $key)); |
|
418 | 418 | |
419 | 419 | } |
420 | 420 | |
@@ -430,30 +430,30 @@ discard block |
||
430 | 430 | * |
431 | 431 | * @return bool|int False if data isn't passed and class not instantiated for creation, or New Form ID. |
432 | 432 | */ |
433 | - public function create( $data = array() ) { |
|
433 | + public function create($data = array()) { |
|
434 | 434 | |
435 | - if ( $this->id != 0 ) { |
|
435 | + if ($this->id != 0) { |
|
436 | 436 | return false; |
437 | 437 | } |
438 | 438 | |
439 | 439 | $defaults = array( |
440 | 440 | 'post_type' => 'give_forms', |
441 | 441 | 'post_status' => 'draft', |
442 | - 'post_title' => __( 'New Donation Form', 'give' ), |
|
442 | + 'post_title' => __('New Donation Form', 'give'), |
|
443 | 443 | ); |
444 | 444 | |
445 | - $args = wp_parse_args( $data, $defaults ); |
|
445 | + $args = wp_parse_args($data, $defaults); |
|
446 | 446 | |
447 | 447 | /** |
448 | 448 | * Fired before a donation form is created |
449 | 449 | * |
450 | 450 | * @param array $args The post object arguments used for creation. |
451 | 451 | */ |
452 | - do_action( 'give_form_pre_create', $args ); |
|
452 | + do_action('give_form_pre_create', $args); |
|
453 | 453 | |
454 | - $id = wp_insert_post( $args, true ); |
|
454 | + $id = wp_insert_post($args, true); |
|
455 | 455 | |
456 | - $donation_form = WP_Post::get_instance( $id ); |
|
456 | + $donation_form = WP_Post::get_instance($id); |
|
457 | 457 | |
458 | 458 | /** |
459 | 459 | * Fired after a donation form is created |
@@ -461,9 +461,9 @@ discard block |
||
461 | 461 | * @param int $id The post ID of the created item. |
462 | 462 | * @param array $args The post object arguments used for creation. |
463 | 463 | */ |
464 | - do_action( 'give_form_post_create', $id, $args ); |
|
464 | + do_action('give_form_post_create', $id, $args); |
|
465 | 465 | |
466 | - return $this->setup_donation_form( $donation_form ); |
|
466 | + return $this->setup_donation_form($donation_form); |
|
467 | 467 | |
468 | 468 | } |
469 | 469 | |
@@ -488,7 +488,7 @@ discard block |
||
488 | 488 | * @return string Donation form name. |
489 | 489 | */ |
490 | 490 | public function get_name() { |
491 | - return get_the_title( $this->ID ); |
|
491 | + return get_the_title($this->ID); |
|
492 | 492 | } |
493 | 493 | |
494 | 494 | /** |
@@ -501,7 +501,7 @@ discard block |
||
501 | 501 | */ |
502 | 502 | public function get_price() { |
503 | 503 | |
504 | - if ( ! isset( $this->price ) ) { |
|
504 | + if ( ! isset($this->price)) { |
|
505 | 505 | |
506 | 506 | $this->price = give_maybe_sanitize_amount( |
507 | 507 | give_get_meta( |
@@ -511,7 +511,7 @@ discard block |
||
511 | 511 | ) |
512 | 512 | ); |
513 | 513 | |
514 | - if ( ! $this->price ) { |
|
514 | + if ( ! $this->price) { |
|
515 | 515 | $this->price = 0; |
516 | 516 | } |
517 | 517 | |
@@ -525,7 +525,7 @@ discard block |
||
525 | 525 | * @param string $price The donation form price. |
526 | 526 | * @param string|int $id The form ID. |
527 | 527 | */ |
528 | - return apply_filters( 'give_get_set_price', $this->price, $this->ID ); |
|
528 | + return apply_filters('give_get_set_price', $this->price, $this->ID); |
|
529 | 529 | } |
530 | 530 | |
531 | 531 | /** |
@@ -538,22 +538,22 @@ discard block |
||
538 | 538 | */ |
539 | 539 | public function get_minimum_price() { |
540 | 540 | |
541 | - if ( ! isset( $this->minimum_price ) ) { |
|
541 | + if ( ! isset($this->minimum_price)) { |
|
542 | 542 | |
543 | - $this->minimum_price = give_get_meta( $this->ID, '_give_custom_amount_range_minimum', true ); |
|
543 | + $this->minimum_price = give_get_meta($this->ID, '_give_custom_amount_range_minimum', true); |
|
544 | 544 | |
545 | 545 | // Give backward < 2.1 |
546 | - if ( empty( $this->minimum_price ) ) { |
|
547 | - $this->minimum_price = give_get_meta( $this->ID, '_give_custom_amount_minimum', true ); |
|
546 | + if (empty($this->minimum_price)) { |
|
547 | + $this->minimum_price = give_get_meta($this->ID, '_give_custom_amount_minimum', true); |
|
548 | 548 | } |
549 | 549 | |
550 | - if ( ! $this->is_custom_price_mode() ) { |
|
551 | - $this->minimum_price = give_get_lowest_price_option( $this->ID ); |
|
550 | + if ( ! $this->is_custom_price_mode()) { |
|
551 | + $this->minimum_price = give_get_lowest_price_option($this->ID); |
|
552 | 552 | } |
553 | 553 | |
554 | 554 | } |
555 | 555 | |
556 | - return apply_filters( 'give_get_set_minimum_price', $this->minimum_price, $this->ID ); |
|
556 | + return apply_filters('give_get_set_minimum_price', $this->minimum_price, $this->ID); |
|
557 | 557 | } |
558 | 558 | |
559 | 559 | /** |
@@ -566,15 +566,15 @@ discard block |
||
566 | 566 | */ |
567 | 567 | public function get_maximum_price() { |
568 | 568 | |
569 | - if ( ! isset( $this->maximum_price ) ) { |
|
570 | - $this->maximum_price = give_get_meta( $this->ID, '_give_custom_amount_range_maximum', true, 999999.99 ); |
|
569 | + if ( ! isset($this->maximum_price)) { |
|
570 | + $this->maximum_price = give_get_meta($this->ID, '_give_custom_amount_range_maximum', true, 999999.99); |
|
571 | 571 | |
572 | - if ( ! $this->is_custom_price_mode() ) { |
|
573 | - $this->maximum_price = give_get_highest_price_option( $this->ID ); |
|
572 | + if ( ! $this->is_custom_price_mode()) { |
|
573 | + $this->maximum_price = give_get_highest_price_option($this->ID); |
|
574 | 574 | } |
575 | 575 | } |
576 | 576 | |
577 | - return apply_filters( 'give_get_set_maximum_price', $this->maximum_price, $this->ID ); |
|
577 | + return apply_filters('give_get_set_maximum_price', $this->maximum_price, $this->ID); |
|
578 | 578 | } |
579 | 579 | |
580 | 580 | /** |
@@ -587,9 +587,9 @@ discard block |
||
587 | 587 | */ |
588 | 588 | public function get_prices() { |
589 | 589 | |
590 | - if ( ! isset( $this->prices ) ) { |
|
590 | + if ( ! isset($this->prices)) { |
|
591 | 591 | |
592 | - $this->prices = give_get_meta( $this->ID, '_give_donation_levels', true ); |
|
592 | + $this->prices = give_get_meta($this->ID, '_give_donation_levels', true); |
|
593 | 593 | |
594 | 594 | } |
595 | 595 | |
@@ -601,7 +601,7 @@ discard block |
||
601 | 601 | * @param array $prices The array of mulit-level prices. |
602 | 602 | * @param int|string $ID The ID of the form. |
603 | 603 | */ |
604 | - return apply_filters( 'give_get_donation_levels', $this->prices, $this->ID ); |
|
604 | + return apply_filters('give_get_donation_levels', $this->prices, $this->ID); |
|
605 | 605 | |
606 | 606 | } |
607 | 607 | |
@@ -615,18 +615,18 @@ discard block |
||
615 | 615 | * |
616 | 616 | * @return array|null |
617 | 617 | */ |
618 | - public function get_level_info( $price_id ) { |
|
618 | + public function get_level_info($price_id) { |
|
619 | 619 | $level_info = array(); |
620 | 620 | |
621 | 621 | // Bailout. |
622 | - if ( 'multi' !== $this->get_type() ) { |
|
622 | + if ('multi' !== $this->get_type()) { |
|
623 | 623 | return null; |
624 | - } elseif ( ! ( $levels = $this->get_prices() ) ) { |
|
624 | + } elseif ( ! ($levels = $this->get_prices())) { |
|
625 | 625 | return $level_info; |
626 | 626 | } |
627 | 627 | |
628 | - foreach ( $levels as $level ) { |
|
629 | - if ( $price_id === $level['_give_id']['level_id'] ) { |
|
628 | + foreach ($levels as $level) { |
|
629 | + if ($price_id === $level['_give_id']['level_id']) { |
|
630 | 630 | $level_info = $level; |
631 | 631 | break; |
632 | 632 | } |
@@ -646,25 +646,25 @@ discard block |
||
646 | 646 | */ |
647 | 647 | public function get_goal() { |
648 | 648 | |
649 | - if ( ! isset( $this->goal ) ) { |
|
649 | + if ( ! isset($this->goal)) { |
|
650 | 650 | |
651 | - $goal_format = give_get_form_goal_format( $this->ID ); |
|
651 | + $goal_format = give_get_form_goal_format($this->ID); |
|
652 | 652 | |
653 | - if ( 'donation' === $goal_format ) { |
|
654 | - $this->goal = give_get_meta( $this->ID, '_give_number_of_donation_goal', true ); |
|
655 | - } elseif ( 'donors' === $goal_format ) { |
|
656 | - $this->goal = give_get_meta( $this->ID, '_give_number_of_donor_goal', true ); |
|
653 | + if ('donation' === $goal_format) { |
|
654 | + $this->goal = give_get_meta($this->ID, '_give_number_of_donation_goal', true); |
|
655 | + } elseif ('donors' === $goal_format) { |
|
656 | + $this->goal = give_get_meta($this->ID, '_give_number_of_donor_goal', true); |
|
657 | 657 | } else { |
658 | - $this->goal = give_get_meta( $this->ID, '_give_set_goal', true ); |
|
658 | + $this->goal = give_get_meta($this->ID, '_give_set_goal', true); |
|
659 | 659 | } |
660 | 660 | |
661 | - if ( ! $this->goal ) { |
|
661 | + if ( ! $this->goal) { |
|
662 | 662 | $this->goal = 0; |
663 | 663 | } |
664 | 664 | |
665 | 665 | } |
666 | 666 | |
667 | - return apply_filters( 'give_get_set_goal', $this->goal, $this->ID ); |
|
667 | + return apply_filters('give_get_set_goal', $this->goal, $this->ID); |
|
668 | 668 | |
669 | 669 | } |
670 | 670 | |
@@ -678,10 +678,10 @@ discard block |
||
678 | 678 | */ |
679 | 679 | public function is_single_price_mode() { |
680 | 680 | |
681 | - $option = give_get_meta( $this->ID, '_give_price_option', true ); |
|
681 | + $option = give_get_meta($this->ID, '_give_price_option', true); |
|
682 | 682 | $ret = 0; |
683 | 683 | |
684 | - if ( empty( $option ) || $option === 'set' ) { |
|
684 | + if (empty($option) || $option === 'set') { |
|
685 | 685 | $ret = 1; |
686 | 686 | } |
687 | 687 | |
@@ -693,7 +693,7 @@ discard block |
||
693 | 693 | * @param bool $ret Is donation form in single price mode? |
694 | 694 | * @param int|string $ID The ID of the donation form. |
695 | 695 | */ |
696 | - return (bool) apply_filters( 'give_single_price_option_mode', $ret, $this->ID ); |
|
696 | + return (bool) apply_filters('give_single_price_option_mode', $ret, $this->ID); |
|
697 | 697 | |
698 | 698 | } |
699 | 699 | |
@@ -707,10 +707,10 @@ discard block |
||
707 | 707 | */ |
708 | 708 | public function is_custom_price_mode() { |
709 | 709 | |
710 | - $option = give_get_meta( $this->ID, '_give_custom_amount', true ); |
|
710 | + $option = give_get_meta($this->ID, '_give_custom_amount', true); |
|
711 | 711 | $ret = 0; |
712 | 712 | |
713 | - if ( give_is_setting_enabled( $option ) ) { |
|
713 | + if (give_is_setting_enabled($option)) { |
|
714 | 714 | $ret = 1; |
715 | 715 | } |
716 | 716 | |
@@ -722,7 +722,7 @@ discard block |
||
722 | 722 | * @param bool $ret Is donation form in custom price mode? |
723 | 723 | * @param int|string $ID The ID of the donation form. |
724 | 724 | */ |
725 | - return (bool) apply_filters( 'give_custom_price_option_mode', $ret, $this->ID ); |
|
725 | + return (bool) apply_filters('give_custom_price_option_mode', $ret, $this->ID); |
|
726 | 726 | |
727 | 727 | } |
728 | 728 | |
@@ -736,20 +736,20 @@ discard block |
||
736 | 736 | * |
737 | 737 | * @return bool |
738 | 738 | */ |
739 | - public function is_custom_price( $amount ) { |
|
739 | + public function is_custom_price($amount) { |
|
740 | 740 | $result = false; |
741 | - $amount = give_maybe_sanitize_amount( $amount ); |
|
741 | + $amount = give_maybe_sanitize_amount($amount); |
|
742 | 742 | |
743 | - if ( $this->is_custom_price_mode() ) { |
|
743 | + if ($this->is_custom_price_mode()) { |
|
744 | 744 | |
745 | - if ( 'set' === $this->get_type() ) { |
|
746 | - if ( $amount !== $this->get_price() ) { |
|
745 | + if ('set' === $this->get_type()) { |
|
746 | + if ($amount !== $this->get_price()) { |
|
747 | 747 | $result = true; |
748 | 748 | } |
749 | 749 | |
750 | - } elseif ( 'multi' === $this->get_type() ) { |
|
751 | - $level_amounts = array_map( 'give_maybe_sanitize_amount', wp_list_pluck( $this->get_prices(), '_give_amount' ) ); |
|
752 | - $result = ! in_array( $amount, $level_amounts ); |
|
750 | + } elseif ('multi' === $this->get_type()) { |
|
751 | + $level_amounts = array_map('give_maybe_sanitize_amount', wp_list_pluck($this->get_prices(), '_give_amount')); |
|
752 | + $result = ! in_array($amount, $level_amounts); |
|
753 | 753 | } |
754 | 754 | } |
755 | 755 | |
@@ -762,7 +762,7 @@ discard block |
||
762 | 762 | * |
763 | 763 | * @since 1.8.18 |
764 | 764 | */ |
765 | - return (bool) apply_filters( 'give_is_custom_price', $result, $amount, $this->ID ); |
|
765 | + return (bool) apply_filters('give_is_custom_price', $result, $amount, $this->ID); |
|
766 | 766 | } |
767 | 767 | |
768 | 768 | /** |
@@ -777,10 +777,10 @@ discard block |
||
777 | 777 | */ |
778 | 778 | public function has_variable_prices() { |
779 | 779 | |
780 | - $option = give_get_meta( $this->ID, '_give_price_option', true ); |
|
780 | + $option = give_get_meta($this->ID, '_give_price_option', true); |
|
781 | 781 | $ret = 0; |
782 | 782 | |
783 | - if ( $option === 'multi' ) { |
|
783 | + if ($option === 'multi') { |
|
784 | 784 | $ret = 1; |
785 | 785 | } |
786 | 786 | |
@@ -790,7 +790,7 @@ discard block |
||
790 | 790 | * @param bool $ret Does donation form have variable prices? |
791 | 791 | * @param int|string $ID The ID of the donation form. |
792 | 792 | */ |
793 | - return (bool) apply_filters( 'give_has_variable_prices', $ret, $this->ID ); |
|
793 | + return (bool) apply_filters('give_has_variable_prices', $ret, $this->ID); |
|
794 | 794 | |
795 | 795 | } |
796 | 796 | |
@@ -804,17 +804,17 @@ discard block |
||
804 | 804 | */ |
805 | 805 | public function get_type() { |
806 | 806 | |
807 | - if ( ! isset( $this->type ) ) { |
|
807 | + if ( ! isset($this->type)) { |
|
808 | 808 | |
809 | - $this->type = give_get_meta( $this->ID, '_give_price_option', true ); |
|
809 | + $this->type = give_get_meta($this->ID, '_give_price_option', true); |
|
810 | 810 | |
811 | - if ( empty( $this->type ) ) { |
|
811 | + if (empty($this->type)) { |
|
812 | 812 | $this->type = 'set'; |
813 | 813 | } |
814 | 814 | |
815 | 815 | } |
816 | 816 | |
817 | - return apply_filters( 'give_get_form_type', $this->type, $this->ID ); |
|
817 | + return apply_filters('give_get_form_type', $this->type, $this->ID); |
|
818 | 818 | |
819 | 819 | } |
820 | 820 | |
@@ -830,23 +830,23 @@ discard block |
||
830 | 830 | * |
831 | 831 | * @return string |
832 | 832 | */ |
833 | - public function get_form_classes( $args ) { |
|
833 | + public function get_form_classes($args) { |
|
834 | 834 | |
835 | - $float_labels_option = give_is_float_labels_enabled( $args ) |
|
835 | + $float_labels_option = give_is_float_labels_enabled($args) |
|
836 | 836 | ? 'float-labels-enabled' |
837 | 837 | : ''; |
838 | 838 | |
839 | - $form_classes_array = apply_filters( 'give_form_classes', array( |
|
839 | + $form_classes_array = apply_filters('give_form_classes', array( |
|
840 | 840 | 'give-form', |
841 | - 'give-form-' . $this->ID, |
|
842 | - 'give-form-type-' . $this->get_type(), |
|
841 | + 'give-form-'.$this->ID, |
|
842 | + 'give-form-type-'.$this->get_type(), |
|
843 | 843 | $float_labels_option, |
844 | - ), $this->ID, $args ); |
|
844 | + ), $this->ID, $args); |
|
845 | 845 | |
846 | 846 | // Remove empty class names. |
847 | - $form_classes_array = array_filter( $form_classes_array ); |
|
847 | + $form_classes_array = array_filter($form_classes_array); |
|
848 | 848 | |
849 | - return implode( ' ', $form_classes_array ); |
|
849 | + return implode(' ', $form_classes_array); |
|
850 | 850 | |
851 | 851 | } |
852 | 852 | |
@@ -861,22 +861,22 @@ discard block |
||
861 | 861 | * |
862 | 862 | * @return string |
863 | 863 | */ |
864 | - public function get_form_wrap_classes( $args ) { |
|
864 | + public function get_form_wrap_classes($args) { |
|
865 | 865 | $custom_class = array( |
866 | 866 | 'give-form-wrap', |
867 | 867 | ); |
868 | 868 | |
869 | - if ( $this->is_close_donation_form() ) { |
|
869 | + if ($this->is_close_donation_form()) { |
|
870 | 870 | $custom_class[] = 'give-form-closed'; |
871 | 871 | } else { |
872 | - $display_option = ( isset( $args['display_style'] ) && ! empty( $args['display_style'] ) ) |
|
872 | + $display_option = (isset($args['display_style']) && ! empty($args['display_style'])) |
|
873 | 873 | ? $args['display_style'] |
874 | - : give_get_meta( $this->ID, '_give_payment_display', true ); |
|
874 | + : give_get_meta($this->ID, '_give_payment_display', true); |
|
875 | 875 | |
876 | 876 | $custom_class[] = "give-display-{$display_option}"; |
877 | 877 | |
878 | 878 | // If admin want to show only button for form then user inbuilt modal functionality. |
879 | - if ( 'button' === $display_option ) { |
|
879 | + if ('button' === $display_option) { |
|
880 | 880 | $custom_class[] = 'give-display-button-only'; |
881 | 881 | } |
882 | 882 | } |
@@ -887,10 +887,10 @@ discard block |
||
887 | 887 | * |
888 | 888 | * @since 1.0 |
889 | 889 | */ |
890 | - $form_wrap_classes_array = (array) apply_filters( 'give_form_wrap_classes', $custom_class, $this->ID, $args ); |
|
890 | + $form_wrap_classes_array = (array) apply_filters('give_form_wrap_classes', $custom_class, $this->ID, $args); |
|
891 | 891 | |
892 | 892 | |
893 | - return implode( ' ', $form_wrap_classes_array ); |
|
893 | + return implode(' ', $form_wrap_classes_array); |
|
894 | 894 | |
895 | 895 | } |
896 | 896 | |
@@ -905,7 +905,7 @@ discard block |
||
905 | 905 | public function is_set_type_donation_form() { |
906 | 906 | $form_type = $this->get_type(); |
907 | 907 | |
908 | - return ( 'set' === $form_type ? true : false ); |
|
908 | + return ('set' === $form_type ? true : false); |
|
909 | 909 | } |
910 | 910 | |
911 | 911 | /** |
@@ -919,7 +919,7 @@ discard block |
||
919 | 919 | public function is_multi_type_donation_form() { |
920 | 920 | $form_type = $this->get_type(); |
921 | 921 | |
922 | - return ( 'multi' === $form_type ? true : false ); |
|
922 | + return ('multi' === $form_type ? true : false); |
|
923 | 923 | |
924 | 924 | } |
925 | 925 | |
@@ -933,15 +933,15 @@ discard block |
||
933 | 933 | */ |
934 | 934 | public function get_sales() { |
935 | 935 | |
936 | - if ( ! isset( $this->sales ) ) { |
|
936 | + if ( ! isset($this->sales)) { |
|
937 | 937 | |
938 | - if ( '' == give_get_meta( $this->ID, '_give_form_sales', true ) ) { |
|
939 | - add_post_meta( $this->ID, '_give_form_sales', 0 ); |
|
938 | + if ('' == give_get_meta($this->ID, '_give_form_sales', true)) { |
|
939 | + add_post_meta($this->ID, '_give_form_sales', 0); |
|
940 | 940 | } // End if |
941 | 941 | |
942 | - $this->sales = give_get_meta( $this->ID, '_give_form_sales', true ); |
|
942 | + $this->sales = give_get_meta($this->ID, '_give_form_sales', true); |
|
943 | 943 | |
944 | - if ( $this->sales < 0 ) { |
|
944 | + if ($this->sales < 0) { |
|
945 | 945 | // Never let sales be less than zero. |
946 | 946 | $this->sales = 0; |
947 | 947 | } |
@@ -962,13 +962,13 @@ discard block |
||
962 | 962 | * |
963 | 963 | * @return int|false New number of total sales. |
964 | 964 | */ |
965 | - public function increase_sales( $quantity = 1 ) { |
|
965 | + public function increase_sales($quantity = 1) { |
|
966 | 966 | |
967 | - $sales = give_get_form_sales_stats( $this->ID ); |
|
968 | - $quantity = absint( $quantity ); |
|
967 | + $sales = give_get_form_sales_stats($this->ID); |
|
968 | + $quantity = absint($quantity); |
|
969 | 969 | $total_sales = $sales + $quantity; |
970 | 970 | |
971 | - if ( $this->update_meta( '_give_form_sales', $total_sales ) ) { |
|
971 | + if ($this->update_meta('_give_form_sales', $total_sales)) { |
|
972 | 972 | |
973 | 973 | $this->sales = $total_sales; |
974 | 974 | |
@@ -989,17 +989,17 @@ discard block |
||
989 | 989 | * |
990 | 990 | * @return int|false New number of total sales. |
991 | 991 | */ |
992 | - public function decrease_sales( $quantity = 1 ) { |
|
992 | + public function decrease_sales($quantity = 1) { |
|
993 | 993 | |
994 | - $sales = give_get_form_sales_stats( $this->ID ); |
|
994 | + $sales = give_get_form_sales_stats($this->ID); |
|
995 | 995 | |
996 | 996 | // Only decrease if not already zero |
997 | - if ( $sales > 0 ) { |
|
997 | + if ($sales > 0) { |
|
998 | 998 | |
999 | - $quantity = absint( $quantity ); |
|
999 | + $quantity = absint($quantity); |
|
1000 | 1000 | $total_sales = $sales - $quantity; |
1001 | 1001 | |
1002 | - if ( $this->update_meta( '_give_form_sales', $total_sales ) ) { |
|
1002 | + if ($this->update_meta('_give_form_sales', $total_sales)) { |
|
1003 | 1003 | |
1004 | 1004 | $this->sales = $sales; |
1005 | 1005 | |
@@ -1023,15 +1023,15 @@ discard block |
||
1023 | 1023 | */ |
1024 | 1024 | public function get_earnings() { |
1025 | 1025 | |
1026 | - if ( ! isset( $this->earnings ) ) { |
|
1026 | + if ( ! isset($this->earnings)) { |
|
1027 | 1027 | |
1028 | - if ( '' == give_get_meta( $this->ID, '_give_form_earnings', true ) ) { |
|
1029 | - add_post_meta( $this->ID, '_give_form_earnings', 0 ); |
|
1028 | + if ('' == give_get_meta($this->ID, '_give_form_earnings', true)) { |
|
1029 | + add_post_meta($this->ID, '_give_form_earnings', 0); |
|
1030 | 1030 | } |
1031 | 1031 | |
1032 | - $this->earnings = give_get_meta( $this->ID, '_give_form_earnings', true ); |
|
1032 | + $this->earnings = give_get_meta($this->ID, '_give_form_earnings', true); |
|
1033 | 1033 | |
1034 | - if ( $this->earnings < 0 ) { |
|
1034 | + if ($this->earnings < 0) { |
|
1035 | 1035 | // Never let earnings be less than zero |
1036 | 1036 | $this->earnings = 0; |
1037 | 1037 | } |
@@ -1055,9 +1055,9 @@ discard block |
||
1055 | 1055 | * |
1056 | 1056 | * @return float|false |
1057 | 1057 | */ |
1058 | - public function increase_earnings( $amount = 0, $payment_id = 0 ) { |
|
1058 | + public function increase_earnings($amount = 0, $payment_id = 0) { |
|
1059 | 1059 | |
1060 | - $earnings = give_get_form_earnings_stats( $this->ID ); |
|
1060 | + $earnings = give_get_form_earnings_stats($this->ID); |
|
1061 | 1061 | |
1062 | 1062 | /** |
1063 | 1063 | * Modify the earning amount when increasing. |
@@ -1068,11 +1068,11 @@ discard block |
||
1068 | 1068 | * @param int $form_id Donation form ID. |
1069 | 1069 | * @param int $payment_id Donation ID. |
1070 | 1070 | */ |
1071 | - $amount = apply_filters( 'give_increase_form_earnings_amount', $amount, $this->ID, $payment_id ); |
|
1071 | + $amount = apply_filters('give_increase_form_earnings_amount', $amount, $this->ID, $payment_id); |
|
1072 | 1072 | |
1073 | 1073 | $new_amount = $earnings + (float) $amount; |
1074 | 1074 | |
1075 | - if ( $this->update_meta( '_give_form_earnings', $new_amount ) ) { |
|
1075 | + if ($this->update_meta('_give_form_earnings', $new_amount)) { |
|
1076 | 1076 | |
1077 | 1077 | $this->earnings = $new_amount; |
1078 | 1078 | |
@@ -1095,11 +1095,11 @@ discard block |
||
1095 | 1095 | * |
1096 | 1096 | * @return float|false |
1097 | 1097 | */ |
1098 | - public function decrease_earnings( $amount, $payment_id = 0 ) { |
|
1098 | + public function decrease_earnings($amount, $payment_id = 0) { |
|
1099 | 1099 | |
1100 | - $earnings = give_get_form_earnings_stats( $this->ID ); |
|
1100 | + $earnings = give_get_form_earnings_stats($this->ID); |
|
1101 | 1101 | |
1102 | - if ( $earnings > 0 ) { |
|
1102 | + if ($earnings > 0) { |
|
1103 | 1103 | |
1104 | 1104 | /** |
1105 | 1105 | * Modify the earning value when decreasing it. |
@@ -1110,12 +1110,12 @@ discard block |
||
1110 | 1110 | * @param int $form_id Donation Form ID. |
1111 | 1111 | * @param int $payment_id Donation ID. |
1112 | 1112 | */ |
1113 | - $amount = apply_filters( 'give_decrease_form_earnings_amount', $amount, $this->ID, $payment_id ); |
|
1113 | + $amount = apply_filters('give_decrease_form_earnings_amount', $amount, $this->ID, $payment_id); |
|
1114 | 1114 | |
1115 | 1115 | // Only decrease if greater than zero |
1116 | 1116 | $new_amount = $earnings - (float) $amount; |
1117 | 1117 | |
1118 | - if ( $this->update_meta( '_give_form_earnings', $new_amount ) ) { |
|
1118 | + if ($this->update_meta('_give_form_earnings', $new_amount)) { |
|
1119 | 1119 | $this->earnings = $new_amount; |
1120 | 1120 | |
1121 | 1121 | return $this->earnings; |
@@ -1141,10 +1141,10 @@ discard block |
||
1141 | 1141 | * @return bool |
1142 | 1142 | */ |
1143 | 1143 | public function is_close_donation_form() { |
1144 | - $is_closed = ( 'closed' === give_get_meta( $this->ID, '_give_form_status', true, 'open' ) ); |
|
1144 | + $is_closed = ('closed' === give_get_meta($this->ID, '_give_form_status', true, 'open')); |
|
1145 | 1145 | |
1146 | 1146 | // If manual upgrade not completed, proceed with backward compatible code. |
1147 | - if ( ! give_has_upgrade_completed( 'v210_verify_form_status_upgrades' ) ) { |
|
1147 | + if ( ! give_has_upgrade_completed('v210_verify_form_status_upgrades')) { |
|
1148 | 1148 | |
1149 | 1149 | // Check for backward compatibility. |
1150 | 1150 | $is_closed = $this->bc_210_is_close_donation_form(); |
@@ -1174,17 +1174,17 @@ discard block |
||
1174 | 1174 | * |
1175 | 1175 | * @return bool The result of the update query. |
1176 | 1176 | */ |
1177 | - private function update_meta( $meta_key = '', $meta_value = '' ) { |
|
1177 | + private function update_meta($meta_key = '', $meta_value = '') { |
|
1178 | 1178 | |
1179 | 1179 | /* @var WPDB $wpdb */ |
1180 | 1180 | global $wpdb; |
1181 | 1181 | |
1182 | 1182 | // Bailout. |
1183 | - if ( empty( $meta_key ) ) { |
|
1183 | + if (empty($meta_key)) { |
|
1184 | 1184 | return false; |
1185 | 1185 | } |
1186 | 1186 | |
1187 | - if ( give_update_meta( $this->ID, $meta_key, $meta_value ) ) { |
|
1187 | + if (give_update_meta($this->ID, $meta_key, $meta_value)) { |
|
1188 | 1188 | return true; |
1189 | 1189 | } |
1190 | 1190 | |
@@ -1201,33 +1201,33 @@ discard block |
||
1201 | 1201 | private function bc_210_is_close_donation_form() { |
1202 | 1202 | |
1203 | 1203 | $close_form = false; |
1204 | - $is_goal_enabled = give_is_setting_enabled( give_get_meta( $this->ID, '_give_goal_option', true, 'disabled' ) ); |
|
1204 | + $is_goal_enabled = give_is_setting_enabled(give_get_meta($this->ID, '_give_goal_option', true, 'disabled')); |
|
1205 | 1205 | |
1206 | 1206 | // Proceed, if the form goal is enabled. |
1207 | - if ( $is_goal_enabled ) { |
|
1207 | + if ($is_goal_enabled) { |
|
1208 | 1208 | |
1209 | - $close_form_when_goal_achieved = give_is_setting_enabled( give_get_meta( $this->ID, '_give_close_form_when_goal_achieved', true, 'disabled' ) ); |
|
1209 | + $close_form_when_goal_achieved = give_is_setting_enabled(give_get_meta($this->ID, '_give_close_form_when_goal_achieved', true, 'disabled')); |
|
1210 | 1210 | |
1211 | 1211 | // Proceed, if close form when goal achieved option is enabled. |
1212 | - if ( $close_form_when_goal_achieved ) { |
|
1212 | + if ($close_form_when_goal_achieved) { |
|
1213 | 1213 | |
1214 | - $form = new Give_Donate_Form( $this->ID ); |
|
1215 | - $goal_format = give_get_form_goal_format( $this->ID ); |
|
1214 | + $form = new Give_Donate_Form($this->ID); |
|
1215 | + $goal_format = give_get_form_goal_format($this->ID); |
|
1216 | 1216 | |
1217 | 1217 | // Verify whether the form is closed or not after processing data based on goal format. |
1218 | - switch ( $goal_format ) { |
|
1218 | + switch ($goal_format) { |
|
1219 | 1219 | case 'donation': |
1220 | 1220 | $closed = $form->get_goal() <= $form->get_sales(); |
1221 | 1221 | break; |
1222 | 1222 | case 'donors': |
1223 | - $closed = $form->get_goal() <= give_get_form_donor_count( $this->ID ); |
|
1223 | + $closed = $form->get_goal() <= give_get_form_donor_count($this->ID); |
|
1224 | 1224 | break; |
1225 | 1225 | default : |
1226 | 1226 | $closed = $form->get_goal() <= $form->get_earnings(); |
1227 | 1227 | break; |
1228 | 1228 | } |
1229 | 1229 | |
1230 | - if ( $closed ) { |
|
1230 | + if ($closed) { |
|
1231 | 1231 | $close_form = true; |
1232 | 1232 | } |
1233 | 1233 |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | * |
156 | 156 | * Used to redirect a user back to the donation form if there are errors present. |
157 | 157 | * |
158 | - * @param array|string $args |
|
158 | + * @param string $args |
|
159 | 159 | * |
160 | 160 | * @access public |
161 | 161 | * @since 1.0 |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | * @since 1.0 |
302 | 302 | * @since 1.8.16 Add security check |
303 | 303 | * |
304 | - * @return bool |
|
304 | + * @return false|null |
|
305 | 305 | */ |
306 | 306 | function give_listen_for_failed_payments() { |
307 | 307 |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -23,14 +23,14 @@ discard block |
||
23 | 23 | |
24 | 24 | global $typenow; |
25 | 25 | |
26 | - if ( $typenow != 'give_forms' ) { |
|
26 | + if ($typenow != 'give_forms') { |
|
27 | 27 | return true; |
28 | 28 | } |
29 | 29 | |
30 | 30 | return false; |
31 | 31 | } |
32 | 32 | |
33 | -add_filter( 'give_shortcode_button_condition', 'give_shortcode_button_condition' ); |
|
33 | +add_filter('give_shortcode_button_condition', 'give_shortcode_button_condition'); |
|
34 | 34 | |
35 | 35 | |
36 | 36 | /** |
@@ -40,11 +40,11 @@ discard block |
||
40 | 40 | * |
41 | 41 | * @return int|false |
42 | 42 | */ |
43 | -function get_form_id_from_args( $args ) { |
|
43 | +function get_form_id_from_args($args) { |
|
44 | 44 | |
45 | - if ( isset( $args['form_id'] ) && $args['form_id'] != 0 ) { |
|
45 | + if (isset($args['form_id']) && $args['form_id'] != 0) { |
|
46 | 46 | |
47 | - return intval( $args['form_id'] ); |
|
47 | + return intval($args['form_id']); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | return false; |
@@ -59,23 +59,23 @@ discard block |
||
59 | 59 | * |
60 | 60 | * @return bool |
61 | 61 | */ |
62 | -function give_is_float_labels_enabled( $args ) { |
|
62 | +function give_is_float_labels_enabled($args) { |
|
63 | 63 | |
64 | 64 | $float_labels = ''; |
65 | 65 | |
66 | - if ( ! empty( $args['float_labels'] ) ) { |
|
66 | + if ( ! empty($args['float_labels'])) { |
|
67 | 67 | $float_labels = $args['float_labels']; |
68 | 68 | } |
69 | 69 | |
70 | - if ( empty( $float_labels ) ) { |
|
71 | - $float_labels = give_get_meta( $args['form_id'], '_give_form_floating_labels', true ); |
|
70 | + if (empty($float_labels)) { |
|
71 | + $float_labels = give_get_meta($args['form_id'], '_give_form_floating_labels', true); |
|
72 | 72 | } |
73 | 73 | |
74 | - if ( empty( $float_labels ) || ( 'global' === $float_labels ) ) { |
|
75 | - $float_labels = give_get_option( 'floatlabels', 'disabled' ); |
|
74 | + if (empty($float_labels) || ('global' === $float_labels)) { |
|
75 | + $float_labels = give_get_option('floatlabels', 'disabled'); |
|
76 | 76 | } |
77 | 77 | |
78 | - return give_is_setting_enabled( $float_labels ); |
|
78 | + return give_is_setting_enabled($float_labels); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | |
92 | 92 | $can_checkout = true; |
93 | 93 | |
94 | - return (bool) apply_filters( 'give_can_checkout', $can_checkout ); |
|
94 | + return (bool) apply_filters('give_can_checkout', $can_checkout); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -105,9 +105,9 @@ discard block |
||
105 | 105 | function give_get_success_page_uri() { |
106 | 106 | $give_options = give_get_settings(); |
107 | 107 | |
108 | - $success_page = isset( $give_options['success_page'] ) ? get_permalink( absint( $give_options['success_page'] ) ) : get_bloginfo( 'url' ); |
|
108 | + $success_page = isset($give_options['success_page']) ? get_permalink(absint($give_options['success_page'])) : get_bloginfo('url'); |
|
109 | 109 | |
110 | - return apply_filters( 'give_get_success_page_uri', $success_page ); |
|
110 | + return apply_filters('give_get_success_page_uri', $success_page); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | /** |
@@ -119,9 +119,9 @@ discard block |
||
119 | 119 | */ |
120 | 120 | function give_is_success_page() { |
121 | 121 | $give_options = give_get_settings(); |
122 | - $is_success_page = isset( $give_options['success_page'] ) ? is_page( $give_options['success_page'] ) : false; |
|
122 | + $is_success_page = isset($give_options['success_page']) ? is_page($give_options['success_page']) : false; |
|
123 | 123 | |
124 | - return apply_filters( 'give_is_success_page', $is_success_page ); |
|
124 | + return apply_filters('give_is_success_page', $is_success_page); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -135,17 +135,17 @@ discard block |
||
135 | 135 | * @since 1.0 |
136 | 136 | * @return void |
137 | 137 | */ |
138 | -function give_send_to_success_page( $query_string = null ) { |
|
138 | +function give_send_to_success_page($query_string = null) { |
|
139 | 139 | |
140 | 140 | $redirect = give_get_success_page_uri(); |
141 | 141 | |
142 | - if ( $query_string ) { |
|
142 | + if ($query_string) { |
|
143 | 143 | $redirect .= $query_string; |
144 | 144 | } |
145 | 145 | |
146 | - $gateway = isset( $_REQUEST['give-gateway'] ) ? $_REQUEST['give-gateway'] : ''; |
|
146 | + $gateway = isset($_REQUEST['give-gateway']) ? $_REQUEST['give-gateway'] : ''; |
|
147 | 147 | |
148 | - wp_redirect( apply_filters( 'give_success_page_redirect', $redirect, $gateway, $query_string ) ); |
|
148 | + wp_redirect(apply_filters('give_success_page_redirect', $redirect, $gateway, $query_string)); |
|
149 | 149 | give_die(); |
150 | 150 | } |
151 | 151 | |
@@ -161,19 +161,19 @@ discard block |
||
161 | 161 | * @since 1.0 |
162 | 162 | * @return Void |
163 | 163 | */ |
164 | -function give_send_back_to_checkout( $args = array() ) { |
|
164 | +function give_send_back_to_checkout($args = array()) { |
|
165 | 165 | |
166 | - $url = isset( $_POST['give-current-url'] ) ? sanitize_text_field( $_POST['give-current-url'] ) : ''; |
|
166 | + $url = isset($_POST['give-current-url']) ? sanitize_text_field($_POST['give-current-url']) : ''; |
|
167 | 167 | $form_id = 0; |
168 | 168 | |
169 | 169 | // Set the form_id. |
170 | - if ( isset( $_POST['give-form-id'] ) ) { |
|
171 | - $form_id = sanitize_text_field( $_POST['give-form-id'] ); |
|
170 | + if (isset($_POST['give-form-id'])) { |
|
171 | + $form_id = sanitize_text_field($_POST['give-form-id']); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | // Need a URL to continue. If none, redirect back to single form. |
175 | - if ( empty( $url ) ) { |
|
176 | - wp_safe_redirect( get_permalink( $form_id ) ); |
|
175 | + if (empty($url)) { |
|
176 | + wp_safe_redirect(get_permalink($form_id)); |
|
177 | 177 | give_die(); |
178 | 178 | } |
179 | 179 | |
@@ -182,41 +182,41 @@ discard block |
||
182 | 182 | ); |
183 | 183 | |
184 | 184 | // Set the $level_id. |
185 | - if ( isset( $_POST['give-price-id'] ) ) { |
|
186 | - $defaults['level-id'] = sanitize_text_field( $_POST['give-price-id'] ); |
|
185 | + if (isset($_POST['give-price-id'])) { |
|
186 | + $defaults['level-id'] = sanitize_text_field($_POST['give-price-id']); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | // Check for backward compatibility. |
190 | - if ( is_string( $args ) ) { |
|
191 | - $args = str_replace( '?', '', $args ); |
|
190 | + if (is_string($args)) { |
|
191 | + $args = str_replace('?', '', $args); |
|
192 | 192 | } |
193 | 193 | |
194 | - $args = wp_parse_args( $args, $defaults ); |
|
194 | + $args = wp_parse_args($args, $defaults); |
|
195 | 195 | |
196 | 196 | // Merge URL query with $args to maintain third-party URL parameters after redirect. |
197 | - $url_data = wp_parse_url( $url ); |
|
197 | + $url_data = wp_parse_url($url); |
|
198 | 198 | |
199 | 199 | // Check if an array to prevent notices before parsing. |
200 | - if ( isset( $url_data['query'] ) && ! empty( $url_data['query'] ) ) { |
|
201 | - parse_str( $url_data['query'], $query ); |
|
200 | + if (isset($url_data['query']) && ! empty($url_data['query'])) { |
|
201 | + parse_str($url_data['query'], $query); |
|
202 | 202 | |
203 | 203 | // Precaution: don't allow any CC info. |
204 | - unset( $query['card_number'] ); |
|
205 | - unset( $query['card_cvc'] ); |
|
204 | + unset($query['card_number']); |
|
205 | + unset($query['card_cvc']); |
|
206 | 206 | |
207 | 207 | } else { |
208 | 208 | // No $url_data so pass empty array. |
209 | 209 | $query = array(); |
210 | 210 | } |
211 | 211 | |
212 | - $new_query = array_merge( $args, $query ); |
|
213 | - $new_query_string = http_build_query( $new_query ); |
|
212 | + $new_query = array_merge($args, $query); |
|
213 | + $new_query_string = http_build_query($new_query); |
|
214 | 214 | |
215 | 215 | // Assemble URL parts. |
216 | - $redirect = home_url( '/' . $url_data['path'] . '?' . $new_query_string . '#give-form-' . $form_id . '-wrap' ); |
|
216 | + $redirect = home_url('/'.$url_data['path'].'?'.$new_query_string.'#give-form-'.$form_id.'-wrap'); |
|
217 | 217 | |
218 | 218 | // Redirect them. |
219 | - wp_safe_redirect( apply_filters( 'give_send_back_to_checkout', $redirect, $args ) ); |
|
219 | + wp_safe_redirect(apply_filters('give_send_back_to_checkout', $redirect, $args)); |
|
220 | 220 | give_die(); |
221 | 221 | |
222 | 222 | } |
@@ -232,16 +232,16 @@ discard block |
||
232 | 232 | * @since 1.0 |
233 | 233 | * @return string |
234 | 234 | */ |
235 | -function give_get_success_page_url( $query_string = null ) { |
|
235 | +function give_get_success_page_url($query_string = null) { |
|
236 | 236 | |
237 | - $success_page = give_get_option( 'success_page', 0 ); |
|
238 | - $success_page = get_permalink( $success_page ); |
|
237 | + $success_page = give_get_option('success_page', 0); |
|
238 | + $success_page = get_permalink($success_page); |
|
239 | 239 | |
240 | - if ( $query_string ) { |
|
240 | + if ($query_string) { |
|
241 | 241 | $success_page .= $query_string; |
242 | 242 | } |
243 | 243 | |
244 | - return apply_filters( 'give_success_page_url', $success_page ); |
|
244 | + return apply_filters('give_success_page_url', $success_page); |
|
245 | 245 | |
246 | 246 | } |
247 | 247 | |
@@ -254,32 +254,31 @@ discard block |
||
254 | 254 | * |
255 | 255 | * @return mixed Full URL to the Failed Donation Page, if present, home page if it doesn't exist. |
256 | 256 | */ |
257 | -function give_get_failed_transaction_uri( $extras = false ) { |
|
257 | +function give_get_failed_transaction_uri($extras = false) { |
|
258 | 258 | $give_options = give_get_settings(); |
259 | 259 | |
260 | 260 | // Remove question mark. |
261 | - if ( 0 === strpos( $extras, '?' ) ) { |
|
262 | - $extras = substr( $extras, 1 ); |
|
261 | + if (0 === strpos($extras, '?')) { |
|
262 | + $extras = substr($extras, 1); |
|
263 | 263 | } |
264 | 264 | |
265 | - $extras_args = wp_parse_args( $extras ); |
|
265 | + $extras_args = wp_parse_args($extras); |
|
266 | 266 | |
267 | 267 | // Set nonce if payment id exist in extra params. |
268 | - if ( array_key_exists( 'payment-id', $extras_args ) ) { |
|
269 | - $extras_args['_wpnonce'] = wp_create_nonce( "give-failed-donation-{$extras_args['payment-id']}" ); |
|
270 | - $extras = http_build_query( $extras_args ); |
|
268 | + if (array_key_exists('payment-id', $extras_args)) { |
|
269 | + $extras_args['_wpnonce'] = wp_create_nonce("give-failed-donation-{$extras_args['payment-id']}"); |
|
270 | + $extras = http_build_query($extras_args); |
|
271 | 271 | } |
272 | 272 | |
273 | - $uri = ! empty( $give_options['failure_page'] ) ? |
|
274 | - trailingslashit( get_permalink( $give_options['failure_page'] ) ) : |
|
275 | - home_url(); |
|
273 | + $uri = ! empty($give_options['failure_page']) ? |
|
274 | + trailingslashit(get_permalink($give_options['failure_page'])) : home_url(); |
|
276 | 275 | |
277 | 276 | |
278 | - if ( $extras ) { |
|
277 | + if ($extras) { |
|
279 | 278 | $uri .= "?{$extras}"; |
280 | 279 | } |
281 | 280 | |
282 | - return apply_filters( 'give_get_failed_transaction_uri', $uri ); |
|
281 | + return apply_filters('give_get_failed_transaction_uri', $uri); |
|
283 | 282 | } |
284 | 283 | |
285 | 284 | /** |
@@ -290,9 +289,9 @@ discard block |
||
290 | 289 | */ |
291 | 290 | function give_is_failed_transaction_page() { |
292 | 291 | $give_options = give_get_settings(); |
293 | - $ret = isset( $give_options['failure_page'] ) ? is_page( $give_options['failure_page'] ) : false; |
|
292 | + $ret = isset($give_options['failure_page']) ? is_page($give_options['failure_page']) : false; |
|
294 | 293 | |
295 | - return apply_filters( 'give_is_failure_page', $ret ); |
|
294 | + return apply_filters('give_is_failure_page', $ret); |
|
296 | 295 | } |
297 | 296 | |
298 | 297 | /** |
@@ -305,25 +304,25 @@ discard block |
||
305 | 304 | */ |
306 | 305 | function give_listen_for_failed_payments() { |
307 | 306 | |
308 | - $failed_page = give_get_option( 'failure_page', 0 ); |
|
309 | - $payment_id = ! empty( $_GET['payment-id'] ) ? absint( $_GET['payment-id'] ) : 0; |
|
310 | - $nonce = ! empty( $_GET['_wpnonce'] ) ? give_clean( $_GET['_wpnonce'] ) : false; |
|
307 | + $failed_page = give_get_option('failure_page', 0); |
|
308 | + $payment_id = ! empty($_GET['payment-id']) ? absint($_GET['payment-id']) : 0; |
|
309 | + $nonce = ! empty($_GET['_wpnonce']) ? give_clean($_GET['_wpnonce']) : false; |
|
311 | 310 | |
312 | 311 | // Bailout. |
313 | - if ( ! $failed_page || ! is_page( $failed_page ) || ! $payment_id || ! $nonce ) { |
|
312 | + if ( ! $failed_page || ! is_page($failed_page) || ! $payment_id || ! $nonce) { |
|
314 | 313 | return false; |
315 | 314 | } |
316 | 315 | |
317 | 316 | // Security check. |
318 | - if ( ! wp_verify_nonce( $nonce, "give-failed-donation-{$payment_id}" ) ) { |
|
319 | - wp_die( __( 'Nonce verification failed.', 'give' ), __( 'Error', 'give' ) ); |
|
317 | + if ( ! wp_verify_nonce($nonce, "give-failed-donation-{$payment_id}")) { |
|
318 | + wp_die(__('Nonce verification failed.', 'give'), __('Error', 'give')); |
|
320 | 319 | } |
321 | 320 | |
322 | 321 | // Set payment status to failure |
323 | - give_update_payment_status( $payment_id, 'failed' ); |
|
322 | + give_update_payment_status($payment_id, 'failed'); |
|
324 | 323 | } |
325 | 324 | |
326 | -add_action( 'template_redirect', 'give_listen_for_failed_payments' ); |
|
325 | +add_action('template_redirect', 'give_listen_for_failed_payments'); |
|
327 | 326 | |
328 | 327 | /** |
329 | 328 | * Retrieve the Donation History page URI |
@@ -336,9 +335,9 @@ discard block |
||
336 | 335 | function give_get_history_page_uri() { |
337 | 336 | $give_options = give_get_settings(); |
338 | 337 | |
339 | - $history_page = isset( $give_options['history_page'] ) ? get_permalink( absint( $give_options['history_page'] ) ) : get_bloginfo( 'url' ); |
|
338 | + $history_page = isset($give_options['history_page']) ? get_permalink(absint($give_options['history_page'])) : get_bloginfo('url'); |
|
340 | 339 | |
341 | - return apply_filters( 'give_get_history_page_uri', $history_page ); |
|
340 | + return apply_filters('give_get_history_page_uri', $history_page); |
|
342 | 341 | } |
343 | 342 | |
344 | 343 | /** |
@@ -351,11 +350,11 @@ discard block |
||
351 | 350 | * @since 1.0 |
352 | 351 | * @return bool |
353 | 352 | */ |
354 | -function give_field_is_required( $field = '', $form_id ) { |
|
353 | +function give_field_is_required($field = '', $form_id) { |
|
355 | 354 | |
356 | - $required_fields = give_get_required_fields( $form_id ); |
|
355 | + $required_fields = give_get_required_fields($form_id); |
|
357 | 356 | |
358 | - return array_key_exists( $field, $required_fields ); |
|
357 | + return array_key_exists($field, $required_fields); |
|
359 | 358 | } |
360 | 359 | |
361 | 360 | /** |
@@ -372,12 +371,12 @@ discard block |
||
372 | 371 | * |
373 | 372 | * @return void |
374 | 373 | */ |
375 | -function give_record_donation_in_log( $give_form_id = 0, $payment_id, $price_id = false, $donation_date = null ) { |
|
374 | +function give_record_donation_in_log($give_form_id = 0, $payment_id, $price_id = false, $donation_date = null) { |
|
376 | 375 | $log_data = array( |
377 | 376 | 'log_parent' => $payment_id, |
378 | 377 | 'log_type' => 'sale', |
379 | - 'log_date' => isset( $donation_date ) ? $donation_date : null, |
|
380 | - 'log_date_gmt' => isset( $donation_date ) ? $donation_date : null, |
|
378 | + 'log_date' => isset($donation_date) ? $donation_date : null, |
|
379 | + 'log_date_gmt' => isset($donation_date) ? $donation_date : null, |
|
381 | 380 | ); |
382 | 381 | |
383 | 382 | $log_meta = array( |
@@ -385,7 +384,7 @@ discard block |
||
385 | 384 | 'price_id' => (int) $price_id, |
386 | 385 | ); |
387 | 386 | |
388 | - Give()->logs->insert_log( $log_data, $log_meta ); |
|
387 | + Give()->logs->insert_log($log_data, $log_meta); |
|
389 | 388 | } |
390 | 389 | |
391 | 390 | |
@@ -399,13 +398,13 @@ discard block |
||
399 | 398 | * |
400 | 399 | * @return bool|int |
401 | 400 | */ |
402 | -function give_increase_donation_count( $form_id = 0, $quantity = 1 ) { |
|
401 | +function give_increase_donation_count($form_id = 0, $quantity = 1) { |
|
403 | 402 | $quantity = (int) $quantity; |
404 | 403 | |
405 | 404 | /** @var \Give_Donate_Form $form */ |
406 | - $form = new Give_Donate_Form( $form_id ); |
|
405 | + $form = new Give_Donate_Form($form_id); |
|
407 | 406 | |
408 | - return $form->increase_sales( $quantity ); |
|
407 | + return $form->increase_sales($quantity); |
|
409 | 408 | } |
410 | 409 | |
411 | 410 | /** |
@@ -418,13 +417,13 @@ discard block |
||
418 | 417 | * |
419 | 418 | * @return bool|int |
420 | 419 | */ |
421 | -function give_decrease_donation_count( $form_id = 0, $quantity = 1 ) { |
|
420 | +function give_decrease_donation_count($form_id = 0, $quantity = 1) { |
|
422 | 421 | $quantity = (int) $quantity; |
423 | 422 | |
424 | 423 | /** @var \Give_Donate_Form $form */ |
425 | - $form = new Give_Donate_Form( $form_id ); |
|
424 | + $form = new Give_Donate_Form($form_id); |
|
426 | 425 | |
427 | - return $form->decrease_sales( $quantity ); |
|
426 | + return $form->decrease_sales($quantity); |
|
428 | 427 | } |
429 | 428 | |
430 | 429 | /** |
@@ -440,11 +439,11 @@ discard block |
||
440 | 439 | * |
441 | 440 | * @return bool|int |
442 | 441 | */ |
443 | -function give_increase_earnings( $give_form_id = 0, $amount, $payment_id = 0 ) { |
|
442 | +function give_increase_earnings($give_form_id = 0, $amount, $payment_id = 0) { |
|
444 | 443 | /** @var \Give_Donate_Form $form */ |
445 | - $form = new Give_Donate_Form( $give_form_id ); |
|
444 | + $form = new Give_Donate_Form($give_form_id); |
|
446 | 445 | |
447 | - return $form->increase_earnings( $amount, $payment_id ); |
|
446 | + return $form->increase_earnings($amount, $payment_id); |
|
448 | 447 | } |
449 | 448 | |
450 | 449 | /** |
@@ -462,11 +461,11 @@ discard block |
||
462 | 461 | * |
463 | 462 | * @return bool|int |
464 | 463 | */ |
465 | -function give_decrease_form_earnings( $form_id = 0, $amount, $payment_id = 0 ) { |
|
464 | +function give_decrease_form_earnings($form_id = 0, $amount, $payment_id = 0) { |
|
466 | 465 | /** @var \Give_Donate_Form $form */ |
467 | - $form = new Give_Donate_Form( $form_id ); |
|
466 | + $form = new Give_Donate_Form($form_id); |
|
468 | 467 | |
469 | - return $form->decrease_earnings( $amount, $payment_id ); |
|
468 | + return $form->decrease_earnings($amount, $payment_id); |
|
470 | 469 | } |
471 | 470 | |
472 | 471 | |
@@ -479,15 +478,15 @@ discard block |
||
479 | 478 | * |
480 | 479 | * @return int $earnings Earnings for a certain form |
481 | 480 | */ |
482 | -function give_get_form_earnings_stats( $form_id = 0 ) { |
|
483 | - $give_form = new Give_Donate_Form( $form_id ); |
|
481 | +function give_get_form_earnings_stats($form_id = 0) { |
|
482 | + $give_form = new Give_Donate_Form($form_id); |
|
484 | 483 | |
485 | 484 | /** |
486 | 485 | * Filter the form earnings |
487 | 486 | * |
488 | 487 | * @since 1.8.17 |
489 | 488 | */ |
490 | - return apply_filters( 'give_get_form_earnings_stats', $give_form->earnings, $form_id, $give_form ); |
|
489 | + return apply_filters('give_get_form_earnings_stats', $give_form->earnings, $form_id, $give_form); |
|
491 | 490 | } |
492 | 491 | |
493 | 492 | |
@@ -500,8 +499,8 @@ discard block |
||
500 | 499 | * |
501 | 500 | * @return int $sales Amount of sales for a certain form |
502 | 501 | */ |
503 | -function give_get_form_sales_stats( $give_form_id = 0 ) { |
|
504 | - $give_form = new Give_Donate_Form( $give_form_id ); |
|
502 | +function give_get_form_sales_stats($give_form_id = 0) { |
|
503 | + $give_form = new Give_Donate_Form($give_form_id); |
|
505 | 504 | |
506 | 505 | return $give_form->sales; |
507 | 506 | } |
@@ -516,16 +515,16 @@ discard block |
||
516 | 515 | * |
517 | 516 | * @return float $sales Average monthly sales |
518 | 517 | */ |
519 | -function give_get_average_monthly_form_sales( $form_id = 0 ) { |
|
520 | - $sales = give_get_form_sales_stats( $form_id ); |
|
521 | - $release_date = get_post_field( 'post_date', $form_id ); |
|
518 | +function give_get_average_monthly_form_sales($form_id = 0) { |
|
519 | + $sales = give_get_form_sales_stats($form_id); |
|
520 | + $release_date = get_post_field('post_date', $form_id); |
|
522 | 521 | |
523 | - $diff = abs( current_time( 'timestamp' ) - strtotime( $release_date ) ); |
|
522 | + $diff = abs(current_time('timestamp') - strtotime($release_date)); |
|
524 | 523 | |
525 | - $months = floor( $diff / ( 30 * 60 * 60 * 24 ) ); // Number of months since publication |
|
524 | + $months = floor($diff / (30 * 60 * 60 * 24)); // Number of months since publication |
|
526 | 525 | |
527 | - if ( $months > 0 ) { |
|
528 | - $sales = ( $sales / $months ); |
|
526 | + if ($months > 0) { |
|
527 | + $sales = ($sales / $months); |
|
529 | 528 | } |
530 | 529 | |
531 | 530 | return $sales; |
@@ -541,16 +540,16 @@ discard block |
||
541 | 540 | * |
542 | 541 | * @return float $earnings Average monthly earnings |
543 | 542 | */ |
544 | -function give_get_average_monthly_form_earnings( $form_id = 0 ) { |
|
545 | - $earnings = give_get_form_earnings_stats( $form_id ); |
|
546 | - $release_date = get_post_field( 'post_date', $form_id ); |
|
543 | +function give_get_average_monthly_form_earnings($form_id = 0) { |
|
544 | + $earnings = give_get_form_earnings_stats($form_id); |
|
545 | + $release_date = get_post_field('post_date', $form_id); |
|
547 | 546 | |
548 | - $diff = abs( current_time( 'timestamp' ) - strtotime( $release_date ) ); |
|
547 | + $diff = abs(current_time('timestamp') - strtotime($release_date)); |
|
549 | 548 | |
550 | - $months = floor( $diff / ( 30 * 60 * 60 * 24 ) ); // Number of months since publication |
|
549 | + $months = floor($diff / (30 * 60 * 60 * 24)); // Number of months since publication |
|
551 | 550 | |
552 | - if ( $months > 0 ) { |
|
553 | - $earnings = ( $earnings / $months ); |
|
551 | + if ($months > 0) { |
|
552 | + $earnings = ($earnings / $months); |
|
554 | 553 | } |
555 | 554 | |
556 | 555 | return $earnings < 0 ? 0 : $earnings; |
@@ -571,34 +570,34 @@ discard block |
||
571 | 570 | * |
572 | 571 | * @return string $price_name Name of the price option |
573 | 572 | */ |
574 | -function give_get_price_option_name( $form_id = 0, $price_id = 0, $payment_id = 0, $use_fallback = true ) { |
|
573 | +function give_get_price_option_name($form_id = 0, $price_id = 0, $payment_id = 0, $use_fallback = true) { |
|
575 | 574 | |
576 | - $prices = give_get_variable_prices( $form_id ); |
|
575 | + $prices = give_get_variable_prices($form_id); |
|
577 | 576 | $price_name = ''; |
578 | 577 | |
579 | - if ( false === $prices ) { |
|
578 | + if (false === $prices) { |
|
580 | 579 | return $price_name; |
581 | 580 | } |
582 | 581 | |
583 | - foreach ( $prices as $price ) { |
|
582 | + foreach ($prices as $price) { |
|
584 | 583 | |
585 | - if ( intval( $price['_give_id']['level_id'] ) === intval( $price_id ) ) { |
|
584 | + if (intval($price['_give_id']['level_id']) === intval($price_id)) { |
|
586 | 585 | |
587 | - $price_text = isset( $price['_give_text'] ) ? $price['_give_text'] : ''; |
|
586 | + $price_text = isset($price['_give_text']) ? $price['_give_text'] : ''; |
|
588 | 587 | $price_fallback = $use_fallback ? |
589 | 588 | give_currency_filter( |
590 | 589 | give_format_amount( |
591 | 590 | $price['_give_amount'], |
592 | - array( 'sanitize' => false ) |
|
591 | + array('sanitize' => false) |
|
593 | 592 | ), |
594 | - array( 'decode_currency' => true ) |
|
593 | + array('decode_currency' => true) |
|
595 | 594 | ) : ''; |
596 | - $price_name = ! empty( $price_text ) ? $price_text : $price_fallback; |
|
595 | + $price_name = ! empty($price_text) ? $price_text : $price_fallback; |
|
597 | 596 | |
598 | 597 | } |
599 | 598 | } |
600 | 599 | |
601 | - return apply_filters( 'give_get_price_option_name', $price_name, $form_id, $payment_id, $price_id ); |
|
600 | + return apply_filters('give_get_price_option_name', $price_name, $form_id, $payment_id, $price_id); |
|
602 | 601 | } |
603 | 602 | |
604 | 603 | |
@@ -612,25 +611,25 @@ discard block |
||
612 | 611 | * |
613 | 612 | * @return string $range A fully formatted price range |
614 | 613 | */ |
615 | -function give_price_range( $form_id = 0, $formatted = true ) { |
|
616 | - $low = give_get_lowest_price_option( $form_id ); |
|
617 | - $high = give_get_highest_price_option( $form_id ); |
|
618 | - $order_type = ! empty( $_REQUEST['order'] ) ? $_REQUEST['order'] : 'asc'; |
|
614 | +function give_price_range($form_id = 0, $formatted = true) { |
|
615 | + $low = give_get_lowest_price_option($form_id); |
|
616 | + $high = give_get_highest_price_option($form_id); |
|
617 | + $order_type = ! empty($_REQUEST['order']) ? $_REQUEST['order'] : 'asc'; |
|
619 | 618 | |
620 | 619 | $range = sprintf( |
621 | 620 | '<span class="give_price_range_%1$s">%2$s</span><span class="give_price_range_sep"> – </span><span class="give_price_range_%3$s">%4$s</span>', |
622 | 621 | 'asc' === $order_type ? 'low' : 'high', |
623 | - 'asc' === $order_type ? give_currency_filter( give_format_amount( $low, array( 'sanitize' => false ) ) ) : give_currency_filter( give_format_amount( $high, array( 'sanitize' => false ) ) ), |
|
622 | + 'asc' === $order_type ? give_currency_filter(give_format_amount($low, array('sanitize' => false))) : give_currency_filter(give_format_amount($high, array('sanitize' => false))), |
|
624 | 623 | 'asc' === $order_type ? 'high' : 'low', |
625 | - 'asc' === $order_type ? give_currency_filter( give_format_amount( $high, array( 'sanitize' => false ) ) ) : give_currency_filter( give_format_amount( $low, array( 'sanitize' => false ) ) ) |
|
624 | + 'asc' === $order_type ? give_currency_filter(give_format_amount($high, array('sanitize' => false))) : give_currency_filter(give_format_amount($low, array('sanitize' => false))) |
|
626 | 625 | |
627 | 626 | ); |
628 | 627 | |
629 | - if ( ! $formatted ) { |
|
630 | - $range = wp_strip_all_tags( $range ); |
|
628 | + if ( ! $formatted) { |
|
629 | + $range = wp_strip_all_tags($range); |
|
631 | 630 | } |
632 | 631 | |
633 | - return apply_filters( 'give_price_range', $range, $form_id, $low, $high ); |
|
632 | + return apply_filters('give_price_range', $range, $form_id, $low, $high); |
|
634 | 633 | } |
635 | 634 | |
636 | 635 | |
@@ -645,35 +644,35 @@ discard block |
||
645 | 644 | * |
646 | 645 | * @return int ID of the lowest price |
647 | 646 | */ |
648 | -function give_get_lowest_price_id( $form_id = 0 ) { |
|
647 | +function give_get_lowest_price_id($form_id = 0) { |
|
649 | 648 | |
650 | - if ( empty( $form_id ) ) { |
|
649 | + if (empty($form_id)) { |
|
651 | 650 | $form_id = get_the_ID(); |
652 | 651 | } |
653 | 652 | |
654 | - if ( ! give_has_variable_prices( $form_id ) ) { |
|
655 | - return give_get_form_price( $form_id ); |
|
653 | + if ( ! give_has_variable_prices($form_id)) { |
|
654 | + return give_get_form_price($form_id); |
|
656 | 655 | } |
657 | 656 | |
658 | - $prices = give_get_variable_prices( $form_id ); |
|
657 | + $prices = give_get_variable_prices($form_id); |
|
659 | 658 | |
660 | 659 | $min = $min_id = 0; |
661 | 660 | |
662 | - if ( ! empty( $prices ) ) { |
|
661 | + if ( ! empty($prices)) { |
|
663 | 662 | |
664 | - foreach ( $prices as $key => $price ) { |
|
663 | + foreach ($prices as $key => $price) { |
|
665 | 664 | |
666 | - if ( empty( $price['_give_amount'] ) ) { |
|
665 | + if (empty($price['_give_amount'])) { |
|
667 | 666 | continue; |
668 | 667 | } |
669 | 668 | |
670 | - if ( ! isset( $min ) ) { |
|
669 | + if ( ! isset($min)) { |
|
671 | 670 | $min = $price['_give_amount']; |
672 | 671 | } else { |
673 | - $min = min( $min, $price['_give_amount'] ); |
|
672 | + $min = min($min, $price['_give_amount']); |
|
674 | 673 | } |
675 | 674 | |
676 | - if ( $price['_give_amount'] == $min ) { |
|
675 | + if ($price['_give_amount'] == $min) { |
|
677 | 676 | $min_id = $price['_give_id']['level_id']; |
678 | 677 | } |
679 | 678 | } |
@@ -691,22 +690,22 @@ discard block |
||
691 | 690 | * |
692 | 691 | * @return float Amount of the lowest price |
693 | 692 | */ |
694 | -function give_get_lowest_price_option( $form_id = 0 ) { |
|
695 | - if ( empty( $form_id ) ) { |
|
693 | +function give_get_lowest_price_option($form_id = 0) { |
|
694 | + if (empty($form_id)) { |
|
696 | 695 | $form_id = get_the_ID(); |
697 | 696 | } |
698 | 697 | |
699 | - if ( ! give_has_variable_prices( $form_id ) ) { |
|
700 | - return give_get_form_price( $form_id ); |
|
698 | + if ( ! give_has_variable_prices($form_id)) { |
|
699 | + return give_get_form_price($form_id); |
|
701 | 700 | } |
702 | 701 | |
703 | - if ( ! ( $low = get_post_meta( $form_id, '_give_levels_minimum_amount', true ) ) ) { |
|
702 | + if ( ! ($low = get_post_meta($form_id, '_give_levels_minimum_amount', true))) { |
|
704 | 703 | // Backward compatibility. |
705 | - $prices = wp_list_pluck( give_get_variable_prices( $form_id ), '_give_amount' ); |
|
706 | - $low = ! empty( $prices ) ? min( $prices ) : 0; |
|
704 | + $prices = wp_list_pluck(give_get_variable_prices($form_id), '_give_amount'); |
|
705 | + $low = ! empty($prices) ? min($prices) : 0; |
|
707 | 706 | } |
708 | 707 | |
709 | - return give_maybe_sanitize_amount( $low ); |
|
708 | + return give_maybe_sanitize_amount($low); |
|
710 | 709 | } |
711 | 710 | |
712 | 711 | /** |
@@ -718,23 +717,23 @@ discard block |
||
718 | 717 | * |
719 | 718 | * @return float Amount of the highest price |
720 | 719 | */ |
721 | -function give_get_highest_price_option( $form_id = 0 ) { |
|
720 | +function give_get_highest_price_option($form_id = 0) { |
|
722 | 721 | |
723 | - if ( empty( $form_id ) ) { |
|
722 | + if (empty($form_id)) { |
|
724 | 723 | $form_id = get_the_ID(); |
725 | 724 | } |
726 | 725 | |
727 | - if ( ! give_has_variable_prices( $form_id ) ) { |
|
728 | - return give_get_form_price( $form_id ); |
|
726 | + if ( ! give_has_variable_prices($form_id)) { |
|
727 | + return give_get_form_price($form_id); |
|
729 | 728 | } |
730 | 729 | |
731 | - if ( ! ( $high = get_post_meta( $form_id, '_give_levels_maximum_amount', true ) ) ) { |
|
730 | + if ( ! ($high = get_post_meta($form_id, '_give_levels_maximum_amount', true))) { |
|
732 | 731 | // Backward compatibility. |
733 | - $prices = wp_list_pluck( give_get_variable_prices( $form_id ), '_give_amount' ); |
|
734 | - $high = ! empty( $prices ) ? max( $prices ) : 0; |
|
732 | + $prices = wp_list_pluck(give_get_variable_prices($form_id), '_give_amount'); |
|
733 | + $high = ! empty($prices) ? max($prices) : 0; |
|
735 | 734 | } |
736 | 735 | |
737 | - return give_maybe_sanitize_amount( $high ); |
|
736 | + return give_maybe_sanitize_amount($high); |
|
738 | 737 | } |
739 | 738 | |
740 | 739 | /** |
@@ -746,15 +745,15 @@ discard block |
||
746 | 745 | * |
747 | 746 | * @return mixed string|int Price of the form |
748 | 747 | */ |
749 | -function give_get_form_price( $form_id = 0 ) { |
|
748 | +function give_get_form_price($form_id = 0) { |
|
750 | 749 | |
751 | - if ( empty( $form_id ) ) { |
|
750 | + if (empty($form_id)) { |
|
752 | 751 | return false; |
753 | 752 | } |
754 | 753 | |
755 | - $form = new Give_Donate_Form( $form_id ); |
|
754 | + $form = new Give_Donate_Form($form_id); |
|
756 | 755 | |
757 | - return $form->__get( 'price' ); |
|
756 | + return $form->__get('price'); |
|
758 | 757 | } |
759 | 758 | |
760 | 759 | /** |
@@ -766,13 +765,13 @@ discard block |
||
766 | 765 | * |
767 | 766 | * @return mixed string|int Minimum price of the form |
768 | 767 | */ |
769 | -function give_get_form_minimum_price( $form_id = 0 ) { |
|
768 | +function give_get_form_minimum_price($form_id = 0) { |
|
770 | 769 | |
771 | - if ( empty( $form_id ) ) { |
|
770 | + if (empty($form_id)) { |
|
772 | 771 | return false; |
773 | 772 | } |
774 | 773 | |
775 | - $form = new Give_Donate_Form( $form_id ); |
|
774 | + $form = new Give_Donate_Form($form_id); |
|
776 | 775 | |
777 | 776 | return $form->get_minimum_price(); |
778 | 777 | |
@@ -787,13 +786,13 @@ discard block |
||
787 | 786 | * |
788 | 787 | * @return bool|float |
789 | 788 | */ |
790 | -function give_get_form_maximum_price( $form_id = 0 ) { |
|
789 | +function give_get_form_maximum_price($form_id = 0) { |
|
791 | 790 | |
792 | - if ( empty( $form_id ) ) { |
|
791 | + if (empty($form_id)) { |
|
793 | 792 | return false; |
794 | 793 | } |
795 | 794 | |
796 | - $form = new Give_Donate_Form( $form_id ); |
|
795 | + $form = new Give_Donate_Form($form_id); |
|
797 | 796 | |
798 | 797 | return $form->get_maximum_price(); |
799 | 798 | } |
@@ -809,48 +808,48 @@ discard block |
||
809 | 808 | * |
810 | 809 | * @return int $formatted_price |
811 | 810 | */ |
812 | -function give_price( $form_id = 0, $echo = true, $price_id = false ) { |
|
811 | +function give_price($form_id = 0, $echo = true, $price_id = false) { |
|
813 | 812 | $price = 0; |
814 | 813 | |
815 | - if ( empty( $form_id ) ) { |
|
814 | + if (empty($form_id)) { |
|
816 | 815 | $form_id = get_the_ID(); |
817 | 816 | } |
818 | 817 | |
819 | - if ( give_has_variable_prices( $form_id ) ) { |
|
818 | + if (give_has_variable_prices($form_id)) { |
|
820 | 819 | |
821 | - $prices = give_get_variable_prices( $form_id ); |
|
820 | + $prices = give_get_variable_prices($form_id); |
|
822 | 821 | |
823 | - if ( false !== $price_id ) { |
|
822 | + if (false !== $price_id) { |
|
824 | 823 | |
825 | 824 | // loop through multi-prices to see which is default |
826 | - foreach ( $prices as $price ) { |
|
825 | + foreach ($prices as $price) { |
|
827 | 826 | // this is the default price |
828 | - if ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) { |
|
827 | + if (isset($price['_give_default']) && $price['_give_default'] === 'default') { |
|
829 | 828 | $price = (float) $price['_give_amount']; |
830 | 829 | }; |
831 | 830 | } |
832 | 831 | } else { |
833 | 832 | |
834 | - $price = give_get_lowest_price_option( $form_id ); |
|
833 | + $price = give_get_lowest_price_option($form_id); |
|
835 | 834 | } |
836 | 835 | } else { |
837 | 836 | |
838 | - $price = give_get_form_price( $form_id ); |
|
837 | + $price = give_get_form_price($form_id); |
|
839 | 838 | } |
840 | 839 | |
841 | - $price = apply_filters( 'give_form_price', give_maybe_sanitize_amount( $price ), $form_id ); |
|
842 | - $formatted_price = '<span class="give_price" id="give_price_' . $form_id . '">' . $price . '</span>'; |
|
843 | - $formatted_price = apply_filters( 'give_form_price_after_html', $formatted_price, $form_id, $price ); |
|
840 | + $price = apply_filters('give_form_price', give_maybe_sanitize_amount($price), $form_id); |
|
841 | + $formatted_price = '<span class="give_price" id="give_price_'.$form_id.'">'.$price.'</span>'; |
|
842 | + $formatted_price = apply_filters('give_form_price_after_html', $formatted_price, $form_id, $price); |
|
844 | 843 | |
845 | - if ( $echo ) { |
|
844 | + if ($echo) { |
|
846 | 845 | echo $formatted_price; |
847 | 846 | } else { |
848 | 847 | return $formatted_price; |
849 | 848 | } |
850 | 849 | } |
851 | 850 | |
852 | -add_filter( 'give_form_price', 'give_format_amount', 10 ); |
|
853 | -add_filter( 'give_form_price', 'give_currency_filter', 20 ); |
|
851 | +add_filter('give_form_price', 'give_format_amount', 10); |
|
852 | +add_filter('give_form_price', 'give_currency_filter', 20); |
|
854 | 853 | |
855 | 854 | |
856 | 855 | /** |
@@ -863,19 +862,19 @@ discard block |
||
863 | 862 | * |
864 | 863 | * @return float $amount Amount of the price option |
865 | 864 | */ |
866 | -function give_get_price_option_amount( $form_id = 0, $price_id = 0 ) { |
|
867 | - $prices = give_get_variable_prices( $form_id ); |
|
865 | +function give_get_price_option_amount($form_id = 0, $price_id = 0) { |
|
866 | + $prices = give_get_variable_prices($form_id); |
|
868 | 867 | |
869 | 868 | $amount = 0.00; |
870 | 869 | |
871 | - foreach ( $prices as $price ) { |
|
872 | - if ( isset( $price['_give_id']['level_id'] ) && $price['_give_id']['level_id'] == $price_id ) { |
|
873 | - $amount = isset( $price['_give_amount'] ) ? $price['_give_amount'] : 0.00; |
|
870 | + foreach ($prices as $price) { |
|
871 | + if (isset($price['_give_id']['level_id']) && $price['_give_id']['level_id'] == $price_id) { |
|
872 | + $amount = isset($price['_give_amount']) ? $price['_give_amount'] : 0.00; |
|
874 | 873 | break; |
875 | 874 | }; |
876 | 875 | } |
877 | 876 | |
878 | - return apply_filters( 'give_get_price_option_amount', give_maybe_sanitize_amount( $amount ), $form_id, $price_id ); |
|
877 | + return apply_filters('give_get_price_option_amount', give_maybe_sanitize_amount($amount), $form_id, $price_id); |
|
879 | 878 | } |
880 | 879 | |
881 | 880 | /** |
@@ -887,13 +886,13 @@ discard block |
||
887 | 886 | * |
888 | 887 | * @return mixed string|int Goal of the form |
889 | 888 | */ |
890 | -function give_get_form_goal( $form_id = 0 ) { |
|
889 | +function give_get_form_goal($form_id = 0) { |
|
891 | 890 | |
892 | - if ( empty( $form_id ) ) { |
|
891 | + if (empty($form_id)) { |
|
893 | 892 | return false; |
894 | 893 | } |
895 | 894 | |
896 | - $form = new Give_Donate_Form( $form_id ); |
|
895 | + $form = new Give_Donate_Form($form_id); |
|
897 | 896 | |
898 | 897 | return $form->goal; |
899 | 898 | |
@@ -908,13 +907,13 @@ discard block |
||
908 | 907 | * |
909 | 908 | * @return mixed string|int Goal of the form |
910 | 909 | */ |
911 | -function give_get_form_goal_format( $form_id = 0 ) { |
|
910 | +function give_get_form_goal_format($form_id = 0) { |
|
912 | 911 | |
913 | - if ( empty( $form_id ) ) { |
|
912 | + if (empty($form_id)) { |
|
914 | 913 | return false; |
915 | 914 | } |
916 | 915 | |
917 | - return give_get_meta( $form_id, '_give_goal_format', true ); |
|
916 | + return give_get_meta($form_id, '_give_goal_format', true); |
|
918 | 917 | |
919 | 918 | } |
920 | 919 | |
@@ -928,19 +927,19 @@ discard block |
||
928 | 927 | * |
929 | 928 | * @return string $formatted_goal |
930 | 929 | */ |
931 | -function give_goal( $form_id = 0, $echo = true ) { |
|
930 | +function give_goal($form_id = 0, $echo = true) { |
|
932 | 931 | |
933 | - if ( empty( $form_id ) ) { |
|
932 | + if (empty($form_id)) { |
|
934 | 933 | $form_id = get_the_ID(); |
935 | 934 | } |
936 | 935 | |
937 | - $goal = give_get_form_goal( $form_id ); |
|
938 | - $goal_format = give_get_form_goal_format( $form_id ); |
|
936 | + $goal = give_get_form_goal($form_id); |
|
937 | + $goal_format = give_get_form_goal_format($form_id); |
|
939 | 938 | |
940 | - if ( 'donation' === $goal_format ) { |
|
939 | + if ('donation' === $goal_format) { |
|
941 | 940 | $goal = "{$goal} donations"; |
942 | 941 | } else { |
943 | - $goal = apply_filters( 'give_form_goal', give_maybe_sanitize_amount( $goal ), $form_id ); |
|
942 | + $goal = apply_filters('give_form_goal', give_maybe_sanitize_amount($goal), $form_id); |
|
944 | 943 | } |
945 | 944 | |
946 | 945 | $formatted_goal = sprintf( |
@@ -948,17 +947,17 @@ discard block |
||
948 | 947 | $form_id, |
949 | 948 | $goal |
950 | 949 | ); |
951 | - $formatted_goal = apply_filters( 'give_form_price_after_html', $formatted_goal, $form_id, $goal ); |
|
950 | + $formatted_goal = apply_filters('give_form_price_after_html', $formatted_goal, $form_id, $goal); |
|
952 | 951 | |
953 | - if ( $echo ) { |
|
952 | + if ($echo) { |
|
954 | 953 | echo $formatted_goal; |
955 | 954 | } else { |
956 | 955 | return $formatted_goal; |
957 | 956 | } |
958 | 957 | } |
959 | 958 | |
960 | -add_filter( 'give_form_goal', 'give_format_amount', 10 ); |
|
961 | -add_filter( 'give_form_goal', 'give_currency_filter', 20 ); |
|
959 | +add_filter('give_form_goal', 'give_format_amount', 10); |
|
960 | +add_filter('give_form_goal', 'give_currency_filter', 20); |
|
962 | 961 | |
963 | 962 | |
964 | 963 | /** |
@@ -970,15 +969,15 @@ discard block |
||
970 | 969 | * |
971 | 970 | * @return bool $ret Whether or not the logged_in_only setting is set |
972 | 971 | */ |
973 | -function give_logged_in_only( $form_id ) { |
|
972 | +function give_logged_in_only($form_id) { |
|
974 | 973 | // If _give_logged_in_only is set to enable then guest can donate from that specific form. |
975 | 974 | // Otherwise it is member only donation form. |
976 | - $val = give_get_meta( $form_id, '_give_logged_in_only', true ); |
|
977 | - $val = ! empty( $val ) ? $val : 'enabled'; |
|
975 | + $val = give_get_meta($form_id, '_give_logged_in_only', true); |
|
976 | + $val = ! empty($val) ? $val : 'enabled'; |
|
978 | 977 | |
979 | - $ret = ! give_is_setting_enabled( $val ); |
|
978 | + $ret = ! give_is_setting_enabled($val); |
|
980 | 979 | |
981 | - return (bool) apply_filters( 'give_logged_in_only', $ret, $form_id ); |
|
980 | + return (bool) apply_filters('give_logged_in_only', $ret, $form_id); |
|
982 | 981 | } |
983 | 982 | |
984 | 983 | |
@@ -991,11 +990,11 @@ discard block |
||
991 | 990 | * |
992 | 991 | * @return string |
993 | 992 | */ |
994 | -function give_show_login_register_option( $form_id ) { |
|
993 | +function give_show_login_register_option($form_id) { |
|
995 | 994 | |
996 | - $show_register_form = give_get_meta( $form_id, '_give_show_register_form', true ); |
|
995 | + $show_register_form = give_get_meta($form_id, '_give_show_register_form', true); |
|
997 | 996 | |
998 | - return apply_filters( 'give_show_register_form', $show_register_form, $form_id ); |
|
997 | + return apply_filters('give_show_register_form', $show_register_form, $form_id); |
|
999 | 998 | |
1000 | 999 | } |
1001 | 1000 | |
@@ -1011,12 +1010,12 @@ discard block |
||
1011 | 1010 | * |
1012 | 1011 | * @return array |
1013 | 1012 | */ |
1014 | -function _give_get_prefill_form_field_values( $form_id ) { |
|
1013 | +function _give_get_prefill_form_field_values($form_id) { |
|
1015 | 1014 | $logged_in_donor_info = array(); |
1016 | 1015 | |
1017 | - if ( is_user_logged_in() ) : |
|
1018 | - $donor_data = get_userdata( get_current_user_id() ); |
|
1019 | - $donor = new Give_Donor( get_current_user_id(), true ); |
|
1016 | + if (is_user_logged_in()) : |
|
1017 | + $donor_data = get_userdata(get_current_user_id()); |
|
1018 | + $donor = new Give_Donor(get_current_user_id(), true); |
|
1020 | 1019 | $donor_address = $donor->get_donor_address(); |
1021 | 1020 | $company_name = $donor->get_company_name(); |
1022 | 1021 | |
@@ -1055,23 +1054,23 @@ discard block |
||
1055 | 1054 | |
1056 | 1055 | // Bailout: Auto fill form field values only form form which donor is donating. |
1057 | 1056 | if ( |
1058 | - empty( $_GET['form-id'] ) |
|
1057 | + empty($_GET['form-id']) |
|
1059 | 1058 | || ! $form_id |
1060 | - || ( $form_id !== absint( $_GET['form-id'] ) ) |
|
1059 | + || ($form_id !== absint($_GET['form-id'])) |
|
1061 | 1060 | ) { |
1062 | 1061 | return $logged_in_donor_info; |
1063 | 1062 | } |
1064 | 1063 | |
1065 | 1064 | // Get purchase data. |
1066 | - $give_purchase_data = Give()->session->get( 'give_purchase' ); |
|
1065 | + $give_purchase_data = Give()->session->get('give_purchase'); |
|
1067 | 1066 | |
1068 | 1067 | // Get donor info from form data. |
1069 | - $give_donor_info_in_session = empty( $give_purchase_data['post_data'] ) |
|
1068 | + $give_donor_info_in_session = empty($give_purchase_data['post_data']) |
|
1070 | 1069 | ? array() |
1071 | 1070 | : $give_purchase_data['post_data']; |
1072 | 1071 | |
1073 | 1072 | // Output. |
1074 | - return wp_parse_args( $give_donor_info_in_session, $logged_in_donor_info ); |
|
1073 | + return wp_parse_args($give_donor_info_in_session, $logged_in_donor_info); |
|
1075 | 1074 | } |
1076 | 1075 | |
1077 | 1076 | /** |
@@ -1084,13 +1083,13 @@ discard block |
||
1084 | 1083 | * |
1085 | 1084 | * @return int |
1086 | 1085 | */ |
1087 | -function give_get_form_donor_count( $form_id, $args = array() ) { |
|
1086 | +function give_get_form_donor_count($form_id, $args = array()) { |
|
1088 | 1087 | global $wpdb; |
1089 | 1088 | |
1090 | - $cache_key = Give_Cache::get_key( "form_donor_count_{$form_id}", $args, false ); |
|
1091 | - $donor_count = absint( Give_Cache::get_db_query( $cache_key ) ); |
|
1089 | + $cache_key = Give_Cache::get_key("form_donor_count_{$form_id}", $args, false); |
|
1090 | + $donor_count = absint(Give_Cache::get_db_query($cache_key)); |
|
1092 | 1091 | |
1093 | - if ( $form_id && ! $donor_count ) { |
|
1092 | + if ($form_id && ! $donor_count) { |
|
1094 | 1093 | // Set arguments. |
1095 | 1094 | $args = wp_parse_args( |
1096 | 1095 | $args, |
@@ -1124,7 +1123,7 @@ discard block |
||
1124 | 1123 | 'publish' |
1125 | 1124 | ); |
1126 | 1125 | |
1127 | - $donor_count = absint( $wpdb->get_var( $query ) ); |
|
1126 | + $donor_count = absint($wpdb->get_var($query)); |
|
1128 | 1127 | } |
1129 | 1128 | |
1130 | 1129 | |
@@ -1133,9 +1132,9 @@ discard block |
||
1133 | 1132 | * |
1134 | 1133 | * @since 2.1.0 |
1135 | 1134 | */ |
1136 | - $donor_count = apply_filters( 'give_get_form_donor_count', $donor_count, $form_id, $args ); |
|
1135 | + $donor_count = apply_filters('give_get_form_donor_count', $donor_count, $form_id, $args); |
|
1137 | 1136 | |
1138 | - Give_Cache::set_db_query( $cache_key, $donor_count ); |
|
1137 | + Give_Cache::set_db_query($cache_key, $donor_count); |
|
1139 | 1138 | |
1140 | 1139 | return $donor_count; |
1141 | 1140 | } |
@@ -1149,33 +1148,33 @@ discard block |
||
1149 | 1148 | * |
1150 | 1149 | * @return void |
1151 | 1150 | */ |
1152 | -function give_set_form_closed_status( $form_id ) { |
|
1151 | +function give_set_form_closed_status($form_id) { |
|
1153 | 1152 | |
1154 | 1153 | // Bailout. |
1155 | - if ( empty( $form_id ) ) { |
|
1154 | + if (empty($form_id)) { |
|
1156 | 1155 | return; |
1157 | 1156 | } |
1158 | 1157 | |
1159 | 1158 | $open_form = false; |
1160 | - $is_goal_enabled = give_is_setting_enabled( give_get_meta( $form_id, '_give_goal_option', true, 'disabled' ) ); |
|
1159 | + $is_goal_enabled = give_is_setting_enabled(give_get_meta($form_id, '_give_goal_option', true, 'disabled')); |
|
1161 | 1160 | |
1162 | 1161 | // Proceed, if the form goal is enabled. |
1163 | - if ( $is_goal_enabled ) { |
|
1162 | + if ($is_goal_enabled) { |
|
1164 | 1163 | |
1165 | - $close_form_when_goal_achieved = give_is_setting_enabled( give_get_meta( $form_id, '_give_close_form_when_goal_achieved', true, 'disabled' ) ); |
|
1164 | + $close_form_when_goal_achieved = give_is_setting_enabled(give_get_meta($form_id, '_give_close_form_when_goal_achieved', true, 'disabled')); |
|
1166 | 1165 | |
1167 | 1166 | // Proceed, if close form when goal achieved option is enabled. |
1168 | - if ( $close_form_when_goal_achieved ) { |
|
1167 | + if ($close_form_when_goal_achieved) { |
|
1169 | 1168 | |
1170 | - $form = new Give_Donate_Form( $form_id ); |
|
1171 | - $goal_progress_stats = give_goal_progress_stats( $form ); |
|
1169 | + $form = new Give_Donate_Form($form_id); |
|
1170 | + $goal_progress_stats = give_goal_progress_stats($form); |
|
1172 | 1171 | |
1173 | 1172 | // Verify whether the form is closed or not after processing data. |
1174 | 1173 | $closed = $goal_progress_stats['raw_goal'] <= $goal_progress_stats['raw_actual']; |
1175 | 1174 | |
1176 | 1175 | // Update form meta if verified that the form is closed. |
1177 | - if ( $closed ) { |
|
1178 | - give_update_meta( $form_id, '_give_form_status', 'closed' ); |
|
1176 | + if ($closed) { |
|
1177 | + give_update_meta($form_id, '_give_form_status', 'closed'); |
|
1179 | 1178 | } else { |
1180 | 1179 | $open_form = true; |
1181 | 1180 | } |
@@ -1187,8 +1186,8 @@ discard block |
||
1187 | 1186 | } |
1188 | 1187 | |
1189 | 1188 | // If $open_form is true, then update form status to open. |
1190 | - if ( $open_form ) { |
|
1191 | - give_update_meta( $form_id, '_give_form_status', 'open' ); |
|
1189 | + if ($open_form) { |
|
1190 | + give_update_meta($form_id, '_give_form_status', 'open'); |
|
1192 | 1191 | } |
1193 | 1192 | } |
1194 | 1193 | |
@@ -1201,32 +1200,31 @@ discard block |
||
1201 | 1200 | * |
1202 | 1201 | * @return string |
1203 | 1202 | */ |
1204 | -function give_admin_form_goal_stats( $form_id ) { |
|
1203 | +function give_admin_form_goal_stats($form_id) { |
|
1205 | 1204 | |
1206 | 1205 | $html = ''; |
1207 | - $goal_stats = give_goal_progress_stats( $form_id ); |
|
1208 | - $percent_complete = round( ( $goal_stats['raw_actual'] / $goal_stats['raw_goal'] ), 3 ) * 100; |
|
1206 | + $goal_stats = give_goal_progress_stats($form_id); |
|
1207 | + $percent_complete = round(($goal_stats['raw_actual'] / $goal_stats['raw_goal']), 3) * 100; |
|
1209 | 1208 | |
1210 | 1209 | $html .= sprintf( |
1211 | 1210 | '<div class="give-admin-progress-bar" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="%1$s"> |
1212 | 1211 | <span style="width:%1$s%%;"></span> |
1213 | 1212 | </div>', |
1214 | - esc_attr( $goal_stats['progress'] ) |
|
1213 | + esc_attr($goal_stats['progress']) |
|
1215 | 1214 | ); |
1216 | 1215 | |
1217 | 1216 | $html .= sprintf( |
1218 | - ( 'percentage' !== $goal_stats['format'] ) ? |
|
1219 | - '<div class="give-goal-text"><span>%1$s</span> %2$s <a href="%3$s">%4$s</a> %5$s ' : |
|
1220 | - '<div class="give-goal-text"><a href="%3$s">%1$s </a>', |
|
1221 | - ( 'percentage' !== $goal_stats['format'] ) ? $goal_stats['actual'] : $percent_complete . '%', |
|
1222 | - ( 'percentage' !== $goal_stats['format'] ) ? __( 'of', 'give' ) : '', |
|
1223 | - esc_url( admin_url( "post.php?post={$form_id}&action=edit&give_tab=donation_goal_options" ) ), |
|
1217 | + ('percentage' !== $goal_stats['format']) ? |
|
1218 | + '<div class="give-goal-text"><span>%1$s</span> %2$s <a href="%3$s">%4$s</a> %5$s ' : '<div class="give-goal-text"><a href="%3$s">%1$s </a>', |
|
1219 | + ('percentage' !== $goal_stats['format']) ? $goal_stats['actual'] : $percent_complete.'%', |
|
1220 | + ('percentage' !== $goal_stats['format']) ? __('of', 'give') : '', |
|
1221 | + esc_url(admin_url("post.php?post={$form_id}&action=edit&give_tab=donation_goal_options")), |
|
1224 | 1222 | $goal_stats['goal'], |
1225 | - ( 'donors' === $goal_stats['format'] ? __( 'Donors', 'give' ) : ( 'donation' === $goal_stats['format'] ? __( 'Donations', 'give' ) : '' ) ) |
|
1223 | + ('donors' === $goal_stats['format'] ? __('Donors', 'give') : ('donation' === $goal_stats['format'] ? __('Donations', 'give') : '')) |
|
1226 | 1224 | ); |
1227 | 1225 | |
1228 | - if ( $goal_stats['raw_actual'] >= $goal_stats['raw_goal'] ) { |
|
1229 | - $html .= sprintf( '<span class="give-admin-goal-achieved"><span class="dashicons dashicons-star-filled"></span> %s</span>', __( 'Goal achieved', 'give' ) ); |
|
1226 | + if ($goal_stats['raw_actual'] >= $goal_stats['raw_goal']) { |
|
1227 | + $html .= sprintf('<span class="give-admin-goal-achieved"><span class="dashicons dashicons-star-filled"></span> %s</span>', __('Goal achieved', 'give')); |
|
1230 | 1228 | } |
1231 | 1229 | |
1232 | 1230 | $html .= '</div>'; |
@@ -24,7 +24,7 @@ |
||
24 | 24 | * |
25 | 25 | * @throws ReflectionException Exception Handling. |
26 | 26 | * |
27 | - * @return mixed |
|
27 | + * @return false|null |
|
28 | 28 | */ |
29 | 29 | function give_process_donation_form() { |
30 | 30 |
@@ -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,18 +28,18 @@ discard block |
||
28 | 28 | */ |
29 | 29 | function give_process_donation_form() { |
30 | 30 | |
31 | - $post_data = give_clean( $_POST ); // WPCS: input var ok, CSRF ok. |
|
32 | - $is_ajax = isset( $post_data['give_ajax'] ); |
|
31 | + $post_data = give_clean($_POST); // WPCS: input var ok, CSRF ok. |
|
32 | + $is_ajax = isset($post_data['give_ajax']); |
|
33 | 33 | |
34 | 34 | // Verify donation form nonce. |
35 | - if ( ! give_verify_donation_form_nonce( $post_data['give-form-hash'], $post_data['give-form-id'] ) ) { |
|
36 | - if ( $is_ajax ) { |
|
35 | + if ( ! give_verify_donation_form_nonce($post_data['give-form-hash'], $post_data['give-form-id'])) { |
|
36 | + if ($is_ajax) { |
|
37 | 37 | /** |
38 | 38 | * Fires when AJAX sends back errors from the donation form. |
39 | 39 | * |
40 | 40 | * @since 1.0 |
41 | 41 | */ |
42 | - do_action( 'give_ajax_donation_errors' ); |
|
42 | + do_action('give_ajax_donation_errors'); |
|
43 | 43 | give_die(); |
44 | 44 | } else { |
45 | 45 | give_send_back_to_checkout(); |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * |
52 | 52 | * @since 1.0 |
53 | 53 | */ |
54 | - do_action( 'give_pre_process_donation' ); |
|
54 | + do_action('give_pre_process_donation'); |
|
55 | 55 | |
56 | 56 | // Validate the form $_POST data. |
57 | 57 | $valid_data = give_donation_form_validate_fields(); |
@@ -67,24 +67,24 @@ discard block |
||
67 | 67 | * @param array $deprecated Deprecated Since 2.0.2. Use $_POST instead. |
68 | 68 | */ |
69 | 69 | $deprecated = $post_data; |
70 | - do_action( 'give_checkout_error_checks', $valid_data, $deprecated ); |
|
70 | + do_action('give_checkout_error_checks', $valid_data, $deprecated); |
|
71 | 71 | |
72 | 72 | // Process the login form. |
73 | - if ( isset( $post_data['give_login_submit'] ) ) { |
|
73 | + if (isset($post_data['give_login_submit'])) { |
|
74 | 74 | give_process_form_login(); |
75 | 75 | } |
76 | 76 | |
77 | 77 | // Validate the user. |
78 | - $user = give_get_donation_form_user( $valid_data ); |
|
78 | + $user = give_get_donation_form_user($valid_data); |
|
79 | 79 | |
80 | - if ( false === $valid_data || give_get_errors() || ! $user ) { |
|
81 | - if ( $is_ajax ) { |
|
80 | + if (false === $valid_data || give_get_errors() || ! $user) { |
|
81 | + if ($is_ajax) { |
|
82 | 82 | /** |
83 | 83 | * Fires when AJAX sends back errors from the donation form. |
84 | 84 | * |
85 | 85 | * @since 1.0 |
86 | 86 | */ |
87 | - do_action( 'give_ajax_donation_errors' ); |
|
87 | + do_action('give_ajax_donation_errors'); |
|
88 | 88 | give_die(); |
89 | 89 | } else { |
90 | 90 | return false; |
@@ -92,17 +92,17 @@ discard block |
||
92 | 92 | } |
93 | 93 | |
94 | 94 | // If AJAX send back success to proceed with form submission. |
95 | - if ( $is_ajax ) { |
|
95 | + if ($is_ajax) { |
|
96 | 96 | echo 'success'; |
97 | 97 | give_die(); |
98 | 98 | } |
99 | 99 | |
100 | 100 | // After AJAX: Setup session if not using php_sessions. |
101 | - if ( ! Give()->session->use_php_sessions() ) { |
|
101 | + if ( ! Give()->session->use_php_sessions()) { |
|
102 | 102 | // Double-check that set_cookie is publicly accessible. |
103 | 103 | // we're using a slightly modified class-wp-sessions.php. |
104 | - $session_reflection = new ReflectionMethod( 'WP_Session', 'set_cookie' ); |
|
105 | - if ( $session_reflection->isPublic() ) { |
|
104 | + $session_reflection = new ReflectionMethod('WP_Session', 'set_cookie'); |
|
105 | + if ($session_reflection->isPublic()) { |
|
106 | 106 | // Manually set the cookie. |
107 | 107 | Give()->session->init()->set_cookie(); |
108 | 108 | } |
@@ -117,20 +117,19 @@ discard block |
||
117 | 117 | 'address' => $user['address'], |
118 | 118 | ); |
119 | 119 | |
120 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
120 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
121 | 121 | |
122 | - $price = isset( $post_data['give-amount'] ) ? |
|
123 | - (float) apply_filters( 'give_donation_total', give_maybe_sanitize_amount( $post_data['give-amount'] ) ) : |
|
124 | - '0.00'; |
|
125 | - $purchase_key = strtolower( md5( $user['user_email'] . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'give', true ) ) ); |
|
122 | + $price = isset($post_data['give-amount']) ? |
|
123 | + (float) apply_filters('give_donation_total', give_maybe_sanitize_amount($post_data['give-amount'])) : '0.00'; |
|
124 | + $purchase_key = strtolower(md5($user['user_email'].date('Y-m-d H:i:s').$auth_key.uniqid('give', true))); |
|
126 | 125 | |
127 | 126 | // Setup donation information. |
128 | 127 | $donation_data = array( |
129 | 128 | 'price' => $price, |
130 | 129 | 'purchase_key' => $purchase_key, |
131 | 130 | 'user_email' => $user['user_email'], |
132 | - 'date' => date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ), |
|
133 | - 'user_info' => stripslashes_deep( $user_info ), |
|
131 | + 'date' => date('Y-m-d H:i:s', current_time('timestamp')), |
|
132 | + 'user_info' => stripslashes_deep($user_info), |
|
134 | 133 | 'post_data' => $post_data, |
135 | 134 | 'gateway' => $valid_data['gateway'], |
136 | 135 | 'card_info' => $valid_data['cc_info'], |
@@ -150,10 +149,10 @@ discard block |
||
150 | 149 | * @param array $user_info Array containing basic user information. |
151 | 150 | * @param bool|array $valid_data Validate fields. |
152 | 151 | */ |
153 | - do_action( 'give_checkout_before_gateway', $post_data, $user_info, $valid_data ); |
|
152 | + do_action('give_checkout_before_gateway', $post_data, $user_info, $valid_data); |
|
154 | 153 | |
155 | 154 | // Sanity check for price. |
156 | - if ( ! $donation_data['price'] ) { |
|
155 | + if ( ! $donation_data['price']) { |
|
157 | 156 | // Revert to manual. |
158 | 157 | $donation_data['gateway'] = 'manual'; |
159 | 158 | $_POST['give-gateway'] = 'manual'; |
@@ -164,26 +163,26 @@ discard block |
||
164 | 163 | * |
165 | 164 | * @since 1.7 |
166 | 165 | */ |
167 | - $donation_data = apply_filters( 'give_donation_data_before_gateway', $donation_data, $valid_data ); |
|
166 | + $donation_data = apply_filters('give_donation_data_before_gateway', $donation_data, $valid_data); |
|
168 | 167 | |
169 | 168 | // Setup the data we're storing in the donation session. |
170 | 169 | $session_data = $donation_data; |
171 | 170 | |
172 | 171 | // Make sure credit card numbers are never stored in sessions. |
173 | - unset( $session_data['card_info']['card_number'] ); |
|
174 | - unset( $session_data['post_data']['card_number'] ); |
|
172 | + unset($session_data['card_info']['card_number']); |
|
173 | + unset($session_data['post_data']['card_number']); |
|
175 | 174 | |
176 | 175 | // Used for showing data to non logged-in users after donation, and for other plugins needing donation data. |
177 | - give_set_purchase_session( $session_data ); |
|
176 | + give_set_purchase_session($session_data); |
|
178 | 177 | |
179 | 178 | // Send info to the gateway for payment processing. |
180 | - give_send_to_gateway( $donation_data['gateway'], $donation_data ); |
|
179 | + give_send_to_gateway($donation_data['gateway'], $donation_data); |
|
181 | 180 | give_die(); |
182 | 181 | } |
183 | 182 | |
184 | -add_action( 'give_purchase', 'give_process_donation_form' ); |
|
185 | -add_action( 'wp_ajax_give_process_donation', 'give_process_donation_form' ); |
|
186 | -add_action( 'wp_ajax_nopriv_give_process_donation', 'give_process_donation_form' ); |
|
183 | +add_action('give_purchase', 'give_process_donation_form'); |
|
184 | +add_action('wp_ajax_give_process_donation', 'give_process_donation_form'); |
|
185 | +add_action('wp_ajax_nopriv_give_process_donation', 'give_process_donation_form'); |
|
187 | 186 | |
188 | 187 | /** |
189 | 188 | * Verify that when a logged in user makes a donation that the email address used doesn't belong to a different customer. |
@@ -194,27 +193,27 @@ discard block |
||
194 | 193 | * |
195 | 194 | * @return void |
196 | 195 | */ |
197 | -function give_check_logged_in_user_for_existing_email( $valid_data ) { |
|
196 | +function give_check_logged_in_user_for_existing_email($valid_data) { |
|
198 | 197 | |
199 | 198 | // Verify that the email address belongs to this customer. |
200 | - if ( is_user_logged_in() ) { |
|
199 | + if (is_user_logged_in()) { |
|
201 | 200 | |
202 | 201 | $submitted_email = $valid_data['logged_in_user']['user_email']; |
203 | - $donor = new Give_Donor( get_current_user_id(), true ); |
|
202 | + $donor = new Give_Donor(get_current_user_id(), true); |
|
204 | 203 | |
205 | 204 | // If this email address is not registered with this customer, see if it belongs to any other customer. |
206 | 205 | if ( |
207 | 206 | $submitted_email !== $donor->email |
208 | - && ( is_array( $donor->emails ) && ! in_array( $submitted_email, $donor->emails, true ) ) |
|
207 | + && (is_array($donor->emails) && ! in_array($submitted_email, $donor->emails, true)) |
|
209 | 208 | ) { |
210 | - $found_donor = new Give_Donor( $submitted_email ); |
|
209 | + $found_donor = new Give_Donor($submitted_email); |
|
211 | 210 | |
212 | - if ( $found_donor->id > 0 ) { |
|
211 | + if ($found_donor->id > 0) { |
|
213 | 212 | give_set_error( |
214 | 213 | 'give-customer-email-exists', |
215 | 214 | sprintf( |
216 | 215 | /* translators: 1. Donor Email, 2. Submitted Email */ |
217 | - __( 'You are logged in as %1$s, and are submitting a donation as %2$s, which is an existing donor. To ensure that the email address is tied to the correct donor, please submit this donation from a logged-out browser, or choose another email address.', 'give' ), |
|
216 | + __('You are logged in as %1$s, and are submitting a donation as %2$s, which is an existing donor. To ensure that the email address is tied to the correct donor, please submit this donation from a logged-out browser, or choose another email address.', 'give'), |
|
218 | 217 | $donor->email, |
219 | 218 | $submitted_email |
220 | 219 | ) |
@@ -224,7 +223,7 @@ discard block |
||
224 | 223 | } |
225 | 224 | } |
226 | 225 | |
227 | -add_action( 'give_checkout_error_checks', 'give_check_logged_in_user_for_existing_email', 10, 1 ); |
|
226 | +add_action('give_checkout_error_checks', 'give_check_logged_in_user_for_existing_email', 10, 1); |
|
228 | 227 | |
229 | 228 | /** |
230 | 229 | * Process the checkout login form |
@@ -236,49 +235,49 @@ discard block |
||
236 | 235 | */ |
237 | 236 | function give_process_form_login() { |
238 | 237 | |
239 | - $is_ajax = ! empty( $_POST['give_ajax'] ) ? give_clean( $_POST['give_ajax'] ) : 0; // WPCS: input var ok, sanitization ok, CSRF ok. |
|
238 | + $is_ajax = ! empty($_POST['give_ajax']) ? give_clean($_POST['give_ajax']) : 0; // WPCS: input var ok, sanitization ok, CSRF ok. |
|
240 | 239 | $referrer = wp_get_referer(); |
241 | 240 | $user_data = give_donation_form_validate_user_login(); |
242 | 241 | |
243 | - if ( give_get_errors() || $user_data['user_id'] < 1 ) { |
|
244 | - if ( $is_ajax ) { |
|
242 | + if (give_get_errors() || $user_data['user_id'] < 1) { |
|
243 | + if ($is_ajax) { |
|
245 | 244 | /** |
246 | 245 | * Fires when AJAX sends back errors from the donation form. |
247 | 246 | * |
248 | 247 | * @since 1.0 |
249 | 248 | */ |
250 | 249 | ob_start(); |
251 | - do_action( 'give_ajax_donation_errors' ); |
|
250 | + do_action('give_ajax_donation_errors'); |
|
252 | 251 | $message = ob_get_contents(); |
253 | 252 | ob_end_clean(); |
254 | - wp_send_json_error( $message ); |
|
253 | + wp_send_json_error($message); |
|
255 | 254 | } else { |
256 | - wp_safe_redirect( $referrer ); |
|
255 | + wp_safe_redirect($referrer); |
|
257 | 256 | exit; |
258 | 257 | } |
259 | 258 | } |
260 | 259 | |
261 | - give_log_user_in( $user_data['user_id'], $user_data['user_login'], $user_data['user_pass'] ); |
|
260 | + give_log_user_in($user_data['user_id'], $user_data['user_login'], $user_data['user_pass']); |
|
262 | 261 | |
263 | - if ( $is_ajax ) { |
|
262 | + if ($is_ajax) { |
|
264 | 263 | $message = Give()->notices->print_frontend_notice( |
265 | 264 | sprintf( |
266 | 265 | /* translators: %s: user first name */ |
267 | - esc_html__( 'Welcome %s! You have successfully logged into your account.', 'give' ), |
|
268 | - ( ! empty( $user_data['user_first'] ) ) ? $user_data['user_first'] : $user_data['user_login'] |
|
266 | + esc_html__('Welcome %s! You have successfully logged into your account.', 'give'), |
|
267 | + ( ! empty($user_data['user_first'])) ? $user_data['user_first'] : $user_data['user_login'] |
|
269 | 268 | ), |
270 | 269 | false, |
271 | 270 | 'success' |
272 | 271 | ); |
273 | 272 | |
274 | - wp_send_json_success( $message ); |
|
273 | + wp_send_json_success($message); |
|
275 | 274 | } else { |
276 | - wp_safe_redirect( $referrer ); |
|
275 | + wp_safe_redirect($referrer); |
|
277 | 276 | } |
278 | 277 | } |
279 | 278 | |
280 | -add_action( 'wp_ajax_give_process_donation_login', 'give_process_form_login' ); |
|
281 | -add_action( 'wp_ajax_nopriv_give_process_donation_login', 'give_process_form_login' ); |
|
279 | +add_action('wp_ajax_give_process_donation_login', 'give_process_form_login'); |
|
280 | +add_action('wp_ajax_nopriv_give_process_donation_login', 'give_process_form_login'); |
|
282 | 281 | |
283 | 282 | /** |
284 | 283 | * Donation Form Validate Fields. |
@@ -290,49 +289,49 @@ discard block |
||
290 | 289 | */ |
291 | 290 | function give_donation_form_validate_fields() { |
292 | 291 | |
293 | - $post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
292 | + $post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
294 | 293 | |
295 | 294 | // Validate Honeypot First. |
296 | - if ( ! empty( $post_data['give-honeypot'] ) ) { |
|
297 | - give_set_error( 'invalid_honeypot', esc_html__( 'Honeypot field detected. Go away bad bot!', 'give' ) ); |
|
295 | + if ( ! empty($post_data['give-honeypot'])) { |
|
296 | + give_set_error('invalid_honeypot', esc_html__('Honeypot field detected. Go away bad bot!', 'give')); |
|
298 | 297 | } |
299 | 298 | |
300 | 299 | // Check spam detect. |
301 | 300 | if ( |
302 | - isset( $post_data['action'] ) && |
|
303 | - give_is_setting_enabled( give_get_option( 'akismet_spam_protection' ) ) && |
|
301 | + isset($post_data['action']) && |
|
302 | + give_is_setting_enabled(give_get_option('akismet_spam_protection')) && |
|
304 | 303 | give_is_spam_donation() |
305 | 304 | ) { |
306 | - give_set_error( 'spam_donation', __( 'This donation has been flagged as spam. Please try again.', 'give' ) ); |
|
305 | + give_set_error('spam_donation', __('This donation has been flagged as spam. Please try again.', 'give')); |
|
307 | 306 | } |
308 | 307 | |
309 | 308 | // Start an array to collect valid data. |
310 | 309 | $valid_data = array( |
311 | 310 | 'gateway' => give_donation_form_validate_gateway(), // Gateway fallback (amount is validated here). |
312 | - 'need_new_user' => false, // New user flag. |
|
313 | - 'need_user_login' => false, // Login user flag. |
|
314 | - 'logged_user_data' => array(), // Logged user collected data. |
|
315 | - 'new_user_data' => array(), // New user collected data. |
|
316 | - 'login_user_data' => array(), // Login user collected data. |
|
317 | - 'guest_user_data' => array(), // Guest user collected data. |
|
311 | + 'need_new_user' => false, // New user flag. |
|
312 | + 'need_user_login' => false, // Login user flag. |
|
313 | + 'logged_user_data' => array(), // Logged user collected data. |
|
314 | + 'new_user_data' => array(), // New user collected data. |
|
315 | + 'login_user_data' => array(), // Login user collected data. |
|
316 | + 'guest_user_data' => array(), // Guest user collected data. |
|
318 | 317 | 'cc_info' => give_donation_form_validate_cc(), // Credit card info. |
319 | 318 | ); |
320 | 319 | |
321 | - $form_id = intval( $post_data['give-form-id'] ); |
|
320 | + $form_id = intval($post_data['give-form-id']); |
|
322 | 321 | |
323 | 322 | // Validate agree to terms. |
324 | - if ( give_is_terms_enabled( $form_id ) ) { |
|
323 | + if (give_is_terms_enabled($form_id)) { |
|
325 | 324 | give_donation_form_validate_agree_to_terms(); |
326 | 325 | } |
327 | 326 | |
328 | - if ( is_user_logged_in() ) { |
|
327 | + if (is_user_logged_in()) { |
|
329 | 328 | |
330 | 329 | // Collect logged in user data. |
331 | 330 | $valid_data['logged_in_user'] = give_donation_form_validate_logged_in_user(); |
332 | 331 | } elseif ( |
333 | - isset( $post_data['give-purchase-var'] ) && |
|
332 | + isset($post_data['give-purchase-var']) && |
|
334 | 333 | 'needs-to-register' === $post_data['give-purchase-var'] && |
335 | - ! empty( $post_data['give_create_account'] ) |
|
334 | + ! empty($post_data['give_create_account']) |
|
336 | 335 | ) { |
337 | 336 | |
338 | 337 | // Set new user registration as required. |
@@ -341,7 +340,7 @@ discard block |
||
341 | 340 | // Validate new user data. |
342 | 341 | $valid_data['new_user_data'] = give_donation_form_validate_new_user(); |
343 | 342 | } elseif ( |
344 | - isset( $post_data['give-purchase-var'] ) && |
|
343 | + isset($post_data['give-purchase-var']) && |
|
345 | 344 | 'needs-to-login' === $post_data['give-purchase-var'] |
346 | 345 | ) { |
347 | 346 | |
@@ -370,14 +369,14 @@ discard block |
||
370 | 369 | function give_is_spam_donation() { |
371 | 370 | $spam = false; |
372 | 371 | |
373 | - $user_agent = (string) isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : ''; |
|
372 | + $user_agent = (string) isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''; |
|
374 | 373 | |
375 | - if ( strlen( $user_agent ) < 2 ) { |
|
374 | + if (strlen($user_agent) < 2) { |
|
376 | 375 | $spam = true; |
377 | 376 | } |
378 | 377 | |
379 | 378 | // Allow developer to customized Akismet spam detect API call and it's response. |
380 | - return apply_filters( 'give_spam', $spam ); |
|
379 | + return apply_filters('give_spam', $spam); |
|
381 | 380 | } |
382 | 381 | |
383 | 382 | /** |
@@ -392,33 +391,33 @@ discard block |
||
392 | 391 | */ |
393 | 392 | function give_donation_form_validate_gateway() { |
394 | 393 | |
395 | - $post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
396 | - $form_id = ! empty( $post_data['give-form-id'] ) ? $post_data['give-form-id'] : 0; |
|
397 | - $amount = ! empty( $post_data['give-amount'] ) ? give_maybe_sanitize_amount( $post_data['give-amount'] ) : 0; |
|
398 | - $gateway = ! empty( $post_data['give-gateway'] ) ? $post_data['give-gateway'] : 0; |
|
394 | + $post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
395 | + $form_id = ! empty($post_data['give-form-id']) ? $post_data['give-form-id'] : 0; |
|
396 | + $amount = ! empty($post_data['give-amount']) ? give_maybe_sanitize_amount($post_data['give-amount']) : 0; |
|
397 | + $gateway = ! empty($post_data['give-gateway']) ? $post_data['give-gateway'] : 0; |
|
399 | 398 | |
400 | 399 | // Bailout, if payment gateway is not submitted with donation form data. |
401 | - if ( empty( $gateway ) ) { |
|
400 | + if (empty($gateway)) { |
|
402 | 401 | |
403 | - give_set_error( 'empty_gateway', __( 'The donation form will process with a valid payment gateway.', 'give' ) ); |
|
402 | + give_set_error('empty_gateway', __('The donation form will process with a valid payment gateway.', 'give')); |
|
404 | 403 | |
405 | - } elseif ( ! give_is_gateway_active( $gateway ) ) { |
|
404 | + } elseif ( ! give_is_gateway_active($gateway)) { |
|
406 | 405 | |
407 | - give_set_error( 'invalid_gateway', __( 'The selected payment gateway is not enabled.', 'give' ) ); |
|
406 | + give_set_error('invalid_gateway', __('The selected payment gateway is not enabled.', 'give')); |
|
408 | 407 | |
409 | - } elseif ( empty( $amount ) ) { |
|
408 | + } elseif (empty($amount)) { |
|
410 | 409 | |
411 | - give_set_error( 'invalid_donation_amount', __( 'Please insert a valid donation amount.', 'give' ) ); |
|
410 | + give_set_error('invalid_donation_amount', __('Please insert a valid donation amount.', 'give')); |
|
412 | 411 | |
413 | - } elseif ( ! give_verify_minimum_price( 'minimum' ) ) { |
|
412 | + } elseif ( ! give_verify_minimum_price('minimum')) { |
|
414 | 413 | |
415 | 414 | give_set_error( |
416 | 415 | 'invalid_donation_minimum', |
417 | 416 | sprintf( |
418 | 417 | /* translators: %s: minimum donation amount */ |
419 | - __( 'This form has a minimum donation amount of %s.', 'give' ), |
|
418 | + __('This form has a minimum donation amount of %s.', 'give'), |
|
420 | 419 | give_currency_filter( |
421 | - give_format_amount( give_get_form_minimum_price( $form_id ), |
|
420 | + give_format_amount(give_get_form_minimum_price($form_id), |
|
422 | 421 | array( |
423 | 422 | 'sanitize' => false, |
424 | 423 | ) |
@@ -426,15 +425,15 @@ discard block |
||
426 | 425 | ) |
427 | 426 | ) |
428 | 427 | ); |
429 | - } elseif ( ! give_verify_minimum_price( 'maximum' ) ) { |
|
428 | + } elseif ( ! give_verify_minimum_price('maximum')) { |
|
430 | 429 | |
431 | 430 | give_set_error( |
432 | 431 | 'invalid_donation_maximum', |
433 | 432 | sprintf( |
434 | 433 | /* translators: %s: Maximum donation amount */ |
435 | - __( 'This form has a maximum donation amount of %s.', 'give' ), |
|
434 | + __('This form has a maximum donation amount of %s.', 'give'), |
|
436 | 435 | give_currency_filter( |
437 | - give_format_amount( give_get_form_maximum_price( $form_id ), |
|
436 | + give_format_amount(give_get_form_maximum_price($form_id), |
|
438 | 437 | array( |
439 | 438 | 'sanitize' => false, |
440 | 439 | ) |
@@ -460,32 +459,32 @@ discard block |
||
460 | 459 | * |
461 | 460 | * @return bool |
462 | 461 | */ |
463 | -function give_verify_minimum_price( $amount_range = 'minimum' ) { |
|
462 | +function give_verify_minimum_price($amount_range = 'minimum') { |
|
464 | 463 | |
465 | - $post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
466 | - $amount = ! empty( $post_data['give-amount'] ) ? give_maybe_sanitize_amount( $post_data['give-amount'] ) : 0; |
|
467 | - $form_id = ! empty( $post_data['give-form-id'] ) ? $post_data['give-form-id'] : 0; |
|
468 | - $price_id = ! empty( $post_data['give-price-id'] ) ? $post_data['give-price-id'] : ''; |
|
464 | + $post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
465 | + $amount = ! empty($post_data['give-amount']) ? give_maybe_sanitize_amount($post_data['give-amount']) : 0; |
|
466 | + $form_id = ! empty($post_data['give-form-id']) ? $post_data['give-form-id'] : 0; |
|
467 | + $price_id = ! empty($post_data['give-price-id']) ? $post_data['give-price-id'] : ''; |
|
469 | 468 | |
470 | - $variable_prices = give_has_variable_prices( $form_id ); |
|
469 | + $variable_prices = give_has_variable_prices($form_id); |
|
471 | 470 | $verified_stat = false; |
472 | 471 | |
473 | - if ( $variable_prices && in_array( $price_id, give_get_variable_price_ids( $form_id ), true ) ) { |
|
472 | + if ($variable_prices && in_array($price_id, give_get_variable_price_ids($form_id), true)) { |
|
474 | 473 | |
475 | - $price_level_amount = give_get_price_option_amount( $form_id, $price_id ); |
|
474 | + $price_level_amount = give_get_price_option_amount($form_id, $price_id); |
|
476 | 475 | |
477 | - if ( $price_level_amount == $amount ) { |
|
476 | + if ($price_level_amount == $amount) { |
|
478 | 477 | $verified_stat = true; |
479 | 478 | } |
480 | 479 | } |
481 | 480 | |
482 | - if ( ! $verified_stat ) { |
|
483 | - switch ( $amount_range ) { |
|
481 | + if ( ! $verified_stat) { |
|
482 | + switch ($amount_range) { |
|
484 | 483 | case 'minimum' : |
485 | - $verified_stat = ( give_get_form_minimum_price( $form_id ) > $amount ) ? false : true; |
|
484 | + $verified_stat = (give_get_form_minimum_price($form_id) > $amount) ? false : true; |
|
486 | 485 | break; |
487 | 486 | case 'maximum' : |
488 | - $verified_stat = ( give_get_form_maximum_price( $form_id ) < $amount ) ? false : true; |
|
487 | + $verified_stat = (give_get_form_maximum_price($form_id) < $amount) ? false : true; |
|
489 | 488 | break; |
490 | 489 | } |
491 | 490 | } |
@@ -499,7 +498,7 @@ discard block |
||
499 | 498 | * @param string $amount_range Type of the amount. |
500 | 499 | * @param integer $form_id Give Donation Form ID. |
501 | 500 | */ |
502 | - return apply_filters( 'give_verify_minimum_maximum_price', $verified_stat, $amount_range, $form_id ); |
|
501 | + return apply_filters('give_verify_minimum_maximum_price', $verified_stat, $amount_range, $form_id); |
|
503 | 502 | } |
504 | 503 | |
505 | 504 | /** |
@@ -512,13 +511,13 @@ discard block |
||
512 | 511 | */ |
513 | 512 | function give_donation_form_validate_agree_to_terms() { |
514 | 513 | |
515 | - $agree_to_terms = ! empty( $_POST['give_agree_to_terms'] ) ? give_clean( $_POST['give_agree_to_terms'] ) : 0; // WPCS: input var ok, sanitization ok, CSRF ok. |
|
514 | + $agree_to_terms = ! empty($_POST['give_agree_to_terms']) ? give_clean($_POST['give_agree_to_terms']) : 0; // WPCS: input var ok, sanitization ok, CSRF ok. |
|
516 | 515 | |
517 | 516 | // Proceed only, if donor agreed to terms. |
518 | - if ( ! $agree_to_terms ) { |
|
517 | + if ( ! $agree_to_terms) { |
|
519 | 518 | |
520 | 519 | // User did not agree. |
521 | - give_set_error( 'agree_to_terms', apply_filters( 'give_agree_to_terms_text', __( 'You must agree to the terms and conditions.', 'give' ) ) ); |
|
520 | + give_set_error('agree_to_terms', apply_filters('give_agree_to_terms_text', __('You must agree to the terms and conditions.', 'give'))); |
|
522 | 521 | } |
523 | 522 | } |
524 | 523 | |
@@ -532,84 +531,84 @@ discard block |
||
532 | 531 | * |
533 | 532 | * @return array |
534 | 533 | */ |
535 | -function give_get_required_fields( $form_id ) { |
|
534 | +function give_get_required_fields($form_id) { |
|
536 | 535 | |
537 | - $payment_mode = give_get_chosen_gateway( $form_id ); |
|
536 | + $payment_mode = give_get_chosen_gateway($form_id); |
|
538 | 537 | |
539 | 538 | $required_fields = array( |
540 | 539 | 'give_email' => array( |
541 | 540 | 'error_id' => 'invalid_email', |
542 | - 'error_message' => __( 'Please enter a valid email address.', 'give' ), |
|
541 | + 'error_message' => __('Please enter a valid email address.', 'give'), |
|
543 | 542 | ), |
544 | 543 | 'give_first' => array( |
545 | 544 | 'error_id' => 'invalid_first_name', |
546 | - 'error_message' => __( 'Please enter your first name.', 'give' ), |
|
545 | + 'error_message' => __('Please enter your first name.', 'give'), |
|
547 | 546 | ), |
548 | 547 | ); |
549 | 548 | |
550 | - $require_address = give_require_billing_address( $payment_mode ); |
|
549 | + $require_address = give_require_billing_address($payment_mode); |
|
551 | 550 | |
552 | - if ( $require_address ) { |
|
553 | - $required_fields['card_address'] = array( |
|
551 | + if ($require_address) { |
|
552 | + $required_fields['card_address'] = array( |
|
554 | 553 | 'error_id' => 'invalid_card_address', |
555 | - 'error_message' => __( 'Please enter your primary billing address.', 'give' ), |
|
554 | + 'error_message' => __('Please enter your primary billing address.', 'give'), |
|
556 | 555 | ); |
557 | - $required_fields['card_zip'] = array( |
|
556 | + $required_fields['card_zip'] = array( |
|
558 | 557 | 'error_id' => 'invalid_zip_code', |
559 | - 'error_message' => __( 'Please enter your zip / postal code.', 'give' ), |
|
558 | + 'error_message' => __('Please enter your zip / postal code.', 'give'), |
|
560 | 559 | ); |
561 | - $required_fields['card_city'] = array( |
|
560 | + $required_fields['card_city'] = array( |
|
562 | 561 | 'error_id' => 'invalid_city', |
563 | - 'error_message' => __( 'Please enter your billing city.', 'give' ), |
|
562 | + 'error_message' => __('Please enter your billing city.', 'give'), |
|
564 | 563 | ); |
565 | 564 | $required_fields['billing_country'] = array( |
566 | 565 | 'error_id' => 'invalid_country', |
567 | - 'error_message' => __( 'Please select your billing country.', 'give' ), |
|
566 | + 'error_message' => __('Please select your billing country.', 'give'), |
|
568 | 567 | ); |
569 | 568 | |
570 | 569 | |
571 | 570 | $required_fields['card_state'] = array( |
572 | 571 | 'error_id' => 'invalid_state', |
573 | - 'error_message' => __( 'Please enter billing state / province / County.', 'give' ), |
|
572 | + 'error_message' => __('Please enter billing state / province / County.', 'give'), |
|
574 | 573 | ); |
575 | 574 | |
576 | - $country = ! empty( $_POST['billing_country'] ) ? give_clean( $_POST['billing_country'] ) : 0; // WPCS: input var ok, sanitization ok, CSRF ok. |
|
575 | + $country = ! empty($_POST['billing_country']) ? give_clean($_POST['billing_country']) : 0; // WPCS: input var ok, sanitization ok, CSRF ok. |
|
577 | 576 | |
578 | 577 | // Check if billing country already exists. |
579 | - if ( $country ) { |
|
578 | + if ($country) { |
|
580 | 579 | |
581 | 580 | // Get the country list that does not required any states init. |
582 | 581 | $states_country = give_states_not_required_country_list(); |
583 | 582 | |
584 | 583 | // Check if states is empty or not. |
585 | - if ( array_key_exists( $country, $states_country ) ) { |
|
584 | + if (array_key_exists($country, $states_country)) { |
|
586 | 585 | // If states is empty remove the required fields of state in billing cart. |
587 | - unset( $required_fields['card_state'] ); |
|
586 | + unset($required_fields['card_state']); |
|
588 | 587 | } |
589 | 588 | } |
590 | 589 | } // End if(). |
591 | 590 | |
592 | - if ( give_is_company_field_enabled( $form_id ) ) { |
|
593 | - $form_option = give_get_meta( $form_id, '_give_company_field', true ); |
|
594 | - $global_setting = give_get_option( 'company_field' ); |
|
591 | + if (give_is_company_field_enabled($form_id)) { |
|
592 | + $form_option = give_get_meta($form_id, '_give_company_field', true); |
|
593 | + $global_setting = give_get_option('company_field'); |
|
595 | 594 | |
596 | 595 | $is_company_field_required = false; |
597 | 596 | |
598 | - if ( ! empty( $form_option ) && give_is_setting_enabled( $form_option, array( 'required' ) ) ) { |
|
597 | + if ( ! empty($form_option) && give_is_setting_enabled($form_option, array('required'))) { |
|
599 | 598 | $is_company_field_required = true; |
600 | 599 | |
601 | - } elseif ( 'global' === $form_option && give_is_setting_enabled( $global_setting, array( 'required' ) ) ) { |
|
600 | + } elseif ('global' === $form_option && give_is_setting_enabled($global_setting, array('required'))) { |
|
602 | 601 | $is_company_field_required = true; |
603 | 602 | |
604 | - } elseif ( empty( $form_option ) && give_is_setting_enabled( $global_setting, array( 'required' ) ) ) { |
|
603 | + } elseif (empty($form_option) && give_is_setting_enabled($global_setting, array('required'))) { |
|
605 | 604 | $is_company_field_required = true; |
606 | 605 | |
607 | 606 | } |
608 | 607 | |
609 | - if ( $is_company_field_required ) { |
|
608 | + if ($is_company_field_required) { |
|
610 | 609 | $required_fields['give_company_name'] = array( |
611 | 610 | 'error_id' => 'invalid_company', |
612 | - 'error_message' => __( 'Please enter Company Name.', 'give' ), |
|
611 | + 'error_message' => __('Please enter Company Name.', 'give'), |
|
613 | 612 | ); |
614 | 613 | } |
615 | 614 | } |
@@ -619,7 +618,7 @@ discard block |
||
619 | 618 | * |
620 | 619 | * @since 1.7 |
621 | 620 | */ |
622 | - $required_fields = apply_filters( 'give_donation_form_required_fields', $required_fields, $form_id ); |
|
621 | + $required_fields = apply_filters('give_donation_form_required_fields', $required_fields, $form_id); |
|
623 | 622 | |
624 | 623 | return $required_fields; |
625 | 624 | |
@@ -634,17 +633,17 @@ discard block |
||
634 | 633 | * |
635 | 634 | * @return bool |
636 | 635 | */ |
637 | -function give_require_billing_address( $payment_mode ) { |
|
636 | +function give_require_billing_address($payment_mode) { |
|
638 | 637 | |
639 | 638 | $return = false; |
640 | - $billing_country = ! empty( $_POST['billing_country'] ) ? give_clean( $_POST['billing_country'] ) : 0; // WPCS: input var ok, sanitization ok, CSRF ok. |
|
639 | + $billing_country = ! empty($_POST['billing_country']) ? give_clean($_POST['billing_country']) : 0; // WPCS: input var ok, sanitization ok, CSRF ok. |
|
641 | 640 | |
642 | - if ( $billing_country || did_action( "give_{$payment_mode}_cc_form" ) || did_action( 'give_cc_form' ) ) { |
|
641 | + if ($billing_country || did_action("give_{$payment_mode}_cc_form") || did_action('give_cc_form')) { |
|
643 | 642 | $return = true; |
644 | 643 | } |
645 | 644 | |
646 | 645 | // Let payment gateways and other extensions determine if address fields should be required. |
647 | - return apply_filters( 'give_require_billing_address', $return ); |
|
646 | + return apply_filters('give_require_billing_address', $return); |
|
648 | 647 | |
649 | 648 | } |
650 | 649 | |
@@ -658,47 +657,47 @@ discard block |
||
658 | 657 | */ |
659 | 658 | function give_donation_form_validate_logged_in_user() { |
660 | 659 | |
661 | - $post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
660 | + $post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
662 | 661 | $user_id = get_current_user_id(); |
663 | - $form_id = ! empty( $post_data['give-form-id'] ) ? $post_data['give-form-id'] : 0; |
|
662 | + $form_id = ! empty($post_data['give-form-id']) ? $post_data['give-form-id'] : 0; |
|
664 | 663 | |
665 | 664 | // Start empty array to collect valid user data. |
666 | 665 | $valid_user_data = array( |
667 | 666 | |
668 | 667 | // Assume there will be errors. |
669 | - 'user_id' => - 1, |
|
668 | + 'user_id' => -1, |
|
670 | 669 | ); |
671 | 670 | |
672 | 671 | // Proceed on;y, if valid $user_id found. |
673 | - if ( $user_id > 0 ) { |
|
672 | + if ($user_id > 0) { |
|
674 | 673 | |
675 | 674 | // Get the logged in user data. |
676 | - $user_data = get_userdata( $user_id ); |
|
675 | + $user_data = get_userdata($user_id); |
|
677 | 676 | |
678 | 677 | // Validate Required Form Fields. |
679 | - give_validate_required_form_fields( $form_id ); |
|
678 | + give_validate_required_form_fields($form_id); |
|
680 | 679 | |
681 | 680 | // Verify data. |
682 | - if ( is_object( $user_data ) && $user_data->ID > 0 ) { |
|
681 | + if (is_object($user_data) && $user_data->ID > 0) { |
|
683 | 682 | |
684 | 683 | // Collected logged in user data. |
685 | 684 | $valid_user_data = array( |
686 | 685 | 'user_id' => $user_id, |
687 | - 'user_email' => ! empty( $post_data['give_email'] ) ? sanitize_email( $post_data['give_email'] ) : $user_data->user_email, |
|
688 | - 'user_first' => ! empty( $post_data['give_first'] ) ? $post_data['give_first'] : $user_data->first_name, |
|
689 | - 'user_last' => ! empty( $post_data['give_last'] ) ? $post_data['give_last'] : $user_data->last_name, |
|
686 | + 'user_email' => ! empty($post_data['give_email']) ? sanitize_email($post_data['give_email']) : $user_data->user_email, |
|
687 | + 'user_first' => ! empty($post_data['give_first']) ? $post_data['give_first'] : $user_data->first_name, |
|
688 | + 'user_last' => ! empty($post_data['give_last']) ? $post_data['give_last'] : $user_data->last_name, |
|
690 | 689 | ); |
691 | 690 | |
692 | 691 | // Validate essential form fields. |
693 | - give_donation_form_validate_name_fields( $post_data ); |
|
692 | + give_donation_form_validate_name_fields($post_data); |
|
694 | 693 | |
695 | - if ( ! is_email( $valid_user_data['user_email'] ) ) { |
|
696 | - give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) ); |
|
694 | + if ( ! is_email($valid_user_data['user_email'])) { |
|
695 | + give_set_error('email_invalid', esc_html__('Invalid email.', 'give')); |
|
697 | 696 | } |
698 | 697 | } else { |
699 | 698 | |
700 | 699 | // Set invalid user information error. |
701 | - give_set_error( 'invalid_user', esc_html__( 'The user information is invalid.', 'give' ) ); |
|
700 | + give_set_error('invalid_user', esc_html__('The user information is invalid.', 'give')); |
|
702 | 701 | } |
703 | 702 | } |
704 | 703 | |
@@ -716,12 +715,12 @@ discard block |
||
716 | 715 | */ |
717 | 716 | function give_donation_form_validate_new_user() { |
718 | 717 | |
719 | - $post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
720 | - $nonce = ! empty( $post_data['give-form-user-register-hash'] ) ? $post_data['give-form-user-register-hash'] : ''; |
|
718 | + $post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
719 | + $nonce = ! empty($post_data['give-form-user-register-hash']) ? $post_data['give-form-user-register-hash'] : ''; |
|
721 | 720 | |
722 | 721 | // Validate user creation nonce. |
723 | - if ( ! wp_verify_nonce( $nonce, 'give_form_create_user_nonce' ) ) { |
|
724 | - give_set_error( 'invalid_nonce', __( 'Nonce verification has failed.', 'give' ) ); |
|
722 | + if ( ! wp_verify_nonce($nonce, 'give_form_create_user_nonce')) { |
|
723 | + give_set_error('invalid_nonce', __('Nonce verification has failed.', 'give')); |
|
725 | 724 | } |
726 | 725 | |
727 | 726 | $auto_generated_password = wp_generate_password(); |
@@ -729,7 +728,7 @@ discard block |
||
729 | 728 | // Default user data. |
730 | 729 | $default_user_data = array( |
731 | 730 | 'give-form-id' => '', |
732 | - 'user_id' => - 1, // Assume there will be errors. |
|
731 | + 'user_id' => -1, // Assume there will be errors. |
|
733 | 732 | 'user_first' => '', |
734 | 733 | 'user_last' => '', |
735 | 734 | 'give_user_login' => false, |
@@ -739,17 +738,17 @@ discard block |
||
739 | 738 | ); |
740 | 739 | |
741 | 740 | // Get user data. |
742 | - $user_data = wp_parse_args( $post_data, $default_user_data ); |
|
741 | + $user_data = wp_parse_args($post_data, $default_user_data); |
|
743 | 742 | $registering_new_user = false; |
744 | - $form_id = absint( $user_data['give-form-id'] ); |
|
743 | + $form_id = absint($user_data['give-form-id']); |
|
745 | 744 | |
746 | - give_donation_form_validate_name_fields( $user_data ); |
|
745 | + give_donation_form_validate_name_fields($user_data); |
|
747 | 746 | |
748 | 747 | // Start an empty array to collect valid user data. |
749 | 748 | $valid_user_data = array( |
750 | 749 | |
751 | 750 | // Assume there will be errors. |
752 | - 'user_id' => - 1, |
|
751 | + 'user_id' => -1, |
|
753 | 752 | |
754 | 753 | // Get first name. |
755 | 754 | 'user_first' => $user_data['give_first'], |
@@ -762,13 +761,13 @@ discard block |
||
762 | 761 | ); |
763 | 762 | |
764 | 763 | // Validate Required Form Fields. |
765 | - give_validate_required_form_fields( $form_id ); |
|
764 | + give_validate_required_form_fields($form_id); |
|
766 | 765 | |
767 | 766 | // Set Email as Username. |
768 | 767 | $valid_user_data['user_login'] = $user_data['give_email']; |
769 | 768 | |
770 | 769 | // Check if we have an email to verify. |
771 | - if ( give_validate_user_email( $user_data['give_email'], $registering_new_user ) ) { |
|
770 | + if (give_validate_user_email($user_data['give_email'], $registering_new_user)) { |
|
772 | 771 | $valid_user_data['user_email'] = $user_data['give_email']; |
773 | 772 | } |
774 | 773 | |
@@ -785,47 +784,47 @@ discard block |
||
785 | 784 | */ |
786 | 785 | function give_donation_form_validate_user_login() { |
787 | 786 | |
788 | - $post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
787 | + $post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
789 | 788 | |
790 | 789 | // Start an array to collect valid user data. |
791 | 790 | $valid_user_data = array( |
792 | 791 | |
793 | 792 | // Assume there will be errors. |
794 | - 'user_id' => - 1, |
|
793 | + 'user_id' => -1, |
|
795 | 794 | ); |
796 | 795 | |
797 | 796 | // Bailout, if Username is empty. |
798 | - if ( empty( $post_data['give_user_login'] ) ) { |
|
799 | - give_set_error( 'must_log_in', __( 'You must register or login to complete your donation.', 'give' ) ); |
|
797 | + if (empty($post_data['give_user_login'])) { |
|
798 | + give_set_error('must_log_in', __('You must register or login to complete your donation.', 'give')); |
|
800 | 799 | |
801 | 800 | return $valid_user_data; |
802 | 801 | } |
803 | 802 | |
804 | 803 | // Get the user by login. |
805 | - $user_data = get_user_by( 'login', strip_tags( $post_data['give_user_login'] ) ); |
|
804 | + $user_data = get_user_by('login', strip_tags($post_data['give_user_login'])); |
|
806 | 805 | |
807 | 806 | // Check if user exists. |
808 | - if ( $user_data ) { |
|
807 | + if ($user_data) { |
|
809 | 808 | |
810 | 809 | // Get password. |
811 | - $user_pass = ! empty( $post_data['give_user_pass'] ) ? $post_data['give_user_pass'] : false; |
|
810 | + $user_pass = ! empty($post_data['give_user_pass']) ? $post_data['give_user_pass'] : false; |
|
812 | 811 | |
813 | 812 | // Check user_pass. |
814 | - if ( $user_pass ) { |
|
813 | + if ($user_pass) { |
|
815 | 814 | |
816 | 815 | // Check if password is valid. |
817 | - if ( ! wp_check_password( $user_pass, $user_data->user_pass, $user_data->ID ) ) { |
|
816 | + if ( ! wp_check_password($user_pass, $user_data->user_pass, $user_data->ID)) { |
|
818 | 817 | |
819 | - $current_page_url = site_url() . '/' . get_page_uri(); |
|
818 | + $current_page_url = site_url().'/'.get_page_uri(); |
|
820 | 819 | |
821 | 820 | // Incorrect password. |
822 | 821 | give_set_error( |
823 | 822 | 'password_incorrect', |
824 | 823 | sprintf( |
825 | 824 | '%1$s <a href="%2$s">%3$s</a>', |
826 | - __( 'The password you entered is incorrect.', 'give' ), |
|
827 | - wp_lostpassword_url( $current_page_url ), |
|
828 | - __( 'Reset Password', 'give' ) |
|
825 | + __('The password you entered is incorrect.', 'give'), |
|
826 | + wp_lostpassword_url($current_page_url), |
|
827 | + __('Reset Password', 'give') |
|
829 | 828 | ) |
830 | 829 | ); |
831 | 830 | |
@@ -843,11 +842,11 @@ discard block |
||
843 | 842 | } |
844 | 843 | } else { |
845 | 844 | // Empty password. |
846 | - give_set_error( 'password_empty', __( 'Enter a password.', 'give' ) ); |
|
845 | + give_set_error('password_empty', __('Enter a password.', 'give')); |
|
847 | 846 | } |
848 | 847 | } else { |
849 | 848 | // No username. |
850 | - give_set_error( 'username_incorrect', __( 'The username you entered does not exist.', 'give' ) ); |
|
849 | + give_set_error('username_incorrect', __('The username you entered does not exist.', 'give')); |
|
851 | 850 | } // End if(). |
852 | 851 | |
853 | 852 | return $valid_user_data; |
@@ -863,8 +862,8 @@ discard block |
||
863 | 862 | */ |
864 | 863 | function give_donation_form_validate_guest_user() { |
865 | 864 | |
866 | - $post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
867 | - $form_id = ! empty( $post_data['give-form-id'] ) ? $post_data['give-form-id'] : 0; |
|
865 | + $post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
866 | + $form_id = ! empty($post_data['give-form-id']) ? $post_data['give-form-id'] : 0; |
|
868 | 867 | |
869 | 868 | // Start an array to collect valid user data. |
870 | 869 | $valid_user_data = array( |
@@ -873,22 +872,22 @@ discard block |
||
873 | 872 | ); |
874 | 873 | |
875 | 874 | // Validate name fields. |
876 | - give_donation_form_validate_name_fields( $post_data ); |
|
875 | + give_donation_form_validate_name_fields($post_data); |
|
877 | 876 | |
878 | 877 | // Validate Required Form Fields. |
879 | - give_validate_required_form_fields( $form_id ); |
|
878 | + give_validate_required_form_fields($form_id); |
|
880 | 879 | |
881 | 880 | // Get the guest email. |
882 | - $guest_email = ! empty( $post_data['give_email'] ) ? $post_data['give_email'] : false; |
|
881 | + $guest_email = ! empty($post_data['give_email']) ? $post_data['give_email'] : false; |
|
883 | 882 | |
884 | 883 | // Check email. |
885 | - if ( $guest_email && strlen( $guest_email ) > 0 ) { |
|
884 | + if ($guest_email && strlen($guest_email) > 0) { |
|
886 | 885 | |
887 | 886 | // Validate email. |
888 | - if ( ! is_email( $guest_email ) ) { |
|
887 | + if ( ! is_email($guest_email)) { |
|
889 | 888 | |
890 | 889 | // Invalid email. |
891 | - give_set_error( 'email_invalid', __( 'Invalid email.', 'give' ) ); |
|
890 | + give_set_error('email_invalid', __('Invalid email.', 'give')); |
|
892 | 891 | |
893 | 892 | } else { |
894 | 893 | |
@@ -896,15 +895,15 @@ discard block |
||
896 | 895 | $valid_user_data['user_email'] = $guest_email; |
897 | 896 | |
898 | 897 | // Get user_id from donor if exist. |
899 | - $donor = new Give_Donor( $guest_email ); |
|
898 | + $donor = new Give_Donor($guest_email); |
|
900 | 899 | |
901 | - if ( $donor->id && $donor->user_id ) { |
|
900 | + if ($donor->id && $donor->user_id) { |
|
902 | 901 | $valid_user_data['user_id'] = $donor->user_id; |
903 | 902 | } |
904 | 903 | } |
905 | 904 | } else { |
906 | 905 | // No email. |
907 | - give_set_error( 'email_empty', __( 'Enter an email.', 'give' ) ); |
|
906 | + give_set_error('email_empty', __('Enter an email.', 'give')); |
|
908 | 907 | } |
909 | 908 | |
910 | 909 | return $valid_user_data; |
@@ -920,36 +919,36 @@ discard block |
||
920 | 919 | * |
921 | 920 | * @return integer |
922 | 921 | */ |
923 | -function give_register_and_login_new_user( $user_data = array() ) { |
|
922 | +function give_register_and_login_new_user($user_data = array()) { |
|
924 | 923 | // Verify the array. |
925 | - if ( empty( $user_data ) ) { |
|
926 | - return - 1; |
|
924 | + if (empty($user_data)) { |
|
925 | + return -1; |
|
927 | 926 | } |
928 | 927 | |
929 | - if ( give_get_errors() ) { |
|
930 | - return - 1; |
|
928 | + if (give_get_errors()) { |
|
929 | + return -1; |
|
931 | 930 | } |
932 | 931 | |
933 | - $user_args = apply_filters( 'give_insert_user_args', array( |
|
934 | - 'user_login' => isset( $user_data['user_login'] ) ? $user_data['user_login'] : '', |
|
935 | - 'user_pass' => isset( $user_data['user_pass'] ) ? $user_data['user_pass'] : '', |
|
936 | - 'user_email' => isset( $user_data['user_email'] ) ? $user_data['user_email'] : '', |
|
937 | - 'first_name' => isset( $user_data['user_first'] ) ? $user_data['user_first'] : '', |
|
938 | - 'last_name' => isset( $user_data['user_last'] ) ? $user_data['user_last'] : '', |
|
939 | - 'user_registered' => date( 'Y-m-d H:i:s' ), |
|
940 | - 'role' => give_get_option( 'donor_default_user_role', 'give_donor' ), |
|
941 | - ), $user_data ); |
|
932 | + $user_args = apply_filters('give_insert_user_args', array( |
|
933 | + 'user_login' => isset($user_data['user_login']) ? $user_data['user_login'] : '', |
|
934 | + 'user_pass' => isset($user_data['user_pass']) ? $user_data['user_pass'] : '', |
|
935 | + 'user_email' => isset($user_data['user_email']) ? $user_data['user_email'] : '', |
|
936 | + 'first_name' => isset($user_data['user_first']) ? $user_data['user_first'] : '', |
|
937 | + 'last_name' => isset($user_data['user_last']) ? $user_data['user_last'] : '', |
|
938 | + 'user_registered' => date('Y-m-d H:i:s'), |
|
939 | + 'role' => give_get_option('donor_default_user_role', 'give_donor'), |
|
940 | + ), $user_data); |
|
942 | 941 | |
943 | 942 | // Insert new user. |
944 | - $user_id = wp_insert_user( $user_args ); |
|
943 | + $user_id = wp_insert_user($user_args); |
|
945 | 944 | |
946 | 945 | // Validate inserted user. |
947 | - if ( is_wp_error( $user_id ) ) { |
|
948 | - return - 1; |
|
946 | + if (is_wp_error($user_id)) { |
|
947 | + return -1; |
|
949 | 948 | } |
950 | 949 | |
951 | 950 | // Allow themes and plugins to filter the user data. |
952 | - $user_data = apply_filters( 'give_insert_user_data', $user_data, $user_args ); |
|
951 | + $user_data = apply_filters('give_insert_user_data', $user_data, $user_args); |
|
953 | 952 | |
954 | 953 | /** |
955 | 954 | * Fires after inserting user. |
@@ -959,7 +958,7 @@ discard block |
||
959 | 958 | * @param int $user_id User id. |
960 | 959 | * @param array $user_data Array containing user data. |
961 | 960 | */ |
962 | - do_action( 'give_insert_user', $user_id, $user_data ); |
|
961 | + do_action('give_insert_user', $user_id, $user_data); |
|
963 | 962 | |
964 | 963 | /** |
965 | 964 | * Filter allow user to alter if user when to login or not when user is register for the first time. |
@@ -968,9 +967,9 @@ discard block |
||
968 | 967 | * |
969 | 968 | * return bool True if login with registration and False if only want to register. |
970 | 969 | */ |
971 | - if ( true === (bool) apply_filters( 'give_log_user_in_on_register', true ) ) { |
|
970 | + if (true === (bool) apply_filters('give_log_user_in_on_register', true)) { |
|
972 | 971 | // Login new user. |
973 | - give_log_user_in( $user_id, $user_data['user_login'], $user_data['user_pass'] ); |
|
972 | + give_log_user_in($user_id, $user_data['user_login'], $user_data['user_pass']); |
|
974 | 973 | } |
975 | 974 | |
976 | 975 | // Return user id. |
@@ -987,33 +986,33 @@ discard block |
||
987 | 986 | * |
988 | 987 | * @return array|bool |
989 | 988 | */ |
990 | -function give_get_donation_form_user( $valid_data = array() ) { |
|
989 | +function give_get_donation_form_user($valid_data = array()) { |
|
991 | 990 | |
992 | 991 | // Initialize user. |
993 | 992 | $user = false; |
994 | - $is_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX; |
|
995 | - $post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
993 | + $is_ajax = defined('DOING_AJAX') && DOING_AJAX; |
|
994 | + $post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
996 | 995 | |
997 | - if ( $is_ajax ) { |
|
996 | + if ($is_ajax) { |
|
998 | 997 | |
999 | 998 | // Do not create or login the user during the ajax submission (check for errors only). |
1000 | 999 | return true; |
1001 | - } elseif ( is_user_logged_in() ) { |
|
1000 | + } elseif (is_user_logged_in()) { |
|
1002 | 1001 | |
1003 | 1002 | // Set the valid user as the logged in collected data. |
1004 | 1003 | $user = $valid_data['logged_in_user']; |
1005 | - } elseif ( true === $valid_data['need_new_user'] || true === $valid_data['need_user_login'] ) { |
|
1004 | + } elseif (true === $valid_data['need_new_user'] || true === $valid_data['need_user_login']) { |
|
1006 | 1005 | |
1007 | 1006 | // New user registration. |
1008 | - if ( true === $valid_data['need_new_user'] ) { |
|
1007 | + if (true === $valid_data['need_new_user']) { |
|
1009 | 1008 | |
1010 | 1009 | // Set user. |
1011 | 1010 | $user = $valid_data['new_user_data']; |
1012 | 1011 | |
1013 | 1012 | // Register and login new user. |
1014 | - $user['user_id'] = give_register_and_login_new_user( $user ); |
|
1013 | + $user['user_id'] = give_register_and_login_new_user($user); |
|
1015 | 1014 | |
1016 | - } elseif ( true === $valid_data['need_user_login'] && ! $is_ajax ) { |
|
1015 | + } elseif (true === $valid_data['need_user_login'] && ! $is_ajax) { |
|
1017 | 1016 | |
1018 | 1017 | /** |
1019 | 1018 | * The login form is now processed in the give_process_donation_login() function. |
@@ -1025,42 +1024,42 @@ discard block |
||
1025 | 1024 | $user = $valid_data['login_user_data']; |
1026 | 1025 | |
1027 | 1026 | // Login user. |
1028 | - give_log_user_in( $user['user_id'], $user['user_login'], $user['user_pass'] ); |
|
1027 | + give_log_user_in($user['user_id'], $user['user_login'], $user['user_pass']); |
|
1029 | 1028 | } |
1030 | 1029 | } // End if(). |
1031 | 1030 | |
1032 | 1031 | // Check guest checkout. |
1033 | - if ( false === $user && false === give_logged_in_only( $post_data['give-form-id'] ) ) { |
|
1032 | + if (false === $user && false === give_logged_in_only($post_data['give-form-id'])) { |
|
1034 | 1033 | |
1035 | 1034 | // Set user. |
1036 | 1035 | $user = $valid_data['guest_user_data']; |
1037 | 1036 | } |
1038 | 1037 | |
1039 | 1038 | // Verify we have an user. |
1040 | - if ( false === $user || empty( $user ) ) { |
|
1039 | + if (false === $user || empty($user)) { |
|
1041 | 1040 | return false; |
1042 | 1041 | } |
1043 | 1042 | |
1044 | 1043 | // Get user first name. |
1045 | - if ( ! isset( $user['user_first'] ) || strlen( trim( $user['user_first'] ) ) < 1 ) { |
|
1046 | - $user['user_first'] = isset( $post_data['give_first'] ) ? strip_tags( trim( $post_data['give_first'] ) ) : ''; |
|
1044 | + if ( ! isset($user['user_first']) || strlen(trim($user['user_first'])) < 1) { |
|
1045 | + $user['user_first'] = isset($post_data['give_first']) ? strip_tags(trim($post_data['give_first'])) : ''; |
|
1047 | 1046 | } |
1048 | 1047 | |
1049 | 1048 | // Get user last name. |
1050 | - if ( ! isset( $user['user_last'] ) || strlen( trim( $user['user_last'] ) ) < 1 ) { |
|
1051 | - $user['user_last'] = isset( $post_data['give_last'] ) ? strip_tags( trim( $post_data['give_last'] ) ) : ''; |
|
1049 | + if ( ! isset($user['user_last']) || strlen(trim($user['user_last'])) < 1) { |
|
1050 | + $user['user_last'] = isset($post_data['give_last']) ? strip_tags(trim($post_data['give_last'])) : ''; |
|
1052 | 1051 | } |
1053 | 1052 | |
1054 | 1053 | // Get the user's billing address details. |
1055 | 1054 | $user['address'] = array(); |
1056 | - $user['address']['line1'] = ! empty( $post_data['card_address'] ) ? $post_data['card_address'] : false; |
|
1057 | - $user['address']['line2'] = ! empty( $post_data['card_address_2'] ) ? $post_data['card_address_2'] : false; |
|
1058 | - $user['address']['city'] = ! empty( $post_data['card_city'] ) ? $post_data['card_city'] : false; |
|
1059 | - $user['address']['state'] = ! empty( $post_data['card_state'] ) ? $post_data['card_state'] : false; |
|
1060 | - $user['address']['zip'] = ! empty( $post_data['card_zip'] ) ? $post_data['card_zip'] : false; |
|
1061 | - $user['address']['country'] = ! empty( $post_data['billing_country'] ) ? $post_data['billing_country'] : false; |
|
1062 | - |
|
1063 | - if ( empty( $user['address']['country'] ) ) { |
|
1055 | + $user['address']['line1'] = ! empty($post_data['card_address']) ? $post_data['card_address'] : false; |
|
1056 | + $user['address']['line2'] = ! empty($post_data['card_address_2']) ? $post_data['card_address_2'] : false; |
|
1057 | + $user['address']['city'] = ! empty($post_data['card_city']) ? $post_data['card_city'] : false; |
|
1058 | + $user['address']['state'] = ! empty($post_data['card_state']) ? $post_data['card_state'] : false; |
|
1059 | + $user['address']['zip'] = ! empty($post_data['card_zip']) ? $post_data['card_zip'] : false; |
|
1060 | + $user['address']['country'] = ! empty($post_data['billing_country']) ? $post_data['billing_country'] : false; |
|
1061 | + |
|
1062 | + if (empty($user['address']['country'])) { |
|
1064 | 1063 | $user['address'] = false; |
1065 | 1064 | } // End if(). |
1066 | 1065 | |
@@ -1081,16 +1080,16 @@ discard block |
||
1081 | 1080 | $card_data = give_get_donation_cc_info(); |
1082 | 1081 | |
1083 | 1082 | // Validate the card zip. |
1084 | - if ( ! empty( $card_data['card_zip'] ) ) { |
|
1085 | - if ( ! give_donation_form_validate_cc_zip( $card_data['card_zip'], $card_data['card_country'] ) ) { |
|
1086 | - give_set_error( 'invalid_cc_zip', __( 'The zip / postal code you entered for your billing address is invalid.', 'give' ) ); |
|
1083 | + if ( ! empty($card_data['card_zip'])) { |
|
1084 | + if ( ! give_donation_form_validate_cc_zip($card_data['card_zip'], $card_data['card_country'])) { |
|
1085 | + give_set_error('invalid_cc_zip', __('The zip / postal code you entered for your billing address is invalid.', 'give')); |
|
1087 | 1086 | } |
1088 | 1087 | } |
1089 | 1088 | |
1090 | 1089 | // Ensure no spaces. |
1091 | - if ( ! empty( $card_data['card_number'] ) ) { |
|
1092 | - $card_data['card_number'] = str_replace( '+', '', $card_data['card_number'] ); // no "+" signs. |
|
1093 | - $card_data['card_number'] = str_replace( ' ', '', $card_data['card_number'] ); // No spaces. |
|
1090 | + if ( ! empty($card_data['card_number'])) { |
|
1091 | + $card_data['card_number'] = str_replace('+', '', $card_data['card_number']); // no "+" signs. |
|
1092 | + $card_data['card_number'] = str_replace(' ', '', $card_data['card_number']); // No spaces. |
|
1094 | 1093 | } |
1095 | 1094 | |
1096 | 1095 | // This should validate card numbers at some point too. |
@@ -1108,20 +1107,20 @@ discard block |
||
1108 | 1107 | function give_get_donation_cc_info() { |
1109 | 1108 | |
1110 | 1109 | // Sanitize the values submitted with donation form. |
1111 | - $post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
1110 | + $post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
1112 | 1111 | |
1113 | 1112 | $cc_info = array(); |
1114 | - $cc_info['card_name'] = ! empty( $post_data['card_name'] ) ? $post_data['card_name'] : ''; |
|
1115 | - $cc_info['card_number'] = ! empty( $post_data['card_number'] ) ? $post_data['card_number'] : ''; |
|
1116 | - $cc_info['card_cvc'] = ! empty( $post_data['card_cvc'] ) ? $post_data['card_cvc'] : ''; |
|
1117 | - $cc_info['card_exp_month'] = ! empty( $post_data['card_exp_month'] ) ? $post_data['card_exp_month'] : ''; |
|
1118 | - $cc_info['card_exp_year'] = ! empty( $post_data['card_exp_year'] ) ? $post_data['card_exp_year'] : ''; |
|
1119 | - $cc_info['card_address'] = ! empty( $post_data['card_address'] ) ? $post_data['card_address'] : ''; |
|
1120 | - $cc_info['card_address_2'] = ! empty( $post_data['card_address_2'] ) ? $post_data['card_address_2'] : ''; |
|
1121 | - $cc_info['card_city'] = ! empty( $post_data['card_city'] ) ? $post_data['card_city'] : ''; |
|
1122 | - $cc_info['card_state'] = ! empty( $post_data['card_state'] ) ? $post_data['card_state'] : ''; |
|
1123 | - $cc_info['card_country'] = ! empty( $post_data['billing_country'] ) ? $post_data['billing_country'] : ''; |
|
1124 | - $cc_info['card_zip'] = ! empty( $post_data['card_zip'] ) ? $post_data['card_zip'] : ''; |
|
1113 | + $cc_info['card_name'] = ! empty($post_data['card_name']) ? $post_data['card_name'] : ''; |
|
1114 | + $cc_info['card_number'] = ! empty($post_data['card_number']) ? $post_data['card_number'] : ''; |
|
1115 | + $cc_info['card_cvc'] = ! empty($post_data['card_cvc']) ? $post_data['card_cvc'] : ''; |
|
1116 | + $cc_info['card_exp_month'] = ! empty($post_data['card_exp_month']) ? $post_data['card_exp_month'] : ''; |
|
1117 | + $cc_info['card_exp_year'] = ! empty($post_data['card_exp_year']) ? $post_data['card_exp_year'] : ''; |
|
1118 | + $cc_info['card_address'] = ! empty($post_data['card_address']) ? $post_data['card_address'] : ''; |
|
1119 | + $cc_info['card_address_2'] = ! empty($post_data['card_address_2']) ? $post_data['card_address_2'] : ''; |
|
1120 | + $cc_info['card_city'] = ! empty($post_data['card_city']) ? $post_data['card_city'] : ''; |
|
1121 | + $cc_info['card_state'] = ! empty($post_data['card_state']) ? $post_data['card_state'] : ''; |
|
1122 | + $cc_info['card_country'] = ! empty($post_data['billing_country']) ? $post_data['billing_country'] : ''; |
|
1123 | + $cc_info['card_zip'] = ! empty($post_data['card_zip']) ? $post_data['card_zip'] : ''; |
|
1125 | 1124 | |
1126 | 1125 | // Return cc info. |
1127 | 1126 | return $cc_info; |
@@ -1137,14 +1136,14 @@ discard block |
||
1137 | 1136 | * |
1138 | 1137 | * @return bool|mixed |
1139 | 1138 | */ |
1140 | -function give_donation_form_validate_cc_zip( $zip = 0, $country_code = '' ) { |
|
1139 | +function give_donation_form_validate_cc_zip($zip = 0, $country_code = '') { |
|
1141 | 1140 | $ret = false; |
1142 | 1141 | |
1143 | - if ( empty( $zip ) || empty( $country_code ) ) { |
|
1142 | + if (empty($zip) || empty($country_code)) { |
|
1144 | 1143 | return $ret; |
1145 | 1144 | } |
1146 | 1145 | |
1147 | - $country_code = strtoupper( $country_code ); |
|
1146 | + $country_code = strtoupper($country_code); |
|
1148 | 1147 | |
1149 | 1148 | $zip_regex = array( |
1150 | 1149 | 'AD' => 'AD\d{3}', |
@@ -1304,11 +1303,11 @@ discard block |
||
1304 | 1303 | 'ZM' => '\d{5}', |
1305 | 1304 | ); |
1306 | 1305 | |
1307 | - if ( ! isset( $zip_regex[ $country_code ] ) || preg_match( '/' . $zip_regex[ $country_code ] . '/i', $zip ) ) { |
|
1306 | + if ( ! isset($zip_regex[$country_code]) || preg_match('/'.$zip_regex[$country_code].'/i', $zip)) { |
|
1308 | 1307 | $ret = true; |
1309 | 1308 | } |
1310 | 1309 | |
1311 | - return apply_filters( 'give_is_zip_valid', $ret, $zip, $country_code ); |
|
1310 | + return apply_filters('give_is_zip_valid', $ret, $zip, $country_code); |
|
1312 | 1311 | } |
1313 | 1312 | |
1314 | 1313 | /** |
@@ -1320,56 +1319,56 @@ discard block |
||
1320 | 1319 | * |
1321 | 1320 | * @return bool |
1322 | 1321 | */ |
1323 | -function give_validate_donation_amount( $valid_data ) { |
|
1322 | +function give_validate_donation_amount($valid_data) { |
|
1324 | 1323 | |
1325 | - $post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
1324 | + $post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
1326 | 1325 | |
1327 | 1326 | /* @var Give_Donate_Form $form */ |
1328 | - $form = new Give_Donate_Form( $post_data['give-form-id'] ); |
|
1327 | + $form = new Give_Donate_Form($post_data['give-form-id']); |
|
1329 | 1328 | |
1330 | 1329 | $donation_level_matched = false; |
1331 | 1330 | |
1332 | - if ( $form->is_set_type_donation_form() ) { |
|
1331 | + if ($form->is_set_type_donation_form()) { |
|
1333 | 1332 | |
1334 | 1333 | // Sanitize donation amount. |
1335 | - $post_data['give-amount'] = give_maybe_sanitize_amount( $post_data['give-amount'] ); |
|
1334 | + $post_data['give-amount'] = give_maybe_sanitize_amount($post_data['give-amount']); |
|
1336 | 1335 | |
1337 | 1336 | // Backward compatibility. |
1338 | - if ( $form->is_custom_price( $post_data['give-amount'] ) ) { |
|
1337 | + if ($form->is_custom_price($post_data['give-amount'])) { |
|
1339 | 1338 | $post_data['give-price-id'] = 'custom'; |
1340 | 1339 | } |
1341 | 1340 | |
1342 | 1341 | $donation_level_matched = true; |
1343 | 1342 | |
1344 | - } elseif ( $form->is_multi_type_donation_form() ) { |
|
1343 | + } elseif ($form->is_multi_type_donation_form()) { |
|
1345 | 1344 | |
1346 | 1345 | $variable_prices = $form->get_prices(); |
1347 | 1346 | |
1348 | 1347 | // Bailout. |
1349 | - if ( ! $variable_prices ) { |
|
1348 | + if ( ! $variable_prices) { |
|
1350 | 1349 | return false; |
1351 | 1350 | } |
1352 | 1351 | |
1353 | 1352 | // Sanitize donation amount. |
1354 | - $post_data['give-amount'] = give_maybe_sanitize_amount( $post_data['give-amount'] ); |
|
1355 | - $variable_price_option_amount = give_maybe_sanitize_amount( give_get_price_option_amount( $post_data['give-form-id'], $post_data['give-price-id'] ) ); |
|
1353 | + $post_data['give-amount'] = give_maybe_sanitize_amount($post_data['give-amount']); |
|
1354 | + $variable_price_option_amount = give_maybe_sanitize_amount(give_get_price_option_amount($post_data['give-form-id'], $post_data['give-price-id'])); |
|
1356 | 1355 | |
1357 | - if ( $post_data['give-amount'] === $variable_price_option_amount ) { |
|
1356 | + if ($post_data['give-amount'] === $variable_price_option_amount) { |
|
1358 | 1357 | return true; |
1359 | 1358 | } |
1360 | 1359 | |
1361 | - if ( $form->is_custom_price( $post_data['give-amount'] ) ) { |
|
1360 | + if ($form->is_custom_price($post_data['give-amount'])) { |
|
1362 | 1361 | $post_data['give-price-id'] = 'custom'; |
1363 | 1362 | } else { |
1364 | 1363 | |
1365 | 1364 | // Find correct donation level from all donation levels. |
1366 | - foreach ( $variable_prices as $variable_price ) { |
|
1365 | + foreach ($variable_prices as $variable_price) { |
|
1367 | 1366 | |
1368 | 1367 | // Sanitize level amount. |
1369 | - $variable_price['_give_amount'] = give_maybe_sanitize_amount( $variable_price['_give_amount'] ); |
|
1368 | + $variable_price['_give_amount'] = give_maybe_sanitize_amount($variable_price['_give_amount']); |
|
1370 | 1369 | |
1371 | 1370 | // Set first match donation level ID. |
1372 | - if ( $post_data['give-amount'] === $variable_price['_give_amount'] ) { |
|
1371 | + if ($post_data['give-amount'] === $variable_price['_give_amount']) { |
|
1373 | 1372 | $post_data['give-price-id'] = $variable_price['_give_id']['level_id']; |
1374 | 1373 | break; |
1375 | 1374 | } |
@@ -1378,15 +1377,15 @@ discard block |
||
1378 | 1377 | |
1379 | 1378 | // If donation amount is not find in donation levels then check if form has custom donation feature enable or not. |
1380 | 1379 | // If yes then set price id to custom if amount is greater then custom minimum amount (if any). |
1381 | - if ( ! empty( $post_data['give-price-id'] ) ) { |
|
1380 | + if ( ! empty($post_data['give-price-id'])) { |
|
1382 | 1381 | $donation_level_matched = true; |
1383 | 1382 | } |
1384 | 1383 | } // End if(). |
1385 | 1384 | |
1386 | - return ( $donation_level_matched ? true : false ); |
|
1385 | + return ($donation_level_matched ? true : false); |
|
1387 | 1386 | } |
1388 | 1387 | |
1389 | -add_action( 'give_checkout_error_checks', 'give_validate_donation_amount', 10, 1 ); |
|
1388 | +add_action('give_checkout_error_checks', 'give_validate_donation_amount', 10, 1); |
|
1390 | 1389 | |
1391 | 1390 | /** |
1392 | 1391 | * Validate Required Form Fields. |
@@ -1395,20 +1394,20 @@ discard block |
||
1395 | 1394 | * |
1396 | 1395 | * @since 2.0 |
1397 | 1396 | */ |
1398 | -function give_validate_required_form_fields( $form_id ) { |
|
1397 | +function give_validate_required_form_fields($form_id) { |
|
1399 | 1398 | |
1400 | 1399 | // Sanitize values submitted with donation form. |
1401 | - $post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
1400 | + $post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
1402 | 1401 | |
1403 | 1402 | // Loop through required fields and show error messages. |
1404 | - foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) { |
|
1403 | + foreach (give_get_required_fields($form_id) as $field_name => $value) { |
|
1405 | 1404 | |
1406 | 1405 | // Clean Up Data of the input fields. |
1407 | - $field_value = $post_data[ $field_name ]; |
|
1406 | + $field_value = $post_data[$field_name]; |
|
1408 | 1407 | |
1409 | 1408 | // Check whether the required field is empty, then show the error message. |
1410 | - if ( in_array( $value, give_get_required_fields( $form_id ), true ) && empty( $field_value ) ) { |
|
1411 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
1409 | + if (in_array($value, give_get_required_fields($form_id), true) && empty($field_value)) { |
|
1410 | + give_set_error($value['error_id'], $value['error_message']); |
|
1412 | 1411 | } |
1413 | 1412 | } |
1414 | 1413 | } |
@@ -1422,11 +1421,11 @@ discard block |
||
1422 | 1421 | * |
1423 | 1422 | * @return void |
1424 | 1423 | */ |
1425 | -function give_donation_form_validate_name_fields( $post_data ) { |
|
1426 | - $is_alpha_first_name = ctype_alpha( $post_data['give_first'] ) ? true : false; |
|
1427 | - $is_alpha_last_name = ctype_alpha( $post_data['give_last'] ) ? true : false; |
|
1424 | +function give_donation_form_validate_name_fields($post_data) { |
|
1425 | + $is_alpha_first_name = ctype_alpha($post_data['give_first']) ? true : false; |
|
1426 | + $is_alpha_last_name = ctype_alpha($post_data['give_last']) ? true : false; |
|
1428 | 1427 | |
1429 | - if ( ! $is_alpha_first_name || ( ! empty( $post_data['give_last'] ) && ! $is_alpha_last_name ) ) { |
|
1430 | - give_set_error( 'invalid_name', esc_html__( '<First Name | Last Name> cannot contain email address, numbers or special characters.', 'give' ) ); |
|
1428 | + if ( ! $is_alpha_first_name || ( ! empty($post_data['give_last']) && ! $is_alpha_last_name)) { |
|
1429 | + give_set_error('invalid_name', esc_html__('<First Name | Last Name> cannot contain email address, numbers or special characters.', 'give')); |
|
1431 | 1430 | } |
1432 | 1431 | } |
@@ -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 | |
@@ -30,54 +30,54 @@ discard block |
||
30 | 30 | * |
31 | 31 | * @return bool|array List of all user donations. |
32 | 32 | */ |
33 | -function give_get_users_donations( $user = 0, $number = 20, $pagination = false, $status = 'complete' ) { |
|
33 | +function give_get_users_donations($user = 0, $number = 20, $pagination = false, $status = 'complete') { |
|
34 | 34 | |
35 | - if ( empty( $user ) ) { |
|
35 | + if (empty($user)) { |
|
36 | 36 | $user = get_current_user_id(); |
37 | 37 | } |
38 | 38 | |
39 | - if ( 0 === $user && ! Give()->email_access->token_exists ) { |
|
39 | + if (0 === $user && ! Give()->email_access->token_exists) { |
|
40 | 40 | return false; |
41 | 41 | } |
42 | 42 | |
43 | - $status = ( 'complete' === $status ) ? 'publish' : $status; |
|
43 | + $status = ('complete' === $status) ? 'publish' : $status; |
|
44 | 44 | $paged = 1; |
45 | 45 | |
46 | - if ( $pagination ) { |
|
47 | - if ( get_query_var( 'paged' ) ) { |
|
48 | - $paged = get_query_var( 'paged' ); |
|
49 | - } elseif ( get_query_var( 'page' ) ) { |
|
50 | - $paged = get_query_var( 'page' ); |
|
46 | + if ($pagination) { |
|
47 | + if (get_query_var('paged')) { |
|
48 | + $paged = get_query_var('paged'); |
|
49 | + } elseif (get_query_var('page')) { |
|
50 | + $paged = get_query_var('page'); |
|
51 | 51 | } |
52 | 52 | } |
53 | 53 | |
54 | - $args = apply_filters( 'give_get_users_donations_args', array( |
|
54 | + $args = apply_filters('give_get_users_donations_args', array( |
|
55 | 55 | 'user' => $user, |
56 | 56 | 'number' => $number, |
57 | 57 | 'status' => $status, |
58 | 58 | 'orderby' => 'date', |
59 | - ) ); |
|
59 | + )); |
|
60 | 60 | |
61 | - if ( $pagination ) { |
|
61 | + if ($pagination) { |
|
62 | 62 | $args['page'] = $paged; |
63 | 63 | } else { |
64 | 64 | $args['nopaging'] = true; |
65 | 65 | } |
66 | 66 | |
67 | - $by_user_id = is_numeric( $user ) ? true : false; |
|
68 | - $donor = new Give_Donor( $user, $by_user_id ); |
|
67 | + $by_user_id = is_numeric($user) ? true : false; |
|
68 | + $donor = new Give_Donor($user, $by_user_id); |
|
69 | 69 | |
70 | - if ( ! empty( $donor->payment_ids ) ) { |
|
70 | + if ( ! empty($donor->payment_ids)) { |
|
71 | 71 | |
72 | - unset( $args['user'] ); |
|
73 | - $args['post__in'] = array_map( 'absint', explode( ',', $donor->payment_ids ) ); |
|
72 | + unset($args['user']); |
|
73 | + $args['post__in'] = array_map('absint', explode(',', $donor->payment_ids)); |
|
74 | 74 | |
75 | 75 | } |
76 | 76 | |
77 | - $donations = give_get_payments( apply_filters( 'give_get_users_donations_args', $args ) ); |
|
77 | + $donations = give_get_payments(apply_filters('give_get_users_donations_args', $args)); |
|
78 | 78 | |
79 | 79 | // No donations. |
80 | - if ( ! $donations ) { |
|
80 | + if ( ! $donations) { |
|
81 | 81 | return false; |
82 | 82 | } |
83 | 83 | |
@@ -96,65 +96,65 @@ discard block |
||
96 | 96 | * |
97 | 97 | * @return bool|object List of unique forms donated by user |
98 | 98 | */ |
99 | -function give_get_users_completed_donations( $user = 0, $status = 'complete' ) { |
|
100 | - if ( empty( $user ) ) { |
|
99 | +function give_get_users_completed_donations($user = 0, $status = 'complete') { |
|
100 | + if (empty($user)) { |
|
101 | 101 | $user = get_current_user_id(); |
102 | 102 | } |
103 | 103 | |
104 | - if ( empty( $user ) ) { |
|
104 | + if (empty($user)) { |
|
105 | 105 | return false; |
106 | 106 | } |
107 | 107 | |
108 | - $by_user_id = is_numeric( $user ) ? true : false; |
|
108 | + $by_user_id = is_numeric($user) ? true : false; |
|
109 | 109 | |
110 | - $donor = new Give_Donor( $user, $by_user_id ); |
|
110 | + $donor = new Give_Donor($user, $by_user_id); |
|
111 | 111 | |
112 | - if ( empty( $donor->payment_ids ) ) { |
|
112 | + if (empty($donor->payment_ids)) { |
|
113 | 113 | return false; |
114 | 114 | } |
115 | 115 | |
116 | 116 | // Get all the items donated. |
117 | - $payment_ids = array_reverse( explode( ',', $donor->payment_ids ) ); |
|
118 | - $limit_payments = apply_filters( 'give_users_completed_donations_payments', 50 ); |
|
119 | - if ( ! empty( $limit_payments ) ) { |
|
120 | - $payment_ids = array_slice( $payment_ids, 0, $limit_payments ); |
|
117 | + $payment_ids = array_reverse(explode(',', $donor->payment_ids)); |
|
118 | + $limit_payments = apply_filters('give_users_completed_donations_payments', 50); |
|
119 | + if ( ! empty($limit_payments)) { |
|
120 | + $payment_ids = array_slice($payment_ids, 0, $limit_payments); |
|
121 | 121 | } |
122 | 122 | $donation_data = array(); |
123 | - foreach ( $payment_ids as $payment_id ) { |
|
124 | - $donation_data[] = give_get_payment_meta( $payment_id ); |
|
123 | + foreach ($payment_ids as $payment_id) { |
|
124 | + $donation_data[] = give_get_payment_meta($payment_id); |
|
125 | 125 | } |
126 | 126 | |
127 | - if ( empty( $donation_data ) ) { |
|
127 | + if (empty($donation_data)) { |
|
128 | 128 | return false; |
129 | 129 | } |
130 | 130 | |
131 | 131 | // Grab only the post ids "form_id" of the forms donated on this order. |
132 | 132 | $completed_donations_ids = array(); |
133 | - foreach ( $donation_data as $donation_meta ) { |
|
134 | - $completed_donations_ids[] = isset( $donation_meta['form_id'] ) ? $donation_meta['form_id'] : ''; |
|
133 | + foreach ($donation_data as $donation_meta) { |
|
134 | + $completed_donations_ids[] = isset($donation_meta['form_id']) ? $donation_meta['form_id'] : ''; |
|
135 | 135 | } |
136 | 136 | |
137 | - if ( empty( $completed_donations_ids ) ) { |
|
137 | + if (empty($completed_donations_ids)) { |
|
138 | 138 | return false; |
139 | 139 | } |
140 | 140 | |
141 | 141 | // Only include each donation once. |
142 | - $form_ids = array_unique( $completed_donations_ids ); |
|
142 | + $form_ids = array_unique($completed_donations_ids); |
|
143 | 143 | |
144 | 144 | // Make sure we still have some products and a first item. |
145 | - if ( empty( $form_ids ) || ! isset( $form_ids[0] ) ) { |
|
145 | + if (empty($form_ids) || ! isset($form_ids[0])) { |
|
146 | 146 | return false; |
147 | 147 | } |
148 | 148 | |
149 | - $post_type = get_post_type( $form_ids[0] ); |
|
149 | + $post_type = get_post_type($form_ids[0]); |
|
150 | 150 | |
151 | - $args = apply_filters( 'give_get_users_completed_donations_args', array( |
|
151 | + $args = apply_filters('give_get_users_completed_donations_args', array( |
|
152 | 152 | 'include' => $form_ids, |
153 | 153 | 'post_type' => $post_type, |
154 | - 'posts_per_page' => - 1, |
|
155 | - ) ); |
|
154 | + 'posts_per_page' => -1, |
|
155 | + )); |
|
156 | 156 | |
157 | - return apply_filters( 'give_users_completed_donations_list', get_posts( $args ) ); |
|
157 | + return apply_filters('give_users_completed_donations_list', get_posts($args)); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | |
@@ -170,12 +170,12 @@ discard block |
||
170 | 170 | * |
171 | 171 | * @return bool True if has donated, false other wise. |
172 | 172 | */ |
173 | -function give_has_donations( $user_id = null ) { |
|
174 | - if ( empty( $user_id ) ) { |
|
173 | +function give_has_donations($user_id = null) { |
|
174 | + if (empty($user_id)) { |
|
175 | 175 | $user_id = get_current_user_id(); |
176 | 176 | } |
177 | 177 | |
178 | - if ( give_get_users_donations( $user_id, 1 ) ) { |
|
178 | + if (give_get_users_donations($user_id, 1)) { |
|
179 | 179 | return true; // User has at least one donation. |
180 | 180 | } |
181 | 181 | |
@@ -196,23 +196,23 @@ discard block |
||
196 | 196 | * |
197 | 197 | * @return array |
198 | 198 | */ |
199 | -function give_get_donation_stats_by_user( $user = '' ) { |
|
199 | +function give_get_donation_stats_by_user($user = '') { |
|
200 | 200 | |
201 | 201 | $field = ''; |
202 | 202 | |
203 | - if ( is_email( $user ) ) { |
|
203 | + if (is_email($user)) { |
|
204 | 204 | $field = 'email'; |
205 | - } elseif ( is_numeric( $user ) ) { |
|
205 | + } elseif (is_numeric($user)) { |
|
206 | 206 | $field = 'user_id'; |
207 | 207 | } |
208 | 208 | |
209 | - $stats = array(); |
|
210 | - $donor = Give()->donors->get_donor_by( $field, $user ); |
|
209 | + $stats = array(); |
|
210 | + $donor = Give()->donors->get_donor_by($field, $user); |
|
211 | 211 | |
212 | - if ( $donor ) { |
|
213 | - $donor = new Give_Donor( $donor->id ); |
|
214 | - $stats['purchases'] = absint( $donor->purchase_count ); |
|
215 | - $stats['total_spent'] = give_maybe_sanitize_amount( $donor->get_total_donation_amount() ); |
|
212 | + if ($donor) { |
|
213 | + $donor = new Give_Donor($donor->id); |
|
214 | + $stats['purchases'] = absint($donor->purchase_count); |
|
215 | + $stats['total_spent'] = give_maybe_sanitize_amount($donor->get_total_donation_amount()); |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | /** |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | * |
221 | 221 | * @since 1.7 |
222 | 222 | */ |
223 | - $stats = (array) apply_filters( 'give_donation_stats_by_user', $stats, $user ); |
|
223 | + $stats = (array) apply_filters('give_donation_stats_by_user', $stats, $user); |
|
224 | 224 | |
225 | 225 | return $stats; |
226 | 226 | } |
@@ -238,21 +238,21 @@ discard block |
||
238 | 238 | * |
239 | 239 | * @return int The total number of donations. |
240 | 240 | */ |
241 | -function give_count_donations_of_donor( $user = null ) { |
|
241 | +function give_count_donations_of_donor($user = null) { |
|
242 | 242 | |
243 | 243 | // Logged in? |
244 | - if ( empty( $user ) ) { |
|
244 | + if (empty($user)) { |
|
245 | 245 | $user = get_current_user_id(); |
246 | 246 | } |
247 | 247 | |
248 | 248 | // Email access? |
249 | - if ( empty( $user ) && Give()->email_access->token_email ) { |
|
249 | + if (empty($user) && Give()->email_access->token_email) { |
|
250 | 250 | $user = Give()->email_access->token_email; |
251 | 251 | } |
252 | 252 | |
253 | - $stats = ! empty( $user ) ? give_get_donation_stats_by_user( $user ) : false; |
|
253 | + $stats = ! empty($user) ? give_get_donation_stats_by_user($user) : false; |
|
254 | 254 | |
255 | - return isset( $stats['purchases'] ) ? $stats['purchases'] : 0; |
|
255 | + return isset($stats['purchases']) ? $stats['purchases'] : 0; |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | /** |
@@ -265,9 +265,9 @@ discard block |
||
265 | 265 | * |
266 | 266 | * @return float The total amount the user has spent |
267 | 267 | */ |
268 | -function give_donation_total_of_user( $user = null ) { |
|
268 | +function give_donation_total_of_user($user = null) { |
|
269 | 269 | |
270 | - $stats = give_get_donation_stats_by_user( $user ); |
|
270 | + $stats = give_get_donation_stats_by_user($user); |
|
271 | 271 | |
272 | 272 | return $stats['total_spent']; |
273 | 273 | } |
@@ -283,40 +283,40 @@ discard block |
||
283 | 283 | * |
284 | 284 | * @return bool |
285 | 285 | */ |
286 | -function give_validate_username( $username, $form_id = 0 ) { |
|
286 | +function give_validate_username($username, $form_id = 0) { |
|
287 | 287 | $valid = true; |
288 | 288 | |
289 | 289 | // Validate username. |
290 | - if ( ! empty( $username ) ) { |
|
290 | + if ( ! empty($username)) { |
|
291 | 291 | |
292 | 292 | // Sanitize username. |
293 | - $sanitized_user_name = sanitize_user( $username, false ); |
|
293 | + $sanitized_user_name = sanitize_user($username, false); |
|
294 | 294 | |
295 | 295 | // We have an user name, check if it already exists. |
296 | - if ( username_exists( $username ) ) { |
|
296 | + if (username_exists($username)) { |
|
297 | 297 | // Username already registered. |
298 | - give_set_error( 'username_unavailable', __( 'Username already taken.', 'give' ) ); |
|
298 | + give_set_error('username_unavailable', __('Username already taken.', 'give')); |
|
299 | 299 | $valid = false; |
300 | 300 | |
301 | 301 | // Check if it's valid. |
302 | - } elseif ( $sanitized_user_name !== $username ) { |
|
302 | + } elseif ($sanitized_user_name !== $username) { |
|
303 | 303 | // Invalid username. |
304 | - if ( is_multisite() ) { |
|
305 | - give_set_error( 'username_invalid', __( 'Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give' ) ); |
|
304 | + if (is_multisite()) { |
|
305 | + give_set_error('username_invalid', __('Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give')); |
|
306 | 306 | $valid = false; |
307 | 307 | } else { |
308 | - give_set_error( 'username_invalid', __( 'Invalid username.', 'give' ) ); |
|
308 | + give_set_error('username_invalid', __('Invalid username.', 'give')); |
|
309 | 309 | $valid = false; |
310 | 310 | } |
311 | 311 | } |
312 | 312 | } else { |
313 | 313 | // Username is empty. |
314 | - give_set_error( 'username_empty', __( 'Enter a username.', 'give' ) ); |
|
314 | + give_set_error('username_empty', __('Enter a username.', 'give')); |
|
315 | 315 | $valid = false; |
316 | 316 | |
317 | 317 | // Check if guest checkout is disable for form. |
318 | - if ( $form_id && give_logged_in_only( $form_id ) ) { |
|
319 | - give_set_error( 'registration_required', __( 'You must register or login to complete your donation.', 'give' ) ); |
|
318 | + if ($form_id && give_logged_in_only($form_id)) { |
|
319 | + give_set_error('registration_required', __('You must register or login to complete your donation.', 'give')); |
|
320 | 320 | $valid = false; |
321 | 321 | } |
322 | 322 | } |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | * |
331 | 331 | * @since 1.8 |
332 | 332 | */ |
333 | - $valid = (bool) apply_filters( 'give_validate_username', $valid, $username, $form_id ); |
|
333 | + $valid = (bool) apply_filters('give_validate_username', $valid, $username, $form_id); |
|
334 | 334 | |
335 | 335 | return $valid; |
336 | 336 | } |
@@ -346,30 +346,30 @@ discard block |
||
346 | 346 | * |
347 | 347 | * @return bool |
348 | 348 | */ |
349 | -function give_validate_user_email( $email, $registering_new_user = false ) { |
|
349 | +function give_validate_user_email($email, $registering_new_user = false) { |
|
350 | 350 | $valid = true; |
351 | 351 | |
352 | - if ( empty( $email ) ) { |
|
352 | + if (empty($email)) { |
|
353 | 353 | // No email. |
354 | - give_set_error( 'email_empty', __( 'Enter an email.', 'give' ) ); |
|
354 | + give_set_error('email_empty', __('Enter an email.', 'give')); |
|
355 | 355 | $valid = false; |
356 | 356 | |
357 | - } elseif ( email_exists( $email ) ) { |
|
357 | + } elseif (email_exists($email)) { |
|
358 | 358 | // Email already exists. |
359 | - give_set_error( 'email_exists', __( 'Email already exists.', 'give' ) ); |
|
359 | + give_set_error('email_exists', __('Email already exists.', 'give')); |
|
360 | 360 | $valid = false; |
361 | 361 | |
362 | - } elseif ( ! is_email( $email ) ) { |
|
362 | + } elseif ( ! is_email($email)) { |
|
363 | 363 | // Validate email. |
364 | - give_set_error( 'email_invalid', __( 'Invalid email.', 'give' ) ); |
|
364 | + give_set_error('email_invalid', __('Invalid email.', 'give')); |
|
365 | 365 | $valid = false; |
366 | 366 | |
367 | - } elseif ( $registering_new_user ) { |
|
367 | + } elseif ($registering_new_user) { |
|
368 | 368 | |
369 | 369 | // If donor email is not primary. |
370 | - if ( ! email_exists( $email ) && give_donor_email_exists( $email ) && give_is_additional_email( $email ) ) { |
|
370 | + if ( ! email_exists($email) && give_donor_email_exists($email) && give_is_additional_email($email)) { |
|
371 | 371 | // Check if email exists. |
372 | - give_set_error( 'email_used', __( 'The email address provided is already active for another user.', 'give' ) ); |
|
372 | + give_set_error('email_used', __('The email address provided is already active for another user.', 'give')); |
|
373 | 373 | $valid = false; |
374 | 374 | } |
375 | 375 | } |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | * |
384 | 384 | * @since 1.8 |
385 | 385 | */ |
386 | - $valid = (bool) apply_filters( 'give_validate_user_email', $valid, $email, $registering_new_user ); |
|
386 | + $valid = (bool) apply_filters('give_validate_user_email', $valid, $email, $registering_new_user); |
|
387 | 387 | |
388 | 388 | return $valid; |
389 | 389 | } |
@@ -399,34 +399,34 @@ discard block |
||
399 | 399 | * |
400 | 400 | * @return bool |
401 | 401 | */ |
402 | -function give_validate_user_password( $password = '', $confirm_password = '', $registering_new_user = false ) { |
|
402 | +function give_validate_user_password($password = '', $confirm_password = '', $registering_new_user = false) { |
|
403 | 403 | $valid = true; |
404 | 404 | |
405 | 405 | // Passwords Validation For New Donors Only. |
406 | - if ( $registering_new_user ) { |
|
406 | + if ($registering_new_user) { |
|
407 | 407 | // Password or confirmation missing. |
408 | - if ( ! $password ) { |
|
408 | + if ( ! $password) { |
|
409 | 409 | // The password is invalid. |
410 | - give_set_error( 'password_empty', __( 'Enter a password.', 'give' ) ); |
|
410 | + give_set_error('password_empty', __('Enter a password.', 'give')); |
|
411 | 411 | $valid = false; |
412 | - } elseif ( ! $confirm_password ) { |
|
412 | + } elseif ( ! $confirm_password) { |
|
413 | 413 | // Confirmation password is invalid. |
414 | - give_set_error( 'confirmation_empty', __( 'Enter the password confirmation.', 'give' ) ); |
|
414 | + give_set_error('confirmation_empty', __('Enter the password confirmation.', 'give')); |
|
415 | 415 | $valid = false; |
416 | 416 | } |
417 | 417 | } |
418 | 418 | // Passwords Validation For New Donors as well as Existing Donors. |
419 | - if ( $password || $confirm_password ) { |
|
420 | - if ( strlen( $password ) < 6 || strlen( $confirm_password ) < 6 ) { |
|
419 | + if ($password || $confirm_password) { |
|
420 | + if (strlen($password) < 6 || strlen($confirm_password) < 6) { |
|
421 | 421 | // Seems Weak Password. |
422 | - give_set_error( 'password_weak', __( 'Passwords should have at least 6 characters.', 'give' ) ); |
|
422 | + give_set_error('password_weak', __('Passwords should have at least 6 characters.', 'give')); |
|
423 | 423 | $valid = false; |
424 | 424 | } |
425 | - if ( $password && $confirm_password ) { |
|
425 | + if ($password && $confirm_password) { |
|
426 | 426 | // Verify confirmation matches. |
427 | - if ( $password !== $confirm_password ) { |
|
427 | + if ($password !== $confirm_password) { |
|
428 | 428 | // Passwords do not match. |
429 | - give_set_error( 'password_mismatch', __( 'Passwords you entered do not match. Please try again.', 'give' ) ); |
|
429 | + give_set_error('password_mismatch', __('Passwords you entered do not match. Please try again.', 'give')); |
|
430 | 430 | $valid = false; |
431 | 431 | } |
432 | 432 | } |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | * |
443 | 443 | * @since 1.8 |
444 | 444 | */ |
445 | - $valid = (bool) apply_filters( 'give_validate_user_email', $valid, $password, $confirm_password, $registering_new_user ); |
|
445 | + $valid = (bool) apply_filters('give_validate_user_email', $valid, $password, $confirm_password, $registering_new_user); |
|
446 | 446 | |
447 | 447 | return $valid; |
448 | 448 | } |
@@ -470,8 +470,8 @@ discard block |
||
470 | 470 | * |
471 | 471 | * @return array The donor's address, if any |
472 | 472 | */ |
473 | -function give_get_donor_address( $donor_id = null, $args = array() ) { |
|
474 | - if ( empty( $donor_id ) ) { |
|
473 | +function give_get_donor_address($donor_id = null, $args = array()) { |
|
474 | + if (empty($donor_id)) { |
|
475 | 475 | $donor_id = get_current_user_id(); |
476 | 476 | } |
477 | 477 | |
@@ -493,33 +493,33 @@ discard block |
||
493 | 493 | |
494 | 494 | |
495 | 495 | // Backward compatibility for user id param. |
496 | - $by_user_id = get_user_by( 'id', $donor_id ) ? true : false; |
|
496 | + $by_user_id = get_user_by('id', $donor_id) ? true : false; |
|
497 | 497 | |
498 | 498 | // Backward compatibility. |
499 | - if ( ! give_has_upgrade_completed( 'v20_upgrades_user_address' ) && $by_user_id ) { |
|
499 | + if ( ! give_has_upgrade_completed('v20_upgrades_user_address') && $by_user_id) { |
|
500 | 500 | return wp_parse_args( |
501 | - (array) get_user_meta( $donor_id, '_give_user_address', true ), |
|
501 | + (array) get_user_meta($donor_id, '_give_user_address', true), |
|
502 | 502 | $default_address |
503 | 503 | ); |
504 | 504 | } |
505 | 505 | |
506 | - $donor = new Give_Donor( $donor_id, $by_user_id ); |
|
506 | + $donor = new Give_Donor($donor_id, $by_user_id); |
|
507 | 507 | |
508 | 508 | if ( |
509 | 509 | ! $donor->id || |
510 | - empty( $donor->address ) || |
|
511 | - ! array_key_exists( $args['address_type'], $donor->address ) |
|
510 | + empty($donor->address) || |
|
511 | + ! array_key_exists($args['address_type'], $donor->address) |
|
512 | 512 | ) { |
513 | 513 | return $default_address; |
514 | 514 | } |
515 | 515 | |
516 | - switch ( true ) { |
|
517 | - case is_string( end( $donor->address[ $args['address_type'] ] ) ): |
|
518 | - $address = wp_parse_args( $donor->address[ $args['address_type'] ], $default_address ); |
|
516 | + switch (true) { |
|
517 | + case is_string(end($donor->address[$args['address_type']])): |
|
518 | + $address = wp_parse_args($donor->address[$args['address_type']], $default_address); |
|
519 | 519 | break; |
520 | 520 | |
521 | - case is_array( end( $donor->address[ $args['address_type'] ] ) ): |
|
522 | - $address = wp_parse_args( array_shift( $donor->address[ $args['address_type'] ] ), $default_address ); |
|
521 | + case is_array(end($donor->address[$args['address_type']])): |
|
522 | + $address = wp_parse_args(array_shift($donor->address[$args['address_type']]), $default_address); |
|
523 | 523 | break; |
524 | 524 | } |
525 | 525 | |
@@ -539,17 +539,17 @@ discard block |
||
539 | 539 | * |
540 | 540 | * @return void |
541 | 541 | */ |
542 | -function give_new_user_notification( $user_id = 0, $user_data = array() ) { |
|
542 | +function give_new_user_notification($user_id = 0, $user_data = array()) { |
|
543 | 543 | // Bailout. |
544 | - if ( empty( $user_id ) || empty( $user_data ) ) { |
|
544 | + if (empty($user_id) || empty($user_data)) { |
|
545 | 545 | return; |
546 | 546 | } |
547 | 547 | |
548 | - do_action( 'give_new-donor-register_email_notification', $user_id, $user_data ); |
|
549 | - do_action( 'give_donor-register_email_notification', $user_id, $user_data ); |
|
548 | + do_action('give_new-donor-register_email_notification', $user_id, $user_data); |
|
549 | + do_action('give_donor-register_email_notification', $user_id, $user_data); |
|
550 | 550 | } |
551 | 551 | |
552 | -add_action( 'give_insert_user', 'give_new_user_notification', 10, 2 ); |
|
552 | +add_action('give_insert_user', 'give_new_user_notification', 10, 2); |
|
553 | 553 | |
554 | 554 | |
555 | 555 | /** |
@@ -565,33 +565,33 @@ discard block |
||
565 | 565 | * |
566 | 566 | * @return string |
567 | 567 | */ |
568 | -function give_get_donor_name_by( $id = 0, $from = 'donation' ) { |
|
568 | +function give_get_donor_name_by($id = 0, $from = 'donation') { |
|
569 | 569 | |
570 | 570 | // ID shouldn't be empty. |
571 | - if ( empty( $id ) ) { |
|
571 | + if (empty($id)) { |
|
572 | 572 | return ''; |
573 | 573 | } |
574 | 574 | |
575 | 575 | $name = ''; |
576 | 576 | |
577 | - switch ( $from ) { |
|
577 | + switch ($from) { |
|
578 | 578 | |
579 | 579 | case 'donation': |
580 | - $first_name = give_get_meta( $id, '_give_donor_billing_first_name', true ); |
|
581 | - $last_name = give_get_meta( $id, '_give_donor_billing_last_name', true ); |
|
580 | + $first_name = give_get_meta($id, '_give_donor_billing_first_name', true); |
|
581 | + $last_name = give_get_meta($id, '_give_donor_billing_last_name', true); |
|
582 | 582 | |
583 | - $name = trim( "{$first_name} {$last_name}" ); |
|
583 | + $name = trim("{$first_name} {$last_name}"); |
|
584 | 584 | |
585 | 585 | break; |
586 | 586 | |
587 | 587 | case 'donor': |
588 | - $name = Give()->donors->get_column( 'name', $id ); |
|
588 | + $name = Give()->donors->get_column('name', $id); |
|
589 | 589 | |
590 | 590 | break; |
591 | 591 | |
592 | 592 | } |
593 | 593 | |
594 | - return trim( $name ); |
|
594 | + return trim($name); |
|
595 | 595 | |
596 | 596 | } |
597 | 597 | |
@@ -604,8 +604,8 @@ discard block |
||
604 | 604 | * |
605 | 605 | * @return boolean The user's ID on success, and false on failure. |
606 | 606 | */ |
607 | -function give_donor_email_exists( $email ) { |
|
608 | - if ( Give()->donors->get_donor_by( 'email', $email ) ) { |
|
607 | +function give_donor_email_exists($email) { |
|
608 | + if (Give()->donors->get_donor_by('email', $email)) { |
|
609 | 609 | return true; |
610 | 610 | } |
611 | 611 | return false; |
@@ -620,14 +620,14 @@ discard block |
||
620 | 620 | * |
621 | 621 | * @return bool |
622 | 622 | */ |
623 | -function give_is_additional_email( $email ) { |
|
623 | +function give_is_additional_email($email) { |
|
624 | 624 | global $wpdb; |
625 | 625 | |
626 | 626 | $meta_table = Give()->donor_meta->table_name; |
627 | 627 | $meta_type = Give()->donor_meta->meta_type; |
628 | - $donor_id = $wpdb->get_var( $wpdb->prepare( "SELECT {$meta_type}_id FROM {$meta_table} WHERE meta_key = 'additional_email' AND meta_value = %s LIMIT 1", $email ) ); |
|
628 | + $donor_id = $wpdb->get_var($wpdb->prepare("SELECT {$meta_type}_id FROM {$meta_table} WHERE meta_key = 'additional_email' AND meta_value = %s LIMIT 1", $email)); |
|
629 | 629 | |
630 | - if ( empty( $donor_id ) ) { |
|
630 | + if (empty($donor_id)) { |
|
631 | 631 | return false; |
632 | 632 | } |
633 | 633 |
@@ -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 | |
@@ -21,14 +21,14 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param $data |
23 | 23 | */ |
24 | -function give_process_gateway_select( $data ) { |
|
25 | - if ( isset( $_POST['gateway_submit'] ) ) { |
|
26 | - wp_redirect( esc_url( add_query_arg( 'payment-mode', $_POST['payment-mode'] ) ) ); |
|
24 | +function give_process_gateway_select($data) { |
|
25 | + if (isset($_POST['gateway_submit'])) { |
|
26 | + wp_redirect(esc_url(add_query_arg('payment-mode', $_POST['payment-mode']))); |
|
27 | 27 | exit; |
28 | 28 | } |
29 | 29 | } |
30 | 30 | |
31 | -add_action( 'give_gateway_select', 'give_process_gateway_select' ); |
|
31 | +add_action('give_gateway_select', 'give_process_gateway_select'); |
|
32 | 32 | |
33 | 33 | /** |
34 | 34 | * Loads a payment gateway via AJAX. |
@@ -39,11 +39,11 @@ discard block |
||
39 | 39 | */ |
40 | 40 | function give_load_ajax_gateway() { |
41 | 41 | |
42 | - $post_data = give_clean( $_POST ); // WPCS: input var ok, CSRF ok. |
|
42 | + $post_data = give_clean($_POST); // WPCS: input var ok, CSRF ok. |
|
43 | 43 | |
44 | - if ( isset( $post_data['give_payment_mode'] ) ) { |
|
44 | + if (isset($post_data['give_payment_mode'])) { |
|
45 | 45 | |
46 | - $form_id_prefix = ! empty( $post_data['give_form_id_prefix'] ) ? $post_data['give_form_id_prefix'] : ''; |
|
46 | + $form_id_prefix = ! empty($post_data['give_form_id_prefix']) ? $post_data['give_form_id_prefix'] : ''; |
|
47 | 47 | |
48 | 48 | $args = array( |
49 | 49 | 'id_prefix' => $form_id_prefix, |
@@ -54,14 +54,14 @@ discard block |
||
54 | 54 | * |
55 | 55 | * @since 1.7 |
56 | 56 | */ |
57 | - do_action( 'give_donation_form', $post_data['give_form_id'], $args ); |
|
57 | + do_action('give_donation_form', $post_data['give_form_id'], $args); |
|
58 | 58 | |
59 | 59 | exit(); |
60 | 60 | } |
61 | 61 | } |
62 | 62 | |
63 | -add_action( 'wp_ajax_give_load_gateway', 'give_load_ajax_gateway' ); |
|
64 | -add_action( 'wp_ajax_nopriv_give_load_gateway', 'give_load_ajax_gateway' ); |
|
63 | +add_action('wp_ajax_give_load_gateway', 'give_load_ajax_gateway'); |
|
64 | +add_action('wp_ajax_nopriv_give_load_gateway', 'give_load_ajax_gateway'); |
|
65 | 65 | |
66 | 66 | /** |
67 | 67 | * Create wp nonce using Ajax call. |
@@ -73,18 +73,18 @@ discard block |
||
73 | 73 | * @return void |
74 | 74 | */ |
75 | 75 | function give_donation_form_nonce() { |
76 | - if ( isset( $_POST['give_form_id'] ) ) { |
|
76 | + if (isset($_POST['give_form_id'])) { |
|
77 | 77 | |
78 | 78 | // Get donation form id. |
79 | - $form_id = is_numeric( $_POST['give_form_id'] ) ? absint( $_POST['give_form_id'] ) : 0; |
|
79 | + $form_id = is_numeric($_POST['give_form_id']) ? absint($_POST['give_form_id']) : 0; |
|
80 | 80 | |
81 | 81 | // Send nonce json data. |
82 | - wp_send_json_success( wp_create_nonce( "give_donation_form_nonce_{$form_id}" ) ); |
|
82 | + wp_send_json_success(wp_create_nonce("give_donation_form_nonce_{$form_id}")); |
|
83 | 83 | } |
84 | 84 | } |
85 | 85 | |
86 | -add_action( 'wp_ajax_give_donation_form_nonce', 'give_donation_form_nonce' ); |
|
87 | -add_action( 'wp_ajax_nopriv_give_donation_form_nonce', 'give_donation_form_nonce' ); |
|
86 | +add_action('wp_ajax_give_donation_form_nonce', 'give_donation_form_nonce'); |
|
87 | +add_action('wp_ajax_nopriv_give_donation_form_nonce', 'give_donation_form_nonce'); |
|
88 | 88 | |
89 | 89 | /** |
90 | 90 | * Sets an error within the donation form if no gateways are enabled. |
@@ -97,11 +97,11 @@ discard block |
||
97 | 97 | function give_no_gateway_error() { |
98 | 98 | $gateways = give_get_enabled_payment_gateways(); |
99 | 99 | |
100 | - if ( empty( $gateways ) ) { |
|
101 | - give_set_error( 'no_gateways', esc_html__( 'You must enable a payment gateway to use Give.', 'give' ) ); |
|
100 | + if (empty($gateways)) { |
|
101 | + give_set_error('no_gateways', esc_html__('You must enable a payment gateway to use Give.', 'give')); |
|
102 | 102 | } else { |
103 | - give_unset_error( 'no_gateways' ); |
|
103 | + give_unset_error('no_gateways'); |
|
104 | 104 | } |
105 | 105 | } |
106 | 106 | |
107 | -add_action( 'init', 'give_no_gateway_error' ); |
|
107 | +add_action('init', 'give_no_gateway_error'); |
@@ -37,8 +37,8 @@ discard block |
||
37 | 37 | * @since 2.1.0 |
38 | 38 | */ |
39 | 39 | public function __construct() { |
40 | - $this->direction = ( is_rtl() || isset( $_GET['d'] ) && 'rtl' === $_GET['d'] ) ? '.rtl' : ''; |
|
41 | - $this->scripts_footer = give_is_setting_enabled( give_get_option( 'scripts_footer' ) ) ? true : false; |
|
40 | + $this->direction = (is_rtl() || isset($_GET['d']) && 'rtl' === $_GET['d']) ? '.rtl' : ''; |
|
41 | + $this->scripts_footer = give_is_setting_enabled(give_get_option('scripts_footer')) ? true : false; |
|
42 | 42 | $this->init(); |
43 | 43 | } |
44 | 44 | |
@@ -49,20 +49,20 @@ discard block |
||
49 | 49 | */ |
50 | 50 | public function init() { |
51 | 51 | |
52 | - add_action( 'admin_enqueue_scripts', array( $this, 'register_styles' ) ); |
|
53 | - add_action( 'admin_enqueue_scripts', array( $this, 'register_scripts' ) ); |
|
54 | - add_action( 'wp_enqueue_scripts', array( $this, 'register_styles' ) ); |
|
55 | - add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts' ) ); |
|
52 | + add_action('admin_enqueue_scripts', array($this, 'register_styles')); |
|
53 | + add_action('admin_enqueue_scripts', array($this, 'register_scripts')); |
|
54 | + add_action('wp_enqueue_scripts', array($this, 'register_styles')); |
|
55 | + add_action('wp_enqueue_scripts', array($this, 'register_scripts')); |
|
56 | 56 | |
57 | - if ( is_admin() ) { |
|
58 | - add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) ); |
|
59 | - add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_styles' ) ); |
|
60 | - add_action( 'enqueue_block_editor_assets', array( $this, 'gutenberg_admin_scripts' ) ); |
|
61 | - add_action( 'admin_head', array( $this, 'global_admin_head' ) ); |
|
57 | + if (is_admin()) { |
|
58 | + add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts')); |
|
59 | + add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_styles')); |
|
60 | + add_action('enqueue_block_editor_assets', array($this, 'gutenberg_admin_scripts')); |
|
61 | + add_action('admin_head', array($this, 'global_admin_head')); |
|
62 | 62 | |
63 | 63 | } else { |
64 | - add_action( 'wp_enqueue_scripts', array( $this, 'public_enqueue_styles' ) ); |
|
65 | - add_action( 'wp_enqueue_scripts', array( $this, 'public_enqueue_scripts' ) ); |
|
64 | + add_action('wp_enqueue_scripts', array($this, 'public_enqueue_styles')); |
|
65 | + add_action('wp_enqueue_scripts', array($this, 'public_enqueue_scripts')); |
|
66 | 66 | } |
67 | 67 | } |
68 | 68 | |
@@ -74,11 +74,11 @@ discard block |
||
74 | 74 | public function register_styles() { |
75 | 75 | |
76 | 76 | // WP-admin. |
77 | - wp_register_style( 'give-admin-styles', GIVE_PLUGIN_URL . 'assets/dist/css/admin' . $this->direction . '.css', array(), GIVE_VERSION ); |
|
77 | + wp_register_style('give-admin-styles', GIVE_PLUGIN_URL.'assets/dist/css/admin'.$this->direction.'.css', array(), GIVE_VERSION); |
|
78 | 78 | |
79 | 79 | // Frontend. |
80 | - if ( give_is_setting_enabled( give_get_option( 'css' ) ) ) { |
|
81 | - wp_register_style( 'give-styles', $this->get_frontend_stylesheet_uri(), array(), GIVE_VERSION, 'all' ); |
|
80 | + if (give_is_setting_enabled(give_get_option('css'))) { |
|
81 | + wp_register_style('give-styles', $this->get_frontend_stylesheet_uri(), array(), GIVE_VERSION, 'all'); |
|
82 | 82 | } |
83 | 83 | } |
84 | 84 | |
@@ -90,15 +90,15 @@ discard block |
||
90 | 90 | public function register_scripts() { |
91 | 91 | |
92 | 92 | // WP-Admin. |
93 | - wp_register_script( 'give-admin-scripts', GIVE_PLUGIN_URL . 'assets/dist/js/admin.js', array( |
|
93 | + wp_register_script('give-admin-scripts', GIVE_PLUGIN_URL.'assets/dist/js/admin.js', array( |
|
94 | 94 | 'jquery', |
95 | 95 | 'jquery-ui-datepicker', |
96 | 96 | 'wp-color-picker', |
97 | 97 | 'jquery-query', |
98 | - ), GIVE_VERSION ); |
|
98 | + ), GIVE_VERSION); |
|
99 | 99 | |
100 | 100 | // Frontend. |
101 | - wp_register_script( 'give', GIVE_PLUGIN_URL . 'assets/dist/js/give.js', array( 'jquery' ), GIVE_VERSION, $this->scripts_footer ); |
|
101 | + wp_register_script('give', GIVE_PLUGIN_URL.'assets/dist/js/give.js', array('jquery'), GIVE_VERSION, $this->scripts_footer); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
@@ -108,20 +108,20 @@ discard block |
||
108 | 108 | * |
109 | 109 | * @param string $hook Page hook. |
110 | 110 | */ |
111 | - public function admin_enqueue_styles( $hook ) { |
|
111 | + public function admin_enqueue_styles($hook) { |
|
112 | 112 | |
113 | 113 | // Give Admin Only. |
114 | - if ( ! apply_filters( 'give_load_admin_styles', give_is_admin_page(), $hook ) ) { |
|
114 | + if ( ! apply_filters('give_load_admin_styles', give_is_admin_page(), $hook)) { |
|
115 | 115 | return; |
116 | 116 | } |
117 | 117 | |
118 | 118 | // Give enqueues. |
119 | - wp_enqueue_style( 'give-admin-styles' ); |
|
120 | - wp_enqueue_style( 'give-admin-bar-notification' ); |
|
119 | + wp_enqueue_style('give-admin-styles'); |
|
120 | + wp_enqueue_style('give-admin-bar-notification'); |
|
121 | 121 | |
122 | 122 | // WP Core enqueues. |
123 | - wp_enqueue_style( 'wp-color-picker' ); |
|
124 | - wp_enqueue_style( 'thickbox' ); // @TODO remove once we have modal API. |
|
123 | + wp_enqueue_style('wp-color-picker'); |
|
124 | + wp_enqueue_style('thickbox'); // @TODO remove once we have modal API. |
|
125 | 125 | |
126 | 126 | } |
127 | 127 | |
@@ -132,21 +132,21 @@ discard block |
||
132 | 132 | * |
133 | 133 | * @param string $hook Page hook. |
134 | 134 | */ |
135 | - public function admin_enqueue_scripts( $hook ) { |
|
135 | + public function admin_enqueue_scripts($hook) { |
|
136 | 136 | |
137 | 137 | // Give Admin Only. |
138 | - if ( ! apply_filters( 'give_load_admin_scripts', give_is_admin_page(), $hook ) ) { |
|
138 | + if ( ! apply_filters('give_load_admin_scripts', give_is_admin_page(), $hook)) { |
|
139 | 139 | return; |
140 | 140 | } |
141 | 141 | |
142 | 142 | // WP Scripts. |
143 | - wp_enqueue_script( 'wp-color-picker' ); |
|
144 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
145 | - wp_enqueue_script( 'thickbox' ); |
|
143 | + wp_enqueue_script('wp-color-picker'); |
|
144 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
145 | + wp_enqueue_script('thickbox'); |
|
146 | 146 | wp_enqueue_media(); |
147 | 147 | |
148 | 148 | // Give admin scripts. |
149 | - wp_enqueue_script( 'give-admin-scripts' ); |
|
149 | + wp_enqueue_script('give-admin-scripts'); |
|
150 | 150 | |
151 | 151 | // Localize admin scripts |
152 | 152 | $this->admin_localize_scripts(); |
@@ -166,111 +166,111 @@ discard block |
||
166 | 166 | $decimal_separator = give_get_price_decimal_separator(); |
167 | 167 | |
168 | 168 | // Localize strings & variables for JS. |
169 | - wp_localize_script( 'give-admin-scripts', 'give_vars', array( |
|
170 | - 'post_id' => isset( $post->ID ) ? $post->ID : null, |
|
169 | + wp_localize_script('give-admin-scripts', 'give_vars', array( |
|
170 | + 'post_id' => isset($post->ID) ? $post->ID : null, |
|
171 | 171 | 'give_version' => GIVE_VERSION, |
172 | 172 | 'thousands_separator' => $thousand_separator, |
173 | 173 | 'decimal_separator' => $decimal_separator, |
174 | - 'quick_edit_warning' => __( 'Not available for variable priced forms.', 'give' ), |
|
175 | - 'delete_payment' => __( 'Are you sure you want to <strong>permanently</strong> delete this donation?', 'give' ), |
|
176 | - 'delete_payment_note' => __( 'Are you sure you want to delete this note?', 'give' ), |
|
177 | - 'revoke_api_key' => __( 'Are you sure you want to revoke this API key?', 'give' ), |
|
178 | - 'regenerate_api_key' => __( 'Are you sure you want to regenerate this API key?', 'give' ), |
|
179 | - 'resend_receipt' => __( 'Are you sure you want to resend the donation receipt?', 'give' ), |
|
180 | - 'disconnect_user' => __( 'Are you sure you want to disconnect the user from this donor?', 'give' ), |
|
181 | - 'one_option' => __( 'Choose a form', 'give' ), |
|
182 | - 'one_or_more_option' => __( 'Choose one or more forms', 'give' ), |
|
183 | - 'currency_sign' => give_currency_filter( '' ), |
|
184 | - 'currency_pos' => isset( $give_options['currency_position'] ) ? $give_options['currency_position'] : 'before', |
|
174 | + 'quick_edit_warning' => __('Not available for variable priced forms.', 'give'), |
|
175 | + 'delete_payment' => __('Are you sure you want to <strong>permanently</strong> delete this donation?', 'give'), |
|
176 | + 'delete_payment_note' => __('Are you sure you want to delete this note?', 'give'), |
|
177 | + 'revoke_api_key' => __('Are you sure you want to revoke this API key?', 'give'), |
|
178 | + 'regenerate_api_key' => __('Are you sure you want to regenerate this API key?', 'give'), |
|
179 | + 'resend_receipt' => __('Are you sure you want to resend the donation receipt?', 'give'), |
|
180 | + 'disconnect_user' => __('Are you sure you want to disconnect the user from this donor?', 'give'), |
|
181 | + 'one_option' => __('Choose a form', 'give'), |
|
182 | + 'one_or_more_option' => __('Choose one or more forms', 'give'), |
|
183 | + 'currency_sign' => give_currency_filter(''), |
|
184 | + 'currency_pos' => isset($give_options['currency_position']) ? $give_options['currency_position'] : 'before', |
|
185 | 185 | 'currency_decimals' => give_get_price_decimals(), |
186 | - 'ok' => __( 'Ok', 'give' ), |
|
187 | - 'cancel' => __( 'Cancel', 'give' ), |
|
188 | - 'close' => __( 'Close', 'give' ), |
|
189 | - 'confirm' => __( 'Confirm', 'give' ), |
|
190 | - 'confirm_action' => __( 'Confirm Action', 'give' ), |
|
191 | - 'confirm_deletion' => __( 'Confirm Deletion', 'give' ), |
|
192 | - 'confirm_delete_donation' => __( 'Confirm Delete Donation', 'give' ), |
|
193 | - 'confirm_resend' => __( 'Confirm re-send', 'give' ), |
|
194 | - 'confirm_bulk_action' => __( 'Confirm bulk action', 'give' ), |
|
195 | - 'restart_upgrade' => __( 'Do you want to restart the update process?', 'give' ), |
|
196 | - 'restart_update' => __( 'It is recommended that you backup your database before proceeding. Do you want to run the update now?', 'give' ), |
|
197 | - 'stop_upgrade' => __( 'Do you want to stop the update process now?', 'give' ), |
|
198 | - 'import_failed' => __( 'Import failed', 'give' ), |
|
199 | - 'flush_success' => __( 'Flush success', 'give' ), |
|
200 | - 'flush_error' => __( 'Flush error', 'give' ), |
|
201 | - 'batch_export_no_class' => __( 'You must choose a method.', 'give' ), |
|
202 | - 'batch_export_no_reqs' => __( 'Required fields not completed.', 'give' ), |
|
203 | - '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' ), |
|
204 | - 'delete_test_donor' => __( 'Are you sure you want to delete all the test donors? This process will also delete test donations as well.', 'give' ), |
|
205 | - 'delete_import_donor' => __( 'Are you sure you want to delete all the imported donors? This process will also delete imported donations as well.', 'give' ), |
|
206 | - 'price_format_guide' => sprintf( __( 'Please enter amount in monetary decimal ( %1$s ) format without thousand separator ( %2$s ) .', 'give' ), $decimal_separator, $thousand_separator ), |
|
186 | + 'ok' => __('Ok', 'give'), |
|
187 | + 'cancel' => __('Cancel', 'give'), |
|
188 | + 'close' => __('Close', 'give'), |
|
189 | + 'confirm' => __('Confirm', 'give'), |
|
190 | + 'confirm_action' => __('Confirm Action', 'give'), |
|
191 | + 'confirm_deletion' => __('Confirm Deletion', 'give'), |
|
192 | + 'confirm_delete_donation' => __('Confirm Delete Donation', 'give'), |
|
193 | + 'confirm_resend' => __('Confirm re-send', 'give'), |
|
194 | + 'confirm_bulk_action' => __('Confirm bulk action', 'give'), |
|
195 | + 'restart_upgrade' => __('Do you want to restart the update process?', 'give'), |
|
196 | + 'restart_update' => __('It is recommended that you backup your database before proceeding. Do you want to run the update now?', 'give'), |
|
197 | + 'stop_upgrade' => __('Do you want to stop the update process now?', 'give'), |
|
198 | + 'import_failed' => __('Import failed', 'give'), |
|
199 | + 'flush_success' => __('Flush success', 'give'), |
|
200 | + 'flush_error' => __('Flush error', 'give'), |
|
201 | + 'batch_export_no_class' => __('You must choose a method.', 'give'), |
|
202 | + 'batch_export_no_reqs' => __('Required fields not completed.', 'give'), |
|
203 | + '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'), |
|
204 | + 'delete_test_donor' => __('Are you sure you want to delete all the test donors? This process will also delete test donations as well.', 'give'), |
|
205 | + 'delete_import_donor' => __('Are you sure you want to delete all the imported donors? This process will also delete imported donations as well.', 'give'), |
|
206 | + 'price_format_guide' => sprintf(__('Please enter amount in monetary decimal ( %1$s ) format without thousand separator ( %2$s ) .', 'give'), $decimal_separator, $thousand_separator), |
|
207 | 207 | /* translators : %s: Donation form options metabox */ |
208 | - 'confirm_before_remove_row_text' => __( 'Do you want to delete this item?', 'give' ), |
|
209 | - 'matched_success_failure_page' => __( 'You cannot set the success and failed pages to the same page', 'give' ), |
|
210 | - 'dismiss_notice_text' => __( 'Dismiss this notice.', 'give' ), |
|
211 | - 'search_placeholder' => __( 'Type to search all forms', 'give' ), |
|
212 | - 'search_placeholder_donor' => __( 'Type to search all donors', 'give' ), |
|
213 | - 'search_placeholder_country' => __( 'Type to search all countries', 'give' ), |
|
214 | - 'search_placeholder_state' => __( 'Type to search all states/provinces', 'give' ), |
|
215 | - 'unlock_donor_fields_title' => __( 'Action forbidden', 'give' ), |
|
216 | - 'unlock_donor_fields_message' => __( 'To edit first name and last name, please go to user profile of the donor.', 'give' ), |
|
217 | - 'remove_from_bulk_delete' => __( 'Remove from Bulk Delete', 'give' ), |
|
208 | + 'confirm_before_remove_row_text' => __('Do you want to delete this item?', 'give'), |
|
209 | + 'matched_success_failure_page' => __('You cannot set the success and failed pages to the same page', 'give'), |
|
210 | + 'dismiss_notice_text' => __('Dismiss this notice.', 'give'), |
|
211 | + 'search_placeholder' => __('Type to search all forms', 'give'), |
|
212 | + 'search_placeholder_donor' => __('Type to search all donors', 'give'), |
|
213 | + 'search_placeholder_country' => __('Type to search all countries', 'give'), |
|
214 | + 'search_placeholder_state' => __('Type to search all states/provinces', 'give'), |
|
215 | + 'unlock_donor_fields_title' => __('Action forbidden', 'give'), |
|
216 | + 'unlock_donor_fields_message' => __('To edit first name and last name, please go to user profile of the donor.', 'give'), |
|
217 | + 'remove_from_bulk_delete' => __('Remove from Bulk Delete', 'give'), |
|
218 | 218 | 'donors_bulk_action' => array( |
219 | 219 | 'no_donor_selected' => array( |
220 | - 'title' => __( 'No donors selected', 'give' ), |
|
221 | - 'desc' => __( 'You must choose at least one or more donors to delete.', 'give' ) |
|
220 | + 'title' => __('No donors selected', 'give'), |
|
221 | + 'desc' => __('You must choose at least one or more donors to delete.', 'give') |
|
222 | 222 | ), |
223 | 223 | 'no_action_selected' => array( |
224 | - 'title' => __( 'No action selected', 'give' ), |
|
225 | - 'desc' => __( 'You must select a bulk action to proceed.', 'give' ), |
|
224 | + 'title' => __('No action selected', 'give'), |
|
225 | + 'desc' => __('You must select a bulk action to proceed.', 'give'), |
|
226 | 226 | ), |
227 | 227 | ), |
228 | 228 | 'donations_bulk_action' => array( |
229 | 229 | 'titles' => array( |
230 | - 'zero' => __( 'No payments selected', 'give' ), |
|
230 | + 'zero' => __('No payments selected', 'give'), |
|
231 | 231 | ), |
232 | 232 | 'delete' => array( |
233 | - 'zero' => __( 'You must choose at least one or more donations to delete.', 'give' ), |
|
234 | - 'single' => __( 'Are you sure you want to permanently delete this donation?', 'give' ), |
|
235 | - 'multiple' => __( 'Are you sure you want to permanently delete the selected {payment_count} donations?', 'give' ), |
|
233 | + 'zero' => __('You must choose at least one or more donations to delete.', 'give'), |
|
234 | + 'single' => __('Are you sure you want to permanently delete this donation?', 'give'), |
|
235 | + 'multiple' => __('Are you sure you want to permanently delete the selected {payment_count} donations?', 'give'), |
|
236 | 236 | ), |
237 | 237 | 'resend-receipt' => array( |
238 | - 'zero' => __( 'You must choose at least one or more recipients to resend the email receipt.', 'give' ), |
|
239 | - 'single' => __( 'Are you sure you want to resend the email receipt to this recipient?', 'give' ), |
|
240 | - 'multiple' => __( 'Are you sure you want to resend the emails receipt to {payment_count} recipients?', 'give' ), |
|
238 | + 'zero' => __('You must choose at least one or more recipients to resend the email receipt.', 'give'), |
|
239 | + 'single' => __('Are you sure you want to resend the email receipt to this recipient?', 'give'), |
|
240 | + 'multiple' => __('Are you sure you want to resend the emails receipt to {payment_count} recipients?', 'give'), |
|
241 | 241 | ), |
242 | 242 | 'set-to-status' => array( |
243 | - 'zero' => __( 'You must choose at least one or more donations to set status to {status}.', 'give' ), |
|
244 | - 'single' => __( 'Are you sure you want to set status of this donation to {status}?', 'give' ), |
|
245 | - 'multiple' => __( 'Are you sure you want to set status of {payment_count} donations to {status}?', 'give' ), |
|
243 | + 'zero' => __('You must choose at least one or more donations to set status to {status}.', 'give'), |
|
244 | + 'single' => __('Are you sure you want to set status of this donation to {status}?', 'give'), |
|
245 | + 'multiple' => __('Are you sure you want to set status of {payment_count} donations to {status}?', 'give'), |
|
246 | 246 | ), |
247 | 247 | ), |
248 | 248 | 'updates' => array( |
249 | - 'ajax_error' => __( 'Please reload this page and try again', 'give' ), |
|
249 | + 'ajax_error' => __('Please reload this page and try again', 'give'), |
|
250 | 250 | ), |
251 | 251 | 'metabox_fields' => array( |
252 | 252 | 'media' => array( |
253 | - 'button_title' => __( 'Choose Image', 'give' ), |
|
253 | + 'button_title' => __('Choose Image', 'give'), |
|
254 | 254 | ), |
255 | 255 | 'file' => array( |
256 | - 'button_title' => __( 'Choose File', 'give' ), |
|
256 | + 'button_title' => __('Choose File', 'give'), |
|
257 | 257 | ), |
258 | 258 | ), |
259 | 259 | 'chosen' => array( |
260 | - 'no_results_msg' => __( 'No results match {search_term}', 'give' ), |
|
261 | - 'ajax_search_msg' => __( 'Searching results for match {search_term}', 'give' ), |
|
260 | + 'no_results_msg' => __('No results match {search_term}', 'give'), |
|
261 | + 'ajax_search_msg' => __('Searching results for match {search_term}', 'give'), |
|
262 | 262 | ), |
263 | - 'db_update_confirmation_msg_button' => __( 'Run Updates', 'give' ), |
|
264 | - 'db_update_confirmation_msg' => __( 'The following process will make updates to your site\'s database. Please create a database backup before proceeding with updates.', 'give' ), |
|
265 | - 'error_message' => __( 'Something went wrong kindly try again!', 'give' ), |
|
263 | + 'db_update_confirmation_msg_button' => __('Run Updates', 'give'), |
|
264 | + 'db_update_confirmation_msg' => __('The following process will make updates to your site\'s database. Please create a database backup before proceeding with updates.', 'give'), |
|
265 | + 'error_message' => __('Something went wrong kindly try again!', 'give'), |
|
266 | 266 | 'give_donation_import' => 'give_donation_import', |
267 | 267 | 'core_settings_import' => 'give_core_settings_import', |
268 | - 'setting_not_save_message' => __( 'Changes you made may not be saved.', 'give' ), |
|
268 | + 'setting_not_save_message' => __('Changes you made may not be saved.', 'give'), |
|
269 | 269 | 'give_donation_amounts' => array( |
270 | - 'minimum' => apply_filters( 'give_donation_minimum_limit', 1 ), |
|
271 | - 'maximum' => apply_filters( 'give_donation_maximum_limit', 999999.99 ), |
|
270 | + 'minimum' => apply_filters('give_donation_minimum_limit', 1), |
|
271 | + 'maximum' => apply_filters('give_donation_maximum_limit', 999999.99), |
|
272 | 272 | ), |
273 | - ) ); |
|
273 | + )); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | /** |
@@ -281,10 +281,10 @@ discard block |
||
281 | 281 | <style type="text/css" media="screen"> |
282 | 282 | @font-face { |
283 | 283 | font-family: 'give-icomoon'; |
284 | - src: url('<?php echo GIVE_PLUGIN_URL . 'assets/dist/fonts/icomoon.eot?ngjl88'; ?>'); |
|
285 | - src: url('<?php echo GIVE_PLUGIN_URL . 'assets/dist/fonts/icomoon.eot?#iefixngjl88'?>') format('embedded-opentype'), |
|
286 | - url('<?php echo GIVE_PLUGIN_URL . 'assets/dist/fonts/icomoon.woff?ngjl88'; ?>') format('woff'), |
|
287 | - url('<?php echo GIVE_PLUGIN_URL . 'assets/dist/fonts/icomoon.svg?ngjl88#icomoon'; ?>') format('svg'); |
|
284 | + src: url('<?php echo GIVE_PLUGIN_URL.'assets/dist/fonts/icomoon.eot?ngjl88'; ?>'); |
|
285 | + src: url('<?php echo GIVE_PLUGIN_URL.'assets/dist/fonts/icomoon.eot?#iefixngjl88'?>') format('embedded-opentype'), |
|
286 | + url('<?php echo GIVE_PLUGIN_URL.'assets/dist/fonts/icomoon.woff?ngjl88'; ?>') format('woff'), |
|
287 | + url('<?php echo GIVE_PLUGIN_URL.'assets/dist/fonts/icomoon.svg?ngjl88#icomoon'; ?>') format('svg'); |
|
288 | 288 | font-weight: normal; |
289 | 289 | font-style: normal; |
290 | 290 | } |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | * @since 2.1.0 |
308 | 308 | */ |
309 | 309 | public function public_enqueue_styles() { |
310 | - wp_enqueue_style( 'give-styles' ); |
|
310 | + wp_enqueue_style('give-styles'); |
|
311 | 311 | } |
312 | 312 | |
313 | 313 | |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | * @since 2.1.0 |
318 | 318 | */ |
319 | 319 | public function public_enqueue_scripts() { |
320 | - wp_enqueue_script( 'give' ); |
|
320 | + wp_enqueue_script('give'); |
|
321 | 321 | |
322 | 322 | $this->public_localize_scripts(); |
323 | 323 | } |
@@ -336,22 +336,22 @@ discard block |
||
336 | 336 | * |
337 | 337 | * @return string $message Send notice message for email access. |
338 | 338 | */ |
339 | - $message = (string) apply_filters( 'give_email_access_mail_send_notice', __( 'Please check your email and click on the link to access your complete donation history.', 'give' ) ); |
|
339 | + $message = (string) apply_filters('give_email_access_mail_send_notice', __('Please check your email and click on the link to access your complete donation history.', 'give')); |
|
340 | 340 | |
341 | - $localize_give_vars = apply_filters( 'give_global_script_vars', array( |
|
341 | + $localize_give_vars = apply_filters('give_global_script_vars', array( |
|
342 | 342 | 'ajaxurl' => give_get_ajax_url(), |
343 | - 'checkout_nonce' => wp_create_nonce( 'give_checkout_nonce' ), |
|
343 | + 'checkout_nonce' => wp_create_nonce('give_checkout_nonce'), |
|
344 | 344 | // Do not use this nonce. Its deprecated. |
345 | 345 | 'currency' => give_get_currency(), |
346 | - 'currency_sign' => give_currency_filter( '' ), |
|
346 | + 'currency_sign' => give_currency_filter(''), |
|
347 | 347 | 'currency_pos' => give_get_currency_position(), |
348 | 348 | 'thousands_separator' => give_get_price_thousand_separator(), |
349 | 349 | 'decimal_separator' => give_get_price_decimal_separator(), |
350 | - 'no_gateway' => __( 'Please select a payment method.', 'give' ), |
|
351 | - 'bad_minimum' => __( 'The minimum custom donation amount for this form is', 'give' ), |
|
352 | - 'bad_maximum' => __( 'The maximum custom donation amount for this form is', 'give' ), |
|
353 | - 'general_loading' => __( 'Loading...', 'give' ), |
|
354 | - 'purchase_loading' => __( 'Please Wait...', 'give' ), |
|
350 | + 'no_gateway' => __('Please select a payment method.', 'give'), |
|
351 | + 'bad_minimum' => __('The minimum custom donation amount for this form is', 'give'), |
|
352 | + 'bad_maximum' => __('The maximum custom donation amount for this form is', 'give'), |
|
353 | + 'general_loading' => __('Loading...', 'give'), |
|
354 | + 'purchase_loading' => __('Please Wait...', 'give'), |
|
355 | 355 | 'number_decimals' => give_get_price_decimals(), |
356 | 356 | 'give_version' => GIVE_VERSION, |
357 | 357 | 'magnific_options' => apply_filters( |
@@ -365,30 +365,30 @@ discard block |
||
365 | 365 | 'give_form_translation_js', |
366 | 366 | array( |
367 | 367 | // Field name Validation message. |
368 | - 'payment-mode' => __( 'Please select payment mode.', 'give' ), |
|
369 | - 'give_first' => __( 'Please enter your first name.', 'give' ), |
|
370 | - 'give_email' => __( 'Please enter a valid email address.', 'give' ), |
|
371 | - 'give_user_login' => __( 'Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give' ), |
|
372 | - 'give_user_pass' => __( 'Enter a password.', 'give' ), |
|
373 | - 'give_user_pass_confirm' => __( 'Enter the password confirmation.', 'give' ), |
|
374 | - 'give_agree_to_terms' => __( 'You must agree to the terms and conditions.', 'give' ), |
|
368 | + 'payment-mode' => __('Please select payment mode.', 'give'), |
|
369 | + 'give_first' => __('Please enter your first name.', 'give'), |
|
370 | + 'give_email' => __('Please enter a valid email address.', 'give'), |
|
371 | + 'give_user_login' => __('Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give'), |
|
372 | + 'give_user_pass' => __('Enter a password.', 'give'), |
|
373 | + 'give_user_pass_confirm' => __('Enter the password confirmation.', 'give'), |
|
374 | + 'give_agree_to_terms' => __('You must agree to the terms and conditions.', 'give'), |
|
375 | 375 | ) |
376 | 376 | ), |
377 | 377 | 'confirm_email_sent_message' => $message, |
378 | - 'ajax_vars' => apply_filters( 'give_global_ajax_vars', array( |
|
378 | + 'ajax_vars' => apply_filters('give_global_ajax_vars', array( |
|
379 | 379 | 'ajaxurl' => give_get_ajax_url(), |
380 | - 'ajaxNonce' => wp_create_nonce( 'give_ajax_nonce' ), |
|
381 | - 'loading' => __( 'Loading', 'give' ), |
|
380 | + 'ajaxNonce' => wp_create_nonce('give_ajax_nonce'), |
|
381 | + 'loading' => __('Loading', 'give'), |
|
382 | 382 | // General loading message. |
383 | - 'select_option' => __( 'Please select an option', 'give' ), |
|
383 | + 'select_option' => __('Please select an option', 'give'), |
|
384 | 384 | // Variable pricing error with multi-donation option enabled. |
385 | - 'default_gateway' => give_get_default_gateway( null ), |
|
386 | - 'permalinks' => get_option( 'permalink_structure' ) ? '1' : '0', |
|
385 | + 'default_gateway' => give_get_default_gateway(null), |
|
386 | + 'permalinks' => get_option('permalink_structure') ? '1' : '0', |
|
387 | 387 | 'number_decimals' => give_get_price_decimals(), |
388 | - ) ), |
|
389 | - ) ); |
|
388 | + )), |
|
389 | + )); |
|
390 | 390 | |
391 | - wp_localize_script( 'give', 'give_global_vars', $localize_give_vars ); |
|
391 | + wp_localize_script('give', 'give_global_vars', $localize_give_vars); |
|
392 | 392 | |
393 | 393 | } |
394 | 394 | |
@@ -402,15 +402,15 @@ discard block |
||
402 | 402 | */ |
403 | 403 | public function get_frontend_stylesheet_uri() { |
404 | 404 | |
405 | - $file = 'give' . $this->direction . '.css'; |
|
405 | + $file = 'give'.$this->direction.'.css'; |
|
406 | 406 | $templates_dir = give_get_theme_template_dir_name(); |
407 | 407 | |
408 | 408 | // Directory paths to CSS files to support checking via file_exists(). |
409 | - $child_theme_style_sheet = trailingslashit( get_stylesheet_directory() ) . $templates_dir . $file; |
|
410 | - $child_theme_style_sheet_2 = trailingslashit( get_stylesheet_directory() ) . $templates_dir . 'give' . $this->direction . '.css'; |
|
411 | - $parent_theme_style_sheet = trailingslashit( get_template_directory() ) . $templates_dir . $file; |
|
412 | - $parent_theme_style_sheet_2 = trailingslashit( get_template_directory() ) . $templates_dir . 'give' . $this->direction . '.css'; |
|
413 | - $give_plugin_style_sheet = trailingslashit( GIVE_PLUGIN_DIR ) . 'assets/dist/css/' . $file; |
|
409 | + $child_theme_style_sheet = trailingslashit(get_stylesheet_directory()).$templates_dir.$file; |
|
410 | + $child_theme_style_sheet_2 = trailingslashit(get_stylesheet_directory()).$templates_dir.'give'.$this->direction.'.css'; |
|
411 | + $parent_theme_style_sheet = trailingslashit(get_template_directory()).$templates_dir.$file; |
|
412 | + $parent_theme_style_sheet_2 = trailingslashit(get_template_directory()).$templates_dir.'give'.$this->direction.'.css'; |
|
413 | + $give_plugin_style_sheet = trailingslashit(GIVE_PLUGIN_DIR).'assets/dist/css/'.$file; |
|
414 | 414 | $uri = false; |
415 | 415 | |
416 | 416 | /** |
@@ -421,23 +421,23 @@ discard block |
||
421 | 421 | * c. followed by non minified version, even if SCRIPT_DEBUG is not enabled. This allows users to copy just give.css to their theme. |
422 | 422 | * d. Finally, fallback to the standard Give version. This is the default styles included within the plugin. |
423 | 423 | */ |
424 | - if ( file_exists( $child_theme_style_sheet ) || ( ! empty( $suffix ) && ( $nonmin = file_exists( $child_theme_style_sheet_2 ) ) ) ) { |
|
425 | - if ( ! empty( $nonmin ) ) { |
|
426 | - $uri = trailingslashit( get_stylesheet_directory_uri() ) . $templates_dir . 'give' . $this->direction . '.css'; |
|
424 | + if (file_exists($child_theme_style_sheet) || ( ! empty($suffix) && ($nonmin = file_exists($child_theme_style_sheet_2)))) { |
|
425 | + if ( ! empty($nonmin)) { |
|
426 | + $uri = trailingslashit(get_stylesheet_directory_uri()).$templates_dir.'give'.$this->direction.'.css'; |
|
427 | 427 | } else { |
428 | - $uri = trailingslashit( get_stylesheet_directory_uri() ) . $templates_dir . $file; |
|
428 | + $uri = trailingslashit(get_stylesheet_directory_uri()).$templates_dir.$file; |
|
429 | 429 | } |
430 | - } elseif ( file_exists( $parent_theme_style_sheet ) || ( ! empty( $suffix ) && ( $nonmin = file_exists( $parent_theme_style_sheet_2 ) ) ) ) { |
|
431 | - if ( ! empty( $nonmin ) ) { |
|
432 | - $uri = trailingslashit( get_template_directory_uri() ) . $templates_dir . 'give' . $this->direction . '.css'; |
|
430 | + } elseif (file_exists($parent_theme_style_sheet) || ( ! empty($suffix) && ($nonmin = file_exists($parent_theme_style_sheet_2)))) { |
|
431 | + if ( ! empty($nonmin)) { |
|
432 | + $uri = trailingslashit(get_template_directory_uri()).$templates_dir.'give'.$this->direction.'.css'; |
|
433 | 433 | } else { |
434 | - $uri = trailingslashit( get_template_directory_uri() ) . $templates_dir . $file; |
|
434 | + $uri = trailingslashit(get_template_directory_uri()).$templates_dir.$file; |
|
435 | 435 | } |
436 | - } elseif ( file_exists( $give_plugin_style_sheet ) ) { |
|
437 | - $uri = trailingslashit( GIVE_PLUGIN_URL ) . 'assets/dist/css/' . $file; |
|
436 | + } elseif (file_exists($give_plugin_style_sheet)) { |
|
437 | + $uri = trailingslashit(GIVE_PLUGIN_URL).'assets/dist/css/'.$file; |
|
438 | 438 | } |
439 | 439 | |
440 | - return apply_filters( 'give_get_stylesheet_uri', $uri ); |
|
440 | + return apply_filters('give_get_stylesheet_uri', $uri); |
|
441 | 441 | |
442 | 442 | } |
443 | 443 | |
@@ -449,19 +449,19 @@ discard block |
||
449 | 449 | // Enqueue the bundled block JS file |
450 | 450 | wp_enqueue_script( |
451 | 451 | 'give-blocks-js', |
452 | - GIVE_PLUGIN_URL . 'assets/dist/js/gutenberg.js', |
|
453 | - array( 'wp-i18n', 'wp-element', 'wp-blocks', 'wp-components', 'wp-api' ), |
|
452 | + GIVE_PLUGIN_URL.'assets/dist/js/gutenberg.js', |
|
453 | + array('wp-i18n', 'wp-element', 'wp-blocks', 'wp-components', 'wp-api'), |
|
454 | 454 | GIVE_VERSION |
455 | 455 | ); |
456 | 456 | |
457 | 457 | // Enqueue public styles |
458 | - wp_enqueue_style( 'give-styles' ); |
|
458 | + wp_enqueue_style('give-styles'); |
|
459 | 459 | |
460 | 460 | // Enqueue the bundled block css file |
461 | 461 | wp_enqueue_style( |
462 | 462 | 'give-blocks-css', |
463 | - GIVE_PLUGIN_URL . 'assets/dist/css/gutenberg.css', |
|
464 | - array( 'wp-blocks' ), |
|
463 | + GIVE_PLUGIN_URL.'assets/dist/css/gutenberg.css', |
|
464 | + array('wp-blocks'), |
|
465 | 465 | GIVE_VERSION |
466 | 466 | ); |
467 | 467 |
@@ -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 | |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | /* @var WPDB $wpdb */ |
54 | 54 | global $wpdb; |
55 | 55 | |
56 | - $wpdb->donormeta = $this->table_name = $wpdb->prefix . 'give_donormeta'; |
|
56 | + $wpdb->donormeta = $this->table_name = $wpdb->prefix.'give_donormeta'; |
|
57 | 57 | $this->primary_key = 'meta_id'; |
58 | 58 | $this->version = '1.0'; |
59 | 59 | |
@@ -92,8 +92,8 @@ discard block |
||
92 | 92 | global $wpdb; |
93 | 93 | |
94 | 94 | if ( |
95 | - ! give_has_upgrade_completed( 'v20_rename_donor_tables' ) && |
|
96 | - $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s","{$wpdb->prefix}give_customermeta" ) ) |
|
95 | + ! give_has_upgrade_completed('v20_rename_donor_tables') && |
|
96 | + $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_customermeta")) |
|
97 | 97 | ) { |
98 | 98 | $wpdb->donormeta = $this->table_name = "{$wpdb->prefix}give_customermeta"; |
99 | 99 | $this->meta_type = 'customer'; |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | * |
113 | 113 | * @return bool |
114 | 114 | */ |
115 | - protected function is_valid_post_type( $ID ) { |
|
115 | + protected function is_valid_post_type($ID) { |
|
116 | 116 | return $ID && true; |
117 | 117 | } |
118 | 118 |