@@ -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 | |
@@ -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 | |
@@ -149,29 +149,29 @@ discard block |
||
| 149 | 149 | * @param int|bool $_id_or_email |
| 150 | 150 | * @param bool $by_user_id |
| 151 | 151 | */ |
| 152 | - public function __construct( $_id_or_email = false, $by_user_id = false ) { |
|
| 152 | + public function __construct($_id_or_email = false, $by_user_id = false) { |
|
| 153 | 153 | |
| 154 | 154 | $this->db = Give()->donors; |
| 155 | 155 | |
| 156 | - if ( false === $_id_or_email || ( is_numeric( $_id_or_email ) && (int) $_id_or_email !== absint( $_id_or_email ) ) ) { |
|
| 156 | + if (false === $_id_or_email || (is_numeric($_id_or_email) && (int) $_id_or_email !== absint($_id_or_email))) { |
|
| 157 | 157 | return false; |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | - $by_user_id = is_bool( $by_user_id ) ? $by_user_id : false; |
|
| 160 | + $by_user_id = is_bool($by_user_id) ? $by_user_id : false; |
|
| 161 | 161 | |
| 162 | - if ( is_numeric( $_id_or_email ) ) { |
|
| 162 | + if (is_numeric($_id_or_email)) { |
|
| 163 | 163 | $field = $by_user_id ? 'user_id' : 'id'; |
| 164 | 164 | } else { |
| 165 | 165 | $field = 'email'; |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | - $donor = $this->db->get_donor_by( $field, $_id_or_email ); |
|
| 168 | + $donor = $this->db->get_donor_by($field, $_id_or_email); |
|
| 169 | 169 | |
| 170 | - if ( empty( $donor ) || ! is_object( $donor ) ) { |
|
| 170 | + if (empty($donor) || ! is_object($donor)) { |
|
| 171 | 171 | return false; |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | - $this->setup_donor( $donor ); |
|
| 174 | + $this->setup_donor($donor); |
|
| 175 | 175 | |
| 176 | 176 | } |
| 177 | 177 | |
@@ -187,19 +187,19 @@ discard block |
||
| 187 | 187 | * |
| 188 | 188 | * @return bool If the setup was successful or not. |
| 189 | 189 | */ |
| 190 | - private function setup_donor( $donor ) { |
|
| 190 | + private function setup_donor($donor) { |
|
| 191 | 191 | |
| 192 | - if ( ! is_object( $donor ) ) { |
|
| 192 | + if ( ! is_object($donor)) { |
|
| 193 | 193 | return false; |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | // Get cached donors. |
| 197 | - $donor_vars = Give_Cache::get_group( $donor->id, 'give-donors' ); |
|
| 197 | + $donor_vars = Give_Cache::get_group($donor->id, 'give-donors'); |
|
| 198 | 198 | |
| 199 | - if ( is_null( $donor_vars ) ) { |
|
| 200 | - foreach ( $donor as $key => $value ) { |
|
| 199 | + if (is_null($donor_vars)) { |
|
| 200 | + foreach ($donor as $key => $value) { |
|
| 201 | 201 | |
| 202 | - switch ( $key ) { |
|
| 202 | + switch ($key) { |
|
| 203 | 203 | |
| 204 | 204 | case 'notes': |
| 205 | 205 | $this->$key = $this->get_notes(); |
@@ -213,20 +213,20 @@ discard block |
||
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | // Get donor's all email including primary email. |
| 216 | - $this->emails = (array) $this->get_meta( 'additional_email', false ); |
|
| 217 | - $this->emails = array( 'primary' => $this->email ) + $this->emails; |
|
| 216 | + $this->emails = (array) $this->get_meta('additional_email', false); |
|
| 217 | + $this->emails = array('primary' => $this->email) + $this->emails; |
|
| 218 | 218 | |
| 219 | 219 | $this->setup_address(); |
| 220 | 220 | |
| 221 | - Give_Cache::set_group( $donor->id, get_object_vars( $this ), 'give-donors' ); |
|
| 221 | + Give_Cache::set_group($donor->id, get_object_vars($this), 'give-donors'); |
|
| 222 | 222 | } else { |
| 223 | - foreach ( $donor_vars as $donor_var => $value ) { |
|
| 223 | + foreach ($donor_vars as $donor_var => $value) { |
|
| 224 | 224 | $this->$donor_var = $value; |
| 225 | 225 | } |
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | // Donor ID and email are the only things that are necessary, make sure they exist. |
| 229 | - if ( ! empty( $this->id ) && ! empty( $this->email ) ) { |
|
| 229 | + if ( ! empty($this->id) && ! empty($this->email)) { |
|
| 230 | 230 | return true; |
| 231 | 231 | } |
| 232 | 232 | |
@@ -245,25 +245,25 @@ discard block |
||
| 245 | 245 | global $wpdb; |
| 246 | 246 | $meta_type = Give()->donor_meta->meta_type; |
| 247 | 247 | |
| 248 | - $addresses = $wpdb->get_results( $wpdb->prepare( " |
|
| 248 | + $addresses = $wpdb->get_results($wpdb->prepare(" |
|
| 249 | 249 | SELECT meta_key, meta_value FROM {$wpdb->donormeta} |
| 250 | 250 | WHERE meta_key |
| 251 | 251 | LIKE '%%%s%%' |
| 252 | 252 | AND {$meta_type}_id=%d |
| 253 | - ", 'give_donor_address', $this->id ), ARRAY_N ); |
|
| 253 | + ", 'give_donor_address', $this->id), ARRAY_N); |
|
| 254 | 254 | |
| 255 | - if ( empty( $addresses ) ) { |
|
| 255 | + if (empty($addresses)) { |
|
| 256 | 256 | return $this->address; |
| 257 | 257 | } |
| 258 | 258 | |
| 259 | - foreach ( $addresses as $address ) { |
|
| 260 | - $address[0] = str_replace( '_give_donor_address_', '', $address[0] ); |
|
| 261 | - $address[0] = explode( '_', $address[0] ); |
|
| 259 | + foreach ($addresses as $address) { |
|
| 260 | + $address[0] = str_replace('_give_donor_address_', '', $address[0]); |
|
| 261 | + $address[0] = explode('_', $address[0]); |
|
| 262 | 262 | |
| 263 | - if ( 3 === count( $address[0] ) ) { |
|
| 264 | - $this->address[ $address[0][0] ][ $address[0][2] ][ $address[0][1] ] = $address[1]; |
|
| 263 | + if (3 === count($address[0])) { |
|
| 264 | + $this->address[$address[0][0]][$address[0][2]][$address[0][1]] = $address[1]; |
|
| 265 | 265 | } else { |
| 266 | - $this->address[ $address[0][0] ][ $address[0][1] ] = $address[1]; |
|
| 266 | + $this->address[$address[0][0]][$address[0][1]] = $address[1]; |
|
| 267 | 267 | } |
| 268 | 268 | } |
| 269 | 269 | } |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | * |
| 280 | 280 | * @return array The donor's address, if any |
| 281 | 281 | */ |
| 282 | - public function get_donor_address( $args = array() ) { |
|
| 282 | + public function get_donor_address($args = array()) { |
|
| 283 | 283 | $args = wp_parse_args( |
| 284 | 284 | $args, |
| 285 | 285 | array( |
@@ -297,24 +297,24 @@ discard block |
||
| 297 | 297 | ); |
| 298 | 298 | |
| 299 | 299 | // Backward compatibility. |
| 300 | - if ( ! give_has_upgrade_completed( 'v20_upgrades_user_address' ) ) { |
|
| 300 | + if ( ! give_has_upgrade_completed('v20_upgrades_user_address')) { |
|
| 301 | 301 | |
| 302 | 302 | // Backward compatibility for user id param. |
| 303 | - return wp_parse_args( (array) get_user_meta( $this->user_id, '_give_user_address', true ), $default_address ); |
|
| 303 | + return wp_parse_args((array) get_user_meta($this->user_id, '_give_user_address', true), $default_address); |
|
| 304 | 304 | |
| 305 | 305 | } |
| 306 | 306 | |
| 307 | - if ( ! $this->id || empty( $this->address ) || ! array_key_exists( $args['address_type'], $this->address ) ) { |
|
| 307 | + if ( ! $this->id || empty($this->address) || ! array_key_exists($args['address_type'], $this->address)) { |
|
| 308 | 308 | return $default_address; |
| 309 | 309 | } |
| 310 | 310 | |
| 311 | - switch ( true ) { |
|
| 312 | - case is_string( end( $this->address[ $args['address_type'] ] ) ): |
|
| 313 | - $address = wp_parse_args( $this->address[ $args['address_type'] ], $default_address ); |
|
| 311 | + switch (true) { |
|
| 312 | + case is_string(end($this->address[$args['address_type']])): |
|
| 313 | + $address = wp_parse_args($this->address[$args['address_type']], $default_address); |
|
| 314 | 314 | break; |
| 315 | 315 | |
| 316 | - case is_array( end( $this->address[ $args['address_type'] ] ) ): |
|
| 317 | - $address = wp_parse_args( array_shift( $this->address[ $args['address_type'] ] ), $default_address ); |
|
| 316 | + case is_array(end($this->address[$args['address_type']])): |
|
| 317 | + $address = wp_parse_args(array_shift($this->address[$args['address_type']]), $default_address); |
|
| 318 | 318 | break; |
| 319 | 319 | } |
| 320 | 320 | |
@@ -331,16 +331,16 @@ discard block |
||
| 331 | 331 | * |
| 332 | 332 | * @return mixed|\WP_Error |
| 333 | 333 | */ |
| 334 | - public function __get( $key ) { |
|
| 334 | + public function __get($key) { |
|
| 335 | 335 | |
| 336 | - if ( method_exists( $this, 'get_' . $key ) ) { |
|
| 336 | + if (method_exists($this, 'get_'.$key)) { |
|
| 337 | 337 | |
| 338 | - return call_user_func( array( $this, 'get_' . $key ) ); |
|
| 338 | + return call_user_func(array($this, 'get_'.$key)); |
|
| 339 | 339 | |
| 340 | 340 | } else { |
| 341 | 341 | |
| 342 | 342 | /* translators: %s: property key */ |
| 343 | - return new WP_Error( 'give-donor-invalid-property', sprintf( esc_html__( 'Can\'t get property %s.', 'give' ), $key ) ); |
|
| 343 | + return new WP_Error('give-donor-invalid-property', sprintf(esc_html__('Can\'t get property %s.', 'give'), $key)); |
|
| 344 | 344 | |
| 345 | 345 | } |
| 346 | 346 | |
@@ -356,9 +356,9 @@ discard block |
||
| 356 | 356 | * |
| 357 | 357 | * @return bool|int False if not a valid creation, donor ID if user is found or valid creation. |
| 358 | 358 | */ |
| 359 | - public function create( $data = array() ) { |
|
| 359 | + public function create($data = array()) { |
|
| 360 | 360 | |
| 361 | - if ( $this->id != 0 || empty( $data ) ) { |
|
| 361 | + if ($this->id != 0 || empty($data)) { |
|
| 362 | 362 | return false; |
| 363 | 363 | } |
| 364 | 364 | |
@@ -366,15 +366,15 @@ discard block |
||
| 366 | 366 | 'payment_ids' => '', |
| 367 | 367 | ); |
| 368 | 368 | |
| 369 | - $args = wp_parse_args( $data, $defaults ); |
|
| 370 | - $args = $this->sanitize_columns( $args ); |
|
| 369 | + $args = wp_parse_args($data, $defaults); |
|
| 370 | + $args = $this->sanitize_columns($args); |
|
| 371 | 371 | |
| 372 | - if ( empty( $args['email'] ) || ! is_email( $args['email'] ) ) { |
|
| 372 | + if (empty($args['email']) || ! is_email($args['email'])) { |
|
| 373 | 373 | return false; |
| 374 | 374 | } |
| 375 | 375 | |
| 376 | - if ( ! empty( $args['payment_ids'] ) && is_array( $args['payment_ids'] ) ) { |
|
| 377 | - $args['payment_ids'] = implode( ',', array_unique( array_values( $args['payment_ids'] ) ) ); |
|
| 376 | + if ( ! empty($args['payment_ids']) && is_array($args['payment_ids'])) { |
|
| 377 | + $args['payment_ids'] = implode(',', array_unique(array_values($args['payment_ids']))); |
|
| 378 | 378 | } |
| 379 | 379 | |
| 380 | 380 | /** |
@@ -384,24 +384,24 @@ discard block |
||
| 384 | 384 | * |
| 385 | 385 | * @param array $args Donor attributes. |
| 386 | 386 | */ |
| 387 | - do_action( 'give_donor_pre_create', $args ); |
|
| 387 | + do_action('give_donor_pre_create', $args); |
|
| 388 | 388 | |
| 389 | 389 | $created = false; |
| 390 | 390 | |
| 391 | 391 | // The DB class 'add' implies an update if the donor being asked to be created already exists |
| 392 | - if ( $this->db->add( $data ) ) { |
|
| 392 | + if ($this->db->add($data)) { |
|
| 393 | 393 | |
| 394 | 394 | // We've successfully added/updated the donor, reset the class vars with the new data |
| 395 | - $donor = $this->db->get_donor_by( 'email', $args['email'] ); |
|
| 395 | + $donor = $this->db->get_donor_by('email', $args['email']); |
|
| 396 | 396 | |
| 397 | 397 | // Setup the donor data with the values from DB |
| 398 | - $this->setup_donor( $donor ); |
|
| 398 | + $this->setup_donor($donor); |
|
| 399 | 399 | |
| 400 | 400 | $created = $this->id; |
| 401 | 401 | |
| 402 | 402 | // Set donor as non anonymous by default |
| 403 | - if( $created ) { |
|
| 404 | - Give()->donor_meta->update_meta( $this->id, '_give_anonymous_donor', 0 ); |
|
| 403 | + if ($created) { |
|
| 404 | + Give()->donor_meta->update_meta($this->id, '_give_anonymous_donor', 0); |
|
| 405 | 405 | } |
| 406 | 406 | } |
| 407 | 407 | |
@@ -413,7 +413,7 @@ discard block |
||
| 413 | 413 | * @param bool|int $created False if not a valid creation, donor ID if user is found or valid creation. |
| 414 | 414 | * @param array $args Customer attributes. |
| 415 | 415 | */ |
| 416 | - do_action( 'give_donor_post_create', $created, $args ); |
|
| 416 | + do_action('give_donor_post_create', $created, $args); |
|
| 417 | 417 | |
| 418 | 418 | return $created; |
| 419 | 419 | |
@@ -429,13 +429,13 @@ discard block |
||
| 429 | 429 | * |
| 430 | 430 | * @return bool If the update was successful or not. |
| 431 | 431 | */ |
| 432 | - public function update( $data = array() ) { |
|
| 432 | + public function update($data = array()) { |
|
| 433 | 433 | |
| 434 | - if ( empty( $data ) ) { |
|
| 434 | + if (empty($data)) { |
|
| 435 | 435 | return false; |
| 436 | 436 | } |
| 437 | 437 | |
| 438 | - $data = $this->sanitize_columns( $data ); |
|
| 438 | + $data = $this->sanitize_columns($data); |
|
| 439 | 439 | |
| 440 | 440 | /** |
| 441 | 441 | * Fires before updating donors. |
@@ -445,15 +445,15 @@ discard block |
||
| 445 | 445 | * @param int $donor_id Donor id. |
| 446 | 446 | * @param array $data Donor attributes. |
| 447 | 447 | */ |
| 448 | - do_action( 'give_donor_pre_update', $this->id, $data ); |
|
| 448 | + do_action('give_donor_pre_update', $this->id, $data); |
|
| 449 | 449 | |
| 450 | 450 | $updated = false; |
| 451 | 451 | |
| 452 | - if ( $this->db->update( $this->id, $data ) ) { |
|
| 452 | + if ($this->db->update($this->id, $data)) { |
|
| 453 | 453 | |
| 454 | - $donor = $this->db->get_donor_by( 'id', $this->id ); |
|
| 454 | + $donor = $this->db->get_donor_by('id', $this->id); |
|
| 455 | 455 | |
| 456 | - $this->setup_donor( $donor ); |
|
| 456 | + $this->setup_donor($donor); |
|
| 457 | 457 | |
| 458 | 458 | $updated = true; |
| 459 | 459 | } |
@@ -467,7 +467,7 @@ discard block |
||
| 467 | 467 | * @param int $donor_id Donor id. |
| 468 | 468 | * @param array $data Donor attributes. |
| 469 | 469 | */ |
| 470 | - do_action( 'give_donor_post_update', $updated, $this->id, $data ); |
|
| 470 | + do_action('give_donor_post_update', $updated, $this->id, $data); |
|
| 471 | 471 | |
| 472 | 472 | return $updated; |
| 473 | 473 | } |
@@ -485,27 +485,27 @@ discard block |
||
| 485 | 485 | * |
| 486 | 486 | * @return bool If the attachment was successfully. |
| 487 | 487 | */ |
| 488 | - public function attach_payment( $payment_id = 0, $update_stats = true ) { |
|
| 488 | + public function attach_payment($payment_id = 0, $update_stats = true) { |
|
| 489 | 489 | |
| 490 | - if ( empty( $payment_id ) ) { |
|
| 490 | + if (empty($payment_id)) { |
|
| 491 | 491 | return false; |
| 492 | 492 | } |
| 493 | 493 | |
| 494 | - if ( empty( $this->payment_ids ) ) { |
|
| 494 | + if (empty($this->payment_ids)) { |
|
| 495 | 495 | |
| 496 | 496 | $new_payment_ids = $payment_id; |
| 497 | 497 | |
| 498 | 498 | } else { |
| 499 | 499 | |
| 500 | - $payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) ); |
|
| 500 | + $payment_ids = array_map('absint', explode(',', $this->payment_ids)); |
|
| 501 | 501 | |
| 502 | - if ( in_array( $payment_id, $payment_ids ) ) { |
|
| 502 | + if (in_array($payment_id, $payment_ids)) { |
|
| 503 | 503 | $update_stats = false; |
| 504 | 504 | } |
| 505 | 505 | |
| 506 | 506 | $payment_ids[] = $payment_id; |
| 507 | 507 | |
| 508 | - $new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) ); |
|
| 508 | + $new_payment_ids = implode(',', array_unique(array_values($payment_ids))); |
|
| 509 | 509 | |
| 510 | 510 | } |
| 511 | 511 | |
@@ -517,20 +517,20 @@ discard block |
||
| 517 | 517 | * @param int $payment_id Payment id. |
| 518 | 518 | * @param int $donor_id Donor id. |
| 519 | 519 | */ |
| 520 | - do_action( 'give_donor_pre_attach_payment', $payment_id, $this->id ); |
|
| 520 | + do_action('give_donor_pre_attach_payment', $payment_id, $this->id); |
|
| 521 | 521 | |
| 522 | - $payment_added = $this->update( array( 'payment_ids' => $new_payment_ids ) ); |
|
| 522 | + $payment_added = $this->update(array('payment_ids' => $new_payment_ids)); |
|
| 523 | 523 | |
| 524 | - if ( $payment_added ) { |
|
| 524 | + if ($payment_added) { |
|
| 525 | 525 | |
| 526 | 526 | $this->payment_ids = $new_payment_ids; |
| 527 | 527 | |
| 528 | 528 | // We added this payment successfully, increment the stats |
| 529 | - if ( $update_stats ) { |
|
| 530 | - $payment_amount = give_donation_amount( $payment_id, array( 'type' => 'stats' ) ); |
|
| 529 | + if ($update_stats) { |
|
| 530 | + $payment_amount = give_donation_amount($payment_id, array('type' => 'stats')); |
|
| 531 | 531 | |
| 532 | - if ( ! empty( $payment_amount ) ) { |
|
| 533 | - $this->increase_value( $payment_amount ); |
|
| 532 | + if ( ! empty($payment_amount)) { |
|
| 533 | + $this->increase_value($payment_amount); |
|
| 534 | 534 | } |
| 535 | 535 | |
| 536 | 536 | $this->increase_purchase_count(); |
@@ -546,7 +546,7 @@ discard block |
||
| 546 | 546 | * @param int $payment_id Payment id. |
| 547 | 547 | * @param int $donor_id Donor id. |
| 548 | 548 | */ |
| 549 | - do_action( 'give_donor_post_attach_payment', $payment_added, $payment_id, $this->id ); |
|
| 549 | + do_action('give_donor_post_attach_payment', $payment_added, $payment_id, $this->id); |
|
| 550 | 550 | |
| 551 | 551 | return $payment_added; |
| 552 | 552 | } |
@@ -564,33 +564,33 @@ discard block |
||
| 564 | 564 | * |
| 565 | 565 | * @return boolean If the removal was successful. |
| 566 | 566 | */ |
| 567 | - public function remove_payment( $payment_id = 0, $update_stats = true ) { |
|
| 567 | + public function remove_payment($payment_id = 0, $update_stats = true) { |
|
| 568 | 568 | |
| 569 | - if ( empty( $payment_id ) ) { |
|
| 569 | + if (empty($payment_id)) { |
|
| 570 | 570 | return false; |
| 571 | 571 | } |
| 572 | 572 | |
| 573 | - $payment = new Give_Payment( $payment_id ); |
|
| 573 | + $payment = new Give_Payment($payment_id); |
|
| 574 | 574 | |
| 575 | - if ( 'publish' !== $payment->status && 'revoked' !== $payment->status ) { |
|
| 575 | + if ('publish' !== $payment->status && 'revoked' !== $payment->status) { |
|
| 576 | 576 | $update_stats = false; |
| 577 | 577 | } |
| 578 | 578 | |
| 579 | 579 | $new_payment_ids = ''; |
| 580 | 580 | |
| 581 | - if ( ! empty( $this->payment_ids ) ) { |
|
| 581 | + if ( ! empty($this->payment_ids)) { |
|
| 582 | 582 | |
| 583 | - $payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) ); |
|
| 583 | + $payment_ids = array_map('absint', explode(',', $this->payment_ids)); |
|
| 584 | 584 | |
| 585 | - $pos = array_search( $payment_id, $payment_ids ); |
|
| 586 | - if ( false === $pos ) { |
|
| 585 | + $pos = array_search($payment_id, $payment_ids); |
|
| 586 | + if (false === $pos) { |
|
| 587 | 587 | return false; |
| 588 | 588 | } |
| 589 | 589 | |
| 590 | - unset( $payment_ids[ $pos ] ); |
|
| 591 | - $payment_ids = array_filter( $payment_ids ); |
|
| 590 | + unset($payment_ids[$pos]); |
|
| 591 | + $payment_ids = array_filter($payment_ids); |
|
| 592 | 592 | |
| 593 | - $new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) ); |
|
| 593 | + $new_payment_ids = implode(',', array_unique(array_values($payment_ids))); |
|
| 594 | 594 | |
| 595 | 595 | } |
| 596 | 596 | |
@@ -602,20 +602,20 @@ discard block |
||
| 602 | 602 | * @param int $payment_id Payment id. |
| 603 | 603 | * @param int $donor_id Customer id. |
| 604 | 604 | */ |
| 605 | - do_action( 'give_donor_pre_remove_payment', $payment_id, $this->id ); |
|
| 605 | + do_action('give_donor_pre_remove_payment', $payment_id, $this->id); |
|
| 606 | 606 | |
| 607 | - $payment_removed = $this->update( array( 'payment_ids' => $new_payment_ids ) ); |
|
| 607 | + $payment_removed = $this->update(array('payment_ids' => $new_payment_ids)); |
|
| 608 | 608 | |
| 609 | - if ( $payment_removed ) { |
|
| 609 | + if ($payment_removed) { |
|
| 610 | 610 | |
| 611 | 611 | $this->payment_ids = $new_payment_ids; |
| 612 | 612 | |
| 613 | - if ( $update_stats ) { |
|
| 613 | + if ($update_stats) { |
|
| 614 | 614 | // We removed this payment successfully, decrement the stats |
| 615 | - $payment_amount = give_donation_amount( $payment_id ); |
|
| 615 | + $payment_amount = give_donation_amount($payment_id); |
|
| 616 | 616 | |
| 617 | - if ( ! empty( $payment_amount ) ) { |
|
| 618 | - $this->decrease_value( $payment_amount ); |
|
| 617 | + if ( ! empty($payment_amount)) { |
|
| 618 | + $this->decrease_value($payment_amount); |
|
| 619 | 619 | } |
| 620 | 620 | |
| 621 | 621 | $this->decrease_donation_count(); |
@@ -631,7 +631,7 @@ discard block |
||
| 631 | 631 | * @param int $payment_id Payment id. |
| 632 | 632 | * @param int $donor_id Donor id. |
| 633 | 633 | */ |
| 634 | - do_action( 'give_donor_post_remove_payment', $payment_removed, $payment_id, $this->id ); |
|
| 634 | + do_action('give_donor_post_remove_payment', $payment_removed, $payment_id, $this->id); |
|
| 635 | 635 | |
| 636 | 636 | return $payment_removed; |
| 637 | 637 | |
@@ -647,10 +647,10 @@ discard block |
||
| 647 | 647 | * |
| 648 | 648 | * @return int The donation count. |
| 649 | 649 | */ |
| 650 | - public function increase_purchase_count( $count = 1 ) { |
|
| 650 | + public function increase_purchase_count($count = 1) { |
|
| 651 | 651 | |
| 652 | 652 | // Make sure it's numeric and not negative. |
| 653 | - if ( ! is_numeric( $count ) || $count != absint( $count ) ) { |
|
| 653 | + if ( ! is_numeric($count) || $count != absint($count)) { |
|
| 654 | 654 | return false; |
| 655 | 655 | } |
| 656 | 656 | |
@@ -664,9 +664,9 @@ discard block |
||
| 664 | 664 | * @param int $count The number to increase by. |
| 665 | 665 | * @param int $donor_id Donor id. |
| 666 | 666 | */ |
| 667 | - do_action( 'give_donor_pre_increase_donation_count', $count, $this->id ); |
|
| 667 | + do_action('give_donor_pre_increase_donation_count', $count, $this->id); |
|
| 668 | 668 | |
| 669 | - if ( $this->update( array( 'purchase_count' => $new_total ) ) ) { |
|
| 669 | + if ($this->update(array('purchase_count' => $new_total))) { |
|
| 670 | 670 | $this->purchase_count = $new_total; |
| 671 | 671 | } |
| 672 | 672 | |
@@ -679,7 +679,7 @@ discard block |
||
| 679 | 679 | * @param int $count The number increased by. |
| 680 | 680 | * @param int $donor_id Donor id. |
| 681 | 681 | */ |
| 682 | - do_action( 'give_donor_post_increase_donation_count', $this->purchase_count, $count, $this->id ); |
|
| 682 | + do_action('give_donor_post_increase_donation_count', $this->purchase_count, $count, $this->id); |
|
| 683 | 683 | |
| 684 | 684 | return $this->purchase_count; |
| 685 | 685 | } |
@@ -694,16 +694,16 @@ discard block |
||
| 694 | 694 | * |
| 695 | 695 | * @return mixed If successful, the new count, otherwise false. |
| 696 | 696 | */ |
| 697 | - public function decrease_donation_count( $count = 1 ) { |
|
| 697 | + public function decrease_donation_count($count = 1) { |
|
| 698 | 698 | |
| 699 | 699 | // Make sure it's numeric and not negative |
| 700 | - if ( ! is_numeric( $count ) || $count != absint( $count ) ) { |
|
| 700 | + if ( ! is_numeric($count) || $count != absint($count)) { |
|
| 701 | 701 | return false; |
| 702 | 702 | } |
| 703 | 703 | |
| 704 | 704 | $new_total = (int) $this->purchase_count - (int) $count; |
| 705 | 705 | |
| 706 | - if ( $new_total < 0 ) { |
|
| 706 | + if ($new_total < 0) { |
|
| 707 | 707 | $new_total = 0; |
| 708 | 708 | } |
| 709 | 709 | |
@@ -715,9 +715,9 @@ discard block |
||
| 715 | 715 | * @param int $count The number to decrease by. |
| 716 | 716 | * @param int $donor_id Customer id. |
| 717 | 717 | */ |
| 718 | - do_action( 'give_donor_pre_decrease_donation_count', $count, $this->id ); |
|
| 718 | + do_action('give_donor_pre_decrease_donation_count', $count, $this->id); |
|
| 719 | 719 | |
| 720 | - if ( $this->update( array( 'purchase_count' => $new_total ) ) ) { |
|
| 720 | + if ($this->update(array('purchase_count' => $new_total))) { |
|
| 721 | 721 | $this->purchase_count = $new_total; |
| 722 | 722 | } |
| 723 | 723 | |
@@ -730,7 +730,7 @@ discard block |
||
| 730 | 730 | * @param int $count The number decreased by. |
| 731 | 731 | * @param int $donor_id Donor id. |
| 732 | 732 | */ |
| 733 | - do_action( 'give_donor_post_decrease_donation_count', $this->purchase_count, $count, $this->id ); |
|
| 733 | + do_action('give_donor_post_decrease_donation_count', $this->purchase_count, $count, $this->id); |
|
| 734 | 734 | |
| 735 | 735 | return $this->purchase_count; |
| 736 | 736 | } |
@@ -745,9 +745,9 @@ discard block |
||
| 745 | 745 | * |
| 746 | 746 | * @return mixed If successful, the new value, otherwise false. |
| 747 | 747 | */ |
| 748 | - public function increase_value( $value = 0.00 ) { |
|
| 748 | + public function increase_value($value = 0.00) { |
|
| 749 | 749 | |
| 750 | - $new_value = floatval( $this->purchase_value ) + $value; |
|
| 750 | + $new_value = floatval($this->purchase_value) + $value; |
|
| 751 | 751 | |
| 752 | 752 | /** |
| 753 | 753 | * Fires before increasing donor lifetime value. |
@@ -757,9 +757,9 @@ discard block |
||
| 757 | 757 | * @param float $value The value to increase by. |
| 758 | 758 | * @param int $donor_id Customer id. |
| 759 | 759 | */ |
| 760 | - do_action( 'give_donor_pre_increase_value', $value, $this->id ); |
|
| 760 | + do_action('give_donor_pre_increase_value', $value, $this->id); |
|
| 761 | 761 | |
| 762 | - if ( $this->update( array( 'purchase_value' => $new_value ) ) ) { |
|
| 762 | + if ($this->update(array('purchase_value' => $new_value))) { |
|
| 763 | 763 | $this->purchase_value = $new_value; |
| 764 | 764 | } |
| 765 | 765 | |
@@ -772,7 +772,7 @@ discard block |
||
| 772 | 772 | * @param float $value The value increased by. |
| 773 | 773 | * @param int $donor_id Donor id. |
| 774 | 774 | */ |
| 775 | - do_action( 'give_donor_post_increase_value', $this->purchase_value, $value, $this->id ); |
|
| 775 | + do_action('give_donor_post_increase_value', $this->purchase_value, $value, $this->id); |
|
| 776 | 776 | |
| 777 | 777 | return $this->purchase_value; |
| 778 | 778 | } |
@@ -787,11 +787,11 @@ discard block |
||
| 787 | 787 | * |
| 788 | 788 | * @return mixed If successful, the new value, otherwise false. |
| 789 | 789 | */ |
| 790 | - public function decrease_value( $value = 0.00 ) { |
|
| 790 | + public function decrease_value($value = 0.00) { |
|
| 791 | 791 | |
| 792 | - $new_value = floatval( $this->purchase_value ) - $value; |
|
| 792 | + $new_value = floatval($this->purchase_value) - $value; |
|
| 793 | 793 | |
| 794 | - if ( $new_value < 0 ) { |
|
| 794 | + if ($new_value < 0) { |
|
| 795 | 795 | $new_value = 0.00; |
| 796 | 796 | } |
| 797 | 797 | |
@@ -803,9 +803,9 @@ discard block |
||
| 803 | 803 | * @param float $value The value to decrease by. |
| 804 | 804 | * @param int $donor_id Donor id. |
| 805 | 805 | */ |
| 806 | - do_action( 'give_donor_pre_decrease_value', $value, $this->id ); |
|
| 806 | + do_action('give_donor_pre_decrease_value', $value, $this->id); |
|
| 807 | 807 | |
| 808 | - if ( $this->update( array( 'purchase_value' => $new_value ) ) ) { |
|
| 808 | + if ($this->update(array('purchase_value' => $new_value))) { |
|
| 809 | 809 | $this->purchase_value = $new_value; |
| 810 | 810 | } |
| 811 | 811 | |
@@ -818,7 +818,7 @@ discard block |
||
| 818 | 818 | * @param float $value The value decreased by. |
| 819 | 819 | * @param int $donor_id Donor id. |
| 820 | 820 | */ |
| 821 | - do_action( 'give_donor_post_decrease_value', $this->purchase_value, $value, $this->id ); |
|
| 821 | + do_action('give_donor_post_decrease_value', $this->purchase_value, $value, $this->id); |
|
| 822 | 822 | |
| 823 | 823 | return $this->purchase_value; |
| 824 | 824 | } |
@@ -838,7 +838,7 @@ discard block |
||
| 838 | 838 | * |
| 839 | 839 | * @return mixed If successful, the new donation stat value, otherwise false. |
| 840 | 840 | */ |
| 841 | - public function update_donation_value( $curr_amount, $new_amount ) { |
|
| 841 | + public function update_donation_value($curr_amount, $new_amount) { |
|
| 842 | 842 | /** |
| 843 | 843 | * Payment total difference value can be: |
| 844 | 844 | * zero (in case amount not change) |
@@ -848,15 +848,15 @@ discard block |
||
| 848 | 848 | $payment_total_diff = $new_amount - $curr_amount; |
| 849 | 849 | |
| 850 | 850 | // We do not need to update donation stat if donation did not change. |
| 851 | - if ( ! $payment_total_diff ) { |
|
| 851 | + if ( ! $payment_total_diff) { |
|
| 852 | 852 | return false; |
| 853 | 853 | } |
| 854 | 854 | |
| 855 | - if ( $payment_total_diff > 0 ) { |
|
| 856 | - $this->increase_value( $payment_total_diff ); |
|
| 855 | + if ($payment_total_diff > 0) { |
|
| 856 | + $this->increase_value($payment_total_diff); |
|
| 857 | 857 | } else { |
| 858 | 858 | // Pass payment total difference as +ve value to decrease amount from user lifetime stat. |
| 859 | - $this->decrease_value( - $payment_total_diff ); |
|
| 859 | + $this->decrease_value( -$payment_total_diff ); |
|
| 860 | 860 | } |
| 861 | 861 | |
| 862 | 862 | return $this->purchase_value; |
@@ -873,15 +873,15 @@ discard block |
||
| 873 | 873 | * |
| 874 | 874 | * @return array The notes requested. |
| 875 | 875 | */ |
| 876 | - public function get_notes( $length = 20, $paged = 1 ) { |
|
| 876 | + public function get_notes($length = 20, $paged = 1) { |
|
| 877 | 877 | |
| 878 | - $length = is_numeric( $length ) ? $length : 20; |
|
| 879 | - $offset = is_numeric( $paged ) && $paged != 1 ? ( ( absint( $paged ) - 1 ) * $length ) : 0; |
|
| 878 | + $length = is_numeric($length) ? $length : 20; |
|
| 879 | + $offset = is_numeric($paged) && $paged != 1 ? ((absint($paged) - 1) * $length) : 0; |
|
| 880 | 880 | |
| 881 | 881 | $all_notes = $this->get_raw_notes(); |
| 882 | - $notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) ); |
|
| 882 | + $notes_array = array_reverse(array_filter(explode("\n\n", $all_notes))); |
|
| 883 | 883 | |
| 884 | - $desired_notes = array_slice( $notes_array, $offset, $length ); |
|
| 884 | + $desired_notes = array_slice($notes_array, $offset, $length); |
|
| 885 | 885 | |
| 886 | 886 | return $desired_notes; |
| 887 | 887 | |
@@ -898,9 +898,9 @@ discard block |
||
| 898 | 898 | public function get_notes_count() { |
| 899 | 899 | |
| 900 | 900 | $all_notes = $this->get_raw_notes(); |
| 901 | - $notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) ); |
|
| 901 | + $notes_array = array_reverse(array_filter(explode("\n\n", $all_notes))); |
|
| 902 | 902 | |
| 903 | - return count( $notes_array ); |
|
| 903 | + return count($notes_array); |
|
| 904 | 904 | |
| 905 | 905 | } |
| 906 | 906 | |
@@ -913,7 +913,7 @@ discard block |
||
| 913 | 913 | * |
| 914 | 914 | * @return string|float |
| 915 | 915 | */ |
| 916 | - public function get_total_donation_amount( $args = array() ) { |
|
| 916 | + public function get_total_donation_amount($args = array()) { |
|
| 917 | 917 | |
| 918 | 918 | /** |
| 919 | 919 | * Filter total donation amount. |
@@ -924,7 +924,7 @@ discard block |
||
| 924 | 924 | * @param integer $donor_id Donor ID. |
| 925 | 925 | * @param array $args Pass additional data. |
| 926 | 926 | */ |
| 927 | - return apply_filters( 'give_get_total_donation_amount', $this->purchase_value, $this->id, $args ); |
|
| 927 | + return apply_filters('give_get_total_donation_amount', $this->purchase_value, $this->id, $args); |
|
| 928 | 928 | } |
| 929 | 929 | |
| 930 | 930 | /** |
@@ -937,22 +937,22 @@ discard block |
||
| 937 | 937 | * |
| 938 | 938 | * @return string|boolean The new note if added successfully, false otherwise. |
| 939 | 939 | */ |
| 940 | - public function add_note( $note = '' ) { |
|
| 940 | + public function add_note($note = '') { |
|
| 941 | 941 | |
| 942 | - $note = trim( $note ); |
|
| 943 | - if ( empty( $note ) ) { |
|
| 942 | + $note = trim($note); |
|
| 943 | + if (empty($note)) { |
|
| 944 | 944 | return false; |
| 945 | 945 | } |
| 946 | 946 | |
| 947 | 947 | $notes = $this->get_raw_notes(); |
| 948 | 948 | |
| 949 | - if ( empty( $notes ) ) { |
|
| 949 | + if (empty($notes)) { |
|
| 950 | 950 | $notes = ''; |
| 951 | 951 | } |
| 952 | 952 | |
| 953 | - $note_string = date_i18n( 'F j, Y H:i:s', current_time( 'timestamp' ) ) . ' - ' . $note; |
|
| 954 | - $new_note = apply_filters( 'give_customer_add_note_string', $note_string ); |
|
| 955 | - $notes .= "\n\n" . $new_note; |
|
| 953 | + $note_string = date_i18n('F j, Y H:i:s', current_time('timestamp')).' - '.$note; |
|
| 954 | + $new_note = apply_filters('give_customer_add_note_string', $note_string); |
|
| 955 | + $notes .= "\n\n".$new_note; |
|
| 956 | 956 | |
| 957 | 957 | /** |
| 958 | 958 | * Fires before donor note is added. |
@@ -962,11 +962,11 @@ discard block |
||
| 962 | 962 | * @param string $new_note New note to add. |
| 963 | 963 | * @param int $donor_id Donor id. |
| 964 | 964 | */ |
| 965 | - do_action( 'give_donor_pre_add_note', $new_note, $this->id ); |
|
| 965 | + do_action('give_donor_pre_add_note', $new_note, $this->id); |
|
| 966 | 966 | |
| 967 | - $updated = $this->update( array( 'notes' => $notes ) ); |
|
| 967 | + $updated = $this->update(array('notes' => $notes)); |
|
| 968 | 968 | |
| 969 | - if ( $updated ) { |
|
| 969 | + if ($updated) { |
|
| 970 | 970 | $this->notes = $this->get_notes(); |
| 971 | 971 | } |
| 972 | 972 | |
@@ -979,7 +979,7 @@ discard block |
||
| 979 | 979 | * @param string $new_note New note added. |
| 980 | 980 | * @param int $donor_id Donor id. |
| 981 | 981 | */ |
| 982 | - do_action( 'give_donor_post_add_note', $this->notes, $new_note, $this->id ); |
|
| 982 | + do_action('give_donor_post_add_note', $this->notes, $new_note, $this->id); |
|
| 983 | 983 | |
| 984 | 984 | // Return the formatted note, so we can test, as well as update any displays |
| 985 | 985 | return $new_note; |
@@ -996,7 +996,7 @@ discard block |
||
| 996 | 996 | */ |
| 997 | 997 | private function get_raw_notes() { |
| 998 | 998 | |
| 999 | - $all_notes = $this->db->get_column( 'notes', $this->id ); |
|
| 999 | + $all_notes = $this->db->get_column('notes', $this->id); |
|
| 1000 | 1000 | |
| 1001 | 1001 | return $all_notes; |
| 1002 | 1002 | |
@@ -1014,8 +1014,8 @@ discard block |
||
| 1014 | 1014 | * @return mixed Will be an array if $single is false. Will be value of meta data field if $single is |
| 1015 | 1015 | * true. |
| 1016 | 1016 | */ |
| 1017 | - public function get_meta( $meta_key = '', $single = true ) { |
|
| 1018 | - return Give()->donor_meta->get_meta( $this->id, $meta_key, $single ); |
|
| 1017 | + public function get_meta($meta_key = '', $single = true) { |
|
| 1018 | + return Give()->donor_meta->get_meta($this->id, $meta_key, $single); |
|
| 1019 | 1019 | } |
| 1020 | 1020 | |
| 1021 | 1021 | /** |
@@ -1030,8 +1030,8 @@ discard block |
||
| 1030 | 1030 | * |
| 1031 | 1031 | * @return bool False for failure. True for success. |
| 1032 | 1032 | */ |
| 1033 | - public function add_meta( $meta_key = '', $meta_value, $unique = false ) { |
|
| 1034 | - return Give()->donor_meta->add_meta( $this->id, $meta_key, $meta_value, $unique ); |
|
| 1033 | + public function add_meta($meta_key = '', $meta_value, $unique = false) { |
|
| 1034 | + return Give()->donor_meta->add_meta($this->id, $meta_key, $meta_value, $unique); |
|
| 1035 | 1035 | } |
| 1036 | 1036 | |
| 1037 | 1037 | /** |
@@ -1046,8 +1046,8 @@ discard block |
||
| 1046 | 1046 | * |
| 1047 | 1047 | * @return bool False on failure, true if success. |
| 1048 | 1048 | */ |
| 1049 | - public function update_meta( $meta_key = '', $meta_value, $prev_value = '' ) { |
|
| 1050 | - return Give()->donor_meta->update_meta( $this->id, $meta_key, $meta_value, $prev_value ); |
|
| 1049 | + public function update_meta($meta_key = '', $meta_value, $prev_value = '') { |
|
| 1050 | + return Give()->donor_meta->update_meta($this->id, $meta_key, $meta_value, $prev_value); |
|
| 1051 | 1051 | } |
| 1052 | 1052 | |
| 1053 | 1053 | /** |
@@ -1061,8 +1061,8 @@ discard block |
||
| 1061 | 1061 | * |
| 1062 | 1062 | * @return bool False for failure. True for success. |
| 1063 | 1063 | */ |
| 1064 | - public function delete_meta( $meta_key = '', $meta_value = '' ) { |
|
| 1065 | - return Give()->donor_meta->delete_meta( $this->id, $meta_key, $meta_value ); |
|
| 1064 | + public function delete_meta($meta_key = '', $meta_value = '') { |
|
| 1065 | + return Give()->donor_meta->delete_meta($this->id, $meta_key, $meta_value); |
|
| 1066 | 1066 | } |
| 1067 | 1067 | |
| 1068 | 1068 | /** |
@@ -1075,51 +1075,51 @@ discard block |
||
| 1075 | 1075 | * |
| 1076 | 1076 | * @return array The sanitized data, based off column defaults. |
| 1077 | 1077 | */ |
| 1078 | - private function sanitize_columns( $data ) { |
|
| 1078 | + private function sanitize_columns($data) { |
|
| 1079 | 1079 | |
| 1080 | 1080 | $columns = $this->db->get_columns(); |
| 1081 | 1081 | $default_values = $this->db->get_column_defaults(); |
| 1082 | 1082 | |
| 1083 | - foreach ( $columns as $key => $type ) { |
|
| 1083 | + foreach ($columns as $key => $type) { |
|
| 1084 | 1084 | |
| 1085 | 1085 | // Only sanitize data that we were provided |
| 1086 | - if ( ! array_key_exists( $key, $data ) ) { |
|
| 1086 | + if ( ! array_key_exists($key, $data)) { |
|
| 1087 | 1087 | continue; |
| 1088 | 1088 | } |
| 1089 | 1089 | |
| 1090 | - switch ( $type ) { |
|
| 1090 | + switch ($type) { |
|
| 1091 | 1091 | |
| 1092 | 1092 | case '%s': |
| 1093 | - if ( 'email' == $key ) { |
|
| 1094 | - $data[ $key ] = sanitize_email( $data[ $key ] ); |
|
| 1095 | - } elseif ( 'notes' == $key ) { |
|
| 1096 | - $data[ $key ] = strip_tags( $data[ $key ] ); |
|
| 1093 | + if ('email' == $key) { |
|
| 1094 | + $data[$key] = sanitize_email($data[$key]); |
|
| 1095 | + } elseif ('notes' == $key) { |
|
| 1096 | + $data[$key] = strip_tags($data[$key]); |
|
| 1097 | 1097 | } else { |
| 1098 | - $data[ $key ] = sanitize_text_field( $data[ $key ] ); |
|
| 1098 | + $data[$key] = sanitize_text_field($data[$key]); |
|
| 1099 | 1099 | } |
| 1100 | 1100 | break; |
| 1101 | 1101 | |
| 1102 | 1102 | case '%d': |
| 1103 | - if ( ! is_numeric( $data[ $key ] ) || (int) $data[ $key ] !== absint( $data[ $key ] ) ) { |
|
| 1104 | - $data[ $key ] = $default_values[ $key ]; |
|
| 1103 | + if ( ! is_numeric($data[$key]) || (int) $data[$key] !== absint($data[$key])) { |
|
| 1104 | + $data[$key] = $default_values[$key]; |
|
| 1105 | 1105 | } else { |
| 1106 | - $data[ $key ] = absint( $data[ $key ] ); |
|
| 1106 | + $data[$key] = absint($data[$key]); |
|
| 1107 | 1107 | } |
| 1108 | 1108 | break; |
| 1109 | 1109 | |
| 1110 | 1110 | case '%f': |
| 1111 | 1111 | // Convert what was given to a float |
| 1112 | - $value = floatval( $data[ $key ] ); |
|
| 1112 | + $value = floatval($data[$key]); |
|
| 1113 | 1113 | |
| 1114 | - if ( ! is_float( $value ) ) { |
|
| 1115 | - $data[ $key ] = $default_values[ $key ]; |
|
| 1114 | + if ( ! is_float($value)) { |
|
| 1115 | + $data[$key] = $default_values[$key]; |
|
| 1116 | 1116 | } else { |
| 1117 | - $data[ $key ] = $value; |
|
| 1117 | + $data[$key] = $value; |
|
| 1118 | 1118 | } |
| 1119 | 1119 | break; |
| 1120 | 1120 | |
| 1121 | 1121 | default: |
| 1122 | - $data[ $key ] = sanitize_text_field( $data[ $key ] ); |
|
| 1122 | + $data[$key] = sanitize_text_field($data[$key]); |
|
| 1123 | 1123 | break; |
| 1124 | 1124 | |
| 1125 | 1125 | } |
@@ -1139,33 +1139,33 @@ discard block |
||
| 1139 | 1139 | * |
| 1140 | 1140 | * @return bool If the email was added successfully |
| 1141 | 1141 | */ |
| 1142 | - public function add_email( $email = '', $primary = false ) { |
|
| 1143 | - if ( ! is_email( $email ) ) { |
|
| 1142 | + public function add_email($email = '', $primary = false) { |
|
| 1143 | + if ( ! is_email($email)) { |
|
| 1144 | 1144 | return false; |
| 1145 | 1145 | } |
| 1146 | - $existing = new Give_Donor( $email ); |
|
| 1146 | + $existing = new Give_Donor($email); |
|
| 1147 | 1147 | |
| 1148 | - if ( $existing->id > 0 ) { |
|
| 1148 | + if ($existing->id > 0) { |
|
| 1149 | 1149 | // Email address already belongs to another donor |
| 1150 | 1150 | return false; |
| 1151 | 1151 | } |
| 1152 | 1152 | |
| 1153 | - if ( email_exists( $email ) ) { |
|
| 1154 | - $user = get_user_by( 'email', $email ); |
|
| 1155 | - if ( $user->ID != $this->user_id ) { |
|
| 1153 | + if (email_exists($email)) { |
|
| 1154 | + $user = get_user_by('email', $email); |
|
| 1155 | + if ($user->ID != $this->user_id) { |
|
| 1156 | 1156 | return false; |
| 1157 | 1157 | } |
| 1158 | 1158 | } |
| 1159 | 1159 | |
| 1160 | - do_action( 'give_donor_pre_add_email', $email, $this->id, $this ); |
|
| 1160 | + do_action('give_donor_pre_add_email', $email, $this->id, $this); |
|
| 1161 | 1161 | |
| 1162 | 1162 | // Add is used to ensure duplicate emails are not added |
| 1163 | - $ret = (bool) $this->add_meta( 'additional_email', $email ); |
|
| 1163 | + $ret = (bool) $this->add_meta('additional_email', $email); |
|
| 1164 | 1164 | |
| 1165 | - do_action( 'give_donor_post_add_email', $email, $this->id, $this ); |
|
| 1165 | + do_action('give_donor_post_add_email', $email, $this->id, $this); |
|
| 1166 | 1166 | |
| 1167 | - if ( $ret && true === $primary ) { |
|
| 1168 | - $this->set_primary_email( $email ); |
|
| 1167 | + if ($ret && true === $primary) { |
|
| 1168 | + $this->set_primary_email($email); |
|
| 1169 | 1169 | } |
| 1170 | 1170 | |
| 1171 | 1171 | return $ret; |
@@ -1181,16 +1181,16 @@ discard block |
||
| 1181 | 1181 | * |
| 1182 | 1182 | * @return bool If the email was removed successfully. |
| 1183 | 1183 | */ |
| 1184 | - public function remove_email( $email = '' ) { |
|
| 1185 | - if ( ! is_email( $email ) ) { |
|
| 1184 | + public function remove_email($email = '') { |
|
| 1185 | + if ( ! is_email($email)) { |
|
| 1186 | 1186 | return false; |
| 1187 | 1187 | } |
| 1188 | 1188 | |
| 1189 | - do_action( 'give_donor_pre_remove_email', $email, $this->id, $this ); |
|
| 1189 | + do_action('give_donor_pre_remove_email', $email, $this->id, $this); |
|
| 1190 | 1190 | |
| 1191 | - $ret = (bool) $this->delete_meta( 'additional_email', $email ); |
|
| 1191 | + $ret = (bool) $this->delete_meta('additional_email', $email); |
|
| 1192 | 1192 | |
| 1193 | - do_action( 'give_donor_post_remove_email', $email, $this->id, $this ); |
|
| 1193 | + do_action('give_donor_post_remove_email', $email, $this->id, $this); |
|
| 1194 | 1194 | |
| 1195 | 1195 | return $ret; |
| 1196 | 1196 | } |
@@ -1207,16 +1207,16 @@ discard block |
||
| 1207 | 1207 | * |
| 1208 | 1208 | * @return bool If the email was set as primary successfully. |
| 1209 | 1209 | */ |
| 1210 | - public function set_primary_email( $new_primary_email = '' ) { |
|
| 1211 | - if ( ! is_email( $new_primary_email ) ) { |
|
| 1210 | + public function set_primary_email($new_primary_email = '') { |
|
| 1211 | + if ( ! is_email($new_primary_email)) { |
|
| 1212 | 1212 | return false; |
| 1213 | 1213 | } |
| 1214 | 1214 | |
| 1215 | - do_action( 'give_donor_pre_set_primary_email', $new_primary_email, $this->id, $this ); |
|
| 1215 | + do_action('give_donor_pre_set_primary_email', $new_primary_email, $this->id, $this); |
|
| 1216 | 1216 | |
| 1217 | - $existing = new Give_Donor( $new_primary_email ); |
|
| 1217 | + $existing = new Give_Donor($new_primary_email); |
|
| 1218 | 1218 | |
| 1219 | - if ( $existing->id > 0 && (int) $existing->id !== (int) $this->id ) { |
|
| 1219 | + if ($existing->id > 0 && (int) $existing->id !== (int) $this->id) { |
|
| 1220 | 1220 | // This email belongs to another donor. |
| 1221 | 1221 | return false; |
| 1222 | 1222 | } |
@@ -1224,21 +1224,21 @@ discard block |
||
| 1224 | 1224 | $old_email = $this->email; |
| 1225 | 1225 | |
| 1226 | 1226 | // Update donor record with new email. |
| 1227 | - $update = $this->update( array( 'email' => $new_primary_email ) ); |
|
| 1227 | + $update = $this->update(array('email' => $new_primary_email)); |
|
| 1228 | 1228 | |
| 1229 | 1229 | // Remove new primary from list of additional emails. |
| 1230 | - $remove = $this->remove_email( $new_primary_email ); |
|
| 1230 | + $remove = $this->remove_email($new_primary_email); |
|
| 1231 | 1231 | |
| 1232 | 1232 | // Add old email to additional emails list. |
| 1233 | - $add = $this->add_email( $old_email ); |
|
| 1233 | + $add = $this->add_email($old_email); |
|
| 1234 | 1234 | |
| 1235 | 1235 | $ret = $update && $remove && $add; |
| 1236 | 1236 | |
| 1237 | - if ( $ret ) { |
|
| 1237 | + if ($ret) { |
|
| 1238 | 1238 | $this->email = $new_primary_email; |
| 1239 | 1239 | } |
| 1240 | 1240 | |
| 1241 | - do_action( 'give_donor_post_set_primary_email', $new_primary_email, $this->id, $this ); |
|
| 1241 | + do_action('give_donor_post_set_primary_email', $new_primary_email, $this->id, $this); |
|
| 1242 | 1242 | |
| 1243 | 1243 | return $ret; |
| 1244 | 1244 | } |
@@ -1253,17 +1253,17 @@ discard block |
||
| 1253 | 1253 | * |
| 1254 | 1254 | * @return bool |
| 1255 | 1255 | */ |
| 1256 | - private function is_valid_address( $address ) { |
|
| 1256 | + private function is_valid_address($address) { |
|
| 1257 | 1257 | $is_valid_address = true; |
| 1258 | 1258 | |
| 1259 | 1259 | // Address ready to process even if only one value set. |
| 1260 | - foreach ( $address as $address_type => $value ) { |
|
| 1260 | + foreach ($address as $address_type => $value) { |
|
| 1261 | 1261 | // @todo: Handle state field validation on basis of country. |
| 1262 | - if ( in_array( $address_type, array( 'line2', 'state' ) ) ) { |
|
| 1262 | + if (in_array($address_type, array('line2', 'state'))) { |
|
| 1263 | 1263 | continue; |
| 1264 | 1264 | } |
| 1265 | 1265 | |
| 1266 | - if ( empty( $value ) ) { |
|
| 1266 | + if (empty($value)) { |
|
| 1267 | 1267 | $is_valid_address = false; |
| 1268 | 1268 | break; |
| 1269 | 1269 | } |
@@ -1290,57 +1290,57 @@ discard block |
||
| 1290 | 1290 | * |
| 1291 | 1291 | * @return bool |
| 1292 | 1292 | */ |
| 1293 | - public function add_address( $address_type, $address ) { |
|
| 1293 | + public function add_address($address_type, $address) { |
|
| 1294 | 1294 | // Bailout. |
| 1295 | - if ( empty( $address_type ) || ! $this->is_valid_address( $address ) || ! $this->id ) { |
|
| 1295 | + if (empty($address_type) || ! $this->is_valid_address($address) || ! $this->id) { |
|
| 1296 | 1296 | return false; |
| 1297 | 1297 | } |
| 1298 | 1298 | |
| 1299 | 1299 | // Check if multiple address exist or not and set params. |
| 1300 | 1300 | $multi_address_id = null; |
| 1301 | - if ( $is_multi_address = ( false !== strpos( $address_type, '[]' ) ) ) { |
|
| 1302 | - $address_type = $is_multi_address ? str_replace( '[]', '', $address_type ) : $address_type; |
|
| 1303 | - } elseif ( $is_multi_address = ( false !== strpos( $address_type, '_' ) ) ) { |
|
| 1304 | - $multi_address_id = $is_multi_address ? array_pop( explode( '_', $address_type ) ) : $address_type; |
|
| 1301 | + if ($is_multi_address = (false !== strpos($address_type, '[]'))) { |
|
| 1302 | + $address_type = $is_multi_address ? str_replace('[]', '', $address_type) : $address_type; |
|
| 1303 | + } elseif ($is_multi_address = (false !== strpos($address_type, '_'))) { |
|
| 1304 | + $multi_address_id = $is_multi_address ? array_pop(explode('_', $address_type)) : $address_type; |
|
| 1305 | 1305 | |
| 1306 | - $address_type = $is_multi_address ? array_shift( explode( '_', $address_type ) ) : $address_type; |
|
| 1306 | + $address_type = $is_multi_address ? array_shift(explode('_', $address_type)) : $address_type; |
|
| 1307 | 1307 | } |
| 1308 | 1308 | |
| 1309 | 1309 | // Bailout: do not save duplicate orders |
| 1310 | - if ( $this->does_address_exist( $address_type, $address ) ) { |
|
| 1310 | + if ($this->does_address_exist($address_type, $address)) { |
|
| 1311 | 1311 | return false; |
| 1312 | 1312 | } |
| 1313 | 1313 | |
| 1314 | 1314 | // Set default address. |
| 1315 | - $address = wp_parse_args( $address, array( |
|
| 1315 | + $address = wp_parse_args($address, array( |
|
| 1316 | 1316 | 'line1' => '', |
| 1317 | 1317 | 'line2' => '', |
| 1318 | 1318 | 'city' => '', |
| 1319 | 1319 | 'state' => '', |
| 1320 | 1320 | 'country' => '', |
| 1321 | 1321 | 'zip' => '', |
| 1322 | - ) ); |
|
| 1322 | + )); |
|
| 1323 | 1323 | |
| 1324 | 1324 | // Set meta key prefix. |
| 1325 | 1325 | global $wpdb; |
| 1326 | 1326 | $meta_key_prefix = "_give_donor_address_{$address_type}_{address_name}"; |
| 1327 | 1327 | $meta_type = Give()->donor_meta->meta_type; |
| 1328 | 1328 | |
| 1329 | - if ( $is_multi_address ) { |
|
| 1330 | - if ( is_null( $multi_address_id ) ) { |
|
| 1329 | + if ($is_multi_address) { |
|
| 1330 | + if (is_null($multi_address_id)) { |
|
| 1331 | 1331 | // Get latest address key to set multi address id. |
| 1332 | - $multi_address_id = $wpdb->get_var( $wpdb->prepare( " |
|
| 1332 | + $multi_address_id = $wpdb->get_var($wpdb->prepare(" |
|
| 1333 | 1333 | SELECT meta_key FROM {$wpdb->donormeta} |
| 1334 | 1334 | WHERE meta_key |
| 1335 | 1335 | LIKE '%%%s%%' |
| 1336 | 1336 | AND {$meta_type}_id=%d |
| 1337 | 1337 | ORDER BY meta_id DESC |
| 1338 | 1338 | LIMIT 1 |
| 1339 | - ", "_give_donor_address_{$address_type}_line1", $this->id ) ); |
|
| 1339 | + ", "_give_donor_address_{$address_type}_line1", $this->id)); |
|
| 1340 | 1340 | |
| 1341 | - if ( ! empty( $multi_address_id ) ) { |
|
| 1342 | - $multi_address_id = absint( substr( strrchr( $multi_address_id, '_' ), 1 ) ); |
|
| 1343 | - $multi_address_id ++; |
|
| 1341 | + if ( ! empty($multi_address_id)) { |
|
| 1342 | + $multi_address_id = absint(substr(strrchr($multi_address_id, '_'), 1)); |
|
| 1343 | + $multi_address_id++; |
|
| 1344 | 1344 | } else { |
| 1345 | 1345 | $multi_address_id = 0; |
| 1346 | 1346 | } |
@@ -1350,9 +1350,9 @@ discard block |
||
| 1350 | 1350 | } |
| 1351 | 1351 | |
| 1352 | 1352 | // Save donor address. |
| 1353 | - foreach ( $address as $type => $value ) { |
|
| 1354 | - $meta_key = str_replace( '{address_name}', $type, $meta_key_prefix ); |
|
| 1355 | - Give()->donor_meta->update_meta( $this->id, $meta_key, $value ); |
|
| 1353 | + foreach ($address as $type => $value) { |
|
| 1354 | + $meta_key = str_replace('{address_name}', $type, $meta_key_prefix); |
|
| 1355 | + Give()->donor_meta->update_meta($this->id, $meta_key, $value); |
|
| 1356 | 1356 | } |
| 1357 | 1357 | |
| 1358 | 1358 | $this->setup_address(); |
@@ -1371,31 +1371,31 @@ discard block |
||
| 1371 | 1371 | * |
| 1372 | 1372 | * @return bool |
| 1373 | 1373 | */ |
| 1374 | - public function remove_address( $address_id ) { |
|
| 1374 | + public function remove_address($address_id) { |
|
| 1375 | 1375 | global $wpdb; |
| 1376 | 1376 | |
| 1377 | 1377 | // Get address type. |
| 1378 | - $is_multi_address = false !== strpos( $address_id, '_' ) ? true : false; |
|
| 1378 | + $is_multi_address = false !== strpos($address_id, '_') ? true : false; |
|
| 1379 | 1379 | |
| 1380 | - $address_type = false !== strpos( $address_id, '_' ) ? array_shift( explode( '_', $address_id ) ) : $address_id; |
|
| 1380 | + $address_type = false !== strpos($address_id, '_') ? array_shift(explode('_', $address_id)) : $address_id; |
|
| 1381 | 1381 | |
| 1382 | - $address_count = false !== strpos( $address_id, '_' ) ? array_pop( explode( '_', $address_id ) ) : null; |
|
| 1382 | + $address_count = false !== strpos($address_id, '_') ? array_pop(explode('_', $address_id)) : null; |
|
| 1383 | 1383 | |
| 1384 | 1384 | // Set meta key prefix. |
| 1385 | 1385 | $meta_key_prefix = "_give_donor_address_{$address_type}_%"; |
| 1386 | - if ( $is_multi_address && is_numeric( $address_count ) ) { |
|
| 1386 | + if ($is_multi_address && is_numeric($address_count)) { |
|
| 1387 | 1387 | $meta_key_prefix .= "_{$address_count}"; |
| 1388 | 1388 | } |
| 1389 | 1389 | |
| 1390 | 1390 | $meta_type = Give()->donor_meta->meta_type; |
| 1391 | 1391 | |
| 1392 | 1392 | // Process query. |
| 1393 | - $row_affected = $wpdb->query( $wpdb->prepare( " |
|
| 1393 | + $row_affected = $wpdb->query($wpdb->prepare(" |
|
| 1394 | 1394 | DELETE FROM {$wpdb->donormeta} |
| 1395 | 1395 | WHERE meta_key |
| 1396 | 1396 | LIKE '%s' |
| 1397 | 1397 | AND {$meta_type}_id=%d |
| 1398 | - ", $meta_key_prefix, $this->id ) ); |
|
| 1398 | + ", $meta_key_prefix, $this->id)); |
|
| 1399 | 1399 | |
| 1400 | 1400 | $this->setup_address(); |
| 1401 | 1401 | |
@@ -1414,39 +1414,39 @@ discard block |
||
| 1414 | 1414 | * |
| 1415 | 1415 | * @return bool |
| 1416 | 1416 | */ |
| 1417 | - public function update_address( $address_id, $address ) { |
|
| 1417 | + public function update_address($address_id, $address) { |
|
| 1418 | 1418 | global $wpdb; |
| 1419 | 1419 | |
| 1420 | 1420 | // Get address type. |
| 1421 | - $is_multi_address = false !== strpos( $address_id, '_' ) ? true : false; |
|
| 1421 | + $is_multi_address = false !== strpos($address_id, '_') ? true : false; |
|
| 1422 | 1422 | |
| 1423 | - $address_type = false !== strpos( $address_id, '_' ) ? array_shift( explode( '_', $address_id ) ) : $address_id; |
|
| 1423 | + $address_type = false !== strpos($address_id, '_') ? array_shift(explode('_', $address_id)) : $address_id; |
|
| 1424 | 1424 | |
| 1425 | - $address_count = false !== strpos( $address_id, '_' ) ? array_pop( explode( '_', $address_id ) ) : null; |
|
| 1425 | + $address_count = false !== strpos($address_id, '_') ? array_pop(explode('_', $address_id)) : null; |
|
| 1426 | 1426 | |
| 1427 | 1427 | // Set meta key prefix. |
| 1428 | 1428 | $meta_key_prefix = "_give_donor_address_{$address_type}_%"; |
| 1429 | - if ( $is_multi_address && is_numeric( $address_count ) ) { |
|
| 1429 | + if ($is_multi_address && is_numeric($address_count)) { |
|
| 1430 | 1430 | $meta_key_prefix .= "_{$address_count}"; |
| 1431 | 1431 | } |
| 1432 | 1432 | |
| 1433 | 1433 | $meta_type = Give()->donor_meta->meta_type; |
| 1434 | 1434 | |
| 1435 | 1435 | // Process query. |
| 1436 | - $row_affected = $wpdb->get_results( $wpdb->prepare( " |
|
| 1436 | + $row_affected = $wpdb->get_results($wpdb->prepare(" |
|
| 1437 | 1437 | SELECT meta_key FROM {$wpdb->donormeta} |
| 1438 | 1438 | WHERE meta_key |
| 1439 | 1439 | LIKE '%s' |
| 1440 | 1440 | AND {$meta_type}_id=%d |
| 1441 | - ", $meta_key_prefix, $this->id ) ); |
|
| 1441 | + ", $meta_key_prefix, $this->id)); |
|
| 1442 | 1442 | |
| 1443 | 1443 | // Return result. |
| 1444 | - if ( ! count( $row_affected ) ) { |
|
| 1444 | + if ( ! count($row_affected)) { |
|
| 1445 | 1445 | return false; |
| 1446 | 1446 | } |
| 1447 | 1447 | |
| 1448 | 1448 | // Update address. |
| 1449 | - if ( ! $this->add_address( $address_id, $address ) ) { |
|
| 1449 | + if ( ! $this->add_address($address_id, $address)) { |
|
| 1450 | 1450 | return false; |
| 1451 | 1451 | } |
| 1452 | 1452 | |
@@ -1465,39 +1465,39 @@ discard block |
||
| 1465 | 1465 | * |
| 1466 | 1466 | * @return bool|null |
| 1467 | 1467 | */ |
| 1468 | - public function does_address_exist( $current_address_type, $current_address ) { |
|
| 1468 | + public function does_address_exist($current_address_type, $current_address) { |
|
| 1469 | 1469 | $status = false; |
| 1470 | 1470 | |
| 1471 | 1471 | // Bailout. |
| 1472 | - if ( empty( $current_address_type ) || empty( $current_address ) ) { |
|
| 1472 | + if (empty($current_address_type) || empty($current_address)) { |
|
| 1473 | 1473 | return null; |
| 1474 | 1474 | } |
| 1475 | 1475 | |
| 1476 | 1476 | // Bailout. |
| 1477 | - if ( empty( $this->address ) || empty( $this->address[ $current_address_type ] ) ) { |
|
| 1477 | + if (empty($this->address) || empty($this->address[$current_address_type])) { |
|
| 1478 | 1478 | return $status; |
| 1479 | 1479 | } |
| 1480 | 1480 | |
| 1481 | 1481 | // Get address. |
| 1482 | - $address = $this->address[ $current_address_type ]; |
|
| 1482 | + $address = $this->address[$current_address_type]; |
|
| 1483 | 1483 | |
| 1484 | - switch ( true ) { |
|
| 1484 | + switch (true) { |
|
| 1485 | 1485 | |
| 1486 | 1486 | // Single address. |
| 1487 | - case is_string( end( $address ) ) : |
|
| 1488 | - $status = $this->is_address_match( $current_address, $address ); |
|
| 1487 | + case is_string(end($address)) : |
|
| 1488 | + $status = $this->is_address_match($current_address, $address); |
|
| 1489 | 1489 | break; |
| 1490 | 1490 | |
| 1491 | 1491 | // Multi address. |
| 1492 | - case is_array( end( $address ) ): |
|
| 1492 | + case is_array(end($address)): |
|
| 1493 | 1493 | // Compare address. |
| 1494 | - foreach ( $address as $saved_address ) { |
|
| 1495 | - if ( empty( $saved_address ) ) { |
|
| 1494 | + foreach ($address as $saved_address) { |
|
| 1495 | + if (empty($saved_address)) { |
|
| 1496 | 1496 | continue; |
| 1497 | 1497 | } |
| 1498 | 1498 | |
| 1499 | 1499 | // Exit loop immediately if address exist. |
| 1500 | - if ( $status = $this->is_address_match( $current_address, $saved_address ) ) { |
|
| 1500 | + if ($status = $this->is_address_match($current_address, $saved_address)) { |
|
| 1501 | 1501 | break; |
| 1502 | 1502 | } |
| 1503 | 1503 | } |
@@ -1518,10 +1518,10 @@ discard block |
||
| 1518 | 1518 | * |
| 1519 | 1519 | * @return bool |
| 1520 | 1520 | */ |
| 1521 | - private function is_address_match( $address_1, $address_2 ) { |
|
| 1522 | - $result = array_diff( $address_1, $address_2 ); |
|
| 1521 | + private function is_address_match($address_1, $address_2) { |
|
| 1522 | + $result = array_diff($address_1, $address_2); |
|
| 1523 | 1523 | |
| 1524 | - return empty( $result ); |
|
| 1524 | + return empty($result); |
|
| 1525 | 1525 | } |
| 1526 | 1526 | |
| 1527 | 1527 | /** |
@@ -1532,23 +1532,23 @@ discard block |
||
| 1532 | 1532 | * @since 2.0 |
| 1533 | 1533 | * @return object |
| 1534 | 1534 | */ |
| 1535 | - public function split_donor_name( $id ) { |
|
| 1535 | + public function split_donor_name($id) { |
|
| 1536 | 1536 | $first_name = $last_name = ''; |
| 1537 | - $donor = new Give_Donor( $id ); |
|
| 1537 | + $donor = new Give_Donor($id); |
|
| 1538 | 1538 | |
| 1539 | - $split_donor_name = explode( ' ', $donor->name, 2 ); |
|
| 1539 | + $split_donor_name = explode(' ', $donor->name, 2); |
|
| 1540 | 1540 | |
| 1541 | 1541 | // Check for existence of first name after split of donor name. |
| 1542 | - if ( is_array( $split_donor_name ) && ! empty( $split_donor_name[0] ) ) { |
|
| 1542 | + if (is_array($split_donor_name) && ! empty($split_donor_name[0])) { |
|
| 1543 | 1543 | $first_name = $split_donor_name[0]; |
| 1544 | 1544 | } |
| 1545 | 1545 | |
| 1546 | 1546 | // Check for existence of last name after split of donor name. |
| 1547 | - if ( is_array( $split_donor_name ) && ! empty( $split_donor_name[1] ) ) { |
|
| 1547 | + if (is_array($split_donor_name) && ! empty($split_donor_name[1])) { |
|
| 1548 | 1548 | $last_name = $split_donor_name[1]; |
| 1549 | 1549 | } |
| 1550 | 1550 | |
| 1551 | - return (object) array( 'first_name' => $first_name, 'last_name' => $last_name ); |
|
| 1551 | + return (object) array('first_name' => $first_name, 'last_name' => $last_name); |
|
| 1552 | 1552 | } |
| 1553 | 1553 | |
| 1554 | 1554 | /** |
@@ -1558,9 +1558,9 @@ discard block |
||
| 1558 | 1558 | * @return string |
| 1559 | 1559 | */ |
| 1560 | 1560 | public function get_first_name() { |
| 1561 | - $first_name = $this->get_meta( '_give_donor_first_name' ); |
|
| 1562 | - if ( ! $first_name ) { |
|
| 1563 | - $first_name = $this->split_donor_name( $this->id )->first_name; |
|
| 1561 | + $first_name = $this->get_meta('_give_donor_first_name'); |
|
| 1562 | + if ( ! $first_name) { |
|
| 1563 | + $first_name = $this->split_donor_name($this->id)->first_name; |
|
| 1564 | 1564 | } |
| 1565 | 1565 | |
| 1566 | 1566 | return $first_name; |
@@ -1573,15 +1573,15 @@ discard block |
||
| 1573 | 1573 | * @return string |
| 1574 | 1574 | */ |
| 1575 | 1575 | public function get_last_name() { |
| 1576 | - $first_name = $this->get_meta( '_give_donor_first_name' ); |
|
| 1577 | - $last_name = $this->get_meta( '_give_donor_last_name' ); |
|
| 1576 | + $first_name = $this->get_meta('_give_donor_first_name'); |
|
| 1577 | + $last_name = $this->get_meta('_give_donor_last_name'); |
|
| 1578 | 1578 | |
| 1579 | 1579 | // This condition will prevent unnecessary splitting of donor name to fetch last name. |
| 1580 | - if ( ! $first_name && ! $last_name ) { |
|
| 1581 | - $last_name = $this->split_donor_name( $this->id )->last_name; |
|
| 1580 | + if ( ! $first_name && ! $last_name) { |
|
| 1581 | + $last_name = $this->split_donor_name($this->id)->last_name; |
|
| 1582 | 1582 | } |
| 1583 | 1583 | |
| 1584 | - return ( $last_name ) ? $last_name : ''; |
|
| 1584 | + return ($last_name) ? $last_name : ''; |
|
| 1585 | 1585 | } |
| 1586 | 1586 | |
| 1587 | 1587 | /** |
@@ -1592,7 +1592,7 @@ discard block |
||
| 1592 | 1592 | * @return string $company_name Donor Company Name |
| 1593 | 1593 | */ |
| 1594 | 1594 | public function get_company_name() { |
| 1595 | - $company_name = $this->get_meta( '_give_donor_company' ); |
|
| 1595 | + $company_name = $this->get_meta('_give_donor_company'); |
|
| 1596 | 1596 | |
| 1597 | 1597 | return $company_name; |
| 1598 | 1598 | } |
@@ -1606,9 +1606,9 @@ discard block |
||
| 1606 | 1606 | */ |
| 1607 | 1607 | public function get_last_donation() { |
| 1608 | 1608 | |
| 1609 | - $payments = array_unique( array_values( explode( ',', $this->payment_ids ) ) ); |
|
| 1609 | + $payments = array_unique(array_values(explode(',', $this->payment_ids))); |
|
| 1610 | 1610 | |
| 1611 | - return end( $payments ); |
|
| 1611 | + return end($payments); |
|
| 1612 | 1612 | |
| 1613 | 1613 | } |
| 1614 | 1614 | |
@@ -1621,18 +1621,18 @@ discard block |
||
| 1621 | 1621 | * |
| 1622 | 1622 | * @return string The date of the last donation. |
| 1623 | 1623 | */ |
| 1624 | - public function get_last_donation_date( $formatted = false ) { |
|
| 1624 | + public function get_last_donation_date($formatted = false) { |
|
| 1625 | 1625 | $completed_data = ''; |
| 1626 | 1626 | |
| 1627 | 1627 | // Return if donation id is invalid. |
| 1628 | - if( ! ( $last_donation = absint( $this->get_last_donation() ) ) ) { |
|
| 1628 | + if ( ! ($last_donation = absint($this->get_last_donation()))) { |
|
| 1629 | 1629 | return $completed_data; |
| 1630 | 1630 | } |
| 1631 | 1631 | |
| 1632 | - $completed_data = give_get_payment_completed_date( $last_donation ); |
|
| 1632 | + $completed_data = give_get_payment_completed_date($last_donation); |
|
| 1633 | 1633 | |
| 1634 | - if ( $formatted ) { |
|
| 1635 | - return date_i18n( give_date_format(), strtotime( $completed_data ) ); |
|
| 1634 | + if ($formatted) { |
|
| 1635 | + return date_i18n(give_date_format(), strtotime($completed_data)); |
|
| 1636 | 1636 | } |
| 1637 | 1637 | |
| 1638 | 1638 | return $completed_data; |
@@ -1648,10 +1648,10 @@ discard block |
||
| 1648 | 1648 | */ |
| 1649 | 1649 | public function get_donor_initals() { |
| 1650 | 1650 | |
| 1651 | - $first_name_initial = mb_substr( $this->get_first_name(), 0, 1, 'utf-8' ); |
|
| 1652 | - $last_name_initial = mb_substr( $this->get_last_name(), 0, 1, 'utf-8' ); |
|
| 1651 | + $first_name_initial = mb_substr($this->get_first_name(), 0, 1, 'utf-8'); |
|
| 1652 | + $last_name_initial = mb_substr($this->get_last_name(), 0, 1, 'utf-8'); |
|
| 1653 | 1653 | |
| 1654 | - return apply_filters( 'get_donor_initals', $first_name_initial . $last_name_initial ); |
|
| 1654 | + return apply_filters('get_donor_initals', $first_name_initial.$last_name_initial); |
|
| 1655 | 1655 | |
| 1656 | 1656 | } |
| 1657 | 1657 | |
@@ -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 | ) |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly. |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -28,15 +28,15 @@ discard block |
||
| 28 | 28 | * @global $wpdb |
| 29 | 29 | * @return void |
| 30 | 30 | */ |
| 31 | -function give_install( $network_wide = false ) { |
|
| 31 | +function give_install($network_wide = false) { |
|
| 32 | 32 | |
| 33 | 33 | global $wpdb; |
| 34 | 34 | |
| 35 | - if ( is_multisite() && $network_wide ) { |
|
| 35 | + if (is_multisite() && $network_wide) { |
|
| 36 | 36 | |
| 37 | - foreach ( $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs LIMIT 100" ) as $blog_id ) { |
|
| 37 | + foreach ($wpdb->get_col("SELECT blog_id FROM $wpdb->blogs LIMIT 100") as $blog_id) { |
|
| 38 | 38 | |
| 39 | - switch_to_blog( $blog_id ); |
|
| 39 | + switch_to_blog($blog_id); |
|
| 40 | 40 | give_run_install(); |
| 41 | 41 | restore_current_blog(); |
| 42 | 42 | |
@@ -63,31 +63,31 @@ discard block |
||
| 63 | 63 | give_setup_post_types(); |
| 64 | 64 | |
| 65 | 65 | // Add Upgraded From Option. |
| 66 | - $current_version = get_option( 'give_version' ); |
|
| 67 | - if ( $current_version ) { |
|
| 68 | - update_option( 'give_version_upgraded_from', $current_version, false ); |
|
| 66 | + $current_version = get_option('give_version'); |
|
| 67 | + if ($current_version) { |
|
| 68 | + update_option('give_version_upgraded_from', $current_version, false); |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | // Setup some default options. |
| 72 | 72 | $options = array(); |
| 73 | 73 | |
| 74 | 74 | //Fresh Install? Setup Test Mode, Base Country (US), Test Gateway, Currency. |
| 75 | - if ( empty( $current_version ) ) { |
|
| 76 | - $options = array_merge( $options, give_get_default_settings() ); |
|
| 75 | + if (empty($current_version)) { |
|
| 76 | + $options = array_merge($options, give_get_default_settings()); |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | // Populate the default values. |
| 80 | - update_option( 'give_settings', array_merge( $give_options, $options ), false ); |
|
| 80 | + update_option('give_settings', array_merge($give_options, $options), false); |
|
| 81 | 81 | |
| 82 | 82 | /** |
| 83 | 83 | * Run plugin upgrades. |
| 84 | 84 | * |
| 85 | 85 | * @since 1.8 |
| 86 | 86 | */ |
| 87 | - do_action( 'give_upgrades' ); |
|
| 87 | + do_action('give_upgrades'); |
|
| 88 | 88 | |
| 89 | - if ( GIVE_VERSION !== get_option( 'give_version' ) ) { |
|
| 90 | - update_option( 'give_version', GIVE_VERSION, false ); |
|
| 89 | + if (GIVE_VERSION !== get_option('give_version')) { |
|
| 90 | + update_option('give_version', GIVE_VERSION, false); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | // Create Give roles. |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | // Set api version, end point and refresh permalink. |
| 99 | 99 | $api = new Give_API(); |
| 100 | 100 | $api->add_endpoint(); |
| 101 | - update_option( 'give_default_api_version', 'v' . $api->get_version(), false ); |
|
| 101 | + update_option('give_default_api_version', 'v'.$api->get_version(), false); |
|
| 102 | 102 | |
| 103 | 103 | flush_rewrite_rules(); |
| 104 | 104 | |
@@ -109,11 +109,11 @@ discard block |
||
| 109 | 109 | $donor_meta->create_table(); |
| 110 | 110 | |
| 111 | 111 | // Add a temporary option to note that Give pages have been created. |
| 112 | - Give_Cache::set( '_give_installed', $options, 30, true ); |
|
| 112 | + Give_Cache::set('_give_installed', $options, 30, true); |
|
| 113 | 113 | |
| 114 | - if ( ! $current_version ) { |
|
| 114 | + if ( ! $current_version) { |
|
| 115 | 115 | |
| 116 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php'; |
|
| 116 | + require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrade-functions.php'; |
|
| 117 | 117 | |
| 118 | 118 | // When new upgrade routines are added, mark them as complete on fresh install. |
| 119 | 119 | $upgrade_routines = array( |
@@ -150,18 +150,18 @@ discard block |
||
| 150 | 150 | 'v224_update_donor_meta_forms_id' |
| 151 | 151 | ); |
| 152 | 152 | |
| 153 | - foreach ( $upgrade_routines as $upgrade ) { |
|
| 154 | - give_set_upgrade_complete( $upgrade ); |
|
| 153 | + foreach ($upgrade_routines as $upgrade) { |
|
| 154 | + give_set_upgrade_complete($upgrade); |
|
| 155 | 155 | } |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | // Bail if activating from network, or bulk. |
| 159 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
| 159 | + if (is_network_admin() || isset($_GET['activate-multi'])) { |
|
| 160 | 160 | return; |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | // Add the transient to redirect. |
| 164 | - Give_Cache::set( '_give_activation_redirect', true, 30, true ); |
|
| 164 | + Give_Cache::set('_give_activation_redirect', true, 30, true); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | /** |
@@ -179,11 +179,11 @@ discard block |
||
| 179 | 179 | * @param int $site_id The Site ID. |
| 180 | 180 | * @param array $meta Blog Meta. |
| 181 | 181 | */ |
| 182 | -function give_on_create_blog( $blog_id, $user_id, $domain, $path, $site_id, $meta ) { |
|
| 182 | +function give_on_create_blog($blog_id, $user_id, $domain, $path, $site_id, $meta) { |
|
| 183 | 183 | |
| 184 | - if ( is_plugin_active_for_network( GIVE_PLUGIN_BASENAME ) ) { |
|
| 184 | + if (is_plugin_active_for_network(GIVE_PLUGIN_BASENAME)) { |
|
| 185 | 185 | |
| 186 | - switch_to_blog( $blog_id ); |
|
| 186 | + switch_to_blog($blog_id); |
|
| 187 | 187 | give_install(); |
| 188 | 188 | restore_current_blog(); |
| 189 | 189 | |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | -add_action( 'wpmu_new_blog', 'give_on_create_blog', 10, 6 ); |
|
| 194 | +add_action('wpmu_new_blog', 'give_on_create_blog', 10, 6); |
|
| 195 | 195 | |
| 196 | 196 | |
| 197 | 197 | /** |
@@ -204,13 +204,13 @@ discard block |
||
| 204 | 204 | * |
| 205 | 205 | * @return array The tables to drop. |
| 206 | 206 | */ |
| 207 | -function give_wpmu_drop_tables( $tables, $blog_id ) { |
|
| 207 | +function give_wpmu_drop_tables($tables, $blog_id) { |
|
| 208 | 208 | |
| 209 | - switch_to_blog( $blog_id ); |
|
| 209 | + switch_to_blog($blog_id); |
|
| 210 | 210 | $donors_db = new Give_DB_Donors(); |
| 211 | 211 | $donor_meta_db = new Give_DB_Donor_Meta(); |
| 212 | 212 | |
| 213 | - if ( $donors_db->installed() ) { |
|
| 213 | + if ($donors_db->installed()) { |
|
| 214 | 214 | $tables[] = $donors_db->table_name; |
| 215 | 215 | $tables[] = $donor_meta_db->table_name; |
| 216 | 216 | } |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | -add_filter( 'wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2 ); |
|
| 223 | +add_filter('wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2); |
|
| 224 | 224 | |
| 225 | 225 | /** |
| 226 | 226 | * Post-installation |
@@ -232,16 +232,16 @@ discard block |
||
| 232 | 232 | */ |
| 233 | 233 | function give_after_install() { |
| 234 | 234 | |
| 235 | - if ( ! is_admin() ) { |
|
| 235 | + if ( ! is_admin()) { |
|
| 236 | 236 | return; |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | - $give_options = Give_Cache::get( '_give_installed', true ); |
|
| 240 | - $give_table_check = get_option( '_give_table_check', false ); |
|
| 239 | + $give_options = Give_Cache::get('_give_installed', true); |
|
| 240 | + $give_table_check = get_option('_give_table_check', false); |
|
| 241 | 241 | |
| 242 | - if ( false === $give_table_check || current_time( 'timestamp' ) > $give_table_check ) { |
|
| 242 | + if (false === $give_table_check || current_time('timestamp') > $give_table_check) { |
|
| 243 | 243 | |
| 244 | - if ( ! @Give()->donor_meta->installed() ) { |
|
| 244 | + if ( ! @Give()->donor_meta->installed()) { |
|
| 245 | 245 | |
| 246 | 246 | // Create the donor meta database. |
| 247 | 247 | // (this ensures it creates it on multisite instances where it is network activated). |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | |
| 250 | 250 | } |
| 251 | 251 | |
| 252 | - if ( ! @Give()->donors->installed() ) { |
|
| 252 | + if ( ! @Give()->donors->installed()) { |
|
| 253 | 253 | // Create the donor database. |
| 254 | 254 | // (this ensures it creates it on multisite instances where it is network activated). |
| 255 | 255 | @Give()->donors->create_table(); |
@@ -261,22 +261,22 @@ discard block |
||
| 261 | 261 | * |
| 262 | 262 | * @param array $give_options Give plugin options. |
| 263 | 263 | */ |
| 264 | - do_action( 'give_after_install', $give_options ); |
|
| 264 | + do_action('give_after_install', $give_options); |
|
| 265 | 265 | } |
| 266 | 266 | |
| 267 | - update_option( '_give_table_check', ( current_time( 'timestamp' ) + WEEK_IN_SECONDS ), false ); |
|
| 267 | + update_option('_give_table_check', (current_time('timestamp') + WEEK_IN_SECONDS), false); |
|
| 268 | 268 | |
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | // Delete the transient |
| 272 | - if ( false !== $give_options ) { |
|
| 273 | - Give_Cache::delete( Give_Cache::get_key( '_give_installed' ) ); |
|
| 272 | + if (false !== $give_options) { |
|
| 273 | + Give_Cache::delete(Give_Cache::get_key('_give_installed')); |
|
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | |
| 277 | 277 | } |
| 278 | 278 | |
| 279 | -add_action( 'admin_init', 'give_after_install' ); |
|
| 279 | +add_action('admin_init', 'give_after_install'); |
|
| 280 | 280 | |
| 281 | 281 | |
| 282 | 282 | /** |
@@ -291,11 +291,11 @@ discard block |
||
| 291 | 291 | |
| 292 | 292 | global $wp_roles; |
| 293 | 293 | |
| 294 | - if ( ! is_object( $wp_roles ) ) { |
|
| 294 | + if ( ! is_object($wp_roles)) { |
|
| 295 | 295 | return; |
| 296 | 296 | } |
| 297 | 297 | |
| 298 | - if ( ! array_key_exists( 'give_manager', $wp_roles->roles ) ) { |
|
| 298 | + if ( ! array_key_exists('give_manager', $wp_roles->roles)) { |
|
| 299 | 299 | |
| 300 | 300 | // Create Give plugin roles |
| 301 | 301 | $roles = new Give_Roles(); |
@@ -306,7 +306,7 @@ discard block |
||
| 306 | 306 | |
| 307 | 307 | } |
| 308 | 308 | |
| 309 | -add_action( 'admin_init', 'give_install_roles_on_network' ); |
|
| 309 | +add_action('admin_init', 'give_install_roles_on_network'); |
|
| 310 | 310 | |
| 311 | 311 | /** |
| 312 | 312 | * Default core setting values. |
@@ -348,14 +348,14 @@ discard block |
||
| 348 | 348 | 'uninstall_on_delete' => 'disabled', |
| 349 | 349 | 'the_content_filter' => 'enabled', |
| 350 | 350 | 'scripts_footer' => 'disabled', |
| 351 | - 'agree_to_terms_label' => __( 'Agree to Terms?', 'give' ), |
|
| 351 | + 'agree_to_terms_label' => __('Agree to Terms?', 'give'), |
|
| 352 | 352 | 'agreement_text' => give_get_default_agreement_text(), |
| 353 | 353 | |
| 354 | 354 | // Paypal IPN verification. |
| 355 | 355 | 'paypal_verification' => 'enabled', |
| 356 | 356 | |
| 357 | 357 | // Default is manual gateway. |
| 358 | - 'gateways' => array( 'manual' => 1, 'offline' => 1 ), |
|
| 358 | + 'gateways' => array('manual' => 1, 'offline' => 1), |
|
| 359 | 359 | 'default_gateway' => 'manual', |
| 360 | 360 | |
| 361 | 361 | // Offline gateway setup. |
@@ -383,7 +383,7 @@ discard block |
||
| 383 | 383 | */ |
| 384 | 384 | function give_get_default_agreement_text() { |
| 385 | 385 | |
| 386 | - $org_name = get_bloginfo( 'name' ); |
|
| 386 | + $org_name = get_bloginfo('name'); |
|
| 387 | 387 | |
| 388 | 388 | $agreement = sprintf( |
| 389 | 389 | '<p>Acceptance of any contribution, gift or grant is at the discretion of the %1$s. The %1$s will not accept any gift unless it can be used or expended consistently with the purpose and mission of the %1$s.</p> |
@@ -397,7 +397,7 @@ discard block |
||
| 397 | 397 | $org_name |
| 398 | 398 | ); |
| 399 | 399 | |
| 400 | - return apply_filters( 'give_get_default_agreement_text', $agreement, $org_name ); |
|
| 400 | + return apply_filters('give_get_default_agreement_text', $agreement, $org_name); |
|
| 401 | 401 | } |
| 402 | 402 | |
| 403 | 403 | |
@@ -411,19 +411,19 @@ discard block |
||
| 411 | 411 | function give_create_pages() { |
| 412 | 412 | |
| 413 | 413 | // Bailout if pages already created. |
| 414 | - if ( get_option( 'give_install_pages_created' ) ) { |
|
| 414 | + if (get_option('give_install_pages_created')) { |
|
| 415 | 415 | return false; |
| 416 | 416 | } |
| 417 | 417 | |
| 418 | 418 | $options = array(); |
| 419 | 419 | |
| 420 | 420 | // Checks if the Success Page option exists AND that the page exists. |
| 421 | - if ( ! get_post( give_get_option( 'success_page' ) ) ) { |
|
| 421 | + if ( ! get_post(give_get_option('success_page'))) { |
|
| 422 | 422 | |
| 423 | 423 | // Donation Confirmation (Success) Page |
| 424 | 424 | $success = wp_insert_post( |
| 425 | 425 | array( |
| 426 | - 'post_title' => esc_html__( 'Donation Confirmation', 'give' ), |
|
| 426 | + 'post_title' => esc_html__('Donation Confirmation', 'give'), |
|
| 427 | 427 | 'post_content' => '[give_receipt]', |
| 428 | 428 | 'post_status' => 'publish', |
| 429 | 429 | 'post_author' => 1, |
@@ -437,13 +437,13 @@ discard block |
||
| 437 | 437 | } |
| 438 | 438 | |
| 439 | 439 | // Checks if the Failure Page option exists AND that the page exists. |
| 440 | - if ( ! get_post( give_get_option( 'failure_page' ) ) ) { |
|
| 440 | + if ( ! get_post(give_get_option('failure_page'))) { |
|
| 441 | 441 | |
| 442 | 442 | // Failed Donation Page |
| 443 | 443 | $failed = wp_insert_post( |
| 444 | 444 | array( |
| 445 | - 'post_title' => esc_html__( 'Donation Failed', 'give' ), |
|
| 446 | - 'post_content' => esc_html__( 'We\'re sorry, your donation failed to process. Please try again or contact site support.', 'give' ), |
|
| 445 | + 'post_title' => esc_html__('Donation Failed', 'give'), |
|
| 446 | + 'post_content' => esc_html__('We\'re sorry, your donation failed to process. Please try again or contact site support.', 'give'), |
|
| 447 | 447 | 'post_status' => 'publish', |
| 448 | 448 | 'post_author' => 1, |
| 449 | 449 | 'post_type' => 'page', |
@@ -455,11 +455,11 @@ discard block |
||
| 455 | 455 | } |
| 456 | 456 | |
| 457 | 457 | // Checks if the History Page option exists AND that the page exists. |
| 458 | - if ( ! get_post( give_get_option( 'history_page' ) ) ) { |
|
| 458 | + if ( ! get_post(give_get_option('history_page'))) { |
|
| 459 | 459 | // Donation History Page |
| 460 | 460 | $history = wp_insert_post( |
| 461 | 461 | array( |
| 462 | - 'post_title' => esc_html__( 'Donation History', 'give' ), |
|
| 462 | + 'post_title' => esc_html__('Donation History', 'give'), |
|
| 463 | 463 | 'post_content' => '[donation_history]', |
| 464 | 464 | 'post_status' => 'publish', |
| 465 | 465 | 'post_author' => 1, |
@@ -471,11 +471,11 @@ discard block |
||
| 471 | 471 | $options['history_page'] = $history; |
| 472 | 472 | } |
| 473 | 473 | |
| 474 | - if ( ! empty( $options ) ) { |
|
| 475 | - update_option( 'give_settings', array_merge( give_get_settings(), $options ), false ); |
|
| 474 | + if ( ! empty($options)) { |
|
| 475 | + update_option('give_settings', array_merge(give_get_settings(), $options), false); |
|
| 476 | 476 | } |
| 477 | 477 | |
| 478 | - add_option( 'give_install_pages_created', 1, '', false ); |
|
| 478 | + add_option('give_install_pages_created', 1, '', false); |
|
| 479 | 479 | } |
| 480 | 480 | |
| 481 | -add_action( 'admin_init', 'give_create_pages', - 1 ); |
|
| 481 | +add_action('admin_init', 'give_create_pages', - 1); |
|
@@ -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'); |
|