@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | // Retrieve the payment ID |
38 | 38 | $payment_id = absint( $data['give_payment_id'] ); |
39 | 39 | |
40 | - /* @var Give_Payment $payment */ |
|
40 | + /* @var Give_Payment $payment */ |
|
41 | 41 | $payment = new Give_Payment( $payment_id ); |
42 | 42 | |
43 | 43 | // Retrieve existing payment meta |
@@ -160,23 +160,23 @@ discard block |
||
160 | 160 | |
161 | 161 | if ( 'publish' == $status ) { |
162 | 162 | |
163 | - // Reduce previous user donation count and amount. |
|
164 | - $previous_customer->decrease_purchase_count(); |
|
165 | - $previous_customer->decrease_value( $curr_total ); |
|
163 | + // Reduce previous user donation count and amount. |
|
164 | + $previous_customer->decrease_purchase_count(); |
|
165 | + $previous_customer->decrease_value( $curr_total ); |
|
166 | 166 | |
167 | - // If donation was completed adjust stats of new customers. |
|
168 | - $customer->increase_purchase_count(); |
|
167 | + // If donation was completed adjust stats of new customers. |
|
168 | + $customer->increase_purchase_count(); |
|
169 | 169 | $customer->increase_value( $new_total ); |
170 | 170 | } |
171 | 171 | |
172 | 172 | $payment->customer_id = $customer->id; |
173 | 173 | } else{ |
174 | 174 | |
175 | - if( 'publish' === $status ){ |
|
176 | - // Update user donation stat. |
|
177 | - $customer->update_donation_value( $curr_total, $new_total ); |
|
178 | - } |
|
179 | - } |
|
175 | + if( 'publish' === $status ){ |
|
176 | + // Update user donation stat. |
|
177 | + $customer->update_donation_value( $curr_total, $new_total ); |
|
178 | + } |
|
179 | + } |
|
180 | 180 | |
181 | 181 | // Set new meta values |
182 | 182 | $payment->user_id = $customer->user_id; |
@@ -217,76 +217,76 @@ discard block |
||
217 | 217 | |
218 | 218 | $payment->save(); |
219 | 219 | |
220 | - // Get new give form ID. |
|
221 | - $new_form_id = absint( $data['forms'] ); |
|
222 | - $current_form_id = absint( $payment->get_meta( '_give_payment_form_id' ) ); |
|
220 | + // Get new give form ID. |
|
221 | + $new_form_id = absint( $data['forms'] ); |
|
222 | + $current_form_id = absint( $payment->get_meta( '_give_payment_form_id' ) ); |
|
223 | 223 | |
224 | - // We are adding payment transfer code in last to remove any conflict with above functionality. |
|
225 | - // For example: above code will automatically handle form stat (increase/decrease) when payment status changes. |
|
226 | - /* Check if user want to transfer current payment to new give form id. */ |
|
227 | - if( $new_form_id != $current_form_id ) { |
|
224 | + // We are adding payment transfer code in last to remove any conflict with above functionality. |
|
225 | + // For example: above code will automatically handle form stat (increase/decrease) when payment status changes. |
|
226 | + /* Check if user want to transfer current payment to new give form id. */ |
|
227 | + if( $new_form_id != $current_form_id ) { |
|
228 | 228 | |
229 | - // Get new give form title. |
|
230 | - $new_form_title = get_the_title( $new_form_id ); |
|
229 | + // Get new give form title. |
|
230 | + $new_form_title = get_the_title( $new_form_id ); |
|
231 | 231 | |
232 | - // Update new give form data in payment data. |
|
233 | - $payment_meta = $payment->get_meta(); |
|
234 | - $payment_meta['form_title'] = $new_form_title; |
|
235 | - $payment_meta['form_id'] = $new_form_id; |
|
232 | + // Update new give form data in payment data. |
|
233 | + $payment_meta = $payment->get_meta(); |
|
234 | + $payment_meta['form_title'] = $new_form_title; |
|
235 | + $payment_meta['form_id'] = $new_form_id; |
|
236 | 236 | |
237 | - // Update price id post meta data for set donation form. |
|
238 | - if( ! give_has_variable_prices( $new_form_id ) ) { |
|
239 | - $payment_meta['price_id'] = ''; |
|
240 | - } |
|
237 | + // Update price id post meta data for set donation form. |
|
238 | + if( ! give_has_variable_prices( $new_form_id ) ) { |
|
239 | + $payment_meta['price_id'] = ''; |
|
240 | + } |
|
241 | 241 | |
242 | - // Update payment give form meta data. |
|
243 | - $payment->update_meta( '_give_payment_form_id', $new_form_id ); |
|
244 | - $payment->update_meta( '_give_payment_form_title', $new_form_title ); |
|
245 | - $payment->update_meta( '_give_payment_meta', $payment_meta ); |
|
242 | + // Update payment give form meta data. |
|
243 | + $payment->update_meta( '_give_payment_form_id', $new_form_id ); |
|
244 | + $payment->update_meta( '_give_payment_form_title', $new_form_title ); |
|
245 | + $payment->update_meta( '_give_payment_meta', $payment_meta ); |
|
246 | 246 | |
247 | - // Update price id payment metadata. |
|
248 | - if( ! give_has_variable_prices( $new_form_id ) ) { |
|
249 | - $payment->update_meta( '_give_payment_price_id', '' ); |
|
250 | - } |
|
247 | + // Update price id payment metadata. |
|
248 | + if( ! give_has_variable_prices( $new_form_id ) ) { |
|
249 | + $payment->update_meta( '_give_payment_price_id', '' ); |
|
250 | + } |
|
251 | 251 | |
252 | 252 | |
253 | - // If donation was completed, adjust stats of forms |
|
254 | - if ( 'publish' == $status ) { |
|
253 | + // If donation was completed, adjust stats of forms |
|
254 | + if ( 'publish' == $status ) { |
|
255 | 255 | |
256 | - // Decrease sale of old give form. For other payment status |
|
257 | - $current_form = new Give_Donate_Form( $current_form_id ); |
|
258 | - $current_form->decrease_sales(); |
|
259 | - $current_form->decrease_earnings( $curr_total ); |
|
256 | + // Decrease sale of old give form. For other payment status |
|
257 | + $current_form = new Give_Donate_Form( $current_form_id ); |
|
258 | + $current_form->decrease_sales(); |
|
259 | + $current_form->decrease_earnings( $curr_total ); |
|
260 | 260 | |
261 | - // Increase sale of new give form. |
|
262 | - $new_form = new Give_Donate_Form($new_form_id); |
|
263 | - $new_form->increase_sales(); |
|
264 | - $new_form->increase_earnings($new_total); |
|
265 | - } |
|
261 | + // Increase sale of new give form. |
|
262 | + $new_form = new Give_Donate_Form($new_form_id); |
|
263 | + $new_form->increase_sales(); |
|
264 | + $new_form->increase_earnings($new_total); |
|
265 | + } |
|
266 | 266 | |
267 | - // Re setup payment to update new meta value in object. |
|
268 | - $payment->update_payment_setup( $payment->ID ); |
|
269 | - } |
|
267 | + // Re setup payment to update new meta value in object. |
|
268 | + $payment->update_payment_setup( $payment->ID ); |
|
269 | + } |
|
270 | 270 | |
271 | - // Update price id if current form is variable form. |
|
272 | - if( ! empty( $data['give-variable-price'] ) && give_has_variable_prices( $payment->form_id ) ) { |
|
271 | + // Update price id if current form is variable form. |
|
272 | + if( ! empty( $data['give-variable-price'] ) && give_has_variable_prices( $payment->form_id ) ) { |
|
273 | 273 | |
274 | - // Get payment meta data. |
|
275 | - $payment_meta = $payment->get_meta(); |
|
274 | + // Get payment meta data. |
|
275 | + $payment_meta = $payment->get_meta(); |
|
276 | 276 | |
277 | - // Set payment id to empty string if variable price id is negative ( i.e. custom amount feature enabled ). |
|
278 | - $data['give-variable-price'] = ( 'custom' === $data['give-variable-price'] ) ? 'custom' : ( 0 < $data['give-variable-price'] ) ? $data['give-variable-price'] : ''; |
|
277 | + // Set payment id to empty string if variable price id is negative ( i.e. custom amount feature enabled ). |
|
278 | + $data['give-variable-price'] = ( 'custom' === $data['give-variable-price'] ) ? 'custom' : ( 0 < $data['give-variable-price'] ) ? $data['give-variable-price'] : ''; |
|
279 | 279 | |
280 | - // Update payment meta data. |
|
281 | - $payment_meta['price_id'] = $data['give-variable-price']; |
|
280 | + // Update payment meta data. |
|
281 | + $payment_meta['price_id'] = $data['give-variable-price']; |
|
282 | 282 | |
283 | - // Update payment give form meta data. |
|
284 | - $payment->update_meta( '_give_payment_price_id', $data['give-variable-price'] ); |
|
285 | - $payment->update_meta( '_give_payment_meta', $payment_meta ); |
|
283 | + // Update payment give form meta data. |
|
284 | + $payment->update_meta( '_give_payment_price_id', $data['give-variable-price'] ); |
|
285 | + $payment->update_meta( '_give_payment_meta', $payment_meta ); |
|
286 | 286 | |
287 | - // Re setup payment to update new meta value in object. |
|
288 | - $payment->update_payment_setup( $payment->ID ); |
|
289 | - } |
|
287 | + // Re setup payment to update new meta value in object. |
|
288 | + $payment->update_payment_setup( $payment->ID ); |
|
289 | + } |
|
290 | 290 | |
291 | 291 | /** |
292 | 292 | * Fires after updating edited donation. |
@@ -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,52 +26,52 @@ discard block |
||
26 | 26 | * @return void |
27 | 27 | * |
28 | 28 | */ |
29 | -function give_update_payment_details( $data ) { |
|
29 | +function give_update_payment_details($data) { |
|
30 | 30 | |
31 | - if ( ! current_user_can( 'edit_give_payments', $data['give_payment_id'] ) ) { |
|
32 | - wp_die( esc_html__( 'You do not have permission to edit payments.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
31 | + if ( ! current_user_can('edit_give_payments', $data['give_payment_id'])) { |
|
32 | + wp_die(esc_html__('You do not have permission to edit payments.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
33 | 33 | } |
34 | 34 | |
35 | - check_admin_referer( 'give_update_payment_details_nonce' ); |
|
35 | + check_admin_referer('give_update_payment_details_nonce'); |
|
36 | 36 | |
37 | 37 | // Retrieve the payment ID |
38 | - $payment_id = absint( $data['give_payment_id'] ); |
|
38 | + $payment_id = absint($data['give_payment_id']); |
|
39 | 39 | |
40 | 40 | /* @var Give_Payment $payment */ |
41 | - $payment = new Give_Payment( $payment_id ); |
|
41 | + $payment = new Give_Payment($payment_id); |
|
42 | 42 | |
43 | 43 | // Retrieve existing payment meta |
44 | 44 | $meta = $payment->get_meta(); |
45 | 45 | $user_info = $payment->user_info; |
46 | 46 | |
47 | 47 | $status = $data['give-payment-status']; |
48 | - $date = sanitize_text_field( $data['give-payment-date'] ); |
|
49 | - $hour = sanitize_text_field( $data['give-payment-time-hour'] ); |
|
48 | + $date = sanitize_text_field($data['give-payment-date']); |
|
49 | + $hour = sanitize_text_field($data['give-payment-time-hour']); |
|
50 | 50 | |
51 | 51 | // Restrict to our high and low |
52 | - if ( $hour > 23 ) { |
|
52 | + if ($hour > 23) { |
|
53 | 53 | $hour = 23; |
54 | - } elseif ( $hour < 0 ) { |
|
54 | + } elseif ($hour < 0) { |
|
55 | 55 | $hour = 00; |
56 | 56 | } |
57 | 57 | |
58 | - $minute = sanitize_text_field( $data['give-payment-time-min'] ); |
|
58 | + $minute = sanitize_text_field($data['give-payment-time-min']); |
|
59 | 59 | |
60 | 60 | // Restrict to our high and low |
61 | - if ( $minute > 59 ) { |
|
61 | + if ($minute > 59) { |
|
62 | 62 | $minute = 59; |
63 | - } elseif ( $minute < 0 ) { |
|
63 | + } elseif ($minute < 0) { |
|
64 | 64 | $minute = 00; |
65 | 65 | } |
66 | 66 | |
67 | - $address = array_map( 'trim', $data['give-payment-address'][0] ); |
|
67 | + $address = array_map('trim', $data['give-payment-address'][0]); |
|
68 | 68 | |
69 | - $curr_total = give_sanitize_amount( $payment->total ); |
|
70 | - $new_total = give_sanitize_amount( $data['give-payment-total'] ); |
|
71 | - $date = date( 'Y-m-d', strtotime( $date ) ) . ' ' . $hour . ':' . $minute . ':00'; |
|
69 | + $curr_total = give_sanitize_amount($payment->total); |
|
70 | + $new_total = give_sanitize_amount($data['give-payment-total']); |
|
71 | + $date = date('Y-m-d', strtotime($date)).' '.$hour.':'.$minute.':00'; |
|
72 | 72 | |
73 | - $curr_customer_id = sanitize_text_field( $data['give-current-customer'] ); |
|
74 | - $new_customer_id = sanitize_text_field( $data['customer-id'] ); |
|
73 | + $curr_customer_id = sanitize_text_field($data['give-current-customer']); |
|
74 | + $new_customer_id = sanitize_text_field($data['customer-id']); |
|
75 | 75 | |
76 | 76 | /** |
77 | 77 | * Fires before updating edited donation. |
@@ -80,62 +80,62 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @param int $payment_id The ID of the payment. |
82 | 82 | */ |
83 | - do_action( 'give_update_edited_purchase', $payment_id ); |
|
83 | + do_action('give_update_edited_purchase', $payment_id); |
|
84 | 84 | |
85 | 85 | $payment->date = $date; |
86 | 86 | $updated = $payment->save(); |
87 | 87 | |
88 | - if ( 0 === $updated ) { |
|
89 | - wp_die( esc_html__( 'Error Updating Donation.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) ); |
|
88 | + if (0 === $updated) { |
|
89 | + wp_die(esc_html__('Error Updating Donation.', 'give'), esc_html__('Error', 'give'), array('response' => 400)); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | |
93 | 93 | $customer_changed = false; |
94 | 94 | |
95 | - if ( isset( $data['give-new-customer'] ) && $data['give-new-customer'] == '1' ) { |
|
95 | + if (isset($data['give-new-customer']) && $data['give-new-customer'] == '1') { |
|
96 | 96 | |
97 | - $email = isset( $data['give-new-customer-email'] ) ? sanitize_text_field( $data['give-new-customer-email'] ) : ''; |
|
98 | - $names = isset( $data['give-new-customer-name'] ) ? sanitize_text_field( $data['give-new-customer-name'] ) : ''; |
|
97 | + $email = isset($data['give-new-customer-email']) ? sanitize_text_field($data['give-new-customer-email']) : ''; |
|
98 | + $names = isset($data['give-new-customer-name']) ? sanitize_text_field($data['give-new-customer-name']) : ''; |
|
99 | 99 | |
100 | - if ( empty( $email ) || empty( $names ) ) { |
|
101 | - wp_die( esc_html__( 'New Customers require a name and email address.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) ); |
|
100 | + if (empty($email) || empty($names)) { |
|
101 | + wp_die(esc_html__('New Customers require a name and email address.', 'give'), esc_html__('Error', 'give'), array('response' => 400)); |
|
102 | 102 | } |
103 | 103 | |
104 | - $customer = new Give_Customer( $email ); |
|
105 | - if ( empty( $customer->id ) ) { |
|
106 | - $customer_data = array( 'name' => $names, 'email' => $email ); |
|
107 | - $user_id = email_exists( $email ); |
|
108 | - if ( false !== $user_id ) { |
|
104 | + $customer = new Give_Customer($email); |
|
105 | + if (empty($customer->id)) { |
|
106 | + $customer_data = array('name' => $names, 'email' => $email); |
|
107 | + $user_id = email_exists($email); |
|
108 | + if (false !== $user_id) { |
|
109 | 109 | $customer_data['user_id'] = $user_id; |
110 | 110 | } |
111 | 111 | |
112 | - if ( ! $customer->create( $customer_data ) ) { |
|
112 | + if ( ! $customer->create($customer_data)) { |
|
113 | 113 | // Failed to crete the new donor, assume the previous donor |
114 | 114 | $customer_changed = false; |
115 | - $customer = new Give_Customer( $curr_customer_id ); |
|
116 | - give_set_error( 'give-payment-new-customer-fail', esc_html__( 'Error creating new donor.', 'give' ) ); |
|
115 | + $customer = new Give_Customer($curr_customer_id); |
|
116 | + give_set_error('give-payment-new-customer-fail', esc_html__('Error creating new donor.', 'give')); |
|
117 | 117 | } |
118 | 118 | } |
119 | 119 | |
120 | 120 | $new_customer_id = $customer->id; |
121 | 121 | |
122 | - $previous_customer = new Give_Customer( $curr_customer_id ); |
|
122 | + $previous_customer = new Give_Customer($curr_customer_id); |
|
123 | 123 | |
124 | 124 | $customer_changed = true; |
125 | 125 | |
126 | - } elseif ( $curr_customer_id !== $new_customer_id ) { |
|
126 | + } elseif ($curr_customer_id !== $new_customer_id) { |
|
127 | 127 | |
128 | - $customer = new Give_Customer( $new_customer_id ); |
|
128 | + $customer = new Give_Customer($new_customer_id); |
|
129 | 129 | $email = $customer->email; |
130 | 130 | $names = $customer->name; |
131 | 131 | |
132 | - $previous_customer = new Give_Customer( $curr_customer_id ); |
|
132 | + $previous_customer = new Give_Customer($curr_customer_id); |
|
133 | 133 | |
134 | 134 | $customer_changed = true; |
135 | 135 | |
136 | 136 | } else { |
137 | 137 | |
138 | - $customer = new Give_Customer( $curr_customer_id ); |
|
138 | + $customer = new Give_Customer($curr_customer_id); |
|
139 | 139 | $email = $customer->email; |
140 | 140 | $names = $customer->name; |
141 | 141 | |
@@ -143,38 +143,38 @@ discard block |
||
143 | 143 | |
144 | 144 | |
145 | 145 | // Setup first and last name from input values |
146 | - $names = explode( ' ', $names ); |
|
147 | - $first_name = ! empty( $names[0] ) ? $names[0] : ''; |
|
146 | + $names = explode(' ', $names); |
|
147 | + $first_name = ! empty($names[0]) ? $names[0] : ''; |
|
148 | 148 | $last_name = ''; |
149 | - if ( ! empty( $names[1] ) ) { |
|
150 | - unset( $names[0] ); |
|
151 | - $last_name = implode( ' ', $names ); |
|
149 | + if ( ! empty($names[1])) { |
|
150 | + unset($names[0]); |
|
151 | + $last_name = implode(' ', $names); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | |
155 | - if ( $customer_changed ) { |
|
155 | + if ($customer_changed) { |
|
156 | 156 | |
157 | 157 | // Remove the stats and payment from the previous customer and attach it to the new customer |
158 | - $previous_customer->remove_payment( $payment_id, false ); |
|
159 | - $customer->attach_payment( $payment_id, false ); |
|
158 | + $previous_customer->remove_payment($payment_id, false); |
|
159 | + $customer->attach_payment($payment_id, false); |
|
160 | 160 | |
161 | - if ( 'publish' == $status ) { |
|
161 | + if ('publish' == $status) { |
|
162 | 162 | |
163 | 163 | // Reduce previous user donation count and amount. |
164 | 164 | $previous_customer->decrease_purchase_count(); |
165 | - $previous_customer->decrease_value( $curr_total ); |
|
165 | + $previous_customer->decrease_value($curr_total); |
|
166 | 166 | |
167 | 167 | // If donation was completed adjust stats of new customers. |
168 | 168 | $customer->increase_purchase_count(); |
169 | - $customer->increase_value( $new_total ); |
|
169 | + $customer->increase_value($new_total); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | $payment->customer_id = $customer->id; |
173 | - } else{ |
|
173 | + } else { |
|
174 | 174 | |
175 | - if( 'publish' === $status ){ |
|
175 | + if ('publish' === $status) { |
|
176 | 176 | // Update user donation stat. |
177 | - $customer->update_donation_value( $curr_total, $new_total ); |
|
177 | + $customer->update_donation_value($curr_total, $new_total); |
|
178 | 178 | } |
179 | 179 | } |
180 | 180 | |
@@ -188,10 +188,10 @@ discard block |
||
188 | 188 | |
189 | 189 | |
190 | 190 | // Check for payment notes |
191 | - if ( ! empty( $data['give-payment-note'] ) ) { |
|
191 | + if ( ! empty($data['give-payment-note'])) { |
|
192 | 192 | |
193 | - $note = wp_kses( $data['give-payment-note'], array() ); |
|
194 | - give_insert_payment_note( $payment_id, $note ); |
|
193 | + $note = wp_kses($data['give-payment-note'], array()); |
|
194 | + give_insert_payment_note($payment_id, $note); |
|
195 | 195 | |
196 | 196 | } |
197 | 197 | |
@@ -199,17 +199,17 @@ discard block |
||
199 | 199 | $payment->status = $status; |
200 | 200 | |
201 | 201 | // Adjust total store earnings if the payment total has been changed |
202 | - if ( $new_total !== $curr_total && 'publish' == $status ) { |
|
202 | + if ($new_total !== $curr_total && 'publish' == $status) { |
|
203 | 203 | |
204 | - if ( $new_total > $curr_total ) { |
|
204 | + if ($new_total > $curr_total) { |
|
205 | 205 | // Increase if our new total is higher |
206 | 206 | $difference = $new_total - $curr_total; |
207 | - give_increase_total_earnings( $difference ); |
|
207 | + give_increase_total_earnings($difference); |
|
208 | 208 | |
209 | - } elseif ( $curr_total > $new_total ) { |
|
209 | + } elseif ($curr_total > $new_total) { |
|
210 | 210 | // Decrease if our new total is lower |
211 | 211 | $difference = $curr_total - $new_total; |
212 | - give_decrease_total_earnings( $difference ); |
|
212 | + give_decrease_total_earnings($difference); |
|
213 | 213 | |
214 | 214 | } |
215 | 215 | |
@@ -218,16 +218,16 @@ discard block |
||
218 | 218 | $payment->save(); |
219 | 219 | |
220 | 220 | // Get new give form ID. |
221 | - $new_form_id = absint( $data['forms'] ); |
|
222 | - $current_form_id = absint( $payment->get_meta( '_give_payment_form_id' ) ); |
|
221 | + $new_form_id = absint($data['forms']); |
|
222 | + $current_form_id = absint($payment->get_meta('_give_payment_form_id')); |
|
223 | 223 | |
224 | 224 | // We are adding payment transfer code in last to remove any conflict with above functionality. |
225 | 225 | // For example: above code will automatically handle form stat (increase/decrease) when payment status changes. |
226 | 226 | /* Check if user want to transfer current payment to new give form id. */ |
227 | - if( $new_form_id != $current_form_id ) { |
|
227 | + if ($new_form_id != $current_form_id) { |
|
228 | 228 | |
229 | 229 | // Get new give form title. |
230 | - $new_form_title = get_the_title( $new_form_id ); |
|
230 | + $new_form_title = get_the_title($new_form_id); |
|
231 | 231 | |
232 | 232 | // Update new give form data in payment data. |
233 | 233 | $payment_meta = $payment->get_meta(); |
@@ -235,28 +235,28 @@ discard block |
||
235 | 235 | $payment_meta['form_id'] = $new_form_id; |
236 | 236 | |
237 | 237 | // Update price id post meta data for set donation form. |
238 | - if( ! give_has_variable_prices( $new_form_id ) ) { |
|
238 | + if ( ! give_has_variable_prices($new_form_id)) { |
|
239 | 239 | $payment_meta['price_id'] = ''; |
240 | 240 | } |
241 | 241 | |
242 | 242 | // Update payment give form meta data. |
243 | - $payment->update_meta( '_give_payment_form_id', $new_form_id ); |
|
244 | - $payment->update_meta( '_give_payment_form_title', $new_form_title ); |
|
245 | - $payment->update_meta( '_give_payment_meta', $payment_meta ); |
|
243 | + $payment->update_meta('_give_payment_form_id', $new_form_id); |
|
244 | + $payment->update_meta('_give_payment_form_title', $new_form_title); |
|
245 | + $payment->update_meta('_give_payment_meta', $payment_meta); |
|
246 | 246 | |
247 | 247 | // Update price id payment metadata. |
248 | - if( ! give_has_variable_prices( $new_form_id ) ) { |
|
249 | - $payment->update_meta( '_give_payment_price_id', '' ); |
|
248 | + if ( ! give_has_variable_prices($new_form_id)) { |
|
249 | + $payment->update_meta('_give_payment_price_id', ''); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | |
253 | 253 | // If donation was completed, adjust stats of forms |
254 | - if ( 'publish' == $status ) { |
|
254 | + if ('publish' == $status) { |
|
255 | 255 | |
256 | 256 | // Decrease sale of old give form. For other payment status |
257 | - $current_form = new Give_Donate_Form( $current_form_id ); |
|
257 | + $current_form = new Give_Donate_Form($current_form_id); |
|
258 | 258 | $current_form->decrease_sales(); |
259 | - $current_form->decrease_earnings( $curr_total ); |
|
259 | + $current_form->decrease_earnings($curr_total); |
|
260 | 260 | |
261 | 261 | // Increase sale of new give form. |
262 | 262 | $new_form = new Give_Donate_Form($new_form_id); |
@@ -265,27 +265,27 @@ discard block |
||
265 | 265 | } |
266 | 266 | |
267 | 267 | // Re setup payment to update new meta value in object. |
268 | - $payment->update_payment_setup( $payment->ID ); |
|
268 | + $payment->update_payment_setup($payment->ID); |
|
269 | 269 | } |
270 | 270 | |
271 | 271 | // Update price id if current form is variable form. |
272 | - if( ! empty( $data['give-variable-price'] ) && give_has_variable_prices( $payment->form_id ) ) { |
|
272 | + if ( ! empty($data['give-variable-price']) && give_has_variable_prices($payment->form_id)) { |
|
273 | 273 | |
274 | 274 | // Get payment meta data. |
275 | 275 | $payment_meta = $payment->get_meta(); |
276 | 276 | |
277 | 277 | // Set payment id to empty string if variable price id is negative ( i.e. custom amount feature enabled ). |
278 | - $data['give-variable-price'] = ( 'custom' === $data['give-variable-price'] ) ? 'custom' : ( 0 < $data['give-variable-price'] ) ? $data['give-variable-price'] : ''; |
|
278 | + $data['give-variable-price'] = ('custom' === $data['give-variable-price']) ? 'custom' : (0 < $data['give-variable-price']) ? $data['give-variable-price'] : ''; |
|
279 | 279 | |
280 | 280 | // Update payment meta data. |
281 | 281 | $payment_meta['price_id'] = $data['give-variable-price']; |
282 | 282 | |
283 | 283 | // Update payment give form meta data. |
284 | - $payment->update_meta( '_give_payment_price_id', $data['give-variable-price'] ); |
|
285 | - $payment->update_meta( '_give_payment_meta', $payment_meta ); |
|
284 | + $payment->update_meta('_give_payment_price_id', $data['give-variable-price']); |
|
285 | + $payment->update_meta('_give_payment_meta', $payment_meta); |
|
286 | 286 | |
287 | 287 | // Re setup payment to update new meta value in object. |
288 | - $payment->update_payment_setup( $payment->ID ); |
|
288 | + $payment->update_payment_setup($payment->ID); |
|
289 | 289 | } |
290 | 290 | |
291 | 291 | /** |
@@ -295,13 +295,13 @@ discard block |
||
295 | 295 | * |
296 | 296 | * @param int $payment_id The ID of the payment. |
297 | 297 | */ |
298 | - do_action( 'give_updated_edited_purchase', $payment_id ); |
|
298 | + do_action('give_updated_edited_purchase', $payment_id); |
|
299 | 299 | |
300 | - wp_safe_redirect( admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&give-message=payment-updated&id=' . $payment_id ) ); |
|
300 | + wp_safe_redirect(admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&give-message=payment-updated&id='.$payment_id)); |
|
301 | 301 | exit; |
302 | 302 | } |
303 | 303 | |
304 | -add_action( 'give_update_payment_details', 'give_update_payment_details' ); |
|
304 | +add_action('give_update_payment_details', 'give_update_payment_details'); |
|
305 | 305 | |
306 | 306 | /** |
307 | 307 | * Trigger a Donation Deletion |
@@ -312,48 +312,48 @@ discard block |
||
312 | 312 | * |
313 | 313 | * @return void |
314 | 314 | */ |
315 | -function give_trigger_purchase_delete( $data ) { |
|
316 | - if ( wp_verify_nonce( $data['_wpnonce'], 'give_payment_nonce' ) ) { |
|
315 | +function give_trigger_purchase_delete($data) { |
|
316 | + if (wp_verify_nonce($data['_wpnonce'], 'give_payment_nonce')) { |
|
317 | 317 | |
318 | - $payment_id = absint( $data['purchase_id'] ); |
|
318 | + $payment_id = absint($data['purchase_id']); |
|
319 | 319 | |
320 | - if ( ! current_user_can( 'edit_give_payments', $payment_id ) ) { |
|
321 | - wp_die( esc_html__( 'You do not have permission to edit payments.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
320 | + if ( ! current_user_can('edit_give_payments', $payment_id)) { |
|
321 | + wp_die(esc_html__('You do not have permission to edit payments.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
322 | 322 | } |
323 | 323 | |
324 | - give_delete_purchase( $payment_id ); |
|
325 | - wp_redirect( admin_url( '/edit.php?post_type=give_forms&page=give-payment-history&give-message=payment_deleted' ) ); |
|
324 | + give_delete_purchase($payment_id); |
|
325 | + wp_redirect(admin_url('/edit.php?post_type=give_forms&page=give-payment-history&give-message=payment_deleted')); |
|
326 | 326 | give_die(); |
327 | 327 | } |
328 | 328 | } |
329 | 329 | |
330 | -add_action( 'give_delete_payment', 'give_trigger_purchase_delete' ); |
|
330 | +add_action('give_delete_payment', 'give_trigger_purchase_delete'); |
|
331 | 331 | |
332 | 332 | /** |
333 | 333 | * AJAX Store Donation Note |
334 | 334 | */ |
335 | 335 | function give_ajax_store_payment_note() { |
336 | 336 | |
337 | - $payment_id = absint( $_POST['payment_id'] ); |
|
338 | - $note = wp_kses( $_POST['note'], array() ); |
|
337 | + $payment_id = absint($_POST['payment_id']); |
|
338 | + $note = wp_kses($_POST['note'], array()); |
|
339 | 339 | |
340 | - if ( ! current_user_can( 'edit_give_payments', $payment_id ) ) { |
|
341 | - wp_die( esc_html__( 'You do not have permission to edit payments.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
340 | + if ( ! current_user_can('edit_give_payments', $payment_id)) { |
|
341 | + wp_die(esc_html__('You do not have permission to edit payments.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
342 | 342 | } |
343 | 343 | |
344 | - if ( empty( $payment_id ) ) { |
|
345 | - die( '-1' ); |
|
344 | + if (empty($payment_id)) { |
|
345 | + die('-1'); |
|
346 | 346 | } |
347 | 347 | |
348 | - if ( empty( $note ) ) { |
|
349 | - die( '-1' ); |
|
348 | + if (empty($note)) { |
|
349 | + die('-1'); |
|
350 | 350 | } |
351 | 351 | |
352 | - $note_id = give_insert_payment_note( $payment_id, $note ); |
|
353 | - die( give_get_payment_note_html( $note_id ) ); |
|
352 | + $note_id = give_insert_payment_note($payment_id, $note); |
|
353 | + die(give_get_payment_note_html($note_id)); |
|
354 | 354 | } |
355 | 355 | |
356 | -add_action( 'wp_ajax_give_insert_payment_note', 'give_ajax_store_payment_note' ); |
|
356 | +add_action('wp_ajax_give_insert_payment_note', 'give_ajax_store_payment_note'); |
|
357 | 357 | |
358 | 358 | /** |
359 | 359 | * Triggers a payment note deletion without ajax |
@@ -364,24 +364,24 @@ discard block |
||
364 | 364 | * |
365 | 365 | * @return void |
366 | 366 | */ |
367 | -function give_trigger_payment_note_deletion( $data ) { |
|
367 | +function give_trigger_payment_note_deletion($data) { |
|
368 | 368 | |
369 | - if ( ! wp_verify_nonce( $data['_wpnonce'], 'give_delete_payment_note_' . $data['note_id'] ) ) { |
|
369 | + if ( ! wp_verify_nonce($data['_wpnonce'], 'give_delete_payment_note_'.$data['note_id'])) { |
|
370 | 370 | return; |
371 | 371 | } |
372 | 372 | |
373 | - if ( ! current_user_can( 'edit_give_payments', $data['payment_id'] ) ) { |
|
374 | - wp_die( esc_html__( 'You do not have permission to edit payments.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
373 | + if ( ! current_user_can('edit_give_payments', $data['payment_id'])) { |
|
374 | + wp_die(esc_html__('You do not have permission to edit payments.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
375 | 375 | } |
376 | 376 | |
377 | - $edit_order_url = admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&give-message=payment-note-deleted&id=' . absint( $data['payment_id'] ) ); |
|
377 | + $edit_order_url = admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&give-message=payment-note-deleted&id='.absint($data['payment_id'])); |
|
378 | 378 | |
379 | - give_delete_payment_note( $data['note_id'], $data['payment_id'] ); |
|
379 | + give_delete_payment_note($data['note_id'], $data['payment_id']); |
|
380 | 380 | |
381 | - wp_redirect( $edit_order_url ); |
|
381 | + wp_redirect($edit_order_url); |
|
382 | 382 | } |
383 | 383 | |
384 | -add_action( 'give_delete_payment_note', 'give_trigger_payment_note_deletion' ); |
|
384 | +add_action('give_delete_payment_note', 'give_trigger_payment_note_deletion'); |
|
385 | 385 | |
386 | 386 | /** |
387 | 387 | * Delete a payment note deletion with ajax |
@@ -392,16 +392,16 @@ discard block |
||
392 | 392 | */ |
393 | 393 | function give_ajax_delete_payment_note() { |
394 | 394 | |
395 | - if ( ! current_user_can( 'edit_give_payments', $_POST['payment_id'] ) ) { |
|
396 | - wp_die( esc_html__( 'You do not have permission to edit payments.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
395 | + if ( ! current_user_can('edit_give_payments', $_POST['payment_id'])) { |
|
396 | + wp_die(esc_html__('You do not have permission to edit payments.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
397 | 397 | } |
398 | 398 | |
399 | - if ( give_delete_payment_note( $_POST['note_id'], $_POST['payment_id'] ) ) { |
|
400 | - die( '1' ); |
|
399 | + if (give_delete_payment_note($_POST['note_id'], $_POST['payment_id'])) { |
|
400 | + die('1'); |
|
401 | 401 | } else { |
402 | - die( '-1' ); |
|
402 | + die('-1'); |
|
403 | 403 | } |
404 | 404 | |
405 | 405 | } |
406 | 406 | |
407 | -add_action( 'wp_ajax_give_delete_payment_note', 'give_ajax_delete_payment_note' ); |
|
408 | 407 | \ No newline at end of file |
408 | +add_action('wp_ajax_give_delete_payment_note', 'give_ajax_delete_payment_note'); |
|
409 | 409 | \ No newline at end of file |
@@ -10,13 +10,13 @@ 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 | |
17 | 17 | // Load WP_List_Table if not loaded |
18 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
19 | - require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
18 | +if ( ! class_exists('WP_List_Table')) { |
|
19 | + require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php'; |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | /** |
@@ -45,11 +45,11 @@ discard block |
||
45 | 45 | global $status, $page; |
46 | 46 | |
47 | 47 | // Set parent defaults |
48 | - parent::__construct( array( |
|
49 | - 'singular' => give_get_forms_label_singular(), // Singular name of the listed records |
|
50 | - 'plural' => give_get_forms_label_plural(), // Plural name of the listed records |
|
48 | + parent::__construct(array( |
|
49 | + 'singular' => give_get_forms_label_singular(), // Singular name of the listed records |
|
50 | + 'plural' => give_get_forms_label_plural(), // Plural name of the listed records |
|
51 | 51 | 'ajax' => false // Does this table support ajax? |
52 | - ) ); |
|
52 | + )); |
|
53 | 53 | |
54 | 54 | } |
55 | 55 | |
@@ -64,10 +64,10 @@ discard block |
||
64 | 64 | * |
65 | 65 | * @return string Column Name |
66 | 66 | */ |
67 | - public function column_default( $item, $column_name ) { |
|
68 | - switch ( $column_name ) { |
|
67 | + public function column_default($item, $column_name) { |
|
68 | + switch ($column_name) { |
|
69 | 69 | default: |
70 | - return $item[ $column_name ]; |
|
70 | + return $item[$column_name]; |
|
71 | 71 | } |
72 | 72 | } |
73 | 73 | |
@@ -80,11 +80,11 @@ discard block |
||
80 | 80 | */ |
81 | 81 | public function get_columns() { |
82 | 82 | $columns = array( |
83 | - 'label' => esc_attr__( 'Gateway', 'give' ), |
|
84 | - 'complete_sales' => esc_attr__( 'Complete Transactions', 'give' ), |
|
85 | - 'pending_sales' => esc_attr__( 'Pending / Failed Transactions', 'give' ), |
|
86 | - 'total_sales' => esc_attr__( 'Total Transactions', 'give' ), |
|
87 | - 'total_donations' => esc_attr__( 'Total Donations', 'give' ) |
|
83 | + 'label' => esc_attr__('Gateway', 'give'), |
|
84 | + 'complete_sales' => esc_attr__('Complete Transactions', 'give'), |
|
85 | + 'pending_sales' => esc_attr__('Pending / Failed Transactions', 'give'), |
|
86 | + 'total_sales' => esc_attr__('Total Transactions', 'give'), |
|
87 | + 'total_donations' => esc_attr__('Total Donations', 'give') |
|
88 | 88 | ); |
89 | 89 | |
90 | 90 | return $columns; |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | * @return int Current page number |
100 | 100 | */ |
101 | 101 | public function get_paged() { |
102 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
102 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | * @since 1.0 |
111 | 111 | * @return void |
112 | 112 | */ |
113 | - public function bulk_actions( $which = '' ) { |
|
113 | + public function bulk_actions($which = '') { |
|
114 | 114 | // These aren't really bulk actions but this outputs the markup in the right place |
115 | 115 | give_report_views(); |
116 | 116 | } |
@@ -123,23 +123,23 @@ discard block |
||
123 | 123 | * |
124 | 124 | * @param string $which |
125 | 125 | */ |
126 | - protected function display_tablenav( $which ) { |
|
126 | + protected function display_tablenav($which) { |
|
127 | 127 | |
128 | - if ( 'top' == $which ) { |
|
129 | - wp_nonce_field( 'bulk-' . $this->_args['plural'] ); |
|
128 | + if ('top' == $which) { |
|
129 | + wp_nonce_field('bulk-'.$this->_args['plural']); |
|
130 | 130 | } |
131 | 131 | ?> |
132 | - <div class="tablenav gateways-report-tablenav give-clearfix <?php echo esc_attr( $which ); ?>"> |
|
132 | + <div class="tablenav gateways-report-tablenav give-clearfix <?php echo esc_attr($which); ?>"> |
|
133 | 133 | |
134 | - <h3 class="alignleft reports-earnings-title"><span><?php esc_html_e( 'Donation Methods Report', 'give' ); ?></span></h3> |
|
134 | + <h3 class="alignleft reports-earnings-title"><span><?php esc_html_e('Donation Methods Report', 'give'); ?></span></h3> |
|
135 | 135 | |
136 | 136 | <div class="alignright tablenav-right"> |
137 | 137 | <div class="actions bulkactions"> |
138 | - <?php $this->bulk_actions( $which ); ?> |
|
138 | + <?php $this->bulk_actions($which); ?> |
|
139 | 139 | </div> |
140 | 140 | <?php |
141 | - $this->extra_tablenav( $which ); |
|
142 | - $this->pagination( $which ); |
|
141 | + $this->extra_tablenav($which); |
|
142 | + $this->pagination($which); |
|
143 | 143 | ?> |
144 | 144 | </div> |
145 | 145 | |
@@ -164,18 +164,18 @@ discard block |
||
164 | 164 | $gateways = give_get_payment_gateways(); |
165 | 165 | $stats = new Give_Payment_Stats(); |
166 | 166 | |
167 | - foreach ( $gateways as $gateway_id => $gateway ) { |
|
167 | + foreach ($gateways as $gateway_id => $gateway) { |
|
168 | 168 | |
169 | - $complete_count = give_count_sales_by_gateway( $gateway_id, 'publish' ); |
|
170 | - $pending_count = give_count_sales_by_gateway( $gateway_id, array( 'pending', 'failed' ) ); |
|
169 | + $complete_count = give_count_sales_by_gateway($gateway_id, 'publish'); |
|
170 | + $pending_count = give_count_sales_by_gateway($gateway_id, array('pending', 'failed')); |
|
171 | 171 | |
172 | 172 | $reports_data[] = array( |
173 | 173 | 'ID' => $gateway_id, |
174 | 174 | 'label' => $gateway['admin_label'], |
175 | - 'complete_sales' => give_format_amount( $complete_count, false ), |
|
176 | - 'pending_sales' => give_format_amount( $pending_count, false ), |
|
177 | - 'total_sales' => give_format_amount( $complete_count + $pending_count, false ), |
|
178 | - 'total_donations' => give_currency_filter( give_format_amount( $stats->get_earnings( 0, 0, 0, $gateway_id ) ) ) |
|
175 | + 'complete_sales' => give_format_amount($complete_count, false), |
|
176 | + 'pending_sales' => give_format_amount($pending_count, false), |
|
177 | + 'total_sales' => give_format_amount($complete_count + $pending_count, false), |
|
178 | + 'total_donations' => give_currency_filter(give_format_amount($stats->get_earnings(0, 0, 0, $gateway_id))) |
|
179 | 179 | ); |
180 | 180 | } |
181 | 181 | |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | $columns = $this->get_columns(); |
198 | 198 | $hidden = array(); // No hidden columns |
199 | 199 | $sortable = $this->get_sortable_columns(); |
200 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
200 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
201 | 201 | $this->items = $this->reports_data(); |
202 | 202 | |
203 | 203 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * @return void |
24 | 24 | */ |
25 | 25 | function give_logs_view_sales() { |
26 | - include( dirname( __FILE__ ) . '/class-sales-logs-list-table.php' ); |
|
26 | + include(dirname(__FILE__).'/class-sales-logs-list-table.php'); |
|
27 | 27 | |
28 | 28 | $logs_table = new Give_Sales_Log_Table(); |
29 | 29 | $logs_table->prepare_items(); |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | |
32 | 32 | } |
33 | 33 | |
34 | -add_action( 'give_logs_view_sales', 'give_logs_view_sales' ); |
|
34 | +add_action('give_logs_view_sales', 'give_logs_view_sales'); |
|
35 | 35 | |
36 | 36 | |
37 | 37 | /** |
@@ -43,14 +43,14 @@ discard block |
||
43 | 43 | * @return void |
44 | 44 | */ |
45 | 45 | function give_logs_view_gateway_errors() { |
46 | - include( dirname( __FILE__ ) . '/class-gateway-error-logs-list-table.php' ); |
|
46 | + include(dirname(__FILE__).'/class-gateway-error-logs-list-table.php'); |
|
47 | 47 | |
48 | 48 | $logs_table = new Give_Gateway_Error_Log_Table(); |
49 | 49 | $logs_table->prepare_items(); |
50 | 50 | $logs_table->display(); |
51 | 51 | } |
52 | 52 | |
53 | -add_action( 'give_logs_view_gateway_errors', 'give_logs_view_gateway_errors' ); |
|
53 | +add_action('give_logs_view_gateway_errors', 'give_logs_view_gateway_errors'); |
|
54 | 54 | |
55 | 55 | /** |
56 | 56 | * API Request Logs |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | * @return void |
63 | 63 | */ |
64 | 64 | function give_logs_view_api_requests() { |
65 | - include( dirname( __FILE__ ) . '/class-api-requests-logs-list-table.php' ); |
|
65 | + include(dirname(__FILE__).'/class-api-requests-logs-list-table.php'); |
|
66 | 66 | |
67 | 67 | $logs_table = new Give_API_Request_Log_Table(); |
68 | 68 | $logs_table->prepare_items(); |
@@ -75,12 +75,12 @@ discard block |
||
75 | 75 | * |
76 | 76 | * @since 1.0 |
77 | 77 | */ |
78 | - do_action( 'give_logs_api_requests_top' ); |
|
78 | + do_action('give_logs_api_requests_top'); |
|
79 | 79 | ?> |
80 | 80 | |
81 | - <form id="give-logs-filter" method="get" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-reports&tab=logs' ); ?>"> |
|
81 | + <form id="give-logs-filter" method="get" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-reports&tab=logs'); ?>"> |
|
82 | 82 | <?php |
83 | - $logs_table->search_box( esc_html__( 'Search', 'give' ), 'give-api-requests' ); |
|
83 | + $logs_table->search_box(esc_html__('Search', 'give'), 'give-api-requests'); |
|
84 | 84 | $logs_table->display(); |
85 | 85 | ?> |
86 | 86 | <input type="hidden" name="post_type" value="give_forms"/> |
@@ -93,14 +93,14 @@ discard block |
||
93 | 93 | * |
94 | 94 | * @since 1.0 |
95 | 95 | */ |
96 | - do_action( 'give_logs_api_requests_bottom' ); |
|
96 | + do_action('give_logs_api_requests_bottom'); |
|
97 | 97 | ?> |
98 | 98 | |
99 | 99 | </div> |
100 | 100 | <?php |
101 | 101 | } |
102 | 102 | |
103 | -add_action( 'give_logs_view_api_requests', 'give_logs_view_api_requests' ); |
|
103 | +add_action('give_logs_view_api_requests', 'give_logs_view_api_requests'); |
|
104 | 104 | |
105 | 105 | |
106 | 106 | /** |
@@ -111,12 +111,12 @@ discard block |
||
111 | 111 | */ |
112 | 112 | function give_log_default_views() { |
113 | 113 | $views = array( |
114 | - 'sales' => esc_html__( 'Donations', 'give' ), |
|
115 | - 'gateway_errors' => esc_html__( 'Payment Errors', 'give' ), |
|
116 | - 'api_requests' => esc_html__( 'API Requests', 'give' ) |
|
114 | + 'sales' => esc_html__('Donations', 'give'), |
|
115 | + 'gateway_errors' => esc_html__('Payment Errors', 'give'), |
|
116 | + 'api_requests' => esc_html__('API Requests', 'give') |
|
117 | 117 | ); |
118 | 118 | |
119 | - $views = apply_filters( 'give_log_views', $views ); |
|
119 | + $views = apply_filters('give_log_views', $views); |
|
120 | 120 | |
121 | 121 | return $views; |
122 | 122 | } |
@@ -129,13 +129,13 @@ discard block |
||
129 | 129 | */ |
130 | 130 | function give_log_views() { |
131 | 131 | $views = give_log_default_views(); |
132 | - $current_view = isset( $_GET['view'] ) && array_key_exists( $_GET['view'], give_log_default_views() ) ? sanitize_text_field( $_GET['view'] ) : 'sales'; |
|
132 | + $current_view = isset($_GET['view']) && array_key_exists($_GET['view'], give_log_default_views()) ? sanitize_text_field($_GET['view']) : 'sales'; |
|
133 | 133 | ?> |
134 | 134 | <form id="give-logs-filter" method="get" action="edit.php"> |
135 | 135 | <select id="give-logs-view" name="view"> |
136 | 136 | <optgroup label="Log Type:"> |
137 | - <?php foreach ( $views as $view_id => $label ): ?> |
|
138 | - <option value="<?php echo esc_attr( $view_id ); ?>" <?php selected( $view_id, $current_view ); ?>><?php echo $label; ?></option> |
|
137 | + <?php foreach ($views as $view_id => $label): ?> |
|
138 | + <option value="<?php echo esc_attr($view_id); ?>" <?php selected($view_id, $current_view); ?>><?php echo $label; ?></option> |
|
139 | 139 | <?php endforeach; ?> |
140 | 140 | </optgroup> |
141 | 141 | </select> |
@@ -148,14 +148,14 @@ discard block |
||
148 | 148 | * |
149 | 149 | * @since 1.0 |
150 | 150 | */ |
151 | - do_action( 'give_log_view_actions' ); |
|
151 | + do_action('give_log_view_actions'); |
|
152 | 152 | ?> |
153 | 153 | |
154 | 154 | <input type="hidden" name="post_type" value="give_forms"/> |
155 | 155 | <input type="hidden" name="page" value="give-reports"/> |
156 | 156 | <input type="hidden" name="tab" value="logs"/> |
157 | 157 | |
158 | - <?php submit_button( esc_html__( 'Apply', 'give' ), 'secondary', 'submit', false ); ?> |
|
158 | + <?php submit_button(esc_html__('Apply', 'give'), 'secondary', 'submit', false); ?> |
|
159 | 159 | </form> |
160 | 160 | <?php |
161 | 161 | } |
162 | 162 | \ No newline at end of file |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
11 | 11 | */ |
12 | 12 | |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -22,11 +22,11 @@ discard block |
||
22 | 22 | */ |
23 | 23 | function give_process_batch_export_form() { |
24 | 24 | |
25 | - if ( ! wp_verify_nonce( $_REQUEST['nonce'], 'give-batch-export' ) ) { |
|
26 | - wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
25 | + if ( ! wp_verify_nonce($_REQUEST['nonce'], 'give-batch-export')) { |
|
26 | + wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
27 | 27 | } |
28 | 28 | |
29 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export.php'; |
|
29 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/class-batch-export.php'; |
|
30 | 30 | |
31 | 31 | /** |
32 | 32 | * Fires before batch export. |
@@ -35,14 +35,14 @@ discard block |
||
35 | 35 | * |
36 | 36 | * @param atring $class Export class. |
37 | 37 | */ |
38 | - do_action( 'give_batch_export_class_include', $_REQUEST['class'] ); |
|
38 | + do_action('give_batch_export_class_include', $_REQUEST['class']); |
|
39 | 39 | |
40 | 40 | $export = new $_REQUEST['class']; |
41 | 41 | $export->export(); |
42 | 42 | |
43 | 43 | } |
44 | 44 | |
45 | -add_action( 'give_form_batch_export', 'give_process_batch_export_form' ); |
|
45 | +add_action('give_form_batch_export', 'give_process_batch_export_form'); |
|
46 | 46 | |
47 | 47 | /** |
48 | 48 | * Exports earnings for a specified time period |
@@ -53,14 +53,14 @@ discard block |
||
53 | 53 | * @return void |
54 | 54 | */ |
55 | 55 | function give_export_earnings() { |
56 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/class-export-earnings.php'; |
|
56 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/class-export-earnings.php'; |
|
57 | 57 | |
58 | 58 | $earnings_export = new Give_Earnings_Export(); |
59 | 59 | |
60 | 60 | $earnings_export->export(); |
61 | 61 | } |
62 | 62 | |
63 | -add_action( 'give_earnings_export', 'give_export_earnings' ); |
|
63 | +add_action('give_earnings_export', 'give_export_earnings'); |
|
64 | 64 | |
65 | 65 | |
66 | 66 | /** |
@@ -73,14 +73,14 @@ discard block |
||
73 | 73 | * @return void |
74 | 74 | */ |
75 | 75 | function give_export_all_customers() { |
76 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/class-export-customers.php'; |
|
76 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/class-export-customers.php'; |
|
77 | 77 | |
78 | 78 | $customer_export = new Give_Donors_Export(); |
79 | 79 | |
80 | 80 | $customer_export->export(); |
81 | 81 | } |
82 | 82 | |
83 | -add_action( 'give_email_export', 'give_export_all_customers' ); |
|
83 | +add_action('give_email_export', 'give_export_all_customers'); |
|
84 | 84 | |
85 | 85 | /** |
86 | 86 | * Add a hook allowing extensions to register a hook on the batch export process |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | * @return void |
90 | 90 | */ |
91 | 91 | function give_register_batch_exporters() { |
92 | - if ( is_admin() ) { |
|
92 | + if (is_admin()) { |
|
93 | 93 | /** |
94 | 94 | * Fires in the admin, while plugins loaded. |
95 | 95 | * |
@@ -99,21 +99,21 @@ discard block |
||
99 | 99 | * |
100 | 100 | * @param string $class Export class. |
101 | 101 | */ |
102 | - do_action( 'give_register_batch_exporter' ); |
|
102 | + do_action('give_register_batch_exporter'); |
|
103 | 103 | } |
104 | 104 | } |
105 | 105 | |
106 | -add_action( 'plugins_loaded', 'give_register_batch_exporters' ); |
|
106 | +add_action('plugins_loaded', 'give_register_batch_exporters'); |
|
107 | 107 | |
108 | 108 | /** |
109 | 109 | * Register the payments batch exporter |
110 | 110 | * @since 1.5 |
111 | 111 | */ |
112 | 112 | function give_register_payments_batch_export() { |
113 | - add_action( 'give_batch_export_class_include', 'give_include_payments_batch_processor', 10, 1 ); |
|
113 | + add_action('give_batch_export_class_include', 'give_include_payments_batch_processor', 10, 1); |
|
114 | 114 | } |
115 | 115 | |
116 | -add_action( 'give_register_batch_exporter', 'give_register_payments_batch_export', 10 ); |
|
116 | +add_action('give_register_batch_exporter', 'give_register_payments_batch_export', 10); |
|
117 | 117 | |
118 | 118 | /** |
119 | 119 | * Loads the payments batch process if needed |
@@ -124,10 +124,10 @@ discard block |
||
124 | 124 | * |
125 | 125 | * @return void |
126 | 126 | */ |
127 | -function give_include_payments_batch_processor( $class ) { |
|
127 | +function give_include_payments_batch_processor($class) { |
|
128 | 128 | |
129 | - if ( 'Give_Batch_Payments_Export' === $class ) { |
|
130 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export-payments.php'; |
|
129 | + if ('Give_Batch_Payments_Export' === $class) { |
|
130 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/class-batch-export-payments.php'; |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | } |
@@ -137,10 +137,10 @@ discard block |
||
137 | 137 | * @since 1.5.2 |
138 | 138 | */ |
139 | 139 | function give_register_customers_batch_export() { |
140 | - add_action( 'give_batch_export_class_include', 'give_include_customers_batch_processor', 10, 1 ); |
|
140 | + add_action('give_batch_export_class_include', 'give_include_customers_batch_processor', 10, 1); |
|
141 | 141 | } |
142 | 142 | |
143 | -add_action( 'give_register_batch_exporter', 'give_register_customers_batch_export', 10 ); |
|
143 | +add_action('give_register_batch_exporter', 'give_register_customers_batch_export', 10); |
|
144 | 144 | |
145 | 145 | /** |
146 | 146 | * Loads the customers batch process if needed |
@@ -151,10 +151,10 @@ discard block |
||
151 | 151 | * |
152 | 152 | * @return void |
153 | 153 | */ |
154 | -function give_include_customers_batch_processor( $class ) { |
|
154 | +function give_include_customers_batch_processor($class) { |
|
155 | 155 | |
156 | - if ( 'Give_Batch_Customers_Export' === $class ) { |
|
157 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export-customers.php'; |
|
156 | + if ('Give_Batch_Customers_Export' === $class) { |
|
157 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/class-batch-export-customers.php'; |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | } |
@@ -165,10 +165,10 @@ discard block |
||
165 | 165 | * @since 1.5 |
166 | 166 | */ |
167 | 167 | function give_register_forms_batch_export() { |
168 | - add_action( 'give_batch_export_class_include', 'give_include_forms_batch_processor', 10, 1 ); |
|
168 | + add_action('give_batch_export_class_include', 'give_include_forms_batch_processor', 10, 1); |
|
169 | 169 | } |
170 | 170 | |
171 | -add_action( 'give_register_batch_exporter', 'give_register_forms_batch_export', 10 ); |
|
171 | +add_action('give_register_batch_exporter', 'give_register_forms_batch_export', 10); |
|
172 | 172 | |
173 | 173 | /** |
174 | 174 | * Loads the file downloads batch process if needed |
@@ -179,10 +179,10 @@ discard block |
||
179 | 179 | * |
180 | 180 | * @return void |
181 | 181 | */ |
182 | -function give_include_forms_batch_processor( $class ) { |
|
182 | +function give_include_forms_batch_processor($class) { |
|
183 | 183 | |
184 | - if ( 'Give_Batch_Forms_Export' === $class ) { |
|
185 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export-forms.php'; |
|
184 | + if ('Give_Batch_Forms_Export' === $class) { |
|
185 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/class-batch-export-forms.php'; |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | } |
189 | 189 | \ No newline at end of file |
@@ -10,11 +10,11 @@ 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 | |
17 | -add_filter( 'cmb2_meta_boxes', 'give_single_forms_cmb2_metaboxes' ); |
|
17 | +add_filter('cmb2_meta_boxes', 'give_single_forms_cmb2_metaboxes'); |
|
18 | 18 | |
19 | 19 | /** |
20 | 20 | * Define the metabox and field configurations. |
@@ -23,23 +23,23 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @return array |
25 | 25 | */ |
26 | -function give_single_forms_cmb2_metaboxes( array $meta_boxes ) { |
|
26 | +function give_single_forms_cmb2_metaboxes(array $meta_boxes) { |
|
27 | 27 | |
28 | 28 | $post_id = give_get_admin_post_id(); |
29 | - $price = give_get_form_price( $post_id ); |
|
30 | - $custom_amount_minimum = give_get_form_minimum_price( $post_id ); |
|
31 | - $goal = give_get_form_goal( $post_id ); |
|
32 | - $variable_pricing = give_has_variable_prices( $post_id ); |
|
33 | - $prices = give_get_variable_prices( $post_id ); |
|
29 | + $price = give_get_form_price($post_id); |
|
30 | + $custom_amount_minimum = give_get_form_minimum_price($post_id); |
|
31 | + $goal = give_get_form_goal($post_id); |
|
32 | + $variable_pricing = give_has_variable_prices($post_id); |
|
33 | + $prices = give_get_variable_prices($post_id); |
|
34 | 34 | |
35 | 35 | //No empty prices - min. 1.00 for new forms |
36 | - if ( empty( $price ) && is_null( $post_id ) ) { |
|
37 | - $price = esc_attr( give_format_amount( '1.00' ) ); |
|
36 | + if (empty($price) && is_null($post_id)) { |
|
37 | + $price = esc_attr(give_format_amount('1.00')); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | //Min. $1.00 for new forms |
41 | - if ( empty( $custom_amount_minimum ) ) { |
|
42 | - $custom_amount_minimum = esc_attr( give_format_amount( '1.00' ) ); |
|
41 | + if (empty($custom_amount_minimum)) { |
|
42 | + $custom_amount_minimum = esc_attr(give_format_amount('1.00')); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | // Start with an underscore to hide fields from custom fields list |
@@ -48,327 +48,327 @@ discard block |
||
48 | 48 | /** |
49 | 49 | * Repeatable Field Groups |
50 | 50 | */ |
51 | - $meta_boxes['form_field_options'] = apply_filters( 'give_forms_field_options', array( |
|
51 | + $meta_boxes['form_field_options'] = apply_filters('give_forms_field_options', array( |
|
52 | 52 | 'id' => 'form_field_options', |
53 | - 'title' => esc_html__( 'Donation Options', 'give' ), |
|
54 | - 'object_types' => array( 'give_forms' ), |
|
53 | + 'title' => esc_html__('Donation Options', 'give'), |
|
54 | + 'object_types' => array('give_forms'), |
|
55 | 55 | 'context' => 'normal', |
56 | 56 | 'priority' => 'high', //Show above Content WYSIWYG |
57 | - 'fields' => apply_filters( 'give_forms_donation_form_metabox_fields', array( |
|
57 | + 'fields' => apply_filters('give_forms_donation_form_metabox_fields', array( |
|
58 | 58 | //Donation Option |
59 | 59 | array( |
60 | - 'name' => esc_html__( 'Donation Option', 'give' ), |
|
61 | - 'description' => esc_html__( 'Would you like this form to have one set donation price or multiple levels (for example, $10, $20, $50)?', 'give' ), |
|
62 | - 'id' => $prefix . 'price_option', |
|
60 | + 'name' => esc_html__('Donation Option', 'give'), |
|
61 | + 'description' => esc_html__('Would you like this form to have one set donation price or multiple levels (for example, $10, $20, $50)?', 'give'), |
|
62 | + 'id' => $prefix.'price_option', |
|
63 | 63 | 'type' => 'radio_inline', |
64 | 64 | 'default' => 'set', |
65 | - 'options' => apply_filters( 'give_forms_price_options', array( |
|
66 | - 'set' => esc_html__( 'Set Donation', 'give' ), |
|
67 | - 'multi' => esc_html__( 'Multi-level Donation', 'give' ), |
|
68 | - ) ), |
|
65 | + 'options' => apply_filters('give_forms_price_options', array( |
|
66 | + 'set' => esc_html__('Set Donation', 'give'), |
|
67 | + 'multi' => esc_html__('Multi-level Donation', 'give'), |
|
68 | + )), |
|
69 | 69 | ), |
70 | 70 | array( |
71 | - 'name' => esc_html__( 'Set Donation', 'give' ), |
|
72 | - 'description' => esc_html__( 'This is the set donation amount for this form. If you have a "Custom Amount Minimum" set, make sure it is less than this amount.', 'give' ), |
|
73 | - 'id' => $prefix . 'set_price', |
|
71 | + 'name' => esc_html__('Set Donation', 'give'), |
|
72 | + 'description' => esc_html__('This is the set donation amount for this form. If you have a "Custom Amount Minimum" set, make sure it is less than this amount.', 'give'), |
|
73 | + 'id' => $prefix.'set_price', |
|
74 | 74 | 'type' => 'text_small', |
75 | 75 | 'row_classes' => 'give-subfield', |
76 | 76 | 'render_row_cb' => 'give_cmb_amount_field_render_row_cb', |
77 | 77 | 'sanitization_cb' => 'give_sanitize_price_field_value', |
78 | 78 | 'attributes' => array( |
79 | - 'placeholder' => give_format_decimal( '1.00' ), |
|
80 | - 'value' => give_format_decimal( $price ), |
|
79 | + 'placeholder' => give_format_decimal('1.00'), |
|
80 | + 'value' => give_format_decimal($price), |
|
81 | 81 | 'class' => 'cmb-type-text-small give-money-field', |
82 | 82 | ), |
83 | 83 | ), |
84 | 84 | //Donation levels: Header |
85 | 85 | array( |
86 | - 'id' => $prefix . 'levels_header', |
|
86 | + 'id' => $prefix.'levels_header', |
|
87 | 87 | 'type' => 'levels_repeater_header', |
88 | 88 | ), |
89 | 89 | //Donation Levels: Repeatable CMB2 Group |
90 | 90 | array( |
91 | - 'id' => $prefix . 'donation_levels', |
|
91 | + 'id' => $prefix.'donation_levels', |
|
92 | 92 | 'type' => 'group', |
93 | 93 | 'row_classes' => 'give-subfield', |
94 | 94 | 'options' => array( |
95 | - 'add_button' => esc_html__( 'Add Level', 'give' ), |
|
95 | + 'add_button' => esc_html__('Add Level', 'give'), |
|
96 | 96 | 'remove_button' => '<span class="dashicons dashicons-no"></span>', |
97 | 97 | 'sortable' => true, // beta |
98 | 98 | ), |
99 | 99 | // Fields array works the same, except id's only need to be unique for this group. Prefix is not needed. |
100 | - 'fields' => apply_filters( 'give_donation_levels_table_row', array( |
|
100 | + 'fields' => apply_filters('give_donation_levels_table_row', array( |
|
101 | 101 | array( |
102 | - 'name' => esc_html__( 'ID', 'give' ), |
|
103 | - 'id' => $prefix . 'id', |
|
102 | + 'name' => esc_html__('ID', 'give'), |
|
103 | + 'id' => $prefix.'id', |
|
104 | 104 | 'type' => 'levels_id', |
105 | 105 | ), |
106 | 106 | array( |
107 | - 'name' => esc_html__( 'Amount', 'give' ), |
|
108 | - 'id' => $prefix . 'amount', |
|
107 | + 'name' => esc_html__('Amount', 'give'), |
|
108 | + 'id' => $prefix.'amount', |
|
109 | 109 | 'type' => 'text_small', |
110 | - 'before_field' => give_get_option( 'currency_position' ) == 'before' ? '<span class="give-money-symbol give-money-symbol-before">' . give_currency_symbol() . '</span>' : '', |
|
111 | - 'after_field' => give_get_option( 'currency_position' ) == 'after' ? '<span class="give-money-symbol give-money-symbol-after">' . give_currency_symbol() . '</span>' : '', |
|
110 | + 'before_field' => give_get_option('currency_position') == 'before' ? '<span class="give-money-symbol give-money-symbol-before">'.give_currency_symbol().'</span>' : '', |
|
111 | + 'after_field' => give_get_option('currency_position') == 'after' ? '<span class="give-money-symbol give-money-symbol-after">'.give_currency_symbol().'</span>' : '', |
|
112 | 112 | 'sanitization_cb' => 'give_sanitize_price_field_value', |
113 | 113 | 'attributes' => array( |
114 | - 'placeholder' => give_format_decimal( '1.00' ), |
|
114 | + 'placeholder' => give_format_decimal('1.00'), |
|
115 | 115 | 'class' => 'cmb-type-text-small give-money-field', |
116 | 116 | ), |
117 | 117 | 'before' => 'give_format_admin_multilevel_amount', |
118 | 118 | ), |
119 | 119 | array( |
120 | - 'name' => esc_html__( 'Text', 'give' ), |
|
121 | - 'id' => $prefix . 'text', |
|
120 | + 'name' => esc_html__('Text', 'give'), |
|
121 | + 'id' => $prefix.'text', |
|
122 | 122 | 'type' => 'text', |
123 | 123 | 'attributes' => array( |
124 | - 'placeholder' => esc_html__( 'Donation Level', 'give' ), |
|
124 | + 'placeholder' => esc_html__('Donation Level', 'give'), |
|
125 | 125 | 'class' => 'give-multilevel-text-field', |
126 | 126 | ), |
127 | 127 | ), |
128 | 128 | array( |
129 | - 'name' => esc_html__( 'Default', 'give' ), |
|
130 | - 'id' => $prefix . 'default', |
|
129 | + 'name' => esc_html__('Default', 'give'), |
|
130 | + 'id' => $prefix.'default', |
|
131 | 131 | 'type' => 'give_default_radio_inline' |
132 | 132 | ), |
133 | - ) ), |
|
133 | + )), |
|
134 | 134 | ), |
135 | 135 | //Display Style |
136 | 136 | array( |
137 | - 'name' => esc_html__( 'Display Style', 'give' ), |
|
138 | - 'description' => esc_html__( 'Set how the donations levels will display on the form.', 'give' ), |
|
139 | - 'id' => $prefix . 'display_style', |
|
137 | + 'name' => esc_html__('Display Style', 'give'), |
|
138 | + 'description' => esc_html__('Set how the donations levels will display on the form.', 'give'), |
|
139 | + 'id' => $prefix.'display_style', |
|
140 | 140 | 'type' => 'radio_inline', |
141 | 141 | 'default' => 'buttons', |
142 | 142 | 'options' => array( |
143 | - 'buttons' => esc_html__( 'Buttons', 'give' ), |
|
144 | - 'radios' => esc_html__( 'Radios', 'give' ), |
|
145 | - 'dropdown' => esc_html__( 'Dropdown', 'give' ), |
|
143 | + 'buttons' => esc_html__('Buttons', 'give'), |
|
144 | + 'radios' => esc_html__('Radios', 'give'), |
|
145 | + 'dropdown' => esc_html__('Dropdown', 'give'), |
|
146 | 146 | ), |
147 | 147 | ), |
148 | 148 | //Custom Amount |
149 | 149 | array( |
150 | - 'name' => esc_html__( 'Custom Amount', 'give' ), |
|
151 | - 'description' => esc_html__( 'Do you want the user to be able to input their own donation amount?', 'give' ), |
|
152 | - 'id' => $prefix . 'custom_amount', |
|
150 | + 'name' => esc_html__('Custom Amount', 'give'), |
|
151 | + 'description' => esc_html__('Do you want the user to be able to input their own donation amount?', 'give'), |
|
152 | + 'id' => $prefix.'custom_amount', |
|
153 | 153 | 'type' => 'radio_inline', |
154 | 154 | 'default' => 'no', |
155 | 155 | 'options' => array( |
156 | - 'yes' => esc_html__( 'Yes', 'give' ), |
|
157 | - 'no' => esc_html__( 'No', 'give' ), |
|
156 | + 'yes' => esc_html__('Yes', 'give'), |
|
157 | + 'no' => esc_html__('No', 'give'), |
|
158 | 158 | ), |
159 | 159 | ), |
160 | 160 | array( |
161 | - 'name' => esc_html__( 'Custom Amount Minimum', 'give' ), |
|
162 | - 'description' => esc_html__( 'If you would like to set a minimum custom donation amount please enter it here.', 'give' ), |
|
163 | - 'id' => $prefix . 'custom_amount_minimum', |
|
161 | + 'name' => esc_html__('Custom Amount Minimum', 'give'), |
|
162 | + 'description' => esc_html__('If you would like to set a minimum custom donation amount please enter it here.', 'give'), |
|
163 | + 'id' => $prefix.'custom_amount_minimum', |
|
164 | 164 | 'type' => 'text_small', |
165 | 165 | 'row_classes' => 'give-subfield', |
166 | 166 | 'render_row_cb' => 'give_cmb_amount_field_render_row_cb', |
167 | 167 | 'sanitization_cb' => 'give_sanitize_price_field_value', |
168 | 168 | 'attributes' => array( |
169 | 169 | 'placeholder' => give_format_decimal('1.00'), |
170 | - 'value' => give_format_decimal( $custom_amount_minimum ), |
|
170 | + 'value' => give_format_decimal($custom_amount_minimum), |
|
171 | 171 | 'class' => 'cmb-type-text-small give-money-field', |
172 | 172 | ) |
173 | 173 | ), |
174 | 174 | array( |
175 | - 'name' => esc_html__( 'Custom Amount Text', 'give' ), |
|
176 | - 'description' => esc_html__( 'This text appears as a label below the custom amount field for set donation forms. For multi-level forms the text will appear as it\'s own level (ie button, radio, or select option).', 'give' ), |
|
177 | - 'id' => $prefix . 'custom_amount_text', |
|
175 | + 'name' => esc_html__('Custom Amount Text', 'give'), |
|
176 | + 'description' => esc_html__('This text appears as a label below the custom amount field for set donation forms. For multi-level forms the text will appear as it\'s own level (ie button, radio, or select option).', 'give'), |
|
177 | + 'id' => $prefix.'custom_amount_text', |
|
178 | 178 | 'type' => 'text', |
179 | 179 | 'row_classes' => 'give-subfield', |
180 | 180 | 'attributes' => array( |
181 | 181 | 'rows' => 3, |
182 | - 'placeholder' => esc_attr__( 'Give a Custom Amount', 'give' ), |
|
182 | + 'placeholder' => esc_attr__('Give a Custom Amount', 'give'), |
|
183 | 183 | ), |
184 | 184 | ), |
185 | 185 | //Goals |
186 | 186 | array( |
187 | - 'name' => esc_html__( 'Goal', 'give' ), |
|
188 | - 'description' => esc_html__( 'Do you want to set a donation goal for this form?', 'give' ), |
|
189 | - 'id' => $prefix . 'goal_option', |
|
187 | + 'name' => esc_html__('Goal', 'give'), |
|
188 | + 'description' => esc_html__('Do you want to set a donation goal for this form?', 'give'), |
|
189 | + 'id' => $prefix.'goal_option', |
|
190 | 190 | 'type' => 'radio_inline', |
191 | 191 | 'default' => 'no', |
192 | 192 | 'options' => array( |
193 | - 'yes' => esc_html__( 'Yes', 'give' ), |
|
194 | - 'no' => esc_html__( 'No', 'give' ), |
|
193 | + 'yes' => esc_html__('Yes', 'give'), |
|
194 | + 'no' => esc_html__('No', 'give'), |
|
195 | 195 | ), |
196 | 196 | ), |
197 | 197 | array( |
198 | - 'name' => esc_html__( 'Goal Amount', 'give' ), |
|
199 | - 'description' => esc_html__( 'This is the monetary goal amount you want to reach for this donation form.', 'give' ), |
|
200 | - 'id' => $prefix . 'set_goal', |
|
198 | + 'name' => esc_html__('Goal Amount', 'give'), |
|
199 | + 'description' => esc_html__('This is the monetary goal amount you want to reach for this donation form.', 'give'), |
|
200 | + 'id' => $prefix.'set_goal', |
|
201 | 201 | 'type' => 'text_small', |
202 | 202 | 'row_classes' => 'give-subfield', |
203 | 203 | 'render_row_cb' => 'give_cmb_amount_field_render_row_cb', |
204 | 204 | 'sanitization_cb' => 'give_sanitize_price_field_value', |
205 | 205 | 'attributes' => array( |
206 | - 'placeholder' => give_format_decimal( '0.00' ), |
|
207 | - 'value' => give_format_decimal( $goal ), |
|
206 | + 'placeholder' => give_format_decimal('0.00'), |
|
207 | + 'value' => give_format_decimal($goal), |
|
208 | 208 | 'class' => 'cmb-type-text-small give-money-field', |
209 | 209 | ), |
210 | 210 | ), |
211 | 211 | |
212 | 212 | array( |
213 | - 'name' => esc_html__( 'Goal Format', 'give' ), |
|
214 | - 'description' => esc_html__( 'Would you like to display the total amount raised based on your monetary goal or a percentage? For instance, "$500 of $1,000 raised" or "50% funded".', 'give' ), |
|
215 | - 'id' => $prefix . 'goal_format', |
|
213 | + 'name' => esc_html__('Goal Format', 'give'), |
|
214 | + 'description' => esc_html__('Would you like to display the total amount raised based on your monetary goal or a percentage? For instance, "$500 of $1,000 raised" or "50% funded".', 'give'), |
|
215 | + 'id' => $prefix.'goal_format', |
|
216 | 216 | 'type' => 'radio_inline', |
217 | 217 | 'default' => 'amount', |
218 | 218 | 'row_classes' => 'give-subfield', |
219 | 219 | 'options' => array( |
220 | - 'amount' => esc_html__( 'Amount', 'give' ), |
|
221 | - 'percentage' => esc_html__( 'Percentage', 'give' ), |
|
220 | + 'amount' => esc_html__('Amount', 'give'), |
|
221 | + 'percentage' => esc_html__('Percentage', 'give'), |
|
222 | 222 | ), |
223 | 223 | ), |
224 | 224 | array( |
225 | - 'name' => esc_html__( 'Goal Progress Bar Color', 'give' ), |
|
226 | - 'id' => $prefix . 'goal_color', |
|
225 | + 'name' => esc_html__('Goal Progress Bar Color', 'give'), |
|
226 | + 'id' => $prefix.'goal_color', |
|
227 | 227 | 'type' => 'colorpicker', |
228 | 228 | 'row_classes' => 'give-subfield', |
229 | 229 | 'default' => '#2bc253', |
230 | 230 | ), |
231 | 231 | |
232 | 232 | array( |
233 | - 'name' => esc_html__( 'Close Form when Goal Achieved', 'give' ), |
|
234 | - 'desc' => esc_html__( 'Would you like to close the donation forms and stop accepting donations once this goal has been met?', 'give' ), |
|
235 | - 'id' => $prefix . 'close_form_when_goal_achieved', |
|
233 | + 'name' => esc_html__('Close Form when Goal Achieved', 'give'), |
|
234 | + 'desc' => esc_html__('Would you like to close the donation forms and stop accepting donations once this goal has been met?', 'give'), |
|
235 | + 'id' => $prefix.'close_form_when_goal_achieved', |
|
236 | 236 | 'type' => 'radio_inline', |
237 | 237 | 'row_classes' => 'give-subfield', |
238 | 238 | 'options' => array( |
239 | - 'yes' => esc_html__( 'Yes', 'give' ), |
|
240 | - 'no' => esc_html__( 'No', 'give' ), |
|
239 | + 'yes' => esc_html__('Yes', 'give'), |
|
240 | + 'no' => esc_html__('No', 'give'), |
|
241 | 241 | ), |
242 | 242 | 'default' => 'no', |
243 | 243 | ), |
244 | 244 | array( |
245 | - 'name' => esc_html__( 'Goal Achieved Message', 'give' ), |
|
246 | - 'desc' => esc_html__( 'Would you like to display a custom message when the goal is closed? If none is provided the default message will be displayed', 'give' ), |
|
247 | - 'id' => $prefix . 'form_goal_achieved_message', |
|
245 | + 'name' => esc_html__('Goal Achieved Message', 'give'), |
|
246 | + 'desc' => esc_html__('Would you like to display a custom message when the goal is closed? If none is provided the default message will be displayed', 'give'), |
|
247 | + 'id' => $prefix.'form_goal_achieved_message', |
|
248 | 248 | 'type' => 'textarea', |
249 | 249 | 'row_classes' => 'give-subfield', |
250 | 250 | 'attributes' => array( |
251 | - 'placeholder' => esc_attr__( 'Thank you to all our donors, we have met our fundraising goal.', 'give' ), |
|
251 | + 'placeholder' => esc_attr__('Thank you to all our donors, we have met our fundraising goal.', 'give'), |
|
252 | 252 | ), |
253 | 253 | ) |
254 | 254 | ) |
255 | 255 | ) |
256 | - ) ); |
|
256 | + )); |
|
257 | 257 | |
258 | 258 | |
259 | 259 | /** |
260 | 260 | * Content Field |
261 | 261 | */ |
262 | - $meta_boxes['form_content_options'] = apply_filters( 'give_forms_content_options', array( |
|
262 | + $meta_boxes['form_content_options'] = apply_filters('give_forms_content_options', array( |
|
263 | 263 | 'id' => 'form_content_options', |
264 | - 'title' => esc_html__( 'Form Content', 'give' ), |
|
265 | - 'object_types' => array( 'give_forms' ), |
|
264 | + 'title' => esc_html__('Form Content', 'give'), |
|
265 | + 'object_types' => array('give_forms'), |
|
266 | 266 | 'context' => 'normal', |
267 | 267 | 'priority' => 'high', //Show above Content WYSIWYG |
268 | - 'fields' => apply_filters( 'give_forms_content_options_metabox_fields', array( |
|
268 | + 'fields' => apply_filters('give_forms_content_options_metabox_fields', array( |
|
269 | 269 | //Donation Option |
270 | 270 | array( |
271 | - 'name' => esc_html__( 'Display Content', 'give' ), |
|
272 | - 'description' => esc_html__( 'Do you want to display content? If you choose to display content, a WYSIWYG editor will appear which you will be able to enter content.', 'give' ), |
|
273 | - 'id' => $prefix . 'content_option', |
|
271 | + 'name' => esc_html__('Display Content', 'give'), |
|
272 | + 'description' => esc_html__('Do you want to display content? If you choose to display content, a WYSIWYG editor will appear which you will be able to enter content.', 'give'), |
|
273 | + 'id' => $prefix.'content_option', |
|
274 | 274 | 'type' => 'select', |
275 | - 'options' => apply_filters( 'give_forms_content_options_select', array( |
|
276 | - 'none' => esc_html__( 'No Content', 'give' ), |
|
277 | - 'give_pre_form' => esc_html__( 'Display content ABOVE the fields', 'give' ), |
|
278 | - 'give_post_form' => esc_html__( 'Display content BELOW the fields', 'give' ), |
|
275 | + 'options' => apply_filters('give_forms_content_options_select', array( |
|
276 | + 'none' => esc_html__('No Content', 'give'), |
|
277 | + 'give_pre_form' => esc_html__('Display content ABOVE the fields', 'give'), |
|
278 | + 'give_post_form' => esc_html__('Display content BELOW the fields', 'give'), |
|
279 | 279 | ) |
280 | 280 | ), |
281 | 281 | 'default' => 'none', |
282 | 282 | ), |
283 | 283 | array( |
284 | - 'name' => esc_html__( 'Content', 'give' ), |
|
285 | - 'description' => esc_html__( 'This content will display on the single give form page.', 'give' ), |
|
286 | - 'id' => $prefix . 'form_content', |
|
284 | + 'name' => esc_html__('Content', 'give'), |
|
285 | + 'description' => esc_html__('This content will display on the single give form page.', 'give'), |
|
286 | + 'id' => $prefix.'form_content', |
|
287 | 287 | 'row_classes' => 'give-subfield', |
288 | 288 | 'type' => 'wysiwyg' |
289 | 289 | ), |
290 | 290 | ) |
291 | 291 | ) |
292 | - ) ); |
|
292 | + )); |
|
293 | 293 | |
294 | 294 | |
295 | 295 | /** |
296 | 296 | * Display Options |
297 | 297 | */ |
298 | - $meta_boxes['form_display_options'] = apply_filters( 'give_form_display_options', array( |
|
298 | + $meta_boxes['form_display_options'] = apply_filters('give_form_display_options', array( |
|
299 | 299 | 'id' => 'form_display_options', |
300 | - 'title' => esc_html__( 'Form Display Options', 'give' ), |
|
301 | - 'object_types' => array( 'give_forms' ), |
|
300 | + 'title' => esc_html__('Form Display Options', 'give'), |
|
301 | + 'object_types' => array('give_forms'), |
|
302 | 302 | 'context' => 'normal', // 'normal', 'advanced', or 'side' |
303 | 303 | 'priority' => 'high', //Show above Content WYSIWYG |
304 | 304 | 'show_names' => true, // Show field names on the left |
305 | - 'fields' => apply_filters( 'give_forms_display_options_metabox_fields', array( |
|
305 | + 'fields' => apply_filters('give_forms_display_options_metabox_fields', array( |
|
306 | 306 | array( |
307 | - 'name' => esc_html__( 'Payment Fields', 'give' ), |
|
308 | - 'desc' => esc_html__( 'How would you like to display donation information for this form? The "Show on Page" option will display the entire form when the page loads. "Reveal Upon Click" places a button below the donation fields and upon click slides into view the rest of the fields. "Modal Window Upon Click" is a similar option, rather than sliding into view the fields they will open in a shadow box or "modal" window.', 'give' ), |
|
309 | - 'id' => $prefix . 'payment_display', |
|
307 | + 'name' => esc_html__('Payment Fields', 'give'), |
|
308 | + 'desc' => esc_html__('How would you like to display donation information for this form? The "Show on Page" option will display the entire form when the page loads. "Reveal Upon Click" places a button below the donation fields and upon click slides into view the rest of the fields. "Modal Window Upon Click" is a similar option, rather than sliding into view the fields they will open in a shadow box or "modal" window.', 'give'), |
|
309 | + 'id' => $prefix.'payment_display', |
|
310 | 310 | 'type' => 'select', |
311 | 311 | 'options' => array( |
312 | - 'onpage' => esc_html__( 'Show on Page', 'give' ), |
|
313 | - 'reveal' => esc_html__( 'Reveal Upon Click', 'give' ), |
|
314 | - 'modal' => esc_html__( 'Modal Window Upon Click', 'give' ), |
|
312 | + 'onpage' => esc_html__('Show on Page', 'give'), |
|
313 | + 'reveal' => esc_html__('Reveal Upon Click', 'give'), |
|
314 | + 'modal' => esc_html__('Modal Window Upon Click', 'give'), |
|
315 | 315 | ), |
316 | 316 | 'default' => 'onpage', |
317 | 317 | ), |
318 | 318 | array( |
319 | - 'id' => $prefix . 'reveal_label', |
|
320 | - 'name' => esc_html__( 'Reveal / Modal Open Text', 'give' ), |
|
321 | - 'desc' => esc_html__( 'The button label for completing the donation.', 'give' ), |
|
319 | + 'id' => $prefix.'reveal_label', |
|
320 | + 'name' => esc_html__('Reveal / Modal Open Text', 'give'), |
|
321 | + 'desc' => esc_html__('The button label for completing the donation.', 'give'), |
|
322 | 322 | 'type' => 'text_small', |
323 | 323 | 'row_classes' => 'give-subfield', |
324 | 324 | 'attributes' => array( |
325 | - 'placeholder' => esc_attr__( 'Donate Now', 'give' ), |
|
325 | + 'placeholder' => esc_attr__('Donate Now', 'give'), |
|
326 | 326 | ), |
327 | 327 | ), |
328 | 328 | array( |
329 | - 'id' => $prefix . 'checkout_label', |
|
330 | - 'name' => esc_html__( 'Complete Donation Text', 'give' ), |
|
331 | - 'desc' => esc_html__( 'The button label for completing a donation.', 'give' ), |
|
329 | + 'id' => $prefix.'checkout_label', |
|
330 | + 'name' => esc_html__('Complete Donation Text', 'give'), |
|
331 | + 'desc' => esc_html__('The button label for completing a donation.', 'give'), |
|
332 | 332 | 'type' => 'text_small', |
333 | 333 | 'attributes' => array( |
334 | - 'placeholder' => esc_html__( 'Donate Now', 'give' ), |
|
334 | + 'placeholder' => esc_html__('Donate Now', 'give'), |
|
335 | 335 | ), |
336 | 336 | ), |
337 | 337 | array( |
338 | - 'name' => esc_html__( 'Default Gateway', 'give' ), |
|
339 | - 'desc' => esc_html__( 'By default, the gateway for this form will inherit the global default gateway (set under Give > Settings > Payment Gateways). This option allows you to customize the default gateway for this form only.', 'give' ), |
|
340 | - 'id' => $prefix . 'default_gateway', |
|
338 | + 'name' => esc_html__('Default Gateway', 'give'), |
|
339 | + 'desc' => esc_html__('By default, the gateway for this form will inherit the global default gateway (set under Give > Settings > Payment Gateways). This option allows you to customize the default gateway for this form only.', 'give'), |
|
340 | + 'id' => $prefix.'default_gateway', |
|
341 | 341 | 'type' => 'default_gateway' |
342 | 342 | ), |
343 | 343 | array( |
344 | - 'name' => esc_html__( 'Disable Guest Donations', 'give' ), |
|
345 | - 'desc' => esc_html__( 'Do you want to require users be logged-in to make donations?', 'give' ), |
|
346 | - 'id' => $prefix . 'logged_in_only', |
|
344 | + 'name' => esc_html__('Disable Guest Donations', 'give'), |
|
345 | + 'desc' => esc_html__('Do you want to require users be logged-in to make donations?', 'give'), |
|
346 | + 'id' => $prefix.'logged_in_only', |
|
347 | 347 | 'type' => 'checkbox' |
348 | 348 | ), |
349 | 349 | array( |
350 | - 'name' => esc_html__( 'Register / Login Form', 'give' ), |
|
351 | - 'desc' => esc_html__( 'Display the registration and login forms in the payment section for non-logged-in users.', 'give' ), |
|
352 | - 'id' => $prefix . 'show_register_form', |
|
350 | + 'name' => esc_html__('Register / Login Form', 'give'), |
|
351 | + 'desc' => esc_html__('Display the registration and login forms in the payment section for non-logged-in users.', 'give'), |
|
352 | + 'id' => $prefix.'show_register_form', |
|
353 | 353 | 'type' => 'select', |
354 | 354 | 'options' => array( |
355 | - 'both' => esc_html__( 'Registration and Login Forms', 'give' ), |
|
356 | - 'registration' => esc_html__( 'Registration Form Only', 'give' ), |
|
357 | - 'login' => esc_html__( 'Login Form Only', 'give' ), |
|
358 | - 'none' => esc_html__( 'None', 'give' ), |
|
355 | + 'both' => esc_html__('Registration and Login Forms', 'give'), |
|
356 | + 'registration' => esc_html__('Registration Form Only', 'give'), |
|
357 | + 'login' => esc_html__('Login Form Only', 'give'), |
|
358 | + 'none' => esc_html__('None', 'give'), |
|
359 | 359 | ), |
360 | 360 | 'default' => 'none', |
361 | 361 | ), |
362 | 362 | array( |
363 | - 'name' => esc_html__( 'Floating Labels', 'give' ), |
|
363 | + 'name' => esc_html__('Floating Labels', 'give'), |
|
364 | 364 | /* translators: %s: forms https://givewp.com/documentation/core/give-forms/creating-give-forms/#floating-labels */ |
365 | - 'desc' => sprintf( __( 'Select the <a href="%s" target="_blank">floating labels</a> setting for this Give form.<br>Be aware that if you have the "Disable CSS" option enabled, you will need to style the floating labels yourself.', 'give' ), esc_url( 'https://givewp.com/documentation/core/give-forms/creating-give-forms/#floating-labels' ) ), |
|
366 | - 'id' => $prefix . 'form_floating_labels', |
|
365 | + 'desc' => sprintf(__('Select the <a href="%s" target="_blank">floating labels</a> setting for this Give form.<br>Be aware that if you have the "Disable CSS" option enabled, you will need to style the floating labels yourself.', 'give'), esc_url('https://givewp.com/documentation/core/give-forms/creating-give-forms/#floating-labels')), |
|
366 | + 'id' => $prefix.'form_floating_labels', |
|
367 | 367 | 'type' => 'select', |
368 | 368 | 'options' => array( |
369 | - '' => esc_html__( 'Use the global setting', 'give' ), |
|
370 | - 'enabled' => esc_html__( 'Enabled', 'give' ), |
|
371 | - 'disabled' => esc_html__( 'Disabled', 'give' ), |
|
369 | + '' => esc_html__('Use the global setting', 'give'), |
|
370 | + 'enabled' => esc_html__('Enabled', 'give'), |
|
371 | + 'disabled' => esc_html__('Disabled', 'give'), |
|
372 | 372 | ), |
373 | 373 | 'default' => 'none', |
374 | 374 | ) |
@@ -380,47 +380,47 @@ discard block |
||
380 | 380 | /** |
381 | 381 | * Terms & Conditions |
382 | 382 | */ |
383 | - $meta_boxes['form_terms_options'] = apply_filters( 'give_forms_terms_options', array( |
|
383 | + $meta_boxes['form_terms_options'] = apply_filters('give_forms_terms_options', array( |
|
384 | 384 | 'id' => 'form_terms_options', |
385 | - 'title' => esc_html__( 'Terms and Conditions', 'give' ), |
|
386 | - 'object_types' => array( 'give_forms' ), |
|
385 | + 'title' => esc_html__('Terms and Conditions', 'give'), |
|
386 | + 'object_types' => array('give_forms'), |
|
387 | 387 | 'context' => 'normal', |
388 | 388 | 'priority' => 'high', //Show above Content WYSIWYG |
389 | - 'fields' => apply_filters( 'give_forms_terms_options_metabox_fields', array( |
|
389 | + 'fields' => apply_filters('give_forms_terms_options_metabox_fields', array( |
|
390 | 390 | //Donation Option |
391 | 391 | array( |
392 | - 'name' => esc_html__( 'Terms and Conditions', 'give' ), |
|
393 | - 'description' => esc_html__( 'Do you want to require the user to agree to terms and conditions prior to being able to complete their donation?', 'give' ), |
|
394 | - 'id' => $prefix . 'terms_option', |
|
392 | + 'name' => esc_html__('Terms and Conditions', 'give'), |
|
393 | + 'description' => esc_html__('Do you want to require the user to agree to terms and conditions prior to being able to complete their donation?', 'give'), |
|
394 | + 'id' => $prefix.'terms_option', |
|
395 | 395 | 'type' => 'select', |
396 | - 'options' => apply_filters( 'give_forms_content_options_select', array( |
|
397 | - 'none' => esc_html__( 'No', 'give' ), |
|
398 | - 'yes' => esc_html__( 'Yes', 'give' ), |
|
396 | + 'options' => apply_filters('give_forms_content_options_select', array( |
|
397 | + 'none' => esc_html__('No', 'give'), |
|
398 | + 'yes' => esc_html__('Yes', 'give'), |
|
399 | 399 | ) |
400 | 400 | ), |
401 | 401 | 'default' => 'none', |
402 | 402 | ), |
403 | 403 | array( |
404 | - 'id' => $prefix . 'agree_label', |
|
405 | - 'name' => esc_html__( 'Agree to Terms Label', 'give' ), |
|
406 | - 'desc' => esc_html__( 'The label shown next to the agree to terms check box. Add your own to customize or leave blank to use the default text placeholder.', 'give' ), |
|
404 | + 'id' => $prefix.'agree_label', |
|
405 | + 'name' => esc_html__('Agree to Terms Label', 'give'), |
|
406 | + 'desc' => esc_html__('The label shown next to the agree to terms check box. Add your own to customize or leave blank to use the default text placeholder.', 'give'), |
|
407 | 407 | 'type' => 'text', |
408 | 408 | 'row_classes' => 'give-subfield', |
409 | 409 | 'size' => 'regular', |
410 | 410 | 'attributes' => array( |
411 | - 'placeholder' => esc_attr__( 'Agree to Terms?', 'give' ), |
|
411 | + 'placeholder' => esc_attr__('Agree to Terms?', 'give'), |
|
412 | 412 | ), |
413 | 413 | ), |
414 | 414 | array( |
415 | - 'id' => $prefix . 'agree_text', |
|
415 | + 'id' => $prefix.'agree_text', |
|
416 | 416 | 'row_classes' => 'give-subfield', |
417 | - 'name' => esc_html__( 'Agreement Text', 'give' ), |
|
418 | - 'desc' => esc_html__( 'This is the actual text which the user will have to agree to in order to make a donation.', 'give' ), |
|
417 | + 'name' => esc_html__('Agreement Text', 'give'), |
|
418 | + 'desc' => esc_html__('This is the actual text which the user will have to agree to in order to make a donation.', 'give'), |
|
419 | 419 | 'type' => 'wysiwyg' |
420 | 420 | ), |
421 | 421 | ) |
422 | 422 | ) |
423 | - ) ); |
|
423 | + )); |
|
424 | 424 | |
425 | 425 | return $meta_boxes; |
426 | 426 | |
@@ -434,9 +434,9 @@ discard block |
||
434 | 434 | |
435 | 435 | <div class="table-container"> |
436 | 436 | <div class="table-row"> |
437 | - <div class="table-cell col-amount"><?php esc_html_e( 'Amount', 'give' ); ?></div> |
|
438 | - <div class="table-cell col-text"><?php esc_html_e( 'Text', 'give' ); ?></div> |
|
439 | - <div class="table-cell col-default"><?php esc_html_e( 'Default', 'give' ); ?></div> |
|
437 | + <div class="table-cell col-amount"><?php esc_html_e('Amount', 'give'); ?></div> |
|
438 | + <div class="table-cell col-text"><?php esc_html_e('Text', 'give'); ?></div> |
|
439 | + <div class="table-cell col-default"><?php esc_html_e('Default', 'give'); ?></div> |
|
440 | 440 | <?php |
441 | 441 | /** |
442 | 442 | * Fires in repeatable donation levels table head. |
@@ -448,9 +448,9 @@ discard block |
||
448 | 448 | * |
449 | 449 | * @since 1.0 |
450 | 450 | */ |
451 | - do_action( 'give_donation_levels_table_head' ); |
|
451 | + do_action('give_donation_levels_table_head'); |
|
452 | 452 | ?> |
453 | - <div class="table-cell col-sort"><?php esc_html_e( 'Sort', 'give' ); ?></div> |
|
453 | + <div class="table-cell col-sort"><?php esc_html_e('Sort', 'give'); ?></div> |
|
454 | 454 | |
455 | 455 | </div> |
456 | 456 | </div> |
@@ -458,7 +458,7 @@ discard block |
||
458 | 458 | <?php |
459 | 459 | } |
460 | 460 | |
461 | -add_action( 'cmb2_render_levels_repeater_header', 'give_cmb_render_levels_repeater_header', 10 ); |
|
461 | +add_action('cmb2_render_levels_repeater_header', 'give_cmb_render_levels_repeater_header', 10); |
|
462 | 462 | |
463 | 463 | |
464 | 464 | /** |
@@ -475,25 +475,25 @@ discard block |
||
475 | 475 | * @param $object_type |
476 | 476 | * @param $field_type_object |
477 | 477 | */ |
478 | -function give_cmb_render_levels_id( $field_object, $escaped_value, $object_id, $object_type, $field_type_object ) { |
|
478 | +function give_cmb_render_levels_id($field_object, $escaped_value, $object_id, $object_type, $field_type_object) { |
|
479 | 479 | |
480 | - $escaped_value = ( isset( $escaped_value['level_id'] ) ? $escaped_value['level_id'] : '' ); |
|
480 | + $escaped_value = (isset($escaped_value['level_id']) ? $escaped_value['level_id'] : ''); |
|
481 | 481 | |
482 | 482 | $field_options_array = array( |
483 | 483 | 'class' => 'give-hidden give-level-id-input', |
484 | - 'name' => $field_type_object->_name( '[level_id]' ), |
|
485 | - 'id' => $field_type_object->_id( '_level_id' ), |
|
484 | + 'name' => $field_type_object->_name('[level_id]'), |
|
485 | + 'id' => $field_type_object->_id('_level_id'), |
|
486 | 486 | 'value' => $escaped_value, |
487 | 487 | 'type' => 'number', |
488 | 488 | 'desc' => '', |
489 | 489 | ); |
490 | 490 | |
491 | - echo '<p class="give-level-id">' . $escaped_value . '</p>'; |
|
492 | - echo $field_type_object->input( $field_options_array ); |
|
491 | + echo '<p class="give-level-id">'.$escaped_value.'</p>'; |
|
492 | + echo $field_type_object->input($field_options_array); |
|
493 | 493 | |
494 | 494 | } |
495 | 495 | |
496 | -add_action( 'cmb2_render_levels_id', 'give_cmb_render_levels_id', 10, 5 ); |
|
496 | +add_action('cmb2_render_levels_id', 'give_cmb_render_levels_id', 10, 5); |
|
497 | 497 | |
498 | 498 | |
499 | 499 | /** |
@@ -505,13 +505,13 @@ discard block |
||
505 | 505 | * @param $object_type |
506 | 506 | * @param $field_type_object |
507 | 507 | */ |
508 | -function give_cmb_give_default_radio_inline( $field_object, $escaped_value, $object_id, $object_type, $field_type_object ) { |
|
509 | - echo '<input type="radio" class="cmb2-option donation-level-radio" name="' . $field_object->args['_name'] . '" id="' . $field_object->args['id'] . '" value="default" ' . checked( 'default', $escaped_value, false ) . '>'; |
|
510 | - echo '<label for="' . $field_object->args['id'] . '">' . esc_html__( 'Default', 'give' ) . '</label>'; |
|
508 | +function give_cmb_give_default_radio_inline($field_object, $escaped_value, $object_id, $object_type, $field_type_object) { |
|
509 | + echo '<input type="radio" class="cmb2-option donation-level-radio" name="'.$field_object->args['_name'].'" id="'.$field_object->args['id'].'" value="default" '.checked('default', $escaped_value, false).'>'; |
|
510 | + echo '<label for="'.$field_object->args['id'].'">'.esc_html__('Default', 'give').'</label>'; |
|
511 | 511 | |
512 | 512 | } |
513 | 513 | |
514 | -add_action( 'cmb2_render_give_default_radio_inline', 'give_cmb_give_default_radio_inline', 10, 5 ); |
|
514 | +add_action('cmb2_render_give_default_radio_inline', 'give_cmb_give_default_radio_inline', 10, 5); |
|
515 | 515 | |
516 | 516 | |
517 | 517 | /** |
@@ -521,20 +521,20 @@ discard block |
||
521 | 521 | */ |
522 | 522 | function give_add_shortcode_to_publish_metabox() { |
523 | 523 | |
524 | - if ( 'give_forms' !== get_post_type() ) { |
|
524 | + if ('give_forms' !== get_post_type()) { |
|
525 | 525 | return false; |
526 | 526 | } |
527 | 527 | |
528 | 528 | global $post; |
529 | 529 | |
530 | 530 | //Only enqueue scripts for CPT on post type screen |
531 | - if ( 'give_forms' === $post->post_type ) { |
|
531 | + if ('give_forms' === $post->post_type) { |
|
532 | 532 | //Shortcode column with select all input |
533 | - $shortcode = htmlentities( '[give_form id="' . $post->ID . '"]' ); |
|
534 | - 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>'; |
|
533 | + $shortcode = htmlentities('[give_form id="'.$post->ID.'"]'); |
|
534 | + 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>'; |
|
535 | 535 | |
536 | 536 | } |
537 | 537 | |
538 | 538 | } |
539 | 539 | |
540 | -add_action( 'post_submitbox_misc_actions', 'give_add_shortcode_to_publish_metabox' ); |
|
540 | +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 | |
@@ -98,11 +98,11 @@ discard block |
||
98 | 98 | * |
99 | 99 | * @return object |
100 | 100 | */ |
101 | - public function get( $row_id ) { |
|
101 | + public function get($row_id) { |
|
102 | 102 | /* @var WPDB $wpdb */ |
103 | 103 | global $wpdb; |
104 | 104 | |
105 | - return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) ); |
|
105 | + return $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id)); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | /** |
@@ -116,12 +116,12 @@ discard block |
||
116 | 116 | * |
117 | 117 | * @return object |
118 | 118 | */ |
119 | - public function get_by( $column, $row_id ) { |
|
119 | + public function get_by($column, $row_id) { |
|
120 | 120 | /* @var WPDB $wpdb */ |
121 | 121 | global $wpdb; |
122 | 122 | |
123 | - $column = esc_sql( $column ); |
|
124 | - return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id ) ); |
|
123 | + $column = esc_sql($column); |
|
124 | + return $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id)); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -135,12 +135,12 @@ discard block |
||
135 | 135 | * |
136 | 136 | * @return string Column value. |
137 | 137 | */ |
138 | - public function get_column( $column, $row_id ) { |
|
138 | + public function get_column($column, $row_id) { |
|
139 | 139 | /* @var WPDB $wpdb */ |
140 | 140 | global $wpdb; |
141 | 141 | |
142 | - $column = esc_sql( $column ); |
|
143 | - return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) ); |
|
142 | + $column = esc_sql($column); |
|
143 | + return $wpdb->get_var($wpdb->prepare("SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id)); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
@@ -155,13 +155,13 @@ discard block |
||
155 | 155 | * |
156 | 156 | * @return string |
157 | 157 | */ |
158 | - public function get_column_by( $column, $column_where, $column_value ) { |
|
158 | + public function get_column_by($column, $column_where, $column_value) { |
|
159 | 159 | /* @var WPDB $wpdb */ |
160 | 160 | global $wpdb; |
161 | 161 | |
162 | - $column_where = esc_sql( $column_where ); |
|
163 | - $column = esc_sql( $column ); |
|
164 | - return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value ) ); |
|
162 | + $column_where = esc_sql($column_where); |
|
163 | + $column = esc_sql($column); |
|
164 | + return $wpdb->get_var($wpdb->prepare("SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value)); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | /** |
@@ -175,12 +175,12 @@ discard block |
||
175 | 175 | * |
176 | 176 | * @return int |
177 | 177 | */ |
178 | - public function insert( $data, $type = '' ) { |
|
178 | + public function insert($data, $type = '') { |
|
179 | 179 | /* @var WPDB $wpdb */ |
180 | 180 | global $wpdb; |
181 | 181 | |
182 | 182 | // Set default values. |
183 | - $data = wp_parse_args( $data, $this->get_column_defaults() ); |
|
183 | + $data = wp_parse_args($data, $this->get_column_defaults()); |
|
184 | 184 | |
185 | 185 | /** |
186 | 186 | * Fires before inserting data to the database. |
@@ -189,22 +189,22 @@ discard block |
||
189 | 189 | * |
190 | 190 | * @param array $data |
191 | 191 | */ |
192 | - do_action( "give_pre_insert_{$type}", $data ); |
|
192 | + do_action("give_pre_insert_{$type}", $data); |
|
193 | 193 | |
194 | 194 | // Initialise column format array |
195 | 195 | $column_formats = $this->get_columns(); |
196 | 196 | |
197 | 197 | // Force fields to lower case |
198 | - $data = array_change_key_case( $data ); |
|
198 | + $data = array_change_key_case($data); |
|
199 | 199 | |
200 | 200 | // White list columns |
201 | - $data = array_intersect_key( $data, $column_formats ); |
|
201 | + $data = array_intersect_key($data, $column_formats); |
|
202 | 202 | |
203 | 203 | // Reorder $column_formats to match the order of columns given in $data |
204 | - $data_keys = array_keys( $data ); |
|
205 | - $column_formats = array_merge( array_flip( $data_keys ), $column_formats ); |
|
204 | + $data_keys = array_keys($data); |
|
205 | + $column_formats = array_merge(array_flip($data_keys), $column_formats); |
|
206 | 206 | |
207 | - $wpdb->insert( $this->table_name, $data, $column_formats ); |
|
207 | + $wpdb->insert($this->table_name, $data, $column_formats); |
|
208 | 208 | |
209 | 209 | /** |
210 | 210 | * Fires after inserting data to the database. |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | * @param int $insert_id |
215 | 215 | * @param array $data |
216 | 216 | */ |
217 | - do_action( "give_post_insert_{$type}", $wpdb->insert_id, $data ); |
|
217 | + do_action("give_post_insert_{$type}", $wpdb->insert_id, $data); |
|
218 | 218 | |
219 | 219 | return $wpdb->insert_id; |
220 | 220 | } |
@@ -231,18 +231,18 @@ discard block |
||
231 | 231 | * |
232 | 232 | * @return bool |
233 | 233 | */ |
234 | - public function update( $row_id, $data = array(), $where = '' ) { |
|
234 | + public function update($row_id, $data = array(), $where = '') { |
|
235 | 235 | /* @var WPDB $wpdb */ |
236 | 236 | global $wpdb; |
237 | 237 | |
238 | 238 | // Row ID must be positive integer |
239 | - $row_id = absint( $row_id ); |
|
239 | + $row_id = absint($row_id); |
|
240 | 240 | |
241 | - if ( empty( $row_id ) ) { |
|
241 | + if (empty($row_id)) { |
|
242 | 242 | return false; |
243 | 243 | } |
244 | 244 | |
245 | - if ( empty( $where ) ) { |
|
245 | + if (empty($where)) { |
|
246 | 246 | $where = $this->primary_key; |
247 | 247 | } |
248 | 248 | |
@@ -250,16 +250,16 @@ discard block |
||
250 | 250 | $column_formats = $this->get_columns(); |
251 | 251 | |
252 | 252 | // Force fields to lower case |
253 | - $data = array_change_key_case( $data ); |
|
253 | + $data = array_change_key_case($data); |
|
254 | 254 | |
255 | 255 | // White list columns |
256 | - $data = array_intersect_key( $data, $column_formats ); |
|
256 | + $data = array_intersect_key($data, $column_formats); |
|
257 | 257 | |
258 | 258 | // Reorder $column_formats to match the order of columns given in $data |
259 | - $data_keys = array_keys( $data ); |
|
260 | - $column_formats = array_merge( array_flip( $data_keys ), $column_formats ); |
|
259 | + $data_keys = array_keys($data); |
|
260 | + $column_formats = array_merge(array_flip($data_keys), $column_formats); |
|
261 | 261 | |
262 | - if ( false === $wpdb->update( $this->table_name, $data, array( $where => $row_id ), $column_formats ) ) { |
|
262 | + if (false === $wpdb->update($this->table_name, $data, array($where => $row_id), $column_formats)) { |
|
263 | 263 | return false; |
264 | 264 | } |
265 | 265 | |
@@ -276,18 +276,18 @@ discard block |
||
276 | 276 | * |
277 | 277 | * @return bool |
278 | 278 | */ |
279 | - public function delete( $row_id = 0 ) { |
|
279 | + public function delete($row_id = 0) { |
|
280 | 280 | /* @var WPDB $wpdb */ |
281 | 281 | global $wpdb; |
282 | 282 | |
283 | 283 | // Row ID must be positive integer |
284 | - $row_id = absint( $row_id ); |
|
284 | + $row_id = absint($row_id); |
|
285 | 285 | |
286 | - if ( empty( $row_id ) ) { |
|
286 | + if (empty($row_id)) { |
|
287 | 287 | return false; |
288 | 288 | } |
289 | 289 | |
290 | - if ( false === $wpdb->query( $wpdb->prepare( "DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id ) ) ) { |
|
290 | + if (false === $wpdb->query($wpdb->prepare("DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id))) { |
|
291 | 291 | return false; |
292 | 292 | } |
293 | 293 | |
@@ -304,13 +304,13 @@ discard block |
||
304 | 304 | * |
305 | 305 | * @return bool If the table name exists. |
306 | 306 | */ |
307 | - public function table_exists( $table ) { |
|
307 | + public function table_exists($table) { |
|
308 | 308 | /* @var WPDB $wpdb */ |
309 | 309 | global $wpdb; |
310 | 310 | |
311 | - $table = sanitize_text_field( $table ); |
|
311 | + $table = sanitize_text_field($table); |
|
312 | 312 | |
313 | - return $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE '%s'", $table ) ) === $table; |
|
313 | + return $wpdb->get_var($wpdb->prepare("SHOW TABLES LIKE '%s'", $table)) === $table; |
|
314 | 314 | } |
315 | 315 | |
316 | 316 | /** |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | * @return bool Returns if the customers table was installed and upgrade routine run. |
323 | 323 | */ |
324 | 324 | public function installed() { |
325 | - return $this->table_exists( $this->table_name ); |
|
325 | + return $this->table_exists($this->table_name); |
|
326 | 326 | } |
327 | 327 | |
328 | 328 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -25,28 +25,28 @@ discard block |
||
25 | 25 | */ |
26 | 26 | function give_donation_history() { |
27 | 27 | |
28 | - $email_access = give_get_option( 'email_access' ); |
|
28 | + $email_access = give_get_option('email_access'); |
|
29 | 29 | |
30 | 30 | //Is user logged in? Does a session exist? Does an email-access token exist? |
31 | - if ( is_user_logged_in() || Give()->session->get_session_expiration() !== false || ( $email_access == 'on' && Give()->email_access->token_exists ) ) { |
|
31 | + if (is_user_logged_in() || Give()->session->get_session_expiration() !== false || ($email_access == 'on' && Give()->email_access->token_exists)) { |
|
32 | 32 | ob_start(); |
33 | - give_get_template_part( 'history', 'donations' ); |
|
33 | + give_get_template_part('history', 'donations'); |
|
34 | 34 | |
35 | 35 | return ob_get_clean(); |
36 | 36 | } //Is Email-based access enabled? |
37 | - elseif ( $email_access == 'on' ) { |
|
37 | + elseif ($email_access == 'on') { |
|
38 | 38 | |
39 | 39 | ob_start(); |
40 | - give_get_template_part( 'email', 'login-form' ); |
|
40 | + give_get_template_part('email', 'login-form'); |
|
41 | 41 | |
42 | 42 | return ob_get_clean(); |
43 | 43 | } else { |
44 | - $message = esc_html__( 'You must be logged in to view your donation history. Please login using your account or create an account using the same email you used to donate with.', 'give' ); |
|
45 | - echo apply_filters( 'give_donation_history_nonuser_message', give_output_error( $message, false ), $message ); |
|
44 | + $message = esc_html__('You must be logged in to view your donation history. Please login using your account or create an account using the same email you used to donate with.', 'give'); |
|
45 | + echo apply_filters('give_donation_history_nonuser_message', give_output_error($message, false), $message); |
|
46 | 46 | } |
47 | 47 | } |
48 | 48 | |
49 | -add_shortcode( 'donation_history', 'give_donation_history' ); |
|
49 | +add_shortcode('donation_history', 'give_donation_history'); |
|
50 | 50 | |
51 | 51 | /** |
52 | 52 | * Donation Form Shortcode |
@@ -60,53 +60,53 @@ discard block |
||
60 | 60 | * |
61 | 61 | * @return string |
62 | 62 | */ |
63 | -function give_form_shortcode( $atts, $content = null ) { |
|
64 | - $atts = shortcode_atts( array( |
|
63 | +function give_form_shortcode($atts, $content = null) { |
|
64 | + $atts = shortcode_atts(array( |
|
65 | 65 | 'id' => '', |
66 | 66 | 'show_title' => true, |
67 | 67 | 'show_goal' => true, |
68 | 68 | 'show_content' => '', |
69 | 69 | 'float_labels' => '', |
70 | 70 | 'display_style' => '', |
71 | - ), $atts, 'give_form' ); |
|
71 | + ), $atts, 'give_form'); |
|
72 | 72 | |
73 | - foreach ( $atts as $key => $value ) { |
|
73 | + foreach ($atts as $key => $value) { |
|
74 | 74 | //convert shortcode_atts values to booleans |
75 | - if ( $key == 'show_title' ) { |
|
76 | - $atts[ $key ] = filter_var( $atts[ $key ], FILTER_VALIDATE_BOOLEAN ); |
|
77 | - } elseif ( $key == 'show_goal' ) { |
|
78 | - $atts[ $key ] = filter_var( $atts[ $key ], FILTER_VALIDATE_BOOLEAN ); |
|
75 | + if ($key == 'show_title') { |
|
76 | + $atts[$key] = filter_var($atts[$key], FILTER_VALIDATE_BOOLEAN); |
|
77 | + } elseif ($key == 'show_goal') { |
|
78 | + $atts[$key] = filter_var($atts[$key], FILTER_VALIDATE_BOOLEAN); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | //validate show_content value |
82 | - if ( $key == 'show_content' ) { |
|
83 | - if ( ! in_array( $value, array( 'none', 'above', 'below' ) ) ) { |
|
84 | - $atts[ $key ] = ''; |
|
85 | - } else if ( $value == 'above' ) { |
|
86 | - $atts[ $key ] = 'give_pre_form'; |
|
87 | - } else if ( $value == 'below' ) { |
|
88 | - $atts[ $key ] = 'give_post_form'; |
|
82 | + if ($key == 'show_content') { |
|
83 | + if ( ! in_array($value, array('none', 'above', 'below'))) { |
|
84 | + $atts[$key] = ''; |
|
85 | + } else if ($value == 'above') { |
|
86 | + $atts[$key] = 'give_pre_form'; |
|
87 | + } else if ($value == 'below') { |
|
88 | + $atts[$key] = 'give_post_form'; |
|
89 | 89 | } |
90 | 90 | } |
91 | 91 | |
92 | 92 | //validate display_style and float_labels value |
93 | - if ( ( $key == 'display_style' && ! in_array( $value, array( 'onpage', 'reveal', 'modal' ) ) ) |
|
94 | - || ( $key == 'float_labels' && ! in_array( $value, array( 'enabled', 'disabled' ) ) ) |
|
93 | + if (($key == 'display_style' && ! in_array($value, array('onpage', 'reveal', 'modal'))) |
|
94 | + || ($key == 'float_labels' && ! in_array($value, array('enabled', 'disabled'))) |
|
95 | 95 | ) { |
96 | 96 | |
97 | - $atts[ $key ] = ''; |
|
97 | + $atts[$key] = ''; |
|
98 | 98 | } |
99 | 99 | } |
100 | 100 | |
101 | 101 | //get the Give Form |
102 | 102 | ob_start(); |
103 | - give_get_donation_form( $atts ); |
|
103 | + give_get_donation_form($atts); |
|
104 | 104 | $final_output = ob_get_clean(); |
105 | 105 | |
106 | - return apply_filters( 'give_donate_form', $final_output, $atts ); |
|
106 | + return apply_filters('give_donate_form', $final_output, $atts); |
|
107 | 107 | } |
108 | 108 | |
109 | -add_shortcode( 'give_form', 'give_form_shortcode' ); |
|
109 | +add_shortcode('give_form', 'give_form_shortcode'); |
|
110 | 110 | |
111 | 111 | /** |
112 | 112 | * Donation Form Goal Shortcode. |
@@ -120,37 +120,37 @@ discard block |
||
120 | 120 | * |
121 | 121 | * @return string |
122 | 122 | */ |
123 | -function give_goal_shortcode( $atts, $content = null ) { |
|
124 | - $atts = shortcode_atts( array( |
|
123 | +function give_goal_shortcode($atts, $content = null) { |
|
124 | + $atts = shortcode_atts(array( |
|
125 | 125 | 'id' => '', |
126 | 126 | 'show_text' => true, |
127 | 127 | 'show_bar' => true, |
128 | - ), $atts, 'give_goal' ); |
|
128 | + ), $atts, 'give_goal'); |
|
129 | 129 | |
130 | 130 | |
131 | 131 | //get the Give Form. |
132 | 132 | ob_start(); |
133 | 133 | |
134 | 134 | //Sanity check 1: ensure there is an ID Provided. |
135 | - if ( empty( $atts['id'] ) ) { |
|
136 | - give_output_error( esc_html__( 'The shortcode is missing Donation Form ID attribute.', 'give' ), true ); |
|
135 | + if (empty($atts['id'])) { |
|
136 | + give_output_error(esc_html__('The shortcode is missing Donation Form ID attribute.', 'give'), true); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | //Sanity check 2: Check the form even has Goals enabled. |
140 | - $goal_option = get_post_meta( $atts['id'], '_give_goal_option', true ); |
|
141 | - if ( empty( $goal_option ) || $goal_option !== 'yes' ) { |
|
142 | - give_output_error( esc_html__( 'The form does not have Goals enabled.', 'give' ), true ); |
|
140 | + $goal_option = get_post_meta($atts['id'], '_give_goal_option', true); |
|
141 | + if (empty($goal_option) || $goal_option !== 'yes') { |
|
142 | + give_output_error(esc_html__('The form does not have Goals enabled.', 'give'), true); |
|
143 | 143 | } else { |
144 | 144 | //Passed all sanity checks: output Goal. |
145 | - give_show_goal_progress( $atts['id'], $atts ); |
|
145 | + give_show_goal_progress($atts['id'], $atts); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | $final_output = ob_get_clean(); |
149 | 149 | |
150 | - return apply_filters( 'give_goal_shortcode_output', $final_output, $atts ); |
|
150 | + return apply_filters('give_goal_shortcode_output', $final_output, $atts); |
|
151 | 151 | } |
152 | 152 | |
153 | -add_shortcode( 'give_goal', 'give_goal_shortcode' ); |
|
153 | +add_shortcode('give_goal', 'give_goal_shortcode'); |
|
154 | 154 | |
155 | 155 | |
156 | 156 | /** |
@@ -167,22 +167,22 @@ discard block |
||
167 | 167 | * @uses give_login_form() |
168 | 168 | * @return string |
169 | 169 | */ |
170 | -function give_login_form_shortcode( $atts, $content = null ) { |
|
171 | - $atts = shortcode_atts( array( |
|
170 | +function give_login_form_shortcode($atts, $content = null) { |
|
171 | + $atts = shortcode_atts(array( |
|
172 | 172 | // Add backward compatibility for redirect attribute. |
173 | 173 | 'redirect' => '', |
174 | 174 | |
175 | 175 | 'login-redirect' => '', |
176 | 176 | 'logout-redirect' => '', |
177 | - ), $atts, 'give_login' ); |
|
177 | + ), $atts, 'give_login'); |
|
178 | 178 | |
179 | 179 | // Check login-redirect attribute first, if it empty or not found then check for redirect attribute and add value of this to login-redirect attribute. |
180 | - $atts['login-redirect'] = ! empty( $atts['login-redirect'] ) ? $atts['login-redirect'] : ( ! empty( $atts['redirect' ] ) ? $atts['redirect'] : '' ); |
|
180 | + $atts['login-redirect'] = ! empty($atts['login-redirect']) ? $atts['login-redirect'] : ( ! empty($atts['redirect']) ? $atts['redirect'] : ''); |
|
181 | 181 | |
182 | - return give_login_form( $atts['login-redirect'], $atts['logout-redirect'] ); |
|
182 | + return give_login_form($atts['login-redirect'], $atts['logout-redirect']); |
|
183 | 183 | } |
184 | 184 | |
185 | -add_shortcode( 'give_login', 'give_login_form_shortcode' ); |
|
185 | +add_shortcode('give_login', 'give_login_form_shortcode'); |
|
186 | 186 | |
187 | 187 | /** |
188 | 188 | * Register Shortcode. |
@@ -197,15 +197,15 @@ discard block |
||
197 | 197 | * @uses give_register_form() |
198 | 198 | * @return string |
199 | 199 | */ |
200 | -function give_register_form_shortcode( $atts, $content = null ) { |
|
201 | - $atts = shortcode_atts( array( |
|
200 | +function give_register_form_shortcode($atts, $content = null) { |
|
201 | + $atts = shortcode_atts(array( |
|
202 | 202 | 'redirect' => '', |
203 | - ), $atts, 'give_register' ); |
|
203 | + ), $atts, 'give_register'); |
|
204 | 204 | |
205 | - return give_register_form( $atts['redirect'] ); |
|
205 | + return give_register_form($atts['redirect']); |
|
206 | 206 | } |
207 | 207 | |
208 | -add_shortcode( 'give_register', 'give_register_form_shortcode' ); |
|
208 | +add_shortcode('give_register', 'give_register_form_shortcode'); |
|
209 | 209 | |
210 | 210 | |
211 | 211 | /** |
@@ -220,62 +220,62 @@ discard block |
||
220 | 220 | * |
221 | 221 | * @return string |
222 | 222 | */ |
223 | -function give_receipt_shortcode( $atts, $content = null ) { |
|
223 | +function give_receipt_shortcode($atts, $content = null) { |
|
224 | 224 | |
225 | 225 | global $give_receipt_args, $payment; |
226 | 226 | |
227 | - $give_receipt_args = shortcode_atts( array( |
|
228 | - 'error' => esc_html__( 'You are missing the payment key to view this donation receipt.', 'give' ), |
|
227 | + $give_receipt_args = shortcode_atts(array( |
|
228 | + 'error' => esc_html__('You are missing the payment key to view this donation receipt.', 'give'), |
|
229 | 229 | 'price' => true, |
230 | 230 | 'donor' => true, |
231 | 231 | 'date' => true, |
232 | 232 | 'payment_key' => false, |
233 | 233 | 'payment_method' => true, |
234 | 234 | 'payment_id' => true |
235 | - ), $atts, 'give_receipt' ); |
|
235 | + ), $atts, 'give_receipt'); |
|
236 | 236 | |
237 | 237 | //set $session var |
238 | 238 | $session = give_get_purchase_session(); |
239 | 239 | |
240 | 240 | //set payment key var |
241 | - if ( isset( $_GET['payment_key'] ) ) { |
|
242 | - $payment_key = urldecode( $_GET['payment_key'] ); |
|
243 | - } elseif ( $session ) { |
|
241 | + if (isset($_GET['payment_key'])) { |
|
242 | + $payment_key = urldecode($_GET['payment_key']); |
|
243 | + } elseif ($session) { |
|
244 | 244 | $payment_key = $session['purchase_key']; |
245 | - } elseif ( $give_receipt_args['payment_key'] ) { |
|
245 | + } elseif ($give_receipt_args['payment_key']) { |
|
246 | 246 | $payment_key = $give_receipt_args['payment_key']; |
247 | 247 | } |
248 | 248 | |
249 | - $email_access = give_get_option( 'email_access' ); |
|
249 | + $email_access = give_get_option('email_access'); |
|
250 | 250 | |
251 | 251 | // No payment_key found & Email Access is Turned on: |
252 | - if ( ! isset( $payment_key ) && $email_access == 'on' && ! Give()->email_access->token_exists ) { |
|
252 | + if ( ! isset($payment_key) && $email_access == 'on' && ! Give()->email_access->token_exists) { |
|
253 | 253 | |
254 | 254 | ob_start(); |
255 | 255 | |
256 | - give_get_template_part( 'email-login-form' ); |
|
256 | + give_get_template_part('email-login-form'); |
|
257 | 257 | |
258 | 258 | return ob_get_clean(); |
259 | 259 | |
260 | - } elseif ( ! isset( $payment_key ) ) { |
|
260 | + } elseif ( ! isset($payment_key)) { |
|
261 | 261 | |
262 | - return give_output_error( $give_receipt_args['error'], false, 'error' ); |
|
262 | + return give_output_error($give_receipt_args['error'], false, 'error'); |
|
263 | 263 | |
264 | 264 | } |
265 | 265 | |
266 | - $payment_id = give_get_purchase_id_by_key( $payment_key ); |
|
267 | - $user_can_view = give_can_view_receipt( $payment_key ); |
|
266 | + $payment_id = give_get_purchase_id_by_key($payment_key); |
|
267 | + $user_can_view = give_can_view_receipt($payment_key); |
|
268 | 268 | |
269 | 269 | // Key was provided, but user is logged out. Offer them the ability to login and view the receipt. |
270 | - if ( ! $user_can_view && $email_access == 'on' && ! Give()->email_access->token_exists ) { |
|
270 | + if ( ! $user_can_view && $email_access == 'on' && ! Give()->email_access->token_exists) { |
|
271 | 271 | |
272 | 272 | ob_start(); |
273 | 273 | |
274 | - give_get_template_part( 'email-login-form' ); |
|
274 | + give_get_template_part('email-login-form'); |
|
275 | 275 | |
276 | 276 | return ob_get_clean(); |
277 | 277 | |
278 | - } elseif ( ! $user_can_view ) { |
|
278 | + } elseif ( ! $user_can_view) { |
|
279 | 279 | |
280 | 280 | global $give_login_redirect; |
281 | 281 | |
@@ -283,9 +283,9 @@ discard block |
||
283 | 283 | |
284 | 284 | ob_start(); |
285 | 285 | |
286 | - give_output_error( apply_filters( 'give_must_be_logged_in_error_message', esc_html__( 'You must be logged in to view this donation receipt.', 'give' ) ) ); |
|
286 | + give_output_error(apply_filters('give_must_be_logged_in_error_message', esc_html__('You must be logged in to view this donation receipt.', 'give'))); |
|
287 | 287 | |
288 | - give_get_template_part( 'shortcode', 'login' ); |
|
288 | + give_get_template_part('shortcode', 'login'); |
|
289 | 289 | |
290 | 290 | $login_form = ob_get_clean(); |
291 | 291 | |
@@ -300,13 +300,13 @@ discard block |
||
300 | 300 | * or if user is logged in and the user can view sensitive shop data. |
301 | 301 | * |
302 | 302 | */ |
303 | - if ( ! apply_filters( 'give_user_can_view_receipt', $user_can_view, $give_receipt_args ) ) { |
|
304 | - return give_output_error( $give_receipt_args['error'], false, 'error' ); |
|
303 | + if ( ! apply_filters('give_user_can_view_receipt', $user_can_view, $give_receipt_args)) { |
|
304 | + return give_output_error($give_receipt_args['error'], false, 'error'); |
|
305 | 305 | } |
306 | 306 | |
307 | 307 | ob_start(); |
308 | 308 | |
309 | - give_get_template_part( 'shortcode', 'receipt' ); |
|
309 | + give_get_template_part('shortcode', 'receipt'); |
|
310 | 310 | |
311 | 311 | $display = ob_get_clean(); |
312 | 312 | |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | |
316 | 316 | } |
317 | 317 | |
318 | -add_shortcode( 'give_receipt', 'give_receipt_shortcode' ); |
|
318 | +add_shortcode('give_receipt', 'give_receipt_shortcode'); |
|
319 | 319 | |
320 | 320 | /** |
321 | 321 | * Profile Editor Shortcode. |
@@ -335,18 +335,18 @@ discard block |
||
335 | 335 | * |
336 | 336 | * @return string Output generated from the profile editor |
337 | 337 | */ |
338 | -function give_profile_editor_shortcode( $atts, $content = null ) { |
|
338 | +function give_profile_editor_shortcode($atts, $content = null) { |
|
339 | 339 | |
340 | 340 | ob_start(); |
341 | 341 | |
342 | - give_get_template_part( 'shortcode', 'profile-editor' ); |
|
342 | + give_get_template_part('shortcode', 'profile-editor'); |
|
343 | 343 | |
344 | 344 | $display = ob_get_clean(); |
345 | 345 | |
346 | 346 | return $display; |
347 | 347 | } |
348 | 348 | |
349 | -add_shortcode( 'give_profile_editor', 'give_profile_editor_shortcode' ); |
|
349 | +add_shortcode('give_profile_editor', 'give_profile_editor_shortcode'); |
|
350 | 350 | |
351 | 351 | /** |
352 | 352 | * Process Profile Updater Form. |
@@ -359,30 +359,30 @@ discard block |
||
359 | 359 | * |
360 | 360 | * @return bool |
361 | 361 | */ |
362 | -function give_process_profile_editor_updates( $data ) { |
|
362 | +function give_process_profile_editor_updates($data) { |
|
363 | 363 | // Profile field change request |
364 | - if ( empty( $_POST['give_profile_editor_submit'] ) && ! is_user_logged_in() ) { |
|
364 | + if (empty($_POST['give_profile_editor_submit']) && ! is_user_logged_in()) { |
|
365 | 365 | return false; |
366 | 366 | } |
367 | 367 | |
368 | 368 | // Nonce security |
369 | - if ( ! wp_verify_nonce( $data['give_profile_editor_nonce'], 'give-profile-editor-nonce' ) ) { |
|
369 | + if ( ! wp_verify_nonce($data['give_profile_editor_nonce'], 'give-profile-editor-nonce')) { |
|
370 | 370 | return false; |
371 | 371 | } |
372 | 372 | |
373 | 373 | $user_id = get_current_user_id(); |
374 | - $old_user_data = get_userdata( $user_id ); |
|
375 | - |
|
376 | - $display_name = isset( $data['give_display_name'] ) ? sanitize_text_field( $data['give_display_name'] ) : $old_user_data->display_name; |
|
377 | - $first_name = isset( $data['give_first_name'] ) ? sanitize_text_field( $data['give_first_name'] ) : $old_user_data->first_name; |
|
378 | - $last_name = isset( $data['give_last_name'] ) ? sanitize_text_field( $data['give_last_name'] ) : $old_user_data->last_name; |
|
379 | - $email = isset( $data['give_email'] ) ? sanitize_email( $data['give_email'] ) : $old_user_data->user_email; |
|
380 | - $line1 = ( isset( $data['give_address_line1'] ) ? sanitize_text_field( $data['give_address_line1'] ) : '' ); |
|
381 | - $line2 = ( isset( $data['give_address_line2'] ) ? sanitize_text_field( $data['give_address_line2'] ) : '' ); |
|
382 | - $city = ( isset( $data['give_address_city'] ) ? sanitize_text_field( $data['give_address_city'] ) : '' ); |
|
383 | - $state = ( isset( $data['give_address_state'] ) ? sanitize_text_field( $data['give_address_state'] ) : '' ); |
|
384 | - $zip = ( isset( $data['give_address_zip'] ) ? sanitize_text_field( $data['give_address_zip'] ) : '' ); |
|
385 | - $country = ( isset( $data['give_address_country'] ) ? sanitize_text_field( $data['give_address_country'] ) : '' ); |
|
374 | + $old_user_data = get_userdata($user_id); |
|
375 | + |
|
376 | + $display_name = isset($data['give_display_name']) ? sanitize_text_field($data['give_display_name']) : $old_user_data->display_name; |
|
377 | + $first_name = isset($data['give_first_name']) ? sanitize_text_field($data['give_first_name']) : $old_user_data->first_name; |
|
378 | + $last_name = isset($data['give_last_name']) ? sanitize_text_field($data['give_last_name']) : $old_user_data->last_name; |
|
379 | + $email = isset($data['give_email']) ? sanitize_email($data['give_email']) : $old_user_data->user_email; |
|
380 | + $line1 = (isset($data['give_address_line1']) ? sanitize_text_field($data['give_address_line1']) : ''); |
|
381 | + $line2 = (isset($data['give_address_line2']) ? sanitize_text_field($data['give_address_line2']) : ''); |
|
382 | + $city = (isset($data['give_address_city']) ? sanitize_text_field($data['give_address_city']) : ''); |
|
383 | + $state = (isset($data['give_address_state']) ? sanitize_text_field($data['give_address_state']) : ''); |
|
384 | + $zip = (isset($data['give_address_zip']) ? sanitize_text_field($data['give_address_zip']) : ''); |
|
385 | + $country = (isset($data['give_address_country']) ? sanitize_text_field($data['give_address_country']) : ''); |
|
386 | 386 | |
387 | 387 | $userdata = array( |
388 | 388 | 'ID' => $user_id, |
@@ -410,38 +410,38 @@ discard block |
||
410 | 410 | * @param int $user_id The ID of the user. |
411 | 411 | * @param array $userdata User info, including ID, first name, last name, display name and email. |
412 | 412 | */ |
413 | - do_action( 'give_pre_update_user_profile', $user_id, $userdata ); |
|
413 | + do_action('give_pre_update_user_profile', $user_id, $userdata); |
|
414 | 414 | |
415 | 415 | // New password |
416 | - if ( ! empty( $data['give_new_user_pass1'] ) ) { |
|
417 | - if ( $data['give_new_user_pass1'] !== $data['give_new_user_pass2'] ) { |
|
418 | - give_set_error( 'password_mismatch', esc_html__( 'The passwords you entered do not match. Please try again.', 'give' ) ); |
|
416 | + if ( ! empty($data['give_new_user_pass1'])) { |
|
417 | + if ($data['give_new_user_pass1'] !== $data['give_new_user_pass2']) { |
|
418 | + give_set_error('password_mismatch', esc_html__('The passwords you entered do not match. Please try again.', 'give')); |
|
419 | 419 | } else { |
420 | 420 | $userdata['user_pass'] = $data['give_new_user_pass1']; |
421 | 421 | } |
422 | 422 | } |
423 | 423 | |
424 | 424 | // Make sure the new email doesn't belong to another user |
425 | - if ( $email != $old_user_data->user_email ) { |
|
426 | - if ( email_exists( $email ) ) { |
|
427 | - give_set_error( 'email_exists', esc_html__( 'The email you entered belongs to another user. Please use another.', 'give' ) ); |
|
425 | + if ($email != $old_user_data->user_email) { |
|
426 | + if (email_exists($email)) { |
|
427 | + give_set_error('email_exists', esc_html__('The email you entered belongs to another user. Please use another.', 'give')); |
|
428 | 428 | } |
429 | 429 | } |
430 | 430 | |
431 | 431 | // Check for errors |
432 | 432 | $errors = give_get_errors(); |
433 | 433 | |
434 | - if ( $errors ) { |
|
434 | + if ($errors) { |
|
435 | 435 | // Send back to the profile editor if there are errors |
436 | - wp_redirect( $data['give_redirect'] ); |
|
436 | + wp_redirect($data['give_redirect']); |
|
437 | 437 | give_die(); |
438 | 438 | } |
439 | 439 | |
440 | 440 | // Update the user |
441 | - $meta = update_user_meta( $user_id, '_give_user_address', $address ); |
|
442 | - $updated = wp_update_user( $userdata ); |
|
441 | + $meta = update_user_meta($user_id, '_give_user_address', $address); |
|
442 | + $updated = wp_update_user($userdata); |
|
443 | 443 | |
444 | - if ( $updated ) { |
|
444 | + if ($updated) { |
|
445 | 445 | |
446 | 446 | /** |
447 | 447 | * Fires after updating user profile. |
@@ -451,13 +451,13 @@ discard block |
||
451 | 451 | * @param int $user_id The ID of the user. |
452 | 452 | * @param array $userdata User info, including ID, first name, last name, display name and email. |
453 | 453 | */ |
454 | - do_action( 'give_user_profile_updated', $user_id, $userdata ); |
|
455 | - wp_redirect( add_query_arg( 'updated', 'true', $data['give_redirect'] ) ); |
|
454 | + do_action('give_user_profile_updated', $user_id, $userdata); |
|
455 | + wp_redirect(add_query_arg('updated', 'true', $data['give_redirect'])); |
|
456 | 456 | give_die(); |
457 | 457 | } |
458 | 458 | |
459 | 459 | return false; |
460 | 460 | } |
461 | 461 | |
462 | -add_action( 'give_edit_user_profile', 'give_process_profile_editor_updates' ); |
|
462 | +add_action('give_edit_user_profile', 'give_process_profile_editor_updates'); |
|
463 | 463 |
@@ -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 | |
@@ -79,12 +79,12 @@ discard block |
||
79 | 79 | */ |
80 | 80 | public function __construct() { |
81 | 81 | |
82 | - if ( 'none' === $this->get_template() ) { |
|
82 | + if ('none' === $this->get_template()) { |
|
83 | 83 | $this->html = false; |
84 | 84 | } |
85 | 85 | |
86 | - add_action( 'give_email_send_before', array( $this, 'send_before' ) ); |
|
87 | - add_action( 'give_email_send_after', array( $this, 'send_after' ) ); |
|
86 | + add_action('give_email_send_before', array($this, 'send_before')); |
|
87 | + add_action('give_email_send_after', array($this, 'send_after')); |
|
88 | 88 | |
89 | 89 | } |
90 | 90 | |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * |
94 | 94 | * @since 1.0 |
95 | 95 | */ |
96 | - public function __set( $key, $value ) { |
|
96 | + public function __set($key, $value) { |
|
97 | 97 | $this->$key = $value; |
98 | 98 | } |
99 | 99 | |
@@ -103,11 +103,11 @@ discard block |
||
103 | 103 | * @since 1.0 |
104 | 104 | */ |
105 | 105 | public function get_from_name() { |
106 | - if ( ! $this->from_name ) { |
|
107 | - $this->from_name = give_get_option( 'from_name', get_bloginfo( 'name' ) ); |
|
106 | + if ( ! $this->from_name) { |
|
107 | + $this->from_name = give_get_option('from_name', get_bloginfo('name')); |
|
108 | 108 | } |
109 | 109 | |
110 | - return apply_filters( 'give_email_from_name', wp_specialchars_decode( $this->from_name ), $this ); |
|
110 | + return apply_filters('give_email_from_name', wp_specialchars_decode($this->from_name), $this); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | /** |
@@ -116,11 +116,11 @@ discard block |
||
116 | 116 | * @since 1.0 |
117 | 117 | */ |
118 | 118 | public function get_from_address() { |
119 | - if ( ! $this->from_address ) { |
|
120 | - $this->from_address = give_get_option( 'from_email', get_option( 'admin_email' ) ); |
|
119 | + if ( ! $this->from_address) { |
|
120 | + $this->from_address = give_get_option('from_email', get_option('admin_email')); |
|
121 | 121 | } |
122 | 122 | |
123 | - return apply_filters( 'give_email_from_address', $this->from_address, $this ); |
|
123 | + return apply_filters('give_email_from_address', $this->from_address, $this); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | /** |
@@ -129,13 +129,13 @@ discard block |
||
129 | 129 | * @since 1.0 |
130 | 130 | */ |
131 | 131 | public function get_content_type() { |
132 | - if ( ! $this->content_type && $this->html ) { |
|
133 | - $this->content_type = apply_filters( 'give_email_default_content_type', 'text/html', $this ); |
|
134 | - } else if ( ! $this->html ) { |
|
132 | + if ( ! $this->content_type && $this->html) { |
|
133 | + $this->content_type = apply_filters('give_email_default_content_type', 'text/html', $this); |
|
134 | + } else if ( ! $this->html) { |
|
135 | 135 | $this->content_type = 'text/plain'; |
136 | 136 | } |
137 | 137 | |
138 | - return apply_filters( 'give_email_content_type', $this->content_type, $this ); |
|
138 | + return apply_filters('give_email_content_type', $this->content_type, $this); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | /** |
@@ -144,13 +144,13 @@ discard block |
||
144 | 144 | * @since 1.0 |
145 | 145 | */ |
146 | 146 | public function get_headers() { |
147 | - if ( ! $this->headers ) { |
|
147 | + if ( ! $this->headers) { |
|
148 | 148 | $this->headers = "From: {$this->get_from_name()} <{$this->get_from_address()}>\r\n"; |
149 | 149 | $this->headers .= "Reply-To: {$this->get_from_address()}\r\n"; |
150 | 150 | $this->headers .= "Content-Type: {$this->get_content_type()}; charset=utf-8\r\n"; |
151 | 151 | } |
152 | 152 | |
153 | - return apply_filters( 'give_email_headers', $this->headers, $this ); |
|
153 | + return apply_filters('give_email_headers', $this->headers, $this); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | /** |
@@ -160,11 +160,11 @@ discard block |
||
160 | 160 | */ |
161 | 161 | public function get_templates() { |
162 | 162 | $templates = array( |
163 | - 'default' => esc_html__( 'Default Template', 'give' ), |
|
164 | - 'none' => esc_html__( 'No template, plain text only', 'give' ) |
|
163 | + 'default' => esc_html__('Default Template', 'give'), |
|
164 | + 'none' => esc_html__('No template, plain text only', 'give') |
|
165 | 165 | ); |
166 | 166 | |
167 | - return apply_filters( 'give_email_templates', $templates ); |
|
167 | + return apply_filters('give_email_templates', $templates); |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | /** |
@@ -173,11 +173,11 @@ discard block |
||
173 | 173 | * @since 1.0 |
174 | 174 | */ |
175 | 175 | public function get_template() { |
176 | - if ( ! $this->template ) { |
|
177 | - $this->template = give_get_option( 'email_template', 'default' ); |
|
176 | + if ( ! $this->template) { |
|
177 | + $this->template = give_get_option('email_template', 'default'); |
|
178 | 178 | } |
179 | 179 | |
180 | - return apply_filters( 'give_email_template', $this->template ); |
|
180 | + return apply_filters('give_email_template', $this->template); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | /** |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | * @since 1.0 |
187 | 187 | */ |
188 | 188 | public function get_heading() { |
189 | - return apply_filters( 'give_email_heading', $this->heading ); |
|
189 | + return apply_filters('give_email_heading', $this->heading); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | /** |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | * |
197 | 197 | * @return mixed |
198 | 198 | */ |
199 | - public function parse_tags( $content ) { |
|
199 | + public function parse_tags($content) { |
|
200 | 200 | return $content; |
201 | 201 | } |
202 | 202 | |
@@ -205,19 +205,19 @@ discard block |
||
205 | 205 | * |
206 | 206 | * @since 1.0 |
207 | 207 | */ |
208 | - public function build_email( $message ) { |
|
208 | + public function build_email($message) { |
|
209 | 209 | |
210 | - if ( false === $this->html ) { |
|
211 | - return apply_filters( 'give_email_message', wp_strip_all_tags( $message ), $this ); |
|
210 | + if (false === $this->html) { |
|
211 | + return apply_filters('give_email_message', wp_strip_all_tags($message), $this); |
|
212 | 212 | } |
213 | 213 | |
214 | - $message = $this->text_to_html( $message ); |
|
214 | + $message = $this->text_to_html($message); |
|
215 | 215 | |
216 | 216 | $template = $this->get_template(); |
217 | 217 | |
218 | 218 | ob_start(); |
219 | 219 | |
220 | - give_get_template_part( 'emails/header', $template, true ); |
|
220 | + give_get_template_part('emails/header', $template, true); |
|
221 | 221 | |
222 | 222 | /** |
223 | 223 | * Fires in the email head. |
@@ -226,17 +226,17 @@ discard block |
||
226 | 226 | * |
227 | 227 | * @param Give_Emails $this The email object. |
228 | 228 | */ |
229 | - do_action( 'give_email_header', $this ); |
|
229 | + do_action('give_email_header', $this); |
|
230 | 230 | |
231 | - if ( has_action( 'give_email_template_' . $template ) ) { |
|
231 | + if (has_action('give_email_template_'.$template)) { |
|
232 | 232 | /** |
233 | 233 | * Fires in a specific email template. |
234 | 234 | * |
235 | 235 | * @since 1.0 |
236 | 236 | */ |
237 | - do_action( "give_email_template_{$template}" ); |
|
237 | + do_action("give_email_template_{$template}"); |
|
238 | 238 | } else { |
239 | - give_get_template_part( 'emails/body', $template, true ); |
|
239 | + give_get_template_part('emails/body', $template, true); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | /** |
@@ -246,9 +246,9 @@ discard block |
||
246 | 246 | * |
247 | 247 | * @param Give_Emails $this The email object. |
248 | 248 | */ |
249 | - do_action( 'give_email_body', $this ); |
|
249 | + do_action('give_email_body', $this); |
|
250 | 250 | |
251 | - give_get_template_part( 'emails/footer', $template, true ); |
|
251 | + give_get_template_part('emails/footer', $template, true); |
|
252 | 252 | |
253 | 253 | /** |
254 | 254 | * Fires in the email footer. |
@@ -257,12 +257,12 @@ discard block |
||
257 | 257 | * |
258 | 258 | * @param Give_Emails $this The email object. |
259 | 259 | */ |
260 | - do_action( 'give_email_footer', $this ); |
|
260 | + do_action('give_email_footer', $this); |
|
261 | 261 | |
262 | 262 | $body = ob_get_clean(); |
263 | - $message = str_replace( '{email}', $message, $body ); |
|
263 | + $message = str_replace('{email}', $message, $body); |
|
264 | 264 | |
265 | - return apply_filters( 'give_email_message', $message, $this ); |
|
265 | + return apply_filters('give_email_message', $message, $this); |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | /** |
@@ -275,10 +275,10 @@ discard block |
||
275 | 275 | * |
276 | 276 | * @return bool |
277 | 277 | */ |
278 | - public function send( $to, $subject, $message, $attachments = '' ) { |
|
278 | + public function send($to, $subject, $message, $attachments = '') { |
|
279 | 279 | |
280 | - if ( ! did_action( 'init' ) && ! did_action( 'admin_init' ) ) { |
|
281 | - _doing_it_wrong( __FUNCTION__, esc_html__( 'You cannot send email with Give_Emails until init/admin_init has been reached.', 'give' ), null ); |
|
280 | + if ( ! did_action('init') && ! did_action('admin_init')) { |
|
281 | + _doing_it_wrong(__FUNCTION__, esc_html__('You cannot send email with Give_Emails until init/admin_init has been reached.', 'give'), null); |
|
282 | 282 | |
283 | 283 | return false; |
284 | 284 | } |
@@ -290,16 +290,16 @@ discard block |
||
290 | 290 | * |
291 | 291 | * @param Give_Emails $this The email object. |
292 | 292 | */ |
293 | - do_action( 'give_email_send_before', $this ); |
|
293 | + do_action('give_email_send_before', $this); |
|
294 | 294 | |
295 | - $subject = $this->parse_tags( $subject ); |
|
296 | - $message = $this->parse_tags( $message ); |
|
295 | + $subject = $this->parse_tags($subject); |
|
296 | + $message = $this->parse_tags($message); |
|
297 | 297 | |
298 | - $message = $this->build_email( $message ); |
|
298 | + $message = $this->build_email($message); |
|
299 | 299 | |
300 | - $attachments = apply_filters( 'give_email_attachments', $attachments, $this ); |
|
300 | + $attachments = apply_filters('give_email_attachments', $attachments, $this); |
|
301 | 301 | |
302 | - $sent = wp_mail( $to, $subject, $message, $this->get_headers(), $attachments ); |
|
302 | + $sent = wp_mail($to, $subject, $message, $this->get_headers(), $attachments); |
|
303 | 303 | |
304 | 304 | /** |
305 | 305 | * Fires after sending an email. |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | * |
309 | 309 | * @param Give_Emails $this The email object. |
310 | 310 | */ |
311 | - do_action( 'give_email_send_after', $this ); |
|
311 | + do_action('give_email_send_after', $this); |
|
312 | 312 | |
313 | 313 | return $sent; |
314 | 314 | |
@@ -320,9 +320,9 @@ discard block |
||
320 | 320 | * @since 1.0 |
321 | 321 | */ |
322 | 322 | public function send_before() { |
323 | - add_filter( 'wp_mail_from', array( $this, 'get_from_address' ) ); |
|
324 | - add_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) ); |
|
325 | - add_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ) ); |
|
323 | + add_filter('wp_mail_from', array($this, 'get_from_address')); |
|
324 | + add_filter('wp_mail_from_name', array($this, 'get_from_name')); |
|
325 | + add_filter('wp_mail_content_type', array($this, 'get_content_type')); |
|
326 | 326 | } |
327 | 327 | |
328 | 328 | /** |
@@ -331,9 +331,9 @@ discard block |
||
331 | 331 | * @since 1.0 |
332 | 332 | */ |
333 | 333 | public function send_after() { |
334 | - remove_filter( 'wp_mail_from', array( $this, 'get_from_address' ) ); |
|
335 | - remove_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) ); |
|
336 | - remove_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ) ); |
|
334 | + remove_filter('wp_mail_from', array($this, 'get_from_address')); |
|
335 | + remove_filter('wp_mail_from_name', array($this, 'get_from_name')); |
|
336 | + remove_filter('wp_mail_content_type', array($this, 'get_content_type')); |
|
337 | 337 | |
338 | 338 | // Reset heading to an empty string |
339 | 339 | $this->heading = ''; |
@@ -344,10 +344,10 @@ discard block |
||
344 | 344 | * |
345 | 345 | * @since 1.0 |
346 | 346 | */ |
347 | - public function text_to_html( $message ) { |
|
347 | + public function text_to_html($message) { |
|
348 | 348 | |
349 | - if ( 'text/html' == $this->content_type || true === $this->html ) { |
|
350 | - $message = wpautop( $message ); |
|
349 | + if ('text/html' == $this->content_type || true === $this->html) { |
|
350 | + $message = wpautop($message); |
|
351 | 351 | } |
352 | 352 | |
353 | 353 | return $message; |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | * |
181 | 181 | * @access private |
182 | 182 | * @global array $give_options |
183 | - * @return bool |
|
183 | + * @return false|null |
|
184 | 184 | */ |
185 | 185 | public function auto_updater() { |
186 | 186 | |
@@ -767,7 +767,7 @@ discard block |
||
767 | 767 | * @since 1.7 |
768 | 768 | * @access private |
769 | 769 | * |
770 | - * @return void|bool |
|
770 | + * @return false|null |
|
771 | 771 | */ |
772 | 772 | private function __remove_license_key_from_subscriptions(){ |
773 | 773 | $subscriptions = get_option( 'give_subscriptions', array() ); |
@@ -8,11 +8,11 @@ discard block |
||
8 | 8 | */ |
9 | 9 | |
10 | 10 | // Exit if accessed directly |
11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
11 | +if ( ! defined('ABSPATH')) { |
|
12 | 12 | exit; |
13 | 13 | } |
14 | 14 | |
15 | -if ( ! class_exists( 'Give_License' ) ) : |
|
15 | +if ( ! class_exists('Give_License')) : |
|
16 | 16 | |
17 | 17 | /** |
18 | 18 | * Give_License Class |
@@ -108,19 +108,19 @@ discard block |
||
108 | 108 | * @param string $_checkout_url |
109 | 109 | * @param string $_account_url |
110 | 110 | */ |
111 | - public function __construct( $_file, $_item_name, $_version, $_author, $_optname = null, $_api_url = null, $_checkout_url = null, $_account_url = null ) { |
|
111 | + public function __construct($_file, $_item_name, $_version, $_author, $_optname = null, $_api_url = null, $_checkout_url = null, $_account_url = null) { |
|
112 | 112 | global $give_options; |
113 | 113 | |
114 | 114 | $this->file = $_file; |
115 | 115 | $this->item_name = $_item_name; |
116 | - $this->item_shortname = 'give_' . preg_replace( '/[^a-zA-Z0-9_\s]/', '', str_replace( ' ', '_', strtolower( $this->item_name ) ) ); |
|
116 | + $this->item_shortname = 'give_'.preg_replace('/[^a-zA-Z0-9_\s]/', '', str_replace(' ', '_', strtolower($this->item_name))); |
|
117 | 117 | $this->version = $_version; |
118 | - $this->license = isset( $give_options[ $this->item_shortname . '_license_key' ] ) ? trim( $give_options[ $this->item_shortname . '_license_key' ] ) : ''; |
|
119 | - $this->license_data = get_option( $this->item_shortname . '_license_active' ); |
|
118 | + $this->license = isset($give_options[$this->item_shortname.'_license_key']) ? trim($give_options[$this->item_shortname.'_license_key']) : ''; |
|
119 | + $this->license_data = get_option($this->item_shortname.'_license_active'); |
|
120 | 120 | $this->author = $_author; |
121 | - $this->api_url = is_null( $_api_url ) ? $this->api_url : $_api_url; |
|
122 | - $this->checkout_url = is_null( $_checkout_url ) ? $this->checkout_url : $_checkout_url; |
|
123 | - $this->account_url = is_null( $_account_url ) ? $this->account_url : $_account_url; |
|
121 | + $this->api_url = is_null($_api_url) ? $this->api_url : $_api_url; |
|
122 | + $this->checkout_url = is_null($_checkout_url) ? $this->checkout_url : $_checkout_url; |
|
123 | + $this->account_url = is_null($_account_url) ? $this->account_url : $_account_url; |
|
124 | 124 | |
125 | 125 | // Setup hooks |
126 | 126 | $this->includes(); |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | * @return void |
139 | 139 | */ |
140 | 140 | private function includes() { |
141 | - if ( ! class_exists( 'EDD_SL_Plugin_Updater' ) ) { |
|
141 | + if ( ! class_exists('EDD_SL_Plugin_Updater')) { |
|
142 | 142 | require_once 'admin/EDD_SL_Plugin_Updater.php'; |
143 | 143 | } |
144 | 144 | } |
@@ -155,24 +155,24 @@ discard block |
||
155 | 155 | private function hooks() { |
156 | 156 | |
157 | 157 | // Register settings |
158 | - add_filter( 'give_settings_licenses', array( $this, 'settings' ), 1 ); |
|
158 | + add_filter('give_settings_licenses', array($this, 'settings'), 1); |
|
159 | 159 | |
160 | 160 | // Activate license key on settings save |
161 | - add_action( 'admin_init', array( $this, 'activate_license' ) ); |
|
161 | + add_action('admin_init', array($this, 'activate_license')); |
|
162 | 162 | |
163 | 163 | // Deactivate license key |
164 | - add_action( 'admin_init', array( $this, 'deactivate_license' ) ); |
|
164 | + add_action('admin_init', array($this, 'deactivate_license')); |
|
165 | 165 | |
166 | 166 | // Updater |
167 | - add_action( 'admin_init', array( $this, 'auto_updater' ), 0 ); |
|
167 | + add_action('admin_init', array($this, 'auto_updater'), 0); |
|
168 | 168 | |
169 | - add_action( 'admin_notices', array( $this, 'notices' ) ); |
|
169 | + add_action('admin_notices', array($this, 'notices')); |
|
170 | 170 | |
171 | 171 | // Check license weekly. |
172 | - add_action( 'give_weekly_scheduled_events', array( $this, 'weekly_license_check' ) ); |
|
172 | + add_action('give_weekly_scheduled_events', array($this, 'weekly_license_check')); |
|
173 | 173 | |
174 | 174 | // Check subscription weekly. |
175 | - add_action( 'give_weekly_scheduled_events', array( $this, 'weekly_subscription_check' ) ); |
|
175 | + add_action('give_weekly_scheduled_events', array($this, 'weekly_subscription_check')); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | /** |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | */ |
185 | 185 | public function auto_updater() { |
186 | 186 | |
187 | - if ( ! $this->is_valid_license() ) { |
|
187 | + if ( ! $this->is_valid_license()) { |
|
188 | 188 | return false; |
189 | 189 | } |
190 | 190 | |
@@ -212,16 +212,16 @@ discard block |
||
212 | 212 | * |
213 | 213 | * @return array License settings. |
214 | 214 | */ |
215 | - public function settings( $settings ) { |
|
215 | + public function settings($settings) { |
|
216 | 216 | |
217 | 217 | $give_license_settings = array( |
218 | 218 | array( |
219 | 219 | 'name' => $this->item_name, |
220 | - 'id' => $this->item_shortname . '_license_key', |
|
220 | + 'id' => $this->item_shortname.'_license_key', |
|
221 | 221 | 'desc' => '', |
222 | 222 | 'type' => 'license_key', |
223 | 223 | 'options' => array( |
224 | - 'license' => get_option( $this->item_shortname . '_license_active' ), |
|
224 | + 'license' => get_option($this->item_shortname.'_license_active'), |
|
225 | 225 | 'shortname' => $this->item_shortname, |
226 | 226 | 'item_name' => $this->item_name, |
227 | 227 | 'api_url' => $this->api_url, |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | ) |
233 | 233 | ); |
234 | 234 | |
235 | - return array_merge( $settings, $give_license_settings ); |
|
235 | + return array_merge($settings, $give_license_settings); |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | /** |
@@ -246,18 +246,18 @@ discard block |
||
246 | 246 | * |
247 | 247 | * @return array License settings content. |
248 | 248 | */ |
249 | - public function license_settings_content( $settings ) { |
|
249 | + public function license_settings_content($settings) { |
|
250 | 250 | |
251 | 251 | $give_license_settings = array( |
252 | 252 | array( |
253 | - 'name' => esc_html__( 'Add-on Licenses', 'give' ), |
|
253 | + 'name' => esc_html__('Add-on Licenses', 'give'), |
|
254 | 254 | 'desc' => '<hr>', |
255 | 255 | 'type' => 'give_title', |
256 | 256 | 'id' => 'give_title' |
257 | 257 | ), |
258 | 258 | ); |
259 | 259 | |
260 | - return array_merge( $settings, $give_license_settings ); |
|
260 | + return array_merge($settings, $give_license_settings); |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | /** |
@@ -271,37 +271,37 @@ discard block |
||
271 | 271 | */ |
272 | 272 | public function activate_license() { |
273 | 273 | // Bailout: Check if license key set of not. |
274 | - if ( ! isset( $_POST[ $this->item_shortname . '_license_key' ] ) ) { |
|
274 | + if ( ! isset($_POST[$this->item_shortname.'_license_key'])) { |
|
275 | 275 | return; |
276 | 276 | } |
277 | 277 | |
278 | 278 | // Security check. |
279 | - if ( ! wp_verify_nonce( $_REQUEST[ $this->item_shortname . '_license_key-nonce' ], $this->item_shortname . '_license_key-nonce' ) ) { |
|
279 | + if ( ! wp_verify_nonce($_REQUEST[$this->item_shortname.'_license_key-nonce'], $this->item_shortname.'_license_key-nonce')) { |
|
280 | 280 | |
281 | - wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
281 | + wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
282 | 282 | |
283 | 283 | } |
284 | 284 | |
285 | 285 | // Check if user have correct permissions. |
286 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
286 | + if ( ! current_user_can('manage_give_settings')) { |
|
287 | 287 | return; |
288 | 288 | } |
289 | 289 | |
290 | 290 | // Allow third party addon developers to handle license activation. |
291 | - if( $this->__is_third_party_addon() ){ |
|
292 | - do_action( 'give_activate_license', $this ); |
|
291 | + if ($this->__is_third_party_addon()) { |
|
292 | + do_action('give_activate_license', $this); |
|
293 | 293 | return; |
294 | 294 | } |
295 | 295 | |
296 | 296 | // Delete previous license setting if a empty license key submitted. |
297 | - if ( empty( $_POST[ $this->item_shortname . '_license_key' ] ) ) { |
|
298 | - delete_option( $this->item_shortname . '_license_active' ); |
|
297 | + if (empty($_POST[$this->item_shortname.'_license_key'])) { |
|
298 | + delete_option($this->item_shortname.'_license_active'); |
|
299 | 299 | return; |
300 | 300 | } |
301 | 301 | |
302 | 302 | // Do not simultaneously activate any addon if user want to deactivate any addon. |
303 | - foreach ( $_POST as $key => $value ) { |
|
304 | - if ( false !== strpos( $key, 'license_key_deactivate' ) ) { |
|
303 | + foreach ($_POST as $key => $value) { |
|
304 | + if (false !== strpos($key, 'license_key_deactivate')) { |
|
305 | 305 | // Don't activate a key when deactivating a different key |
306 | 306 | return; |
307 | 307 | } |
@@ -309,15 +309,15 @@ discard block |
||
309 | 309 | |
310 | 310 | |
311 | 311 | // Check if plugin previously installed. |
312 | - if ( $this->is_valid_license() ) { |
|
312 | + if ($this->is_valid_license()) { |
|
313 | 313 | return; |
314 | 314 | } |
315 | 315 | |
316 | 316 | // Get license key. |
317 | - $license = sanitize_text_field( $_POST[ $this->item_shortname . '_license_key' ] ); |
|
317 | + $license = sanitize_text_field($_POST[$this->item_shortname.'_license_key']); |
|
318 | 318 | |
319 | 319 | // Bailout. |
320 | - if( empty( $license ) ) { |
|
320 | + if (empty($license)) { |
|
321 | 321 | return; |
322 | 322 | } |
323 | 323 | |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | $api_params = array( |
329 | 329 | 'edd_action' => 'activate_license', //never change from "edd_" to "give_"! |
330 | 330 | 'license' => $license, |
331 | - 'item_name' => urlencode( $this->item_name ), |
|
331 | + 'item_name' => urlencode($this->item_name), |
|
332 | 332 | 'url' => home_url() |
333 | 333 | ); |
334 | 334 | |
@@ -343,16 +343,16 @@ discard block |
||
343 | 343 | ); |
344 | 344 | |
345 | 345 | // Make sure there are no errors |
346 | - if ( is_wp_error( $response ) ) { |
|
346 | + if (is_wp_error($response)) { |
|
347 | 347 | return; |
348 | 348 | } |
349 | 349 | |
350 | 350 | // Tell WordPress to look for updates |
351 | - set_site_transient( 'update_plugins', null ); |
|
351 | + set_site_transient('update_plugins', null); |
|
352 | 352 | |
353 | 353 | // Decode license data |
354 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
355 | - update_option( $this->item_shortname . '_license_active', $license_data ); |
|
354 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
355 | + update_option($this->item_shortname.'_license_active', $license_data); |
|
356 | 356 | |
357 | 357 | // Check subscription for license key and store this to db (if any). |
358 | 358 | $this->__single_subscription_check(); |
@@ -369,34 +369,34 @@ discard block |
||
369 | 369 | */ |
370 | 370 | public function deactivate_license() { |
371 | 371 | |
372 | - if ( ! isset( $_POST[ $this->item_shortname . '_license_key' ] ) ) { |
|
372 | + if ( ! isset($_POST[$this->item_shortname.'_license_key'])) { |
|
373 | 373 | return; |
374 | 374 | } |
375 | 375 | |
376 | - if ( ! wp_verify_nonce( $_REQUEST[ $this->item_shortname . '_license_key-nonce' ], $this->item_shortname . '_license_key-nonce' ) ) { |
|
376 | + if ( ! wp_verify_nonce($_REQUEST[$this->item_shortname.'_license_key-nonce'], $this->item_shortname.'_license_key-nonce')) { |
|
377 | 377 | |
378 | - wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
378 | + wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
379 | 379 | |
380 | 380 | } |
381 | 381 | |
382 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
382 | + if ( ! current_user_can('manage_give_settings')) { |
|
383 | 383 | return; |
384 | 384 | } |
385 | 385 | |
386 | 386 | // Allow third party addon developers to handle license deactivation. |
387 | - if( $this->__is_third_party_addon() ){ |
|
388 | - do_action( 'give_deactivate_license', $this ); |
|
387 | + if ($this->__is_third_party_addon()) { |
|
388 | + do_action('give_deactivate_license', $this); |
|
389 | 389 | return; |
390 | 390 | } |
391 | 391 | |
392 | 392 | // Run on deactivate button press |
393 | - if ( isset( $_POST[ $this->item_shortname . '_license_key_deactivate' ] ) ) { |
|
393 | + if (isset($_POST[$this->item_shortname.'_license_key_deactivate'])) { |
|
394 | 394 | |
395 | 395 | // Data to send to the API |
396 | 396 | $api_params = array( |
397 | 397 | 'edd_action' => 'deactivate_license', //never change from "edd_" to "give_"! |
398 | 398 | 'license' => $this->license, |
399 | - 'item_name' => urlencode( $this->item_name ), |
|
399 | + 'item_name' => urlencode($this->item_name), |
|
400 | 400 | 'url' => home_url() |
401 | 401 | ); |
402 | 402 | |
@@ -412,16 +412,16 @@ discard block |
||
412 | 412 | |
413 | 413 | |
414 | 414 | // Make sure there are no errors |
415 | - if ( is_wp_error( $response ) ) { |
|
415 | + if (is_wp_error($response)) { |
|
416 | 416 | return; |
417 | 417 | } |
418 | 418 | |
419 | 419 | // Decode the license data |
420 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
420 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
421 | 421 | |
422 | 422 | |
423 | 423 | // Remove license data. |
424 | - delete_option( $this->item_shortname . '_license_active' ); |
|
424 | + delete_option($this->item_shortname.'_license_active'); |
|
425 | 425 | |
426 | 426 | // Remove license key from subscriptions if exist. |
427 | 427 | $this->__remove_license_key_from_subscriptions(); |
@@ -439,18 +439,18 @@ discard block |
||
439 | 439 | */ |
440 | 440 | public function weekly_license_check() { |
441 | 441 | |
442 | - if( ! empty( $_POST['give_settings'] ) ) { |
|
442 | + if ( ! empty($_POST['give_settings'])) { |
|
443 | 443 | // Don't fire when saving settings |
444 | 444 | return false; |
445 | 445 | } |
446 | 446 | |
447 | - if( empty( $this->license ) ) { |
|
447 | + if (empty($this->license)) { |
|
448 | 448 | return false; |
449 | 449 | } |
450 | 450 | |
451 | 451 | // Allow third party addon developers to handle there license check. |
452 | - if( $this->__is_third_party_addon() ){ |
|
453 | - do_action( 'give_weekly_license_check', $this ); |
|
452 | + if ($this->__is_third_party_addon()) { |
|
453 | + do_action('give_weekly_license_check', $this); |
|
454 | 454 | return false; |
455 | 455 | } |
456 | 456 | |
@@ -458,7 +458,7 @@ discard block |
||
458 | 458 | $api_params = array( |
459 | 459 | 'edd_action'=> 'check_license', |
460 | 460 | 'license' => $this->license, |
461 | - 'item_name' => urlencode( $this->item_name ), |
|
461 | + 'item_name' => urlencode($this->item_name), |
|
462 | 462 | 'url' => home_url() |
463 | 463 | ); |
464 | 464 | |
@@ -473,12 +473,12 @@ discard block |
||
473 | 473 | ); |
474 | 474 | |
475 | 475 | // Make sure the response came back okay. |
476 | - if ( is_wp_error( $response ) ) { |
|
476 | + if (is_wp_error($response)) { |
|
477 | 477 | return false; |
478 | 478 | } |
479 | 479 | |
480 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
481 | - update_option( $this->item_shortname . '_license_active', $license_data ); |
|
480 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
481 | + update_option($this->item_shortname.'_license_active', $license_data); |
|
482 | 482 | } |
483 | 483 | |
484 | 484 | |
@@ -492,24 +492,24 @@ discard block |
||
492 | 492 | */ |
493 | 493 | public function weekly_subscription_check() { |
494 | 494 | |
495 | - if( ! empty( $_POST['give_settings'] ) ) { |
|
495 | + if ( ! empty($_POST['give_settings'])) { |
|
496 | 496 | // Don't fire when saving settings |
497 | 497 | return false; |
498 | 498 | } |
499 | 499 | |
500 | 500 | // Remove old subscription data. |
501 | - if( absint( get_option( '_give_subscriptions_edit_last', true ) ) < current_time( 'timestamp' , 1 ) ){ |
|
502 | - delete_option( 'give_subscriptions' ); |
|
503 | - update_option( '_give_subscriptions_edit_last', strtotime( '+ 1 day', current_time( 'timestamp' , 1 ) ) ); |
|
501 | + if (absint(get_option('_give_subscriptions_edit_last', true)) < current_time('timestamp', 1)) { |
|
502 | + delete_option('give_subscriptions'); |
|
503 | + update_option('_give_subscriptions_edit_last', strtotime('+ 1 day', current_time('timestamp', 1))); |
|
504 | 504 | } |
505 | 505 | |
506 | - if( empty( $this->license ) ) { |
|
506 | + if (empty($this->license)) { |
|
507 | 507 | return false; |
508 | 508 | } |
509 | 509 | |
510 | 510 | // Allow third party addon developers to handle there subscription check. |
511 | - if( $this->__is_third_party_addon() ){ |
|
512 | - do_action( 'give_weekly_subscription_check', $this ); |
|
511 | + if ($this->__is_third_party_addon()) { |
|
512 | + do_action('give_weekly_subscription_check', $this); |
|
513 | 513 | return false; |
514 | 514 | } |
515 | 515 | |
@@ -523,7 +523,7 @@ discard block |
||
523 | 523 | // This is custom feature to check subscriptions. |
524 | 524 | 'edd_action'=> 'check_subscription', |
525 | 525 | 'license' => $this->license, |
526 | - 'item_name' => urlencode( $this->item_name ), |
|
526 | + 'item_name' => urlencode($this->item_name), |
|
527 | 527 | 'url' => home_url() |
528 | 528 | ); |
529 | 529 | |
@@ -538,27 +538,27 @@ discard block |
||
538 | 538 | ); |
539 | 539 | |
540 | 540 | // Make sure the response came back okay. |
541 | - if ( is_wp_error( $response ) ) { |
|
541 | + if (is_wp_error($response)) { |
|
542 | 542 | return false; |
543 | 543 | } |
544 | 544 | |
545 | - $subscription_data = json_decode( wp_remote_retrieve_body( $response ), true ); |
|
545 | + $subscription_data = json_decode(wp_remote_retrieve_body($response), true); |
|
546 | 546 | |
547 | - if( ! empty( $subscription_data['success'] ) && absint( $subscription_data['success'] ) ) { |
|
548 | - $subscriptions = get_option( 'give_subscriptions', array() ); |
|
547 | + if ( ! empty($subscription_data['success']) && absint($subscription_data['success'])) { |
|
548 | + $subscriptions = get_option('give_subscriptions', array()); |
|
549 | 549 | |
550 | 550 | // Update subscription data only if subscription does not exist already. |
551 | - if( ! array_key_exists( $subscription_data['id'], $subscriptions ) ) { |
|
552 | - $subscriptions[ $subscription_data['id'] ] = $subscription_data; |
|
553 | - $subscriptions[ $subscription_data['id'] ]['licenses'] = array(); |
|
551 | + if ( ! array_key_exists($subscription_data['id'], $subscriptions)) { |
|
552 | + $subscriptions[$subscription_data['id']] = $subscription_data; |
|
553 | + $subscriptions[$subscription_data['id']]['licenses'] = array(); |
|
554 | 554 | } |
555 | 555 | |
556 | 556 | // Store licenses for subscription. |
557 | - if( ! in_array( $this->license, $subscriptions[ $subscription_data['id'] ]['licenses'] ) ) { |
|
558 | - $subscriptions[ $subscription_data['id'] ]['licenses'][] = $this->license; |
|
557 | + if ( ! in_array($this->license, $subscriptions[$subscription_data['id']]['licenses'])) { |
|
558 | + $subscriptions[$subscription_data['id']]['licenses'][] = $this->license; |
|
559 | 559 | } |
560 | 560 | |
561 | - update_option( 'give_subscriptions', $subscriptions ); |
|
561 | + update_option('give_subscriptions', $subscriptions); |
|
562 | 562 | } |
563 | 563 | } |
564 | 564 | |
@@ -573,11 +573,11 @@ discard block |
||
573 | 573 | */ |
574 | 574 | private function __single_subscription_check() { |
575 | 575 | // Do not fire if license key is not set. |
576 | - if ( ! isset( $_POST[ $this->item_shortname . '_license_key' ] ) ) { |
|
576 | + if ( ! isset($_POST[$this->item_shortname.'_license_key'])) { |
|
577 | 577 | return false; |
578 | 578 | } |
579 | 579 | |
580 | - if( empty( $this->license ) ) { |
|
580 | + if (empty($this->license)) { |
|
581 | 581 | return false; |
582 | 582 | } |
583 | 583 | |
@@ -588,7 +588,7 @@ discard block |
||
588 | 588 | // This is custom feature to check subscriptions. |
589 | 589 | 'edd_action'=> 'check_subscription', |
590 | 590 | 'license' => $this->license, |
591 | - 'item_name' => urlencode( $this->item_name ), |
|
591 | + 'item_name' => urlencode($this->item_name), |
|
592 | 592 | 'url' => home_url() |
593 | 593 | ); |
594 | 594 | |
@@ -603,27 +603,27 @@ discard block |
||
603 | 603 | ); |
604 | 604 | |
605 | 605 | // Make sure the response came back okay. |
606 | - if ( is_wp_error( $response ) ) { |
|
606 | + if (is_wp_error($response)) { |
|
607 | 607 | return false; |
608 | 608 | } |
609 | 609 | |
610 | - $subscription_data = json_decode( wp_remote_retrieve_body( $response ), true ); |
|
610 | + $subscription_data = json_decode(wp_remote_retrieve_body($response), true); |
|
611 | 611 | |
612 | - if( ! empty( $subscription_data['success'] ) && absint( $subscription_data['success'] ) ) { |
|
613 | - $subscriptions = get_option( 'give_subscriptions', array() ); |
|
612 | + if ( ! empty($subscription_data['success']) && absint($subscription_data['success'])) { |
|
613 | + $subscriptions = get_option('give_subscriptions', array()); |
|
614 | 614 | |
615 | 615 | // Update subscription data only if subscription does not exist already. |
616 | - if( ! array_key_exists( $subscription_data['id'], $subscriptions ) ) { |
|
617 | - $subscriptions[ $subscription_data['id'] ] = $subscription_data; |
|
618 | - $subscriptions[ $subscription_data['id'] ]['licenses'] = array(); |
|
616 | + if ( ! array_key_exists($subscription_data['id'], $subscriptions)) { |
|
617 | + $subscriptions[$subscription_data['id']] = $subscription_data; |
|
618 | + $subscriptions[$subscription_data['id']]['licenses'] = array(); |
|
619 | 619 | } |
620 | 620 | |
621 | 621 | // Store licenses for subscription. |
622 | - if( ! in_array( $this->license, $subscriptions[ $subscription_data['id'] ]['licenses'] ) ) { |
|
623 | - $subscriptions[ $subscription_data['id'] ]['licenses'][] = $this->license; |
|
622 | + if ( ! in_array($this->license, $subscriptions[$subscription_data['id']]['licenses'])) { |
|
623 | + $subscriptions[$subscription_data['id']]['licenses'][] = $this->license; |
|
624 | 624 | } |
625 | 625 | |
626 | - update_option( 'give_subscriptions', $subscriptions ); |
|
626 | + update_option('give_subscriptions', $subscriptions); |
|
627 | 627 | } |
628 | 628 | } |
629 | 629 | |
@@ -641,89 +641,89 @@ discard block |
||
641 | 641 | static $addon_license_key_in_subscriptions; |
642 | 642 | |
643 | 643 | // Set default value. |
644 | - $addon_license_key_in_subscriptions = ! empty( $addon_license_key_in_subscriptions ) ? $addon_license_key_in_subscriptions : array(); |
|
644 | + $addon_license_key_in_subscriptions = ! empty($addon_license_key_in_subscriptions) ? $addon_license_key_in_subscriptions : array(); |
|
645 | 645 | |
646 | - if( empty( $this->license ) ) { |
|
646 | + if (empty($this->license)) { |
|
647 | 647 | return; |
648 | 648 | } |
649 | 649 | |
650 | - if( ! current_user_can( 'manage_shop_settings' ) ) { |
|
650 | + if ( ! current_user_can('manage_shop_settings')) { |
|
651 | 651 | return; |
652 | 652 | } |
653 | 653 | |
654 | 654 | // Do not show licenses notices on license tab. |
655 | - if( ! empty( $_GET['tab'] ) && 'licenses' === $_GET['tab'] ) { |
|
655 | + if ( ! empty($_GET['tab']) && 'licenses' === $_GET['tab']) { |
|
656 | 656 | return; |
657 | 657 | } |
658 | 658 | |
659 | 659 | $messages = array(); |
660 | 660 | |
661 | 661 | // Get subscriptions. |
662 | - $subscriptions = get_option( 'give_subscriptions' ); |
|
662 | + $subscriptions = get_option('give_subscriptions'); |
|
663 | 663 | |
664 | 664 | |
665 | 665 | // Show subscription messages. |
666 | - if( ! empty( $subscriptions ) && ! $showed_subscriptions_message ) { |
|
666 | + if ( ! empty($subscriptions) && ! $showed_subscriptions_message) { |
|
667 | 667 | |
668 | - foreach ( $subscriptions as $subscription ) { |
|
668 | + foreach ($subscriptions as $subscription) { |
|
669 | 669 | // Subscription expires timestamp. |
670 | - $subscription_expires = strtotime( $subscription['expires'] ); |
|
670 | + $subscription_expires = strtotime($subscription['expires']); |
|
671 | 671 | |
672 | 672 | // Start showing subscriptions message before one week of renewal date. |
673 | - if( strtotime( '- 7 days', $subscription_expires ) > current_time( 'timestamp', 1 ) ) { |
|
673 | + if (strtotime('- 7 days', $subscription_expires) > current_time('timestamp', 1)) { |
|
674 | 674 | continue; |
675 | 675 | } |
676 | 676 | |
677 | 677 | // Check if subscription message already exist in messages. |
678 | - if( array_key_exists( $subscription['id'], $messages ) ) { |
|
678 | + if (array_key_exists($subscription['id'], $messages)) { |
|
679 | 679 | continue; |
680 | 680 | } |
681 | 681 | |
682 | - if( ( ! $this->__is_notice_dismissed( $subscription['id'] ) && 'active' !== $subscription['status'] ) ) { |
|
682 | + if (( ! $this->__is_notice_dismissed($subscription['id']) && 'active' !== $subscription['status'])) { |
|
683 | 683 | |
684 | - if( strtotime( $subscription['expires'] ) < current_time( 'timestamp', 1 ) ) {// Check if license already expired. |
|
684 | + if (strtotime($subscription['expires']) < current_time('timestamp', 1)) {// Check if license already expired. |
|
685 | 685 | $messages[$subscription['id']] = sprintf( |
686 | - __( 'You Give addon license expired for payment <a href="%s" target="_blank">#%d</a>. <a href="%s" target="_blank">Click to renew an existing license</a> or <a href="%s">Click here if already renewed</a>.', 'give' ), |
|
687 | - urldecode( $subscription['invoice_url'] ), |
|
686 | + __('You Give addon license expired for payment <a href="%s" target="_blank">#%d</a>. <a href="%s" target="_blank">Click to renew an existing license</a> or <a href="%s">Click here if already renewed</a>.', 'give'), |
|
687 | + urldecode($subscription['invoice_url']), |
|
688 | 688 | $subscription['payment_id'], |
689 | 689 | "{$this->checkout_url}?edd_license_key={$subscription['license_key']}&utm_campaign=admin&utm_source=licenses&utm_medium=expired", |
690 | - esc_url( add_query_arg( '_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI'] ) ) |
|
690 | + esc_url(add_query_arg('_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI'])) |
|
691 | 691 | ); |
692 | - }else{ |
|
692 | + } else { |
|
693 | 693 | $messages[$subscription['id']] = sprintf( |
694 | - __( 'You Give addon license will expire in %s for payment <a href="%s" target="_blank">#%d</a>. <a href="%s" target="_blank">Click to renew an existing license</a> or <a href="%s">Click here if already renewed</a>.', 'give' ), |
|
695 | - human_time_diff( current_time( 'timestamp', 1 ), strtotime( $subscription['expires'] ) ), |
|
696 | - urldecode( $subscription['invoice_url'] ), |
|
694 | + __('You Give addon license will expire in %s for payment <a href="%s" target="_blank">#%d</a>. <a href="%s" target="_blank">Click to renew an existing license</a> or <a href="%s">Click here if already renewed</a>.', 'give'), |
|
695 | + human_time_diff(current_time('timestamp', 1), strtotime($subscription['expires'])), |
|
696 | + urldecode($subscription['invoice_url']), |
|
697 | 697 | $subscription['payment_id'], |
698 | 698 | "{$this->checkout_url}?edd_license_key={$subscription['license_key']}&utm_campaign=admin&utm_source=licenses&utm_medium=expired", |
699 | - esc_url( add_query_arg( '_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI'] ) ) |
|
699 | + esc_url(add_query_arg('_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI'])) |
|
700 | 700 | ); |
701 | 701 | } |
702 | 702 | } |
703 | 703 | |
704 | 704 | // Stop validation for these licencse keys. |
705 | - $addon_license_key_in_subscriptions = array_merge( $addon_license_key_in_subscriptions, $subscription['licenses'] ); |
|
705 | + $addon_license_key_in_subscriptions = array_merge($addon_license_key_in_subscriptions, $subscription['licenses']); |
|
706 | 706 | } |
707 | 707 | $showed_subscriptions_message = true; |
708 | 708 | } |
709 | 709 | |
710 | 710 | |
711 | 711 | // Show non subscription addon messages. |
712 | - if( ! in_array( $this->license, $addon_license_key_in_subscriptions ) && ! $this->__is_notice_dismissed( 'general' ) && ! $this->is_valid_license() && empty( $showed_invalid_message ) ) { |
|
712 | + if ( ! in_array($this->license, $addon_license_key_in_subscriptions) && ! $this->__is_notice_dismissed('general') && ! $this->is_valid_license() && empty($showed_invalid_message)) { |
|
713 | 713 | |
714 | 714 | $messages['general'] = sprintf( |
715 | - __( 'You have invalid or expired license keys for Give Addon. Please go to the <a href="%s">Licenses page</a> to correct this issue.', 'give' ), |
|
716 | - admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=licenses' ) |
|
715 | + __('You have invalid or expired license keys for Give Addon. Please go to the <a href="%s">Licenses page</a> to correct this issue.', 'give'), |
|
716 | + admin_url('edit.php?post_type=give_forms&page=give-settings&tab=licenses') |
|
717 | 717 | ); |
718 | 718 | $showed_invalid_message = true; |
719 | 719 | |
720 | 720 | } |
721 | 721 | |
722 | 722 | // Print messages. |
723 | - if( ! empty( $messages ) ) { |
|
724 | - foreach( $messages as $notice_id => $message ) { |
|
725 | - echo '<div class="notice notice-error is-dismissible give-license-notice" data-dismiss-notice-shortly="' . esc_url( add_query_arg( '_give_hide_license_notices_shortly', $notice_id, $_SERVER['REQUEST_URI'] ) ) . '">'; |
|
726 | - echo '<p>' . $message . '</p>'; |
|
723 | + if ( ! empty($messages)) { |
|
724 | + foreach ($messages as $notice_id => $message) { |
|
725 | + echo '<div class="notice notice-error is-dismissible give-license-notice" data-dismiss-notice-shortly="'.esc_url(add_query_arg('_give_hide_license_notices_shortly', $notice_id, $_SERVER['REQUEST_URI'])).'">'; |
|
726 | + echo '<p>'.$message.'</p>'; |
|
727 | 727 | echo '</div>'; |
728 | 728 | } |
729 | 729 | } |
@@ -738,7 +738,7 @@ discard block |
||
738 | 738 | * @return bool |
739 | 739 | */ |
740 | 740 | public function is_valid_license() { |
741 | - if( apply_filters( 'give_is_valid_license' , ( is_object( $this->license_data ) && ! empty( $this->license_data ) && property_exists( $this->license_data, 'license' )&& 'valid' === $this->license_data->license ) ) ) { |
|
741 | + if (apply_filters('give_is_valid_license', (is_object($this->license_data) && ! empty($this->license_data) && property_exists($this->license_data, 'license') && 'valid' === $this->license_data->license))) { |
|
742 | 742 | return true; |
743 | 743 | } |
744 | 744 | |
@@ -754,7 +754,7 @@ discard block |
||
754 | 754 | * @return bool |
755 | 755 | */ |
756 | 756 | private function __is_third_party_addon() { |
757 | - return ( false === strpos( $this->api_url, 'givewp.com/' ) ); |
|
757 | + return (false === strpos($this->api_url, 'givewp.com/')); |
|
758 | 758 | } |
759 | 759 | |
760 | 760 | |
@@ -769,26 +769,26 @@ discard block |
||
769 | 769 | * |
770 | 770 | * @return void|bool |
771 | 771 | */ |
772 | - private function __remove_license_key_from_subscriptions(){ |
|
773 | - $subscriptions = get_option( 'give_subscriptions', array() ); |
|
772 | + private function __remove_license_key_from_subscriptions() { |
|
773 | + $subscriptions = get_option('give_subscriptions', array()); |
|
774 | 774 | |
775 | 775 | // Bailout. |
776 | - if( empty( $this->license ) ) { |
|
776 | + if (empty($this->license)) { |
|
777 | 777 | return false; |
778 | 778 | } |
779 | 779 | |
780 | - if( ! empty( $subscriptions ) ) { |
|
781 | - foreach ( $subscriptions as $subscription_id => $subscription ) { |
|
782 | - $license_index = array_search( $this->license, $subscription['licenses'] ); |
|
783 | - if( false !== $license_index ) { |
|
780 | + if ( ! empty($subscriptions)) { |
|
781 | + foreach ($subscriptions as $subscription_id => $subscription) { |
|
782 | + $license_index = array_search($this->license, $subscription['licenses']); |
|
783 | + if (false !== $license_index) { |
|
784 | 784 | // Remove license key. |
785 | - unset( $subscriptions[ $subscription_id ]['licenses'][$license_index] ); |
|
785 | + unset($subscriptions[$subscription_id]['licenses'][$license_index]); |
|
786 | 786 | |
787 | 787 | // Rearrange license keys. |
788 | - $subscriptions[ $subscription_id ]['licenses'] = array_values( $subscriptions[ $subscription_id ]['licenses'] ); |
|
788 | + $subscriptions[$subscription_id]['licenses'] = array_values($subscriptions[$subscription_id]['licenses']); |
|
789 | 789 | |
790 | 790 | // Update subscription information. |
791 | - update_option( 'give_subscriptions', $subscriptions ); |
|
791 | + update_option('give_subscriptions', $subscriptions); |
|
792 | 792 | break; |
793 | 793 | } |
794 | 794 | } |
@@ -803,7 +803,7 @@ discard block |
||
803 | 803 | * |
804 | 804 | * @return void |
805 | 805 | */ |
806 | - private function __remove_license_notices_show_blocker(){ |
|
806 | + private function __remove_license_notices_show_blocker() { |
|
807 | 807 | global $wpdb; |
808 | 808 | |
809 | 809 | // Delete permanent notice blocker. |
@@ -841,18 +841,18 @@ discard block |
||
841 | 841 | * |
842 | 842 | * @return bool |
843 | 843 | */ |
844 | - private function __is_notice_dismissed( $notice_id ){ |
|
844 | + private function __is_notice_dismissed($notice_id) { |
|
845 | 845 | global $current_user; |
846 | 846 | $is_notice_dismissed = false; |
847 | 847 | |
848 | 848 | // Ge is notice dismissed permanently. |
849 | - $already_dismiss_notices = ( $already_dismiss_notices = get_user_meta( $current_user->ID, '_give_hide_license_notices_permanently', true ) ) |
|
849 | + $already_dismiss_notices = ($already_dismiss_notices = get_user_meta($current_user->ID, '_give_hide_license_notices_permanently', true)) |
|
850 | 850 | ? $already_dismiss_notices |
851 | 851 | : array(); |
852 | 852 | |
853 | 853 | |
854 | - if( in_array( $notice_id, $already_dismiss_notices ) || get_transient( "_give_hide_license_notices_shortly_{$current_user->ID}_{$notice_id}" ) ) { |
|
855 | - $is_notice_dismissed = true; |
|
854 | + if (in_array($notice_id, $already_dismiss_notices) || get_transient("_give_hide_license_notices_shortly_{$current_user->ID}_{$notice_id}")) { |
|
855 | + $is_notice_dismissed = true; |
|
856 | 856 | } |
857 | 857 | |
858 | 858 | return $is_notice_dismissed; |
@@ -689,7 +689,7 @@ |
||
689 | 689 | "{$this->checkout_url}?edd_license_key={$subscription['license_key']}&utm_campaign=admin&utm_source=licenses&utm_medium=expired", |
690 | 690 | esc_url( add_query_arg( '_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI'] ) ) |
691 | 691 | ); |
692 | - }else{ |
|
692 | + } else{ |
|
693 | 693 | $messages[$subscription['id']] = sprintf( |
694 | 694 | __( 'You Give addon license will expire in %s for payment <a href="%s" target="_blank">#%d</a>. <a href="%s" target="_blank">Click to renew an existing license</a> or <a href="%s">Click here if already renewed</a>.', 'give' ), |
695 | 695 | human_time_diff( current_time( 'timestamp', 1 ), strtotime( $subscription['expires'] ) ), |