@@ -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 donation 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 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 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 donation 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'); |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | */ |
10 | 10 | |
11 | 11 | // Exit if accessed directly. |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; |
14 | 14 | } |
15 | 15 | |
@@ -23,10 +23,10 @@ discard block |
||
23 | 23 | */ |
24 | 24 | public function __construct() { |
25 | 25 | |
26 | - $this->shortcode['title'] = esc_html__( 'Donation Form Goal', 'give' ); |
|
27 | - $this->shortcode['label'] = esc_html__( 'Donation Form Goal', 'give' ); |
|
26 | + $this->shortcode['title'] = esc_html__('Donation Form Goal', 'give'); |
|
27 | + $this->shortcode['label'] = esc_html__('Donation Form Goal', 'give'); |
|
28 | 28 | |
29 | - parent::__construct( 'give_goal' ); |
|
29 | + parent::__construct('give_goal'); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | /** |
@@ -38,8 +38,8 @@ discard block |
||
38 | 38 | |
39 | 39 | $create_form_link = sprintf( |
40 | 40 | /* translators: %s: create new form URL */ |
41 | - __( '<a href="%s">Create</a> a new Donation Form.', 'give' ), |
|
42 | - admin_url( 'post-new.php?post_type=give_forms' ) |
|
41 | + __('<a href="%s">Create</a> a new Donation Form.', 'give'), |
|
42 | + admin_url('post-new.php?post_type=give_forms') |
|
43 | 43 | ); |
44 | 44 | |
45 | 45 | return array( |
@@ -49,35 +49,35 @@ discard block |
||
49 | 49 | 'post_type' => 'give_forms', |
50 | 50 | ), |
51 | 51 | 'name' => 'id', |
52 | - 'tooltip' => esc_attr__( 'Select a Donation Form', 'give' ), |
|
53 | - 'placeholder' => '- ' . esc_attr__( 'Select a Donation Form', 'give' ) . ' -', |
|
52 | + 'tooltip' => esc_attr__('Select a Donation Form', 'give'), |
|
53 | + 'placeholder' => '- '.esc_attr__('Select a Donation Form', 'give').' -', |
|
54 | 54 | 'required' => array( |
55 | - 'alert' => esc_html__( 'You must first select a Form!', 'give' ), |
|
56 | - 'error' => sprintf( '<p class="strong">%s</p><p class="no-margin">%s</p>', esc_html__( 'No forms found.', 'give' ), $create_form_link ), |
|
55 | + 'alert' => esc_html__('You must first select a Form!', 'give'), |
|
56 | + 'error' => sprintf('<p class="strong">%s</p><p class="no-margin">%s</p>', esc_html__('No forms found.', 'give'), $create_form_link), |
|
57 | 57 | ), |
58 | 58 | ), |
59 | 59 | array( |
60 | 60 | 'type' => 'container', |
61 | - 'html' => sprintf( '<p class="strong margin-top">%s</p>', esc_html__( 'Optional settings', 'give' ) ), |
|
61 | + 'html' => sprintf('<p class="strong margin-top">%s</p>', esc_html__('Optional settings', 'give')), |
|
62 | 62 | ), |
63 | 63 | array( |
64 | 64 | 'type' => 'listbox', |
65 | 65 | 'name' => 'show_text', |
66 | - 'label' => esc_attr__( 'Show Text:', 'give' ), |
|
67 | - 'tooltip' => esc_attr__( 'This text displays the amount of income raised compared to the goal.', 'give' ), |
|
66 | + 'label' => esc_attr__('Show Text:', 'give'), |
|
67 | + 'tooltip' => esc_attr__('This text displays the amount of income raised compared to the goal.', 'give'), |
|
68 | 68 | 'options' => array( |
69 | - 'true' => esc_html__( 'Show', 'give' ), |
|
70 | - 'false' => esc_html__( 'Hide', 'give' ), |
|
69 | + 'true' => esc_html__('Show', 'give'), |
|
70 | + 'false' => esc_html__('Hide', 'give'), |
|
71 | 71 | ), |
72 | 72 | ), |
73 | 73 | array( |
74 | 74 | 'type' => 'listbox', |
75 | 75 | 'name' => 'show_bar', |
76 | - 'label' => esc_attr__( 'Show Progress Bar:', 'give' ), |
|
77 | - 'tooltip' => esc_attr__( 'Do you want to display the goal\'s progress bar?', 'give' ), |
|
76 | + 'label' => esc_attr__('Show Progress Bar:', 'give'), |
|
77 | + 'tooltip' => esc_attr__('Do you want to display the goal\'s progress bar?', 'give'), |
|
78 | 78 | 'options' => array( |
79 | - 'true' => esc_html__( 'Show', 'give' ), |
|
80 | - 'false' => esc_html__( 'Hide', 'give' ), |
|
79 | + 'true' => esc_html__('Show', 'give'), |
|
80 | + 'false' => esc_html__('Hide', 'give'), |
|
81 | 81 | ), |
82 | 82 | ), |
83 | 83 | ); |
@@ -565,7 +565,7 @@ discard block |
||
565 | 565 | * |
566 | 566 | * @since 1.6.3 |
567 | 567 | * |
568 | - * @param $pending_reason |
|
568 | + * @param string $pending_reason |
|
569 | 569 | * |
570 | 570 | * @return string |
571 | 571 | */ |
@@ -642,7 +642,7 @@ discard block |
||
642 | 642 | * @param int $payment_id Payment ID |
643 | 643 | * @param array $payment_data Array of payment data. |
644 | 644 | * |
645 | - * @return mixed|string |
|
645 | + * @return string |
|
646 | 646 | */ |
647 | 647 | function give_build_paypal_url( $payment_id, $payment_data ) { |
648 | 648 | // Only send to PayPal if the pending payment is created successfully. |
@@ -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 | |
@@ -22,10 +22,10 @@ discard block |
||
22 | 22 | * |
23 | 23 | * @return bool |
24 | 24 | */ |
25 | -function give_paypal_standard_billing_fields( $form_id ) { |
|
25 | +function give_paypal_standard_billing_fields($form_id) { |
|
26 | 26 | |
27 | - if ( give_is_setting_enabled( give_get_option( 'paypal_standard_billing_details' ) ) ) { |
|
28 | - give_default_cc_address_fields( $form_id ); |
|
27 | + if (give_is_setting_enabled(give_get_option('paypal_standard_billing_details'))) { |
|
28 | + give_default_cc_address_fields($form_id); |
|
29 | 29 | |
30 | 30 | return true; |
31 | 31 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | |
35 | 35 | } |
36 | 36 | |
37 | -add_action( 'give_paypal_cc_form', 'give_paypal_standard_billing_fields' ); |
|
37 | +add_action('give_paypal_cc_form', 'give_paypal_standard_billing_fields'); |
|
38 | 38 | |
39 | 39 | /** |
40 | 40 | * Process PayPal Payment. |
@@ -45,27 +45,27 @@ discard block |
||
45 | 45 | * |
46 | 46 | * @return void |
47 | 47 | */ |
48 | -function give_process_paypal_payment( $payment_data ) { |
|
48 | +function give_process_paypal_payment($payment_data) { |
|
49 | 49 | |
50 | 50 | // Validate nonce. |
51 | - give_validate_nonce( $payment_data['gateway_nonce'], 'give-gateway' ); |
|
52 | - $payment_id = give_create_payment( $payment_data ); |
|
51 | + give_validate_nonce($payment_data['gateway_nonce'], 'give-gateway'); |
|
52 | + $payment_id = give_create_payment($payment_data); |
|
53 | 53 | |
54 | 54 | // Check payment. |
55 | - if ( empty( $payment_id ) ) { |
|
55 | + if (empty($payment_id)) { |
|
56 | 56 | // Record the error. |
57 | - give_record_gateway_error( __( 'Payment Error', 'give' ), sprintf( /* translators: %s: payment data */ |
|
58 | - __( 'Payment creation failed before sending donor to PayPal. Payment data: %s', 'give' ), json_encode( $payment_data ) ), $payment_id ); |
|
57 | + give_record_gateway_error(__('Payment Error', 'give'), sprintf( /* translators: %s: payment data */ |
|
58 | + __('Payment creation failed before sending donor to PayPal. Payment data: %s', 'give'), json_encode($payment_data) ), $payment_id); |
|
59 | 59 | // Problems? Send back. |
60 | - give_send_back_to_checkout( '?payment-mode=' . $payment_data['post_data']['give-gateway'] ); |
|
60 | + give_send_back_to_checkout('?payment-mode='.$payment_data['post_data']['give-gateway']); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | // Redirect to PayPal. |
64 | - wp_redirect( give_build_paypal_url( $payment_id, $payment_data ) ); |
|
64 | + wp_redirect(give_build_paypal_url($payment_id, $payment_data)); |
|
65 | 65 | exit; |
66 | 66 | } |
67 | 67 | |
68 | -add_action( 'give_gateway_paypal', 'give_process_paypal_payment' ); |
|
68 | +add_action('give_gateway_paypal', 'give_process_paypal_payment'); |
|
69 | 69 | |
70 | 70 | /** |
71 | 71 | * Listens for a PayPal IPN requests and then sends to the processing function. |
@@ -75,17 +75,17 @@ discard block |
||
75 | 75 | */ |
76 | 76 | function give_listen_for_paypal_ipn() { |
77 | 77 | // Regular PayPal IPN |
78 | - if ( isset( $_GET['give-listener'] ) && $_GET['give-listener'] == 'IPN' ) { |
|
78 | + if (isset($_GET['give-listener']) && $_GET['give-listener'] == 'IPN') { |
|
79 | 79 | /** |
80 | 80 | * Fires while verifying PayPal IPN |
81 | 81 | * |
82 | 82 | * @since 1.0 |
83 | 83 | */ |
84 | - do_action( 'give_verify_paypal_ipn' ); |
|
84 | + do_action('give_verify_paypal_ipn'); |
|
85 | 85 | } |
86 | 86 | } |
87 | 87 | |
88 | -add_action( 'init', 'give_listen_for_paypal_ipn' ); |
|
88 | +add_action('init', 'give_listen_for_paypal_ipn'); |
|
89 | 89 | |
90 | 90 | /** |
91 | 91 | * Process PayPal IPN |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | function give_process_paypal_ipn() { |
97 | 97 | |
98 | 98 | // Check the request method is POST. |
99 | - if ( isset( $_SERVER['REQUEST_METHOD'] ) && 'POST' !== $_SERVER['REQUEST_METHOD'] ) { |
|
99 | + if (isset($_SERVER['REQUEST_METHOD']) && 'POST' !== $_SERVER['REQUEST_METHOD']) { |
|
100 | 100 | return; |
101 | 101 | } |
102 | 102 | |
@@ -104,11 +104,11 @@ discard block |
||
104 | 104 | $post_data = ''; |
105 | 105 | |
106 | 106 | // Fallback just in case post_max_size is lower than needed. |
107 | - if ( ini_get( 'allow_url_fopen' ) ) { |
|
108 | - $post_data = file_get_contents( 'php://input' ); |
|
107 | + if (ini_get('allow_url_fopen')) { |
|
108 | + $post_data = file_get_contents('php://input'); |
|
109 | 109 | } else { |
110 | 110 | // If allow_url_fopen is not enabled, then make sure that post_max_size is large enough. |
111 | - ini_set( 'post_max_size', '12M' ); |
|
111 | + ini_set('post_max_size', '12M'); |
|
112 | 112 | } |
113 | 113 | // Start the encoded data collection with notification command. |
114 | 114 | $encoded_data = 'cmd=_notify-validate'; |
@@ -117,39 +117,39 @@ discard block |
||
117 | 117 | $arg_separator = give_get_php_arg_separator_output(); |
118 | 118 | |
119 | 119 | // Verify there is a post_data. |
120 | - if ( $post_data || strlen( $post_data ) > 0 ) { |
|
120 | + if ($post_data || strlen($post_data) > 0) { |
|
121 | 121 | // Append the data. |
122 | - $encoded_data .= $arg_separator . $post_data; |
|
122 | + $encoded_data .= $arg_separator.$post_data; |
|
123 | 123 | } else { |
124 | 124 | // Check if POST is empty. |
125 | - if ( empty( $_POST ) ) { |
|
125 | + if (empty($_POST)) { |
|
126 | 126 | // Nothing to do. |
127 | 127 | return; |
128 | 128 | } else { |
129 | 129 | // Loop through each POST. |
130 | - foreach ( $_POST as $key => $value ) { |
|
130 | + foreach ($_POST as $key => $value) { |
|
131 | 131 | // Encode the value and append the data. |
132 | - $encoded_data .= $arg_separator . "$key=" . urlencode( $value ); |
|
132 | + $encoded_data .= $arg_separator."$key=".urlencode($value); |
|
133 | 133 | } |
134 | 134 | } |
135 | 135 | } |
136 | 136 | |
137 | 137 | // Convert collected post data to an array. |
138 | - parse_str( $encoded_data, $encoded_data_array ); |
|
138 | + parse_str($encoded_data, $encoded_data_array); |
|
139 | 139 | |
140 | - foreach ( $encoded_data_array as $key => $value ) { |
|
140 | + foreach ($encoded_data_array as $key => $value) { |
|
141 | 141 | |
142 | - if ( false !== strpos( $key, 'amp;' ) ) { |
|
143 | - $new_key = str_replace( '&', '&', $key ); |
|
144 | - $new_key = str_replace( 'amp;', '&', $new_key ); |
|
142 | + if (false !== strpos($key, 'amp;')) { |
|
143 | + $new_key = str_replace('&', '&', $key); |
|
144 | + $new_key = str_replace('amp;', '&', $new_key); |
|
145 | 145 | |
146 | - unset( $encoded_data_array[ $key ] ); |
|
147 | - $encoded_data_array[ $new_key ] = $value; |
|
146 | + unset($encoded_data_array[$key]); |
|
147 | + $encoded_data_array[$new_key] = $value; |
|
148 | 148 | } |
149 | 149 | } |
150 | 150 | |
151 | 151 | // Validate IPN request w/ PayPal if user hasn't disabled this security measure. |
152 | - if ( give_is_setting_enabled( give_get_option( 'paypal_verification' ) ) ) { |
|
152 | + if (give_is_setting_enabled(give_get_option('paypal_verification'))) { |
|
153 | 153 | |
154 | 154 | $remote_post_vars = array( |
155 | 155 | 'method' => 'POST', |
@@ -169,25 +169,25 @@ discard block |
||
169 | 169 | ); |
170 | 170 | |
171 | 171 | // Validate the IPN. |
172 | - $api_response = wp_remote_post( give_get_paypal_redirect(), $remote_post_vars ); |
|
172 | + $api_response = wp_remote_post(give_get_paypal_redirect(), $remote_post_vars); |
|
173 | 173 | |
174 | - if ( is_wp_error( $api_response ) ) { |
|
175 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( /* translators: %s: Paypal IPN response */ |
|
176 | - __( 'Invalid IPN verification response. IPN data: %s', 'give' ), json_encode( $api_response ) ) ); |
|
174 | + if (is_wp_error($api_response)) { |
|
175 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf( /* translators: %s: Paypal IPN response */ |
|
176 | + __('Invalid IPN verification response. IPN data: %s', 'give'), json_encode($api_response) )); |
|
177 | 177 | |
178 | 178 | return; // Something went wrong |
179 | 179 | } |
180 | 180 | |
181 | - if ( 'VERIFIED' !== $api_response['body'] ) { |
|
182 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( /* translators: %s: Paypal IPN response */ |
|
183 | - __( 'Invalid IPN verification response. IPN data: %s', 'give' ), json_encode( $api_response ) ) ); |
|
181 | + if ('VERIFIED' !== $api_response['body']) { |
|
182 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf( /* translators: %s: Paypal IPN response */ |
|
183 | + __('Invalid IPN verification response. IPN data: %s', 'give'), json_encode($api_response) )); |
|
184 | 184 | |
185 | 185 | return; // Response not okay. |
186 | 186 | } |
187 | 187 | }// End if(). |
188 | 188 | |
189 | 189 | // Check if $post_data_array has been populated. |
190 | - if ( ! is_array( $encoded_data_array ) && ! empty( $encoded_data_array ) ) { |
|
190 | + if ( ! is_array($encoded_data_array) && ! empty($encoded_data_array)) { |
|
191 | 191 | return; |
192 | 192 | } |
193 | 193 | |
@@ -196,12 +196,12 @@ discard block |
||
196 | 196 | 'payment_status' => '', |
197 | 197 | ); |
198 | 198 | |
199 | - $encoded_data_array = wp_parse_args( $encoded_data_array, $defaults ); |
|
199 | + $encoded_data_array = wp_parse_args($encoded_data_array, $defaults); |
|
200 | 200 | |
201 | - $payment_id = isset( $encoded_data_array['custom'] ) ? absint( $encoded_data_array['custom'] ) : 0; |
|
201 | + $payment_id = isset($encoded_data_array['custom']) ? absint($encoded_data_array['custom']) : 0; |
|
202 | 202 | $txn_type = $encoded_data_array['txn_type']; |
203 | 203 | |
204 | - if ( has_action( 'give_paypal_' . $txn_type ) ) { |
|
204 | + if (has_action('give_paypal_'.$txn_type)) { |
|
205 | 205 | /** |
206 | 206 | * Fires while processing PayPal IPN $txn_type. |
207 | 207 | * |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | * @param array $encoded_data_array Encoded data. |
213 | 213 | * @param int $payment_id Payment id. |
214 | 214 | */ |
215 | - do_action( "give_paypal_{$txn_type}", $encoded_data_array, $payment_id ); |
|
215 | + do_action("give_paypal_{$txn_type}", $encoded_data_array, $payment_id); |
|
216 | 216 | } else { |
217 | 217 | /** |
218 | 218 | * Fires while process PayPal IPN. |
@@ -224,12 +224,12 @@ discard block |
||
224 | 224 | * @param array $encoded_data_array Encoded data. |
225 | 225 | * @param int $payment_id Payment id. |
226 | 226 | */ |
227 | - do_action( 'give_paypal_web_accept', $encoded_data_array, $payment_id ); |
|
227 | + do_action('give_paypal_web_accept', $encoded_data_array, $payment_id); |
|
228 | 228 | } |
229 | 229 | exit; |
230 | 230 | } |
231 | 231 | |
232 | -add_action( 'give_verify_paypal_ipn', 'give_process_paypal_ipn' ); |
|
232 | +add_action('give_verify_paypal_ipn', 'give_process_paypal_ipn'); |
|
233 | 233 | |
234 | 234 | /** |
235 | 235 | * Process web accept (one time) payment IPNs. |
@@ -241,99 +241,99 @@ discard block |
||
241 | 241 | * |
242 | 242 | * @return void |
243 | 243 | */ |
244 | -function give_process_paypal_web_accept( $data, $payment_id ) { |
|
244 | +function give_process_paypal_web_accept($data, $payment_id) { |
|
245 | 245 | |
246 | 246 | // Only allow through these transaction types. |
247 | - if ( 'web_accept' !== $data['txn_type'] && 'cart' !== $data['txn_type'] && 'refunded' !== strtolower( $data['payment_status'] ) ) { |
|
247 | + if ('web_accept' !== $data['txn_type'] && 'cart' !== $data['txn_type'] && 'refunded' !== strtolower($data['payment_status'])) { |
|
248 | 248 | return; |
249 | 249 | } |
250 | 250 | |
251 | 251 | // Need $payment_id to continue. |
252 | - if ( empty( $payment_id ) ) { |
|
252 | + if (empty($payment_id)) { |
|
253 | 253 | return; |
254 | 254 | } |
255 | 255 | |
256 | 256 | // Collect donation payment details. |
257 | 257 | $paypal_amount = $data['mc_gross']; |
258 | - $payment_status = strtolower( $data['payment_status'] ); |
|
259 | - $currency_code = strtolower( $data['mc_currency'] ); |
|
260 | - $business_email = isset( $data['business'] ) && is_email( $data['business'] ) ? trim( $data['business'] ) : trim( $data['receiver_email'] ); |
|
261 | - $payment_meta = give_get_payment_meta( $payment_id ); |
|
258 | + $payment_status = strtolower($data['payment_status']); |
|
259 | + $currency_code = strtolower($data['mc_currency']); |
|
260 | + $business_email = isset($data['business']) && is_email($data['business']) ? trim($data['business']) : trim($data['receiver_email']); |
|
261 | + $payment_meta = give_get_payment_meta($payment_id); |
|
262 | 262 | |
263 | 263 | // Must be a PayPal standard IPN. |
264 | - if ( 'paypal' !== give_get_payment_gateway( $payment_id ) ) { |
|
264 | + if ('paypal' !== give_get_payment_gateway($payment_id)) { |
|
265 | 265 | return; |
266 | 266 | } |
267 | 267 | |
268 | 268 | // Verify payment recipient |
269 | - if ( strcasecmp( $business_email, trim( give_get_option( 'paypal_email' ) ) ) !== 0 ) { |
|
269 | + if (strcasecmp($business_email, trim(give_get_option('paypal_email'))) !== 0) { |
|
270 | 270 | |
271 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( /* translators: %s: Paypal IPN response */ |
|
272 | - __( 'Invalid business email in IPN response. IPN data: %s', 'give' ), json_encode( $data ) ), $payment_id ); |
|
273 | - give_update_payment_status( $payment_id, 'failed' ); |
|
274 | - give_insert_payment_note( $payment_id, __( 'Payment failed due to invalid PayPal business email.', 'give' ) ); |
|
271 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf( /* translators: %s: Paypal IPN response */ |
|
272 | + __('Invalid business email in IPN response. IPN data: %s', 'give'), json_encode($data) ), $payment_id); |
|
273 | + give_update_payment_status($payment_id, 'failed'); |
|
274 | + give_insert_payment_note($payment_id, __('Payment failed due to invalid PayPal business email.', 'give')); |
|
275 | 275 | |
276 | 276 | return; |
277 | 277 | } |
278 | 278 | |
279 | 279 | // Verify payment currency. |
280 | - if ( $currency_code !== strtolower( $payment_meta['currency'] ) ) { |
|
280 | + if ($currency_code !== strtolower($payment_meta['currency'])) { |
|
281 | 281 | |
282 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( /* translators: %s: Paypal IPN response */ |
|
283 | - __( 'Invalid currency in IPN response. IPN data: %s', 'give' ), json_encode( $data ) ), $payment_id ); |
|
284 | - give_update_payment_status( $payment_id, 'failed' ); |
|
285 | - give_insert_payment_note( $payment_id, __( 'Payment failed due to invalid currency in PayPal IPN.', 'give' ) ); |
|
282 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf( /* translators: %s: Paypal IPN response */ |
|
283 | + __('Invalid currency in IPN response. IPN data: %s', 'give'), json_encode($data) ), $payment_id); |
|
284 | + give_update_payment_status($payment_id, 'failed'); |
|
285 | + give_insert_payment_note($payment_id, __('Payment failed due to invalid currency in PayPal IPN.', 'give')); |
|
286 | 286 | |
287 | 287 | return; |
288 | 288 | } |
289 | 289 | |
290 | 290 | // Process refunds & reversed. |
291 | - if ( 'refunded' === $payment_status || 'reversed' === $payment_status ) { |
|
292 | - give_process_paypal_refund( $data, $payment_id ); |
|
291 | + if ('refunded' === $payment_status || 'reversed' === $payment_status) { |
|
292 | + give_process_paypal_refund($data, $payment_id); |
|
293 | 293 | |
294 | 294 | return; |
295 | 295 | } |
296 | 296 | |
297 | 297 | // Only complete payments once. |
298 | - if ( 'publish' === get_post_status( $payment_id ) ) { |
|
298 | + if ('publish' === get_post_status($payment_id)) { |
|
299 | 299 | return; |
300 | 300 | } |
301 | 301 | |
302 | 302 | // Retrieve the total donation amount (before PayPal). |
303 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
303 | + $payment_amount = give_get_payment_amount($payment_id); |
|
304 | 304 | |
305 | 305 | // Check that the donation PP and local db amounts match. |
306 | - if ( number_format( (float) $paypal_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) { |
|
306 | + if (number_format((float) $paypal_amount, 2) < number_format((float) $payment_amount, 2)) { |
|
307 | 307 | // The prices don't match |
308 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( /* translators: %s: Paypal IPN response */ |
|
309 | - __( 'Invalid payment amount in IPN response. IPN data: %s', 'give' ), json_encode( $data ) ), $payment_id ); |
|
310 | - give_update_payment_status( $payment_id, 'failed' ); |
|
311 | - give_insert_payment_note( $payment_id, __( 'Payment failed due to invalid amount in PayPal IPN.', 'give' ) ); |
|
308 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf( /* translators: %s: Paypal IPN response */ |
|
309 | + __('Invalid payment amount in IPN response. IPN data: %s', 'give'), json_encode($data) ), $payment_id); |
|
310 | + give_update_payment_status($payment_id, 'failed'); |
|
311 | + give_insert_payment_note($payment_id, __('Payment failed due to invalid amount in PayPal IPN.', 'give')); |
|
312 | 312 | |
313 | 313 | return; |
314 | 314 | } |
315 | 315 | |
316 | 316 | // Process completed donations. |
317 | - if ( 'completed' === $payment_status || give_is_test_mode() ) { |
|
317 | + if ('completed' === $payment_status || give_is_test_mode()) { |
|
318 | 318 | |
319 | - give_insert_payment_note( $payment_id, sprintf( /* translators: %s: Paypal transaction ID */ |
|
320 | - __( 'PayPal Transaction ID: %s', 'give' ), $data['txn_id'] ) ); |
|
321 | - give_set_payment_transaction_id( $payment_id, $data['txn_id'] ); |
|
322 | - give_update_payment_status( $payment_id, 'publish' ); |
|
319 | + give_insert_payment_note($payment_id, sprintf( /* translators: %s: Paypal transaction ID */ |
|
320 | + __('PayPal Transaction ID: %s', 'give'), $data['txn_id'] )); |
|
321 | + give_set_payment_transaction_id($payment_id, $data['txn_id']); |
|
322 | + give_update_payment_status($payment_id, 'publish'); |
|
323 | 323 | |
324 | - } elseif ( 'pending' === $payment_status && isset( $data['pending_reason'] ) ) { |
|
324 | + } elseif ('pending' === $payment_status && isset($data['pending_reason'])) { |
|
325 | 325 | |
326 | 326 | // Look for possible pending reasons, such as an echeck. |
327 | - $note = give_paypal_get_pending_donation_note( strtolower( $data['pending_reason'] ) ); |
|
327 | + $note = give_paypal_get_pending_donation_note(strtolower($data['pending_reason'])); |
|
328 | 328 | |
329 | - if ( ! empty( $note ) ) { |
|
330 | - give_insert_payment_note( $payment_id, $note ); |
|
329 | + if ( ! empty($note)) { |
|
330 | + give_insert_payment_note($payment_id, $note); |
|
331 | 331 | } |
332 | 332 | } |
333 | 333 | |
334 | 334 | } |
335 | 335 | |
336 | -add_action( 'give_paypal_web_accept', 'give_process_paypal_web_accept', 10, 2 ); |
|
336 | +add_action('give_paypal_web_accept', 'give_process_paypal_web_accept', 10, 2); |
|
337 | 337 | |
338 | 338 | /** |
339 | 339 | * Process PayPal IPN Refunds |
@@ -345,35 +345,35 @@ discard block |
||
345 | 345 | * |
346 | 346 | * @return void |
347 | 347 | */ |
348 | -function give_process_paypal_refund( $data, $payment_id = 0 ) { |
|
348 | +function give_process_paypal_refund($data, $payment_id = 0) { |
|
349 | 349 | |
350 | 350 | // Collect payment details. |
351 | - if ( empty( $payment_id ) ) { |
|
351 | + if (empty($payment_id)) { |
|
352 | 352 | return; |
353 | 353 | } |
354 | 354 | |
355 | 355 | // Only refund payments once. |
356 | - if ( 'refunded' === get_post_status( $payment_id ) ) { |
|
356 | + if ('refunded' === get_post_status($payment_id)) { |
|
357 | 357 | return; |
358 | 358 | } |
359 | 359 | |
360 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
360 | + $payment_amount = give_get_payment_amount($payment_id); |
|
361 | 361 | $refund_amount = $data['payment_gross'] * - 1; |
362 | 362 | |
363 | - if ( number_format( (float) $refund_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) { |
|
363 | + if (number_format((float) $refund_amount, 2) < number_format((float) $payment_amount, 2)) { |
|
364 | 364 | |
365 | - give_insert_payment_note( $payment_id, sprintf( /* translators: %s: Paypal parent transaction ID */ |
|
366 | - __( 'Partial PayPal refund processed: %s', 'give' ), $data['parent_txn_id'] ) ); |
|
365 | + give_insert_payment_note($payment_id, sprintf( /* translators: %s: Paypal parent transaction ID */ |
|
366 | + __('Partial PayPal refund processed: %s', 'give'), $data['parent_txn_id'] )); |
|
367 | 367 | |
368 | 368 | return; // This is a partial refund |
369 | 369 | |
370 | 370 | } |
371 | 371 | |
372 | - give_insert_payment_note( $payment_id, sprintf( /* translators: 1: Paypal parent transaction ID 2. Paypal reason code */ |
|
373 | - __( 'PayPal Payment #%1$s Refunded for reason: %2$s', 'give' ), $data['parent_txn_id'], $data['reason_code'] ) ); |
|
374 | - give_insert_payment_note( $payment_id, sprintf( /* translators: %s: Paypal transaction ID */ |
|
375 | - __( 'PayPal Refund Transaction ID: %s', 'give' ), $data['txn_id'] ) ); |
|
376 | - give_update_payment_status( $payment_id, 'refunded' ); |
|
372 | + give_insert_payment_note($payment_id, sprintf( /* translators: 1: Paypal parent transaction ID 2. Paypal reason code */ |
|
373 | + __('PayPal Payment #%1$s Refunded for reason: %2$s', 'give'), $data['parent_txn_id'], $data['reason_code'] )); |
|
374 | + give_insert_payment_note($payment_id, sprintf( /* translators: %s: Paypal transaction ID */ |
|
375 | + __('PayPal Refund Transaction ID: %s', 'give'), $data['txn_id'] )); |
|
376 | + give_update_payment_status($payment_id, 'refunded'); |
|
377 | 377 | } |
378 | 378 | |
379 | 379 | /** |
@@ -385,24 +385,24 @@ discard block |
||
385 | 385 | * |
386 | 386 | * @return string |
387 | 387 | */ |
388 | -function give_get_paypal_redirect( $ssl_check = false ) { |
|
388 | +function give_get_paypal_redirect($ssl_check = false) { |
|
389 | 389 | |
390 | - if ( is_ssl() || ! $ssl_check ) { |
|
390 | + if (is_ssl() || ! $ssl_check) { |
|
391 | 391 | $protocol = 'https://'; |
392 | 392 | } else { |
393 | 393 | $protocol = 'http://'; |
394 | 394 | } |
395 | 395 | |
396 | 396 | // Check the current payment mode |
397 | - if ( give_is_test_mode() ) { |
|
397 | + if (give_is_test_mode()) { |
|
398 | 398 | // Test mode |
399 | - $paypal_uri = $protocol . 'www.sandbox.paypal.com/cgi-bin/webscr'; |
|
399 | + $paypal_uri = $protocol.'www.sandbox.paypal.com/cgi-bin/webscr'; |
|
400 | 400 | } else { |
401 | 401 | // Live mode |
402 | - $paypal_uri = $protocol . 'www.paypal.com/cgi-bin/webscr'; |
|
402 | + $paypal_uri = $protocol.'www.paypal.com/cgi-bin/webscr'; |
|
403 | 403 | } |
404 | 404 | |
405 | - return apply_filters( 'give_paypal_uri', $paypal_uri ); |
|
405 | + return apply_filters('give_paypal_uri', $paypal_uri); |
|
406 | 406 | } |
407 | 407 | |
408 | 408 | /** |
@@ -412,9 +412,9 @@ discard block |
||
412 | 412 | * @return string |
413 | 413 | */ |
414 | 414 | function give_get_paypal_page_style() { |
415 | - $page_style = trim( give_get_option( 'paypal_page_style', 'PayPal' ) ); |
|
415 | + $page_style = trim(give_get_option('paypal_page_style', 'PayPal')); |
|
416 | 416 | |
417 | - return apply_filters( 'give_paypal_page_style', $page_style ); |
|
417 | + return apply_filters('give_paypal_page_style', $page_style); |
|
418 | 418 | } |
419 | 419 | |
420 | 420 | /** |
@@ -428,26 +428,26 @@ discard block |
||
428 | 428 | * |
429 | 429 | * @return string |
430 | 430 | */ |
431 | -function give_paypal_success_page_content( $content ) { |
|
431 | +function give_paypal_success_page_content($content) { |
|
432 | 432 | |
433 | - if ( ! isset( $_GET['payment-id'] ) && ! give_get_purchase_session() ) { |
|
433 | + if ( ! isset($_GET['payment-id']) && ! give_get_purchase_session()) { |
|
434 | 434 | return $content; |
435 | 435 | } |
436 | 436 | |
437 | - $payment_id = isset( $_GET['payment-id'] ) ? absint( $_GET['payment-id'] ) : false; |
|
437 | + $payment_id = isset($_GET['payment-id']) ? absint($_GET['payment-id']) : false; |
|
438 | 438 | |
439 | - if ( ! $payment_id ) { |
|
439 | + if ( ! $payment_id) { |
|
440 | 440 | $session = give_get_purchase_session(); |
441 | - $payment_id = give_get_purchase_id_by_key( $session['purchase_key'] ); |
|
441 | + $payment_id = give_get_purchase_id_by_key($session['purchase_key']); |
|
442 | 442 | } |
443 | 443 | |
444 | - $payment = get_post( $payment_id ); |
|
445 | - if ( $payment && 'pending' === $payment->post_status ) { |
|
444 | + $payment = get_post($payment_id); |
|
445 | + if ($payment && 'pending' === $payment->post_status) { |
|
446 | 446 | |
447 | 447 | // Payment is still pending so show processing indicator to fix the race condition. |
448 | 448 | ob_start(); |
449 | 449 | |
450 | - give_get_template_part( 'payment', 'processing' ); |
|
450 | + give_get_template_part('payment', 'processing'); |
|
451 | 451 | |
452 | 452 | $content = ob_get_clean(); |
453 | 453 | |
@@ -457,7 +457,7 @@ discard block |
||
457 | 457 | |
458 | 458 | } |
459 | 459 | |
460 | -add_filter( 'give_payment_confirm_paypal', 'give_paypal_success_page_content' ); |
|
460 | +add_filter('give_payment_confirm_paypal', 'give_paypal_success_page_content'); |
|
461 | 461 | |
462 | 462 | /** |
463 | 463 | * Given a Payment ID, extract the transaction ID |
@@ -468,22 +468,22 @@ discard block |
||
468 | 468 | * |
469 | 469 | * @return string Transaction ID |
470 | 470 | */ |
471 | -function give_paypal_get_payment_transaction_id( $payment_id ) { |
|
471 | +function give_paypal_get_payment_transaction_id($payment_id) { |
|
472 | 472 | |
473 | 473 | $transaction_id = ''; |
474 | - $notes = give_get_payment_notes( $payment_id ); |
|
474 | + $notes = give_get_payment_notes($payment_id); |
|
475 | 475 | |
476 | - foreach ( $notes as $note ) { |
|
477 | - if ( preg_match( '/^PayPal Transaction ID: ([^\s]+)/', $note->comment_content, $match ) ) { |
|
476 | + foreach ($notes as $note) { |
|
477 | + if (preg_match('/^PayPal Transaction ID: ([^\s]+)/', $note->comment_content, $match)) { |
|
478 | 478 | $transaction_id = $match[1]; |
479 | 479 | continue; |
480 | 480 | } |
481 | 481 | } |
482 | 482 | |
483 | - return apply_filters( 'give_paypal_set_payment_transaction_id', $transaction_id, $payment_id ); |
|
483 | + return apply_filters('give_paypal_set_payment_transaction_id', $transaction_id, $payment_id); |
|
484 | 484 | } |
485 | 485 | |
486 | -add_filter( 'give_get_payment_transaction_id-paypal', 'give_paypal_get_payment_transaction_id', 10, 1 ); |
|
486 | +add_filter('give_get_payment_transaction_id-paypal', 'give_paypal_get_payment_transaction_id', 10, 1); |
|
487 | 487 | |
488 | 488 | /** |
489 | 489 | * Given a transaction ID, generate a link to the PayPal transaction ID details |
@@ -495,16 +495,16 @@ discard block |
||
495 | 495 | * |
496 | 496 | * @return string A link to the PayPal transaction details |
497 | 497 | */ |
498 | -function give_paypal_link_transaction_id( $transaction_id, $payment_id ) { |
|
498 | +function give_paypal_link_transaction_id($transaction_id, $payment_id) { |
|
499 | 499 | |
500 | 500 | $paypal_base_url = 'https://history.paypal.com/cgi-bin/webscr?cmd=_history-details-from-hub&id='; |
501 | - $transaction_url = '<a href="' . esc_url( $paypal_base_url . $transaction_id ) . '" target="_blank">' . $transaction_id . '</a>'; |
|
501 | + $transaction_url = '<a href="'.esc_url($paypal_base_url.$transaction_id).'" target="_blank">'.$transaction_id.'</a>'; |
|
502 | 502 | |
503 | - return apply_filters( 'give_paypal_link_payment_details_transaction_id', $transaction_url ); |
|
503 | + return apply_filters('give_paypal_link_payment_details_transaction_id', $transaction_url); |
|
504 | 504 | |
505 | 505 | } |
506 | 506 | |
507 | -add_filter( 'give_payment_details_transaction_id-paypal', 'give_paypal_link_transaction_id', 10, 2 ); |
|
507 | +add_filter('give_payment_details_transaction_id-paypal', 'give_paypal_link_transaction_id', 10, 2); |
|
508 | 508 | |
509 | 509 | |
510 | 510 | /** |
@@ -516,64 +516,64 @@ discard block |
||
516 | 516 | * |
517 | 517 | * @return string |
518 | 518 | */ |
519 | -function give_paypal_get_pending_donation_note( $pending_reason ) { |
|
519 | +function give_paypal_get_pending_donation_note($pending_reason) { |
|
520 | 520 | |
521 | 521 | $note = ''; |
522 | 522 | |
523 | - switch ( $pending_reason ) { |
|
523 | + switch ($pending_reason) { |
|
524 | 524 | |
525 | 525 | case 'echeck' : |
526 | 526 | |
527 | - $note = __( 'Payment made via eCheck and will clear automatically in 5-8 days.', 'give' ); |
|
527 | + $note = __('Payment made via eCheck and will clear automatically in 5-8 days.', 'give'); |
|
528 | 528 | |
529 | 529 | break; |
530 | 530 | |
531 | 531 | case 'address' : |
532 | 532 | |
533 | - $note = __( 'Payment requires a confirmed donor address and must be accepted manually through PayPal.', 'give' ); |
|
533 | + $note = __('Payment requires a confirmed donor address and must be accepted manually through PayPal.', 'give'); |
|
534 | 534 | |
535 | 535 | break; |
536 | 536 | |
537 | 537 | case 'intl' : |
538 | 538 | |
539 | - $note = __( 'Payment must be accepted manually through PayPal due to international account regulations.', 'give' ); |
|
539 | + $note = __('Payment must be accepted manually through PayPal due to international account regulations.', 'give'); |
|
540 | 540 | |
541 | 541 | break; |
542 | 542 | |
543 | 543 | case 'multi-currency' : |
544 | 544 | |
545 | - $note = __( 'Payment received in non-shop currency and must be accepted manually through PayPal.', 'give' ); |
|
545 | + $note = __('Payment received in non-shop currency and must be accepted manually through PayPal.', 'give'); |
|
546 | 546 | |
547 | 547 | break; |
548 | 548 | |
549 | 549 | case 'paymentreview' : |
550 | 550 | case 'regulatory_review' : |
551 | 551 | |
552 | - $note = __( 'Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations.', 'give' ); |
|
552 | + $note = __('Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations.', 'give'); |
|
553 | 553 | |
554 | 554 | break; |
555 | 555 | |
556 | 556 | case 'unilateral' : |
557 | 557 | |
558 | - $note = __( 'Payment was sent to non-confirmed or non-registered email address.', 'give' ); |
|
558 | + $note = __('Payment was sent to non-confirmed or non-registered email address.', 'give'); |
|
559 | 559 | |
560 | 560 | break; |
561 | 561 | |
562 | 562 | case 'upgrade' : |
563 | 563 | |
564 | - $note = __( 'PayPal account must be upgraded before this payment can be accepted.', 'give' ); |
|
564 | + $note = __('PayPal account must be upgraded before this payment can be accepted.', 'give'); |
|
565 | 565 | |
566 | 566 | break; |
567 | 567 | |
568 | 568 | case 'verify' : |
569 | 569 | |
570 | - $note = __( 'PayPal account is not verified. Verify account in order to accept this donation.', 'give' ); |
|
570 | + $note = __('PayPal account is not verified. Verify account in order to accept this donation.', 'give'); |
|
571 | 571 | |
572 | 572 | break; |
573 | 573 | |
574 | 574 | case 'other' : |
575 | 575 | |
576 | - $note = __( 'Payment is pending for unknown reasons. Contact PayPal support for assistance.', 'give' ); |
|
576 | + $note = __('Payment is pending for unknown reasons. Contact PayPal support for assistance.', 'give'); |
|
577 | 577 | |
578 | 578 | break; |
579 | 579 | |
@@ -591,49 +591,49 @@ discard block |
||
591 | 591 | * |
592 | 592 | * @return mixed|string |
593 | 593 | */ |
594 | -function give_build_paypal_url( $payment_id, $payment_data ) { |
|
594 | +function give_build_paypal_url($payment_id, $payment_data) { |
|
595 | 595 | // Only send to PayPal if the pending payment is created successfully. |
596 | - $listener_url = add_query_arg( 'give-listener', 'IPN', home_url( 'index.php' ) ); |
|
596 | + $listener_url = add_query_arg('give-listener', 'IPN', home_url('index.php')); |
|
597 | 597 | |
598 | 598 | // Get the success url. |
599 | - $return_url = add_query_arg( array( |
|
599 | + $return_url = add_query_arg(array( |
|
600 | 600 | 'payment-confirmation' => 'paypal', |
601 | 601 | 'payment-id' => $payment_id, |
602 | 602 | |
603 | - ), get_permalink( give_get_option( 'success_page' ) ) ); |
|
603 | + ), get_permalink(give_get_option('success_page'))); |
|
604 | 604 | |
605 | 605 | // Get the PayPal redirect uri. |
606 | - $paypal_redirect = trailingslashit( give_get_paypal_redirect() ) . '?'; |
|
606 | + $paypal_redirect = trailingslashit(give_get_paypal_redirect()).'?'; |
|
607 | 607 | |
608 | 608 | // Item name. |
609 | - $item_name = give_build_paypal_item_title( $payment_data ); |
|
609 | + $item_name = give_build_paypal_item_title($payment_data); |
|
610 | 610 | |
611 | 611 | // Setup PayPal API params. |
612 | 612 | $paypal_args = array( |
613 | - 'business' => give_get_option( 'paypal_email', false ), |
|
613 | + 'business' => give_get_option('paypal_email', false), |
|
614 | 614 | 'first_name' => $payment_data['user_info']['first_name'], |
615 | 615 | 'last_name' => $payment_data['user_info']['last_name'], |
616 | 616 | 'email' => $payment_data['user_email'], |
617 | 617 | 'invoice' => $payment_data['purchase_key'], |
618 | 618 | 'amount' => $payment_data['price'], |
619 | - 'item_name' => stripslashes( $item_name ), |
|
619 | + 'item_name' => stripslashes($item_name), |
|
620 | 620 | 'no_shipping' => '1', |
621 | 621 | 'shipping' => '0', |
622 | 622 | 'no_note' => '1', |
623 | 623 | 'currency_code' => give_get_currency(), |
624 | - 'charset' => get_bloginfo( 'charset' ), |
|
624 | + 'charset' => get_bloginfo('charset'), |
|
625 | 625 | 'custom' => $payment_id, |
626 | 626 | 'rm' => '2', |
627 | 627 | 'return' => $return_url, |
628 | - 'cancel_return' => give_get_failed_transaction_uri( '?payment-id=' . $payment_id ), |
|
628 | + 'cancel_return' => give_get_failed_transaction_uri('?payment-id='.$payment_id), |
|
629 | 629 | 'notify_url' => $listener_url, |
630 | 630 | 'page_style' => give_get_paypal_page_style(), |
631 | - 'cbt' => get_bloginfo( 'name' ), |
|
631 | + 'cbt' => get_bloginfo('name'), |
|
632 | 632 | 'bn' => 'givewp_SP', |
633 | 633 | ); |
634 | 634 | |
635 | 635 | // Add user address if present. |
636 | - if ( ! empty( $payment_data['user_info']['address'] ) ) { |
|
636 | + if ( ! empty($payment_data['user_info']['address'])) { |
|
637 | 637 | $default_address = array( |
638 | 638 | 'line1' => '', |
639 | 639 | 'line2' => '', |
@@ -643,7 +643,7 @@ discard block |
||
643 | 643 | 'country' => '', |
644 | 644 | ); |
645 | 645 | |
646 | - $address = wp_parse_args( $payment_data['user_info']['address'], $default_address ); |
|
646 | + $address = wp_parse_args($payment_data['user_info']['address'], $default_address); |
|
647 | 647 | |
648 | 648 | $paypal_args['address1'] = $address['line1']; |
649 | 649 | $paypal_args['address2'] = $address['line2']; |
@@ -664,13 +664,13 @@ discard block |
||
664 | 664 | * @param array $paypal_args |
665 | 665 | * @param array $payment_data |
666 | 666 | */ |
667 | - $paypal_args = apply_filters( 'give_paypal_redirect_args', $paypal_args, $payment_data ); |
|
667 | + $paypal_args = apply_filters('give_paypal_redirect_args', $paypal_args, $payment_data); |
|
668 | 668 | |
669 | 669 | // Build query. |
670 | - $paypal_redirect .= http_build_query( $paypal_args ); |
|
670 | + $paypal_redirect .= http_build_query($paypal_args); |
|
671 | 671 | |
672 | 672 | // Fix for some sites that encode the entities. |
673 | - $paypal_redirect = str_replace( '&', '&', $paypal_redirect ); |
|
673 | + $paypal_redirect = str_replace('&', '&', $paypal_redirect); |
|
674 | 674 | |
675 | 675 | return $paypal_redirect; |
676 | 676 | } |
@@ -685,7 +685,7 @@ discard block |
||
685 | 685 | function give_get_paypal_button_type() { |
686 | 686 | // paypal_button_type can be donation or standard. |
687 | 687 | $paypal_button_type = '_donations'; |
688 | - if ( 'standard' === give_get_option( 'paypal_button_type' ) ) { |
|
688 | + if ('standard' === give_get_option('paypal_button_type')) { |
|
689 | 689 | $paypal_button_type = '_xclick'; |
690 | 690 | } |
691 | 691 | |
@@ -702,30 +702,30 @@ discard block |
||
702 | 702 | * |
703 | 703 | * @return string |
704 | 704 | */ |
705 | -function give_build_paypal_item_title( $payment_data ) { |
|
706 | - $form_id = intval( $payment_data['post_data']['give-form-id'] ); |
|
705 | +function give_build_paypal_item_title($payment_data) { |
|
706 | + $form_id = intval($payment_data['post_data']['give-form-id']); |
|
707 | 707 | $item_name = $payment_data['post_data']['give-form-title']; |
708 | 708 | |
709 | 709 | // Verify has variable prices. |
710 | - if ( give_has_variable_prices( $form_id ) && isset( $payment_data['post_data']['give-price-id'] ) ) { |
|
710 | + if (give_has_variable_prices($form_id) && isset($payment_data['post_data']['give-price-id'])) { |
|
711 | 711 | |
712 | - $item_price_level_text = give_get_price_option_name( $form_id, $payment_data['post_data']['give-price-id'] ); |
|
713 | - $price_level_amount = give_get_price_option_amount( $form_id, $payment_data['post_data']['give-price-id'] ); |
|
712 | + $item_price_level_text = give_get_price_option_name($form_id, $payment_data['post_data']['give-price-id']); |
|
713 | + $price_level_amount = give_get_price_option_amount($form_id, $payment_data['post_data']['give-price-id']); |
|
714 | 714 | |
715 | 715 | // Donation given doesn't match selected level (must be a custom amount). |
716 | - if ( $price_level_amount != give_sanitize_amount( $payment_data['price'] ) ) { |
|
717 | - $custom_amount_text = give_get_meta( $form_id, '_give_custom_amount_text', true ); |
|
716 | + if ($price_level_amount != give_sanitize_amount($payment_data['price'])) { |
|
717 | + $custom_amount_text = give_get_meta($form_id, '_give_custom_amount_text', true); |
|
718 | 718 | // user custom amount text if any, fallback to default if not. |
719 | - $item_name .= ' - ' . give_check_variable( $custom_amount_text, 'empty', __( 'Custom Amount', 'give' ) ); |
|
719 | + $item_name .= ' - '.give_check_variable($custom_amount_text, 'empty', __('Custom Amount', 'give')); |
|
720 | 720 | |
721 | - } elseif ( ! empty( $item_price_level_text ) ) { |
|
722 | - $item_name .= ' - ' . $item_price_level_text; |
|
721 | + } elseif ( ! empty($item_price_level_text)) { |
|
722 | + $item_name .= ' - '.$item_price_level_text; |
|
723 | 723 | } |
724 | 724 | } // End if(). |
725 | - elseif ( give_get_form_price( $form_id ) !== give_sanitize_amount( $payment_data['price'] ) ) { |
|
726 | - $custom_amount_text = give_get_meta( $form_id, '_give_custom_amount_text', true ); |
|
725 | + elseif (give_get_form_price($form_id) !== give_sanitize_amount($payment_data['price'])) { |
|
726 | + $custom_amount_text = give_get_meta($form_id, '_give_custom_amount_text', true); |
|
727 | 727 | // user custom amount text if any, fallback to default if not. |
728 | - $item_name .= ' - ' . give_check_variable( $custom_amount_text, 'empty', __( 'Custom Amount', 'give' ) ); |
|
728 | + $item_name .= ' - '.give_check_variable($custom_amount_text, 'empty', __('Custom Amount', 'give')); |
|
729 | 729 | } |
730 | 730 | |
731 | 731 | return $item_name; |
@@ -9,11 +9,11 @@ discard block |
||
9 | 9 | * @since 1.8 |
10 | 10 | */ |
11 | 11 | |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; // Exit if accessed directly |
14 | 14 | } |
15 | 15 | |
16 | -if ( ! class_exists( 'Give_Settings_License' ) ) : |
|
16 | +if ( ! class_exists('Give_Settings_License')) : |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Give_Settings_License. |
@@ -43,10 +43,10 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function __construct() { |
45 | 45 | $this->id = 'licenses'; |
46 | - $this->label = esc_html__( 'Licenses', 'give' ); |
|
46 | + $this->label = esc_html__('Licenses', 'give'); |
|
47 | 47 | |
48 | - add_filter( 'give-settings_tabs_array', array( $this, 'add_settings_page' ), 20 ); |
|
49 | - add_action( "give-settings_settings_{$this->id}_page", array( $this, 'output' ) ); |
|
48 | + add_filter('give-settings_tabs_array', array($this, 'add_settings_page'), 20); |
|
49 | + add_action("give-settings_settings_{$this->id}_page", array($this, 'output')); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
@@ -56,11 +56,11 @@ discard block |
||
56 | 56 | * @param array $pages Lst of pages. |
57 | 57 | * @return array |
58 | 58 | */ |
59 | - public function add_settings_page( $pages ) { |
|
59 | + public function add_settings_page($pages) { |
|
60 | 60 | $setting = $this->get_settings(); |
61 | 61 | // Bailout: Do not add licenses setting tab if it does not contain any setting fields. |
62 | - if( ! empty( $setting ) ) { |
|
63 | - $pages[ $this->id ] = $this->label; |
|
62 | + if ( ! empty($setting)) { |
|
63 | + $pages[$this->id] = $this->label; |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | return $pages; |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | * Filter the licenses settings. |
80 | 80 | * Backward compatibility: Please do not use this filter. This filter is deprecated in 1.8 |
81 | 81 | */ |
82 | - $settings = apply_filters( 'give_settings_licenses', $settings ); |
|
82 | + $settings = apply_filters('give_settings_licenses', $settings); |
|
83 | 83 | |
84 | 84 | /** |
85 | 85 | * Filter the settings. |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | * @since 1.8 |
88 | 88 | * @param array $settings |
89 | 89 | */ |
90 | - $settings = apply_filters( 'give_get_settings_' . $this->id, $settings ); |
|
90 | + $settings = apply_filters('give_get_settings_'.$this->id, $settings); |
|
91 | 91 | |
92 | 92 | // Output. |
93 | 93 | return $settings; |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | public function output() { |
103 | 103 | $settings = $this->get_settings(); |
104 | 104 | |
105 | - Give_Admin_Settings::output_fields( $settings, 'give_settings' ); |
|
105 | + Give_Admin_Settings::output_fields($settings, 'give_settings'); |
|
106 | 106 | } |
107 | 107 | } |
108 | 108 |
@@ -9,11 +9,11 @@ discard block |
||
9 | 9 | * @since 1.8 |
10 | 10 | */ |
11 | 11 | |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; // Exit if accessed directly |
14 | 14 | } |
15 | 15 | |
16 | -if ( ! class_exists( 'Give_Settings_Addon' ) ) : |
|
16 | +if ( ! class_exists('Give_Settings_Addon')) : |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Give_Settings_Addon. |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | */ |
27 | 27 | public function __construct() { |
28 | 28 | $this->id = 'addons'; |
29 | - $this->label = esc_html__( 'Add-ons', 'give' ); |
|
29 | + $this->label = esc_html__('Add-ons', 'give'); |
|
30 | 30 | |
31 | 31 | parent::__construct(); |
32 | 32 | } |
@@ -38,12 +38,12 @@ discard block |
||
38 | 38 | * @param $setting_tab |
39 | 39 | * @return string |
40 | 40 | */ |
41 | - function set_default_setting_tab( $setting_tab ) { |
|
41 | + function set_default_setting_tab($setting_tab) { |
|
42 | 42 | $default_tab = ''; |
43 | 43 | |
44 | 44 | // Set default tab to first setting tab. |
45 | - if( $sections = array_keys( $this->get_sections() ) ) { |
|
46 | - $default_tab = current( $sections ); |
|
45 | + if ($sections = array_keys($this->get_sections())) { |
|
46 | + $default_tab = current($sections); |
|
47 | 47 | } |
48 | 48 | return $default_tab; |
49 | 49 | } |
@@ -55,11 +55,11 @@ discard block |
||
55 | 55 | * @param array $pages Lst of pages. |
56 | 56 | * @return array |
57 | 57 | */ |
58 | - public function add_settings_page( $pages ) { |
|
58 | + public function add_settings_page($pages) { |
|
59 | 59 | $setting = $this->get_settings(); |
60 | 60 | // Bailout: Do not add addons setting tab if it does not contain any setting fields. |
61 | - if( ! empty( $setting ) ) { |
|
62 | - $pages[ $this->id ] = $this->label; |
|
61 | + if ( ! empty($setting)) { |
|
62 | + $pages[$this->id] = $this->label; |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | return $pages; |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * Filter the addons settings. |
79 | 79 | * Backward compatibility: Please do not use this filter. This filter is deprecated in 1.8 |
80 | 80 | */ |
81 | - $settings = apply_filters( 'give_settings_addons', $settings ); |
|
81 | + $settings = apply_filters('give_settings_addons', $settings); |
|
82 | 82 | |
83 | 83 | /** |
84 | 84 | * Filter the settings. |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | * @since 1.8 |
87 | 87 | * @param array $settings |
88 | 88 | */ |
89 | - $settings = apply_filters( 'give_get_settings_' . $this->id, $settings ); |
|
89 | + $settings = apply_filters('give_get_settings_'.$this->id, $settings); |
|
90 | 90 | |
91 | 91 | // Output. |
92 | 92 | return $settings; |
@@ -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 | |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @return mixed |
28 | 28 | */ |
29 | -function _give_sanitize_number_decimals_setting_field( $value ) { |
|
30 | - return absint( $value ); |
|
29 | +function _give_sanitize_number_decimals_setting_field($value) { |
|
30 | + return absint($value); |
|
31 | 31 | } |
32 | -add_filter( 'give_admin_settings_sanitize_option_number_decimals', '_give_sanitize_number_decimals_setting_field', 10 ); |
|
33 | 32 | \ No newline at end of file |
33 | +add_filter('give_admin_settings_sanitize_option_number_decimals', '_give_sanitize_number_decimals_setting_field', 10); |
|
34 | 34 | \ No newline at end of file |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -22,19 +22,19 @@ discard block |
||
22 | 22 | */ |
23 | 23 | function give_add_shortcode_to_publish_metabox() { |
24 | 24 | |
25 | - if ( 'give_forms' !== get_post_type() ) { |
|
25 | + if ('give_forms' !== get_post_type()) { |
|
26 | 26 | return false; |
27 | 27 | } |
28 | 28 | global $post; |
29 | 29 | |
30 | 30 | //Only enqueue scripts for CPT on post type screen |
31 | - if ( 'give_forms' === $post->post_type ) { |
|
31 | + if ('give_forms' === $post->post_type) { |
|
32 | 32 | //Shortcode column with select all input |
33 | - $shortcode = htmlentities( '[give_form id="' . $post->ID . '"]' ); |
|
34 | - echo '<div class="shortcode-wrap box-sizing"><label for="shortcode-input">' . esc_html__( 'Give Form Shortcode:', 'give' ) . '</label><input onClick="this.setSelectionRange(0, this.value.length)" type="text" name="shortcode-input" id="shortcode-input" class="shortcode-input" readonly value="' . $shortcode . '"></div>'; |
|
33 | + $shortcode = htmlentities('[give_form id="'.$post->ID.'"]'); |
|
34 | + echo '<div class="shortcode-wrap box-sizing"><label for="shortcode-input">'.esc_html__('Give Form Shortcode:', 'give').'</label><input onClick="this.setSelectionRange(0, this.value.length)" type="text" name="shortcode-input" id="shortcode-input" class="shortcode-input" readonly value="'.$shortcode.'"></div>'; |
|
35 | 35 | |
36 | 36 | } |
37 | 37 | |
38 | 38 | } |
39 | 39 | |
40 | -add_action( 'post_submitbox_misc_actions', 'give_add_shortcode_to_publish_metabox' ); |
|
40 | +add_action('post_submitbox_misc_actions', 'give_add_shortcode_to_publish_metabox'); |
@@ -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,14 +24,14 @@ discard block |
||
24 | 24 | * |
25 | 25 | * @return string |
26 | 26 | */ |
27 | -function give_admin_rate_us( $footer_text ) { |
|
27 | +function give_admin_rate_us($footer_text) { |
|
28 | 28 | global $typenow; |
29 | 29 | |
30 | - if ( $typenow == 'give_forms' ) { |
|
30 | + if ($typenow == 'give_forms') { |
|
31 | 31 | $rate_text = sprintf( |
32 | 32 | /* translators: %s: Link to 5 star rating */ |
33 | - __( 'If you like <strong>Give</strong> please leave us a %s rating. It takes a minute and helps a lot. Thanks in advance!', 'give' ), |
|
34 | - '<a href="https://wordpress.org/support/view/plugin-reviews/give?filter=5#postform" target="_blank" class="give-rating-link" style="text-decoration:none;" data-rated="' . esc_attr__( 'Thanks :)', 'give' ) . '">★★★★★</a>' |
|
33 | + __('If you like <strong>Give</strong> please leave us a %s rating. It takes a minute and helps a lot. Thanks in advance!', 'give'), |
|
34 | + '<a href="https://wordpress.org/support/view/plugin-reviews/give?filter=5#postform" target="_blank" class="give-rating-link" style="text-decoration:none;" data-rated="'.esc_attr__('Thanks :)', 'give').'">★★★★★</a>' |
|
35 | 35 | ); |
36 | 36 | |
37 | 37 | return $rate_text; |
@@ -40,4 +40,4 @@ discard block |
||
40 | 40 | } |
41 | 41 | } |
42 | 42 | |
43 | -add_filter( 'admin_footer_text', 'give_admin_rate_us' ); |
|
43 | +add_filter('admin_footer_text', 'give_admin_rate_us'); |
@@ -98,7 +98,7 @@ |
||
98 | 98 | * |
99 | 99 | * @since 1.8 |
100 | 100 | * |
101 | - * @return bool |
|
101 | + * @return false|null |
|
102 | 102 | */ |
103 | 103 | function give_redirect_to_clean_url_admin_pages() { |
104 | 104 | // Give admin pages. |
@@ -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,19 +20,19 @@ discard block |
||
20 | 20 | * @since 1.8 |
21 | 21 | */ |
22 | 22 | function give_load_wp_editor() { |
23 | - if ( ! isset( $_POST['wp_editor'] ) ) { |
|
23 | + if ( ! isset($_POST['wp_editor'])) { |
|
24 | 24 | die(); |
25 | 25 | } |
26 | 26 | |
27 | - $wp_editor = json_decode( base64_decode( $_POST['wp_editor'] ), true ); |
|
27 | + $wp_editor = json_decode(base64_decode($_POST['wp_editor']), true); |
|
28 | 28 | $wp_editor[2]['textarea_name'] = $_POST['textarea_name']; |
29 | 29 | |
30 | - wp_editor( $wp_editor[0], $_POST['wp_editor_id'], $wp_editor[2] ); |
|
30 | + wp_editor($wp_editor[0], $_POST['wp_editor_id'], $wp_editor[2]); |
|
31 | 31 | |
32 | 32 | die(); |
33 | 33 | } |
34 | 34 | |
35 | -add_action( 'wp_ajax_give_load_wp_editor', 'give_load_wp_editor' ); |
|
35 | +add_action('wp_ajax_give_load_wp_editor', 'give_load_wp_editor'); |
|
36 | 36 | |
37 | 37 | |
38 | 38 | /** |
@@ -51,13 +51,13 @@ discard block |
||
51 | 51 | ); |
52 | 52 | |
53 | 53 | // Get current page. |
54 | - $current_page = isset( $_GET['page'] ) ? esc_attr( $_GET['page'] ) : ''; |
|
54 | + $current_page = isset($_GET['page']) ? esc_attr($_GET['page']) : ''; |
|
55 | 55 | |
56 | 56 | // Bailout. |
57 | 57 | if ( |
58 | - empty( $current_page ) |
|
59 | - || empty( $_GET['_wp_http_referer'] ) |
|
60 | - || ! in_array( $current_page, $give_pages ) |
|
58 | + empty($current_page) |
|
59 | + || empty($_GET['_wp_http_referer']) |
|
60 | + || ! in_array($current_page, $give_pages) |
|
61 | 61 | ) { |
62 | 62 | return false; |
63 | 63 | } |
@@ -67,21 +67,21 @@ discard block |
||
67 | 67 | * |
68 | 68 | * @since 1.8 |
69 | 69 | */ |
70 | - $redirect = apply_filters( "give_validate_{$current_page}", true ); |
|
70 | + $redirect = apply_filters("give_validate_{$current_page}", true); |
|
71 | 71 | |
72 | - if ( $redirect ) { |
|
72 | + if ($redirect) { |
|
73 | 73 | // Redirect. |
74 | 74 | wp_redirect( |
75 | 75 | remove_query_arg( |
76 | - array( '_wp_http_referer', '_wpnonce' ), |
|
77 | - wp_unslash( $_SERVER['REQUEST_URI'] ) |
|
76 | + array('_wp_http_referer', '_wpnonce'), |
|
77 | + wp_unslash($_SERVER['REQUEST_URI']) |
|
78 | 78 | ) |
79 | 79 | ); |
80 | 80 | exit; |
81 | 81 | } |
82 | 82 | } |
83 | 83 | |
84 | -add_action( 'admin_init', 'give_redirect_to_clean_url_admin_pages' ); |
|
84 | +add_action('admin_init', 'give_redirect_to_clean_url_admin_pages'); |
|
85 | 85 | |
86 | 86 | |
87 | 87 | /** |
@@ -95,25 +95,25 @@ discard block |
||
95 | 95 | */ |
96 | 96 | function give_hide_outdated_php_notice() { |
97 | 97 | |
98 | - if ( ! isset( $_POST['_give_hide_outdated_php_notices_shortly'] ) ) { |
|
98 | + if ( ! isset($_POST['_give_hide_outdated_php_notices_shortly'])) { |
|
99 | 99 | give_die(); |
100 | 100 | } |
101 | 101 | |
102 | 102 | // Transient key name. |
103 | 103 | $transient_key = "_give_hide_outdated_php_notices_shortly"; |
104 | 104 | |
105 | - if ( Give_Cache::get( $transient_key, true ) ) { |
|
105 | + if (Give_Cache::get($transient_key, true)) { |
|
106 | 106 | return; |
107 | 107 | } |
108 | 108 | |
109 | 109 | // Hide notice for 24 hours. |
110 | - Give_Cache::set( $transient_key, true, DAY_IN_SECONDS, true ); |
|
110 | + Give_Cache::set($transient_key, true, DAY_IN_SECONDS, true); |
|
111 | 111 | |
112 | 112 | give_die(); |
113 | 113 | |
114 | 114 | } |
115 | 115 | |
116 | -add_action( 'wp_ajax_give_hide_outdated_php_notice', 'give_hide_outdated_php_notice' ); |
|
116 | +add_action('wp_ajax_give_hide_outdated_php_notice', 'give_hide_outdated_php_notice'); |
|
117 | 117 | |
118 | 118 | /** |
119 | 119 | * Register admin notices. |
@@ -122,43 +122,43 @@ discard block |
||
122 | 122 | */ |
123 | 123 | function _give_register_admin_notices() { |
124 | 124 | // Bailout. |
125 | - if( ! is_admin() ) { |
|
125 | + if ( ! is_admin()) { |
|
126 | 126 | return; |
127 | 127 | } |
128 | 128 | |
129 | 129 | // Add PHP version update notice |
130 | - if ( function_exists( 'phpversion' ) && version_compare( GIVE_REQUIRED_PHP_VERSION, phpversion(), '>' ) ) { |
|
130 | + if (function_exists('phpversion') && version_compare(GIVE_REQUIRED_PHP_VERSION, phpversion(), '>')) { |
|
131 | 131 | |
132 | - $notice_desc = '<p><strong>' . __( 'Your site could be faster and more secure with a newer PHP version.', 'give' ) . '</strong></p>'; |
|
133 | - $notice_desc .= '<p>' . __( 'Hey, we\'ve noticed that you\'re running an outdated version of PHP. PHP is the programming language that WordPress and Give are built on. The version that is currently used for your site is no longer supported. Newer versions of PHP are both faster and more secure. In fact, your version of PHP no longer receives security updates, which is why we\'re sending you this notice.', 'give' ) . '</p>'; |
|
134 | - $notice_desc .= '<p>' . __( 'Hosts have the ability to update your PHP version, but sometimes they don\'t dare to do that because they\'re afraid they\'ll break your site.', 'give' ) . '</p>'; |
|
135 | - $notice_desc .= '<p><strong>' . __( 'To which version should I update?', 'give' ) . '</strong></p>'; |
|
136 | - $notice_desc .= '<p>' . __( 'You should update your PHP version to either 5.6 or to 7.0 or 7.1. On a normal WordPress site, switching to PHP 5.6 should never cause issues. We would however actually recommend you switch to PHP7. There are some plugins that are not ready for PHP7 though, so do some testing first. PHP7 is much faster than PHP 5.6. It\'s also the only PHP version still in active development and therefore the better option for your site in the long run.', 'give' ) . '</p>'; |
|
137 | - $notice_desc .= '<p><strong>' . __( 'Can\'t update? Ask your host!', 'give' ) . '</strong></p>'; |
|
138 | - $notice_desc .= '<p>' . sprintf( __( 'If you cannot upgrade your PHP version yourself, you can send an email to your host. If they don\'t want to upgrade your PHP version, we would suggest you switch hosts. Have a look at one of the recommended %1$sWordPress hosting partners%2$s.', 'give' ), sprintf( '<a href="%1$s" target="_blank">', esc_url( 'https://wordpress.org/hosting/' ) ), '</a>' ) . '</p>'; |
|
132 | + $notice_desc = '<p><strong>'.__('Your site could be faster and more secure with a newer PHP version.', 'give').'</strong></p>'; |
|
133 | + $notice_desc .= '<p>'.__('Hey, we\'ve noticed that you\'re running an outdated version of PHP. PHP is the programming language that WordPress and Give are built on. The version that is currently used for your site is no longer supported. Newer versions of PHP are both faster and more secure. In fact, your version of PHP no longer receives security updates, which is why we\'re sending you this notice.', 'give').'</p>'; |
|
134 | + $notice_desc .= '<p>'.__('Hosts have the ability to update your PHP version, but sometimes they don\'t dare to do that because they\'re afraid they\'ll break your site.', 'give').'</p>'; |
|
135 | + $notice_desc .= '<p><strong>'.__('To which version should I update?', 'give').'</strong></p>'; |
|
136 | + $notice_desc .= '<p>'.__('You should update your PHP version to either 5.6 or to 7.0 or 7.1. On a normal WordPress site, switching to PHP 5.6 should never cause issues. We would however actually recommend you switch to PHP7. There are some plugins that are not ready for PHP7 though, so do some testing first. PHP7 is much faster than PHP 5.6. It\'s also the only PHP version still in active development and therefore the better option for your site in the long run.', 'give').'</p>'; |
|
137 | + $notice_desc .= '<p><strong>'.__('Can\'t update? Ask your host!', 'give').'</strong></p>'; |
|
138 | + $notice_desc .= '<p>'.sprintf(__('If you cannot upgrade your PHP version yourself, you can send an email to your host. If they don\'t want to upgrade your PHP version, we would suggest you switch hosts. Have a look at one of the recommended %1$sWordPress hosting partners%2$s.', 'give'), sprintf('<a href="%1$s" target="_blank">', esc_url('https://wordpress.org/hosting/')), '</a>').'</p>'; |
|
139 | 139 | |
140 | - Give()->notices->register_notice( array( |
|
140 | + Give()->notices->register_notice(array( |
|
141 | 141 | 'id' => 'give-invalid-php-version', |
142 | 142 | 'type' => 'error', |
143 | 143 | 'description' => $notice_desc, |
144 | 144 | 'dismissible_type' => 'user', |
145 | 145 | 'dismiss_interval' => 'shortly', |
146 | - ) ); |
|
146 | + )); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | // Add payment bulk notice. |
150 | 150 | if ( |
151 | - current_user_can( 'edit_give_payments' ) |
|
152 | - && isset( $_GET['action'] ) |
|
153 | - && ! empty( $_GET['action'] ) |
|
154 | - && isset( $_GET['payment'] ) |
|
155 | - && ! empty( $_GET['payment'] ) |
|
151 | + current_user_can('edit_give_payments') |
|
152 | + && isset($_GET['action']) |
|
153 | + && ! empty($_GET['action']) |
|
154 | + && isset($_GET['payment']) |
|
155 | + && ! empty($_GET['payment']) |
|
156 | 156 | ) { |
157 | - $payment_count = isset( $_GET['payment'] ) ? count( $_GET['payment'] ) : 0; |
|
157 | + $payment_count = isset($_GET['payment']) ? count($_GET['payment']) : 0; |
|
158 | 158 | |
159 | - switch ( $_GET['action'] ) { |
|
159 | + switch ($_GET['action']) { |
|
160 | 160 | case 'delete': |
161 | - Give()->notices->register_notice( array( |
|
161 | + Give()->notices->register_notice(array( |
|
162 | 162 | 'id' => 'bulk_action_delete', |
163 | 163 | 'type' => 'updated', |
164 | 164 | 'description' => sprintf( |
@@ -170,12 +170,12 @@ discard block |
||
170 | 170 | ), |
171 | 171 | $payment_count ), |
172 | 172 | 'show' => true, |
173 | - ) ); |
|
173 | + )); |
|
174 | 174 | |
175 | 175 | break; |
176 | 176 | |
177 | 177 | case 'resend-receipt': |
178 | - Give()->notices->register_notice( array( |
|
178 | + Give()->notices->register_notice(array( |
|
179 | 179 | 'id' => 'bulk_action_resend_receipt', |
180 | 180 | 'type' => 'updated', |
181 | 181 | 'description' => sprintf( |
@@ -188,196 +188,196 @@ discard block |
||
188 | 188 | $payment_count |
189 | 189 | ), |
190 | 190 | 'show' => true, |
191 | - ) ); |
|
191 | + )); |
|
192 | 192 | break; |
193 | 193 | } |
194 | 194 | } |
195 | 195 | |
196 | 196 | // Add give message notices. |
197 | - if ( ! empty( $_GET['give-message'] ) ) { |
|
197 | + if ( ! empty($_GET['give-message'])) { |
|
198 | 198 | // Donation reports errors. |
199 | - if ( current_user_can( 'view_give_reports' ) ) { |
|
200 | - switch ( $_GET['give-message'] ) { |
|
199 | + if (current_user_can('view_give_reports')) { |
|
200 | + switch ($_GET['give-message']) { |
|
201 | 201 | case 'donation_deleted' : |
202 | - Give()->notices->register_notice( array( |
|
202 | + Give()->notices->register_notice(array( |
|
203 | 203 | 'id' => 'give-donation-deleted', |
204 | 204 | 'type' => 'updated', |
205 | - 'description' => __( 'The donation has been deleted.', 'give' ), |
|
205 | + 'description' => __('The donation has been deleted.', 'give'), |
|
206 | 206 | 'show' => true, |
207 | - ) ); |
|
207 | + )); |
|
208 | 208 | break; |
209 | 209 | case 'email_sent' : |
210 | - Give()->notices->register_notice( array( |
|
210 | + Give()->notices->register_notice(array( |
|
211 | 211 | 'id' => 'give-payment-sent', |
212 | 212 | 'type' => 'updated', |
213 | - 'description' => __( 'The donation receipt has been resent.', 'give' ), |
|
213 | + 'description' => __('The donation receipt has been resent.', 'give'), |
|
214 | 214 | 'show' => true, |
215 | - ) ); |
|
215 | + )); |
|
216 | 216 | break; |
217 | 217 | case 'refreshed-reports' : |
218 | - Give()->notices->register_notice( array( |
|
218 | + Give()->notices->register_notice(array( |
|
219 | 219 | 'id' => 'give-refreshed-reports', |
220 | 220 | 'type' => 'updated', |
221 | - 'description' => __( 'The reports cache has been cleared.', 'give' ), |
|
221 | + 'description' => __('The reports cache has been cleared.', 'give'), |
|
222 | 222 | 'show' => true, |
223 | - ) ); |
|
223 | + )); |
|
224 | 224 | break; |
225 | 225 | case 'donation-note-deleted' : |
226 | - Give()->notices->register_notice( array( |
|
226 | + Give()->notices->register_notice(array( |
|
227 | 227 | 'id' => 'give-donation-note-deleted', |
228 | 228 | 'type' => 'updated', |
229 | - 'description' => __( 'The donation note has been deleted.', 'give' ), |
|
229 | + 'description' => __('The donation note has been deleted.', 'give'), |
|
230 | 230 | 'show' => true, |
231 | - ) ); |
|
231 | + )); |
|
232 | 232 | break; |
233 | 233 | } |
234 | 234 | } |
235 | 235 | |
236 | 236 | // Give settings notices and errors. |
237 | - if ( current_user_can( 'manage_give_settings' ) ) { |
|
238 | - switch ( $_GET['give-message'] ) { |
|
237 | + if (current_user_can('manage_give_settings')) { |
|
238 | + switch ($_GET['give-message']) { |
|
239 | 239 | case 'settings-imported' : |
240 | - Give()->notices->register_notice( array( |
|
240 | + Give()->notices->register_notice(array( |
|
241 | 241 | 'id' => 'give-settings-imported', |
242 | 242 | 'type' => 'updated', |
243 | - 'description' => __( 'The settings have been imported.', 'give' ), |
|
243 | + 'description' => __('The settings have been imported.', 'give'), |
|
244 | 244 | 'show' => true, |
245 | - ) ); |
|
245 | + )); |
|
246 | 246 | break; |
247 | 247 | case 'api-key-generated' : |
248 | - Give()->notices->register_notice( array( |
|
248 | + Give()->notices->register_notice(array( |
|
249 | 249 | 'id' => 'give-api-key-generated', |
250 | 250 | 'type' => 'updated', |
251 | - 'description' => __( 'API keys have been generated.', 'give' ), |
|
251 | + 'description' => __('API keys have been generated.', 'give'), |
|
252 | 252 | 'show' => true, |
253 | - ) ); |
|
253 | + )); |
|
254 | 254 | break; |
255 | 255 | case 'api-key-exists' : |
256 | - Give()->notices->register_notice( array( |
|
256 | + Give()->notices->register_notice(array( |
|
257 | 257 | 'id' => 'give-api-key-exists', |
258 | 258 | 'type' => 'updated', |
259 | - 'description' => __( 'The specified user already has API keys.', 'give' ), |
|
259 | + 'description' => __('The specified user already has API keys.', 'give'), |
|
260 | 260 | 'show' => true, |
261 | - ) ); |
|
261 | + )); |
|
262 | 262 | break; |
263 | 263 | case 'api-key-regenerated' : |
264 | - Give()->notices->register_notice( array( |
|
264 | + Give()->notices->register_notice(array( |
|
265 | 265 | 'id' => 'give-api-key-regenerated', |
266 | 266 | 'type' => 'updated', |
267 | - 'description' => __( 'API keys have been regenerated.', 'give' ), |
|
267 | + 'description' => __('API keys have been regenerated.', 'give'), |
|
268 | 268 | 'show' => true, |
269 | - ) ); |
|
269 | + )); |
|
270 | 270 | break; |
271 | 271 | case 'api-key-revoked' : |
272 | - Give()->notices->register_notice( array( |
|
272 | + Give()->notices->register_notice(array( |
|
273 | 273 | 'id' => 'give-api-key-revoked', |
274 | 274 | 'type' => 'updated', |
275 | - 'description' => __( 'API keys have been revoked.', 'give' ), |
|
275 | + 'description' => __('API keys have been revoked.', 'give'), |
|
276 | 276 | 'show' => true, |
277 | - ) ); |
|
277 | + )); |
|
278 | 278 | break; |
279 | 279 | case 'sent-test-email' : |
280 | - Give()->notices->register_notice( array( |
|
280 | + Give()->notices->register_notice(array( |
|
281 | 281 | 'id' => 'give-sent-test-email', |
282 | 282 | 'type' => 'updated', |
283 | - 'description' => __( 'The test email has been sent.', 'give' ), |
|
283 | + 'description' => __('The test email has been sent.', 'give'), |
|
284 | 284 | 'show' => true, |
285 | - ) ); |
|
285 | + )); |
|
286 | 286 | break; |
287 | 287 | case 'matched-success-failure-page': |
288 | - Give()->notices->register_notice( array( |
|
288 | + Give()->notices->register_notice(array( |
|
289 | 289 | 'id' => 'give-matched-success-failure-page', |
290 | 290 | 'type' => 'updated', |
291 | - 'description' => __( 'You cannot set the success and failed pages to the same page', 'give' ), |
|
291 | + 'description' => __('You cannot set the success and failed pages to the same page', 'give'), |
|
292 | 292 | 'show' => true, |
293 | - ) ); |
|
293 | + )); |
|
294 | 294 | break; |
295 | 295 | } |
296 | 296 | } |
297 | 297 | // Payments errors. |
298 | - if ( current_user_can( 'edit_give_payments' ) ) { |
|
299 | - switch ( $_GET['give-message'] ) { |
|
298 | + if (current_user_can('edit_give_payments')) { |
|
299 | + switch ($_GET['give-message']) { |
|
300 | 300 | case 'note-added' : |
301 | - Give()->notices->register_notice( array( |
|
301 | + Give()->notices->register_notice(array( |
|
302 | 302 | 'id' => 'give-note-added', |
303 | 303 | 'type' => 'updated', |
304 | - 'description' => __( 'The donation note has been added.', 'give' ), |
|
304 | + 'description' => __('The donation note has been added.', 'give'), |
|
305 | 305 | 'show' => true, |
306 | - ) ); |
|
306 | + )); |
|
307 | 307 | break; |
308 | 308 | case 'payment-updated' : |
309 | - Give()->notices->register_notice( array( |
|
309 | + Give()->notices->register_notice(array( |
|
310 | 310 | 'id' => 'give-payment-updated', |
311 | 311 | 'type' => 'updated', |
312 | - 'description' => __( 'The donation has been updated.', 'give' ), |
|
312 | + 'description' => __('The donation has been updated.', 'give'), |
|
313 | 313 | 'show' => true, |
314 | - ) ); |
|
314 | + )); |
|
315 | 315 | break; |
316 | 316 | } |
317 | 317 | } |
318 | 318 | |
319 | 319 | // Donor Notices. |
320 | - if ( current_user_can( 'edit_give_payments' ) ) { |
|
321 | - switch ( $_GET['give-message'] ) { |
|
320 | + if (current_user_can('edit_give_payments')) { |
|
321 | + switch ($_GET['give-message']) { |
|
322 | 322 | case 'donor-deleted' : |
323 | - Give()->notices->register_notice( array( |
|
323 | + Give()->notices->register_notice(array( |
|
324 | 324 | 'id' => 'give-donor-deleted', |
325 | 325 | 'type' => 'updated', |
326 | - 'description' => __( 'The donor has been deleted.', 'give' ), |
|
326 | + 'description' => __('The donor has been deleted.', 'give'), |
|
327 | 327 | 'show' => true, |
328 | - ) ); |
|
328 | + )); |
|
329 | 329 | break; |
330 | 330 | |
331 | 331 | case 'email-added' : |
332 | - Give()->notices->register_notice( array( |
|
332 | + Give()->notices->register_notice(array( |
|
333 | 333 | 'id' => 'give-donor-email-added', |
334 | 334 | 'type' => 'updated', |
335 | - 'description' => __( 'Donor email added.', 'give' ), |
|
335 | + 'description' => __('Donor email added.', 'give'), |
|
336 | 336 | 'show' => true, |
337 | - ) ); |
|
337 | + )); |
|
338 | 338 | break; |
339 | 339 | |
340 | 340 | case 'email-removed' : |
341 | - Give()->notices->register_notice( array( |
|
341 | + Give()->notices->register_notice(array( |
|
342 | 342 | 'id' => 'give-donor-email-removed', |
343 | 343 | 'type' => 'updated', |
344 | - 'description' => __( 'Donor email removed.', 'give' ), |
|
344 | + 'description' => __('Donor email removed.', 'give'), |
|
345 | 345 | 'show' => true, |
346 | - ) ); |
|
346 | + )); |
|
347 | 347 | break; |
348 | 348 | |
349 | 349 | case 'email-remove-failed' : |
350 | - Give()->notices->register_notice( array( |
|
350 | + Give()->notices->register_notice(array( |
|
351 | 351 | 'id' => 'give-donor-email-remove-failed', |
352 | 352 | 'type' => 'updated', |
353 | - 'description' => __( 'Failed to remove donor email.', 'give' ), |
|
353 | + 'description' => __('Failed to remove donor email.', 'give'), |
|
354 | 354 | 'show' => true, |
355 | - ) ); |
|
355 | + )); |
|
356 | 356 | break; |
357 | 357 | |
358 | 358 | case 'primary-email-updated' : |
359 | - Give()->notices->register_notice( array( |
|
359 | + Give()->notices->register_notice(array( |
|
360 | 360 | 'id' => 'give-donor-primary-email-updated', |
361 | 361 | 'type' => 'updated', |
362 | - 'description' => __( 'Primary email updated for donor.', 'give' ), |
|
362 | + 'description' => __('Primary email updated for donor.', 'give'), |
|
363 | 363 | 'show' => true, |
364 | - ) ); |
|
364 | + )); |
|
365 | 365 | break; |
366 | 366 | |
367 | 367 | case 'primary-email-failed' : |
368 | - Give()->notices->register_notice( array( |
|
368 | + Give()->notices->register_notice(array( |
|
369 | 369 | 'id' => 'give-donor-primary-email-failed', |
370 | 370 | 'type' => 'updated', |
371 | - 'description' => __( 'Failed to set primary email.', 'give' ), |
|
371 | + 'description' => __('Failed to set primary email.', 'give'), |
|
372 | 372 | 'show' => true, |
373 | - ) ); |
|
373 | + )); |
|
374 | 374 | break; |
375 | 375 | } |
376 | 376 | } |
377 | 377 | } |
378 | 378 | } |
379 | 379 | |
380 | -add_action( 'admin_notices', '_give_register_admin_notices', - 1 ); |
|
380 | +add_action('admin_notices', '_give_register_admin_notices', - 1); |
|
381 | 381 | |
382 | 382 | |
383 | 383 | /** |
@@ -387,27 +387,26 @@ discard block |
||
387 | 387 | * |
388 | 388 | * @return bool |
389 | 389 | */ |
390 | -function _give_show_test_mode_notice_in_admin_bar( $wp_admin_bar ) { |
|
391 | - $is_test_mode = ! empty( $_POST['test_mode'] ) ? |
|
392 | - give_is_setting_enabled( $_POST['test_mode'] ) : |
|
393 | - give_is_test_mode(); |
|
390 | +function _give_show_test_mode_notice_in_admin_bar($wp_admin_bar) { |
|
391 | + $is_test_mode = ! empty($_POST['test_mode']) ? |
|
392 | + give_is_setting_enabled($_POST['test_mode']) : give_is_test_mode(); |
|
394 | 393 | |
395 | 394 | if ( |
396 | - ! current_user_can( 'view_give_reports' ) || |
|
395 | + ! current_user_can('view_give_reports') || |
|
397 | 396 | ! $is_test_mode |
398 | 397 | ) { |
399 | 398 | return false; |
400 | 399 | } |
401 | 400 | |
402 | 401 | // Add the main siteadmin menu item. |
403 | - $wp_admin_bar->add_menu( array( |
|
402 | + $wp_admin_bar->add_menu(array( |
|
404 | 403 | 'id' => 'give-test-notice', |
405 | - 'href' => admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=gateways' ), |
|
404 | + 'href' => admin_url('edit.php?post_type=give_forms&page=give-settings&tab=gateways'), |
|
406 | 405 | 'parent' => 'top-secondary', |
407 | - 'title' => esc_html__( 'Give Test Mode Active', 'give' ), |
|
408 | - 'meta' => array( 'class' => 'give-test-mode-active' ), |
|
409 | - ) ); |
|
406 | + 'title' => esc_html__('Give Test Mode Active', 'give'), |
|
407 | + 'meta' => array('class' => 'give-test-mode-active'), |
|
408 | + )); |
|
410 | 409 | |
411 | 410 | return true; |
412 | 411 | } |
413 | -add_action( 'admin_bar_menu', '_give_show_test_mode_notice_in_admin_bar', 1000, 1 ); |
|
414 | 412 | \ No newline at end of file |
413 | +add_action('admin_bar_menu', '_give_show_test_mode_notice_in_admin_bar', 1000, 1); |
|
415 | 414 | \ No newline at end of file |