@@ -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 | |
@@ -72,8 +72,8 @@ discard block |
||
72 | 72 | * @access public |
73 | 73 | */ |
74 | 74 | public function __construct() { |
75 | - if( is_multisite() ) { |
|
76 | - add_action( 'switch_blog', array( $this, 'handle_switch_blog' ), 10, 2 ); |
|
75 | + if (is_multisite()) { |
|
76 | + add_action('switch_blog', array($this, 'handle_switch_blog'), 10, 2); |
|
77 | 77 | } |
78 | 78 | } |
79 | 79 | |
@@ -111,16 +111,16 @@ discard block |
||
111 | 111 | * |
112 | 112 | * @return object |
113 | 113 | */ |
114 | - public function get( $row_id ) { |
|
114 | + public function get($row_id) { |
|
115 | 115 | /* @var WPDB $wpdb */ |
116 | 116 | global $wpdb; |
117 | 117 | |
118 | 118 | // Bailout. |
119 | - if ( empty( $row_id ) ) { |
|
119 | + if (empty($row_id)) { |
|
120 | 120 | return null; |
121 | 121 | } |
122 | 122 | |
123 | - return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) ); |
|
123 | + return $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id)); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | /** |
@@ -134,18 +134,18 @@ discard block |
||
134 | 134 | * |
135 | 135 | * @return object |
136 | 136 | */ |
137 | - public function get_by( $column, $row_id ) { |
|
137 | + public function get_by($column, $row_id) { |
|
138 | 138 | /* @var WPDB $wpdb */ |
139 | 139 | global $wpdb; |
140 | 140 | |
141 | 141 | // Bailout. |
142 | - if ( empty( $column ) || empty( $row_id ) ) { |
|
142 | + if (empty($column) || empty($row_id)) { |
|
143 | 143 | return null; |
144 | 144 | } |
145 | 145 | |
146 | - $column = esc_sql( $column ); |
|
146 | + $column = esc_sql($column); |
|
147 | 147 | |
148 | - return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id ) ); |
|
148 | + return $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id)); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | /** |
@@ -159,12 +159,12 @@ discard block |
||
159 | 159 | * |
160 | 160 | * @return array |
161 | 161 | */ |
162 | - public function get_results_by( $column_args ) { |
|
162 | + public function get_results_by($column_args) { |
|
163 | 163 | /* @var WPDB $wpdb */ |
164 | 164 | global $wpdb; |
165 | 165 | |
166 | 166 | // Bailout. |
167 | - if ( empty( $column_args ) ) { |
|
167 | + if (empty($column_args)) { |
|
168 | 168 | return null; |
169 | 169 | } |
170 | 170 | |
@@ -179,12 +179,12 @@ discard block |
||
179 | 179 | unset($column_args['relation']); |
180 | 180 | |
181 | 181 | $where = array(); |
182 | - foreach ( $column_args as $column_name => $column_value ) { |
|
183 | - $where[] = esc_sql( $column_name ) . "='$column_value'"; |
|
182 | + foreach ($column_args as $column_name => $column_value) { |
|
183 | + $where[] = esc_sql($column_name)."='$column_value'"; |
|
184 | 184 | } |
185 | - $where = implode( " {$relation} ", $where ); |
|
185 | + $where = implode(" {$relation} ", $where); |
|
186 | 186 | |
187 | - return $wpdb->get_results( "SELECT * FROM {$this->table_name} WHERE {$where};" ); |
|
187 | + return $wpdb->get_results("SELECT * FROM {$this->table_name} WHERE {$where};"); |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | /** |
@@ -198,18 +198,18 @@ discard block |
||
198 | 198 | * |
199 | 199 | * @return string Column value. |
200 | 200 | */ |
201 | - public function get_column( $column, $row_id ) { |
|
201 | + public function get_column($column, $row_id) { |
|
202 | 202 | /* @var WPDB $wpdb */ |
203 | 203 | global $wpdb; |
204 | 204 | |
205 | 205 | // Bailout. |
206 | - if ( empty( $column ) || empty( $row_id ) ) { |
|
206 | + if (empty($column) || empty($row_id)) { |
|
207 | 207 | return null; |
208 | 208 | } |
209 | 209 | |
210 | - $column = esc_sql( $column ); |
|
210 | + $column = esc_sql($column); |
|
211 | 211 | |
212 | - return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) ); |
|
212 | + return $wpdb->get_var($wpdb->prepare("SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id)); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | /** |
@@ -224,19 +224,19 @@ discard block |
||
224 | 224 | * |
225 | 225 | * @return string |
226 | 226 | */ |
227 | - public function get_column_by( $column, $column_where, $column_value ) { |
|
227 | + public function get_column_by($column, $column_where, $column_value) { |
|
228 | 228 | /* @var WPDB $wpdb */ |
229 | 229 | global $wpdb; |
230 | 230 | |
231 | 231 | // Bailout. |
232 | - if ( empty( $column ) || empty( $column_where ) || empty( $column_value ) ) { |
|
232 | + if (empty($column) || empty($column_where) || empty($column_value)) { |
|
233 | 233 | return null; |
234 | 234 | } |
235 | 235 | |
236 | - $column_where = esc_sql( $column_where ); |
|
237 | - $column = esc_sql( $column ); |
|
236 | + $column_where = esc_sql($column_where); |
|
237 | + $column = esc_sql($column); |
|
238 | 238 | |
239 | - return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value ) ); |
|
239 | + return $wpdb->get_var($wpdb->prepare("SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value)); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | /** |
@@ -250,12 +250,12 @@ discard block |
||
250 | 250 | * |
251 | 251 | * @return int |
252 | 252 | */ |
253 | - public function insert( $data, $type = '' ) { |
|
253 | + public function insert($data, $type = '') { |
|
254 | 254 | /* @var WPDB $wpdb */ |
255 | 255 | global $wpdb; |
256 | 256 | |
257 | 257 | // Set default values. |
258 | - $data = wp_parse_args( $data, $this->get_column_defaults() ); |
|
258 | + $data = wp_parse_args($data, $this->get_column_defaults()); |
|
259 | 259 | |
260 | 260 | /** |
261 | 261 | * Fires before inserting data to the database. |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | * |
265 | 265 | * @param array $data |
266 | 266 | */ |
267 | - do_action( "give_pre_insert_{$type}", $data ); |
|
267 | + do_action("give_pre_insert_{$type}", $data); |
|
268 | 268 | |
269 | 269 | // Initialise column format array |
270 | 270 | $column_formats = $this->get_columns(); |
@@ -273,13 +273,13 @@ discard block |
||
273 | 273 | // $data = array_change_key_case( $data ); |
274 | 274 | |
275 | 275 | // White list columns |
276 | - $data = array_intersect_key( $data, $column_formats ); |
|
276 | + $data = array_intersect_key($data, $column_formats); |
|
277 | 277 | |
278 | 278 | // Reorder $column_formats to match the order of columns given in $data |
279 | - $data_keys = array_keys( $data ); |
|
280 | - $column_formats = array_merge( array_flip( $data_keys ), $column_formats ); |
|
279 | + $data_keys = array_keys($data); |
|
280 | + $column_formats = array_merge(array_flip($data_keys), $column_formats); |
|
281 | 281 | |
282 | - $wpdb->insert( $this->table_name, $data, $column_formats ); |
|
282 | + $wpdb->insert($this->table_name, $data, $column_formats); |
|
283 | 283 | |
284 | 284 | /** |
285 | 285 | * Fires after inserting data to the database. |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | * @param int $insert_id |
290 | 290 | * @param array $data |
291 | 291 | */ |
292 | - do_action( "give_post_insert_{$type}", $wpdb->insert_id, $data ); |
|
292 | + do_action("give_post_insert_{$type}", $wpdb->insert_id, $data); |
|
293 | 293 | |
294 | 294 | return $wpdb->insert_id; |
295 | 295 | } |
@@ -306,18 +306,18 @@ discard block |
||
306 | 306 | * |
307 | 307 | * @return bool |
308 | 308 | */ |
309 | - public function update( $row_id, $data = array(), $where = '' ) { |
|
309 | + public function update($row_id, $data = array(), $where = '') { |
|
310 | 310 | /* @var WPDB $wpdb */ |
311 | 311 | global $wpdb; |
312 | 312 | |
313 | 313 | // Row ID must be positive integer |
314 | - $row_id = absint( $row_id ); |
|
314 | + $row_id = absint($row_id); |
|
315 | 315 | |
316 | - if ( empty( $row_id ) ) { |
|
316 | + if (empty($row_id)) { |
|
317 | 317 | return false; |
318 | 318 | } |
319 | 319 | |
320 | - if ( empty( $where ) ) { |
|
320 | + if (empty($where)) { |
|
321 | 321 | $where = $this->primary_key; |
322 | 322 | } |
323 | 323 | |
@@ -325,16 +325,16 @@ discard block |
||
325 | 325 | $column_formats = $this->get_columns(); |
326 | 326 | |
327 | 327 | // Force fields to lower case |
328 | - $data = array_change_key_case( $data ); |
|
328 | + $data = array_change_key_case($data); |
|
329 | 329 | |
330 | 330 | // White list columns |
331 | - $data = array_intersect_key( $data, $column_formats ); |
|
331 | + $data = array_intersect_key($data, $column_formats); |
|
332 | 332 | |
333 | 333 | // Reorder $column_formats to match the order of columns given in $data |
334 | - $data_keys = array_keys( $data ); |
|
335 | - $column_formats = array_merge( array_flip( $data_keys ), $column_formats ); |
|
334 | + $data_keys = array_keys($data); |
|
335 | + $column_formats = array_merge(array_flip($data_keys), $column_formats); |
|
336 | 336 | |
337 | - if ( false === $wpdb->update( $this->table_name, $data, array( $where => $row_id ), $column_formats ) ) { |
|
337 | + if (false === $wpdb->update($this->table_name, $data, array($where => $row_id), $column_formats)) { |
|
338 | 338 | return false; |
339 | 339 | } |
340 | 340 | |
@@ -351,18 +351,18 @@ discard block |
||
351 | 351 | * |
352 | 352 | * @return bool |
353 | 353 | */ |
354 | - public function delete( $row_id = 0 ) { |
|
354 | + public function delete($row_id = 0) { |
|
355 | 355 | /* @var WPDB $wpdb */ |
356 | 356 | global $wpdb; |
357 | 357 | |
358 | 358 | // Row ID must be positive integer |
359 | - $row_id = absint( $row_id ); |
|
359 | + $row_id = absint($row_id); |
|
360 | 360 | |
361 | - if ( empty( $row_id ) ) { |
|
361 | + if (empty($row_id)) { |
|
362 | 362 | return false; |
363 | 363 | } |
364 | 364 | |
365 | - if ( false === $wpdb->query( $wpdb->prepare( "DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id ) ) ) { |
|
365 | + if (false === $wpdb->query($wpdb->prepare("DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id))) { |
|
366 | 366 | return false; |
367 | 367 | } |
368 | 368 | |
@@ -379,13 +379,13 @@ discard block |
||
379 | 379 | * |
380 | 380 | * @return bool If the table name exists. |
381 | 381 | */ |
382 | - public function table_exists( $table ) { |
|
382 | + public function table_exists($table) { |
|
383 | 383 | /* @var WPDB $wpdb */ |
384 | 384 | global $wpdb; |
385 | 385 | |
386 | - $table = sanitize_text_field( $table ); |
|
386 | + $table = sanitize_text_field($table); |
|
387 | 387 | |
388 | - return $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE '%s'", $table ) ) === $table; |
|
388 | + return $wpdb->get_var($wpdb->prepare("SHOW TABLES LIKE '%s'", $table)) === $table; |
|
389 | 389 | } |
390 | 390 | |
391 | 391 | /** |
@@ -399,16 +399,16 @@ discard block |
||
399 | 399 | * |
400 | 400 | * @return bool |
401 | 401 | */ |
402 | - public function does_column_exist( $column_name ) { |
|
402 | + public function does_column_exist($column_name) { |
|
403 | 403 | |
404 | 404 | global $wpdb; |
405 | 405 | |
406 | - $column = $wpdb->get_results( $wpdb->prepare( |
|
406 | + $column = $wpdb->get_results($wpdb->prepare( |
|
407 | 407 | "SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = %s AND TABLE_NAME = %s AND COLUMN_NAME = %s ", |
408 | 408 | DB_NAME, $this->table_name, $column_name |
409 | - ) ); |
|
409 | + )); |
|
410 | 410 | |
411 | - if ( ! empty( $column ) ) { |
|
411 | + if ( ! empty($column)) { |
|
412 | 412 | return true; |
413 | 413 | } |
414 | 414 | |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | * @return bool Returns if the customers table was installed and upgrade routine run. |
425 | 425 | */ |
426 | 426 | public function installed() { |
427 | - return $this->table_exists( $this->table_name ); |
|
427 | + return $this->table_exists($this->table_name); |
|
428 | 428 | } |
429 | 429 | |
430 | 430 | /** |
@@ -434,8 +434,8 @@ discard block |
||
434 | 434 | * @access public |
435 | 435 | */ |
436 | 436 | public function register_table() { |
437 | - $current_version = get_option( $this->table_name . '_db_version' ); |
|
438 | - if ( ! $current_version || version_compare( $current_version, $this->version, '<' ) ) { |
|
437 | + $current_version = get_option($this->table_name.'_db_version'); |
|
438 | + if ( ! $current_version || version_compare($current_version, $this->version, '<')) { |
|
439 | 439 | $this->create_table(); |
440 | 440 | } |
441 | 441 | } |
@@ -460,23 +460,23 @@ discard block |
||
460 | 460 | * |
461 | 461 | * @return int|bool The normalized log ID or false if it's found to not be valid. |
462 | 462 | */ |
463 | - public function sanitize_id( $id ) { |
|
464 | - if ( ! is_numeric( $id ) ) { |
|
463 | + public function sanitize_id($id) { |
|
464 | + if ( ! is_numeric($id)) { |
|
465 | 465 | return false; |
466 | 466 | } |
467 | 467 | |
468 | 468 | $id = (int) $id; |
469 | 469 | |
470 | 470 | // We were given a non positive number. |
471 | - if ( absint( $id ) !== $id ) { |
|
471 | + if (absint($id) !== $id) { |
|
472 | 472 | return false; |
473 | 473 | } |
474 | 474 | |
475 | - if ( empty( $id ) ) { |
|
475 | + if (empty($id)) { |
|
476 | 476 | return false; |
477 | 477 | } |
478 | 478 | |
479 | - return absint( $id ); |
|
479 | + return absint($id); |
|
480 | 480 | |
481 | 481 | } |
482 | 482 | |
@@ -490,23 +490,23 @@ discard block |
||
490 | 490 | * @param $new_blog_id |
491 | 491 | * @param $prev_blog_id |
492 | 492 | */ |
493 | - public function handle_switch_blog( $new_blog_id, $prev_blog_id ) { |
|
493 | + public function handle_switch_blog($new_blog_id, $prev_blog_id) { |
|
494 | 494 | global $wpdb; |
495 | 495 | |
496 | 496 | // Bailout. |
497 | - if ( $new_blog_id === $prev_blog_id ) { |
|
497 | + if ($new_blog_id === $prev_blog_id) { |
|
498 | 498 | return; |
499 | 499 | } |
500 | 500 | |
501 | 501 | |
502 | 502 | $this->table_name = str_replace( |
503 | - 1 != $prev_blog_id ? $wpdb->get_blog_prefix( $prev_blog_id ) : $wpdb->base_prefix, |
|
504 | - 1 != $new_blog_id ? $wpdb->get_blog_prefix( $new_blog_id ) : $wpdb->base_prefix, |
|
503 | + 1 != $prev_blog_id ? $wpdb->get_blog_prefix($prev_blog_id) : $wpdb->base_prefix, |
|
504 | + 1 != $new_blog_id ? $wpdb->get_blog_prefix($new_blog_id) : $wpdb->base_prefix, |
|
505 | 505 | $this->table_name |
506 | 506 | ); |
507 | 507 | |
508 | - if ( $this instanceof Give_DB_Meta ) { |
|
509 | - $wpdb->{$this->get_meta_type() . 'meta'} = $this->table_name; |
|
508 | + if ($this instanceof Give_DB_Meta) { |
|
509 | + $wpdb->{$this->get_meta_type().'meta'} = $this->table_name; |
|
510 | 510 | } |
511 | 511 | |
512 | 512 | } |
@@ -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 | |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | * |
87 | 87 | * @param $args array The array of arguments that can be passed in and used for setting up this payment query. |
88 | 88 | */ |
89 | - public function __construct( $args = array() ) { |
|
89 | + public function __construct($args = array()) { |
|
90 | 90 | $defaults = array( |
91 | 91 | 'number' => 20, |
92 | 92 | 'offset' => 0, |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | // 'form' => array(), |
117 | 117 | ); |
118 | 118 | |
119 | - $this->args = wp_parse_args( $args, $defaults ); |
|
119 | + $this->args = wp_parse_args($args, $defaults); |
|
120 | 120 | $this->table_name = Give()->donors->table_name; |
121 | 121 | $this->meta_table_name = Give()->donor_meta->table_name; |
122 | 122 | $this->meta_type = Give()->donor_meta->meta_type; |
@@ -158,21 +158,21 @@ discard block |
||
158 | 158 | * |
159 | 159 | * @param Give_Donors_Query $this Donors query object. |
160 | 160 | */ |
161 | - do_action( 'give_pre_get_donors', $this ); |
|
161 | + do_action('give_pre_get_donors', $this); |
|
162 | 162 | |
163 | - $cache_key = Give_Cache::get_key( 'give_donor', $this->get_sql(), false ); |
|
163 | + $cache_key = Give_Cache::get_key('give_donor', $this->get_sql(), false); |
|
164 | 164 | |
165 | 165 | // Get donors from cache. |
166 | - $this->donors = Give_Cache::get_db_query( $cache_key ); |
|
166 | + $this->donors = Give_Cache::get_db_query($cache_key); |
|
167 | 167 | |
168 | - if ( is_null( $this->donors ) ) { |
|
169 | - if ( empty( $this->args['count'] ) ) { |
|
170 | - $this->donors = $wpdb->get_results( $this->get_sql() ); |
|
168 | + if (is_null($this->donors)) { |
|
169 | + if (empty($this->args['count'])) { |
|
170 | + $this->donors = $wpdb->get_results($this->get_sql()); |
|
171 | 171 | } else { |
172 | - $this->donors = $wpdb->get_var( $this->get_sql() ); |
|
172 | + $this->donors = $wpdb->get_var($this->get_sql()); |
|
173 | 173 | } |
174 | 174 | |
175 | - Give_Cache::set_db_query( $cache_key, $this->donors ); |
|
175 | + Give_Cache::set_db_query($cache_key, $this->donors); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | * |
184 | 184 | * @param Give_Donors_Query $this Donors query object. |
185 | 185 | */ |
186 | - do_action( 'give_post_get_donors', $this ); |
|
186 | + do_action('give_post_get_donors', $this); |
|
187 | 187 | |
188 | 188 | return $this->donors; |
189 | 189 | } |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | public function get_sql() { |
201 | 201 | global $wpdb; |
202 | 202 | |
203 | - if ( $this->args['number'] < 1 ) { |
|
203 | + if ($this->args['number'] < 1) { |
|
204 | 204 | $this->args['number'] = 99999999999; |
205 | 205 | } |
206 | 206 | |
@@ -208,32 +208,32 @@ discard block |
||
208 | 208 | |
209 | 209 | |
210 | 210 | // Set offset. |
211 | - if ( empty( $this->args['offset'] ) && ( 0 < $this->args['paged'] ) ) { |
|
212 | - $this->args['offset'] = $this->args['number'] * ( $this->args['paged'] - 1 ); |
|
211 | + if (empty($this->args['offset']) && (0 < $this->args['paged'])) { |
|
212 | + $this->args['offset'] = $this->args['number'] * ($this->args['paged'] - 1); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | // Set fields. |
216 | 216 | $fields = "{$this->table_name}.*"; |
217 | - if ( ! empty( $this->args['fields'] ) && 'all' !== $this->args['fields'] ) { |
|
218 | - if ( is_string( $this->args['fields'] ) ) { |
|
217 | + if ( ! empty($this->args['fields']) && 'all' !== $this->args['fields']) { |
|
218 | + if (is_string($this->args['fields'])) { |
|
219 | 219 | $fields = "{$this->table_name}.{$this->args['fields']}"; |
220 | - } elseif ( is_array( $this->args['fields'] ) ) { |
|
221 | - $fields = "{$this->table_name}." . implode( " , {$this->table_name}.", $this->args['fields'] ); |
|
220 | + } elseif (is_array($this->args['fields'])) { |
|
221 | + $fields = "{$this->table_name}.".implode(" , {$this->table_name}.", $this->args['fields']); |
|
222 | 222 | } |
223 | 223 | } |
224 | 224 | |
225 | 225 | // Set count. |
226 | - if ( ! empty( $this->args['count'] ) ) { |
|
226 | + if ( ! empty($this->args['count'])) { |
|
227 | 227 | $fields = "COUNT({$this->table_name}.id)"; |
228 | 228 | } |
229 | 229 | |
230 | 230 | $orderby = $this->get_order_query(); |
231 | 231 | |
232 | - $sql = $wpdb->prepare( "SELECT {$fields} FROM {$this->table_name} LIMIT %d,%d;", absint( $this->args['offset'] ), absint( $this->args['number'] ) ); |
|
232 | + $sql = $wpdb->prepare("SELECT {$fields} FROM {$this->table_name} LIMIT %d,%d;", absint($this->args['offset']), absint($this->args['number'])); |
|
233 | 233 | |
234 | 234 | // $where, $orderby and order already prepared query they can generate notice if you re prepare them in above. |
235 | 235 | // WordPress consider LIKE condition as placeholder if start with s,f, or d. |
236 | - $sql = str_replace( 'LIMIT', "{$where} {$orderby} LIMIT", $sql ); |
|
236 | + $sql = str_replace('LIMIT', "{$where} {$orderby} LIMIT", $sql); |
|
237 | 237 | |
238 | 238 | return $sql; |
239 | 239 | } |
@@ -250,11 +250,11 @@ discard block |
||
250 | 250 | private function get_where_query() { |
251 | 251 | |
252 | 252 | // Get sql query for meta. |
253 | - if ( ! empty( $this->args['meta_query'] ) ) { |
|
254 | - $meta_query_object = new WP_Meta_Query( $this->args['meta_query'] ); |
|
255 | - $meta_query = $meta_query_object->get_sql( $this->meta_type, $this->table_name, 'id' ); |
|
253 | + if ( ! empty($this->args['meta_query'])) { |
|
254 | + $meta_query_object = new WP_Meta_Query($this->args['meta_query']); |
|
255 | + $meta_query = $meta_query_object->get_sql($this->meta_type, $this->table_name, 'id'); |
|
256 | 256 | |
257 | - $where[] = implode( '', $meta_query ); |
|
257 | + $where[] = implode('', $meta_query); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | $where[] = 'WHERE 1=1'; |
@@ -267,9 +267,9 @@ discard block |
||
267 | 267 | $where[] = $this->get_where_donation_count(); |
268 | 268 | $where[] = $this->get_where_give_forms(); |
269 | 269 | |
270 | - $where = array_filter( $where ); |
|
270 | + $where = array_filter($where); |
|
271 | 271 | |
272 | - return trim( implode( ' ', array_map( 'trim', $where ) ) ); |
|
272 | + return trim(implode(' ', array_map('trim', $where))); |
|
273 | 273 | |
274 | 274 | } |
275 | 275 | |
@@ -287,17 +287,17 @@ discard block |
||
287 | 287 | |
288 | 288 | $where = ''; |
289 | 289 | |
290 | - if ( ! empty( $this->args['email'] ) ) { |
|
290 | + if ( ! empty($this->args['email'])) { |
|
291 | 291 | |
292 | - if ( is_array( $this->args['email'] ) ) { |
|
292 | + if (is_array($this->args['email'])) { |
|
293 | 293 | |
294 | - $emails_count = count( $this->args['email'] ); |
|
295 | - $emails_placeholder = array_fill( 0, $emails_count, '%s' ); |
|
296 | - $emails = implode( ', ', $emails_placeholder ); |
|
294 | + $emails_count = count($this->args['email']); |
|
295 | + $emails_placeholder = array_fill(0, $emails_count, '%s'); |
|
296 | + $emails = implode(', ', $emails_placeholder); |
|
297 | 297 | |
298 | - $where .= $wpdb->prepare( "AND {$this->table_name}.email IN( $emails )", $this->args['email'] ); |
|
298 | + $where .= $wpdb->prepare("AND {$this->table_name}.email IN( $emails )", $this->args['email']); |
|
299 | 299 | } else { |
300 | - $where .= $wpdb->prepare( "AND {$this->table_name}.email = %s", $this->args['email'] ); |
|
300 | + $where .= $wpdb->prepare("AND {$this->table_name}.email = %s", $this->args['email']); |
|
301 | 301 | } |
302 | 302 | } |
303 | 303 | |
@@ -317,11 +317,11 @@ discard block |
||
317 | 317 | $where = ''; |
318 | 318 | |
319 | 319 | // Specific donors. |
320 | - if ( ! empty( $this->args['donor'] ) ) { |
|
321 | - if ( ! is_array( $this->args['donor'] ) ) { |
|
322 | - $this->args['donor'] = explode( ',', $this->args['donor'] ); |
|
320 | + if ( ! empty($this->args['donor'])) { |
|
321 | + if ( ! is_array($this->args['donor'])) { |
|
322 | + $this->args['donor'] = explode(',', $this->args['donor']); |
|
323 | 323 | } |
324 | - $donor_ids = implode( ',', array_map( 'intval', $this->args['donor'] ) ); |
|
324 | + $donor_ids = implode(',', array_map('intval', $this->args['donor'])); |
|
325 | 325 | |
326 | 326 | $where .= "AND {$this->table_name}.id IN( {$donor_ids} )"; |
327 | 327 | } |
@@ -342,10 +342,10 @@ discard block |
||
342 | 342 | $where = ''; |
343 | 343 | |
344 | 344 | // Donors created for a specific date or in a date range |
345 | - if ( ! empty( $this->args['date_query'] ) ) { |
|
346 | - $date_query_object = new WP_Date_Query( is_array( $this->args['date_query'] ) ? $this->args['date_query'] : wp_parse_args( $this->args['date_query'] ), "{$this->table_name}.date_created" ); |
|
345 | + if ( ! empty($this->args['date_query'])) { |
|
346 | + $date_query_object = new WP_Date_Query(is_array($this->args['date_query']) ? $this->args['date_query'] : wp_parse_args($this->args['date_query']), "{$this->table_name}.date_created"); |
|
347 | 347 | |
348 | - $where .= str_replace( array( |
|
348 | + $where .= str_replace(array( |
|
349 | 349 | "\n", |
350 | 350 | '( (', |
351 | 351 | '))', |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | '', |
354 | 354 | '( (', |
355 | 355 | ') )', |
356 | - ), $date_query_object->get_sql() ); |
|
356 | + ), $date_query_object->get_sql()); |
|
357 | 357 | } |
358 | 358 | |
359 | 359 | return $where; |
@@ -372,11 +372,11 @@ discard block |
||
372 | 372 | $where = ''; |
373 | 373 | |
374 | 374 | // Donors created for a specific date or in a date range |
375 | - if ( ! empty( $this->args['s'] ) && false !== strpos( $this->args['s'], ':' ) ) { |
|
376 | - $search_parts = explode( ':', $this->args['s'] ); |
|
375 | + if ( ! empty($this->args['s']) && false !== strpos($this->args['s'], ':')) { |
|
376 | + $search_parts = explode(':', $this->args['s']); |
|
377 | 377 | |
378 | - if ( ! empty( $search_parts[0] ) ) { |
|
379 | - switch ( $search_parts[0] ) { |
|
378 | + if ( ! empty($search_parts[0])) { |
|
379 | + switch ($search_parts[0]) { |
|
380 | 380 | case 'name': |
381 | 381 | $where = "AND {$this->table_name}.name LIKE '%{$search_parts[1]}%'"; |
382 | 382 | break; |
@@ -404,11 +404,11 @@ discard block |
||
404 | 404 | $where = ''; |
405 | 405 | |
406 | 406 | // Donors create for specific wp user. |
407 | - if ( ! empty( $this->args['user'] ) ) { |
|
408 | - if ( ! is_array( $this->args['user'] ) ) { |
|
409 | - $this->args['user'] = explode( ',', $this->args['user'] ); |
|
407 | + if ( ! empty($this->args['user'])) { |
|
408 | + if ( ! is_array($this->args['user'])) { |
|
409 | + $this->args['user'] = explode(',', $this->args['user']); |
|
410 | 410 | } |
411 | - $user_ids = implode( ',', array_map( 'intval', $this->args['user'] ) ); |
|
411 | + $user_ids = implode(',', array_map('intval', $this->args['user'])); |
|
412 | 412 | |
413 | 413 | $where .= "AND {$this->table_name}.user_id IN( {$user_ids} )"; |
414 | 414 | } |
@@ -430,7 +430,7 @@ discard block |
||
430 | 430 | $query = array(); |
431 | 431 | $ordersby = $this->args['orderby']; |
432 | 432 | |
433 | - if( ! is_array( $ordersby ) ) { |
|
433 | + if ( ! is_array($ordersby)) { |
|
434 | 434 | $ordersby = array( |
435 | 435 | $this->args['orderby'] => $this->args['order'] |
436 | 436 | ); |
@@ -438,23 +438,23 @@ discard block |
||
438 | 438 | |
439 | 439 | // Remove non existing column. |
440 | 440 | // Filter orderby values. |
441 | - foreach ( $ordersby as $orderby => $order ) { |
|
442 | - if( ! array_key_exists( $orderby, $table_columns ) ) { |
|
443 | - unset( $ordersby[$orderby] ); |
|
441 | + foreach ($ordersby as $orderby => $order) { |
|
442 | + if ( ! array_key_exists($orderby, $table_columns)) { |
|
443 | + unset($ordersby[$orderby]); |
|
444 | 444 | } |
445 | 445 | |
446 | - $ordersby[ esc_sql( $orderby ) ] = esc_sql( $order ); |
|
446 | + $ordersby[esc_sql($orderby)] = esc_sql($order); |
|
447 | 447 | } |
448 | 448 | |
449 | - if( empty( $ordersby ) ) { |
|
449 | + if (empty($ordersby)) { |
|
450 | 450 | $ordersby = array( |
451 | 451 | 'id' => $this->args['order'] |
452 | 452 | ); |
453 | 453 | } |
454 | 454 | |
455 | 455 | // Create query. |
456 | - foreach ( $ordersby as $orderby => $order ) { |
|
457 | - switch ( $table_columns[ $orderby ] ) { |
|
456 | + foreach ($ordersby as $orderby => $order) { |
|
457 | + switch ($table_columns[$orderby]) { |
|
458 | 458 | case '%d': |
459 | 459 | case '%f': |
460 | 460 | $query[] = "{$this->table_name}.{$orderby}+0 {$order}"; |
@@ -465,7 +465,7 @@ discard block |
||
465 | 465 | } |
466 | 466 | } |
467 | 467 | |
468 | - return ! empty( $query ) ? 'ORDER BY ' . implode( ', ', $query ) : ''; |
|
468 | + return ! empty($query) ? 'ORDER BY '.implode(', ', $query) : ''; |
|
469 | 469 | } |
470 | 470 | |
471 | 471 | /** |
@@ -481,10 +481,10 @@ discard block |
||
481 | 481 | private function get_where_donation_count() { |
482 | 482 | $where = ''; |
483 | 483 | |
484 | - if ( ! empty( $this->args['donation_count'] ) ) { |
|
484 | + if ( ! empty($this->args['donation_count'])) { |
|
485 | 485 | $compare = '>'; |
486 | 486 | $amount = $this->args['donation_count']; |
487 | - if ( is_array( $this->args['donation_count'] ) ) { |
|
487 | + if (is_array($this->args['donation_count'])) { |
|
488 | 488 | $compare = $this->args['donation_count'] ['compare']; |
489 | 489 | $amount = $this->args['donation_count']['amount']; |
490 | 490 | } |
@@ -508,10 +508,10 @@ discard block |
||
508 | 508 | private function get_where_donation_amount() { |
509 | 509 | $where = ''; |
510 | 510 | |
511 | - if ( ! empty( $this->args['donation_amount'] ) ) { |
|
511 | + if ( ! empty($this->args['donation_amount'])) { |
|
512 | 512 | $compare = '>'; |
513 | 513 | $amount = $this->args['donation_amount']; |
514 | - if ( is_array( $this->args['donation_amount'] ) ) { |
|
514 | + if (is_array($this->args['donation_amount'])) { |
|
515 | 515 | $compare = $this->args['donation_amount'] ['compare']; |
516 | 516 | $amount = $this->args['donation_amount']['amount']; |
517 | 517 | } |
@@ -537,13 +537,13 @@ discard block |
||
537 | 537 | global $wpdb; |
538 | 538 | $where = ''; |
539 | 539 | |
540 | - if ( ! empty( $this->args['give_forms'] ) ) { |
|
541 | - if ( ! is_array( $this->args['give_forms'] ) ) { |
|
542 | - $this->args['give_forms'] = explode( ',', $this->args['give_forms'] ); |
|
540 | + if ( ! empty($this->args['give_forms'])) { |
|
541 | + if ( ! is_array($this->args['give_forms'])) { |
|
542 | + $this->args['give_forms'] = explode(',', $this->args['give_forms']); |
|
543 | 543 | } |
544 | 544 | |
545 | - $form_ids = implode( ',', array_map( 'intval', $this->args['give_forms'] ) ); |
|
546 | - $donation_id_col = Give()->payment_meta->get_meta_type() . '_id'; |
|
545 | + $form_ids = implode(',', array_map('intval', $this->args['give_forms'])); |
|
546 | + $donation_id_col = Give()->payment_meta->get_meta_type().'_id'; |
|
547 | 547 | |
548 | 548 | $query = $wpdb->prepare( |
549 | 549 | " |
@@ -562,12 +562,12 @@ discard block |
||
562 | 562 | $form_ids |
563 | 563 | ); |
564 | 564 | |
565 | - $donor_ids = $wpdb->get_results( $query, ARRAY_A ); |
|
565 | + $donor_ids = $wpdb->get_results($query, ARRAY_A); |
|
566 | 566 | |
567 | - if ( ! empty( $donor_ids ) ) { |
|
568 | - $donor_ids = wp_list_pluck( $donor_ids, 'donor_id' ); |
|
569 | - $donor_ids = implode( ',', array_map( 'intval', $donor_ids ) ); |
|
570 | - $where .= "AND {$this->table_name}.id IN ({$donor_ids})"; |
|
567 | + if ( ! empty($donor_ids)) { |
|
568 | + $donor_ids = wp_list_pluck($donor_ids, 'donor_id'); |
|
569 | + $donor_ids = implode(',', array_map('intval', $donor_ids)); |
|
570 | + $where .= "AND {$this->table_name}.id IN ({$donor_ids})"; |
|
571 | 571 | } else { |
572 | 572 | $where .= "AND {$this->table_name}.id IN ('0')"; |
573 | 573 | } |
@@ -9,11 +9,11 @@ discard block |
||
9 | 9 | * @since 1.8 |
10 | 10 | */ |
11 | 11 | |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; // Exit if accessed directly |
14 | 14 | } |
15 | 15 | |
16 | -if ( ! class_exists( 'Give_Settings_Gateways' ) ) : |
|
16 | +if ( ! class_exists('Give_Settings_Gateways')) : |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Give_Settings_Gateways. |
@@ -27,15 +27,15 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public function __construct() { |
29 | 29 | $this->id = 'gateways'; |
30 | - $this->label = esc_html__( 'Payment Gateways', 'give' ); |
|
30 | + $this->label = esc_html__('Payment Gateways', 'give'); |
|
31 | 31 | |
32 | 32 | $this->default_tab = 'gateways-settings'; |
33 | 33 | |
34 | 34 | parent::__construct(); |
35 | 35 | |
36 | 36 | // Do not use main form for this tab. |
37 | - if ( give_get_current_setting_tab() === $this->id ) { |
|
38 | - add_action( 'give_admin_field_enabled_gateways', array( $this, 'render_enabled_gateways' ), 10, 2 ); |
|
37 | + if (give_get_current_setting_tab() === $this->id) { |
|
38 | + add_action('give_admin_field_enabled_gateways', array($this, 'render_enabled_gateways'), 10, 2); |
|
39 | 39 | } |
40 | 40 | } |
41 | 41 | |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | $settings = array(); |
50 | 50 | $current_section = give_get_current_setting_section(); |
51 | 51 | |
52 | - switch ( $current_section ) { |
|
52 | + switch ($current_section) { |
|
53 | 53 | case 'paypal-standard': |
54 | 54 | $settings = array( |
55 | 55 | // Section 2: PayPal Standard. |
@@ -58,62 +58,62 @@ discard block |
||
58 | 58 | 'id' => 'give_title_gateway_settings_2', |
59 | 59 | ), |
60 | 60 | array( |
61 | - 'name' => __( 'PayPal Email', 'give' ), |
|
62 | - 'desc' => __( 'Enter your PayPal account\'s email.', 'give' ), |
|
61 | + 'name' => __('PayPal Email', 'give'), |
|
62 | + 'desc' => __('Enter your PayPal account\'s email.', 'give'), |
|
63 | 63 | 'id' => 'paypal_email', |
64 | 64 | 'type' => 'email', |
65 | 65 | ), |
66 | 66 | array( |
67 | - 'name' => __( 'PayPal Page Style', 'give' ), |
|
68 | - 'desc' => __( 'Enter the name of the PayPal page style to use, or leave blank to use the default.', 'give' ), |
|
67 | + 'name' => __('PayPal Page Style', 'give'), |
|
68 | + 'desc' => __('Enter the name of the PayPal page style to use, or leave blank to use the default.', 'give'), |
|
69 | 69 | 'id' => 'paypal_page_style', |
70 | 70 | 'type' => 'text', |
71 | 71 | ), |
72 | 72 | array( |
73 | - 'name' => __( 'PayPal Transaction Type', 'give' ), |
|
74 | - 'desc' => __( 'Nonprofits must verify their status to withdraw donations they receive via PayPal. PayPal users that are not verified nonprofits must demonstrate how their donations will be used, once they raise more than $10,000. By default, Give transactions are sent to PayPal as donations. You may change the transaction type using this option if you feel you may not meet PayPal\'s donation requirements.', 'give' ), |
|
73 | + 'name' => __('PayPal Transaction Type', 'give'), |
|
74 | + 'desc' => __('Nonprofits must verify their status to withdraw donations they receive via PayPal. PayPal users that are not verified nonprofits must demonstrate how their donations will be used, once they raise more than $10,000. By default, Give transactions are sent to PayPal as donations. You may change the transaction type using this option if you feel you may not meet PayPal\'s donation requirements.', 'give'), |
|
75 | 75 | 'id' => 'paypal_button_type', |
76 | 76 | 'type' => 'radio_inline', |
77 | 77 | 'options' => array( |
78 | - 'donation' => __( 'Donation', 'give' ), |
|
79 | - 'standard' => __( 'Standard Transaction', 'give' ) |
|
78 | + 'donation' => __('Donation', 'give'), |
|
79 | + 'standard' => __('Standard Transaction', 'give') |
|
80 | 80 | ), |
81 | 81 | 'default' => 'donation', |
82 | 82 | ), |
83 | 83 | array( |
84 | - 'name' => __( 'Billing Details', 'give' ), |
|
85 | - 'desc' => __( 'This option will enable the billing details section for PayPal Standard which requires the donor\'s address to complete the donation. These fields are not required by PayPal to process the transaction, but you may have a need to collect the data.', 'give' ), |
|
84 | + 'name' => __('Billing Details', 'give'), |
|
85 | + 'desc' => __('This option will enable the billing details section for PayPal Standard which requires the donor\'s address to complete the donation. These fields are not required by PayPal to process the transaction, but you may have a need to collect the data.', 'give'), |
|
86 | 86 | 'id' => 'paypal_standard_billing_details', |
87 | 87 | 'type' => 'radio_inline', |
88 | 88 | 'default' => 'disabled', |
89 | 89 | 'options' => array( |
90 | - 'enabled' => __( 'Enabled', 'give' ), |
|
91 | - 'disabled' => __( 'Disabled', 'give' ), |
|
90 | + 'enabled' => __('Enabled', 'give'), |
|
91 | + 'disabled' => __('Disabled', 'give'), |
|
92 | 92 | ) |
93 | 93 | ), |
94 | 94 | array( |
95 | - 'name' => __( 'PayPal IPN Verification', 'give' ), |
|
96 | - 'desc' => __( 'If donations are not getting marked as complete, use a slightly less secure method of verifying donations.', 'give' ), |
|
95 | + 'name' => __('PayPal IPN Verification', 'give'), |
|
96 | + 'desc' => __('If donations are not getting marked as complete, use a slightly less secure method of verifying donations.', 'give'), |
|
97 | 97 | 'id' => 'paypal_verification', |
98 | 98 | 'type' => 'radio_inline', |
99 | 99 | 'default' => 'enabled', |
100 | 100 | 'options' => array( |
101 | - 'enabled' => __( 'Enabled', 'give' ), |
|
102 | - 'disabled' => __( 'Disabled', 'give' ), |
|
101 | + 'enabled' => __('Enabled', 'give'), |
|
102 | + 'disabled' => __('Disabled', 'give'), |
|
103 | 103 | ) |
104 | 104 | ), |
105 | 105 | array( |
106 | 106 | 'id' => 'paypal_invoice_prefix', |
107 | - 'name' => esc_html__( 'Invoice ID Prefix', 'give' ), |
|
108 | - 'desc' => esc_html__( 'Please enter a prefix for your invoice numbers. If you use your PayPal account for multiple stores ensure this prefix is unique as PayPal will not allow orders with the same invoice number.', 'give' ), |
|
107 | + 'name' => esc_html__('Invoice ID Prefix', 'give'), |
|
108 | + 'desc' => esc_html__('Please enter a prefix for your invoice numbers. If you use your PayPal account for multiple stores ensure this prefix is unique as PayPal will not allow orders with the same invoice number.', 'give'), |
|
109 | 109 | 'type' => 'text', |
110 | 110 | 'default' => 'GIVE-', |
111 | 111 | ), |
112 | 112 | array( |
113 | - 'name' => __( 'PayPal Standard Gateway Settings Docs Link', 'give' ), |
|
113 | + 'name' => __('PayPal Standard Gateway Settings Docs Link', 'give'), |
|
114 | 114 | 'id' => 'paypal_standard_gateway_settings_docs_link', |
115 | - 'url' => esc_url( 'http://docs.givewp.com/settings-gateway-paypal-standard' ), |
|
116 | - 'title' => __( 'PayPal Standard Gateway Settings', 'give' ), |
|
115 | + 'url' => esc_url('http://docs.givewp.com/settings-gateway-paypal-standard'), |
|
116 | + 'title' => __('PayPal Standard Gateway Settings', 'give'), |
|
117 | 117 | 'type' => 'give_docs_link', |
118 | 118 | ), |
119 | 119 | array( |
@@ -131,19 +131,19 @@ discard block |
||
131 | 131 | 'id' => 'give_title_gateway_settings_3', |
132 | 132 | ), |
133 | 133 | array( |
134 | - 'name' => __( 'Collect Billing Details', 'give' ), |
|
135 | - 'desc' => __( 'Enable to request billing details for offline donations. Will appear above offline donation instructions. Can be enabled/disabled per form.', 'give' ), |
|
134 | + 'name' => __('Collect Billing Details', 'give'), |
|
135 | + 'desc' => __('Enable to request billing details for offline donations. Will appear above offline donation instructions. Can be enabled/disabled per form.', 'give'), |
|
136 | 136 | 'id' => 'give_offline_donation_enable_billing_fields', |
137 | 137 | 'type' => 'radio_inline', |
138 | 138 | 'default' => 'disabled', |
139 | 139 | 'options' => array( |
140 | - 'enabled' => __( 'Enabled', 'give' ), |
|
141 | - 'disabled' => __( 'Disabled', 'give' ) |
|
140 | + 'enabled' => __('Enabled', 'give'), |
|
141 | + 'disabled' => __('Disabled', 'give') |
|
142 | 142 | ) |
143 | 143 | ), |
144 | 144 | array( |
145 | - 'name' => __( 'Offline Donation Instructions', 'give' ), |
|
146 | - 'desc' => __( 'The following content will appear for all forms when the user selects the offline donation payment option. Note: You may customize the content per form as needed.', 'give' ), |
|
145 | + 'name' => __('Offline Donation Instructions', 'give'), |
|
146 | + 'desc' => __('The following content will appear for all forms when the user selects the offline donation payment option. Note: You may customize the content per form as needed.', 'give'), |
|
147 | 147 | 'id' => 'global_offline_donation_content', |
148 | 148 | 'default' => give_get_default_offline_donation_content(), |
149 | 149 | 'type' => 'wysiwyg', |
@@ -152,10 +152,10 @@ discard block |
||
152 | 152 | ) |
153 | 153 | ), |
154 | 154 | array( |
155 | - 'name' => esc_html__( 'Offline Donations Settings Docs Link', 'give' ), |
|
155 | + 'name' => esc_html__('Offline Donations Settings Docs Link', 'give'), |
|
156 | 156 | 'id' => 'offline_gateway_settings_docs_link', |
157 | - 'url' => esc_url( 'http://docs.givewp.com/offlinegateway' ), |
|
158 | - 'title' => __( 'Offline Gateway Settings', 'give' ), |
|
157 | + 'url' => esc_url('http://docs.givewp.com/offlinegateway'), |
|
158 | + 'title' => __('Offline Gateway Settings', 'give'), |
|
159 | 159 | 'type' => 'give_docs_link', |
160 | 160 | ), |
161 | 161 | array( |
@@ -173,19 +173,19 @@ discard block |
||
173 | 173 | 'type' => 'title' |
174 | 174 | ), |
175 | 175 | array( |
176 | - 'name' => __( 'Test Mode', 'give' ), |
|
177 | - 'desc' => __( 'While in test mode no live donations are processed. To fully use test mode, you must have a sandbox (test) account for the payment gateway you are testing.', 'give' ), |
|
176 | + 'name' => __('Test Mode', 'give'), |
|
177 | + 'desc' => __('While in test mode no live donations are processed. To fully use test mode, you must have a sandbox (test) account for the payment gateway you are testing.', 'give'), |
|
178 | 178 | 'id' => 'test_mode', |
179 | 179 | 'type' => 'radio_inline', |
180 | 180 | 'default' => 'disabled', |
181 | 181 | 'options' => array( |
182 | - 'enabled' => __( 'Enabled', 'give' ), |
|
183 | - 'disabled' => __( 'Disabled', 'give' ), |
|
182 | + 'enabled' => __('Enabled', 'give'), |
|
183 | + 'disabled' => __('Disabled', 'give'), |
|
184 | 184 | ) |
185 | 185 | ), |
186 | 186 | array( |
187 | - 'name' => __( 'Enabled Gateways', 'give' ), |
|
188 | - 'desc' => __( 'Enable your payment gateway. Can be ordered by dragging.', 'give' ), |
|
187 | + 'name' => __('Enabled Gateways', 'give'), |
|
188 | + 'desc' => __('Enable your payment gateway. Can be ordered by dragging.', 'give'), |
|
189 | 189 | 'id' => 'gateways', |
190 | 190 | 'type' => 'enabled_gateways' |
191 | 191 | ), |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | * This setting will not render on admin setting screen but help internal code to recognize "gateways_label" setting and add them to give setting when save. |
198 | 198 | */ |
199 | 199 | array( |
200 | - 'name' => __( 'Gateways Label', 'give' ), |
|
200 | + 'name' => __('Gateways Label', 'give'), |
|
201 | 201 | 'desc' => '', |
202 | 202 | 'id' => 'gateways_label', |
203 | 203 | 'type' => 'gateways_label_hidden' |
@@ -210,17 +210,17 @@ discard block |
||
210 | 210 | * This setting will not render on admin setting screen but help internal code to recognize "default_gateway" setting and add them to give setting when save. |
211 | 211 | */ |
212 | 212 | array( |
213 | - 'name' => __( 'Default Gateway', 'give' ), |
|
214 | - 'desc' => __( 'The gateway that will be selected by default.', 'give' ), |
|
213 | + 'name' => __('Default Gateway', 'give'), |
|
214 | + 'desc' => __('The gateway that will be selected by default.', 'give'), |
|
215 | 215 | 'id' => 'default_gateway', |
216 | 216 | 'type' => 'default_gateway_hidden' |
217 | 217 | ), |
218 | 218 | |
219 | 219 | array( |
220 | - 'name' => __( 'Gateways Docs Link', 'give' ), |
|
220 | + 'name' => __('Gateways Docs Link', 'give'), |
|
221 | 221 | 'id' => 'gateway_settings_docs_link', |
222 | - 'url' => esc_url( 'http://docs.givewp.com/settings-gateways' ), |
|
223 | - 'title' => __( 'Gateway Settings', 'give' ), |
|
222 | + 'url' => esc_url('http://docs.givewp.com/settings-gateways'), |
|
223 | + 'title' => __('Gateway Settings', 'give'), |
|
224 | 224 | 'type' => 'give_docs_link', |
225 | 225 | ), |
226 | 226 | array( |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | * Filter the payment gateways settings. |
236 | 236 | * Backward compatibility: Please do not use this filter. This filter is deprecated in 1.8 |
237 | 237 | */ |
238 | - $settings = apply_filters( 'give_settings_gateways', $settings ); |
|
238 | + $settings = apply_filters('give_settings_gateways', $settings); |
|
239 | 239 | |
240 | 240 | /** |
241 | 241 | * Filter the settings. |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | * |
245 | 245 | * @param array $settings |
246 | 246 | */ |
247 | - $settings = apply_filters( 'give_get_settings_' . $this->id, $settings ); |
|
247 | + $settings = apply_filters('give_get_settings_'.$this->id, $settings); |
|
248 | 248 | |
249 | 249 | // Output. |
250 | 250 | return $settings; |
@@ -258,12 +258,12 @@ discard block |
||
258 | 258 | */ |
259 | 259 | public function get_sections() { |
260 | 260 | $sections = array( |
261 | - 'gateways-settings' => __( 'Gateways', 'give' ), |
|
262 | - 'paypal-standard' => __( 'PayPal Standard', 'give' ), |
|
263 | - 'offline-donations' => __( 'Offline Donations', 'give' ) |
|
261 | + 'gateways-settings' => __('Gateways', 'give'), |
|
262 | + 'paypal-standard' => __('PayPal Standard', 'give'), |
|
263 | + 'offline-donations' => __('Offline Donations', 'give') |
|
264 | 264 | ); |
265 | 265 | |
266 | - return apply_filters( 'give_get_sections_' . $this->id, $sections ); |
|
266 | + return apply_filters('give_get_sections_'.$this->id, $sections); |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | |
@@ -276,11 +276,11 @@ discard block |
||
276 | 276 | * @param $field |
277 | 277 | * @param $settings |
278 | 278 | */ |
279 | - public function render_enabled_gateways( $field, $settings ) { |
|
279 | + public function render_enabled_gateways($field, $settings) { |
|
280 | 280 | $id = $field['id']; |
281 | - $gateways = give_get_ordered_payment_gateways( give_get_payment_gateways() ); |
|
282 | - $gateways_label = give_get_option( 'gateways_label', array() ); |
|
283 | - $default_gateway = give_get_option( 'default_gateway', current( array_keys( $gateways ) ) ); |
|
281 | + $gateways = give_get_ordered_payment_gateways(give_get_payment_gateways()); |
|
282 | + $gateways_label = give_get_option('gateways_label', array()); |
|
283 | + $default_gateway = give_get_option('default_gateway', current(array_keys($gateways))); |
|
284 | 284 | |
285 | 285 | ob_start(); |
286 | 286 | |
@@ -295,51 +295,51 @@ discard block |
||
295 | 295 | <span>%3$s</span> |
296 | 296 | <span>%4$s</span> |
297 | 297 | ', |
298 | - __( 'Gateway', 'give' ), |
|
299 | - __( 'Label', 'give' ), |
|
300 | - __( 'Default', 'give' ), |
|
301 | - __( 'Enabled', 'give' ) |
|
298 | + __('Gateway', 'give'), |
|
299 | + __('Label', 'give'), |
|
300 | + __('Default', 'give'), |
|
301 | + __('Enabled', 'give') |
|
302 | 302 | ); |
303 | 303 | echo '</div>'; |
304 | 304 | |
305 | 305 | echo '<ul class="give-checklist-fields give-payment-gatways-list">'; |
306 | - foreach ( $gateways as $key => $option ) : |
|
306 | + foreach ($gateways as $key => $option) : |
|
307 | 307 | $enabled = null; |
308 | - if ( is_array( $settings ) && array_key_exists( $key, $settings ) ) { |
|
308 | + if (is_array($settings) && array_key_exists($key, $settings)) { |
|
309 | 309 | $enabled = '1'; |
310 | 310 | } |
311 | 311 | |
312 | 312 | echo '<li>'; |
313 | - printf( '<span class="give-drag-handle"><span class="dashicons dashicons-menu"></span></span>' ); |
|
314 | - printf( '<span class="admin-label">%s</span>', esc_html( $option['admin_label'] ) ); |
|
313 | + printf('<span class="give-drag-handle"><span class="dashicons dashicons-menu"></span></span>'); |
|
314 | + printf('<span class="admin-label">%s</span>', esc_html($option['admin_label'])); |
|
315 | 315 | |
316 | 316 | $label = ''; |
317 | - if ( ! empty( $gateways_label[ $key ] ) ) { |
|
318 | - $label = $gateways_label[ $key ]; |
|
317 | + if ( ! empty($gateways_label[$key])) { |
|
318 | + $label = $gateways_label[$key]; |
|
319 | 319 | } |
320 | 320 | |
321 | 321 | printf( |
322 | 322 | '<input class="checkout-label" type="text" id="%1$s[%2$s]" name="%1$s[%2$s]" value="%3$s" placeholder="%4$s"/>', |
323 | 323 | 'gateways_label', |
324 | - esc_attr( $key ), |
|
325 | - esc_html( $label ), |
|
326 | - esc_html( $option['checkout_label'] ) |
|
324 | + esc_attr($key), |
|
325 | + esc_html($label), |
|
326 | + esc_html($option['checkout_label']) |
|
327 | 327 | ); |
328 | 328 | |
329 | 329 | printf( |
330 | 330 | '<input class="gateways-radio" type="radio" name="%1$s" value="%2$s" %3$s %4$s>', |
331 | 331 | 'default_gateway', |
332 | 332 | $key, |
333 | - checked( $key, $default_gateway, false ), |
|
334 | - disabled( NULL, $enabled, false ) |
|
333 | + checked($key, $default_gateway, false), |
|
334 | + disabled(NULL, $enabled, false) |
|
335 | 335 | ); |
336 | 336 | |
337 | 337 | printf( |
338 | 338 | '<input class="gateways-checkbox" name="%1$s[%2$s]" id="%1$s[%2$s]" type="checkbox" value="1" %3$s data-payment-gateway="%4$s"/>', |
339 | - esc_attr( $id ), |
|
340 | - esc_attr( $key ), |
|
341 | - checked( '1', $enabled, false ), |
|
342 | - esc_html( $option['admin_label'] ) |
|
339 | + esc_attr($id), |
|
340 | + esc_attr($key), |
|
341 | + checked('1', $enabled, false), |
|
342 | + esc_html($option['admin_label']) |
|
343 | 343 | ); |
344 | 344 | echo '</li>'; |
345 | 345 | endforeach; |
@@ -4,13 +4,13 @@ discard block |
||
4 | 4 | */ |
5 | 5 | |
6 | 6 | // Exit if accessed directly. |
7 | -if ( ! defined( 'ABSPATH' ) ) { |
|
7 | +if ( ! defined('ABSPATH')) { |
|
8 | 8 | exit; |
9 | 9 | } |
10 | 10 | |
11 | 11 | /** @var $donor Give_Donor */ |
12 | 12 | $donor = $args[0]; |
13 | -$donor = new Give_Donor( $donor->id ); |
|
13 | +$donor = new Give_Donor($donor->id); |
|
14 | 14 | |
15 | 15 | $give_settings = $args[1]; // Give settings. |
16 | 16 | $atts = $args[2]; // Shortcode attributes. |
@@ -21,26 +21,26 @@ discard block |
||
21 | 21 | <div class="give-donor__header"> |
22 | 22 | <?php |
23 | 23 | // Maybe display the Avatar. |
24 | - if ( true === $atts['show_avatar'] ) { |
|
25 | - echo give_get_donor_avatar( $donor ); |
|
24 | + if (true === $atts['show_avatar']) { |
|
25 | + echo give_get_donor_avatar($donor); |
|
26 | 26 | } |
27 | 27 | ?> |
28 | 28 | |
29 | 29 | <div class="give-donor__details"> |
30 | - <?php if ( true === $atts['show_name'] ) : ?> |
|
30 | + <?php if (true === $atts['show_name']) : ?> |
|
31 | 31 | <h3 class="give-donor__name"> |
32 | - <?php esc_html_e( $donor->name ); ?> |
|
32 | + <?php esc_html_e($donor->name); ?> |
|
33 | 33 | </h3> |
34 | 34 | <?php endif; ?> |
35 | 35 | |
36 | - <?php if ( true === $atts['show_total'] ) : ?> |
|
36 | + <?php if (true === $atts['show_total']) : ?> |
|
37 | 37 | <span class="give-donor__total"> |
38 | 38 | <?php |
39 | 39 | // If not filtered by form ID then display total donations |
40 | 40 | // Else filtered by form ID, only display donations made for this form. |
41 | 41 | $donated_amount = $donor->purchase_value; |
42 | 42 | |
43 | - if ( ! empty( $atts['form_id'] ) ) { |
|
43 | + if ( ! empty($atts['form_id'])) { |
|
44 | 44 | $donated_amount = Give_Donor_Stats::donated( |
45 | 45 | array( |
46 | 46 | 'donor' => $donor->id, |
@@ -48,17 +48,17 @@ discard block |
||
48 | 48 | ) |
49 | 49 | ); |
50 | 50 | } |
51 | - echo give_currency_filter( give_format_amount( $donated_amount, array( 'sanitize' => false ) ) ); |
|
51 | + echo give_currency_filter(give_format_amount($donated_amount, array('sanitize' => false))); |
|
52 | 52 | ?> |
53 | 53 | </span> |
54 | 54 | <?php endif; ?> |
55 | 55 | |
56 | - <?php if ( true === $atts['show_time'] ) : ?> |
|
56 | + <?php if (true === $atts['show_time']) : ?> |
|
57 | 57 | <span class="give-donor__timestamp"> |
58 | 58 | <?php |
59 | 59 | // If not filtered by form ID then display the "Donor Since" text. |
60 | 60 | // If filtered by form ID then display the last donation date. |
61 | - echo $donor->get_last_donation_date( true ); |
|
61 | + echo $donor->get_last_donation_date(true); |
|
62 | 62 | ?> |
63 | 63 | </span> |
64 | 64 | <?php endif; ?> |
@@ -66,18 +66,18 @@ discard block |
||
66 | 66 | </div> |
67 | 67 | |
68 | 68 | <?php |
69 | - $comment = give_get_donor_latest_comment( $donor->id, $atts['form_id'] ); |
|
69 | + $comment = give_get_donor_latest_comment($donor->id, $atts['form_id']); |
|
70 | 70 | |
71 | - if ( true === $atts['show_comments'] && absint( $atts['comment_length'] ) && $comment instanceof WP_Comment ) : |
|
71 | + if (true === $atts['show_comments'] && absint($atts['comment_length']) && $comment instanceof WP_Comment) : |
|
72 | 72 | ?> |
73 | 73 | <div class="give-donor__content"> |
74 | 74 | <?php |
75 | - $comment_content = apply_filters( 'the_content', $comment->comment_content ); |
|
75 | + $comment_content = apply_filters('the_content', $comment->comment_content); |
|
76 | 76 | |
77 | - if ( $atts['comment_length'] < strlen( $comment->comment_content ) ) { |
|
77 | + if ($atts['comment_length'] < strlen($comment->comment_content)) { |
|
78 | 78 | echo sprintf( |
79 | 79 | '<p class="give-donor__comment_excerpt">%s…<span> <a class="give-donor__read-more">%s</a></span></p>', |
80 | - substr( $comment_content, 0, $atts['comment_length'] ), |
|
80 | + substr($comment_content, 0, $atts['comment_length']), |
|
81 | 81 | $atts['readmore_text'] |
82 | 82 | ); |
83 | 83 |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | * @return Give_Donor_Stats |
39 | 39 | */ |
40 | 40 | public static function get_instance() { |
41 | - if ( null === static::$instance ) { |
|
41 | + if (null === static::$instance) { |
|
42 | 42 | self::$instance = new static(); |
43 | 43 | } |
44 | 44 | |
@@ -57,13 +57,13 @@ discard block |
||
57 | 57 | * @return string |
58 | 58 | * |
59 | 59 | */ |
60 | - public static function donated( $args = array() ) { |
|
60 | + public static function donated($args = array()) { |
|
61 | 61 | global $wpdb; |
62 | - $donation_id_col = Give()->payment_meta->get_meta_type() . '_id'; |
|
62 | + $donation_id_col = Give()->payment_meta->get_meta_type().'_id'; |
|
63 | 63 | |
64 | 64 | $donated_amount = 0; |
65 | 65 | |
66 | - if ( empty( $args['donor'] ) ) { |
|
66 | + if (empty($args['donor'])) { |
|
67 | 67 | return $donated_amount; |
68 | 68 | } |
69 | 69 | |
@@ -72,25 +72,25 @@ discard block |
||
72 | 72 | $args['fields'] = 'ids'; |
73 | 73 | $args['number'] = - 1; |
74 | 74 | |
75 | - $donation_query = new Give_Payments_Query( $args ); |
|
75 | + $donation_query = new Give_Payments_Query($args); |
|
76 | 76 | $donations = $donation_query->get_payments(); |
77 | - $donation_id_str = implode( '\',\'', $donations ); |
|
77 | + $donation_id_str = implode('\',\'', $donations); |
|
78 | 78 | |
79 | 79 | $query = "SELECT {$donation_id_col} as id, meta_value as total |
80 | 80 | FROM {$wpdb->donationmeta} |
81 | 81 | WHERE meta_key='_give_payment_total' |
82 | 82 | AND {$donation_id_col} IN ('{$donation_id_str}')"; |
83 | 83 | |
84 | - $donated_amounts = $wpdb->get_results( $query, ARRAY_A ); |
|
84 | + $donated_amounts = $wpdb->get_results($query, ARRAY_A); |
|
85 | 85 | |
86 | - if ( ! empty( $donated_amounts ) ) { |
|
87 | - foreach ( $donated_amounts as $donation ) { |
|
86 | + if ( ! empty($donated_amounts)) { |
|
87 | + foreach ($donated_amounts as $donation) { |
|
88 | 88 | // Do not include anonymous donation in calculation. |
89 | - if ( give_is_anonymous_donation( $donation['id'] ) ) { |
|
89 | + if (give_is_anonymous_donation($donation['id'])) { |
|
90 | 90 | continue; |
91 | 91 | } |
92 | 92 | |
93 | - $currency_code = give_get_payment_currency_code( $donation['id'] ); |
|
93 | + $currency_code = give_get_payment_currency_code($donation['id']); |
|
94 | 94 | |
95 | 95 | /** |
96 | 96 | * Filter the donation amount |
@@ -100,13 +100,13 @@ discard block |
||
100 | 100 | */ |
101 | 101 | $formatted_amount = apply_filters( |
102 | 102 | 'give_donation_amount', |
103 | - give_format_amount( $donation['total'], array( 'currency' => $currency_code ) ), |
|
103 | + give_format_amount($donation['total'], array('currency' => $currency_code)), |
|
104 | 104 | $donation['total'], |
105 | 105 | $donation['id'], |
106 | - array( 'type' => 'stats', 'currency' => false, 'amount' => false ) |
|
106 | + array('type' => 'stats', 'currency' => false, 'amount' => false) |
|
107 | 107 | ); |
108 | 108 | |
109 | - $donated_amount += (float) give_maybe_sanitize_amount( $formatted_amount, array( 'currency' => $currency_code ) ); |
|
109 | + $donated_amount += (float) give_maybe_sanitize_amount($formatted_amount, array('currency' => $currency_code)); |
|
110 | 110 | } |
111 | 111 | } |
112 | 112 |
@@ -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 | |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | * @return Give_Donor_Wall |
51 | 51 | */ |
52 | 52 | public static function get_instance() { |
53 | - if ( null === static::$instance ) { |
|
53 | + if (null === static::$instance) { |
|
54 | 54 | self::$instance = new static(); |
55 | 55 | |
56 | 56 | self::$instance->setup_actions(); |
@@ -68,10 +68,10 @@ discard block |
||
68 | 68 | */ |
69 | 69 | public function setup_actions() { |
70 | 70 | |
71 | - add_shortcode( 'give_donor_wall', array( $this, 'render_shortcode' ) ); |
|
71 | + add_shortcode('give_donor_wall', array($this, 'render_shortcode')); |
|
72 | 72 | |
73 | - add_action( 'wp_ajax_give_get_donor_comments', array( $this, 'ajax_handler' ) ); |
|
74 | - add_action( 'wp_ajax_nopriv_give_get_donor_comments', array( $this, 'ajax_handler' ) ); |
|
73 | + add_action('wp_ajax_give_get_donor_comments', array($this, 'ajax_handler')); |
|
74 | + add_action('wp_ajax_nopriv_give_get_donor_comments', array($this, 'ajax_handler')); |
|
75 | 75 | |
76 | 76 | } |
77 | 77 | |
@@ -107,29 +107,29 @@ discard block |
||
107 | 107 | * } |
108 | 108 | * @return string|bool The markup of the form grid or false. |
109 | 109 | */ |
110 | - public function render_shortcode( $atts ) { |
|
110 | + public function render_shortcode($atts) { |
|
111 | 111 | |
112 | 112 | $give_settings = give_get_settings(); |
113 | 113 | |
114 | - $atts = $this->parse_atts( $atts ); |
|
115 | - $donor_query = $this->get_donor_query_atts( $atts ); |
|
116 | - $donors = $this->get_donors( $donor_query ); |
|
114 | + $atts = $this->parse_atts($atts); |
|
115 | + $donor_query = $this->get_donor_query_atts($atts); |
|
116 | + $donors = $this->get_donors($donor_query); |
|
117 | 117 | $html = ''; |
118 | 118 | |
119 | - if ( $donors ) { |
|
119 | + if ($donors) { |
|
120 | 120 | |
121 | 121 | ob_start(); |
122 | 122 | |
123 | - foreach ( $donors as $donor ) { |
|
123 | + foreach ($donors as $donor) { |
|
124 | 124 | // Give/templates/shortcode-donor-wall.php. |
125 | - give_get_template( 'shortcode-donor-wall', array( $donor, $give_settings, $atts ) ); |
|
125 | + give_get_template('shortcode-donor-wall', array($donor, $give_settings, $atts)); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | $html = ob_get_clean(); |
129 | 129 | |
130 | 130 | // Return only donor html. |
131 | 131 | if ( |
132 | - isset( $atts['only_donor_html'] ) |
|
132 | + isset($atts['only_donor_html']) |
|
133 | 133 | && wp_doing_ajax() |
134 | 134 | && $atts['only_donor_html'] |
135 | 135 | ) { |
@@ -142,10 +142,10 @@ discard block |
||
142 | 142 | $next_donor_query['fields'] = 'id'; |
143 | 143 | |
144 | 144 | $more_btn_html = ''; |
145 | - if ( $this->get_donors( $next_donor_query ) ) { |
|
145 | + if ($this->get_donors($next_donor_query)) { |
|
146 | 146 | $more_btn_html = sprintf( |
147 | 147 | '<button class="give-donor__load_more give-button-with-loader" data-shortcode="%1$s"><span class="give-loading-animation"></span>%2$s</button>', |
148 | - rawurlencode( http_build_query( $atts ) ), |
|
148 | + rawurlencode(http_build_query($atts)), |
|
149 | 149 | $atts['loadmore_text'] |
150 | 150 | ); |
151 | 151 | } |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | $html = $html |
154 | 154 | ? sprintf( |
155 | 155 | '<div class="give-wrap give-grid-ie-utility"><div class="give-grid give-grid--%1$s">%2$s</div>%3$s</div>', |
156 | - esc_attr( $atts['columns'] ), |
|
156 | + esc_attr($atts['columns']), |
|
157 | 157 | $html, |
158 | 158 | $more_btn_html |
159 | 159 | ) |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | * |
173 | 173 | * @return array |
174 | 174 | */ |
175 | - public function parse_atts( $atts ) { |
|
175 | + public function parse_atts($atts) { |
|
176 | 176 | $atts = shortcode_atts( |
177 | 177 | array( |
178 | 178 | 'donors_per_page' => 20, |
@@ -187,8 +187,8 @@ discard block |
||
187 | 187 | 'show_comments' => true, |
188 | 188 | 'comment_length' => 20, |
189 | 189 | 'only_comments' => false, |
190 | - 'readmore_text' => esc_html__( 'Read More', 'give' ), |
|
191 | - 'loadmore_text' => esc_html__( 'Load More', 'give' ), |
|
190 | + 'readmore_text' => esc_html__('Read More', 'give'), |
|
191 | + 'loadmore_text' => esc_html__('Load More', 'give'), |
|
192 | 192 | 'avatar_size' => 60, |
193 | 193 | 'orderby' => 'donation_count', |
194 | 194 | 'order' => 'DESC', |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | ); |
199 | 199 | |
200 | 200 | // Validate integer attributes. |
201 | - $atts['donors_per_page'] = absint( $atts['donors_per_page'] ); |
|
201 | + $atts['donors_per_page'] = absint($atts['donors_per_page']); |
|
202 | 202 | |
203 | 203 | // Validate boolean attributes. |
204 | 204 | $boolean_attributes = array( |
@@ -213,14 +213,14 @@ discard block |
||
213 | 213 | 'only_donor_html', |
214 | 214 | ); |
215 | 215 | |
216 | - foreach ( $boolean_attributes as $att ) { |
|
216 | + foreach ($boolean_attributes as $att) { |
|
217 | 217 | // Convert numeric to boolean. |
218 | 218 | // It will prevent condition check against boolean value. |
219 | - if ( is_numeric( $atts[ $att ] ) ) { |
|
220 | - $atts[ $att ] = (bool) $atts[ $att ]; |
|
219 | + if (is_numeric($atts[$att])) { |
|
220 | + $atts[$att] = (bool) $atts[$att]; |
|
221 | 221 | } |
222 | 222 | |
223 | - $atts[ $att ] = filter_var( $atts[ $att ], FILTER_VALIDATE_BOOLEAN ); |
|
223 | + $atts[$att] = filter_var($atts[$att], FILTER_VALIDATE_BOOLEAN); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | return $atts; |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | * |
237 | 237 | * @return array |
238 | 238 | */ |
239 | - public function get_donor_query_atts( $atts ) { |
|
239 | + public function get_donor_query_atts($atts) { |
|
240 | 240 | // Set default form query args. |
241 | 241 | $donor_args = array( |
242 | 242 | 'number' => $atts['donors_per_page'], |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | 'order' => $atts['order'] |
246 | 246 | ); |
247 | 247 | |
248 | - if ( give_has_upgrade_completed( 'v224_update_donor_meta_forms_id' ) ) { |
|
248 | + if (give_has_upgrade_completed('v224_update_donor_meta_forms_id')) { |
|
249 | 249 | // Hide anonymous donor. |
250 | 250 | $donor_args['meta_query'][] = array( |
251 | 251 | 'key' => '_give_anonymous_donor', |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | } |
256 | 256 | |
257 | 257 | // Hide donors with zero donation amount. |
258 | - if ( $atts['hide_empty'] ) { |
|
258 | + if ($atts['hide_empty']) { |
|
259 | 259 | $donor_args['donation_amount'] = array( |
260 | 260 | 'compare' => '>=', |
261 | 261 | 'amount' => 1, |
@@ -263,10 +263,10 @@ discard block |
||
263 | 263 | } |
264 | 264 | |
265 | 265 | // Show donor who donated to specific form. |
266 | - if ( $atts['form_id'] ) { |
|
266 | + if ($atts['form_id']) { |
|
267 | 267 | $donor_args['give_forms'] = $atts['form_id']; |
268 | 268 | |
269 | - if( give_has_upgrade_completed('v224_update_donor_meta_forms_id') ) { |
|
269 | + if (give_has_upgrade_completed('v224_update_donor_meta_forms_id')) { |
|
270 | 270 | $donor_args['meta_query']['relation'] = 'AND'; |
271 | 271 | $donor_args['meta_query'][] = array( |
272 | 272 | array( |
@@ -278,13 +278,13 @@ discard block |
||
278 | 278 | } |
279 | 279 | |
280 | 280 | // Show donor by id. |
281 | - if ( $atts['ids'] ) { |
|
281 | + if ($atts['ids']) { |
|
282 | 282 | $donor_args['donor'] = $atts['ids']; |
283 | 283 | } |
284 | 284 | |
285 | 285 | // Replace donation with purchase because donor table has that prefix in column name. |
286 | 286 | $donor_args['orderby'] = str_replace( |
287 | - array( 'donation', 'amount' ), array( |
|
287 | + array('donation', 'amount'), array( |
|
288 | 288 | 'purchase', |
289 | 289 | 'value', |
290 | 290 | ), $atts['orderby'] |
@@ -296,12 +296,12 @@ discard block |
||
296 | 296 | 'date_created' => 'DESC', |
297 | 297 | ); |
298 | 298 | |
299 | - unset( $donor_args['order'] ); |
|
299 | + unset($donor_args['order']); |
|
300 | 300 | |
301 | 301 | // Set payment query. |
302 | 302 | // @codingStandardsIgnoreStart |
303 | - if ( true === $atts['only_comments'] ) { |
|
304 | - if( ! array_key_exists( 'relation', $donor_args['meta_query'] ) ) { |
|
303 | + if (true === $atts['only_comments']) { |
|
304 | + if ( ! array_key_exists('relation', $donor_args['meta_query'])) { |
|
305 | 305 | $donor_args['meta_query']['relation'] = 'AND'; |
306 | 306 | } |
307 | 307 | |
@@ -327,8 +327,8 @@ discard block |
||
327 | 327 | * |
328 | 328 | * @return array |
329 | 329 | */ |
330 | - public function get_donors( $donor_query ) { |
|
331 | - $donor_query = new Give_Donors_Query( $donor_query ); |
|
330 | + public function get_donors($donor_query) { |
|
331 | + $donor_query = new Give_Donors_Query($donor_query); |
|
332 | 332 | $donors = $donor_query->get_donors(); |
333 | 333 | |
334 | 334 | return $donors; |
@@ -342,26 +342,26 @@ discard block |
||
342 | 342 | * @access public |
343 | 343 | */ |
344 | 344 | public function ajax_handler() { |
345 | - $shortcode_atts = wp_parse_args( give_clean( rawurldecode( $_POST['data'] ) ) ); // @codingStandardsIgnoreLine |
|
345 | + $shortcode_atts = wp_parse_args(give_clean(rawurldecode($_POST['data']))); // @codingStandardsIgnoreLine |
|
346 | 346 | |
347 | 347 | // Get next page donor comments. |
348 | 348 | $shortcode_atts['paged'] = $shortcode_atts['paged'] + 1; |
349 | 349 | $shortcode_atts['only_donor_html'] = true; |
350 | 350 | |
351 | - $donors_comment_html = $this->render_shortcode( $shortcode_atts ); |
|
351 | + $donors_comment_html = $this->render_shortcode($shortcode_atts); |
|
352 | 352 | |
353 | 353 | // Check if donor comment remaining. |
354 | - $donor_query = $this->get_donor_query_atts( $shortcode_atts ); |
|
354 | + $donor_query = $this->get_donor_query_atts($shortcode_atts); |
|
355 | 355 | $donor_query['paged'] = $donor_query['paged'] + 1; |
356 | 356 | $donor_query['fields'] = 'id'; |
357 | - $has_donors = $this->get_donors( $donor_query ) ? 1 : 0; |
|
357 | + $has_donors = $this->get_donors($donor_query) ? 1 : 0; |
|
358 | 358 | |
359 | 359 | // Remove internal shortcode param. |
360 | - unset( $shortcode_atts['only_donor_html'] ); |
|
360 | + unset($shortcode_atts['only_donor_html']); |
|
361 | 361 | |
362 | 362 | wp_send_json( |
363 | 363 | array( |
364 | - 'shortcode' => rawurlencode( http_build_query( $shortcode_atts ) ), |
|
364 | + 'shortcode' => rawurlencode(http_build_query($shortcode_atts)), |
|
365 | 365 | 'html' => $donors_comment_html, |
366 | 366 | 'remaining' => $has_donors, |
367 | 367 | ) |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | */ |
14 | 14 | |
15 | 15 | // Exit if accessed directly. |
16 | -if ( ! defined( 'ABSPATH' ) ) { |
|
16 | +if ( ! defined('ABSPATH')) { |
|
17 | 17 | exit; |
18 | 18 | } |
19 | 19 | |
@@ -25,70 +25,70 @@ discard block |
||
25 | 25 | */ |
26 | 26 | function give_do_automatic_upgrades() { |
27 | 27 | $did_upgrade = false; |
28 | - $give_version = preg_replace( '/[^0-9.].*/', '', get_option( 'give_version' ) ); |
|
28 | + $give_version = preg_replace('/[^0-9.].*/', '', get_option('give_version')); |
|
29 | 29 | |
30 | - if ( ! $give_version ) { |
|
30 | + if ( ! $give_version) { |
|
31 | 31 | // 1.0 is the first version to use this option so we must add it. |
32 | 32 | $give_version = '1.0'; |
33 | 33 | } |
34 | 34 | |
35 | - switch ( true ) { |
|
35 | + switch (true) { |
|
36 | 36 | |
37 | - case version_compare( $give_version, '1.6', '<' ): |
|
37 | + case version_compare($give_version, '1.6', '<'): |
|
38 | 38 | give_v16_upgrades(); |
39 | 39 | $did_upgrade = true; |
40 | 40 | |
41 | - case version_compare( $give_version, '1.7', '<' ): |
|
41 | + case version_compare($give_version, '1.7', '<'): |
|
42 | 42 | give_v17_upgrades(); |
43 | 43 | $did_upgrade = true; |
44 | 44 | |
45 | - case version_compare( $give_version, '1.8', '<' ): |
|
45 | + case version_compare($give_version, '1.8', '<'): |
|
46 | 46 | give_v18_upgrades(); |
47 | 47 | $did_upgrade = true; |
48 | 48 | |
49 | - case version_compare( $give_version, '1.8.7', '<' ): |
|
49 | + case version_compare($give_version, '1.8.7', '<'): |
|
50 | 50 | give_v187_upgrades(); |
51 | 51 | $did_upgrade = true; |
52 | 52 | |
53 | - case version_compare( $give_version, '1.8.8', '<' ): |
|
53 | + case version_compare($give_version, '1.8.8', '<'): |
|
54 | 54 | give_v188_upgrades(); |
55 | 55 | $did_upgrade = true; |
56 | 56 | |
57 | - case version_compare( $give_version, '1.8.9', '<' ): |
|
57 | + case version_compare($give_version, '1.8.9', '<'): |
|
58 | 58 | give_v189_upgrades(); |
59 | 59 | $did_upgrade = true; |
60 | 60 | |
61 | - case version_compare( $give_version, '1.8.12', '<' ): |
|
61 | + case version_compare($give_version, '1.8.12', '<'): |
|
62 | 62 | give_v1812_upgrades(); |
63 | 63 | $did_upgrade = true; |
64 | 64 | |
65 | - case version_compare( $give_version, '1.8.13', '<' ): |
|
65 | + case version_compare($give_version, '1.8.13', '<'): |
|
66 | 66 | give_v1813_upgrades(); |
67 | 67 | $did_upgrade = true; |
68 | 68 | |
69 | - case version_compare( $give_version, '1.8.17', '<' ): |
|
69 | + case version_compare($give_version, '1.8.17', '<'): |
|
70 | 70 | give_v1817_upgrades(); |
71 | 71 | $did_upgrade = true; |
72 | 72 | |
73 | - case version_compare( $give_version, '1.8.18', '<' ): |
|
73 | + case version_compare($give_version, '1.8.18', '<'): |
|
74 | 74 | give_v1818_upgrades(); |
75 | 75 | $did_upgrade = true; |
76 | 76 | |
77 | - case version_compare( $give_version, '2.0', '<' ): |
|
77 | + case version_compare($give_version, '2.0', '<'): |
|
78 | 78 | give_v20_upgrades(); |
79 | 79 | $did_upgrade = true; |
80 | 80 | |
81 | - case version_compare( $give_version, '2.0.1', '<' ): |
|
81 | + case version_compare($give_version, '2.0.1', '<'): |
|
82 | 82 | // Do nothing on fresh install. |
83 | - if ( ! doing_action( 'give_upgrades' ) ) { |
|
83 | + if ( ! doing_action('give_upgrades')) { |
|
84 | 84 | give_v201_create_tables(); |
85 | - Give_Updates::get_instance()->__health_background_update( Give_Updates::get_instance() ); |
|
85 | + Give_Updates::get_instance()->__health_background_update(Give_Updates::get_instance()); |
|
86 | 86 | Give_Updates::$background_updater->dispatch(); |
87 | 87 | } |
88 | 88 | |
89 | 89 | $did_upgrade = true; |
90 | 90 | |
91 | - case version_compare( $give_version, '2.0.2', '<' ): |
|
91 | + case version_compare($give_version, '2.0.2', '<'): |
|
92 | 92 | // Remove 2.0.1 update to rerun on 2.0.2 |
93 | 93 | $completed_upgrades = give_get_completed_upgrades(); |
94 | 94 | $v201_updates = array( |
@@ -98,43 +98,43 @@ discard block |
||
98 | 98 | 'v201_logs_upgrades', |
99 | 99 | ); |
100 | 100 | |
101 | - foreach ( $v201_updates as $v201_update ) { |
|
102 | - if ( in_array( $v201_update, $completed_upgrades ) ) { |
|
103 | - unset( $completed_upgrades[ array_search( $v201_update, $completed_upgrades ) ] ); |
|
101 | + foreach ($v201_updates as $v201_update) { |
|
102 | + if (in_array($v201_update, $completed_upgrades)) { |
|
103 | + unset($completed_upgrades[array_search($v201_update, $completed_upgrades)]); |
|
104 | 104 | } |
105 | 105 | } |
106 | 106 | |
107 | - update_option( 'give_completed_upgrades', $completed_upgrades, false ); |
|
107 | + update_option('give_completed_upgrades', $completed_upgrades, false); |
|
108 | 108 | |
109 | 109 | // Do nothing on fresh install. |
110 | - if ( ! doing_action( 'give_upgrades' ) ) { |
|
110 | + if ( ! doing_action('give_upgrades')) { |
|
111 | 111 | give_v201_create_tables(); |
112 | - Give_Updates::get_instance()->__health_background_update( Give_Updates::get_instance() ); |
|
112 | + Give_Updates::get_instance()->__health_background_update(Give_Updates::get_instance()); |
|
113 | 113 | Give_Updates::$background_updater->dispatch(); |
114 | 114 | } |
115 | 115 | |
116 | 116 | $did_upgrade = true; |
117 | 117 | |
118 | - case version_compare( $give_version, '2.0.3', '<' ): |
|
118 | + case version_compare($give_version, '2.0.3', '<'): |
|
119 | 119 | give_v203_upgrades(); |
120 | 120 | $did_upgrade = true; |
121 | 121 | |
122 | - case version_compare( $give_version, '2.2.0', '<' ): |
|
122 | + case version_compare($give_version, '2.2.0', '<'): |
|
123 | 123 | give_v220_upgrades(); |
124 | 124 | $did_upgrade = true; |
125 | 125 | |
126 | - case version_compare( $give_version, '2.2.1', '<' ): |
|
126 | + case version_compare($give_version, '2.2.1', '<'): |
|
127 | 127 | give_v221_upgrades(); |
128 | 128 | $did_upgrade = true; |
129 | 129 | } |
130 | 130 | |
131 | - if ( $did_upgrade ) { |
|
132 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ), false ); |
|
131 | + if ($did_upgrade) { |
|
132 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION), false); |
|
133 | 133 | } |
134 | 134 | } |
135 | 135 | |
136 | -add_action( 'admin_init', 'give_do_automatic_upgrades' ); |
|
137 | -add_action( 'give_upgrades', 'give_do_automatic_upgrades' ); |
|
136 | +add_action('admin_init', 'give_do_automatic_upgrades'); |
|
137 | +add_action('give_upgrades', 'give_do_automatic_upgrades'); |
|
138 | 138 | |
139 | 139 | /** |
140 | 140 | * Display Upgrade Notices. |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | * |
149 | 149 | * @return void |
150 | 150 | */ |
151 | -function give_show_upgrade_notices( $give_updates ) { |
|
151 | +function give_show_upgrade_notices($give_updates) { |
|
152 | 152 | // v1.3.2 Upgrades |
153 | 153 | $give_updates->register( |
154 | 154 | array( |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | 'id' => 'v20_move_metadata_into_new_table', |
302 | 302 | 'version' => '2.0.0', |
303 | 303 | 'callback' => 'give_v20_move_metadata_into_new_table_callback', |
304 | - 'depend' => array( 'v20_upgrades_payment_metadata', 'v20_upgrades_form_metadata' ), |
|
304 | + 'depend' => array('v20_upgrades_payment_metadata', 'v20_upgrades_form_metadata'), |
|
305 | 305 | ) |
306 | 306 | ); |
307 | 307 | |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | 'id' => 'v201_move_metadata_into_new_table', |
347 | 347 | 'version' => '2.0.1', |
348 | 348 | 'callback' => 'give_v201_move_metadata_into_new_table_callback', |
349 | - 'depend' => array( 'v201_upgrades_payment_metadata', 'v201_add_missing_donors' ), |
|
349 | + 'depend' => array('v201_upgrades_payment_metadata', 'v201_add_missing_donors'), |
|
350 | 350 | ) |
351 | 351 | ); |
352 | 352 | |
@@ -374,7 +374,7 @@ discard block |
||
374 | 374 | 'id' => 'v213_delete_donation_meta', |
375 | 375 | 'version' => '2.1.3', |
376 | 376 | 'callback' => 'give_v213_delete_donation_meta_callback', |
377 | - 'depends' => array( 'v201_move_metadata_into_new_table' ), |
|
377 | + 'depends' => array('v201_move_metadata_into_new_table'), |
|
378 | 378 | ) |
379 | 379 | ); |
380 | 380 | |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | ); |
408 | 408 | } |
409 | 409 | |
410 | -add_action( 'give_register_updates', 'give_show_upgrade_notices' ); |
|
410 | +add_action('give_register_updates', 'give_show_upgrade_notices'); |
|
411 | 411 | |
412 | 412 | /** |
413 | 413 | * Triggers all upgrade functions |
@@ -419,31 +419,31 @@ discard block |
||
419 | 419 | */ |
420 | 420 | function give_trigger_upgrades() { |
421 | 421 | |
422 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
422 | + if ( ! current_user_can('manage_give_settings')) { |
|
423 | 423 | wp_die( |
424 | - esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
424 | + esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array( |
|
425 | 425 | 'response' => 403, |
426 | 426 | ) |
427 | 427 | ); |
428 | 428 | } |
429 | 429 | |
430 | - $give_version = get_option( 'give_version' ); |
|
430 | + $give_version = get_option('give_version'); |
|
431 | 431 | |
432 | - if ( ! $give_version ) { |
|
432 | + if ( ! $give_version) { |
|
433 | 433 | // 1.0 is the first version to use this option so we must add it. |
434 | 434 | $give_version = '1.0'; |
435 | - add_option( 'give_version', $give_version, '', false ); |
|
435 | + add_option('give_version', $give_version, '', false); |
|
436 | 436 | } |
437 | 437 | |
438 | - update_option( 'give_version', GIVE_VERSION, false ); |
|
439 | - delete_option( 'give_doing_upgrade' ); |
|
438 | + update_option('give_version', GIVE_VERSION, false); |
|
439 | + delete_option('give_doing_upgrade'); |
|
440 | 440 | |
441 | - if ( DOING_AJAX ) { |
|
442 | - die( 'complete' ); |
|
441 | + if (DOING_AJAX) { |
|
442 | + die('complete'); |
|
443 | 443 | } // End if(). |
444 | 444 | } |
445 | 445 | |
446 | -add_action( 'wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades' ); |
|
446 | +add_action('wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades'); |
|
447 | 447 | |
448 | 448 | |
449 | 449 | /** |
@@ -461,10 +461,10 @@ discard block |
||
461 | 461 | |
462 | 462 | // UPDATE DB METAKEYS. |
463 | 463 | $sql = "UPDATE $wpdb->postmeta SET meta_key = '_give_payment_customer_id' WHERE meta_key = '_give_payment_donor_id'"; |
464 | - $query = $wpdb->query( $sql ); |
|
464 | + $query = $wpdb->query($sql); |
|
465 | 465 | |
466 | 466 | $give_updates->percentage = 100; |
467 | - give_set_upgrade_complete( 'upgrade_give_payment_customer_id' ); |
|
467 | + give_set_upgrade_complete('upgrade_give_payment_customer_id'); |
|
468 | 468 | } |
469 | 469 | |
470 | 470 | |
@@ -488,24 +488,24 @@ discard block |
||
488 | 488 | $where .= "AND ( p.post_status = 'abandoned' )"; |
489 | 489 | $where .= "AND ( m.meta_key = '_give_payment_gateway' AND m.meta_value = 'offline' )"; |
490 | 490 | |
491 | - $sql = $select . $join . $where; |
|
492 | - $found_payments = $wpdb->get_col( $sql ); |
|
491 | + $sql = $select.$join.$where; |
|
492 | + $found_payments = $wpdb->get_col($sql); |
|
493 | 493 | |
494 | - foreach ( $found_payments as $payment ) { |
|
494 | + foreach ($found_payments as $payment) { |
|
495 | 495 | |
496 | 496 | // Only change ones marked abandoned since our release last week because the admin may have marked some abandoned themselves. |
497 | - $modified_time = get_post_modified_time( 'U', false, $payment ); |
|
497 | + $modified_time = get_post_modified_time('U', false, $payment); |
|
498 | 498 | |
499 | 499 | // 1450124863 = 12/10/2015 20:42:25. |
500 | - if ( $modified_time >= 1450124863 ) { |
|
500 | + if ($modified_time >= 1450124863) { |
|
501 | 501 | |
502 | - give_update_payment_status( $payment, 'pending' ); |
|
502 | + give_update_payment_status($payment, 'pending'); |
|
503 | 503 | |
504 | 504 | } |
505 | 505 | } |
506 | 506 | |
507 | 507 | $give_updates->percentage = 100; |
508 | - give_set_upgrade_complete( 'upgrade_give_offline_status' ); |
|
508 | + give_set_upgrade_complete('upgrade_give_offline_status'); |
|
509 | 509 | } |
510 | 510 | |
511 | 511 | |
@@ -518,17 +518,17 @@ discard block |
||
518 | 518 | */ |
519 | 519 | function give_v152_cleanup_users() { |
520 | 520 | |
521 | - $give_version = get_option( 'give_version' ); |
|
521 | + $give_version = get_option('give_version'); |
|
522 | 522 | |
523 | - if ( ! $give_version ) { |
|
523 | + if ( ! $give_version) { |
|
524 | 524 | // 1.0 is the first version to use this option so we must add it. |
525 | 525 | $give_version = '1.0'; |
526 | 526 | } |
527 | 527 | |
528 | - $give_version = preg_replace( '/[^0-9.].*/', '', $give_version ); |
|
528 | + $give_version = preg_replace('/[^0-9.].*/', '', $give_version); |
|
529 | 529 | |
530 | 530 | // v1.5.2 Upgrades |
531 | - if ( version_compare( $give_version, '1.5.2', '<' ) || ! give_has_upgrade_completed( 'upgrade_give_user_caps_cleanup' ) ) { |
|
531 | + if (version_compare($give_version, '1.5.2', '<') || ! give_has_upgrade_completed('upgrade_give_user_caps_cleanup')) { |
|
532 | 532 | |
533 | 533 | // Delete all caps with "ss". |
534 | 534 | // Also delete all unused "campaign" roles. |
@@ -575,9 +575,9 @@ discard block |
||
575 | 575 | ); |
576 | 576 | |
577 | 577 | global $wp_roles; |
578 | - foreach ( $delete_caps as $cap ) { |
|
579 | - foreach ( array_keys( $wp_roles->roles ) as $role ) { |
|
580 | - $wp_roles->remove_cap( $role, $cap ); |
|
578 | + foreach ($delete_caps as $cap) { |
|
579 | + foreach (array_keys($wp_roles->roles) as $role) { |
|
580 | + $wp_roles->remove_cap($role, $cap); |
|
581 | 581 | } |
582 | 582 | } |
583 | 583 | |
@@ -587,15 +587,15 @@ discard block |
||
587 | 587 | $roles->add_caps(); |
588 | 588 | |
589 | 589 | // The Update Ran. |
590 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ), false ); |
|
591 | - give_set_upgrade_complete( 'upgrade_give_user_caps_cleanup' ); |
|
592 | - delete_option( 'give_doing_upgrade' ); |
|
590 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION), false); |
|
591 | + give_set_upgrade_complete('upgrade_give_user_caps_cleanup'); |
|
592 | + delete_option('give_doing_upgrade'); |
|
593 | 593 | |
594 | 594 | }// End if(). |
595 | 595 | |
596 | 596 | } |
597 | 597 | |
598 | -add_action( 'admin_init', 'give_v152_cleanup_users' ); |
|
598 | +add_action('admin_init', 'give_v152_cleanup_users'); |
|
599 | 599 | |
600 | 600 | /** |
601 | 601 | * 1.6 Upgrade routine to create the customer meta table. |
@@ -638,53 +638,53 @@ discard block |
||
638 | 638 | |
639 | 639 | // Get addons license key. |
640 | 640 | $addons = array(); |
641 | - foreach ( $give_options as $key => $value ) { |
|
642 | - if ( false !== strpos( $key, '_license_key' ) ) { |
|
643 | - $addons[ $key ] = $value; |
|
641 | + foreach ($give_options as $key => $value) { |
|
642 | + if (false !== strpos($key, '_license_key')) { |
|
643 | + $addons[$key] = $value; |
|
644 | 644 | } |
645 | 645 | } |
646 | 646 | |
647 | 647 | // Bailout: We do not have any addon license data to upgrade. |
648 | - if ( empty( $addons ) ) { |
|
648 | + if (empty($addons)) { |
|
649 | 649 | return false; |
650 | 650 | } |
651 | 651 | |
652 | - foreach ( $addons as $key => $addon_license ) { |
|
652 | + foreach ($addons as $key => $addon_license) { |
|
653 | 653 | |
654 | 654 | // Get addon shortname. |
655 | - $shortname = str_replace( '_license_key', '', $key ); |
|
655 | + $shortname = str_replace('_license_key', '', $key); |
|
656 | 656 | |
657 | 657 | // Addon license option name. |
658 | - $addon_license_option_name = $shortname . '_license_active'; |
|
658 | + $addon_license_option_name = $shortname.'_license_active'; |
|
659 | 659 | |
660 | 660 | // bailout if license is empty. |
661 | - if ( empty( $addon_license ) ) { |
|
662 | - delete_option( $addon_license_option_name ); |
|
661 | + if (empty($addon_license)) { |
|
662 | + delete_option($addon_license_option_name); |
|
663 | 663 | continue; |
664 | 664 | } |
665 | 665 | |
666 | 666 | // Get addon name. |
667 | 667 | $addon_name = array(); |
668 | - $addon_name_parts = explode( '_', str_replace( 'give_', '', $shortname ) ); |
|
669 | - foreach ( $addon_name_parts as $name_part ) { |
|
668 | + $addon_name_parts = explode('_', str_replace('give_', '', $shortname)); |
|
669 | + foreach ($addon_name_parts as $name_part) { |
|
670 | 670 | |
671 | 671 | // Fix addon name |
672 | - switch ( $name_part ) { |
|
672 | + switch ($name_part) { |
|
673 | 673 | case 'authorizenet': |
674 | 674 | $name_part = 'authorize.net'; |
675 | 675 | break; |
676 | 676 | } |
677 | 677 | |
678 | - $addon_name[] = ucfirst( $name_part ); |
|
678 | + $addon_name[] = ucfirst($name_part); |
|
679 | 679 | } |
680 | 680 | |
681 | - $addon_name = implode( ' ', $addon_name ); |
|
681 | + $addon_name = implode(' ', $addon_name); |
|
682 | 682 | |
683 | 683 | // Data to send to the API. |
684 | 684 | $api_params = array( |
685 | 685 | 'edd_action' => 'activate_license', // never change from "edd_" to "give_"! |
686 | 686 | 'license' => $addon_license, |
687 | - 'item_name' => urlencode( $addon_name ), |
|
687 | + 'item_name' => urlencode($addon_name), |
|
688 | 688 | 'url' => home_url(), |
689 | 689 | ); |
690 | 690 | |
@@ -699,17 +699,17 @@ discard block |
||
699 | 699 | ); |
700 | 700 | |
701 | 701 | // Make sure there are no errors. |
702 | - if ( is_wp_error( $response ) ) { |
|
703 | - delete_option( $addon_license_option_name ); |
|
702 | + if (is_wp_error($response)) { |
|
703 | + delete_option($addon_license_option_name); |
|
704 | 704 | continue; |
705 | 705 | } |
706 | 706 | |
707 | 707 | // Tell WordPress to look for updates. |
708 | - set_site_transient( 'update_plugins', null ); |
|
708 | + set_site_transient('update_plugins', null); |
|
709 | 709 | |
710 | 710 | // Decode license data. |
711 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
712 | - update_option( $addon_license_option_name, $license_data, false ); |
|
711 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
712 | + update_option($addon_license_option_name, $license_data, false); |
|
713 | 713 | }// End foreach(). |
714 | 714 | } |
715 | 715 | |
@@ -739,9 +739,9 @@ discard block |
||
739 | 739 | ); |
740 | 740 | |
741 | 741 | global $wp_roles; |
742 | - foreach ( $delete_caps as $cap ) { |
|
743 | - foreach ( array_keys( $wp_roles->roles ) as $role ) { |
|
744 | - $wp_roles->remove_cap( $role, $cap ); |
|
742 | + foreach ($delete_caps as $cap) { |
|
743 | + foreach (array_keys($wp_roles->roles) as $role) { |
|
744 | + $wp_roles->remove_cap($role, $cap); |
|
745 | 745 | } |
746 | 746 | } |
747 | 747 | |
@@ -775,7 +775,7 @@ discard block |
||
775 | 775 | function give_v18_upgrades_core_setting() { |
776 | 776 | // Core settings which changes from checkbox to radio. |
777 | 777 | $core_setting_names = array_merge( |
778 | - array_keys( give_v18_renamed_core_settings() ), |
|
778 | + array_keys(give_v18_renamed_core_settings()), |
|
779 | 779 | array( |
780 | 780 | 'uninstall_on_delete', |
781 | 781 | 'scripts_footer', |
@@ -787,48 +787,48 @@ discard block |
||
787 | 787 | ); |
788 | 788 | |
789 | 789 | // Bailout: If not any setting define. |
790 | - if ( $give_settings = get_option( 'give_settings' ) ) { |
|
790 | + if ($give_settings = get_option('give_settings')) { |
|
791 | 791 | |
792 | 792 | $setting_changed = false; |
793 | 793 | |
794 | 794 | // Loop: check each setting field. |
795 | - foreach ( $core_setting_names as $setting_name ) { |
|
795 | + foreach ($core_setting_names as $setting_name) { |
|
796 | 796 | // New setting name. |
797 | - $new_setting_name = preg_replace( '/^(enable_|disable_)/', '', $setting_name ); |
|
797 | + $new_setting_name = preg_replace('/^(enable_|disable_)/', '', $setting_name); |
|
798 | 798 | |
799 | 799 | // Continue: If setting already set. |
800 | 800 | if ( |
801 | - array_key_exists( $new_setting_name, $give_settings ) |
|
802 | - && in_array( $give_settings[ $new_setting_name ], array( 'enabled', 'disabled' ) ) |
|
801 | + array_key_exists($new_setting_name, $give_settings) |
|
802 | + && in_array($give_settings[$new_setting_name], array('enabled', 'disabled')) |
|
803 | 803 | ) { |
804 | 804 | continue; |
805 | 805 | } |
806 | 806 | |
807 | 807 | // Set checkbox value to radio value. |
808 | - $give_settings[ $setting_name ] = ( ! empty( $give_settings[ $setting_name ] ) && 'on' === $give_settings[ $setting_name ] ? 'enabled' : 'disabled' ); |
|
808 | + $give_settings[$setting_name] = ( ! empty($give_settings[$setting_name]) && 'on' === $give_settings[$setting_name] ? 'enabled' : 'disabled'); |
|
809 | 809 | |
810 | 810 | // @see https://github.com/WordImpress/Give/issues/1063. |
811 | - if ( false !== strpos( $setting_name, 'disable_' ) ) { |
|
811 | + if (false !== strpos($setting_name, 'disable_')) { |
|
812 | 812 | |
813 | - $give_settings[ $new_setting_name ] = ( give_is_setting_enabled( $give_settings[ $setting_name ] ) ? 'disabled' : 'enabled' ); |
|
814 | - } elseif ( false !== strpos( $setting_name, 'enable_' ) ) { |
|
813 | + $give_settings[$new_setting_name] = (give_is_setting_enabled($give_settings[$setting_name]) ? 'disabled' : 'enabled'); |
|
814 | + } elseif (false !== strpos($setting_name, 'enable_')) { |
|
815 | 815 | |
816 | - $give_settings[ $new_setting_name ] = ( give_is_setting_enabled( $give_settings[ $setting_name ] ) ? 'enabled' : 'disabled' ); |
|
816 | + $give_settings[$new_setting_name] = (give_is_setting_enabled($give_settings[$setting_name]) ? 'enabled' : 'disabled'); |
|
817 | 817 | } |
818 | 818 | |
819 | 819 | // Tell bot to update core setting to db. |
820 | - if ( ! $setting_changed ) { |
|
820 | + if ( ! $setting_changed) { |
|
821 | 821 | $setting_changed = true; |
822 | 822 | } |
823 | 823 | } |
824 | 824 | |
825 | 825 | // Update setting only if they changed. |
826 | - if ( $setting_changed ) { |
|
827 | - update_option( 'give_settings', $give_settings, false ); |
|
826 | + if ($setting_changed) { |
|
827 | + update_option('give_settings', $give_settings, false); |
|
828 | 828 | } |
829 | 829 | }// End if(). |
830 | 830 | |
831 | - give_set_upgrade_complete( 'v18_upgrades_core_setting' ); |
|
831 | + give_set_upgrade_complete('v18_upgrades_core_setting'); |
|
832 | 832 | } |
833 | 833 | |
834 | 834 | /** |
@@ -852,41 +852,41 @@ discard block |
||
852 | 852 | ) |
853 | 853 | ); |
854 | 854 | |
855 | - if ( $forms->have_posts() ) { |
|
856 | - $give_updates->set_percentage( $forms->found_posts, ( $give_updates->step * 20 ) ); |
|
855 | + if ($forms->have_posts()) { |
|
856 | + $give_updates->set_percentage($forms->found_posts, ($give_updates->step * 20)); |
|
857 | 857 | |
858 | - while ( $forms->have_posts() ) { |
|
858 | + while ($forms->have_posts()) { |
|
859 | 859 | $forms->the_post(); |
860 | 860 | |
861 | 861 | // Form content. |
862 | 862 | // Note in version 1.8 display content setting split into display content and content placement setting. |
863 | 863 | // You can delete _give_content_option in future. |
864 | - $show_content = give_get_meta( get_the_ID(), '_give_content_option', true ); |
|
865 | - if ( $show_content && ! give_get_meta( get_the_ID(), '_give_display_content', true ) ) { |
|
866 | - $field_value = ( 'none' !== $show_content ? 'enabled' : 'disabled' ); |
|
867 | - give_update_meta( get_the_ID(), '_give_display_content', $field_value ); |
|
864 | + $show_content = give_get_meta(get_the_ID(), '_give_content_option', true); |
|
865 | + if ($show_content && ! give_get_meta(get_the_ID(), '_give_display_content', true)) { |
|
866 | + $field_value = ('none' !== $show_content ? 'enabled' : 'disabled'); |
|
867 | + give_update_meta(get_the_ID(), '_give_display_content', $field_value); |
|
868 | 868 | |
869 | - $field_value = ( 'none' !== $show_content ? $show_content : 'give_pre_form' ); |
|
870 | - give_update_meta( get_the_ID(), '_give_content_placement', $field_value ); |
|
869 | + $field_value = ('none' !== $show_content ? $show_content : 'give_pre_form'); |
|
870 | + give_update_meta(get_the_ID(), '_give_content_placement', $field_value); |
|
871 | 871 | } |
872 | 872 | |
873 | 873 | // "Disable" Guest Donation. Checkbox. |
874 | 874 | // See: https://github.com/WordImpress/Give/issues/1470. |
875 | - $guest_donation = give_get_meta( get_the_ID(), '_give_logged_in_only', true ); |
|
876 | - $guest_donation_newval = ( in_array( $guest_donation, array( 'yes', 'on' ) ) ? 'disabled' : 'enabled' ); |
|
877 | - give_update_meta( get_the_ID(), '_give_logged_in_only', $guest_donation_newval ); |
|
875 | + $guest_donation = give_get_meta(get_the_ID(), '_give_logged_in_only', true); |
|
876 | + $guest_donation_newval = (in_array($guest_donation, array('yes', 'on')) ? 'disabled' : 'enabled'); |
|
877 | + give_update_meta(get_the_ID(), '_give_logged_in_only', $guest_donation_newval); |
|
878 | 878 | |
879 | 879 | // Offline Donations. |
880 | 880 | // See: https://github.com/WordImpress/Give/issues/1579. |
881 | - $offline_donation = give_get_meta( get_the_ID(), '_give_customize_offline_donations', true ); |
|
882 | - if ( 'no' === $offline_donation ) { |
|
881 | + $offline_donation = give_get_meta(get_the_ID(), '_give_customize_offline_donations', true); |
|
882 | + if ('no' === $offline_donation) { |
|
883 | 883 | $offline_donation_newval = 'global'; |
884 | - } elseif ( 'yes' === $offline_donation ) { |
|
884 | + } elseif ('yes' === $offline_donation) { |
|
885 | 885 | $offline_donation_newval = 'enabled'; |
886 | 886 | } else { |
887 | 887 | $offline_donation_newval = 'disabled'; |
888 | 888 | } |
889 | - give_update_meta( get_the_ID(), '_give_customize_offline_donations', $offline_donation_newval ); |
|
889 | + give_update_meta(get_the_ID(), '_give_customize_offline_donations', $offline_donation_newval); |
|
890 | 890 | |
891 | 891 | // Convert yes/no setting field to enabled/disabled. |
892 | 892 | $form_radio_settings = array( |
@@ -906,15 +906,15 @@ discard block |
||
906 | 906 | '_give_offline_donation_enable_billing_fields_single', |
907 | 907 | ); |
908 | 908 | |
909 | - foreach ( $form_radio_settings as $meta_key ) { |
|
909 | + foreach ($form_radio_settings as $meta_key) { |
|
910 | 910 | // Get value. |
911 | - $field_value = give_get_meta( get_the_ID(), $meta_key, true ); |
|
911 | + $field_value = give_get_meta(get_the_ID(), $meta_key, true); |
|
912 | 912 | |
913 | 913 | // Convert meta value only if it is in yes/no/none. |
914 | - if ( in_array( $field_value, array( 'yes', 'on', 'no', 'none' ) ) ) { |
|
914 | + if (in_array($field_value, array('yes', 'on', 'no', 'none'))) { |
|
915 | 915 | |
916 | - $field_value = ( in_array( $field_value, array( 'yes', 'on' ) ) ? 'enabled' : 'disabled' ); |
|
917 | - give_update_meta( get_the_ID(), $meta_key, $field_value ); |
|
916 | + $field_value = (in_array($field_value, array('yes', 'on')) ? 'enabled' : 'disabled'); |
|
917 | + give_update_meta(get_the_ID(), $meta_key, $field_value); |
|
918 | 918 | } |
919 | 919 | } |
920 | 920 | }// End while(). |
@@ -923,7 +923,7 @@ discard block |
||
923 | 923 | |
924 | 924 | } else { |
925 | 925 | // No more forms found, finish up. |
926 | - give_set_upgrade_complete( 'v18_upgrades_form_metadata' ); |
|
926 | + give_set_upgrade_complete('v18_upgrades_form_metadata'); |
|
927 | 927 | } |
928 | 928 | } |
929 | 929 | |
@@ -990,7 +990,7 @@ discard block |
||
990 | 990 | '%_transient_give_stats_%', |
991 | 991 | 'give_cache%', |
992 | 992 | '%_transient_give_add_ons_feed%', |
993 | - '%_transient__give_ajax_works' . |
|
993 | + '%_transient__give_ajax_works'. |
|
994 | 994 | '%_transient_give_total_api_keys%', |
995 | 995 | '%_transient_give_i18n_give_promo_hide%', |
996 | 996 | '%_transient_give_contributors%', |
@@ -1017,24 +1017,24 @@ discard block |
||
1017 | 1017 | ARRAY_A |
1018 | 1018 | ); |
1019 | 1019 | |
1020 | - if ( ! empty( $user_apikey_options ) ) { |
|
1021 | - foreach ( $user_apikey_options as $user ) { |
|
1022 | - $cached_options[] = '_transient_' . md5( 'give_api_user_' . $user['meta_key'] ); |
|
1023 | - $cached_options[] = '_transient_' . md5( 'give_api_user_public_key' . $user['user_id'] ); |
|
1024 | - $cached_options[] = '_transient_' . md5( 'give_api_user_secret_key' . $user['user_id'] ); |
|
1020 | + if ( ! empty($user_apikey_options)) { |
|
1021 | + foreach ($user_apikey_options as $user) { |
|
1022 | + $cached_options[] = '_transient_'.md5('give_api_user_'.$user['meta_key']); |
|
1023 | + $cached_options[] = '_transient_'.md5('give_api_user_public_key'.$user['user_id']); |
|
1024 | + $cached_options[] = '_transient_'.md5('give_api_user_secret_key'.$user['user_id']); |
|
1025 | 1025 | } |
1026 | 1026 | } |
1027 | 1027 | |
1028 | - if ( ! empty( $cached_options ) ) { |
|
1029 | - foreach ( $cached_options as $option ) { |
|
1030 | - switch ( true ) { |
|
1031 | - case ( false !== strpos( $option, 'transient' ) ): |
|
1032 | - $option = str_replace( '_transient_', '', $option ); |
|
1033 | - delete_transient( $option ); |
|
1028 | + if ( ! empty($cached_options)) { |
|
1029 | + foreach ($cached_options as $option) { |
|
1030 | + switch (true) { |
|
1031 | + case (false !== strpos($option, 'transient')): |
|
1032 | + $option = str_replace('_transient_', '', $option); |
|
1033 | + delete_transient($option); |
|
1034 | 1034 | break; |
1035 | 1035 | |
1036 | 1036 | default: |
1037 | - delete_option( $option ); |
|
1037 | + delete_option($option); |
|
1038 | 1038 | } |
1039 | 1039 | } |
1040 | 1040 | } |
@@ -1052,7 +1052,7 @@ discard block |
||
1052 | 1052 | global $wp_roles; |
1053 | 1053 | |
1054 | 1054 | // Get the role object. |
1055 | - $give_worker = get_role( 'give_worker' ); |
|
1055 | + $give_worker = get_role('give_worker'); |
|
1056 | 1056 | |
1057 | 1057 | // A list of capabilities to add for give workers. |
1058 | 1058 | $caps_to_add = array( |
@@ -1060,9 +1060,9 @@ discard block |
||
1060 | 1060 | 'edit_pages', |
1061 | 1061 | ); |
1062 | 1062 | |
1063 | - foreach ( $caps_to_add as $cap ) { |
|
1063 | + foreach ($caps_to_add as $cap) { |
|
1064 | 1064 | // Add the capability. |
1065 | - $give_worker->add_cap( $cap ); |
|
1065 | + $give_worker->add_cap($cap); |
|
1066 | 1066 | } |
1067 | 1067 | |
1068 | 1068 | } |
@@ -1089,10 +1089,10 @@ discard block |
||
1089 | 1089 | ) |
1090 | 1090 | ); |
1091 | 1091 | |
1092 | - if ( $donation_forms->have_posts() ) { |
|
1093 | - $give_updates->set_percentage( $donation_forms->found_posts, ( $give_updates->step * 20 ) ); |
|
1092 | + if ($donation_forms->have_posts()) { |
|
1093 | + $give_updates->set_percentage($donation_forms->found_posts, ($give_updates->step * 20)); |
|
1094 | 1094 | |
1095 | - while ( $donation_forms->have_posts() ) { |
|
1095 | + while ($donation_forms->have_posts()) { |
|
1096 | 1096 | $donation_forms->the_post(); |
1097 | 1097 | $form_id = get_the_ID(); |
1098 | 1098 | |
@@ -1100,41 +1100,41 @@ discard block |
||
1100 | 1100 | update_post_meta( |
1101 | 1101 | $form_id, |
1102 | 1102 | '_give_set_price', |
1103 | - give_sanitize_amount( get_post_meta( $form_id, '_give_set_price', true ) ) |
|
1103 | + give_sanitize_amount(get_post_meta($form_id, '_give_set_price', true)) |
|
1104 | 1104 | ); |
1105 | 1105 | |
1106 | 1106 | // Remove formatting from _give_custom_amount_minimum. |
1107 | 1107 | update_post_meta( |
1108 | 1108 | $form_id, |
1109 | 1109 | '_give_custom_amount_minimum', |
1110 | - give_sanitize_amount( get_post_meta( $form_id, '_give_custom_amount_minimum', true ) ) |
|
1110 | + give_sanitize_amount(get_post_meta($form_id, '_give_custom_amount_minimum', true)) |
|
1111 | 1111 | ); |
1112 | 1112 | |
1113 | 1113 | // Bailout. |
1114 | - if ( 'set' === get_post_meta( $form_id, '_give_price_option', true ) ) { |
|
1114 | + if ('set' === get_post_meta($form_id, '_give_price_option', true)) { |
|
1115 | 1115 | continue; |
1116 | 1116 | } |
1117 | 1117 | |
1118 | - $donation_levels = get_post_meta( $form_id, '_give_donation_levels', true ); |
|
1118 | + $donation_levels = get_post_meta($form_id, '_give_donation_levels', true); |
|
1119 | 1119 | |
1120 | - if ( ! empty( $donation_levels ) ) { |
|
1120 | + if ( ! empty($donation_levels)) { |
|
1121 | 1121 | |
1122 | - foreach ( $donation_levels as $index => $donation_level ) { |
|
1123 | - if ( isset( $donation_level['_give_amount'] ) ) { |
|
1124 | - $donation_levels[ $index ]['_give_amount'] = give_sanitize_amount( $donation_level['_give_amount'] ); |
|
1122 | + foreach ($donation_levels as $index => $donation_level) { |
|
1123 | + if (isset($donation_level['_give_amount'])) { |
|
1124 | + $donation_levels[$index]['_give_amount'] = give_sanitize_amount($donation_level['_give_amount']); |
|
1125 | 1125 | } |
1126 | 1126 | } |
1127 | 1127 | |
1128 | - update_post_meta( $form_id, '_give_donation_levels', $donation_levels ); |
|
1128 | + update_post_meta($form_id, '_give_donation_levels', $donation_levels); |
|
1129 | 1129 | |
1130 | - $donation_levels_amounts = wp_list_pluck( $donation_levels, '_give_amount' ); |
|
1130 | + $donation_levels_amounts = wp_list_pluck($donation_levels, '_give_amount'); |
|
1131 | 1131 | |
1132 | - $min_amount = min( $donation_levels_amounts ); |
|
1133 | - $max_amount = max( $donation_levels_amounts ); |
|
1132 | + $min_amount = min($donation_levels_amounts); |
|
1133 | + $max_amount = max($donation_levels_amounts); |
|
1134 | 1134 | |
1135 | 1135 | // Set Minimum and Maximum amount for Multi Level Donation Forms |
1136 | - give_update_meta( $form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount( $min_amount ) : 0 ); |
|
1137 | - give_update_meta( $form_id, '_give_levels_maximum_amount', $max_amount ? give_sanitize_amount( $max_amount ) : 0 ); |
|
1136 | + give_update_meta($form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount($min_amount) : 0); |
|
1137 | + give_update_meta($form_id, '_give_levels_maximum_amount', $max_amount ? give_sanitize_amount($max_amount) : 0); |
|
1138 | 1138 | } |
1139 | 1139 | } |
1140 | 1140 | |
@@ -1142,7 +1142,7 @@ discard block |
||
1142 | 1142 | wp_reset_postdata(); |
1143 | 1143 | } else { |
1144 | 1144 | // The Update Ran. |
1145 | - give_set_upgrade_complete( 'v189_upgrades_levels_post_meta' ); |
|
1145 | + give_set_upgrade_complete('v189_upgrades_levels_post_meta'); |
|
1146 | 1146 | } |
1147 | 1147 | |
1148 | 1148 | } |
@@ -1192,7 +1192,7 @@ discard block |
||
1192 | 1192 | */ |
1193 | 1193 | function give_v20_upgrades() { |
1194 | 1194 | // Update cache setting. |
1195 | - give_update_option( 'cache', 'enabled' ); |
|
1195 | + give_update_option('cache', 'enabled'); |
|
1196 | 1196 | |
1197 | 1197 | // Upgrade email settings. |
1198 | 1198 | give_v20_upgrades_email_setting(); |
@@ -1211,7 +1211,7 @@ discard block |
||
1211 | 1211 | $all_setting = give_get_settings(); |
1212 | 1212 | |
1213 | 1213 | // Bailout on fresh install. |
1214 | - if ( empty( $all_setting ) ) { |
|
1214 | + if (empty($all_setting)) { |
|
1215 | 1215 | return; |
1216 | 1216 | } |
1217 | 1217 | |
@@ -1230,19 +1230,19 @@ discard block |
||
1230 | 1230 | 'admin_notices' => 'new-donation_notification', |
1231 | 1231 | ); |
1232 | 1232 | |
1233 | - foreach ( $settings as $old_setting => $new_setting ) { |
|
1233 | + foreach ($settings as $old_setting => $new_setting) { |
|
1234 | 1234 | // Do not update already modified |
1235 | - if ( ! is_array( $new_setting ) ) { |
|
1236 | - if ( array_key_exists( $new_setting, $all_setting ) || ! array_key_exists( $old_setting, $all_setting ) ) { |
|
1235 | + if ( ! is_array($new_setting)) { |
|
1236 | + if (array_key_exists($new_setting, $all_setting) || ! array_key_exists($old_setting, $all_setting)) { |
|
1237 | 1237 | continue; |
1238 | 1238 | } |
1239 | 1239 | } |
1240 | 1240 | |
1241 | - switch ( $old_setting ) { |
|
1241 | + switch ($old_setting) { |
|
1242 | 1242 | case 'admin_notices': |
1243 | - $notification_status = give_get_option( $old_setting, 'enabled' ); |
|
1243 | + $notification_status = give_get_option($old_setting, 'enabled'); |
|
1244 | 1244 | |
1245 | - give_update_option( $new_setting, $notification_status ); |
|
1245 | + give_update_option($new_setting, $notification_status); |
|
1246 | 1246 | |
1247 | 1247 | // @todo: Delete this option later ( version > 2.0 ), We need this for per form email addon. |
1248 | 1248 | // give_delete_option( $old_setting ); |
@@ -1252,19 +1252,19 @@ discard block |
||
1252 | 1252 | case 'admin_notice_emails': |
1253 | 1253 | $recipients = give_get_admin_notice_emails(); |
1254 | 1254 | |
1255 | - foreach ( $new_setting as $setting ) { |
|
1255 | + foreach ($new_setting as $setting) { |
|
1256 | 1256 | // bailout if setting already exist. |
1257 | - if ( array_key_exists( $setting, $all_setting ) ) { |
|
1257 | + if (array_key_exists($setting, $all_setting)) { |
|
1258 | 1258 | continue; |
1259 | 1259 | } |
1260 | 1260 | |
1261 | - give_update_option( $setting, $recipients ); |
|
1261 | + give_update_option($setting, $recipients); |
|
1262 | 1262 | } |
1263 | 1263 | break; |
1264 | 1264 | |
1265 | 1265 | default: |
1266 | - give_update_option( $new_setting, give_get_option( $old_setting ) ); |
|
1267 | - give_delete_option( $old_setting ); |
|
1266 | + give_update_option($new_setting, give_get_option($old_setting)); |
|
1267 | + give_delete_option($old_setting); |
|
1268 | 1268 | } |
1269 | 1269 | } |
1270 | 1270 | } |
@@ -1281,22 +1281,22 @@ discard block |
||
1281 | 1281 | $give_settings = give_get_settings(); |
1282 | 1282 | $give_setting_updated = false; |
1283 | 1283 | |
1284 | - if ( $give_settings['thousands_separator'] === $give_settings['decimal_separator'] ) { |
|
1284 | + if ($give_settings['thousands_separator'] === $give_settings['decimal_separator']) { |
|
1285 | 1285 | $give_settings['number_decimals'] = 0; |
1286 | 1286 | $give_settings['decimal_separator'] = ''; |
1287 | 1287 | $give_setting_updated = true; |
1288 | 1288 | |
1289 | - } elseif ( empty( $give_settings['decimal_separator'] ) ) { |
|
1289 | + } elseif (empty($give_settings['decimal_separator'])) { |
|
1290 | 1290 | $give_settings['number_decimals'] = 0; |
1291 | 1291 | $give_setting_updated = true; |
1292 | 1292 | |
1293 | - } elseif ( 6 < absint( $give_settings['number_decimals'] ) ) { |
|
1293 | + } elseif (6 < absint($give_settings['number_decimals'])) { |
|
1294 | 1294 | $give_settings['number_decimals'] = 5; |
1295 | 1295 | $give_setting_updated = true; |
1296 | 1296 | } |
1297 | 1297 | |
1298 | - if ( $give_setting_updated ) { |
|
1299 | - update_option( 'give_settings', $give_settings, false ); |
|
1298 | + if ($give_setting_updated) { |
|
1299 | + update_option('give_settings', $give_settings, false); |
|
1300 | 1300 | } |
1301 | 1301 | } |
1302 | 1302 | |
@@ -1320,73 +1320,73 @@ discard block |
||
1320 | 1320 | 'paged' => $give_updates->step, |
1321 | 1321 | 'status' => 'any', |
1322 | 1322 | 'order' => 'ASC', |
1323 | - 'post_type' => array( 'give_forms', 'give_payment' ), |
|
1323 | + 'post_type' => array('give_forms', 'give_payment'), |
|
1324 | 1324 | 'posts_per_page' => 20, |
1325 | 1325 | ) |
1326 | 1326 | ); |
1327 | - if ( $donation_forms->have_posts() ) { |
|
1328 | - $give_updates->set_percentage( $donation_forms->found_posts, ( $give_updates->step * 20 ) ); |
|
1327 | + if ($donation_forms->have_posts()) { |
|
1328 | + $give_updates->set_percentage($donation_forms->found_posts, ($give_updates->step * 20)); |
|
1329 | 1329 | |
1330 | - while ( $donation_forms->have_posts() ) { |
|
1330 | + while ($donation_forms->have_posts()) { |
|
1331 | 1331 | $donation_forms->the_post(); |
1332 | 1332 | global $post; |
1333 | 1333 | |
1334 | - $meta = get_post_meta( $post->ID ); |
|
1334 | + $meta = get_post_meta($post->ID); |
|
1335 | 1335 | |
1336 | - switch ( $post->post_type ) { |
|
1336 | + switch ($post->post_type) { |
|
1337 | 1337 | case 'give_forms': |
1338 | 1338 | // _give_set_price. |
1339 | - if ( ! empty( $meta['_give_set_price'][0] ) ) { |
|
1340 | - update_post_meta( $post->ID, '_give_set_price', give_sanitize_amount_for_db( $meta['_give_set_price'][0] ) ); |
|
1339 | + if ( ! empty($meta['_give_set_price'][0])) { |
|
1340 | + update_post_meta($post->ID, '_give_set_price', give_sanitize_amount_for_db($meta['_give_set_price'][0])); |
|
1341 | 1341 | } |
1342 | 1342 | |
1343 | 1343 | // _give_custom_amount_minimum. |
1344 | - if ( ! empty( $meta['_give_custom_amount_minimum'][0] ) ) { |
|
1345 | - update_post_meta( $post->ID, '_give_custom_amount_minimum', give_sanitize_amount_for_db( $meta['_give_custom_amount_minimum'][0] ) ); |
|
1344 | + if ( ! empty($meta['_give_custom_amount_minimum'][0])) { |
|
1345 | + update_post_meta($post->ID, '_give_custom_amount_minimum', give_sanitize_amount_for_db($meta['_give_custom_amount_minimum'][0])); |
|
1346 | 1346 | } |
1347 | 1347 | |
1348 | 1348 | // _give_levels_minimum_amount. |
1349 | - if ( ! empty( $meta['_give_levels_minimum_amount'][0] ) ) { |
|
1350 | - update_post_meta( $post->ID, '_give_levels_minimum_amount', give_sanitize_amount_for_db( $meta['_give_levels_minimum_amount'][0] ) ); |
|
1349 | + if ( ! empty($meta['_give_levels_minimum_amount'][0])) { |
|
1350 | + update_post_meta($post->ID, '_give_levels_minimum_amount', give_sanitize_amount_for_db($meta['_give_levels_minimum_amount'][0])); |
|
1351 | 1351 | } |
1352 | 1352 | |
1353 | 1353 | // _give_levels_maximum_amount. |
1354 | - if ( ! empty( $meta['_give_levels_maximum_amount'][0] ) ) { |
|
1355 | - update_post_meta( $post->ID, '_give_levels_maximum_amount', give_sanitize_amount_for_db( $meta['_give_levels_maximum_amount'][0] ) ); |
|
1354 | + if ( ! empty($meta['_give_levels_maximum_amount'][0])) { |
|
1355 | + update_post_meta($post->ID, '_give_levels_maximum_amount', give_sanitize_amount_for_db($meta['_give_levels_maximum_amount'][0])); |
|
1356 | 1356 | } |
1357 | 1357 | |
1358 | 1358 | // _give_set_goal. |
1359 | - if ( ! empty( $meta['_give_set_goal'][0] ) ) { |
|
1360 | - update_post_meta( $post->ID, '_give_set_goal', give_sanitize_amount_for_db( $meta['_give_set_goal'][0] ) ); |
|
1359 | + if ( ! empty($meta['_give_set_goal'][0])) { |
|
1360 | + update_post_meta($post->ID, '_give_set_goal', give_sanitize_amount_for_db($meta['_give_set_goal'][0])); |
|
1361 | 1361 | } |
1362 | 1362 | |
1363 | 1363 | // _give_form_earnings. |
1364 | - if ( ! empty( $meta['_give_form_earnings'][0] ) ) { |
|
1365 | - update_post_meta( $post->ID, '_give_form_earnings', give_sanitize_amount_for_db( $meta['_give_form_earnings'][0] ) ); |
|
1364 | + if ( ! empty($meta['_give_form_earnings'][0])) { |
|
1365 | + update_post_meta($post->ID, '_give_form_earnings', give_sanitize_amount_for_db($meta['_give_form_earnings'][0])); |
|
1366 | 1366 | } |
1367 | 1367 | |
1368 | 1368 | // _give_custom_amount_minimum. |
1369 | - if ( ! empty( $meta['_give_donation_levels'][0] ) ) { |
|
1370 | - $donation_levels = unserialize( $meta['_give_donation_levels'][0] ); |
|
1369 | + if ( ! empty($meta['_give_donation_levels'][0])) { |
|
1370 | + $donation_levels = unserialize($meta['_give_donation_levels'][0]); |
|
1371 | 1371 | |
1372 | - foreach ( $donation_levels as $index => $level ) { |
|
1373 | - if ( empty( $level['_give_amount'] ) ) { |
|
1372 | + foreach ($donation_levels as $index => $level) { |
|
1373 | + if (empty($level['_give_amount'])) { |
|
1374 | 1374 | continue; |
1375 | 1375 | } |
1376 | 1376 | |
1377 | - $donation_levels[ $index ]['_give_amount'] = give_sanitize_amount_for_db( $level['_give_amount'] ); |
|
1377 | + $donation_levels[$index]['_give_amount'] = give_sanitize_amount_for_db($level['_give_amount']); |
|
1378 | 1378 | } |
1379 | 1379 | |
1380 | 1380 | $meta['_give_donation_levels'] = $donation_levels; |
1381 | - update_post_meta( $post->ID, '_give_donation_levels', $meta['_give_donation_levels'] ); |
|
1381 | + update_post_meta($post->ID, '_give_donation_levels', $meta['_give_donation_levels']); |
|
1382 | 1382 | } |
1383 | 1383 | |
1384 | 1384 | break; |
1385 | 1385 | |
1386 | 1386 | case 'give_payment': |
1387 | 1387 | // _give_payment_total. |
1388 | - if ( ! empty( $meta['_give_payment_total'][0] ) ) { |
|
1389 | - update_post_meta( $post->ID, '_give_payment_total', give_sanitize_amount_for_db( $meta['_give_payment_total'][0] ) ); |
|
1388 | + if ( ! empty($meta['_give_payment_total'][0])) { |
|
1389 | + update_post_meta($post->ID, '_give_payment_total', give_sanitize_amount_for_db($meta['_give_payment_total'][0])); |
|
1390 | 1390 | } |
1391 | 1391 | |
1392 | 1392 | break; |
@@ -1397,7 +1397,7 @@ discard block |
||
1397 | 1397 | wp_reset_postdata(); |
1398 | 1398 | } else { |
1399 | 1399 | // The Update Ran. |
1400 | - give_set_upgrade_complete( 'v1812_update_amount_values' ); |
|
1400 | + give_set_upgrade_complete('v1812_update_amount_values'); |
|
1401 | 1401 | } |
1402 | 1402 | } |
1403 | 1403 | |
@@ -1419,20 +1419,20 @@ discard block |
||
1419 | 1419 | $donors = Give()->donors->get_donors( |
1420 | 1420 | array( |
1421 | 1421 | 'number' => 20, |
1422 | - 'offset' => $give_updates->get_offset( 20 ), |
|
1422 | + 'offset' => $give_updates->get_offset(20), |
|
1423 | 1423 | ) |
1424 | 1424 | ); |
1425 | 1425 | |
1426 | - if ( ! empty( $donors ) ) { |
|
1427 | - $give_updates->set_percentage( Give()->donors->count(), $give_updates->get_offset( 20 ) ); |
|
1426 | + if ( ! empty($donors)) { |
|
1427 | + $give_updates->set_percentage(Give()->donors->count(), $give_updates->get_offset(20)); |
|
1428 | 1428 | |
1429 | 1429 | /* @var Object $donor */ |
1430 | - foreach ( $donors as $donor ) { |
|
1431 | - Give()->donors->update( $donor->id, array( 'purchase_value' => give_sanitize_amount_for_db( $donor->purchase_value ) ) ); |
|
1430 | + foreach ($donors as $donor) { |
|
1431 | + Give()->donors->update($donor->id, array('purchase_value' => give_sanitize_amount_for_db($donor->purchase_value))); |
|
1432 | 1432 | } |
1433 | 1433 | } else { |
1434 | 1434 | // The Update Ran. |
1435 | - give_set_upgrade_complete( 'v1812_update_donor_purchase_values' ); |
|
1435 | + give_set_upgrade_complete('v1812_update_donor_purchase_values'); |
|
1436 | 1436 | } |
1437 | 1437 | } |
1438 | 1438 | |
@@ -1449,23 +1449,23 @@ discard block |
||
1449 | 1449 | $donors = Give()->donors->get_donors( |
1450 | 1450 | array( |
1451 | 1451 | 'number' => 20, |
1452 | - 'offset' => $give_updates->get_offset( 20 ), |
|
1452 | + 'offset' => $give_updates->get_offset(20), |
|
1453 | 1453 | ) |
1454 | 1454 | ); |
1455 | 1455 | |
1456 | - if ( ! empty( $donors ) ) { |
|
1457 | - $give_updates->set_percentage( Give()->donors->count(), $give_updates->get_offset( 20 ) ); |
|
1456 | + if ( ! empty($donors)) { |
|
1457 | + $give_updates->set_percentage(Give()->donors->count(), $give_updates->get_offset(20)); |
|
1458 | 1458 | |
1459 | 1459 | /* @var Object $donor */ |
1460 | - foreach ( $donors as $donor ) { |
|
1460 | + foreach ($donors as $donor) { |
|
1461 | 1461 | $user_id = $donor->user_id; |
1462 | 1462 | |
1463 | 1463 | // Proceed, if donor is attached with user. |
1464 | - if ( $user_id ) { |
|
1465 | - $user = get_userdata( $user_id ); |
|
1464 | + if ($user_id) { |
|
1465 | + $user = get_userdata($user_id); |
|
1466 | 1466 | |
1467 | 1467 | // Update user role, if user has subscriber role. |
1468 | - if ( is_array( $user->roles ) && in_array( 'subscriber', $user->roles ) ) { |
|
1468 | + if (is_array($user->roles) && in_array('subscriber', $user->roles)) { |
|
1469 | 1469 | wp_update_user( |
1470 | 1470 | array( |
1471 | 1471 | 'ID' => $user_id, |
@@ -1477,7 +1477,7 @@ discard block |
||
1477 | 1477 | } |
1478 | 1478 | } else { |
1479 | 1479 | // The Update Ran. |
1480 | - give_set_upgrade_complete( 'v1813_update_donor_user_roles' ); |
|
1480 | + give_set_upgrade_complete('v1813_update_donor_user_roles'); |
|
1481 | 1481 | } |
1482 | 1482 | } |
1483 | 1483 | |
@@ -1489,7 +1489,7 @@ discard block |
||
1489 | 1489 | */ |
1490 | 1490 | function give_v1813_upgrades() { |
1491 | 1491 | // Update admin setting. |
1492 | - give_update_option( 'donor_default_user_role', 'give_donor' ); |
|
1492 | + give_update_option('donor_default_user_role', 'give_donor'); |
|
1493 | 1493 | |
1494 | 1494 | // Update Give roles. |
1495 | 1495 | $roles = new Give_Roles(); |
@@ -1512,27 +1512,27 @@ discard block |
||
1512 | 1512 | 'paged' => $give_updates->step, |
1513 | 1513 | 'status' => 'any', |
1514 | 1514 | 'order' => 'ASC', |
1515 | - 'post_type' => array( 'give_payment' ), |
|
1515 | + 'post_type' => array('give_payment'), |
|
1516 | 1516 | 'posts_per_page' => 100, |
1517 | 1517 | ) |
1518 | 1518 | ); |
1519 | 1519 | |
1520 | - if ( $payments->have_posts() ) { |
|
1521 | - $give_updates->set_percentage( $payments->found_posts, ( $give_updates->step * 100 ) ); |
|
1520 | + if ($payments->have_posts()) { |
|
1521 | + $give_updates->set_percentage($payments->found_posts, ($give_updates->step * 100)); |
|
1522 | 1522 | |
1523 | - while ( $payments->have_posts() ) { |
|
1523 | + while ($payments->have_posts()) { |
|
1524 | 1524 | $payments->the_post(); |
1525 | 1525 | |
1526 | - $payment_meta = give_get_payment_meta( get_the_ID() ); |
|
1526 | + $payment_meta = give_get_payment_meta(get_the_ID()); |
|
1527 | 1527 | |
1528 | - if ( 'RIAL' === $payment_meta['currency'] ) { |
|
1528 | + if ('RIAL' === $payment_meta['currency']) { |
|
1529 | 1529 | $payment_meta['currency'] = 'IRR'; |
1530 | - give_update_meta( get_the_ID(), '_give_payment_meta', $payment_meta ); |
|
1530 | + give_update_meta(get_the_ID(), '_give_payment_meta', $payment_meta); |
|
1531 | 1531 | } |
1532 | 1532 | } |
1533 | 1533 | } else { |
1534 | 1534 | // The Update Ran. |
1535 | - give_set_upgrade_complete( 'v1817_update_donation_iranian_currency_code' ); |
|
1535 | + give_set_upgrade_complete('v1817_update_donation_iranian_currency_code'); |
|
1536 | 1536 | } |
1537 | 1537 | } |
1538 | 1538 | |
@@ -1545,9 +1545,9 @@ discard block |
||
1545 | 1545 | function give_v1817_upgrades() { |
1546 | 1546 | $give_settings = give_get_settings(); |
1547 | 1547 | |
1548 | - if ( 'RIAL' === $give_settings['currency'] ) { |
|
1548 | + if ('RIAL' === $give_settings['currency']) { |
|
1549 | 1549 | $give_settings['currency'] = 'IRR'; |
1550 | - update_option( 'give_settings', $give_settings, false ); |
|
1550 | + update_option('give_settings', $give_settings, false); |
|
1551 | 1551 | } |
1552 | 1552 | } |
1553 | 1553 | |
@@ -1560,7 +1560,7 @@ discard block |
||
1560 | 1560 | |
1561 | 1561 | global $wp_roles; |
1562 | 1562 | |
1563 | - if ( ! ( $wp_roles instanceof WP_Roles ) ) { |
|
1563 | + if ( ! ($wp_roles instanceof WP_Roles)) { |
|
1564 | 1564 | return; |
1565 | 1565 | } |
1566 | 1566 | |
@@ -1584,15 +1584,15 @@ discard block |
||
1584 | 1584 | ), |
1585 | 1585 | ); |
1586 | 1586 | |
1587 | - foreach ( $add_caps as $role => $caps ) { |
|
1588 | - foreach ( $caps as $cap ) { |
|
1589 | - $wp_roles->add_cap( $role, $cap ); |
|
1587 | + foreach ($add_caps as $role => $caps) { |
|
1588 | + foreach ($caps as $cap) { |
|
1589 | + $wp_roles->add_cap($role, $cap); |
|
1590 | 1590 | } |
1591 | 1591 | } |
1592 | 1592 | |
1593 | - foreach ( $remove_caps as $role => $caps ) { |
|
1594 | - foreach ( $caps as $cap ) { |
|
1595 | - $wp_roles->remove_cap( $role, $cap ); |
|
1593 | + foreach ($remove_caps as $role => $caps) { |
|
1594 | + foreach ($caps as $cap) { |
|
1595 | + $wp_roles->remove_cap($role, $cap); |
|
1596 | 1596 | } |
1597 | 1597 | } |
1598 | 1598 | |
@@ -1616,7 +1616,7 @@ discard block |
||
1616 | 1616 | $roles->add_roles(); |
1617 | 1617 | $roles->add_caps(); |
1618 | 1618 | |
1619 | - give_set_upgrade_complete( 'v1817_cleanup_user_roles' ); |
|
1619 | + give_set_upgrade_complete('v1817_cleanup_user_roles'); |
|
1620 | 1620 | } |
1621 | 1621 | |
1622 | 1622 | /** |
@@ -1627,7 +1627,7 @@ discard block |
||
1627 | 1627 | function give_v1818_upgrades() { |
1628 | 1628 | |
1629 | 1629 | // Remove email_access_installed from give_settings. |
1630 | - give_delete_option( 'email_access_installed' ); |
|
1630 | + give_delete_option('email_access_installed'); |
|
1631 | 1631 | } |
1632 | 1632 | |
1633 | 1633 | /** |
@@ -1645,19 +1645,19 @@ discard block |
||
1645 | 1645 | 'paged' => $give_updates->step, |
1646 | 1646 | 'status' => 'any', |
1647 | 1647 | 'order' => 'ASC', |
1648 | - 'post_type' => array( 'give_payment' ), |
|
1648 | + 'post_type' => array('give_payment'), |
|
1649 | 1649 | 'posts_per_page' => 100, |
1650 | 1650 | ) |
1651 | 1651 | ); |
1652 | 1652 | |
1653 | - if ( $donations->have_posts() ) { |
|
1654 | - $give_updates->set_percentage( $donations->found_posts, $give_updates->step * 100 ); |
|
1653 | + if ($donations->have_posts()) { |
|
1654 | + $give_updates->set_percentage($donations->found_posts, $give_updates->step * 100); |
|
1655 | 1655 | |
1656 | - while ( $donations->have_posts() ) { |
|
1656 | + while ($donations->have_posts()) { |
|
1657 | 1657 | $donations->the_post(); |
1658 | 1658 | |
1659 | - $form = new Give_Donate_Form( give_get_meta( get_the_ID(), '_give_payment_form_id', true ) ); |
|
1660 | - $donation_meta = give_get_payment_meta( get_the_ID() ); |
|
1659 | + $form = new Give_Donate_Form(give_get_meta(get_the_ID(), '_give_payment_form_id', true)); |
|
1660 | + $donation_meta = give_get_payment_meta(get_the_ID()); |
|
1661 | 1661 | |
1662 | 1662 | // Update Donation meta with price_id set as custom, only if it is: |
1663 | 1663 | // 1. Donation Type = Set Donation. |
@@ -1666,19 +1666,19 @@ discard block |
||
1666 | 1666 | if ( |
1667 | 1667 | $form->ID && |
1668 | 1668 | $form->is_set_type_donation_form() && |
1669 | - ( 'custom' !== $donation_meta['price_id'] ) && |
|
1670 | - $form->is_custom_price( give_get_meta( get_the_ID(), '_give_payment_total', true ) ) |
|
1669 | + ('custom' !== $donation_meta['price_id']) && |
|
1670 | + $form->is_custom_price(give_get_meta(get_the_ID(), '_give_payment_total', true)) |
|
1671 | 1671 | ) { |
1672 | 1672 | $donation_meta['price_id'] = 'custom'; |
1673 | - give_update_meta( get_the_ID(), '_give_payment_meta', $donation_meta ); |
|
1674 | - give_update_meta( get_the_ID(), '_give_payment_price_id', 'custom' ); |
|
1673 | + give_update_meta(get_the_ID(), '_give_payment_meta', $donation_meta); |
|
1674 | + give_update_meta(get_the_ID(), '_give_payment_price_id', 'custom'); |
|
1675 | 1675 | } |
1676 | 1676 | } |
1677 | 1677 | |
1678 | 1678 | wp_reset_postdata(); |
1679 | 1679 | } else { |
1680 | 1680 | // Update Ran Successfully. |
1681 | - give_set_upgrade_complete( 'v1818_assign_custom_amount_set_donation' ); |
|
1681 | + give_set_upgrade_complete('v1818_assign_custom_amount_set_donation'); |
|
1682 | 1682 | } |
1683 | 1683 | } |
1684 | 1684 | |
@@ -1696,7 +1696,7 @@ discard block |
||
1696 | 1696 | |
1697 | 1697 | global $wp_roles; |
1698 | 1698 | |
1699 | - if ( ! ( $wp_roles instanceof WP_Roles ) ) { |
|
1699 | + if ( ! ($wp_roles instanceof WP_Roles)) { |
|
1700 | 1700 | return; |
1701 | 1701 | } |
1702 | 1702 | |
@@ -1714,9 +1714,9 @@ discard block |
||
1714 | 1714 | ), |
1715 | 1715 | ); |
1716 | 1716 | |
1717 | - foreach ( $remove_caps as $role => $caps ) { |
|
1718 | - foreach ( $caps as $cap ) { |
|
1719 | - $wp_roles->remove_cap( $role, $cap ); |
|
1717 | + foreach ($remove_caps as $role => $caps) { |
|
1718 | + foreach ($caps as $cap) { |
|
1719 | + $wp_roles->remove_cap($role, $cap); |
|
1720 | 1720 | } |
1721 | 1721 | } |
1722 | 1722 | |
@@ -1727,7 +1727,7 @@ discard block |
||
1727 | 1727 | $roles->add_roles(); |
1728 | 1728 | $roles->add_caps(); |
1729 | 1729 | |
1730 | - give_set_upgrade_complete( 'v1818_give_worker_role_cleanup' ); |
|
1730 | + give_set_upgrade_complete('v1818_give_worker_role_cleanup'); |
|
1731 | 1731 | } |
1732 | 1732 | |
1733 | 1733 | /** |
@@ -1751,15 +1751,15 @@ discard block |
||
1751 | 1751 | ) |
1752 | 1752 | ); |
1753 | 1753 | |
1754 | - if ( $forms->have_posts() ) { |
|
1755 | - $give_updates->set_percentage( $forms->found_posts, ( $give_updates->step * 100 ) ); |
|
1754 | + if ($forms->have_posts()) { |
|
1755 | + $give_updates->set_percentage($forms->found_posts, ($give_updates->step * 100)); |
|
1756 | 1756 | |
1757 | - while ( $forms->have_posts() ) { |
|
1757 | + while ($forms->have_posts()) { |
|
1758 | 1758 | $forms->the_post(); |
1759 | 1759 | global $post; |
1760 | 1760 | |
1761 | 1761 | // Update offline instruction email notification status. |
1762 | - $offline_instruction_notification_status = get_post_meta( get_the_ID(), '_give_customize_offline_donations', true ); |
|
1762 | + $offline_instruction_notification_status = get_post_meta(get_the_ID(), '_give_customize_offline_donations', true); |
|
1763 | 1763 | $offline_instruction_notification_status = give_is_setting_enabled( |
1764 | 1764 | $offline_instruction_notification_status, array( |
1765 | 1765 | 'enabled', |
@@ -1768,7 +1768,7 @@ discard block |
||
1768 | 1768 | ) |
1769 | 1769 | ? $offline_instruction_notification_status |
1770 | 1770 | : 'global'; |
1771 | - update_post_meta( get_the_ID(), '_give_offline-donation-instruction_notification', $offline_instruction_notification_status ); |
|
1771 | + update_post_meta(get_the_ID(), '_give_offline-donation-instruction_notification', $offline_instruction_notification_status); |
|
1772 | 1772 | |
1773 | 1773 | // Update offline instruction email message. |
1774 | 1774 | update_post_meta( |
@@ -1799,7 +1799,7 @@ discard block |
||
1799 | 1799 | wp_reset_postdata(); |
1800 | 1800 | } else { |
1801 | 1801 | // No more forms found, finish up. |
1802 | - give_set_upgrade_complete( 'v20_upgrades_form_metadata' ); |
|
1802 | + give_set_upgrade_complete('v20_upgrades_form_metadata'); |
|
1803 | 1803 | } |
1804 | 1804 | } |
1805 | 1805 | |
@@ -1826,19 +1826,19 @@ discard block |
||
1826 | 1826 | ) |
1827 | 1827 | ); |
1828 | 1828 | |
1829 | - if ( $forms->have_posts() ) { |
|
1830 | - $give_updates->set_percentage( $forms->found_posts, ( $give_updates->step * 100 ) ); |
|
1829 | + if ($forms->have_posts()) { |
|
1830 | + $give_updates->set_percentage($forms->found_posts, ($give_updates->step * 100)); |
|
1831 | 1831 | |
1832 | - while ( $forms->have_posts() ) { |
|
1832 | + while ($forms->have_posts()) { |
|
1833 | 1833 | $forms->the_post(); |
1834 | 1834 | global $post; |
1835 | 1835 | |
1836 | 1836 | // Split _give_payment_meta meta. |
1837 | 1837 | // @todo Remove _give_payment_meta after releases 2.0 |
1838 | - $payment_meta = give_get_meta( $post->ID, '_give_payment_meta', true ); |
|
1838 | + $payment_meta = give_get_meta($post->ID, '_give_payment_meta', true); |
|
1839 | 1839 | |
1840 | - if ( ! empty( $payment_meta ) ) { |
|
1841 | - _give_20_bc_split_and_save_give_payment_meta( $post->ID, $payment_meta ); |
|
1840 | + if ( ! empty($payment_meta)) { |
|
1841 | + _give_20_bc_split_and_save_give_payment_meta($post->ID, $payment_meta); |
|
1842 | 1842 | } |
1843 | 1843 | |
1844 | 1844 | $deprecated_meta_keys = array( |
@@ -1847,9 +1847,9 @@ discard block |
||
1847 | 1847 | '_give_payment_user_ip' => '_give_payment_donor_ip', |
1848 | 1848 | ); |
1849 | 1849 | |
1850 | - foreach ( $deprecated_meta_keys as $old_meta_key => $new_meta_key ) { |
|
1850 | + foreach ($deprecated_meta_keys as $old_meta_key => $new_meta_key) { |
|
1851 | 1851 | // Do not add new meta key if already exist. |
1852 | - if ( $wpdb->get_var( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id=%d AND meta_key=%s", $post->ID, $new_meta_key ) ) ) { |
|
1852 | + if ($wpdb->get_var($wpdb->prepare("SELECT meta_id FROM $wpdb->postmeta WHERE post_id=%d AND meta_key=%s", $post->ID, $new_meta_key))) { |
|
1853 | 1853 | continue; |
1854 | 1854 | } |
1855 | 1855 | |
@@ -1858,25 +1858,25 @@ discard block |
||
1858 | 1858 | array( |
1859 | 1859 | 'post_id' => $post->ID, |
1860 | 1860 | 'meta_key' => $new_meta_key, |
1861 | - 'meta_value' => give_get_meta( $post->ID, $old_meta_key, true ), |
|
1861 | + 'meta_value' => give_get_meta($post->ID, $old_meta_key, true), |
|
1862 | 1862 | ) |
1863 | 1863 | ); |
1864 | 1864 | } |
1865 | 1865 | |
1866 | 1866 | // Bailout |
1867 | - if ( $donor_id = give_get_meta( $post->ID, '_give_payment_donor_id', true ) ) { |
|
1867 | + if ($donor_id = give_get_meta($post->ID, '_give_payment_donor_id', true)) { |
|
1868 | 1868 | /* @var Give_Donor $donor */ |
1869 | - $donor = new Give_Donor( $donor_id ); |
|
1869 | + $donor = new Give_Donor($donor_id); |
|
1870 | 1870 | |
1871 | - $address['line1'] = give_get_meta( $post->ID, '_give_donor_billing_address1', true, '' ); |
|
1872 | - $address['line2'] = give_get_meta( $post->ID, '_give_donor_billing_address2', true, '' ); |
|
1873 | - $address['city'] = give_get_meta( $post->ID, '_give_donor_billing_city', true, '' ); |
|
1874 | - $address['state'] = give_get_meta( $post->ID, '_give_donor_billing_state', true, '' ); |
|
1875 | - $address['zip'] = give_get_meta( $post->ID, '_give_donor_billing_zip', true, '' ); |
|
1876 | - $address['country'] = give_get_meta( $post->ID, '_give_donor_billing_country', true, '' ); |
|
1871 | + $address['line1'] = give_get_meta($post->ID, '_give_donor_billing_address1', true, ''); |
|
1872 | + $address['line2'] = give_get_meta($post->ID, '_give_donor_billing_address2', true, ''); |
|
1873 | + $address['city'] = give_get_meta($post->ID, '_give_donor_billing_city', true, ''); |
|
1874 | + $address['state'] = give_get_meta($post->ID, '_give_donor_billing_state', true, ''); |
|
1875 | + $address['zip'] = give_get_meta($post->ID, '_give_donor_billing_zip', true, ''); |
|
1876 | + $address['country'] = give_get_meta($post->ID, '_give_donor_billing_country', true, ''); |
|
1877 | 1877 | |
1878 | 1878 | // Save address. |
1879 | - $donor->add_address( 'billing[]', $address ); |
|
1879 | + $donor->add_address('billing[]', $address); |
|
1880 | 1880 | } |
1881 | 1881 | }// End while(). |
1882 | 1882 | |
@@ -1885,7 +1885,7 @@ discard block |
||
1885 | 1885 | // @todo Delete user id meta after releases 2.0 |
1886 | 1886 | // $wpdb->get_var( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE meta_key=%s", '_give_payment_user_id' ) ); |
1887 | 1887 | // No more forms found, finish up. |
1888 | - give_set_upgrade_complete( 'v20_upgrades_payment_metadata' ); |
|
1888 | + give_set_upgrade_complete('v20_upgrades_payment_metadata'); |
|
1889 | 1889 | } |
1890 | 1890 | } |
1891 | 1891 | |
@@ -1911,20 +1911,20 @@ discard block |
||
1911 | 1911 | ) |
1912 | 1912 | ); |
1913 | 1913 | |
1914 | - if ( $forms->have_posts() ) { |
|
1915 | - $give_updates->set_percentage( $forms->found_posts, $give_updates->step * 100 ); |
|
1914 | + if ($forms->have_posts()) { |
|
1915 | + $give_updates->set_percentage($forms->found_posts, $give_updates->step * 100); |
|
1916 | 1916 | |
1917 | - while ( $forms->have_posts() ) { |
|
1917 | + while ($forms->have_posts()) { |
|
1918 | 1918 | $forms->the_post(); |
1919 | 1919 | global $post; |
1920 | 1920 | |
1921 | - if ( $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_logs WHERE ID=%d", $post->ID ) ) ) { |
|
1921 | + if ($wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_logs WHERE ID=%d", $post->ID))) { |
|
1922 | 1922 | continue; |
1923 | 1923 | } |
1924 | 1924 | |
1925 | - $term = get_the_terms( $post->ID, 'give_log_type' ); |
|
1926 | - $term = ! is_wp_error( $term ) && ! empty( $term ) ? $term[0] : array(); |
|
1927 | - $term_name = ! empty( $term ) ? $term->slug : ''; |
|
1925 | + $term = get_the_terms($post->ID, 'give_log_type'); |
|
1926 | + $term = ! is_wp_error($term) && ! empty($term) ? $term[0] : array(); |
|
1927 | + $term_name = ! empty($term) ? $term->slug : ''; |
|
1928 | 1928 | |
1929 | 1929 | $log_data = array( |
1930 | 1930 | 'ID' => $post->ID, |
@@ -1937,29 +1937,29 @@ discard block |
||
1937 | 1937 | ); |
1938 | 1938 | $log_meta = array(); |
1939 | 1939 | |
1940 | - if ( $old_log_meta = get_post_meta( $post->ID ) ) { |
|
1941 | - foreach ( $old_log_meta as $meta_key => $meta_value ) { |
|
1942 | - switch ( $meta_key ) { |
|
1940 | + if ($old_log_meta = get_post_meta($post->ID)) { |
|
1941 | + foreach ($old_log_meta as $meta_key => $meta_value) { |
|
1942 | + switch ($meta_key) { |
|
1943 | 1943 | case '_give_log_payment_id': |
1944 | - $log_data['log_parent'] = current( $meta_value ); |
|
1944 | + $log_data['log_parent'] = current($meta_value); |
|
1945 | 1945 | $log_meta['_give_log_form_id'] = $post->post_parent; |
1946 | 1946 | break; |
1947 | 1947 | |
1948 | 1948 | default: |
1949 | - $log_meta[ $meta_key ] = current( $meta_value ); |
|
1949 | + $log_meta[$meta_key] = current($meta_value); |
|
1950 | 1950 | } |
1951 | 1951 | } |
1952 | 1952 | } |
1953 | 1953 | |
1954 | - if ( 'api_request' === $term_name ) { |
|
1954 | + if ('api_request' === $term_name) { |
|
1955 | 1955 | $log_meta['_give_log_api_query'] = $post->post_excerpt; |
1956 | 1956 | } |
1957 | 1957 | |
1958 | - $wpdb->insert( "{$wpdb->prefix}give_logs", $log_data ); |
|
1958 | + $wpdb->insert("{$wpdb->prefix}give_logs", $log_data); |
|
1959 | 1959 | |
1960 | - if ( ! empty( $log_meta ) ) { |
|
1961 | - foreach ( $log_meta as $meta_key => $meta_value ) { |
|
1962 | - Give()->logs->logmeta_db->update_meta( $post->ID, $meta_key, $meta_value ); |
|
1960 | + if ( ! empty($log_meta)) { |
|
1961 | + foreach ($log_meta as $meta_key => $meta_value) { |
|
1962 | + Give()->logs->logmeta_db->update_meta($post->ID, $meta_key, $meta_value); |
|
1963 | 1963 | } |
1964 | 1964 | } |
1965 | 1965 | |
@@ -2004,7 +2004,7 @@ discard block |
||
2004 | 2004 | Give()->logs->delete_cache(); |
2005 | 2005 | |
2006 | 2006 | // No more forms found, finish up. |
2007 | - give_set_upgrade_complete( 'v20_logs_upgrades' ); |
|
2007 | + give_set_upgrade_complete('v20_logs_upgrades'); |
|
2008 | 2008 | } |
2009 | 2009 | } |
2010 | 2010 | |
@@ -2025,15 +2025,15 @@ discard block |
||
2025 | 2025 | 'paged' => $give_updates->step, |
2026 | 2026 | 'status' => 'any', |
2027 | 2027 | 'order' => 'ASC', |
2028 | - 'post_type' => array( 'give_forms', 'give_payment' ), |
|
2028 | + 'post_type' => array('give_forms', 'give_payment'), |
|
2029 | 2029 | 'posts_per_page' => 100, |
2030 | 2030 | ) |
2031 | 2031 | ); |
2032 | 2032 | |
2033 | - if ( $payments->have_posts() ) { |
|
2034 | - $give_updates->set_percentage( $payments->found_posts, $give_updates->step * 100 ); |
|
2033 | + if ($payments->have_posts()) { |
|
2034 | + $give_updates->set_percentage($payments->found_posts, $give_updates->step * 100); |
|
2035 | 2035 | |
2036 | - while ( $payments->have_posts() ) { |
|
2036 | + while ($payments->have_posts()) { |
|
2037 | 2037 | $payments->the_post(); |
2038 | 2038 | global $post; |
2039 | 2039 | |
@@ -2045,19 +2045,19 @@ discard block |
||
2045 | 2045 | ARRAY_A |
2046 | 2046 | ); |
2047 | 2047 | |
2048 | - if ( ! empty( $meta_data ) ) { |
|
2049 | - foreach ( $meta_data as $index => $data ) { |
|
2048 | + if ( ! empty($meta_data)) { |
|
2049 | + foreach ($meta_data as $index => $data) { |
|
2050 | 2050 | // Check for duplicate meta values. |
2051 | - if ( $result = $wpdb->get_results( $wpdb->prepare( 'SELECT * FROM ' . ( 'give_forms' === $post->post_type ? $wpdb->formmeta : $wpdb->paymentmeta ) . ' WHERE meta_id=%d', $data['meta_id'] ), ARRAY_A ) ) { |
|
2051 | + if ($result = $wpdb->get_results($wpdb->prepare('SELECT * FROM '.('give_forms' === $post->post_type ? $wpdb->formmeta : $wpdb->paymentmeta).' WHERE meta_id=%d', $data['meta_id']), ARRAY_A)) { |
|
2052 | 2052 | continue; |
2053 | 2053 | } |
2054 | 2054 | |
2055 | - switch ( $post->post_type ) { |
|
2055 | + switch ($post->post_type) { |
|
2056 | 2056 | case 'give_forms': |
2057 | 2057 | $data['form_id'] = $data['post_id']; |
2058 | - unset( $data['post_id'] ); |
|
2058 | + unset($data['post_id']); |
|
2059 | 2059 | |
2060 | - Give()->form_meta->insert( $data ); |
|
2060 | + Give()->form_meta->insert($data); |
|
2061 | 2061 | // @todo: delete form meta from post meta table after releases 2.0. |
2062 | 2062 | /*delete_post_meta( get_the_ID(), $data['meta_key'] );*/ |
2063 | 2063 | |
@@ -2065,9 +2065,9 @@ discard block |
||
2065 | 2065 | |
2066 | 2066 | case 'give_payment': |
2067 | 2067 | $data['payment_id'] = $data['post_id']; |
2068 | - unset( $data['post_id'] ); |
|
2068 | + unset($data['post_id']); |
|
2069 | 2069 | |
2070 | - Give()->payment_meta->insert( $data ); |
|
2070 | + Give()->payment_meta->insert($data); |
|
2071 | 2071 | |
2072 | 2072 | // @todo: delete donation meta from post meta table after releases 2.0. |
2073 | 2073 | /*delete_post_meta( get_the_ID(), $data['meta_key'] );*/ |
@@ -2081,7 +2081,7 @@ discard block |
||
2081 | 2081 | wp_reset_postdata(); |
2082 | 2082 | } else { |
2083 | 2083 | // No more forms found, finish up. |
2084 | - give_set_upgrade_complete( 'v20_move_metadata_into_new_table' ); |
|
2084 | + give_set_upgrade_complete('v20_move_metadata_into_new_table'); |
|
2085 | 2085 | } |
2086 | 2086 | |
2087 | 2087 | } |
@@ -2104,38 +2104,38 @@ discard block |
||
2104 | 2104 | ) |
2105 | 2105 | ); |
2106 | 2106 | |
2107 | - if ( $donors ) { |
|
2108 | - $give_updates->set_percentage( count( $donors ), $give_updates->step * 100 ); |
|
2107 | + if ($donors) { |
|
2108 | + $give_updates->set_percentage(count($donors), $give_updates->step * 100); |
|
2109 | 2109 | // Loop through Donors |
2110 | - foreach ( $donors as $donor ) { |
|
2110 | + foreach ($donors as $donor) { |
|
2111 | 2111 | |
2112 | - $donor_name = explode( ' ', $donor->name, 2 ); |
|
2113 | - $donor_first_name = Give()->donor_meta->get_meta( $donor->id, '_give_donor_first_name' ); |
|
2114 | - $donor_last_name = Give()->donor_meta->get_meta( $donor->id, '_give_donor_last_name' ); |
|
2112 | + $donor_name = explode(' ', $donor->name, 2); |
|
2113 | + $donor_first_name = Give()->donor_meta->get_meta($donor->id, '_give_donor_first_name'); |
|
2114 | + $donor_last_name = Give()->donor_meta->get_meta($donor->id, '_give_donor_last_name'); |
|
2115 | 2115 | |
2116 | 2116 | // If first name meta of donor is not created, then create it. |
2117 | - if ( ! $donor_first_name && isset( $donor_name[0] ) ) { |
|
2118 | - Give()->donor_meta->add_meta( $donor->id, '_give_donor_first_name', $donor_name[0] ); |
|
2117 | + if ( ! $donor_first_name && isset($donor_name[0])) { |
|
2118 | + Give()->donor_meta->add_meta($donor->id, '_give_donor_first_name', $donor_name[0]); |
|
2119 | 2119 | } |
2120 | 2120 | |
2121 | 2121 | // If last name meta of donor is not created, then create it. |
2122 | - if ( ! $donor_last_name && isset( $donor_name[1] ) ) { |
|
2123 | - Give()->donor_meta->add_meta( $donor->id, '_give_donor_last_name', $donor_name[1] ); |
|
2122 | + if ( ! $donor_last_name && isset($donor_name[1])) { |
|
2123 | + Give()->donor_meta->add_meta($donor->id, '_give_donor_last_name', $donor_name[1]); |
|
2124 | 2124 | } |
2125 | 2125 | |
2126 | 2126 | // If Donor is connected with WP User then update user meta. |
2127 | - if ( $donor->user_id ) { |
|
2128 | - if ( isset( $donor_name[0] ) ) { |
|
2129 | - update_user_meta( $donor->user_id, 'first_name', $donor_name[0] ); |
|
2127 | + if ($donor->user_id) { |
|
2128 | + if (isset($donor_name[0])) { |
|
2129 | + update_user_meta($donor->user_id, 'first_name', $donor_name[0]); |
|
2130 | 2130 | } |
2131 | - if ( isset( $donor_name[1] ) ) { |
|
2132 | - update_user_meta( $donor->user_id, 'last_name', $donor_name[1] ); |
|
2131 | + if (isset($donor_name[1])) { |
|
2132 | + update_user_meta($donor->user_id, 'last_name', $donor_name[1]); |
|
2133 | 2133 | } |
2134 | 2134 | } |
2135 | 2135 | } |
2136 | 2136 | } else { |
2137 | 2137 | // The Update Ran. |
2138 | - give_set_upgrade_complete( 'v20_upgrades_donor_name' ); |
|
2138 | + give_set_upgrade_complete('v20_upgrades_donor_name'); |
|
2139 | 2139 | } |
2140 | 2140 | |
2141 | 2141 | } |
@@ -2164,15 +2164,15 @@ discard block |
||
2164 | 2164 | |
2165 | 2165 | $users = $user_query->get_results(); |
2166 | 2166 | |
2167 | - if ( $users ) { |
|
2168 | - $give_updates->set_percentage( $user_query->get_total(), $give_updates->step * 100 ); |
|
2167 | + if ($users) { |
|
2168 | + $give_updates->set_percentage($user_query->get_total(), $give_updates->step * 100); |
|
2169 | 2169 | |
2170 | 2170 | // Loop through Donors |
2171 | - foreach ( $users as $user ) { |
|
2171 | + foreach ($users as $user) { |
|
2172 | 2172 | /* @var Give_Donor $donor */ |
2173 | - $donor = new Give_Donor( $user->ID, true ); |
|
2173 | + $donor = new Give_Donor($user->ID, true); |
|
2174 | 2174 | |
2175 | - if ( ! $donor->id ) { |
|
2175 | + if ( ! $donor->id) { |
|
2176 | 2176 | continue; |
2177 | 2177 | } |
2178 | 2178 | |
@@ -2188,10 +2188,10 @@ discard block |
||
2188 | 2188 | ) |
2189 | 2189 | ); |
2190 | 2190 | |
2191 | - if ( ! empty( $address ) ) { |
|
2192 | - $address = maybe_unserialize( $address ); |
|
2193 | - $donor->add_address( 'personal', $address ); |
|
2194 | - $donor->add_address( 'billing[]', $address ); |
|
2191 | + if ( ! empty($address)) { |
|
2192 | + $address = maybe_unserialize($address); |
|
2193 | + $donor->add_address('personal', $address); |
|
2194 | + $donor->add_address('billing[]', $address); |
|
2195 | 2195 | |
2196 | 2196 | // @todo: delete _give_user_address from user meta after releases 2.0. |
2197 | 2197 | /*delete_user_meta( $user->ID, '_give_user_address' );*/ |
@@ -2199,7 +2199,7 @@ discard block |
||
2199 | 2199 | } |
2200 | 2200 | } else { |
2201 | 2201 | // The Update Ran. |
2202 | - give_set_upgrade_complete( 'v20_upgrades_user_address' ); |
|
2202 | + give_set_upgrade_complete('v20_upgrades_user_address'); |
|
2203 | 2203 | } |
2204 | 2204 | |
2205 | 2205 | } |
@@ -2223,15 +2223,15 @@ discard block |
||
2223 | 2223 | ); |
2224 | 2224 | |
2225 | 2225 | // Alter customer table |
2226 | - foreach ( $tables as $old_table => $new_table ) { |
|
2226 | + foreach ($tables as $old_table => $new_table) { |
|
2227 | 2227 | if ( |
2228 | - $wpdb->query( $wpdb->prepare( 'SHOW TABLES LIKE %s', $old_table ) ) && |
|
2229 | - ! $wpdb->query( $wpdb->prepare( 'SHOW TABLES LIKE %s', $new_table ) ) |
|
2228 | + $wpdb->query($wpdb->prepare('SHOW TABLES LIKE %s', $old_table)) && |
|
2229 | + ! $wpdb->query($wpdb->prepare('SHOW TABLES LIKE %s', $new_table)) |
|
2230 | 2230 | ) { |
2231 | - $wpdb->query( "ALTER TABLE {$old_table} RENAME TO {$new_table}" ); |
|
2231 | + $wpdb->query("ALTER TABLE {$old_table} RENAME TO {$new_table}"); |
|
2232 | 2232 | |
2233 | - if ( "{$wpdb->prefix}give_donormeta" === $new_table ) { |
|
2234 | - $wpdb->query( "ALTER TABLE {$new_table} CHANGE COLUMN customer_id donor_id bigint(20)" ); |
|
2233 | + if ("{$wpdb->prefix}give_donormeta" === $new_table) { |
|
2234 | + $wpdb->query("ALTER TABLE {$new_table} CHANGE COLUMN customer_id donor_id bigint(20)"); |
|
2235 | 2235 | } |
2236 | 2236 | } |
2237 | 2237 | } |
@@ -2239,7 +2239,7 @@ discard block |
||
2239 | 2239 | $give_updates->percentage = 100; |
2240 | 2240 | |
2241 | 2241 | // No more forms found, finish up. |
2242 | - give_set_upgrade_complete( 'v20_rename_donor_tables' ); |
|
2242 | + give_set_upgrade_complete('v20_rename_donor_tables'); |
|
2243 | 2243 | |
2244 | 2244 | // Re initiate donor classes. |
2245 | 2245 | Give()->donors = new Give_DB_Donors(); |
@@ -2257,19 +2257,19 @@ discard block |
||
2257 | 2257 | function give_v201_create_tables() { |
2258 | 2258 | global $wpdb; |
2259 | 2259 | |
2260 | - if ( ! $wpdb->query( $wpdb->prepare( 'SHOW TABLES LIKE %s', "{$wpdb->prefix}give_paymentmeta" ) ) ) { |
|
2260 | + if ( ! $wpdb->query($wpdb->prepare('SHOW TABLES LIKE %s', "{$wpdb->prefix}give_paymentmeta"))) { |
|
2261 | 2261 | Give()->payment_meta->create_table(); |
2262 | 2262 | } |
2263 | 2263 | |
2264 | - if ( ! $wpdb->query( $wpdb->prepare( 'SHOW TABLES LIKE %s', "{$wpdb->prefix}give_formmeta" ) ) ) { |
|
2264 | + if ( ! $wpdb->query($wpdb->prepare('SHOW TABLES LIKE %s', "{$wpdb->prefix}give_formmeta"))) { |
|
2265 | 2265 | Give()->form_meta->create_table(); |
2266 | 2266 | } |
2267 | 2267 | |
2268 | - if ( ! $wpdb->query( $wpdb->prepare( 'SHOW TABLES LIKE %s', "{$wpdb->prefix}give_logs" ) ) ) { |
|
2268 | + if ( ! $wpdb->query($wpdb->prepare('SHOW TABLES LIKE %s', "{$wpdb->prefix}give_logs"))) { |
|
2269 | 2269 | Give()->logs->log_db->create_table(); |
2270 | 2270 | } |
2271 | 2271 | |
2272 | - if ( ! $wpdb->query( $wpdb->prepare( 'SHOW TABLES LIKE %s', "{$wpdb->prefix}give_logmeta" ) ) ) { |
|
2272 | + if ( ! $wpdb->query($wpdb->prepare('SHOW TABLES LIKE %s', "{$wpdb->prefix}give_logmeta"))) { |
|
2273 | 2273 | Give()->logs->logmeta_db->create_table(); |
2274 | 2274 | } |
2275 | 2275 | } |
@@ -2294,30 +2294,30 @@ discard block |
||
2294 | 2294 | $wpdb->posts.post_date >= '2018-01-08 00:00:00' |
2295 | 2295 | ) |
2296 | 2296 | AND $wpdb->posts.post_type = 'give_payment' |
2297 | - AND {$wpdb->posts}.post_status IN ('" . implode( "','", array_keys( give_get_payment_statuses() ) ) . "') |
|
2297 | + AND {$wpdb->posts}.post_status IN ('".implode("','", array_keys(give_get_payment_statuses()))."') |
|
2298 | 2298 | ORDER BY $wpdb->posts.post_date ASC |
2299 | 2299 | LIMIT 100 |
2300 | - OFFSET " . $give_updates->get_offset( 100 ) |
|
2300 | + OFFSET ".$give_updates->get_offset(100) |
|
2301 | 2301 | ); |
2302 | 2302 | |
2303 | - if ( ! empty( $payments ) ) { |
|
2304 | - $give_updates->set_percentage( give_get_total_post_type_count( 'give_payment' ), ( $give_updates->step * 100 ) ); |
|
2303 | + if ( ! empty($payments)) { |
|
2304 | + $give_updates->set_percentage(give_get_total_post_type_count('give_payment'), ($give_updates->step * 100)); |
|
2305 | 2305 | |
2306 | - foreach ( $payments as $payment_id ) { |
|
2307 | - $post = get_post( $payment_id ); |
|
2308 | - setup_postdata( $post ); |
|
2306 | + foreach ($payments as $payment_id) { |
|
2307 | + $post = get_post($payment_id); |
|
2308 | + setup_postdata($post); |
|
2309 | 2309 | |
2310 | 2310 | // Do not add new meta keys if already refactored. |
2311 | - if ( $wpdb->get_var( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id=%d AND meta_key=%s", $post->ID, '_give_payment_donor_id' ) ) ) { |
|
2311 | + if ($wpdb->get_var($wpdb->prepare("SELECT meta_id FROM $wpdb->postmeta WHERE post_id=%d AND meta_key=%s", $post->ID, '_give_payment_donor_id'))) { |
|
2312 | 2312 | continue; |
2313 | 2313 | } |
2314 | 2314 | |
2315 | 2315 | // Split _give_payment_meta meta. |
2316 | 2316 | // @todo Remove _give_payment_meta after releases 2.0 |
2317 | - $payment_meta = give_get_meta( $post->ID, '_give_payment_meta', true ); |
|
2317 | + $payment_meta = give_get_meta($post->ID, '_give_payment_meta', true); |
|
2318 | 2318 | |
2319 | - if ( ! empty( $payment_meta ) ) { |
|
2320 | - _give_20_bc_split_and_save_give_payment_meta( $post->ID, $payment_meta ); |
|
2319 | + if ( ! empty($payment_meta)) { |
|
2320 | + _give_20_bc_split_and_save_give_payment_meta($post->ID, $payment_meta); |
|
2321 | 2321 | } |
2322 | 2322 | |
2323 | 2323 | $deprecated_meta_keys = array( |
@@ -2326,9 +2326,9 @@ discard block |
||
2326 | 2326 | '_give_payment_user_ip' => '_give_payment_donor_ip', |
2327 | 2327 | ); |
2328 | 2328 | |
2329 | - foreach ( $deprecated_meta_keys as $old_meta_key => $new_meta_key ) { |
|
2329 | + foreach ($deprecated_meta_keys as $old_meta_key => $new_meta_key) { |
|
2330 | 2330 | // Do not add new meta key if already exist. |
2331 | - if ( $wpdb->get_var( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id=%d AND meta_key=%s", $post->ID, $new_meta_key ) ) ) { |
|
2331 | + if ($wpdb->get_var($wpdb->prepare("SELECT meta_id FROM $wpdb->postmeta WHERE post_id=%d AND meta_key=%s", $post->ID, $new_meta_key))) { |
|
2332 | 2332 | continue; |
2333 | 2333 | } |
2334 | 2334 | |
@@ -2337,25 +2337,25 @@ discard block |
||
2337 | 2337 | array( |
2338 | 2338 | 'post_id' => $post->ID, |
2339 | 2339 | 'meta_key' => $new_meta_key, |
2340 | - 'meta_value' => give_get_meta( $post->ID, $old_meta_key, true ), |
|
2340 | + 'meta_value' => give_get_meta($post->ID, $old_meta_key, true), |
|
2341 | 2341 | ) |
2342 | 2342 | ); |
2343 | 2343 | } |
2344 | 2344 | |
2345 | 2345 | // Bailout |
2346 | - if ( $donor_id = give_get_meta( $post->ID, '_give_payment_donor_id', true ) ) { |
|
2346 | + if ($donor_id = give_get_meta($post->ID, '_give_payment_donor_id', true)) { |
|
2347 | 2347 | /* @var Give_Donor $donor */ |
2348 | - $donor = new Give_Donor( $donor_id ); |
|
2348 | + $donor = new Give_Donor($donor_id); |
|
2349 | 2349 | |
2350 | - $address['line1'] = give_get_meta( $post->ID, '_give_donor_billing_address1', true, '' ); |
|
2351 | - $address['line2'] = give_get_meta( $post->ID, '_give_donor_billing_address2', true, '' ); |
|
2352 | - $address['city'] = give_get_meta( $post->ID, '_give_donor_billing_city', true, '' ); |
|
2353 | - $address['state'] = give_get_meta( $post->ID, '_give_donor_billing_state', true, '' ); |
|
2354 | - $address['zip'] = give_get_meta( $post->ID, '_give_donor_billing_zip', true, '' ); |
|
2355 | - $address['country'] = give_get_meta( $post->ID, '_give_donor_billing_country', true, '' ); |
|
2350 | + $address['line1'] = give_get_meta($post->ID, '_give_donor_billing_address1', true, ''); |
|
2351 | + $address['line2'] = give_get_meta($post->ID, '_give_donor_billing_address2', true, ''); |
|
2352 | + $address['city'] = give_get_meta($post->ID, '_give_donor_billing_city', true, ''); |
|
2353 | + $address['state'] = give_get_meta($post->ID, '_give_donor_billing_state', true, ''); |
|
2354 | + $address['zip'] = give_get_meta($post->ID, '_give_donor_billing_zip', true, ''); |
|
2355 | + $address['country'] = give_get_meta($post->ID, '_give_donor_billing_country', true, ''); |
|
2356 | 2356 | |
2357 | 2357 | // Save address. |
2358 | - $donor->add_address( 'billing[]', $address ); |
|
2358 | + $donor->add_address('billing[]', $address); |
|
2359 | 2359 | } |
2360 | 2360 | }// End while(). |
2361 | 2361 | |
@@ -2364,7 +2364,7 @@ discard block |
||
2364 | 2364 | // @todo Delete user id meta after releases 2.0 |
2365 | 2365 | // $wpdb->get_var( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE meta_key=%s", '_give_payment_user_id' ) ); |
2366 | 2366 | // No more forms found, finish up. |
2367 | - give_set_upgrade_complete( 'v201_upgrades_payment_metadata' ); |
|
2367 | + give_set_upgrade_complete('v201_upgrades_payment_metadata'); |
|
2368 | 2368 | } |
2369 | 2369 | } |
2370 | 2370 | |
@@ -2384,13 +2384,13 @@ discard block |
||
2384 | 2384 | SELECT ID FROM $wpdb->posts |
2385 | 2385 | WHERE 1=1 |
2386 | 2386 | AND ( $wpdb->posts.post_type = 'give_payment' OR $wpdb->posts.post_type = 'give_forms' ) |
2387 | - AND {$wpdb->posts}.post_status IN ('" . implode( "','", array_keys( give_get_payment_statuses() ) ) . "') |
|
2387 | + AND {$wpdb->posts}.post_status IN ('".implode("','", array_keys(give_get_payment_statuses()))."') |
|
2388 | 2388 | ORDER BY $wpdb->posts.post_date ASC |
2389 | 2389 | LIMIT 100 |
2390 | - OFFSET " . $give_updates->get_offset( 100 ) |
|
2390 | + OFFSET ".$give_updates->get_offset(100) |
|
2391 | 2391 | ); |
2392 | 2392 | |
2393 | - if ( ! empty( $payments ) ) { |
|
2393 | + if ( ! empty($payments)) { |
|
2394 | 2394 | $give_updates->set_percentage( |
2395 | 2395 | give_get_total_post_type_count( |
2396 | 2396 | array( |
@@ -2400,9 +2400,9 @@ discard block |
||
2400 | 2400 | ), $give_updates->step * 100 |
2401 | 2401 | ); |
2402 | 2402 | |
2403 | - foreach ( $payments as $payment_id ) { |
|
2404 | - $post = get_post( $payment_id ); |
|
2405 | - setup_postdata( $post ); |
|
2403 | + foreach ($payments as $payment_id) { |
|
2404 | + $post = get_post($payment_id); |
|
2405 | + setup_postdata($post); |
|
2406 | 2406 | |
2407 | 2407 | $meta_data = $wpdb->get_results( |
2408 | 2408 | $wpdb->prepare( |
@@ -2412,19 +2412,19 @@ discard block |
||
2412 | 2412 | ARRAY_A |
2413 | 2413 | ); |
2414 | 2414 | |
2415 | - if ( ! empty( $meta_data ) ) { |
|
2416 | - foreach ( $meta_data as $index => $data ) { |
|
2415 | + if ( ! empty($meta_data)) { |
|
2416 | + foreach ($meta_data as $index => $data) { |
|
2417 | 2417 | // Check for duplicate meta values. |
2418 | - if ( $result = $wpdb->get_results( $wpdb->prepare( 'SELECT * FROM ' . ( 'give_forms' === $post->post_type ? $wpdb->formmeta : $wpdb->paymentmeta ) . ' WHERE meta_id=%d', $data['meta_id'] ), ARRAY_A ) ) { |
|
2418 | + if ($result = $wpdb->get_results($wpdb->prepare('SELECT * FROM '.('give_forms' === $post->post_type ? $wpdb->formmeta : $wpdb->paymentmeta).' WHERE meta_id=%d', $data['meta_id']), ARRAY_A)) { |
|
2419 | 2419 | continue; |
2420 | 2420 | } |
2421 | 2421 | |
2422 | - switch ( $post->post_type ) { |
|
2422 | + switch ($post->post_type) { |
|
2423 | 2423 | case 'give_forms': |
2424 | 2424 | $data['form_id'] = $data['post_id']; |
2425 | - unset( $data['post_id'] ); |
|
2425 | + unset($data['post_id']); |
|
2426 | 2426 | |
2427 | - Give()->form_meta->insert( $data ); |
|
2427 | + Give()->form_meta->insert($data); |
|
2428 | 2428 | // @todo: delete form meta from post meta table after releases 2.0. |
2429 | 2429 | /*delete_post_meta( get_the_ID(), $data['meta_key'] );*/ |
2430 | 2430 | |
@@ -2432,9 +2432,9 @@ discard block |
||
2432 | 2432 | |
2433 | 2433 | case 'give_payment': |
2434 | 2434 | $data['payment_id'] = $data['post_id']; |
2435 | - unset( $data['post_id'] ); |
|
2435 | + unset($data['post_id']); |
|
2436 | 2436 | |
2437 | - Give()->payment_meta->insert( $data ); |
|
2437 | + Give()->payment_meta->insert($data); |
|
2438 | 2438 | |
2439 | 2439 | // @todo: delete donation meta from post meta table after releases 2.0. |
2440 | 2440 | /*delete_post_meta( get_the_ID(), $data['meta_key'] );*/ |
@@ -2448,7 +2448,7 @@ discard block |
||
2448 | 2448 | wp_reset_postdata(); |
2449 | 2449 | } else { |
2450 | 2450 | // No more forms found, finish up. |
2451 | - give_set_upgrade_complete( 'v201_move_metadata_into_new_table' ); |
|
2451 | + give_set_upgrade_complete('v201_move_metadata_into_new_table'); |
|
2452 | 2452 | } |
2453 | 2453 | |
2454 | 2454 | } |
@@ -2469,26 +2469,26 @@ discard block |
||
2469 | 2469 | SELECT ID FROM $wpdb->posts |
2470 | 2470 | WHERE 1=1 |
2471 | 2471 | AND $wpdb->posts.post_type = 'give_log' |
2472 | - AND {$wpdb->posts}.post_status IN ('" . implode( "','", array_keys( give_get_payment_statuses() ) ) . "') |
|
2472 | + AND {$wpdb->posts}.post_status IN ('".implode("','", array_keys(give_get_payment_statuses()))."') |
|
2473 | 2473 | ORDER BY $wpdb->posts.post_date ASC |
2474 | 2474 | LIMIT 100 |
2475 | - OFFSET " . $give_updates->get_offset( 100 ) |
|
2475 | + OFFSET ".$give_updates->get_offset(100) |
|
2476 | 2476 | ); |
2477 | 2477 | |
2478 | - if ( ! empty( $logs ) ) { |
|
2479 | - $give_updates->set_percentage( give_get_total_post_type_count( 'give_log' ), $give_updates->step * 100 ); |
|
2478 | + if ( ! empty($logs)) { |
|
2479 | + $give_updates->set_percentage(give_get_total_post_type_count('give_log'), $give_updates->step * 100); |
|
2480 | 2480 | |
2481 | - foreach ( $logs as $log_id ) { |
|
2482 | - $post = get_post( $log_id ); |
|
2483 | - setup_postdata( $post ); |
|
2481 | + foreach ($logs as $log_id) { |
|
2482 | + $post = get_post($log_id); |
|
2483 | + setup_postdata($post); |
|
2484 | 2484 | |
2485 | - if ( $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_logs WHERE ID=%d", $post->ID ) ) ) { |
|
2485 | + if ($wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_logs WHERE ID=%d", $post->ID))) { |
|
2486 | 2486 | continue; |
2487 | 2487 | } |
2488 | 2488 | |
2489 | - $term = get_the_terms( $post->ID, 'give_log_type' ); |
|
2490 | - $term = ! is_wp_error( $term ) && ! empty( $term ) ? $term[0] : array(); |
|
2491 | - $term_name = ! empty( $term ) ? $term->slug : ''; |
|
2489 | + $term = get_the_terms($post->ID, 'give_log_type'); |
|
2490 | + $term = ! is_wp_error($term) && ! empty($term) ? $term[0] : array(); |
|
2491 | + $term_name = ! empty($term) ? $term->slug : ''; |
|
2492 | 2492 | |
2493 | 2493 | $log_data = array( |
2494 | 2494 | 'ID' => $post->ID, |
@@ -2501,29 +2501,29 @@ discard block |
||
2501 | 2501 | ); |
2502 | 2502 | $log_meta = array(); |
2503 | 2503 | |
2504 | - if ( $old_log_meta = get_post_meta( $post->ID ) ) { |
|
2505 | - foreach ( $old_log_meta as $meta_key => $meta_value ) { |
|
2506 | - switch ( $meta_key ) { |
|
2504 | + if ($old_log_meta = get_post_meta($post->ID)) { |
|
2505 | + foreach ($old_log_meta as $meta_key => $meta_value) { |
|
2506 | + switch ($meta_key) { |
|
2507 | 2507 | case '_give_log_payment_id': |
2508 | - $log_data['log_parent'] = current( $meta_value ); |
|
2508 | + $log_data['log_parent'] = current($meta_value); |
|
2509 | 2509 | $log_meta['_give_log_form_id'] = $post->post_parent; |
2510 | 2510 | break; |
2511 | 2511 | |
2512 | 2512 | default: |
2513 | - $log_meta[ $meta_key ] = current( $meta_value ); |
|
2513 | + $log_meta[$meta_key] = current($meta_value); |
|
2514 | 2514 | } |
2515 | 2515 | } |
2516 | 2516 | } |
2517 | 2517 | |
2518 | - if ( 'api_request' === $term_name ) { |
|
2518 | + if ('api_request' === $term_name) { |
|
2519 | 2519 | $log_meta['_give_log_api_query'] = $post->post_excerpt; |
2520 | 2520 | } |
2521 | 2521 | |
2522 | - $wpdb->insert( "{$wpdb->prefix}give_logs", $log_data ); |
|
2522 | + $wpdb->insert("{$wpdb->prefix}give_logs", $log_data); |
|
2523 | 2523 | |
2524 | - if ( ! empty( $log_meta ) ) { |
|
2525 | - foreach ( $log_meta as $meta_key => $meta_value ) { |
|
2526 | - Give()->logs->logmeta_db->update_meta( $post->ID, $meta_key, $meta_value ); |
|
2524 | + if ( ! empty($log_meta)) { |
|
2525 | + foreach ($log_meta as $meta_key => $meta_value) { |
|
2526 | + Give()->logs->logmeta_db->update_meta($post->ID, $meta_key, $meta_value); |
|
2527 | 2527 | } |
2528 | 2528 | } |
2529 | 2529 | |
@@ -2536,7 +2536,7 @@ discard block |
||
2536 | 2536 | Give()->logs->delete_cache(); |
2537 | 2537 | |
2538 | 2538 | // No more forms found, finish up. |
2539 | - give_set_upgrade_complete( 'v201_logs_upgrades' ); |
|
2539 | + give_set_upgrade_complete('v201_logs_upgrades'); |
|
2540 | 2540 | } |
2541 | 2541 | } |
2542 | 2542 | |
@@ -2551,51 +2551,51 @@ discard block |
||
2551 | 2551 | global $wpdb; |
2552 | 2552 | give_v201_create_tables(); |
2553 | 2553 | |
2554 | - if ( $wpdb->query( $wpdb->prepare( 'SHOW TABLES LIKE %s', "{$wpdb->prefix}give_customers" ) ) ) { |
|
2555 | - $customers = wp_list_pluck( $wpdb->get_results( "SELECT id FROM {$wpdb->prefix}give_customers" ), 'id' ); |
|
2556 | - $donors = wp_list_pluck( $wpdb->get_results( "SELECT id FROM {$wpdb->prefix}give_donors" ), 'id' ); |
|
2554 | + if ($wpdb->query($wpdb->prepare('SHOW TABLES LIKE %s', "{$wpdb->prefix}give_customers"))) { |
|
2555 | + $customers = wp_list_pluck($wpdb->get_results("SELECT id FROM {$wpdb->prefix}give_customers"), 'id'); |
|
2556 | + $donors = wp_list_pluck($wpdb->get_results("SELECT id FROM {$wpdb->prefix}give_donors"), 'id'); |
|
2557 | 2557 | $donor_data = array(); |
2558 | 2558 | |
2559 | - if ( $missing_donors = array_diff( $customers, $donors ) ) { |
|
2560 | - foreach ( $missing_donors as $donor_id ) { |
|
2559 | + if ($missing_donors = array_diff($customers, $donors)) { |
|
2560 | + foreach ($missing_donors as $donor_id) { |
|
2561 | 2561 | $donor_data[] = array( |
2562 | - 'info' => $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_customers WHERE id=%d", $donor_id ) ), |
|
2563 | - 'meta' => $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_customermeta WHERE customer_id=%d", $donor_id ) ), |
|
2562 | + 'info' => $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_customers WHERE id=%d", $donor_id)), |
|
2563 | + 'meta' => $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_customermeta WHERE customer_id=%d", $donor_id)), |
|
2564 | 2564 | |
2565 | 2565 | ); |
2566 | 2566 | } |
2567 | 2567 | } |
2568 | 2568 | |
2569 | - if ( ! empty( $donor_data ) ) { |
|
2569 | + if ( ! empty($donor_data)) { |
|
2570 | 2570 | $donor_table_name = Give()->donors->table_name; |
2571 | 2571 | $donor_meta_table_name = Give()->donor_meta->table_name; |
2572 | 2572 | |
2573 | 2573 | Give()->donors->table_name = "{$wpdb->prefix}give_donors"; |
2574 | 2574 | Give()->donor_meta->table_name = "{$wpdb->prefix}give_donormeta"; |
2575 | 2575 | |
2576 | - foreach ( $donor_data as $donor ) { |
|
2576 | + foreach ($donor_data as $donor) { |
|
2577 | 2577 | $donor['info'][0] = (array) $donor['info'][0]; |
2578 | 2578 | |
2579 | 2579 | // Prevent duplicate meta id issue. |
2580 | - if ( $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_donors WHERE id=%d", $donor['info'][0]['id'] ) ) ) { |
|
2580 | + if ($wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_donors WHERE id=%d", $donor['info'][0]['id']))) { |
|
2581 | 2581 | continue; |
2582 | 2582 | } |
2583 | 2583 | |
2584 | - $donor_id = Give()->donors->add( $donor['info'][0] ); |
|
2584 | + $donor_id = Give()->donors->add($donor['info'][0]); |
|
2585 | 2585 | |
2586 | - if ( ! empty( $donor['meta'] ) ) { |
|
2587 | - foreach ( $donor['meta'] as $donor_meta ) { |
|
2586 | + if ( ! empty($donor['meta'])) { |
|
2587 | + foreach ($donor['meta'] as $donor_meta) { |
|
2588 | 2588 | $donor_meta = (array) $donor_meta; |
2589 | 2589 | |
2590 | 2590 | // Prevent duplicate meta id issue. |
2591 | - if ( $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_donormeta WHERE meta_id=%d", $donor_meta['meta_id'] ) ) ) { |
|
2592 | - unset( $donor_meta['meta_id'] ); |
|
2591 | + if ($wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_donormeta WHERE meta_id=%d", $donor_meta['meta_id']))) { |
|
2592 | + unset($donor_meta['meta_id']); |
|
2593 | 2593 | } |
2594 | 2594 | |
2595 | 2595 | $donor_meta['donor_id'] = $donor_meta['customer_id']; |
2596 | - unset( $donor_meta['customer_id'] ); |
|
2596 | + unset($donor_meta['customer_id']); |
|
2597 | 2597 | |
2598 | - Give()->donor_meta->insert( $donor_meta ); |
|
2598 | + Give()->donor_meta->insert($donor_meta); |
|
2599 | 2599 | } |
2600 | 2600 | } |
2601 | 2601 | |
@@ -2614,35 +2614,35 @@ discard block |
||
2614 | 2614 | ) |
2615 | 2615 | ); |
2616 | 2616 | |
2617 | - $donor = new Give_Donor( $donor_id ); |
|
2617 | + $donor = new Give_Donor($donor_id); |
|
2618 | 2618 | |
2619 | - if ( ! empty( $address ) ) { |
|
2620 | - $address = maybe_unserialize( $address ); |
|
2621 | - $donor->add_address( 'personal', $address ); |
|
2622 | - $donor->add_address( 'billing[]', $address ); |
|
2619 | + if ( ! empty($address)) { |
|
2620 | + $address = maybe_unserialize($address); |
|
2621 | + $donor->add_address('personal', $address); |
|
2622 | + $donor->add_address('billing[]', $address); |
|
2623 | 2623 | } |
2624 | 2624 | |
2625 | - $donor_name = explode( ' ', $donor->name, 2 ); |
|
2626 | - $donor_first_name = Give()->donor_meta->get_meta( $donor->id, '_give_donor_first_name' ); |
|
2627 | - $donor_last_name = Give()->donor_meta->get_meta( $donor->id, '_give_donor_last_name' ); |
|
2625 | + $donor_name = explode(' ', $donor->name, 2); |
|
2626 | + $donor_first_name = Give()->donor_meta->get_meta($donor->id, '_give_donor_first_name'); |
|
2627 | + $donor_last_name = Give()->donor_meta->get_meta($donor->id, '_give_donor_last_name'); |
|
2628 | 2628 | |
2629 | 2629 | // If first name meta of donor is not created, then create it. |
2630 | - if ( ! $donor_first_name && isset( $donor_name[0] ) ) { |
|
2631 | - Give()->donor_meta->add_meta( $donor->id, '_give_donor_first_name', $donor_name[0] ); |
|
2630 | + if ( ! $donor_first_name && isset($donor_name[0])) { |
|
2631 | + Give()->donor_meta->add_meta($donor->id, '_give_donor_first_name', $donor_name[0]); |
|
2632 | 2632 | } |
2633 | 2633 | |
2634 | 2634 | // If last name meta of donor is not created, then create it. |
2635 | - if ( ! $donor_last_name && isset( $donor_name[1] ) ) { |
|
2636 | - Give()->donor_meta->add_meta( $donor->id, '_give_donor_last_name', $donor_name[1] ); |
|
2635 | + if ( ! $donor_last_name && isset($donor_name[1])) { |
|
2636 | + Give()->donor_meta->add_meta($donor->id, '_give_donor_last_name', $donor_name[1]); |
|
2637 | 2637 | } |
2638 | 2638 | |
2639 | 2639 | // If Donor is connected with WP User then update user meta. |
2640 | - if ( $donor->user_id ) { |
|
2641 | - if ( isset( $donor_name[0] ) ) { |
|
2642 | - update_user_meta( $donor->user_id, 'first_name', $donor_name[0] ); |
|
2640 | + if ($donor->user_id) { |
|
2641 | + if (isset($donor_name[0])) { |
|
2642 | + update_user_meta($donor->user_id, 'first_name', $donor_name[0]); |
|
2643 | 2643 | } |
2644 | - if ( isset( $donor_name[1] ) ) { |
|
2645 | - update_user_meta( $donor->user_id, 'last_name', $donor_name[1] ); |
|
2644 | + if (isset($donor_name[1])) { |
|
2645 | + update_user_meta($donor->user_id, 'last_name', $donor_name[1]); |
|
2646 | 2646 | } |
2647 | 2647 | } |
2648 | 2648 | } |
@@ -2653,7 +2653,7 @@ discard block |
||
2653 | 2653 | } |
2654 | 2654 | |
2655 | 2655 | Give_Updates::get_instance()->percentage = 100; |
2656 | - give_set_upgrade_complete( 'v201_add_missing_donors' ); |
|
2656 | + give_set_upgrade_complete('v201_add_missing_donors'); |
|
2657 | 2657 | } |
2658 | 2658 | |
2659 | 2659 | |
@@ -2666,14 +2666,14 @@ discard block |
||
2666 | 2666 | global $wpdb; |
2667 | 2667 | |
2668 | 2668 | // Do not auto load option. |
2669 | - $wpdb->update( $wpdb->options, array( 'autoload' => 'no' ), array( 'option_name' => 'give_completed_upgrades' ) ); |
|
2669 | + $wpdb->update($wpdb->options, array('autoload' => 'no'), array('option_name' => 'give_completed_upgrades')); |
|
2670 | 2670 | |
2671 | 2671 | // Remove from cache. |
2672 | 2672 | $all_options = wp_load_alloptions(); |
2673 | 2673 | |
2674 | - if ( isset( $all_options['give_completed_upgrades'] ) ) { |
|
2675 | - unset( $all_options['give_completed_upgrades'] ); |
|
2676 | - wp_cache_set( 'alloptions', $all_options, 'options' ); |
|
2674 | + if (isset($all_options['give_completed_upgrades'])) { |
|
2675 | + unset($all_options['give_completed_upgrades']); |
|
2676 | + wp_cache_set('alloptions', $all_options, 'options'); |
|
2677 | 2677 | } |
2678 | 2678 | |
2679 | 2679 | } |
@@ -2737,11 +2737,11 @@ discard block |
||
2737 | 2737 | " |
2738 | 2738 | ); |
2739 | 2739 | |
2740 | - if ( ! empty( $option_like ) ) { |
|
2741 | - $options = array_merge( $options, $option_like ); |
|
2740 | + if ( ! empty($option_like)) { |
|
2741 | + $options = array_merge($options, $option_like); |
|
2742 | 2742 | } |
2743 | 2743 | |
2744 | - $options_str = '\'' . implode( "','", $options ) . '\''; |
|
2744 | + $options_str = '\''.implode("','", $options).'\''; |
|
2745 | 2745 | |
2746 | 2746 | $wpdb->query( |
2747 | 2747 | " |
@@ -2765,7 +2765,7 @@ discard block |
||
2765 | 2765 | * |
2766 | 2766 | * Change column length |
2767 | 2767 | */ |
2768 | - $wpdb->query( "ALTER TABLE $wpdb->donors MODIFY email varchar(255) NOT NULL" ); |
|
2768 | + $wpdb->query("ALTER TABLE $wpdb->donors MODIFY email varchar(255) NOT NULL"); |
|
2769 | 2769 | } |
2770 | 2770 | |
2771 | 2771 | /** |
@@ -2788,16 +2788,16 @@ discard block |
||
2788 | 2788 | ) |
2789 | 2789 | ); |
2790 | 2790 | |
2791 | - if ( $donation_forms->have_posts() ) { |
|
2792 | - $give_updates->set_percentage( $donation_forms->found_posts, ( $give_updates->step * 20 ) ); |
|
2791 | + if ($donation_forms->have_posts()) { |
|
2792 | + $give_updates->set_percentage($donation_forms->found_posts, ($give_updates->step * 20)); |
|
2793 | 2793 | |
2794 | - while ( $donation_forms->have_posts() ) { |
|
2794 | + while ($donation_forms->have_posts()) { |
|
2795 | 2795 | $donation_forms->the_post(); |
2796 | 2796 | $form_id = get_the_ID(); |
2797 | 2797 | |
2798 | - $form_closed_status = give_get_meta( $form_id, '_give_form_status', true ); |
|
2799 | - if ( empty( $form_closed_status ) ) { |
|
2800 | - give_set_form_closed_status( $form_id ); |
|
2798 | + $form_closed_status = give_get_meta($form_id, '_give_form_status', true); |
|
2799 | + if (empty($form_closed_status)) { |
|
2800 | + give_set_form_closed_status($form_id); |
|
2801 | 2801 | } |
2802 | 2802 | } |
2803 | 2803 | |
@@ -2807,7 +2807,7 @@ discard block |
||
2807 | 2807 | } else { |
2808 | 2808 | |
2809 | 2809 | // The Update Ran. |
2810 | - give_set_upgrade_complete( 'v210_verify_form_status_upgrades' ); |
|
2810 | + give_set_upgrade_complete('v210_verify_form_status_upgrades'); |
|
2811 | 2811 | } |
2812 | 2812 | } |
2813 | 2813 | |
@@ -2826,22 +2826,22 @@ discard block |
||
2826 | 2826 | SELECT DISTINCT payment_id |
2827 | 2827 | FROM {$donation_meta_table} |
2828 | 2828 | LIMIT 20 |
2829 | - OFFSET {$give_updates->get_offset( 20 )} |
|
2829 | + OFFSET {$give_updates->get_offset(20)} |
|
2830 | 2830 | " |
2831 | 2831 | ); |
2832 | 2832 | |
2833 | - if ( ! empty( $donations ) ) { |
|
2834 | - foreach ( $donations as $donation ) { |
|
2835 | - $donation_obj = get_post( $donation ); |
|
2833 | + if ( ! empty($donations)) { |
|
2834 | + foreach ($donations as $donation) { |
|
2835 | + $donation_obj = get_post($donation); |
|
2836 | 2836 | |
2837 | - if ( ! $donation_obj instanceof WP_Post ) { |
|
2838 | - Give()->payment_meta->delete_all_meta( $donation ); |
|
2837 | + if ( ! $donation_obj instanceof WP_Post) { |
|
2838 | + Give()->payment_meta->delete_all_meta($donation); |
|
2839 | 2839 | } |
2840 | 2840 | } |
2841 | 2841 | } else { |
2842 | 2842 | |
2843 | 2843 | // The Update Ran. |
2844 | - give_set_upgrade_complete( 'v213_delete_donation_meta' ); |
|
2844 | + give_set_upgrade_complete('v213_delete_donation_meta'); |
|
2845 | 2845 | } |
2846 | 2846 | } |
2847 | 2847 | |
@@ -2857,16 +2857,16 @@ discard block |
||
2857 | 2857 | |
2858 | 2858 | // Check upgrade before running. |
2859 | 2859 | if ( |
2860 | - give_has_upgrade_completed( 'v220_rename_donation_meta_type' ) |
|
2861 | - || ! $wpdb->query( $wpdb->prepare( 'SHOW TABLES LIKE %s', "{$wpdb->prefix}give_paymentmeta" ) ) |
|
2860 | + give_has_upgrade_completed('v220_rename_donation_meta_type') |
|
2861 | + || ! $wpdb->query($wpdb->prepare('SHOW TABLES LIKE %s', "{$wpdb->prefix}give_paymentmeta")) |
|
2862 | 2862 | ) { |
2863 | 2863 | return; |
2864 | 2864 | } |
2865 | 2865 | |
2866 | - $wpdb->query( "ALTER TABLE {$wpdb->prefix}give_paymentmeta CHANGE COLUMN payment_id donation_id bigint(20)" ); |
|
2867 | - $wpdb->query( "ALTER TABLE {$wpdb->prefix}give_paymentmeta RENAME TO {$wpdb->prefix}give_donationmeta" ); |
|
2866 | + $wpdb->query("ALTER TABLE {$wpdb->prefix}give_paymentmeta CHANGE COLUMN payment_id donation_id bigint(20)"); |
|
2867 | + $wpdb->query("ALTER TABLE {$wpdb->prefix}give_paymentmeta RENAME TO {$wpdb->prefix}give_donationmeta"); |
|
2868 | 2868 | |
2869 | - give_set_upgrade_complete( 'v220_rename_donation_meta_type' ); |
|
2869 | + give_set_upgrade_complete('v220_rename_donation_meta_type'); |
|
2870 | 2870 | } |
2871 | 2871 | |
2872 | 2872 | /** |
@@ -2876,10 +2876,10 @@ discard block |
||
2876 | 2876 | */ |
2877 | 2877 | function give_v215_update_donor_user_roles_callback() { |
2878 | 2878 | |
2879 | - $role = get_role( 'give_manager' ); |
|
2880 | - $role->add_cap( 'view_give_payments' ); |
|
2879 | + $role = get_role('give_manager'); |
|
2880 | + $role->add_cap('view_give_payments'); |
|
2881 | 2881 | |
2882 | - give_set_upgrade_complete( 'v215_update_donor_user_roles' ); |
|
2882 | + give_set_upgrade_complete('v215_update_donor_user_roles'); |
|
2883 | 2883 | } |
2884 | 2884 | |
2885 | 2885 | |
@@ -2894,7 +2894,7 @@ discard block |
||
2894 | 2894 | function give_v220_delete_wp_session_data() { |
2895 | 2895 | global $wpdb; |
2896 | 2896 | |
2897 | - $wpdb->query( "DELETE FROM $wpdb->options WHERE option_name LIKE '_wp_session_%'" ); |
|
2897 | + $wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE '_wp_session_%'"); |
|
2898 | 2898 | } |
2899 | 2899 | |
2900 | 2900 | |
@@ -2921,20 +2921,20 @@ discard block |
||
2921 | 2921 | ) |
2922 | 2922 | ); |
2923 | 2923 | |
2924 | - if ( $donors ) { |
|
2925 | - $give_updates->set_percentage( $donor_count, $give_updates->step * 100 ); |
|
2924 | + if ($donors) { |
|
2925 | + $give_updates->set_percentage($donor_count, $give_updates->step * 100); |
|
2926 | 2926 | // Loop through Donors |
2927 | - foreach ( $donors as $donor ) { |
|
2928 | - $anonymous_metadata = Give()->donor_meta->get_meta( $donor->id, '_give_anonymous_donor', true ); |
|
2927 | + foreach ($donors as $donor) { |
|
2928 | + $anonymous_metadata = Give()->donor_meta->get_meta($donor->id, '_give_anonymous_donor', true); |
|
2929 | 2929 | |
2930 | 2930 | // If first name meta of donor is not created, then create it. |
2931 | - if ( ! in_array( $anonymous_metadata, array( '0', '1' ) ) ) { |
|
2932 | - Give()->donor_meta->add_meta( $donor->id, '_give_anonymous_donor', '0' ); |
|
2931 | + if ( ! in_array($anonymous_metadata, array('0', '1'))) { |
|
2932 | + Give()->donor_meta->add_meta($donor->id, '_give_anonymous_donor', '0'); |
|
2933 | 2933 | } |
2934 | 2934 | } |
2935 | 2935 | } else { |
2936 | 2936 | // The Update Ran. |
2937 | - give_set_upgrade_complete( 'v224_update_donor_meta' ); |
|
2937 | + give_set_upgrade_complete('v224_update_donor_meta'); |
|
2938 | 2938 | } |
2939 | 2939 | } |
2940 | 2940 | |
@@ -2949,39 +2949,39 @@ discard block |
||
2949 | 2949 | function give_v224_update_donor_meta_forms_id_callback() { |
2950 | 2950 | $give_updates = Give_Updates::get_instance(); |
2951 | 2951 | |
2952 | - $donations = new WP_Query( array( |
|
2952 | + $donations = new WP_Query(array( |
|
2953 | 2953 | 'paged' => $give_updates->step, |
2954 | 2954 | 'status' => 'any', |
2955 | 2955 | 'order' => 'ASC', |
2956 | - 'post_type' => array( 'give_payment' ), |
|
2956 | + 'post_type' => array('give_payment'), |
|
2957 | 2957 | 'posts_per_page' => 20, |
2958 | 2958 | ) |
2959 | 2959 | ); |
2960 | 2960 | |
2961 | - if ( $donations->have_posts() ) { |
|
2962 | - $give_updates->set_percentage( $donations->found_posts, $give_updates->step * 20 ); |
|
2961 | + if ($donations->have_posts()) { |
|
2962 | + $give_updates->set_percentage($donations->found_posts, $give_updates->step * 20); |
|
2963 | 2963 | |
2964 | - while ( $donations->have_posts() ) { |
|
2964 | + while ($donations->have_posts()) { |
|
2965 | 2965 | $donations->the_post(); |
2966 | 2966 | |
2967 | 2967 | $donation_id = get_the_ID(); |
2968 | 2968 | |
2969 | - $form_id = give_get_payment_form_id( $donation_id ); |
|
2970 | - $donor_id = give_get_payment_donor_id( $donation_id ); |
|
2971 | - $is_donated_as_anonymous = give_is_anonymous_donation( $donation_id ); |
|
2969 | + $form_id = give_get_payment_form_id($donation_id); |
|
2970 | + $donor_id = give_get_payment_donor_id($donation_id); |
|
2971 | + $is_donated_as_anonymous = give_is_anonymous_donation($donation_id); |
|
2972 | 2972 | |
2973 | - $is_anonymous_donor = Give()->donor_meta->get_meta( $donor_id, "_give_anonymous_donor_form_{$form_id}", true ); |
|
2974 | - $is_edit_donor_meta = ! in_array( $is_anonymous_donor, array( '0', '1' ) ) |
|
2973 | + $is_anonymous_donor = Give()->donor_meta->get_meta($donor_id, "_give_anonymous_donor_form_{$form_id}", true); |
|
2974 | + $is_edit_donor_meta = ! in_array($is_anonymous_donor, array('0', '1')) |
|
2975 | 2975 | ? true |
2976 | - : ( 0 !== absint( $is_anonymous_donor ) ); |
|
2976 | + : (0 !== absint($is_anonymous_donor)); |
|
2977 | 2977 | |
2978 | - if ( $is_edit_donor_meta ) { |
|
2979 | - Give()->donor_meta->update_meta( $donor_id, "_give_anonymous_donor_form_{$form_id}", absint( $is_donated_as_anonymous ) ); |
|
2978 | + if ($is_edit_donor_meta) { |
|
2979 | + Give()->donor_meta->update_meta($donor_id, "_give_anonymous_donor_form_{$form_id}", absint($is_donated_as_anonymous)); |
|
2980 | 2980 | } |
2981 | 2981 | } |
2982 | 2982 | |
2983 | 2983 | wp_reset_postdata(); |
2984 | 2984 | } else { |
2985 | - give_set_upgrade_complete( 'v224_update_donor_meta_forms_id' ); |
|
2985 | + give_set_upgrade_complete('v224_update_donor_meta_forms_id'); |
|
2986 | 2986 | } |
2987 | 2987 | } |
@@ -8,40 +8,40 @@ discard block |
||
8 | 8 | * @param array $donation_data |
9 | 9 | * |
10 | 10 | */ |
11 | -function __give_insert_donor_donation_comment( $donation_id, $donation_data ) { |
|
12 | - $is_anonymous_donation = isset( $_POST['give_anonymous_donation'] ) |
|
13 | - ? absint( $_POST['give_anonymous_donation'] ) |
|
11 | +function __give_insert_donor_donation_comment($donation_id, $donation_data) { |
|
12 | + $is_anonymous_donation = isset($_POST['give_anonymous_donation']) |
|
13 | + ? absint($_POST['give_anonymous_donation']) |
|
14 | 14 | : 0; |
15 | 15 | |
16 | - $form_id = isset( $donation_data['give_form_id'] ) ? absint( $donation_data['give_form_id'] ) : 0; |
|
16 | + $form_id = isset($donation_data['give_form_id']) ? absint($donation_data['give_form_id']) : 0; |
|
17 | 17 | $donor_id = $donation_data['user_info']['donor_id']; |
18 | - $is_anonymous_donor = Give()->donor_meta->get_meta( $donor_id, "_give_anonymous_donor_form_{$form_id}", true ); |
|
19 | - $is_edit_donor_meta = ! in_array( $is_anonymous_donor, array( '0', '1' ) ) |
|
18 | + $is_anonymous_donor = Give()->donor_meta->get_meta($donor_id, "_give_anonymous_donor_form_{$form_id}", true); |
|
19 | + $is_edit_donor_meta = ! in_array($is_anonymous_donor, array('0', '1')) |
|
20 | 20 | ? true |
21 | - : ( 0 !== absint( $is_anonymous_donor ) ); |
|
21 | + : (0 !== absint($is_anonymous_donor)); |
|
22 | 22 | |
23 | 23 | |
24 | - if ( ! empty( $_POST['give_comment'] ) ) { |
|
24 | + if ( ! empty($_POST['give_comment'])) { |
|
25 | 25 | $comment_id = give_insert_donor_donation_comment( |
26 | 26 | $donation_id, |
27 | 27 | $donation_data['user_info']['donor_id'], |
28 | - trim( $_POST['give_comment'] ), // We are sanitizing comment in Give_comment:add |
|
29 | - array( 'comment_author_email' => $donation_data['user_info']['email'] ) |
|
28 | + trim($_POST['give_comment']), // We are sanitizing comment in Give_comment:add |
|
29 | + array('comment_author_email' => $donation_data['user_info']['email']) |
|
30 | 30 | ); |
31 | 31 | |
32 | - update_comment_meta( $comment_id, '_give_anonymous_donation', $is_anonymous_donation ); |
|
33 | - Give()->donor_meta->update_meta( $donor_id, '_give_has_comment', '1' ); |
|
32 | + update_comment_meta($comment_id, '_give_anonymous_donation', $is_anonymous_donation); |
|
33 | + Give()->donor_meta->update_meta($donor_id, '_give_has_comment', '1'); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | // Set donor as anonymous for donation form. |
37 | - if ( $is_edit_donor_meta ) { |
|
38 | - Give()->donor_meta->update_meta( $donor_id, "_give_anonymous_donor_form_{$form_id}", $is_anonymous_donation ); |
|
37 | + if ($is_edit_donor_meta) { |
|
38 | + Give()->donor_meta->update_meta($donor_id, "_give_anonymous_donor_form_{$form_id}", $is_anonymous_donation); |
|
39 | 39 | } |
40 | 40 | |
41 | - give_update_meta( $donation_id, '_give_anonymous_donation', $is_anonymous_donation ); |
|
41 | + give_update_meta($donation_id, '_give_anonymous_donation', $is_anonymous_donation); |
|
42 | 42 | } |
43 | 43 | |
44 | -add_action( 'give_insert_payment', '__give_insert_donor_donation_comment', 10, 2 ); |
|
44 | +add_action('give_insert_payment', '__give_insert_donor_donation_comment', 10, 2); |
|
45 | 45 | |
46 | 46 | |
47 | 47 | /** |
@@ -51,16 +51,16 @@ discard block |
||
51 | 51 | */ |
52 | 52 | function __give_validate_donor_comment() { |
53 | 53 | // Check wp_check_comment_data_max_lengths for comment length validation. |
54 | - if ( ! empty( $_POST['give_comment'] ) ) { |
|
54 | + if ( ! empty($_POST['give_comment'])) { |
|
55 | 55 | $max_lengths = wp_get_comment_fields_max_lengths(); |
56 | - $comment = give_clean( $_POST['give_comment'] ); |
|
56 | + $comment = give_clean($_POST['give_comment']); |
|
57 | 57 | |
58 | - if ( mb_strlen( $comment, '8bit' ) > $max_lengths['comment_content'] ) { |
|
59 | - give_set_error( 'comment_content_column_length', __( 'Your comment is too long.', 'give' ) ); |
|
58 | + if (mb_strlen($comment, '8bit') > $max_lengths['comment_content']) { |
|
59 | + give_set_error('comment_content_column_length', __('Your comment is too long.', 'give')); |
|
60 | 60 | } |
61 | 61 | } |
62 | 62 | } |
63 | -add_action( 'give_checkout_error_checks', '__give_validate_donor_comment', 10, 1 ); |
|
63 | +add_action('give_checkout_error_checks', '__give_validate_donor_comment', 10, 1); |
|
64 | 64 | |
65 | 65 | |
66 | 66 | /** |
@@ -71,18 +71,18 @@ discard block |
||
71 | 71 | * @param $donation_id |
72 | 72 | * @param $status |
73 | 73 | */ |
74 | -function __give_update_donor_donation_comment_status( $donation_id, $status ) { |
|
75 | - $approve = absint( 'publish' === $status ); |
|
74 | +function __give_update_donor_donation_comment_status($donation_id, $status) { |
|
75 | + $approve = absint('publish' === $status); |
|
76 | 76 | |
77 | 77 | /* @var WP_Comment $note */ |
78 | - $donor_comment = give_get_donor_donation_comment( $donation_id, give_get_payment_donor_id( $donation_id ) ); |
|
78 | + $donor_comment = give_get_donor_donation_comment($donation_id, give_get_payment_donor_id($donation_id)); |
|
79 | 79 | |
80 | - if( $donor_comment instanceof WP_Comment ) { |
|
81 | - wp_set_comment_status( $donor_comment->comment_ID, (string) $approve ); |
|
80 | + if ($donor_comment instanceof WP_Comment) { |
|
81 | + wp_set_comment_status($donor_comment->comment_ID, (string) $approve); |
|
82 | 82 | } |
83 | 83 | } |
84 | 84 | |
85 | -add_action( 'give_update_payment_status', '__give_update_donor_donation_comment_status', 10, 2 ); |
|
85 | +add_action('give_update_payment_status', '__give_update_donor_donation_comment_status', 10, 2); |
|
86 | 86 | |
87 | 87 | /** |
88 | 88 | * Remove donor comment when donation delete |
@@ -91,13 +91,13 @@ discard block |
||
91 | 91 | * |
92 | 92 | * @param $donation_id |
93 | 93 | */ |
94 | -function __give_remove_donor_donation_comment( $donation_id ) { |
|
94 | +function __give_remove_donor_donation_comment($donation_id) { |
|
95 | 95 | /* @var WP_Comment $note */ |
96 | - $donor_comment = give_get_donor_donation_comment( $donation_id, give_get_payment_donor_id( $donation_id ) ); |
|
96 | + $donor_comment = give_get_donor_donation_comment($donation_id, give_get_payment_donor_id($donation_id)); |
|
97 | 97 | |
98 | - if( $donor_comment instanceof WP_Comment ) { |
|
99 | - wp_delete_comment( $donor_comment->comment_ID ); |
|
98 | + if ($donor_comment instanceof WP_Comment) { |
|
99 | + wp_delete_comment($donor_comment->comment_ID); |
|
100 | 100 | } |
101 | 101 | } |
102 | 102 | |
103 | -add_action( 'give_payment_deleted', '__give_remove_donor_donation_comment', 10 ); |
|
103 | +add_action('give_payment_deleted', '__give_remove_donor_donation_comment', 10); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -25,48 +25,48 @@ discard block |
||
25 | 25 | * |
26 | 26 | * @return void |
27 | 27 | */ |
28 | -function give_update_payment_details( $data ) { |
|
28 | +function give_update_payment_details($data) { |
|
29 | 29 | |
30 | - if ( ! current_user_can( 'edit_give_payments', $data['give_payment_id'] ) ) { |
|
31 | - wp_die( __( 'You do not have permission to edit payments.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
30 | + if ( ! current_user_can('edit_give_payments', $data['give_payment_id'])) { |
|
31 | + wp_die(__('You do not have permission to edit payments.', 'give'), __('Error', 'give'), array('response' => 403)); |
|
32 | 32 | } |
33 | 33 | |
34 | - check_admin_referer( 'give_update_payment_details_nonce' ); |
|
34 | + check_admin_referer('give_update_payment_details_nonce'); |
|
35 | 35 | |
36 | 36 | // Retrieve the payment ID. |
37 | - $payment_id = absint( $data['give_payment_id'] ); |
|
37 | + $payment_id = absint($data['give_payment_id']); |
|
38 | 38 | |
39 | 39 | /* @var Give_Payment $payment */ |
40 | - $payment = new Give_Payment( $payment_id ); |
|
40 | + $payment = new Give_Payment($payment_id); |
|
41 | 41 | |
42 | 42 | $status = $data['give-payment-status']; |
43 | - $date = sanitize_text_field( $data['give-payment-date'] ); |
|
44 | - $hour = sanitize_text_field( $data['give-payment-time-hour'] ); |
|
43 | + $date = sanitize_text_field($data['give-payment-date']); |
|
44 | + $hour = sanitize_text_field($data['give-payment-time-hour']); |
|
45 | 45 | |
46 | 46 | // Restrict to our high and low. |
47 | - if ( $hour > 23 ) { |
|
47 | + if ($hour > 23) { |
|
48 | 48 | $hour = 23; |
49 | - } elseif ( $hour < 0 ) { |
|
49 | + } elseif ($hour < 0) { |
|
50 | 50 | $hour = 00; |
51 | 51 | } |
52 | 52 | |
53 | - $minute = sanitize_text_field( $data['give-payment-time-min'] ); |
|
53 | + $minute = sanitize_text_field($data['give-payment-time-min']); |
|
54 | 54 | |
55 | 55 | // Restrict to our high and low. |
56 | - if ( $minute > 59 ) { |
|
56 | + if ($minute > 59) { |
|
57 | 57 | $minute = 59; |
58 | - } elseif ( $minute < 0 ) { |
|
58 | + } elseif ($minute < 0) { |
|
59 | 59 | $minute = 00; |
60 | 60 | } |
61 | 61 | |
62 | - $address = give_clean( $data['give-payment-address'][0] ); |
|
62 | + $address = give_clean($data['give-payment-address'][0]); |
|
63 | 63 | |
64 | 64 | $curr_total = $payment->total; |
65 | - $new_total = give_maybe_sanitize_amount( ( ! empty( $data['give-payment-total'] ) ? $data['give-payment-total'] : 0 ) ); |
|
66 | - $date = date( 'Y-m-d', strtotime( $date ) ) . ' ' . $hour . ':' . $minute . ':00'; |
|
65 | + $new_total = give_maybe_sanitize_amount(( ! empty($data['give-payment-total']) ? $data['give-payment-total'] : 0)); |
|
66 | + $date = date('Y-m-d', strtotime($date)).' '.$hour.':'.$minute.':00'; |
|
67 | 67 | |
68 | - $curr_donor_id = sanitize_text_field( $data['give-current-donor'] ); |
|
69 | - $new_donor_id = sanitize_text_field( $data['donor-id'] ); |
|
68 | + $curr_donor_id = sanitize_text_field($data['give-current-donor']); |
|
69 | + $new_donor_id = sanitize_text_field($data['donor-id']); |
|
70 | 70 | |
71 | 71 | /** |
72 | 72 | * Fires before updating edited donation. |
@@ -76,74 +76,74 @@ discard block |
||
76 | 76 | * |
77 | 77 | * @param int $payment_id The ID of the payment. |
78 | 78 | */ |
79 | - do_action( 'give_update_edited_donation', $payment_id ); |
|
79 | + do_action('give_update_edited_donation', $payment_id); |
|
80 | 80 | |
81 | 81 | $payment->date = $date; |
82 | - $payment->anonymous = isset( $data['give_anonymous_donation'] ) ? absint( $data['give_anonymous_donation'] ) : 0; |
|
82 | + $payment->anonymous = isset($data['give_anonymous_donation']) ? absint($data['give_anonymous_donation']) : 0; |
|
83 | 83 | |
84 | 84 | |
85 | - $updated = $payment->save(); |
|
85 | + $updated = $payment->save(); |
|
86 | 86 | |
87 | - if ( 0 === $updated ) { |
|
88 | - wp_die( __( 'Error Updating Donation.', 'give' ), __( 'Error', 'give' ), array( 'response' => 400 ) ); |
|
87 | + if (0 === $updated) { |
|
88 | + wp_die(__('Error Updating Donation.', 'give'), __('Error', 'give'), array('response' => 400)); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | $donor_changed = false; |
92 | 92 | |
93 | - if ( isset( $data['give-new-donor'] ) && $data['give-new-donor'] == '1' ) { |
|
93 | + if (isset($data['give-new-donor']) && $data['give-new-donor'] == '1') { |
|
94 | 94 | |
95 | - $email = ! empty( $data['give-new-donor-email'] ) ? sanitize_text_field( $data['give-new-donor-email'] ) : ''; |
|
96 | - $first_name = ! empty( $data['give-new-donor-first-name'] ) ? sanitize_text_field( $data['give-new-donor-first-name'] ) : ''; |
|
97 | - $last_name = ! empty( $data['give-new-donor-last-name'] ) ? sanitize_text_field( $data['give-new-donor-last-name'] ) : ''; |
|
98 | - $names = strip_tags( wp_unslash( trim( "{$first_name} {$last_name}" ) ) ); |
|
95 | + $email = ! empty($data['give-new-donor-email']) ? sanitize_text_field($data['give-new-donor-email']) : ''; |
|
96 | + $first_name = ! empty($data['give-new-donor-first-name']) ? sanitize_text_field($data['give-new-donor-first-name']) : ''; |
|
97 | + $last_name = ! empty($data['give-new-donor-last-name']) ? sanitize_text_field($data['give-new-donor-last-name']) : ''; |
|
98 | + $names = strip_tags(wp_unslash(trim("{$first_name} {$last_name}"))); |
|
99 | 99 | |
100 | - if ( empty( $email ) || empty( $first_name ) ) { |
|
101 | - wp_die( __( 'New Donor requires first name and email address.', 'give' ), __( 'Error', 'give' ), array( 'response' => 400 ) ); |
|
100 | + if (empty($email) || empty($first_name)) { |
|
101 | + wp_die(__('New Donor requires first name and email address.', 'give'), __('Error', 'give'), array('response' => 400)); |
|
102 | 102 | } |
103 | 103 | |
104 | - $donor = new Give_Donor( $email ); |
|
105 | - if ( empty( $donor->id ) ) { |
|
106 | - $donor_data = array( 'name' => $names, 'email' => $email ); |
|
107 | - $user_id = email_exists( $email ); |
|
108 | - if ( false !== $user_id ) { |
|
104 | + $donor = new Give_Donor($email); |
|
105 | + if (empty($donor->id)) { |
|
106 | + $donor_data = array('name' => $names, 'email' => $email); |
|
107 | + $user_id = email_exists($email); |
|
108 | + if (false !== $user_id) { |
|
109 | 109 | $donor_data['user_id'] = $user_id; |
110 | 110 | } |
111 | 111 | |
112 | - if ( ! $donor->create( $donor_data ) ) { |
|
112 | + if ( ! $donor->create($donor_data)) { |
|
113 | 113 | // Failed to create the new donor, assume the previous donor. |
114 | 114 | $donor_changed = false; |
115 | - $donor = new Give_Donor( $curr_donor_id ); |
|
116 | - give_set_error( 'give-payment-new-donor-fail', __( 'Error creating new donor.', 'give' ) ); |
|
115 | + $donor = new Give_Donor($curr_donor_id); |
|
116 | + give_set_error('give-payment-new-donor-fail', __('Error creating new donor.', 'give')); |
|
117 | 117 | } |
118 | 118 | } |
119 | 119 | |
120 | 120 | // Create and Update Donor First Name and Last Name in Meta Fields. |
121 | - $donor->update_meta( '_give_donor_first_name', $first_name ); |
|
122 | - $donor->update_meta( '_give_donor_last_name', $last_name ); |
|
121 | + $donor->update_meta('_give_donor_first_name', $first_name); |
|
122 | + $donor->update_meta('_give_donor_last_name', $last_name); |
|
123 | 123 | |
124 | 124 | $new_donor_id = $donor->id; |
125 | 125 | |
126 | - $previous_donor = new Give_Donor( $curr_donor_id ); |
|
126 | + $previous_donor = new Give_Donor($curr_donor_id); |
|
127 | 127 | |
128 | 128 | $donor_changed = true; |
129 | 129 | |
130 | - } elseif ( $curr_donor_id !== $new_donor_id ) { |
|
130 | + } elseif ($curr_donor_id !== $new_donor_id) { |
|
131 | 131 | |
132 | - $donor = new Give_Donor( $new_donor_id ); |
|
132 | + $donor = new Give_Donor($new_donor_id); |
|
133 | 133 | $email = $donor->email; |
134 | 134 | $names = $donor->name; |
135 | 135 | |
136 | - $previous_donor = new Give_Donor( $curr_donor_id ); |
|
136 | + $previous_donor = new Give_Donor($curr_donor_id); |
|
137 | 137 | |
138 | 138 | $donor_changed = true; |
139 | 139 | |
140 | 140 | } else { |
141 | - $donor = new Give_Donor( $curr_donor_id ); |
|
141 | + $donor = new Give_Donor($curr_donor_id); |
|
142 | 142 | $email = $donor->email; |
143 | 143 | $names = $donor->name; |
144 | 144 | } |
145 | 145 | |
146 | - if ( $donor_changed ) { |
|
146 | + if ($donor_changed) { |
|
147 | 147 | |
148 | 148 | // Setup first and last name from input values. |
149 | 149 | $first_name = $donor->get_first_name(); |
@@ -153,26 +153,26 @@ discard block |
||
153 | 153 | $payment->last_name = $last_name; |
154 | 154 | |
155 | 155 | // Remove the stats and payment from the previous donor and attach it to the new donor. |
156 | - $previous_donor->remove_payment( $payment_id, false ); |
|
157 | - $donor->attach_payment( $payment_id, false ); |
|
156 | + $previous_donor->remove_payment($payment_id, false); |
|
157 | + $donor->attach_payment($payment_id, false); |
|
158 | 158 | |
159 | - if ( 'publish' == $status ) { |
|
159 | + if ('publish' == $status) { |
|
160 | 160 | |
161 | 161 | // Reduce previous user donation count and amount. |
162 | 162 | $previous_donor->decrease_donation_count(); |
163 | - $previous_donor->decrease_value( $curr_total ); |
|
163 | + $previous_donor->decrease_value($curr_total); |
|
164 | 164 | |
165 | 165 | // If donation was completed adjust stats of new donors. |
166 | 166 | $donor->increase_purchase_count(); |
167 | - $donor->increase_value( $new_total ); |
|
167 | + $donor->increase_value($new_total); |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | $payment->customer_id = $donor->id; |
171 | 171 | } else { |
172 | 172 | |
173 | - if ( 'publish' === $status ) { |
|
173 | + if ('publish' === $status) { |
|
174 | 174 | // Update user donation stat. |
175 | - $donor->update_donation_value( $curr_total, $new_total ); |
|
175 | + $donor->update_donation_value($curr_total, $new_total); |
|
176 | 176 | } |
177 | 177 | } |
178 | 178 | |
@@ -183,10 +183,10 @@ discard block |
||
183 | 183 | $payment->total = $new_total; |
184 | 184 | |
185 | 185 | // Check for payment notes. |
186 | - if ( ! empty( $data['give-payment-note'] ) ) { |
|
186 | + if ( ! empty($data['give-payment-note'])) { |
|
187 | 187 | |
188 | - $note = wp_kses( $data['give-payment-note'], array() ); |
|
189 | - give_insert_payment_note( $payment_id, $note ); |
|
188 | + $note = wp_kses($data['give-payment-note'], array()); |
|
189 | + give_insert_payment_note($payment_id, $note); |
|
190 | 190 | |
191 | 191 | } |
192 | 192 | |
@@ -194,77 +194,77 @@ discard block |
||
194 | 194 | $payment->status = $status; |
195 | 195 | |
196 | 196 | // Adjust total store earnings if the payment total has been changed. |
197 | - if ( $new_total !== $curr_total && 'publish' == $status ) { |
|
197 | + if ($new_total !== $curr_total && 'publish' == $status) { |
|
198 | 198 | |
199 | - if ( $new_total > $curr_total ) { |
|
199 | + if ($new_total > $curr_total) { |
|
200 | 200 | // Increase if our new total is higher. |
201 | 201 | $difference = $new_total - $curr_total; |
202 | - give_increase_total_earnings( $difference ); |
|
202 | + give_increase_total_earnings($difference); |
|
203 | 203 | |
204 | 204 | // Increase form earnings. |
205 | - give_increase_earnings( $payment->form_id, $difference, $payment->ID ); |
|
206 | - } elseif ( $curr_total > $new_total ) { |
|
205 | + give_increase_earnings($payment->form_id, $difference, $payment->ID); |
|
206 | + } elseif ($curr_total > $new_total) { |
|
207 | 207 | // Decrease if our new total is lower. |
208 | 208 | $difference = $curr_total - $new_total; |
209 | - give_decrease_total_earnings( $difference ); |
|
209 | + give_decrease_total_earnings($difference); |
|
210 | 210 | |
211 | 211 | // Decrease form earnings. |
212 | - give_decrease_form_earnings( $payment->form_id, $difference, $payment->ID ); |
|
212 | + give_decrease_form_earnings($payment->form_id, $difference, $payment->ID); |
|
213 | 213 | } |
214 | 214 | } |
215 | 215 | |
216 | 216 | $payment->save(); |
217 | 217 | |
218 | 218 | // Get new give form ID. |
219 | - $new_form_id = absint( $data['give-payment-form-select'] ); |
|
220 | - $current_form_id = absint( $payment->get_meta( '_give_payment_form_id' ) ); |
|
219 | + $new_form_id = absint($data['give-payment-form-select']); |
|
220 | + $current_form_id = absint($payment->get_meta('_give_payment_form_id')); |
|
221 | 221 | |
222 | 222 | // We are adding payment transfer code in last to remove any conflict with above functionality. |
223 | 223 | // For example: above code will automatically handle form stat (increase/decrease) when payment status changes. |
224 | 224 | // Check if user want to transfer current payment to new give form id. |
225 | - if ( $new_form_id && $new_form_id != $current_form_id ) { |
|
225 | + if ($new_form_id && $new_form_id != $current_form_id) { |
|
226 | 226 | |
227 | 227 | // Get new give form title. |
228 | - $new_form_title = get_the_title( $new_form_id ); |
|
228 | + $new_form_title = get_the_title($new_form_id); |
|
229 | 229 | |
230 | 230 | // Update payment give form meta data. |
231 | - $payment->update_meta( '_give_payment_form_id', $new_form_id ); |
|
232 | - $payment->update_meta( '_give_payment_form_title', $new_form_title ); |
|
231 | + $payment->update_meta('_give_payment_form_id', $new_form_id); |
|
232 | + $payment->update_meta('_give_payment_form_title', $new_form_title); |
|
233 | 233 | |
234 | 234 | // Update price id payment metadata. |
235 | - if ( ! give_has_variable_prices( $new_form_id ) ) { |
|
236 | - $payment->update_meta( '_give_payment_price_id', '' ); |
|
235 | + if ( ! give_has_variable_prices($new_form_id)) { |
|
236 | + $payment->update_meta('_give_payment_price_id', ''); |
|
237 | 237 | } |
238 | 238 | |
239 | 239 | // If donation was completed, adjust stats of forms. |
240 | - if ( 'publish' == $status ) { |
|
240 | + if ('publish' == $status) { |
|
241 | 241 | |
242 | 242 | // Decrease sale of old give form. For other payment status. |
243 | - $current_form = new Give_Donate_Form( $current_form_id ); |
|
243 | + $current_form = new Give_Donate_Form($current_form_id); |
|
244 | 244 | $current_form->decrease_sales(); |
245 | - $current_form->decrease_earnings( $curr_total, $payment->ID ); |
|
245 | + $current_form->decrease_earnings($curr_total, $payment->ID); |
|
246 | 246 | |
247 | 247 | // Increase sale of new give form. |
248 | - $new_form = new Give_Donate_Form( $new_form_id ); |
|
248 | + $new_form = new Give_Donate_Form($new_form_id); |
|
249 | 249 | $new_form->increase_sales(); |
250 | - $new_form->increase_earnings( $new_total, $payment->ID ); |
|
250 | + $new_form->increase_earnings($new_total, $payment->ID); |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | // Re setup payment to update new meta value in object. |
254 | - $payment->update_payment_setup( $payment->ID ); |
|
254 | + $payment->update_payment_setup($payment->ID); |
|
255 | 255 | |
256 | 256 | // Update form id in payment logs. |
257 | - Give()->async_process->data( array( |
|
258 | - 'data' => array( $new_form_id, $payment_id ), |
|
257 | + Give()->async_process->data(array( |
|
258 | + 'data' => array($new_form_id, $payment_id), |
|
259 | 259 | 'hook' => 'give_update_log_form_id', |
260 | - ) )->dispatch(); |
|
260 | + ))->dispatch(); |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | // Update price id if current form is variable form. |
264 | 264 | /* @var Give_Donate_Form $form */ |
265 | - $form = new Give_Donate_Form( $payment->form_id ); |
|
265 | + $form = new Give_Donate_Form($payment->form_id); |
|
266 | 266 | |
267 | - if ( isset( $data['give-variable-price'] ) && $form->has_variable_prices() ) { |
|
267 | + if (isset($data['give-variable-price']) && $form->has_variable_prices()) { |
|
268 | 268 | |
269 | 269 | // Get payment meta data. |
270 | 270 | $payment_meta = $payment->get_meta(); |
@@ -273,9 +273,9 @@ discard block |
||
273 | 273 | $price_id = ''; |
274 | 274 | |
275 | 275 | // Get price info |
276 | - if( 0 <= $data['give-variable-price'] ) { |
|
277 | - foreach ( $form->prices as $variable_price ) { |
|
278 | - if( $new_total === give_maybe_sanitize_amount( $variable_price['_give_amount'] ) ) { |
|
276 | + if (0 <= $data['give-variable-price']) { |
|
277 | + foreach ($form->prices as $variable_price) { |
|
278 | + if ($new_total === give_maybe_sanitize_amount($variable_price['_give_amount'])) { |
|
279 | 279 | $price_info = $variable_price; |
280 | 280 | break; |
281 | 281 | } |
@@ -283,15 +283,15 @@ discard block |
||
283 | 283 | } |
284 | 284 | |
285 | 285 | // Set price id. |
286 | - if( ! empty( $price_info ) ) { |
|
286 | + if ( ! empty($price_info)) { |
|
287 | 287 | $price_id = $data['give-variable-price']; |
288 | 288 | |
289 | - if( $data['give-variable-price'] !== $price_info['_give_id']['level_id'] ) { |
|
289 | + if ($data['give-variable-price'] !== $price_info['_give_id']['level_id']) { |
|
290 | 290 | // Set price id to amount match. |
291 | 291 | $price_id = $price_info['_give_id']['level_id']; |
292 | 292 | } |
293 | 293 | |
294 | - } elseif( $form->is_custom_price_mode() ){ |
|
294 | + } elseif ($form->is_custom_price_mode()) { |
|
295 | 295 | $price_id = 'custom'; |
296 | 296 | } |
297 | 297 | |
@@ -299,26 +299,26 @@ discard block |
||
299 | 299 | $payment_meta['price_id'] = $price_id; |
300 | 300 | |
301 | 301 | // Update payment give form meta data. |
302 | - $payment->update_meta( '_give_payment_price_id', $price_id ); |
|
303 | - $payment->update_meta( '_give_payment_meta', $payment_meta ); |
|
302 | + $payment->update_meta('_give_payment_price_id', $price_id); |
|
303 | + $payment->update_meta('_give_payment_meta', $payment_meta); |
|
304 | 304 | |
305 | 305 | // Re setup payment to update new meta value in object. |
306 | - $payment->update_payment_setup( $payment->ID ); |
|
306 | + $payment->update_payment_setup($payment->ID); |
|
307 | 307 | } |
308 | 308 | |
309 | - $comment_id = isset( $data['give_comment_id'] ) ? absint( $data['give_comment_id'] ) : 0; |
|
310 | - $has_anonymous_setting_field = give_is_anonymous_donation_field_enabled( $payment->form_id ); |
|
309 | + $comment_id = isset($data['give_comment_id']) ? absint($data['give_comment_id']) : 0; |
|
310 | + $has_anonymous_setting_field = give_is_anonymous_donation_field_enabled($payment->form_id); |
|
311 | 311 | |
312 | - if ( $has_anonymous_setting_field ) { |
|
313 | - give_update_meta( $payment->ID, '_give_anonymous_donation', $payment->anonymous ); |
|
312 | + if ($has_anonymous_setting_field) { |
|
313 | + give_update_meta($payment->ID, '_give_anonymous_donation', $payment->anonymous); |
|
314 | 314 | |
315 | 315 | // Set donor as anonymous only if donor does not have any non anonymous donation. |
316 | - $donations = Give()->donors->get_column_by( 'payment_ids', 'id', $payment->donor_id ); |
|
317 | - $donations = ! empty( $donations ) ? explode( ',', $donations ) : array(); |
|
316 | + $donations = Give()->donors->get_column_by('payment_ids', 'id', $payment->donor_id); |
|
317 | + $donations = ! empty($donations) ? explode(',', $donations) : array(); |
|
318 | 318 | $update_anonymous_donor_meta = false; |
319 | 319 | |
320 | - if( ! empty( $donations ) ) { |
|
321 | - $non_anonymous_donations = new WP_Query( array( |
|
320 | + if ( ! empty($donations)) { |
|
321 | + $non_anonymous_donations = new WP_Query(array( |
|
322 | 322 | 'post_type' => 'give_payment', |
323 | 323 | 'post_status' => 'publish', |
324 | 324 | 'post__in' => $donations, |
@@ -334,48 +334,48 @@ discard block |
||
334 | 334 | 'value' => $payment->form_id, |
335 | 335 | ), |
336 | 336 | ), |
337 | - ) ); |
|
337 | + )); |
|
338 | 338 | |
339 | - $update_anonymous_donor_meta = ! ( 0 < $non_anonymous_donations->found_posts ); |
|
339 | + $update_anonymous_donor_meta = ! (0 < $non_anonymous_donations->found_posts); |
|
340 | 340 | |
341 | - if( |
|
342 | - 0 === absint( $non_anonymous_donations->found_posts ) |
|
341 | + if ( |
|
342 | + 0 === absint($non_anonymous_donations->found_posts) |
|
343 | 343 | && $payment->anonymous |
344 | 344 | ) { |
345 | 345 | $update_anonymous_donor_meta = true; |
346 | 346 | } elseif ( |
347 | - 1 === absint( $non_anonymous_donations->found_posts ) |
|
347 | + 1 === absint($non_anonymous_donations->found_posts) |
|
348 | 348 | && ! $payment->anonymous |
349 | 349 | ) { |
350 | - $update_anonymous_donor_meta = true; |
|
350 | + $update_anonymous_donor_meta = true; |
|
351 | 351 | } |
352 | 352 | } |
353 | 353 | |
354 | - if ( $update_anonymous_donor_meta ) { |
|
355 | - Give()->donor_meta->update_meta( $payment->donor_id, "_give_anonymous_donor_form_{$payment->form_id}", $payment->anonymous ); |
|
354 | + if ($update_anonymous_donor_meta) { |
|
355 | + Give()->donor_meta->update_meta($payment->donor_id, "_give_anonymous_donor_form_{$payment->form_id}", $payment->anonymous); |
|
356 | 356 | } |
357 | 357 | |
358 | 358 | // Update comment meta if admin is not updating comment. |
359 | - if( $comment_id ) { |
|
360 | - update_comment_meta( $comment_id, '_give_anonymous_donation', $payment->anonymous ); |
|
359 | + if ($comment_id) { |
|
360 | + update_comment_meta($comment_id, '_give_anonymous_donation', $payment->anonymous); |
|
361 | 361 | } |
362 | 362 | } |
363 | 363 | |
364 | 364 | // Update comment. |
365 | - if ( give_is_donor_comment_field_enabled( $payment->form_id ) ) { |
|
365 | + if (give_is_donor_comment_field_enabled($payment->form_id)) { |
|
366 | 366 | // We are access comment directly from $_POST because comment formatting remove because of give_clean in give_post_actions. |
367 | - $data['give_comment'] = trim( $_POST['give_comment'] ); |
|
367 | + $data['give_comment'] = trim($_POST['give_comment']); |
|
368 | 368 | |
369 | - if ( empty( $data['give_comment'] ) ) { |
|
369 | + if (empty($data['give_comment'])) { |
|
370 | 370 | // Delete comment if empty |
371 | - Give_Comment::delete( $comment_id, $payment_id, 'payment' ); |
|
371 | + Give_Comment::delete($comment_id, $payment_id, 'payment'); |
|
372 | 372 | |
373 | 373 | } else { |
374 | 374 | $comment_args = array( |
375 | 375 | 'comment_author_email' => $payment->email |
376 | 376 | ); |
377 | 377 | |
378 | - if ( $comment_id ) { |
|
378 | + if ($comment_id) { |
|
379 | 379 | $comment_args['comment_ID'] = $comment_id; |
380 | 380 | } |
381 | 381 | |
@@ -387,11 +387,11 @@ discard block |
||
387 | 387 | ); |
388 | 388 | } |
389 | 389 | |
390 | - $donor_has_comment = empty( $data['give_comment'] ) |
|
391 | - ? ( $latest_comment = give_get_donor_latest_comment( $payment->donor_id ) && empty( $latest_comment ) ? '0' : '1' ) |
|
390 | + $donor_has_comment = empty($data['give_comment']) |
|
391 | + ? ($latest_comment = give_get_donor_latest_comment($payment->donor_id) && empty($latest_comment) ? '0' : '1') |
|
392 | 392 | : '1'; |
393 | 393 | |
394 | - Give()->donor_meta->update_meta( $payment->donor_id, '_give_has_comment', $donor_has_comment ); |
|
394 | + Give()->donor_meta->update_meta($payment->donor_id, '_give_has_comment', $donor_has_comment); |
|
395 | 395 | } |
396 | 396 | |
397 | 397 | /** |
@@ -402,13 +402,13 @@ discard block |
||
402 | 402 | * |
403 | 403 | * @param int $payment_id The ID of the payment. |
404 | 404 | */ |
405 | - do_action( 'give_updated_edited_donation', $payment_id ); |
|
405 | + do_action('give_updated_edited_donation', $payment_id); |
|
406 | 406 | |
407 | - wp_safe_redirect( admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&give-messages[]=payment-updated&id=' . $payment_id ) ); |
|
407 | + wp_safe_redirect(admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&give-messages[]=payment-updated&id='.$payment_id)); |
|
408 | 408 | exit; |
409 | 409 | } |
410 | 410 | |
411 | -add_action( 'give_update_payment_details', 'give_update_payment_details' ); |
|
411 | +add_action('give_update_payment_details', 'give_update_payment_details'); |
|
412 | 412 | |
413 | 413 | /** |
414 | 414 | * Trigger a Donation Deletion. |
@@ -419,48 +419,48 @@ discard block |
||
419 | 419 | * |
420 | 420 | * @return void |
421 | 421 | */ |
422 | -function give_trigger_donation_delete( $data ) { |
|
423 | - if ( wp_verify_nonce( $data['_wpnonce'], 'give_donation_nonce' ) ) { |
|
422 | +function give_trigger_donation_delete($data) { |
|
423 | + if (wp_verify_nonce($data['_wpnonce'], 'give_donation_nonce')) { |
|
424 | 424 | |
425 | - $payment_id = absint( $data['purchase_id'] ); |
|
425 | + $payment_id = absint($data['purchase_id']); |
|
426 | 426 | |
427 | - if ( ! current_user_can( 'edit_give_payments', $payment_id ) ) { |
|
428 | - wp_die( __( 'You do not have permission to edit payments.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
427 | + if ( ! current_user_can('edit_give_payments', $payment_id)) { |
|
428 | + wp_die(__('You do not have permission to edit payments.', 'give'), __('Error', 'give'), array('response' => 403)); |
|
429 | 429 | } |
430 | 430 | |
431 | - give_delete_donation( $payment_id ); |
|
432 | - wp_redirect( admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&give-messages[]=donation-deleted' ) ); |
|
431 | + give_delete_donation($payment_id); |
|
432 | + wp_redirect(admin_url('edit.php?post_type=give_forms&page=give-payment-history&give-messages[]=donation-deleted')); |
|
433 | 433 | give_die(); |
434 | 434 | } |
435 | 435 | } |
436 | 436 | |
437 | -add_action( 'give_delete_payment', 'give_trigger_donation_delete' ); |
|
437 | +add_action('give_delete_payment', 'give_trigger_donation_delete'); |
|
438 | 438 | |
439 | 439 | /** |
440 | 440 | * AJAX Store Donation Note |
441 | 441 | */ |
442 | 442 | function give_ajax_store_payment_note() { |
443 | 443 | |
444 | - $payment_id = absint( $_POST['payment_id'] ); |
|
445 | - $note = wp_kses( $_POST['note'], array() ); |
|
444 | + $payment_id = absint($_POST['payment_id']); |
|
445 | + $note = wp_kses($_POST['note'], array()); |
|
446 | 446 | |
447 | - if ( ! current_user_can( 'edit_give_payments', $payment_id ) ) { |
|
448 | - wp_die( __( 'You do not have permission to edit payments.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
447 | + if ( ! current_user_can('edit_give_payments', $payment_id)) { |
|
448 | + wp_die(__('You do not have permission to edit payments.', 'give'), __('Error', 'give'), array('response' => 403)); |
|
449 | 449 | } |
450 | 450 | |
451 | - if ( empty( $payment_id ) ) { |
|
452 | - die( '-1' ); |
|
451 | + if (empty($payment_id)) { |
|
452 | + die('-1'); |
|
453 | 453 | } |
454 | 454 | |
455 | - if ( empty( $note ) ) { |
|
456 | - die( '-1' ); |
|
455 | + if (empty($note)) { |
|
456 | + die('-1'); |
|
457 | 457 | } |
458 | 458 | |
459 | - $note_id = give_insert_payment_note( $payment_id, $note ); |
|
460 | - die( give_get_payment_note_html( $note_id ) ); |
|
459 | + $note_id = give_insert_payment_note($payment_id, $note); |
|
460 | + die(give_get_payment_note_html($note_id)); |
|
461 | 461 | } |
462 | 462 | |
463 | -add_action( 'wp_ajax_give_insert_payment_note', 'give_ajax_store_payment_note' ); |
|
463 | +add_action('wp_ajax_give_insert_payment_note', 'give_ajax_store_payment_note'); |
|
464 | 464 | |
465 | 465 | /** |
466 | 466 | * Triggers a donation note deletion without ajax |
@@ -471,24 +471,24 @@ discard block |
||
471 | 471 | * |
472 | 472 | * @return void |
473 | 473 | */ |
474 | -function give_trigger_payment_note_deletion( $data ) { |
|
474 | +function give_trigger_payment_note_deletion($data) { |
|
475 | 475 | |
476 | - if ( ! wp_verify_nonce( $data['_wpnonce'], 'give_delete_payment_note_' . $data['note_id'] ) ) { |
|
476 | + if ( ! wp_verify_nonce($data['_wpnonce'], 'give_delete_payment_note_'.$data['note_id'])) { |
|
477 | 477 | return; |
478 | 478 | } |
479 | 479 | |
480 | - if ( ! current_user_can( 'edit_give_payments', $data['payment_id'] ) ) { |
|
481 | - wp_die( __( 'You do not have permission to edit payments.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
480 | + if ( ! current_user_can('edit_give_payments', $data['payment_id'])) { |
|
481 | + wp_die(__('You do not have permission to edit payments.', 'give'), __('Error', 'give'), array('response' => 403)); |
|
482 | 482 | } |
483 | 483 | |
484 | - $edit_order_url = admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&give-messages[]=donation-note-deleted&id=' . absint( $data['payment_id'] ) ); |
|
484 | + $edit_order_url = admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&give-messages[]=donation-note-deleted&id='.absint($data['payment_id'])); |
|
485 | 485 | |
486 | - give_delete_payment_note( $data['note_id'], $data['payment_id'] ); |
|
486 | + give_delete_payment_note($data['note_id'], $data['payment_id']); |
|
487 | 487 | |
488 | - wp_redirect( $edit_order_url ); |
|
488 | + wp_redirect($edit_order_url); |
|
489 | 489 | } |
490 | 490 | |
491 | -add_action( 'give_delete_payment_note', 'give_trigger_payment_note_deletion' ); |
|
491 | +add_action('give_delete_payment_note', 'give_trigger_payment_note_deletion'); |
|
492 | 492 | |
493 | 493 | /** |
494 | 494 | * Delete a payment note deletion with ajax |
@@ -499,16 +499,16 @@ discard block |
||
499 | 499 | */ |
500 | 500 | function give_ajax_delete_payment_note() { |
501 | 501 | |
502 | - if ( ! current_user_can( 'edit_give_payments', $_POST['payment_id'] ) ) { |
|
503 | - wp_die( __( 'You do not have permission to edit payments.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
502 | + if ( ! current_user_can('edit_give_payments', $_POST['payment_id'])) { |
|
503 | + wp_die(__('You do not have permission to edit payments.', 'give'), __('Error', 'give'), array('response' => 403)); |
|
504 | 504 | } |
505 | 505 | |
506 | - if ( give_delete_payment_note( $_POST['note_id'], $_POST['payment_id'] ) ) { |
|
507 | - die( '1' ); |
|
506 | + if (give_delete_payment_note($_POST['note_id'], $_POST['payment_id'])) { |
|
507 | + die('1'); |
|
508 | 508 | } else { |
509 | - die( '-1' ); |
|
509 | + die('-1'); |
|
510 | 510 | } |
511 | 511 | |
512 | 512 | } |
513 | 513 | |
514 | -add_action( 'wp_ajax_give_delete_payment_note', 'give_ajax_delete_payment_note' ); |
|
514 | +add_action('wp_ajax_give_delete_payment_note', 'give_ajax_delete_payment_note'); |