@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | * |
| 122 | 122 | * @param string $cache_key |
| 123 | 123 | * @param bool $custom_key |
| 124 | - * @param mixed $query_args |
|
| 124 | + * @param string $query_args |
|
| 125 | 125 | * |
| 126 | 126 | * @return mixed |
| 127 | 127 | */ |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | * |
| 238 | 238 | * @param bool $force If set to true then all cached values will be delete instead of only expired |
| 239 | 239 | * |
| 240 | - * @return bool |
|
| 240 | + * @return false|null |
|
| 241 | 241 | */ |
| 242 | 242 | public static function delete_all_expired( $force = false ) { |
| 243 | 243 | global $wpdb; |
@@ -669,7 +669,7 @@ discard block |
||
| 669 | 669 | * @since 2.0 |
| 670 | 670 | * @access private |
| 671 | 671 | * |
| 672 | - * @param $group |
|
| 672 | + * @param string $group |
|
| 673 | 673 | * |
| 674 | 674 | * @return mixed |
| 675 | 675 | */ |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | 13 | // Exit if accessed directly. |
| 14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 14 | +if ( ! defined('ABSPATH')) { |
|
| 15 | 15 | exit; |
| 16 | 16 | } |
| 17 | 17 | |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | * @return static |
| 54 | 54 | */ |
| 55 | 55 | public static function get_instance() { |
| 56 | - if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Give_Cache ) ) { |
|
| 56 | + if ( ! isset(self::$instance) && ! (self::$instance instanceof Give_Cache)) { |
|
| 57 | 57 | self::$instance = new Give_Cache(); |
| 58 | 58 | } |
| 59 | 59 | |
@@ -68,17 +68,17 @@ discard block |
||
| 68 | 68 | */ |
| 69 | 69 | public function setup() { |
| 70 | 70 | // Currently enable cache only for backend. |
| 71 | - self::$instance->is_cache = give_is_setting_enabled( give_get_option( 'cache', 'enabled' ) ) && is_admin(); |
|
| 71 | + self::$instance->is_cache = give_is_setting_enabled(give_get_option('cache', 'enabled')) && is_admin(); |
|
| 72 | 72 | |
| 73 | 73 | // weekly delete all expired cache. |
| 74 | - Give_Cron::add_weekly_event( array( $this, 'delete_all_expired' ) ); |
|
| 74 | + Give_Cron::add_weekly_event(array($this, 'delete_all_expired')); |
|
| 75 | 75 | |
| 76 | - add_action( 'save_post_give_forms', array( $this, 'delete_form_related_cache' ) ); |
|
| 77 | - add_action( 'save_post_give_payment', array( $this, 'delete_payment_related_cache' ) ); |
|
| 78 | - add_action( 'give_deleted_give-donors_cache', array( $this, 'delete_donor_related_cache' ), 10, 3 ); |
|
| 79 | - add_action( 'give_deleted_give-donations_cache', array( $this, 'delete_donations_related_cache' ), 10, 3 ); |
|
| 76 | + add_action('save_post_give_forms', array($this, 'delete_form_related_cache')); |
|
| 77 | + add_action('save_post_give_payment', array($this, 'delete_payment_related_cache')); |
|
| 78 | + add_action('give_deleted_give-donors_cache', array($this, 'delete_donor_related_cache'), 10, 3); |
|
| 79 | + add_action('give_deleted_give-donations_cache', array($this, 'delete_donations_related_cache'), 10, 3); |
|
| 80 | 80 | |
| 81 | - add_action( 'give_save_settings_give_settings', array( $this, 'flush_cache' ) ); |
|
| 81 | + add_action('give_save_settings_give_settings', array($this, 'flush_cache')); |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | /** |
@@ -92,18 +92,18 @@ discard block |
||
| 92 | 92 | * |
| 93 | 93 | * @return string |
| 94 | 94 | */ |
| 95 | - public static function get_key( $action, $query_args = null, $is_prefix = true ) { |
|
| 95 | + public static function get_key($action, $query_args = null, $is_prefix = true) { |
|
| 96 | 96 | // Bailout. |
| 97 | - if ( empty( $action ) ) { |
|
| 98 | - return new WP_Error( 'give_invalid_cache_key_action', __( 'Do not pass empty action to generate cache key.', 'give' ) ); |
|
| 97 | + if (empty($action)) { |
|
| 98 | + return new WP_Error('give_invalid_cache_key_action', __('Do not pass empty action to generate cache key.', 'give')); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | // Set cache key. |
| 102 | 102 | $cache_key = $is_prefix ? "give_cache_{$action}" : $action; |
| 103 | 103 | |
| 104 | 104 | // Bailout. |
| 105 | - if ( ! empty( $query_args ) ) { |
|
| 106 | - $cache_key = "{$cache_key}_" . substr( md5( serialize( $query_args ) ), 0, 15 ); |
|
| 105 | + if ( ! empty($query_args)) { |
|
| 106 | + $cache_key = "{$cache_key}_".substr(md5(serialize($query_args)), 0, 15); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | /** |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | * |
| 112 | 112 | * @since 2.0 |
| 113 | 113 | */ |
| 114 | - return apply_filters( 'give_get_cache_key', $cache_key, $action, $query_args ); |
|
| 114 | + return apply_filters('give_get_cache_key', $cache_key, $action, $query_args); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | /** |
@@ -125,26 +125,26 @@ discard block |
||
| 125 | 125 | * |
| 126 | 126 | * @return mixed |
| 127 | 127 | */ |
| 128 | - public static function get( $cache_key, $custom_key = false, $query_args = array() ) { |
|
| 129 | - if ( ! self::is_valid_cache_key( $cache_key ) ) { |
|
| 130 | - if ( ! $custom_key ) { |
|
| 131 | - return new WP_Error( 'give_invalid_cache_key', __( 'Cache key format should be give_cache_*', 'give' ) ); |
|
| 128 | + public static function get($cache_key, $custom_key = false, $query_args = array()) { |
|
| 129 | + if ( ! self::is_valid_cache_key($cache_key)) { |
|
| 130 | + if ( ! $custom_key) { |
|
| 131 | + return new WP_Error('give_invalid_cache_key', __('Cache key format should be give_cache_*', 'give')); |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | - $cache_key = self::get_key( $cache_key, $query_args ); |
|
| 134 | + $cache_key = self::get_key($cache_key, $query_args); |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - $option = get_option( $cache_key ); |
|
| 137 | + $option = get_option($cache_key); |
|
| 138 | 138 | |
| 139 | 139 | // Backward compatibility (<1.8.7). |
| 140 | - if ( ! is_array( $option ) || empty( $option ) || ! array_key_exists( 'expiration', $option ) ) { |
|
| 140 | + if ( ! is_array($option) || empty($option) || ! array_key_exists('expiration', $option)) { |
|
| 141 | 141 | return $option; |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | // Get current time. |
| 145 | - $current_time = current_time( 'timestamp', 1 ); |
|
| 145 | + $current_time = current_time('timestamp', 1); |
|
| 146 | 146 | |
| 147 | - if ( empty( $option['expiration'] ) || ( $current_time < $option['expiration'] ) ) { |
|
| 147 | + if (empty($option['expiration']) || ($current_time < $option['expiration'])) { |
|
| 148 | 148 | $option = $option['data']; |
| 149 | 149 | } else { |
| 150 | 150 | $option = false; |
@@ -166,23 +166,23 @@ discard block |
||
| 166 | 166 | * |
| 167 | 167 | * @return mixed |
| 168 | 168 | */ |
| 169 | - public static function set( $cache_key, $data, $expiration = null, $custom_key = false, $query_args = array() ) { |
|
| 170 | - if ( ! self::is_valid_cache_key( $cache_key ) ) { |
|
| 171 | - if ( ! $custom_key ) { |
|
| 172 | - return new WP_Error( 'give_invalid_cache_key', __( 'Cache key format should be give_cache_*', 'give' ) ); |
|
| 169 | + public static function set($cache_key, $data, $expiration = null, $custom_key = false, $query_args = array()) { |
|
| 170 | + if ( ! self::is_valid_cache_key($cache_key)) { |
|
| 171 | + if ( ! $custom_key) { |
|
| 172 | + return new WP_Error('give_invalid_cache_key', __('Cache key format should be give_cache_*', 'give')); |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | - $cache_key = self::get_key( $cache_key, $query_args ); |
|
| 175 | + $cache_key = self::get_key($cache_key, $query_args); |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | $option_value = array( |
| 179 | 179 | 'data' => $data, |
| 180 | - 'expiration' => ! is_null( $expiration ) |
|
| 181 | - ? ( $expiration + current_time( 'timestamp', 1 ) ) |
|
| 180 | + 'expiration' => ! is_null($expiration) |
|
| 181 | + ? ($expiration + current_time('timestamp', 1)) |
|
| 182 | 182 | : null, |
| 183 | 183 | ); |
| 184 | 184 | |
| 185 | - $result = update_option( $cache_key, $option_value, 'no' ); |
|
| 185 | + $result = update_option($cache_key, $option_value, 'no'); |
|
| 186 | 186 | |
| 187 | 187 | return $result; |
| 188 | 188 | } |
@@ -198,27 +198,27 @@ discard block |
||
| 198 | 198 | * |
| 199 | 199 | * @return bool|WP_Error |
| 200 | 200 | */ |
| 201 | - public static function delete( $cache_keys ) { |
|
| 201 | + public static function delete($cache_keys) { |
|
| 202 | 202 | $result = true; |
| 203 | 203 | $invalid_keys = array(); |
| 204 | 204 | |
| 205 | - if ( ! empty( $cache_keys ) ) { |
|
| 206 | - $cache_keys = is_array( $cache_keys ) ? $cache_keys : array( $cache_keys ); |
|
| 205 | + if ( ! empty($cache_keys)) { |
|
| 206 | + $cache_keys = is_array($cache_keys) ? $cache_keys : array($cache_keys); |
|
| 207 | 207 | |
| 208 | - foreach ( $cache_keys as $cache_key ) { |
|
| 209 | - if ( ! self::is_valid_cache_key( $cache_key ) ) { |
|
| 208 | + foreach ($cache_keys as $cache_key) { |
|
| 209 | + if ( ! self::is_valid_cache_key($cache_key)) { |
|
| 210 | 210 | $invalid_keys[] = $cache_key; |
| 211 | 211 | $result = false; |
| 212 | 212 | } |
| 213 | 213 | |
| 214 | - delete_option( $cache_key ); |
|
| 214 | + delete_option($cache_key); |
|
| 215 | 215 | } |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | - if ( ! $result ) { |
|
| 218 | + if ( ! $result) { |
|
| 219 | 219 | $result = new WP_Error( |
| 220 | 220 | 'give_invalid_cache_key', |
| 221 | - __( 'Cache key format should be give_cache_*', 'give' ), |
|
| 221 | + __('Cache key format should be give_cache_*', 'give'), |
|
| 222 | 222 | $invalid_keys |
| 223 | 223 | ); |
| 224 | 224 | } |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | * |
| 240 | 240 | * @return bool |
| 241 | 241 | */ |
| 242 | - public static function delete_all_expired( $force = false ) { |
|
| 242 | + public static function delete_all_expired($force = false) { |
|
| 243 | 243 | global $wpdb; |
| 244 | 244 | $options = $wpdb->get_results( |
| 245 | 245 | $wpdb->prepare( |
@@ -253,30 +253,30 @@ discard block |
||
| 253 | 253 | ); |
| 254 | 254 | |
| 255 | 255 | // Bailout. |
| 256 | - if ( empty( $options ) ) { |
|
| 256 | + if (empty($options)) { |
|
| 257 | 257 | return false; |
| 258 | 258 | } |
| 259 | 259 | |
| 260 | - $current_time = current_time( 'timestamp', 1 ); |
|
| 260 | + $current_time = current_time('timestamp', 1); |
|
| 261 | 261 | |
| 262 | 262 | // Delete log cache. |
| 263 | - foreach ( $options as $option ) { |
|
| 264 | - $option['option_value'] = maybe_unserialize( $option['option_value'] ); |
|
| 263 | + foreach ($options as $option) { |
|
| 264 | + $option['option_value'] = maybe_unserialize($option['option_value']); |
|
| 265 | 265 | |
| 266 | 266 | if ( |
| 267 | 267 | ( |
| 268 | - ! self::is_valid_cache_key( $option['option_name'] ) |
|
| 269 | - || ! is_array( $option['option_value'] ) // Backward compatibility (<1.8.7). |
|
| 270 | - || ! array_key_exists( 'expiration', $option['option_value'] ) // Backward compatibility (<1.8.7). |
|
| 271 | - || empty( $option['option_value']['expiration'] ) |
|
| 272 | - || ( $current_time < $option['option_value']['expiration'] ) |
|
| 268 | + ! self::is_valid_cache_key($option['option_name']) |
|
| 269 | + || ! is_array($option['option_value']) // Backward compatibility (<1.8.7). |
|
| 270 | + || ! array_key_exists('expiration', $option['option_value']) // Backward compatibility (<1.8.7). |
|
| 271 | + || empty($option['option_value']['expiration']) |
|
| 272 | + || ($current_time < $option['option_value']['expiration']) |
|
| 273 | 273 | ) |
| 274 | 274 | && ! $force |
| 275 | 275 | ) { |
| 276 | 276 | continue; |
| 277 | 277 | } |
| 278 | 278 | |
| 279 | - self::delete( $option['option_name'] ); |
|
| 279 | + self::delete($option['option_name']); |
|
| 280 | 280 | } |
| 281 | 281 | } |
| 282 | 282 | |
@@ -294,16 +294,16 @@ discard block |
||
| 294 | 294 | * |
| 295 | 295 | * @return array |
| 296 | 296 | */ |
| 297 | - public static function get_options_like( $option_name, $fields = false ) { |
|
| 297 | + public static function get_options_like($option_name, $fields = false) { |
|
| 298 | 298 | global $wpdb; |
| 299 | 299 | |
| 300 | - if ( empty( $option_name ) ) { |
|
| 300 | + if (empty($option_name)) { |
|
| 301 | 301 | return array(); |
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | $field_names = $fields ? 'option_name, option_value' : 'option_name'; |
| 305 | 305 | |
| 306 | - if ( $fields ) { |
|
| 306 | + if ($fields) { |
|
| 307 | 307 | $options = $wpdb->get_results( |
| 308 | 308 | $wpdb->prepare( |
| 309 | 309 | "SELECT {$field_names } |
@@ -327,10 +327,10 @@ discard block |
||
| 327 | 327 | ); |
| 328 | 328 | } |
| 329 | 329 | |
| 330 | - if ( ! empty( $options ) && $fields ) { |
|
| 331 | - foreach ( $options as $index => $option ) { |
|
| 332 | - $option['option_value'] = maybe_unserialize( $option['option_value'] ); |
|
| 333 | - $options[ $index ] = $option; |
|
| 330 | + if ( ! empty($options) && $fields) { |
|
| 331 | + foreach ($options as $index => $option) { |
|
| 332 | + $option['option_value'] = maybe_unserialize($option['option_value']); |
|
| 333 | + $options[$index] = $option; |
|
| 334 | 334 | } |
| 335 | 335 | } |
| 336 | 336 | |
@@ -347,8 +347,8 @@ discard block |
||
| 347 | 347 | * |
| 348 | 348 | * @return bool |
| 349 | 349 | */ |
| 350 | - public static function is_valid_cache_key( $cache_key ) { |
|
| 351 | - $is_valid = ( false !== strpos( $cache_key, 'give_cache_' ) ); |
|
| 350 | + public static function is_valid_cache_key($cache_key) { |
|
| 351 | + $is_valid = (false !== strpos($cache_key, 'give_cache_')); |
|
| 352 | 352 | |
| 353 | 353 | |
| 354 | 354 | /** |
@@ -356,7 +356,7 @@ discard block |
||
| 356 | 356 | * |
| 357 | 357 | * @since 2.0 |
| 358 | 358 | */ |
| 359 | - return apply_filters( 'give_is_valid_cache_key', $is_valid, $cache_key ); |
|
| 359 | + return apply_filters('give_is_valid_cache_key', $is_valid, $cache_key); |
|
| 360 | 360 | } |
| 361 | 361 | |
| 362 | 362 | |
@@ -371,14 +371,14 @@ discard block |
||
| 371 | 371 | * |
| 372 | 372 | * @return mixed |
| 373 | 373 | */ |
| 374 | - public static function get_group( $id, $group = '' ) { |
|
| 374 | + public static function get_group($id, $group = '') { |
|
| 375 | 375 | $cached_data = null; |
| 376 | 376 | |
| 377 | 377 | // Bailout. |
| 378 | - if ( self::$instance->is_cache && ! empty( $id ) ) { |
|
| 379 | - $group = self::$instance->filter_group_name( $group ); |
|
| 378 | + if (self::$instance->is_cache && ! empty($id)) { |
|
| 379 | + $group = self::$instance->filter_group_name($group); |
|
| 380 | 380 | |
| 381 | - $cached_data = wp_cache_get( $id, $group ); |
|
| 381 | + $cached_data = wp_cache_get($id, $group); |
|
| 382 | 382 | $cached_data = false !== $cached_data ? $cached_data : null; |
| 383 | 383 | } |
| 384 | 384 | |
@@ -398,17 +398,17 @@ discard block |
||
| 398 | 398 | * |
| 399 | 399 | * @return bool |
| 400 | 400 | */ |
| 401 | - public static function set_group( $id, $data, $group = '', $expire = 0 ) { |
|
| 401 | + public static function set_group($id, $data, $group = '', $expire = 0) { |
|
| 402 | 402 | $status = false; |
| 403 | 403 | |
| 404 | 404 | // Bailout. |
| 405 | - if ( ! self::$instance->is_cache || empty( $id ) ) { |
|
| 405 | + if ( ! self::$instance->is_cache || empty($id)) { |
|
| 406 | 406 | return $status; |
| 407 | 407 | } |
| 408 | 408 | |
| 409 | - $group = self::$instance->filter_group_name( $group ); |
|
| 409 | + $group = self::$instance->filter_group_name($group); |
|
| 410 | 410 | |
| 411 | - $status = wp_cache_set( $id, $data, $group, $expire ); |
|
| 411 | + $status = wp_cache_set($id, $data, $group, $expire); |
|
| 412 | 412 | |
| 413 | 413 | return $status; |
| 414 | 414 | } |
@@ -424,15 +424,15 @@ discard block |
||
| 424 | 424 | * |
| 425 | 425 | * @return bool |
| 426 | 426 | */ |
| 427 | - public static function set_db_query( $id, $data ) { |
|
| 427 | + public static function set_db_query($id, $data) { |
|
| 428 | 428 | $status = false; |
| 429 | 429 | |
| 430 | 430 | // Bailout. |
| 431 | - if ( ! self::$instance->is_cache || empty( $id ) ) { |
|
| 431 | + if ( ! self::$instance->is_cache || empty($id)) { |
|
| 432 | 432 | return $status; |
| 433 | 433 | } |
| 434 | 434 | |
| 435 | - return self::set_group( $id, $data, 'give-db-queries', 0 ); |
|
| 435 | + return self::set_group($id, $data, 'give-db-queries', 0); |
|
| 436 | 436 | } |
| 437 | 437 | |
| 438 | 438 | /** |
@@ -445,8 +445,8 @@ discard block |
||
| 445 | 445 | * |
| 446 | 446 | * @return mixed |
| 447 | 447 | */ |
| 448 | - public static function get_db_query( $id ) { |
|
| 449 | - return self::get_group( $id, 'give-db-queries' ); |
|
| 448 | + public static function get_db_query($id) { |
|
| 449 | + return self::get_group($id, 'give-db-queries'); |
|
| 450 | 450 | } |
| 451 | 451 | |
| 452 | 452 | /** |
@@ -461,20 +461,20 @@ discard block |
||
| 461 | 461 | * |
| 462 | 462 | * @return bool |
| 463 | 463 | */ |
| 464 | - public static function delete_group( $ids, $group = '', $expire = 0 ) { |
|
| 464 | + public static function delete_group($ids, $group = '', $expire = 0) { |
|
| 465 | 465 | $status = false; |
| 466 | 466 | |
| 467 | 467 | // Bailout. |
| 468 | - if ( ! self::$instance->is_cache || empty( $ids ) ) { |
|
| 468 | + if ( ! self::$instance->is_cache || empty($ids)) { |
|
| 469 | 469 | return $status; |
| 470 | 470 | } |
| 471 | 471 | |
| 472 | - $group = self::$instance->filter_group_name( $group ); |
|
| 472 | + $group = self::$instance->filter_group_name($group); |
|
| 473 | 473 | |
| 474 | 474 | // Delete single or multiple cache items from cache. |
| 475 | - if ( ! is_array( $ids ) ) { |
|
| 476 | - $status = wp_cache_delete( $ids, $group, $expire ); |
|
| 477 | - self::$instance->get_incrementer( true ); |
|
| 475 | + if ( ! is_array($ids)) { |
|
| 476 | + $status = wp_cache_delete($ids, $group, $expire); |
|
| 477 | + self::$instance->get_incrementer(true); |
|
| 478 | 478 | |
| 479 | 479 | /** |
| 480 | 480 | * Fire action when cache deleted for specific id. |
@@ -485,12 +485,12 @@ discard block |
||
| 485 | 485 | * @param string $group |
| 486 | 486 | * @param int $expire |
| 487 | 487 | */ |
| 488 | - do_action( "give_deleted_{$group}_cache", $ids, $group, $expire, $status ); |
|
| 488 | + do_action("give_deleted_{$group}_cache", $ids, $group, $expire, $status); |
|
| 489 | 489 | |
| 490 | 490 | } else { |
| 491 | - foreach ( $ids as $id ) { |
|
| 492 | - $status = wp_cache_delete( $id, $group, $expire ); |
|
| 493 | - self::$instance->get_incrementer( true ); |
|
| 491 | + foreach ($ids as $id) { |
|
| 492 | + $status = wp_cache_delete($id, $group, $expire); |
|
| 493 | + self::$instance->get_incrementer(true); |
|
| 494 | 494 | |
| 495 | 495 | /** |
| 496 | 496 | * Fire action when cache deleted for specific id . |
@@ -501,7 +501,7 @@ discard block |
||
| 501 | 501 | * @param string $group |
| 502 | 502 | * @param int $expire |
| 503 | 503 | */ |
| 504 | - do_action( "give_deleted_{$group}_cache", $id, $group, $expire, $status ); |
|
| 504 | + do_action("give_deleted_{$group}_cache", $id, $group, $expire, $status); |
|
| 505 | 505 | } |
| 506 | 506 | } |
| 507 | 507 | |
@@ -518,30 +518,30 @@ discard block |
||
| 518 | 518 | * |
| 519 | 519 | * @param int $form_id |
| 520 | 520 | */ |
| 521 | - public function delete_form_related_cache( $form_id ) { |
|
| 521 | + public function delete_form_related_cache($form_id) { |
|
| 522 | 522 | // If this is just a revision, don't send the email. |
| 523 | - if ( wp_is_post_revision( $form_id ) ) { |
|
| 523 | + if (wp_is_post_revision($form_id)) { |
|
| 524 | 524 | return; |
| 525 | 525 | } |
| 526 | 526 | |
| 527 | 527 | $donation_query = new Give_Payments_Query( |
| 528 | 528 | array( |
| 529 | - 'number' => - 1, |
|
| 529 | + 'number' => -1, |
|
| 530 | 530 | 'give_forms' => $form_id, |
| 531 | 531 | ) |
| 532 | 532 | ); |
| 533 | 533 | |
| 534 | 534 | $donations = $donation_query->get_payments(); |
| 535 | 535 | |
| 536 | - if ( ! empty( $donations ) ) { |
|
| 536 | + if ( ! empty($donations)) { |
|
| 537 | 537 | /* @var Give_Payment $donation */ |
| 538 | - foreach ( $donations as $donation ) { |
|
| 539 | - wp_cache_delete( $donation->ID, 'give-donations' ); |
|
| 540 | - wp_cache_delete( $donation->donor_id, 'give-donors' ); |
|
| 538 | + foreach ($donations as $donation) { |
|
| 539 | + wp_cache_delete($donation->ID, 'give-donations'); |
|
| 540 | + wp_cache_delete($donation->donor_id, 'give-donors'); |
|
| 541 | 541 | } |
| 542 | 542 | } |
| 543 | 543 | |
| 544 | - self::$instance->get_incrementer( true ); |
|
| 544 | + self::$instance->get_incrementer(true); |
|
| 545 | 545 | } |
| 546 | 546 | |
| 547 | 547 | /** |
@@ -553,22 +553,22 @@ discard block |
||
| 553 | 553 | * |
| 554 | 554 | * @param int $donation_id |
| 555 | 555 | */ |
| 556 | - public function delete_payment_related_cache( $donation_id ) { |
|
| 556 | + public function delete_payment_related_cache($donation_id) { |
|
| 557 | 557 | // If this is just a revision, don't send the email. |
| 558 | - if ( wp_is_post_revision( $donation_id ) ) { |
|
| 558 | + if (wp_is_post_revision($donation_id)) { |
|
| 559 | 559 | return; |
| 560 | 560 | } |
| 561 | 561 | |
| 562 | 562 | /* @var Give_Payment $donation */ |
| 563 | - $donation = new Give_Payment( $donation_id ); |
|
| 563 | + $donation = new Give_Payment($donation_id); |
|
| 564 | 564 | |
| 565 | - if ( $donation && $donation->donor_id ) { |
|
| 566 | - wp_cache_delete( $donation->donor_id, 'give-donors' ); |
|
| 565 | + if ($donation && $donation->donor_id) { |
|
| 566 | + wp_cache_delete($donation->donor_id, 'give-donors'); |
|
| 567 | 567 | } |
| 568 | 568 | |
| 569 | - wp_cache_delete( $donation->ID, 'give-donations' ); |
|
| 569 | + wp_cache_delete($donation->ID, 'give-donations'); |
|
| 570 | 570 | |
| 571 | - self::$instance->get_incrementer( true ); |
|
| 571 | + self::$instance->get_incrementer(true); |
|
| 572 | 572 | } |
| 573 | 573 | |
| 574 | 574 | /** |
@@ -582,17 +582,17 @@ discard block |
||
| 582 | 582 | * @param string $group |
| 583 | 583 | * @param int $expire |
| 584 | 584 | */ |
| 585 | - public function delete_donor_related_cache( $id, $group, $expire ) { |
|
| 586 | - $donor = new Give_Donor( $id ); |
|
| 587 | - $donation_ids = array_map( 'trim', (array) explode( ',', trim( $donor->payment_ids ) ) ); |
|
| 585 | + public function delete_donor_related_cache($id, $group, $expire) { |
|
| 586 | + $donor = new Give_Donor($id); |
|
| 587 | + $donation_ids = array_map('trim', (array) explode(',', trim($donor->payment_ids))); |
|
| 588 | 588 | |
| 589 | - if ( ! empty( $donation_ids ) ) { |
|
| 590 | - foreach ( $donation_ids as $donation ) { |
|
| 591 | - wp_cache_delete( $donation, 'give-donations' ); |
|
| 589 | + if ( ! empty($donation_ids)) { |
|
| 590 | + foreach ($donation_ids as $donation) { |
|
| 591 | + wp_cache_delete($donation, 'give-donations'); |
|
| 592 | 592 | } |
| 593 | 593 | } |
| 594 | 594 | |
| 595 | - self::$instance->get_incrementer( true ); |
|
| 595 | + self::$instance->get_incrementer(true); |
|
| 596 | 596 | } |
| 597 | 597 | |
| 598 | 598 | /** |
@@ -606,15 +606,15 @@ discard block |
||
| 606 | 606 | * @param string $group |
| 607 | 607 | * @param int $expire |
| 608 | 608 | */ |
| 609 | - public function delete_donations_related_cache( $id, $group, $expire ) { |
|
| 609 | + public function delete_donations_related_cache($id, $group, $expire) { |
|
| 610 | 610 | /* @var Give_Payment $donation */ |
| 611 | - $donation = new Give_Payment( $id ); |
|
| 611 | + $donation = new Give_Payment($id); |
|
| 612 | 612 | |
| 613 | - if ( $donation && $donation->donor_id ) { |
|
| 614 | - wp_cache_delete( $donation->donor_id, 'give-donors' ); |
|
| 613 | + if ($donation && $donation->donor_id) { |
|
| 614 | + wp_cache_delete($donation->donor_id, 'give-donors'); |
|
| 615 | 615 | } |
| 616 | 616 | |
| 617 | - self::$instance->get_incrementer( true ); |
|
| 617 | + self::$instance->get_incrementer(true); |
|
| 618 | 618 | } |
| 619 | 619 | |
| 620 | 620 | |
@@ -632,12 +632,12 @@ discard block |
||
| 632 | 632 | * |
| 633 | 633 | * @return string |
| 634 | 634 | */ |
| 635 | - private function get_incrementer( $refresh = false, $incrementer_key = 'give-cahce-incrementer-db-queries' ) { |
|
| 636 | - $incrementer_value = wp_cache_get( $incrementer_key ); |
|
| 635 | + private function get_incrementer($refresh = false, $incrementer_key = 'give-cahce-incrementer-db-queries') { |
|
| 636 | + $incrementer_value = wp_cache_get($incrementer_key); |
|
| 637 | 637 | |
| 638 | - if ( false === $incrementer_value || true === $refresh ) { |
|
| 639 | - $incrementer_value = microtime( true ); |
|
| 640 | - wp_cache_set( $incrementer_key, $incrementer_value ); |
|
| 638 | + if (false === $incrementer_value || true === $refresh) { |
|
| 639 | + $incrementer_value = microtime(true); |
|
| 640 | + wp_cache_set($incrementer_key, $incrementer_value); |
|
| 641 | 641 | } |
| 642 | 642 | |
| 643 | 643 | return $incrementer_value; |
@@ -654,11 +654,11 @@ discard block |
||
| 654 | 654 | public function flush_cache() { |
| 655 | 655 | if ( |
| 656 | 656 | Give_Admin_Settings::is_saving_settings() && |
| 657 | - isset( $_POST['cache'] ) && |
|
| 658 | - give_is_setting_enabled( give_clean( $_POST['cache'] ) ) |
|
| 657 | + isset($_POST['cache']) && |
|
| 658 | + give_is_setting_enabled(give_clean($_POST['cache'])) |
|
| 659 | 659 | ) { |
| 660 | - $this->get_incrementer( true ); |
|
| 661 | - $this->get_incrementer( true, 'give-cahce-incrementer' ); |
|
| 660 | + $this->get_incrementer(true); |
|
| 661 | + $this->get_incrementer(true, 'give-cahce-incrementer'); |
|
| 662 | 662 | } |
| 663 | 663 | } |
| 664 | 664 | |
@@ -673,11 +673,11 @@ discard block |
||
| 673 | 673 | * |
| 674 | 674 | * @return mixed |
| 675 | 675 | */ |
| 676 | - private function filter_group_name( $group ) { |
|
| 677 | - if ( ! empty( $group ) ) { |
|
| 678 | - $incrementer = self::$instance->get_incrementer( false, 'give-cahce-incrementer' ); |
|
| 676 | + private function filter_group_name($group) { |
|
| 677 | + if ( ! empty($group)) { |
|
| 678 | + $incrementer = self::$instance->get_incrementer(false, 'give-cahce-incrementer'); |
|
| 679 | 679 | |
| 680 | - if ( 'give-db-queries' === $group ) { |
|
| 680 | + if ('give-db-queries' === $group) { |
|
| 681 | 681 | $incrementer = self::$instance->get_incrementer(); |
| 682 | 682 | } |
| 683 | 683 | |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | * NOTE: This should not be called directly as it does not make necessary changes to |
| 208 | 208 | * the payment meta and logs. Use give_donor_delete() instead. |
| 209 | 209 | * |
| 210 | - * @param bool|string|int $_id_or_email ID or Email of Donor. |
|
| 210 | + * @param integer $_id_or_email ID or Email of Donor. |
|
| 211 | 211 | * |
| 212 | 212 | * @since 1.0 |
| 213 | 213 | * @access public |
@@ -407,7 +407,7 @@ discard block |
||
| 407 | 407 | * @access public |
| 408 | 408 | * |
| 409 | 409 | * @param string $field ID or email. Default is 'id'. |
| 410 | - * @param mixed $value The Customer ID or email to search. Default is 0. |
|
| 410 | + * @param integer $value The Customer ID or email to search. Default is 0. |
|
| 411 | 411 | * |
| 412 | 412 | * @return mixed Upon success, an object of the donor. Upon failure, NULL |
| 413 | 413 | */ |
@@ -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 | |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | $this->bc_200_params(); |
| 43 | 43 | |
| 44 | 44 | // Set hooks and register table only if instance loading first time. |
| 45 | - if ( ! ( Give()->donors instanceof Give_DB_Donors ) ) { |
|
| 45 | + if ( ! (Give()->donors instanceof Give_DB_Donors)) { |
|
| 46 | 46 | // Install table. |
| 47 | 47 | $this->register_table(); |
| 48 | 48 | } |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | 'purchase_value' => 0.00, |
| 92 | 92 | 'purchase_count' => 0, |
| 93 | 93 | 'notes' => '', |
| 94 | - 'date_created' => date( 'Y-m-d H:i:s' ), |
|
| 94 | + 'date_created' => date('Y-m-d H:i:s'), |
|
| 95 | 95 | 'token' => '', |
| 96 | 96 | 'verify_key' => '', |
| 97 | 97 | 'verify_throttle' => '', |
@@ -108,40 +108,40 @@ discard block |
||
| 108 | 108 | * |
| 109 | 109 | * @return int|bool |
| 110 | 110 | */ |
| 111 | - public function add( $data = array() ) { |
|
| 111 | + public function add($data = array()) { |
|
| 112 | 112 | |
| 113 | 113 | $defaults = array( |
| 114 | 114 | 'payment_ids' => '', |
| 115 | 115 | ); |
| 116 | 116 | |
| 117 | - $args = wp_parse_args( $data, $defaults ); |
|
| 117 | + $args = wp_parse_args($data, $defaults); |
|
| 118 | 118 | |
| 119 | - if ( empty( $args['email'] ) ) { |
|
| 119 | + if (empty($args['email'])) { |
|
| 120 | 120 | return false; |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - if ( ! empty( $args['payment_ids'] ) && is_array( $args['payment_ids'] ) ) { |
|
| 124 | - $args['payment_ids'] = implode( ',', array_unique( array_values( $args['payment_ids'] ) ) ); |
|
| 123 | + if ( ! empty($args['payment_ids']) && is_array($args['payment_ids'])) { |
|
| 124 | + $args['payment_ids'] = implode(',', array_unique(array_values($args['payment_ids']))); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - $donor = $this->get_donor_by( 'email', $args['email'] ); |
|
| 127 | + $donor = $this->get_donor_by('email', $args['email']); |
|
| 128 | 128 | |
| 129 | 129 | // update an existing donor. |
| 130 | - if ( $donor ) { |
|
| 130 | + if ($donor) { |
|
| 131 | 131 | |
| 132 | 132 | // Update the payment IDs attached to the donor |
| 133 | - if ( ! empty( $args['payment_ids'] ) ) { |
|
| 133 | + if ( ! empty($args['payment_ids'])) { |
|
| 134 | 134 | |
| 135 | - if ( empty( $donor->payment_ids ) ) { |
|
| 135 | + if (empty($donor->payment_ids)) { |
|
| 136 | 136 | |
| 137 | 137 | $donor->payment_ids = $args['payment_ids']; |
| 138 | 138 | |
| 139 | 139 | } else { |
| 140 | 140 | |
| 141 | - $existing_ids = array_map( 'absint', explode( ',', $donor->payment_ids ) ); |
|
| 142 | - $payment_ids = array_map( 'absint', explode( ',', $args['payment_ids'] ) ); |
|
| 143 | - $payment_ids = array_merge( $payment_ids, $existing_ids ); |
|
| 144 | - $donor->payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) ); |
|
| 141 | + $existing_ids = array_map('absint', explode(',', $donor->payment_ids)); |
|
| 142 | + $payment_ids = array_map('absint', explode(',', $args['payment_ids'])); |
|
| 143 | + $payment_ids = array_merge($payment_ids, $existing_ids); |
|
| 144 | + $donor->payment_ids = implode(',', array_unique(array_values($payment_ids))); |
|
| 145 | 145 | |
| 146 | 146 | } |
| 147 | 147 | |
@@ -149,13 +149,13 @@ discard block |
||
| 149 | 149 | |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | - $this->update( $donor->id, $args ); |
|
| 152 | + $this->update($donor->id, $args); |
|
| 153 | 153 | |
| 154 | 154 | return $donor->id; |
| 155 | 155 | |
| 156 | 156 | } else { |
| 157 | 157 | |
| 158 | - return $this->insert( $args, 'donor' ); |
|
| 158 | + return $this->insert($args, 'donor'); |
|
| 159 | 159 | |
| 160 | 160 | } |
| 161 | 161 | |
@@ -172,12 +172,12 @@ discard block |
||
| 172 | 172 | * |
| 173 | 173 | * @return bool |
| 174 | 174 | */ |
| 175 | - public function update( $row_id, $data = array(), $where = '' ) { |
|
| 175 | + public function update($row_id, $data = array(), $where = '') { |
|
| 176 | 176 | |
| 177 | - $status = parent::update( $row_id, $data, $where ); |
|
| 177 | + $status = parent::update($row_id, $data, $where); |
|
| 178 | 178 | |
| 179 | - if ( $status ) { |
|
| 180 | - Give_Cache::delete_group( $row_id, 'give-donors' ); |
|
| 179 | + if ($status) { |
|
| 180 | + Give_Cache::delete_group($row_id, 'give-donors'); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | return $status; |
@@ -191,11 +191,11 @@ discard block |
||
| 191 | 191 | * |
| 192 | 192 | * @return int |
| 193 | 193 | */ |
| 194 | - public function insert( $data, $type = '' ) { |
|
| 195 | - $donor_id = parent::insert( $data, $type ); |
|
| 194 | + public function insert($data, $type = '') { |
|
| 195 | + $donor_id = parent::insert($data, $type); |
|
| 196 | 196 | |
| 197 | - if ( $donor_id ) { |
|
| 198 | - Give_Cache::delete_group( $donor_id, 'give-donors' ); |
|
| 197 | + if ($donor_id) { |
|
| 198 | + Give_Cache::delete_group($donor_id, 'give-donors'); |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | return $donor_id; |
@@ -214,16 +214,16 @@ discard block |
||
| 214 | 214 | * |
| 215 | 215 | * @return bool|int |
| 216 | 216 | */ |
| 217 | - public function delete( $_id_or_email = false ) { |
|
| 217 | + public function delete($_id_or_email = false) { |
|
| 218 | 218 | |
| 219 | - if ( empty( $_id_or_email ) ) { |
|
| 219 | + if (empty($_id_or_email)) { |
|
| 220 | 220 | return false; |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | - $column = is_email( $_id_or_email ) ? 'email' : 'id'; |
|
| 224 | - $donor = $this->get_donor_by( $column, $_id_or_email ); |
|
| 223 | + $column = is_email($_id_or_email) ? 'email' : 'id'; |
|
| 224 | + $donor = $this->get_donor_by($column, $_id_or_email); |
|
| 225 | 225 | |
| 226 | - if ( $donor->id > 0 ) { |
|
| 226 | + if ($donor->id > 0) { |
|
| 227 | 227 | |
| 228 | 228 | global $wpdb; |
| 229 | 229 | |
@@ -232,11 +232,11 @@ discard block |
||
| 232 | 232 | * |
| 233 | 233 | * @since 1.8.14 |
| 234 | 234 | */ |
| 235 | - Give()->donor_meta->delete_all_meta( $donor->id ); |
|
| 235 | + Give()->donor_meta->delete_all_meta($donor->id); |
|
| 236 | 236 | |
| 237 | 237 | // Cache already deleted in delete_all_meta fn. |
| 238 | 238 | |
| 239 | - return $wpdb->delete( $this->table_name, array( 'id' => $donor->id ), array( '%d' ) ); |
|
| 239 | + return $wpdb->delete($this->table_name, array('id' => $donor->id), array('%d')); |
|
| 240 | 240 | |
| 241 | 241 | } else { |
| 242 | 242 | return false; |
@@ -257,10 +257,10 @@ discard block |
||
| 257 | 257 | * |
| 258 | 258 | * @return bool|int |
| 259 | 259 | */ |
| 260 | - public function delete_by_user_id( $user_id = false ) { |
|
| 260 | + public function delete_by_user_id($user_id = false) { |
|
| 261 | 261 | global $wpdb; |
| 262 | 262 | |
| 263 | - if ( empty( $user_id ) ) { |
|
| 263 | + if (empty($user_id)) { |
|
| 264 | 264 | return false; |
| 265 | 265 | } |
| 266 | 266 | |
@@ -269,14 +269,14 @@ discard block |
||
| 269 | 269 | * |
| 270 | 270 | * @since 1.8.14 |
| 271 | 271 | */ |
| 272 | - $donor = new Give_Donor( $user_id, true ); |
|
| 273 | - if ( ! empty( $donor->id ) ) { |
|
| 274 | - Give()->donor_meta->delete_all_meta( $donor->id ); |
|
| 272 | + $donor = new Give_Donor($user_id, true); |
|
| 273 | + if ( ! empty($donor->id)) { |
|
| 274 | + Give()->donor_meta->delete_all_meta($donor->id); |
|
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | // Cache is already deleted in delete_all_meta fn. |
| 278 | 278 | |
| 279 | - return $wpdb->delete( $this->table_name, array( 'user_id' => $user_id ), array( '%d' ) ); |
|
| 279 | + return $wpdb->delete($this->table_name, array('user_id' => $user_id), array('%d')); |
|
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | /** |
@@ -290,14 +290,14 @@ discard block |
||
| 290 | 290 | * |
| 291 | 291 | * @return bool True is exists, false otherwise. |
| 292 | 292 | */ |
| 293 | - public function exists( $value = '', $field = 'email' ) { |
|
| 293 | + public function exists($value = '', $field = 'email') { |
|
| 294 | 294 | |
| 295 | 295 | $columns = $this->get_columns(); |
| 296 | - if ( ! array_key_exists( $field, $columns ) ) { |
|
| 296 | + if ( ! array_key_exists($field, $columns)) { |
|
| 297 | 297 | return false; |
| 298 | 298 | } |
| 299 | 299 | |
| 300 | - return (bool) $this->get_column_by( 'id', $field, $value ); |
|
| 300 | + return (bool) $this->get_column_by('id', $field, $value); |
|
| 301 | 301 | |
| 302 | 302 | } |
| 303 | 303 | |
@@ -312,16 +312,16 @@ discard block |
||
| 312 | 312 | * |
| 313 | 313 | * @return bool |
| 314 | 314 | */ |
| 315 | - public function attach_payment( $donor_id = 0, $payment_id = 0 ) { |
|
| 315 | + public function attach_payment($donor_id = 0, $payment_id = 0) { |
|
| 316 | 316 | |
| 317 | - $donor = new Give_Donor( $donor_id ); |
|
| 317 | + $donor = new Give_Donor($donor_id); |
|
| 318 | 318 | |
| 319 | - if ( empty( $donor->id ) ) { |
|
| 319 | + if (empty($donor->id)) { |
|
| 320 | 320 | return false; |
| 321 | 321 | } |
| 322 | 322 | |
| 323 | 323 | // Attach the payment, but don't increment stats, as this function previously did not |
| 324 | - return $donor->attach_payment( $payment_id, false ); |
|
| 324 | + return $donor->attach_payment($payment_id, false); |
|
| 325 | 325 | |
| 326 | 326 | } |
| 327 | 327 | |
@@ -336,16 +336,16 @@ discard block |
||
| 336 | 336 | * |
| 337 | 337 | * @return bool |
| 338 | 338 | */ |
| 339 | - public function remove_payment( $donor_id = 0, $payment_id = 0 ) { |
|
| 339 | + public function remove_payment($donor_id = 0, $payment_id = 0) { |
|
| 340 | 340 | |
| 341 | - $donor = new Give_Donor( $donor_id ); |
|
| 341 | + $donor = new Give_Donor($donor_id); |
|
| 342 | 342 | |
| 343 | - if ( ! $donor ) { |
|
| 343 | + if ( ! $donor) { |
|
| 344 | 344 | return false; |
| 345 | 345 | } |
| 346 | 346 | |
| 347 | 347 | // Remove the payment, but don't decrease stats, as this function previously did not |
| 348 | - return $donor->remove_payment( $payment_id, false ); |
|
| 348 | + return $donor->remove_payment($payment_id, false); |
|
| 349 | 349 | |
| 350 | 350 | } |
| 351 | 351 | |
@@ -359,18 +359,18 @@ discard block |
||
| 359 | 359 | * |
| 360 | 360 | * @return bool |
| 361 | 361 | */ |
| 362 | - public function increment_stats( $donor_id = 0, $amount = 0.00 ) { |
|
| 362 | + public function increment_stats($donor_id = 0, $amount = 0.00) { |
|
| 363 | 363 | |
| 364 | - $donor = new Give_Donor( $donor_id ); |
|
| 364 | + $donor = new Give_Donor($donor_id); |
|
| 365 | 365 | |
| 366 | - if ( empty( $donor->id ) ) { |
|
| 366 | + if (empty($donor->id)) { |
|
| 367 | 367 | return false; |
| 368 | 368 | } |
| 369 | 369 | |
| 370 | 370 | $increased_count = $donor->increase_purchase_count(); |
| 371 | - $increased_value = $donor->increase_value( $amount ); |
|
| 371 | + $increased_value = $donor->increase_value($amount); |
|
| 372 | 372 | |
| 373 | - return ( $increased_count && $increased_value ) ? true : false; |
|
| 373 | + return ($increased_count && $increased_value) ? true : false; |
|
| 374 | 374 | |
| 375 | 375 | } |
| 376 | 376 | |
@@ -385,18 +385,18 @@ discard block |
||
| 385 | 385 | * |
| 386 | 386 | * @return bool |
| 387 | 387 | */ |
| 388 | - public function decrement_stats( $donor_id = 0, $amount = 0.00 ) { |
|
| 388 | + public function decrement_stats($donor_id = 0, $amount = 0.00) { |
|
| 389 | 389 | |
| 390 | - $donor = new Give_Donor( $donor_id ); |
|
| 390 | + $donor = new Give_Donor($donor_id); |
|
| 391 | 391 | |
| 392 | - if ( ! $donor ) { |
|
| 392 | + if ( ! $donor) { |
|
| 393 | 393 | return false; |
| 394 | 394 | } |
| 395 | 395 | |
| 396 | 396 | $decreased_count = $donor->decrease_donation_count(); |
| 397 | - $decreased_value = $donor->decrease_value( $amount ); |
|
| 397 | + $decreased_value = $donor->decrease_value($amount); |
|
| 398 | 398 | |
| 399 | - return ( $decreased_count && $decreased_value ) ? true : false; |
|
| 399 | + return ($decreased_count && $decreased_value) ? true : false; |
|
| 400 | 400 | |
| 401 | 401 | } |
| 402 | 402 | |
@@ -411,44 +411,44 @@ discard block |
||
| 411 | 411 | * |
| 412 | 412 | * @return mixed Upon success, an object of the donor. Upon failure, NULL |
| 413 | 413 | */ |
| 414 | - public function get_donor_by( $field = 'id', $value = 0 ) { |
|
| 415 | - $value = sanitize_text_field( $value ); |
|
| 414 | + public function get_donor_by($field = 'id', $value = 0) { |
|
| 415 | + $value = sanitize_text_field($value); |
|
| 416 | 416 | |
| 417 | 417 | // Bailout. |
| 418 | - if ( empty( $field ) || empty( $value ) ) { |
|
| 418 | + if (empty($field) || empty($value)) { |
|
| 419 | 419 | return null; |
| 420 | 420 | } |
| 421 | 421 | |
| 422 | 422 | // Verify values. |
| 423 | - if ( 'id' === $field || 'user_id' === $field ) { |
|
| 423 | + if ('id' === $field || 'user_id' === $field) { |
|
| 424 | 424 | // Make sure the value is numeric to avoid casting objects, for example, |
| 425 | 425 | // to int 1. |
| 426 | - if ( ! is_numeric( $value ) ) { |
|
| 426 | + if ( ! is_numeric($value)) { |
|
| 427 | 427 | return false; |
| 428 | 428 | } |
| 429 | 429 | |
| 430 | - $value = absint( $value ); |
|
| 430 | + $value = absint($value); |
|
| 431 | 431 | |
| 432 | - if ( $value < 1 ) { |
|
| 432 | + if ($value < 1) { |
|
| 433 | 433 | return false; |
| 434 | 434 | } |
| 435 | 435 | |
| 436 | - } elseif ( 'email' === $field ) { |
|
| 436 | + } elseif ('email' === $field) { |
|
| 437 | 437 | |
| 438 | - if ( ! is_email( $value ) ) { |
|
| 438 | + if ( ! is_email($value)) { |
|
| 439 | 439 | return false; |
| 440 | 440 | } |
| 441 | 441 | |
| 442 | - $value = trim( $value ); |
|
| 442 | + $value = trim($value); |
|
| 443 | 443 | } |
| 444 | 444 | |
| 445 | 445 | // Bailout |
| 446 | - if ( ! $value ) { |
|
| 446 | + if ( ! $value) { |
|
| 447 | 447 | return false; |
| 448 | 448 | } |
| 449 | 449 | |
| 450 | 450 | // Set query params. |
| 451 | - switch ( $field ) { |
|
| 451 | + switch ($field) { |
|
| 452 | 452 | case 'id': |
| 453 | 453 | $args['donor'] = $value; |
| 454 | 454 | break; |
@@ -463,9 +463,9 @@ discard block |
||
| 463 | 463 | } |
| 464 | 464 | |
| 465 | 465 | // Get donors. |
| 466 | - $donor = new Give_Donors_Query( $args ); |
|
| 466 | + $donor = new Give_Donors_Query($args); |
|
| 467 | 467 | |
| 468 | - if ( ! $donor = $donor->get_donors() ) { |
|
| 468 | + if ( ! $donor = $donor->get_donors()) { |
|
| 469 | 469 | // Look for donor from an additional email. |
| 470 | 470 | $args = array( |
| 471 | 471 | 'meta_query' => array( |
@@ -476,15 +476,15 @@ discard block |
||
| 476 | 476 | ), |
| 477 | 477 | ); |
| 478 | 478 | |
| 479 | - $donor = new Give_Donors_Query( $args ); |
|
| 479 | + $donor = new Give_Donors_Query($args); |
|
| 480 | 480 | $donor = $donor->get_donors(); |
| 481 | 481 | |
| 482 | - if ( empty( $donor ) ) { |
|
| 482 | + if (empty($donor)) { |
|
| 483 | 483 | return false; |
| 484 | 484 | } |
| 485 | 485 | } |
| 486 | 486 | |
| 487 | - return current( $donor ); |
|
| 487 | + return current($donor); |
|
| 488 | 488 | } |
| 489 | 489 | |
| 490 | 490 | /** |
@@ -497,10 +497,10 @@ discard block |
||
| 497 | 497 | * |
| 498 | 498 | * @return array|object|null Donors array or object. Null if not found. |
| 499 | 499 | */ |
| 500 | - public function get_donors( $args = array() ) { |
|
| 501 | - $this->bc_1814_params( $args ); |
|
| 500 | + public function get_donors($args = array()) { |
|
| 501 | + $this->bc_1814_params($args); |
|
| 502 | 502 | |
| 503 | - $donors = new Give_Donors_Query( $args ); |
|
| 503 | + $donors = new Give_Donors_Query($args); |
|
| 504 | 504 | |
| 505 | 505 | return $donors->get_donors(); |
| 506 | 506 | |
@@ -517,21 +517,21 @@ discard block |
||
| 517 | 517 | * |
| 518 | 518 | * @return int Total number of donors. |
| 519 | 519 | */ |
| 520 | - public function count( $args = array() ) { |
|
| 521 | - $this->bc_1814_params( $args ); |
|
| 520 | + public function count($args = array()) { |
|
| 521 | + $this->bc_1814_params($args); |
|
| 522 | 522 | $args['count'] = true; |
| 523 | 523 | |
| 524 | - $cache_key = md5( 'give_donors_count' . serialize( $args ) ); |
|
| 525 | - $count = Give_Cache::get_group( $cache_key, 'donors' ); |
|
| 524 | + $cache_key = md5('give_donors_count'.serialize($args)); |
|
| 525 | + $count = Give_Cache::get_group($cache_key, 'donors'); |
|
| 526 | 526 | |
| 527 | - if ( is_null( $count ) ) { |
|
| 528 | - $donors = new Give_Donors_Query( $args ); |
|
| 527 | + if (is_null($count)) { |
|
| 528 | + $donors = new Give_Donors_Query($args); |
|
| 529 | 529 | $count = $donors->get_donors(); |
| 530 | 530 | |
| 531 | - Give_Cache::set_group( $cache_key, $count, 'donors', 3600 ); |
|
| 531 | + Give_Cache::set_group($cache_key, $count, 'donors', 3600); |
|
| 532 | 532 | } |
| 533 | 533 | |
| 534 | - return absint( $count ); |
|
| 534 | + return absint($count); |
|
| 535 | 535 | |
| 536 | 536 | } |
| 537 | 537 | |
@@ -545,9 +545,9 @@ discard block |
||
| 545 | 545 | */ |
| 546 | 546 | public function create_table() { |
| 547 | 547 | |
| 548 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
| 548 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
| 549 | 549 | |
| 550 | - $sql = "CREATE TABLE " . $this->table_name . " ( |
|
| 550 | + $sql = "CREATE TABLE ".$this->table_name." ( |
|
| 551 | 551 | id bigint(20) NOT NULL AUTO_INCREMENT, |
| 552 | 552 | user_id bigint(20) NOT NULL, |
| 553 | 553 | email varchar(50) NOT NULL, |
@@ -565,9 +565,9 @@ discard block |
||
| 565 | 565 | KEY user (user_id) |
| 566 | 566 | ) CHARACTER SET utf8 COLLATE utf8_general_ci;"; |
| 567 | 567 | |
| 568 | - dbDelta( $sql ); |
|
| 568 | + dbDelta($sql); |
|
| 569 | 569 | |
| 570 | - update_option( $this->table_name . '_db_version', $this->version ); |
|
| 570 | + update_option($this->table_name.'_db_version', $this->version); |
|
| 571 | 571 | } |
| 572 | 572 | |
| 573 | 573 | /** |
@@ -582,8 +582,8 @@ discard block |
||
| 582 | 582 | global $wpdb; |
| 583 | 583 | |
| 584 | 584 | if ( |
| 585 | - ! give_has_upgrade_completed( 'v20_rename_donor_tables' ) && |
|
| 586 | - $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", "{$wpdb->prefix}give_customers" ) ) |
|
| 585 | + ! give_has_upgrade_completed('v20_rename_donor_tables') && |
|
| 586 | + $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_customers")) |
|
| 587 | 587 | ) { |
| 588 | 588 | $wpdb->donors = $this->table_name = "{$wpdb->prefix}give_customers"; |
| 589 | 589 | } |
@@ -597,41 +597,41 @@ discard block |
||
| 597 | 597 | * |
| 598 | 598 | * @param $args |
| 599 | 599 | */ |
| 600 | - private function bc_1814_params( &$args ) { |
|
| 600 | + private function bc_1814_params(&$args) { |
|
| 601 | 601 | // Backward compatibility: user_id |
| 602 | - if ( ! empty( $args['user_id'] ) ) { |
|
| 602 | + if ( ! empty($args['user_id'])) { |
|
| 603 | 603 | $args['user'] = $args['user_id']; |
| 604 | 604 | } |
| 605 | 605 | |
| 606 | 606 | // Backward compatibility: id |
| 607 | - if ( ! empty( $args['id'] ) ) { |
|
| 607 | + if ( ! empty($args['id'])) { |
|
| 608 | 608 | $args['donor'] = $args['id']; |
| 609 | 609 | } |
| 610 | 610 | |
| 611 | 611 | // Backward compatibility: name |
| 612 | - if ( ! empty( $args['name'] ) ) { |
|
| 612 | + if ( ! empty($args['name'])) { |
|
| 613 | 613 | $args['s'] = "name:{$args['name']}"; |
| 614 | 614 | } |
| 615 | 615 | |
| 616 | 616 | // Backward compatibility: date |
| 617 | 617 | // Donors created for a specific date or in a date range. |
| 618 | - if ( ! empty( $args['date'] ) ) { |
|
| 618 | + if ( ! empty($args['date'])) { |
|
| 619 | 619 | |
| 620 | - if ( is_array( $args['date'] ) ) { |
|
| 620 | + if (is_array($args['date'])) { |
|
| 621 | 621 | |
| 622 | - if ( ! empty( $args['date']['start'] ) ) { |
|
| 623 | - $args['date_query']['after'] = date( 'Y-m-d H:i:s', strtotime( $args['date']['start'] ) ); |
|
| 622 | + if ( ! empty($args['date']['start'])) { |
|
| 623 | + $args['date_query']['after'] = date('Y-m-d H:i:s', strtotime($args['date']['start'])); |
|
| 624 | 624 | } |
| 625 | 625 | |
| 626 | - if ( ! empty( $args['date']['end'] ) ) { |
|
| 627 | - $args['date_query']['before'] = date( 'Y-m-d H:i:s', strtotime( $args['date']['end'] ) ); |
|
| 626 | + if ( ! empty($args['date']['end'])) { |
|
| 627 | + $args['date_query']['before'] = date('Y-m-d H:i:s', strtotime($args['date']['end'])); |
|
| 628 | 628 | } |
| 629 | 629 | |
| 630 | 630 | } else { |
| 631 | 631 | |
| 632 | - $args['date_query']['year'] = date( 'Y', strtotime( $args['date'] ) ); |
|
| 633 | - $args['date_query']['month'] = date( 'm', strtotime( $args['date'] ) ); |
|
| 634 | - $args['date_query']['day'] = date( 'd', strtotime( $args['date'] ) ); |
|
| 632 | + $args['date_query']['year'] = date('Y', strtotime($args['date'])); |
|
| 633 | + $args['date_query']['month'] = date('m', strtotime($args['date'])); |
|
| 634 | + $args['date_query']['day'] = date('d', strtotime($args['date'])); |
|
| 635 | 635 | } |
| 636 | 636 | } |
| 637 | 637 | } |
@@ -512,7 +512,7 @@ |
||
| 512 | 512 | * @since 1.7 |
| 513 | 513 | * @access public |
| 514 | 514 | * |
| 515 | - * @return bool |
|
| 515 | + * @return false|null |
|
| 516 | 516 | */ |
| 517 | 517 | public function delete_cache() { |
| 518 | 518 | // Add log related keys to delete. |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly. |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -53,8 +53,8 @@ discard block |
||
| 53 | 53 | * Setup properties |
| 54 | 54 | */ |
| 55 | 55 | |
| 56 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-logs.php'; |
|
| 57 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-logs-meta.php'; |
|
| 56 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-db-logs.php'; |
|
| 57 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-db-logs-meta.php'; |
|
| 58 | 58 | $this->log_db = new Give_DB_Logs(); |
| 59 | 59 | $this->logmeta_db = new Give_DB_Log_Meta(); |
| 60 | 60 | |
@@ -62,22 +62,22 @@ discard block |
||
| 62 | 62 | * Setup hooks. |
| 63 | 63 | */ |
| 64 | 64 | |
| 65 | - add_action( 'save_post_give_payment', array( $this, 'background_process_delete_cache' ) ); |
|
| 66 | - add_action( 'save_post_give_forms', array( $this, 'background_process_delete_cache' ) ); |
|
| 67 | - add_action( 'save_post_give_log', array( $this, 'background_process_delete_cache' ) ); |
|
| 68 | - add_action( 'give_delete_log_cache', array( $this, 'delete_cache' ) ); |
|
| 69 | - add_action( 'update_log_metadata', array( $this, 'bc_200_set_payment_as_log_parent' ), 10, 4 ); |
|
| 65 | + add_action('save_post_give_payment', array($this, 'background_process_delete_cache')); |
|
| 66 | + add_action('save_post_give_forms', array($this, 'background_process_delete_cache')); |
|
| 67 | + add_action('save_post_give_log', array($this, 'background_process_delete_cache')); |
|
| 68 | + add_action('give_delete_log_cache', array($this, 'delete_cache')); |
|
| 69 | + add_action('update_log_metadata', array($this, 'bc_200_set_payment_as_log_parent'), 10, 4); |
|
| 70 | 70 | |
| 71 | 71 | // Backward compatibility. |
| 72 | - if ( ! give_has_upgrade_completed( 'v20_logs_upgrades' ) ) { |
|
| 72 | + if ( ! give_has_upgrade_completed('v20_logs_upgrades')) { |
|
| 73 | 73 | // Create the log post type |
| 74 | - add_action( 'init', array( $this, 'register_post_type' ), -2 ); |
|
| 74 | + add_action('init', array($this, 'register_post_type'), -2); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | // Create types taxonomy and default types |
| 78 | 78 | // @todo: remove this taxonomy, some addon use this taxonomy with there custom log post type for example: recurring |
| 79 | 79 | // Do not use this taxonomy with your log type because we will remove it in future releases. |
| 80 | - add_action( 'init', array( $this, 'register_taxonomy' ), -2 ); |
|
| 80 | + add_action('init', array($this, 'register_taxonomy'), -2); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | /* Logs post type */ |
| 96 | 96 | $log_args = array( |
| 97 | 97 | 'labels' => array( |
| 98 | - 'name' => esc_html__( 'Logs', 'give' ), |
|
| 98 | + 'name' => esc_html__('Logs', 'give'), |
|
| 99 | 99 | ), |
| 100 | 100 | 'public' => false, |
| 101 | 101 | 'exclude_from_search' => true, |
@@ -104,11 +104,11 @@ discard block |
||
| 104 | 104 | 'query_var' => false, |
| 105 | 105 | 'rewrite' => false, |
| 106 | 106 | 'capability_type' => 'post', |
| 107 | - 'supports' => array( 'title', 'editor' ), |
|
| 107 | + 'supports' => array('title', 'editor'), |
|
| 108 | 108 | 'can_export' => true, |
| 109 | 109 | ); |
| 110 | 110 | |
| 111 | - register_post_type( 'give_log', $log_args ); |
|
| 111 | + register_post_type('give_log', $log_args); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | /** |
@@ -122,9 +122,9 @@ discard block |
||
| 122 | 122 | * @return void |
| 123 | 123 | */ |
| 124 | 124 | public function register_taxonomy() { |
| 125 | - register_taxonomy( 'give_log_type', 'give_log', array( |
|
| 125 | + register_taxonomy('give_log_type', 'give_log', array( |
|
| 126 | 126 | 'public' => false, |
| 127 | - ) ); |
|
| 127 | + )); |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | /** |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | 'api_request', |
| 145 | 145 | ); |
| 146 | 146 | |
| 147 | - return apply_filters( 'give_log_types', $terms ); |
|
| 147 | + return apply_filters('give_log_types', $terms); |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | /** |
@@ -159,8 +159,8 @@ discard block |
||
| 159 | 159 | * |
| 160 | 160 | * @return bool Whether log type is valid. |
| 161 | 161 | */ |
| 162 | - public function valid_type( $type ) { |
|
| 163 | - return in_array( $type, $this->log_types() ); |
|
| 162 | + public function valid_type($type) { |
|
| 163 | + return in_array($type, $this->log_types()); |
|
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | /** |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | * |
| 180 | 180 | * @return int Log ID. |
| 181 | 181 | */ |
| 182 | - public function add( $title = '', $message = '', $parent = 0, $type = '' ) { |
|
| 182 | + public function add($title = '', $message = '', $parent = 0, $type = '') { |
|
| 183 | 183 | $log_data = array( |
| 184 | 184 | 'post_title' => $title, |
| 185 | 185 | 'post_content' => $message, |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | 'log_type' => $type, |
| 188 | 188 | ); |
| 189 | 189 | |
| 190 | - return $this->insert_log( $log_data ); |
|
| 190 | + return $this->insert_log($log_data); |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | /** |
@@ -204,12 +204,12 @@ discard block |
||
| 204 | 204 | * |
| 205 | 205 | * @return array An array of the connected logs. |
| 206 | 206 | */ |
| 207 | - public function get_logs( $object_id = 0, $type = '', $paged = null ) { |
|
| 208 | - return $this->get_connected_logs( array( |
|
| 207 | + public function get_logs($object_id = 0, $type = '', $paged = null) { |
|
| 208 | + return $this->get_connected_logs(array( |
|
| 209 | 209 | 'log_parent' => $object_id, |
| 210 | 210 | 'paged' => $paged, |
| 211 | 211 | 'log_type' => $type, |
| 212 | - ) ); |
|
| 212 | + )); |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | /** |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | * |
| 224 | 224 | * @return int The ID of the newly created log item. |
| 225 | 225 | */ |
| 226 | - public function insert_log( $log_data = array(), $log_meta = array() ) { |
|
| 226 | + public function insert_log($log_data = array(), $log_meta = array()) { |
|
| 227 | 227 | $log_id = 0; |
| 228 | 228 | |
| 229 | 229 | $defaults = array( |
@@ -236,28 +236,28 @@ discard block |
||
| 236 | 236 | 'post_status' => 'publish', |
| 237 | 237 | ); |
| 238 | 238 | |
| 239 | - $args = wp_parse_args( $log_data, $defaults ); |
|
| 240 | - $this->bc_200_validate_params( $args, $log_meta ); |
|
| 239 | + $args = wp_parse_args($log_data, $defaults); |
|
| 240 | + $this->bc_200_validate_params($args, $log_meta); |
|
| 241 | 241 | |
| 242 | - if ( ! give_has_upgrade_completed( 'v20_logs_upgrades' ) ) { |
|
| 242 | + if ( ! give_has_upgrade_completed('v20_logs_upgrades')) { |
|
| 243 | 243 | global $wpdb; |
| 244 | 244 | |
| 245 | 245 | // Backward Compatibility. |
| 246 | - if ( ! $wpdb->get_var( "SELECT ID from {$this->log_db->table_name} ORDER BY id DESC LIMIT 1" ) ) { |
|
| 247 | - $latest_log_id = $wpdb->get_var( "SELECT ID from $wpdb->posts ORDER BY id DESC LIMIT 1" ); |
|
| 248 | - $latest_log_id = empty( $latest_log_id ) ? 1 : ++ $latest_log_id; |
|
| 246 | + if ( ! $wpdb->get_var("SELECT ID from {$this->log_db->table_name} ORDER BY id DESC LIMIT 1")) { |
|
| 247 | + $latest_log_id = $wpdb->get_var("SELECT ID from $wpdb->posts ORDER BY id DESC LIMIT 1"); |
|
| 248 | + $latest_log_id = empty($latest_log_id) ? 1 : ++ $latest_log_id; |
|
| 249 | 249 | |
| 250 | 250 | $args['ID'] = $latest_log_id; |
| 251 | - $this->log_db->insert( $args ); |
|
| 251 | + $this->log_db->insert($args); |
|
| 252 | 252 | } |
| 253 | 253 | } |
| 254 | 254 | |
| 255 | - $log_id = $this->log_db->add( $args ); |
|
| 255 | + $log_id = $this->log_db->add($args); |
|
| 256 | 256 | |
| 257 | 257 | // Set log meta, if any |
| 258 | - if ( $log_id && ! empty( $log_meta ) ) { |
|
| 259 | - foreach ( (array) $log_meta as $key => $meta ) { |
|
| 260 | - $this->logmeta_db->update_meta( $log_id, '_give_log_' . sanitize_key( $key ), $meta ); |
|
| 258 | + if ($log_id && ! empty($log_meta)) { |
|
| 259 | + foreach ((array) $log_meta as $key => $meta) { |
|
| 260 | + $this->logmeta_db->update_meta($log_id, '_give_log_'.sanitize_key($key), $meta); |
|
| 261 | 261 | } |
| 262 | 262 | } |
| 263 | 263 | |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | * |
| 280 | 280 | * @return bool|null True if successful, false otherwise. |
| 281 | 281 | */ |
| 282 | - public function update_log( $log_data = array(), $log_meta = array() ) { |
|
| 282 | + public function update_log($log_data = array(), $log_meta = array()) { |
|
| 283 | 283 | $log_id = 0; |
| 284 | 284 | |
| 285 | 285 | /** |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | * @param array $log_data Log entry data. |
| 291 | 291 | * @param array $log_meta Log entry meta. |
| 292 | 292 | */ |
| 293 | - do_action( 'give_pre_update_log', $log_data, $log_meta ); |
|
| 293 | + do_action('give_pre_update_log', $log_data, $log_meta); |
|
| 294 | 294 | |
| 295 | 295 | $defaults = array( |
| 296 | 296 | 'log_parent' => 0, |
@@ -300,28 +300,28 @@ discard block |
||
| 300 | 300 | 'post_status' => 'publish', |
| 301 | 301 | ); |
| 302 | 302 | |
| 303 | - $args = wp_parse_args( $log_data, $defaults ); |
|
| 304 | - $this->bc_200_validate_params( $args, $log_meta ); |
|
| 303 | + $args = wp_parse_args($log_data, $defaults); |
|
| 304 | + $this->bc_200_validate_params($args, $log_meta); |
|
| 305 | 305 | |
| 306 | 306 | // Store the log entry |
| 307 | - if ( ! give_has_upgrade_completed( 'v20_logs_upgrades' ) ) { |
|
| 307 | + if ( ! give_has_upgrade_completed('v20_logs_upgrades')) { |
|
| 308 | 308 | // Backward compatibility. |
| 309 | - $log_id = wp_update_post( $args ); |
|
| 309 | + $log_id = wp_update_post($args); |
|
| 310 | 310 | |
| 311 | - if ( $log_id && ! empty( $log_meta ) ) { |
|
| 312 | - foreach ( (array) $log_meta as $key => $meta ) { |
|
| 313 | - if ( ! empty( $meta ) ) { |
|
| 314 | - give_update_meta( $log_id, '_give_log_' . sanitize_key( $key ), $meta ); |
|
| 311 | + if ($log_id && ! empty($log_meta)) { |
|
| 312 | + foreach ((array) $log_meta as $key => $meta) { |
|
| 313 | + if ( ! empty($meta)) { |
|
| 314 | + give_update_meta($log_id, '_give_log_'.sanitize_key($key), $meta); |
|
| 315 | 315 | } |
| 316 | 316 | } |
| 317 | 317 | } |
| 318 | 318 | } else { |
| 319 | - $log_id = $this->log_db->add( $args ); |
|
| 319 | + $log_id = $this->log_db->add($args); |
|
| 320 | 320 | |
| 321 | - if ( $log_id && ! empty( $log_meta ) ) { |
|
| 322 | - foreach ( (array) $log_meta as $key => $meta ) { |
|
| 323 | - if ( ! empty( $meta ) ) { |
|
| 324 | - $this->logmeta_db->update_meta( $log_id, '_give_log_' . sanitize_key( $key ), $meta ); |
|
| 321 | + if ($log_id && ! empty($log_meta)) { |
|
| 322 | + foreach ((array) $log_meta as $key => $meta) { |
|
| 323 | + if ( ! empty($meta)) { |
|
| 324 | + $this->logmeta_db->update_meta($log_id, '_give_log_'.sanitize_key($key), $meta); |
|
| 325 | 325 | } |
| 326 | 326 | } |
| 327 | 327 | } |
@@ -336,7 +336,7 @@ discard block |
||
| 336 | 336 | * @param array $log_data Log entry data. |
| 337 | 337 | * @param array $log_meta Log entry meta. |
| 338 | 338 | */ |
| 339 | - do_action( 'give_post_update_log', $log_id, $log_data, $log_meta ); |
|
| 339 | + do_action('give_post_update_log', $log_id, $log_data, $log_meta); |
|
| 340 | 340 | } |
| 341 | 341 | |
| 342 | 342 | /** |
@@ -353,30 +353,30 @@ discard block |
||
| 353 | 353 | * |
| 354 | 354 | * @return array|false Array if logs were found, false otherwise. |
| 355 | 355 | */ |
| 356 | - public function get_connected_logs( $args = array() ) { |
|
| 356 | + public function get_connected_logs($args = array()) { |
|
| 357 | 357 | $logs = array(); |
| 358 | 358 | |
| 359 | - $defaults = array( |
|
| 359 | + $defaults = array( |
|
| 360 | 360 | 'number' => 20, |
| 361 | - 'paged' => get_query_var( 'paged' ), |
|
| 361 | + 'paged' => get_query_var('paged'), |
|
| 362 | 362 | 'log_type' => false, |
| 363 | 363 | |
| 364 | 364 | // Backward compatibility. |
| 365 | 365 | 'post_type' => 'give_log', |
| 366 | 366 | 'post_status' => 'publish', |
| 367 | 367 | ); |
| 368 | - $query_args = wp_parse_args( $args, $defaults ); |
|
| 369 | - $this->bc_200_validate_params( $query_args ); |
|
| 368 | + $query_args = wp_parse_args($args, $defaults); |
|
| 369 | + $this->bc_200_validate_params($query_args); |
|
| 370 | 370 | |
| 371 | - if ( ! give_has_upgrade_completed( 'v20_logs_upgrades' ) ) { |
|
| 371 | + if ( ! give_has_upgrade_completed('v20_logs_upgrades')) { |
|
| 372 | 372 | // Backward compatibility. |
| 373 | - $logs = get_posts( $query_args ); |
|
| 374 | - $this->bc_200_add_new_properties( $logs ); |
|
| 373 | + $logs = get_posts($query_args); |
|
| 374 | + $this->bc_200_add_new_properties($logs); |
|
| 375 | 375 | } else { |
| 376 | - $logs = $this->log_db->get_logs( $query_args ); |
|
| 376 | + $logs = $this->log_db->get_logs($query_args); |
|
| 377 | 377 | } |
| 378 | 378 | |
| 379 | - return ( ! empty( $logs ) ? $logs : false ); |
|
| 379 | + return ( ! empty($logs) ? $logs : false); |
|
| 380 | 380 | } |
| 381 | 381 | |
| 382 | 382 | /** |
@@ -394,41 +394,41 @@ discard block |
||
| 394 | 394 | * |
| 395 | 395 | * @return int Log count. |
| 396 | 396 | */ |
| 397 | - public function get_log_count( $object_id = 0, $type = '', $meta_query = null, $date_query = null ) { |
|
| 397 | + public function get_log_count($object_id = 0, $type = '', $meta_query = null, $date_query = null) { |
|
| 398 | 398 | $logs_count = 0; |
| 399 | 399 | |
| 400 | 400 | $query_args = array( |
| 401 | - 'number' => - 1, |
|
| 401 | + 'number' => -1, |
|
| 402 | 402 | |
| 403 | 403 | // Backward comatibility. |
| 404 | 404 | 'post_type' => 'give_log', |
| 405 | 405 | 'post_status' => 'publish', |
| 406 | 406 | ); |
| 407 | 407 | |
| 408 | - if ( $object_id ) { |
|
| 408 | + if ($object_id) { |
|
| 409 | 409 | $query_args['log_parent'] = $object_id; |
| 410 | 410 | } |
| 411 | 411 | |
| 412 | - if ( ! empty( $type ) && $this->valid_type( $type ) ) { |
|
| 412 | + if ( ! empty($type) && $this->valid_type($type)) { |
|
| 413 | 413 | $query_args['log_type'] = $type; |
| 414 | 414 | } |
| 415 | 415 | |
| 416 | - if ( ! empty( $meta_query ) ) { |
|
| 416 | + if ( ! empty($meta_query)) { |
|
| 417 | 417 | $query_args['meta_query'] = $meta_query; |
| 418 | 418 | } |
| 419 | 419 | |
| 420 | - if ( ! empty( $date_query ) ) { |
|
| 420 | + if ( ! empty($date_query)) { |
|
| 421 | 421 | $query_args['date_query'] = $date_query; |
| 422 | 422 | } |
| 423 | 423 | |
| 424 | - $this->bc_200_validate_params( $query_args ); |
|
| 424 | + $this->bc_200_validate_params($query_args); |
|
| 425 | 425 | |
| 426 | - if ( ! give_has_upgrade_completed( 'v20_logs_upgrades' ) ) { |
|
| 426 | + if ( ! give_has_upgrade_completed('v20_logs_upgrades')) { |
|
| 427 | 427 | // Backward compatibility. |
| 428 | - $logs = new WP_Query( $query_args ); |
|
| 428 | + $logs = new WP_Query($query_args); |
|
| 429 | 429 | $logs_count = (int) $logs->post_count; |
| 430 | 430 | } else { |
| 431 | - $logs_count = $this->log_db->count( $query_args ); |
|
| 431 | + $logs_count = $this->log_db->count($query_args); |
|
| 432 | 432 | } |
| 433 | 433 | |
| 434 | 434 | return $logs_count; |
@@ -448,10 +448,10 @@ discard block |
||
| 448 | 448 | * |
| 449 | 449 | * @return void |
| 450 | 450 | */ |
| 451 | - public function delete_logs( $object_id = 0, $type = '', $meta_query = null ) { |
|
| 451 | + public function delete_logs($object_id = 0, $type = '', $meta_query = null) { |
|
| 452 | 452 | $query_args = array( |
| 453 | 453 | 'log_parent' => $object_id, |
| 454 | - 'number' => - 1, |
|
| 454 | + 'number' => -1, |
|
| 455 | 455 | 'fields' => 'ID', |
| 456 | 456 | |
| 457 | 457 | // Backward compatibility. |
@@ -459,32 +459,32 @@ discard block |
||
| 459 | 459 | 'post_status' => 'publish', |
| 460 | 460 | ); |
| 461 | 461 | |
| 462 | - if ( ! empty( $type ) && $this->valid_type( $type ) ) { |
|
| 462 | + if ( ! empty($type) && $this->valid_type($type)) { |
|
| 463 | 463 | $query_args['log_type'] = $type; |
| 464 | 464 | } |
| 465 | 465 | |
| 466 | - if ( ! empty( $meta_query ) ) { |
|
| 466 | + if ( ! empty($meta_query)) { |
|
| 467 | 467 | $query_args['meta_query'] = $meta_query; |
| 468 | 468 | } |
| 469 | 469 | |
| 470 | - $this->bc_200_validate_params( $query_args ); |
|
| 470 | + $this->bc_200_validate_params($query_args); |
|
| 471 | 471 | |
| 472 | - if ( ! give_has_upgrade_completed( 'v20_logs_upgrades' ) ) { |
|
| 472 | + if ( ! give_has_upgrade_completed('v20_logs_upgrades')) { |
|
| 473 | 473 | // Backward compatibility. |
| 474 | - $logs = get_posts( $query_args ); |
|
| 474 | + $logs = get_posts($query_args); |
|
| 475 | 475 | |
| 476 | - if ( $logs ) { |
|
| 477 | - foreach ( $logs as $log ) { |
|
| 478 | - wp_delete_post( $log, true ); |
|
| 476 | + if ($logs) { |
|
| 477 | + foreach ($logs as $log) { |
|
| 478 | + wp_delete_post($log, true); |
|
| 479 | 479 | } |
| 480 | 480 | } |
| 481 | 481 | } else { |
| 482 | - $logs = $this->log_db->get_logs( $query_args ); |
|
| 482 | + $logs = $this->log_db->get_logs($query_args); |
|
| 483 | 483 | |
| 484 | - if ( $logs ) { |
|
| 485 | - foreach ( $logs as $log ) { |
|
| 486 | - if ( $this->log_db->delete( $log->ID ) ) { |
|
| 487 | - $this->logmeta_db->delete_row( $log->ID ); |
|
| 484 | + if ($logs) { |
|
| 485 | + foreach ($logs as $log) { |
|
| 486 | + if ($this->log_db->delete($log->ID)) { |
|
| 487 | + $this->logmeta_db->delete_row($log->ID); |
|
| 488 | 488 | } |
| 489 | 489 | } |
| 490 | 490 | } |
@@ -501,9 +501,9 @@ discard block |
||
| 501 | 501 | * |
| 502 | 502 | * @param int $post_id |
| 503 | 503 | */ |
| 504 | - public function background_process_delete_cache( $post_id ) { |
|
| 504 | + public function background_process_delete_cache($post_id) { |
|
| 505 | 505 | // Delete log cache immediately |
| 506 | - wp_schedule_single_event( time() - 5, 'give_delete_log_cache' ); |
|
| 506 | + wp_schedule_single_event(time() - 5, 'give_delete_log_cache'); |
|
| 507 | 507 | } |
| 508 | 508 | |
| 509 | 509 | /** |
@@ -516,17 +516,17 @@ discard block |
||
| 516 | 516 | */ |
| 517 | 517 | public function delete_cache() { |
| 518 | 518 | // Add log related keys to delete. |
| 519 | - $cache_give_logs = Give_Cache::get_options_like( 'give_logs' ); |
|
| 520 | - $cache_give_log_count = Give_Cache::get_options_like( 'log_count' ); |
|
| 519 | + $cache_give_logs = Give_Cache::get_options_like('give_logs'); |
|
| 520 | + $cache_give_log_count = Give_Cache::get_options_like('log_count'); |
|
| 521 | 521 | |
| 522 | - $cache_option_names = array_merge( $cache_give_logs, $cache_give_log_count ); |
|
| 522 | + $cache_option_names = array_merge($cache_give_logs, $cache_give_log_count); |
|
| 523 | 523 | |
| 524 | 524 | // Bailout. |
| 525 | - if ( empty( $cache_option_names ) ) { |
|
| 525 | + if (empty($cache_option_names)) { |
|
| 526 | 526 | return false; |
| 527 | 527 | } |
| 528 | 528 | |
| 529 | - Give_Cache::delete( $cache_option_names ); |
|
| 529 | + Give_Cache::delete($cache_option_names); |
|
| 530 | 530 | } |
| 531 | 531 | |
| 532 | 532 | /** |
@@ -538,7 +538,7 @@ discard block |
||
| 538 | 538 | * @param array $log_query |
| 539 | 539 | * @param array $log_meta |
| 540 | 540 | */ |
| 541 | - private function bc_200_validate_params( &$log_query, &$log_meta = array() ) { |
|
| 541 | + private function bc_200_validate_params(&$log_query, &$log_meta = array()) { |
|
| 542 | 542 | $query_params = array( |
| 543 | 543 | 'log_title' => 'post_title', |
| 544 | 544 | 'log_parent' => 'post_parent', |
@@ -550,41 +550,41 @@ discard block |
||
| 550 | 550 | 'meta_query' => 'meta_query', |
| 551 | 551 | ); |
| 552 | 552 | |
| 553 | - if ( ! give_has_upgrade_completed( 'v20_logs_upgrades' ) ) { |
|
| 553 | + if ( ! give_has_upgrade_completed('v20_logs_upgrades')) { |
|
| 554 | 554 | // Set old params. |
| 555 | - foreach ( $query_params as $new_query_param => $old_query_param ) { |
|
| 555 | + foreach ($query_params as $new_query_param => $old_query_param) { |
|
| 556 | 556 | |
| 557 | - if ( isset( $log_query[ $old_query_param ] ) && empty( $log_query[ $new_query_param ] ) ) { |
|
| 558 | - $log_query[ $new_query_param ] = $log_query[ $old_query_param ]; |
|
| 557 | + if (isset($log_query[$old_query_param]) && empty($log_query[$new_query_param])) { |
|
| 558 | + $log_query[$new_query_param] = $log_query[$old_query_param]; |
|
| 559 | 559 | continue; |
| 560 | - } elseif ( ! isset( $log_query[ $new_query_param ] ) ) { |
|
| 560 | + } elseif ( ! isset($log_query[$new_query_param])) { |
|
| 561 | 561 | continue; |
| 562 | - } elseif( empty( $log_query[ $new_query_param ] ) ) { |
|
| 562 | + } elseif (empty($log_query[$new_query_param])) { |
|
| 563 | 563 | continue; |
| 564 | 564 | } |
| 565 | 565 | |
| 566 | - switch ( $new_query_param ) { |
|
| 566 | + switch ($new_query_param) { |
|
| 567 | 567 | case 'log_type': |
| 568 | 568 | $log_query['tax_query'] = array( |
| 569 | 569 | array( |
| 570 | 570 | 'taxonomy' => 'give_log_type', |
| 571 | 571 | 'field' => 'slug', |
| 572 | - 'terms' => $log_query[ $new_query_param ], |
|
| 572 | + 'terms' => $log_query[$new_query_param], |
|
| 573 | 573 | ), |
| 574 | 574 | ); |
| 575 | 575 | break; |
| 576 | 576 | |
| 577 | 577 | case 'meta_query': |
| 578 | - if( ! empty( $log_query['meta_query'] ) && empty( $log_query['post_parent'] ) ) { |
|
| 579 | - foreach ( $log_query['meta_query'] as $index => $meta_query ){ |
|
| 580 | - if( ! is_array( $meta_query ) || empty( $meta_query['key'] ) ) { |
|
| 578 | + if ( ! empty($log_query['meta_query']) && empty($log_query['post_parent'])) { |
|
| 579 | + foreach ($log_query['meta_query'] as $index => $meta_query) { |
|
| 580 | + if ( ! is_array($meta_query) || empty($meta_query['key'])) { |
|
| 581 | 581 | continue; |
| 582 | 582 | } |
| 583 | 583 | |
| 584 | - switch ( $meta_query['key'] ) { |
|
| 584 | + switch ($meta_query['key']) { |
|
| 585 | 585 | case '_give_log_form_id': |
| 586 | 586 | $log_query['post_parent'] = $meta_query['value']; |
| 587 | - unset( $log_query['meta_query'][$index] ); |
|
| 587 | + unset($log_query['meta_query'][$index]); |
|
| 588 | 588 | break; |
| 589 | 589 | } |
| 590 | 590 | } |
@@ -592,40 +592,40 @@ discard block |
||
| 592 | 592 | break; |
| 593 | 593 | |
| 594 | 594 | default: |
| 595 | - switch( $new_query_param ){ |
|
| 595 | + switch ($new_query_param) { |
|
| 596 | 596 | case 'log_parent': |
| 597 | 597 | $log_query['meta_query'][] = array( |
| 598 | 598 | 'key' => '_give_log_payment_id', |
| 599 | - 'value' => $log_query[ $new_query_param ] |
|
| 599 | + 'value' => $log_query[$new_query_param] |
|
| 600 | 600 | ); |
| 601 | 601 | |
| 602 | 602 | break; |
| 603 | 603 | |
| 604 | 604 | default: |
| 605 | - $log_query[ $old_query_param ] = $log_query[ $new_query_param ]; |
|
| 605 | + $log_query[$old_query_param] = $log_query[$new_query_param]; |
|
| 606 | 606 | } |
| 607 | 607 | } |
| 608 | 608 | } |
| 609 | 609 | } else { |
| 610 | 610 | // Set only old params. |
| 611 | - $query_params = array_flip( $query_params ); |
|
| 612 | - foreach ( $query_params as $old_query_param => $new_query_param ) { |
|
| 613 | - if ( isset( $log_query[ $new_query_param ] ) && empty( $log_query[ $old_query_param ] ) ) { |
|
| 614 | - $log_query[ $old_query_param ] = $log_query[ $new_query_param ]; |
|
| 611 | + $query_params = array_flip($query_params); |
|
| 612 | + foreach ($query_params as $old_query_param => $new_query_param) { |
|
| 613 | + if (isset($log_query[$new_query_param]) && empty($log_query[$old_query_param])) { |
|
| 614 | + $log_query[$old_query_param] = $log_query[$new_query_param]; |
|
| 615 | 615 | continue; |
| 616 | - } elseif ( ! isset( $log_query[ $old_query_param ] ) ) { |
|
| 616 | + } elseif ( ! isset($log_query[$old_query_param])) { |
|
| 617 | 617 | continue; |
| 618 | 618 | } |
| 619 | 619 | |
| 620 | - switch ( $old_query_param ) { |
|
| 620 | + switch ($old_query_param) { |
|
| 621 | 621 | case 'tax_query': |
| 622 | - if ( isset( $log_query[ $old_query_param ][0]['terms'] ) ) { |
|
| 623 | - $log_query[ $new_query_param ] = $log_query[ $old_query_param ][0]['terms']; |
|
| 622 | + if (isset($log_query[$old_query_param][0]['terms'])) { |
|
| 623 | + $log_query[$new_query_param] = $log_query[$old_query_param][0]['terms']; |
|
| 624 | 624 | } |
| 625 | 625 | break; |
| 626 | 626 | |
| 627 | 627 | default: |
| 628 | - $log_query[ $new_query_param ] = $log_query[ $old_query_param ]; |
|
| 628 | + $log_query[$new_query_param] = $log_query[$old_query_param]; |
|
| 629 | 629 | } |
| 630 | 630 | } |
| 631 | 631 | } |
@@ -639,8 +639,8 @@ discard block |
||
| 639 | 639 | * |
| 640 | 640 | * @param array $logs |
| 641 | 641 | */ |
| 642 | - private function bc_200_add_new_properties( &$logs ) { |
|
| 643 | - if ( empty( $logs ) ) { |
|
| 642 | + private function bc_200_add_new_properties(&$logs) { |
|
| 643 | + if (empty($logs)) { |
|
| 644 | 644 | return; |
| 645 | 645 | } |
| 646 | 646 | |
@@ -653,30 +653,30 @@ discard block |
||
| 653 | 653 | 'log_type' => 'give_log_type', |
| 654 | 654 | ); |
| 655 | 655 | |
| 656 | - if ( ! give_has_upgrade_completed( 'v20_logs_upgrades' ) ) { |
|
| 657 | - foreach ( $logs as $index => $log ) { |
|
| 658 | - foreach ( $query_params as $new_query_param => $old_query_param ) { |
|
| 659 | - if ( ! property_exists( $log, $old_query_param ) ) { |
|
| 656 | + if ( ! give_has_upgrade_completed('v20_logs_upgrades')) { |
|
| 657 | + foreach ($logs as $index => $log) { |
|
| 658 | + foreach ($query_params as $new_query_param => $old_query_param) { |
|
| 659 | + if ( ! property_exists($log, $old_query_param)) { |
|
| 660 | 660 | /** |
| 661 | 661 | * Set unmatched properties. |
| 662 | 662 | */ |
| 663 | 663 | |
| 664 | 664 | // 1. log_type |
| 665 | - $term = get_the_terms( $log->ID, 'give_log_type' ); |
|
| 666 | - $term = ! is_wp_error( $term ) && ! empty( $term ) ? $term[0] : array(); |
|
| 665 | + $term = get_the_terms($log->ID, 'give_log_type'); |
|
| 666 | + $term = ! is_wp_error($term) && ! empty($term) ? $term[0] : array(); |
|
| 667 | 667 | |
| 668 | - $logs[ $index ]->{$new_query_param} = ! empty( $term ) ? $term->slug : ''; |
|
| 668 | + $logs[$index]->{$new_query_param} = ! empty($term) ? $term->slug : ''; |
|
| 669 | 669 | |
| 670 | 670 | continue; |
| 671 | 671 | } |
| 672 | 672 | |
| 673 | - switch ( $old_query_param ) { |
|
| 673 | + switch ($old_query_param) { |
|
| 674 | 674 | case 'post_parent': |
| 675 | - $logs[ $index ]->{$new_query_param} = give_get_meta( $log->ID, '_give_log_payment_id', true ); |
|
| 675 | + $logs[$index]->{$new_query_param} = give_get_meta($log->ID, '_give_log_payment_id', true); |
|
| 676 | 676 | break; |
| 677 | 677 | |
| 678 | 678 | default: |
| 679 | - $logs[ $index ]->{$new_query_param} = $log->{$old_query_param}; |
|
| 679 | + $logs[$index]->{$new_query_param} = $log->{$old_query_param}; |
|
| 680 | 680 | } |
| 681 | 681 | } |
| 682 | 682 | } |
@@ -696,10 +696,10 @@ discard block |
||
| 696 | 696 | * |
| 697 | 697 | * @return mixed |
| 698 | 698 | */ |
| 699 | - public function bc_200_set_payment_as_log_parent( $check, $log_id, $meta_key, $meta_value ) { |
|
| 699 | + public function bc_200_set_payment_as_log_parent($check, $log_id, $meta_key, $meta_value) { |
|
| 700 | 700 | global $wpdb; |
| 701 | 701 | $update_status = false; |
| 702 | - $post_type = get_post_type( $log_id ); |
|
| 702 | + $post_type = get_post_type($log_id); |
|
| 703 | 703 | |
| 704 | 704 | // Bailout. |
| 705 | 705 | if ( |
@@ -719,9 +719,9 @@ discard block |
||
| 719 | 719 | ) |
| 720 | 720 | ); |
| 721 | 721 | |
| 722 | - if ( $form_id ) { |
|
| 723 | - $this->logmeta_db->delete_meta( $log_id, '_give_log_payment_id' ); |
|
| 724 | - $this->logmeta_db->update_meta( $log_id, '_give_log_form_id', $form_id ); |
|
| 722 | + if ($form_id) { |
|
| 723 | + $this->logmeta_db->delete_meta($log_id, '_give_log_payment_id'); |
|
| 724 | + $this->logmeta_db->update_meta($log_id, '_give_log_form_id', $form_id); |
|
| 725 | 725 | |
| 726 | 726 | $update_status = $wpdb->update( |
| 727 | 727 | $this->log_db->table_name, |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | * |
| 22 | 22 | * @since 1.0 |
| 23 | 23 | * |
| 24 | - * @return string Donation form. |
|
| 24 | + * @return false|null Donation form. |
|
| 25 | 25 | */ |
| 26 | 26 | function give_get_donation_form( $args = array() ) { |
| 27 | 27 | |
@@ -1443,7 +1443,7 @@ discard block |
||
| 1443 | 1443 | * |
| 1444 | 1444 | * @param int $form_id The form ID. |
| 1445 | 1445 | * |
| 1446 | - * @return bool |
|
| 1446 | + * @return false|null |
|
| 1447 | 1447 | */ |
| 1448 | 1448 | function give_terms_agreement( $form_id ) { |
| 1449 | 1449 | $form_option = give_get_meta( $form_id, '_give_terms_option', true ); |
@@ -1621,7 +1621,7 @@ discard block |
||
| 1621 | 1621 | * @param int $form_id The form ID. |
| 1622 | 1622 | * @param array $args An array of form arguments. |
| 1623 | 1623 | * |
| 1624 | - * @return mixed |
|
| 1624 | + * @return boolean |
|
| 1625 | 1625 | */ |
| 1626 | 1626 | function give_show_goal_progress( $form_id, $args ) { |
| 1627 | 1627 | |
@@ -1646,7 +1646,7 @@ discard block |
||
| 1646 | 1646 | * |
| 1647 | 1647 | * @since 1.8 |
| 1648 | 1648 | * |
| 1649 | - * @param $form_id |
|
| 1649 | + * @param integer $form_id |
|
| 1650 | 1650 | * @param $args |
| 1651 | 1651 | * |
| 1652 | 1652 | * @return mixed|string |
@@ -1687,7 +1687,7 @@ discard block |
||
| 1687 | 1687 | * @param int $form_id The form ID. |
| 1688 | 1688 | * @param array $args An array of form arguments. |
| 1689 | 1689 | * |
| 1690 | - * @return void|bool |
|
| 1690 | + * @return false|null |
|
| 1691 | 1691 | */ |
| 1692 | 1692 | function give_form_content( $form_id, $args ) { |
| 1693 | 1693 | |
@@ -928,10 +928,10 @@ discard block |
||
| 928 | 928 | <?php echo( give_field_is_required( 'billing_country', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
| 929 | 929 | > |
| 930 | 930 | <?php |
| 931 | - foreach ( $countries as $country_code => $country ) { |
|
| 932 | - echo '<option value="' . esc_attr( $country_code ) . '"' . selected( $country_code, $selected_country, false ) . '>' . $country . '</option>'; |
|
| 933 | - } |
|
| 934 | - ?> |
|
| 931 | + foreach ( $countries as $country_code => $country ) { |
|
| 932 | + echo '<option value="' . esc_attr( $country_code ) . '"' . selected( $country_code, $selected_country, false ) . '>' . $country . '</option>'; |
|
| 933 | + } |
|
| 934 | + ?> |
|
| 935 | 935 | </select> |
| 936 | 936 | </p> |
| 937 | 937 | |
@@ -1000,7 +1000,7 @@ discard block |
||
| 1000 | 1000 | <label for="card_state" class="give-label"> |
| 1001 | 1001 | <span class="state-label-text"><?php echo $label; ?></span> |
| 1002 | 1002 | <?php if ( give_field_is_required( 'card_state', $form_id ) ) : |
| 1003 | - ?> |
|
| 1003 | + ?> |
|
| 1004 | 1004 | <span class="give-required-indicator <?php echo( array_key_exists( $selected_country, $states_not_required_country_list ) ? 'give-hidden' : '' ) ?> ">*</span> |
| 1005 | 1005 | <?php endif; ?> |
| 1006 | 1006 | <span class="give-tooltip give-icon give-icon-question" |
@@ -1008,17 +1008,17 @@ discard block |
||
| 1008 | 1008 | </label> |
| 1009 | 1009 | <?php |
| 1010 | 1010 | |
| 1011 | - if ( ! empty( $states ) ) : ?> |
|
| 1011 | + if ( ! empty( $states ) ) : ?> |
|
| 1012 | 1012 | <select |
| 1013 | 1013 | name="card_state" |
| 1014 | 1014 | id="card_state" |
| 1015 | 1015 | class="card_state give-select<?php echo( give_field_is_required( 'card_state', $form_id ) ? ' required' : '' ); ?>" |
| 1016 | 1016 | <?php echo( give_field_is_required( 'card_state', $form_id ) ? ' required aria-required="true" ' : '' ); ?>> |
| 1017 | 1017 | <?php |
| 1018 | - foreach ( $states as $state_code => $state ) { |
|
| 1019 | - echo '<option value="' . $state_code . '"' . selected( $state_code, $selected_state, false ) . '>' . $state . '</option>'; |
|
| 1020 | - } |
|
| 1021 | - ?> |
|
| 1018 | + foreach ( $states as $state_code => $state ) { |
|
| 1019 | + echo '<option value="' . $state_code . '"' . selected( $state_code, $selected_state, false ) . '>' . $state . '</option>'; |
|
| 1020 | + } |
|
| 1021 | + ?> |
|
| 1022 | 1022 | </select> |
| 1023 | 1023 | <?php else : ?> |
| 1024 | 1024 | <input type="text" size="6" name="card_state" id="card_state" class="card_state give-input" |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly. |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -23,50 +23,50 @@ discard block |
||
| 23 | 23 | * |
| 24 | 24 | * @return string Donation form. |
| 25 | 25 | */ |
| 26 | -function give_get_donation_form( $args = array() ) { |
|
| 26 | +function give_get_donation_form($args = array()) { |
|
| 27 | 27 | |
| 28 | 28 | global $post; |
| 29 | 29 | |
| 30 | - $form_id = is_object( $post ) ? $post->ID : 0; |
|
| 30 | + $form_id = is_object($post) ? $post->ID : 0; |
|
| 31 | 31 | |
| 32 | - if ( isset( $args['id'] ) ) { |
|
| 32 | + if (isset($args['id'])) { |
|
| 33 | 33 | $form_id = $args['id']; |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - $defaults = apply_filters( 'give_form_args_defaults', array( |
|
| 36 | + $defaults = apply_filters('give_form_args_defaults', array( |
|
| 37 | 37 | 'form_id' => $form_id, |
| 38 | - ) ); |
|
| 38 | + )); |
|
| 39 | 39 | |
| 40 | - $args = wp_parse_args( $args, $defaults ); |
|
| 40 | + $args = wp_parse_args($args, $defaults); |
|
| 41 | 41 | |
| 42 | - $form = new Give_Donate_Form( $args['form_id'] ); |
|
| 42 | + $form = new Give_Donate_Form($args['form_id']); |
|
| 43 | 43 | |
| 44 | 44 | //bail if no form ID. |
| 45 | - if ( empty( $form->ID ) ) { |
|
| 45 | + if (empty($form->ID)) { |
|
| 46 | 46 | return false; |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - $payment_mode = give_get_chosen_gateway( $form->ID ); |
|
| 49 | + $payment_mode = give_get_chosen_gateway($form->ID); |
|
| 50 | 50 | |
| 51 | - $form_action = add_query_arg( apply_filters( 'give_form_action_args', array( |
|
| 51 | + $form_action = add_query_arg(apply_filters('give_form_action_args', array( |
|
| 52 | 52 | 'payment-mode' => $payment_mode, |
| 53 | - ) ), |
|
| 53 | + )), |
|
| 54 | 54 | give_get_current_page_url() |
| 55 | 55 | ); |
| 56 | 56 | |
| 57 | 57 | //Sanity Check: Donation form not published or user doesn't have permission to view drafts. |
| 58 | 58 | if ( |
| 59 | - ( 'publish' !== $form->post_status && ! current_user_can( 'edit_give_forms', $form->ID ) ) |
|
| 60 | - || ( 'trash' === $form->post_status ) |
|
| 59 | + ('publish' !== $form->post_status && ! current_user_can('edit_give_forms', $form->ID)) |
|
| 60 | + || ('trash' === $form->post_status) |
|
| 61 | 61 | ) { |
| 62 | 62 | return false; |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | //Get the form wrap CSS classes. |
| 66 | - $form_wrap_classes = $form->get_form_wrap_classes( $args ); |
|
| 66 | + $form_wrap_classes = $form->get_form_wrap_classes($args); |
|
| 67 | 67 | |
| 68 | 68 | //Get the <form> tag wrap CSS classes. |
| 69 | - $form_classes = $form->get_form_classes( $args ); |
|
| 69 | + $form_classes = $form->get_form_classes($args); |
|
| 70 | 70 | |
| 71 | 71 | ob_start(); |
| 72 | 72 | |
@@ -78,19 +78,19 @@ discard block |
||
| 78 | 78 | * @param int $form_id The form ID. |
| 79 | 79 | * @param array $args An array of form arguments. |
| 80 | 80 | */ |
| 81 | - do_action( 'give_pre_form_output', $form->ID, $args, $form ); |
|
| 81 | + do_action('give_pre_form_output', $form->ID, $args, $form); |
|
| 82 | 82 | |
| 83 | 83 | ?> |
| 84 | 84 | <div id="give-form-<?php echo $form->ID; ?>-wrap" class="<?php echo $form_wrap_classes; ?>"> |
| 85 | 85 | |
| 86 | - <?php if ( $form->is_close_donation_form() ) { |
|
| 86 | + <?php if ($form->is_close_donation_form()) { |
|
| 87 | 87 | |
| 88 | 88 | // Get Goal thank you message. |
| 89 | - $goal_achieved_message = get_post_meta( $form->ID, '_give_form_goal_achieved_message', true ); |
|
| 90 | - $goal_achieved_message = ! empty( $goal_achieved_message ) ? apply_filters( 'the_content', $goal_achieved_message ) : ''; |
|
| 89 | + $goal_achieved_message = get_post_meta($form->ID, '_give_form_goal_achieved_message', true); |
|
| 90 | + $goal_achieved_message = ! empty($goal_achieved_message) ? apply_filters('the_content', $goal_achieved_message) : ''; |
|
| 91 | 91 | |
| 92 | 92 | // Print thank you message. |
| 93 | - echo apply_filters( 'give_goal_closed_output', $goal_achieved_message, $form->ID, $form ); |
|
| 93 | + echo apply_filters('give_goal_closed_output', $goal_achieved_message, $form->ID, $form); |
|
| 94 | 94 | |
| 95 | 95 | } else { |
| 96 | 96 | /** |
@@ -98,13 +98,13 @@ discard block |
||
| 98 | 98 | * 1. if show_title params set to true |
| 99 | 99 | * 2. if admin set form display_style to button |
| 100 | 100 | */ |
| 101 | - $form_title = apply_filters( 'give_form_title', '<h2 class="give-form-title">' . get_the_title( $form_id ) . '</h2>' ); |
|
| 101 | + $form_title = apply_filters('give_form_title', '<h2 class="give-form-title">'.get_the_title($form_id).'</h2>'); |
|
| 102 | 102 | if ( |
| 103 | 103 | ( |
| 104 | - ( isset( $args['show_title'] ) && $args['show_title'] == true ) |
|
| 105 | - || ( 'button' === get_post_meta( $form_id, '_give_payment_display', true ) ) |
|
| 104 | + (isset($args['show_title']) && $args['show_title'] == true) |
|
| 105 | + || ('button' === get_post_meta($form_id, '_give_payment_display', true)) |
|
| 106 | 106 | ) |
| 107 | - && ! doing_action( 'give_single_form_summary' ) |
|
| 107 | + && ! doing_action('give_single_form_summary') |
|
| 108 | 108 | ) { |
| 109 | 109 | echo $form_title; |
| 110 | 110 | } |
@@ -118,13 +118,13 @@ discard block |
||
| 118 | 118 | * @param array $args An array of form arguments. |
| 119 | 119 | * @param Give_Donate_Form $form Form object. |
| 120 | 120 | */ |
| 121 | - do_action( 'give_pre_form', $form->ID, $args, $form ); |
|
| 121 | + do_action('give_pre_form', $form->ID, $args, $form); |
|
| 122 | 122 | |
| 123 | 123 | // Set form html tags. |
| 124 | 124 | $form_html_tags = array( |
| 125 | 125 | 'id' => "give-form-{$form_id}", |
| 126 | 126 | 'class' => $form_classes, |
| 127 | - 'action' => esc_url_raw( $form_action ), |
|
| 127 | + 'action' => esc_url_raw($form_action), |
|
| 128 | 128 | ); |
| 129 | 129 | |
| 130 | 130 | /** |
@@ -135,9 +135,9 @@ discard block |
||
| 135 | 135 | * @param array $form_html_tags Array of form html tags. |
| 136 | 136 | * @param Give_Donate_Form $form Form object. |
| 137 | 137 | */ |
| 138 | - $form_html_tags = apply_filters( 'give_form_html_tags', (array) $form_html_tags, $form ); |
|
| 138 | + $form_html_tags = apply_filters('give_form_html_tags', (array) $form_html_tags, $form); |
|
| 139 | 139 | ?> |
| 140 | - <form <?php echo give_get_attribute_str( $form_html_tags ); ?> method="post"> |
|
| 140 | + <form <?php echo give_get_attribute_str($form_html_tags); ?> method="post"> |
|
| 141 | 141 | |
| 142 | 142 | <!-- The following field is for robots only, invisible to humans: --> |
| 143 | 143 | <span class="give-hidden" style="display: none !important;"> |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | * @param array $args An array of form arguments. |
| 157 | 157 | * @param Give_Donate_Form $form Form object. |
| 158 | 158 | */ |
| 159 | - do_action( 'give_donation_form_top', $form->ID, $args, $form ); |
|
| 159 | + do_action('give_donation_form_top', $form->ID, $args, $form); |
|
| 160 | 160 | |
| 161 | 161 | /** |
| 162 | 162 | * Fires while outputting donation form, for payment gateway fields. |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | * @param array $args An array of form arguments. |
| 168 | 168 | * @param Give_Donate_Form $form Form object. |
| 169 | 169 | */ |
| 170 | - do_action( 'give_payment_mode_select', $form->ID, $args, $form ); |
|
| 170 | + do_action('give_payment_mode_select', $form->ID, $args, $form); |
|
| 171 | 171 | |
| 172 | 172 | /** |
| 173 | 173 | * Fires while outputting donation form, after all other fields. |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | * @param array $args An array of form arguments. |
| 179 | 179 | * @param Give_Donate_Form $form Form object. |
| 180 | 180 | */ |
| 181 | - do_action( 'give_donation_form_bottom', $form->ID, $args, $form ); |
|
| 181 | + do_action('give_donation_form_bottom', $form->ID, $args, $form); |
|
| 182 | 182 | |
| 183 | 183 | ?> |
| 184 | 184 | </form> |
@@ -193,12 +193,12 @@ discard block |
||
| 193 | 193 | * @param array $args An array of form arguments. |
| 194 | 194 | * @param Give_Donate_Form $form Form object. |
| 195 | 195 | */ |
| 196 | - do_action( 'give_post_form', $form->ID, $args, $form ); |
|
| 196 | + do_action('give_post_form', $form->ID, $args, $form); |
|
| 197 | 197 | |
| 198 | 198 | } |
| 199 | 199 | ?> |
| 200 | 200 | |
| 201 | - </div><!--end #give-form-<?php echo absint( $form->ID ); ?>--> |
|
| 201 | + </div><!--end #give-form-<?php echo absint($form->ID); ?>--> |
|
| 202 | 202 | <?php |
| 203 | 203 | |
| 204 | 204 | /** |
@@ -209,11 +209,11 @@ discard block |
||
| 209 | 209 | * @param int $form_id The form ID. |
| 210 | 210 | * @param array $args An array of form arguments. |
| 211 | 211 | */ |
| 212 | - do_action( 'give_post_form_output', $form->ID, $args ); |
|
| 212 | + do_action('give_post_form_output', $form->ID, $args); |
|
| 213 | 213 | |
| 214 | 214 | $final_output = ob_get_clean(); |
| 215 | 215 | |
| 216 | - echo apply_filters( 'give_donate_form', $final_output, $args ); |
|
| 216 | + echo apply_filters('give_donate_form', $final_output, $args); |
|
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | /** |
@@ -230,11 +230,11 @@ discard block |
||
| 230 | 230 | * |
| 231 | 231 | * @return string |
| 232 | 232 | */ |
| 233 | -function give_show_purchase_form( $form_id ) { |
|
| 233 | +function give_show_purchase_form($form_id) { |
|
| 234 | 234 | |
| 235 | - $payment_mode = give_get_chosen_gateway( $form_id ); |
|
| 235 | + $payment_mode = give_get_chosen_gateway($form_id); |
|
| 236 | 236 | |
| 237 | - if ( ! isset( $form_id ) && isset( $_POST['give_form_id'] ) ) { |
|
| 237 | + if ( ! isset($form_id) && isset($_POST['give_form_id'])) { |
|
| 238 | 238 | $form_id = $_POST['give_form_id']; |
| 239 | 239 | } |
| 240 | 240 | |
@@ -243,33 +243,33 @@ discard block |
||
| 243 | 243 | * |
| 244 | 244 | * @since 1.7 |
| 245 | 245 | */ |
| 246 | - do_action( 'give_payment_fields_top', $form_id ); |
|
| 246 | + do_action('give_payment_fields_top', $form_id); |
|
| 247 | 247 | |
| 248 | - if ( give_can_checkout() && isset( $form_id ) ) { |
|
| 248 | + if (give_can_checkout() && isset($form_id)) { |
|
| 249 | 249 | |
| 250 | 250 | /** |
| 251 | 251 | * Fires while displaying donation form, before registration login. |
| 252 | 252 | * |
| 253 | 253 | * @since 1.7 |
| 254 | 254 | */ |
| 255 | - do_action( 'give_donation_form_before_register_login', $form_id ); |
|
| 255 | + do_action('give_donation_form_before_register_login', $form_id); |
|
| 256 | 256 | |
| 257 | 257 | /** |
| 258 | 258 | * Fire when register/login form fields render. |
| 259 | 259 | * |
| 260 | 260 | * @since 1.7 |
| 261 | 261 | */ |
| 262 | - do_action( 'give_donation_form_register_login_fields', $form_id ); |
|
| 262 | + do_action('give_donation_form_register_login_fields', $form_id); |
|
| 263 | 263 | |
| 264 | 264 | /** |
| 265 | 265 | * Fire when credit card form fields render. |
| 266 | 266 | * |
| 267 | 267 | * @since 1.7 |
| 268 | 268 | */ |
| 269 | - do_action( 'give_donation_form_before_cc_form', $form_id ); |
|
| 269 | + do_action('give_donation_form_before_cc_form', $form_id); |
|
| 270 | 270 | |
| 271 | 271 | // Load the credit card form and allow gateways to load their own if they wish. |
| 272 | - if ( has_action( 'give_' . $payment_mode . '_cc_form' ) ) { |
|
| 272 | + if (has_action('give_'.$payment_mode.'_cc_form')) { |
|
| 273 | 273 | /** |
| 274 | 274 | * Fires while displaying donation form, credit card form fields for a given gateway. |
| 275 | 275 | * |
@@ -277,7 +277,7 @@ discard block |
||
| 277 | 277 | * |
| 278 | 278 | * @param int $form_id The form ID. |
| 279 | 279 | */ |
| 280 | - do_action( "give_{$payment_mode}_cc_form", $form_id ); |
|
| 280 | + do_action("give_{$payment_mode}_cc_form", $form_id); |
|
| 281 | 281 | } else { |
| 282 | 282 | /** |
| 283 | 283 | * Fires while displaying donation form, credit card form fields. |
@@ -286,7 +286,7 @@ discard block |
||
| 286 | 286 | * |
| 287 | 287 | * @param int $form_id The form ID. |
| 288 | 288 | */ |
| 289 | - do_action( 'give_cc_form', $form_id ); |
|
| 289 | + do_action('give_cc_form', $form_id); |
|
| 290 | 290 | } |
| 291 | 291 | |
| 292 | 292 | /** |
@@ -294,7 +294,7 @@ discard block |
||
| 294 | 294 | * |
| 295 | 295 | * @since 1.7 |
| 296 | 296 | */ |
| 297 | - do_action( 'give_donation_form_after_cc_form', $form_id ); |
|
| 297 | + do_action('give_donation_form_after_cc_form', $form_id); |
|
| 298 | 298 | |
| 299 | 299 | } else { |
| 300 | 300 | /** |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | * |
| 303 | 303 | * @since 1.7 |
| 304 | 304 | */ |
| 305 | - do_action( 'give_donation_form_no_access', $form_id ); |
|
| 305 | + do_action('give_donation_form_no_access', $form_id); |
|
| 306 | 306 | |
| 307 | 307 | } |
| 308 | 308 | |
@@ -311,10 +311,10 @@ discard block |
||
| 311 | 311 | * |
| 312 | 312 | * @since 1.7 |
| 313 | 313 | */ |
| 314 | - do_action( 'give_payment_fields_bottom', $form_id ); |
|
| 314 | + do_action('give_payment_fields_bottom', $form_id); |
|
| 315 | 315 | } |
| 316 | 316 | |
| 317 | -add_action( 'give_donation_form', 'give_show_purchase_form' ); |
|
| 317 | +add_action('give_donation_form', 'give_show_purchase_form'); |
|
| 318 | 318 | |
| 319 | 319 | /** |
| 320 | 320 | * Give Show Login/Register Form Fields. |
@@ -325,11 +325,11 @@ discard block |
||
| 325 | 325 | * |
| 326 | 326 | * @return void |
| 327 | 327 | */ |
| 328 | -function give_show_register_login_fields( $form_id ) { |
|
| 328 | +function give_show_register_login_fields($form_id) { |
|
| 329 | 329 | |
| 330 | - $show_register_form = give_show_login_register_option( $form_id ); |
|
| 330 | + $show_register_form = give_show_login_register_option($form_id); |
|
| 331 | 331 | |
| 332 | - if ( ( $show_register_form === 'registration' || ( $show_register_form === 'both' && ! isset( $_GET['login'] ) ) ) && ! is_user_logged_in() ) : |
|
| 332 | + if (($show_register_form === 'registration' || ($show_register_form === 'both' && ! isset($_GET['login']))) && ! is_user_logged_in()) : |
|
| 333 | 333 | ?> |
| 334 | 334 | <div id="give-checkout-login-register-<?php echo $form_id; ?>"> |
| 335 | 335 | <?php |
@@ -338,11 +338,11 @@ discard block |
||
| 338 | 338 | * |
| 339 | 339 | * @since 1.7 |
| 340 | 340 | */ |
| 341 | - do_action( 'give_donation_form_register_fields', $form_id ); |
|
| 341 | + do_action('give_donation_form_register_fields', $form_id); |
|
| 342 | 342 | ?> |
| 343 | 343 | </div> |
| 344 | 344 | <?php |
| 345 | - elseif ( ( $show_register_form === 'login' || ( $show_register_form === 'both' && isset( $_GET['login'] ) ) ) && ! is_user_logged_in() ) : |
|
| 345 | + elseif (($show_register_form === 'login' || ($show_register_form === 'both' && isset($_GET['login']))) && ! is_user_logged_in()) : |
|
| 346 | 346 | ?> |
| 347 | 347 | <div id="give-checkout-login-register-<?php echo $form_id; ?>"> |
| 348 | 348 | <?php |
@@ -351,23 +351,23 @@ discard block |
||
| 351 | 351 | * |
| 352 | 352 | * @since 1.7 |
| 353 | 353 | */ |
| 354 | - do_action( 'give_donation_form_login_fields', $form_id ); |
|
| 354 | + do_action('give_donation_form_login_fields', $form_id); |
|
| 355 | 355 | ?> |
| 356 | 356 | </div> |
| 357 | 357 | <?php |
| 358 | 358 | endif; |
| 359 | 359 | |
| 360 | - if ( ( ! isset( $_GET['login'] ) && is_user_logged_in() ) || ! isset( $show_register_form ) || 'none' === $show_register_form || 'login' === $show_register_form ) { |
|
| 360 | + if (( ! isset($_GET['login']) && is_user_logged_in()) || ! isset($show_register_form) || 'none' === $show_register_form || 'login' === $show_register_form) { |
|
| 361 | 361 | /** |
| 362 | 362 | * Fire when user info render. |
| 363 | 363 | * |
| 364 | 364 | * @since 1.7 |
| 365 | 365 | */ |
| 366 | - do_action( 'give_donation_form_after_user_info', $form_id ); |
|
| 366 | + do_action('give_donation_form_after_user_info', $form_id); |
|
| 367 | 367 | } |
| 368 | 368 | } |
| 369 | 369 | |
| 370 | -add_action( 'give_donation_form_register_login_fields', 'give_show_register_login_fields' ); |
|
| 370 | +add_action('give_donation_form_register_login_fields', 'give_show_register_login_fields'); |
|
| 371 | 371 | |
| 372 | 372 | /** |
| 373 | 373 | * Donation Amount Field. |
@@ -382,16 +382,16 @@ discard block |
||
| 382 | 382 | * |
| 383 | 383 | * @return void |
| 384 | 384 | */ |
| 385 | -function give_output_donation_amount_top( $form_id = 0, $args = array() ) { |
|
| 385 | +function give_output_donation_amount_top($form_id = 0, $args = array()) { |
|
| 386 | 386 | |
| 387 | 387 | $give_options = give_get_settings(); |
| 388 | - $variable_pricing = give_has_variable_prices( $form_id ); |
|
| 389 | - $allow_custom_amount = give_get_meta( $form_id, '_give_custom_amount', true ); |
|
| 390 | - $currency_position = isset( $give_options['currency_position'] ) ? $give_options['currency_position'] : 'before'; |
|
| 391 | - $symbol = give_currency_symbol( give_get_currency( $form_id, $args ) ); |
|
| 392 | - $currency_output = '<span class="give-currency-symbol give-currency-position-' . $currency_position . '">' . $symbol . '</span>'; |
|
| 393 | - $default_amount = give_format_amount( give_get_default_form_amount( $form_id ), array( 'sanitize' => false, 'currency' => give_get_currency( $form_id ) ) ); |
|
| 394 | - $custom_amount_text = give_get_meta( $form_id, '_give_custom_amount_text', true ); |
|
| 388 | + $variable_pricing = give_has_variable_prices($form_id); |
|
| 389 | + $allow_custom_amount = give_get_meta($form_id, '_give_custom_amount', true); |
|
| 390 | + $currency_position = isset($give_options['currency_position']) ? $give_options['currency_position'] : 'before'; |
|
| 391 | + $symbol = give_currency_symbol(give_get_currency($form_id, $args)); |
|
| 392 | + $currency_output = '<span class="give-currency-symbol give-currency-position-'.$currency_position.'">'.$symbol.'</span>'; |
|
| 393 | + $default_amount = give_format_amount(give_get_default_form_amount($form_id), array('sanitize' => false, 'currency' => give_get_currency($form_id))); |
|
| 394 | + $custom_amount_text = give_get_meta($form_id, '_give_custom_amount_text', true); |
|
| 395 | 395 | |
| 396 | 396 | /** |
| 397 | 397 | * Fires while displaying donation form, before donation level fields. |
@@ -401,20 +401,20 @@ discard block |
||
| 401 | 401 | * @param int $form_id The form ID. |
| 402 | 402 | * @param array $args An array of form arguments. |
| 403 | 403 | */ |
| 404 | - do_action( 'give_before_donation_levels', $form_id, $args ); |
|
| 404 | + do_action('give_before_donation_levels', $form_id, $args); |
|
| 405 | 405 | |
| 406 | 406 | //Set Price, No Custom Amount Allowed means hidden price field |
| 407 | - if ( ! give_is_setting_enabled( $allow_custom_amount ) ) { |
|
| 407 | + if ( ! give_is_setting_enabled($allow_custom_amount)) { |
|
| 408 | 408 | ?> |
| 409 | - <label class="give-hidden" for="give-amount-hidden"><?php esc_html_e( 'Donation Amount:', 'give' ); ?></label> |
|
| 409 | + <label class="give-hidden" for="give-amount-hidden"><?php esc_html_e('Donation Amount:', 'give'); ?></label> |
|
| 410 | 410 | <input id="give-amount" class="give-amount-hidden" type="hidden" name="give-amount" |
| 411 | 411 | value="<?php echo $default_amount; ?>" required aria-required="true"/> |
| 412 | 412 | <div class="set-price give-donation-amount form-row-wide"> |
| 413 | - <?php if ( $currency_position == 'before' ) { |
|
| 413 | + <?php if ($currency_position == 'before') { |
|
| 414 | 414 | echo $currency_output; |
| 415 | 415 | } ?> |
| 416 | 416 | <span id="give-amount-text" class="give-text-input give-amount-top"><?php echo $default_amount; ?></span> |
| 417 | - <?php if ( $currency_position == 'after' ) { |
|
| 417 | + <?php if ($currency_position == 'after') { |
|
| 418 | 418 | echo $currency_output; |
| 419 | 419 | } ?> |
| 420 | 420 | </div> |
@@ -424,13 +424,13 @@ discard block |
||
| 424 | 424 | ?> |
| 425 | 425 | <div class="give-total-wrap"> |
| 426 | 426 | <div class="give-donation-amount form-row-wide"> |
| 427 | - <?php if ( $currency_position == 'before' ) { |
|
| 427 | + <?php if ($currency_position == 'before') { |
|
| 428 | 428 | echo $currency_output; |
| 429 | 429 | } ?> |
| 430 | - <label class="give-hidden" for="give-amount"><?php esc_html_e( 'Donation Amount:', 'give' ); ?></label> |
|
| 430 | + <label class="give-hidden" for="give-amount"><?php esc_html_e('Donation Amount:', 'give'); ?></label> |
|
| 431 | 431 | <input class="give-text-input give-amount-top" id="give-amount" name="give-amount" type="tel" |
| 432 | 432 | placeholder="" value="<?php echo $default_amount; ?>" autocomplete="off"> |
| 433 | - <?php if ( $currency_position == 'after' ) { |
|
| 433 | + <?php if ($currency_position == 'after') { |
|
| 434 | 434 | echo $currency_output; |
| 435 | 435 | } ?> |
| 436 | 436 | </div> |
@@ -445,16 +445,16 @@ discard block |
||
| 445 | 445 | * @param int $form_id The form ID. |
| 446 | 446 | * @param array $args An array of form arguments. |
| 447 | 447 | */ |
| 448 | - do_action( 'give_after_donation_amount', $form_id, $args ); |
|
| 448 | + do_action('give_after_donation_amount', $form_id, $args); |
|
| 449 | 449 | |
| 450 | 450 | //Custom Amount Text |
| 451 | - if ( ! $variable_pricing && give_is_setting_enabled( $allow_custom_amount ) && ! empty( $custom_amount_text ) ) { ?> |
|
| 451 | + if ( ! $variable_pricing && give_is_setting_enabled($allow_custom_amount) && ! empty($custom_amount_text)) { ?> |
|
| 452 | 452 | <p class="give-custom-amount-text"><?php echo $custom_amount_text; ?></p> |
| 453 | 453 | <?php } |
| 454 | 454 | |
| 455 | 455 | //Output Variable Pricing Levels. |
| 456 | - if ( $variable_pricing ) { |
|
| 457 | - give_output_levels( $form_id ); |
|
| 456 | + if ($variable_pricing) { |
|
| 457 | + give_output_levels($form_id); |
|
| 458 | 458 | } |
| 459 | 459 | |
| 460 | 460 | /** |
@@ -465,10 +465,10 @@ discard block |
||
| 465 | 465 | * @param int $form_id The form ID. |
| 466 | 466 | * @param array $args An array of form arguments. |
| 467 | 467 | */ |
| 468 | - do_action( 'give_after_donation_levels', $form_id, $args ); |
|
| 468 | + do_action('give_after_donation_levels', $form_id, $args); |
|
| 469 | 469 | } |
| 470 | 470 | |
| 471 | -add_action( 'give_donation_form_top', 'give_output_donation_amount_top', 10, 2 ); |
|
| 471 | +add_action('give_donation_form_top', 'give_output_donation_amount_top', 10, 2); |
|
| 472 | 472 | |
| 473 | 473 | /** |
| 474 | 474 | * Outputs the Donation Levels in various formats such as dropdown, radios, and buttons. |
@@ -479,30 +479,30 @@ discard block |
||
| 479 | 479 | * |
| 480 | 480 | * @return string Donation levels. |
| 481 | 481 | */ |
| 482 | -function give_output_levels( $form_id ) { |
|
| 482 | +function give_output_levels($form_id) { |
|
| 483 | 483 | |
| 484 | 484 | //Get variable pricing. |
| 485 | - $prices = apply_filters( 'give_form_variable_prices', give_get_variable_prices( $form_id ), $form_id ); |
|
| 486 | - $display_style = give_get_meta( $form_id, '_give_display_style', true ); |
|
| 487 | - $custom_amount = give_get_meta( $form_id, '_give_custom_amount', true ); |
|
| 488 | - $custom_amount_text = give_get_meta( $form_id, '_give_custom_amount_text', true ); |
|
| 489 | - if ( empty( $custom_amount_text ) ) { |
|
| 490 | - $custom_amount_text = esc_html__( 'Give a Custom Amount', 'give' ); |
|
| 485 | + $prices = apply_filters('give_form_variable_prices', give_get_variable_prices($form_id), $form_id); |
|
| 486 | + $display_style = give_get_meta($form_id, '_give_display_style', true); |
|
| 487 | + $custom_amount = give_get_meta($form_id, '_give_custom_amount', true); |
|
| 488 | + $custom_amount_text = give_get_meta($form_id, '_give_custom_amount_text', true); |
|
| 489 | + if (empty($custom_amount_text)) { |
|
| 490 | + $custom_amount_text = esc_html__('Give a Custom Amount', 'give'); |
|
| 491 | 491 | } |
| 492 | 492 | |
| 493 | 493 | $output = ''; |
| 494 | 494 | |
| 495 | - switch ( $display_style ) { |
|
| 495 | + switch ($display_style) { |
|
| 496 | 496 | case 'buttons': |
| 497 | 497 | |
| 498 | 498 | $output .= '<ul id="give-donation-level-button-wrap" class="give-donation-levels-wrap give-list-inline">'; |
| 499 | 499 | |
| 500 | - foreach ( $prices as $price ) { |
|
| 501 | - $level_text = apply_filters( 'give_form_level_text', ! empty( $price['_give_text'] ) ? $price['_give_text'] : give_currency_filter( give_format_amount( $price['_give_amount'], array( 'sanitize' => false ) ) ), $form_id, $price ); |
|
| 502 | - $level_classes = apply_filters( 'give_form_level_classes', 'give-donation-level-btn give-btn give-btn-level-' . $price['_give_id']['level_id'] . ' ' . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? 'give-default-level' : '' ), $form_id, $price ); |
|
| 500 | + foreach ($prices as $price) { |
|
| 501 | + $level_text = apply_filters('give_form_level_text', ! empty($price['_give_text']) ? $price['_give_text'] : give_currency_filter(give_format_amount($price['_give_amount'], array('sanitize' => false))), $form_id, $price); |
|
| 502 | + $level_classes = apply_filters('give_form_level_classes', 'give-donation-level-btn give-btn give-btn-level-'.$price['_give_id']['level_id'].' '.((isset($price['_give_default']) && $price['_give_default'] === 'default') ? 'give-default-level' : ''), $form_id, $price); |
|
| 503 | 503 | |
| 504 | 504 | $output .= '<li>'; |
| 505 | - $output .= '<button type="button" data-price-id="' . $price['_give_id']['level_id'] . '" class=" ' . $level_classes . '" value="' . give_format_amount( $price['_give_amount'], array( 'sanitize' => false ) ) . '">'; |
|
| 505 | + $output .= '<button type="button" data-price-id="'.$price['_give_id']['level_id'].'" class=" '.$level_classes.'" value="'.give_format_amount($price['_give_amount'], array('sanitize' => false)).'">'; |
|
| 506 | 506 | $output .= $level_text; |
| 507 | 507 | $output .= '</button>'; |
| 508 | 508 | $output .= '</li>'; |
@@ -510,7 +510,7 @@ discard block |
||
| 510 | 510 | } |
| 511 | 511 | |
| 512 | 512 | //Custom Amount. |
| 513 | - if ( give_is_setting_enabled( $custom_amount ) && ! empty( $custom_amount_text ) ) { |
|
| 513 | + if (give_is_setting_enabled($custom_amount) && ! empty($custom_amount_text)) { |
|
| 514 | 514 | $output .= '<li>'; |
| 515 | 515 | $output .= '<button type="button" data-price-id="custom" class="give-donation-level-btn give-btn give-btn-level-custom" value="custom">'; |
| 516 | 516 | $output .= $custom_amount_text; |
@@ -526,22 +526,22 @@ discard block |
||
| 526 | 526 | |
| 527 | 527 | $output .= '<ul id="give-donation-level-radio-list" class="give-donation-levels-wrap">'; |
| 528 | 528 | |
| 529 | - foreach ( $prices as $price ) { |
|
| 530 | - $level_text = apply_filters( 'give_form_level_text', ! empty( $price['_give_text'] ) ? $price['_give_text'] : give_currency_filter( give_format_amount( $price['_give_amount'], array( 'sanitize' => false ) ) ), $form_id, $price ); |
|
| 531 | - $level_classes = apply_filters( 'give_form_level_classes', 'give-radio-input give-radio-input-level give-radio-level-' . $price['_give_id']['level_id'] . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? ' give-default-level' : '' ), $form_id, $price ); |
|
| 529 | + foreach ($prices as $price) { |
|
| 530 | + $level_text = apply_filters('give_form_level_text', ! empty($price['_give_text']) ? $price['_give_text'] : give_currency_filter(give_format_amount($price['_give_amount'], array('sanitize' => false))), $form_id, $price); |
|
| 531 | + $level_classes = apply_filters('give_form_level_classes', 'give-radio-input give-radio-input-level give-radio-level-'.$price['_give_id']['level_id'].((isset($price['_give_default']) && $price['_give_default'] === 'default') ? ' give-default-level' : ''), $form_id, $price); |
|
| 532 | 532 | |
| 533 | 533 | $output .= '<li>'; |
| 534 | - $output .= '<input type="radio" data-price-id="' . $price['_give_id']['level_id'] . '" class="' . $level_classes . '" name="give-radio-donation-level" id="give-radio-level-' . $price['_give_id']['level_id'] . '" ' . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? 'checked="checked"' : '' ) . ' value="' . give_format_amount( $price['_give_amount'], array( 'sanitize' => false ) ) . '">'; |
|
| 535 | - $output .= '<label for="give-radio-level-' . $price['_give_id']['level_id'] . '">' . $level_text . '</label>'; |
|
| 534 | + $output .= '<input type="radio" data-price-id="'.$price['_give_id']['level_id'].'" class="'.$level_classes.'" name="give-radio-donation-level" id="give-radio-level-'.$price['_give_id']['level_id'].'" '.((isset($price['_give_default']) && $price['_give_default'] === 'default') ? 'checked="checked"' : '').' value="'.give_format_amount($price['_give_amount'], array('sanitize' => false)).'">'; |
|
| 535 | + $output .= '<label for="give-radio-level-'.$price['_give_id']['level_id'].'">'.$level_text.'</label>'; |
|
| 536 | 536 | $output .= '</li>'; |
| 537 | 537 | |
| 538 | 538 | } |
| 539 | 539 | |
| 540 | 540 | //Custom Amount. |
| 541 | - if ( give_is_setting_enabled( $custom_amount ) && ! empty( $custom_amount_text ) ) { |
|
| 541 | + if (give_is_setting_enabled($custom_amount) && ! empty($custom_amount_text)) { |
|
| 542 | 542 | $output .= '<li>'; |
| 543 | 543 | $output .= '<input type="radio" data-price-id="custom" class="give-radio-input give-radio-input-level give-radio-level-custom" name="give-radio-donation-level" id="give-radio-level-custom" value="custom">'; |
| 544 | - $output .= '<label for="give-radio-level-custom">' . $custom_amount_text . '</label>'; |
|
| 544 | + $output .= '<label for="give-radio-level-custom">'.$custom_amount_text.'</label>'; |
|
| 545 | 545 | $output .= '</li>'; |
| 546 | 546 | } |
| 547 | 547 | |
@@ -551,23 +551,23 @@ discard block |
||
| 551 | 551 | |
| 552 | 552 | case 'dropdown': |
| 553 | 553 | |
| 554 | - $output .= '<label for="give-donation-level-select-' . $form_id . '" class="give-hidden">' . esc_html__( 'Choose Your Donation Amount', 'give' ) . ':</label>'; |
|
| 555 | - $output .= '<select id="give-donation-level-select-' . $form_id . '" class="give-select give-select-level give-donation-levels-wrap">'; |
|
| 554 | + $output .= '<label for="give-donation-level-select-'.$form_id.'" class="give-hidden">'.esc_html__('Choose Your Donation Amount', 'give').':</label>'; |
|
| 555 | + $output .= '<select id="give-donation-level-select-'.$form_id.'" class="give-select give-select-level give-donation-levels-wrap">'; |
|
| 556 | 556 | |
| 557 | 557 | //first loop through prices. |
| 558 | - foreach ( $prices as $price ) { |
|
| 559 | - $level_text = apply_filters( 'give_form_level_text', ! empty( $price['_give_text'] ) ? $price['_give_text'] : give_currency_filter( give_format_amount( $price['_give_amount'], array( 'sanitize' => false ) ) ), $form_id, $price ); |
|
| 560 | - $level_classes = apply_filters( 'give_form_level_classes', 'give-donation-level-' . $price['_give_id']['level_id'] . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? ' give-default-level' : '' ), $form_id, $price ); |
|
| 558 | + foreach ($prices as $price) { |
|
| 559 | + $level_text = apply_filters('give_form_level_text', ! empty($price['_give_text']) ? $price['_give_text'] : give_currency_filter(give_format_amount($price['_give_amount'], array('sanitize' => false))), $form_id, $price); |
|
| 560 | + $level_classes = apply_filters('give_form_level_classes', 'give-donation-level-'.$price['_give_id']['level_id'].((isset($price['_give_default']) && $price['_give_default'] === 'default') ? ' give-default-level' : ''), $form_id, $price); |
|
| 561 | 561 | |
| 562 | - $output .= '<option data-price-id="' . $price['_give_id']['level_id'] . '" class="' . $level_classes . '" ' . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? 'selected="selected"' : '' ) . ' value="' . give_format_amount( $price['_give_amount'], array( 'sanitize' => false ) ) . '">'; |
|
| 562 | + $output .= '<option data-price-id="'.$price['_give_id']['level_id'].'" class="'.$level_classes.'" '.((isset($price['_give_default']) && $price['_give_default'] === 'default') ? 'selected="selected"' : '').' value="'.give_format_amount($price['_give_amount'], array('sanitize' => false)).'">'; |
|
| 563 | 563 | $output .= $level_text; |
| 564 | 564 | $output .= '</option>'; |
| 565 | 565 | |
| 566 | 566 | } |
| 567 | 567 | |
| 568 | 568 | //Custom Amount. |
| 569 | - if ( give_is_setting_enabled( $custom_amount ) && ! empty( $custom_amount_text ) ) { |
|
| 570 | - $output .= '<option data-price-id="custom" class="give-donation-level-custom" value="custom">' . $custom_amount_text . '</option>'; |
|
| 569 | + if (give_is_setting_enabled($custom_amount) && ! empty($custom_amount_text)) { |
|
| 570 | + $output .= '<option data-price-id="custom" class="give-donation-level-custom" value="custom">'.$custom_amount_text.'</option>'; |
|
| 571 | 571 | } |
| 572 | 572 | |
| 573 | 573 | $output .= '</select>'; |
@@ -575,7 +575,7 @@ discard block |
||
| 575 | 575 | break; |
| 576 | 576 | } |
| 577 | 577 | |
| 578 | - echo apply_filters( 'give_form_level_output', $output, $form_id ); |
|
| 578 | + echo apply_filters('give_form_level_output', $output, $form_id); |
|
| 579 | 579 | } |
| 580 | 580 | |
| 581 | 581 | /** |
@@ -590,27 +590,27 @@ discard block |
||
| 590 | 590 | * |
| 591 | 591 | * @return string Checkout button. |
| 592 | 592 | */ |
| 593 | -function give_display_checkout_button( $form_id, $args ) { |
|
| 593 | +function give_display_checkout_button($form_id, $args) { |
|
| 594 | 594 | |
| 595 | - $display_option = ( isset( $args['display_style'] ) && ! empty( $args['display_style'] ) ) |
|
| 595 | + $display_option = (isset($args['display_style']) && ! empty($args['display_style'])) |
|
| 596 | 596 | ? $args['display_style'] |
| 597 | - : give_get_meta( $form_id, '_give_payment_display', true ); |
|
| 597 | + : give_get_meta($form_id, '_give_payment_display', true); |
|
| 598 | 598 | |
| 599 | - if ( 'button' === $display_option ) { |
|
| 599 | + if ('button' === $display_option) { |
|
| 600 | 600 | $display_option = 'modal'; |
| 601 | - } elseif ( $display_option === 'onpage' ) { |
|
| 601 | + } elseif ($display_option === 'onpage') { |
|
| 602 | 602 | return ''; |
| 603 | 603 | } |
| 604 | 604 | |
| 605 | - $display_label_field = give_get_meta( $form_id, '_give_reveal_label', true ); |
|
| 606 | - $display_label = ! empty( $args['continue_button_title'] ) ? $args['continue_button_title'] : ( ! empty( $display_label_field ) ? $display_label_field : esc_html__( 'Donate Now', 'give' ) ); |
|
| 605 | + $display_label_field = give_get_meta($form_id, '_give_reveal_label', true); |
|
| 606 | + $display_label = ! empty($args['continue_button_title']) ? $args['continue_button_title'] : ( ! empty($display_label_field) ? $display_label_field : esc_html__('Donate Now', 'give')); |
|
| 607 | 607 | |
| 608 | - $output = '<button type="button" class="give-btn give-btn-' . $display_option . '">' . $display_label . '</button>'; |
|
| 608 | + $output = '<button type="button" class="give-btn give-btn-'.$display_option.'">'.$display_label.'</button>'; |
|
| 609 | 609 | |
| 610 | - echo apply_filters( 'give_display_checkout_button', $output ); |
|
| 610 | + echo apply_filters('give_display_checkout_button', $output); |
|
| 611 | 611 | } |
| 612 | 612 | |
| 613 | -add_action( 'give_after_donation_levels', 'give_display_checkout_button', 10, 2 ); |
|
| 613 | +add_action('give_after_donation_levels', 'give_display_checkout_button', 10, 2); |
|
| 614 | 614 | |
| 615 | 615 | /** |
| 616 | 616 | * Shows the User Info fields in the Personal Info box, more fields can be added via the hooks provided. |
@@ -623,55 +623,55 @@ discard block |
||
| 623 | 623 | * |
| 624 | 624 | * @return void |
| 625 | 625 | */ |
| 626 | -function give_user_info_fields( $form_id ) { |
|
| 626 | +function give_user_info_fields($form_id) { |
|
| 627 | 627 | // Get user info. |
| 628 | - $give_user_info = _give_get_prefill_form_field_values( $form_id ); |
|
| 628 | + $give_user_info = _give_get_prefill_form_field_values($form_id); |
|
| 629 | 629 | |
| 630 | 630 | /** |
| 631 | 631 | * Fire before user personal information fields |
| 632 | 632 | * |
| 633 | 633 | * @since 1.7 |
| 634 | 634 | */ |
| 635 | - do_action( 'give_donation_form_before_personal_info', $form_id ); |
|
| 635 | + do_action('give_donation_form_before_personal_info', $form_id); |
|
| 636 | 636 | ?> |
| 637 | 637 | <fieldset id="give_checkout_user_info"> |
| 638 | - <legend><?php echo apply_filters( 'give_checkout_personal_info_text', __( 'Personal Info', 'give' ) ); ?></legend> |
|
| 638 | + <legend><?php echo apply_filters('give_checkout_personal_info_text', __('Personal Info', 'give')); ?></legend> |
|
| 639 | 639 | <p id="give-first-name-wrap" class="form-row form-row-first form-row-responsive"> |
| 640 | 640 | <label class="give-label" for="give-first"> |
| 641 | - <?php _e( 'First Name', 'give' ); ?> |
|
| 642 | - <?php if ( give_field_is_required( 'give_first', $form_id ) ) : ?> |
|
| 641 | + <?php _e('First Name', 'give'); ?> |
|
| 642 | + <?php if (give_field_is_required('give_first', $form_id)) : ?> |
|
| 643 | 643 | <span class="give-required-indicator">*</span> |
| 644 | 644 | <?php endif ?> |
| 645 | - <?php echo Give()->tooltips->render_help( __( 'We will use this to personalize your account experience.', 'give' ) ); ?> |
|
| 645 | + <?php echo Give()->tooltips->render_help(__('We will use this to personalize your account experience.', 'give')); ?> |
|
| 646 | 646 | </label> |
| 647 | 647 | <input |
| 648 | 648 | class="give-input required" |
| 649 | 649 | type="text" |
| 650 | 650 | name="give_first" |
| 651 | - placeholder="<?php _e( 'First Name', 'give' ); ?>" |
|
| 651 | + placeholder="<?php _e('First Name', 'give'); ?>" |
|
| 652 | 652 | id="give-first" |
| 653 | - value="<?php echo isset( $give_user_info['give_first'] ) ? $give_user_info['give_first'] : ''; ?>" |
|
| 654 | - <?php echo( give_field_is_required( 'give_first', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
| 653 | + value="<?php echo isset($give_user_info['give_first']) ? $give_user_info['give_first'] : ''; ?>" |
|
| 654 | + <?php echo(give_field_is_required('give_first', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
| 655 | 655 | /> |
| 656 | 656 | </p> |
| 657 | 657 | |
| 658 | 658 | <p id="give-last-name-wrap" class="form-row form-row-last form-row-responsive"> |
| 659 | 659 | <label class="give-label" for="give-last"> |
| 660 | - <?php _e( 'Last Name', 'give' ); ?> |
|
| 661 | - <?php if ( give_field_is_required( 'give_last', $form_id ) ) : ?> |
|
| 660 | + <?php _e('Last Name', 'give'); ?> |
|
| 661 | + <?php if (give_field_is_required('give_last', $form_id)) : ?> |
|
| 662 | 662 | <span class="give-required-indicator">*</span> |
| 663 | 663 | <?php endif ?> |
| 664 | - <?php echo Give()->tooltips->render_help( __( 'We will use this as well to personalize your account experience.', 'give' ) ); ?> |
|
| 664 | + <?php echo Give()->tooltips->render_help(__('We will use this as well to personalize your account experience.', 'give')); ?> |
|
| 665 | 665 | </label> |
| 666 | 666 | |
| 667 | 667 | <input |
| 668 | - class="give-input<?php echo( give_field_is_required( 'give_last', $form_id ) ? ' required' : '' ); ?>" |
|
| 668 | + class="give-input<?php echo(give_field_is_required('give_last', $form_id) ? ' required' : ''); ?>" |
|
| 669 | 669 | type="text" |
| 670 | 670 | name="give_last" |
| 671 | 671 | id="give-last" |
| 672 | - placeholder="<?php _e( 'Last Name', 'give' ); ?>" |
|
| 673 | - value="<?php echo isset( $give_user_info['give_last'] ) ? $give_user_info['give_last'] : ''; ?>" |
|
| 674 | - <?php echo( give_field_is_required( 'give_last', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
| 672 | + placeholder="<?php _e('Last Name', 'give'); ?>" |
|
| 673 | + value="<?php echo isset($give_user_info['give_last']) ? $give_user_info['give_last'] : ''; ?>" |
|
| 674 | + <?php echo(give_field_is_required('give_last', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
| 675 | 675 | /> |
| 676 | 676 | </p> |
| 677 | 677 | |
@@ -681,25 +681,25 @@ discard block |
||
| 681 | 681 | * |
| 682 | 682 | * @since 1.7 |
| 683 | 683 | */ |
| 684 | - do_action( 'give_donation_form_before_email', $form_id ); |
|
| 684 | + do_action('give_donation_form_before_email', $form_id); |
|
| 685 | 685 | ?> |
| 686 | 686 | <p id="give-email-wrap" class="form-row form-row-wide"> |
| 687 | 687 | <label class="give-label" for="give-email"> |
| 688 | - <?php _e( 'Email Address', 'give' ); ?> |
|
| 689 | - <?php if ( give_field_is_required( 'give_email', $form_id ) ) { ?> |
|
| 688 | + <?php _e('Email Address', 'give'); ?> |
|
| 689 | + <?php if (give_field_is_required('give_email', $form_id)) { ?> |
|
| 690 | 690 | <span class="give-required-indicator">*</span> |
| 691 | 691 | <?php } ?> |
| 692 | - <?php echo Give()->tooltips->render_help( __( 'We will send the donation receipt to this address.', 'give' ) ); ?> |
|
| 692 | + <?php echo Give()->tooltips->render_help(__('We will send the donation receipt to this address.', 'give')); ?> |
|
| 693 | 693 | </label> |
| 694 | 694 | |
| 695 | 695 | <input |
| 696 | 696 | class="give-input required" |
| 697 | 697 | type="email" |
| 698 | 698 | name="give_email" |
| 699 | - placeholder="<?php _e( 'Email Address', 'give' ); ?>" |
|
| 699 | + placeholder="<?php _e('Email Address', 'give'); ?>" |
|
| 700 | 700 | id="give-email" |
| 701 | - value="<?php echo isset( $give_user_info['give_email'] ) ? $give_user_info['give_email'] : ''; ?>" |
|
| 702 | - <?php echo( give_field_is_required( 'give_email', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
| 701 | + value="<?php echo isset($give_user_info['give_email']) ? $give_user_info['give_email'] : ''; ?>" |
|
| 702 | + <?php echo(give_field_is_required('give_email', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
| 703 | 703 | /> |
| 704 | 704 | |
| 705 | 705 | </p> |
@@ -709,14 +709,14 @@ discard block |
||
| 709 | 709 | * |
| 710 | 710 | * @since 1.7 |
| 711 | 711 | */ |
| 712 | - do_action( 'give_donation_form_after_email', $form_id ); |
|
| 712 | + do_action('give_donation_form_after_email', $form_id); |
|
| 713 | 713 | |
| 714 | 714 | /** |
| 715 | 715 | * Fire after personal email field |
| 716 | 716 | * |
| 717 | 717 | * @since 1.7 |
| 718 | 718 | */ |
| 719 | - do_action( 'give_donation_form_user_info', $form_id ); |
|
| 719 | + do_action('give_donation_form_user_info', $form_id); |
|
| 720 | 720 | ?> |
| 721 | 721 | </fieldset> |
| 722 | 722 | <?php |
@@ -725,11 +725,11 @@ discard block |
||
| 725 | 725 | * |
| 726 | 726 | * @since 1.7 |
| 727 | 727 | */ |
| 728 | - do_action( 'give_donation_form_after_personal_info', $form_id ); |
|
| 728 | + do_action('give_donation_form_after_personal_info', $form_id); |
|
| 729 | 729 | } |
| 730 | 730 | |
| 731 | -add_action( 'give_donation_form_after_user_info', 'give_user_info_fields' ); |
|
| 732 | -add_action( 'give_register_fields_before', 'give_user_info_fields' ); |
|
| 731 | +add_action('give_donation_form_after_user_info', 'give_user_info_fields'); |
|
| 732 | +add_action('give_register_fields_before', 'give_user_info_fields'); |
|
| 733 | 733 | |
| 734 | 734 | /** |
| 735 | 735 | * Renders the credit card info form. |
@@ -740,7 +740,7 @@ discard block |
||
| 740 | 740 | * |
| 741 | 741 | * @return void |
| 742 | 742 | */ |
| 743 | -function give_get_cc_form( $form_id ) { |
|
| 743 | +function give_get_cc_form($form_id) { |
|
| 744 | 744 | |
| 745 | 745 | ob_start(); |
| 746 | 746 | |
@@ -751,50 +751,50 @@ discard block |
||
| 751 | 751 | * |
| 752 | 752 | * @param int $form_id The form ID. |
| 753 | 753 | */ |
| 754 | - do_action( 'give_before_cc_fields', $form_id ); |
|
| 754 | + do_action('give_before_cc_fields', $form_id); |
|
| 755 | 755 | ?> |
| 756 | 756 | <fieldset id="give_cc_fields-<?php echo $form_id ?>" class="give-do-validate"> |
| 757 | - <legend><?php echo apply_filters( 'give_credit_card_fieldset_heading', esc_html__( 'Credit Card Info', 'give' ) ); ?></legend> |
|
| 758 | - <?php if ( is_ssl() ) : ?> |
|
| 757 | + <legend><?php echo apply_filters('give_credit_card_fieldset_heading', esc_html__('Credit Card Info', 'give')); ?></legend> |
|
| 758 | + <?php if (is_ssl()) : ?> |
|
| 759 | 759 | <div id="give_secure_site_wrapper-<?php echo $form_id ?>"> |
| 760 | 760 | <span class="give-icon padlock"></span> |
| 761 | - <span><?php _e( 'This is a secure SSL encrypted payment.', 'give' ); ?></span> |
|
| 761 | + <span><?php _e('This is a secure SSL encrypted payment.', 'give'); ?></span> |
|
| 762 | 762 | </div> |
| 763 | 763 | <?php endif; ?> |
| 764 | 764 | <p id="give-card-number-wrap-<?php echo $form_id ?>" class="form-row form-row-two-thirds form-row-responsive"> |
| 765 | 765 | <label for="card_number-<?php echo $form_id ?>" class="give-label"> |
| 766 | - <?php _e( 'Card Number', 'give' ); ?> |
|
| 766 | + <?php _e('Card Number', 'give'); ?> |
|
| 767 | 767 | <span class="give-required-indicator">*</span> |
| 768 | - <?php echo Give()->tooltips->render_help( __( 'The (typically) 16 digits on the front of your credit card.', 'give' ) ); ?> |
|
| 768 | + <?php echo Give()->tooltips->render_help(__('The (typically) 16 digits on the front of your credit card.', 'give')); ?> |
|
| 769 | 769 | <span class="card-type"></span> |
| 770 | 770 | </label> |
| 771 | 771 | |
| 772 | 772 | <input type="tel" autocomplete="off" name="card_number" id="card_number-<?php echo $form_id ?>" |
| 773 | - class="card-number give-input required" placeholder="<?php _e( 'Card number', 'give' ); ?>" |
|
| 773 | + class="card-number give-input required" placeholder="<?php _e('Card number', 'give'); ?>" |
|
| 774 | 774 | required aria-required="true"/> |
| 775 | 775 | </p> |
| 776 | 776 | |
| 777 | 777 | <p id="give-card-cvc-wrap-<?php echo $form_id ?>" class="form-row form-row-one-third form-row-responsive"> |
| 778 | 778 | <label for="card_cvc-<?php echo $form_id ?>" class="give-label"> |
| 779 | - <?php _e( 'CVC', 'give' ); ?> |
|
| 779 | + <?php _e('CVC', 'give'); ?> |
|
| 780 | 780 | <span class="give-required-indicator">*</span> |
| 781 | - <?php echo Give()->tooltips->render_help( __( 'The 3 digit (back) or 4 digit (front) value on your card.', 'give' ) ); ?> |
|
| 781 | + <?php echo Give()->tooltips->render_help(__('The 3 digit (back) or 4 digit (front) value on your card.', 'give')); ?> |
|
| 782 | 782 | </label> |
| 783 | 783 | |
| 784 | 784 | <input type="tel" size="4" autocomplete="off" name="card_cvc" id="card_cvc-<?php echo $form_id ?>" |
| 785 | - class="card-cvc give-input required" placeholder="<?php _e( 'Security code', 'give' ); ?>" |
|
| 785 | + class="card-cvc give-input required" placeholder="<?php _e('Security code', 'give'); ?>" |
|
| 786 | 786 | required aria-required="true"/> |
| 787 | 787 | </p> |
| 788 | 788 | |
| 789 | 789 | <p id="give-card-name-wrap-<?php echo $form_id ?>" class="form-row form-row-two-thirds form-row-responsive"> |
| 790 | 790 | <label for="card_name-<?php echo $form_id ?>" class="give-label"> |
| 791 | - <?php _e( 'Name on the Card', 'give' ); ?> |
|
| 791 | + <?php _e('Name on the Card', 'give'); ?> |
|
| 792 | 792 | <span class="give-required-indicator">*</span> |
| 793 | - <?php echo Give()->tooltips->render_help( __( 'The name printed on the front of your credit card.', 'give' ) ); ?> |
|
| 793 | + <?php echo Give()->tooltips->render_help(__('The name printed on the front of your credit card.', 'give')); ?> |
|
| 794 | 794 | </label> |
| 795 | 795 | |
| 796 | 796 | <input type="text" autocomplete="off" name="card_name" id="card_name-<?php echo $form_id ?>" |
| 797 | - class="card-name give-input required" placeholder="<?php esc_attr_e( 'Card name', 'give' ); ?>" |
|
| 797 | + class="card-name give-input required" placeholder="<?php esc_attr_e('Card name', 'give'); ?>" |
|
| 798 | 798 | required aria-required="true"/> |
| 799 | 799 | </p> |
| 800 | 800 | <?php |
@@ -805,19 +805,19 @@ discard block |
||
| 805 | 805 | * |
| 806 | 806 | * @param int $form_id The form ID. |
| 807 | 807 | */ |
| 808 | - do_action( 'give_before_cc_expiration' ); |
|
| 808 | + do_action('give_before_cc_expiration'); |
|
| 809 | 809 | ?> |
| 810 | 810 | <p class="card-expiration form-row form-row-one-third form-row-responsive"> |
| 811 | 811 | <label for="card_expiry-<?php echo $form_id ?>" class="give-label"> |
| 812 | - <?php _e( 'Expiration', 'give' ); ?> |
|
| 812 | + <?php _e('Expiration', 'give'); ?> |
|
| 813 | 813 | <span class="give-required-indicator">*</span> |
| 814 | - <?php echo Give()->tooltips->render_help( __( 'The date your credit card expires, typically on the front of the card.', 'give' ) ); ?> |
|
| 814 | + <?php echo Give()->tooltips->render_help(__('The date your credit card expires, typically on the front of the card.', 'give')); ?> |
|
| 815 | 815 | </label> |
| 816 | 816 | |
| 817 | 817 | <input type="hidden" id="card_exp_month-<?php echo $form_id ?>" name="card_exp_month" class="card-expiry-month"/> |
| 818 | 818 | <input type="hidden" id="card_exp_year-<?php echo $form_id ?>" name="card_exp_year" class="card-expiry-year"/> |
| 819 | 819 | |
| 820 | - <input type="tel" autocomplete="off" name="card_expiry" id="card_expiry-<?php echo $form_id ?>" class="card-expiry give-input required" placeholder="<?php esc_attr_e( 'MM / YY', 'give' ); ?>" required aria-required="true"/> |
|
| 820 | + <input type="tel" autocomplete="off" name="card_expiry" id="card_expiry-<?php echo $form_id ?>" class="card-expiry give-input required" placeholder="<?php esc_attr_e('MM / YY', 'give'); ?>" required aria-required="true"/> |
|
| 821 | 821 | </p> |
| 822 | 822 | <?php |
| 823 | 823 | /** |
@@ -827,7 +827,7 @@ discard block |
||
| 827 | 827 | * |
| 828 | 828 | * @param int $form_id The form ID. |
| 829 | 829 | */ |
| 830 | - do_action( 'give_after_cc_expiration', $form_id ); |
|
| 830 | + do_action('give_after_cc_expiration', $form_id); |
|
| 831 | 831 | ?> |
| 832 | 832 | </fieldset> |
| 833 | 833 | <?php |
@@ -838,12 +838,12 @@ discard block |
||
| 838 | 838 | * |
| 839 | 839 | * @param int $form_id The form ID. |
| 840 | 840 | */ |
| 841 | - do_action( 'give_after_cc_fields', $form_id ); |
|
| 841 | + do_action('give_after_cc_fields', $form_id); |
|
| 842 | 842 | |
| 843 | 843 | echo ob_get_clean(); |
| 844 | 844 | } |
| 845 | 845 | |
| 846 | -add_action( 'give_cc_form', 'give_get_cc_form' ); |
|
| 846 | +add_action('give_cc_form', 'give_get_cc_form'); |
|
| 847 | 847 | |
| 848 | 848 | /** |
| 849 | 849 | * Outputs the default credit card address fields. |
@@ -854,20 +854,20 @@ discard block |
||
| 854 | 854 | * |
| 855 | 855 | * @return void |
| 856 | 856 | */ |
| 857 | -function give_default_cc_address_fields( $form_id ) { |
|
| 857 | +function give_default_cc_address_fields($form_id) { |
|
| 858 | 858 | // Get user info. |
| 859 | - $give_user_info = _give_get_prefill_form_field_values( $form_id ); |
|
| 859 | + $give_user_info = _give_get_prefill_form_field_values($form_id); |
|
| 860 | 860 | |
| 861 | 861 | $logged_in = is_user_logged_in(); |
| 862 | 862 | |
| 863 | - if ( $logged_in ) { |
|
| 864 | - $user_address = give_get_donor_address( get_current_user_id() ); |
|
| 863 | + if ($logged_in) { |
|
| 864 | + $user_address = give_get_donor_address(get_current_user_id()); |
|
| 865 | 865 | } |
| 866 | 866 | |
| 867 | 867 | ob_start(); |
| 868 | 868 | ?> |
| 869 | 869 | <fieldset id="give_cc_address" class="cc-address"> |
| 870 | - <legend><?php echo apply_filters( 'give_billing_details_fieldset_heading', esc_html__( 'Billing Details', 'give' ) ); ?></legend> |
|
| 870 | + <legend><?php echo apply_filters('give_billing_details_fieldset_heading', esc_html__('Billing Details', 'give')); ?></legend> |
|
| 871 | 871 | <?php |
| 872 | 872 | /** |
| 873 | 873 | * Fires while rendering credit card billing form, before address fields. |
@@ -876,36 +876,36 @@ discard block |
||
| 876 | 876 | * |
| 877 | 877 | * @param int $form_id The form ID. |
| 878 | 878 | */ |
| 879 | - do_action( 'give_cc_billing_top' ); |
|
| 879 | + do_action('give_cc_billing_top'); |
|
| 880 | 880 | |
| 881 | 881 | // For Country. |
| 882 | 882 | $selected_country = give_get_country(); |
| 883 | - if ( ! empty( $give_user_info['billing_country'] ) && '*' !== $give_user_info['billing_country'] ) { |
|
| 883 | + if ( ! empty($give_user_info['billing_country']) && '*' !== $give_user_info['billing_country']) { |
|
| 884 | 884 | $selected_country = $give_user_info['billing_country']; |
| 885 | 885 | } |
| 886 | 886 | $countries = give_get_country_list(); |
| 887 | 887 | |
| 888 | 888 | // For state |
| 889 | 889 | $selected_state = ''; |
| 890 | - if ( $selected_country === give_get_country() ) { |
|
| 890 | + if ($selected_country === give_get_country()) { |
|
| 891 | 891 | // Get defalut selected state by admin. |
| 892 | 892 | $selected_state = give_get_state(); |
| 893 | 893 | } |
| 894 | 894 | // Get the last payment made by user states. |
| 895 | - if ( ! empty( $give_user_info['card_state'] ) && '*' !== $give_user_info['card_state'] ) { |
|
| 895 | + if ( ! empty($give_user_info['card_state']) && '*' !== $give_user_info['card_state']) { |
|
| 896 | 896 | $selected_state = $give_user_info['card_state']; |
| 897 | 897 | } |
| 898 | 898 | // Get the country code |
| 899 | - if ( ! empty( $give_user_info['billing_country'] ) && '*' !== $give_user_info['billing_country'] ) { |
|
| 899 | + if ( ! empty($give_user_info['billing_country']) && '*' !== $give_user_info['billing_country']) { |
|
| 900 | 900 | $selected_country = $give_user_info['billing_country']; |
| 901 | 901 | } |
| 902 | - $label = __( 'State', 'give' ); |
|
| 902 | + $label = __('State', 'give'); |
|
| 903 | 903 | $states_label = give_get_states_label(); |
| 904 | 904 | // Check if $country code exists in the array key for states label. |
| 905 | - if ( array_key_exists( $selected_country, $states_label ) ) { |
|
| 906 | - $label = $states_label[ $selected_country ]; |
|
| 905 | + if (array_key_exists($selected_country, $states_label)) { |
|
| 906 | + $label = $states_label[$selected_country]; |
|
| 907 | 907 | } |
| 908 | - $states = give_get_states( $selected_country ); |
|
| 908 | + $states = give_get_states($selected_country); |
|
| 909 | 909 | // Get the country list that do not have any states init. |
| 910 | 910 | $no_states_country = give_no_states_country_list(); |
| 911 | 911 | // Get the country list that does not require states. |
@@ -913,23 +913,23 @@ discard block |
||
| 913 | 913 | ?> |
| 914 | 914 | <p id="give-card-country-wrap" class="form-row form-row-wide"> |
| 915 | 915 | <label for="billing_country" class="give-label"> |
| 916 | - <?php esc_html_e( 'Country', 'give' ); ?> |
|
| 917 | - <?php if ( give_field_is_required( 'billing_country', $form_id ) ) : ?> |
|
| 916 | + <?php esc_html_e('Country', 'give'); ?> |
|
| 917 | + <?php if (give_field_is_required('billing_country', $form_id)) : ?> |
|
| 918 | 918 | <span class="give-required-indicator">*</span> |
| 919 | 919 | <?php endif; ?> |
| 920 | 920 | <span class="give-tooltip give-icon give-icon-question" |
| 921 | - data-tooltip="<?php esc_attr_e( 'The country for your billing address.', 'give' ); ?>"></span> |
|
| 921 | + data-tooltip="<?php esc_attr_e('The country for your billing address.', 'give'); ?>"></span> |
|
| 922 | 922 | </label> |
| 923 | 923 | |
| 924 | 924 | <select |
| 925 | 925 | name="billing_country" |
| 926 | 926 | id="billing_country" |
| 927 | - class="billing-country billing_country give-select<?php echo( give_field_is_required( 'billing_country', $form_id ) ? ' required' : '' ); ?>" |
|
| 928 | - <?php echo( give_field_is_required( 'billing_country', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
| 927 | + class="billing-country billing_country give-select<?php echo(give_field_is_required('billing_country', $form_id) ? ' required' : ''); ?>" |
|
| 928 | + <?php echo(give_field_is_required('billing_country', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
| 929 | 929 | > |
| 930 | 930 | <?php |
| 931 | - foreach ( $countries as $country_code => $country ) { |
|
| 932 | - echo '<option value="' . esc_attr( $country_code ) . '"' . selected( $country_code, $selected_country, false ) . '>' . $country . '</option>'; |
|
| 931 | + foreach ($countries as $country_code => $country) { |
|
| 932 | + echo '<option value="'.esc_attr($country_code).'"'.selected($country_code, $selected_country, false).'>'.$country.'</option>'; |
|
| 933 | 933 | } |
| 934 | 934 | ?> |
| 935 | 935 | </select> |
@@ -937,86 +937,86 @@ discard block |
||
| 937 | 937 | |
| 938 | 938 | <p id="give-card-address-wrap" class="form-row form-row-wide"> |
| 939 | 939 | <label for="card_address" class="give-label"> |
| 940 | - <?php _e( 'Address 1', 'give' ); ?> |
|
| 940 | + <?php _e('Address 1', 'give'); ?> |
|
| 941 | 941 | <?php |
| 942 | - if ( give_field_is_required( 'card_address', $form_id ) ) : ?> |
|
| 942 | + if (give_field_is_required('card_address', $form_id)) : ?> |
|
| 943 | 943 | <span class="give-required-indicator">*</span> |
| 944 | 944 | <?php endif; ?> |
| 945 | - <?php echo Give()->tooltips->render_help( __( 'The primary billing address for your credit card.', 'give' ) ); ?> |
|
| 945 | + <?php echo Give()->tooltips->render_help(__('The primary billing address for your credit card.', 'give')); ?> |
|
| 946 | 946 | </label> |
| 947 | 947 | |
| 948 | 948 | <input |
| 949 | 949 | type="text" |
| 950 | 950 | id="card_address" |
| 951 | 951 | name="card_address" |
| 952 | - class="card-address give-input<?php echo( give_field_is_required( 'card_address', $form_id ) ? ' required' : '' ); ?>" |
|
| 953 | - placeholder="<?php _e( 'Address line 1', 'give' ); ?>" |
|
| 954 | - value="<?php echo isset( $give_user_info['card_address'] ) ? $give_user_info['card_address'] : ''; ?>" |
|
| 955 | - <?php echo( give_field_is_required( 'card_address', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
| 952 | + class="card-address give-input<?php echo(give_field_is_required('card_address', $form_id) ? ' required' : ''); ?>" |
|
| 953 | + placeholder="<?php _e('Address line 1', 'give'); ?>" |
|
| 954 | + value="<?php echo isset($give_user_info['card_address']) ? $give_user_info['card_address'] : ''; ?>" |
|
| 955 | + <?php echo(give_field_is_required('card_address', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
| 956 | 956 | /> |
| 957 | 957 | </p> |
| 958 | 958 | |
| 959 | 959 | <p id="give-card-address-2-wrap" class="form-row form-row-wide"> |
| 960 | 960 | <label for="card_address_2" class="give-label"> |
| 961 | - <?php _e( 'Address 2', 'give' ); ?> |
|
| 962 | - <?php if ( give_field_is_required( 'card_address_2', $form_id ) ) : ?> |
|
| 961 | + <?php _e('Address 2', 'give'); ?> |
|
| 962 | + <?php if (give_field_is_required('card_address_2', $form_id)) : ?> |
|
| 963 | 963 | <span class="give-required-indicator">*</span> |
| 964 | 964 | <?php endif; ?> |
| 965 | - <?php echo Give()->tooltips->render_help( __( '(optional) The suite, apartment number, post office box (etc) associated with your billing address.', 'give' ) ); ?> |
|
| 965 | + <?php echo Give()->tooltips->render_help(__('(optional) The suite, apartment number, post office box (etc) associated with your billing address.', 'give')); ?> |
|
| 966 | 966 | </label> |
| 967 | 967 | |
| 968 | 968 | <input |
| 969 | 969 | type="text" |
| 970 | 970 | id="card_address_2" |
| 971 | 971 | name="card_address_2" |
| 972 | - class="card-address-2 give-input<?php echo( give_field_is_required( 'card_address_2', $form_id ) ? ' required' : '' ); ?>" |
|
| 973 | - placeholder="<?php _e( 'Address line 2', 'give' ); ?>" |
|
| 974 | - value="<?php echo isset( $give_user_info['card_address_2'] ) ? $give_user_info['card_address_2'] : ''; ?>" |
|
| 975 | - <?php echo( give_field_is_required( 'card_address_2', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
| 972 | + class="card-address-2 give-input<?php echo(give_field_is_required('card_address_2', $form_id) ? ' required' : ''); ?>" |
|
| 973 | + placeholder="<?php _e('Address line 2', 'give'); ?>" |
|
| 974 | + value="<?php echo isset($give_user_info['card_address_2']) ? $give_user_info['card_address_2'] : ''; ?>" |
|
| 975 | + <?php echo(give_field_is_required('card_address_2', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
| 976 | 976 | /> |
| 977 | 977 | </p> |
| 978 | 978 | |
| 979 | 979 | <p id="give-card-city-wrap" class="form-row form-row-wide"> |
| 980 | 980 | <label for="card_city" class="give-label"> |
| 981 | - <?php _e( 'City', 'give' ); ?> |
|
| 982 | - <?php if ( give_field_is_required( 'card_city', $form_id ) ) : ?> |
|
| 981 | + <?php _e('City', 'give'); ?> |
|
| 982 | + <?php if (give_field_is_required('card_city', $form_id)) : ?> |
|
| 983 | 983 | <span class="give-required-indicator">*</span> |
| 984 | 984 | <?php endif; ?> |
| 985 | - <?php echo Give()->tooltips->render_help( __( 'The city for your billing address.', 'give' ) ); ?> |
|
| 985 | + <?php echo Give()->tooltips->render_help(__('The city for your billing address.', 'give')); ?> |
|
| 986 | 986 | </label> |
| 987 | 987 | <input |
| 988 | 988 | type="text" |
| 989 | 989 | id="card_city" |
| 990 | 990 | name="card_city" |
| 991 | - class="card-city give-input<?php echo( give_field_is_required( 'card_city', $form_id ) ? ' required' : '' ); ?>" |
|
| 992 | - placeholder="<?php _e( 'City', 'give' ); ?>" |
|
| 993 | - value="<?php echo isset( $give_user_info['card_city'] ) ? $give_user_info['card_city'] : ''; ?>" |
|
| 994 | - <?php echo( give_field_is_required( 'card_city', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
| 991 | + class="card-city give-input<?php echo(give_field_is_required('card_city', $form_id) ? ' required' : ''); ?>" |
|
| 992 | + placeholder="<?php _e('City', 'give'); ?>" |
|
| 993 | + value="<?php echo isset($give_user_info['card_city']) ? $give_user_info['card_city'] : ''; ?>" |
|
| 994 | + <?php echo(give_field_is_required('card_city', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
| 995 | 995 | /> |
| 996 | 996 | </p> |
| 997 | 997 | |
| 998 | 998 | <p id="give-card-state-wrap" |
| 999 | - class="form-row form-row-first form-row-responsive <?php echo ( ! empty( $selected_country ) && array_key_exists( $selected_country, $no_states_country ) ) ? 'give-hidden' : ''; ?> "> |
|
| 999 | + class="form-row form-row-first form-row-responsive <?php echo ( ! empty($selected_country) && array_key_exists($selected_country, $no_states_country)) ? 'give-hidden' : ''; ?> "> |
|
| 1000 | 1000 | <label for="card_state" class="give-label"> |
| 1001 | 1001 | <span class="state-label-text"><?php echo $label; ?></span> |
| 1002 | - <?php if ( give_field_is_required( 'card_state', $form_id ) ) : |
|
| 1002 | + <?php if (give_field_is_required('card_state', $form_id)) : |
|
| 1003 | 1003 | ?> |
| 1004 | - <span class="give-required-indicator <?php echo( array_key_exists( $selected_country, $states_not_required_country_list ) ? 'give-hidden' : '' ) ?> ">*</span> |
|
| 1004 | + <span class="give-required-indicator <?php echo(array_key_exists($selected_country, $states_not_required_country_list) ? 'give-hidden' : '') ?> ">*</span> |
|
| 1005 | 1005 | <?php endif; ?> |
| 1006 | 1006 | <span class="give-tooltip give-icon give-icon-question" |
| 1007 | - data-tooltip="<?php esc_attr_e( 'The state, province, or county for your billing address.', 'give' ); ?>"></span> |
|
| 1007 | + data-tooltip="<?php esc_attr_e('The state, province, or county for your billing address.', 'give'); ?>"></span> |
|
| 1008 | 1008 | </label> |
| 1009 | 1009 | <?php |
| 1010 | 1010 | |
| 1011 | - if ( ! empty( $states ) ) : ?> |
|
| 1011 | + if ( ! empty($states)) : ?> |
|
| 1012 | 1012 | <select |
| 1013 | 1013 | name="card_state" |
| 1014 | 1014 | id="card_state" |
| 1015 | - class="card_state give-select<?php echo( give_field_is_required( 'card_state', $form_id ) ? ' required' : '' ); ?>" |
|
| 1016 | - <?php echo( give_field_is_required( 'card_state', $form_id ) ? ' required aria-required="true" ' : '' ); ?>> |
|
| 1015 | + class="card_state give-select<?php echo(give_field_is_required('card_state', $form_id) ? ' required' : ''); ?>" |
|
| 1016 | + <?php echo(give_field_is_required('card_state', $form_id) ? ' required aria-required="true" ' : ''); ?>> |
|
| 1017 | 1017 | <?php |
| 1018 | - foreach ( $states as $state_code => $state ) { |
|
| 1019 | - echo '<option value="' . $state_code . '"' . selected( $state_code, $selected_state, false ) . '>' . $state . '</option>'; |
|
| 1018 | + foreach ($states as $state_code => $state) { |
|
| 1019 | + echo '<option value="'.$state_code.'"'.selected($state_code, $selected_state, false).'>'.$state.'</option>'; |
|
| 1020 | 1020 | } |
| 1021 | 1021 | ?> |
| 1022 | 1022 | </select> |
@@ -1028,11 +1028,11 @@ discard block |
||
| 1028 | 1028 | |
| 1029 | 1029 | <p id="give-card-zip-wrap" class="form-row form-row-last form-row-responsive"> |
| 1030 | 1030 | <label for="card_zip" class="give-label"> |
| 1031 | - <?php _e( 'Zip / Postal Code', 'give' ); ?> |
|
| 1032 | - <?php if ( give_field_is_required( 'card_zip', $form_id ) ) : ?> |
|
| 1031 | + <?php _e('Zip / Postal Code', 'give'); ?> |
|
| 1032 | + <?php if (give_field_is_required('card_zip', $form_id)) : ?> |
|
| 1033 | 1033 | <span class="give-required-indicator">*</span> |
| 1034 | 1034 | <?php endif; ?> |
| 1035 | - <?php echo Give()->tooltips->render_help( __( 'The ZIP Code or postal code for your billing address.', 'give' ) ); ?> |
|
| 1035 | + <?php echo Give()->tooltips->render_help(__('The ZIP Code or postal code for your billing address.', 'give')); ?> |
|
| 1036 | 1036 | </label> |
| 1037 | 1037 | |
| 1038 | 1038 | <input |
@@ -1040,10 +1040,10 @@ discard block |
||
| 1040 | 1040 | size="4" |
| 1041 | 1041 | id="card_zip" |
| 1042 | 1042 | name="card_zip" |
| 1043 | - class="card-zip give-input<?php echo( give_field_is_required( 'card_zip', $form_id ) ? ' required' : '' ); ?>" |
|
| 1044 | - placeholder="<?php _e( 'Zip / Postal Code', 'give' ); ?>" |
|
| 1045 | - value="<?php echo isset( $give_user_info['card_zip'] ) ? $give_user_info['card_zip'] : ''; ?>" |
|
| 1046 | - <?php echo( give_field_is_required( 'card_zip', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
| 1043 | + class="card-zip give-input<?php echo(give_field_is_required('card_zip', $form_id) ? ' required' : ''); ?>" |
|
| 1044 | + placeholder="<?php _e('Zip / Postal Code', 'give'); ?>" |
|
| 1045 | + value="<?php echo isset($give_user_info['card_zip']) ? $give_user_info['card_zip'] : ''; ?>" |
|
| 1046 | + <?php echo(give_field_is_required('card_zip', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
| 1047 | 1047 | /> |
| 1048 | 1048 | </p> |
| 1049 | 1049 | <?php |
@@ -1054,14 +1054,14 @@ discard block |
||
| 1054 | 1054 | * |
| 1055 | 1055 | * @param int $form_id The form ID. |
| 1056 | 1056 | */ |
| 1057 | - do_action( 'give_cc_billing_bottom' ); |
|
| 1057 | + do_action('give_cc_billing_bottom'); |
|
| 1058 | 1058 | ?> |
| 1059 | 1059 | </fieldset> |
| 1060 | 1060 | <?php |
| 1061 | 1061 | echo ob_get_clean(); |
| 1062 | 1062 | } |
| 1063 | 1063 | |
| 1064 | -add_action( 'give_after_cc_fields', 'give_default_cc_address_fields' ); |
|
| 1064 | +add_action('give_after_cc_fields', 'give_default_cc_address_fields'); |
|
| 1065 | 1065 | |
| 1066 | 1066 | |
| 1067 | 1067 | /** |
@@ -1074,15 +1074,15 @@ discard block |
||
| 1074 | 1074 | * |
| 1075 | 1075 | * @return string |
| 1076 | 1076 | */ |
| 1077 | -function give_get_register_fields( $form_id ) { |
|
| 1077 | +function give_get_register_fields($form_id) { |
|
| 1078 | 1078 | |
| 1079 | 1079 | global $user_ID; |
| 1080 | 1080 | |
| 1081 | - if ( is_user_logged_in() ) { |
|
| 1082 | - $user_data = get_userdata( $user_ID ); |
|
| 1081 | + if (is_user_logged_in()) { |
|
| 1082 | + $user_data = get_userdata($user_ID); |
|
| 1083 | 1083 | } |
| 1084 | 1084 | |
| 1085 | - $show_register_form = give_show_login_register_option( $form_id ); |
|
| 1085 | + $show_register_form = give_show_login_register_option($form_id); |
|
| 1086 | 1086 | |
| 1087 | 1087 | ob_start(); ?> |
| 1088 | 1088 | <fieldset id="give-register-fields-<?php echo $form_id; ?>"> |
@@ -1095,7 +1095,7 @@ discard block |
||
| 1095 | 1095 | * |
| 1096 | 1096 | * @param int $form_id The form ID. |
| 1097 | 1097 | */ |
| 1098 | - do_action( 'give_register_fields_before', $form_id ); |
|
| 1098 | + do_action('give_register_fields_before', $form_id); |
|
| 1099 | 1099 | ?> |
| 1100 | 1100 | |
| 1101 | 1101 | <fieldset id="give-register-account-fields-<?php echo $form_id; ?>"> |
@@ -1107,22 +1107,22 @@ discard block |
||
| 1107 | 1107 | * |
| 1108 | 1108 | * @param int $form_id The form ID. |
| 1109 | 1109 | */ |
| 1110 | - do_action( 'give_register_account_fields_before', $form_id ); |
|
| 1110 | + do_action('give_register_account_fields_before', $form_id); |
|
| 1111 | 1111 | ?> |
| 1112 | 1112 | <div id="give-create-account-wrap-<?php echo $form_id; ?>" class="form-row form-row-first form-row-responsive"> |
| 1113 | 1113 | <label for="give-create-account-<?php echo $form_id; ?>"> |
| 1114 | 1114 | <?php |
| 1115 | 1115 | // Add attributes to checkbox, if Guest Checkout is disabled. |
| 1116 | - $is_guest_checkout = give_get_meta( $form_id, '_give_logged_in_only', true ); |
|
| 1117 | - $id = 'give-create-account-' . $form_id; |
|
| 1118 | - if ( ! give_is_setting_enabled( $is_guest_checkout ) ) { |
|
| 1116 | + $is_guest_checkout = give_get_meta($form_id, '_give_logged_in_only', true); |
|
| 1117 | + $id = 'give-create-account-'.$form_id; |
|
| 1118 | + if ( ! give_is_setting_enabled($is_guest_checkout)) { |
|
| 1119 | 1119 | echo Give()->tooltips->render( |
| 1120 | 1120 | array( |
| 1121 | 1121 | 'tag_content' => sprintf( |
| 1122 | 1122 | '<input type="checkbox" name="give_create_account" id="%s" class="give-input" checked disabled /><input type="hidden" name="give_create_account" value="on" />', |
| 1123 | 1123 | $id |
| 1124 | 1124 | ), |
| 1125 | - 'label' => __( 'Registration is required to donate.', 'give' ), |
|
| 1125 | + 'label' => __('Registration is required to donate.', 'give'), |
|
| 1126 | 1126 | ) ); |
| 1127 | 1127 | } else { |
| 1128 | 1128 | ?> |
@@ -1130,16 +1130,16 @@ discard block |
||
| 1130 | 1130 | <?php |
| 1131 | 1131 | } |
| 1132 | 1132 | ?> |
| 1133 | - <?php _e( 'Create an account', 'give' ); ?> |
|
| 1134 | - <?php echo Give()->tooltips->render_help( __( 'Create an account on the site to see and manage donation history.', 'give' ) ); ?> |
|
| 1133 | + <?php _e('Create an account', 'give'); ?> |
|
| 1134 | + <?php echo Give()->tooltips->render_help(__('Create an account on the site to see and manage donation history.', 'give')); ?> |
|
| 1135 | 1135 | </label> |
| 1136 | 1136 | </div> |
| 1137 | 1137 | |
| 1138 | - <?php if ( 'both' === $show_register_form ) { ?> |
|
| 1138 | + <?php if ('both' === $show_register_form) { ?> |
|
| 1139 | 1139 | <div class="give-login-account-wrap form-row form-row-last form-row-responsive"> |
| 1140 | - <p class="give-login-message"><?php esc_html_e( 'Already have an account?', 'give' ); ?> |
|
| 1141 | - <a href="<?php echo esc_url( add_query_arg( 'login', 1 ) ); ?>" class="give-checkout-login" |
|
| 1142 | - data-action="give_checkout_login"><?php esc_html_e( 'Login', 'give' ); ?></a> |
|
| 1140 | + <p class="give-login-message"><?php esc_html_e('Already have an account?', 'give'); ?> |
|
| 1141 | + <a href="<?php echo esc_url(add_query_arg('login', 1)); ?>" class="give-checkout-login" |
|
| 1142 | + data-action="give_checkout_login"><?php esc_html_e('Login', 'give'); ?></a> |
|
| 1143 | 1143 | </p> |
| 1144 | 1144 | <p class="give-loading-text"> |
| 1145 | 1145 | <span class="give-loading-animation"></span> |
@@ -1155,7 +1155,7 @@ discard block |
||
| 1155 | 1155 | * |
| 1156 | 1156 | * @param int $form_id The form ID. |
| 1157 | 1157 | */ |
| 1158 | - do_action( 'give_register_account_fields_after', $form_id ); |
|
| 1158 | + do_action('give_register_account_fields_after', $form_id); |
|
| 1159 | 1159 | ?> |
| 1160 | 1160 | </fieldset> |
| 1161 | 1161 | |
@@ -1167,7 +1167,7 @@ discard block |
||
| 1167 | 1167 | * |
| 1168 | 1168 | * @param int $form_id The form ID. |
| 1169 | 1169 | */ |
| 1170 | - do_action( 'give_register_fields_after', $form_id ); |
|
| 1170 | + do_action('give_register_fields_after', $form_id); |
|
| 1171 | 1171 | ?> |
| 1172 | 1172 | |
| 1173 | 1173 | <input type="hidden" name="give-purchase-var" value="needs-to-register"/> |
@@ -1178,7 +1178,7 @@ discard block |
||
| 1178 | 1178 | * |
| 1179 | 1179 | * @since 1.7 |
| 1180 | 1180 | */ |
| 1181 | - do_action( 'give_donation_form_user_info', $form_id ); |
|
| 1181 | + do_action('give_donation_form_user_info', $form_id); |
|
| 1182 | 1182 | ?> |
| 1183 | 1183 | |
| 1184 | 1184 | </fieldset> |
@@ -1186,7 +1186,7 @@ discard block |
||
| 1186 | 1186 | echo ob_get_clean(); |
| 1187 | 1187 | } |
| 1188 | 1188 | |
| 1189 | -add_action( 'give_donation_form_register_fields', 'give_get_register_fields' ); |
|
| 1189 | +add_action('give_donation_form_register_fields', 'give_get_register_fields'); |
|
| 1190 | 1190 | |
| 1191 | 1191 | /** |
| 1192 | 1192 | * Gets the login fields for the login form on the checkout. This function hooks |
@@ -1199,27 +1199,27 @@ discard block |
||
| 1199 | 1199 | * |
| 1200 | 1200 | * @return string |
| 1201 | 1201 | */ |
| 1202 | -function give_get_login_fields( $form_id ) { |
|
| 1202 | +function give_get_login_fields($form_id) { |
|
| 1203 | 1203 | |
| 1204 | - $form_id = isset( $_POST['form_id'] ) ? $_POST['form_id'] : $form_id; |
|
| 1205 | - $show_register_form = give_show_login_register_option( $form_id ); |
|
| 1204 | + $form_id = isset($_POST['form_id']) ? $_POST['form_id'] : $form_id; |
|
| 1205 | + $show_register_form = give_show_login_register_option($form_id); |
|
| 1206 | 1206 | |
| 1207 | 1207 | ob_start(); |
| 1208 | 1208 | ?> |
| 1209 | 1209 | <fieldset id="give-login-fields-<?php echo $form_id; ?>"> |
| 1210 | - <legend><?php echo apply_filters( 'give_account_login_fieldset_heading', __( 'Login to Your Account', 'give' ) ); |
|
| 1211 | - if ( ! give_logged_in_only( $form_id ) ) { |
|
| 1212 | - echo ' <span class="sub-text">' . __( '(optional)', 'give' ) . '</span>'; |
|
| 1210 | + <legend><?php echo apply_filters('give_account_login_fieldset_heading', __('Login to Your Account', 'give')); |
|
| 1211 | + if ( ! give_logged_in_only($form_id)) { |
|
| 1212 | + echo ' <span class="sub-text">'.__('(optional)', 'give').'</span>'; |
|
| 1213 | 1213 | } ?> |
| 1214 | 1214 | </legend> |
| 1215 | - <?php if ( $show_register_form == 'both' ) { ?> |
|
| 1215 | + <?php if ($show_register_form == 'both') { ?> |
|
| 1216 | 1216 | <p class="give-new-account-link"> |
| 1217 | - <?php _e( 'Need to create an account?', 'give' ); ?> |
|
| 1218 | - <a href="<?php echo remove_query_arg( 'login' ); ?>" class="give-checkout-register-cancel" |
|
| 1217 | + <?php _e('Need to create an account?', 'give'); ?> |
|
| 1218 | + <a href="<?php echo remove_query_arg('login'); ?>" class="give-checkout-register-cancel" |
|
| 1219 | 1219 | data-action="give_checkout_register"> |
| 1220 | - <?php _e( 'Register', 'give' ); |
|
| 1221 | - if ( ! give_logged_in_only( $form_id ) ) { |
|
| 1222 | - echo ' ' . __( 'and donate as a guest »', 'give' ); |
|
| 1220 | + <?php _e('Register', 'give'); |
|
| 1221 | + if ( ! give_logged_in_only($form_id)) { |
|
| 1222 | + echo ' '.__('and donate as a guest »', 'give'); |
|
| 1223 | 1223 | } ?> |
| 1224 | 1224 | </a> |
| 1225 | 1225 | </p> |
@@ -1235,49 +1235,49 @@ discard block |
||
| 1235 | 1235 | * |
| 1236 | 1236 | * @param int $form_id The form ID. |
| 1237 | 1237 | */ |
| 1238 | - do_action( 'give_checkout_login_fields_before', $form_id ); |
|
| 1238 | + do_action('give_checkout_login_fields_before', $form_id); |
|
| 1239 | 1239 | ?> |
| 1240 | 1240 | <div id="give-user-login-wrap-<?php echo $form_id; ?>" class="form-row form-row-first form-row-responsive"> |
| 1241 | 1241 | <label class="give-label" for="give-user-login-<?php echo $form_id; ?>"> |
| 1242 | - <?php _e( 'Username', 'give' ); ?> |
|
| 1243 | - <?php if ( give_logged_in_only( $form_id ) ) { ?> |
|
| 1242 | + <?php _e('Username', 'give'); ?> |
|
| 1243 | + <?php if (give_logged_in_only($form_id)) { ?> |
|
| 1244 | 1244 | <span class="give-required-indicator">*</span> |
| 1245 | 1245 | <?php } ?> |
| 1246 | 1246 | </label> |
| 1247 | 1247 | |
| 1248 | - <input class="give-input<?php echo ( give_logged_in_only( $form_id ) ) ? ' required' : ''; ?>" type="text" |
|
| 1248 | + <input class="give-input<?php echo (give_logged_in_only($form_id)) ? ' required' : ''; ?>" type="text" |
|
| 1249 | 1249 | name="give_user_login" id="give-user-login-<?php echo $form_id; ?>" value="" |
| 1250 | - placeholder="<?php _e( 'Your username', 'give' ); ?>"<?php echo ( give_logged_in_only( $form_id ) ) ? ' required aria-required="true" ' : ''; ?>/> |
|
| 1250 | + placeholder="<?php _e('Your username', 'give'); ?>"<?php echo (give_logged_in_only($form_id)) ? ' required aria-required="true" ' : ''; ?>/> |
|
| 1251 | 1251 | </div> |
| 1252 | 1252 | |
| 1253 | 1253 | <div id="give-user-pass-wrap-<?php echo $form_id; ?>" |
| 1254 | 1254 | class="give_login_password form-row form-row-last form-row-responsive"> |
| 1255 | 1255 | <label class="give-label" for="give-user-pass-<?php echo $form_id; ?>"> |
| 1256 | - <?php _e( 'Password', 'give' ); ?> |
|
| 1257 | - <?php if ( give_logged_in_only( $form_id ) ) { ?> |
|
| 1256 | + <?php _e('Password', 'give'); ?> |
|
| 1257 | + <?php if (give_logged_in_only($form_id)) { ?> |
|
| 1258 | 1258 | <span class="give-required-indicator">*</span> |
| 1259 | 1259 | <?php } ?> |
| 1260 | 1260 | </label> |
| 1261 | - <input class="give-input<?php echo ( give_logged_in_only( $form_id ) ) ? ' required' : ''; ?>" |
|
| 1261 | + <input class="give-input<?php echo (give_logged_in_only($form_id)) ? ' required' : ''; ?>" |
|
| 1262 | 1262 | type="password" name="give_user_pass" id="give-user-pass-<?php echo $form_id; ?>" |
| 1263 | - placeholder="<?php _e( 'Your password', 'give' ); ?>"<?php echo ( give_logged_in_only( $form_id ) ) ? ' required aria-required="true" ' : ''; ?>/> |
|
| 1263 | + placeholder="<?php _e('Your password', 'give'); ?>"<?php echo (give_logged_in_only($form_id)) ? ' required aria-required="true" ' : ''; ?>/> |
|
| 1264 | 1264 | <input type="hidden" name="give-purchase-var" value="needs-to-login"/> |
| 1265 | 1265 | </div> |
| 1266 | 1266 | |
| 1267 | 1267 | <div id="give-forgot-password-wrap-<?php echo $form_id; ?>" class="give_login_forgot_password"> |
| 1268 | 1268 | <span class="give-forgot-password "> |
| 1269 | 1269 | <a href="<?php echo wp_lostpassword_url() ?>" |
| 1270 | - target="_blank"><?php _e( 'Reset Password', 'give' ) ?></a> |
|
| 1270 | + target="_blank"><?php _e('Reset Password', 'give') ?></a> |
|
| 1271 | 1271 | </span> |
| 1272 | 1272 | </div> |
| 1273 | 1273 | |
| 1274 | 1274 | <div id="give-user-login-submit-<?php echo $form_id; ?>" class="give-clearfix"> |
| 1275 | 1275 | <input type="submit" class="give-submit give-btn button" name="give_login_submit" |
| 1276 | - value="<?php _e( 'Login', 'give' ); ?>"/> |
|
| 1277 | - <?php if ( $show_register_form !== 'login' ) { ?> |
|
| 1276 | + value="<?php _e('Login', 'give'); ?>"/> |
|
| 1277 | + <?php if ($show_register_form !== 'login') { ?> |
|
| 1278 | 1278 | <input type="button" data-action="give_cancel_login" |
| 1279 | 1279 | class="give-cancel-login give-checkout-register-cancel give-btn button" name="give_login_cancel" |
| 1280 | - value="<?php _e( 'Cancel', 'give' ); ?>"/> |
|
| 1280 | + value="<?php _e('Cancel', 'give'); ?>"/> |
|
| 1281 | 1281 | <?php } ?> |
| 1282 | 1282 | <span class="give-loading-animation"></span> |
| 1283 | 1283 | </div> |
@@ -1289,14 +1289,14 @@ discard block |
||
| 1289 | 1289 | * |
| 1290 | 1290 | * @param int $form_id The form ID. |
| 1291 | 1291 | */ |
| 1292 | - do_action( 'give_checkout_login_fields_after', $form_id ); |
|
| 1292 | + do_action('give_checkout_login_fields_after', $form_id); |
|
| 1293 | 1293 | ?> |
| 1294 | 1294 | </fieldset><!--end #give-login-fields--> |
| 1295 | 1295 | <?php |
| 1296 | 1296 | echo ob_get_clean(); |
| 1297 | 1297 | } |
| 1298 | 1298 | |
| 1299 | -add_action( 'give_donation_form_login_fields', 'give_get_login_fields', 10, 1 ); |
|
| 1299 | +add_action('give_donation_form_login_fields', 'give_get_login_fields', 10, 1); |
|
| 1300 | 1300 | |
| 1301 | 1301 | /** |
| 1302 | 1302 | * Payment Mode Select. |
@@ -1312,9 +1312,9 @@ discard block |
||
| 1312 | 1312 | * |
| 1313 | 1313 | * @return void |
| 1314 | 1314 | */ |
| 1315 | -function give_payment_mode_select( $form_id ) { |
|
| 1315 | +function give_payment_mode_select($form_id) { |
|
| 1316 | 1316 | |
| 1317 | - $gateways = give_get_enabled_payment_gateways( $form_id ); |
|
| 1317 | + $gateways = give_get_enabled_payment_gateways($form_id); |
|
| 1318 | 1318 | |
| 1319 | 1319 | /** |
| 1320 | 1320 | * Fires while selecting payment gateways, before the fields. |
@@ -1323,10 +1323,10 @@ discard block |
||
| 1323 | 1323 | * |
| 1324 | 1324 | * @param int $form_id The form ID. |
| 1325 | 1325 | */ |
| 1326 | - do_action( 'give_payment_mode_top', $form_id ); |
|
| 1326 | + do_action('give_payment_mode_top', $form_id); |
|
| 1327 | 1327 | ?> |
| 1328 | 1328 | |
| 1329 | - <fieldset id="give-payment-mode-select" <?php if ( count( $gateways ) <= 1 ) { |
|
| 1329 | + <fieldset id="give-payment-mode-select" <?php if (count($gateways) <= 1) { |
|
| 1330 | 1330 | echo 'style="display: none;"'; |
| 1331 | 1331 | } ?>> |
| 1332 | 1332 | <?php |
@@ -1337,10 +1337,10 @@ discard block |
||
| 1337 | 1337 | * |
| 1338 | 1338 | * @param int $form_id The form ID. |
| 1339 | 1339 | */ |
| 1340 | - do_action( 'give_payment_mode_before_gateways_wrap' ); |
|
| 1340 | + do_action('give_payment_mode_before_gateways_wrap'); |
|
| 1341 | 1341 | ?> |
| 1342 | 1342 | <legend |
| 1343 | - class="give-payment-mode-label"><?php echo apply_filters( 'give_checkout_payment_method_text', esc_html__( 'Select Payment Method', 'give' ) ); ?> |
|
| 1343 | + class="give-payment-mode-label"><?php echo apply_filters('give_checkout_payment_method_text', esc_html__('Select Payment Method', 'give')); ?> |
|
| 1344 | 1344 | <span class="give-loading-text"><span |
| 1345 | 1345 | class="give-loading-animation"></span> |
| 1346 | 1346 | </span> |
@@ -1353,26 +1353,26 @@ discard block |
||
| 1353 | 1353 | * |
| 1354 | 1354 | * @since 1.7 |
| 1355 | 1355 | */ |
| 1356 | - do_action( 'give_payment_mode_before_gateways' ) |
|
| 1356 | + do_action('give_payment_mode_before_gateways') |
|
| 1357 | 1357 | ?> |
| 1358 | 1358 | <ul id="give-gateway-radio-list"> |
| 1359 | 1359 | <?php |
| 1360 | 1360 | /** |
| 1361 | 1361 | * Loop through the active payment gateways. |
| 1362 | 1362 | */ |
| 1363 | - $selected_gateway = give_get_chosen_gateway( $form_id ); |
|
| 1363 | + $selected_gateway = give_get_chosen_gateway($form_id); |
|
| 1364 | 1364 | |
| 1365 | - foreach ( $gateways as $gateway_id => $gateway ) : |
|
| 1365 | + foreach ($gateways as $gateway_id => $gateway) : |
|
| 1366 | 1366 | //Determine the default gateway. |
| 1367 | - $checked = checked( $gateway_id, $selected_gateway, false ); |
|
| 1367 | + $checked = checked($gateway_id, $selected_gateway, false); |
|
| 1368 | 1368 | $checked_class = $checked ? ' class="give-gateway-option-selected"' : ''; ?> |
| 1369 | 1369 | <li<?php echo $checked_class ?>> |
| 1370 | 1370 | <input type="radio" name="payment-mode" class="give-gateway" |
| 1371 | - id="give-gateway-<?php echo esc_attr( $gateway_id ) . '-' . $form_id; ?>" |
|
| 1372 | - value="<?php echo esc_attr( $gateway_id ); ?>"<?php echo $checked; ?>> |
|
| 1373 | - <label for="give-gateway-<?php echo esc_attr( $gateway_id ) . '-' . $form_id; ?>" |
|
| 1371 | + id="give-gateway-<?php echo esc_attr($gateway_id).'-'.$form_id; ?>" |
|
| 1372 | + value="<?php echo esc_attr($gateway_id); ?>"<?php echo $checked; ?>> |
|
| 1373 | + <label for="give-gateway-<?php echo esc_attr($gateway_id).'-'.$form_id; ?>" |
|
| 1374 | 1374 | class="give-gateway-option" |
| 1375 | - id="give-gateway-option-<?php echo esc_attr( $gateway_id ); ?>"> <?php echo esc_html( $gateway['checkout_label'] ); ?></label> |
|
| 1375 | + id="give-gateway-option-<?php echo esc_attr($gateway_id); ?>"> <?php echo esc_html($gateway['checkout_label']); ?></label> |
|
| 1376 | 1376 | </li> |
| 1377 | 1377 | <?php |
| 1378 | 1378 | endforeach; |
@@ -1384,7 +1384,7 @@ discard block |
||
| 1384 | 1384 | * |
| 1385 | 1385 | * @since 1.7 |
| 1386 | 1386 | */ |
| 1387 | - do_action( 'give_payment_mode_after_gateways' ); |
|
| 1387 | + do_action('give_payment_mode_after_gateways'); |
|
| 1388 | 1388 | ?> |
| 1389 | 1389 | </div> |
| 1390 | 1390 | <?php |
@@ -1395,7 +1395,7 @@ discard block |
||
| 1395 | 1395 | * |
| 1396 | 1396 | * @param int $form_id The form ID. |
| 1397 | 1397 | */ |
| 1398 | - do_action( 'give_payment_mode_after_gateways_wrap' ); |
|
| 1398 | + do_action('give_payment_mode_after_gateways_wrap'); |
|
| 1399 | 1399 | ?> |
| 1400 | 1400 | </fieldset> |
| 1401 | 1401 | |
@@ -1407,7 +1407,7 @@ discard block |
||
| 1407 | 1407 | * |
| 1408 | 1408 | * @param int $form_id The form ID. |
| 1409 | 1409 | */ |
| 1410 | - do_action( 'give_payment_mode_bottom', $form_id ); |
|
| 1410 | + do_action('give_payment_mode_bottom', $form_id); |
|
| 1411 | 1411 | ?> |
| 1412 | 1412 | |
| 1413 | 1413 | <div id="give_purchase_form_wrap"> |
@@ -1418,7 +1418,7 @@ discard block |
||
| 1418 | 1418 | * |
| 1419 | 1419 | * @since 1.7 |
| 1420 | 1420 | */ |
| 1421 | - do_action( 'give_donation_form', $form_id ); |
|
| 1421 | + do_action('give_donation_form', $form_id); |
|
| 1422 | 1422 | ?> |
| 1423 | 1423 | |
| 1424 | 1424 | </div> |
@@ -1429,10 +1429,10 @@ discard block |
||
| 1429 | 1429 | * |
| 1430 | 1430 | * @since 1.7 |
| 1431 | 1431 | */ |
| 1432 | - do_action( 'give_donation_form_wrap_bottom', $form_id ); |
|
| 1432 | + do_action('give_donation_form_wrap_bottom', $form_id); |
|
| 1433 | 1433 | } |
| 1434 | 1434 | |
| 1435 | -add_action( 'give_payment_mode_select', 'give_payment_mode_select' ); |
|
| 1435 | +add_action('give_payment_mode_select', 'give_payment_mode_select'); |
|
| 1436 | 1436 | |
| 1437 | 1437 | /** |
| 1438 | 1438 | * Renders the Checkout Agree to Terms, this displays a checkbox for users to |
@@ -1445,31 +1445,31 @@ discard block |
||
| 1445 | 1445 | * |
| 1446 | 1446 | * @return bool |
| 1447 | 1447 | */ |
| 1448 | -function give_terms_agreement( $form_id ) { |
|
| 1449 | - $form_option = give_get_meta( $form_id, '_give_terms_option', true ); |
|
| 1448 | +function give_terms_agreement($form_id) { |
|
| 1449 | + $form_option = give_get_meta($form_id, '_give_terms_option', true); |
|
| 1450 | 1450 | |
| 1451 | 1451 | // Bailout if per form and global term and conditions is not setup. |
| 1452 | 1452 | if ( |
| 1453 | - give_is_setting_enabled( $form_option, 'global' ) |
|
| 1454 | - && give_is_setting_enabled( give_get_option( 'terms' ) ) |
|
| 1453 | + give_is_setting_enabled($form_option, 'global') |
|
| 1454 | + && give_is_setting_enabled(give_get_option('terms')) |
|
| 1455 | 1455 | ) { |
| 1456 | - $label = give_get_option( 'agree_to_terms_label', esc_html__( 'Agree to Terms?', 'give' ) ); |
|
| 1457 | - $terms = $terms = give_get_option( 'agreement_text', '' ); |
|
| 1458 | - $edit_term_url = admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=display§ion=term-and-conditions' ); |
|
| 1456 | + $label = give_get_option('agree_to_terms_label', esc_html__('Agree to Terms?', 'give')); |
|
| 1457 | + $terms = $terms = give_get_option('agreement_text', ''); |
|
| 1458 | + $edit_term_url = admin_url('edit.php?post_type=give_forms&page=give-settings&tab=display§ion=term-and-conditions'); |
|
| 1459 | 1459 | |
| 1460 | - } elseif ( give_is_setting_enabled( $form_option ) ) { |
|
| 1461 | - $label = ( $label = give_get_meta( $form_id, '_give_agree_label', true ) ) ? stripslashes( $label ) : esc_html__( 'Agree to Terms?', 'give' ); |
|
| 1462 | - $terms = give_get_meta( $form_id, '_give_agree_text', true ); |
|
| 1463 | - $edit_term_url = admin_url( 'post.php?post=' . $form_id . '&action=edit#form_terms_options' ); |
|
| 1460 | + } elseif (give_is_setting_enabled($form_option)) { |
|
| 1461 | + $label = ($label = give_get_meta($form_id, '_give_agree_label', true)) ? stripslashes($label) : esc_html__('Agree to Terms?', 'give'); |
|
| 1462 | + $terms = give_get_meta($form_id, '_give_agree_text', true); |
|
| 1463 | + $edit_term_url = admin_url('post.php?post='.$form_id.'&action=edit#form_terms_options'); |
|
| 1464 | 1464 | |
| 1465 | 1465 | } else { |
| 1466 | 1466 | return false; |
| 1467 | 1467 | } |
| 1468 | 1468 | |
| 1469 | 1469 | // Bailout: Check if term and conditions text is empty or not. |
| 1470 | - if ( empty( $terms ) ) { |
|
| 1471 | - if ( is_user_logged_in() && current_user_can( 'edit_give_forms' ) ) { |
|
| 1472 | - echo sprintf( __( 'Please enter valid terms and conditions in <a href="%s">this form\'s settings</a>.', 'give' ), $edit_term_url ); |
|
| 1470 | + if (empty($terms)) { |
|
| 1471 | + if (is_user_logged_in() && current_user_can('edit_give_forms')) { |
|
| 1472 | + echo sprintf(__('Please enter valid terms and conditions in <a href="%s">this form\'s settings</a>.', 'give'), $edit_term_url); |
|
| 1473 | 1473 | } |
| 1474 | 1474 | |
| 1475 | 1475 | return false; |
@@ -1477,7 +1477,7 @@ discard block |
||
| 1477 | 1477 | |
| 1478 | 1478 | ?> |
| 1479 | 1479 | <fieldset id="give_terms_agreement"> |
| 1480 | - <legend><?php echo apply_filters( 'give_terms_agreement_text', esc_html__( 'Terms', 'give' ) ); ?></legend> |
|
| 1480 | + <legend><?php echo apply_filters('give_terms_agreement_text', esc_html__('Terms', 'give')); ?></legend> |
|
| 1481 | 1481 | <div id="give_terms" class="give_terms-<?php echo $form_id; ?>" style="display:none;"> |
| 1482 | 1482 | <?php |
| 1483 | 1483 | /** |
@@ -1485,22 +1485,22 @@ discard block |
||
| 1485 | 1485 | * |
| 1486 | 1486 | * @since 1.0 |
| 1487 | 1487 | */ |
| 1488 | - do_action( 'give_before_terms' ); |
|
| 1488 | + do_action('give_before_terms'); |
|
| 1489 | 1489 | |
| 1490 | - echo wpautop( stripslashes( $terms ) ); |
|
| 1490 | + echo wpautop(stripslashes($terms)); |
|
| 1491 | 1491 | /** |
| 1492 | 1492 | * Fires while rendering terms of agreement, after the fields. |
| 1493 | 1493 | * |
| 1494 | 1494 | * @since 1.0 |
| 1495 | 1495 | */ |
| 1496 | - do_action( 'give_after_terms' ); |
|
| 1496 | + do_action('give_after_terms'); |
|
| 1497 | 1497 | ?> |
| 1498 | 1498 | </div> |
| 1499 | 1499 | <div id="give_show_terms"> |
| 1500 | 1500 | <a href="#" class="give_terms_links give_terms_links-<?php echo $form_id; ?>" role="button" |
| 1501 | - aria-controls="give_terms"><?php esc_html_e( 'Show Terms', 'give' ); ?></a> |
|
| 1501 | + aria-controls="give_terms"><?php esc_html_e('Show Terms', 'give'); ?></a> |
|
| 1502 | 1502 | <a href="#" class="give_terms_links give_terms_links-<?php echo $form_id; ?>" role="button" |
| 1503 | - aria-controls="give_terms" style="display:none;"><?php esc_html_e( 'Hide Terms', 'give' ); ?></a> |
|
| 1503 | + aria-controls="give_terms" style="display:none;"><?php esc_html_e('Hide Terms', 'give'); ?></a> |
|
| 1504 | 1504 | </div> |
| 1505 | 1505 | |
| 1506 | 1506 | <input name="give_agree_to_terms" class="required" type="checkbox" |
@@ -1511,7 +1511,7 @@ discard block |
||
| 1511 | 1511 | <?php |
| 1512 | 1512 | } |
| 1513 | 1513 | |
| 1514 | -add_action( 'give_donation_form_after_cc_form', 'give_terms_agreement', 8888, 1 ); |
|
| 1514 | +add_action('give_donation_form_after_cc_form', 'give_terms_agreement', 8888, 1); |
|
| 1515 | 1515 | |
| 1516 | 1516 | /** |
| 1517 | 1517 | * Checkout Final Total. |
@@ -1524,31 +1524,30 @@ discard block |
||
| 1524 | 1524 | * |
| 1525 | 1525 | * @return void |
| 1526 | 1526 | */ |
| 1527 | -function give_checkout_final_total( $form_id ) { |
|
| 1527 | +function give_checkout_final_total($form_id) { |
|
| 1528 | 1528 | |
| 1529 | - $total = isset( $_POST['give_total'] ) ? |
|
| 1530 | - apply_filters( 'give_donation_total', give_maybe_sanitize_amount( $_POST['give_total'] ) ) : |
|
| 1531 | - give_get_default_form_amount( $form_id ); |
|
| 1529 | + $total = isset($_POST['give_total']) ? |
|
| 1530 | + apply_filters('give_donation_total', give_maybe_sanitize_amount($_POST['give_total'])) : give_get_default_form_amount($form_id); |
|
| 1532 | 1531 | |
| 1533 | 1532 | |
| 1534 | 1533 | // Only proceed if give_total available. |
| 1535 | - if ( empty( $total ) ) { |
|
| 1534 | + if (empty($total)) { |
|
| 1536 | 1535 | return; |
| 1537 | 1536 | } |
| 1538 | 1537 | ?> |
| 1539 | 1538 | <p id="give-final-total-wrap" class="form-wrap "> |
| 1540 | 1539 | <span class="give-donation-total-label"> |
| 1541 | - <?php echo apply_filters( 'give_donation_total_label', esc_html__( 'Donation Total:', 'give' ) ); ?> |
|
| 1540 | + <?php echo apply_filters('give_donation_total_label', esc_html__('Donation Total:', 'give')); ?> |
|
| 1542 | 1541 | </span> |
| 1543 | 1542 | <span class="give-final-total-amount" |
| 1544 | - data-total="<?php echo give_format_amount( $total, array( 'sanitize' => false ) ); ?>"> |
|
| 1545 | - <?php echo give_currency_filter( give_format_amount( $total, array( 'sanitize' => false ) ), array( 'currency_code' => give_get_currency( $form_id ) ) ); ?> |
|
| 1543 | + data-total="<?php echo give_format_amount($total, array('sanitize' => false)); ?>"> |
|
| 1544 | + <?php echo give_currency_filter(give_format_amount($total, array('sanitize' => false)), array('currency_code' => give_get_currency($form_id))); ?> |
|
| 1546 | 1545 | </span> |
| 1547 | 1546 | </p> |
| 1548 | 1547 | <?php |
| 1549 | 1548 | } |
| 1550 | 1549 | |
| 1551 | -add_action( 'give_donation_form_before_submit', 'give_checkout_final_total', 999 ); |
|
| 1550 | +add_action('give_donation_form_before_submit', 'give_checkout_final_total', 999); |
|
| 1552 | 1551 | |
| 1553 | 1552 | /** |
| 1554 | 1553 | * Renders the Checkout Submit section. |
@@ -1559,7 +1558,7 @@ discard block |
||
| 1559 | 1558 | * |
| 1560 | 1559 | * @return void |
| 1561 | 1560 | */ |
| 1562 | -function give_checkout_submit( $form_id ) { |
|
| 1561 | +function give_checkout_submit($form_id) { |
|
| 1563 | 1562 | ?> |
| 1564 | 1563 | <fieldset id="give_purchase_submit"> |
| 1565 | 1564 | <?php |
@@ -1568,24 +1567,24 @@ discard block |
||
| 1568 | 1567 | * |
| 1569 | 1568 | * @since 1.7 |
| 1570 | 1569 | */ |
| 1571 | - do_action( 'give_donation_form_before_submit', $form_id ); |
|
| 1570 | + do_action('give_donation_form_before_submit', $form_id); |
|
| 1572 | 1571 | |
| 1573 | - give_checkout_hidden_fields( $form_id ); |
|
| 1572 | + give_checkout_hidden_fields($form_id); |
|
| 1574 | 1573 | |
| 1575 | - echo give_get_donation_form_submit_button( $form_id ); |
|
| 1574 | + echo give_get_donation_form_submit_button($form_id); |
|
| 1576 | 1575 | |
| 1577 | 1576 | /** |
| 1578 | 1577 | * Fire after donation form submit. |
| 1579 | 1578 | * |
| 1580 | 1579 | * @since 1.7 |
| 1581 | 1580 | */ |
| 1582 | - do_action( 'give_donation_form_after_submit', $form_id ); |
|
| 1581 | + do_action('give_donation_form_after_submit', $form_id); |
|
| 1583 | 1582 | ?> |
| 1584 | 1583 | </fieldset> |
| 1585 | 1584 | <?php |
| 1586 | 1585 | } |
| 1587 | 1586 | |
| 1588 | -add_action( 'give_donation_form_after_cc_form', 'give_checkout_submit', 9999 ); |
|
| 1587 | +add_action('give_donation_form_after_cc_form', 'give_checkout_submit', 9999); |
|
| 1589 | 1588 | |
| 1590 | 1589 | /** |
| 1591 | 1590 | * Give Donation form submit button. |
@@ -1596,10 +1595,10 @@ discard block |
||
| 1596 | 1595 | * |
| 1597 | 1596 | * @return string |
| 1598 | 1597 | */ |
| 1599 | -function give_get_donation_form_submit_button( $form_id ) { |
|
| 1598 | +function give_get_donation_form_submit_button($form_id) { |
|
| 1600 | 1599 | |
| 1601 | - $display_label_field = give_get_meta( $form_id, '_give_checkout_label', true ); |
|
| 1602 | - $display_label = ( ! empty( $display_label_field ) ? $display_label_field : esc_html__( 'Donate Now', 'give' ) ); |
|
| 1600 | + $display_label_field = give_get_meta($form_id, '_give_checkout_label', true); |
|
| 1601 | + $display_label = ( ! empty($display_label_field) ? $display_label_field : esc_html__('Donate Now', 'give')); |
|
| 1603 | 1602 | ob_start(); |
| 1604 | 1603 | ?> |
| 1605 | 1604 | <div class="give-submit-button-wrap give-clearfix"> |
@@ -1608,7 +1607,7 @@ discard block |
||
| 1608 | 1607 | <span class="give-loading-animation"></span> |
| 1609 | 1608 | </div> |
| 1610 | 1609 | <?php |
| 1611 | - return apply_filters( 'give_donation_form_submit_button', ob_get_clean(), $form_id ); |
|
| 1610 | + return apply_filters('give_donation_form_submit_button', ob_get_clean(), $form_id); |
|
| 1612 | 1611 | } |
| 1613 | 1612 | |
| 1614 | 1613 | /** |
@@ -1623,22 +1622,22 @@ discard block |
||
| 1623 | 1622 | * |
| 1624 | 1623 | * @return mixed |
| 1625 | 1624 | */ |
| 1626 | -function give_show_goal_progress( $form_id, $args ) { |
|
| 1625 | +function give_show_goal_progress($form_id, $args) { |
|
| 1627 | 1626 | |
| 1628 | 1627 | ob_start(); |
| 1629 | - give_get_template( 'shortcode-goal', array( 'form_id' => $form_id, 'args' => $args ) ); |
|
| 1628 | + give_get_template('shortcode-goal', array('form_id' => $form_id, 'args' => $args)); |
|
| 1630 | 1629 | |
| 1631 | 1630 | /** |
| 1632 | 1631 | * Filter progress bar output |
| 1633 | 1632 | * |
| 1634 | 1633 | * @since 2.0 |
| 1635 | 1634 | */ |
| 1636 | - echo apply_filters( 'give_goal_output', ob_get_clean(), $form_id, $args ); |
|
| 1635 | + echo apply_filters('give_goal_output', ob_get_clean(), $form_id, $args); |
|
| 1637 | 1636 | |
| 1638 | 1637 | return true; |
| 1639 | 1638 | } |
| 1640 | 1639 | |
| 1641 | -add_action( 'give_pre_form', 'give_show_goal_progress', 10, 2 ); |
|
| 1640 | +add_action('give_pre_form', 'give_show_goal_progress', 10, 2); |
|
| 1642 | 1641 | |
| 1643 | 1642 | |
| 1644 | 1643 | /** |
@@ -1651,10 +1650,10 @@ discard block |
||
| 1651 | 1650 | * |
| 1652 | 1651 | * @return mixed|string |
| 1653 | 1652 | */ |
| 1654 | -function give_get_form_content_placement( $form_id, $args ) { |
|
| 1653 | +function give_get_form_content_placement($form_id, $args) { |
|
| 1655 | 1654 | $show_content = ''; |
| 1656 | 1655 | |
| 1657 | - if ( isset( $args['show_content'] ) && ! empty( $args['show_content'] ) ) { |
|
| 1656 | + if (isset($args['show_content']) && ! empty($args['show_content'])) { |
|
| 1658 | 1657 | // Content positions. |
| 1659 | 1658 | $content_placement = array( |
| 1660 | 1659 | 'above' => 'give_pre_form', |
@@ -1662,18 +1661,18 @@ discard block |
||
| 1662 | 1661 | ); |
| 1663 | 1662 | |
| 1664 | 1663 | // Check if content position already decoded. |
| 1665 | - if ( in_array( $args['show_content'], $content_placement ) ) { |
|
| 1664 | + if (in_array($args['show_content'], $content_placement)) { |
|
| 1666 | 1665 | return $args['show_content']; |
| 1667 | 1666 | } |
| 1668 | 1667 | |
| 1669 | - $show_content = ( 'none' !== $args['show_content'] ? $content_placement[ $args['show_content'] ] : '' ); |
|
| 1668 | + $show_content = ('none' !== $args['show_content'] ? $content_placement[$args['show_content']] : ''); |
|
| 1670 | 1669 | |
| 1671 | - } elseif ( give_is_setting_enabled( give_get_meta( $form_id, '_give_display_content', true ) ) ) { |
|
| 1672 | - $show_content = give_get_meta( $form_id, '_give_content_placement', true ); |
|
| 1670 | + } elseif (give_is_setting_enabled(give_get_meta($form_id, '_give_display_content', true))) { |
|
| 1671 | + $show_content = give_get_meta($form_id, '_give_content_placement', true); |
|
| 1673 | 1672 | |
| 1674 | - } elseif ( 'none' !== give_get_meta( $form_id, '_give_content_option', true ) ) { |
|
| 1673 | + } elseif ('none' !== give_get_meta($form_id, '_give_content_option', true)) { |
|
| 1675 | 1674 | // Backward compatibility for _give_content_option for v18. |
| 1676 | - $show_content = give_get_meta( $form_id, '_give_content_option', true ); |
|
| 1675 | + $show_content = give_get_meta($form_id, '_give_content_option', true); |
|
| 1677 | 1676 | } |
| 1678 | 1677 | |
| 1679 | 1678 | return $show_content; |
@@ -1689,20 +1688,20 @@ discard block |
||
| 1689 | 1688 | * |
| 1690 | 1689 | * @return void|bool |
| 1691 | 1690 | */ |
| 1692 | -function give_form_content( $form_id, $args ) { |
|
| 1691 | +function give_form_content($form_id, $args) { |
|
| 1693 | 1692 | |
| 1694 | - $show_content = give_get_form_content_placement( $form_id, $args ); |
|
| 1693 | + $show_content = give_get_form_content_placement($form_id, $args); |
|
| 1695 | 1694 | |
| 1696 | 1695 | // Bailout. |
| 1697 | - if ( empty( $show_content ) ) { |
|
| 1696 | + if (empty($show_content)) { |
|
| 1698 | 1697 | return false; |
| 1699 | 1698 | } |
| 1700 | 1699 | |
| 1701 | 1700 | // Add action according to value. |
| 1702 | - add_action( $show_content, 'give_form_display_content', 10, 2 ); |
|
| 1701 | + add_action($show_content, 'give_form_display_content', 10, 2); |
|
| 1703 | 1702 | } |
| 1704 | 1703 | |
| 1705 | -add_action( 'give_pre_form_output', 'give_form_content', 10, 2 ); |
|
| 1704 | +add_action('give_pre_form_output', 'give_form_content', 10, 2); |
|
| 1706 | 1705 | |
| 1707 | 1706 | /** |
| 1708 | 1707 | * Renders Post Form Content. |
@@ -1716,22 +1715,22 @@ discard block |
||
| 1716 | 1715 | * |
| 1717 | 1716 | * @return void |
| 1718 | 1717 | */ |
| 1719 | -function give_form_display_content( $form_id, $args ) { |
|
| 1718 | +function give_form_display_content($form_id, $args) { |
|
| 1720 | 1719 | |
| 1721 | - $content = wpautop( give_get_meta( $form_id, '_give_form_content', true ) ); |
|
| 1722 | - $show_content = give_get_form_content_placement( $form_id, $args ); |
|
| 1720 | + $content = wpautop(give_get_meta($form_id, '_give_form_content', true)); |
|
| 1721 | + $show_content = give_get_form_content_placement($form_id, $args); |
|
| 1723 | 1722 | |
| 1724 | - if ( give_is_setting_enabled( give_get_option( 'the_content_filter' ) ) ) { |
|
| 1725 | - $content = apply_filters( 'the_content', $content ); |
|
| 1723 | + if (give_is_setting_enabled(give_get_option('the_content_filter'))) { |
|
| 1724 | + $content = apply_filters('the_content', $content); |
|
| 1726 | 1725 | } |
| 1727 | 1726 | |
| 1728 | - $output = '<div id="give-form-content-' . $form_id . '" class="give-form-content-wrap ' . $show_content . '-content">' . $content . '</div>'; |
|
| 1727 | + $output = '<div id="give-form-content-'.$form_id.'" class="give-form-content-wrap '.$show_content.'-content">'.$content.'</div>'; |
|
| 1729 | 1728 | |
| 1730 | - echo apply_filters( 'give_form_content_output', $output ); |
|
| 1729 | + echo apply_filters('give_form_content_output', $output); |
|
| 1731 | 1730 | |
| 1732 | 1731 | // remove action to prevent content output on addition forms on page. |
| 1733 | 1732 | // @see: https://github.com/WordImpress/Give/issues/634. |
| 1734 | - remove_action( $show_content, 'give_form_display_content' ); |
|
| 1733 | + remove_action($show_content, 'give_form_display_content'); |
|
| 1735 | 1734 | } |
| 1736 | 1735 | |
| 1737 | 1736 | /** |
@@ -1743,7 +1742,7 @@ discard block |
||
| 1743 | 1742 | * |
| 1744 | 1743 | * @return void |
| 1745 | 1744 | */ |
| 1746 | -function give_checkout_hidden_fields( $form_id ) { |
|
| 1745 | +function give_checkout_hidden_fields($form_id) { |
|
| 1747 | 1746 | |
| 1748 | 1747 | /** |
| 1749 | 1748 | * Fires while rendering hidden checkout fields, before the fields. |
@@ -1752,13 +1751,13 @@ discard block |
||
| 1752 | 1751 | * |
| 1753 | 1752 | * @param int $form_id The form ID. |
| 1754 | 1753 | */ |
| 1755 | - do_action( 'give_hidden_fields_before', $form_id ); |
|
| 1754 | + do_action('give_hidden_fields_before', $form_id); |
|
| 1756 | 1755 | |
| 1757 | - if ( is_user_logged_in() ) { ?> |
|
| 1756 | + if (is_user_logged_in()) { ?> |
|
| 1758 | 1757 | <input type="hidden" name="give-user-id" value="<?php echo get_current_user_id(); ?>"/> |
| 1759 | 1758 | <?php } ?> |
| 1760 | 1759 | <input type="hidden" name="give_action" value="purchase"/> |
| 1761 | - <input type="hidden" name="give-gateway" value="<?php echo give_get_chosen_gateway( $form_id ); ?>"/> |
|
| 1760 | + <input type="hidden" name="give-gateway" value="<?php echo give_get_chosen_gateway($form_id); ?>"/> |
|
| 1762 | 1761 | <?php |
| 1763 | 1762 | /** |
| 1764 | 1763 | * Fires while rendering hidden checkout fields, after the fields. |
@@ -1767,7 +1766,7 @@ discard block |
||
| 1767 | 1766 | * |
| 1768 | 1767 | * @param int $form_id The form ID. |
| 1769 | 1768 | */ |
| 1770 | - do_action( 'give_hidden_fields_after', $form_id ); |
|
| 1769 | + do_action('give_hidden_fields_after', $form_id); |
|
| 1771 | 1770 | |
| 1772 | 1771 | } |
| 1773 | 1772 | |
@@ -1782,20 +1781,20 @@ discard block |
||
| 1782 | 1781 | * |
| 1783 | 1782 | * @return string $content Filtered content. |
| 1784 | 1783 | */ |
| 1785 | -function give_filter_success_page_content( $content ) { |
|
| 1784 | +function give_filter_success_page_content($content) { |
|
| 1786 | 1785 | |
| 1787 | 1786 | $give_options = give_get_settings(); |
| 1788 | 1787 | |
| 1789 | - if ( isset( $give_options['success_page'] ) && isset( $_GET['payment-confirmation'] ) && is_page( $give_options['success_page'] ) ) { |
|
| 1790 | - if ( has_filter( 'give_payment_confirm_' . $_GET['payment-confirmation'] ) ) { |
|
| 1791 | - $content = apply_filters( 'give_payment_confirm_' . $_GET['payment-confirmation'], $content ); |
|
| 1788 | + if (isset($give_options['success_page']) && isset($_GET['payment-confirmation']) && is_page($give_options['success_page'])) { |
|
| 1789 | + if (has_filter('give_payment_confirm_'.$_GET['payment-confirmation'])) { |
|
| 1790 | + $content = apply_filters('give_payment_confirm_'.$_GET['payment-confirmation'], $content); |
|
| 1792 | 1791 | } |
| 1793 | 1792 | } |
| 1794 | 1793 | |
| 1795 | 1794 | return $content; |
| 1796 | 1795 | } |
| 1797 | 1796 | |
| 1798 | -add_filter( 'the_content', 'give_filter_success_page_content' ); |
|
| 1797 | +add_filter('the_content', 'give_filter_success_page_content'); |
|
| 1799 | 1798 | |
| 1800 | 1799 | /** |
| 1801 | 1800 | * Test Mode Frontend Warning. |
@@ -1806,12 +1805,12 @@ discard block |
||
| 1806 | 1805 | */ |
| 1807 | 1806 | function give_test_mode_frontend_warning() { |
| 1808 | 1807 | |
| 1809 | - if ( give_is_test_mode() ) { |
|
| 1810 | - echo '<div class="give_error give_warning" id="give_error_test_mode"><p><strong>' . esc_html__( 'Notice:', 'give' ) . '</strong> ' . esc_html__( 'Test mode is enabled. While in test mode no live donations are processed.', 'give' ) . '</p></div>'; |
|
| 1808 | + if (give_is_test_mode()) { |
|
| 1809 | + echo '<div class="give_error give_warning" id="give_error_test_mode"><p><strong>'.esc_html__('Notice:', 'give').'</strong> '.esc_html__('Test mode is enabled. While in test mode no live donations are processed.', 'give').'</p></div>'; |
|
| 1811 | 1810 | } |
| 1812 | 1811 | } |
| 1813 | 1812 | |
| 1814 | -add_action( 'give_pre_form', 'give_test_mode_frontend_warning', 10 ); |
|
| 1813 | +add_action('give_pre_form', 'give_test_mode_frontend_warning', 10); |
|
| 1815 | 1814 | |
| 1816 | 1815 | /** |
| 1817 | 1816 | * Members-only Form. |
@@ -1825,21 +1824,21 @@ discard block |
||
| 1825 | 1824 | * |
| 1826 | 1825 | * @return string |
| 1827 | 1826 | */ |
| 1828 | -function give_members_only_form( $final_output, $args ) { |
|
| 1827 | +function give_members_only_form($final_output, $args) { |
|
| 1829 | 1828 | |
| 1830 | - $form_id = isset( $args['form_id'] ) ? $args['form_id'] : 0; |
|
| 1829 | + $form_id = isset($args['form_id']) ? $args['form_id'] : 0; |
|
| 1831 | 1830 | |
| 1832 | 1831 | //Sanity Check: Must have form_id & not be logged in. |
| 1833 | - if ( empty( $form_id ) || is_user_logged_in() ) { |
|
| 1832 | + if (empty($form_id) || is_user_logged_in()) { |
|
| 1834 | 1833 | return $final_output; |
| 1835 | 1834 | } |
| 1836 | 1835 | |
| 1837 | 1836 | //Logged in only and Register / Login set to none. |
| 1838 | - if ( give_logged_in_only( $form_id ) && give_show_login_register_option( $form_id ) == 'none' ) { |
|
| 1837 | + if (give_logged_in_only($form_id) && give_show_login_register_option($form_id) == 'none') { |
|
| 1839 | 1838 | |
| 1840 | - $final_output = Give()->notices->print_frontend_notice( esc_html__( 'Please log in in order to complete your donation.', 'give' ), false ); |
|
| 1839 | + $final_output = Give()->notices->print_frontend_notice(esc_html__('Please log in in order to complete your donation.', 'give'), false); |
|
| 1841 | 1840 | |
| 1842 | - return apply_filters( 'give_members_only_output', $final_output, $form_id ); |
|
| 1841 | + return apply_filters('give_members_only_output', $final_output, $form_id); |
|
| 1843 | 1842 | |
| 1844 | 1843 | } |
| 1845 | 1844 | |
@@ -1847,7 +1846,7 @@ discard block |
||
| 1847 | 1846 | |
| 1848 | 1847 | } |
| 1849 | 1848 | |
| 1850 | -add_filter( 'give_donate_form', 'give_members_only_form', 10, 2 ); |
|
| 1849 | +add_filter('give_donate_form', 'give_members_only_form', 10, 2); |
|
| 1851 | 1850 | |
| 1852 | 1851 | |
| 1853 | 1852 | /** |
@@ -1859,28 +1858,28 @@ discard block |
||
| 1859 | 1858 | * @param array $args |
| 1860 | 1859 | * @param Give_Donate_Form $form |
| 1861 | 1860 | */ |
| 1862 | -function __give_form_add_donation_hidden_field( $form_id, $args, $form ) { |
|
| 1861 | +function __give_form_add_donation_hidden_field($form_id, $args, $form) { |
|
| 1863 | 1862 | ?> |
| 1864 | 1863 | <input type="hidden" name="give-form-id" value="<?php echo $form_id; ?>"/> |
| 1865 | - <input type="hidden" name="give-form-title" value="<?php echo htmlentities( $form->post_title ); ?>"/> |
|
| 1864 | + <input type="hidden" name="give-form-title" value="<?php echo htmlentities($form->post_title); ?>"/> |
|
| 1866 | 1865 | <input type="hidden" name="give-current-url" |
| 1867 | - value="<?php echo htmlspecialchars( give_get_current_page_url() ); ?>"/> |
|
| 1868 | - <input type="hidden" name="give-form-url" value="<?php echo htmlspecialchars( give_get_current_page_url() ); ?>"/> |
|
| 1866 | + value="<?php echo htmlspecialchars(give_get_current_page_url()); ?>"/> |
|
| 1867 | + <input type="hidden" name="give-form-url" value="<?php echo htmlspecialchars(give_get_current_page_url()); ?>"/> |
|
| 1869 | 1868 | <input type="hidden" name="give-form-minimum" |
| 1870 | - value="<?php echo give_format_amount( give_get_form_minimum_price( $form_id ), array( 'sanitize' => false ) ); ?>"/> |
|
| 1869 | + value="<?php echo give_format_amount(give_get_form_minimum_price($form_id), array('sanitize' => false)); ?>"/> |
|
| 1871 | 1870 | <?php |
| 1872 | 1871 | |
| 1873 | 1872 | // WP nonce field. |
| 1874 | - wp_nonce_field( "donation_form_nonce_{$form_id}", '_wpnonce', false ); |
|
| 1873 | + wp_nonce_field("donation_form_nonce_{$form_id}", '_wpnonce', false); |
|
| 1875 | 1874 | |
| 1876 | 1875 | // Price ID hidden field for variable (multi-level) donation forms. |
| 1877 | - if ( give_has_variable_prices( $form_id ) ) { |
|
| 1876 | + if (give_has_variable_prices($form_id)) { |
|
| 1878 | 1877 | // Get default selected price ID. |
| 1879 | - $prices = apply_filters( 'give_form_variable_prices', give_get_variable_prices( $form_id ), $form_id ); |
|
| 1878 | + $prices = apply_filters('give_form_variable_prices', give_get_variable_prices($form_id), $form_id); |
|
| 1880 | 1879 | $price_id = 0; |
| 1881 | 1880 | //loop through prices. |
| 1882 | - foreach ( $prices as $price ) { |
|
| 1883 | - if ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) { |
|
| 1881 | + foreach ($prices as $price) { |
|
| 1882 | + if (isset($price['_give_default']) && $price['_give_default'] === 'default') { |
|
| 1884 | 1883 | $price_id = $price['_give_id']['level_id']; |
| 1885 | 1884 | }; |
| 1886 | 1885 | } |
@@ -1893,7 +1892,7 @@ discard block |
||
| 1893 | 1892 | } |
| 1894 | 1893 | } |
| 1895 | 1894 | |
| 1896 | -add_action( 'give_donation_form_top', '__give_form_add_donation_hidden_field', 0, 3 ); |
|
| 1895 | +add_action('give_donation_form_top', '__give_form_add_donation_hidden_field', 0, 3); |
|
| 1897 | 1896 | |
| 1898 | 1897 | /** |
| 1899 | 1898 | * Add currency settings on donation form. |
@@ -1905,20 +1904,20 @@ discard block |
||
| 1905 | 1904 | * |
| 1906 | 1905 | * @return array |
| 1907 | 1906 | */ |
| 1908 | -function __give_form_add_currency_settings( $form_html_tags, $form ) { |
|
| 1909 | - $form_currency = give_get_currency( $form->ID ); |
|
| 1910 | - $currency_settings = give_get_currency_formatting_settings( $form_currency ); |
|
| 1907 | +function __give_form_add_currency_settings($form_html_tags, $form) { |
|
| 1908 | + $form_currency = give_get_currency($form->ID); |
|
| 1909 | + $currency_settings = give_get_currency_formatting_settings($form_currency); |
|
| 1911 | 1910 | |
| 1912 | 1911 | // Check if currency exist. |
| 1913 | - if ( empty( $currency_settings ) ) { |
|
| 1912 | + if (empty($currency_settings)) { |
|
| 1914 | 1913 | return $form_html_tags; |
| 1915 | 1914 | } |
| 1916 | 1915 | |
| 1917 | - $form_html_tags['data-currency_symbol'] = give_currency_symbol( $form_currency ); |
|
| 1916 | + $form_html_tags['data-currency_symbol'] = give_currency_symbol($form_currency); |
|
| 1918 | 1917 | $form_html_tags['data-currency_code'] = $form_currency; |
| 1919 | 1918 | |
| 1920 | - if ( ! empty( $currency_settings ) ) { |
|
| 1921 | - foreach ( $currency_settings as $key => $value ) { |
|
| 1919 | + if ( ! empty($currency_settings)) { |
|
| 1920 | + foreach ($currency_settings as $key => $value) { |
|
| 1922 | 1921 | $form_html_tags["data-{$key}"] = $value; |
| 1923 | 1922 | } |
| 1924 | 1923 | } |
@@ -1926,4 +1925,4 @@ discard block |
||
| 1926 | 1925 | return $form_html_tags; |
| 1927 | 1926 | } |
| 1928 | 1927 | |
| 1929 | -add_filter( 'give_form_html_tags', '__give_form_add_currency_settings', 0, 2 ); |
|
| 1928 | +add_filter('give_form_html_tags', '__give_form_add_currency_settings', 0, 2); |
|
@@ -397,7 +397,7 @@ |
||
| 397 | 397 | * |
| 398 | 398 | * @since 1.8.11 |
| 399 | 399 | * |
| 400 | - * @return void |
|
| 400 | + * @return false|null |
|
| 401 | 401 | */ |
| 402 | 402 | function give_create_pages() { |
| 403 | 403 | |
@@ -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 ); |
|
| 66 | + $current_version = get_option('give_version'); |
|
| 67 | + if ($current_version) { |
|
| 68 | + update_option('give_version_upgraded_from', $current_version); |
|
| 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 ) ); |
|
| 80 | + update_option('give_settings', array_merge($give_options, $options)); |
|
| 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 ); |
|
| 89 | + if (GIVE_VERSION !== get_option('give_version')) { |
|
| 90 | + update_option('give_version', GIVE_VERSION); |
|
| 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() ); |
|
| 101 | + update_option('give_default_api_version', 'v'.$api->get_version()); |
|
| 102 | 102 | |
| 103 | 103 | flush_rewrite_rules(); |
| 104 | 104 | |
@@ -113,11 +113,11 @@ discard block |
||
| 113 | 113 | $give_sessions->use_php_sessions(); |
| 114 | 114 | |
| 115 | 115 | // Add a temporary option to note that Give pages have been created. |
| 116 | - Give_Cache::set( '_give_installed', $options, 30, true ); |
|
| 116 | + Give_Cache::set('_give_installed', $options, 30, true); |
|
| 117 | 117 | |
| 118 | - if ( ! $current_version ) { |
|
| 118 | + if ( ! $current_version) { |
|
| 119 | 119 | |
| 120 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php'; |
|
| 120 | + require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrade-functions.php'; |
|
| 121 | 121 | |
| 122 | 122 | // When new upgrade routines are added, mark them as complete on fresh install. |
| 123 | 123 | $upgrade_routines = array( |
@@ -144,18 +144,18 @@ discard block |
||
| 144 | 144 | 'v20_upgrades_payment_metadata' |
| 145 | 145 | ); |
| 146 | 146 | |
| 147 | - foreach ( $upgrade_routines as $upgrade ) { |
|
| 148 | - give_set_upgrade_complete( $upgrade ); |
|
| 147 | + foreach ($upgrade_routines as $upgrade) { |
|
| 148 | + give_set_upgrade_complete($upgrade); |
|
| 149 | 149 | } |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | // Bail if activating from network, or bulk. |
| 153 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
| 153 | + if (is_network_admin() || isset($_GET['activate-multi'])) { |
|
| 154 | 154 | return; |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | // Add the transient to redirect. |
| 158 | - Give_Cache::set( '_give_activation_redirect', true, 30, true ); |
|
| 158 | + Give_Cache::set('_give_activation_redirect', true, 30, true); |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | /** |
@@ -173,11 +173,11 @@ discard block |
||
| 173 | 173 | * @param int $site_id The Site ID. |
| 174 | 174 | * @param array $meta Blog Meta. |
| 175 | 175 | */ |
| 176 | -function give_on_create_blog( $blog_id, $user_id, $domain, $path, $site_id, $meta ) { |
|
| 176 | +function give_on_create_blog($blog_id, $user_id, $domain, $path, $site_id, $meta) { |
|
| 177 | 177 | |
| 178 | - if ( is_plugin_active_for_network( GIVE_PLUGIN_BASENAME ) ) { |
|
| 178 | + if (is_plugin_active_for_network(GIVE_PLUGIN_BASENAME)) { |
|
| 179 | 179 | |
| 180 | - switch_to_blog( $blog_id ); |
|
| 180 | + switch_to_blog($blog_id); |
|
| 181 | 181 | give_install(); |
| 182 | 182 | restore_current_blog(); |
| 183 | 183 | |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | -add_action( 'wpmu_new_blog', 'give_on_create_blog', 10, 6 ); |
|
| 188 | +add_action('wpmu_new_blog', 'give_on_create_blog', 10, 6); |
|
| 189 | 189 | |
| 190 | 190 | |
| 191 | 191 | /** |
@@ -198,13 +198,13 @@ discard block |
||
| 198 | 198 | * |
| 199 | 199 | * @return array The tables to drop. |
| 200 | 200 | */ |
| 201 | -function give_wpmu_drop_tables( $tables, $blog_id ) { |
|
| 201 | +function give_wpmu_drop_tables($tables, $blog_id) { |
|
| 202 | 202 | |
| 203 | - switch_to_blog( $blog_id ); |
|
| 203 | + switch_to_blog($blog_id); |
|
| 204 | 204 | $donors_db = new Give_DB_Donors(); |
| 205 | 205 | $donor_meta_db = new Give_DB_Donor_Meta(); |
| 206 | 206 | |
| 207 | - if ( $donors_db->installed() ) { |
|
| 207 | + if ($donors_db->installed()) { |
|
| 208 | 208 | $tables[] = $donors_db->table_name; |
| 209 | 209 | $tables[] = $donor_meta_db->table_name; |
| 210 | 210 | } |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | |
| 215 | 215 | } |
| 216 | 216 | |
| 217 | -add_filter( 'wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2 ); |
|
| 217 | +add_filter('wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2); |
|
| 218 | 218 | |
| 219 | 219 | /** |
| 220 | 220 | * Post-installation |
@@ -226,16 +226,16 @@ discard block |
||
| 226 | 226 | */ |
| 227 | 227 | function give_after_install() { |
| 228 | 228 | |
| 229 | - if ( ! is_admin() ) { |
|
| 229 | + if ( ! is_admin()) { |
|
| 230 | 230 | return; |
| 231 | 231 | } |
| 232 | 232 | |
| 233 | - $give_options = Give_Cache::get( '_give_installed', true ); |
|
| 234 | - $give_table_check = get_option( '_give_table_check', false ); |
|
| 233 | + $give_options = Give_Cache::get('_give_installed', true); |
|
| 234 | + $give_table_check = get_option('_give_table_check', false); |
|
| 235 | 235 | |
| 236 | - if ( false === $give_table_check || current_time( 'timestamp' ) > $give_table_check ) { |
|
| 236 | + if (false === $give_table_check || current_time('timestamp') > $give_table_check) { |
|
| 237 | 237 | |
| 238 | - if ( ! @Give()->donor_meta->installed() ) { |
|
| 238 | + if ( ! @Give()->donor_meta->installed()) { |
|
| 239 | 239 | |
| 240 | 240 | // Create the donor meta database. |
| 241 | 241 | // (this ensures it creates it on multisite instances where it is network activated). |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | |
| 244 | 244 | } |
| 245 | 245 | |
| 246 | - if ( ! @Give()->donors->installed() ) { |
|
| 246 | + if ( ! @Give()->donors->installed()) { |
|
| 247 | 247 | // Create the donor database. |
| 248 | 248 | // (this ensures it creates it on multisite instances where it is network activated). |
| 249 | 249 | @Give()->donors->create_table(); |
@@ -255,22 +255,22 @@ discard block |
||
| 255 | 255 | * |
| 256 | 256 | * @param array $give_options Give plugin options. |
| 257 | 257 | */ |
| 258 | - do_action( 'give_after_install', $give_options ); |
|
| 258 | + do_action('give_after_install', $give_options); |
|
| 259 | 259 | } |
| 260 | 260 | |
| 261 | - update_option( '_give_table_check', ( current_time( 'timestamp' ) + WEEK_IN_SECONDS ) ); |
|
| 261 | + update_option('_give_table_check', (current_time('timestamp') + WEEK_IN_SECONDS)); |
|
| 262 | 262 | |
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | // Delete the transient |
| 266 | - if ( false !== $give_options ) { |
|
| 267 | - Give_Cache::delete( Give_Cache::get_key( '_give_installed' ) ); |
|
| 266 | + if (false !== $give_options) { |
|
| 267 | + Give_Cache::delete(Give_Cache::get_key('_give_installed')); |
|
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | |
| 271 | 271 | } |
| 272 | 272 | |
| 273 | -add_action( 'admin_init', 'give_after_install' ); |
|
| 273 | +add_action('admin_init', 'give_after_install'); |
|
| 274 | 274 | |
| 275 | 275 | |
| 276 | 276 | /** |
@@ -285,11 +285,11 @@ discard block |
||
| 285 | 285 | |
| 286 | 286 | global $wp_roles; |
| 287 | 287 | |
| 288 | - if ( ! is_object( $wp_roles ) ) { |
|
| 288 | + if ( ! is_object($wp_roles)) { |
|
| 289 | 289 | return; |
| 290 | 290 | } |
| 291 | 291 | |
| 292 | - if ( ! array_key_exists( 'give_manager', $wp_roles->roles ) ) { |
|
| 292 | + if ( ! array_key_exists('give_manager', $wp_roles->roles)) { |
|
| 293 | 293 | |
| 294 | 294 | // Create Give plugin roles |
| 295 | 295 | $roles = new Give_Roles(); |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | |
| 301 | 301 | } |
| 302 | 302 | |
| 303 | -add_action( 'admin_init', 'give_install_roles_on_network' ); |
|
| 303 | +add_action('admin_init', 'give_install_roles_on_network'); |
|
| 304 | 304 | |
| 305 | 305 | /** |
| 306 | 306 | * Default core setting values. |
@@ -339,14 +339,14 @@ discard block |
||
| 339 | 339 | 'uninstall_on_delete' => 'disabled', |
| 340 | 340 | 'the_content_filter' => 'enabled', |
| 341 | 341 | 'scripts_footer' => 'disabled', |
| 342 | - 'agree_to_terms_label' => __( 'Agree to Terms?', 'give' ), |
|
| 342 | + 'agree_to_terms_label' => __('Agree to Terms?', 'give'), |
|
| 343 | 343 | 'agreement_text' => give_get_default_agreement_text(), |
| 344 | 344 | |
| 345 | 345 | // Paypal IPN verification. |
| 346 | 346 | 'paypal_verification' => 'enabled', |
| 347 | 347 | |
| 348 | 348 | // Default is manual gateway. |
| 349 | - 'gateways' => array( 'manual' => 1, 'offline' => 1 ), |
|
| 349 | + 'gateways' => array('manual' => 1, 'offline' => 1), |
|
| 350 | 350 | 'default_gateway' => 'manual', |
| 351 | 351 | |
| 352 | 352 | // Offline gateway setup. |
@@ -374,7 +374,7 @@ discard block |
||
| 374 | 374 | */ |
| 375 | 375 | function give_get_default_agreement_text() { |
| 376 | 376 | |
| 377 | - $org_name = get_bloginfo( 'name' ); |
|
| 377 | + $org_name = get_bloginfo('name'); |
|
| 378 | 378 | |
| 379 | 379 | $agreement = sprintf( |
| 380 | 380 | '<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> |
@@ -388,7 +388,7 @@ discard block |
||
| 388 | 388 | $org_name |
| 389 | 389 | ); |
| 390 | 390 | |
| 391 | - return apply_filters( 'give_get_default_agreement_text', $agreement, $org_name ); |
|
| 391 | + return apply_filters('give_get_default_agreement_text', $agreement, $org_name); |
|
| 392 | 392 | } |
| 393 | 393 | |
| 394 | 394 | |
@@ -402,19 +402,19 @@ discard block |
||
| 402 | 402 | function give_create_pages() { |
| 403 | 403 | |
| 404 | 404 | // Bailout if pages already created. |
| 405 | - if ( get_option( 'give_install_pages_created' ) ) { |
|
| 405 | + if (get_option('give_install_pages_created')) { |
|
| 406 | 406 | return false; |
| 407 | 407 | } |
| 408 | 408 | |
| 409 | 409 | $options = array(); |
| 410 | 410 | |
| 411 | 411 | // Checks if the Success Page option exists AND that the page exists. |
| 412 | - if ( ! get_post( give_get_option( 'success_page' ) ) ) { |
|
| 412 | + if ( ! get_post(give_get_option('success_page'))) { |
|
| 413 | 413 | |
| 414 | 414 | // Donation Confirmation (Success) Page |
| 415 | 415 | $success = wp_insert_post( |
| 416 | 416 | array( |
| 417 | - 'post_title' => esc_html__( 'Donation Confirmation', 'give' ), |
|
| 417 | + 'post_title' => esc_html__('Donation Confirmation', 'give'), |
|
| 418 | 418 | 'post_content' => '[give_receipt]', |
| 419 | 419 | 'post_status' => 'publish', |
| 420 | 420 | 'post_author' => 1, |
@@ -428,13 +428,13 @@ discard block |
||
| 428 | 428 | } |
| 429 | 429 | |
| 430 | 430 | // Checks if the Failure Page option exists AND that the page exists. |
| 431 | - if ( ! get_post( give_get_option( 'failure_page' ) ) ) { |
|
| 431 | + if ( ! get_post(give_get_option('failure_page'))) { |
|
| 432 | 432 | |
| 433 | 433 | // Failed Donation Page |
| 434 | 434 | $failed = wp_insert_post( |
| 435 | 435 | array( |
| 436 | - 'post_title' => esc_html__( 'Donation Failed', 'give' ), |
|
| 437 | - 'post_content' => esc_html__( 'We\'re sorry, your donation failed to process. Please try again or contact site support.', 'give' ), |
|
| 436 | + 'post_title' => esc_html__('Donation Failed', 'give'), |
|
| 437 | + 'post_content' => esc_html__('We\'re sorry, your donation failed to process. Please try again or contact site support.', 'give'), |
|
| 438 | 438 | 'post_status' => 'publish', |
| 439 | 439 | 'post_author' => 1, |
| 440 | 440 | 'post_type' => 'page', |
@@ -446,11 +446,11 @@ discard block |
||
| 446 | 446 | } |
| 447 | 447 | |
| 448 | 448 | // Checks if the History Page option exists AND that the page exists. |
| 449 | - if ( ! get_post( give_get_option( 'history_page' ) ) ) { |
|
| 449 | + if ( ! get_post(give_get_option('history_page'))) { |
|
| 450 | 450 | // Donation History Page |
| 451 | 451 | $history = wp_insert_post( |
| 452 | 452 | array( |
| 453 | - 'post_title' => esc_html__( 'Donation History', 'give' ), |
|
| 453 | + 'post_title' => esc_html__('Donation History', 'give'), |
|
| 454 | 454 | 'post_content' => '[donation_history]', |
| 455 | 455 | 'post_status' => 'publish', |
| 456 | 456 | 'post_author' => 1, |
@@ -462,11 +462,11 @@ discard block |
||
| 462 | 462 | $options['history_page'] = $history; |
| 463 | 463 | } |
| 464 | 464 | |
| 465 | - if ( ! empty( $options ) ) { |
|
| 466 | - update_option( 'give_settings', array_merge( give_get_settings(), $options ) ); |
|
| 465 | + if ( ! empty($options)) { |
|
| 466 | + update_option('give_settings', array_merge(give_get_settings(), $options)); |
|
| 467 | 467 | } |
| 468 | 468 | |
| 469 | - add_option( 'give_install_pages_created', 1, '', 'no' ); |
|
| 469 | + add_option('give_install_pages_created', 1, '', 'no'); |
|
| 470 | 470 | } |
| 471 | 471 | |
| 472 | -add_action( 'admin_init', 'give_create_pages', - 1 ); |
|
| 472 | +add_action('admin_init', 'give_create_pages', - 1); |
|
@@ -207,7 +207,7 @@ |
||
| 207 | 207 | * metadata entries with the specified value. |
| 208 | 208 | * Otherwise, update all entries. |
| 209 | 209 | * |
| 210 | - * @return mixed |
|
| 210 | + * @return null|boolean |
|
| 211 | 211 | */ |
| 212 | 212 | function _give_20_bc_saving_old_payment_meta( $check, $object_id, $meta_key, $meta_value, $prev_value ) { |
| 213 | 213 | // Bailout. |
@@ -9,74 +9,74 @@ discard block |
||
| 9 | 9 | * |
| 10 | 10 | * @return void |
| 11 | 11 | */ |
| 12 | -function _give_20_bc_split_and_save_give_payment_meta( $object_id, $meta_value ) { |
|
| 12 | +function _give_20_bc_split_and_save_give_payment_meta($object_id, $meta_value) { |
|
| 13 | 13 | // Bailout |
| 14 | - if ( empty( $meta_value ) ) { |
|
| 14 | + if (empty($meta_value)) { |
|
| 15 | 15 | return; |
| 16 | - } elseif ( ! is_array( $meta_value ) ) { |
|
| 16 | + } elseif ( ! is_array($meta_value)) { |
|
| 17 | 17 | $meta_value = array(); |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | - remove_filter( 'get_post_metadata', '_give_20_bc_get_new_payment_meta', 10 ); |
|
| 20 | + remove_filter('get_post_metadata', '_give_20_bc_get_new_payment_meta', 10); |
|
| 21 | 21 | |
| 22 | 22 | // Date payment meta. |
| 23 | - if ( ! empty( $meta_value['date'] ) ) { |
|
| 24 | - give_update_meta( $object_id, '_give_payment_date', $meta_value['date'] ); |
|
| 23 | + if ( ! empty($meta_value['date'])) { |
|
| 24 | + give_update_meta($object_id, '_give_payment_date', $meta_value['date']); |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | // Currency payment meta. |
| 28 | - if ( ! empty( $meta_value['currency'] ) ) { |
|
| 29 | - give_update_meta( $object_id, '_give_payment_currency', $meta_value['currency'] ); |
|
| 28 | + if ( ! empty($meta_value['currency'])) { |
|
| 29 | + give_update_meta($object_id, '_give_payment_currency', $meta_value['currency']); |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | // User information. |
| 33 | - if ( ! empty( $meta_value['user_info'] ) ) { |
|
| 33 | + if ( ! empty($meta_value['user_info'])) { |
|
| 34 | 34 | // Donor first name. |
| 35 | - if ( ! empty( $meta_value['user_info']['first_name'] ) ) { |
|
| 36 | - give_update_meta( $object_id, '_give_donor_billing_first_name', $meta_value['user_info']['first_name'] ); |
|
| 35 | + if ( ! empty($meta_value['user_info']['first_name'])) { |
|
| 36 | + give_update_meta($object_id, '_give_donor_billing_first_name', $meta_value['user_info']['first_name']); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | // Donor last name. |
| 40 | - if ( ! empty( $meta_value['user_info']['last_name'] ) ) { |
|
| 41 | - give_update_meta( $object_id, '_give_donor_billing_last_name', $meta_value['user_info']['last_name'] ); |
|
| 40 | + if ( ! empty($meta_value['user_info']['last_name'])) { |
|
| 41 | + give_update_meta($object_id, '_give_donor_billing_last_name', $meta_value['user_info']['last_name']); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | // Donor address payment meta. |
| 45 | - if ( ! empty( $meta_value['user_info']['address'] ) ) { |
|
| 45 | + if ( ! empty($meta_value['user_info']['address'])) { |
|
| 46 | 46 | |
| 47 | 47 | // Address1. |
| 48 | - if ( ! empty( $meta_value['user_info']['address']['line1'] ) ) { |
|
| 49 | - give_update_meta( $object_id, '_give_donor_billing_address1', $meta_value['user_info']['address']['line1'] ); |
|
| 48 | + if ( ! empty($meta_value['user_info']['address']['line1'])) { |
|
| 49 | + give_update_meta($object_id, '_give_donor_billing_address1', $meta_value['user_info']['address']['line1']); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | // Address2. |
| 53 | - if ( ! empty( $meta_value['user_info']['address']['line2'] ) ) { |
|
| 54 | - give_update_meta( $object_id, '_give_donor_billing_address2', $meta_value['user_info']['address']['line2'] ); |
|
| 53 | + if ( ! empty($meta_value['user_info']['address']['line2'])) { |
|
| 54 | + give_update_meta($object_id, '_give_donor_billing_address2', $meta_value['user_info']['address']['line2']); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | // City. |
| 58 | - if ( ! empty( $meta_value['user_info']['address']['city'] ) ) { |
|
| 59 | - give_update_meta( $object_id, '_give_donor_billing_city', $meta_value['user_info']['address']['city'] ); |
|
| 58 | + if ( ! empty($meta_value['user_info']['address']['city'])) { |
|
| 59 | + give_update_meta($object_id, '_give_donor_billing_city', $meta_value['user_info']['address']['city']); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | // Zip. |
| 63 | - if ( ! empty( $meta_value['user_info']['address']['zip'] ) ) { |
|
| 64 | - give_update_meta( $object_id, '_give_donor_billing_zip', $meta_value['user_info']['address']['zip'] ); |
|
| 63 | + if ( ! empty($meta_value['user_info']['address']['zip'])) { |
|
| 64 | + give_update_meta($object_id, '_give_donor_billing_zip', $meta_value['user_info']['address']['zip']); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | // State. |
| 68 | - if ( ! empty( $meta_value['user_info']['address']['state'] ) ) { |
|
| 69 | - give_update_meta( $object_id, '_give_donor_billing_state', $meta_value['user_info']['address']['state'] ); |
|
| 68 | + if ( ! empty($meta_value['user_info']['address']['state'])) { |
|
| 69 | + give_update_meta($object_id, '_give_donor_billing_state', $meta_value['user_info']['address']['state']); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | // Country. |
| 73 | - if ( ! empty( $meta_value['user_info']['address']['country'] ) ) { |
|
| 74 | - give_update_meta( $object_id, '_give_donor_billing_country', $meta_value['user_info']['address']['country'] ); |
|
| 73 | + if ( ! empty($meta_value['user_info']['address']['country'])) { |
|
| 74 | + give_update_meta($object_id, '_give_donor_billing_country', $meta_value['user_info']['address']['country']); |
|
| 75 | 75 | } |
| 76 | 76 | } |
| 77 | 77 | }// End if(). |
| 78 | 78 | |
| 79 | - add_filter( 'get_post_metadata', '_give_20_bc_get_new_payment_meta', 10, 5 ); |
|
| 79 | + add_filter('get_post_metadata', '_give_20_bc_get_new_payment_meta', 10, 5); |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | /** |
@@ -89,103 +89,99 @@ discard block |
||
| 89 | 89 | * |
| 90 | 90 | * @return array |
| 91 | 91 | */ |
| 92 | -function _give_20_bc_give_payment_meta_value( $object_id, $meta_value ) { |
|
| 92 | +function _give_20_bc_give_payment_meta_value($object_id, $meta_value) { |
|
| 93 | 93 | $cache_key = "_give_payment_meta_{$object_id}"; |
| 94 | - $cache = Give_Cache::get_db_query( $cache_key ); |
|
| 94 | + $cache = Give_Cache::get_db_query($cache_key); |
|
| 95 | 95 | |
| 96 | - if ( ! is_null( $cache ) ) { |
|
| 96 | + if ( ! is_null($cache)) { |
|
| 97 | 97 | return $cache; |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | // Set default value to array. |
| 101 | - if ( ! is_array( $meta_value ) ) { |
|
| 101 | + if ( ! is_array($meta_value)) { |
|
| 102 | 102 | $meta_value = array(); |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | // Donation key. |
| 106 | - $meta_value['key'] = give_get_meta( $object_id, '_give_payment_purchase_key', true ); |
|
| 106 | + $meta_value['key'] = give_get_meta($object_id, '_give_payment_purchase_key', true); |
|
| 107 | 107 | |
| 108 | 108 | // Donation form. |
| 109 | - $meta_value['form_title'] = give_get_meta( $object_id, '_give_payment_form_title', true ); |
|
| 109 | + $meta_value['form_title'] = give_get_meta($object_id, '_give_payment_form_title', true); |
|
| 110 | 110 | |
| 111 | 111 | // Donor email. |
| 112 | - $meta_value['email'] = give_get_meta( $object_id, '_give_payment_donor_email', true ); |
|
| 113 | - $meta_value['email'] = ! empty( $meta_value['email'] ) ? |
|
| 114 | - $meta_value['email'] : |
|
| 115 | - Give()->donors->get_column( 'email', give_get_payment_donor_id( $object_id ) ); |
|
| 112 | + $meta_value['email'] = give_get_meta($object_id, '_give_payment_donor_email', true); |
|
| 113 | + $meta_value['email'] = ! empty($meta_value['email']) ? |
|
| 114 | + $meta_value['email'] : Give()->donors->get_column('email', give_get_payment_donor_id($object_id)); |
|
| 116 | 115 | |
| 117 | 116 | // Form id. |
| 118 | - $meta_value['form_id'] = give_get_meta( $object_id, '_give_payment_form_id', true ); |
|
| 117 | + $meta_value['form_id'] = give_get_meta($object_id, '_give_payment_form_id', true); |
|
| 119 | 118 | |
| 120 | 119 | // Price id. |
| 121 | - $meta_value['price_id'] = give_get_meta( $object_id, '_give_payment_price_id', true ); |
|
| 120 | + $meta_value['price_id'] = give_get_meta($object_id, '_give_payment_price_id', true); |
|
| 122 | 121 | |
| 123 | 122 | // Date. |
| 124 | - $meta_value['date'] = give_get_meta( $object_id, '_give_payment_date', true ); |
|
| 125 | - $meta_value['date'] = ! empty( $meta_value['date'] ) ? |
|
| 126 | - $meta_value['date'] : |
|
| 127 | - get_post_field( 'post_date', $object_id ); |
|
| 123 | + $meta_value['date'] = give_get_meta($object_id, '_give_payment_date', true); |
|
| 124 | + $meta_value['date'] = ! empty($meta_value['date']) ? |
|
| 125 | + $meta_value['date'] : get_post_field('post_date', $object_id); |
|
| 128 | 126 | |
| 129 | 127 | // Currency. |
| 130 | - $meta_value['currency'] = give_get_meta( $object_id, '_give_payment_currency', true ); |
|
| 128 | + $meta_value['currency'] = give_get_meta($object_id, '_give_payment_currency', true); |
|
| 131 | 129 | |
| 132 | 130 | // Decode donor data. |
| 133 | - $donor_names = give_get_donor_name_by( give_get_meta( $object_id, '_give_payment_donor_id', true ), 'donor' ); |
|
| 134 | - $donor_names = explode( ' ', $donor_names, 2 ); |
|
| 131 | + $donor_names = give_get_donor_name_by(give_get_meta($object_id, '_give_payment_donor_id', true), 'donor'); |
|
| 132 | + $donor_names = explode(' ', $donor_names, 2); |
|
| 135 | 133 | |
| 136 | 134 | // Donor first name. |
| 137 | - $donor_data['first_name'] = give_get_meta( $object_id, '_give_donor_billing_first_name', true ); |
|
| 138 | - $donor_data['first_name'] = ! empty( $donor_data['first_name'] ) ? |
|
| 139 | - $donor_data['first_name'] : |
|
| 140 | - $donor_names[0]; |
|
| 135 | + $donor_data['first_name'] = give_get_meta($object_id, '_give_donor_billing_first_name', true); |
|
| 136 | + $donor_data['first_name'] = ! empty($donor_data['first_name']) ? |
|
| 137 | + $donor_data['first_name'] : $donor_names[0]; |
|
| 141 | 138 | |
| 142 | 139 | // Donor last name. |
| 143 | - $donor_data['last_name'] = give_get_meta( $object_id, '_give_donor_billing_last_name', true ); |
|
| 144 | - $donor_data['last_name'] = ! empty( $donor_data['last_name'] ) ? |
|
| 145 | - $donor_data['last_name'] : |
|
| 146 | - ( isset( $donor_names[1] ) ? $donor_names[1] : '' ); |
|
| 140 | + $donor_data['last_name'] = give_get_meta($object_id, '_give_donor_billing_last_name', true); |
|
| 141 | + $donor_data['last_name'] = ! empty($donor_data['last_name']) ? |
|
| 142 | + $donor_data['last_name'] : (isset($donor_names[1]) ? $donor_names[1] : ''); |
|
| 147 | 143 | |
| 148 | 144 | // Donor email. |
| 149 | 145 | $donor_data['email'] = $meta_value['email']; |
| 150 | 146 | |
| 151 | 147 | // User ID. |
| 152 | - $donor_data['id'] = give_get_payment_user_id( $object_id ); |
|
| 148 | + $donor_data['id'] = give_get_payment_user_id($object_id); |
|
| 153 | 149 | |
| 154 | 150 | $donor_data['address'] = false; |
| 155 | 151 | |
| 156 | 152 | // Address1. |
| 157 | - if ( $address1 = give_get_meta( $object_id, '_give_donor_billing_address1', true ) ) { |
|
| 153 | + if ($address1 = give_get_meta($object_id, '_give_donor_billing_address1', true)) { |
|
| 158 | 154 | $donor_data['address']['line1'] = $address1; |
| 159 | 155 | } |
| 160 | 156 | |
| 161 | 157 | // Address2. |
| 162 | - if ( $address2 = give_get_meta( $object_id, '_give_donor_billing_address2', true ) ) { |
|
| 158 | + if ($address2 = give_get_meta($object_id, '_give_donor_billing_address2', true)) { |
|
| 163 | 159 | $donor_data['address']['line2'] = $address2; |
| 164 | 160 | } |
| 165 | 161 | |
| 166 | 162 | // City. |
| 167 | - if ( $city = give_get_meta( $object_id, '_give_donor_billing_city', true ) ) { |
|
| 163 | + if ($city = give_get_meta($object_id, '_give_donor_billing_city', true)) { |
|
| 168 | 164 | $donor_data['address']['city'] = $city; |
| 169 | 165 | } |
| 170 | 166 | |
| 171 | 167 | // Zip. |
| 172 | - if ( $zip = give_get_meta( $object_id, '_give_donor_billing_zip', true ) ) { |
|
| 168 | + if ($zip = give_get_meta($object_id, '_give_donor_billing_zip', true)) { |
|
| 173 | 169 | $donor_data['address']['zip'] = $zip; |
| 174 | 170 | } |
| 175 | 171 | |
| 176 | 172 | // State. |
| 177 | - if ( $state = give_get_meta( $object_id, '_give_donor_billing_state', true ) ) { |
|
| 173 | + if ($state = give_get_meta($object_id, '_give_donor_billing_state', true)) { |
|
| 178 | 174 | $donor_data['address']['state'] = $state; |
| 179 | 175 | } |
| 180 | 176 | |
| 181 | 177 | // Country. |
| 182 | - if ( $country = give_get_meta( $object_id, '_give_donor_billing_country', true ) ) { |
|
| 178 | + if ($country = give_get_meta($object_id, '_give_donor_billing_country', true)) { |
|
| 183 | 179 | $donor_data['address']['country'] = $country; |
| 184 | 180 | } |
| 185 | 181 | |
| 186 | - $meta_value['user_info'] = maybe_unserialize( $donor_data ); |
|
| 182 | + $meta_value['user_info'] = maybe_unserialize($donor_data); |
|
| 187 | 183 | |
| 188 | - Give_Cache::set_db_query( $cache_key, $meta_value ); |
|
| 184 | + Give_Cache::set_db_query($cache_key, $meta_value); |
|
| 189 | 185 | |
| 190 | 186 | return $meta_value; |
| 191 | 187 | } |
@@ -209,37 +205,37 @@ discard block |
||
| 209 | 205 | * |
| 210 | 206 | * @return mixed |
| 211 | 207 | */ |
| 212 | -function _give_20_bc_saving_old_payment_meta( $check, $object_id, $meta_key, $meta_value, $prev_value ) { |
|
| 208 | +function _give_20_bc_saving_old_payment_meta($check, $object_id, $meta_key, $meta_value, $prev_value) { |
|
| 213 | 209 | // Bailout. |
| 214 | 210 | if ( |
| 215 | - 'give_payment' !== get_post_type( $object_id ) || |
|
| 216 | - ! in_array( $meta_key, array( |
|
| 211 | + 'give_payment' !== get_post_type($object_id) || |
|
| 212 | + ! in_array($meta_key, array( |
|
| 217 | 213 | '_give_payment_meta', |
| 218 | 214 | '_give_payment_user_email', |
| 219 | 215 | '_give_payment_customer_id', |
| 220 | 216 | 'give_payment_user_ip', |
| 221 | - ) ) |
|
| 217 | + )) |
|
| 222 | 218 | ) { |
| 223 | 219 | return $check; |
| 224 | 220 | } |
| 225 | 221 | |
| 226 | - if ( '_give_payment_meta' === $meta_key ) { |
|
| 227 | - _give_20_bc_split_and_save_give_payment_meta( $object_id, $meta_value ); |
|
| 228 | - } elseif ( '_give_payment_user_email' === $meta_key ) { |
|
| 229 | - give_update_meta( $object_id, '_give_payment_donor_email', $meta_value ); |
|
| 222 | + if ('_give_payment_meta' === $meta_key) { |
|
| 223 | + _give_20_bc_split_and_save_give_payment_meta($object_id, $meta_value); |
|
| 224 | + } elseif ('_give_payment_user_email' === $meta_key) { |
|
| 225 | + give_update_meta($object_id, '_give_payment_donor_email', $meta_value); |
|
| 230 | 226 | $check = true; |
| 231 | - } elseif ( '_give_payment_customer_id' === $meta_key ) { |
|
| 232 | - give_update_meta( $object_id, '_give_payment_donor_id', $meta_value ); |
|
| 227 | + } elseif ('_give_payment_customer_id' === $meta_key) { |
|
| 228 | + give_update_meta($object_id, '_give_payment_donor_id', $meta_value); |
|
| 233 | 229 | $check = true; |
| 234 | - } elseif ( 'give_payment_user_ip' === $meta_key ) { |
|
| 235 | - give_update_meta( $object_id, '_give_payment_donor_ip', $meta_value ); |
|
| 230 | + } elseif ('give_payment_user_ip' === $meta_key) { |
|
| 231 | + give_update_meta($object_id, '_give_payment_donor_ip', $meta_value); |
|
| 236 | 232 | $check = true; |
| 237 | 233 | } |
| 238 | 234 | |
| 239 | 235 | return $check; |
| 240 | 236 | } |
| 241 | 237 | |
| 242 | -add_filter( 'update_post_metadata', '_give_20_bc_saving_old_payment_meta', 10, 5 ); |
|
| 238 | +add_filter('update_post_metadata', '_give_20_bc_saving_old_payment_meta', 10, 5); |
|
| 243 | 239 | |
| 244 | 240 | |
| 245 | 241 | /** |
@@ -254,7 +250,7 @@ discard block |
||
| 254 | 250 | * |
| 255 | 251 | * @return mixed |
| 256 | 252 | */ |
| 257 | -function _give_20_bc_get_old_payment_meta( $check, $object_id, $meta_key, $single ) { |
|
| 253 | +function _give_20_bc_get_old_payment_meta($check, $object_id, $meta_key, $single) { |
|
| 258 | 254 | global $wpdb; |
| 259 | 255 | |
| 260 | 256 | // Deprecated meta keys. |
@@ -265,32 +261,31 @@ discard block |
||
| 265 | 261 | ); |
| 266 | 262 | |
| 267 | 263 | // Add _give_payment_meta to backward compatibility |
| 268 | - if ( ! give_has_upgrade_completed( 'v20_upgrades_payment_metadata' ) ) { |
|
| 264 | + if ( ! give_has_upgrade_completed('v20_upgrades_payment_metadata')) { |
|
| 269 | 265 | $old_meta_keys[] = '_give_payment_meta'; |
| 270 | 266 | } |
| 271 | 267 | |
| 272 | 268 | // Bailout. |
| 273 | 269 | if ( |
| 274 | - 'give_payment' !== get_post_type( $object_id ) || |
|
| 275 | - ! in_array( $meta_key, $old_meta_keys ) |
|
| 270 | + 'give_payment' !== get_post_type($object_id) || |
|
| 271 | + ! in_array($meta_key, $old_meta_keys) |
|
| 276 | 272 | ) { |
| 277 | 273 | return $check; |
| 278 | 274 | } |
| 279 | 275 | |
| 280 | 276 | $cache_key = "{$meta_key}_{$object_id}"; |
| 281 | - $check = Give_Cache::get_db_query( $cache_key ); |
|
| 277 | + $check = Give_Cache::get_db_query($cache_key); |
|
| 282 | 278 | |
| 283 | - if ( is_null( $check ) ) { |
|
| 284 | - switch ( $meta_key ) { |
|
| 279 | + if (is_null($check)) { |
|
| 280 | + switch ($meta_key) { |
|
| 285 | 281 | |
| 286 | 282 | // Handle old meta keys. |
| 287 | 283 | case '_give_payment_meta': |
| 288 | - remove_filter( 'get_post_metadata', '_give_20_bc_get_old_payment_meta' ); |
|
| 284 | + remove_filter('get_post_metadata', '_give_20_bc_get_old_payment_meta'); |
|
| 289 | 285 | |
| 290 | 286 | // if ( $meta_value = give_get_meta( $object_id, '_give_payment_meta' ) ) { |
| 291 | - $meta_value = ! empty( $meta_value ) ? |
|
| 292 | - current( $meta_value ) : |
|
| 293 | - (array) maybe_unserialize( |
|
| 287 | + $meta_value = ! empty($meta_value) ? |
|
| 288 | + current($meta_value) : (array) maybe_unserialize( |
|
| 294 | 289 | $wpdb->get_var( |
| 295 | 290 | $wpdb->prepare( |
| 296 | 291 | " |
@@ -304,44 +299,44 @@ discard block |
||
| 304 | 299 | ) |
| 305 | 300 | ) |
| 306 | 301 | ); |
| 307 | - $check = _give_20_bc_give_payment_meta_value( $object_id, $meta_value ); |
|
| 302 | + $check = _give_20_bc_give_payment_meta_value($object_id, $meta_value); |
|
| 308 | 303 | // } |
| 309 | 304 | |
| 310 | - add_filter( 'get_post_metadata', '_give_20_bc_get_old_payment_meta', 10, 5 ); |
|
| 305 | + add_filter('get_post_metadata', '_give_20_bc_get_old_payment_meta', 10, 5); |
|
| 311 | 306 | |
| 312 | 307 | break; |
| 313 | 308 | |
| 314 | 309 | case '_give_payment_customer_id': |
| 315 | - if ( $donor_id = give_get_meta( $object_id, '_give_payment_donor_id', $single ) ) { |
|
| 310 | + if ($donor_id = give_get_meta($object_id, '_give_payment_donor_id', $single)) { |
|
| 316 | 311 | $check = $donor_id; |
| 317 | 312 | } |
| 318 | 313 | break; |
| 319 | 314 | |
| 320 | 315 | case '_give_payment_user_email': |
| 321 | - if ( $donor_email = give_get_meta( $object_id, '_give_payment_donor_email', $single ) ) { |
|
| 316 | + if ($donor_email = give_get_meta($object_id, '_give_payment_donor_email', $single)) { |
|
| 322 | 317 | $check = $donor_email; |
| 323 | 318 | } |
| 324 | 319 | break; |
| 325 | 320 | |
| 326 | 321 | case '_give_payment_user_ip': |
| 327 | - if ( $donor_ip = give_get_meta( $object_id, '_give_payment_donor_ip', $single ) ) { |
|
| 322 | + if ($donor_ip = give_get_meta($object_id, '_give_payment_donor_ip', $single)) { |
|
| 328 | 323 | $check = $donor_ip; |
| 329 | 324 | } |
| 330 | 325 | break; |
| 331 | 326 | }// End switch(). |
| 332 | 327 | |
| 333 | - Give_Cache::set_db_query( $cache_key, $check ); |
|
| 328 | + Give_Cache::set_db_query($cache_key, $check); |
|
| 334 | 329 | } |
| 335 | 330 | |
| 336 | 331 | // Put result in an array on zero index. |
| 337 | - if ( ! is_null( $check ) ) { |
|
| 338 | - $check = array( $check ); |
|
| 332 | + if ( ! is_null($check)) { |
|
| 333 | + $check = array($check); |
|
| 339 | 334 | } |
| 340 | 335 | |
| 341 | 336 | return $check; |
| 342 | 337 | } |
| 343 | 338 | |
| 344 | -add_filter( 'get_post_metadata', '_give_20_bc_get_old_payment_meta', 10, 5 ); |
|
| 339 | +add_filter('get_post_metadata', '_give_20_bc_get_old_payment_meta', 10, 5); |
|
| 345 | 340 | |
| 346 | 341 | |
| 347 | 342 | /** |
@@ -356,9 +351,9 @@ discard block |
||
| 356 | 351 | * |
| 357 | 352 | * @return mixed |
| 358 | 353 | */ |
| 359 | -function _give_20_bc_get_new_payment_meta( $check, $object_id, $meta_key, $single ) { |
|
| 354 | +function _give_20_bc_get_new_payment_meta($check, $object_id, $meta_key, $single) { |
|
| 360 | 355 | // Bailout: do not apply backward compatibility if upgrade done. |
| 361 | - if ( give_has_upgrade_completed( 'v20_upgrades_payment_metadata' ) ) { |
|
| 356 | + if (give_has_upgrade_completed('v20_upgrades_payment_metadata')) { |
|
| 362 | 357 | return $check; |
| 363 | 358 | } |
| 364 | 359 | |
@@ -380,26 +375,26 @@ discard block |
||
| 380 | 375 | ); |
| 381 | 376 | |
| 382 | 377 | // metadata_exists fx will cause of firing get_post_metadata filter again so remove it to prevent infinite loop. |
| 383 | - remove_filter( 'get_post_metadata', '_give_20_bc_get_new_payment_meta' ); |
|
| 378 | + remove_filter('get_post_metadata', '_give_20_bc_get_new_payment_meta'); |
|
| 384 | 379 | |
| 385 | 380 | // Bailout. |
| 386 | 381 | if ( |
| 387 | - 'give_payment' !== get_post_type( $object_id ) || |
|
| 388 | - ! in_array( $meta_key, $new_meta_keys ) || |
|
| 389 | - metadata_exists( 'post', $object_id, $meta_key ) |
|
| 382 | + 'give_payment' !== get_post_type($object_id) || |
|
| 383 | + ! in_array($meta_key, $new_meta_keys) || |
|
| 384 | + metadata_exists('post', $object_id, $meta_key) |
|
| 390 | 385 | ) { |
| 391 | - add_filter( 'get_post_metadata', '_give_20_bc_get_new_payment_meta', 10, 5 ); |
|
| 386 | + add_filter('get_post_metadata', '_give_20_bc_get_new_payment_meta', 10, 5); |
|
| 392 | 387 | |
| 393 | 388 | return $check; |
| 394 | 389 | } |
| 395 | 390 | |
| 396 | - add_filter( 'get_post_metadata', '_give_20_bc_get_new_payment_meta', 10, 5 ); |
|
| 391 | + add_filter('get_post_metadata', '_give_20_bc_get_new_payment_meta', 10, 5); |
|
| 397 | 392 | |
| 398 | 393 | $cache_key = "{$meta_key}_{$object_id}"; |
| 399 | - $check = Give_Cache::get_db_query( $cache_key ); |
|
| 394 | + $check = Give_Cache::get_db_query($cache_key); |
|
| 400 | 395 | |
| 401 | - if ( is_null( $check ) ) { |
|
| 402 | - switch ( $meta_key ) { |
|
| 396 | + if (is_null($check)) { |
|
| 397 | + switch ($meta_key) { |
|
| 403 | 398 | |
| 404 | 399 | // Handle new meta keys. |
| 405 | 400 | case '_give_payment_donor_id': |
@@ -442,9 +437,9 @@ discard block |
||
| 442 | 437 | case '_give_donor_billing_country': |
| 443 | 438 | case '_give_payment_date': |
| 444 | 439 | case '_give_payment_currency': |
| 445 | - $donation_meta = Give_Cache::get_db_query( "_give_payment_meta_{$object_id}" ); |
|
| 440 | + $donation_meta = Give_Cache::get_db_query("_give_payment_meta_{$object_id}"); |
|
| 446 | 441 | |
| 447 | - if ( is_null( $donation_meta ) ) { |
|
| 442 | + if (is_null($donation_meta)) { |
|
| 448 | 443 | $donation_meta = $wpdb->get_var( |
| 449 | 444 | $wpdb->prepare( |
| 450 | 445 | "SELECT meta_value FROM {$wpdb->postmeta} WHERE post_id=%d AND meta_key=%s", |
@@ -452,51 +447,51 @@ discard block |
||
| 452 | 447 | '_give_payment_meta' |
| 453 | 448 | ) |
| 454 | 449 | ); |
| 455 | - $donation_meta = maybe_unserialize( $donation_meta ); |
|
| 456 | - $donation_meta = ! is_array( $donation_meta ) ? array() : $donation_meta; |
|
| 457 | - Give_Cache::set_db_query( "_give_payment_meta_{$object_id}", $donation_meta ); |
|
| 450 | + $donation_meta = maybe_unserialize($donation_meta); |
|
| 451 | + $donation_meta = ! is_array($donation_meta) ? array() : $donation_meta; |
|
| 452 | + Give_Cache::set_db_query("_give_payment_meta_{$object_id}", $donation_meta); |
|
| 458 | 453 | } |
| 459 | 454 | |
| 460 | 455 | // Get results. |
| 461 | - if ( empty( $donation_meta ) ) { |
|
| 456 | + if (empty($donation_meta)) { |
|
| 462 | 457 | $check = ''; |
| 463 | - } elseif ( in_array( $meta_key, array( '_give_payment_date', '_give_payment_currency' ) ) ) { |
|
| 464 | - $payment_meta_key = str_replace( '_give_payment_', '', $meta_key ); |
|
| 458 | + } elseif (in_array($meta_key, array('_give_payment_date', '_give_payment_currency'))) { |
|
| 459 | + $payment_meta_key = str_replace('_give_payment_', '', $meta_key); |
|
| 465 | 460 | |
| 466 | - if ( isset( $donation_meta[ $payment_meta_key ] ) ) { |
|
| 467 | - $check = $donation_meta[ $payment_meta_key ]; |
|
| 461 | + if (isset($donation_meta[$payment_meta_key])) { |
|
| 462 | + $check = $donation_meta[$payment_meta_key]; |
|
| 468 | 463 | } |
| 469 | 464 | } else { |
| 470 | - $payment_meta_key = str_replace( '_give_donor_billing_', '', $meta_key ); |
|
| 465 | + $payment_meta_key = str_replace('_give_donor_billing_', '', $meta_key); |
|
| 471 | 466 | |
| 472 | - switch ( $payment_meta_key ) { |
|
| 467 | + switch ($payment_meta_key) { |
|
| 473 | 468 | case 'address1': |
| 474 | - if ( isset( $donation_meta['user_info']['address']['line1'] ) ) { |
|
| 469 | + if (isset($donation_meta['user_info']['address']['line1'])) { |
|
| 475 | 470 | $check = $donation_meta['user_info']['address']['line1']; |
| 476 | 471 | } |
| 477 | 472 | break; |
| 478 | 473 | |
| 479 | 474 | case 'address2': |
| 480 | - if ( isset( $donation_meta['user_info']['address']['line2'] ) ) { |
|
| 475 | + if (isset($donation_meta['user_info']['address']['line2'])) { |
|
| 481 | 476 | $check = $donation_meta['user_info']['address']['line2']; |
| 482 | 477 | } |
| 483 | 478 | break; |
| 484 | 479 | |
| 485 | 480 | case 'first_name': |
| 486 | - if ( isset( $donation_meta['user_info']['first_name'] ) ) { |
|
| 481 | + if (isset($donation_meta['user_info']['first_name'])) { |
|
| 487 | 482 | $check = $donation_meta['user_info']['first_name']; |
| 488 | 483 | } |
| 489 | 484 | break; |
| 490 | 485 | |
| 491 | 486 | case 'last_name': |
| 492 | - if ( isset( $donation_meta['user_info']['last_name'] ) ) { |
|
| 487 | + if (isset($donation_meta['user_info']['last_name'])) { |
|
| 493 | 488 | $check = $donation_meta['user_info']['last_name']; |
| 494 | 489 | } |
| 495 | 490 | break; |
| 496 | 491 | |
| 497 | 492 | default: |
| 498 | - if ( isset( $donation_meta['user_info']['address'][ $payment_meta_key ] ) ) { |
|
| 499 | - $check = $donation_meta['user_info']['address'][ $payment_meta_key ]; |
|
| 493 | + if (isset($donation_meta['user_info']['address'][$payment_meta_key])) { |
|
| 494 | + $check = $donation_meta['user_info']['address'][$payment_meta_key]; |
|
| 500 | 495 | } |
| 501 | 496 | } |
| 502 | 497 | } |
@@ -505,19 +500,19 @@ discard block |
||
| 505 | 500 | }// End switch(). |
| 506 | 501 | |
| 507 | 502 | // Set cache. |
| 508 | - Give_Cache::set_db_query( $cache_key, $check ); |
|
| 503 | + Give_Cache::set_db_query($cache_key, $check); |
|
| 509 | 504 | } |
| 510 | 505 | |
| 511 | 506 | // Put result in an array on zero index. |
| 512 | - if ( ! $single ) { |
|
| 513 | - $check = array( $check ); |
|
| 507 | + if ( ! $single) { |
|
| 508 | + $check = array($check); |
|
| 514 | 509 | } |
| 515 | 510 | |
| 516 | 511 | |
| 517 | 512 | return $check; |
| 518 | 513 | } |
| 519 | 514 | |
| 520 | -add_filter( 'get_post_metadata', '_give_20_bc_get_new_payment_meta', 10, 5 ); |
|
| 515 | +add_filter('get_post_metadata', '_give_20_bc_get_new_payment_meta', 10, 5); |
|
| 521 | 516 | |
| 522 | 517 | |
| 523 | 518 | /** |
@@ -529,9 +524,9 @@ discard block |
||
| 529 | 524 | * |
| 530 | 525 | * @return void |
| 531 | 526 | */ |
| 532 | -function _give_20_bc_support_deprecated_meta_key_query( $query ) { |
|
| 527 | +function _give_20_bc_support_deprecated_meta_key_query($query) { |
|
| 533 | 528 | // Bailout. |
| 534 | - if ( give_has_upgrade_completed( 'v20_upgrades_payment_metadata' ) ) { |
|
| 529 | + if (give_has_upgrade_completed('v20_upgrades_payment_metadata')) { |
|
| 535 | 530 | return; |
| 536 | 531 | } |
| 537 | 532 | |
@@ -541,21 +536,21 @@ discard block |
||
| 541 | 536 | // '_give_payment_user_ip' => '_give_payment_donor_ip', |
| 542 | 537 | ); |
| 543 | 538 | |
| 544 | - $deprecated_meta_keys = array_flip( $new_meta_keys ); |
|
| 539 | + $deprecated_meta_keys = array_flip($new_meta_keys); |
|
| 545 | 540 | |
| 546 | 541 | // Set meta keys. |
| 547 | 542 | $meta_keys = array(); |
| 548 | 543 | |
| 549 | 544 | |
| 550 | 545 | // Bailout. |
| 551 | - if ( ! empty( $query->query_vars['meta_key'] ) ) { |
|
| 552 | - if ( in_array( $query->query_vars['meta_key'], $new_meta_keys ) ) { |
|
| 546 | + if ( ! empty($query->query_vars['meta_key'])) { |
|
| 547 | + if (in_array($query->query_vars['meta_key'], $new_meta_keys)) { |
|
| 553 | 548 | $meta_keys = $deprecated_meta_keys; |
| 554 | - } elseif ( in_array( $query->query_vars['meta_key'], $deprecated_meta_keys ) ) { |
|
| 549 | + } elseif (in_array($query->query_vars['meta_key'], $deprecated_meta_keys)) { |
|
| 555 | 550 | $meta_keys = $new_meta_keys; |
| 556 | 551 | } |
| 557 | 552 | |
| 558 | - if ( ! empty( $meta_keys ) ) { |
|
| 553 | + if ( ! empty($meta_keys)) { |
|
| 559 | 554 | // Set meta_query |
| 560 | 555 | $query->set( |
| 561 | 556 | 'meta_query', |
@@ -566,35 +561,35 @@ discard block |
||
| 566 | 561 | 'value' => $query->query_vars['meta_value'], |
| 567 | 562 | ), |
| 568 | 563 | array( |
| 569 | - 'key' => $meta_keys[ $query->query_vars['meta_key'] ], |
|
| 564 | + 'key' => $meta_keys[$query->query_vars['meta_key']], |
|
| 570 | 565 | 'value' => $query->query_vars['meta_value'], |
| 571 | 566 | ), |
| 572 | 567 | ) |
| 573 | 568 | ); |
| 574 | 569 | |
| 575 | 570 | // Unset single meta query. |
| 576 | - unset( $query->query_vars['meta_key'] ); |
|
| 577 | - unset( $query->query_vars['meta_value'] ); |
|
| 571 | + unset($query->query_vars['meta_key']); |
|
| 572 | + unset($query->query_vars['meta_value']); |
|
| 578 | 573 | } |
| 579 | 574 | } elseif ( |
| 580 | - ! empty( $query->query_vars['meta_query'] ) && |
|
| 581 | - ( 1 === count( $query->query_vars['meta_query'] ) ) |
|
| 575 | + ! empty($query->query_vars['meta_query']) && |
|
| 576 | + (1 === count($query->query_vars['meta_query'])) |
|
| 582 | 577 | ) { |
| 583 | - $meta_query = current( $query->query_vars['meta_query'] ); |
|
| 578 | + $meta_query = current($query->query_vars['meta_query']); |
|
| 584 | 579 | |
| 585 | - if ( empty( $meta_query[0]['key'] ) ) { |
|
| 580 | + if (empty($meta_query[0]['key'])) { |
|
| 586 | 581 | return; |
| 587 | 582 | } |
| 588 | 583 | |
| 589 | - if ( in_array( $meta_query[0]['key'], $new_meta_keys ) ) { |
|
| 584 | + if (in_array($meta_query[0]['key'], $new_meta_keys)) { |
|
| 590 | 585 | $meta_keys = $deprecated_meta_keys; |
| 591 | - } elseif ( in_array( $meta_query[0]['key'], $deprecated_meta_keys ) ) { |
|
| 586 | + } elseif (in_array($meta_query[0]['key'], $deprecated_meta_keys)) { |
|
| 592 | 587 | $meta_keys = $new_meta_keys; |
| 593 | 588 | } else { |
| 594 | 589 | return; |
| 595 | 590 | } |
| 596 | 591 | |
| 597 | - if ( ! empty( $meta_keys ) ) { |
|
| 592 | + if ( ! empty($meta_keys)) { |
|
| 598 | 593 | // Set meta_query |
| 599 | 594 | $query->set( |
| 600 | 595 | 'meta_query', |
@@ -605,7 +600,7 @@ discard block |
||
| 605 | 600 | 'value' => $query->query_vars['meta_query'][0]['value'], |
| 606 | 601 | ), |
| 607 | 602 | array( |
| 608 | - 'key' => $meta_keys[ $query->query_vars['meta_query'][0]['key'] ], |
|
| 603 | + 'key' => $meta_keys[$query->query_vars['meta_query'][0]['key']], |
|
| 609 | 604 | 'value' => $query->query_vars['meta_query'][0]['value'], |
| 610 | 605 | ), |
| 611 | 606 | ) |
@@ -614,7 +609,7 @@ discard block |
||
| 614 | 609 | } |
| 615 | 610 | } |
| 616 | 611 | |
| 617 | -add_action( 'pre_get_posts', '_give_20_bc_support_deprecated_meta_key_query' ); |
|
| 612 | +add_action('pre_get_posts', '_give_20_bc_support_deprecated_meta_key_query'); |
|
| 618 | 613 | |
| 619 | 614 | |
| 620 | 615 | /** |
@@ -627,49 +622,49 @@ discard block |
||
| 627 | 622 | * @param Give_Payment $payment |
| 628 | 623 | * @param string $key |
| 629 | 624 | */ |
| 630 | -function _give_20_bc_payment_save( $payment, $key ) { |
|
| 625 | +function _give_20_bc_payment_save($payment, $key) { |
|
| 631 | 626 | // Bailout. |
| 632 | - if ( ! give_has_upgrade_completed( 'v20_upgrades_payment_metadata' ) ) { |
|
| 627 | + if ( ! give_has_upgrade_completed('v20_upgrades_payment_metadata')) { |
|
| 633 | 628 | return; |
| 634 | 629 | } |
| 635 | 630 | |
| 636 | - switch ( $key ) { |
|
| 631 | + switch ($key) { |
|
| 637 | 632 | case 'user_info': |
| 638 | - if ( empty( $payment->user_info ) ) { |
|
| 633 | + if (empty($payment->user_info)) { |
|
| 639 | 634 | // Bailout. |
| 640 | 635 | break; |
| 641 | - } elseif ( is_string( $payment->user_info ) ) { |
|
| 636 | + } elseif (is_string($payment->user_info)) { |
|
| 642 | 637 | // Check if value serialize. |
| 643 | - $payment->user_info = maybe_unserialize( $payment->user_info ); |
|
| 638 | + $payment->user_info = maybe_unserialize($payment->user_info); |
|
| 644 | 639 | } |
| 645 | 640 | |
| 646 | 641 | |
| 647 | 642 | // Save first name. |
| 648 | - if ( isset( $payment->user_info['first_name'] ) ) { |
|
| 649 | - $payment->update_meta( '_give_donor_billing_first_name', $payment->user_info['first_name'] ); |
|
| 643 | + if (isset($payment->user_info['first_name'])) { |
|
| 644 | + $payment->update_meta('_give_donor_billing_first_name', $payment->user_info['first_name']); |
|
| 650 | 645 | } |
| 651 | 646 | |
| 652 | 647 | |
| 653 | 648 | // Save last name. |
| 654 | - if ( isset( $payment->user_info['last_name'] ) ) { |
|
| 655 | - $payment->update_meta( '_give_donor_billing_last_name', $payment->user_info['last_name'] ); |
|
| 649 | + if (isset($payment->user_info['last_name'])) { |
|
| 650 | + $payment->update_meta('_give_donor_billing_last_name', $payment->user_info['last_name']); |
|
| 656 | 651 | } |
| 657 | 652 | |
| 658 | 653 | |
| 659 | 654 | // Save address. |
| 660 | - if ( ! empty( $payment->user_info['address'] ) ) { |
|
| 661 | - foreach ( $payment->user_info['address'] as $address_name => $address ) { |
|
| 662 | - switch ( $address_name ) { |
|
| 655 | + if ( ! empty($payment->user_info['address'])) { |
|
| 656 | + foreach ($payment->user_info['address'] as $address_name => $address) { |
|
| 657 | + switch ($address_name) { |
|
| 663 | 658 | case 'line1': |
| 664 | - $payment->update_meta( '_give_donor_billing_address1', $address ); |
|
| 659 | + $payment->update_meta('_give_donor_billing_address1', $address); |
|
| 665 | 660 | break; |
| 666 | 661 | |
| 667 | 662 | case 'line2': |
| 668 | - $payment->update_meta( '_give_donor_billing_address2', $address ); |
|
| 663 | + $payment->update_meta('_give_donor_billing_address2', $address); |
|
| 669 | 664 | break; |
| 670 | 665 | |
| 671 | 666 | default: |
| 672 | - $payment->update_meta( "_give_donor_billing_{$address_name}", $address ); |
|
| 667 | + $payment->update_meta("_give_donor_billing_{$address_name}", $address); |
|
| 673 | 668 | } |
| 674 | 669 | } |
| 675 | 670 | } |
@@ -678,7 +673,7 @@ discard block |
||
| 678 | 673 | } |
| 679 | 674 | } |
| 680 | 675 | |
| 681 | -add_action( 'give_payment_save', '_give_20_bc_payment_save', 10, 2 ); |
|
| 676 | +add_action('give_payment_save', '_give_20_bc_payment_save', 10, 2); |
|
| 682 | 677 | |
| 683 | 678 | |
| 684 | 679 | /** |
@@ -691,16 +686,16 @@ discard block |
||
| 691 | 686 | * |
| 692 | 687 | * @return mixed |
| 693 | 688 | */ |
| 694 | -function __give_20_bc_flush_cache( $check, $object_id ) { |
|
| 689 | +function __give_20_bc_flush_cache($check, $object_id) { |
|
| 695 | 690 | if ( |
| 696 | - ! give_has_upgrade_completed( 'v20_move_metadata_into_new_table' ) && |
|
| 697 | - 'give_payment' === get_post_type( $object_id ) |
|
| 691 | + ! give_has_upgrade_completed('v20_move_metadata_into_new_table') && |
|
| 692 | + 'give_payment' === get_post_type($object_id) |
|
| 698 | 693 | ) { |
| 699 | - Give_Cache::delete_group( $object_id, 'give-donations' ); |
|
| 694 | + Give_Cache::delete_group($object_id, 'give-donations'); |
|
| 700 | 695 | } |
| 701 | 696 | |
| 702 | 697 | return $check; |
| 703 | 698 | } |
| 704 | 699 | |
| 705 | -add_action( 'update_post_metadata', '__give_20_bc_flush_cache', 9999, 2 ); |
|
| 706 | -add_action( 'add_post_metadata', '__give_20_bc_flush_cache', 9999, 2 ); |
|
| 700 | +add_action('update_post_metadata', '__give_20_bc_flush_cache', 9999, 2); |
|
| 701 | +add_action('add_post_metadata', '__give_20_bc_flush_cache', 9999, 2); |
|
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | * @since 1.0 |
| 108 | 108 | * @access public |
| 109 | 109 | * |
| 110 | - * @param $query_var |
|
| 110 | + * @param string $query_var |
|
| 111 | 111 | * @param $value |
| 112 | 112 | */ |
| 113 | 113 | public function __set( $query_var, $value ) { |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | * @since 1.0 |
| 125 | 125 | * @access public |
| 126 | 126 | * |
| 127 | - * @param $query_var |
|
| 127 | + * @param string $query_var |
|
| 128 | 128 | */ |
| 129 | 129 | public function __unset( $query_var ) { |
| 130 | 130 | unset( $this->args[ $query_var ] ); |
@@ -468,7 +468,7 @@ discard block |
||
| 468 | 468 | * @param string $order |
| 469 | 469 | * @param WP_Query $query |
| 470 | 470 | * |
| 471 | - * @return mixed |
|
| 471 | + * @return string |
|
| 472 | 472 | */ |
| 473 | 473 | public function custom_orderby( $order, $query ) { |
| 474 | 474 | |
@@ -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 | |
@@ -66,10 +66,10 @@ discard block |
||
| 66 | 66 | * |
| 67 | 67 | * @param $args array The array of arguments that can be passed in and used for setting up this payment query. |
| 68 | 68 | */ |
| 69 | - public function __construct( $args = array() ) { |
|
| 69 | + public function __construct($args = array()) { |
|
| 70 | 70 | $defaults = array( |
| 71 | 71 | 'output' => 'payments', |
| 72 | - 'post_type' => array( 'give_payment' ), |
|
| 72 | + 'post_type' => array('give_payment'), |
|
| 73 | 73 | 'start_date' => false, |
| 74 | 74 | 'end_date' => false, |
| 75 | 75 | 'number' => 20, |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | 'count' => false, |
| 97 | 97 | ); |
| 98 | 98 | |
| 99 | - $this->args = $this->_args = wp_parse_args( $args, $defaults ); |
|
| 99 | + $this->args = $this->_args = wp_parse_args($args, $defaults); |
|
| 100 | 100 | |
| 101 | 101 | $this->init(); |
| 102 | 102 | } |
@@ -110,11 +110,11 @@ discard block |
||
| 110 | 110 | * @param $query_var |
| 111 | 111 | * @param $value |
| 112 | 112 | */ |
| 113 | - public function __set( $query_var, $value ) { |
|
| 114 | - if ( in_array( $query_var, array( 'meta_query', 'tax_query' ) ) ) { |
|
| 115 | - $this->args[ $query_var ][] = $value; |
|
| 113 | + public function __set($query_var, $value) { |
|
| 114 | + if (in_array($query_var, array('meta_query', 'tax_query'))) { |
|
| 115 | + $this->args[$query_var][] = $value; |
|
| 116 | 116 | } else { |
| 117 | - $this->args[ $query_var ] = $value; |
|
| 117 | + $this->args[$query_var] = $value; |
|
| 118 | 118 | } |
| 119 | 119 | } |
| 120 | 120 | |
@@ -126,8 +126,8 @@ discard block |
||
| 126 | 126 | * |
| 127 | 127 | * @param $query_var |
| 128 | 128 | */ |
| 129 | - public function __unset( $query_var ) { |
|
| 130 | - unset( $this->args[ $query_var ] ); |
|
| 129 | + public function __unset($query_var) { |
|
| 130 | + unset($this->args[$query_var]); |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | /** |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | $this->give_forms(); |
| 168 | 168 | $this->gateway_filter(); |
| 169 | 169 | |
| 170 | - add_filter( 'posts_orderby', array( $this, 'custom_orderby' ), 10, 2 ); |
|
| 170 | + add_filter('posts_orderby', array($this, 'custom_orderby'), 10, 2); |
|
| 171 | 171 | |
| 172 | 172 | /** |
| 173 | 173 | * Fires after setup filters. |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | * |
| 177 | 177 | * @param Give_Payments_Query $this Payments query object. |
| 178 | 178 | */ |
| 179 | - do_action( 'give_pre_get_payments', $this ); |
|
| 179 | + do_action('give_pre_get_payments', $this); |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | /** |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | * @access private |
| 187 | 187 | */ |
| 188 | 188 | private function unset_filters() { |
| 189 | - remove_filter( 'posts_orderby', array( $this, 'custom_orderby' ) ); |
|
| 189 | + remove_filter('posts_orderby', array($this, 'custom_orderby')); |
|
| 190 | 190 | |
| 191 | 191 | /** |
| 192 | 192 | * Fires after retrieving payments. |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | * |
| 196 | 196 | * @param Give_Payments_Query $this Payments query object. |
| 197 | 197 | */ |
| 198 | - do_action( 'give_post_get_payments', $this ); |
|
| 198 | + do_action('give_post_get_payments', $this); |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | |
@@ -212,11 +212,11 @@ discard block |
||
| 212 | 212 | * @return array |
| 213 | 213 | */ |
| 214 | 214 | public function get_payments() { |
| 215 | - $cache_key = Give_Cache::get_key( 'give_payment_query', $this->args, false ); |
|
| 216 | - $this->payments = Give_Cache::get_db_query( $cache_key ); |
|
| 215 | + $cache_key = Give_Cache::get_key('give_payment_query', $this->args, false); |
|
| 216 | + $this->payments = Give_Cache::get_db_query($cache_key); |
|
| 217 | 217 | |
| 218 | 218 | // Return cached result. |
| 219 | - if ( ! is_null( $this->payments ) ) { |
|
| 219 | + if ( ! is_null($this->payments)) { |
|
| 220 | 220 | return $this->payments; |
| 221 | 221 | } |
| 222 | 222 | |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | // Modify the query/query arguments before we retrieve payments. |
| 225 | 225 | $this->set_filters(); |
| 226 | 226 | |
| 227 | - $query = new WP_Query( $this->args ); |
|
| 227 | + $query = new WP_Query($this->args); |
|
| 228 | 228 | $this->payments = array(); |
| 229 | 229 | |
| 230 | 230 | $custom_output = array( |
@@ -232,24 +232,24 @@ discard block |
||
| 232 | 232 | 'give_payments', |
| 233 | 233 | ); |
| 234 | 234 | |
| 235 | - if ( ! in_array( $this->args['output'], $custom_output ) ) { |
|
| 235 | + if ( ! in_array($this->args['output'], $custom_output)) { |
|
| 236 | 236 | return $query->posts; |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | - if ( $query->have_posts() ) { |
|
| 240 | - while ( $query->have_posts() ) { |
|
| 239 | + if ($query->have_posts()) { |
|
| 240 | + while ($query->have_posts()) { |
|
| 241 | 241 | $query->the_post(); |
| 242 | 242 | |
| 243 | 243 | $payment_id = get_post()->ID; |
| 244 | - $payment = new Give_Payment( $payment_id ); |
|
| 244 | + $payment = new Give_Payment($payment_id); |
|
| 245 | 245 | |
| 246 | - $this->payments[] = apply_filters( 'give_payment', $payment, $payment_id, $this ); |
|
| 246 | + $this->payments[] = apply_filters('give_payment', $payment, $payment_id, $this); |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | wp_reset_postdata(); |
| 250 | 250 | } |
| 251 | 251 | |
| 252 | - Give_Cache::set_db_query( $cache_key, $this->payments ); |
|
| 252 | + Give_Cache::set_db_query($cache_key, $this->payments); |
|
| 253 | 253 | |
| 254 | 254 | // Remove query filters after we retrieve payments. |
| 255 | 255 | $this->unset_filters(); |
@@ -268,31 +268,31 @@ discard block |
||
| 268 | 268 | public function get_payment_by_group() { |
| 269 | 269 | global $wpdb; |
| 270 | 270 | |
| 271 | - $allowed_groups = array( 'post_status' ); |
|
| 271 | + $allowed_groups = array('post_status'); |
|
| 272 | 272 | $result = array(); |
| 273 | 273 | |
| 274 | 274 | |
| 275 | - if ( in_array( $this->args['group_by'], $allowed_groups ) ) { |
|
| 275 | + if (in_array($this->args['group_by'], $allowed_groups)) { |
|
| 276 | 276 | // Set only count in result. |
| 277 | - if ( $this->args['count'] ) { |
|
| 277 | + if ($this->args['count']) { |
|
| 278 | 278 | |
| 279 | 279 | $this->set_filters(); |
| 280 | 280 | |
| 281 | - $new_results = $wpdb->get_results( $this->get_sql(), ARRAY_N ); |
|
| 281 | + $new_results = $wpdb->get_results($this->get_sql(), ARRAY_N); |
|
| 282 | 282 | |
| 283 | 283 | $this->unset_filters(); |
| 284 | 284 | |
| 285 | - foreach ( $new_results as $results ) { |
|
| 286 | - $result[ $results[0] ] = $results[1]; |
|
| 285 | + foreach ($new_results as $results) { |
|
| 286 | + $result[$results[0]] = $results[1]; |
|
| 287 | 287 | } |
| 288 | 288 | |
| 289 | - switch ( $this->args['group_by'] ) { |
|
| 289 | + switch ($this->args['group_by']) { |
|
| 290 | 290 | case 'post_status': |
| 291 | 291 | |
| 292 | 292 | /* @var Give_Payment $donation */ |
| 293 | - foreach ( give_get_payment_status_keys() as $status ) { |
|
| 294 | - if ( ! isset( $result[ $status ] ) ) { |
|
| 295 | - $result[ $status ] = 0; |
|
| 293 | + foreach (give_get_payment_status_keys() as $status) { |
|
| 294 | + if ( ! isset($result[$status])) { |
|
| 295 | + $result[$status] = 0; |
|
| 296 | 296 | } |
| 297 | 297 | } |
| 298 | 298 | |
@@ -302,8 +302,8 @@ discard block |
||
| 302 | 302 | $donations = $this->get_payments(); |
| 303 | 303 | |
| 304 | 304 | /* @var $donation Give_Payment */ |
| 305 | - foreach ( $donations as $donation ) { |
|
| 306 | - $result[ $donation->{$this->args['group_by']} ][] = $donation; |
|
| 305 | + foreach ($donations as $donation) { |
|
| 306 | + $result[$donation->{$this->args['group_by']}][] = $donation; |
|
| 307 | 307 | } |
| 308 | 308 | } |
| 309 | 309 | } |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | * |
| 315 | 315 | * @since 1.8.17 |
| 316 | 316 | */ |
| 317 | - return apply_filters( 'give_get_payment_by_group', $result, $this ); |
|
| 317 | + return apply_filters('give_get_payment_by_group', $result, $this); |
|
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | /** |
@@ -326,29 +326,29 @@ discard block |
||
| 326 | 326 | * @return void |
| 327 | 327 | */ |
| 328 | 328 | public function date_filter_pre() { |
| 329 | - if ( ! ( $this->args['start_date'] || $this->args['end_date'] ) ) { |
|
| 329 | + if ( ! ($this->args['start_date'] || $this->args['end_date'])) { |
|
| 330 | 330 | return; |
| 331 | 331 | } |
| 332 | 332 | |
| 333 | - $this->setup_dates( $this->args['start_date'], $this->args['end_date'] ); |
|
| 334 | - $is_start_date = property_exists( __CLASS__, 'start_date' ); |
|
| 335 | - $is_end_date = property_exists( __CLASS__, 'end_date' ); |
|
| 333 | + $this->setup_dates($this->args['start_date'], $this->args['end_date']); |
|
| 334 | + $is_start_date = property_exists(__CLASS__, 'start_date'); |
|
| 335 | + $is_end_date = property_exists(__CLASS__, 'end_date'); |
|
| 336 | 336 | |
| 337 | - if ( $is_start_date || $is_end_date ) { |
|
| 337 | + if ($is_start_date || $is_end_date) { |
|
| 338 | 338 | $date_query = array(); |
| 339 | 339 | |
| 340 | - if ( $is_start_date && ! is_wp_error( $this->start_date ) ) { |
|
| 341 | - $date_query['after'] = date( 'Y-m-d H:i:s', $this->start_date ); |
|
| 340 | + if ($is_start_date && ! is_wp_error($this->start_date)) { |
|
| 341 | + $date_query['after'] = date('Y-m-d H:i:s', $this->start_date); |
|
| 342 | 342 | } |
| 343 | 343 | |
| 344 | - if ( $is_end_date && ! is_wp_error( $this->end_date ) ) { |
|
| 345 | - $date_query['before'] = date( 'Y-m-d H:i:s', $this->end_date ); |
|
| 344 | + if ($is_end_date && ! is_wp_error($this->end_date)) { |
|
| 345 | + $date_query['before'] = date('Y-m-d H:i:s', $this->end_date); |
|
| 346 | 346 | } |
| 347 | 347 | |
| 348 | 348 | // Include Start Date and End Date while querying. |
| 349 | 349 | $date_query['inclusive'] = true; |
| 350 | 350 | |
| 351 | - $this->__set( 'date_query', $date_query ); |
|
| 351 | + $this->__set('date_query', $date_query); |
|
| 352 | 352 | |
| 353 | 353 | } |
| 354 | 354 | |
@@ -363,12 +363,12 @@ discard block |
||
| 363 | 363 | * @return void |
| 364 | 364 | */ |
| 365 | 365 | public function status() { |
| 366 | - if ( ! isset( $this->args['status'] ) ) { |
|
| 366 | + if ( ! isset($this->args['status'])) { |
|
| 367 | 367 | return; |
| 368 | 368 | } |
| 369 | 369 | |
| 370 | - $this->__set( 'post_status', $this->args['status'] ); |
|
| 371 | - $this->__unset( 'status' ); |
|
| 370 | + $this->__set('post_status', $this->args['status']); |
|
| 371 | + $this->__unset('status'); |
|
| 372 | 372 | } |
| 373 | 373 | |
| 374 | 374 | /** |
@@ -380,12 +380,12 @@ discard block |
||
| 380 | 380 | * @return void |
| 381 | 381 | */ |
| 382 | 382 | public function page() { |
| 383 | - if ( ! isset( $this->args['page'] ) ) { |
|
| 383 | + if ( ! isset($this->args['page'])) { |
|
| 384 | 384 | return; |
| 385 | 385 | } |
| 386 | 386 | |
| 387 | - $this->__set( 'paged', $this->args['page'] ); |
|
| 388 | - $this->__unset( 'page' ); |
|
| 387 | + $this->__set('paged', $this->args['page']); |
|
| 388 | + $this->__unset('page'); |
|
| 389 | 389 | } |
| 390 | 390 | |
| 391 | 391 | /** |
@@ -398,17 +398,17 @@ discard block |
||
| 398 | 398 | */ |
| 399 | 399 | public function per_page() { |
| 400 | 400 | |
| 401 | - if ( ! isset( $this->args['number'] ) ) { |
|
| 401 | + if ( ! isset($this->args['number'])) { |
|
| 402 | 402 | return; |
| 403 | 403 | } |
| 404 | 404 | |
| 405 | - if ( $this->args['number'] == - 1 ) { |
|
| 406 | - $this->__set( 'nopaging', true ); |
|
| 405 | + if ($this->args['number'] == - 1) { |
|
| 406 | + $this->__set('nopaging', true); |
|
| 407 | 407 | } else { |
| 408 | - $this->__set( 'posts_per_page', $this->args['number'] ); |
|
| 408 | + $this->__set('posts_per_page', $this->args['number']); |
|
| 409 | 409 | } |
| 410 | 410 | |
| 411 | - $this->__unset( 'number' ); |
|
| 411 | + $this->__unset('number'); |
|
| 412 | 412 | } |
| 413 | 413 | |
| 414 | 414 | /** |
@@ -420,12 +420,12 @@ discard block |
||
| 420 | 420 | * @return void |
| 421 | 421 | */ |
| 422 | 422 | public function month() { |
| 423 | - if ( ! isset( $this->args['month'] ) ) { |
|
| 423 | + if ( ! isset($this->args['month'])) { |
|
| 424 | 424 | return; |
| 425 | 425 | } |
| 426 | 426 | |
| 427 | - $this->__set( 'monthnum', $this->args['month'] ); |
|
| 428 | - $this->__unset( 'month' ); |
|
| 427 | + $this->__set('monthnum', $this->args['month']); |
|
| 428 | + $this->__unset('month'); |
|
| 429 | 429 | } |
| 430 | 430 | |
| 431 | 431 | /** |
@@ -437,23 +437,23 @@ discard block |
||
| 437 | 437 | * @return void |
| 438 | 438 | */ |
| 439 | 439 | public function orderby() { |
| 440 | - switch ( $this->args['orderby'] ) { |
|
| 440 | + switch ($this->args['orderby']) { |
|
| 441 | 441 | case 'amount': |
| 442 | - $this->__set( 'orderby', 'meta_value_num' ); |
|
| 443 | - $this->__set( 'meta_key', '_give_payment_total' ); |
|
| 442 | + $this->__set('orderby', 'meta_value_num'); |
|
| 443 | + $this->__set('meta_key', '_give_payment_total'); |
|
| 444 | 444 | break; |
| 445 | 445 | |
| 446 | 446 | case 'status': |
| 447 | - $this->__set( 'orderby', 'post_status' ); |
|
| 447 | + $this->__set('orderby', 'post_status'); |
|
| 448 | 448 | break; |
| 449 | 449 | |
| 450 | 450 | case 'donation_form': |
| 451 | - $this->__set( 'orderby', 'meta_value' ); |
|
| 452 | - $this->__set( 'meta_key', '_give_payment_form_title' ); |
|
| 451 | + $this->__set('orderby', 'meta_value'); |
|
| 452 | + $this->__set('meta_key', '_give_payment_form_title'); |
|
| 453 | 453 | break; |
| 454 | 454 | |
| 455 | 455 | default: |
| 456 | - $this->__set( 'orderby', $this->args['orderby'] ); |
|
| 456 | + $this->__set('orderby', $this->args['orderby']); |
|
| 457 | 457 | break; |
| 458 | 458 | } |
| 459 | 459 | } |
@@ -470,19 +470,19 @@ discard block |
||
| 470 | 470 | * |
| 471 | 471 | * @return mixed |
| 472 | 472 | */ |
| 473 | - public function custom_orderby( $order, $query ) { |
|
| 473 | + public function custom_orderby($order, $query) { |
|
| 474 | 474 | |
| 475 | - if ( ! empty( $query->query['post_type'] ) ) { |
|
| 476 | - $post_types = is_array( $query->query['post_type'] ) ? $query->query['post_type'] : array( $query->query['post_type'] ); |
|
| 475 | + if ( ! empty($query->query['post_type'])) { |
|
| 476 | + $post_types = is_array($query->query['post_type']) ? $query->query['post_type'] : array($query->query['post_type']); |
|
| 477 | 477 | |
| 478 | - if ( ! in_array( 'give_payment', $post_types ) || is_array( $query->query['orderby'] ) ) { |
|
| 478 | + if ( ! in_array('give_payment', $post_types) || is_array($query->query['orderby'])) { |
|
| 479 | 479 | return $order; |
| 480 | 480 | } |
| 481 | 481 | |
| 482 | 482 | global $wpdb; |
| 483 | - switch ( $query->query['orderby'] ) { |
|
| 483 | + switch ($query->query['orderby']) { |
|
| 484 | 484 | case 'post_status': |
| 485 | - $order = $wpdb->posts . '.post_status ' . strtoupper( $query->query['order'] ); |
|
| 485 | + $order = $wpdb->posts.'.post_status '.strtoupper($query->query['order']); |
|
| 486 | 486 | break; |
| 487 | 487 | } |
| 488 | 488 | } |
@@ -499,11 +499,11 @@ discard block |
||
| 499 | 499 | * @return void |
| 500 | 500 | */ |
| 501 | 501 | public function user() { |
| 502 | - if ( is_null( $this->args['user'] ) ) { |
|
| 502 | + if (is_null($this->args['user'])) { |
|
| 503 | 503 | return; |
| 504 | 504 | } |
| 505 | 505 | |
| 506 | - if ( is_numeric( $this->args['user'] ) ) { |
|
| 506 | + if (is_numeric($this->args['user'])) { |
|
| 507 | 507 | $user_key = '_give_payment_donor_id'; |
| 508 | 508 | } else { |
| 509 | 509 | $user_key = '_give_payment_donor_email'; |
@@ -525,16 +525,16 @@ discard block |
||
| 525 | 525 | * @return void |
| 526 | 526 | */ |
| 527 | 527 | public function donor() { |
| 528 | - if ( is_null( $this->args['donor'] ) || ! is_numeric( $this->args['donor'] ) ) { |
|
| 528 | + if (is_null($this->args['donor']) || ! is_numeric($this->args['donor'])) { |
|
| 529 | 529 | return; |
| 530 | 530 | } |
| 531 | 531 | |
| 532 | 532 | $donor_meta_type = Give()->donor_meta->meta_type; |
| 533 | 533 | |
| 534 | - $this->__set( 'meta_query', array( |
|
| 534 | + $this->__set('meta_query', array( |
|
| 535 | 535 | 'key' => "_give_payment_{$donor_meta_type}_id", |
| 536 | 536 | 'value' => (int) $this->args['donor'], |
| 537 | - ) ); |
|
| 537 | + )); |
|
| 538 | 538 | } |
| 539 | 539 | |
| 540 | 540 | /** |
@@ -547,33 +547,33 @@ discard block |
||
| 547 | 547 | */ |
| 548 | 548 | public function search() { |
| 549 | 549 | |
| 550 | - if ( ! isset( $this->args['s'] ) ) { |
|
| 550 | + if ( ! isset($this->args['s'])) { |
|
| 551 | 551 | return; |
| 552 | 552 | } |
| 553 | 553 | |
| 554 | - $search = trim( $this->args['s'] ); |
|
| 554 | + $search = trim($this->args['s']); |
|
| 555 | 555 | |
| 556 | - if ( empty( $search ) ) { |
|
| 556 | + if (empty($search)) { |
|
| 557 | 557 | return; |
| 558 | 558 | } |
| 559 | 559 | |
| 560 | - $is_email = is_email( $search ) || strpos( $search, '@' ) !== false; |
|
| 561 | - $is_user = strpos( $search, strtolower( 'user:' ) ) !== false; |
|
| 560 | + $is_email = is_email($search) || strpos($search, '@') !== false; |
|
| 561 | + $is_user = strpos($search, strtolower('user:')) !== false; |
|
| 562 | 562 | |
| 563 | - if ( ! empty( $this->args['search_in_notes'] ) ) { |
|
| 563 | + if ( ! empty($this->args['search_in_notes'])) { |
|
| 564 | 564 | |
| 565 | - $notes = give_get_payment_notes( 0, $search ); |
|
| 565 | + $notes = give_get_payment_notes(0, $search); |
|
| 566 | 566 | |
| 567 | - if ( ! empty( $notes ) ) { |
|
| 567 | + if ( ! empty($notes)) { |
|
| 568 | 568 | |
| 569 | - $payment_ids = wp_list_pluck( (array) $notes, 'comment_post_ID' ); |
|
| 569 | + $payment_ids = wp_list_pluck((array) $notes, 'comment_post_ID'); |
|
| 570 | 570 | |
| 571 | - $this->__set( 'post__in', $payment_ids ); |
|
| 571 | + $this->__set('post__in', $payment_ids); |
|
| 572 | 572 | } |
| 573 | 573 | |
| 574 | - $this->__unset( 's' ); |
|
| 574 | + $this->__unset('s'); |
|
| 575 | 575 | |
| 576 | - } elseif ( $is_email || strlen( $search ) == 32 ) { |
|
| 576 | + } elseif ($is_email || strlen($search) == 32) { |
|
| 577 | 577 | |
| 578 | 578 | $key = $is_email ? '_give_payment_donor_email' : '_give_payment_purchase_key'; |
| 579 | 579 | $search_meta = array( |
@@ -582,19 +582,19 @@ discard block |
||
| 582 | 582 | 'compare' => 'LIKE', |
| 583 | 583 | ); |
| 584 | 584 | |
| 585 | - $this->__set( 'meta_query', $search_meta ); |
|
| 586 | - $this->__unset( 's' ); |
|
| 585 | + $this->__set('meta_query', $search_meta); |
|
| 586 | + $this->__unset('s'); |
|
| 587 | 587 | |
| 588 | - } elseif ( $is_user ) { |
|
| 588 | + } elseif ($is_user) { |
|
| 589 | 589 | |
| 590 | 590 | $search_meta = array( |
| 591 | 591 | 'key' => '_give_payment_donor_id', |
| 592 | - 'value' => trim( str_replace( 'user:', '', strtolower( $search ) ) ), |
|
| 592 | + 'value' => trim(str_replace('user:', '', strtolower($search))), |
|
| 593 | 593 | ); |
| 594 | 594 | |
| 595 | - $this->__set( 'meta_query', $search_meta ); |
|
| 595 | + $this->__set('meta_query', $search_meta); |
|
| 596 | 596 | |
| 597 | - if ( give_get_option( 'enable_sequential' ) ) { |
|
| 597 | + if (give_get_option('enable_sequential')) { |
|
| 598 | 598 | |
| 599 | 599 | $search_meta = array( |
| 600 | 600 | 'key' => '_give_payment_number', |
@@ -602,19 +602,19 @@ discard block |
||
| 602 | 602 | 'compare' => 'LIKE', |
| 603 | 603 | ); |
| 604 | 604 | |
| 605 | - $this->__set( 'meta_query', $search_meta ); |
|
| 605 | + $this->__set('meta_query', $search_meta); |
|
| 606 | 606 | |
| 607 | 607 | $this->args['meta_query']['relation'] = 'OR'; |
| 608 | 608 | |
| 609 | 609 | } |
| 610 | 610 | |
| 611 | - $this->__unset( 's' ); |
|
| 611 | + $this->__unset('s'); |
|
| 612 | 612 | |
| 613 | 613 | } elseif ( |
| 614 | - give_get_option( 'enable_sequential' ) && |
|
| 614 | + give_get_option('enable_sequential') && |
|
| 615 | 615 | ( |
| 616 | - false !== strpos( $search, give_get_option( 'sequential_prefix' ) ) || |
|
| 617 | - false !== strpos( $search, give_get_option( 'sequential_postfix' ) ) |
|
| 616 | + false !== strpos($search, give_get_option('sequential_prefix')) || |
|
| 617 | + false !== strpos($search, give_get_option('sequential_postfix')) |
|
| 618 | 618 | ) |
| 619 | 619 | ) { |
| 620 | 620 | |
@@ -624,29 +624,29 @@ discard block |
||
| 624 | 624 | 'compare' => 'LIKE', |
| 625 | 625 | ); |
| 626 | 626 | |
| 627 | - $this->__set( 'meta_query', $search_meta ); |
|
| 628 | - $this->__unset( 's' ); |
|
| 627 | + $this->__set('meta_query', $search_meta); |
|
| 628 | + $this->__unset('s'); |
|
| 629 | 629 | |
| 630 | - } elseif ( is_numeric( $search ) ) { |
|
| 630 | + } elseif (is_numeric($search)) { |
|
| 631 | 631 | |
| 632 | - $post = get_post( $search ); |
|
| 632 | + $post = get_post($search); |
|
| 633 | 633 | |
| 634 | - if ( is_object( $post ) && $post->post_type == 'give_payment' ) { |
|
| 634 | + if (is_object($post) && $post->post_type == 'give_payment') { |
|
| 635 | 635 | |
| 636 | 636 | $arr = array(); |
| 637 | 637 | $arr[] = $search; |
| 638 | - $this->__set( 'post__in', $arr ); |
|
| 639 | - $this->__unset( 's' ); |
|
| 638 | + $this->__set('post__in', $arr); |
|
| 639 | + $this->__unset('s'); |
|
| 640 | 640 | } |
| 641 | - } elseif ( '#' == substr( $search, 0, 1 ) ) { |
|
| 641 | + } elseif ('#' == substr($search, 0, 1)) { |
|
| 642 | 642 | |
| 643 | - $search = str_replace( '#:', '', $search ); |
|
| 644 | - $search = str_replace( '#', '', $search ); |
|
| 645 | - $this->__set( 'give_forms', $search ); |
|
| 646 | - $this->__unset( 's' ); |
|
| 643 | + $search = str_replace('#:', '', $search); |
|
| 644 | + $search = str_replace('#', '', $search); |
|
| 645 | + $this->__set('give_forms', $search); |
|
| 646 | + $this->__unset('s'); |
|
| 647 | 647 | |
| 648 | 648 | } else { |
| 649 | - $this->__set( 's', $search ); |
|
| 649 | + $this->__set('s', $search); |
|
| 650 | 650 | |
| 651 | 651 | } |
| 652 | 652 | |
@@ -661,8 +661,8 @@ discard block |
||
| 661 | 661 | * @return void |
| 662 | 662 | */ |
| 663 | 663 | public function mode() { |
| 664 | - if ( empty( $this->args['mode'] ) || $this->args['mode'] == 'all' ) { |
|
| 665 | - $this->__unset( 'mode' ); |
|
| 664 | + if (empty($this->args['mode']) || $this->args['mode'] == 'all') { |
|
| 665 | + $this->__unset('mode'); |
|
| 666 | 666 | |
| 667 | 667 | return; |
| 668 | 668 | } |
@@ -684,10 +684,10 @@ discard block |
||
| 684 | 684 | * @return void |
| 685 | 685 | */ |
| 686 | 686 | public function children() { |
| 687 | - if ( empty( $this->args['children'] ) ) { |
|
| 688 | - $this->__set( 'post_parent', 0 ); |
|
| 687 | + if (empty($this->args['children'])) { |
|
| 688 | + $this->__set('post_parent', 0); |
|
| 689 | 689 | } |
| 690 | - $this->__unset( 'children' ); |
|
| 690 | + $this->__unset('children'); |
|
| 691 | 691 | } |
| 692 | 692 | |
| 693 | 693 | /** |
@@ -700,13 +700,13 @@ discard block |
||
| 700 | 700 | */ |
| 701 | 701 | public function give_forms() { |
| 702 | 702 | |
| 703 | - if ( empty( $this->args['give_forms'] ) ) { |
|
| 703 | + if (empty($this->args['give_forms'])) { |
|
| 704 | 704 | return; |
| 705 | 705 | } |
| 706 | 706 | |
| 707 | 707 | $compare = '='; |
| 708 | 708 | |
| 709 | - if ( is_array( $this->args['give_forms'] ) ) { |
|
| 709 | + if (is_array($this->args['give_forms'])) { |
|
| 710 | 710 | $compare = 'IN'; |
| 711 | 711 | } |
| 712 | 712 | |
@@ -719,7 +719,7 @@ discard block |
||
| 719 | 719 | ) |
| 720 | 720 | ); |
| 721 | 721 | |
| 722 | - $this->__unset( 'give_forms' ); |
|
| 722 | + $this->__unset('give_forms'); |
|
| 723 | 723 | |
| 724 | 724 | } |
| 725 | 725 | |
@@ -733,13 +733,13 @@ discard block |
||
| 733 | 733 | */ |
| 734 | 734 | public function gateway_filter() { |
| 735 | 735 | |
| 736 | - if ( empty( $this->args['gateway'] ) ) { |
|
| 736 | + if (empty($this->args['gateway'])) { |
|
| 737 | 737 | return; |
| 738 | 738 | } |
| 739 | 739 | |
| 740 | 740 | $compare = '='; |
| 741 | 741 | |
| 742 | - if ( is_array( $this->args['gateway'] ) ) { |
|
| 742 | + if (is_array($this->args['gateway'])) { |
|
| 743 | 743 | $compare = 'IN'; |
| 744 | 744 | } |
| 745 | 745 | |
@@ -753,7 +753,7 @@ discard block |
||
| 753 | 753 | ) |
| 754 | 754 | ); |
| 755 | 755 | |
| 756 | - $this->__unset( 'gateway' ); |
|
| 756 | + $this->__unset('gateway'); |
|
| 757 | 757 | |
| 758 | 758 | } |
| 759 | 759 | |
@@ -773,9 +773,9 @@ discard block |
||
| 773 | 773 | global $wpdb; |
| 774 | 774 | |
| 775 | 775 | $where = "WHERE {$wpdb->posts}.post_type = 'give_payment'"; |
| 776 | - $where .= " AND {$wpdb->posts}.post_status IN ('" . implode( "','", $this->args['post_status'] ) . "')"; |
|
| 776 | + $where .= " AND {$wpdb->posts}.post_status IN ('".implode("','", $this->args['post_status'])."')"; |
|
| 777 | 777 | |
| 778 | - if( is_numeric( $this->args['post_parent'] ) ) { |
|
| 778 | + if (is_numeric($this->args['post_parent'])) { |
|
| 779 | 779 | $where .= " AND {$wpdb->posts}.post_parent={$this->args['post_parent']}"; |
| 780 | 780 | } |
| 781 | 781 | |
@@ -784,42 +784,42 @@ discard block |
||
| 784 | 784 | $group_by = ''; |
| 785 | 785 | |
| 786 | 786 | // Set group by. |
| 787 | - if ( ! empty( $this->args['group_by'] ) ) { |
|
| 787 | + if ( ! empty($this->args['group_by'])) { |
|
| 788 | 788 | $group_by = "GROUP BY {$wpdb->posts}.{$this->args['group_by']}"; |
| 789 | 789 | } |
| 790 | 790 | |
| 791 | 791 | // Set offset. |
| 792 | 792 | if ( |
| 793 | - empty( $this->args['nopaging'] ) && |
|
| 794 | - empty( $this->args['offset'] ) && |
|
| 795 | - ( ! empty( $this->args['page'] ) && 0 < $this->args['page'] ) |
|
| 793 | + empty($this->args['nopaging']) && |
|
| 794 | + empty($this->args['offset']) && |
|
| 795 | + ( ! empty($this->args['page']) && 0 < $this->args['page']) |
|
| 796 | 796 | ) { |
| 797 | - $this->args['offset'] = $this->args['posts_per_page'] * ( $this->args['page'] - 1 ); |
|
| 797 | + $this->args['offset'] = $this->args['posts_per_page'] * ($this->args['page'] - 1); |
|
| 798 | 798 | } |
| 799 | 799 | |
| 800 | 800 | // Set fields. |
| 801 | 801 | $fields = "{$wpdb->posts}.*"; |
| 802 | - if ( ! empty( $this->args['fields'] ) && 'all' !== $this->args['fields'] ) { |
|
| 803 | - if ( is_string( $this->args['fields'] ) ) { |
|
| 802 | + if ( ! empty($this->args['fields']) && 'all' !== $this->args['fields']) { |
|
| 803 | + if (is_string($this->args['fields'])) { |
|
| 804 | 804 | $fields = "{$wpdb->posts}.{$this->args['fields']}"; |
| 805 | - } elseif ( is_array( $this->args['fields'] ) ) { |
|
| 806 | - $fields = "{$wpdb->posts}." . implode( " , {$wpdb->posts}.", $this->args['fields'] ); |
|
| 805 | + } elseif (is_array($this->args['fields'])) { |
|
| 806 | + $fields = "{$wpdb->posts}.".implode(" , {$wpdb->posts}.", $this->args['fields']); |
|
| 807 | 807 | } |
| 808 | 808 | } |
| 809 | 809 | |
| 810 | 810 | // Set count. |
| 811 | - if ( ! empty( $this->args['count'] ) ) { |
|
| 811 | + if ( ! empty($this->args['count'])) { |
|
| 812 | 812 | $fields = "COUNT({$wpdb->posts}.ID)"; |
| 813 | 813 | |
| 814 | - if ( ! empty( $this->args['group_by'] ) ) { |
|
| 814 | + if ( ! empty($this->args['group_by'])) { |
|
| 815 | 815 | $fields = "{$wpdb->posts}.{$this->args['group_by']}, {$fields}"; |
| 816 | 816 | } |
| 817 | 817 | } |
| 818 | 818 | |
| 819 | 819 | // Date query. |
| 820 | - if ( ! empty( $this->args['date_query'] ) ) { |
|
| 821 | - $date_query_obj = new WP_Date_Query( $this->args['date_query'] ); |
|
| 822 | - $where .= str_replace( |
|
| 820 | + if ( ! empty($this->args['date_query'])) { |
|
| 821 | + $date_query_obj = new WP_Date_Query($this->args['date_query']); |
|
| 822 | + $where .= str_replace( |
|
| 823 | 823 | array( |
| 824 | 824 | "\n", |
| 825 | 825 | '( (', |
@@ -835,21 +835,21 @@ discard block |
||
| 835 | 835 | } |
| 836 | 836 | |
| 837 | 837 | // Meta query. |
| 838 | - if ( ! empty( $this->args['meta_query'] ) ) { |
|
| 839 | - $meta_query_obj = new WP_Meta_Query( $this->args['meta_query'] ); |
|
| 840 | - $where = implode( ' ', $meta_query_obj->get_sql( 'post', $wpdb->posts, 'ID' ) ) . " {$where}"; |
|
| 838 | + if ( ! empty($this->args['meta_query'])) { |
|
| 839 | + $meta_query_obj = new WP_Meta_Query($this->args['meta_query']); |
|
| 840 | + $where = implode(' ', $meta_query_obj->get_sql('post', $wpdb->posts, 'ID'))." {$where}"; |
|
| 841 | 841 | } |
| 842 | 842 | |
| 843 | 843 | // Set sql query. |
| 844 | 844 | $sql = $wpdb->prepare( |
| 845 | 845 | "SELECT {$fields} FROM {$wpdb->posts} LIMIT %d,%d;", |
| 846 | - absint( $this->args['offset'] ), |
|
| 847 | - ( empty( $this->args['nopaging'] ) ? absint( $this->args['posts_per_page'] ) : 999999999999999 ) |
|
| 846 | + absint($this->args['offset']), |
|
| 847 | + (empty($this->args['nopaging']) ? absint($this->args['posts_per_page']) : 999999999999999) |
|
| 848 | 848 | ); |
| 849 | 849 | |
| 850 | 850 | // $where, $orderby and order already prepared query they can generate notice if you re prepare them in above. |
| 851 | 851 | // WordPress consider LIKE condition as placeholder if start with s,f, or d. |
| 852 | - $sql = str_replace( 'LIMIT', "{$where} {$group_by} {$orderby} {$this->args['order']} LIMIT", $sql ); |
|
| 852 | + $sql = str_replace('LIMIT', "{$where} {$group_by} {$orderby} {$this->args['order']} LIMIT", $sql); |
|
| 853 | 853 | |
| 854 | 854 | return $sql; |
| 855 | 855 | } |
@@ -565,7 +565,7 @@ discard block |
||
| 565 | 565 | * |
| 566 | 566 | * @since 1.0 |
| 567 | 567 | * |
| 568 | - * @return int $earnings Earnings |
|
| 568 | + * @return double $earnings Earnings |
|
| 569 | 569 | */ |
| 570 | 570 | function give_get_earnings_by_date( $day = null, $month_num, $year = null, $hour = null ) { |
| 571 | 571 | // This is getting deprecated soon. Use Give_Payment_Stats with the get_earnings() method instead. |
@@ -881,7 +881,7 @@ discard block |
||
| 881 | 881 | * |
| 882 | 882 | * @since 1.0 |
| 883 | 883 | * |
| 884 | - * @return int $form_id Form ID. |
|
| 884 | + * @return string $form_id Form ID. |
|
| 885 | 885 | */ |
| 886 | 886 | function give_get_payment_form_id( $payment_id ) { |
| 887 | 887 | $payment = new Give_Payment( $payment_id ); |
@@ -1729,7 +1729,7 @@ discard block |
||
| 1729 | 1729 | * |
| 1730 | 1730 | * Retrieves the form title and appends the level name if present. |
| 1731 | 1731 | * |
| 1732 | - * @param int|Give_Payment $donation Donation Data Object. |
|
| 1732 | + * @param Give_Payment $donation Donation Data Object. |
|
| 1733 | 1733 | * @param array $args a. only_level = If set to true will only return the level name if multi-level enabled. |
| 1734 | 1734 | * b. separator = The separator between the Form Title and the Donation Level. |
| 1735 | 1735 | * |
@@ -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 | |
@@ -44,15 +44,15 @@ discard block |
||
| 44 | 44 | * |
| 45 | 45 | * @return array $payments Payments retrieved from the database |
| 46 | 46 | */ |
| 47 | -function give_get_payments( $args = array() ) { |
|
| 47 | +function give_get_payments($args = array()) { |
|
| 48 | 48 | |
| 49 | 49 | // Fallback to post objects to ensure backwards compatibility. |
| 50 | - if ( ! isset( $args['output'] ) ) { |
|
| 50 | + if ( ! isset($args['output'])) { |
|
| 51 | 51 | $args['output'] = 'posts'; |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - $args = apply_filters( 'give_get_payments_args', $args ); |
|
| 55 | - $payments = new Give_Payments_Query( $args ); |
|
| 54 | + $args = apply_filters('give_get_payments_args', $args); |
|
| 55 | + $payments = new Give_Payments_Query($args); |
|
| 56 | 56 | |
| 57 | 57 | return $payments->get_payments(); |
| 58 | 58 | } |
@@ -67,48 +67,48 @@ discard block |
||
| 67 | 67 | * |
| 68 | 68 | * @return mixed |
| 69 | 69 | */ |
| 70 | -function give_get_payment_by( $field = '', $value = '' ) { |
|
| 70 | +function give_get_payment_by($field = '', $value = '') { |
|
| 71 | 71 | |
| 72 | - if ( empty( $field ) || empty( $value ) ) { |
|
| 72 | + if (empty($field) || empty($value)) { |
|
| 73 | 73 | return false; |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - switch ( strtolower( $field ) ) { |
|
| 76 | + switch (strtolower($field)) { |
|
| 77 | 77 | |
| 78 | 78 | case 'id': |
| 79 | - $payment = new Give_Payment( $value ); |
|
| 79 | + $payment = new Give_Payment($value); |
|
| 80 | 80 | $id = $payment->ID; |
| 81 | 81 | |
| 82 | - if ( empty( $id ) ) { |
|
| 82 | + if (empty($id)) { |
|
| 83 | 83 | return false; |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | break; |
| 87 | 87 | |
| 88 | 88 | case 'key': |
| 89 | - $payment = give_get_payments( array( |
|
| 89 | + $payment = give_get_payments(array( |
|
| 90 | 90 | 'meta_key' => '_give_payment_purchase_key', |
| 91 | 91 | 'meta_value' => $value, |
| 92 | 92 | 'posts_per_page' => 1, |
| 93 | 93 | 'fields' => 'ids', |
| 94 | - ) ); |
|
| 94 | + )); |
|
| 95 | 95 | |
| 96 | - if ( $payment ) { |
|
| 97 | - $payment = new Give_Payment( $payment[0] ); |
|
| 96 | + if ($payment) { |
|
| 97 | + $payment = new Give_Payment($payment[0]); |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | break; |
| 101 | 101 | |
| 102 | 102 | case 'payment_number': |
| 103 | - $payment = give_get_payments( array( |
|
| 103 | + $payment = give_get_payments(array( |
|
| 104 | 104 | 'meta_key' => '_give_payment_number', |
| 105 | 105 | 'meta_value' => $value, |
| 106 | 106 | 'posts_per_page' => 1, |
| 107 | 107 | 'fields' => 'ids', |
| 108 | - ) ); |
|
| 108 | + )); |
|
| 109 | 109 | |
| 110 | - if ( $payment ) { |
|
| 111 | - $payment = new Give_Payment( $payment[0] ); |
|
| 110 | + if ($payment) { |
|
| 111 | + $payment = new Give_Payment($payment[0]); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | break; |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | return false; |
| 118 | 118 | }// End switch(). |
| 119 | 119 | |
| 120 | - if ( $payment ) { |
|
| 120 | + if ($payment) { |
|
| 121 | 121 | return $payment; |
| 122 | 122 | } |
| 123 | 123 | |
@@ -133,9 +133,9 @@ discard block |
||
| 133 | 133 | * |
| 134 | 134 | * @return int|bool Payment ID if payment is inserted, false otherwise. |
| 135 | 135 | */ |
| 136 | -function give_insert_payment( $payment_data = array() ) { |
|
| 136 | +function give_insert_payment($payment_data = array()) { |
|
| 137 | 137 | |
| 138 | - if ( empty( $payment_data ) ) { |
|
| 138 | + if (empty($payment_data)) { |
|
| 139 | 139 | return false; |
| 140 | 140 | } |
| 141 | 141 | |
@@ -146,25 +146,25 @@ discard block |
||
| 146 | 146 | * |
| 147 | 147 | * @param array $payment_data Arguments passed. |
| 148 | 148 | */ |
| 149 | - $payment_data = apply_filters( 'give_pre_insert_payment', $payment_data ); |
|
| 149 | + $payment_data = apply_filters('give_pre_insert_payment', $payment_data); |
|
| 150 | 150 | |
| 151 | 151 | $payment = new Give_Payment(); |
| 152 | - $gateway = ! empty( $payment_data['gateway'] ) ? $payment_data['gateway'] : ''; |
|
| 153 | - $gateway = empty( $gateway ) && isset( $_POST['give-gateway'] ) ? $_POST['give-gateway'] : $gateway; |
|
| 154 | - $form_id = isset( $payment_data['give_form_id'] ) ? $payment_data['give_form_id'] : 0; |
|
| 155 | - $price_id = give_get_payment_meta_price_id( $payment_data ); |
|
| 156 | - $form_title = isset( $payment_data['give_form_title'] ) ? $payment_data['give_form_title'] : get_the_title( $form_id ); |
|
| 152 | + $gateway = ! empty($payment_data['gateway']) ? $payment_data['gateway'] : ''; |
|
| 153 | + $gateway = empty($gateway) && isset($_POST['give-gateway']) ? $_POST['give-gateway'] : $gateway; |
|
| 154 | + $form_id = isset($payment_data['give_form_id']) ? $payment_data['give_form_id'] : 0; |
|
| 155 | + $price_id = give_get_payment_meta_price_id($payment_data); |
|
| 156 | + $form_title = isset($payment_data['give_form_title']) ? $payment_data['give_form_title'] : get_the_title($form_id); |
|
| 157 | 157 | |
| 158 | 158 | // Set properties. |
| 159 | 159 | $payment->total = $payment_data['price']; |
| 160 | - $payment->status = ! empty( $payment_data['status'] ) ? $payment_data['status'] : 'pending'; |
|
| 161 | - $payment->currency = ! empty( $payment_data['currency'] ) ? $payment_data['currency'] : give_get_currency( $payment_data['give_form_id'], $payment_data ); |
|
| 160 | + $payment->status = ! empty($payment_data['status']) ? $payment_data['status'] : 'pending'; |
|
| 161 | + $payment->currency = ! empty($payment_data['currency']) ? $payment_data['currency'] : give_get_currency($payment_data['give_form_id'], $payment_data); |
|
| 162 | 162 | $payment->user_info = $payment_data['user_info']; |
| 163 | 163 | $payment->gateway = $gateway; |
| 164 | 164 | $payment->form_title = $form_title; |
| 165 | 165 | $payment->form_id = $form_id; |
| 166 | 166 | $payment->price_id = $price_id; |
| 167 | - $payment->donor_id = ( ! empty( $payment_data['donor_id'] ) ? $payment_data['donor_id'] : '' ); |
|
| 167 | + $payment->donor_id = ( ! empty($payment_data['donor_id']) ? $payment_data['donor_id'] : ''); |
|
| 168 | 168 | $payment->user_id = $payment_data['user_info']['id']; |
| 169 | 169 | $payment->email = $payment_data['user_email']; |
| 170 | 170 | $payment->first_name = $payment_data['user_info']['first_name']; |
@@ -172,8 +172,8 @@ discard block |
||
| 172 | 172 | $payment->email = $payment_data['user_info']['email']; |
| 173 | 173 | $payment->ip = give_get_ip(); |
| 174 | 174 | $payment->key = $payment_data['purchase_key']; |
| 175 | - $payment->mode = ( ! empty( $payment_data['mode'] ) ? (string) $payment_data['mode'] : ( give_is_test_mode() ? 'test' : 'live' ) ); |
|
| 176 | - $payment->parent_payment = ! empty( $payment_data['parent'] ) ? absint( $payment_data['parent'] ) : ''; |
|
| 175 | + $payment->mode = ( ! empty($payment_data['mode']) ? (string) $payment_data['mode'] : (give_is_test_mode() ? 'test' : 'live')); |
|
| 176 | + $payment->parent_payment = ! empty($payment_data['parent']) ? absint($payment_data['parent']) : ''; |
|
| 177 | 177 | |
| 178 | 178 | // Add the donation. |
| 179 | 179 | $args = array( |
@@ -181,19 +181,19 @@ discard block |
||
| 181 | 181 | 'price_id' => $payment->price_id, |
| 182 | 182 | ); |
| 183 | 183 | |
| 184 | - $payment->add_donation( $payment->form_id, $args ); |
|
| 184 | + $payment->add_donation($payment->form_id, $args); |
|
| 185 | 185 | |
| 186 | 186 | |
| 187 | 187 | // Set date if present. |
| 188 | - if ( isset( $payment_data['post_date'] ) ) { |
|
| 188 | + if (isset($payment_data['post_date'])) { |
|
| 189 | 189 | $payment->date = $payment_data['post_date']; |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | // Handle sequential payments. |
| 193 | - if ( give_get_option( 'enable_sequential' ) ) { |
|
| 193 | + if (give_get_option('enable_sequential')) { |
|
| 194 | 194 | $number = give_get_next_payment_number(); |
| 195 | - $payment->number = give_format_payment_number( $number ); |
|
| 196 | - update_option( 'give_last_payment_number', $number ); |
|
| 195 | + $payment->number = give_format_payment_number($number); |
|
| 196 | + update_option('give_last_payment_number', $number); |
|
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | // Save payment. |
@@ -207,10 +207,10 @@ discard block |
||
| 207 | 207 | * @param int $payment_id The payment ID. |
| 208 | 208 | * @param array $payment_data Arguments passed. |
| 209 | 209 | */ |
| 210 | - do_action( 'give_insert_payment', $payment->ID, $payment_data ); |
|
| 210 | + do_action('give_insert_payment', $payment->ID, $payment_data); |
|
| 211 | 211 | |
| 212 | 212 | // Return payment ID upon success. |
| 213 | - if ( ! empty( $payment->ID ) ) { |
|
| 213 | + if ( ! empty($payment->ID)) { |
|
| 214 | 214 | return $payment->ID; |
| 215 | 215 | } |
| 216 | 216 | |
@@ -226,10 +226,10 @@ discard block |
||
| 226 | 226 | * |
| 227 | 227 | * @return bool|int |
| 228 | 228 | */ |
| 229 | -function give_create_payment( $payment_data ) { |
|
| 229 | +function give_create_payment($payment_data) { |
|
| 230 | 230 | |
| 231 | - $form_id = intval( $payment_data['post_data']['give-form-id'] ); |
|
| 232 | - $price_id = isset( $payment_data['post_data']['give-price-id'] ) ? $payment_data['post_data']['give-price-id'] : ''; |
|
| 231 | + $form_id = intval($payment_data['post_data']['give-form-id']); |
|
| 232 | + $price_id = isset($payment_data['post_data']['give-price-id']) ? $payment_data['post_data']['give-price-id'] : ''; |
|
| 233 | 233 | |
| 234 | 234 | // Collect payment data. |
| 235 | 235 | $insert_payment_data = array( |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | 'date' => $payment_data['date'], |
| 241 | 241 | 'user_email' => $payment_data['user_email'], |
| 242 | 242 | 'purchase_key' => $payment_data['purchase_key'], |
| 243 | - 'currency' => give_get_currency( $form_id, $payment_data ), |
|
| 243 | + 'currency' => give_get_currency($form_id, $payment_data), |
|
| 244 | 244 | 'user_info' => $payment_data['user_info'], |
| 245 | 245 | 'status' => 'pending', |
| 246 | 246 | 'gateway' => 'paypal', |
@@ -253,10 +253,10 @@ discard block |
||
| 253 | 253 | * |
| 254 | 254 | * @param array $insert_payment_data |
| 255 | 255 | */ |
| 256 | - $insert_payment_data = apply_filters( 'give_create_payment', $insert_payment_data ); |
|
| 256 | + $insert_payment_data = apply_filters('give_create_payment', $insert_payment_data); |
|
| 257 | 257 | |
| 258 | 258 | // Record the pending payment. |
| 259 | - return give_insert_payment( $insert_payment_data ); |
|
| 259 | + return give_insert_payment($insert_payment_data); |
|
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | /** |
@@ -269,12 +269,12 @@ discard block |
||
| 269 | 269 | * |
| 270 | 270 | * @return bool |
| 271 | 271 | */ |
| 272 | -function give_update_payment_status( $payment_id, $new_status = 'publish' ) { |
|
| 272 | +function give_update_payment_status($payment_id, $new_status = 'publish') { |
|
| 273 | 273 | |
| 274 | 274 | $updated = false; |
| 275 | - $payment = new Give_Payment( $payment_id ); |
|
| 275 | + $payment = new Give_Payment($payment_id); |
|
| 276 | 276 | |
| 277 | - if ( $payment && $payment->ID > 0 ) { |
|
| 277 | + if ($payment && $payment->ID > 0) { |
|
| 278 | 278 | |
| 279 | 279 | $payment->status = $new_status; |
| 280 | 280 | $updated = $payment->save(); |
@@ -295,45 +295,45 @@ discard block |
||
| 295 | 295 | * |
| 296 | 296 | * @return void |
| 297 | 297 | */ |
| 298 | -function give_delete_donation( $payment_id = 0, $update_donor = true ) { |
|
| 299 | - $payment = new Give_Payment( $payment_id ); |
|
| 298 | +function give_delete_donation($payment_id = 0, $update_donor = true) { |
|
| 299 | + $payment = new Give_Payment($payment_id); |
|
| 300 | 300 | |
| 301 | 301 | // Bailout. |
| 302 | - if ( ! $payment->ID ) { |
|
| 302 | + if ( ! $payment->ID) { |
|
| 303 | 303 | return; |
| 304 | 304 | } |
| 305 | 305 | |
| 306 | - $amount = give_donation_amount( $payment_id ); |
|
| 306 | + $amount = give_donation_amount($payment_id); |
|
| 307 | 307 | $status = $payment->post_status; |
| 308 | - $donor_id = give_get_payment_donor_id( $payment_id ); |
|
| 309 | - $donor = new Give_Donor( $donor_id ); |
|
| 308 | + $donor_id = give_get_payment_donor_id($payment_id); |
|
| 309 | + $donor = new Give_Donor($donor_id); |
|
| 310 | 310 | |
| 311 | 311 | // Only undo donations that aren't these statuses. |
| 312 | - $dont_undo_statuses = apply_filters( 'give_undo_donation_statuses', array( |
|
| 312 | + $dont_undo_statuses = apply_filters('give_undo_donation_statuses', array( |
|
| 313 | 313 | 'pending', |
| 314 | 314 | 'cancelled', |
| 315 | - ) ); |
|
| 315 | + )); |
|
| 316 | 316 | |
| 317 | - if ( ! in_array( $status, $dont_undo_statuses ) ) { |
|
| 318 | - give_undo_donation( $payment_id ); |
|
| 317 | + if ( ! in_array($status, $dont_undo_statuses)) { |
|
| 318 | + give_undo_donation($payment_id); |
|
| 319 | 319 | } |
| 320 | 320 | |
| 321 | 321 | // Only undo donations that aren't these statuses. |
| 322 | - $status_to_decrease_stats = apply_filters( 'give_decrease_donor_statuses', array( 'publish' ) ); |
|
| 322 | + $status_to_decrease_stats = apply_filters('give_decrease_donor_statuses', array('publish')); |
|
| 323 | 323 | |
| 324 | - if ( in_array( $status, $status_to_decrease_stats ) ) { |
|
| 324 | + if (in_array($status, $status_to_decrease_stats)) { |
|
| 325 | 325 | |
| 326 | 326 | // Only decrease earnings if they haven't already been decreased (or were never increased for this payment). |
| 327 | - give_decrease_total_earnings( $amount ); |
|
| 327 | + give_decrease_total_earnings($amount); |
|
| 328 | 328 | |
| 329 | 329 | // @todo: Refresh only range related stat cache |
| 330 | 330 | give_delete_donation_stats(); |
| 331 | 331 | |
| 332 | - if ( $donor->id && $update_donor ) { |
|
| 332 | + if ($donor->id && $update_donor) { |
|
| 333 | 333 | |
| 334 | 334 | // Decrement the stats for the donor. |
| 335 | 335 | $donor->decrease_donation_count(); |
| 336 | - $donor->decrease_value( $amount ); |
|
| 336 | + $donor->decrease_value($amount); |
|
| 337 | 337 | |
| 338 | 338 | } |
| 339 | 339 | } |
@@ -345,18 +345,18 @@ discard block |
||
| 345 | 345 | * |
| 346 | 346 | * @since 1.0 |
| 347 | 347 | */ |
| 348 | - do_action( 'give_payment_delete', $payment_id ); |
|
| 348 | + do_action('give_payment_delete', $payment_id); |
|
| 349 | 349 | |
| 350 | - if ( $donor->id && $update_donor ) { |
|
| 350 | + if ($donor->id && $update_donor) { |
|
| 351 | 351 | // Remove the payment ID from the donor. |
| 352 | - $donor->remove_payment( $payment_id ); |
|
| 352 | + $donor->remove_payment($payment_id); |
|
| 353 | 353 | } |
| 354 | 354 | |
| 355 | 355 | // Remove the payment. |
| 356 | - wp_delete_post( $payment_id, true ); |
|
| 356 | + wp_delete_post($payment_id, true); |
|
| 357 | 357 | |
| 358 | 358 | // Remove related sale log entries. |
| 359 | - Give()->logs->delete_logs( $payment_id ); |
|
| 359 | + Give()->logs->delete_logs($payment_id); |
|
| 360 | 360 | |
| 361 | 361 | /** |
| 362 | 362 | * Fires after payment deleted. |
@@ -365,7 +365,7 @@ discard block |
||
| 365 | 365 | * |
| 366 | 366 | * @since 1.0 |
| 367 | 367 | */ |
| 368 | - do_action( 'give_payment_deleted', $payment_id ); |
|
| 368 | + do_action('give_payment_deleted', $payment_id); |
|
| 369 | 369 | } |
| 370 | 370 | |
| 371 | 371 | /** |
@@ -380,20 +380,20 @@ discard block |
||
| 380 | 380 | * |
| 381 | 381 | * @return void |
| 382 | 382 | */ |
| 383 | -function give_undo_donation( $payment_id ) { |
|
| 383 | +function give_undo_donation($payment_id) { |
|
| 384 | 384 | |
| 385 | - $payment = new Give_Payment( $payment_id ); |
|
| 385 | + $payment = new Give_Payment($payment_id); |
|
| 386 | 386 | |
| 387 | - $maybe_decrease_earnings = apply_filters( 'give_decrease_earnings_on_undo', true, $payment, $payment->form_id ); |
|
| 388 | - if ( true === $maybe_decrease_earnings ) { |
|
| 387 | + $maybe_decrease_earnings = apply_filters('give_decrease_earnings_on_undo', true, $payment, $payment->form_id); |
|
| 388 | + if (true === $maybe_decrease_earnings) { |
|
| 389 | 389 | // Decrease earnings. |
| 390 | - give_decrease_form_earnings( $payment->form_id, $payment->total ); |
|
| 390 | + give_decrease_form_earnings($payment->form_id, $payment->total); |
|
| 391 | 391 | } |
| 392 | 392 | |
| 393 | - $maybe_decrease_donations = apply_filters( 'give_decrease_donations_on_undo', true, $payment, $payment->form_id ); |
|
| 394 | - if ( true === $maybe_decrease_donations ) { |
|
| 393 | + $maybe_decrease_donations = apply_filters('give_decrease_donations_on_undo', true, $payment, $payment->form_id); |
|
| 394 | + if (true === $maybe_decrease_donations) { |
|
| 395 | 395 | // Decrease donation count. |
| 396 | - give_decrease_donation_count( $payment->form_id ); |
|
| 396 | + give_decrease_donation_count($payment->form_id); |
|
| 397 | 397 | } |
| 398 | 398 | |
| 399 | 399 | } |
@@ -410,21 +410,21 @@ discard block |
||
| 410 | 410 | * |
| 411 | 411 | * @return object $stats Contains the number of payments per payment status. |
| 412 | 412 | */ |
| 413 | -function give_count_payments( $args = array() ) { |
|
| 413 | +function give_count_payments($args = array()) { |
|
| 414 | 414 | // Backward compatibility. |
| 415 | - if ( ! empty( $args['start-date'] ) ) { |
|
| 415 | + if ( ! empty($args['start-date'])) { |
|
| 416 | 416 | $args['start_date'] = $args['start-date']; |
| 417 | - unset( $args['start-date'] ); |
|
| 417 | + unset($args['start-date']); |
|
| 418 | 418 | } |
| 419 | 419 | |
| 420 | - if ( ! empty( $args['end-date'] ) ) { |
|
| 420 | + if ( ! empty($args['end-date'])) { |
|
| 421 | 421 | $args['end_date'] = $args['end-date']; |
| 422 | - unset( $args['end-date'] ); |
|
| 422 | + unset($args['end-date']); |
|
| 423 | 423 | } |
| 424 | 424 | |
| 425 | - if ( ! empty( $args['form_id'] ) ) { |
|
| 425 | + if ( ! empty($args['form_id'])) { |
|
| 426 | 426 | $args['give_forms'] = $args['form_id']; |
| 427 | - unset( $args['form_id'] ); |
|
| 427 | + unset($args['form_id']); |
|
| 428 | 428 | } |
| 429 | 429 | |
| 430 | 430 | // Extract all donations |
@@ -432,7 +432,7 @@ discard block |
||
| 432 | 432 | $args['group_by'] = 'post_status'; |
| 433 | 433 | $args['count'] = 'true'; |
| 434 | 434 | |
| 435 | - $donations_obj = new Give_Payments_Query( $args ); |
|
| 435 | + $donations_obj = new Give_Payments_Query($args); |
|
| 436 | 436 | $donations_count = $donations_obj->get_payment_by_group(); |
| 437 | 437 | |
| 438 | 438 | /** |
@@ -440,7 +440,7 @@ discard block |
||
| 440 | 440 | * |
| 441 | 441 | * @since 1.0 |
| 442 | 442 | */ |
| 443 | - return (object) apply_filters( 'give_count_payments', $donations_count, $args, $donations_obj ); |
|
| 443 | + return (object) apply_filters('give_count_payments', $donations_count, $args, $donations_obj); |
|
| 444 | 444 | } |
| 445 | 445 | |
| 446 | 446 | |
@@ -453,11 +453,11 @@ discard block |
||
| 453 | 453 | * |
| 454 | 454 | * @return bool $exists True if payment exists, false otherwise. |
| 455 | 455 | */ |
| 456 | -function give_check_for_existing_payment( $payment_id ) { |
|
| 456 | +function give_check_for_existing_payment($payment_id) { |
|
| 457 | 457 | $exists = false; |
| 458 | - $payment = new Give_Payment( $payment_id ); |
|
| 458 | + $payment = new Give_Payment($payment_id); |
|
| 459 | 459 | |
| 460 | - if ( $payment_id === $payment->ID && 'publish' === $payment->status ) { |
|
| 460 | + if ($payment_id === $payment->ID && 'publish' === $payment->status) { |
|
| 461 | 461 | $exists = true; |
| 462 | 462 | } |
| 463 | 463 | |
@@ -475,41 +475,41 @@ discard block |
||
| 475 | 475 | * |
| 476 | 476 | * @return bool|mixed True if payment status exists, false otherwise. |
| 477 | 477 | */ |
| 478 | -function give_get_payment_status( $payment, $return_label = false ) { |
|
| 478 | +function give_get_payment_status($payment, $return_label = false) { |
|
| 479 | 479 | |
| 480 | - if ( is_numeric( $payment ) ) { |
|
| 480 | + if (is_numeric($payment)) { |
|
| 481 | 481 | |
| 482 | - $payment = new Give_Payment( $payment ); |
|
| 482 | + $payment = new Give_Payment($payment); |
|
| 483 | 483 | |
| 484 | - if ( ! $payment->ID > 0 ) { |
|
| 484 | + if ( ! $payment->ID > 0) { |
|
| 485 | 485 | return false; |
| 486 | 486 | } |
| 487 | 487 | |
| 488 | 488 | } |
| 489 | 489 | |
| 490 | - if ( ! is_object( $payment ) || ! isset( $payment->post_status ) ) { |
|
| 490 | + if ( ! is_object($payment) || ! isset($payment->post_status)) { |
|
| 491 | 491 | return false; |
| 492 | 492 | } |
| 493 | 493 | |
| 494 | 494 | $statuses = give_get_payment_statuses(); |
| 495 | 495 | |
| 496 | - if ( ! is_array( $statuses ) || empty( $statuses ) ) { |
|
| 496 | + if ( ! is_array($statuses) || empty($statuses)) { |
|
| 497 | 497 | return false; |
| 498 | 498 | } |
| 499 | 499 | |
| 500 | 500 | // Get payment object if not already given. |
| 501 | - $payment = $payment instanceof Give_Payment ? $payment : new Give_Payment( $payment->ID ); |
|
| 501 | + $payment = $payment instanceof Give_Payment ? $payment : new Give_Payment($payment->ID); |
|
| 502 | 502 | |
| 503 | - if ( array_key_exists( $payment->status, $statuses ) ) { |
|
| 504 | - if ( true === $return_label ) { |
|
| 503 | + if (array_key_exists($payment->status, $statuses)) { |
|
| 504 | + if (true === $return_label) { |
|
| 505 | 505 | // Return translated status label. |
| 506 | - return $statuses[ $payment->status ]; |
|
| 506 | + return $statuses[$payment->status]; |
|
| 507 | 507 | } else { |
| 508 | 508 | // Account that our 'publish' status is labeled 'Complete' |
| 509 | 509 | $post_status = 'publish' === $payment->status ? 'Complete' : $payment->post_status; |
| 510 | 510 | |
| 511 | 511 | // Make sure we're matching cases, since they matter |
| 512 | - return array_search( strtolower( $post_status ), array_map( 'strtolower', $statuses ) ); |
|
| 512 | + return array_search(strtolower($post_status), array_map('strtolower', $statuses)); |
|
| 513 | 513 | } |
| 514 | 514 | } |
| 515 | 515 | |
@@ -525,18 +525,18 @@ discard block |
||
| 525 | 525 | */ |
| 526 | 526 | function give_get_payment_statuses() { |
| 527 | 527 | $payment_statuses = array( |
| 528 | - 'pending' => __( 'Pending', 'give' ), |
|
| 529 | - 'publish' => __( 'Complete', 'give' ), |
|
| 530 | - 'refunded' => __( 'Refunded', 'give' ), |
|
| 531 | - 'failed' => __( 'Failed', 'give' ), |
|
| 532 | - 'cancelled' => __( 'Cancelled', 'give' ), |
|
| 533 | - 'abandoned' => __( 'Abandoned', 'give' ), |
|
| 534 | - 'preapproval' => __( 'Pre-Approved', 'give' ), |
|
| 535 | - 'processing' => __( 'Processing', 'give' ), |
|
| 536 | - 'revoked' => __( 'Revoked', 'give' ), |
|
| 528 | + 'pending' => __('Pending', 'give'), |
|
| 529 | + 'publish' => __('Complete', 'give'), |
|
| 530 | + 'refunded' => __('Refunded', 'give'), |
|
| 531 | + 'failed' => __('Failed', 'give'), |
|
| 532 | + 'cancelled' => __('Cancelled', 'give'), |
|
| 533 | + 'abandoned' => __('Abandoned', 'give'), |
|
| 534 | + 'preapproval' => __('Pre-Approved', 'give'), |
|
| 535 | + 'processing' => __('Processing', 'give'), |
|
| 536 | + 'revoked' => __('Revoked', 'give'), |
|
| 537 | 537 | ); |
| 538 | 538 | |
| 539 | - return apply_filters( 'give_payment_statuses', $payment_statuses ); |
|
| 539 | + return apply_filters('give_payment_statuses', $payment_statuses); |
|
| 540 | 540 | } |
| 541 | 541 | |
| 542 | 542 | /** |
@@ -549,10 +549,10 @@ discard block |
||
| 549 | 549 | * @return array $payment_status All the available payment statuses. |
| 550 | 550 | */ |
| 551 | 551 | function give_get_payment_status_keys() { |
| 552 | - $statuses = array_keys( give_get_payment_statuses() ); |
|
| 553 | - asort( $statuses ); |
|
| 552 | + $statuses = array_keys(give_get_payment_statuses()); |
|
| 553 | + asort($statuses); |
|
| 554 | 554 | |
| 555 | - return array_values( $statuses ); |
|
| 555 | + return array_values($statuses); |
|
| 556 | 556 | } |
| 557 | 557 | |
| 558 | 558 | /** |
@@ -567,44 +567,44 @@ discard block |
||
| 567 | 567 | * |
| 568 | 568 | * @return int $earnings Earnings |
| 569 | 569 | */ |
| 570 | -function give_get_earnings_by_date( $day = null, $month_num, $year = null, $hour = null ) { |
|
| 570 | +function give_get_earnings_by_date($day = null, $month_num, $year = null, $hour = null) { |
|
| 571 | 571 | // This is getting deprecated soon. Use Give_Payment_Stats with the get_earnings() method instead. |
| 572 | 572 | |
| 573 | 573 | global $wpdb; |
| 574 | - $meta_table = __give_v20_bc_table_details( 'payment' ); |
|
| 574 | + $meta_table = __give_v20_bc_table_details('payment'); |
|
| 575 | 575 | |
| 576 | 576 | $args = array( |
| 577 | 577 | 'post_type' => 'give_payment', |
| 578 | 578 | 'nopaging' => true, |
| 579 | 579 | 'year' => $year, |
| 580 | 580 | 'monthnum' => $month_num, |
| 581 | - 'post_status' => array( 'publish' ), |
|
| 581 | + 'post_status' => array('publish'), |
|
| 582 | 582 | 'fields' => 'ids', |
| 583 | 583 | 'update_post_term_cache' => false, |
| 584 | 584 | ); |
| 585 | - if ( ! empty( $day ) ) { |
|
| 585 | + if ( ! empty($day)) { |
|
| 586 | 586 | $args['day'] = $day; |
| 587 | 587 | } |
| 588 | 588 | |
| 589 | - if ( isset( $hour ) ) { |
|
| 589 | + if (isset($hour)) { |
|
| 590 | 590 | $args['hour'] = $hour; |
| 591 | 591 | } |
| 592 | 592 | |
| 593 | - $args = apply_filters( 'give_get_earnings_by_date_args', $args ); |
|
| 594 | - $key = Give_Cache::get_key( 'give_stats', $args ); |
|
| 593 | + $args = apply_filters('give_get_earnings_by_date_args', $args); |
|
| 594 | + $key = Give_Cache::get_key('give_stats', $args); |
|
| 595 | 595 | |
| 596 | - if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) { |
|
| 596 | + if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) { |
|
| 597 | 597 | $earnings = false; |
| 598 | 598 | } else { |
| 599 | - $earnings = Give_Cache::get( $key ); |
|
| 599 | + $earnings = Give_Cache::get($key); |
|
| 600 | 600 | } |
| 601 | 601 | |
| 602 | - if ( false === $earnings ) { |
|
| 603 | - $donations = get_posts( $args ); |
|
| 602 | + if (false === $earnings) { |
|
| 603 | + $donations = get_posts($args); |
|
| 604 | 604 | $earnings = 0; |
| 605 | - if ( $donations ) { |
|
| 606 | - $donations = implode( ',', $donations ); |
|
| 607 | - $earning_totals = $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN ({$donations})" ); |
|
| 605 | + if ($donations) { |
|
| 606 | + $donations = implode(',', $donations); |
|
| 607 | + $earning_totals = $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN ({$donations})"); |
|
| 608 | 608 | |
| 609 | 609 | /** |
| 610 | 610 | * Filter The earnings by dates. |
@@ -615,13 +615,13 @@ discard block |
||
| 615 | 615 | * @param array $donations Donations lists. |
| 616 | 616 | * @param array $args Donation query args. |
| 617 | 617 | */ |
| 618 | - $earnings = apply_filters( 'give_get_earnings_by_date', $earning_totals, $donations, $args ); |
|
| 618 | + $earnings = apply_filters('give_get_earnings_by_date', $earning_totals, $donations, $args); |
|
| 619 | 619 | } |
| 620 | 620 | // Cache the results for one hour. |
| 621 | - Give_Cache::set( $key, $earnings, HOUR_IN_SECONDS ); |
|
| 621 | + Give_Cache::set($key, $earnings, HOUR_IN_SECONDS); |
|
| 622 | 622 | } |
| 623 | 623 | |
| 624 | - return round( $earnings, 2 ); |
|
| 624 | + return round($earnings, 2); |
|
| 625 | 625 | } |
| 626 | 626 | |
| 627 | 627 | /** |
@@ -636,7 +636,7 @@ discard block |
||
| 636 | 636 | * |
| 637 | 637 | * @return int $count Sales |
| 638 | 638 | */ |
| 639 | -function give_get_sales_by_date( $day = null, $month_num = null, $year = null, $hour = null ) { |
|
| 639 | +function give_get_sales_by_date($day = null, $month_num = null, $year = null, $hour = null) { |
|
| 640 | 640 | |
| 641 | 641 | // This is getting deprecated soon. Use Give_Payment_Stats with the get_sales() method instead. |
| 642 | 642 | $args = array( |
@@ -644,14 +644,14 @@ discard block |
||
| 644 | 644 | 'nopaging' => true, |
| 645 | 645 | 'year' => $year, |
| 646 | 646 | 'fields' => 'ids', |
| 647 | - 'post_status' => array( 'publish' ), |
|
| 647 | + 'post_status' => array('publish'), |
|
| 648 | 648 | 'update_post_meta_cache' => false, |
| 649 | 649 | 'update_post_term_cache' => false, |
| 650 | 650 | ); |
| 651 | 651 | |
| 652 | - $show_free = apply_filters( 'give_sales_by_date_show_free', true, $args ); |
|
| 652 | + $show_free = apply_filters('give_sales_by_date_show_free', true, $args); |
|
| 653 | 653 | |
| 654 | - if ( false === $show_free ) { |
|
| 654 | + if (false === $show_free) { |
|
| 655 | 655 | $args['meta_query'] = array( |
| 656 | 656 | array( |
| 657 | 657 | 'key' => '_give_payment_total', |
@@ -662,33 +662,33 @@ discard block |
||
| 662 | 662 | ); |
| 663 | 663 | } |
| 664 | 664 | |
| 665 | - if ( ! empty( $month_num ) ) { |
|
| 665 | + if ( ! empty($month_num)) { |
|
| 666 | 666 | $args['monthnum'] = $month_num; |
| 667 | 667 | } |
| 668 | 668 | |
| 669 | - if ( ! empty( $day ) ) { |
|
| 669 | + if ( ! empty($day)) { |
|
| 670 | 670 | $args['day'] = $day; |
| 671 | 671 | } |
| 672 | 672 | |
| 673 | - if ( isset( $hour ) ) { |
|
| 673 | + if (isset($hour)) { |
|
| 674 | 674 | $args['hour'] = $hour; |
| 675 | 675 | } |
| 676 | 676 | |
| 677 | - $args = apply_filters( 'give_get_sales_by_date_args', $args ); |
|
| 677 | + $args = apply_filters('give_get_sales_by_date_args', $args); |
|
| 678 | 678 | |
| 679 | - $key = Give_Cache::get_key( 'give_stats', $args ); |
|
| 679 | + $key = Give_Cache::get_key('give_stats', $args); |
|
| 680 | 680 | |
| 681 | - if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) { |
|
| 681 | + if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) { |
|
| 682 | 682 | $count = false; |
| 683 | 683 | } else { |
| 684 | - $count = Give_Cache::get( $key ); |
|
| 684 | + $count = Give_Cache::get($key); |
|
| 685 | 685 | } |
| 686 | 686 | |
| 687 | - if ( false === $count ) { |
|
| 688 | - $donations = new WP_Query( $args ); |
|
| 687 | + if (false === $count) { |
|
| 688 | + $donations = new WP_Query($args); |
|
| 689 | 689 | $count = (int) $donations->post_count; |
| 690 | 690 | // Cache the results for one hour. |
| 691 | - Give_Cache::set( $key, $count, HOUR_IN_SECONDS ); |
|
| 691 | + Give_Cache::set($key, $count, HOUR_IN_SECONDS); |
|
| 692 | 692 | } |
| 693 | 693 | |
| 694 | 694 | return $count; |
@@ -703,19 +703,19 @@ discard block |
||
| 703 | 703 | * |
| 704 | 704 | * @return bool $ret True if complete, false otherwise. |
| 705 | 705 | */ |
| 706 | -function give_is_payment_complete( $payment_id ) { |
|
| 707 | - $payment = new Give_Payment( $payment_id ); |
|
| 706 | +function give_is_payment_complete($payment_id) { |
|
| 707 | + $payment = new Give_Payment($payment_id); |
|
| 708 | 708 | |
| 709 | 709 | $ret = false; |
| 710 | 710 | |
| 711 | - if ( $payment->ID > 0 ) { |
|
| 711 | + if ($payment->ID > 0) { |
|
| 712 | 712 | |
| 713 | - if ( (int) $payment_id === (int) $payment->ID && 'publish' == $payment->status ) { |
|
| 713 | + if ((int) $payment_id === (int) $payment->ID && 'publish' == $payment->status) { |
|
| 714 | 714 | $ret = true; |
| 715 | 715 | } |
| 716 | 716 | } |
| 717 | 717 | |
| 718 | - return apply_filters( 'give_is_payment_complete', $ret, $payment_id, $payment->post_status ); |
|
| 718 | + return apply_filters('give_is_payment_complete', $ret, $payment_id, $payment->post_status); |
|
| 719 | 719 | } |
| 720 | 720 | |
| 721 | 721 | /** |
@@ -741,50 +741,50 @@ discard block |
||
| 741 | 741 | * |
| 742 | 742 | * @return float $total Total earnings. |
| 743 | 743 | */ |
| 744 | -function give_get_total_earnings( $recalculate = false ) { |
|
| 744 | +function give_get_total_earnings($recalculate = false) { |
|
| 745 | 745 | |
| 746 | - $total = get_option( 'give_earnings_total', 0 ); |
|
| 747 | - $meta_table = __give_v20_bc_table_details( 'payment' ); |
|
| 746 | + $total = get_option('give_earnings_total', 0); |
|
| 747 | + $meta_table = __give_v20_bc_table_details('payment'); |
|
| 748 | 748 | |
| 749 | 749 | // Calculate total earnings. |
| 750 | - if ( ! $total || $recalculate ) { |
|
| 750 | + if ( ! $total || $recalculate) { |
|
| 751 | 751 | global $wpdb; |
| 752 | 752 | |
| 753 | 753 | $total = (float) 0; |
| 754 | 754 | |
| 755 | - $args = apply_filters( 'give_get_total_earnings_args', array( |
|
| 755 | + $args = apply_filters('give_get_total_earnings_args', array( |
|
| 756 | 756 | 'offset' => 0, |
| 757 | - 'number' => - 1, |
|
| 758 | - 'status' => array( 'publish' ), |
|
| 757 | + 'number' => -1, |
|
| 758 | + 'status' => array('publish'), |
|
| 759 | 759 | 'fields' => 'ids', |
| 760 | - ) ); |
|
| 760 | + )); |
|
| 761 | 761 | |
| 762 | - $payments = give_get_payments( $args ); |
|
| 763 | - if ( $payments ) { |
|
| 762 | + $payments = give_get_payments($args); |
|
| 763 | + if ($payments) { |
|
| 764 | 764 | |
| 765 | 765 | /** |
| 766 | 766 | * If performing a donation, we need to skip the very last payment in the database, |
| 767 | 767 | * since it calls give_increase_total_earnings() on completion, |
| 768 | 768 | * which results in duplicated earnings for the very first donation. |
| 769 | 769 | */ |
| 770 | - if ( did_action( 'give_update_payment_status' ) ) { |
|
| 771 | - array_pop( $payments ); |
|
| 770 | + if (did_action('give_update_payment_status')) { |
|
| 771 | + array_pop($payments); |
|
| 772 | 772 | } |
| 773 | 773 | |
| 774 | - if ( ! empty( $payments ) ) { |
|
| 775 | - $payments = implode( ',', $payments ); |
|
| 776 | - $total += $wpdb->get_var( "SELECT SUM(meta_value) FROM {$meta_table['name']} WHERE meta_key = '_give_payment_total' AND {$meta_table['column']['id']} IN({$payments})" ); |
|
| 774 | + if ( ! empty($payments)) { |
|
| 775 | + $payments = implode(',', $payments); |
|
| 776 | + $total += $wpdb->get_var("SELECT SUM(meta_value) FROM {$meta_table['name']} WHERE meta_key = '_give_payment_total' AND {$meta_table['column']['id']} IN({$payments})"); |
|
| 777 | 777 | } |
| 778 | 778 | } |
| 779 | 779 | |
| 780 | - update_option( 'give_earnings_total', $total, 'no' ); |
|
| 780 | + update_option('give_earnings_total', $total, 'no'); |
|
| 781 | 781 | } |
| 782 | 782 | |
| 783 | - if ( $total < 0 ) { |
|
| 783 | + if ($total < 0) { |
|
| 784 | 784 | $total = 0; // Don't ever show negative earnings. |
| 785 | 785 | } |
| 786 | 786 | |
| 787 | - return apply_filters( 'give_total_earnings', round( $total, give_get_price_decimals() ), $total ); |
|
| 787 | + return apply_filters('give_total_earnings', round($total, give_get_price_decimals()), $total); |
|
| 788 | 788 | } |
| 789 | 789 | |
| 790 | 790 | /** |
@@ -796,10 +796,10 @@ discard block |
||
| 796 | 796 | * |
| 797 | 797 | * @return float $total Total earnings. |
| 798 | 798 | */ |
| 799 | -function give_increase_total_earnings( $amount = 0 ) { |
|
| 799 | +function give_increase_total_earnings($amount = 0) { |
|
| 800 | 800 | $total = give_get_total_earnings(); |
| 801 | 801 | $total += $amount; |
| 802 | - update_option( 'give_earnings_total', $total ); |
|
| 802 | + update_option('give_earnings_total', $total); |
|
| 803 | 803 | |
| 804 | 804 | return $total; |
| 805 | 805 | } |
@@ -813,13 +813,13 @@ discard block |
||
| 813 | 813 | * |
| 814 | 814 | * @return float $total Total earnings. |
| 815 | 815 | */ |
| 816 | -function give_decrease_total_earnings( $amount = 0 ) { |
|
| 816 | +function give_decrease_total_earnings($amount = 0) { |
|
| 817 | 817 | $total = give_get_total_earnings(); |
| 818 | 818 | $total -= $amount; |
| 819 | - if ( $total < 0 ) { |
|
| 819 | + if ($total < 0) { |
|
| 820 | 820 | $total = 0; |
| 821 | 821 | } |
| 822 | - update_option( 'give_earnings_total', $total ); |
|
| 822 | + update_option('give_earnings_total', $total); |
|
| 823 | 823 | |
| 824 | 824 | return $total; |
| 825 | 825 | } |
@@ -835,10 +835,10 @@ discard block |
||
| 835 | 835 | * |
| 836 | 836 | * @return mixed $meta Payment Meta. |
| 837 | 837 | */ |
| 838 | -function give_get_payment_meta( $payment_id = 0, $meta_key = '_give_payment_meta', $single = true ) { |
|
| 839 | - $payment = new Give_Payment( $payment_id ); |
|
| 838 | +function give_get_payment_meta($payment_id = 0, $meta_key = '_give_payment_meta', $single = true) { |
|
| 839 | + $payment = new Give_Payment($payment_id); |
|
| 840 | 840 | |
| 841 | - return $payment->get_meta( $meta_key, $single ); |
|
| 841 | + return $payment->get_meta($meta_key, $single); |
|
| 842 | 842 | } |
| 843 | 843 | |
| 844 | 844 | /** |
@@ -851,10 +851,10 @@ discard block |
||
| 851 | 851 | * |
| 852 | 852 | * @return mixed Meta ID if successful, false if unsuccessful. |
| 853 | 853 | */ |
| 854 | -function give_update_payment_meta( $payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '' ) { |
|
| 855 | - $payment = new Give_Payment( $payment_id ); |
|
| 854 | +function give_update_payment_meta($payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '') { |
|
| 855 | + $payment = new Give_Payment($payment_id); |
|
| 856 | 856 | |
| 857 | - return $payment->update_meta( $meta_key, $meta_value, $prev_value ); |
|
| 857 | + return $payment->update_meta($meta_key, $meta_value, $prev_value); |
|
| 858 | 858 | } |
| 859 | 859 | |
| 860 | 860 | /** |
@@ -866,8 +866,8 @@ discard block |
||
| 866 | 866 | * |
| 867 | 867 | * @return array $user_info User Info Meta Values. |
| 868 | 868 | */ |
| 869 | -function give_get_payment_meta_user_info( $payment_id ) { |
|
| 870 | - $payment = new Give_Payment( $payment_id ); |
|
| 869 | +function give_get_payment_meta_user_info($payment_id) { |
|
| 870 | + $payment = new Give_Payment($payment_id); |
|
| 871 | 871 | |
| 872 | 872 | return $payment->user_info; |
| 873 | 873 | } |
@@ -883,8 +883,8 @@ discard block |
||
| 883 | 883 | * |
| 884 | 884 | * @return int $form_id Form ID. |
| 885 | 885 | */ |
| 886 | -function give_get_payment_form_id( $payment_id ) { |
|
| 887 | - $payment = new Give_Payment( $payment_id ); |
|
| 886 | +function give_get_payment_form_id($payment_id) { |
|
| 887 | + $payment = new Give_Payment($payment_id); |
|
| 888 | 888 | |
| 889 | 889 | return $payment->form_id; |
| 890 | 890 | } |
@@ -898,8 +898,8 @@ discard block |
||
| 898 | 898 | * |
| 899 | 899 | * @return string $email User email. |
| 900 | 900 | */ |
| 901 | -function give_get_payment_user_email( $payment_id ) { |
|
| 902 | - $payment = new Give_Payment( $payment_id ); |
|
| 901 | +function give_get_payment_user_email($payment_id) { |
|
| 902 | + $payment = new Give_Payment($payment_id); |
|
| 903 | 903 | |
| 904 | 904 | return $payment->email; |
| 905 | 905 | } |
@@ -913,11 +913,11 @@ discard block |
||
| 913 | 913 | * |
| 914 | 914 | * @return bool $is_guest_payment If the payment is associated with a user (false) or not (true) |
| 915 | 915 | */ |
| 916 | -function give_is_guest_payment( $payment_id ) { |
|
| 917 | - $payment_user_id = give_get_payment_user_id( $payment_id ); |
|
| 918 | - $is_guest_payment = ! empty( $payment_user_id ) && $payment_user_id > 0 ? false : true; |
|
| 916 | +function give_is_guest_payment($payment_id) { |
|
| 917 | + $payment_user_id = give_get_payment_user_id($payment_id); |
|
| 918 | + $is_guest_payment = ! empty($payment_user_id) && $payment_user_id > 0 ? false : true; |
|
| 919 | 919 | |
| 920 | - return (bool) apply_filters( 'give_is_guest_payment', $is_guest_payment, $payment_id ); |
|
| 920 | + return (bool) apply_filters('give_is_guest_payment', $is_guest_payment, $payment_id); |
|
| 921 | 921 | } |
| 922 | 922 | |
| 923 | 923 | /** |
@@ -929,8 +929,8 @@ discard block |
||
| 929 | 929 | * |
| 930 | 930 | * @return int $user_id User ID. |
| 931 | 931 | */ |
| 932 | -function give_get_payment_user_id( $payment_id ) { |
|
| 933 | - $payment = new Give_Payment( $payment_id ); |
|
| 932 | +function give_get_payment_user_id($payment_id) { |
|
| 933 | + $payment = new Give_Payment($payment_id); |
|
| 934 | 934 | |
| 935 | 935 | return $payment->user_id; |
| 936 | 936 | } |
@@ -944,8 +944,8 @@ discard block |
||
| 944 | 944 | * |
| 945 | 945 | * @return int $payment->customer_id Donor ID. |
| 946 | 946 | */ |
| 947 | -function give_get_payment_donor_id( $payment_id ) { |
|
| 948 | - $payment = new Give_Payment( $payment_id ); |
|
| 947 | +function give_get_payment_donor_id($payment_id) { |
|
| 948 | + $payment = new Give_Payment($payment_id); |
|
| 949 | 949 | |
| 950 | 950 | return $payment->customer_id; |
| 951 | 951 | } |
@@ -959,8 +959,8 @@ discard block |
||
| 959 | 959 | * |
| 960 | 960 | * @return string $ip User IP. |
| 961 | 961 | */ |
| 962 | -function give_get_payment_user_ip( $payment_id ) { |
|
| 963 | - $payment = new Give_Payment( $payment_id ); |
|
| 962 | +function give_get_payment_user_ip($payment_id) { |
|
| 963 | + $payment = new Give_Payment($payment_id); |
|
| 964 | 964 | |
| 965 | 965 | return $payment->ip; |
| 966 | 966 | } |
@@ -974,8 +974,8 @@ discard block |
||
| 974 | 974 | * |
| 975 | 975 | * @return string $date The date the payment was completed. |
| 976 | 976 | */ |
| 977 | -function give_get_payment_completed_date( $payment_id = 0 ) { |
|
| 978 | - $payment = new Give_Payment( $payment_id ); |
|
| 977 | +function give_get_payment_completed_date($payment_id = 0) { |
|
| 978 | + $payment = new Give_Payment($payment_id); |
|
| 979 | 979 | |
| 980 | 980 | return $payment->completed_date; |
| 981 | 981 | } |
@@ -989,8 +989,8 @@ discard block |
||
| 989 | 989 | * |
| 990 | 990 | * @return string $gateway Gateway. |
| 991 | 991 | */ |
| 992 | -function give_get_payment_gateway( $payment_id ) { |
|
| 993 | - $payment = new Give_Payment( $payment_id ); |
|
| 992 | +function give_get_payment_gateway($payment_id) { |
|
| 993 | + $payment = new Give_Payment($payment_id); |
|
| 994 | 994 | |
| 995 | 995 | return $payment->gateway; |
| 996 | 996 | } |
@@ -1004,8 +1004,8 @@ discard block |
||
| 1004 | 1004 | * |
| 1005 | 1005 | * @return string $currency The currency code. |
| 1006 | 1006 | */ |
| 1007 | -function give_get_payment_currency_code( $payment_id = 0 ) { |
|
| 1008 | - $payment = new Give_Payment( $payment_id ); |
|
| 1007 | +function give_get_payment_currency_code($payment_id = 0) { |
|
| 1008 | + $payment = new Give_Payment($payment_id); |
|
| 1009 | 1009 | |
| 1010 | 1010 | return $payment->currency; |
| 1011 | 1011 | } |
@@ -1019,10 +1019,10 @@ discard block |
||
| 1019 | 1019 | * |
| 1020 | 1020 | * @return string $currency The currency name. |
| 1021 | 1021 | */ |
| 1022 | -function give_get_payment_currency( $payment_id = 0 ) { |
|
| 1023 | - $currency = give_get_payment_currency_code( $payment_id ); |
|
| 1022 | +function give_get_payment_currency($payment_id = 0) { |
|
| 1023 | + $currency = give_get_payment_currency_code($payment_id); |
|
| 1024 | 1024 | |
| 1025 | - return apply_filters( 'give_payment_currency', give_get_currency_name( $currency ), $payment_id ); |
|
| 1025 | + return apply_filters('give_payment_currency', give_get_currency_name($currency), $payment_id); |
|
| 1026 | 1026 | } |
| 1027 | 1027 | |
| 1028 | 1028 | /** |
@@ -1034,8 +1034,8 @@ discard block |
||
| 1034 | 1034 | * |
| 1035 | 1035 | * @return string $key Donation key. |
| 1036 | 1036 | */ |
| 1037 | -function give_get_payment_key( $payment_id = 0 ) { |
|
| 1038 | - $payment = new Give_Payment( $payment_id ); |
|
| 1037 | +function give_get_payment_key($payment_id = 0) { |
|
| 1038 | + $payment = new Give_Payment($payment_id); |
|
| 1039 | 1039 | |
| 1040 | 1040 | return $payment->key; |
| 1041 | 1041 | } |
@@ -1051,8 +1051,8 @@ discard block |
||
| 1051 | 1051 | * |
| 1052 | 1052 | * @return string $number Payment order number. |
| 1053 | 1053 | */ |
| 1054 | -function give_get_payment_number( $payment_id = 0 ) { |
|
| 1055 | - $payment = new Give_Payment( $payment_id ); |
|
| 1054 | +function give_get_payment_number($payment_id = 0) { |
|
| 1055 | + $payment = new Give_Payment($payment_id); |
|
| 1056 | 1056 | |
| 1057 | 1057 | return $payment->number; |
| 1058 | 1058 | } |
@@ -1066,23 +1066,23 @@ discard block |
||
| 1066 | 1066 | * |
| 1067 | 1067 | * @return string The formatted payment number. |
| 1068 | 1068 | */ |
| 1069 | -function give_format_payment_number( $number ) { |
|
| 1069 | +function give_format_payment_number($number) { |
|
| 1070 | 1070 | |
| 1071 | - if ( ! give_get_option( 'enable_sequential' ) ) { |
|
| 1071 | + if ( ! give_get_option('enable_sequential')) { |
|
| 1072 | 1072 | return $number; |
| 1073 | 1073 | } |
| 1074 | 1074 | |
| 1075 | - if ( ! is_numeric( $number ) ) { |
|
| 1075 | + if ( ! is_numeric($number)) { |
|
| 1076 | 1076 | return $number; |
| 1077 | 1077 | } |
| 1078 | 1078 | |
| 1079 | - $prefix = give_get_option( 'sequential_prefix' ); |
|
| 1080 | - $number = absint( $number ); |
|
| 1081 | - $postfix = give_get_option( 'sequential_postfix' ); |
|
| 1079 | + $prefix = give_get_option('sequential_prefix'); |
|
| 1080 | + $number = absint($number); |
|
| 1081 | + $postfix = give_get_option('sequential_postfix'); |
|
| 1082 | 1082 | |
| 1083 | - $formatted_number = $prefix . $number . $postfix; |
|
| 1083 | + $formatted_number = $prefix.$number.$postfix; |
|
| 1084 | 1084 | |
| 1085 | - return apply_filters( 'give_format_payment_number', $formatted_number, $prefix, $number, $postfix ); |
|
| 1085 | + return apply_filters('give_format_payment_number', $formatted_number, $prefix, $number, $postfix); |
|
| 1086 | 1086 | } |
| 1087 | 1087 | |
| 1088 | 1088 | /** |
@@ -1096,17 +1096,17 @@ discard block |
||
| 1096 | 1096 | */ |
| 1097 | 1097 | function give_get_next_payment_number() { |
| 1098 | 1098 | |
| 1099 | - if ( ! give_get_option( 'enable_sequential' ) ) { |
|
| 1099 | + if ( ! give_get_option('enable_sequential')) { |
|
| 1100 | 1100 | return false; |
| 1101 | 1101 | } |
| 1102 | 1102 | |
| 1103 | - $number = get_option( 'give_last_payment_number' ); |
|
| 1104 | - $start = give_get_option( 'sequential_start', 1 ); |
|
| 1103 | + $number = get_option('give_last_payment_number'); |
|
| 1104 | + $start = give_get_option('sequential_start', 1); |
|
| 1105 | 1105 | $increment_number = true; |
| 1106 | 1106 | |
| 1107 | - if ( false !== $number ) { |
|
| 1107 | + if (false !== $number) { |
|
| 1108 | 1108 | |
| 1109 | - if ( empty( $number ) ) { |
|
| 1109 | + if (empty($number)) { |
|
| 1110 | 1110 | |
| 1111 | 1111 | $number = $start; |
| 1112 | 1112 | $increment_number = false; |
@@ -1115,24 +1115,24 @@ discard block |
||
| 1115 | 1115 | } else { |
| 1116 | 1116 | |
| 1117 | 1117 | // This case handles the first addition of the new option, as well as if it get's deleted for any reason. |
| 1118 | - $payments = new Give_Payments_Query( array( |
|
| 1118 | + $payments = new Give_Payments_Query(array( |
|
| 1119 | 1119 | 'number' => 1, |
| 1120 | 1120 | 'order' => 'DESC', |
| 1121 | 1121 | 'orderby' => 'ID', |
| 1122 | 1122 | 'output' => 'posts', |
| 1123 | 1123 | 'fields' => 'ids', |
| 1124 | - ) ); |
|
| 1124 | + )); |
|
| 1125 | 1125 | $last_payment = $payments->get_payments(); |
| 1126 | 1126 | |
| 1127 | - if ( ! empty( $last_payment ) ) { |
|
| 1127 | + if ( ! empty($last_payment)) { |
|
| 1128 | 1128 | |
| 1129 | - $number = give_get_payment_number( $last_payment[0] ); |
|
| 1129 | + $number = give_get_payment_number($last_payment[0]); |
|
| 1130 | 1130 | |
| 1131 | 1131 | } |
| 1132 | 1132 | |
| 1133 | - if ( ! empty( $number ) && $number !== (int) $last_payment[0] ) { |
|
| 1133 | + if ( ! empty($number) && $number !== (int) $last_payment[0]) { |
|
| 1134 | 1134 | |
| 1135 | - $number = give_remove_payment_prefix_postfix( $number ); |
|
| 1135 | + $number = give_remove_payment_prefix_postfix($number); |
|
| 1136 | 1136 | |
| 1137 | 1137 | } else { |
| 1138 | 1138 | |
@@ -1141,13 +1141,13 @@ discard block |
||
| 1141 | 1141 | } |
| 1142 | 1142 | }// End if(). |
| 1143 | 1143 | |
| 1144 | - $increment_number = apply_filters( 'give_increment_payment_number', $increment_number, $number ); |
|
| 1144 | + $increment_number = apply_filters('give_increment_payment_number', $increment_number, $number); |
|
| 1145 | 1145 | |
| 1146 | - if ( $increment_number ) { |
|
| 1147 | - $number ++; |
|
| 1146 | + if ($increment_number) { |
|
| 1147 | + $number++; |
|
| 1148 | 1148 | } |
| 1149 | 1149 | |
| 1150 | - return apply_filters( 'give_get_next_payment_number', $number ); |
|
| 1150 | + return apply_filters('give_get_next_payment_number', $number); |
|
| 1151 | 1151 | } |
| 1152 | 1152 | |
| 1153 | 1153 | /** |
@@ -1159,25 +1159,25 @@ discard block |
||
| 1159 | 1159 | * |
| 1160 | 1160 | * @return string The new Payment number without prefix and postfix. |
| 1161 | 1161 | */ |
| 1162 | -function give_remove_payment_prefix_postfix( $number ) { |
|
| 1162 | +function give_remove_payment_prefix_postfix($number) { |
|
| 1163 | 1163 | |
| 1164 | - $prefix = give_get_option( 'sequential_prefix' ); |
|
| 1165 | - $postfix = give_get_option( 'sequential_postfix' ); |
|
| 1164 | + $prefix = give_get_option('sequential_prefix'); |
|
| 1165 | + $postfix = give_get_option('sequential_postfix'); |
|
| 1166 | 1166 | |
| 1167 | 1167 | // Remove prefix. |
| 1168 | - $number = preg_replace( '/' . $prefix . '/', '', $number, 1 ); |
|
| 1168 | + $number = preg_replace('/'.$prefix.'/', '', $number, 1); |
|
| 1169 | 1169 | |
| 1170 | 1170 | // Remove the postfix. |
| 1171 | - $length = strlen( $number ); |
|
| 1172 | - $postfix_pos = strrpos( $number, $postfix ); |
|
| 1173 | - if ( false !== $postfix_pos ) { |
|
| 1174 | - $number = substr_replace( $number, '', $postfix_pos, $length ); |
|
| 1171 | + $length = strlen($number); |
|
| 1172 | + $postfix_pos = strrpos($number, $postfix); |
|
| 1173 | + if (false !== $postfix_pos) { |
|
| 1174 | + $number = substr_replace($number, '', $postfix_pos, $length); |
|
| 1175 | 1175 | } |
| 1176 | 1176 | |
| 1177 | 1177 | // Ensure it's a whole number. |
| 1178 | - $number = intval( $number ); |
|
| 1178 | + $number = intval($number); |
|
| 1179 | 1179 | |
| 1180 | - return apply_filters( 'give_remove_payment_prefix_postfix', $number, $prefix, $postfix ); |
|
| 1180 | + return apply_filters('give_remove_payment_prefix_postfix', $number, $prefix, $postfix); |
|
| 1181 | 1181 | |
| 1182 | 1182 | } |
| 1183 | 1183 | |
@@ -1195,16 +1195,16 @@ discard block |
||
| 1195 | 1195 | * |
| 1196 | 1196 | * @return string $amount Fully formatted donation amount. |
| 1197 | 1197 | */ |
| 1198 | -function give_donation_amount( $donation, $format_args = array() ) { |
|
| 1198 | +function give_donation_amount($donation, $format_args = array()) { |
|
| 1199 | 1199 | /* @var Give_Payment $donation */ |
| 1200 | - if ( ! ( $donation instanceof Give_Payment ) ) { |
|
| 1201 | - $donation = new Give_Payment( absint( $donation ) ); |
|
| 1200 | + if ( ! ($donation instanceof Give_Payment)) { |
|
| 1201 | + $donation = new Give_Payment(absint($donation)); |
|
| 1202 | 1202 | } |
| 1203 | 1203 | |
| 1204 | 1204 | $amount = $donation->total; |
| 1205 | 1205 | $formatted_amount = $amount; |
| 1206 | 1206 | |
| 1207 | - if ( is_bool( $format_args ) ) { |
|
| 1207 | + if (is_bool($format_args)) { |
|
| 1208 | 1208 | $format_args = array( |
| 1209 | 1209 | 'currency' => (bool) $format_args, |
| 1210 | 1210 | 'amount' => (bool) $format_args, |
@@ -1227,27 +1227,25 @@ discard block |
||
| 1227 | 1227 | ) |
| 1228 | 1228 | ); |
| 1229 | 1229 | |
| 1230 | - if ( $format_args['amount'] || $format_args['currency'] ) { |
|
| 1230 | + if ($format_args['amount'] || $format_args['currency']) { |
|
| 1231 | 1231 | |
| 1232 | - if ( $format_args['amount'] ) { |
|
| 1232 | + if ($format_args['amount']) { |
|
| 1233 | 1233 | |
| 1234 | 1234 | $formatted_amount = give_format_amount( |
| 1235 | 1235 | $amount, |
| 1236 | - ! is_array( $format_args['amount'] ) ? |
|
| 1236 | + ! is_array($format_args['amount']) ? |
|
| 1237 | 1237 | array( |
| 1238 | 1238 | 'sanitize' => false, |
| 1239 | 1239 | 'currency' => $donation->currency, |
| 1240 | - ) : |
|
| 1241 | - $format_args['amount'] |
|
| 1240 | + ) : $format_args['amount'] |
|
| 1242 | 1241 | ); |
| 1243 | 1242 | } |
| 1244 | 1243 | |
| 1245 | - if ( $format_args['currency'] ) { |
|
| 1244 | + if ($format_args['currency']) { |
|
| 1246 | 1245 | $formatted_amount = give_currency_filter( |
| 1247 | 1246 | $formatted_amount, |
| 1248 | - ! is_array( $format_args['currency'] ) ? |
|
| 1249 | - array( 'currency_code' => $donation->currency ) : |
|
| 1250 | - $format_args['currency'] |
|
| 1247 | + ! is_array($format_args['currency']) ? |
|
| 1248 | + array('currency_code' => $donation->currency) : $format_args['currency'] |
|
| 1251 | 1249 | ); |
| 1252 | 1250 | } |
| 1253 | 1251 | } |
@@ -1262,7 +1260,7 @@ discard block |
||
| 1262 | 1260 | * @param int $donation_id Donation ID. |
| 1263 | 1261 | * @param string $type Donation amount type. |
| 1264 | 1262 | */ |
| 1265 | - return apply_filters( 'give_donation_amount', (string) $formatted_amount, $amount, $donation, $format_args ); |
|
| 1263 | + return apply_filters('give_donation_amount', (string) $formatted_amount, $amount, $donation, $format_args); |
|
| 1266 | 1264 | } |
| 1267 | 1265 | |
| 1268 | 1266 | /** |
@@ -1279,10 +1277,10 @@ discard block |
||
| 1279 | 1277 | * |
| 1280 | 1278 | * @return array Fully formatted payment subtotal. |
| 1281 | 1279 | */ |
| 1282 | -function give_payment_subtotal( $payment_id = 0 ) { |
|
| 1283 | - $subtotal = give_get_payment_subtotal( $payment_id ); |
|
| 1280 | +function give_payment_subtotal($payment_id = 0) { |
|
| 1281 | + $subtotal = give_get_payment_subtotal($payment_id); |
|
| 1284 | 1282 | |
| 1285 | - return give_currency_filter( give_format_amount( $subtotal, array( 'sanitize' => false ) ), array( 'currency_code' => give_get_payment_currency_code( $payment_id ) ) ); |
|
| 1283 | + return give_currency_filter(give_format_amount($subtotal, array('sanitize' => false)), array('currency_code' => give_get_payment_currency_code($payment_id))); |
|
| 1286 | 1284 | } |
| 1287 | 1285 | |
| 1288 | 1286 | /** |
@@ -1296,8 +1294,8 @@ discard block |
||
| 1296 | 1294 | * |
| 1297 | 1295 | * @return float $subtotal Subtotal for payment (non formatted). |
| 1298 | 1296 | */ |
| 1299 | -function give_get_payment_subtotal( $payment_id = 0 ) { |
|
| 1300 | - $payment = new Give_Payment( $payment_id ); |
|
| 1297 | +function give_get_payment_subtotal($payment_id = 0) { |
|
| 1298 | + $payment = new Give_Payment($payment_id); |
|
| 1301 | 1299 | |
| 1302 | 1300 | return $payment->subtotal; |
| 1303 | 1301 | } |
@@ -1311,8 +1309,8 @@ discard block |
||
| 1311 | 1309 | * |
| 1312 | 1310 | * @return string The donation ID. |
| 1313 | 1311 | */ |
| 1314 | -function give_get_payment_transaction_id( $payment_id = 0 ) { |
|
| 1315 | - $payment = new Give_Payment( $payment_id ); |
|
| 1312 | +function give_get_payment_transaction_id($payment_id = 0) { |
|
| 1313 | + $payment = new Give_Payment($payment_id); |
|
| 1316 | 1314 | |
| 1317 | 1315 | return $payment->transaction_id; |
| 1318 | 1316 | } |
@@ -1327,15 +1325,15 @@ discard block |
||
| 1327 | 1325 | * |
| 1328 | 1326 | * @return bool|mixed |
| 1329 | 1327 | */ |
| 1330 | -function give_set_payment_transaction_id( $payment_id = 0, $transaction_id = '' ) { |
|
| 1328 | +function give_set_payment_transaction_id($payment_id = 0, $transaction_id = '') { |
|
| 1331 | 1329 | |
| 1332 | - if ( empty( $payment_id ) || empty( $transaction_id ) ) { |
|
| 1330 | + if (empty($payment_id) || empty($transaction_id)) { |
|
| 1333 | 1331 | return false; |
| 1334 | 1332 | } |
| 1335 | 1333 | |
| 1336 | - $transaction_id = apply_filters( 'give_set_payment_transaction_id', $transaction_id, $payment_id ); |
|
| 1334 | + $transaction_id = apply_filters('give_set_payment_transaction_id', $transaction_id, $payment_id); |
|
| 1337 | 1335 | |
| 1338 | - return give_update_payment_meta( $payment_id, '_give_payment_transaction_id', $transaction_id ); |
|
| 1336 | + return give_update_payment_meta($payment_id, '_give_payment_transaction_id', $transaction_id); |
|
| 1339 | 1337 | } |
| 1340 | 1338 | |
| 1341 | 1339 | /** |
@@ -1348,10 +1346,10 @@ discard block |
||
| 1348 | 1346 | * |
| 1349 | 1347 | * @return int $purchase Donation ID. |
| 1350 | 1348 | */ |
| 1351 | -function give_get_donation_id_by_key( $key ) { |
|
| 1349 | +function give_get_donation_id_by_key($key) { |
|
| 1352 | 1350 | global $wpdb; |
| 1353 | 1351 | |
| 1354 | - $meta_table = __give_v20_bc_table_details( 'payment' ); |
|
| 1352 | + $meta_table = __give_v20_bc_table_details('payment'); |
|
| 1355 | 1353 | |
| 1356 | 1354 | $purchase = $wpdb->get_var( |
| 1357 | 1355 | $wpdb->prepare( |
@@ -1367,7 +1365,7 @@ discard block |
||
| 1367 | 1365 | ) |
| 1368 | 1366 | ); |
| 1369 | 1367 | |
| 1370 | - if ( $purchase != null ) { |
|
| 1368 | + if ($purchase != null) { |
|
| 1371 | 1369 | return $purchase; |
| 1372 | 1370 | } |
| 1373 | 1371 | |
@@ -1385,13 +1383,13 @@ discard block |
||
| 1385 | 1383 | * |
| 1386 | 1384 | * @return int $purchase Donation ID. |
| 1387 | 1385 | */ |
| 1388 | -function give_get_purchase_id_by_transaction_id( $key ) { |
|
| 1386 | +function give_get_purchase_id_by_transaction_id($key) { |
|
| 1389 | 1387 | global $wpdb; |
| 1390 | - $meta_table = __give_v20_bc_table_details( 'payment' ); |
|
| 1388 | + $meta_table = __give_v20_bc_table_details('payment'); |
|
| 1391 | 1389 | |
| 1392 | - $purchase = $wpdb->get_var( $wpdb->prepare( "SELECT {$meta_table['column']['id']} FROM {$meta_table['name']} WHERE meta_key = '_give_payment_transaction_id' AND meta_value = %s LIMIT 1", $key ) ); |
|
| 1390 | + $purchase = $wpdb->get_var($wpdb->prepare("SELECT {$meta_table['column']['id']} FROM {$meta_table['name']} WHERE meta_key = '_give_payment_transaction_id' AND meta_value = %s LIMIT 1", $key)); |
|
| 1393 | 1391 | |
| 1394 | - if ( $purchase != null ) { |
|
| 1392 | + if ($purchase != null) { |
|
| 1395 | 1393 | return $purchase; |
| 1396 | 1394 | } |
| 1397 | 1395 | |
@@ -1408,23 +1406,23 @@ discard block |
||
| 1408 | 1406 | * |
| 1409 | 1407 | * @return array $notes Donation Notes |
| 1410 | 1408 | */ |
| 1411 | -function give_get_payment_notes( $payment_id = 0, $search = '' ) { |
|
| 1409 | +function give_get_payment_notes($payment_id = 0, $search = '') { |
|
| 1412 | 1410 | |
| 1413 | - if ( empty( $payment_id ) && empty( $search ) ) { |
|
| 1411 | + if (empty($payment_id) && empty($search)) { |
|
| 1414 | 1412 | return false; |
| 1415 | 1413 | } |
| 1416 | 1414 | |
| 1417 | - remove_action( 'pre_get_comments', 'give_hide_payment_notes', 10 ); |
|
| 1418 | - remove_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10 ); |
|
| 1415 | + remove_action('pre_get_comments', 'give_hide_payment_notes', 10); |
|
| 1416 | + remove_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10); |
|
| 1419 | 1417 | |
| 1420 | - $notes = get_comments( array( |
|
| 1418 | + $notes = get_comments(array( |
|
| 1421 | 1419 | 'post_id' => $payment_id, |
| 1422 | 1420 | 'order' => 'ASC', |
| 1423 | 1421 | 'search' => $search, |
| 1424 | - ) ); |
|
| 1422 | + )); |
|
| 1425 | 1423 | |
| 1426 | - add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 ); |
|
| 1427 | - add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 ); |
|
| 1424 | + add_action('pre_get_comments', 'give_hide_payment_notes', 10); |
|
| 1425 | + add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2); |
|
| 1428 | 1426 | |
| 1429 | 1427 | return $notes; |
| 1430 | 1428 | } |
@@ -1440,8 +1438,8 @@ discard block |
||
| 1440 | 1438 | * |
| 1441 | 1439 | * @return int The new note ID |
| 1442 | 1440 | */ |
| 1443 | -function give_insert_payment_note( $payment_id = 0, $note = '' ) { |
|
| 1444 | - if ( empty( $payment_id ) ) { |
|
| 1441 | +function give_insert_payment_note($payment_id = 0, $note = '') { |
|
| 1442 | + if (empty($payment_id)) { |
|
| 1445 | 1443 | return false; |
| 1446 | 1444 | } |
| 1447 | 1445 | |
@@ -1453,14 +1451,14 @@ discard block |
||
| 1453 | 1451 | * |
| 1454 | 1452 | * @since 1.0 |
| 1455 | 1453 | */ |
| 1456 | - do_action( 'give_pre_insert_payment_note', $payment_id, $note ); |
|
| 1454 | + do_action('give_pre_insert_payment_note', $payment_id, $note); |
|
| 1457 | 1455 | |
| 1458 | - $note_id = wp_insert_comment( wp_filter_comment( array( |
|
| 1456 | + $note_id = wp_insert_comment(wp_filter_comment(array( |
|
| 1459 | 1457 | 'comment_post_ID' => $payment_id, |
| 1460 | 1458 | 'comment_content' => $note, |
| 1461 | 1459 | 'user_id' => is_admin() ? get_current_user_id() : 0, |
| 1462 | - 'comment_date' => current_time( 'mysql' ), |
|
| 1463 | - 'comment_date_gmt' => current_time( 'mysql', 1 ), |
|
| 1460 | + 'comment_date' => current_time('mysql'), |
|
| 1461 | + 'comment_date_gmt' => current_time('mysql', 1), |
|
| 1464 | 1462 | 'comment_approved' => 1, |
| 1465 | 1463 | 'comment_parent' => 0, |
| 1466 | 1464 | 'comment_author' => '', |
@@ -1469,7 +1467,7 @@ discard block |
||
| 1469 | 1467 | 'comment_author_email' => '', |
| 1470 | 1468 | 'comment_type' => 'give_payment_note', |
| 1471 | 1469 | |
| 1472 | - ) ) ); |
|
| 1470 | + ))); |
|
| 1473 | 1471 | |
| 1474 | 1472 | /** |
| 1475 | 1473 | * Fires after payment note inserted. |
@@ -1480,7 +1478,7 @@ discard block |
||
| 1480 | 1478 | * |
| 1481 | 1479 | * @since 1.0 |
| 1482 | 1480 | */ |
| 1483 | - do_action( 'give_insert_payment_note', $note_id, $payment_id, $note ); |
|
| 1481 | + do_action('give_insert_payment_note', $note_id, $payment_id, $note); |
|
| 1484 | 1482 | |
| 1485 | 1483 | return $note_id; |
| 1486 | 1484 | } |
@@ -1495,8 +1493,8 @@ discard block |
||
| 1495 | 1493 | * |
| 1496 | 1494 | * @return bool True on success, false otherwise. |
| 1497 | 1495 | */ |
| 1498 | -function give_delete_payment_note( $comment_id = 0, $payment_id = 0 ) { |
|
| 1499 | - if ( empty( $comment_id ) ) { |
|
| 1496 | +function give_delete_payment_note($comment_id = 0, $payment_id = 0) { |
|
| 1497 | + if (empty($comment_id)) { |
|
| 1500 | 1498 | return false; |
| 1501 | 1499 | } |
| 1502 | 1500 | |
@@ -1508,9 +1506,9 @@ discard block |
||
| 1508 | 1506 | * |
| 1509 | 1507 | * @since 1.0 |
| 1510 | 1508 | */ |
| 1511 | - do_action( 'give_pre_delete_payment_note', $comment_id, $payment_id ); |
|
| 1509 | + do_action('give_pre_delete_payment_note', $comment_id, $payment_id); |
|
| 1512 | 1510 | |
| 1513 | - $ret = wp_delete_comment( $comment_id, true ); |
|
| 1511 | + $ret = wp_delete_comment($comment_id, true); |
|
| 1514 | 1512 | |
| 1515 | 1513 | /** |
| 1516 | 1514 | * Fires after donation note deleted. |
@@ -1520,7 +1518,7 @@ discard block |
||
| 1520 | 1518 | * |
| 1521 | 1519 | * @since 1.0 |
| 1522 | 1520 | */ |
| 1523 | - do_action( 'give_post_delete_payment_note', $comment_id, $payment_id ); |
|
| 1521 | + do_action('give_post_delete_payment_note', $comment_id, $payment_id); |
|
| 1524 | 1522 | |
| 1525 | 1523 | return $ret; |
| 1526 | 1524 | } |
@@ -1535,32 +1533,32 @@ discard block |
||
| 1535 | 1533 | * |
| 1536 | 1534 | * @return string |
| 1537 | 1535 | */ |
| 1538 | -function give_get_payment_note_html( $note, $payment_id = 0 ) { |
|
| 1536 | +function give_get_payment_note_html($note, $payment_id = 0) { |
|
| 1539 | 1537 | |
| 1540 | - if ( is_numeric( $note ) ) { |
|
| 1541 | - $note = get_comment( $note ); |
|
| 1538 | + if (is_numeric($note)) { |
|
| 1539 | + $note = get_comment($note); |
|
| 1542 | 1540 | } |
| 1543 | 1541 | |
| 1544 | - if ( ! empty( $note->user_id ) ) { |
|
| 1545 | - $user = get_userdata( $note->user_id ); |
|
| 1542 | + if ( ! empty($note->user_id)) { |
|
| 1543 | + $user = get_userdata($note->user_id); |
|
| 1546 | 1544 | $user = $user->display_name; |
| 1547 | 1545 | } else { |
| 1548 | - $user = __( 'System', 'give' ); |
|
| 1546 | + $user = __('System', 'give'); |
|
| 1549 | 1547 | } |
| 1550 | 1548 | |
| 1551 | - $date_format = give_date_format() . ', ' . get_option( 'time_format' ); |
|
| 1549 | + $date_format = give_date_format().', '.get_option('time_format'); |
|
| 1552 | 1550 | |
| 1553 | - $delete_note_url = wp_nonce_url( add_query_arg( array( |
|
| 1551 | + $delete_note_url = wp_nonce_url(add_query_arg(array( |
|
| 1554 | 1552 | 'give-action' => 'delete_payment_note', |
| 1555 | 1553 | 'note_id' => $note->comment_ID, |
| 1556 | 1554 | 'payment_id' => $payment_id, |
| 1557 | - ) ), 'give_delete_payment_note_' . $note->comment_ID ); |
|
| 1555 | + )), 'give_delete_payment_note_'.$note->comment_ID); |
|
| 1558 | 1556 | |
| 1559 | - $note_html = '<div class="give-payment-note" id="give-payment-note-' . $note->comment_ID . '">'; |
|
| 1557 | + $note_html = '<div class="give-payment-note" id="give-payment-note-'.$note->comment_ID.'">'; |
|
| 1560 | 1558 | $note_html .= '<p>'; |
| 1561 | - $note_html .= '<strong>' . $user . '</strong> – <span style="color:#aaa;font-style:italic;">' . date_i18n( $date_format, strtotime( $note->comment_date ) ) . '</span><br/>'; |
|
| 1559 | + $note_html .= '<strong>'.$user.'</strong> – <span style="color:#aaa;font-style:italic;">'.date_i18n($date_format, strtotime($note->comment_date)).'</span><br/>'; |
|
| 1562 | 1560 | $note_html .= $note->comment_content; |
| 1563 | - $note_html .= ' – <a href="' . esc_url( $delete_note_url ) . '" class="give-delete-payment-note" data-note-id="' . absint( $note->comment_ID ) . '" data-payment-id="' . absint( $payment_id ) . '" aria-label="' . __( 'Delete this donation note.', 'give' ) . '">' . __( 'Delete', 'give' ) . '</a>'; |
|
| 1561 | + $note_html .= ' – <a href="'.esc_url($delete_note_url).'" class="give-delete-payment-note" data-note-id="'.absint($note->comment_ID).'" data-payment-id="'.absint($payment_id).'" aria-label="'.__('Delete this donation note.', 'give').'">'.__('Delete', 'give').'</a>'; |
|
| 1564 | 1562 | $note_html .= '</p>'; |
| 1565 | 1563 | $note_html .= '</div>'; |
| 1566 | 1564 | |
@@ -1578,18 +1576,18 @@ discard block |
||
| 1578 | 1576 | * |
| 1579 | 1577 | * @return void |
| 1580 | 1578 | */ |
| 1581 | -function give_hide_payment_notes( $query ) { |
|
| 1582 | - if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.1', '>=' ) ) { |
|
| 1583 | - $types = isset( $query->query_vars['type__not_in'] ) ? $query->query_vars['type__not_in'] : array(); |
|
| 1584 | - if ( ! is_array( $types ) ) { |
|
| 1585 | - $types = array( $types ); |
|
| 1579 | +function give_hide_payment_notes($query) { |
|
| 1580 | + if (version_compare(floatval(get_bloginfo('version')), '4.1', '>=')) { |
|
| 1581 | + $types = isset($query->query_vars['type__not_in']) ? $query->query_vars['type__not_in'] : array(); |
|
| 1582 | + if ( ! is_array($types)) { |
|
| 1583 | + $types = array($types); |
|
| 1586 | 1584 | } |
| 1587 | 1585 | $types[] = 'give_payment_note'; |
| 1588 | 1586 | $query->query_vars['type__not_in'] = $types; |
| 1589 | 1587 | } |
| 1590 | 1588 | } |
| 1591 | 1589 | |
| 1592 | -add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 ); |
|
| 1590 | +add_action('pre_get_comments', 'give_hide_payment_notes', 10); |
|
| 1593 | 1591 | |
| 1594 | 1592 | /** |
| 1595 | 1593 | * Exclude notes (comments) on give_payment post type from showing in Recent Comments widgets |
@@ -1601,15 +1599,15 @@ discard block |
||
| 1601 | 1599 | * |
| 1602 | 1600 | * @return array $clauses Updated comment clauses. |
| 1603 | 1601 | */ |
| 1604 | -function give_hide_payment_notes_pre_41( $clauses, $wp_comment_query ) { |
|
| 1605 | - if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.1', '<' ) ) { |
|
| 1602 | +function give_hide_payment_notes_pre_41($clauses, $wp_comment_query) { |
|
| 1603 | + if (version_compare(floatval(get_bloginfo('version')), '4.1', '<')) { |
|
| 1606 | 1604 | $clauses['where'] .= ' AND comment_type != "give_payment_note"'; |
| 1607 | 1605 | } |
| 1608 | 1606 | |
| 1609 | 1607 | return $clauses; |
| 1610 | 1608 | } |
| 1611 | 1609 | |
| 1612 | -add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 ); |
|
| 1610 | +add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2); |
|
| 1613 | 1611 | |
| 1614 | 1612 | |
| 1615 | 1613 | /** |
@@ -1622,15 +1620,15 @@ discard block |
||
| 1622 | 1620 | * |
| 1623 | 1621 | * @return string $where |
| 1624 | 1622 | */ |
| 1625 | -function give_hide_payment_notes_from_feeds( $where, $wp_comment_query ) { |
|
| 1623 | +function give_hide_payment_notes_from_feeds($where, $wp_comment_query) { |
|
| 1626 | 1624 | global $wpdb; |
| 1627 | 1625 | |
| 1628 | - $where .= $wpdb->prepare( ' AND comment_type != %s', 'give_payment_note' ); |
|
| 1626 | + $where .= $wpdb->prepare(' AND comment_type != %s', 'give_payment_note'); |
|
| 1629 | 1627 | |
| 1630 | 1628 | return $where; |
| 1631 | 1629 | } |
| 1632 | 1630 | |
| 1633 | -add_filter( 'comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2 ); |
|
| 1631 | +add_filter('comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2); |
|
| 1634 | 1632 | |
| 1635 | 1633 | |
| 1636 | 1634 | /** |
@@ -1644,32 +1642,32 @@ discard block |
||
| 1644 | 1642 | * |
| 1645 | 1643 | * @return array|object Array of comment counts. |
| 1646 | 1644 | */ |
| 1647 | -function give_remove_payment_notes_in_comment_counts( $stats, $post_id ) { |
|
| 1645 | +function give_remove_payment_notes_in_comment_counts($stats, $post_id) { |
|
| 1648 | 1646 | global $wpdb, $pagenow; |
| 1649 | 1647 | |
| 1650 | - if ( 'index.php' != $pagenow ) { |
|
| 1648 | + if ('index.php' != $pagenow) { |
|
| 1651 | 1649 | return $stats; |
| 1652 | 1650 | } |
| 1653 | 1651 | |
| 1654 | 1652 | $post_id = (int) $post_id; |
| 1655 | 1653 | |
| 1656 | - if ( apply_filters( 'give_count_payment_notes_in_comments', false ) ) { |
|
| 1654 | + if (apply_filters('give_count_payment_notes_in_comments', false)) { |
|
| 1657 | 1655 | return $stats; |
| 1658 | 1656 | } |
| 1659 | 1657 | |
| 1660 | - $stats = Give_Cache::get_group( "comments-{$post_id}", 'counts' ); |
|
| 1658 | + $stats = Give_Cache::get_group("comments-{$post_id}", 'counts'); |
|
| 1661 | 1659 | |
| 1662 | - if ( ! is_null( $stats ) ) { |
|
| 1660 | + if ( ! is_null($stats)) { |
|
| 1663 | 1661 | return $stats; |
| 1664 | 1662 | } |
| 1665 | 1663 | |
| 1666 | 1664 | $where = 'WHERE comment_type != "give_payment_note"'; |
| 1667 | 1665 | |
| 1668 | - if ( $post_id > 0 ) { |
|
| 1669 | - $where .= $wpdb->prepare( ' AND comment_post_ID = %d', $post_id ); |
|
| 1666 | + if ($post_id > 0) { |
|
| 1667 | + $where .= $wpdb->prepare(' AND comment_post_ID = %d', $post_id); |
|
| 1670 | 1668 | } |
| 1671 | 1669 | |
| 1672 | - $count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A ); |
|
| 1670 | + $count = $wpdb->get_results("SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A); |
|
| 1673 | 1671 | |
| 1674 | 1672 | $total = 0; |
| 1675 | 1673 | $approved = array( |
@@ -1679,30 +1677,30 @@ discard block |
||
| 1679 | 1677 | 'trash' => 'trash', |
| 1680 | 1678 | 'post-trashed' => 'post-trashed', |
| 1681 | 1679 | ); |
| 1682 | - foreach ( (array) $count as $row ) { |
|
| 1680 | + foreach ((array) $count as $row) { |
|
| 1683 | 1681 | // Don't count post-trashed toward totals. |
| 1684 | - if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] ) { |
|
| 1682 | + if ('post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved']) { |
|
| 1685 | 1683 | $total += $row['num_comments']; |
| 1686 | 1684 | } |
| 1687 | - if ( isset( $approved[ $row['comment_approved'] ] ) ) { |
|
| 1688 | - $stats[ $approved[ $row['comment_approved'] ] ] = $row['num_comments']; |
|
| 1685 | + if (isset($approved[$row['comment_approved']])) { |
|
| 1686 | + $stats[$approved[$row['comment_approved']]] = $row['num_comments']; |
|
| 1689 | 1687 | } |
| 1690 | 1688 | } |
| 1691 | 1689 | |
| 1692 | 1690 | $stats['total_comments'] = $total; |
| 1693 | - foreach ( $approved as $key ) { |
|
| 1694 | - if ( empty( $stats[ $key ] ) ) { |
|
| 1695 | - $stats[ $key ] = 0; |
|
| 1691 | + foreach ($approved as $key) { |
|
| 1692 | + if (empty($stats[$key])) { |
|
| 1693 | + $stats[$key] = 0; |
|
| 1696 | 1694 | } |
| 1697 | 1695 | } |
| 1698 | 1696 | |
| 1699 | 1697 | $stats = (object) $stats; |
| 1700 | - Give_Cache::set_group( "comments-{$post_id}", $stats, 'counts' ); |
|
| 1698 | + Give_Cache::set_group("comments-{$post_id}", $stats, 'counts'); |
|
| 1701 | 1699 | |
| 1702 | 1700 | return $stats; |
| 1703 | 1701 | } |
| 1704 | 1702 | |
| 1705 | -add_filter( 'wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2 ); |
|
| 1703 | +add_filter('wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2); |
|
| 1706 | 1704 | |
| 1707 | 1705 | |
| 1708 | 1706 | /** |
@@ -1715,9 +1713,9 @@ discard block |
||
| 1715 | 1713 | * |
| 1716 | 1714 | * @return string $where Modified where clause. |
| 1717 | 1715 | */ |
| 1718 | -function give_filter_where_older_than_week( $where = '' ) { |
|
| 1716 | +function give_filter_where_older_than_week($where = '') { |
|
| 1719 | 1717 | // Payments older than one week. |
| 1720 | - $start = date( 'Y-m-d', strtotime( '-7 days' ) ); |
|
| 1718 | + $start = date('Y-m-d', strtotime('-7 days')); |
|
| 1721 | 1719 | $where .= " AND post_date <= '{$start}'"; |
| 1722 | 1720 | |
| 1723 | 1721 | return $where; |
@@ -1737,13 +1735,13 @@ discard block |
||
| 1737 | 1735 | * |
| 1738 | 1736 | * @return string $form_title Returns the full title if $only_level is false, otherwise returns the levels title. |
| 1739 | 1737 | */ |
| 1740 | -function give_get_donation_form_title( $donation, $args = array() ) { |
|
| 1738 | +function give_get_donation_form_title($donation, $args = array()) { |
|
| 1741 | 1739 | |
| 1742 | - if ( ! $donation instanceof Give_Payment ) { |
|
| 1743 | - $donation = new Give_Payment( $donation ); |
|
| 1740 | + if ( ! $donation instanceof Give_Payment) { |
|
| 1741 | + $donation = new Give_Payment($donation); |
|
| 1744 | 1742 | } |
| 1745 | 1743 | |
| 1746 | - if( ! $donation->ID ) { |
|
| 1744 | + if ( ! $donation->ID) { |
|
| 1747 | 1745 | return ''; |
| 1748 | 1746 | } |
| 1749 | 1747 | |
@@ -1752,7 +1750,7 @@ discard block |
||
| 1752 | 1750 | 'separator' => '', |
| 1753 | 1751 | ); |
| 1754 | 1752 | |
| 1755 | - $args = wp_parse_args( $args, $defaults ); |
|
| 1753 | + $args = wp_parse_args($args, $defaults); |
|
| 1756 | 1754 | |
| 1757 | 1755 | $form_id = $donation->form_id; |
| 1758 | 1756 | $price_id = $donation->price_id; |
@@ -1773,32 +1771,32 @@ discard block |
||
| 1773 | 1771 | , false |
| 1774 | 1772 | ); |
| 1775 | 1773 | |
| 1776 | - $form_title_html = Give_Cache::get_db_query( $cache_key ); |
|
| 1774 | + $form_title_html = Give_Cache::get_db_query($cache_key); |
|
| 1777 | 1775 | |
| 1778 | - if ( is_null( $form_title_html ) ) { |
|
| 1779 | - if ( true === $only_level ) { |
|
| 1776 | + if (is_null($form_title_html)) { |
|
| 1777 | + if (true === $only_level) { |
|
| 1780 | 1778 | $form_title = ''; |
| 1781 | 1779 | } |
| 1782 | 1780 | |
| 1783 | 1781 | $form_title_html = $form_title; |
| 1784 | 1782 | |
| 1785 | - if ( 'custom' === $price_id ) { |
|
| 1786 | - $custom_amount_text = give_get_meta( $form_id, '_give_custom_amount_text', true ); |
|
| 1787 | - $level_label = ! empty( $custom_amount_text ) ? $custom_amount_text : __( 'Custom Amount', 'give' ); |
|
| 1788 | - } elseif ( give_has_variable_prices( $form_id ) ) { |
|
| 1789 | - $level_label = give_get_price_option_name( $form_id, $price_id ); |
|
| 1783 | + if ('custom' === $price_id) { |
|
| 1784 | + $custom_amount_text = give_get_meta($form_id, '_give_custom_amount_text', true); |
|
| 1785 | + $level_label = ! empty($custom_amount_text) ? $custom_amount_text : __('Custom Amount', 'give'); |
|
| 1786 | + } elseif (give_has_variable_prices($form_id)) { |
|
| 1787 | + $level_label = give_get_price_option_name($form_id, $price_id); |
|
| 1790 | 1788 | } |
| 1791 | 1789 | |
| 1792 | 1790 | // Only add separator if there is a form title. |
| 1793 | 1791 | if ( |
| 1794 | - ! empty( $form_title_html ) && |
|
| 1795 | - ! empty( $level_label ) |
|
| 1792 | + ! empty($form_title_html) && |
|
| 1793 | + ! empty($level_label) |
|
| 1796 | 1794 | ) { |
| 1797 | 1795 | $form_title_html .= " {$separator} "; |
| 1798 | 1796 | } |
| 1799 | 1797 | |
| 1800 | 1798 | $form_title_html .= "<span class=\"donation-level-text-wrap\">{$level_label}</span>"; |
| 1801 | - Give_Cache::set_db_query( $cache_key, $form_title_html ); |
|
| 1799 | + Give_Cache::set_db_query($cache_key, $form_title_html); |
|
| 1802 | 1800 | } |
| 1803 | 1801 | |
| 1804 | 1802 | /** |
@@ -1806,7 +1804,7 @@ discard block |
||
| 1806 | 1804 | * |
| 1807 | 1805 | * @since 1.0 |
| 1808 | 1806 | */ |
| 1809 | - return apply_filters( 'give_get_donation_form_title', $form_title_html, $donation->payment_meta, $donation ); |
|
| 1807 | + return apply_filters('give_get_donation_form_title', $form_title_html, $donation->payment_meta, $donation); |
|
| 1810 | 1808 | } |
| 1811 | 1809 | |
| 1812 | 1810 | /** |
@@ -1819,19 +1817,19 @@ discard block |
||
| 1819 | 1817 | * |
| 1820 | 1818 | * @return string $price_id |
| 1821 | 1819 | */ |
| 1822 | -function give_get_price_id( $form_id, $price ) { |
|
| 1820 | +function give_get_price_id($form_id, $price) { |
|
| 1823 | 1821 | $price_id = null; |
| 1824 | 1822 | |
| 1825 | - if ( give_has_variable_prices( $form_id ) ) { |
|
| 1823 | + if (give_has_variable_prices($form_id)) { |
|
| 1826 | 1824 | |
| 1827 | - $levels = give_get_meta( $form_id, '_give_donation_levels', true ); |
|
| 1825 | + $levels = give_get_meta($form_id, '_give_donation_levels', true); |
|
| 1828 | 1826 | |
| 1829 | - foreach ( $levels as $level ) { |
|
| 1827 | + foreach ($levels as $level) { |
|
| 1830 | 1828 | |
| 1831 | - $level_amount = give_maybe_sanitize_amount( $level['_give_amount'] ); |
|
| 1829 | + $level_amount = give_maybe_sanitize_amount($level['_give_amount']); |
|
| 1832 | 1830 | |
| 1833 | 1831 | // Check that this indeed the recurring price. |
| 1834 | - if ( $level_amount == $price ) { |
|
| 1832 | + if ($level_amount == $price) { |
|
| 1835 | 1833 | |
| 1836 | 1834 | $price_id = $level['_give_id']['level_id']; |
| 1837 | 1835 | break; |
@@ -1839,13 +1837,13 @@ discard block |
||
| 1839 | 1837 | } |
| 1840 | 1838 | } |
| 1841 | 1839 | |
| 1842 | - if ( is_null( $price_id ) && give_is_custom_price_mode( $form_id ) ) { |
|
| 1840 | + if (is_null($price_id) && give_is_custom_price_mode($form_id)) { |
|
| 1843 | 1841 | $price_id = 'custom'; |
| 1844 | 1842 | } |
| 1845 | 1843 | } |
| 1846 | 1844 | |
| 1847 | 1845 | // Price ID must be numeric or string. |
| 1848 | - $price_id = ! is_numeric( $price_id ) && ! is_string( $price_id ) ? 0 : $price_id; |
|
| 1846 | + $price_id = ! is_numeric($price_id) && ! is_string($price_id) ? 0 : $price_id; |
|
| 1849 | 1847 | |
| 1850 | 1848 | /** |
| 1851 | 1849 | * Filter the price id |
@@ -1855,7 +1853,7 @@ discard block |
||
| 1855 | 1853 | * @param string $price_id |
| 1856 | 1854 | * @param int $form_id |
| 1857 | 1855 | */ |
| 1858 | - return apply_filters( 'give_get_price_id', $price_id, $form_id ); |
|
| 1856 | + return apply_filters('give_get_price_id', $price_id, $form_id); |
|
| 1859 | 1857 | } |
| 1860 | 1858 | |
| 1861 | 1859 | /** |
@@ -1871,10 +1869,10 @@ discard block |
||
| 1871 | 1869 | * |
| 1872 | 1870 | * @return string |
| 1873 | 1871 | */ |
| 1874 | -function give_get_form_dropdown( $args = array(), $echo = false ) { |
|
| 1875 | - $form_dropdown_html = Give()->html->forms_dropdown( $args ); |
|
| 1872 | +function give_get_form_dropdown($args = array(), $echo = false) { |
|
| 1873 | + $form_dropdown_html = Give()->html->forms_dropdown($args); |
|
| 1876 | 1874 | |
| 1877 | - if ( ! $echo ) { |
|
| 1875 | + if ( ! $echo) { |
|
| 1878 | 1876 | return $form_dropdown_html; |
| 1879 | 1877 | } |
| 1880 | 1878 | |
@@ -1891,17 +1889,17 @@ discard block |
||
| 1891 | 1889 | * |
| 1892 | 1890 | * @return string|bool |
| 1893 | 1891 | */ |
| 1894 | -function give_get_form_variable_price_dropdown( $args = array(), $echo = false ) { |
|
| 1892 | +function give_get_form_variable_price_dropdown($args = array(), $echo = false) { |
|
| 1895 | 1893 | |
| 1896 | 1894 | // Check for give form id. |
| 1897 | - if ( empty( $args['id'] ) ) { |
|
| 1895 | + if (empty($args['id'])) { |
|
| 1898 | 1896 | return false; |
| 1899 | 1897 | } |
| 1900 | 1898 | |
| 1901 | - $form = new Give_Donate_Form( $args['id'] ); |
|
| 1899 | + $form = new Give_Donate_Form($args['id']); |
|
| 1902 | 1900 | |
| 1903 | 1901 | // Check if form has variable prices or not. |
| 1904 | - if ( ! $form->ID || ! $form->has_variable_prices() ) { |
|
| 1902 | + if ( ! $form->ID || ! $form->has_variable_prices()) { |
|
| 1905 | 1903 | return false; |
| 1906 | 1904 | } |
| 1907 | 1905 | |
@@ -1909,24 +1907,24 @@ discard block |
||
| 1909 | 1907 | $variable_price_options = array(); |
| 1910 | 1908 | |
| 1911 | 1909 | // Check if multi donation form support custom donation or not. |
| 1912 | - if ( $form->is_custom_price_mode() ) { |
|
| 1913 | - $variable_price_options['custom'] = _x( 'Custom', 'custom donation dropdown item', 'give' ); |
|
| 1910 | + if ($form->is_custom_price_mode()) { |
|
| 1911 | + $variable_price_options['custom'] = _x('Custom', 'custom donation dropdown item', 'give'); |
|
| 1914 | 1912 | } |
| 1915 | 1913 | |
| 1916 | 1914 | // Get variable price and ID from variable price array. |
| 1917 | - foreach ( $variable_prices as $variable_price ) { |
|
| 1918 | - $variable_price_options[ $variable_price['_give_id']['level_id'] ] = ! empty( $variable_price['_give_text'] ) ? $variable_price['_give_text'] : give_currency_filter( give_format_amount( $variable_price['_give_amount'], array( 'sanitize' => false ) ) ); |
|
| 1915 | + foreach ($variable_prices as $variable_price) { |
|
| 1916 | + $variable_price_options[$variable_price['_give_id']['level_id']] = ! empty($variable_price['_give_text']) ? $variable_price['_give_text'] : give_currency_filter(give_format_amount($variable_price['_give_amount'], array('sanitize' => false))); |
|
| 1919 | 1917 | } |
| 1920 | 1918 | |
| 1921 | 1919 | // Update options. |
| 1922 | - $args = array_merge( $args, array( |
|
| 1920 | + $args = array_merge($args, array( |
|
| 1923 | 1921 | 'options' => $variable_price_options, |
| 1924 | - ) ); |
|
| 1922 | + )); |
|
| 1925 | 1923 | |
| 1926 | 1924 | // Generate select html. |
| 1927 | - $form_dropdown_html = Give()->html->select( $args ); |
|
| 1925 | + $form_dropdown_html = Give()->html->select($args); |
|
| 1928 | 1926 | |
| 1929 | - if ( ! $echo ) { |
|
| 1927 | + if ( ! $echo) { |
|
| 1930 | 1928 | return $form_dropdown_html; |
| 1931 | 1929 | } |
| 1932 | 1930 | |
@@ -1945,14 +1943,14 @@ discard block |
||
| 1945 | 1943 | * |
| 1946 | 1944 | * @return string |
| 1947 | 1945 | */ |
| 1948 | -function give_get_payment_meta_price_id( $payment_meta ) { |
|
| 1946 | +function give_get_payment_meta_price_id($payment_meta) { |
|
| 1949 | 1947 | |
| 1950 | - if ( isset( $payment_meta['give_price_id'] ) ) { |
|
| 1948 | + if (isset($payment_meta['give_price_id'])) { |
|
| 1951 | 1949 | $price_id = $payment_meta['give_price_id']; |
| 1952 | - } elseif ( isset( $payment_meta['price_id'] ) ) { |
|
| 1950 | + } elseif (isset($payment_meta['price_id'])) { |
|
| 1953 | 1951 | $price_id = $payment_meta['price_id']; |
| 1954 | 1952 | } else { |
| 1955 | - $price_id = give_get_price_id( $payment_meta['give_form_id'], $payment_meta['price'] ); |
|
| 1953 | + $price_id = give_get_price_id($payment_meta['give_form_id'], $payment_meta['price']); |
|
| 1956 | 1954 | } |
| 1957 | 1955 | |
| 1958 | 1956 | /** |
@@ -1963,6 +1961,6 @@ discard block |
||
| 1963 | 1961 | * @param string $price_id |
| 1964 | 1962 | * @param array $payment_meta |
| 1965 | 1963 | */ |
| 1966 | - return apply_filters( 'give_get_payment_meta_price_id', $price_id, $payment_meta ); |
|
| 1964 | + return apply_filters('give_get_payment_meta_price_id', $price_id, $payment_meta); |
|
| 1967 | 1965 | |
| 1968 | 1966 | } |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | * @access private |
| 23 | 23 | * @since 1.0 |
| 24 | 24 | * |
| 25 | - * @return mixed |
|
| 25 | + * @return false|null |
|
| 26 | 26 | */ |
| 27 | 27 | function give_process_donation_form() { |
| 28 | 28 | $is_ajax = isset( $_POST['give_ajax'] ); |
@@ -462,7 +462,7 @@ discard block |
||
| 462 | 462 | * @access private |
| 463 | 463 | * @since 1.0 |
| 464 | 464 | * |
| 465 | - * @param $form_id |
|
| 465 | + * @param integer $form_id |
|
| 466 | 466 | * |
| 467 | 467 | * @return array |
| 468 | 468 | */ |
@@ -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,20 +25,20 @@ discard block |
||
| 25 | 25 | * @return mixed |
| 26 | 26 | */ |
| 27 | 27 | function give_process_donation_form() { |
| 28 | - $is_ajax = isset( $_POST['give_ajax'] ); |
|
| 28 | + $is_ajax = isset($_POST['give_ajax']); |
|
| 29 | 29 | |
| 30 | 30 | // Verify donation form nonce. |
| 31 | - if( ! give_verify_donation_form_nonce() ) { |
|
| 32 | - if( $is_ajax ) { |
|
| 31 | + if ( ! give_verify_donation_form_nonce()) { |
|
| 32 | + if ($is_ajax) { |
|
| 33 | 33 | /** |
| 34 | 34 | * Fires when AJAX sends back errors from the donation form. |
| 35 | 35 | * |
| 36 | 36 | * @since 1.0 |
| 37 | 37 | */ |
| 38 | - do_action( 'give_ajax_donation_errors' ); |
|
| 38 | + do_action('give_ajax_donation_errors'); |
|
| 39 | 39 | |
| 40 | 40 | give_die(); |
| 41 | - } else{ |
|
| 41 | + } else { |
|
| 42 | 42 | give_send_back_to_checkout(); |
| 43 | 43 | } |
| 44 | 44 | } |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | * |
| 49 | 49 | * @since 1.0 |
| 50 | 50 | */ |
| 51 | - do_action( 'give_pre_process_donation' ); |
|
| 51 | + do_action('give_pre_process_donation'); |
|
| 52 | 52 | |
| 53 | 53 | // Validate the form $_POST data. |
| 54 | 54 | $valid_data = give_donation_form_validate_fields(); |
@@ -63,24 +63,24 @@ discard block |
||
| 63 | 63 | * @param bool|array $valid_data Validate fields. |
| 64 | 64 | * @param array $_POST Array of variables passed via the HTTP POST. |
| 65 | 65 | */ |
| 66 | - do_action( 'give_checkout_error_checks', $valid_data, $_POST ); |
|
| 66 | + do_action('give_checkout_error_checks', $valid_data, $_POST); |
|
| 67 | 67 | |
| 68 | 68 | // Process the login form. |
| 69 | - if ( isset( $_POST['give_login_submit'] ) ) { |
|
| 69 | + if (isset($_POST['give_login_submit'])) { |
|
| 70 | 70 | give_process_form_login(); |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | // Validate the user. |
| 74 | - $user = give_get_donation_form_user( $valid_data ); |
|
| 74 | + $user = give_get_donation_form_user($valid_data); |
|
| 75 | 75 | |
| 76 | - if ( false === $valid_data || give_get_errors() || ! $user ) { |
|
| 77 | - if ( $is_ajax ) { |
|
| 76 | + if (false === $valid_data || give_get_errors() || ! $user) { |
|
| 77 | + if ($is_ajax) { |
|
| 78 | 78 | /** |
| 79 | 79 | * Fires when AJAX sends back errors from the donation form. |
| 80 | 80 | * |
| 81 | 81 | * @since 1.0 |
| 82 | 82 | */ |
| 83 | - do_action( 'give_ajax_donation_errors' ); |
|
| 83 | + do_action('give_ajax_donation_errors'); |
|
| 84 | 84 | give_die(); |
| 85 | 85 | } else { |
| 86 | 86 | return false; |
@@ -88,17 +88,17 @@ discard block |
||
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | // If AJAX send back success to proceed with form submission. |
| 91 | - if ( $is_ajax ) { |
|
| 91 | + if ($is_ajax) { |
|
| 92 | 92 | echo 'success'; |
| 93 | 93 | give_die(); |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | // After AJAX: Setup session if not using php_sessions. |
| 97 | - if ( ! Give()->session->use_php_sessions() ) { |
|
| 97 | + if ( ! Give()->session->use_php_sessions()) { |
|
| 98 | 98 | // Double-check that set_cookie is publicly accessible. |
| 99 | 99 | // we're using a slightly modified class-wp-sessions.php. |
| 100 | - $session_reflection = new ReflectionMethod( 'WP_Session', 'set_cookie' ); |
|
| 101 | - if ( $session_reflection->isPublic() ) { |
|
| 100 | + $session_reflection = new ReflectionMethod('WP_Session', 'set_cookie'); |
|
| 101 | + if ($session_reflection->isPublic()) { |
|
| 102 | 102 | // Manually set the cookie. |
| 103 | 103 | Give()->session->init()->set_cookie(); |
| 104 | 104 | } |
@@ -113,21 +113,20 @@ discard block |
||
| 113 | 113 | 'address' => $user['address'], |
| 114 | 114 | ); |
| 115 | 115 | |
| 116 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
| 116 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
| 117 | 117 | |
| 118 | - $price = isset( $_POST['give-amount'] ) ? |
|
| 119 | - (float) apply_filters( 'give_donation_total', give_maybe_sanitize_amount( $_POST['give-amount'] ) ) : |
|
| 120 | - '0.00'; |
|
| 121 | - $purchase_key = strtolower( md5( $user['user_email'] . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'give', true ) ) ); |
|
| 118 | + $price = isset($_POST['give-amount']) ? |
|
| 119 | + (float) apply_filters('give_donation_total', give_maybe_sanitize_amount($_POST['give-amount'])) : '0.00'; |
|
| 120 | + $purchase_key = strtolower(md5($user['user_email'].date('Y-m-d H:i:s').$auth_key.uniqid('give', true))); |
|
| 122 | 121 | |
| 123 | 122 | // Setup donation information. |
| 124 | 123 | $donation_data = array( |
| 125 | 124 | 'price' => $price, |
| 126 | 125 | 'purchase_key' => $purchase_key, |
| 127 | 126 | 'user_email' => $user['user_email'], |
| 128 | - 'date' => date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ), |
|
| 129 | - 'user_info' => stripslashes_deep( $user_info ), |
|
| 130 | - 'post_data' => give_clean( $_POST ), |
|
| 127 | + 'date' => date('Y-m-d H:i:s', current_time('timestamp')), |
|
| 128 | + 'user_info' => stripslashes_deep($user_info), |
|
| 129 | + 'post_data' => give_clean($_POST), |
|
| 131 | 130 | 'gateway' => $valid_data['gateway'], |
| 132 | 131 | 'card_info' => $valid_data['cc_info'], |
| 133 | 132 | ); |
@@ -146,10 +145,10 @@ discard block |
||
| 146 | 145 | * @param array $user_info Array containing basic user information. |
| 147 | 146 | * @param bool|array $valid_data Validate fields. |
| 148 | 147 | */ |
| 149 | - do_action( 'give_checkout_before_gateway', give_clean( $_POST ), $user_info, $valid_data ); |
|
| 148 | + do_action('give_checkout_before_gateway', give_clean($_POST), $user_info, $valid_data); |
|
| 150 | 149 | |
| 151 | 150 | // Sanity check for price. |
| 152 | - if ( ! $donation_data['price'] ) { |
|
| 151 | + if ( ! $donation_data['price']) { |
|
| 153 | 152 | // Revert to manual. |
| 154 | 153 | $donation_data['gateway'] = 'manual'; |
| 155 | 154 | $_POST['give-gateway'] = 'manual'; |
@@ -160,26 +159,26 @@ discard block |
||
| 160 | 159 | * |
| 161 | 160 | * @since 1.7 |
| 162 | 161 | */ |
| 163 | - $donation_data = apply_filters( 'give_donation_data_before_gateway', $donation_data, $valid_data ); |
|
| 162 | + $donation_data = apply_filters('give_donation_data_before_gateway', $donation_data, $valid_data); |
|
| 164 | 163 | |
| 165 | 164 | // Setup the data we're storing in the donation session. |
| 166 | 165 | $session_data = $donation_data; |
| 167 | 166 | |
| 168 | 167 | // Make sure credit card numbers are never stored in sessions. |
| 169 | - unset( $session_data['card_info']['card_number'] ); |
|
| 170 | - unset( $session_data['post_data']['card_number'] ); |
|
| 168 | + unset($session_data['card_info']['card_number']); |
|
| 169 | + unset($session_data['post_data']['card_number']); |
|
| 171 | 170 | |
| 172 | 171 | // Used for showing data to non logged-in users after donation, and for other plugins needing donation data. |
| 173 | - give_set_purchase_session( $session_data ); |
|
| 172 | + give_set_purchase_session($session_data); |
|
| 174 | 173 | |
| 175 | 174 | // Send info to the gateway for payment processing. |
| 176 | - give_send_to_gateway( $donation_data['gateway'], $donation_data ); |
|
| 175 | + give_send_to_gateway($donation_data['gateway'], $donation_data); |
|
| 177 | 176 | give_die(); |
| 178 | 177 | } |
| 179 | 178 | |
| 180 | -add_action( 'give_purchase', 'give_process_donation_form' ); |
|
| 181 | -add_action( 'wp_ajax_give_process_donation', 'give_process_donation_form' ); |
|
| 182 | -add_action( 'wp_ajax_nopriv_give_process_donation', 'give_process_donation_form' ); |
|
| 179 | +add_action('give_purchase', 'give_process_donation_form'); |
|
| 180 | +add_action('wp_ajax_give_process_donation', 'give_process_donation_form'); |
|
| 181 | +add_action('wp_ajax_nopriv_give_process_donation', 'give_process_donation_form'); |
|
| 183 | 182 | |
| 184 | 183 | |
| 185 | 184 | /** |
@@ -192,29 +191,29 @@ discard block |
||
| 192 | 191 | * |
| 193 | 192 | * @return void |
| 194 | 193 | */ |
| 195 | -function give_check_logged_in_user_for_existing_email( $valid_data, $post ) { |
|
| 194 | +function give_check_logged_in_user_for_existing_email($valid_data, $post) { |
|
| 196 | 195 | |
| 197 | 196 | // Verify that the email address belongs to this customer. |
| 198 | - if ( is_user_logged_in() ) { |
|
| 197 | + if (is_user_logged_in()) { |
|
| 199 | 198 | |
| 200 | 199 | $submitted_email = $valid_data['logged_in_user']['user_email']; |
| 201 | - $donor = new Give_Donor( get_current_user_id(), true ); |
|
| 200 | + $donor = new Give_Donor(get_current_user_id(), true); |
|
| 202 | 201 | |
| 203 | 202 | // If this email address is not registered with this customer, see if it belongs to any other customer. |
| 204 | 203 | if ( |
| 205 | 204 | $submitted_email !== $donor->email |
| 206 | - && ( is_array( $donor->emails ) && ! in_array( $submitted_email, $donor->emails ) ) |
|
| 205 | + && (is_array($donor->emails) && ! in_array($submitted_email, $donor->emails)) |
|
| 207 | 206 | ) { |
| 208 | - $found_donor = new Give_Donor( $submitted_email ); |
|
| 207 | + $found_donor = new Give_Donor($submitted_email); |
|
| 209 | 208 | |
| 210 | - if ( $found_donor->id > 0 ) { |
|
| 211 | - give_set_error( 'give-customer-email-exists', sprintf( __( 'You are logged in as %1$s, and are submitting a donation as %2$s, which is an existing donor. To ensure that the email address is tied to the correct donor, please submit this donation from a logged-out browser, or choose another email address.', 'give' ), $donor->email, $submitted_email ) ); |
|
| 209 | + if ($found_donor->id > 0) { |
|
| 210 | + give_set_error('give-customer-email-exists', sprintf(__('You are logged in as %1$s, and are submitting a donation as %2$s, which is an existing donor. To ensure that the email address is tied to the correct donor, please submit this donation from a logged-out browser, or choose another email address.', 'give'), $donor->email, $submitted_email)); |
|
| 212 | 211 | } |
| 213 | 212 | } |
| 214 | 213 | } |
| 215 | 214 | } |
| 216 | 215 | |
| 217 | -add_action( 'give_checkout_error_checks', 'give_check_logged_in_user_for_existing_email', 10, 2 ); |
|
| 216 | +add_action('give_checkout_error_checks', 'give_check_logged_in_user_for_existing_email', 10, 2); |
|
| 218 | 217 | |
| 219 | 218 | /** |
| 220 | 219 | * Process the checkout login form |
@@ -224,49 +223,49 @@ discard block |
||
| 224 | 223 | * @return void |
| 225 | 224 | */ |
| 226 | 225 | function give_process_form_login() { |
| 227 | - $is_ajax = isset( $_POST['give_ajax'] ); |
|
| 226 | + $is_ajax = isset($_POST['give_ajax']); |
|
| 228 | 227 | |
| 229 | 228 | $user_data = give_donation_form_validate_user_login(); |
| 230 | 229 | |
| 231 | - if ( give_get_errors() || $user_data['user_id'] < 1 ) { |
|
| 232 | - if ( $is_ajax ) { |
|
| 230 | + if (give_get_errors() || $user_data['user_id'] < 1) { |
|
| 231 | + if ($is_ajax) { |
|
| 233 | 232 | /** |
| 234 | 233 | * Fires when AJAX sends back errors from the donation form. |
| 235 | 234 | * |
| 236 | 235 | * @since 1.0 |
| 237 | 236 | */ |
| 238 | 237 | ob_start(); |
| 239 | - do_action( 'give_ajax_donation_errors' ); |
|
| 238 | + do_action('give_ajax_donation_errors'); |
|
| 240 | 239 | $message = ob_get_contents(); |
| 241 | 240 | ob_end_clean(); |
| 242 | - wp_send_json_error( $message ); |
|
| 241 | + wp_send_json_error($message); |
|
| 243 | 242 | } else { |
| 244 | - wp_redirect( $_SERVER['HTTP_REFERER'] ); |
|
| 243 | + wp_redirect($_SERVER['HTTP_REFERER']); |
|
| 245 | 244 | exit; |
| 246 | 245 | } |
| 247 | 246 | } |
| 248 | 247 | |
| 249 | - give_log_user_in( $user_data['user_id'], $user_data['user_login'], $user_data['user_pass'] ); |
|
| 248 | + give_log_user_in($user_data['user_id'], $user_data['user_login'], $user_data['user_pass']); |
|
| 250 | 249 | |
| 251 | - if ( $is_ajax ) { |
|
| 250 | + if ($is_ajax) { |
|
| 252 | 251 | $message = Give()->notices->print_frontend_notice( |
| 253 | 252 | sprintf( |
| 254 | 253 | /* translators: %s: user first name */ |
| 255 | - esc_html__( 'Welcome %s! You have successfully logged into your account.', 'give' ), |
|
| 256 | - ( ! empty( $user_data['user_first'] ) ) ? $user_data['user_first'] : $user_data['user_login'] |
|
| 254 | + esc_html__('Welcome %s! You have successfully logged into your account.', 'give'), |
|
| 255 | + ( ! empty($user_data['user_first'])) ? $user_data['user_first'] : $user_data['user_login'] |
|
| 257 | 256 | ), |
| 258 | 257 | false, |
| 259 | 258 | 'success' |
| 260 | 259 | ); |
| 261 | 260 | |
| 262 | - wp_send_json_success( $message ); |
|
| 261 | + wp_send_json_success($message); |
|
| 263 | 262 | } else { |
| 264 | - wp_redirect( $_SERVER['HTTP_REFERER'] ); |
|
| 263 | + wp_redirect($_SERVER['HTTP_REFERER']); |
|
| 265 | 264 | } |
| 266 | 265 | } |
| 267 | 266 | |
| 268 | -add_action( 'wp_ajax_give_process_donation_login', 'give_process_form_login' ); |
|
| 269 | -add_action( 'wp_ajax_nopriv_give_process_donation_login', 'give_process_form_login' ); |
|
| 267 | +add_action('wp_ajax_give_process_donation_login', 'give_process_form_login'); |
|
| 268 | +add_action('wp_ajax_nopriv_give_process_donation_login', 'give_process_form_login'); |
|
| 270 | 269 | |
| 271 | 270 | /** |
| 272 | 271 | * Donation Form Validate Fields. |
@@ -278,52 +277,52 @@ discard block |
||
| 278 | 277 | function give_donation_form_validate_fields() { |
| 279 | 278 | |
| 280 | 279 | // Check if there is $_POST. |
| 281 | - if ( empty( $_POST ) ) { |
|
| 280 | + if (empty($_POST)) { |
|
| 282 | 281 | return false; |
| 283 | 282 | } |
| 284 | 283 | |
| 285 | - $form_id = ! empty( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
| 284 | + $form_id = ! empty($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
| 286 | 285 | |
| 287 | 286 | // Start an array to collect valid data. |
| 288 | 287 | $valid_data = array( |
| 289 | 288 | 'gateway' => give_donation_form_validate_gateway(), // Gateway fallback (amount is validated here). |
| 290 | - 'need_new_user' => false, // New user flag. |
|
| 291 | - 'need_user_login' => false, // Login user flag. |
|
| 292 | - 'logged_user_data' => array(), // Logged user collected data. |
|
| 293 | - 'new_user_data' => array(), // New user collected data. |
|
| 294 | - 'login_user_data' => array(), // Login user collected data. |
|
| 295 | - 'guest_user_data' => array(), // Guest user collected data. |
|
| 296 | - 'cc_info' => give_donation_form_validate_cc(),// Credit card info. |
|
| 289 | + 'need_new_user' => false, // New user flag. |
|
| 290 | + 'need_user_login' => false, // Login user flag. |
|
| 291 | + 'logged_user_data' => array(), // Logged user collected data. |
|
| 292 | + 'new_user_data' => array(), // New user collected data. |
|
| 293 | + 'login_user_data' => array(), // Login user collected data. |
|
| 294 | + 'guest_user_data' => array(), // Guest user collected data. |
|
| 295 | + 'cc_info' => give_donation_form_validate_cc(), // Credit card info. |
|
| 297 | 296 | ); |
| 298 | 297 | |
| 299 | 298 | // Validate Honeypot First. |
| 300 | - if ( ! empty( $_POST['give-honeypot'] ) ) { |
|
| 301 | - give_set_error( 'invalid_honeypot', esc_html__( 'Honeypot field detected. Go away bad bot!', 'give' ) ); |
|
| 299 | + if ( ! empty($_POST['give-honeypot'])) { |
|
| 300 | + give_set_error('invalid_honeypot', esc_html__('Honeypot field detected. Go away bad bot!', 'give')); |
|
| 302 | 301 | } |
| 303 | 302 | |
| 304 | 303 | // Check spam detect. |
| 305 | - if ( isset( $_POST['action'] ) |
|
| 306 | - && give_is_setting_enabled( give_get_option( 'akismet_spam_protection' ) ) |
|
| 304 | + if (isset($_POST['action']) |
|
| 305 | + && give_is_setting_enabled(give_get_option('akismet_spam_protection')) |
|
| 307 | 306 | && give_is_spam_donation() |
| 308 | 307 | ) { |
| 309 | - give_set_error( 'invalid_donation', __( 'This donation has been flagged as spam. Please try again.', 'give' ) ); |
|
| 308 | + give_set_error('invalid_donation', __('This donation has been flagged as spam. Please try again.', 'give')); |
|
| 310 | 309 | } |
| 311 | 310 | |
| 312 | 311 | // Validate agree to terms. |
| 313 | - if ( give_is_terms_enabled( $form_id ) ) { |
|
| 312 | + if (give_is_terms_enabled($form_id)) { |
|
| 314 | 313 | give_donation_form_validate_agree_to_terms(); |
| 315 | 314 | } |
| 316 | 315 | |
| 317 | - if ( is_user_logged_in() ) { |
|
| 316 | + if (is_user_logged_in()) { |
|
| 318 | 317 | // Collect logged in user data. |
| 319 | 318 | $valid_data['logged_in_user'] = give_donation_form_validate_logged_in_user(); |
| 320 | - } elseif ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-register' && ! empty( $_POST['give_create_account'] ) ) { |
|
| 319 | + } elseif (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-register' && ! empty($_POST['give_create_account'])) { |
|
| 321 | 320 | // Set new user registration as required. |
| 322 | 321 | $valid_data['need_new_user'] = true; |
| 323 | 322 | // Validate new user data. |
| 324 | 323 | $valid_data['new_user_data'] = give_donation_form_validate_new_user(); |
| 325 | 324 | // Check if login validation is needed. |
| 326 | - } elseif ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-login' ) { |
|
| 325 | + } elseif (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-login') { |
|
| 327 | 326 | // Set user login as required. |
| 328 | 327 | $valid_data['need_user_login'] = true; |
| 329 | 328 | // Validate users login info. |
@@ -347,14 +346,14 @@ discard block |
||
| 347 | 346 | function give_is_spam_donation() { |
| 348 | 347 | $spam = false; |
| 349 | 348 | |
| 350 | - $user_agent = (string) isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : ''; |
|
| 349 | + $user_agent = (string) isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''; |
|
| 351 | 350 | |
| 352 | - if ( strlen( $user_agent ) < 2 ) { |
|
| 351 | + if (strlen($user_agent) < 2) { |
|
| 353 | 352 | $spam = true; |
| 354 | 353 | } |
| 355 | 354 | |
| 356 | 355 | // Allow developer to customized Akismet spam detect API call and it's response. |
| 357 | - return apply_filters( 'give_spam', $spam ); |
|
| 356 | + return apply_filters('give_spam', $spam); |
|
| 358 | 357 | } |
| 359 | 358 | |
| 360 | 359 | /** |
@@ -368,41 +367,41 @@ discard block |
||
| 368 | 367 | */ |
| 369 | 368 | function give_donation_form_validate_gateway() { |
| 370 | 369 | |
| 371 | - $form_id = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0; |
|
| 372 | - $amount = isset( $_REQUEST['give-amount'] ) ? give_maybe_sanitize_amount( $_REQUEST['give-amount'] ) : 0; |
|
| 373 | - $gateway = give_get_default_gateway( $form_id ); |
|
| 370 | + $form_id = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0; |
|
| 371 | + $amount = isset($_REQUEST['give-amount']) ? give_maybe_sanitize_amount($_REQUEST['give-amount']) : 0; |
|
| 372 | + $gateway = give_get_default_gateway($form_id); |
|
| 374 | 373 | |
| 375 | 374 | // Check if a gateway value is present. |
| 376 | - if ( ! empty( $_REQUEST['give-gateway'] ) ) { |
|
| 375 | + if ( ! empty($_REQUEST['give-gateway'])) { |
|
| 377 | 376 | |
| 378 | - $gateway = sanitize_text_field( $_REQUEST['give-gateway'] ); |
|
| 377 | + $gateway = sanitize_text_field($_REQUEST['give-gateway']); |
|
| 379 | 378 | |
| 380 | 379 | // Is amount being donated in LIVE mode 0.00? If so, error: |
| 381 | - if ( $amount == 0 && ! give_is_test_mode() ) { |
|
| 380 | + if ($amount == 0 && ! give_is_test_mode()) { |
|
| 382 | 381 | |
| 383 | - give_set_error( 'invalid_donation_amount', __( 'Please insert a valid donation amount.', 'give' ) ); |
|
| 382 | + give_set_error('invalid_donation_amount', __('Please insert a valid donation amount.', 'give')); |
|
| 384 | 383 | |
| 385 | 384 | } // End if(). |
| 386 | - elseif ( ! give_verify_minimum_price() ) { |
|
| 385 | + elseif ( ! give_verify_minimum_price()) { |
|
| 387 | 386 | // translators: %s: minimum donation amount. |
| 388 | 387 | give_set_error( |
| 389 | 388 | 'invalid_donation_minimum', |
| 390 | 389 | sprintf( |
| 391 | 390 | /* translators: %s: minimum donation amount */ |
| 392 | - __( 'This form has a minimum donation amount of %s.', 'give' ), |
|
| 393 | - give_currency_filter( give_format_amount( give_get_form_minimum_price( $form_id ), array( 'sanitize' => false ) ) ) |
|
| 391 | + __('This form has a minimum donation amount of %s.', 'give'), |
|
| 392 | + give_currency_filter(give_format_amount(give_get_form_minimum_price($form_id), array('sanitize' => false))) |
|
| 394 | 393 | ) |
| 395 | 394 | ); |
| 396 | 395 | |
| 397 | 396 | } //Is this test mode zero donation? Let it through but set to manual gateway. |
| 398 | - elseif ( $amount == 0 && give_is_test_mode() ) { |
|
| 397 | + elseif ($amount == 0 && give_is_test_mode()) { |
|
| 399 | 398 | |
| 400 | 399 | $gateway = 'manual'; |
| 401 | 400 | |
| 402 | 401 | } //Check if this gateway is active. |
| 403 | - elseif ( ! give_is_gateway_active( $gateway ) ) { |
|
| 402 | + elseif ( ! give_is_gateway_active($gateway)) { |
|
| 404 | 403 | |
| 405 | - give_set_error( 'invalid_gateway', __( 'The selected payment gateway is not enabled.', 'give' ) ); |
|
| 404 | + give_set_error('invalid_gateway', __('The selected payment gateway is not enabled.', 'give')); |
|
| 406 | 405 | |
| 407 | 406 | } |
| 408 | 407 | } |
@@ -420,21 +419,21 @@ discard block |
||
| 420 | 419 | */ |
| 421 | 420 | function give_verify_minimum_price() { |
| 422 | 421 | |
| 423 | - $amount = give_maybe_sanitize_amount( $_REQUEST['give-amount'] ); |
|
| 424 | - $form_id = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0; |
|
| 425 | - $price_id = isset( $_REQUEST['give-price-id'] ) ? $_REQUEST['give-price-id'] : null; |
|
| 426 | - $variable_prices = give_has_variable_prices( $form_id ); |
|
| 422 | + $amount = give_maybe_sanitize_amount($_REQUEST['give-amount']); |
|
| 423 | + $form_id = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0; |
|
| 424 | + $price_id = isset($_REQUEST['give-price-id']) ? $_REQUEST['give-price-id'] : null; |
|
| 425 | + $variable_prices = give_has_variable_prices($form_id); |
|
| 427 | 426 | |
| 428 | - if ( $variable_prices && in_array( $price_id, give_get_variable_price_ids( $form_id ) ) ) { |
|
| 427 | + if ($variable_prices && in_array($price_id, give_get_variable_price_ids($form_id))) { |
|
| 429 | 428 | |
| 430 | - $price_level_amount = give_get_price_option_amount( $form_id, $price_id ); |
|
| 429 | + $price_level_amount = give_get_price_option_amount($form_id, $price_id); |
|
| 431 | 430 | |
| 432 | - if ( $price_level_amount == $amount ) { |
|
| 431 | + if ($price_level_amount == $amount) { |
|
| 433 | 432 | return true; |
| 434 | 433 | } |
| 435 | 434 | } |
| 436 | 435 | |
| 437 | - if ( give_get_form_minimum_price( $form_id ) > $amount ) { |
|
| 436 | + if (give_get_form_minimum_price($form_id) > $amount) { |
|
| 438 | 437 | return false; |
| 439 | 438 | } |
| 440 | 439 | |
@@ -450,9 +449,9 @@ discard block |
||
| 450 | 449 | */ |
| 451 | 450 | function give_donation_form_validate_agree_to_terms() { |
| 452 | 451 | // Validate agree to terms. |
| 453 | - if ( ! isset( $_POST['give_agree_to_terms'] ) || $_POST['give_agree_to_terms'] != 1 ) { |
|
| 452 | + if ( ! isset($_POST['give_agree_to_terms']) || $_POST['give_agree_to_terms'] != 1) { |
|
| 454 | 453 | // User did not agree. |
| 455 | - give_set_error( 'agree_to_terms', apply_filters( 'give_agree_to_terms_text', __( 'You must agree to the terms and conditions.', 'give' ) ) ); |
|
| 454 | + give_set_error('agree_to_terms', apply_filters('give_agree_to_terms_text', __('You must agree to the terms and conditions.', 'give'))); |
|
| 456 | 455 | } |
| 457 | 456 | } |
| 458 | 457 | |
@@ -466,59 +465,59 @@ discard block |
||
| 466 | 465 | * |
| 467 | 466 | * @return array |
| 468 | 467 | */ |
| 469 | -function give_get_required_fields( $form_id ) { |
|
| 468 | +function give_get_required_fields($form_id) { |
|
| 470 | 469 | |
| 471 | - $payment_mode = give_get_chosen_gateway( $form_id ); |
|
| 470 | + $payment_mode = give_get_chosen_gateway($form_id); |
|
| 472 | 471 | |
| 473 | 472 | $required_fields = array( |
| 474 | 473 | 'give_email' => array( |
| 475 | 474 | 'error_id' => 'invalid_email', |
| 476 | - 'error_message' => __( 'Please enter a valid email address.', 'give' ), |
|
| 475 | + 'error_message' => __('Please enter a valid email address.', 'give'), |
|
| 477 | 476 | ), |
| 478 | 477 | 'give_first' => array( |
| 479 | 478 | 'error_id' => 'invalid_first_name', |
| 480 | - 'error_message' => __( 'Please enter your first name.', 'give' ), |
|
| 479 | + 'error_message' => __('Please enter your first name.', 'give'), |
|
| 481 | 480 | ), |
| 482 | 481 | ); |
| 483 | 482 | |
| 484 | - $require_address = give_require_billing_address( $payment_mode ); |
|
| 483 | + $require_address = give_require_billing_address($payment_mode); |
|
| 485 | 484 | |
| 486 | - if ( $require_address ) { |
|
| 487 | - $required_fields['card_address'] = array( |
|
| 485 | + if ($require_address) { |
|
| 486 | + $required_fields['card_address'] = array( |
|
| 488 | 487 | 'error_id' => 'invalid_card_address', |
| 489 | - 'error_message' => __( 'Please enter your primary billing address.', 'give' ), |
|
| 488 | + 'error_message' => __('Please enter your primary billing address.', 'give'), |
|
| 490 | 489 | ); |
| 491 | - $required_fields['card_zip'] = array( |
|
| 490 | + $required_fields['card_zip'] = array( |
|
| 492 | 491 | 'error_id' => 'invalid_zip_code', |
| 493 | - 'error_message' => __( 'Please enter your zip / postal code.', 'give' ), |
|
| 492 | + 'error_message' => __('Please enter your zip / postal code.', 'give'), |
|
| 494 | 493 | ); |
| 495 | - $required_fields['card_city'] = array( |
|
| 494 | + $required_fields['card_city'] = array( |
|
| 496 | 495 | 'error_id' => 'invalid_city', |
| 497 | - 'error_message' => __( 'Please enter your billing city.', 'give' ), |
|
| 496 | + 'error_message' => __('Please enter your billing city.', 'give'), |
|
| 498 | 497 | ); |
| 499 | 498 | $required_fields['billing_country'] = array( |
| 500 | 499 | 'error_id' => 'invalid_country', |
| 501 | - 'error_message' => __( 'Please select your billing country.', 'give' ), |
|
| 500 | + 'error_message' => __('Please select your billing country.', 'give'), |
|
| 502 | 501 | ); |
| 503 | 502 | |
| 504 | 503 | |
| 505 | 504 | $required_fields['card_state'] = array( |
| 506 | 505 | 'error_id' => 'invalid_state', |
| 507 | - 'error_message' => __( 'Please enter billing state / province / County.', 'give' ), |
|
| 506 | + 'error_message' => __('Please enter billing state / province / County.', 'give'), |
|
| 508 | 507 | ); |
| 509 | 508 | |
| 510 | 509 | // Check if billing country already exists. |
| 511 | - if ( ! empty( $_POST['billing_country'] ) ) { |
|
| 510 | + if ( ! empty($_POST['billing_country'])) { |
|
| 512 | 511 | // Get the value from $_POST. |
| 513 | - $country = sanitize_text_field( $_POST['billing_country'] ); |
|
| 512 | + $country = sanitize_text_field($_POST['billing_country']); |
|
| 514 | 513 | |
| 515 | 514 | // Get the country list that does not required any states init. |
| 516 | 515 | $states_country = give_states_not_required_country_list(); |
| 517 | 516 | |
| 518 | 517 | // Check if states is empty or not. |
| 519 | - if ( array_key_exists( $country, $states_country ) ) { |
|
| 518 | + if (array_key_exists($country, $states_country)) { |
|
| 520 | 519 | // If states is empty remove the required feilds of state in billing cart. |
| 521 | - unset( $required_fields['card_state'] ); |
|
| 520 | + unset($required_fields['card_state']); |
|
| 522 | 521 | } |
| 523 | 522 | } |
| 524 | 523 | } |
@@ -528,7 +527,7 @@ discard block |
||
| 528 | 527 | * |
| 529 | 528 | * @since 1.7 |
| 530 | 529 | */ |
| 531 | - $required_fields = apply_filters( 'give_donation_form_required_fields', $required_fields, $form_id ); |
|
| 530 | + $required_fields = apply_filters('give_donation_form_required_fields', $required_fields, $form_id); |
|
| 532 | 531 | |
| 533 | 532 | return $required_fields; |
| 534 | 533 | |
@@ -543,16 +542,16 @@ discard block |
||
| 543 | 542 | * |
| 544 | 543 | * @return bool |
| 545 | 544 | */ |
| 546 | -function give_require_billing_address( $payment_mode ) { |
|
| 545 | +function give_require_billing_address($payment_mode) { |
|
| 547 | 546 | |
| 548 | 547 | $return = false; |
| 549 | 548 | |
| 550 | - if ( isset( $_POST['billing_country'] ) || did_action( "give_{$payment_mode}_cc_form" ) || did_action( 'give_cc_form' ) ) { |
|
| 549 | + if (isset($_POST['billing_country']) || did_action("give_{$payment_mode}_cc_form") || did_action('give_cc_form')) { |
|
| 551 | 550 | $return = true; |
| 552 | 551 | } |
| 553 | 552 | |
| 554 | 553 | // Let payment gateways and other extensions determine if address fields should be required. |
| 555 | - return apply_filters( 'give_require_billing_address', $return ); |
|
| 554 | + return apply_filters('give_require_billing_address', $return); |
|
| 556 | 555 | |
| 557 | 556 | } |
| 558 | 557 | |
@@ -566,38 +565,38 @@ discard block |
||
| 566 | 565 | function give_donation_form_validate_logged_in_user() { |
| 567 | 566 | global $user_ID; |
| 568 | 567 | |
| 569 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
| 568 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
| 570 | 569 | |
| 571 | 570 | // Start empty array to collect valid user data. |
| 572 | 571 | $valid_user_data = array( |
| 573 | 572 | // Assume there will be errors. |
| 574 | - 'user_id' => - 1, |
|
| 573 | + 'user_id' => -1, |
|
| 575 | 574 | ); |
| 576 | 575 | |
| 577 | 576 | // Verify there is a user_ID. |
| 578 | - if ( $user_ID > 0 ) { |
|
| 577 | + if ($user_ID > 0) { |
|
| 579 | 578 | // Get the logged in user data. |
| 580 | - $user_data = get_userdata( $user_ID ); |
|
| 579 | + $user_data = get_userdata($user_ID); |
|
| 581 | 580 | |
| 582 | 581 | // Validate Required Form Fields. |
| 583 | - give_validate_required_form_fields( $form_id ); |
|
| 582 | + give_validate_required_form_fields($form_id); |
|
| 584 | 583 | |
| 585 | 584 | // Verify data. |
| 586 | - if ( $user_data ) { |
|
| 585 | + if ($user_data) { |
|
| 587 | 586 | // Collected logged in user data. |
| 588 | 587 | $valid_user_data = array( |
| 589 | 588 | 'user_id' => $user_ID, |
| 590 | - 'user_email' => isset( $_POST['give_email'] ) ? sanitize_email( $_POST['give_email'] ) : $user_data->user_email, |
|
| 591 | - 'user_first' => isset( $_POST['give_first'] ) && ! empty( $_POST['give_first'] ) ? sanitize_text_field( $_POST['give_first'] ) : $user_data->first_name, |
|
| 592 | - 'user_last' => isset( $_POST['give_last'] ) && ! empty( $_POST['give_last'] ) ? sanitize_text_field( $_POST['give_last'] ) : $user_data->last_name, |
|
| 589 | + 'user_email' => isset($_POST['give_email']) ? sanitize_email($_POST['give_email']) : $user_data->user_email, |
|
| 590 | + 'user_first' => isset($_POST['give_first']) && ! empty($_POST['give_first']) ? sanitize_text_field($_POST['give_first']) : $user_data->first_name, |
|
| 591 | + 'user_last' => isset($_POST['give_last']) && ! empty($_POST['give_last']) ? sanitize_text_field($_POST['give_last']) : $user_data->last_name, |
|
| 593 | 592 | ); |
| 594 | 593 | |
| 595 | - if ( ! is_email( $valid_user_data['user_email'] ) ) { |
|
| 596 | - give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) ); |
|
| 594 | + if ( ! is_email($valid_user_data['user_email'])) { |
|
| 595 | + give_set_error('email_invalid', esc_html__('Invalid email.', 'give')); |
|
| 597 | 596 | } |
| 598 | 597 | } else { |
| 599 | 598 | // Set invalid user error. |
| 600 | - give_set_error( 'invalid_user', esc_html__( 'The user information is invalid.', 'give' ) ); |
|
| 599 | + give_set_error('invalid_user', esc_html__('The user information is invalid.', 'give')); |
|
| 601 | 600 | } |
| 602 | 601 | } |
| 603 | 602 | |
@@ -619,7 +618,7 @@ discard block |
||
| 619 | 618 | // Default user data. |
| 620 | 619 | $default_user_data = array( |
| 621 | 620 | 'give-form-id' => '', |
| 622 | - 'user_id' => - 1, // Assume there will be errors. |
|
| 621 | + 'user_id' => -1, // Assume there will be errors. |
|
| 623 | 622 | 'user_first' => '', |
| 624 | 623 | 'user_last' => '', |
| 625 | 624 | 'give_user_login' => false, |
@@ -629,14 +628,14 @@ discard block |
||
| 629 | 628 | ); |
| 630 | 629 | |
| 631 | 630 | // Get user data. |
| 632 | - $user_data = wp_parse_args( give_clean( $_POST ), $default_user_data ); |
|
| 631 | + $user_data = wp_parse_args(give_clean($_POST), $default_user_data); |
|
| 633 | 632 | $registering_new_user = false; |
| 634 | - $form_id = absint( $user_data['give-form-id'] ); |
|
| 633 | + $form_id = absint($user_data['give-form-id']); |
|
| 635 | 634 | |
| 636 | 635 | // Start an empty array to collect valid user data. |
| 637 | 636 | $valid_user_data = array( |
| 638 | 637 | // Assume there will be errors. |
| 639 | - 'user_id' => - 1, |
|
| 638 | + 'user_id' => -1, |
|
| 640 | 639 | |
| 641 | 640 | // Get first name. |
| 642 | 641 | 'user_first' => $user_data['give_first'], |
@@ -649,13 +648,13 @@ discard block |
||
| 649 | 648 | ); |
| 650 | 649 | |
| 651 | 650 | // Validate Required Form Fields. |
| 652 | - give_validate_required_form_fields( $form_id ); |
|
| 651 | + give_validate_required_form_fields($form_id); |
|
| 653 | 652 | |
| 654 | 653 | // Set Email as Username. |
| 655 | 654 | $valid_user_data['user_login'] = $user_data['give_email']; |
| 656 | 655 | |
| 657 | 656 | // Check if we have an email to verify. |
| 658 | - if ( give_validate_user_email( $user_data['give_email'], $registering_new_user ) ) { |
|
| 657 | + if (give_validate_user_email($user_data['give_email'], $registering_new_user)) { |
|
| 659 | 658 | $valid_user_data['user_email'] = $user_data['give_email']; |
| 660 | 659 | } |
| 661 | 660 | |
@@ -674,36 +673,36 @@ discard block |
||
| 674 | 673 | // Start an array to collect valid user data. |
| 675 | 674 | $valid_user_data = array( |
| 676 | 675 | // Assume there will be errors. |
| 677 | - 'user_id' => - 1, |
|
| 676 | + 'user_id' => -1, |
|
| 678 | 677 | ); |
| 679 | 678 | |
| 680 | 679 | // Username. |
| 681 | - if ( ! isset( $_POST['give_user_login'] ) || $_POST['give_user_login'] == '' ) { |
|
| 682 | - give_set_error( 'must_log_in', __( 'You must register or login to complete your donation.', 'give' ) ); |
|
| 680 | + if ( ! isset($_POST['give_user_login']) || $_POST['give_user_login'] == '') { |
|
| 681 | + give_set_error('must_log_in', __('You must register or login to complete your donation.', 'give')); |
|
| 683 | 682 | |
| 684 | 683 | return $valid_user_data; |
| 685 | 684 | } |
| 686 | 685 | |
| 687 | 686 | // Get the user by login. |
| 688 | - $user_data = get_user_by( 'login', strip_tags( $_POST['give_user_login'] ) ); |
|
| 687 | + $user_data = get_user_by('login', strip_tags($_POST['give_user_login'])); |
|
| 689 | 688 | |
| 690 | 689 | // Check if user exists. |
| 691 | - if ( $user_data ) { |
|
| 690 | + if ($user_data) { |
|
| 692 | 691 | // Get password. |
| 693 | - $user_pass = isset( $_POST['give_user_pass'] ) ? $_POST['give_user_pass'] : false; |
|
| 692 | + $user_pass = isset($_POST['give_user_pass']) ? $_POST['give_user_pass'] : false; |
|
| 694 | 693 | |
| 695 | 694 | // Check user_pass. |
| 696 | - if ( $user_pass ) { |
|
| 695 | + if ($user_pass) { |
|
| 697 | 696 | // Check if password is valid. |
| 698 | - if ( ! wp_check_password( $user_pass, $user_data->user_pass, $user_data->ID ) ) { |
|
| 697 | + if ( ! wp_check_password($user_pass, $user_data->user_pass, $user_data->ID)) { |
|
| 699 | 698 | // Incorrect password. |
| 700 | 699 | give_set_error( |
| 701 | 700 | 'password_incorrect', |
| 702 | 701 | sprintf( |
| 703 | 702 | '%1$s <a href="%2$s">%3$s</a>', |
| 704 | - __( 'The password you entered is incorrect.', 'give' ), |
|
| 705 | - wp_lostpassword_url( "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]" ), |
|
| 706 | - __( 'Reset Password', 'give' ) |
|
| 703 | + __('The password you entered is incorrect.', 'give'), |
|
| 704 | + wp_lostpassword_url("http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"), |
|
| 705 | + __('Reset Password', 'give') |
|
| 707 | 706 | ) |
| 708 | 707 | ); |
| 709 | 708 | // All is correct. |
@@ -721,11 +720,11 @@ discard block |
||
| 721 | 720 | } |
| 722 | 721 | } else { |
| 723 | 722 | // Empty password. |
| 724 | - give_set_error( 'password_empty', __( 'Enter a password.', 'give' ) ); |
|
| 723 | + give_set_error('password_empty', __('Enter a password.', 'give')); |
|
| 725 | 724 | } |
| 726 | 725 | } else { |
| 727 | 726 | // No username. |
| 728 | - give_set_error( 'username_incorrect', __( 'The username you entered does not exist.', 'give' ) ); |
|
| 727 | + give_set_error('username_incorrect', __('The username you entered does not exist.', 'give')); |
|
| 729 | 728 | }// End if(). |
| 730 | 729 | |
| 731 | 730 | return $valid_user_data; |
@@ -740,7 +739,7 @@ discard block |
||
| 740 | 739 | */ |
| 741 | 740 | function give_donation_form_validate_guest_user() { |
| 742 | 741 | |
| 743 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
| 742 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
| 744 | 743 | |
| 745 | 744 | // Start an array to collect valid user data. |
| 746 | 745 | $valid_user_data = array( |
@@ -749,31 +748,31 @@ discard block |
||
| 749 | 748 | ); |
| 750 | 749 | |
| 751 | 750 | // Get the guest email. |
| 752 | - $guest_email = isset( $_POST['give_email'] ) ? $_POST['give_email'] : false; |
|
| 751 | + $guest_email = isset($_POST['give_email']) ? $_POST['give_email'] : false; |
|
| 753 | 752 | |
| 754 | 753 | // Check email. |
| 755 | - if ( $guest_email && strlen( $guest_email ) > 0 ) { |
|
| 754 | + if ($guest_email && strlen($guest_email) > 0) { |
|
| 756 | 755 | // Validate email. |
| 757 | - if ( ! is_email( $guest_email ) ) { |
|
| 756 | + if ( ! is_email($guest_email)) { |
|
| 758 | 757 | // Invalid email. |
| 759 | - give_set_error( 'email_invalid', __( 'Invalid email.', 'give' ) ); |
|
| 758 | + give_set_error('email_invalid', __('Invalid email.', 'give')); |
|
| 760 | 759 | } else { |
| 761 | 760 | // All is good to go. |
| 762 | 761 | $valid_user_data['user_email'] = $guest_email; |
| 763 | 762 | |
| 764 | 763 | // Get user_id from donor if exist. |
| 765 | - $donor = new Give_Donor( $guest_email ); |
|
| 766 | - if ( $donor->id && $donor->user_id ) { |
|
| 764 | + $donor = new Give_Donor($guest_email); |
|
| 765 | + if ($donor->id && $donor->user_id) { |
|
| 767 | 766 | $valid_user_data['user_id'] = $donor->user_id; |
| 768 | 767 | } |
| 769 | 768 | } |
| 770 | 769 | } else { |
| 771 | 770 | // No email. |
| 772 | - give_set_error( 'email_empty', __( 'Enter an email.', 'give' ) ); |
|
| 771 | + give_set_error('email_empty', __('Enter an email.', 'give')); |
|
| 773 | 772 | } |
| 774 | 773 | |
| 775 | 774 | // Validate Required Form Fields. |
| 776 | - give_validate_required_form_fields( $form_id ); |
|
| 775 | + give_validate_required_form_fields($form_id); |
|
| 777 | 776 | |
| 778 | 777 | return $valid_user_data; |
| 779 | 778 | } |
@@ -787,36 +786,36 @@ discard block |
||
| 787 | 786 | * @since 1.0 |
| 788 | 787 | * @return integer |
| 789 | 788 | */ |
| 790 | -function give_register_and_login_new_user( $user_data = array() ) { |
|
| 789 | +function give_register_and_login_new_user($user_data = array()) { |
|
| 791 | 790 | // Verify the array. |
| 792 | - if ( empty( $user_data ) ) { |
|
| 793 | - return - 1; |
|
| 791 | + if (empty($user_data)) { |
|
| 792 | + return -1; |
|
| 794 | 793 | } |
| 795 | 794 | |
| 796 | - if ( give_get_errors() ) { |
|
| 797 | - return - 1; |
|
| 795 | + if (give_get_errors()) { |
|
| 796 | + return -1; |
|
| 798 | 797 | } |
| 799 | 798 | |
| 800 | - $user_args = apply_filters( 'give_insert_user_args', array( |
|
| 801 | - 'user_login' => isset( $user_data['user_login'] ) ? $user_data['user_login'] : '', |
|
| 802 | - 'user_pass' => isset( $user_data['user_pass'] ) ? $user_data['user_pass'] : '', |
|
| 803 | - 'user_email' => isset( $user_data['user_email'] ) ? $user_data['user_email'] : '', |
|
| 804 | - 'first_name' => isset( $user_data['user_first'] ) ? $user_data['user_first'] : '', |
|
| 805 | - 'last_name' => isset( $user_data['user_last'] ) ? $user_data['user_last'] : '', |
|
| 806 | - 'user_registered' => date( 'Y-m-d H:i:s' ), |
|
| 807 | - 'role' => give_get_option( 'donor_default_user_role', 'give_donor' ), |
|
| 808 | - ), $user_data ); |
|
| 799 | + $user_args = apply_filters('give_insert_user_args', array( |
|
| 800 | + 'user_login' => isset($user_data['user_login']) ? $user_data['user_login'] : '', |
|
| 801 | + 'user_pass' => isset($user_data['user_pass']) ? $user_data['user_pass'] : '', |
|
| 802 | + 'user_email' => isset($user_data['user_email']) ? $user_data['user_email'] : '', |
|
| 803 | + 'first_name' => isset($user_data['user_first']) ? $user_data['user_first'] : '', |
|
| 804 | + 'last_name' => isset($user_data['user_last']) ? $user_data['user_last'] : '', |
|
| 805 | + 'user_registered' => date('Y-m-d H:i:s'), |
|
| 806 | + 'role' => give_get_option('donor_default_user_role', 'give_donor'), |
|
| 807 | + ), $user_data); |
|
| 809 | 808 | |
| 810 | 809 | // Insert new user. |
| 811 | - $user_id = wp_insert_user( $user_args ); |
|
| 810 | + $user_id = wp_insert_user($user_args); |
|
| 812 | 811 | |
| 813 | 812 | // Validate inserted user. |
| 814 | - if ( is_wp_error( $user_id ) ) { |
|
| 815 | - return - 1; |
|
| 813 | + if (is_wp_error($user_id)) { |
|
| 814 | + return -1; |
|
| 816 | 815 | } |
| 817 | 816 | |
| 818 | 817 | // Allow themes and plugins to filter the user data. |
| 819 | - $user_data = apply_filters( 'give_insert_user_data', $user_data, $user_args ); |
|
| 818 | + $user_data = apply_filters('give_insert_user_data', $user_data, $user_args); |
|
| 820 | 819 | |
| 821 | 820 | /** |
| 822 | 821 | * Fires after inserting user. |
@@ -826,7 +825,7 @@ discard block |
||
| 826 | 825 | * @param int $user_id User id. |
| 827 | 826 | * @param array $user_data Array containing user data. |
| 828 | 827 | */ |
| 829 | - do_action( 'give_insert_user', $user_id, $user_data ); |
|
| 828 | + do_action('give_insert_user', $user_id, $user_data); |
|
| 830 | 829 | |
| 831 | 830 | /** |
| 832 | 831 | * Filter allow user to alter if user when to login or not when user is register for the first time. |
@@ -835,9 +834,9 @@ discard block |
||
| 835 | 834 | * |
| 836 | 835 | * return bool True if login with registration and False if only want to register. |
| 837 | 836 | */ |
| 838 | - if ( true === (bool) apply_filters( 'give_log_user_in_on_register', true ) ) { |
|
| 837 | + if (true === (bool) apply_filters('give_log_user_in_on_register', true)) { |
|
| 839 | 838 | // Login new user. |
| 840 | - give_log_user_in( $user_id, $user_data['user_login'], $user_data['user_pass'] ); |
|
| 839 | + give_log_user_in($user_id, $user_data['user_login'], $user_data['user_pass']); |
|
| 841 | 840 | } |
| 842 | 841 | |
| 843 | 842 | // Return user id. |
@@ -853,27 +852,27 @@ discard block |
||
| 853 | 852 | * @since 1.0 |
| 854 | 853 | * @return array|bool |
| 855 | 854 | */ |
| 856 | -function give_get_donation_form_user( $valid_data = array() ) { |
|
| 855 | +function give_get_donation_form_user($valid_data = array()) { |
|
| 857 | 856 | |
| 858 | 857 | // Initialize user. |
| 859 | 858 | $user = false; |
| 860 | - $is_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX; |
|
| 859 | + $is_ajax = defined('DOING_AJAX') && DOING_AJAX; |
|
| 861 | 860 | |
| 862 | - if ( $is_ajax ) { |
|
| 861 | + if ($is_ajax) { |
|
| 863 | 862 | // Do not create or login the user during the ajax submission (check for errors only). |
| 864 | 863 | return true; |
| 865 | - } elseif ( is_user_logged_in() ) { |
|
| 864 | + } elseif (is_user_logged_in()) { |
|
| 866 | 865 | // Set the valid user as the logged in collected data. |
| 867 | 866 | $user = $valid_data['logged_in_user']; |
| 868 | - } elseif ( $valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true ) { |
|
| 867 | + } elseif ($valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true) { |
|
| 869 | 868 | // New user registration. |
| 870 | - if ( $valid_data['need_new_user'] === true ) { |
|
| 869 | + if ($valid_data['need_new_user'] === true) { |
|
| 871 | 870 | // Set user. |
| 872 | 871 | $user = $valid_data['new_user_data']; |
| 873 | 872 | // Register and login new user. |
| 874 | - $user['user_id'] = give_register_and_login_new_user( $user ); |
|
| 873 | + $user['user_id'] = give_register_and_login_new_user($user); |
|
| 875 | 874 | // User login |
| 876 | - } elseif ( $valid_data['need_user_login'] === true && ! $is_ajax ) { |
|
| 875 | + } elseif ($valid_data['need_user_login'] === true && ! $is_ajax) { |
|
| 877 | 876 | |
| 878 | 877 | /** |
| 879 | 878 | * The login form is now processed in the give_process_donation_login() function. |
@@ -885,42 +884,42 @@ discard block |
||
| 885 | 884 | // Set user. |
| 886 | 885 | $user = $valid_data['login_user_data']; |
| 887 | 886 | // Login user. |
| 888 | - give_log_user_in( $user['user_id'], $user['user_login'], $user['user_pass'] ); |
|
| 887 | + give_log_user_in($user['user_id'], $user['user_login'], $user['user_pass']); |
|
| 889 | 888 | } |
| 890 | 889 | } |
| 891 | 890 | |
| 892 | 891 | // Check guest checkout. |
| 893 | - if ( false === $user && false === give_logged_in_only( $_POST['give-form-id'] ) ) { |
|
| 892 | + if (false === $user && false === give_logged_in_only($_POST['give-form-id'])) { |
|
| 894 | 893 | // Set user |
| 895 | 894 | $user = $valid_data['guest_user_data']; |
| 896 | 895 | } |
| 897 | 896 | |
| 898 | 897 | // Verify we have an user. |
| 899 | - if ( false === $user || empty( $user ) ) { |
|
| 898 | + if (false === $user || empty($user)) { |
|
| 900 | 899 | // Return false. |
| 901 | 900 | return false; |
| 902 | 901 | } |
| 903 | 902 | |
| 904 | 903 | // Get user first name. |
| 905 | - if ( ! isset( $user['user_first'] ) || strlen( trim( $user['user_first'] ) ) < 1 ) { |
|
| 906 | - $user['user_first'] = isset( $_POST['give_first'] ) ? strip_tags( trim( $_POST['give_first'] ) ) : ''; |
|
| 904 | + if ( ! isset($user['user_first']) || strlen(trim($user['user_first'])) < 1) { |
|
| 905 | + $user['user_first'] = isset($_POST['give_first']) ? strip_tags(trim($_POST['give_first'])) : ''; |
|
| 907 | 906 | } |
| 908 | 907 | |
| 909 | 908 | // Get user last name. |
| 910 | - if ( ! isset( $user['user_last'] ) || strlen( trim( $user['user_last'] ) ) < 1 ) { |
|
| 911 | - $user['user_last'] = isset( $_POST['give_last'] ) ? strip_tags( trim( $_POST['give_last'] ) ) : ''; |
|
| 909 | + if ( ! isset($user['user_last']) || strlen(trim($user['user_last'])) < 1) { |
|
| 910 | + $user['user_last'] = isset($_POST['give_last']) ? strip_tags(trim($_POST['give_last'])) : ''; |
|
| 912 | 911 | } |
| 913 | 912 | |
| 914 | 913 | // Get the user's billing address details. |
| 915 | 914 | $user['address'] = array(); |
| 916 | - $user['address']['line1'] = ! empty( $_POST['card_address'] ) ? give_clean( $_POST['card_address'] ) : false; |
|
| 917 | - $user['address']['line2'] = ! empty( $_POST['card_address_2'] ) ? give_clean( $_POST['card_address_2'] ) : false; |
|
| 918 | - $user['address']['city'] = ! empty( $_POST['card_city'] ) ? give_clean( $_POST['card_city'] ) : false; |
|
| 919 | - $user['address']['state'] = ! empty( $_POST['card_state'] ) ? give_clean( $_POST['card_state'] ) : false; |
|
| 920 | - $user['address']['zip'] = ! empty( $_POST['card_zip'] ) ? give_clean( $_POST['card_zip'] ) : false; |
|
| 921 | - $user['address']['country'] = ! empty( $_POST['billing_country'] ) ? give_clean( $_POST['billing_country'] ) : false; |
|
| 922 | - |
|
| 923 | - if ( empty( $user['address']['country'] ) ) { |
|
| 915 | + $user['address']['line1'] = ! empty($_POST['card_address']) ? give_clean($_POST['card_address']) : false; |
|
| 916 | + $user['address']['line2'] = ! empty($_POST['card_address_2']) ? give_clean($_POST['card_address_2']) : false; |
|
| 917 | + $user['address']['city'] = ! empty($_POST['card_city']) ? give_clean($_POST['card_city']) : false; |
|
| 918 | + $user['address']['state'] = ! empty($_POST['card_state']) ? give_clean($_POST['card_state']) : false; |
|
| 919 | + $user['address']['zip'] = ! empty($_POST['card_zip']) ? give_clean($_POST['card_zip']) : false; |
|
| 920 | + $user['address']['country'] = ! empty($_POST['billing_country']) ? give_clean($_POST['billing_country']) : false; |
|
| 921 | + |
|
| 922 | + if (empty($user['address']['country'])) { |
|
| 924 | 923 | $user['address'] = false; |
| 925 | 924 | } // End if(). |
| 926 | 925 | |
@@ -940,16 +939,16 @@ discard block |
||
| 940 | 939 | $card_data = give_get_donation_cc_info(); |
| 941 | 940 | |
| 942 | 941 | // Validate the card zip. |
| 943 | - if ( ! empty( $card_data['card_zip'] ) ) { |
|
| 944 | - if ( ! give_donation_form_validate_cc_zip( $card_data['card_zip'], $card_data['card_country'] ) ) { |
|
| 945 | - give_set_error( 'invalid_cc_zip', __( 'The zip / postal code you entered for your billing address is invalid.', 'give' ) ); |
|
| 942 | + if ( ! empty($card_data['card_zip'])) { |
|
| 943 | + if ( ! give_donation_form_validate_cc_zip($card_data['card_zip'], $card_data['card_country'])) { |
|
| 944 | + give_set_error('invalid_cc_zip', __('The zip / postal code you entered for your billing address is invalid.', 'give')); |
|
| 946 | 945 | } |
| 947 | 946 | } |
| 948 | 947 | |
| 949 | 948 | // Ensure no spaces. |
| 950 | - if ( ! empty( $card_data['card_number'] ) ) { |
|
| 951 | - $card_data['card_number'] = str_replace( '+', '', $card_data['card_number'] ); // no "+" signs |
|
| 952 | - $card_data['card_number'] = str_replace( ' ', '', $card_data['card_number'] ); // No spaces |
|
| 949 | + if ( ! empty($card_data['card_number'])) { |
|
| 950 | + $card_data['card_number'] = str_replace('+', '', $card_data['card_number']); // no "+" signs |
|
| 951 | + $card_data['card_number'] = str_replace(' ', '', $card_data['card_number']); // No spaces |
|
| 953 | 952 | } |
| 954 | 953 | |
| 955 | 954 | // This should validate card numbers at some point too. |
@@ -966,17 +965,17 @@ discard block |
||
| 966 | 965 | function give_get_donation_cc_info() { |
| 967 | 966 | |
| 968 | 967 | $cc_info = array(); |
| 969 | - $cc_info['card_name'] = isset( $_POST['card_name'] ) ? sanitize_text_field( $_POST['card_name'] ) : ''; |
|
| 970 | - $cc_info['card_number'] = isset( $_POST['card_number'] ) ? sanitize_text_field( $_POST['card_number'] ) : ''; |
|
| 971 | - $cc_info['card_cvc'] = isset( $_POST['card_cvc'] ) ? sanitize_text_field( $_POST['card_cvc'] ) : ''; |
|
| 972 | - $cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] ) ? sanitize_text_field( $_POST['card_exp_month'] ) : ''; |
|
| 973 | - $cc_info['card_exp_year'] = isset( $_POST['card_exp_year'] ) ? sanitize_text_field( $_POST['card_exp_year'] ) : ''; |
|
| 974 | - $cc_info['card_address'] = isset( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : ''; |
|
| 975 | - $cc_info['card_address_2'] = isset( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : ''; |
|
| 976 | - $cc_info['card_city'] = isset( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : ''; |
|
| 977 | - $cc_info['card_state'] = isset( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : ''; |
|
| 978 | - $cc_info['card_country'] = isset( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : ''; |
|
| 979 | - $cc_info['card_zip'] = isset( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : ''; |
|
| 968 | + $cc_info['card_name'] = isset($_POST['card_name']) ? sanitize_text_field($_POST['card_name']) : ''; |
|
| 969 | + $cc_info['card_number'] = isset($_POST['card_number']) ? sanitize_text_field($_POST['card_number']) : ''; |
|
| 970 | + $cc_info['card_cvc'] = isset($_POST['card_cvc']) ? sanitize_text_field($_POST['card_cvc']) : ''; |
|
| 971 | + $cc_info['card_exp_month'] = isset($_POST['card_exp_month']) ? sanitize_text_field($_POST['card_exp_month']) : ''; |
|
| 972 | + $cc_info['card_exp_year'] = isset($_POST['card_exp_year']) ? sanitize_text_field($_POST['card_exp_year']) : ''; |
|
| 973 | + $cc_info['card_address'] = isset($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : ''; |
|
| 974 | + $cc_info['card_address_2'] = isset($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : ''; |
|
| 975 | + $cc_info['card_city'] = isset($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : ''; |
|
| 976 | + $cc_info['card_state'] = isset($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : ''; |
|
| 977 | + $cc_info['card_country'] = isset($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : ''; |
|
| 978 | + $cc_info['card_zip'] = isset($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : ''; |
|
| 980 | 979 | |
| 981 | 980 | // Return cc info. |
| 982 | 981 | return $cc_info; |
@@ -992,14 +991,14 @@ discard block |
||
| 992 | 991 | * |
| 993 | 992 | * @return bool|mixed |
| 994 | 993 | */ |
| 995 | -function give_donation_form_validate_cc_zip( $zip = 0, $country_code = '' ) { |
|
| 994 | +function give_donation_form_validate_cc_zip($zip = 0, $country_code = '') { |
|
| 996 | 995 | $ret = false; |
| 997 | 996 | |
| 998 | - if ( empty( $zip ) || empty( $country_code ) ) { |
|
| 997 | + if (empty($zip) || empty($country_code)) { |
|
| 999 | 998 | return $ret; |
| 1000 | 999 | } |
| 1001 | 1000 | |
| 1002 | - $country_code = strtoupper( $country_code ); |
|
| 1001 | + $country_code = strtoupper($country_code); |
|
| 1003 | 1002 | |
| 1004 | 1003 | $zip_regex = array( |
| 1005 | 1004 | 'AD' => 'AD\d{3}', |
@@ -1159,11 +1158,11 @@ discard block |
||
| 1159 | 1158 | 'ZM' => '\d{5}', |
| 1160 | 1159 | ); |
| 1161 | 1160 | |
| 1162 | - if ( ! isset( $zip_regex[ $country_code ] ) || preg_match( '/' . $zip_regex[ $country_code ] . '/i', $zip ) ) { |
|
| 1161 | + if ( ! isset($zip_regex[$country_code]) || preg_match('/'.$zip_regex[$country_code].'/i', $zip)) { |
|
| 1163 | 1162 | $ret = true; |
| 1164 | 1163 | } |
| 1165 | 1164 | |
| 1166 | - return apply_filters( 'give_is_zip_valid', $ret, $zip, $country_code ); |
|
| 1165 | + return apply_filters('give_is_zip_valid', $ret, $zip, $country_code); |
|
| 1167 | 1166 | } |
| 1168 | 1167 | |
| 1169 | 1168 | |
@@ -1177,47 +1176,47 @@ discard block |
||
| 1177 | 1176 | * |
| 1178 | 1177 | * @return bool |
| 1179 | 1178 | */ |
| 1180 | -function give_validate_donation_amount( $valid_data, $data ) { |
|
| 1179 | +function give_validate_donation_amount($valid_data, $data) { |
|
| 1181 | 1180 | /* @var Give_Donate_Form $form */ |
| 1182 | - $form = new Give_Donate_Form( $data['give-form-id'] ); |
|
| 1181 | + $form = new Give_Donate_Form($data['give-form-id']); |
|
| 1183 | 1182 | |
| 1184 | 1183 | $donation_level_matched = false; |
| 1185 | 1184 | |
| 1186 | - if ( $form->is_set_type_donation_form() ) { |
|
| 1185 | + if ($form->is_set_type_donation_form()) { |
|
| 1187 | 1186 | // Sanitize donation amount. |
| 1188 | - $data['give-amount'] = give_maybe_sanitize_amount( $data['give-amount'] ); |
|
| 1187 | + $data['give-amount'] = give_maybe_sanitize_amount($data['give-amount']); |
|
| 1189 | 1188 | |
| 1190 | 1189 | // Backward compatibility. |
| 1191 | - if ( $form->is_custom_price( $data['give-amount'] ) ) { |
|
| 1190 | + if ($form->is_custom_price($data['give-amount'])) { |
|
| 1192 | 1191 | $_POST['give-price-id'] = 'custom'; |
| 1193 | 1192 | } |
| 1194 | 1193 | |
| 1195 | 1194 | $donation_level_matched = true; |
| 1196 | 1195 | |
| 1197 | - } elseif ( $form->is_multi_type_donation_form() ) { |
|
| 1196 | + } elseif ($form->is_multi_type_donation_form()) { |
|
| 1198 | 1197 | |
| 1199 | 1198 | // Bailout. |
| 1200 | - if ( ! ( $variable_prices = $form->get_prices() ) ) { |
|
| 1199 | + if ( ! ($variable_prices = $form->get_prices())) { |
|
| 1201 | 1200 | return false; |
| 1202 | 1201 | } |
| 1203 | 1202 | |
| 1204 | 1203 | // Sanitize donation amount. |
| 1205 | - $data['give-amount'] = give_maybe_sanitize_amount( $data['give-amount'] ); |
|
| 1204 | + $data['give-amount'] = give_maybe_sanitize_amount($data['give-amount']); |
|
| 1206 | 1205 | |
| 1207 | - if ( $data['give-amount'] === give_maybe_sanitize_amount( give_get_price_option_amount( $data['give-form-id'], $data['give-price-id'] ) ) ) { |
|
| 1206 | + if ($data['give-amount'] === give_maybe_sanitize_amount(give_get_price_option_amount($data['give-form-id'], $data['give-price-id']))) { |
|
| 1208 | 1207 | return true; |
| 1209 | 1208 | } |
| 1210 | 1209 | |
| 1211 | - if ( $form->is_custom_price( $data['give-amount'] ) ) { |
|
| 1210 | + if ($form->is_custom_price($data['give-amount'])) { |
|
| 1212 | 1211 | $_POST['give-price-id'] = 'custom'; |
| 1213 | 1212 | } else { |
| 1214 | 1213 | // Find correct donation level from all donation levels. |
| 1215 | - foreach ( $variable_prices as $variable_price ) { |
|
| 1214 | + foreach ($variable_prices as $variable_price) { |
|
| 1216 | 1215 | // Sanitize level amount. |
| 1217 | - $variable_price['_give_amount'] = give_maybe_sanitize_amount( $variable_price['_give_amount'] ); |
|
| 1216 | + $variable_price['_give_amount'] = give_maybe_sanitize_amount($variable_price['_give_amount']); |
|
| 1218 | 1217 | |
| 1219 | 1218 | // Set first match donation level ID. |
| 1220 | - if ( $data['give-amount'] === $variable_price['_give_amount'] ) { |
|
| 1219 | + if ($data['give-amount'] === $variable_price['_give_amount']) { |
|
| 1221 | 1220 | $_POST['give-price-id'] = $variable_price['_give_id']['level_id']; |
| 1222 | 1221 | break; |
| 1223 | 1222 | } |
@@ -1226,15 +1225,15 @@ discard block |
||
| 1226 | 1225 | |
| 1227 | 1226 | // If donation amount is not find in donation levels then check if form has custom donation feature enable or not. |
| 1228 | 1227 | // If yes then set price id to custom if amount is greater then custom minimum amount (if any). |
| 1229 | - if ( ! empty( $_POST['give-price-id'] ) ) { |
|
| 1228 | + if ( ! empty($_POST['give-price-id'])) { |
|
| 1230 | 1229 | $donation_level_matched = true; |
| 1231 | 1230 | } |
| 1232 | 1231 | }// End if(). |
| 1233 | 1232 | |
| 1234 | - return ( $donation_level_matched ? true : false ); |
|
| 1233 | + return ($donation_level_matched ? true : false); |
|
| 1235 | 1234 | } |
| 1236 | 1235 | |
| 1237 | -add_action( 'give_checkout_error_checks', 'give_validate_donation_amount', 10, 2 ); |
|
| 1236 | +add_action('give_checkout_error_checks', 'give_validate_donation_amount', 10, 2); |
|
| 1238 | 1237 | |
| 1239 | 1238 | /** |
| 1240 | 1239 | * Validate Required Form Fields. |
@@ -1243,17 +1242,17 @@ discard block |
||
| 1243 | 1242 | * |
| 1244 | 1243 | * @since 2.0 |
| 1245 | 1244 | */ |
| 1246 | -function give_validate_required_form_fields( $form_id ) { |
|
| 1245 | +function give_validate_required_form_fields($form_id) { |
|
| 1247 | 1246 | |
| 1248 | 1247 | // Loop through required fields and show error messages. |
| 1249 | - foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) { |
|
| 1248 | + foreach (give_get_required_fields($form_id) as $field_name => $value) { |
|
| 1250 | 1249 | |
| 1251 | 1250 | // Clean Up Data of the input fields. |
| 1252 | - $field_value = give_clean( $_POST[ $field_name ] ); |
|
| 1251 | + $field_value = give_clean($_POST[$field_name]); |
|
| 1253 | 1252 | |
| 1254 | 1253 | // Check whether the required field is empty, then show the error message. |
| 1255 | - if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $field_value ) ) { |
|
| 1256 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
| 1254 | + if (in_array($value, give_get_required_fields($form_id)) && empty($field_value)) { |
|
| 1255 | + give_set_error($value['error_id'], $value['error_message']); |
|
| 1257 | 1256 | } |
| 1258 | 1257 | } |
| 1259 | 1258 | } |