@@ -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 | |
@@ -24,17 +24,17 @@ discard block |
||
| 24 | 24 | // Default, built-in gateways |
| 25 | 25 | $gateways = array( |
| 26 | 26 | 'paypal' => array( |
| 27 | - 'admin_label' => esc_html__( 'PayPal Standard', 'give' ), |
|
| 28 | - 'checkout_label' => esc_html__( 'PayPal', 'give' ), |
|
| 29 | - 'supports' => array( 'buy_now' ) |
|
| 27 | + 'admin_label' => esc_html__('PayPal Standard', 'give'), |
|
| 28 | + 'checkout_label' => esc_html__('PayPal', 'give'), |
|
| 29 | + 'supports' => array('buy_now') |
|
| 30 | 30 | ), |
| 31 | 31 | 'manual' => array( |
| 32 | - 'admin_label' => esc_html__( 'Test Payment', 'give' ), |
|
| 33 | - 'checkout_label' => esc_html__( 'Test Payment', 'give' ) |
|
| 32 | + 'admin_label' => esc_html__('Test Payment', 'give'), |
|
| 33 | + 'checkout_label' => esc_html__('Test Payment', 'give') |
|
| 34 | 34 | ), |
| 35 | 35 | ); |
| 36 | 36 | |
| 37 | - return apply_filters( 'give_payment_gateways', $gateways ); |
|
| 37 | + return apply_filters('give_payment_gateways', $gateways); |
|
| 38 | 38 | |
| 39 | 39 | } |
| 40 | 40 | |
@@ -48,20 +48,20 @@ discard block |
||
| 48 | 48 | |
| 49 | 49 | $gateways = give_get_payment_gateways(); |
| 50 | 50 | |
| 51 | - $enabled = isset( $_POST['gateways'] ) ? $_POST['gateways'] : give_get_option( 'gateways' ); |
|
| 51 | + $enabled = isset($_POST['gateways']) ? $_POST['gateways'] : give_get_option('gateways'); |
|
| 52 | 52 | |
| 53 | 53 | $gateway_list = array(); |
| 54 | 54 | |
| 55 | - foreach ( $gateways as $key => $gateway ) { |
|
| 56 | - if ( isset( $enabled[ $key ] ) && $enabled[ $key ] == 1 ) { |
|
| 57 | - $gateway_list[ $key ] = $gateway; |
|
| 55 | + foreach ($gateways as $key => $gateway) { |
|
| 56 | + if (isset($enabled[$key]) && $enabled[$key] == 1) { |
|
| 57 | + $gateway_list[$key] = $gateway; |
|
| 58 | 58 | } |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | // Set order of payment gateway in list. |
| 62 | - $gateway_list = give_get_ordered_payment_gateways( $gateway_list ); |
|
| 62 | + $gateway_list = give_get_ordered_payment_gateways($gateway_list); |
|
| 63 | 63 | |
| 64 | - return apply_filters( 'give_enabled_payment_gateways', $gateway_list ); |
|
| 64 | + return apply_filters('give_enabled_payment_gateways', $gateway_list); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | /** |
@@ -73,12 +73,12 @@ discard block |
||
| 73 | 73 | * |
| 74 | 74 | * @return boolean true if enabled, false otherwise |
| 75 | 75 | */ |
| 76 | -function give_is_gateway_active( $gateway ) { |
|
| 76 | +function give_is_gateway_active($gateway) { |
|
| 77 | 77 | $gateways = give_get_enabled_payment_gateways(); |
| 78 | 78 | |
| 79 | - $ret = array_key_exists( $gateway, $gateways ); |
|
| 79 | + $ret = array_key_exists($gateway, $gateways); |
|
| 80 | 80 | |
| 81 | - return apply_filters( 'give_is_gateway_active', $ret, $gateway, $gateways ); |
|
| 81 | + return apply_filters('give_is_gateway_active', $ret, $gateway, $gateways); |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | /** |
@@ -91,24 +91,24 @@ discard block |
||
| 91 | 91 | * |
| 92 | 92 | * @return string Gateway ID |
| 93 | 93 | */ |
| 94 | -function give_get_default_gateway( $form_id ) { |
|
| 94 | +function give_get_default_gateway($form_id) { |
|
| 95 | 95 | |
| 96 | 96 | global $give_options; |
| 97 | 97 | |
| 98 | - $default = isset( $give_options['default_gateway'] ) && give_is_gateway_active( $give_options['default_gateway'] ) ? $give_options['default_gateway'] : 'paypal'; |
|
| 99 | - $form_default = get_post_meta( $form_id, '_give_default_gateway', true ); |
|
| 98 | + $default = isset($give_options['default_gateway']) && give_is_gateway_active($give_options['default_gateway']) ? $give_options['default_gateway'] : 'paypal'; |
|
| 99 | + $form_default = get_post_meta($form_id, '_give_default_gateway', true); |
|
| 100 | 100 | |
| 101 | 101 | //Single Form settings varies compared to the Global default settings |
| 102 | - if ( ! empty( $form_default ) && |
|
| 102 | + if ( ! empty($form_default) && |
|
| 103 | 103 | $form_id !== null && |
| 104 | 104 | $default !== $form_default && |
| 105 | 105 | $form_default !== 'global' && |
| 106 | - give_is_gateway_active( $form_default ) |
|
| 106 | + give_is_gateway_active($form_default) |
|
| 107 | 107 | ) { |
| 108 | 108 | $default = $form_default; |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - return apply_filters( 'give_default_gateway', $default ); |
|
| 111 | + return apply_filters('give_default_gateway', $default); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | /** |
@@ -120,18 +120,18 @@ discard block |
||
| 120 | 120 | * |
| 121 | 121 | * @return string Gateway admin label |
| 122 | 122 | */ |
| 123 | -function give_get_gateway_admin_label( $gateway ) { |
|
| 123 | +function give_get_gateway_admin_label($gateway) { |
|
| 124 | 124 | $gateways = give_get_enabled_payment_gateways(); |
| 125 | - $label = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['admin_label'] : $gateway; |
|
| 126 | - $payment = isset( $_GET['id'] ) ? absint( $_GET['id'] ) : false; |
|
| 125 | + $label = isset($gateways[$gateway]) ? $gateways[$gateway]['admin_label'] : $gateway; |
|
| 126 | + $payment = isset($_GET['id']) ? absint($_GET['id']) : false; |
|
| 127 | 127 | |
| 128 | - if ( $gateway == 'manual' && $payment ) { |
|
| 129 | - if ( give_get_payment_amount( $payment ) == 0 ) { |
|
| 130 | - $label = esc_html__( 'Test Donation', 'give' ); |
|
| 128 | + if ($gateway == 'manual' && $payment) { |
|
| 129 | + if (give_get_payment_amount($payment) == 0) { |
|
| 130 | + $label = esc_html__('Test Donation', 'give'); |
|
| 131 | 131 | } |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | - return apply_filters( 'give_gateway_admin_label', $label, $gateway ); |
|
| 134 | + return apply_filters('give_gateway_admin_label', $label, $gateway); |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | /** |
@@ -143,15 +143,15 @@ discard block |
||
| 143 | 143 | * |
| 144 | 144 | * @return string Checkout label for the gateway |
| 145 | 145 | */ |
| 146 | -function give_get_gateway_checkout_label( $gateway ) { |
|
| 146 | +function give_get_gateway_checkout_label($gateway) { |
|
| 147 | 147 | $gateways = give_get_enabled_payment_gateways(); |
| 148 | - $label = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['checkout_label'] : $gateway; |
|
| 148 | + $label = isset($gateways[$gateway]) ? $gateways[$gateway]['checkout_label'] : $gateway; |
|
| 149 | 149 | |
| 150 | - if ( $gateway == 'manual' ) { |
|
| 151 | - $label = esc_html__( 'Test Donation', 'give' ); |
|
| 150 | + if ($gateway == 'manual') { |
|
| 151 | + $label = esc_html__('Test Donation', 'give'); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | - return apply_filters( 'give_gateway_checkout_label', $label, $gateway ); |
|
| 154 | + return apply_filters('give_gateway_checkout_label', $label, $gateway); |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | /** |
@@ -163,11 +163,11 @@ discard block |
||
| 163 | 163 | * |
| 164 | 164 | * @return array Options the gateway supports |
| 165 | 165 | */ |
| 166 | -function give_get_gateway_supports( $gateway ) { |
|
| 166 | +function give_get_gateway_supports($gateway) { |
|
| 167 | 167 | $gateways = give_get_enabled_payment_gateways(); |
| 168 | - $supports = isset( $gateways[ $gateway ]['supports'] ) ? $gateways[ $gateway ]['supports'] : array(); |
|
| 168 | + $supports = isset($gateways[$gateway]['supports']) ? $gateways[$gateway]['supports'] : array(); |
|
| 169 | 169 | |
| 170 | - return apply_filters( 'give_gateway_supports', $supports, $gateway ); |
|
| 170 | + return apply_filters('give_gateway_supports', $supports, $gateway); |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | /** |
@@ -179,11 +179,11 @@ discard block |
||
| 179 | 179 | * |
| 180 | 180 | * @return bool |
| 181 | 181 | */ |
| 182 | -function give_gateway_supports_buy_now( $gateway ) { |
|
| 183 | - $supports = give_get_gateway_supports( $gateway ); |
|
| 184 | - $ret = in_array( 'buy_now', $supports ); |
|
| 182 | +function give_gateway_supports_buy_now($gateway) { |
|
| 183 | + $supports = give_get_gateway_supports($gateway); |
|
| 184 | + $ret = in_array('buy_now', $supports); |
|
| 185 | 185 | |
| 186 | - return apply_filters( 'give_gateway_supports_buy_now', $ret, $gateway ); |
|
| 186 | + return apply_filters('give_gateway_supports_buy_now', $ret, $gateway); |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | /** |
@@ -196,16 +196,16 @@ discard block |
||
| 196 | 196 | $gateways = give_get_enabled_payment_gateways(); |
| 197 | 197 | $ret = false; |
| 198 | 198 | |
| 199 | - if ( $gateways ) { |
|
| 200 | - foreach ( $gateways as $gateway_id => $gateway ) { |
|
| 201 | - if ( give_gateway_supports_buy_now( $gateway_id ) ) { |
|
| 199 | + if ($gateways) { |
|
| 200 | + foreach ($gateways as $gateway_id => $gateway) { |
|
| 201 | + if (give_gateway_supports_buy_now($gateway_id)) { |
|
| 202 | 202 | $ret = true; |
| 203 | 203 | break; |
| 204 | 204 | } |
| 205 | 205 | } |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | - return apply_filters( 'give_give_supports_buy_now', $ret ); |
|
| 208 | + return apply_filters('give_give_supports_buy_now', $ret); |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | /** |
@@ -218,12 +218,12 @@ discard block |
||
| 218 | 218 | * |
| 219 | 219 | * @return void |
| 220 | 220 | */ |
| 221 | -function give_send_to_gateway( $gateway, $payment_data ) { |
|
| 221 | +function give_send_to_gateway($gateway, $payment_data) { |
|
| 222 | 222 | |
| 223 | - $payment_data['gateway_nonce'] = wp_create_nonce( 'give-gateway' ); |
|
| 223 | + $payment_data['gateway_nonce'] = wp_create_nonce('give-gateway'); |
|
| 224 | 224 | |
| 225 | 225 | // $gateway must match the ID used when registering the gateway |
| 226 | - do_action( 'give_gateway_' . $gateway, $payment_data ); |
|
| 226 | + do_action('give_gateway_'.$gateway, $payment_data); |
|
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | |
@@ -240,32 +240,32 @@ discard block |
||
| 240 | 240 | * |
| 241 | 241 | * @return string $enabled_gateway The slug of the gateway |
| 242 | 242 | */ |
| 243 | -function give_get_chosen_gateway( $form_id ) { |
|
| 243 | +function give_get_chosen_gateway($form_id) { |
|
| 244 | 244 | $gateways = give_get_enabled_payment_gateways(); |
| 245 | - $request_form_id = isset( $_REQUEST['give_form_id'] ) ? $_REQUEST['give_form_id'] : 0; |
|
| 246 | - if ( empty( $request_form_id ) ) { |
|
| 247 | - $request_form_id = isset( $_REQUEST['form-id'] ) ? $_REQUEST['form-id'] : 0; |
|
| 245 | + $request_form_id = isset($_REQUEST['give_form_id']) ? $_REQUEST['give_form_id'] : 0; |
|
| 246 | + if (empty($request_form_id)) { |
|
| 247 | + $request_form_id = isset($_REQUEST['form-id']) ? $_REQUEST['form-id'] : 0; |
|
| 248 | 248 | } |
| 249 | - $chosen = give_get_default_gateway( $form_id ); |
|
| 249 | + $chosen = give_get_default_gateway($form_id); |
|
| 250 | 250 | $enabled_gateway = ''; |
| 251 | 251 | |
| 252 | 252 | //Take into account request Form ID args |
| 253 | - if ( ! empty( $request_form_id ) && $form_id == $request_form_id ) { |
|
| 253 | + if ( ! empty($request_form_id) && $form_id == $request_form_id) { |
|
| 254 | 254 | $chosen = $_REQUEST['payment-mode']; |
| 255 | 255 | } |
| 256 | 256 | |
| 257 | - if ( $chosen ) { |
|
| 258 | - $enabled_gateway = urldecode( $chosen ); |
|
| 259 | - } else if ( count( $gateways ) >= 1 && ! $chosen ) { |
|
| 260 | - foreach ( $gateways as $gateway_id => $gateway ): |
|
| 257 | + if ($chosen) { |
|
| 258 | + $enabled_gateway = urldecode($chosen); |
|
| 259 | + } else if (count($gateways) >= 1 && ! $chosen) { |
|
| 260 | + foreach ($gateways as $gateway_id => $gateway): |
|
| 261 | 261 | $enabled_gateway = $gateway_id; |
| 262 | 262 | endforeach; |
| 263 | 263 | } else { |
| 264 | - $enabled_gateway = give_get_default_gateway( $form_id ); |
|
| 264 | + $enabled_gateway = give_get_default_gateway($form_id); |
|
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | |
| 268 | - return apply_filters( 'give_chosen_gateway', $enabled_gateway ); |
|
| 268 | + return apply_filters('give_chosen_gateway', $enabled_gateway); |
|
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | /** |
@@ -282,8 +282,8 @@ discard block |
||
| 282 | 282 | * |
| 283 | 283 | * @return int ID of the new log entry |
| 284 | 284 | */ |
| 285 | -function give_record_gateway_error( $title = '', $message = '', $parent = 0 ) { |
|
| 286 | - return give_record_log( $title, $message, $parent, 'gateway_error' ); |
|
| 285 | +function give_record_gateway_error($title = '', $message = '', $parent = 0) { |
|
| 286 | + return give_record_log($title, $message, $parent, 'gateway_error'); |
|
| 287 | 287 | } |
| 288 | 288 | |
| 289 | 289 | /** |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | * |
| 297 | 297 | * @return int |
| 298 | 298 | */ |
| 299 | -function give_count_sales_by_gateway( $gateway_id = 'paypal', $status = 'publish' ) { |
|
| 299 | +function give_count_sales_by_gateway($gateway_id = 'paypal', $status = 'publish') { |
|
| 300 | 300 | |
| 301 | 301 | $ret = 0; |
| 302 | 302 | $args = array( |
@@ -308,9 +308,9 @@ discard block |
||
| 308 | 308 | 'fields' => 'ids' |
| 309 | 309 | ); |
| 310 | 310 | |
| 311 | - $payments = new WP_Query( $args ); |
|
| 311 | + $payments = new WP_Query($args); |
|
| 312 | 312 | |
| 313 | - if ( $payments ) { |
|
| 313 | + if ($payments) { |
|
| 314 | 314 | $ret = $payments->post_count; |
| 315 | 315 | } |
| 316 | 316 | |
@@ -327,27 +327,27 @@ discard block |
||
| 327 | 327 | * |
| 328 | 328 | * @return array $gateways All the available gateways |
| 329 | 329 | */ |
| 330 | -function give_get_ordered_payment_gateways( $gateways ) { |
|
| 330 | +function give_get_ordered_payment_gateways($gateways) { |
|
| 331 | 331 | |
| 332 | 332 | // Get gateways setting. |
| 333 | - $gateways_setting = isset( $_POST['gateways'] ) ? $_POST['gateways'] : give_get_option( 'gateways' ); |
|
| 333 | + $gateways_setting = isset($_POST['gateways']) ? $_POST['gateways'] : give_get_option('gateways'); |
|
| 334 | 334 | |
| 335 | 335 | // Return from here if we do not have gateways setting. |
| 336 | - if ( empty( $gateways_setting ) ) { |
|
| 336 | + if (empty($gateways_setting)) { |
|
| 337 | 337 | return $gateways; |
| 338 | 338 | } |
| 339 | 339 | |
| 340 | 340 | // Reverse array to order payment gateways. |
| 341 | - $gateways_setting = array_reverse( $gateways_setting ); |
|
| 341 | + $gateways_setting = array_reverse($gateways_setting); |
|
| 342 | 342 | |
| 343 | 343 | // Reorder gateways array |
| 344 | - foreach ( $gateways_setting as $gateway_key => $value ) { |
|
| 344 | + foreach ($gateways_setting as $gateway_key => $value) { |
|
| 345 | 345 | |
| 346 | - $new_gateway_value = isset( $gateways[ $gateway_key ] ) ? $gateways[ $gateway_key ] : ''; |
|
| 347 | - unset( $gateways[ $gateway_key ] ); |
|
| 346 | + $new_gateway_value = isset($gateways[$gateway_key]) ? $gateways[$gateway_key] : ''; |
|
| 347 | + unset($gateways[$gateway_key]); |
|
| 348 | 348 | |
| 349 | - if(!empty($new_gateway_value)) { |
|
| 350 | - $gateways = array_merge( array( $gateway_key => $new_gateway_value ), $gateways ); |
|
| 349 | + if ( ! empty($new_gateway_value)) { |
|
| 350 | + $gateways = array_merge(array($gateway_key => $new_gateway_value), $gateways); |
|
| 351 | 351 | } |
| 352 | 352 | } |
| 353 | 353 | |
@@ -358,5 +358,5 @@ discard block |
||
| 358 | 358 | * |
| 359 | 359 | * @param array $gateways All the available gateways |
| 360 | 360 | */ |
| 361 | - return apply_filters( 'give_payment_gateways_order', $gateways ); |
|
| 361 | + return apply_filters('give_payment_gateways_order', $gateways); |
|
| 362 | 362 | } |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | * @since 1.0 |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 12 | +if ( ! defined('ABSPATH')) { |
|
| 13 | 13 | exit; |
| 14 | 14 | } |
| 15 | 15 | |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | * @access private |
| 22 | 22 | * @since 1.0 |
| 23 | 23 | */ |
| 24 | -add_action( 'give_paypal_cc_form', '__return_false' ); |
|
| 24 | +add_action('give_paypal_cc_form', '__return_false'); |
|
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | 27 | * Process PayPal Purchase |
@@ -32,13 +32,13 @@ discard block |
||
| 32 | 32 | * |
| 33 | 33 | * @return void |
| 34 | 34 | */ |
| 35 | -function give_process_paypal_purchase( $purchase_data ) { |
|
| 35 | +function give_process_paypal_purchase($purchase_data) { |
|
| 36 | 36 | |
| 37 | - if ( ! wp_verify_nonce( $purchase_data['gateway_nonce'], 'give-gateway' ) ) { |
|
| 38 | - wp_die( esc_html__( 'Nonce verification has failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 37 | + if ( ! wp_verify_nonce($purchase_data['gateway_nonce'], 'give-gateway')) { |
|
| 38 | + wp_die(esc_html__('Nonce verification has failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - $form_id = intval( $purchase_data['post_data']['give-form-id'] ); |
|
| 41 | + $form_id = intval($purchase_data['post_data']['give-form-id']); |
|
| 42 | 42 | $price_id = isset($purchase_data['post_data']['give-price-id']) ? $purchase_data['post_data']['give-price-id'] : ''; |
| 43 | 43 | |
| 44 | 44 | // Collect payment data |
@@ -57,67 +57,67 @@ discard block |
||
| 57 | 57 | ); |
| 58 | 58 | |
| 59 | 59 | // Record the pending payment |
| 60 | - $payment = give_insert_payment( $payment_data ); |
|
| 60 | + $payment = give_insert_payment($payment_data); |
|
| 61 | 61 | |
| 62 | 62 | // Check payment |
| 63 | - if ( ! $payment ) { |
|
| 63 | + if ( ! $payment) { |
|
| 64 | 64 | // Record the error |
| 65 | 65 | give_record_gateway_error( |
| 66 | - esc_html__( 'Payment Error', 'give' ), |
|
| 66 | + esc_html__('Payment Error', 'give'), |
|
| 67 | 67 | sprintf( |
| 68 | 68 | /* translators: %s: payment data */ |
| 69 | - esc_html__( 'Payment creation failed before sending buyer to PayPal. Payment data: %s', 'give' ), |
|
| 70 | - json_encode( $payment_data ) |
|
| 69 | + esc_html__('Payment creation failed before sending buyer to PayPal. Payment data: %s', 'give'), |
|
| 70 | + json_encode($payment_data) |
|
| 71 | 71 | ), |
| 72 | 72 | $payment |
| 73 | 73 | ); |
| 74 | 74 | // Problems? send back |
| 75 | - give_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['give-gateway'] ); |
|
| 75 | + give_send_back_to_checkout('?payment-mode='.$purchase_data['post_data']['give-gateway']); |
|
| 76 | 76 | } else { |
| 77 | 77 | // Only send to PayPal if the pending payment is created successfully |
| 78 | - $listener_url = add_query_arg( 'give-listener', 'IPN', home_url( 'index.php' ) ); |
|
| 78 | + $listener_url = add_query_arg('give-listener', 'IPN', home_url('index.php')); |
|
| 79 | 79 | |
| 80 | 80 | // Get the success url |
| 81 | - $return_url = add_query_arg( array( |
|
| 81 | + $return_url = add_query_arg(array( |
|
| 82 | 82 | 'payment-confirmation' => 'paypal', |
| 83 | 83 | 'payment-id' => $payment |
| 84 | 84 | |
| 85 | - ), get_permalink( give_get_option( 'success_page' ) ) ); |
|
| 85 | + ), get_permalink(give_get_option('success_page'))); |
|
| 86 | 86 | |
| 87 | 87 | // Get the PayPal redirect uri |
| 88 | - $paypal_redirect = trailingslashit( give_get_paypal_redirect() ) . '?'; |
|
| 88 | + $paypal_redirect = trailingslashit(give_get_paypal_redirect()).'?'; |
|
| 89 | 89 | |
| 90 | 90 | //Item name - pass level name if variable priced |
| 91 | 91 | $item_name = $purchase_data['post_data']['give-form-title']; |
| 92 | 92 | |
| 93 | 93 | //Verify has variable prices |
| 94 | - if ( give_has_variable_prices( $form_id ) && isset( $purchase_data['post_data']['give-price-id'] ) ) { |
|
| 94 | + if (give_has_variable_prices($form_id) && isset($purchase_data['post_data']['give-price-id'])) { |
|
| 95 | 95 | |
| 96 | - $item_price_level_text = give_get_price_option_name( $form_id, $purchase_data['post_data']['give-price-id'] ); |
|
| 96 | + $item_price_level_text = give_get_price_option_name($form_id, $purchase_data['post_data']['give-price-id']); |
|
| 97 | 97 | |
| 98 | - $price_level_amount = give_get_price_option_amount( $form_id, $purchase_data['post_data']['give-price-id'] ); |
|
| 98 | + $price_level_amount = give_get_price_option_amount($form_id, $purchase_data['post_data']['give-price-id']); |
|
| 99 | 99 | |
| 100 | 100 | //Donation given doesn't match selected level (must be a custom amount) |
| 101 | - if ( $price_level_amount != give_sanitize_amount( $purchase_data['price'] ) ) { |
|
| 102 | - $custom_amount_text = get_post_meta( $form_id, '_give_custom_amount_text', true ); |
|
| 101 | + if ($price_level_amount != give_sanitize_amount($purchase_data['price'])) { |
|
| 102 | + $custom_amount_text = get_post_meta($form_id, '_give_custom_amount_text', true); |
|
| 103 | 103 | //user custom amount text if any, fallback to default if not |
| 104 | - $item_name .= ' - ' . ( ! empty( $custom_amount_text ) ? $custom_amount_text : esc_html__( 'Custom Amount', 'give' ) ); |
|
| 104 | + $item_name .= ' - '.( ! empty($custom_amount_text) ? $custom_amount_text : esc_html__('Custom Amount', 'give')); |
|
| 105 | 105 | |
| 106 | 106 | } //Is there any donation level text? |
| 107 | - elseif ( ! empty( $item_price_level_text ) ) { |
|
| 108 | - $item_name .= ' - ' . $item_price_level_text; |
|
| 107 | + elseif ( ! empty($item_price_level_text)) { |
|
| 108 | + $item_name .= ' - '.$item_price_level_text; |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | } //Single donation: Custom Amount |
| 112 | - elseif ( give_get_form_price( $form_id ) !== give_sanitize_amount( $purchase_data['price'] ) ) { |
|
| 113 | - $custom_amount_text = get_post_meta( $form_id, '_give_custom_amount_text', true ); |
|
| 112 | + elseif (give_get_form_price($form_id) !== give_sanitize_amount($purchase_data['price'])) { |
|
| 113 | + $custom_amount_text = get_post_meta($form_id, '_give_custom_amount_text', true); |
|
| 114 | 114 | //user custom amount text if any, fallback to default if not |
| 115 | - $item_name .= ' - ' . ( ! empty( $custom_amount_text ) ? $custom_amount_text : esc_html__( 'Custom Amount', 'give' ) ); |
|
| 115 | + $item_name .= ' - '.( ! empty($custom_amount_text) ? $custom_amount_text : esc_html__('Custom Amount', 'give')); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | // Setup PayPal arguments |
| 119 | 119 | $paypal_args = array( |
| 120 | - 'business' => give_get_option( 'paypal_email', false ), |
|
| 120 | + 'business' => give_get_option('paypal_email', false), |
|
| 121 | 121 | 'email' => $purchase_data['user_email'], |
| 122 | 122 | 'invoice' => $purchase_data['purchase_key'], |
| 123 | 123 | 'amount' => $purchase_data['price'], |
@@ -128,25 +128,25 @@ discard block |
||
| 128 | 128 | 'shipping' => '0', |
| 129 | 129 | 'no_note' => '1', |
| 130 | 130 | 'currency_code' => give_get_currency(), |
| 131 | - 'charset' => get_bloginfo( 'charset' ), |
|
| 131 | + 'charset' => get_bloginfo('charset'), |
|
| 132 | 132 | 'custom' => $payment, |
| 133 | 133 | 'rm' => '2', |
| 134 | 134 | 'return' => $return_url, |
| 135 | - 'cancel_return' => give_get_failed_transaction_uri( '?payment-id=' . $payment ), |
|
| 135 | + 'cancel_return' => give_get_failed_transaction_uri('?payment-id='.$payment), |
|
| 136 | 136 | 'notify_url' => $listener_url, |
| 137 | 137 | 'page_style' => give_get_paypal_page_style(), |
| 138 | - 'cbt' => get_bloginfo( 'name' ), |
|
| 138 | + 'cbt' => get_bloginfo('name'), |
|
| 139 | 139 | 'bn' => 'givewp_SP' |
| 140 | 140 | ); |
| 141 | 141 | |
| 142 | - if ( ! empty( $purchase_data['user_info']['address'] ) ) { |
|
| 142 | + if ( ! empty($purchase_data['user_info']['address'])) { |
|
| 143 | 143 | $paypal_args['address1'] = $purchase_data['user_info']['address']['line1']; |
| 144 | 144 | $paypal_args['address2'] = $purchase_data['user_info']['address']['line2']; |
| 145 | 145 | $paypal_args['city'] = $purchase_data['user_info']['address']['city']; |
| 146 | 146 | $paypal_args['country'] = $purchase_data['user_info']['address']['country']; |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | - if ( give_get_option( 'paypal_button_type' ) === 'standard' ) { |
|
| 149 | + if (give_get_option('paypal_button_type') === 'standard') { |
|
| 150 | 150 | $paypal_extra_args = array( |
| 151 | 151 | 'cmd' => '_xclick', |
| 152 | 152 | ); |
@@ -156,23 +156,23 @@ discard block |
||
| 156 | 156 | ); |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - $paypal_args = array_merge( $paypal_extra_args, $paypal_args ); |
|
| 160 | - $paypal_args = apply_filters( 'give_paypal_redirect_args', $paypal_args, $purchase_data ); |
|
| 159 | + $paypal_args = array_merge($paypal_extra_args, $paypal_args); |
|
| 160 | + $paypal_args = apply_filters('give_paypal_redirect_args', $paypal_args, $purchase_data); |
|
| 161 | 161 | |
| 162 | 162 | // Build query |
| 163 | - $paypal_redirect .= http_build_query( $paypal_args ); |
|
| 163 | + $paypal_redirect .= http_build_query($paypal_args); |
|
| 164 | 164 | |
| 165 | 165 | // Fix for some sites that encode the entities |
| 166 | - $paypal_redirect = str_replace( '&', '&', $paypal_redirect ); |
|
| 166 | + $paypal_redirect = str_replace('&', '&', $paypal_redirect); |
|
| 167 | 167 | |
| 168 | 168 | // Redirect to PayPal |
| 169 | - wp_redirect( $paypal_redirect ); |
|
| 169 | + wp_redirect($paypal_redirect); |
|
| 170 | 170 | exit; |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | -add_action( 'give_gateway_paypal', 'give_process_paypal_purchase' ); |
|
| 175 | +add_action('give_gateway_paypal', 'give_process_paypal_purchase'); |
|
| 176 | 176 | |
| 177 | 177 | /** |
| 178 | 178 | * Listens for a PayPal IPN requests and then sends to the processing function |
@@ -182,12 +182,12 @@ discard block |
||
| 182 | 182 | */ |
| 183 | 183 | function give_listen_for_paypal_ipn() { |
| 184 | 184 | // Regular PayPal IPN |
| 185 | - if ( isset( $_GET['give-listener'] ) && $_GET['give-listener'] == 'IPN' ) { |
|
| 186 | - do_action( 'give_verify_paypal_ipn' ); |
|
| 185 | + if (isset($_GET['give-listener']) && $_GET['give-listener'] == 'IPN') { |
|
| 186 | + do_action('give_verify_paypal_ipn'); |
|
| 187 | 187 | } |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | -add_action( 'init', 'give_listen_for_paypal_ipn' ); |
|
| 190 | +add_action('init', 'give_listen_for_paypal_ipn'); |
|
| 191 | 191 | |
| 192 | 192 | /** |
| 193 | 193 | * Process PayPal IPN |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | function give_process_paypal_ipn() { |
| 199 | 199 | |
| 200 | 200 | // Check the request method is POST |
| 201 | - if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] != 'POST' ) { |
|
| 201 | + if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'POST') { |
|
| 202 | 202 | return; |
| 203 | 203 | } |
| 204 | 204 | |
@@ -206,11 +206,11 @@ discard block |
||
| 206 | 206 | $post_data = ''; |
| 207 | 207 | |
| 208 | 208 | // Fallback just in case post_max_size is lower than needed |
| 209 | - if ( ini_get( 'allow_url_fopen' ) ) { |
|
| 210 | - $post_data = file_get_contents( 'php://input' ); |
|
| 209 | + if (ini_get('allow_url_fopen')) { |
|
| 210 | + $post_data = file_get_contents('php://input'); |
|
| 211 | 211 | } else { |
| 212 | 212 | // If allow_url_fopen is not enabled, then make sure that post_max_size is large enough |
| 213 | - ini_set( 'post_max_size', '12M' ); |
|
| 213 | + ini_set('post_max_size', '12M'); |
|
| 214 | 214 | } |
| 215 | 215 | // Start the encoded data collection with notification command |
| 216 | 216 | $encoded_data = 'cmd=_notify-validate'; |
@@ -219,40 +219,40 @@ discard block |
||
| 219 | 219 | $arg_separator = give_get_php_arg_separator_output(); |
| 220 | 220 | |
| 221 | 221 | // Verify there is a post_data |
| 222 | - if ( $post_data || strlen( $post_data ) > 0 ) { |
|
| 222 | + if ($post_data || strlen($post_data) > 0) { |
|
| 223 | 223 | // Append the data |
| 224 | - $encoded_data .= $arg_separator . $post_data; |
|
| 224 | + $encoded_data .= $arg_separator.$post_data; |
|
| 225 | 225 | } else { |
| 226 | 226 | // Check if POST is empty |
| 227 | - if ( empty( $_POST ) ) { |
|
| 227 | + if (empty($_POST)) { |
|
| 228 | 228 | // Nothing to do |
| 229 | 229 | return; |
| 230 | 230 | } else { |
| 231 | 231 | // Loop through each POST |
| 232 | - foreach ( $_POST as $key => $value ) { |
|
| 232 | + foreach ($_POST as $key => $value) { |
|
| 233 | 233 | // Encode the value and append the data |
| 234 | - $encoded_data .= $arg_separator . "$key=" . urlencode( $value ); |
|
| 234 | + $encoded_data .= $arg_separator."$key=".urlencode($value); |
|
| 235 | 235 | } |
| 236 | 236 | } |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | // Convert collected post data to an array |
| 240 | - parse_str( $encoded_data, $encoded_data_array ); |
|
| 240 | + parse_str($encoded_data, $encoded_data_array); |
|
| 241 | 241 | |
| 242 | - foreach ( $encoded_data_array as $key => $value ) { |
|
| 242 | + foreach ($encoded_data_array as $key => $value) { |
|
| 243 | 243 | |
| 244 | - if ( false !== strpos( $key, 'amp;' ) ) { |
|
| 245 | - $new_key = str_replace( '&', '&', $key ); |
|
| 246 | - $new_key = str_replace( 'amp;', '&' , $new_key ); |
|
| 244 | + if (false !== strpos($key, 'amp;')) { |
|
| 245 | + $new_key = str_replace('&', '&', $key); |
|
| 246 | + $new_key = str_replace('amp;', '&', $new_key); |
|
| 247 | 247 | |
| 248 | - unset( $encoded_data_array[ $key ] ); |
|
| 249 | - $encoded_data_array[ $new_key ] = $value; |
|
| 248 | + unset($encoded_data_array[$key]); |
|
| 249 | + $encoded_data_array[$new_key] = $value; |
|
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | //Validate IPN request w/ PayPal if user hasn't disabled this security measure |
| 255 | - if ( ! give_get_option( 'disable_paypal_verification' ) ) { |
|
| 255 | + if ( ! give_get_option('disable_paypal_verification')) { |
|
| 256 | 256 | |
| 257 | 257 | $remote_post_vars = array( |
| 258 | 258 | 'method' => 'POST', |
@@ -272,27 +272,27 @@ discard block |
||
| 272 | 272 | ); |
| 273 | 273 | |
| 274 | 274 | // Validate the IPN |
| 275 | - $api_response = wp_remote_post( give_get_paypal_redirect(), $remote_post_vars ); |
|
| 275 | + $api_response = wp_remote_post(give_get_paypal_redirect(), $remote_post_vars); |
|
| 276 | 276 | |
| 277 | - if ( is_wp_error( $api_response ) ) { |
|
| 277 | + if (is_wp_error($api_response)) { |
|
| 278 | 278 | give_record_gateway_error( |
| 279 | - esc_html__( 'IPN Error', 'give' ), |
|
| 279 | + esc_html__('IPN Error', 'give'), |
|
| 280 | 280 | sprintf( |
| 281 | 281 | /* translators: %s: Paypal IPN response */ |
| 282 | - esc_html__( 'Invalid IPN verification response. IPN data: %s', 'give' ), |
|
| 283 | - json_encode( $api_response ) |
|
| 282 | + esc_html__('Invalid IPN verification response. IPN data: %s', 'give'), |
|
| 283 | + json_encode($api_response) |
|
| 284 | 284 | ) |
| 285 | 285 | ); |
| 286 | 286 | return; // Something went wrong |
| 287 | 287 | } |
| 288 | 288 | |
| 289 | - if ( $api_response['body'] !== 'VERIFIED' && give_get_option( 'disable_paypal_verification', false ) ) { |
|
| 289 | + if ($api_response['body'] !== 'VERIFIED' && give_get_option('disable_paypal_verification', false)) { |
|
| 290 | 290 | give_record_gateway_error( |
| 291 | - esc_html__( 'IPN Error', 'give' ), |
|
| 291 | + esc_html__('IPN Error', 'give'), |
|
| 292 | 292 | sprintf( |
| 293 | 293 | /* translators: %s: Paypal IPN response */ |
| 294 | - esc_html__( 'Invalid IPN verification response. IPN data: %s', 'give' ), |
|
| 295 | - json_encode( $api_response ) |
|
| 294 | + esc_html__('Invalid IPN verification response. IPN data: %s', 'give'), |
|
| 295 | + json_encode($api_response) |
|
| 296 | 296 | ) |
| 297 | 297 | ); |
| 298 | 298 | return; // Response not okay |
@@ -301,7 +301,7 @@ discard block |
||
| 301 | 301 | } |
| 302 | 302 | |
| 303 | 303 | // Check if $post_data_array has been populated |
| 304 | - if ( ! is_array( $encoded_data_array ) && ! empty( $encoded_data_array ) ) { |
|
| 304 | + if ( ! is_array($encoded_data_array) && ! empty($encoded_data_array)) { |
|
| 305 | 305 | return; |
| 306 | 306 | } |
| 307 | 307 | |
@@ -310,21 +310,21 @@ discard block |
||
| 310 | 310 | 'payment_status' => '' |
| 311 | 311 | ); |
| 312 | 312 | |
| 313 | - $encoded_data_array = wp_parse_args( $encoded_data_array, $defaults ); |
|
| 313 | + $encoded_data_array = wp_parse_args($encoded_data_array, $defaults); |
|
| 314 | 314 | |
| 315 | - $payment_id = isset( $encoded_data_array['custom'] ) ? absint( $encoded_data_array['custom'] ) : 0; |
|
| 315 | + $payment_id = isset($encoded_data_array['custom']) ? absint($encoded_data_array['custom']) : 0; |
|
| 316 | 316 | |
| 317 | - if ( has_action( 'give_paypal_' . $encoded_data_array['txn_type'] ) ) { |
|
| 317 | + if (has_action('give_paypal_'.$encoded_data_array['txn_type'])) { |
|
| 318 | 318 | // Allow PayPal IPN types to be processed separately |
| 319 | - do_action( 'give_paypal_' . $encoded_data_array['txn_type'], $encoded_data_array, $payment_id ); |
|
| 319 | + do_action('give_paypal_'.$encoded_data_array['txn_type'], $encoded_data_array, $payment_id); |
|
| 320 | 320 | } else { |
| 321 | 321 | // Fallback to web accept just in case the txn_type isn't present |
| 322 | - do_action( 'give_paypal_web_accept', $encoded_data_array, $payment_id ); |
|
| 322 | + do_action('give_paypal_web_accept', $encoded_data_array, $payment_id); |
|
| 323 | 323 | } |
| 324 | 324 | exit; |
| 325 | 325 | } |
| 326 | 326 | |
| 327 | -add_action( 'give_verify_paypal_ipn', 'give_process_paypal_ipn' ); |
|
| 327 | +add_action('give_verify_paypal_ipn', 'give_process_paypal_ipn'); |
|
| 328 | 328 | |
| 329 | 329 | /** |
| 330 | 330 | * Process web accept (one time) payment IPNs |
@@ -335,224 +335,224 @@ discard block |
||
| 335 | 335 | * |
| 336 | 336 | * @return void |
| 337 | 337 | */ |
| 338 | -function give_process_paypal_web_accept_and_cart( $data, $payment_id ) { |
|
| 338 | +function give_process_paypal_web_accept_and_cart($data, $payment_id) { |
|
| 339 | 339 | |
| 340 | - if ( $data['txn_type'] != 'web_accept' && $data['txn_type'] != 'cart' && $data['payment_status'] != 'Refunded' ) { |
|
| 340 | + if ($data['txn_type'] != 'web_accept' && $data['txn_type'] != 'cart' && $data['payment_status'] != 'Refunded') { |
|
| 341 | 341 | return; |
| 342 | 342 | } |
| 343 | 343 | |
| 344 | - if ( empty( $payment_id ) ) { |
|
| 344 | + if (empty($payment_id)) { |
|
| 345 | 345 | return; |
| 346 | 346 | } |
| 347 | 347 | |
| 348 | 348 | // Collect payment details |
| 349 | - $purchase_key = isset( $data['invoice'] ) ? $data['invoice'] : $data['item_number']; |
|
| 349 | + $purchase_key = isset($data['invoice']) ? $data['invoice'] : $data['item_number']; |
|
| 350 | 350 | $paypal_amount = $data['mc_gross']; |
| 351 | - $payment_status = strtolower( $data['payment_status'] ); |
|
| 352 | - $currency_code = strtolower( $data['mc_currency'] ); |
|
| 353 | - $business_email = isset( $data['business'] ) && is_email( $data['business'] ) ? trim( $data['business'] ) : trim( $data['receiver_email'] ); |
|
| 354 | - $payment_meta = give_get_payment_meta( $payment_id ); |
|
| 351 | + $payment_status = strtolower($data['payment_status']); |
|
| 352 | + $currency_code = strtolower($data['mc_currency']); |
|
| 353 | + $business_email = isset($data['business']) && is_email($data['business']) ? trim($data['business']) : trim($data['receiver_email']); |
|
| 354 | + $payment_meta = give_get_payment_meta($payment_id); |
|
| 355 | 355 | |
| 356 | 356 | |
| 357 | - if ( give_get_payment_gateway( $payment_id ) != 'paypal' ) { |
|
| 357 | + if (give_get_payment_gateway($payment_id) != 'paypal') { |
|
| 358 | 358 | return; // this isn't a PayPal standard IPN |
| 359 | 359 | } |
| 360 | 360 | |
| 361 | 361 | // Verify payment recipient |
| 362 | - if ( strcasecmp( $business_email, trim( give_get_option( 'paypal_email' ) ) ) != 0 ) { |
|
| 362 | + if (strcasecmp($business_email, trim(give_get_option('paypal_email'))) != 0) { |
|
| 363 | 363 | |
| 364 | 364 | give_record_gateway_error( |
| 365 | - esc_html__( 'IPN Error', 'give' ), |
|
| 365 | + esc_html__('IPN Error', 'give'), |
|
| 366 | 366 | sprintf( |
| 367 | 367 | /* translators: %s: Paypal IPN response */ |
| 368 | - esc_html__( 'Invalid business email in IPN response. IPN data: %s', 'give' ), |
|
| 369 | - json_encode( $data ) |
|
| 368 | + esc_html__('Invalid business email in IPN response. IPN data: %s', 'give'), |
|
| 369 | + json_encode($data) |
|
| 370 | 370 | ), |
| 371 | 371 | $payment_id |
| 372 | 372 | ); |
| 373 | - give_update_payment_status( $payment_id, 'failed' ); |
|
| 374 | - give_insert_payment_note( $payment_id, esc_html__( 'Payment failed due to invalid PayPal business email.', 'give' ) ); |
|
| 373 | + give_update_payment_status($payment_id, 'failed'); |
|
| 374 | + give_insert_payment_note($payment_id, esc_html__('Payment failed due to invalid PayPal business email.', 'give')); |
|
| 375 | 375 | |
| 376 | 376 | return; |
| 377 | 377 | } |
| 378 | 378 | |
| 379 | 379 | // Verify payment currency |
| 380 | - if ( $currency_code != strtolower( $payment_meta['currency'] ) ) { |
|
| 380 | + if ($currency_code != strtolower($payment_meta['currency'])) { |
|
| 381 | 381 | |
| 382 | 382 | give_record_gateway_error( |
| 383 | - esc_html__( 'IPN Error', 'give' ), |
|
| 383 | + esc_html__('IPN Error', 'give'), |
|
| 384 | 384 | sprintf( |
| 385 | 385 | /* translators: %s: Paypal IPN response */ |
| 386 | - esc_html__( 'Invalid currency in IPN response. IPN data: %s', 'give' ), |
|
| 387 | - json_encode( $data ) |
|
| 386 | + esc_html__('Invalid currency in IPN response. IPN data: %s', 'give'), |
|
| 387 | + json_encode($data) |
|
| 388 | 388 | ), |
| 389 | 389 | $payment_id |
| 390 | 390 | ); |
| 391 | - give_update_payment_status( $payment_id, 'failed' ); |
|
| 392 | - give_insert_payment_note( $payment_id, esc_html__( 'Payment failed due to invalid currency in PayPal IPN.', 'give' ) ); |
|
| 391 | + give_update_payment_status($payment_id, 'failed'); |
|
| 392 | + give_insert_payment_note($payment_id, esc_html__('Payment failed due to invalid currency in PayPal IPN.', 'give')); |
|
| 393 | 393 | |
| 394 | 394 | return; |
| 395 | 395 | } |
| 396 | 396 | |
| 397 | - if ( ! give_get_payment_user_email( $payment_id ) ) { |
|
| 397 | + if ( ! give_get_payment_user_email($payment_id)) { |
|
| 398 | 398 | |
| 399 | 399 | // No email associated with purchase, so store from PayPal |
| 400 | - give_update_payment_meta( $payment_id, '_give_payment_user_email', $data['payer_email'] ); |
|
| 400 | + give_update_payment_meta($payment_id, '_give_payment_user_email', $data['payer_email']); |
|
| 401 | 401 | |
| 402 | 402 | // Setup and store the donors's details |
| 403 | 403 | $address = array(); |
| 404 | - $address['line1'] = ! empty( $data['address_street'] ) ? sanitize_text_field( $data['address_street'] ) : false; |
|
| 405 | - $address['city'] = ! empty( $data['address_city'] ) ? sanitize_text_field( $data['address_city'] ) : false; |
|
| 406 | - $address['state'] = ! empty( $data['address_state'] ) ? sanitize_text_field( $data['address_state'] ) : false; |
|
| 407 | - $address['country'] = ! empty( $data['address_country_code'] ) ? sanitize_text_field( $data['address_country_code'] ) : false; |
|
| 408 | - $address['zip'] = ! empty( $data['address_zip'] ) ? sanitize_text_field( $data['address_zip'] ) : false; |
|
| 404 | + $address['line1'] = ! empty($data['address_street']) ? sanitize_text_field($data['address_street']) : false; |
|
| 405 | + $address['city'] = ! empty($data['address_city']) ? sanitize_text_field($data['address_city']) : false; |
|
| 406 | + $address['state'] = ! empty($data['address_state']) ? sanitize_text_field($data['address_state']) : false; |
|
| 407 | + $address['country'] = ! empty($data['address_country_code']) ? sanitize_text_field($data['address_country_code']) : false; |
|
| 408 | + $address['zip'] = ! empty($data['address_zip']) ? sanitize_text_field($data['address_zip']) : false; |
|
| 409 | 409 | |
| 410 | 410 | $user_info = array( |
| 411 | 411 | 'id' => '-1', |
| 412 | - 'email' => sanitize_text_field( $data['payer_email'] ), |
|
| 413 | - 'first_name' => sanitize_text_field( $data['first_name'] ), |
|
| 414 | - 'last_name' => sanitize_text_field( $data['last_name'] ), |
|
| 412 | + 'email' => sanitize_text_field($data['payer_email']), |
|
| 413 | + 'first_name' => sanitize_text_field($data['first_name']), |
|
| 414 | + 'last_name' => sanitize_text_field($data['last_name']), |
|
| 415 | 415 | 'discount' => '', |
| 416 | 416 | 'address' => $address |
| 417 | 417 | ); |
| 418 | 418 | |
| 419 | 419 | $payment_meta['user_info'] = $user_info; |
| 420 | - give_update_payment_meta( $payment_id, '_give_payment_meta', $payment_meta ); |
|
| 420 | + give_update_payment_meta($payment_id, '_give_payment_meta', $payment_meta); |
|
| 421 | 421 | } |
| 422 | 422 | |
| 423 | - if ( $payment_status == 'refunded' || $payment_status == 'reversed' ) { |
|
| 423 | + if ($payment_status == 'refunded' || $payment_status == 'reversed') { |
|
| 424 | 424 | |
| 425 | 425 | // Process a refund |
| 426 | - give_process_paypal_refund( $data, $payment_id ); |
|
| 426 | + give_process_paypal_refund($data, $payment_id); |
|
| 427 | 427 | |
| 428 | 428 | } else { |
| 429 | 429 | |
| 430 | - if ( get_post_status( $payment_id ) == 'publish' ) { |
|
| 430 | + if (get_post_status($payment_id) == 'publish') { |
|
| 431 | 431 | return; // Only complete payments once |
| 432 | 432 | } |
| 433 | 433 | |
| 434 | 434 | // Retrieve the total purchase amount (before PayPal) |
| 435 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
| 435 | + $payment_amount = give_get_payment_amount($payment_id); |
|
| 436 | 436 | |
| 437 | - if ( number_format( (float) $paypal_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) { |
|
| 437 | + if (number_format((float) $paypal_amount, 2) < number_format((float) $payment_amount, 2)) { |
|
| 438 | 438 | // The prices don't match |
| 439 | 439 | give_record_gateway_error( |
| 440 | - esc_html__( 'IPN Error', 'give' ), |
|
| 440 | + esc_html__('IPN Error', 'give'), |
|
| 441 | 441 | sprintf( |
| 442 | 442 | /* translators: %s: Paypal IPN response */ |
| 443 | - esc_html__( 'Invalid payment amount in IPN response. IPN data: %s', 'give' ), |
|
| 444 | - json_encode( $data ) |
|
| 443 | + esc_html__('Invalid payment amount in IPN response. IPN data: %s', 'give'), |
|
| 444 | + json_encode($data) |
|
| 445 | 445 | ), |
| 446 | 446 | $payment_id |
| 447 | 447 | ); |
| 448 | - give_update_payment_status( $payment_id, 'failed' ); |
|
| 449 | - give_insert_payment_note( $payment_id, esc_html__( 'Payment failed due to invalid amount in PayPal IPN.', 'give' ) ); |
|
| 448 | + give_update_payment_status($payment_id, 'failed'); |
|
| 449 | + give_insert_payment_note($payment_id, esc_html__('Payment failed due to invalid amount in PayPal IPN.', 'give')); |
|
| 450 | 450 | |
| 451 | 451 | return; |
| 452 | 452 | } |
| 453 | - if ( $purchase_key != give_get_payment_key( $payment_id ) ) { |
|
| 453 | + if ($purchase_key != give_get_payment_key($payment_id)) { |
|
| 454 | 454 | // Purchase keys don't match |
| 455 | 455 | give_record_gateway_error( |
| 456 | - esc_html__( 'IPN Error', 'give' ), |
|
| 456 | + esc_html__('IPN Error', 'give'), |
|
| 457 | 457 | sprintf( |
| 458 | 458 | /* translators: %s: Paypal IPN response */ |
| 459 | - esc_html__( 'Invalid purchase key in IPN response. IPN data: %s', 'give' ), |
|
| 460 | - json_encode( $data ) |
|
| 459 | + esc_html__('Invalid purchase key in IPN response. IPN data: %s', 'give'), |
|
| 460 | + json_encode($data) |
|
| 461 | 461 | ), |
| 462 | 462 | $payment_id |
| 463 | 463 | ); |
| 464 | - give_update_payment_status( $payment_id, 'failed' ); |
|
| 465 | - give_insert_payment_note( $payment_id, esc_html__( 'Payment failed due to invalid purchase key in PayPal IPN.', 'give' ) ); |
|
| 464 | + give_update_payment_status($payment_id, 'failed'); |
|
| 465 | + give_insert_payment_note($payment_id, esc_html__('Payment failed due to invalid purchase key in PayPal IPN.', 'give')); |
|
| 466 | 466 | |
| 467 | 467 | return; |
| 468 | 468 | } |
| 469 | 469 | |
| 470 | - if ( $payment_status == 'completed' || give_is_test_mode() ) { |
|
| 470 | + if ($payment_status == 'completed' || give_is_test_mode()) { |
|
| 471 | 471 | give_insert_payment_note( |
| 472 | 472 | $payment_id, |
| 473 | 473 | sprintf( |
| 474 | 474 | /* translators: %s: Paypal transaction ID */ |
| 475 | - esc_html__( 'PayPal Transaction ID: %s', 'give' ), |
|
| 475 | + esc_html__('PayPal Transaction ID: %s', 'give'), |
|
| 476 | 476 | $data['txn_id'] |
| 477 | 477 | ) |
| 478 | 478 | ); |
| 479 | - give_set_payment_transaction_id( $payment_id, $data['txn_id'] ); |
|
| 480 | - give_update_payment_status( $payment_id, 'publish' ); |
|
| 481 | - } else if ( 'pending' == $payment_status && isset( $data['pending_reason'] ) ) { |
|
| 479 | + give_set_payment_transaction_id($payment_id, $data['txn_id']); |
|
| 480 | + give_update_payment_status($payment_id, 'publish'); |
|
| 481 | + } else if ('pending' == $payment_status && isset($data['pending_reason'])) { |
|
| 482 | 482 | |
| 483 | 483 | // Look for possible pending reasons, such as an echeck |
| 484 | 484 | |
| 485 | 485 | $note = ''; |
| 486 | 486 | |
| 487 | - switch ( strtolower( $data['pending_reason'] ) ) { |
|
| 487 | + switch (strtolower($data['pending_reason'])) { |
|
| 488 | 488 | |
| 489 | 489 | case 'echeck' : |
| 490 | 490 | |
| 491 | - $note = esc_html__( 'Payment made via eCheck and will clear automatically in 5-8 days.', 'give' ); |
|
| 491 | + $note = esc_html__('Payment made via eCheck and will clear automatically in 5-8 days.', 'give'); |
|
| 492 | 492 | |
| 493 | 493 | break; |
| 494 | 494 | |
| 495 | 495 | case 'address' : |
| 496 | 496 | |
| 497 | - $note = esc_html__( 'Payment requires a confirmed donor address and must be accepted manually through PayPal.', 'give' ); |
|
| 497 | + $note = esc_html__('Payment requires a confirmed donor address and must be accepted manually through PayPal.', 'give'); |
|
| 498 | 498 | |
| 499 | 499 | break; |
| 500 | 500 | |
| 501 | 501 | case 'intl' : |
| 502 | 502 | |
| 503 | - $note = esc_html__( 'Payment must be accepted manually through PayPal due to international account regulations.', 'give' ); |
|
| 503 | + $note = esc_html__('Payment must be accepted manually through PayPal due to international account regulations.', 'give'); |
|
| 504 | 504 | |
| 505 | 505 | break; |
| 506 | 506 | |
| 507 | 507 | case 'multi-currency' : |
| 508 | 508 | |
| 509 | - $note = esc_html__( 'Payment received in non-shop currency and must be accepted manually through PayPal.', 'give' ); |
|
| 509 | + $note = esc_html__('Payment received in non-shop currency and must be accepted manually through PayPal.', 'give'); |
|
| 510 | 510 | |
| 511 | 511 | break; |
| 512 | 512 | |
| 513 | 513 | case 'paymentreview' : |
| 514 | 514 | case 'regulatory_review' : |
| 515 | 515 | |
| 516 | - $note = esc_html__( 'Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations.', 'give' ); |
|
| 516 | + $note = esc_html__('Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations.', 'give'); |
|
| 517 | 517 | |
| 518 | 518 | break; |
| 519 | 519 | |
| 520 | 520 | case 'unilateral' : |
| 521 | 521 | |
| 522 | - $note = esc_html__( 'Payment was sent to non-confirmed or non-registered email address.', 'give' ); |
|
| 522 | + $note = esc_html__('Payment was sent to non-confirmed or non-registered email address.', 'give'); |
|
| 523 | 523 | |
| 524 | 524 | break; |
| 525 | 525 | |
| 526 | 526 | case 'upgrade' : |
| 527 | 527 | |
| 528 | - $note = esc_html__( 'PayPal account must be upgraded before this payment can be accepted.', 'give' ); |
|
| 528 | + $note = esc_html__('PayPal account must be upgraded before this payment can be accepted.', 'give'); |
|
| 529 | 529 | |
| 530 | 530 | break; |
| 531 | 531 | |
| 532 | 532 | case 'verify' : |
| 533 | 533 | |
| 534 | - $note = esc_html__( 'PayPal account is not verified. Verify account in order to accept this payment.', 'give' ); |
|
| 534 | + $note = esc_html__('PayPal account is not verified. Verify account in order to accept this payment.', 'give'); |
|
| 535 | 535 | |
| 536 | 536 | break; |
| 537 | 537 | |
| 538 | 538 | case 'other' : |
| 539 | 539 | |
| 540 | - $note = esc_html__( 'Payment is pending for unknown reasons. Contact PayPal support for assistance.', 'give' ); |
|
| 540 | + $note = esc_html__('Payment is pending for unknown reasons. Contact PayPal support for assistance.', 'give'); |
|
| 541 | 541 | |
| 542 | 542 | break; |
| 543 | 543 | |
| 544 | 544 | } |
| 545 | 545 | |
| 546 | - if ( ! empty( $note ) ) { |
|
| 546 | + if ( ! empty($note)) { |
|
| 547 | 547 | |
| 548 | - give_insert_payment_note( $payment_id, $note ); |
|
| 548 | + give_insert_payment_note($payment_id, $note); |
|
| 549 | 549 | |
| 550 | 550 | } |
| 551 | 551 | } |
| 552 | 552 | } |
| 553 | 553 | } |
| 554 | 554 | |
| 555 | -add_action( 'give_paypal_web_accept', 'give_process_paypal_web_accept_and_cart', 10, 2 ); |
|
| 555 | +add_action('give_paypal_web_accept', 'give_process_paypal_web_accept_and_cart', 10, 2); |
|
| 556 | 556 | |
| 557 | 557 | /** |
| 558 | 558 | * Process PayPal IPN Refunds |
@@ -563,28 +563,28 @@ discard block |
||
| 563 | 563 | * |
| 564 | 564 | * @return void |
| 565 | 565 | */ |
| 566 | -function give_process_paypal_refund( $data, $payment_id = 0 ) { |
|
| 566 | +function give_process_paypal_refund($data, $payment_id = 0) { |
|
| 567 | 567 | |
| 568 | 568 | // Collect payment details |
| 569 | 569 | |
| 570 | - if ( empty( $payment_id ) ) { |
|
| 570 | + if (empty($payment_id)) { |
|
| 571 | 571 | return; |
| 572 | 572 | } |
| 573 | 573 | |
| 574 | - if ( get_post_status( $payment_id ) == 'refunded' ) { |
|
| 574 | + if (get_post_status($payment_id) == 'refunded') { |
|
| 575 | 575 | return; // Only refund payments once |
| 576 | 576 | } |
| 577 | 577 | |
| 578 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
| 578 | + $payment_amount = give_get_payment_amount($payment_id); |
|
| 579 | 579 | $refund_amount = $data['payment_gross'] * - 1; |
| 580 | 580 | |
| 581 | - if ( number_format( (float) $refund_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) { |
|
| 581 | + if (number_format((float) $refund_amount, 2) < number_format((float) $payment_amount, 2)) { |
|
| 582 | 582 | |
| 583 | 583 | give_insert_payment_note( |
| 584 | 584 | $payment_id, |
| 585 | 585 | sprintf( |
| 586 | 586 | /* translators: %s: Paypal parent transaction ID */ |
| 587 | - esc_html__( 'Partial PayPal refund processed: %s', 'give' ), |
|
| 587 | + esc_html__('Partial PayPal refund processed: %s', 'give'), |
|
| 588 | 588 | $data['parent_txn_id'] |
| 589 | 589 | ) |
| 590 | 590 | ); |
@@ -597,7 +597,7 @@ discard block |
||
| 597 | 597 | $payment_id, |
| 598 | 598 | sprintf( |
| 599 | 599 | /* translators: %s: Paypal parent transaction ID */ |
| 600 | - esc_html__( 'PayPal Payment #%s Refunded for reason: %s', 'give' ), |
|
| 600 | + esc_html__('PayPal Payment #%s Refunded for reason: %s', 'give'), |
|
| 601 | 601 | $data['parent_txn_id'], $data['reason_code'] |
| 602 | 602 | ) |
| 603 | 603 | ); |
@@ -605,11 +605,11 @@ discard block |
||
| 605 | 605 | $payment_id, |
| 606 | 606 | sprintf( |
| 607 | 607 | /* translators: %s: Paypal transaction ID */ |
| 608 | - esc_html__( 'PayPal Refund Transaction ID: %s', 'give' ), |
|
| 608 | + esc_html__('PayPal Refund Transaction ID: %s', 'give'), |
|
| 609 | 609 | $data['txn_id'] |
| 610 | 610 | ) |
| 611 | 611 | ); |
| 612 | - give_update_payment_status( $payment_id, 'refunded' ); |
|
| 612 | + give_update_payment_status($payment_id, 'refunded'); |
|
| 613 | 613 | } |
| 614 | 614 | |
| 615 | 615 | /** |
@@ -621,24 +621,24 @@ discard block |
||
| 621 | 621 | * |
| 622 | 622 | * @return string |
| 623 | 623 | */ |
| 624 | -function give_get_paypal_redirect( $ssl_check = false ) { |
|
| 624 | +function give_get_paypal_redirect($ssl_check = false) { |
|
| 625 | 625 | |
| 626 | - if ( is_ssl() || ! $ssl_check ) { |
|
| 626 | + if (is_ssl() || ! $ssl_check) { |
|
| 627 | 627 | $protocal = 'https://'; |
| 628 | 628 | } else { |
| 629 | 629 | $protocal = 'http://'; |
| 630 | 630 | } |
| 631 | 631 | |
| 632 | 632 | // Check the current payment mode |
| 633 | - if ( give_is_test_mode() ) { |
|
| 633 | + if (give_is_test_mode()) { |
|
| 634 | 634 | // Test mode |
| 635 | - $paypal_uri = $protocal . 'www.sandbox.paypal.com/cgi-bin/webscr'; |
|
| 635 | + $paypal_uri = $protocal.'www.sandbox.paypal.com/cgi-bin/webscr'; |
|
| 636 | 636 | } else { |
| 637 | 637 | // Live mode |
| 638 | - $paypal_uri = $protocal . 'www.paypal.com/cgi-bin/webscr'; |
|
| 638 | + $paypal_uri = $protocal.'www.paypal.com/cgi-bin/webscr'; |
|
| 639 | 639 | } |
| 640 | 640 | |
| 641 | - return apply_filters( 'give_paypal_uri', $paypal_uri ); |
|
| 641 | + return apply_filters('give_paypal_uri', $paypal_uri); |
|
| 642 | 642 | } |
| 643 | 643 | |
| 644 | 644 | /** |
@@ -648,8 +648,8 @@ discard block |
||
| 648 | 648 | * @return string |
| 649 | 649 | */ |
| 650 | 650 | function give_get_paypal_page_style() { |
| 651 | - $page_style = trim( give_get_option( 'paypal_page_style', 'PayPal' ) ); |
|
| 652 | - return apply_filters( 'give_paypal_page_style', $page_style ); |
|
| 651 | + $page_style = trim(give_get_option('paypal_page_style', 'PayPal')); |
|
| 652 | + return apply_filters('give_paypal_page_style', $page_style); |
|
| 653 | 653 | } |
| 654 | 654 | |
| 655 | 655 | /** |
@@ -664,27 +664,27 @@ discard block |
||
| 664 | 664 | * @return string |
| 665 | 665 | * |
| 666 | 666 | */ |
| 667 | -function give_paypal_success_page_content( $content ) { |
|
| 667 | +function give_paypal_success_page_content($content) { |
|
| 668 | 668 | |
| 669 | - if ( ! isset( $_GET['payment-id'] ) && ! give_get_purchase_session() ) { |
|
| 669 | + if ( ! isset($_GET['payment-id']) && ! give_get_purchase_session()) { |
|
| 670 | 670 | return $content; |
| 671 | 671 | } |
| 672 | 672 | |
| 673 | - $payment_id = isset( $_GET['payment-id'] ) ? absint( $_GET['payment-id'] ) : false; |
|
| 673 | + $payment_id = isset($_GET['payment-id']) ? absint($_GET['payment-id']) : false; |
|
| 674 | 674 | |
| 675 | - if ( ! $payment_id ) { |
|
| 675 | + if ( ! $payment_id) { |
|
| 676 | 676 | $session = give_get_purchase_session(); |
| 677 | - $payment_id = give_get_purchase_id_by_key( $session['purchase_key'] ); |
|
| 677 | + $payment_id = give_get_purchase_id_by_key($session['purchase_key']); |
|
| 678 | 678 | } |
| 679 | 679 | |
| 680 | - $payment = get_post( $payment_id ); |
|
| 680 | + $payment = get_post($payment_id); |
|
| 681 | 681 | |
| 682 | - if ( $payment && 'pending' == $payment->post_status ) { |
|
| 682 | + if ($payment && 'pending' == $payment->post_status) { |
|
| 683 | 683 | |
| 684 | 684 | // Payment is still pending so show processing indicator to fix the Race Condition |
| 685 | 685 | ob_start(); |
| 686 | 686 | |
| 687 | - give_get_template_part( 'payment', 'processing' ); |
|
| 687 | + give_get_template_part('payment', 'processing'); |
|
| 688 | 688 | |
| 689 | 689 | $content = ob_get_clean(); |
| 690 | 690 | |
@@ -694,7 +694,7 @@ discard block |
||
| 694 | 694 | |
| 695 | 695 | } |
| 696 | 696 | |
| 697 | -add_filter( 'give_payment_confirm_paypal', 'give_paypal_success_page_content' ); |
|
| 697 | +add_filter('give_payment_confirm_paypal', 'give_paypal_success_page_content'); |
|
| 698 | 698 | |
| 699 | 699 | /** |
| 700 | 700 | * Given a Payment ID, extract the transaction ID |
@@ -705,22 +705,22 @@ discard block |
||
| 705 | 705 | * |
| 706 | 706 | * @return string Transaction ID |
| 707 | 707 | */ |
| 708 | -function give_paypal_get_payment_transaction_id( $payment_id ) { |
|
| 708 | +function give_paypal_get_payment_transaction_id($payment_id) { |
|
| 709 | 709 | |
| 710 | 710 | $transaction_id = ''; |
| 711 | - $notes = give_get_payment_notes( $payment_id ); |
|
| 711 | + $notes = give_get_payment_notes($payment_id); |
|
| 712 | 712 | |
| 713 | - foreach ( $notes as $note ) { |
|
| 714 | - if ( preg_match( '/^PayPal Transaction ID: ([^\s]+)/', $note->comment_content, $match ) ) { |
|
| 713 | + foreach ($notes as $note) { |
|
| 714 | + if (preg_match('/^PayPal Transaction ID: ([^\s]+)/', $note->comment_content, $match)) { |
|
| 715 | 715 | $transaction_id = $match[1]; |
| 716 | 716 | continue; |
| 717 | 717 | } |
| 718 | 718 | } |
| 719 | 719 | |
| 720 | - return apply_filters( 'give_paypal_set_payment_transaction_id', $transaction_id, $payment_id ); |
|
| 720 | + return apply_filters('give_paypal_set_payment_transaction_id', $transaction_id, $payment_id); |
|
| 721 | 721 | } |
| 722 | 722 | |
| 723 | -add_filter( 'give_get_payment_transaction_id-paypal', 'give_paypal_get_payment_transaction_id', 10, 1 ); |
|
| 723 | +add_filter('give_get_payment_transaction_id-paypal', 'give_paypal_get_payment_transaction_id', 10, 1); |
|
| 724 | 724 | |
| 725 | 725 | /** |
| 726 | 726 | * Given a transaction ID, generate a link to the PayPal transaction ID details |
@@ -732,13 +732,13 @@ discard block |
||
| 732 | 732 | * |
| 733 | 733 | * @return string A link to the PayPal transaction details |
| 734 | 734 | */ |
| 735 | -function give_paypal_link_transaction_id( $transaction_id, $payment_id ) { |
|
| 735 | +function give_paypal_link_transaction_id($transaction_id, $payment_id) { |
|
| 736 | 736 | |
| 737 | 737 | $paypal_base_url = 'https://history.paypal.com/cgi-bin/webscr?cmd=_history-details-from-hub&id='; |
| 738 | - $transaction_url = '<a href="' . esc_url( $paypal_base_url . $transaction_id ) . '" target="_blank">' . $transaction_id . '</a>'; |
|
| 738 | + $transaction_url = '<a href="'.esc_url($paypal_base_url.$transaction_id).'" target="_blank">'.$transaction_id.'</a>'; |
|
| 739 | 739 | |
| 740 | - return apply_filters( 'give_paypal_link_payment_details_transaction_id', $transaction_url ); |
|
| 740 | + return apply_filters('give_paypal_link_payment_details_transaction_id', $transaction_url); |
|
| 741 | 741 | |
| 742 | 742 | } |
| 743 | 743 | |
| 744 | -add_filter( 'give_payment_details_transaction_id-paypal', 'give_paypal_link_transaction_id', 10, 2 ); |
|
| 744 | +add_filter('give_payment_details_transaction_id-paypal', 'give_paypal_link_transaction_id', 10, 2); |
|
@@ -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 | |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | * @since 1.0 |
| 21 | 21 | * @return void |
| 22 | 22 | */ |
| 23 | -add_action( 'give_manual_cc_form', '__return_false' ); |
|
| 23 | +add_action('give_manual_cc_form', '__return_false'); |
|
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | 26 | * Processes the purchase data and uses the Manual Payment gateway to record |
@@ -32,17 +32,17 @@ discard block |
||
| 32 | 32 | * |
| 33 | 33 | * @return void |
| 34 | 34 | */ |
| 35 | -function give_manual_payment( $purchase_data ) { |
|
| 35 | +function give_manual_payment($purchase_data) { |
|
| 36 | 36 | |
| 37 | - if ( ! wp_verify_nonce( $purchase_data['gateway_nonce'], 'give-gateway' ) ) { |
|
| 38 | - wp_die( esc_html__( 'Nonce verification has failed', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 37 | + if ( ! wp_verify_nonce($purchase_data['gateway_nonce'], 'give-gateway')) { |
|
| 38 | + wp_die(esc_html__('Nonce verification has failed', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | //Create payment_data array |
| 42 | 42 | $payment_data = array( |
| 43 | 43 | 'price' => $purchase_data['price'], |
| 44 | 44 | 'give_form_title' => $purchase_data['post_data']['give-form-title'], |
| 45 | - 'give_form_id' => intval( $purchase_data['post_data']['give-form-id'] ), |
|
| 45 | + 'give_form_id' => intval($purchase_data['post_data']['give-form-id']), |
|
| 46 | 46 | 'give_price_id' => isset($purchase_data['post_data']['give-price-id']) ? $purchase_data['post_data']['give-price-id'] : '', |
| 47 | 47 | 'date' => $purchase_data['date'], |
| 48 | 48 | 'user_email' => $purchase_data['user_email'], |
@@ -52,24 +52,24 @@ discard block |
||
| 52 | 52 | 'status' => 'pending' |
| 53 | 53 | ); |
| 54 | 54 | // Record the pending payment |
| 55 | - $payment = give_insert_payment( $payment_data ); |
|
| 55 | + $payment = give_insert_payment($payment_data); |
|
| 56 | 56 | |
| 57 | - if ( $payment ) { |
|
| 58 | - give_update_payment_status( $payment, 'publish' ); |
|
| 57 | + if ($payment) { |
|
| 58 | + give_update_payment_status($payment, 'publish'); |
|
| 59 | 59 | give_send_to_success_page(); |
| 60 | 60 | } else { |
| 61 | 61 | give_record_gateway_error( |
| 62 | - esc_html__( 'Payment Error', 'give' ), |
|
| 62 | + esc_html__('Payment Error', 'give'), |
|
| 63 | 63 | sprintf( |
| 64 | 64 | /* translators: %s: payment data */ |
| 65 | - esc_html__( 'The payment creation failed while processing a manual (free or test) donation. Payment data: %s', 'give' ), |
|
| 66 | - json_encode( $payment_data ) |
|
| 65 | + esc_html__('The payment creation failed while processing a manual (free or test) donation. Payment data: %s', 'give'), |
|
| 66 | + json_encode($payment_data) |
|
| 67 | 67 | ), |
| 68 | 68 | $payment |
| 69 | 69 | ); |
| 70 | 70 | // If errors are present, send the user back to the purchase page so they can be corrected |
| 71 | - give_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['give-gateway'] ); |
|
| 71 | + give_send_back_to_checkout('?payment-mode='.$purchase_data['post_data']['give-gateway']); |
|
| 72 | 72 | } |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | -add_action( 'give_gateway_manual', 'give_manual_payment' ); |
|
| 75 | +add_action('give_gateway_manual', 'give_manual_payment'); |
|
@@ -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 | |
@@ -24,9 +24,9 @@ discard block |
||
| 24 | 24 | function give_is_test_mode() { |
| 25 | 25 | global $give_options; |
| 26 | 26 | |
| 27 | - $ret = ! empty( $give_options['test_mode'] ); |
|
| 27 | + $ret = ! empty($give_options['test_mode']); |
|
| 28 | 28 | |
| 29 | - return (bool) apply_filters( 'give_is_test_mode', $ret ); |
|
| 29 | + return (bool) apply_filters('give_is_test_mode', $ret); |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | /** |
@@ -37,9 +37,9 @@ discard block |
||
| 37 | 37 | */ |
| 38 | 38 | function give_get_currency() { |
| 39 | 39 | global $give_options; |
| 40 | - $currency = isset( $give_options['currency'] ) ? $give_options['currency'] : 'USD'; |
|
| 40 | + $currency = isset($give_options['currency']) ? $give_options['currency'] : 'USD'; |
|
| 41 | 41 | |
| 42 | - return apply_filters( 'give_currency', $currency ); |
|
| 42 | + return apply_filters('give_currency', $currency); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | /** |
@@ -51,9 +51,9 @@ discard block |
||
| 51 | 51 | */ |
| 52 | 52 | function give_get_currency_position() { |
| 53 | 53 | global $give_options; |
| 54 | - $currency_pos = isset( $give_options['currency_position'] ) ? $give_options['currency_position'] : 'before'; |
|
| 54 | + $currency_pos = isset($give_options['currency_position']) ? $give_options['currency_position'] : 'before'; |
|
| 55 | 55 | |
| 56 | - return apply_filters( 'give_currency_position', $currency_pos ); |
|
| 56 | + return apply_filters('give_currency_position', $currency_pos); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | |
@@ -66,39 +66,39 @@ discard block |
||
| 66 | 66 | |
| 67 | 67 | function give_get_currencies() { |
| 68 | 68 | $currencies = array( |
| 69 | - 'USD' => esc_html__( 'US Dollars ($)', 'give' ), |
|
| 70 | - 'EUR' => esc_html__( 'Euros (€)', 'give' ), |
|
| 71 | - 'GBP' => esc_html__( 'Pounds Sterling (£)', 'give' ), |
|
| 72 | - 'AUD' => esc_html__( 'Australian Dollars ($)', 'give' ), |
|
| 73 | - 'BRL' => esc_html__( 'Brazilian Real (R$)', 'give' ), |
|
| 74 | - 'CAD' => esc_html__( 'Canadian Dollars ($)', 'give' ), |
|
| 75 | - 'CZK' => esc_html__( 'Czech Koruna (Kč)', 'give' ), |
|
| 76 | - 'DKK' => esc_html__( 'Danish Krone (kr)', 'give' ), |
|
| 77 | - 'HKD' => esc_html__( 'Hong Kong Dollar ($)', 'give' ), |
|
| 78 | - 'HUF' => esc_html__( 'Hungarian Forint (Ft)', 'give' ), |
|
| 79 | - 'ILS' => esc_html__( 'Israeli Shekel (₪)', 'give' ), |
|
| 80 | - 'JPY' => esc_html__( 'Japanese Yen (¥)', 'give' ), |
|
| 81 | - 'MYR' => esc_html__( 'Malaysian Ringgits (RM)', 'give' ), |
|
| 82 | - 'MXN' => esc_html__( 'Mexican Peso ($)', 'give' ), |
|
| 83 | - 'MAD' => esc_html__( 'Moroccan Dirham (.د.م)', 'give' ), |
|
| 84 | - 'NZD' => esc_html__( 'New Zealand Dollar ($)', 'give' ), |
|
| 85 | - 'NOK' => esc_html__( 'Norwegian Krone (Kr.)', 'give' ), |
|
| 86 | - 'PHP' => esc_html__( 'Philippine Pesos (₱)', 'give' ), |
|
| 87 | - 'PLN' => esc_html__( 'Polish Zloty (zł)', 'give' ), |
|
| 88 | - 'SGD' => esc_html__( 'Singapore Dollar ($)', 'give' ), |
|
| 89 | - 'KRW' => esc_html__( 'South Korean Won (₩)', 'give' ), |
|
| 90 | - 'ZAR' => esc_html__( 'South African Rand (R)', 'give' ), |
|
| 91 | - 'SEK' => esc_html__( 'Swedish Krona (kr)', 'give' ), |
|
| 92 | - 'CHF' => esc_html__( 'Swiss Franc (CHF)', 'give' ), |
|
| 93 | - 'TWD' => esc_html__( 'Taiwan New Dollars (NT$)', 'give' ), |
|
| 94 | - 'THB' => esc_html__( 'Thai Baht (฿)', 'give' ), |
|
| 95 | - 'INR' => esc_html__( 'Indian Rupee (₹)', 'give' ), |
|
| 96 | - 'TRY' => esc_html__( 'Turkish Lira (₺)', 'give' ), |
|
| 97 | - 'RIAL' => esc_html__( 'Iranian Rial (﷼)', 'give' ), |
|
| 98 | - 'RUB' => esc_html__( 'Russian Rubles (руб)', 'give' ) |
|
| 69 | + 'USD' => esc_html__('US Dollars ($)', 'give'), |
|
| 70 | + 'EUR' => esc_html__('Euros (€)', 'give'), |
|
| 71 | + 'GBP' => esc_html__('Pounds Sterling (£)', 'give'), |
|
| 72 | + 'AUD' => esc_html__('Australian Dollars ($)', 'give'), |
|
| 73 | + 'BRL' => esc_html__('Brazilian Real (R$)', 'give'), |
|
| 74 | + 'CAD' => esc_html__('Canadian Dollars ($)', 'give'), |
|
| 75 | + 'CZK' => esc_html__('Czech Koruna (Kč)', 'give'), |
|
| 76 | + 'DKK' => esc_html__('Danish Krone (kr)', 'give'), |
|
| 77 | + 'HKD' => esc_html__('Hong Kong Dollar ($)', 'give'), |
|
| 78 | + 'HUF' => esc_html__('Hungarian Forint (Ft)', 'give'), |
|
| 79 | + 'ILS' => esc_html__('Israeli Shekel (₪)', 'give'), |
|
| 80 | + 'JPY' => esc_html__('Japanese Yen (¥)', 'give'), |
|
| 81 | + 'MYR' => esc_html__('Malaysian Ringgits (RM)', 'give'), |
|
| 82 | + 'MXN' => esc_html__('Mexican Peso ($)', 'give'), |
|
| 83 | + 'MAD' => esc_html__('Moroccan Dirham (.د.م)', 'give'), |
|
| 84 | + 'NZD' => esc_html__('New Zealand Dollar ($)', 'give'), |
|
| 85 | + 'NOK' => esc_html__('Norwegian Krone (Kr.)', 'give'), |
|
| 86 | + 'PHP' => esc_html__('Philippine Pesos (₱)', 'give'), |
|
| 87 | + 'PLN' => esc_html__('Polish Zloty (zł)', 'give'), |
|
| 88 | + 'SGD' => esc_html__('Singapore Dollar ($)', 'give'), |
|
| 89 | + 'KRW' => esc_html__('South Korean Won (₩)', 'give'), |
|
| 90 | + 'ZAR' => esc_html__('South African Rand (R)', 'give'), |
|
| 91 | + 'SEK' => esc_html__('Swedish Krona (kr)', 'give'), |
|
| 92 | + 'CHF' => esc_html__('Swiss Franc (CHF)', 'give'), |
|
| 93 | + 'TWD' => esc_html__('Taiwan New Dollars (NT$)', 'give'), |
|
| 94 | + 'THB' => esc_html__('Thai Baht (฿)', 'give'), |
|
| 95 | + 'INR' => esc_html__('Indian Rupee (₹)', 'give'), |
|
| 96 | + 'TRY' => esc_html__('Turkish Lira (₺)', 'give'), |
|
| 97 | + 'RIAL' => esc_html__('Iranian Rial (﷼)', 'give'), |
|
| 98 | + 'RUB' => esc_html__('Russian Rubles (руб)', 'give') |
|
| 99 | 99 | ); |
| 100 | 100 | |
| 101 | - return apply_filters( 'give_currencies', $currencies ); |
|
| 101 | + return apply_filters('give_currencies', $currencies); |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | |
@@ -113,12 +113,12 @@ discard block |
||
| 113 | 113 | * |
| 114 | 114 | * @return string The symbol to use for the currency |
| 115 | 115 | */ |
| 116 | -function give_currency_symbol( $currency = '' ) { |
|
| 116 | +function give_currency_symbol($currency = '') { |
|
| 117 | 117 | |
| 118 | - if ( empty( $currency ) ) { |
|
| 118 | + if (empty($currency)) { |
|
| 119 | 119 | $currency = give_get_currency(); |
| 120 | 120 | } |
| 121 | - switch ( $currency ) : |
|
| 121 | + switch ($currency) : |
|
| 122 | 122 | case 'GBP' : |
| 123 | 123 | $symbol = '£'; |
| 124 | 124 | break; |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | endswitch; |
| 198 | 198 | |
| 199 | 199 | |
| 200 | - return apply_filters( 'give_currency_symbol', $symbol, $currency ); |
|
| 200 | + return apply_filters('give_currency_symbol', $symbol, $currency); |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | |
@@ -209,13 +209,13 @@ discard block |
||
| 209 | 209 | */ |
| 210 | 210 | function give_get_current_page_url() { |
| 211 | 211 | |
| 212 | - if ( is_front_page() ) { |
|
| 213 | - $current_url = home_url( '/' ); |
|
| 212 | + if (is_front_page()) { |
|
| 213 | + $current_url = home_url('/'); |
|
| 214 | 214 | } else { |
| 215 | - $current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . untrailingslashit( $_SERVER['REQUEST_URI'] ) ); |
|
| 215 | + $current_url = set_url_scheme('http://'.$_SERVER['HTTP_HOST'].untrailingslashit($_SERVER['REQUEST_URI'])); |
|
| 216 | 216 | } |
| 217 | 217 | |
| 218 | - return apply_filters( 'give_get_current_page_url', esc_url( $current_url ) ); |
|
| 218 | + return apply_filters('give_get_current_page_url', esc_url($current_url)); |
|
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | |
@@ -236,15 +236,15 @@ discard block |
||
| 236 | 236 | */ |
| 237 | 237 | $gateways = give_get_enabled_payment_gateways(); |
| 238 | 238 | |
| 239 | - if ( count( $gateways ) == 1 && ! isset( $gateways['paypal'] ) && ! isset( $gateways['manual'] ) ) { |
|
| 239 | + if (count($gateways) == 1 && ! isset($gateways['paypal']) && ! isset($gateways['manual'])) { |
|
| 240 | 240 | $ret = true; |
| 241 | - } else if ( count( $gateways ) == 1 ) { |
|
| 241 | + } else if (count($gateways) == 1) { |
|
| 242 | 242 | $ret = false; |
| 243 | - } else if ( count( $gateways ) == 2 && isset( $gateways['paypal'] ) && isset( $gateways['manual'] ) ) { |
|
| 243 | + } else if (count($gateways) == 2 && isset($gateways['paypal']) && isset($gateways['manual'])) { |
|
| 244 | 244 | $ret = false; |
| 245 | 245 | } |
| 246 | 246 | |
| 247 | - return (bool) apply_filters( 'give_verify_credit_cards', $ret ); |
|
| 247 | + return (bool) apply_filters('give_verify_credit_cards', $ret); |
|
| 248 | 248 | } |
| 249 | 249 | |
| 250 | 250 | /** |
@@ -256,26 +256,26 @@ discard block |
||
| 256 | 256 | function give_get_timezone_id() { |
| 257 | 257 | |
| 258 | 258 | // if site timezone string exists, return it |
| 259 | - if ( $timezone = get_option( 'timezone_string' ) ) { |
|
| 259 | + if ($timezone = get_option('timezone_string')) { |
|
| 260 | 260 | return $timezone; |
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | // get UTC offset, if it isn't set return UTC |
| 264 | - if ( ! ( $utc_offset = 3600 * get_option( 'gmt_offset', 0 ) ) ) { |
|
| 264 | + if ( ! ($utc_offset = 3600 * get_option('gmt_offset', 0))) { |
|
| 265 | 265 | return 'UTC'; |
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | // attempt to guess the timezone string from the UTC offset |
| 269 | - $timezone = timezone_name_from_abbr( '', $utc_offset ); |
|
| 269 | + $timezone = timezone_name_from_abbr('', $utc_offset); |
|
| 270 | 270 | |
| 271 | 271 | // last try, guess timezone string manually |
| 272 | - if ( $timezone === false ) { |
|
| 272 | + if ($timezone === false) { |
|
| 273 | 273 | |
| 274 | - $is_dst = date( 'I' ); |
|
| 274 | + $is_dst = date('I'); |
|
| 275 | 275 | |
| 276 | - foreach ( timezone_abbreviations_list() as $abbr ) { |
|
| 277 | - foreach ( $abbr as $city ) { |
|
| 278 | - if ( $city['dst'] == $is_dst && $city['offset'] == $utc_offset ) { |
|
| 276 | + foreach (timezone_abbreviations_list() as $abbr) { |
|
| 277 | + foreach ($abbr as $city) { |
|
| 278 | + if ($city['dst'] == $is_dst && $city['offset'] == $utc_offset) { |
|
| 279 | 279 | return $city['timezone_id']; |
| 280 | 280 | } |
| 281 | 281 | } |
@@ -299,17 +299,17 @@ discard block |
||
| 299 | 299 | |
| 300 | 300 | $ip = '127.0.0.1'; |
| 301 | 301 | |
| 302 | - if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) { |
|
| 302 | + if ( ! empty($_SERVER['HTTP_CLIENT_IP'])) { |
|
| 303 | 303 | //check ip from share internet |
| 304 | 304 | $ip = $_SERVER['HTTP_CLIENT_IP']; |
| 305 | - } elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) { |
|
| 305 | + } elseif ( ! empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
|
| 306 | 306 | //to check ip is pass from proxy |
| 307 | 307 | $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; |
| 308 | - } elseif ( ! empty( $_SERVER['REMOTE_ADDR'] ) ) { |
|
| 308 | + } elseif ( ! empty($_SERVER['REMOTE_ADDR'])) { |
|
| 309 | 309 | $ip = $_SERVER['REMOTE_ADDR']; |
| 310 | 310 | } |
| 311 | 311 | |
| 312 | - return apply_filters( 'give_get_ip', $ip ); |
|
| 312 | + return apply_filters('give_get_ip', $ip); |
|
| 313 | 313 | } |
| 314 | 314 | |
| 315 | 315 | |
@@ -324,9 +324,9 @@ discard block |
||
| 324 | 324 | * |
| 325 | 325 | * @uses Give()->session->set() |
| 326 | 326 | */ |
| 327 | -function give_set_purchase_session( $purchase_data = array() ) { |
|
| 328 | - Give()->session->set( 'give_purchase', $purchase_data ); |
|
| 329 | - Give()->session->set( 'give_email', $purchase_data['user_email'] ); |
|
| 327 | +function give_set_purchase_session($purchase_data = array()) { |
|
| 328 | + Give()->session->set('give_purchase', $purchase_data); |
|
| 329 | + Give()->session->set('give_email', $purchase_data['user_email']); |
|
| 330 | 330 | } |
| 331 | 331 | |
| 332 | 332 | /** |
@@ -340,7 +340,7 @@ discard block |
||
| 340 | 340 | * @return mixed array | false |
| 341 | 341 | */ |
| 342 | 342 | function give_get_purchase_session() { |
| 343 | - return Give()->session->get( 'give_purchase' ); |
|
| 343 | + return Give()->session->get('give_purchase'); |
|
| 344 | 344 | } |
| 345 | 345 | |
| 346 | 346 | /** |
@@ -355,14 +355,14 @@ discard block |
||
| 355 | 355 | * |
| 356 | 356 | * @return string |
| 357 | 357 | */ |
| 358 | -function give_get_purchase_summary( $purchase_data, $email = true ) { |
|
| 358 | +function give_get_purchase_summary($purchase_data, $email = true) { |
|
| 359 | 359 | $summary = ''; |
| 360 | 360 | |
| 361 | - if ( $email ) { |
|
| 362 | - $summary .= $purchase_data['user_email'] . ' - '; |
|
| 361 | + if ($email) { |
|
| 362 | + $summary .= $purchase_data['user_email'].' - '; |
|
| 363 | 363 | } |
| 364 | 364 | |
| 365 | - $summary .= get_the_title( $purchase_data['post_data']['give-form-id'] ); |
|
| 365 | + $summary .= get_the_title($purchase_data['post_data']['give-form-id']); |
|
| 366 | 366 | |
| 367 | 367 | return $summary; |
| 368 | 368 | } |
@@ -379,31 +379,31 @@ discard block |
||
| 379 | 379 | function give_get_host() { |
| 380 | 380 | $host = false; |
| 381 | 381 | |
| 382 | - if ( defined( 'WPE_APIKEY' ) ) { |
|
| 382 | + if (defined('WPE_APIKEY')) { |
|
| 383 | 383 | $host = 'WP Engine'; |
| 384 | - } elseif ( defined( 'PAGELYBIN' ) ) { |
|
| 384 | + } elseif (defined('PAGELYBIN')) { |
|
| 385 | 385 | $host = 'Pagely'; |
| 386 | - } elseif ( DB_HOST == 'localhost:/tmp/mysql5.sock' ) { |
|
| 386 | + } elseif (DB_HOST == 'localhost:/tmp/mysql5.sock') { |
|
| 387 | 387 | $host = 'ICDSoft'; |
| 388 | - } elseif ( DB_HOST == 'mysqlv5' ) { |
|
| 388 | + } elseif (DB_HOST == 'mysqlv5') { |
|
| 389 | 389 | $host = 'NetworkSolutions'; |
| 390 | - } elseif ( strpos( DB_HOST, 'ipagemysql.com' ) !== false ) { |
|
| 390 | + } elseif (strpos(DB_HOST, 'ipagemysql.com') !== false) { |
|
| 391 | 391 | $host = 'iPage'; |
| 392 | - } elseif ( strpos( DB_HOST, 'ipowermysql.com' ) !== false ) { |
|
| 392 | + } elseif (strpos(DB_HOST, 'ipowermysql.com') !== false) { |
|
| 393 | 393 | $host = 'IPower'; |
| 394 | - } elseif ( strpos( DB_HOST, '.gridserver.com' ) !== false ) { |
|
| 394 | + } elseif (strpos(DB_HOST, '.gridserver.com') !== false) { |
|
| 395 | 395 | $host = 'MediaTemple Grid'; |
| 396 | - } elseif ( strpos( DB_HOST, '.pair.com' ) !== false ) { |
|
| 396 | + } elseif (strpos(DB_HOST, '.pair.com') !== false) { |
|
| 397 | 397 | $host = 'pair Networks'; |
| 398 | - } elseif ( strpos( DB_HOST, '.stabletransit.com' ) !== false ) { |
|
| 398 | + } elseif (strpos(DB_HOST, '.stabletransit.com') !== false) { |
|
| 399 | 399 | $host = 'Rackspace Cloud'; |
| 400 | - } elseif ( strpos( DB_HOST, '.sysfix.eu' ) !== false ) { |
|
| 400 | + } elseif (strpos(DB_HOST, '.sysfix.eu') !== false) { |
|
| 401 | 401 | $host = 'SysFix.eu Power Hosting'; |
| 402 | - } elseif ( strpos( $_SERVER['SERVER_NAME'], 'Flywheel' ) !== false ) { |
|
| 402 | + } elseif (strpos($_SERVER['SERVER_NAME'], 'Flywheel') !== false) { |
|
| 403 | 403 | $host = 'Flywheel'; |
| 404 | 404 | } else { |
| 405 | 405 | // Adding a general fallback for data gathering |
| 406 | - $host = 'DBH: ' . DB_HOST . ', SRV: ' . $_SERVER['SERVER_NAME']; |
|
| 406 | + $host = 'DBH: '.DB_HOST.', SRV: '.$_SERVER['SERVER_NAME']; |
|
| 407 | 407 | } |
| 408 | 408 | |
| 409 | 409 | return $host; |
@@ -419,67 +419,67 @@ discard block |
||
| 419 | 419 | * |
| 420 | 420 | * @return bool true if host matches, false if not |
| 421 | 421 | */ |
| 422 | -function give_is_host( $host = false ) { |
|
| 422 | +function give_is_host($host = false) { |
|
| 423 | 423 | |
| 424 | 424 | $return = false; |
| 425 | 425 | |
| 426 | - if ( $host ) { |
|
| 427 | - $host = str_replace( ' ', '', strtolower( $host ) ); |
|
| 426 | + if ($host) { |
|
| 427 | + $host = str_replace(' ', '', strtolower($host)); |
|
| 428 | 428 | |
| 429 | - switch ( $host ) { |
|
| 429 | + switch ($host) { |
|
| 430 | 430 | case 'wpengine': |
| 431 | - if ( defined( 'WPE_APIKEY' ) ) { |
|
| 431 | + if (defined('WPE_APIKEY')) { |
|
| 432 | 432 | $return = true; |
| 433 | 433 | } |
| 434 | 434 | break; |
| 435 | 435 | case 'pagely': |
| 436 | - if ( defined( 'PAGELYBIN' ) ) { |
|
| 436 | + if (defined('PAGELYBIN')) { |
|
| 437 | 437 | $return = true; |
| 438 | 438 | } |
| 439 | 439 | break; |
| 440 | 440 | case 'icdsoft': |
| 441 | - if ( DB_HOST == 'localhost:/tmp/mysql5.sock' ) { |
|
| 441 | + if (DB_HOST == 'localhost:/tmp/mysql5.sock') { |
|
| 442 | 442 | $return = true; |
| 443 | 443 | } |
| 444 | 444 | break; |
| 445 | 445 | case 'networksolutions': |
| 446 | - if ( DB_HOST == 'mysqlv5' ) { |
|
| 446 | + if (DB_HOST == 'mysqlv5') { |
|
| 447 | 447 | $return = true; |
| 448 | 448 | } |
| 449 | 449 | break; |
| 450 | 450 | case 'ipage': |
| 451 | - if ( strpos( DB_HOST, 'ipagemysql.com' ) !== false ) { |
|
| 451 | + if (strpos(DB_HOST, 'ipagemysql.com') !== false) { |
|
| 452 | 452 | $return = true; |
| 453 | 453 | } |
| 454 | 454 | break; |
| 455 | 455 | case 'ipower': |
| 456 | - if ( strpos( DB_HOST, 'ipowermysql.com' ) !== false ) { |
|
| 456 | + if (strpos(DB_HOST, 'ipowermysql.com') !== false) { |
|
| 457 | 457 | $return = true; |
| 458 | 458 | } |
| 459 | 459 | break; |
| 460 | 460 | case 'mediatemplegrid': |
| 461 | - if ( strpos( DB_HOST, '.gridserver.com' ) !== false ) { |
|
| 461 | + if (strpos(DB_HOST, '.gridserver.com') !== false) { |
|
| 462 | 462 | $return = true; |
| 463 | 463 | } |
| 464 | 464 | break; |
| 465 | 465 | case 'pairnetworks': |
| 466 | - if ( strpos( DB_HOST, '.pair.com' ) !== false ) { |
|
| 466 | + if (strpos(DB_HOST, '.pair.com') !== false) { |
|
| 467 | 467 | $return = true; |
| 468 | 468 | } |
| 469 | 469 | break; |
| 470 | 470 | case 'rackspacecloud': |
| 471 | - if ( strpos( DB_HOST, '.stabletransit.com' ) !== false ) { |
|
| 471 | + if (strpos(DB_HOST, '.stabletransit.com') !== false) { |
|
| 472 | 472 | $return = true; |
| 473 | 473 | } |
| 474 | 474 | break; |
| 475 | 475 | case 'sysfix.eu': |
| 476 | 476 | case 'sysfix.eupowerhosting': |
| 477 | - if ( strpos( DB_HOST, '.sysfix.eu' ) !== false ) { |
|
| 477 | + if (strpos(DB_HOST, '.sysfix.eu') !== false) { |
|
| 478 | 478 | $return = true; |
| 479 | 479 | } |
| 480 | 480 | break; |
| 481 | 481 | case 'flywheel': |
| 482 | - if ( strpos( $_SERVER['SERVER_NAME'], 'Flywheel' ) !== false ) { |
|
| 482 | + if (strpos($_SERVER['SERVER_NAME'], 'Flywheel') !== false) { |
|
| 483 | 483 | $return = true; |
| 484 | 484 | } |
| 485 | 485 | break; |
@@ -512,20 +512,20 @@ discard block |
||
| 512 | 512 | * @param string $replacement Optional. The function that should have been called |
| 513 | 513 | * @param array $backtrace Optional. Contains stack backtrace of deprecated function |
| 514 | 514 | */ |
| 515 | -function _give_deprecated_function( $function, $version, $replacement = null, $backtrace = null ) { |
|
| 516 | - do_action( 'give_deprecated_function_run', $function, $replacement, $version ); |
|
| 515 | +function _give_deprecated_function($function, $version, $replacement = null, $backtrace = null) { |
|
| 516 | + do_action('give_deprecated_function_run', $function, $replacement, $version); |
|
| 517 | 517 | |
| 518 | - $show_errors = current_user_can( 'manage_options' ); |
|
| 518 | + $show_errors = current_user_can('manage_options'); |
|
| 519 | 519 | |
| 520 | 520 | // Allow plugin to filter the output error trigger |
| 521 | - if ( WP_DEBUG && apply_filters( 'give_deprecated_function_trigger_error', $show_errors ) ) { |
|
| 522 | - if ( ! is_null( $replacement ) ) { |
|
| 523 | - trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since Give version %2$s! Use %3$s instead.', 'give' ), $function, $version, $replacement ) ); |
|
| 524 | - trigger_error( print_r( $backtrace, 1 ) ); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine. |
|
| 521 | + if (WP_DEBUG && apply_filters('give_deprecated_function_trigger_error', $show_errors)) { |
|
| 522 | + if ( ! is_null($replacement)) { |
|
| 523 | + trigger_error(sprintf(__('%1$s is <strong>deprecated</strong> since Give version %2$s! Use %3$s instead.', 'give'), $function, $version, $replacement)); |
|
| 524 | + trigger_error(print_r($backtrace, 1)); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine. |
|
| 525 | 525 | // Alternatively we could dump this to a file. |
| 526 | 526 | } else { |
| 527 | - trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since Give version %2$s with no alternative available.', 'give' ), $function, $version ) ); |
|
| 528 | - trigger_error( print_r( $backtrace, 1 ) );// Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine. |
|
| 527 | + trigger_error(sprintf(__('%1$s is <strong>deprecated</strong> since Give version %2$s with no alternative available.', 'give'), $function, $version)); |
|
| 528 | + trigger_error(print_r($backtrace, 1)); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine. |
|
| 529 | 529 | // Alternatively we could dump this to a file. |
| 530 | 530 | } |
| 531 | 531 | } |
@@ -539,8 +539,8 @@ discard block |
||
| 539 | 539 | * @return string $post_id |
| 540 | 540 | */ |
| 541 | 541 | function give_get_admin_post_id() { |
| 542 | - $post_id = isset( $_GET['post'] ) ? $_GET['post'] : null; |
|
| 543 | - if ( ! $post_id && isset( $_POST['post_id'] ) ) { |
|
| 542 | + $post_id = isset($_GET['post']) ? $_GET['post'] : null; |
|
| 543 | + if ( ! $post_id && isset($_POST['post_id'])) { |
|
| 544 | 544 | $post_id = $_POST['post_id']; |
| 545 | 545 | } |
| 546 | 546 | |
@@ -554,7 +554,7 @@ discard block |
||
| 554 | 554 | * @return string Arg separator output |
| 555 | 555 | */ |
| 556 | 556 | function give_get_php_arg_separator_output() { |
| 557 | - return ini_get( 'arg_separator.output' ); |
|
| 557 | + return ini_get('arg_separator.output'); |
|
| 558 | 558 | } |
| 559 | 559 | |
| 560 | 560 | |
@@ -569,10 +569,10 @@ discard block |
||
| 569 | 569 | * |
| 570 | 570 | * @return string Short month name |
| 571 | 571 | */ |
| 572 | -function give_month_num_to_name( $n ) { |
|
| 573 | - $timestamp = mktime( 0, 0, 0, $n, 1, 2005 ); |
|
| 572 | +function give_month_num_to_name($n) { |
|
| 573 | + $timestamp = mktime(0, 0, 0, $n, 1, 2005); |
|
| 574 | 574 | |
| 575 | - return date_i18n( "M", $timestamp ); |
|
| 575 | + return date_i18n("M", $timestamp); |
|
| 576 | 576 | } |
| 577 | 577 | |
| 578 | 578 | |
@@ -585,10 +585,10 @@ discard block |
||
| 585 | 585 | * |
| 586 | 586 | * @return bool Whether or not function is disabled. |
| 587 | 587 | */ |
| 588 | -function give_is_func_disabled( $function ) { |
|
| 589 | - $disabled = explode( ',', ini_get( 'disable_functions' ) ); |
|
| 588 | +function give_is_func_disabled($function) { |
|
| 589 | + $disabled = explode(',', ini_get('disable_functions')); |
|
| 590 | 590 | |
| 591 | - return in_array( $function, $disabled ); |
|
| 591 | + return in_array($function, $disabled); |
|
| 592 | 592 | } |
| 593 | 593 | |
| 594 | 594 | |
@@ -603,7 +603,7 @@ discard block |
||
| 603 | 603 | |
| 604 | 604 | <form action="//givewp.us3.list-manage.com/subscribe/post?u=3ccb75d68bda4381e2f45794c&id=12a081aa13" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate> |
| 605 | 605 | <div class="give-newsletter-confirmation"> |
| 606 | - <p><?php esc_html_e( 'Thanks for Subscribing!', 'give' ); ?> :)</p> |
|
| 606 | + <p><?php esc_html_e('Thanks for Subscribing!', 'give'); ?> :)</p> |
|
| 607 | 607 | </div> |
| 608 | 608 | |
| 609 | 609 | <table class="form-table give-newsletter-form"> |
@@ -699,7 +699,7 @@ discard block |
||
| 699 | 699 | * |
| 700 | 700 | * @return mixed |
| 701 | 701 | */ |
| 702 | -function give_svg_icons( $icon ) { |
|
| 702 | +function give_svg_icons($icon) { |
|
| 703 | 703 | |
| 704 | 704 | // Store your SVGs in an associative array |
| 705 | 705 | $svgs = array( |
@@ -711,7 +711,7 @@ discard block |
||
| 711 | 711 | ); |
| 712 | 712 | |
| 713 | 713 | // Return the chosen icon's SVG string |
| 714 | - return $svgs[ $icon ]; |
|
| 714 | + return $svgs[$icon]; |
|
| 715 | 715 | } |
| 716 | 716 | |
| 717 | 717 | /** |
@@ -723,15 +723,15 @@ discard block |
||
| 723 | 723 | * |
| 724 | 724 | * @return mixed |
| 725 | 725 | */ |
| 726 | -function modify_nav_menu_meta_box_object( $post_type ) { |
|
| 727 | - if ( isset( $post_type->name ) && $post_type->name == 'give_forms' ) { |
|
| 726 | +function modify_nav_menu_meta_box_object($post_type) { |
|
| 727 | + if (isset($post_type->name) && $post_type->name == 'give_forms') { |
|
| 728 | 728 | $post_type->labels->name = 'Donation Forms'; |
| 729 | 729 | } |
| 730 | 730 | |
| 731 | 731 | return $post_type; |
| 732 | 732 | } |
| 733 | 733 | |
| 734 | -add_filter( 'nav_menu_meta_box_object', 'modify_nav_menu_meta_box_object' ); |
|
| 734 | +add_filter('nav_menu_meta_box_object', 'modify_nav_menu_meta_box_object'); |
|
| 735 | 735 | |
| 736 | 736 | |
| 737 | 737 | /** |
@@ -744,7 +744,7 @@ discard block |
||
| 744 | 744 | * @license http://opensource.org/licenses/MIT MIT |
| 745 | 745 | */ |
| 746 | 746 | |
| 747 | -if ( ! function_exists( 'array_column' ) ) { |
|
| 747 | +if ( ! function_exists('array_column')) { |
|
| 748 | 748 | /** |
| 749 | 749 | * Returns the values from a single column of the input array, identified by |
| 750 | 750 | * the $columnKey. |
@@ -763,56 +763,56 @@ discard block |
||
| 763 | 763 | * |
| 764 | 764 | * @return array |
| 765 | 765 | */ |
| 766 | - function array_column( $input = null, $columnKey = null, $indexKey = null ) { |
|
| 766 | + function array_column($input = null, $columnKey = null, $indexKey = null) { |
|
| 767 | 767 | // Using func_get_args() in order to check for proper number of |
| 768 | 768 | // parameters and trigger errors exactly as the built-in array_column() |
| 769 | 769 | // does in PHP 5.5. |
| 770 | 770 | $argc = func_num_args(); |
| 771 | 771 | $params = func_get_args(); |
| 772 | 772 | |
| 773 | - if ( $argc < 2 ) { |
|
| 774 | - trigger_error( "array_column() expects at least 2 parameters, {$argc} given", E_USER_WARNING ); |
|
| 773 | + if ($argc < 2) { |
|
| 774 | + trigger_error("array_column() expects at least 2 parameters, {$argc} given", E_USER_WARNING); |
|
| 775 | 775 | |
| 776 | 776 | return null; |
| 777 | 777 | } |
| 778 | 778 | |
| 779 | - if ( ! is_array( $params[0] ) ) { |
|
| 779 | + if ( ! is_array($params[0])) { |
|
| 780 | 780 | trigger_error( |
| 781 | - 'array_column() expects parameter 1 to be array, ' . gettype( $params[0] ) . ' given', |
|
| 781 | + 'array_column() expects parameter 1 to be array, '.gettype($params[0]).' given', |
|
| 782 | 782 | E_USER_WARNING |
| 783 | 783 | ); |
| 784 | 784 | |
| 785 | 785 | return null; |
| 786 | 786 | } |
| 787 | 787 | |
| 788 | - if ( ! is_int( $params[1] ) |
|
| 789 | - && ! is_float( $params[1] ) |
|
| 790 | - && ! is_string( $params[1] ) |
|
| 788 | + if ( ! is_int($params[1]) |
|
| 789 | + && ! is_float($params[1]) |
|
| 790 | + && ! is_string($params[1]) |
|
| 791 | 791 | && $params[1] !== null |
| 792 | - && ! ( is_object( $params[1] ) && method_exists( $params[1], '__toString' ) ) |
|
| 792 | + && ! (is_object($params[1]) && method_exists($params[1], '__toString')) |
|
| 793 | 793 | ) { |
| 794 | - trigger_error( 'array_column(): The column key should be either a string or an integer', E_USER_WARNING ); |
|
| 794 | + trigger_error('array_column(): The column key should be either a string or an integer', E_USER_WARNING); |
|
| 795 | 795 | |
| 796 | 796 | return false; |
| 797 | 797 | } |
| 798 | 798 | |
| 799 | - if ( isset( $params[2] ) |
|
| 800 | - && ! is_int( $params[2] ) |
|
| 801 | - && ! is_float( $params[2] ) |
|
| 802 | - && ! is_string( $params[2] ) |
|
| 803 | - && ! ( is_object( $params[2] ) && method_exists( $params[2], '__toString' ) ) |
|
| 799 | + if (isset($params[2]) |
|
| 800 | + && ! is_int($params[2]) |
|
| 801 | + && ! is_float($params[2]) |
|
| 802 | + && ! is_string($params[2]) |
|
| 803 | + && ! (is_object($params[2]) && method_exists($params[2], '__toString')) |
|
| 804 | 804 | ) { |
| 805 | - trigger_error( 'array_column(): The index key should be either a string or an integer', E_USER_WARNING ); |
|
| 805 | + trigger_error('array_column(): The index key should be either a string or an integer', E_USER_WARNING); |
|
| 806 | 806 | |
| 807 | 807 | return false; |
| 808 | 808 | } |
| 809 | 809 | |
| 810 | 810 | $paramsInput = $params[0]; |
| 811 | - $paramsColumnKey = ( $params[1] !== null ) ? (string) $params[1] : null; |
|
| 811 | + $paramsColumnKey = ($params[1] !== null) ? (string) $params[1] : null; |
|
| 812 | 812 | |
| 813 | 813 | $paramsIndexKey = null; |
| 814 | - if ( isset( $params[2] ) ) { |
|
| 815 | - if ( is_float( $params[2] ) || is_int( $params[2] ) ) { |
|
| 814 | + if (isset($params[2])) { |
|
| 815 | + if (is_float($params[2]) || is_int($params[2])) { |
|
| 816 | 816 | $paramsIndexKey = (int) $params[2]; |
| 817 | 817 | } else { |
| 818 | 818 | $paramsIndexKey = (string) $params[2]; |
@@ -821,26 +821,26 @@ discard block |
||
| 821 | 821 | |
| 822 | 822 | $resultArray = array(); |
| 823 | 823 | |
| 824 | - foreach ( $paramsInput as $row ) { |
|
| 824 | + foreach ($paramsInput as $row) { |
|
| 825 | 825 | $key = $value = null; |
| 826 | 826 | $keySet = $valueSet = false; |
| 827 | 827 | |
| 828 | - if ( $paramsIndexKey !== null && array_key_exists( $paramsIndexKey, $row ) ) { |
|
| 828 | + if ($paramsIndexKey !== null && array_key_exists($paramsIndexKey, $row)) { |
|
| 829 | 829 | $keySet = true; |
| 830 | - $key = (string) $row[ $paramsIndexKey ]; |
|
| 830 | + $key = (string) $row[$paramsIndexKey]; |
|
| 831 | 831 | } |
| 832 | 832 | |
| 833 | - if ( $paramsColumnKey === null ) { |
|
| 833 | + if ($paramsColumnKey === null) { |
|
| 834 | 834 | $valueSet = true; |
| 835 | 835 | $value = $row; |
| 836 | - } elseif ( is_array( $row ) && array_key_exists( $paramsColumnKey, $row ) ) { |
|
| 836 | + } elseif (is_array($row) && array_key_exists($paramsColumnKey, $row)) { |
|
| 837 | 837 | $valueSet = true; |
| 838 | - $value = $row[ $paramsColumnKey ]; |
|
| 838 | + $value = $row[$paramsColumnKey]; |
|
| 839 | 839 | } |
| 840 | 840 | |
| 841 | - if ( $valueSet ) { |
|
| 842 | - if ( $keySet ) { |
|
| 843 | - $resultArray[ $key ] = $value; |
|
| 841 | + if ($valueSet) { |
|
| 842 | + if ($keySet) { |
|
| 843 | + $resultArray[$key] = $value; |
|
| 844 | 844 | } else { |
| 845 | 845 | $resultArray[] = $value; |
| 846 | 846 | } |
@@ -862,40 +862,40 @@ discard block |
||
| 862 | 862 | * |
| 863 | 863 | * @return bool Whether the receipt is visible or not. |
| 864 | 864 | */ |
| 865 | -function give_can_view_receipt( $payment_key = '' ) { |
|
| 865 | +function give_can_view_receipt($payment_key = '') { |
|
| 866 | 866 | |
| 867 | 867 | $return = false; |
| 868 | 868 | |
| 869 | - if ( empty( $payment_key ) ) { |
|
| 869 | + if (empty($payment_key)) { |
|
| 870 | 870 | return $return; |
| 871 | 871 | } |
| 872 | 872 | |
| 873 | 873 | global $give_receipt_args; |
| 874 | 874 | |
| 875 | - $give_receipt_args['id'] = give_get_purchase_id_by_key( $payment_key ); |
|
| 875 | + $give_receipt_args['id'] = give_get_purchase_id_by_key($payment_key); |
|
| 876 | 876 | |
| 877 | - $user_id = (int) give_get_payment_user_id( $give_receipt_args['id'] ); |
|
| 877 | + $user_id = (int) give_get_payment_user_id($give_receipt_args['id']); |
|
| 878 | 878 | |
| 879 | - $payment_meta = give_get_payment_meta( $give_receipt_args['id'] ); |
|
| 879 | + $payment_meta = give_get_payment_meta($give_receipt_args['id']); |
|
| 880 | 880 | |
| 881 | - if ( is_user_logged_in() ) { |
|
| 882 | - if ( $user_id === (int) get_current_user_id() ) { |
|
| 881 | + if (is_user_logged_in()) { |
|
| 882 | + if ($user_id === (int) get_current_user_id()) { |
|
| 883 | 883 | $return = true; |
| 884 | - } elseif ( wp_get_current_user()->user_email === give_get_payment_user_email( $give_receipt_args['id'] ) ) { |
|
| 884 | + } elseif (wp_get_current_user()->user_email === give_get_payment_user_email($give_receipt_args['id'])) { |
|
| 885 | 885 | $return = true; |
| 886 | - } elseif ( current_user_can( 'view_give_sensitive_data' ) ) { |
|
| 886 | + } elseif (current_user_can('view_give_sensitive_data')) { |
|
| 887 | 887 | $return = true; |
| 888 | 888 | } |
| 889 | 889 | } |
| 890 | 890 | |
| 891 | 891 | $session = give_get_purchase_session(); |
| 892 | - if ( ! empty( $session ) && ! is_user_logged_in() ) { |
|
| 893 | - if ( $session['purchase_key'] === $payment_meta['key'] ) { |
|
| 892 | + if ( ! empty($session) && ! is_user_logged_in()) { |
|
| 893 | + if ($session['purchase_key'] === $payment_meta['key']) { |
|
| 894 | 894 | $return = true; |
| 895 | 895 | } |
| 896 | 896 | } |
| 897 | 897 | |
| 898 | - return (bool) apply_filters( 'give_can_view_receipt', $return, $payment_key ); |
|
| 898 | + return (bool) apply_filters('give_can_view_receipt', $return, $payment_key); |
|
| 899 | 899 | |
| 900 | 900 | } |
| 901 | 901 | |
@@ -904,7 +904,7 @@ discard block |
||
| 904 | 904 | * |
| 905 | 905 | * @description: Fallback in case the calendar extension is not loaded in PHP; Only supports Gregorian calendar |
| 906 | 906 | */ |
| 907 | -if ( ! function_exists( 'cal_days_in_month' ) ) { |
|
| 907 | +if ( ! function_exists('cal_days_in_month')) { |
|
| 908 | 908 | /** |
| 909 | 909 | * cal_days_in_month |
| 910 | 910 | * |
@@ -914,7 +914,7 @@ discard block |
||
| 914 | 914 | * |
| 915 | 915 | * @return bool|string |
| 916 | 916 | */ |
| 917 | - function cal_days_in_month( $calendar, $month, $year ) { |
|
| 918 | - return date( 't', mktime( 0, 0, 0, $month, 1, $year ) ); |
|
| 917 | + function cal_days_in_month($calendar, $month, $year) { |
|
| 918 | + return date('t', mktime(0, 0, 0, $month, 1, $year)); |
|
| 919 | 919 | } |
| 920 | 920 | } |
@@ -337,7 +337,7 @@ discard block |
||
| 337 | 337 | * |
| 338 | 338 | * @since 1.0 |
| 339 | 339 | * @uses Give()->session->get() |
| 340 | - * @return mixed array | false |
|
| 340 | + * @return string array | false |
|
| 341 | 341 | */ |
| 342 | 342 | function give_get_purchase_session() { |
| 343 | 343 | return Give()->session->get( 'give_purchase' ); |
@@ -695,9 +695,9 @@ discard block |
||
| 695 | 695 | /** |
| 696 | 696 | * Create SVG library function |
| 697 | 697 | * |
| 698 | - * @param $icon |
|
| 698 | + * @param string $icon |
|
| 699 | 699 | * |
| 700 | - * @return mixed |
|
| 700 | + * @return string |
|
| 701 | 701 | */ |
| 702 | 702 | function give_svg_icons( $icon ) { |
| 703 | 703 | |
@@ -754,7 +754,7 @@ discard block |
||
| 754 | 754 | * |
| 755 | 755 | * @param array $input A multi-dimensional array (record set) from which to pull |
| 756 | 756 | * a column of values. |
| 757 | - * @param mixed $columnKey The column of values to return. This value may be the |
|
| 757 | + * @param string $columnKey The column of values to return. This value may be the |
|
| 758 | 758 | * integer key of the column you wish to retrieve, or it |
| 759 | 759 | * may be the string key name for an associative array. |
| 760 | 760 | * @param mixed $indexKey (Optional.) The column to use as the index/keys for |
@@ -908,7 +908,7 @@ discard block |
||
| 908 | 908 | /** |
| 909 | 909 | * cal_days_in_month |
| 910 | 910 | * |
| 911 | - * @param $calendar |
|
| 911 | + * @param integer $calendar |
|
| 912 | 912 | * @param $month |
| 913 | 913 | * @param $year |
| 914 | 914 | * |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | * @since 1.3.0 |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | -defined( 'ABSPATH' ) or exit; |
|
| 12 | +defined('ABSPATH') or exit; |
|
| 13 | 13 | |
| 14 | 14 | class Give_Shortcode_Profile_Editor extends Give_Shortcode_Generator { |
| 15 | 15 | |
@@ -18,9 +18,9 @@ discard block |
||
| 18 | 18 | */ |
| 19 | 19 | public function __construct() { |
| 20 | 20 | |
| 21 | - $this->shortcode['label'] = esc_html__( 'Profile Editor', 'give' ); |
|
| 21 | + $this->shortcode['label'] = esc_html__('Profile Editor', 'give'); |
|
| 22 | 22 | |
| 23 | - parent::__construct( 'give_profile_editor' ); |
|
| 23 | + parent::__construct('give_profile_editor'); |
|
| 24 | 24 | } |
| 25 | 25 | } |
| 26 | 26 | |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | * @since 1.3.0 |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | -defined( 'ABSPATH' ) or exit; |
|
| 12 | +defined('ABSPATH') or exit; |
|
| 13 | 13 | |
| 14 | 14 | class Give_Shortcode_Donation_Receipt extends Give_Shortcode_Generator { |
| 15 | 15 | |
@@ -18,10 +18,10 @@ discard block |
||
| 18 | 18 | */ |
| 19 | 19 | public function __construct() { |
| 20 | 20 | |
| 21 | - $this->shortcode['title'] = esc_html__( 'Donation Receipt', 'give' ); |
|
| 22 | - $this->shortcode['label'] = esc_html__( 'Donation Receipt', 'give' ); |
|
| 21 | + $this->shortcode['title'] = esc_html__('Donation Receipt', 'give'); |
|
| 22 | + $this->shortcode['label'] = esc_html__('Donation Receipt', 'give'); |
|
| 23 | 23 | |
| 24 | - parent::__construct( 'give_receipt' ); |
|
| 24 | + parent::__construct('give_receipt'); |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | /** |
@@ -34,60 +34,60 @@ discard block |
||
| 34 | 34 | return array( |
| 35 | 35 | array( |
| 36 | 36 | 'type' => 'container', |
| 37 | - 'html' => sprintf( '<p class="strong">%s</p>', esc_html__( 'Optional settings', 'give' ) ), |
|
| 37 | + 'html' => sprintf('<p class="strong">%s</p>', esc_html__('Optional settings', 'give')), |
|
| 38 | 38 | ), |
| 39 | 39 | array( |
| 40 | 40 | 'type' => 'listbox', |
| 41 | 41 | 'name' => 'price', |
| 42 | - 'label' => esc_html__( 'Show Donation Amount:', 'give' ), |
|
| 42 | + 'label' => esc_html__('Show Donation Amount:', 'give'), |
|
| 43 | 43 | 'options' => array( |
| 44 | - 'true' => esc_html__( 'Show', 'give' ), |
|
| 45 | - 'false' => esc_html__( 'Hide', 'give' ), |
|
| 44 | + 'true' => esc_html__('Show', 'give'), |
|
| 45 | + 'false' => esc_html__('Hide', 'give'), |
|
| 46 | 46 | ), |
| 47 | 47 | ), |
| 48 | 48 | array( |
| 49 | 49 | 'type' => 'listbox', |
| 50 | 50 | 'name' => 'donor', |
| 51 | - 'label' => esc_html__( 'Show Donor Name:', 'give' ), |
|
| 51 | + 'label' => esc_html__('Show Donor Name:', 'give'), |
|
| 52 | 52 | 'options' => array( |
| 53 | - 'true' => esc_html__( 'Show', 'give' ), |
|
| 54 | - 'false' => esc_html__( 'Hide', 'give' ), |
|
| 53 | + 'true' => esc_html__('Show', 'give'), |
|
| 54 | + 'false' => esc_html__('Hide', 'give'), |
|
| 55 | 55 | ), |
| 56 | 56 | ), |
| 57 | 57 | array( |
| 58 | 58 | 'type' => 'listbox', |
| 59 | 59 | 'name' => 'date', |
| 60 | - 'label' => esc_html__( 'Show Date:', 'give' ), |
|
| 60 | + 'label' => esc_html__('Show Date:', 'give'), |
|
| 61 | 61 | 'options' => array( |
| 62 | - 'true' => esc_html__( 'Show', 'give' ), |
|
| 63 | - 'false' => esc_html__( 'Hide', 'give' ), |
|
| 62 | + 'true' => esc_html__('Show', 'give'), |
|
| 63 | + 'false' => esc_html__('Hide', 'give'), |
|
| 64 | 64 | ), |
| 65 | 65 | ), |
| 66 | 66 | array( |
| 67 | 67 | 'type' => 'listbox', |
| 68 | 68 | 'name' => 'payment_key', |
| 69 | - 'label' => esc_html__( 'Show Payment Key:', 'give' ), |
|
| 69 | + 'label' => esc_html__('Show Payment Key:', 'give'), |
|
| 70 | 70 | 'options' => array( |
| 71 | - 'true' => esc_html__( 'Show', 'give' ), |
|
| 72 | - 'false' => esc_html__( 'Hide', 'give' ), |
|
| 71 | + 'true' => esc_html__('Show', 'give'), |
|
| 72 | + 'false' => esc_html__('Hide', 'give'), |
|
| 73 | 73 | ), |
| 74 | 74 | ), |
| 75 | 75 | array( |
| 76 | 76 | 'type' => 'listbox', |
| 77 | 77 | 'name' => 'payment_method', |
| 78 | - 'label' => esc_html__( 'Show Payment Method:', 'give' ), |
|
| 78 | + 'label' => esc_html__('Show Payment Method:', 'give'), |
|
| 79 | 79 | 'options' => array( |
| 80 | - 'true' => esc_html__( 'Show', 'give' ), |
|
| 81 | - 'false' => esc_html__( 'Hide', 'give' ), |
|
| 80 | + 'true' => esc_html__('Show', 'give'), |
|
| 81 | + 'false' => esc_html__('Hide', 'give'), |
|
| 82 | 82 | ), |
| 83 | 83 | ), |
| 84 | 84 | array( |
| 85 | 85 | 'type' => 'listbox', |
| 86 | 86 | 'name' => 'payment_id', |
| 87 | - 'label' => esc_html__( 'Show Payment ID:', 'give' ), |
|
| 87 | + 'label' => esc_html__('Show Payment ID:', 'give'), |
|
| 88 | 88 | 'options' => array( |
| 89 | - 'true' => esc_html__( 'Show', 'give' ), |
|
| 90 | - 'false' => esc_html__( 'Hide', 'give' ), |
|
| 89 | + 'true' => esc_html__('Show', 'give'), |
|
| 90 | + 'false' => esc_html__('Hide', 'give'), |
|
| 91 | 91 | ), |
| 92 | 92 | ), |
| 93 | 93 | ); |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | * @since 1.3.0 |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | -defined( 'ABSPATH' ) or exit; |
|
| 12 | +defined('ABSPATH') or exit; |
|
| 13 | 13 | |
| 14 | 14 | class Give_Shortcode_Donation_History extends Give_Shortcode_Generator { |
| 15 | 15 | |
@@ -18,9 +18,9 @@ discard block |
||
| 18 | 18 | */ |
| 19 | 19 | public function __construct() { |
| 20 | 20 | |
| 21 | - $this->shortcode['label'] = esc_html__( 'Donation History', 'give' ); |
|
| 21 | + $this->shortcode['label'] = esc_html__('Donation History', 'give'); |
|
| 22 | 22 | |
| 23 | - parent::__construct( 'donation_history' ); |
|
| 23 | + parent::__construct('donation_history'); |
|
| 24 | 24 | } |
| 25 | 25 | } |
| 26 | 26 | |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | * @since 1.3.0 |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | -defined( 'ABSPATH' ) or exit; |
|
| 12 | +defined('ABSPATH') or exit; |
|
| 13 | 13 | |
| 14 | 14 | class Give_Shortcode_Register extends Give_Shortcode_Generator { |
| 15 | 15 | |
@@ -18,10 +18,10 @@ discard block |
||
| 18 | 18 | */ |
| 19 | 19 | public function __construct() { |
| 20 | 20 | |
| 21 | - $this->shortcode['title'] = esc_html__( 'Register', 'give' ); |
|
| 22 | - $this->shortcode['label'] = esc_html__( 'Register', 'give' ); |
|
| 21 | + $this->shortcode['title'] = esc_html__('Register', 'give'); |
|
| 22 | + $this->shortcode['label'] = esc_html__('Register', 'give'); |
|
| 23 | 23 | |
| 24 | - parent::__construct( 'give_register' ); |
|
| 24 | + parent::__construct('give_register'); |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | /** |
@@ -34,13 +34,13 @@ discard block |
||
| 34 | 34 | return array( |
| 35 | 35 | array( |
| 36 | 36 | 'type' => 'container', |
| 37 | - 'html' => sprintf( '<p class="no-margin">%s</p>', esc_html__( 'Redirect URL (optional):', 'give' ) ), |
|
| 37 | + 'html' => sprintf('<p class="no-margin">%s</p>', esc_html__('Redirect URL (optional):', 'give')), |
|
| 38 | 38 | ), |
| 39 | 39 | array( |
| 40 | 40 | 'type' => 'textbox', |
| 41 | 41 | 'name' => 'redirect', |
| 42 | 42 | 'minWidth' => 320, |
| 43 | - 'tooltip' => esc_attr__( 'Enter an URL here to redirect to after registering.', 'give' ), |
|
| 43 | + 'tooltip' => esc_attr__('Enter an URL here to redirect to after registering.', 'give'), |
|
| 44 | 44 | ), |
| 45 | 45 | ); |
| 46 | 46 | } |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | 14 | // Exit if accessed directly |
| 15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 15 | +if ( ! defined('ABSPATH')) { |
|
| 16 | 16 | exit; |
| 17 | 17 | } |
| 18 | 18 | |
@@ -46,16 +46,16 @@ discard block |
||
| 46 | 46 | * |
| 47 | 47 | * @param array $request The Form Data passed into the batch processing |
| 48 | 48 | */ |
| 49 | - public function set_properties( $request ) { |
|
| 49 | + public function set_properties($request) { |
|
| 50 | 50 | |
| 51 | 51 | //Set data from form submission |
| 52 | - if ( isset( $_POST['form'] ) ) { |
|
| 53 | - parse_str( $_POST['form'], $this->data ); |
|
| 52 | + if (isset($_POST['form'])) { |
|
| 53 | + parse_str($_POST['form'], $this->data); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | $this->form = $this->data['forms']; |
| 57 | 57 | |
| 58 | - $this->price_id = ! empty( $request['give_price_option'] ) && 0 !== $request['give_price_option'] ? absint( $request['give_price_option'] ) : null; |
|
| 58 | + $this->price_id = ! empty($request['give_price_option']) && 0 !== $request['give_price_option'] ? absint($request['give_price_option']) : null; |
|
| 59 | 59 | |
| 60 | 60 | } |
| 61 | 61 | |
@@ -70,36 +70,36 @@ discard block |
||
| 70 | 70 | |
| 71 | 71 | $cols = array(); |
| 72 | 72 | |
| 73 | - $columns = isset( $this->data['give_export_option'] ) ? $this->data['give_export_option'] : array(); |
|
| 73 | + $columns = isset($this->data['give_export_option']) ? $this->data['give_export_option'] : array(); |
|
| 74 | 74 | |
| 75 | - if ( empty( $columns ) ) { |
|
| 75 | + if (empty($columns)) { |
|
| 76 | 76 | return false; |
| 77 | 77 | } |
| 78 | - if ( ! empty( $columns['full_name'] ) ) { |
|
| 79 | - $cols['full_name'] = esc_html__( 'Full Name', 'give' ); |
|
| 78 | + if ( ! empty($columns['full_name'])) { |
|
| 79 | + $cols['full_name'] = esc_html__('Full Name', 'give'); |
|
| 80 | 80 | } |
| 81 | - if ( ! empty( $columns['email'] ) ) { |
|
| 82 | - $cols['email'] = esc_html__( 'Email Address', 'give' ); |
|
| 81 | + if ( ! empty($columns['email'])) { |
|
| 82 | + $cols['email'] = esc_html__('Email Address', 'give'); |
|
| 83 | 83 | } |
| 84 | - if ( ! empty( $columns['address'] ) ) { |
|
| 85 | - $cols['address_line1'] = esc_html__( 'Address', 'give' ); |
|
| 86 | - $cols['address_line2'] = esc_html__( 'Address (Line 2)', 'give' ); |
|
| 87 | - $cols['address_city'] = esc_html__( 'City', 'give' ); |
|
| 88 | - $cols['address_state'] = esc_html__( 'State', 'give' ); |
|
| 89 | - $cols['address_zip'] = esc_html__( 'Zip', 'give' ); |
|
| 90 | - $cols['address_country'] = esc_html__( 'Country', 'give' ); |
|
| 84 | + if ( ! empty($columns['address'])) { |
|
| 85 | + $cols['address_line1'] = esc_html__('Address', 'give'); |
|
| 86 | + $cols['address_line2'] = esc_html__('Address (Line 2)', 'give'); |
|
| 87 | + $cols['address_city'] = esc_html__('City', 'give'); |
|
| 88 | + $cols['address_state'] = esc_html__('State', 'give'); |
|
| 89 | + $cols['address_zip'] = esc_html__('Zip', 'give'); |
|
| 90 | + $cols['address_country'] = esc_html__('Country', 'give'); |
|
| 91 | 91 | } |
| 92 | - if ( ! empty( $columns['userid'] ) ) { |
|
| 93 | - $cols['userid'] = esc_html__( 'User ID', 'give' ); |
|
| 92 | + if ( ! empty($columns['userid'])) { |
|
| 93 | + $cols['userid'] = esc_html__('User ID', 'give'); |
|
| 94 | 94 | } |
| 95 | - if ( ! empty( $columns['date_first_donated'] ) ) { |
|
| 96 | - $cols['date_first_donated'] = esc_html__( 'First Donation Date', 'give' ); |
|
| 95 | + if ( ! empty($columns['date_first_donated'])) { |
|
| 96 | + $cols['date_first_donated'] = esc_html__('First Donation Date', 'give'); |
|
| 97 | 97 | } |
| 98 | - if ( ! empty( $columns['donations'] ) ) { |
|
| 99 | - $cols['donations'] = esc_html__( 'Number of Donations', 'give' ); |
|
| 98 | + if ( ! empty($columns['donations'])) { |
|
| 99 | + $cols['donations'] = esc_html__('Number of Donations', 'give'); |
|
| 100 | 100 | } |
| 101 | - if ( ! empty( $columns['donation_sum'] ) ) { |
|
| 102 | - $cols['donation_sum'] = esc_html__( 'Sum of Donations', 'give' ); |
|
| 101 | + if ( ! empty($columns['donation_sum'])) { |
|
| 102 | + $cols['donation_sum'] = esc_html__('Sum of Donations', 'give'); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | return $cols; |
@@ -119,20 +119,20 @@ discard block |
||
| 119 | 119 | |
| 120 | 120 | $i = 0; |
| 121 | 121 | |
| 122 | - if ( ! empty( $this->form ) ) { |
|
| 122 | + if ( ! empty($this->form)) { |
|
| 123 | 123 | |
| 124 | 124 | // Export donors of a specific product |
| 125 | 125 | global $give_logs; |
| 126 | 126 | |
| 127 | 127 | $args = array( |
| 128 | - 'post_parent' => absint( $this->form ), |
|
| 128 | + 'post_parent' => absint($this->form), |
|
| 129 | 129 | 'log_type' => 'sale', |
| 130 | 130 | 'posts_per_page' => 30, |
| 131 | 131 | 'paged' => $this->step |
| 132 | 132 | ); |
| 133 | 133 | |
| 134 | 134 | //Check for price option |
| 135 | - if ( null !== $this->price_id ) { |
|
| 135 | + if (null !== $this->price_id) { |
|
| 136 | 136 | $args['meta_query'] = array( |
| 137 | 137 | array( |
| 138 | 138 | 'key' => '_give_log_price_id', |
@@ -141,33 +141,33 @@ discard block |
||
| 141 | 141 | ); |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | - $logs = $give_logs->get_connected_logs( $args ); |
|
| 144 | + $logs = $give_logs->get_connected_logs($args); |
|
| 145 | 145 | |
| 146 | - if ( $logs ) { |
|
| 147 | - foreach ( $logs as $log ) { |
|
| 148 | - $payment_id = get_post_meta( $log->ID, '_give_log_payment_id', true ); |
|
| 149 | - $payment = new Give_Payment( $payment_id ); |
|
| 150 | - $donor = Give()->customers->get_customer_by( 'id', $payment->customer_id ); |
|
| 151 | - $data[] = $this->set_donor_data( $i, $data, $donor ); |
|
| 152 | - $i ++; |
|
| 146 | + if ($logs) { |
|
| 147 | + foreach ($logs as $log) { |
|
| 148 | + $payment_id = get_post_meta($log->ID, '_give_log_payment_id', true); |
|
| 149 | + $payment = new Give_Payment($payment_id); |
|
| 150 | + $donor = Give()->customers->get_customer_by('id', $payment->customer_id); |
|
| 151 | + $data[] = $this->set_donor_data($i, $data, $donor); |
|
| 152 | + $i++; |
|
| 153 | 153 | } |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | } else { |
| 157 | 157 | |
| 158 | 158 | // Export all customers |
| 159 | - $offset = 30 * ( $this->step - 1 ); |
|
| 160 | - $donors = Give()->customers->get_customers( array( 'number' => 30, 'offset' => $offset ) ); |
|
| 159 | + $offset = 30 * ($this->step - 1); |
|
| 160 | + $donors = Give()->customers->get_customers(array('number' => 30, 'offset' => $offset)); |
|
| 161 | 161 | |
| 162 | - foreach ( $donors as $donor ) { |
|
| 162 | + foreach ($donors as $donor) { |
|
| 163 | 163 | |
| 164 | - $data[] = $this->set_donor_data( $i, $data, $donor ); |
|
| 165 | - $i ++; |
|
| 164 | + $data[] = $this->set_donor_data($i, $data, $donor); |
|
| 165 | + $i++; |
|
| 166 | 166 | } |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | - $data = apply_filters( 'give_export_get_data', $data ); |
|
| 170 | - $data = apply_filters( 'give_export_get_data_' . $this->export_type, $data ); |
|
| 169 | + $data = apply_filters('give_export_get_data', $data); |
|
| 170 | + $data = apply_filters('give_export_get_data_'.$this->export_type, $data); |
|
| 171 | 171 | |
| 172 | 172 | return $data; |
| 173 | 173 | } |
@@ -183,19 +183,19 @@ discard block |
||
| 183 | 183 | $percentage = 0; |
| 184 | 184 | |
| 185 | 185 | // We can't count the number when getting them for a specific form |
| 186 | - if ( empty( $this->form ) ) { |
|
| 186 | + if (empty($this->form)) { |
|
| 187 | 187 | |
| 188 | 188 | $total = Give()->customers->count(); |
| 189 | 189 | |
| 190 | - if ( $total > 0 ) { |
|
| 190 | + if ($total > 0) { |
|
| 191 | 191 | |
| 192 | - $percentage = ( ( 30 * $this->step ) / $total ) * 100; |
|
| 192 | + $percentage = ((30 * $this->step) / $total) * 100; |
|
| 193 | 193 | |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | - if ( $percentage > 100 ) { |
|
| 198 | + if ($percentage > 100) { |
|
| 199 | 199 | $percentage = 100; |
| 200 | 200 | } |
| 201 | 201 | |
@@ -207,46 +207,46 @@ discard block |
||
| 207 | 207 | * |
| 208 | 208 | * @param $donor |
| 209 | 209 | */ |
| 210 | - private function set_donor_data( $i, $data, $donor ) { |
|
| 210 | + private function set_donor_data($i, $data, $donor) { |
|
| 211 | 211 | |
| 212 | 212 | $columns = $this->csv_cols(); |
| 213 | 213 | |
| 214 | 214 | //Set address variable |
| 215 | 215 | $address = ''; |
| 216 | - if ( isset( $donor->user_id ) && $donor->user_id > 0 ) { |
|
| 217 | - $address = give_get_donor_address( $donor->user_id ); |
|
| 216 | + if (isset($donor->user_id) && $donor->user_id > 0) { |
|
| 217 | + $address = give_get_donor_address($donor->user_id); |
|
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | //Set columns |
| 221 | - if ( ! empty( $columns['full_name'] ) ) { |
|
| 222 | - $data[ $i ]['full_name'] = $donor->name; |
|
| 221 | + if ( ! empty($columns['full_name'])) { |
|
| 222 | + $data[$i]['full_name'] = $donor->name; |
|
| 223 | 223 | } |
| 224 | - if ( ! empty( $columns['email'] ) ) { |
|
| 225 | - $data[ $i ]['email'] = $donor->email; |
|
| 224 | + if ( ! empty($columns['email'])) { |
|
| 225 | + $data[$i]['email'] = $donor->email; |
|
| 226 | 226 | } |
| 227 | - if ( ! empty( $columns['address_line1'] ) ) { |
|
| 227 | + if ( ! empty($columns['address_line1'])) { |
|
| 228 | 228 | |
| 229 | - $data[ $i ]['address_line1'] = isset( $address['line1'] ) ? $address['line1'] : ''; |
|
| 230 | - $data[ $i ]['address_line2'] = isset( $address['line2'] ) ? $address['line2'] : ''; |
|
| 231 | - $data[ $i ]['address_city'] = isset( $address['city'] ) ? $address['city'] : ''; |
|
| 232 | - $data[ $i ]['address_state'] = isset( $address['state'] ) ? $address['state'] : ''; |
|
| 233 | - $data[ $i ]['address_zip'] = isset( $address['zip'] ) ? $address['zip'] : ''; |
|
| 234 | - $data[ $i ]['address_country'] = isset( $address['country'] ) ? $address['country'] : ''; |
|
| 229 | + $data[$i]['address_line1'] = isset($address['line1']) ? $address['line1'] : ''; |
|
| 230 | + $data[$i]['address_line2'] = isset($address['line2']) ? $address['line2'] : ''; |
|
| 231 | + $data[$i]['address_city'] = isset($address['city']) ? $address['city'] : ''; |
|
| 232 | + $data[$i]['address_state'] = isset($address['state']) ? $address['state'] : ''; |
|
| 233 | + $data[$i]['address_zip'] = isset($address['zip']) ? $address['zip'] : ''; |
|
| 234 | + $data[$i]['address_country'] = isset($address['country']) ? $address['country'] : ''; |
|
| 235 | 235 | } |
| 236 | - if ( ! empty( $columns['userid'] ) ) { |
|
| 237 | - $data[ $i ]['userid'] = ! empty( $donor->user_id ) ? $donor->user_id : ''; |
|
| 236 | + if ( ! empty($columns['userid'])) { |
|
| 237 | + $data[$i]['userid'] = ! empty($donor->user_id) ? $donor->user_id : ''; |
|
| 238 | 238 | } |
| 239 | - if ( ! empty( $columns['date_first_donated'] ) ) { |
|
| 240 | - $data[ $i ]['date_first_donated'] = date_i18n( get_option( 'date_format' ), strtotime( $donor->date_created ) ); |
|
| 239 | + if ( ! empty($columns['date_first_donated'])) { |
|
| 240 | + $data[$i]['date_first_donated'] = date_i18n(get_option('date_format'), strtotime($donor->date_created)); |
|
| 241 | 241 | } |
| 242 | - if ( ! empty( $columns['donations'] ) ) { |
|
| 243 | - $data[ $i ]['donations'] = $donor->purchase_count; |
|
| 242 | + if ( ! empty($columns['donations'])) { |
|
| 243 | + $data[$i]['donations'] = $donor->purchase_count; |
|
| 244 | 244 | } |
| 245 | - if ( ! empty( $columns['donation_sum'] ) ) { |
|
| 246 | - $data[ $i ]['donation_sum'] = give_format_amount( $donor->purchase_value ); |
|
| 245 | + if ( ! empty($columns['donation_sum'])) { |
|
| 246 | + $data[$i]['donation_sum'] = give_format_amount($donor->purchase_value); |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | - return $data[ $i ]; |
|
| 249 | + return $data[$i]; |
|
| 250 | 250 | |
| 251 | 251 | } |
| 252 | 252 | |