@@ -17,18 +17,18 @@ discard block |
||
17 | 17 | $post_type = 'give_payment'; |
18 | 18 | $responses = array(); |
19 | 19 | |
20 | - $form_id = isset( $_POST['form_id'] ) ? intval( $_POST['form_id'] ) : ''; |
|
20 | + $form_id = isset($_POST['form_id']) ? intval($_POST['form_id']) : ''; |
|
21 | 21 | |
22 | - if ( empty( $form_id ) ) { |
|
22 | + if (empty($form_id)) { |
|
23 | 23 | return false; |
24 | 24 | } |
25 | 25 | |
26 | - $args = array( |
|
27 | - 'give_forms' => array( $form_id ), |
|
28 | - 'posts_per_page' => - 1, |
|
26 | + $args = array( |
|
27 | + 'give_forms' => array($form_id), |
|
28 | + 'posts_per_page' => -1, |
|
29 | 29 | 'fields' => 'ids', |
30 | 30 | ); |
31 | - $donation_list = implode( ',', (array) give_get_payments( $args ) ); |
|
31 | + $donation_list = implode(',', (array) give_get_payments($args)); |
|
32 | 32 | |
33 | 33 | $query_and = sprintf( |
34 | 34 | "AND $wpdb->posts.ID IN (%s) |
@@ -43,12 +43,12 @@ discard block |
||
43 | 43 | LEFT JOIN $wpdb->paymentmeta |
44 | 44 | ON $wpdb->posts.ID = $wpdb->paymentmeta.payment_id |
45 | 45 | WHERE $wpdb->posts.post_type = '%s' |
46 | - " . $query_and; |
|
46 | + ".$query_and; |
|
47 | 47 | |
48 | - $meta_keys = $wpdb->get_col( $wpdb->prepare( $query, $post_type ) ); |
|
48 | + $meta_keys = $wpdb->get_col($wpdb->prepare($query, $post_type)); |
|
49 | 49 | |
50 | - if ( ! empty( $meta_keys ) ) { |
|
51 | - $responses['standard_fields'] = array_values( $meta_keys ); |
|
50 | + if ( ! empty($meta_keys)) { |
|
51 | + $responses['standard_fields'] = array_values($meta_keys); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | $query_and = sprintf( |
@@ -64,9 +64,9 @@ discard block |
||
64 | 64 | LEFT JOIN $wpdb->paymentmeta |
65 | 65 | ON $wpdb->posts.ID = $wpdb->paymentmeta.payment_id |
66 | 66 | WHERE $wpdb->posts.post_type = '%s' |
67 | - " . $query_and; |
|
67 | + ".$query_and; |
|
68 | 68 | |
69 | - $hidden_meta_keys = $wpdb->get_col( $wpdb->prepare( $query, $post_type ) ); |
|
69 | + $hidden_meta_keys = $wpdb->get_col($wpdb->prepare($query, $post_type)); |
|
70 | 70 | |
71 | 71 | /** |
72 | 72 | * Filter to modify hidden keys that are going to be ignore when displaying the hidden keys |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * |
79 | 79 | * @return array $ignore_hidden_keys Hidden keys that are going to be ignore |
80 | 80 | */ |
81 | - $ignore_hidden_keys = apply_filters( 'give_export_donations_ignore_hidden_keys', array( |
|
81 | + $ignore_hidden_keys = apply_filters('give_export_donations_ignore_hidden_keys', array( |
|
82 | 82 | '_give_payment_meta', |
83 | 83 | '_give_payment_gateway', |
84 | 84 | '_give_payment_form_title', |
@@ -111,14 +111,14 @@ discard block |
||
111 | 111 | ); |
112 | 112 | |
113 | 113 | // Unset ignored hidden keys. |
114 | - foreach ( $ignore_hidden_keys as $key ) { |
|
115 | - if ( ( $key = array_search( $key, $hidden_meta_keys ) ) !== false ) { |
|
116 | - unset( $hidden_meta_keys[ $key ] ); |
|
114 | + foreach ($ignore_hidden_keys as $key) { |
|
115 | + if (($key = array_search($key, $hidden_meta_keys)) !== false) { |
|
116 | + unset($hidden_meta_keys[$key]); |
|
117 | 117 | } |
118 | 118 | } |
119 | 119 | |
120 | - if ( ! empty( $hidden_meta_keys ) ) { |
|
121 | - $responses['hidden_fields'] = array_values( $hidden_meta_keys ); |
|
120 | + if ( ! empty($hidden_meta_keys)) { |
|
121 | + $responses['hidden_fields'] = array_values($hidden_meta_keys); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
@@ -131,11 +131,11 @@ discard block |
||
131 | 131 | * |
132 | 132 | * @return array $responses |
133 | 133 | */ |
134 | - wp_send_json( (array) apply_filters( 'give_export_donations_get_custom_fields', $responses, $form_id ) ); |
|
134 | + wp_send_json((array) apply_filters('give_export_donations_get_custom_fields', $responses, $form_id)); |
|
135 | 135 | |
136 | 136 | } |
137 | 137 | |
138 | -add_action( 'wp_ajax_give_export_donations_get_custom_fields', 'give_export_donations_get_custom_fields' ); |
|
138 | +add_action('wp_ajax_give_export_donations_get_custom_fields', 'give_export_donations_get_custom_fields'); |
|
139 | 139 | |
140 | 140 | /** |
141 | 141 | * Register the payments batch exporter |
@@ -143,10 +143,10 @@ discard block |
||
143 | 143 | * @since 1.0 |
144 | 144 | */ |
145 | 145 | function give_register_export_donations_batch_export() { |
146 | - add_action( 'give_batch_export_class_include', 'give_export_donations_include_export_class', 10, 1 ); |
|
146 | + add_action('give_batch_export_class_include', 'give_export_donations_include_export_class', 10, 1); |
|
147 | 147 | } |
148 | 148 | |
149 | -add_action( 'give_register_batch_exporter', 'give_register_export_donations_batch_export', 10 ); |
|
149 | +add_action('give_register_batch_exporter', 'give_register_export_donations_batch_export', 10); |
|
150 | 150 | |
151 | 151 | |
152 | 152 | /** |
@@ -154,9 +154,9 @@ discard block |
||
154 | 154 | * |
155 | 155 | * @param $class Give_Export_Donations_CSV |
156 | 156 | */ |
157 | -function give_export_donations_include_export_class( $class ) { |
|
158 | - if ( 'Give_Export_Donations_CSV' === $class ) { |
|
159 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/give-export-donations-exporter.php'; |
|
157 | +function give_export_donations_include_export_class($class) { |
|
158 | + if ('Give_Export_Donations_CSV' === $class) { |
|
159 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/give-export-donations-exporter.php'; |
|
160 | 160 | } |
161 | 161 | } |
162 | 162 | |
@@ -168,8 +168,8 @@ discard block |
||
168 | 168 | * |
169 | 169 | * @return string |
170 | 170 | */ |
171 | -function give_export_donations_create_column_key( $string ) { |
|
172 | - return sanitize_key( str_replace( ' ', '_', $string ) ); |
|
171 | +function give_export_donations_create_column_key($string) { |
|
172 | + return sanitize_key(str_replace(' ', '_', $string)); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | /** |
@@ -181,23 +181,23 @@ discard block |
||
181 | 181 | * |
182 | 182 | * @return array |
183 | 183 | */ |
184 | -function give_export_donation_form_search_args( $args ) { |
|
185 | - if ( empty( $_POST['fields'] ) ) { |
|
184 | +function give_export_donation_form_search_args($args) { |
|
185 | + if (empty($_POST['fields'])) { |
|
186 | 186 | return $args; |
187 | 187 | } |
188 | 188 | |
189 | - $fields = isset( $_POST['fields'] ) ? $_POST['fields'] : null; |
|
190 | - parse_str( $fields ); |
|
189 | + $fields = isset($_POST['fields']) ? $_POST['fields'] : null; |
|
190 | + parse_str($fields); |
|
191 | 191 | |
192 | - if ( ! empty( $give_forms_categories ) || ! empty( $give_forms_tags ) ) { |
|
192 | + if ( ! empty($give_forms_categories) || ! empty($give_forms_tags)) { |
|
193 | 193 | $args['posts_per_page'] = -1; |
194 | 194 | } |
195 | 195 | |
196 | - if ( ! empty( $give_forms_categories ) && ! empty( $give_forms_tags ) ) { |
|
196 | + if ( ! empty($give_forms_categories) && ! empty($give_forms_tags)) { |
|
197 | 197 | $args['tax_query']['relation'] = 'AND'; |
198 | 198 | } |
199 | 199 | |
200 | - if ( ! empty( $give_forms_categories ) ) { |
|
200 | + if ( ! empty($give_forms_categories)) { |
|
201 | 201 | $args['tax_query'][] = array( |
202 | 202 | 'taxonomy' => 'give_forms_category', |
203 | 203 | 'field' => 'term_id', |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | ); |
207 | 207 | } |
208 | 208 | |
209 | - if ( ! empty( $give_forms_tags ) ) { |
|
209 | + if ( ! empty($give_forms_tags)) { |
|
210 | 210 | $args['tax_query'][] = array( |
211 | 211 | 'taxonomy' => 'give_forms_tag', |
212 | 212 | 'field' => 'term_id', |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | return $args; |
219 | 219 | } |
220 | 220 | |
221 | -add_filter( 'give_ajax_form_search_args', 'give_export_donation_form_search_args' ); |
|
221 | +add_filter('give_ajax_form_search_args', 'give_export_donation_form_search_args'); |
|
222 | 222 | |
223 | 223 | /** |
224 | 224 | * Add Donation standard fields in export donation page |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | ?> |
230 | 230 | <tr> |
231 | 231 | <td scope="row" class="row-title"> |
232 | - <label><?php _e( 'Standard Columns:', 'give' ); ?></label> |
|
232 | + <label><?php _e('Standard Columns:', 'give'); ?></label> |
|
233 | 233 | </td> |
234 | 234 | <td> |
235 | 235 | <div class="give-clearfix"> |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | |
240 | 240 | <li class="give-export-option-label give-export-option-donation-label"> |
241 | 241 | <span> |
242 | - <?php _e( 'Donation Payment Fields', 'give' ); ?> |
|
242 | + <?php _e('Donation Payment Fields', 'give'); ?> |
|
243 | 243 | </span> |
244 | 244 | </li> |
245 | 245 | |
@@ -247,18 +247,18 @@ discard block |
||
247 | 247 | <label for="give-export-donation-id"> |
248 | 248 | <input type="checkbox" checked |
249 | 249 | name="give_give_donations_export_option[donation_id]" |
250 | - id="give-export-donation-id"><?php _e( 'Donation ID', 'give' ); ?> |
|
250 | + id="give-export-donation-id"><?php _e('Donation ID', 'give'); ?> |
|
251 | 251 | </label> |
252 | 252 | </li> |
253 | 253 | |
254 | 254 | <?php |
255 | - if ( give_is_setting_enabled( give_get_option( 'sequential-ordering_status', 'disabled' ) ) ) { |
|
255 | + if (give_is_setting_enabled(give_get_option('sequential-ordering_status', 'disabled'))) { |
|
256 | 256 | ?> |
257 | 257 | <li> |
258 | 258 | <label for="give-export-seq-id"> |
259 | 259 | <input type="checkbox" checked |
260 | 260 | name="give_give_donations_export_option[seq_id]" |
261 | - id="give-export-seq-id"><?php _e( 'Donation Number', 'give' ); ?> |
|
261 | + id="give-export-seq-id"><?php _e('Donation Number', 'give'); ?> |
|
262 | 262 | </label> |
263 | 263 | </li> |
264 | 264 | <?php |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | <label for="give-export-donation-sum"> |
270 | 270 | <input type="checkbox" checked |
271 | 271 | name="give_give_donations_export_option[donation_total]" |
272 | - id="give-export-donation-sum"><?php _e( 'Donation Total', 'give' ); ?> |
|
272 | + id="give-export-donation-sum"><?php _e('Donation Total', 'give'); ?> |
|
273 | 273 | </label> |
274 | 274 | </li> |
275 | 275 | |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | <label for="give-export-donation-currency_code"> |
278 | 278 | <input type="checkbox" checked |
279 | 279 | name="give_give_donations_export_option[currency_code]" |
280 | - id="give-export-donation-currency_code"><?php _e( 'Currency Code', 'give' ); ?> |
|
280 | + id="give-export-donation-currency_code"><?php _e('Currency Code', 'give'); ?> |
|
281 | 281 | </label> |
282 | 282 | </li> |
283 | 283 | |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | <label for="give-export-donation-currency_symbol"> |
286 | 286 | <input type="checkbox" checked |
287 | 287 | name="give_give_donations_export_option[currency_symbol]" |
288 | - id="give-export-donation-currency_symbol"><?php _e( 'Currency Symbol', 'give' ); ?> |
|
288 | + id="give-export-donation-currency_symbol"><?php _e('Currency Symbol', 'give'); ?> |
|
289 | 289 | </label> |
290 | 290 | </li> |
291 | 291 | |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | <label for="give-export-donation-status"> |
294 | 294 | <input type="checkbox" checked |
295 | 295 | name="give_give_donations_export_option[donation_status]" |
296 | - id="give-export-donation-status"><?php _e( 'Donation Status', 'give' ); ?> |
|
296 | + id="give-export-donation-status"><?php _e('Donation Status', 'give'); ?> |
|
297 | 297 | </label> |
298 | 298 | </li> |
299 | 299 | |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | <label for="give-export-donation-date"> |
302 | 302 | <input type="checkbox" checked |
303 | 303 | name="give_give_donations_export_option[donation_date]" |
304 | - id="give-export-donation-date"><?php _e( 'Donation Date', 'give' ); ?> |
|
304 | + id="give-export-donation-date"><?php _e('Donation Date', 'give'); ?> |
|
305 | 305 | </label> |
306 | 306 | </li> |
307 | 307 | |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | <label for="give-export-donation-time"> |
310 | 310 | <input type="checkbox" checked |
311 | 311 | name="give_give_donations_export_option[donation_time]" |
312 | - id="give-export-donation-time"><?php _e( 'Donation Time', 'give' ); ?> |
|
312 | + id="give-export-donation-time"><?php _e('Donation Time', 'give'); ?> |
|
313 | 313 | </label> |
314 | 314 | </li> |
315 | 315 | |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | <label for="give-export-payment-gateway"> |
318 | 318 | <input type="checkbox" checked |
319 | 319 | name="give_give_donations_export_option[payment_gateway]" |
320 | - id="give-export-payment-gateway"><?php _e( 'Payment Gateway', 'give' ); ?> |
|
320 | + id="give-export-payment-gateway"><?php _e('Payment Gateway', 'give'); ?> |
|
321 | 321 | </label> |
322 | 322 | </li> |
323 | 323 | |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | * |
328 | 328 | * @since 2.1 |
329 | 329 | */ |
330 | - do_action( 'give_export_donation_standard_payment_fields' ); |
|
330 | + do_action('give_export_donation_standard_payment_fields'); |
|
331 | 331 | ?> |
332 | 332 | </ul> |
333 | 333 | </li> |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | |
338 | 338 | <li class="give-export-option-label give-export-option-Form-label"> |
339 | 339 | <span> |
340 | - <?php _e( 'Donation Form Fields', 'give' ); ?> |
|
340 | + <?php _e('Donation Form Fields', 'give'); ?> |
|
341 | 341 | </span> |
342 | 342 | </li> |
343 | 343 | |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | <label for="give-export-donation-form-id"> |
347 | 347 | <input type="checkbox" checked |
348 | 348 | name="give_give_donations_export_option[form_id]" |
349 | - id="give-export-donation-form-id"><?php _e( 'Donation Form ID', 'give' ); ?> |
|
349 | + id="give-export-donation-form-id"><?php _e('Donation Form ID', 'give'); ?> |
|
350 | 350 | </label> |
351 | 351 | </li> |
352 | 352 | |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | <label for="give-export-donation-form-title"> |
355 | 355 | <input type="checkbox" checked |
356 | 356 | name="give_give_donations_export_option[form_title]" |
357 | - id="give-export-donation-form-title"><?php _e( 'Donation Form Title', 'give' ); ?> |
|
357 | + id="give-export-donation-form-title"><?php _e('Donation Form Title', 'give'); ?> |
|
358 | 358 | </label> |
359 | 359 | </li> |
360 | 360 | |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | <label for="give-export-donation-form-level-id"> |
363 | 363 | <input type="checkbox" checked |
364 | 364 | name="give_give_donations_export_option[form_level_id]" |
365 | - id="give-export-donation-form-level-id"><?php _e( 'Donation Form Level ID', 'give' ); ?> |
|
365 | + id="give-export-donation-form-level-id"><?php _e('Donation Form Level ID', 'give'); ?> |
|
366 | 366 | </label> |
367 | 367 | </li> |
368 | 368 | |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | <label for="give-export-donation-form-level-title"> |
371 | 371 | <input type="checkbox" checked |
372 | 372 | name="give_give_donations_export_option[form_level_title]" |
373 | - id="give-export-donation-form-level-title"><?php _e( 'Donation Form Level Title', 'give' ); ?> |
|
373 | + id="give-export-donation-form-level-title"><?php _e('Donation Form Level Title', 'give'); ?> |
|
374 | 374 | </label> |
375 | 375 | </li> |
376 | 376 | |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | * |
381 | 381 | * @since 2.1 |
382 | 382 | */ |
383 | - do_action( 'give_export_donation_standard_form_fields' ); |
|
383 | + do_action('give_export_donation_standard_form_fields'); |
|
384 | 384 | ?> |
385 | 385 | </ul> |
386 | 386 | </li> |
@@ -390,7 +390,7 @@ discard block |
||
390 | 390 | |
391 | 391 | <li class="give-export-option-label give-export-option-donor-label"> |
392 | 392 | <span> |
393 | - <?php _e( 'Donor Fields', 'give' ); ?> |
|
393 | + <?php _e('Donor Fields', 'give'); ?> |
|
394 | 394 | </span> |
395 | 395 | </li> |
396 | 396 | |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | <label for="give-export-first-name"> |
399 | 399 | <input type="checkbox" checked |
400 | 400 | name="give_give_donations_export_option[first_name]" |
401 | - id="give-export-first-name"><?php _e( 'Donor\'s First Name', 'give' ); ?> |
|
401 | + id="give-export-first-name"><?php _e('Donor\'s First Name', 'give'); ?> |
|
402 | 402 | </label> |
403 | 403 | </li> |
404 | 404 | |
@@ -406,7 +406,7 @@ discard block |
||
406 | 406 | <label for="give-export-last-name"> |
407 | 407 | <input type="checkbox" checked |
408 | 408 | name="give_give_donations_export_option[last_name]" |
409 | - id="give-export-last-name"><?php _e( 'Donor\'s Last Name', 'give' ); ?> |
|
409 | + id="give-export-last-name"><?php _e('Donor\'s Last Name', 'give'); ?> |
|
410 | 410 | </label> |
411 | 411 | </li> |
412 | 412 | |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | <label for="give-export-email"> |
415 | 415 | <input type="checkbox" checked |
416 | 416 | name="give_give_donations_export_option[email]" |
417 | - id="give-export-email"><?php _e( 'Donor\'s Email', 'give' ); ?> |
|
417 | + id="give-export-email"><?php _e('Donor\'s Email', 'give'); ?> |
|
418 | 418 | </label> |
419 | 419 | </li> |
420 | 420 | |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | <label for="give-export-company"> |
423 | 423 | <input type="checkbox" checked |
424 | 424 | name="give_give_donations_export_option[company]" |
425 | - id="give-export-company"><?php _e( 'Company Name', 'give' ); ?> |
|
425 | + id="give-export-company"><?php _e('Company Name', 'give'); ?> |
|
426 | 426 | </label> |
427 | 427 | </li> |
428 | 428 | |
@@ -430,7 +430,7 @@ discard block |
||
430 | 430 | <label for="give-export-address"> |
431 | 431 | <input type="checkbox" checked |
432 | 432 | name="give_give_donations_export_option[address]" |
433 | - id="give-export-address"><?php _e( 'Donor\'s Billing Address', 'give' ); ?> |
|
433 | + id="give-export-address"><?php _e('Donor\'s Billing Address', 'give'); ?> |
|
434 | 434 | </label> |
435 | 435 | </li> |
436 | 436 | |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | <label for="give-export-userid"> |
439 | 439 | <input type="checkbox" checked |
440 | 440 | name="give_give_donations_export_option[userid]" |
441 | - id="give-export-userid"><?php _e( 'User ID', 'give' ); ?> |
|
441 | + id="give-export-userid"><?php _e('User ID', 'give'); ?> |
|
442 | 442 | </label> |
443 | 443 | </li> |
444 | 444 | |
@@ -446,7 +446,7 @@ discard block |
||
446 | 446 | <label for="give-export-donorid"> |
447 | 447 | <input type="checkbox" checked |
448 | 448 | name="give_give_donations_export_option[donorid]" |
449 | - id="give-export-donorid"><?php _e( 'Donor ID', 'give' ); ?> |
|
449 | + id="give-export-donorid"><?php _e('Donor ID', 'give'); ?> |
|
450 | 450 | </label> |
451 | 451 | </li> |
452 | 452 | |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | <label for="give-export-donor-ip"> |
455 | 455 | <input type="checkbox" checked |
456 | 456 | name="give_give_donations_export_option[donor_ip]" |
457 | - id="give-export-donor-ip"><?php _e( 'Donor IP Address', 'give' ); ?> |
|
457 | + id="give-export-donor-ip"><?php _e('Donor IP Address', 'give'); ?> |
|
458 | 458 | </label> |
459 | 459 | </li> |
460 | 460 | |
@@ -464,7 +464,7 @@ discard block |
||
464 | 464 | * |
465 | 465 | * @since 2.1 |
466 | 466 | */ |
467 | - do_action( 'give_export_donation_standard_donor_fields' ); |
|
467 | + do_action('give_export_donation_standard_donor_fields'); |
|
468 | 468 | ?> |
469 | 469 | </ul> |
470 | 470 | </li> |
@@ -475,7 +475,7 @@ discard block |
||
475 | 475 | * |
476 | 476 | * @since 2.1.4 |
477 | 477 | */ |
478 | - do_action( 'give_export_donation_add_custom_column' ); |
|
478 | + do_action('give_export_donation_add_custom_column'); |
|
479 | 479 | ?> |
480 | 480 | </ul> |
481 | 481 | </div> |
@@ -484,7 +484,7 @@ discard block |
||
484 | 484 | <?php |
485 | 485 | } |
486 | 486 | |
487 | -add_action( 'give_export_donation_fields', 'give_export_donation_standard_fields', 10 ); |
|
487 | +add_action('give_export_donation_fields', 'give_export_donation_standard_fields', 10); |
|
488 | 488 | |
489 | 489 | /** |
490 | 490 | * Add Donation Custom fields in export donation page |
@@ -496,19 +496,19 @@ discard block |
||
496 | 496 | <tr |
497 | 497 | class="give-hidden give-export-donations-hide give-export-donations-standard-fields"> |
498 | 498 | <td scope="row" class="row-title"> |
499 | - <label><?php _e( 'Custom Field Columns:', 'give' ); ?></label> |
|
499 | + <label><?php _e('Custom Field Columns:', 'give'); ?></label> |
|
500 | 500 | </td> |
501 | 501 | <td class="give-field-wrap"> |
502 | 502 | <div class="give-clearfix"> |
503 | 503 | <ul class="give-export-option-ul"></ul> |
504 | - <p class="give-field-description"><?php _e( 'The following fields may have been created by custom code, or another plugin.', 'give' ); ?></p> |
|
504 | + <p class="give-field-description"><?php _e('The following fields may have been created by custom code, or another plugin.', 'give'); ?></p> |
|
505 | 505 | </div> |
506 | 506 | </td> |
507 | 507 | </tr> |
508 | 508 | <?php |
509 | 509 | } |
510 | 510 | |
511 | -add_action( 'give_export_donation_fields', 'give_export_donation_custom_fields', 30 ); |
|
511 | +add_action('give_export_donation_fields', 'give_export_donation_custom_fields', 30); |
|
512 | 512 | |
513 | 513 | |
514 | 514 | /** |
@@ -521,17 +521,17 @@ discard block |
||
521 | 521 | |
522 | 522 | <tr class="give-hidden give-export-donations-hide give-export-donations-hidden-fields"> |
523 | 523 | <td scope="row" class="row-title"> |
524 | - <label><?php _e( 'Hidden Custom Field Columns:', 'give' ); ?></label> |
|
524 | + <label><?php _e('Hidden Custom Field Columns:', 'give'); ?></label> |
|
525 | 525 | </td> |
526 | 526 | <td class="give-field-wrap"> |
527 | 527 | <div class="give-clearfix"> |
528 | 528 | <ul class="give-export-option-ul"></ul> |
529 | - <p class="give-field-description"><?php _e( 'The following hidden custom fields contain data created by Give Core, a Give Add-on, another plugin, etc.<br/>Hidden fields are generally used for programming logic, but you may contain data you would like to export.', 'give' ); ?></p> |
|
529 | + <p class="give-field-description"><?php _e('The following hidden custom fields contain data created by Give Core, a Give Add-on, another plugin, etc.<br/>Hidden fields are generally used for programming logic, but you may contain data you would like to export.', 'give'); ?></p> |
|
530 | 530 | </div> |
531 | 531 | </td> |
532 | 532 | </tr> |
533 | 533 | <?php |
534 | 534 | } |
535 | 535 | |
536 | -add_action( 'give_export_donation_fields', 'give_export_donation_hidden_fields', 40 ); |
|
536 | +add_action('give_export_donation_fields', 'give_export_donation_hidden_fields', 40); |
|
537 | 537 |
@@ -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 | |
@@ -85,28 +85,28 @@ discard block |
||
85 | 85 | * |
86 | 86 | * @param array $request The Form Data passed into the batch processing. |
87 | 87 | */ |
88 | - public function set_properties( $request ) { |
|
88 | + public function set_properties($request) { |
|
89 | 89 | |
90 | 90 | // Set data from form submission |
91 | - if ( isset( $_POST['form'] ) ) { |
|
92 | - $this->data = give_clean( wp_parse_args( $_POST['form'] ) ); |
|
91 | + if (isset($_POST['form'])) { |
|
92 | + $this->data = give_clean(wp_parse_args($_POST['form'])); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | $this->form = $this->data['forms']; |
96 | - $this->categories = ! empty( $request['give_forms_categories'] ) ? (array) $request['give_forms_categories'] : array(); |
|
97 | - $this->tags = ! empty( $request['give_forms_tags'] ) ? (array) $request['give_forms_tags'] : array(); |
|
98 | - $this->form_id = $this->get_form_ids( $request ); |
|
99 | - $this->price_id = isset( $request['give_price_option'] ) && ( 'all' !== $request['give_price_option'] && '' !== $request['give_price_option'] ) ? absint( $request['give_price_option'] ) : null; |
|
100 | - $this->start = isset( $request['start'] ) ? sanitize_text_field( $request['start'] ) : ''; |
|
101 | - $this->end = isset( $request['end'] ) ? sanitize_text_field( $request['end'] ) : ''; |
|
102 | - $this->status = isset( $request['status'] ) ? sanitize_text_field( $request['status'] ) : 'complete'; |
|
96 | + $this->categories = ! empty($request['give_forms_categories']) ? (array) $request['give_forms_categories'] : array(); |
|
97 | + $this->tags = ! empty($request['give_forms_tags']) ? (array) $request['give_forms_tags'] : array(); |
|
98 | + $this->form_id = $this->get_form_ids($request); |
|
99 | + $this->price_id = isset($request['give_price_option']) && ('all' !== $request['give_price_option'] && '' !== $request['give_price_option']) ? absint($request['give_price_option']) : null; |
|
100 | + $this->start = isset($request['start']) ? sanitize_text_field($request['start']) : ''; |
|
101 | + $this->end = isset($request['end']) ? sanitize_text_field($request['end']) : ''; |
|
102 | + $this->status = isset($request['status']) ? sanitize_text_field($request['status']) : 'complete'; |
|
103 | 103 | |
104 | 104 | /** |
105 | 105 | * Hook to use after setting properties. |
106 | 106 | * |
107 | 107 | * @since 2.1.3 |
108 | 108 | */ |
109 | - do_action( 'give_export_donations_form_data', $this->data ); |
|
109 | + do_action('give_export_donations_form_data', $this->data); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | /** |
@@ -118,13 +118,13 @@ discard block |
||
118 | 118 | * |
119 | 119 | * @return array|boolean|null $form get all the donation id that need to be exported |
120 | 120 | */ |
121 | - public function get_form_ids( $request = array() ) { |
|
122 | - $form = ! empty( $request['forms'] ) && 0 !== $request['forms'] ? absint( $request['forms'] ) : null; |
|
121 | + public function get_form_ids($request = array()) { |
|
122 | + $form = ! empty($request['forms']) && 0 !== $request['forms'] ? absint($request['forms']) : null; |
|
123 | 123 | |
124 | - $form_ids = ! empty( $request['form_ids'] ) ? sanitize_text_field( $request['form_ids'] ) : null; |
|
124 | + $form_ids = ! empty($request['form_ids']) ? sanitize_text_field($request['form_ids']) : null; |
|
125 | 125 | |
126 | - if ( empty( $form ) && ! empty( $form_ids ) && ( ! empty( $this->categories ) || ! empty( $this->tags ) ) ) { |
|
127 | - $form = explode( ',', $form_ids ); |
|
126 | + if (empty($form) && ! empty($form_ids) && ( ! empty($this->categories) || ! empty($this->tags))) { |
|
127 | + $form = explode(',', $form_ids); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | return $form; |
@@ -141,14 +141,14 @@ discard block |
||
141 | 141 | */ |
142 | 142 | public function csv_cols() { |
143 | 143 | |
144 | - $columns = isset( $this->data['give_give_donations_export_option'] ) ? $this->data['give_give_donations_export_option'] : array(); |
|
144 | + $columns = isset($this->data['give_give_donations_export_option']) ? $this->data['give_give_donations_export_option'] : array(); |
|
145 | 145 | |
146 | 146 | // We need columns. |
147 | - if ( empty( $columns ) ) { |
|
147 | + if (empty($columns)) { |
|
148 | 148 | return false; |
149 | 149 | } |
150 | 150 | |
151 | - $this->cols = $this->get_cols( $columns ); |
|
151 | + $this->cols = $this->get_cols($columns); |
|
152 | 152 | |
153 | 153 | return $this->cols; |
154 | 154 | } |
@@ -163,83 +163,83 @@ discard block |
||
163 | 163 | * |
164 | 164 | * @return array |
165 | 165 | */ |
166 | - private function get_cols( $columns ) { |
|
166 | + private function get_cols($columns) { |
|
167 | 167 | |
168 | 168 | $cols = array(); |
169 | 169 | |
170 | - foreach ( $columns as $key => $value ) { |
|
170 | + foreach ($columns as $key => $value) { |
|
171 | 171 | |
172 | - switch ( $key ) { |
|
172 | + switch ($key) { |
|
173 | 173 | case 'donation_id' : |
174 | - $cols['donation_id'] = __( 'Donation ID', 'give' ); |
|
174 | + $cols['donation_id'] = __('Donation ID', 'give'); |
|
175 | 175 | break; |
176 | 176 | case 'seq_id' : |
177 | - $cols['seq_id'] = __( 'Donation Number', 'give' ); |
|
177 | + $cols['seq_id'] = __('Donation Number', 'give'); |
|
178 | 178 | break; |
179 | 179 | case 'first_name' : |
180 | - $cols['first_name'] = __( 'First Name', 'give' ); |
|
180 | + $cols['first_name'] = __('First Name', 'give'); |
|
181 | 181 | break; |
182 | 182 | case 'last_name' : |
183 | - $cols['last_name'] = __( 'Last Name', 'give' ); |
|
183 | + $cols['last_name'] = __('Last Name', 'give'); |
|
184 | 184 | break; |
185 | 185 | case 'email' : |
186 | - $cols['email'] = __( 'Email Address', 'give' ); |
|
186 | + $cols['email'] = __('Email Address', 'give'); |
|
187 | 187 | break; |
188 | 188 | case 'company' : |
189 | - $cols['company'] = __( 'Company Name', 'give' ); |
|
189 | + $cols['company'] = __('Company Name', 'give'); |
|
190 | 190 | break; |
191 | 191 | case 'address' : |
192 | - $cols['address_line1'] = __( 'Address 1', 'give' ); |
|
193 | - $cols['address_line2'] = __( 'Address 2', 'give' ); |
|
194 | - $cols['address_city'] = __( 'City', 'give' ); |
|
195 | - $cols['address_state'] = __( 'State', 'give' ); |
|
196 | - $cols['address_zip'] = __( 'Zip', 'give' ); |
|
197 | - $cols['address_country'] = __( 'Country', 'give' ); |
|
192 | + $cols['address_line1'] = __('Address 1', 'give'); |
|
193 | + $cols['address_line2'] = __('Address 2', 'give'); |
|
194 | + $cols['address_city'] = __('City', 'give'); |
|
195 | + $cols['address_state'] = __('State', 'give'); |
|
196 | + $cols['address_zip'] = __('Zip', 'give'); |
|
197 | + $cols['address_country'] = __('Country', 'give'); |
|
198 | 198 | break; |
199 | 199 | case 'donation_total' : |
200 | - $cols['donation_total'] = __( 'Donation Total', 'give' ); |
|
200 | + $cols['donation_total'] = __('Donation Total', 'give'); |
|
201 | 201 | break; |
202 | 202 | case 'currency_code' : |
203 | - $cols['currency_code'] = __( 'Currency Code', 'give' ); |
|
203 | + $cols['currency_code'] = __('Currency Code', 'give'); |
|
204 | 204 | break; |
205 | 205 | case 'currency_symbol' : |
206 | - $cols['currency_symbol'] = __( 'Currency Symbol', 'give' ); |
|
206 | + $cols['currency_symbol'] = __('Currency Symbol', 'give'); |
|
207 | 207 | break; |
208 | 208 | case 'donation_status' : |
209 | - $cols['donation_status'] = __( 'Donation Status', 'give' ); |
|
209 | + $cols['donation_status'] = __('Donation Status', 'give'); |
|
210 | 210 | break; |
211 | 211 | case 'payment_gateway' : |
212 | - $cols['payment_gateway'] = __( 'Payment Gateway', 'give' ); |
|
212 | + $cols['payment_gateway'] = __('Payment Gateway', 'give'); |
|
213 | 213 | break; |
214 | 214 | case 'form_id' : |
215 | - $cols['form_id'] = __( 'Form ID', 'give' ); |
|
215 | + $cols['form_id'] = __('Form ID', 'give'); |
|
216 | 216 | break; |
217 | 217 | case 'form_title' : |
218 | - $cols['form_title'] = __( 'Form Title', 'give' ); |
|
218 | + $cols['form_title'] = __('Form Title', 'give'); |
|
219 | 219 | break; |
220 | 220 | case 'form_level_id' : |
221 | - $cols['form_level_id'] = __( 'Level ID', 'give' ); |
|
221 | + $cols['form_level_id'] = __('Level ID', 'give'); |
|
222 | 222 | break; |
223 | 223 | case 'form_level_title' : |
224 | - $cols['form_level_title'] = __( 'Level Title', 'give' ); |
|
224 | + $cols['form_level_title'] = __('Level Title', 'give'); |
|
225 | 225 | break; |
226 | 226 | case 'donation_date' : |
227 | - $cols['donation_date'] = __( 'Donation Date', 'give' ); |
|
227 | + $cols['donation_date'] = __('Donation Date', 'give'); |
|
228 | 228 | break; |
229 | 229 | case 'donation_time' : |
230 | - $cols['donation_time'] = __( 'Donation Time', 'give' ); |
|
230 | + $cols['donation_time'] = __('Donation Time', 'give'); |
|
231 | 231 | break; |
232 | 232 | case 'userid' : |
233 | - $cols['userid'] = __( 'User ID', 'give' ); |
|
233 | + $cols['userid'] = __('User ID', 'give'); |
|
234 | 234 | break; |
235 | 235 | case 'donorid' : |
236 | - $cols['donorid'] = __( 'Donor ID', 'give' ); |
|
236 | + $cols['donorid'] = __('Donor ID', 'give'); |
|
237 | 237 | break; |
238 | 238 | case 'donor_ip' : |
239 | - $cols['donor_ip'] = __( 'Donor IP Address', 'give' ); |
|
239 | + $cols['donor_ip'] = __('Donor IP Address', 'give'); |
|
240 | 240 | break; |
241 | 241 | default: |
242 | - $cols[ $key ] = $key; |
|
242 | + $cols[$key] = $key; |
|
243 | 243 | |
244 | 244 | } |
245 | 245 | } |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | * @param array $cols columns name for CSV |
253 | 253 | * @param array $columns columns select by admin to export |
254 | 254 | */ |
255 | - return (array) apply_filters( 'give_export_donation_get_columns_name', $cols, $columns ); |
|
255 | + return (array) apply_filters('give_export_donation_get_columns_name', $cols, $columns); |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | /** |
@@ -264,24 +264,24 @@ discard block |
||
264 | 264 | * |
265 | 265 | * @return array $args donation argument |
266 | 266 | */ |
267 | - public function get_donation_argument( $args = array() ) { |
|
267 | + public function get_donation_argument($args = array()) { |
|
268 | 268 | $defaults = array( |
269 | 269 | 'number' => 30, |
270 | 270 | 'page' => $this->step, |
271 | 271 | 'status' => $this->status, |
272 | 272 | ); |
273 | 273 | // Date query. |
274 | - if ( ! empty( $this->start ) || ! empty( $this->end ) ) { |
|
275 | - if ( ! empty( $this->start ) ) { |
|
276 | - $defaults['date_query'][0]['after'] = date( 'Y-n-d 00:00:00', strtotime( $this->start ) ); |
|
274 | + if ( ! empty($this->start) || ! empty($this->end)) { |
|
275 | + if ( ! empty($this->start)) { |
|
276 | + $defaults['date_query'][0]['after'] = date('Y-n-d 00:00:00', strtotime($this->start)); |
|
277 | 277 | } |
278 | - if ( ! empty( $this->end ) ) { |
|
279 | - $defaults['date_query'][0]['before'] = date( 'Y-n-d 00:00:00', strtotime( $this->end ) ); |
|
278 | + if ( ! empty($this->end)) { |
|
279 | + $defaults['date_query'][0]['before'] = date('Y-n-d 00:00:00', strtotime($this->end)); |
|
280 | 280 | } |
281 | 281 | } |
282 | 282 | |
283 | - if ( ! empty( $this->form_id ) ) { |
|
284 | - $defaults['give_forms'] = is_array( $this->form_id ) ? $this->form_id : array( $this->form_id ); |
|
283 | + if ( ! empty($this->form_id)) { |
|
284 | + $defaults['give_forms'] = is_array($this->form_id) ? $this->form_id : array($this->form_id); |
|
285 | 285 | } |
286 | 286 | |
287 | 287 | /** |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | * |
291 | 291 | * @since 2.1.3 |
292 | 292 | */ |
293 | - return apply_filters( 'give_export_donations_donation_query_args', wp_parse_args( $args, $defaults ) ); |
|
293 | + return apply_filters('give_export_donations_donation_query_args', wp_parse_args($args, $defaults)); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | /** |
@@ -309,119 +309,119 @@ discard block |
||
309 | 309 | $data = array(); |
310 | 310 | $i = 0; |
311 | 311 | // Payment query. |
312 | - $payments = give_get_payments( $this->get_donation_argument() ); |
|
312 | + $payments = give_get_payments($this->get_donation_argument()); |
|
313 | 313 | |
314 | - if ( $payments ) { |
|
314 | + if ($payments) { |
|
315 | 315 | |
316 | - foreach ( $payments as $payment ) { |
|
316 | + foreach ($payments as $payment) { |
|
317 | 317 | |
318 | 318 | $columns = $this->csv_cols(); |
319 | - $payment = new Give_Payment( $payment->ID ); |
|
319 | + $payment = new Give_Payment($payment->ID); |
|
320 | 320 | $payment_meta = $payment->payment_meta; |
321 | 321 | $address = $payment->address; |
322 | 322 | |
323 | 323 | // Set columns |
324 | - if ( ! empty( $columns['donation_id'] ) ) { |
|
325 | - $data[ $i ]['donation_id'] = $payment->ID; |
|
324 | + if ( ! empty($columns['donation_id'])) { |
|
325 | + $data[$i]['donation_id'] = $payment->ID; |
|
326 | 326 | } |
327 | 327 | |
328 | - if ( ! empty( $columns['seq_id'] ) ) { |
|
329 | - $data[ $i ]['seq_id'] = Give()->seq_donation_number->get_serial_code( $payment->ID ); |
|
328 | + if ( ! empty($columns['seq_id'])) { |
|
329 | + $data[$i]['seq_id'] = Give()->seq_donation_number->get_serial_code($payment->ID); |
|
330 | 330 | } |
331 | 331 | |
332 | - if ( ! empty( $columns['first_name'] ) ) { |
|
333 | - $data[ $i ]['first_name'] = isset( $payment->first_name ) ? $payment->first_name : ''; |
|
332 | + if ( ! empty($columns['first_name'])) { |
|
333 | + $data[$i]['first_name'] = isset($payment->first_name) ? $payment->first_name : ''; |
|
334 | 334 | } |
335 | 335 | |
336 | - if ( ! empty( $columns['last_name'] ) ) { |
|
337 | - $data[ $i ]['last_name'] = isset( $payment->last_name ) ? $payment->last_name : ''; |
|
336 | + if ( ! empty($columns['last_name'])) { |
|
337 | + $data[$i]['last_name'] = isset($payment->last_name) ? $payment->last_name : ''; |
|
338 | 338 | } |
339 | 339 | |
340 | - if ( ! empty( $columns['email'] ) ) { |
|
341 | - $data[ $i ]['email'] = $payment->email; |
|
340 | + if ( ! empty($columns['email'])) { |
|
341 | + $data[$i]['email'] = $payment->email; |
|
342 | 342 | } |
343 | 343 | |
344 | - if ( ! empty( $columns['company'] ) ) { |
|
345 | - $data[ $i ]['company'] = empty( $payment_meta['_give_donation_company'] ) ? '' : str_replace( "\'", "'", $payment_meta['_give_donation_company'] ); |
|
344 | + if ( ! empty($columns['company'])) { |
|
345 | + $data[$i]['company'] = empty($payment_meta['_give_donation_company']) ? '' : str_replace("\'", "'", $payment_meta['_give_donation_company']); |
|
346 | 346 | } |
347 | 347 | |
348 | - if ( ! empty( $columns['address_line1'] ) ) { |
|
349 | - $data[ $i ]['address_line1'] = isset( $address['line1'] ) ? $address['line1'] : ''; |
|
350 | - $data[ $i ]['address_line2'] = isset( $address['line2'] ) ? $address['line2'] : ''; |
|
351 | - $data[ $i ]['address_city'] = isset( $address['city'] ) ? $address['city'] : ''; |
|
352 | - $data[ $i ]['address_state'] = isset( $address['state'] ) ? $address['state'] : ''; |
|
353 | - $data[ $i ]['address_zip'] = isset( $address['zip'] ) ? $address['zip'] : ''; |
|
354 | - $data[ $i ]['address_country'] = isset( $address['country'] ) ? $address['country'] : ''; |
|
348 | + if ( ! empty($columns['address_line1'])) { |
|
349 | + $data[$i]['address_line1'] = isset($address['line1']) ? $address['line1'] : ''; |
|
350 | + $data[$i]['address_line2'] = isset($address['line2']) ? $address['line2'] : ''; |
|
351 | + $data[$i]['address_city'] = isset($address['city']) ? $address['city'] : ''; |
|
352 | + $data[$i]['address_state'] = isset($address['state']) ? $address['state'] : ''; |
|
353 | + $data[$i]['address_zip'] = isset($address['zip']) ? $address['zip'] : ''; |
|
354 | + $data[$i]['address_country'] = isset($address['country']) ? $address['country'] : ''; |
|
355 | 355 | } |
356 | 356 | |
357 | - if ( ! empty( $columns['donation_total'] ) ) { |
|
358 | - $data[ $i ]['donation_total'] = give_format_amount( give_donation_amount( $payment->ID ) ); |
|
357 | + if ( ! empty($columns['donation_total'])) { |
|
358 | + $data[$i]['donation_total'] = give_format_amount(give_donation_amount($payment->ID)); |
|
359 | 359 | } |
360 | 360 | |
361 | - if ( ! empty( $columns['currency_code'] ) ) { |
|
362 | - $data[ $i ]['currency_code'] = empty( $payment_meta['_give_payment_currency'] ) ? give_get_currency() : $payment_meta['_give_payment_currency']; |
|
361 | + if ( ! empty($columns['currency_code'])) { |
|
362 | + $data[$i]['currency_code'] = empty($payment_meta['_give_payment_currency']) ? give_get_currency() : $payment_meta['_give_payment_currency']; |
|
363 | 363 | } |
364 | 364 | |
365 | - if ( ! empty( $columns['currency_symbol'] ) ) { |
|
366 | - $currency_code = $data[ $i ]['currency_code']; |
|
367 | - $data[ $i ]['currency_symbol'] = give_currency_symbol( $currency_code, true ); |
|
365 | + if ( ! empty($columns['currency_symbol'])) { |
|
366 | + $currency_code = $data[$i]['currency_code']; |
|
367 | + $data[$i]['currency_symbol'] = give_currency_symbol($currency_code, true); |
|
368 | 368 | } |
369 | 369 | |
370 | - if ( ! empty( $columns['donation_status'] ) ) { |
|
371 | - $data[ $i ]['donation_status'] = give_get_payment_status( $payment, true ); |
|
370 | + if ( ! empty($columns['donation_status'])) { |
|
371 | + $data[$i]['donation_status'] = give_get_payment_status($payment, true); |
|
372 | 372 | } |
373 | 373 | |
374 | - if ( ! empty( $columns['payment_gateway'] ) ) { |
|
375 | - $data[ $i ]['payment_gateway'] = $payment->gateway; |
|
374 | + if ( ! empty($columns['payment_gateway'])) { |
|
375 | + $data[$i]['payment_gateway'] = $payment->gateway; |
|
376 | 376 | } |
377 | 377 | |
378 | - if ( ! empty( $columns['form_id'] ) ) { |
|
379 | - $data[ $i ]['form_id'] = $payment->form_id; |
|
378 | + if ( ! empty($columns['form_id'])) { |
|
379 | + $data[$i]['form_id'] = $payment->form_id; |
|
380 | 380 | } |
381 | 381 | |
382 | - if ( ! empty( $columns['form_title'] ) ) { |
|
383 | - $data[ $i ]['form_title'] = get_the_title( $payment->form_id ); |
|
382 | + if ( ! empty($columns['form_title'])) { |
|
383 | + $data[$i]['form_title'] = get_the_title($payment->form_id); |
|
384 | 384 | } |
385 | 385 | |
386 | - if ( ! empty( $columns['form_level_id'] ) ) { |
|
387 | - $data[ $i ]['form_level_id'] = $payment->price_id; |
|
386 | + if ( ! empty($columns['form_level_id'])) { |
|
387 | + $data[$i]['form_level_id'] = $payment->price_id; |
|
388 | 388 | } |
389 | 389 | |
390 | - if ( ! empty( $columns['form_level_title'] ) ) { |
|
391 | - $var_prices = give_has_variable_prices( $payment->form_id ); |
|
392 | - if ( empty( $var_prices ) ) { |
|
393 | - $data[ $i ]['form_level_title'] = ''; |
|
390 | + if ( ! empty($columns['form_level_title'])) { |
|
391 | + $var_prices = give_has_variable_prices($payment->form_id); |
|
392 | + if (empty($var_prices)) { |
|
393 | + $data[$i]['form_level_title'] = ''; |
|
394 | 394 | } else { |
395 | 395 | $prices_atts = ''; |
396 | - if ( $variable_prices = give_get_variable_prices( $payment->form_id ) ) { |
|
397 | - foreach ( $variable_prices as $variable_price ) { |
|
398 | - $prices_atts[ $variable_price['_give_id']['level_id'] ] = give_format_amount( $variable_price['_give_amount'] ); |
|
396 | + if ($variable_prices = give_get_variable_prices($payment->form_id)) { |
|
397 | + foreach ($variable_prices as $variable_price) { |
|
398 | + $prices_atts[$variable_price['_give_id']['level_id']] = give_format_amount($variable_price['_give_amount']); |
|
399 | 399 | } |
400 | 400 | } |
401 | - $data[ $i ]['form_level_title'] = give_get_price_option_name( $payment->form_id, $payment->price_id ); |
|
401 | + $data[$i]['form_level_title'] = give_get_price_option_name($payment->form_id, $payment->price_id); |
|
402 | 402 | } |
403 | 403 | } |
404 | 404 | |
405 | - if ( ! empty( $columns['donation_date'] ) ) { |
|
406 | - $payment_date = strtotime( $payment->date ); |
|
407 | - $data[ $i ]['donation_date'] = date( give_date_format(), $payment_date ); |
|
405 | + if ( ! empty($columns['donation_date'])) { |
|
406 | + $payment_date = strtotime($payment->date); |
|
407 | + $data[$i]['donation_date'] = date(give_date_format(), $payment_date); |
|
408 | 408 | } |
409 | 409 | |
410 | - if ( ! empty( $columns['donation_time'] ) ) { |
|
411 | - $payment_date = strtotime( $payment->date ); |
|
412 | - $data[ $i ]['donation_time'] = date_i18n( 'H', $payment_date ) . ':' . date( 'i', $payment_date ); |
|
410 | + if ( ! empty($columns['donation_time'])) { |
|
411 | + $payment_date = strtotime($payment->date); |
|
412 | + $data[$i]['donation_time'] = date_i18n('H', $payment_date).':'.date('i', $payment_date); |
|
413 | 413 | } |
414 | 414 | |
415 | - if ( ! empty( $columns['userid'] ) ) { |
|
416 | - $data[ $i ]['userid'] = $payment->user_id; |
|
415 | + if ( ! empty($columns['userid'])) { |
|
416 | + $data[$i]['userid'] = $payment->user_id; |
|
417 | 417 | } |
418 | 418 | |
419 | - if ( ! empty( $columns['donorid'] ) ) { |
|
420 | - $data[ $i ]['donorid'] = $payment->customer_id; |
|
419 | + if ( ! empty($columns['donorid'])) { |
|
420 | + $data[$i]['donorid'] = $payment->customer_id; |
|
421 | 421 | } |
422 | 422 | |
423 | - if ( ! empty( $columns['donor_ip'] ) ) { |
|
424 | - $data[ $i ]['donor_ip'] = give_get_payment_user_ip( $payment->ID ); |
|
423 | + if ( ! empty($columns['donor_ip'])) { |
|
424 | + $data[$i]['donor_ip'] = give_get_payment_user_ip($payment->ID); |
|
425 | 425 | } |
426 | 426 | |
427 | 427 | // Add custom field data. |
@@ -452,15 +452,15 @@ discard block |
||
452 | 452 | ); |
453 | 453 | |
454 | 454 | // Removing above keys... |
455 | - foreach ( $remove_keys as $key ) { |
|
456 | - unset( $columns[ $key ] ); |
|
455 | + foreach ($remove_keys as $key) { |
|
456 | + unset($columns[$key]); |
|
457 | 457 | } |
458 | 458 | |
459 | 459 | // Now loop through remaining meta fields. |
460 | - foreach ( $columns as $col ) { |
|
461 | - $field_data = get_post_meta( $payment->ID, $col, true ); |
|
462 | - $data[ $i ][ $col ] = $field_data; |
|
463 | - unset( $columns[ $col ] ); |
|
460 | + foreach ($columns as $col) { |
|
461 | + $field_data = get_post_meta($payment->ID, $col, true); |
|
462 | + $data[$i][$col] = $field_data; |
|
463 | + unset($columns[$col]); |
|
464 | 464 | } |
465 | 465 | |
466 | 466 | /** |
@@ -475,27 +475,27 @@ discard block |
||
475 | 475 | * |
476 | 476 | * @return array Donation data |
477 | 477 | */ |
478 | - $data[ $i ] = apply_filters( 'give_export_donation_data', $data[ $i ], $payment, $columns, $this ); |
|
478 | + $data[$i] = apply_filters('give_export_donation_data', $data[$i], $payment, $columns, $this); |
|
479 | 479 | |
480 | 480 | $new_data = array(); |
481 | - $old_data = $data[ $i ]; |
|
481 | + $old_data = $data[$i]; |
|
482 | 482 | |
483 | 483 | // sorting the columns bas on row |
484 | - foreach ( $this->csv_cols() as $key => $value ) { |
|
485 | - if ( array_key_exists( $key, $old_data ) ) { |
|
486 | - $new_data[ $key ] = $old_data[ $key ]; |
|
484 | + foreach ($this->csv_cols() as $key => $value) { |
|
485 | + if (array_key_exists($key, $old_data)) { |
|
486 | + $new_data[$key] = $old_data[$key]; |
|
487 | 487 | } |
488 | 488 | } |
489 | 489 | |
490 | - $data[ $i ] = $new_data; |
|
490 | + $data[$i] = $new_data; |
|
491 | 491 | |
492 | 492 | // Increment iterator. |
493 | - $i ++; |
|
493 | + $i++; |
|
494 | 494 | |
495 | 495 | } |
496 | 496 | |
497 | - $data = apply_filters( 'give_export_get_data', $data ); |
|
498 | - $data = apply_filters( "give_export_get_data_{$this->export_type}", $data ); |
|
497 | + $data = apply_filters('give_export_get_data', $data); |
|
498 | + $data = apply_filters("give_export_get_data_{$this->export_type}", $data); |
|
499 | 499 | |
500 | 500 | return $data; |
501 | 501 | |
@@ -513,17 +513,17 @@ discard block |
||
513 | 513 | * @return int |
514 | 514 | */ |
515 | 515 | public function get_percentage_complete() { |
516 | - $args = $this->get_donation_argument( array( 'number' => - 1 ) ); |
|
517 | - if ( isset( $args['page'] ) ) { |
|
518 | - unset( $args['page'] ); |
|
516 | + $args = $this->get_donation_argument(array('number' => -1)); |
|
517 | + if (isset($args['page'])) { |
|
518 | + unset($args['page']); |
|
519 | 519 | } |
520 | - $query = give_get_payments( $args ); |
|
521 | - $total = count( $query ); |
|
520 | + $query = give_get_payments($args); |
|
521 | + $total = count($query); |
|
522 | 522 | $percentage = 100; |
523 | - if ( $total > 0 ) { |
|
524 | - $percentage = ( ( 30 * $this->step ) / $total ) * 100; |
|
523 | + if ($total > 0) { |
|
524 | + $percentage = ((30 * $this->step) / $total) * 100; |
|
525 | 525 | } |
526 | - if ( $percentage > 100 ) { |
|
526 | + if ($percentage > 100) { |
|
527 | 527 | $percentage = 100; |
528 | 528 | } |
529 | 529 | |
@@ -545,23 +545,23 @@ discard block |
||
545 | 545 | $data = $this->get_data(); |
546 | 546 | $cols = $this->get_csv_cols(); |
547 | 547 | |
548 | - if ( $data ) { |
|
548 | + if ($data) { |
|
549 | 549 | |
550 | 550 | // Output each row |
551 | - foreach ( $data as $row ) { |
|
551 | + foreach ($data as $row) { |
|
552 | 552 | $i = 1; |
553 | - foreach ( $row as $col_id => $column ) { |
|
553 | + foreach ($row as $col_id => $column) { |
|
554 | 554 | // Make sure the column is valid |
555 | - if ( array_key_exists( $col_id, $cols ) ) { |
|
556 | - $row_data .= '"' . preg_replace( '/"/', "'", $column ) . '"'; |
|
557 | - $row_data .= $i == count( $cols ) ? '' : ','; |
|
558 | - $i ++; |
|
555 | + if (array_key_exists($col_id, $cols)) { |
|
556 | + $row_data .= '"'.preg_replace('/"/', "'", $column).'"'; |
|
557 | + $row_data .= $i == count($cols) ? '' : ','; |
|
558 | + $i++; |
|
559 | 559 | } |
560 | 560 | } |
561 | 561 | $row_data .= "\r\n"; |
562 | 562 | } |
563 | 563 | |
564 | - $this->stash_step_data( $row_data ); |
|
564 | + $this->stash_step_data($row_data); |
|
565 | 565 | |
566 | 566 | return $row_data; |
567 | 567 | } |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
9 | 9 | * @since 1.8 |
10 | 10 | */ |
11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
11 | +if ( ! defined('ABSPATH')) { |
|
12 | 12 | exit; // Exit if accessed directly |
13 | 13 | } |
14 | 14 | |
@@ -22,8 +22,8 @@ discard block |
||
22 | 22 | * |
23 | 23 | * @return bool|string |
24 | 24 | */ |
25 | -function give_is_field_callback_exist( $field ) { |
|
26 | - return ( give_get_field_callback( $field ) ? true : false ); |
|
25 | +function give_is_field_callback_exist($field) { |
|
26 | + return (give_get_field_callback($field) ? true : false); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
@@ -35,12 +35,12 @@ discard block |
||
35 | 35 | * |
36 | 36 | * @return bool|string |
37 | 37 | */ |
38 | -function give_get_field_callback( $field ) { |
|
38 | +function give_get_field_callback($field) { |
|
39 | 39 | $func_name_prefix = 'give'; |
40 | 40 | $func_name = ''; |
41 | 41 | |
42 | 42 | // Set callback function on basis of cmb2 field name. |
43 | - switch ( $field['type'] ) { |
|
43 | + switch ($field['type']) { |
|
44 | 44 | case 'radio_inline': |
45 | 45 | $func_name = "{$func_name_prefix}_radio"; |
46 | 46 | break; |
@@ -82,8 +82,8 @@ discard block |
||
82 | 82 | default: |
83 | 83 | |
84 | 84 | if ( |
85 | - array_key_exists( 'callback', $field ) |
|
86 | - && ! empty( $field['callback'] ) |
|
85 | + array_key_exists('callback', $field) |
|
86 | + && ! empty($field['callback']) |
|
87 | 87 | ) { |
88 | 88 | $func_name = $field['callback']; |
89 | 89 | } else { |
@@ -96,15 +96,15 @@ discard block |
||
96 | 96 | * |
97 | 97 | * @since 1.8 |
98 | 98 | */ |
99 | - $func_name = apply_filters( 'give_get_field_callback', $func_name, $field ); |
|
99 | + $func_name = apply_filters('give_get_field_callback', $func_name, $field); |
|
100 | 100 | |
101 | 101 | // Exit if not any function exist. |
102 | 102 | // Check if render callback exist or not. |
103 | - if ( empty( $func_name ) ) { |
|
103 | + if (empty($func_name)) { |
|
104 | 104 | return false; |
105 | - } elseif ( is_string( $func_name ) && ! function_exists( "$func_name" ) ) { |
|
105 | + } elseif (is_string($func_name) && ! function_exists("$func_name")) { |
|
106 | 106 | return false; |
107 | - } elseif ( is_array( $func_name ) && ! method_exists( $func_name[0], "$func_name[1]" ) ) { |
|
107 | + } elseif (is_array($func_name) && ! method_exists($func_name[0], "$func_name[1]")) { |
|
108 | 108 | return false; |
109 | 109 | } |
110 | 110 | |
@@ -120,35 +120,35 @@ discard block |
||
120 | 120 | * |
121 | 121 | * @return bool |
122 | 122 | */ |
123 | -function give_render_field( $field ) { |
|
123 | +function give_render_field($field) { |
|
124 | 124 | |
125 | 125 | // Check if render callback exist or not. |
126 | - if ( ! ( $func_name = give_get_field_callback( $field ) ) ) { |
|
126 | + if ( ! ($func_name = give_get_field_callback($field))) { |
|
127 | 127 | return false; |
128 | 128 | } |
129 | 129 | |
130 | 130 | // CMB2 compatibility: Push all classes to attributes's class key |
131 | - if ( empty( $field['class'] ) ) { |
|
131 | + if (empty($field['class'])) { |
|
132 | 132 | $field['class'] = ''; |
133 | 133 | } |
134 | 134 | |
135 | - if ( empty( $field['attributes']['class'] ) ) { |
|
135 | + if (empty($field['attributes']['class'])) { |
|
136 | 136 | $field['attributes']['class'] = ''; |
137 | 137 | } |
138 | 138 | |
139 | - $field['attributes']['class'] = trim( "give-field {$field['attributes']['class']} give-{$field['type']} {$field['class']}" ); |
|
140 | - unset( $field['class'] ); |
|
139 | + $field['attributes']['class'] = trim("give-field {$field['attributes']['class']} give-{$field['type']} {$field['class']}"); |
|
140 | + unset($field['class']); |
|
141 | 141 | |
142 | 142 | // CMB2 compatibility: Set wrapper class if any. |
143 | - if ( ! empty( $field['row_classes'] ) ) { |
|
143 | + if ( ! empty($field['row_classes'])) { |
|
144 | 144 | $field['wrapper_class'] = $field['row_classes']; |
145 | - unset( $field['row_classes'] ); |
|
145 | + unset($field['row_classes']); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | // Set field params on basis of cmb2 field name. |
149 | - switch ( $field['type'] ) { |
|
149 | + switch ($field['type']) { |
|
150 | 150 | case 'radio_inline': |
151 | - if ( empty( $field['wrapper_class'] ) ) { |
|
151 | + if (empty($field['wrapper_class'])) { |
|
152 | 152 | $field['wrapper_class'] = ''; |
153 | 153 | } |
154 | 154 | $field['wrapper_class'] .= ' give-inline-radio-fields'; |
@@ -161,15 +161,15 @@ discard block |
||
161 | 161 | case 'text-small' : |
162 | 162 | case 'text_small' : |
163 | 163 | // CMB2 compatibility: Set field type to text. |
164 | - $field['type'] = isset( $field['attributes']['type'] ) ? $field['attributes']['type'] : 'text'; |
|
164 | + $field['type'] = isset($field['attributes']['type']) ? $field['attributes']['type'] : 'text'; |
|
165 | 165 | |
166 | 166 | // CMB2 compatibility: Set data type to price. |
167 | 167 | if ( |
168 | - empty( $field['data_type'] ) |
|
169 | - && ! empty( $field['attributes']['class'] ) |
|
168 | + empty($field['data_type']) |
|
169 | + && ! empty($field['attributes']['class']) |
|
170 | 170 | && ( |
171 | - false !== strpos( $field['attributes']['class'], 'money' ) |
|
172 | - || false !== strpos( $field['attributes']['class'], 'amount' ) |
|
171 | + false !== strpos($field['attributes']['class'], 'money') |
|
172 | + || false !== strpos($field['attributes']['class'], 'amount') |
|
173 | 173 | ) |
174 | 174 | ) { |
175 | 175 | $field['data_type'] = 'decimal'; |
@@ -188,26 +188,26 @@ discard block |
||
188 | 188 | case 'give_default_radio_inline': |
189 | 189 | $field['type'] = 'radio'; |
190 | 190 | $field['options'] = array( |
191 | - 'default' => __( 'Default' ), |
|
191 | + 'default' => __('Default'), |
|
192 | 192 | ); |
193 | 193 | break; |
194 | 194 | |
195 | 195 | case 'donation_limit': |
196 | - $field['type'] = 'donation_limit'; |
|
196 | + $field['type'] = 'donation_limit'; |
|
197 | 197 | break; |
198 | 198 | } |
199 | 199 | |
200 | 200 | // CMB2 compatibility: Add support to define field description by desc & description param. |
201 | 201 | // We encourage you to use description param. |
202 | - $field['description'] = ( ! empty( $field['description'] ) |
|
202 | + $field['description'] = ( ! empty($field['description']) |
|
203 | 203 | ? $field['description'] |
204 | - : ( ! empty( $field['desc'] ) ? $field['desc'] : '' ) ); |
|
204 | + : ( ! empty($field['desc']) ? $field['desc'] : '')); |
|
205 | 205 | |
206 | 206 | // Call render function. |
207 | - if ( is_array( $func_name ) ) { |
|
208 | - $func_name[0]->{$func_name[1]}( $field ); |
|
207 | + if (is_array($func_name)) { |
|
208 | + $func_name[0]->{$func_name[1]}($field); |
|
209 | 209 | } else { |
210 | - $func_name( $field ); |
|
210 | + $func_name($field); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | return true; |
@@ -237,29 +237,29 @@ discard block |
||
237 | 237 | * } |
238 | 238 | * @return void |
239 | 239 | */ |
240 | -function give_text_input( $field ) { |
|
240 | +function give_text_input($field) { |
|
241 | 241 | global $thepostid, $post; |
242 | 242 | |
243 | - $thepostid = empty( $thepostid ) ? $post->ID : $thepostid; |
|
244 | - $field['style'] = isset( $field['style'] ) ? $field['style'] : ''; |
|
245 | - $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : ''; |
|
246 | - $field['value'] = give_get_field_value( $field, $thepostid ); |
|
247 | - $field['type'] = isset( $field['type'] ) ? $field['type'] : 'text'; |
|
243 | + $thepostid = empty($thepostid) ? $post->ID : $thepostid; |
|
244 | + $field['style'] = isset($field['style']) ? $field['style'] : ''; |
|
245 | + $field['wrapper_class'] = isset($field['wrapper_class']) ? $field['wrapper_class'] : ''; |
|
246 | + $field['value'] = give_get_field_value($field, $thepostid); |
|
247 | + $field['type'] = isset($field['type']) ? $field['type'] : 'text'; |
|
248 | 248 | $field['before_field'] = ''; |
249 | 249 | $field['after_field'] = ''; |
250 | - $data_type = empty( $field['data_type'] ) ? '' : $field['data_type']; |
|
250 | + $data_type = empty($field['data_type']) ? '' : $field['data_type']; |
|
251 | 251 | |
252 | - switch ( $data_type ) { |
|
252 | + switch ($data_type) { |
|
253 | 253 | case 'price' : |
254 | - $field['value'] = ( ! empty( $field['value'] ) ? give_format_decimal( give_maybe_sanitize_amount( $field['value'] ), false, false ) : $field['value'] ); |
|
254 | + $field['value'] = ( ! empty($field['value']) ? give_format_decimal(give_maybe_sanitize_amount($field['value']), false, false) : $field['value']); |
|
255 | 255 | |
256 | - $field['before_field'] = ! empty( $field['before_field'] ) ? $field['before_field'] : ( give_get_option( 'currency_position', 'before' ) == 'before' ? '<span class="give-money-symbol give-money-symbol-before">' . give_currency_symbol() . '</span>' : '' ); |
|
257 | - $field['after_field'] = ! empty( $field['after_field'] ) ? $field['after_field'] : ( give_get_option( 'currency_position', 'before' ) == 'after' ? '<span class="give-money-symbol give-money-symbol-after">' . give_currency_symbol() . '</span>' : '' ); |
|
256 | + $field['before_field'] = ! empty($field['before_field']) ? $field['before_field'] : (give_get_option('currency_position', 'before') == 'before' ? '<span class="give-money-symbol give-money-symbol-before">'.give_currency_symbol().'</span>' : ''); |
|
257 | + $field['after_field'] = ! empty($field['after_field']) ? $field['after_field'] : (give_get_option('currency_position', 'before') == 'after' ? '<span class="give-money-symbol give-money-symbol-after">'.give_currency_symbol().'</span>' : ''); |
|
258 | 258 | break; |
259 | 259 | |
260 | 260 | case 'decimal' : |
261 | 261 | $field['attributes']['class'] .= ' give_input_decimal'; |
262 | - $field['value'] = ( ! empty( $field['value'] ) ? give_format_decimal( give_maybe_sanitize_amount( $field['value'] ), false, false ) : $field['value'] ); |
|
262 | + $field['value'] = ( ! empty($field['value']) ? give_format_decimal(give_maybe_sanitize_amount($field['value']), false, false) : $field['value']); |
|
263 | 263 | break; |
264 | 264 | |
265 | 265 | default : |
@@ -267,20 +267,20 @@ discard block |
||
267 | 267 | } |
268 | 268 | |
269 | 269 | ?> |
270 | - <p class="give-field-wrap <?php echo esc_attr( $field['id'] ); ?>_field <?php echo esc_attr( $field['wrapper_class'] ); ?>"> |
|
271 | - <label for="<?php echo give_get_field_name( $field ); ?>"><?php echo wp_kses_post( $field['name'] ); ?></label> |
|
270 | + <p class="give-field-wrap <?php echo esc_attr($field['id']); ?>_field <?php echo esc_attr($field['wrapper_class']); ?>"> |
|
271 | + <label for="<?php echo give_get_field_name($field); ?>"><?php echo wp_kses_post($field['name']); ?></label> |
|
272 | 272 | <?php echo $field['before_field']; ?> |
273 | 273 | <input |
274 | - type="<?php echo esc_attr( $field['type'] ); ?>" |
|
275 | - style="<?php echo esc_attr( $field['style'] ); ?>" |
|
276 | - name="<?php echo give_get_field_name( $field ); ?>" |
|
277 | - id="<?php echo esc_attr( $field['id'] ); ?>" |
|
278 | - value="<?php echo esc_attr( $field['value'] ); ?>" |
|
279 | - <?php echo give_get_custom_attributes( $field ); ?> |
|
274 | + type="<?php echo esc_attr($field['type']); ?>" |
|
275 | + style="<?php echo esc_attr($field['style']); ?>" |
|
276 | + name="<?php echo give_get_field_name($field); ?>" |
|
277 | + id="<?php echo esc_attr($field['id']); ?>" |
|
278 | + value="<?php echo esc_attr($field['value']); ?>" |
|
279 | + <?php echo give_get_custom_attributes($field); ?> |
|
280 | 280 | /> |
281 | 281 | <?php echo $field['after_field']; ?> |
282 | 282 | <?php |
283 | - echo give_get_field_description( $field ); |
|
283 | + echo give_get_field_description($field); |
|
284 | 284 | echo '</p>'; |
285 | 285 | } |
286 | 286 | |
@@ -310,107 +310,107 @@ discard block |
||
310 | 310 | * |
311 | 311 | * @return void |
312 | 312 | */ |
313 | -function give_donation_limit( $field ) { |
|
313 | +function give_donation_limit($field) { |
|
314 | 314 | global $thepostid, $post; |
315 | 315 | |
316 | 316 | // Get Give donation form ID. |
317 | - $thepostid = empty( $thepostid ) ? $post->ID : $thepostid; |
|
317 | + $thepostid = empty($thepostid) ? $post->ID : $thepostid; |
|
318 | 318 | |
319 | 319 | // Default arguments. |
320 | 320 | $default_options = array( |
321 | 321 | 'style' => '', |
322 | 322 | 'wrapper_class' => '', |
323 | - 'value' => give_get_field_value( $field, $thepostid ), |
|
323 | + 'value' => give_get_field_value($field, $thepostid), |
|
324 | 324 | 'data_type' => 'decimal', |
325 | 325 | 'before_field' => '', |
326 | 326 | 'after_field' => '', |
327 | 327 | ); |
328 | 328 | |
329 | 329 | // Field options. |
330 | - $field['options'] = ! empty( $field['options'] ) ? $field['options'] : array(); |
|
330 | + $field['options'] = ! empty($field['options']) ? $field['options'] : array(); |
|
331 | 331 | |
332 | 332 | // Default field option arguments. |
333 | - $field['options'] = wp_parse_args( $field['options'], array( |
|
333 | + $field['options'] = wp_parse_args($field['options'], array( |
|
334 | 334 | 'display_label' => '', |
335 | - 'minimum' => give_format_decimal( '1.00', false, false ), |
|
336 | - 'maximum' => give_format_decimal( '999999.99', false, false ), |
|
335 | + 'minimum' => give_format_decimal('1.00', false, false), |
|
336 | + 'maximum' => give_format_decimal('999999.99', false, false), |
|
337 | 337 | ) |
338 | 338 | ); |
339 | 339 | |
340 | 340 | // Set default field options. |
341 | - $field_options = wp_parse_args( $field, $default_options ); |
|
341 | + $field_options = wp_parse_args($field, $default_options); |
|
342 | 342 | |
343 | 343 | // Get default minimum value, if empty. |
344 | - $field_options['value']['minimum'] = ! empty( $field_options['value']['minimum'] ) |
|
344 | + $field_options['value']['minimum'] = ! empty($field_options['value']['minimum']) |
|
345 | 345 | ? $field_options['value']['minimum'] |
346 | 346 | : $field_options['options']['minimum']; |
347 | 347 | |
348 | 348 | // Get default maximum value, if empty. |
349 | - $field_options['value']['maximum'] = ! empty( $field_options['value']['maximum'] ) |
|
349 | + $field_options['value']['maximum'] = ! empty($field_options['value']['maximum']) |
|
350 | 350 | ? $field_options['value']['maximum'] |
351 | 351 | : $field_options['options']['maximum']; |
352 | 352 | ?> |
353 | - <p class="give-field-wrap <?php echo esc_attr( $field_options['id'] ); ?>_field <?php echo esc_attr( $field_options['wrapper_class'] ); ?>"> |
|
354 | - <label for="<?php echo give_get_field_name( $field_options ); ?>"><?php echo wp_kses_post( $field_options['name'] ); ?></label> |
|
353 | + <p class="give-field-wrap <?php echo esc_attr($field_options['id']); ?>_field <?php echo esc_attr($field_options['wrapper_class']); ?>"> |
|
354 | + <label for="<?php echo give_get_field_name($field_options); ?>"><?php echo wp_kses_post($field_options['name']); ?></label> |
|
355 | 355 | <span class="give_donation_limit_display"> |
356 | 356 | <?php |
357 | - foreach ( $field_options['value'] as $amount_range => $amount_value ) { |
|
357 | + foreach ($field_options['value'] as $amount_range => $amount_value) { |
|
358 | 358 | |
359 | - switch ( $field_options['data_type'] ) { |
|
359 | + switch ($field_options['data_type']) { |
|
360 | 360 | case 'price' : |
361 | - $currency_position = give_get_option( 'currency_position', 'before' ); |
|
362 | - $price_field_labels = 'minimum' === $amount_range ? __( 'Minimum amount', 'give' ) : __( 'Maximum amount', 'give' ); |
|
361 | + $currency_position = give_get_option('currency_position', 'before'); |
|
362 | + $price_field_labels = 'minimum' === $amount_range ? __('Minimum amount', 'give') : __('Maximum amount', 'give'); |
|
363 | 363 | |
364 | 364 | $tooltip_html = array( |
365 | - 'before' => Give()->tooltips->render_span( array( |
|
365 | + 'before' => Give()->tooltips->render_span(array( |
|
366 | 366 | 'label' => $price_field_labels, |
367 | - 'tag_content' => sprintf( '<span class="give-money-symbol give-money-symbol-before">%s</span>', give_currency_symbol() ), |
|
368 | - ) ), |
|
369 | - 'after' => Give()->tooltips->render_span( array( |
|
367 | + 'tag_content' => sprintf('<span class="give-money-symbol give-money-symbol-before">%s</span>', give_currency_symbol()), |
|
368 | + )), |
|
369 | + 'after' => Give()->tooltips->render_span(array( |
|
370 | 370 | 'label' => $price_field_labels, |
371 | - 'tag_content' => sprintf( '<span class="give-money-symbol give-money-symbol-after">%s</span>', give_currency_symbol() ), |
|
372 | - ) ), |
|
371 | + 'tag_content' => sprintf('<span class="give-money-symbol give-money-symbol-after">%s</span>', give_currency_symbol()), |
|
372 | + )), |
|
373 | 373 | ); |
374 | 374 | |
375 | - $before_html = ! empty( $field_options['before_field'] ) |
|
375 | + $before_html = ! empty($field_options['before_field']) |
|
376 | 376 | ? $field_options['before_field'] |
377 | - : ( 'before' === $currency_position ? $tooltip_html['before'] : '' ); |
|
377 | + : ('before' === $currency_position ? $tooltip_html['before'] : ''); |
|
378 | 378 | |
379 | - $after_html = ! empty( $field_options['after_field'] ) |
|
379 | + $after_html = ! empty($field_options['after_field']) |
|
380 | 380 | ? $field_options['after_field'] |
381 | - : ( 'after' === $currency_position ? $tooltip_html['after'] : '' ); |
|
381 | + : ('after' === $currency_position ? $tooltip_html['after'] : ''); |
|
382 | 382 | |
383 | - $field_options['attributes']['class'] .= ' give-text_small'; |
|
384 | - $field_options['value'][ $amount_range ] = $amount_value; |
|
383 | + $field_options['attributes']['class'] .= ' give-text_small'; |
|
384 | + $field_options['value'][$amount_range] = $amount_value; |
|
385 | 385 | break; |
386 | 386 | |
387 | 387 | case 'decimal' : |
388 | - $field_options['attributes']['class'] .= ' give_input_decimal give-text_small'; |
|
389 | - $field_options['value'][ $amount_range ] = $amount_value; |
|
388 | + $field_options['attributes']['class'] .= ' give_input_decimal give-text_small'; |
|
389 | + $field_options['value'][$amount_range] = $amount_value; |
|
390 | 390 | break; |
391 | 391 | } |
392 | 392 | |
393 | 393 | echo '<span class=give-minmax-wrap>'; |
394 | - printf( '<label for="%1$s_give_donation_limit_%2$s">%3$s</label>', esc_attr( $field_options['id'] ), esc_attr( $amount_range ), esc_html( $price_field_labels ) ); |
|
394 | + printf('<label for="%1$s_give_donation_limit_%2$s">%3$s</label>', esc_attr($field_options['id']), esc_attr($amount_range), esc_html($price_field_labels)); |
|
395 | 395 | |
396 | - echo isset( $before_html ) ? $before_html : ''; |
|
396 | + echo isset($before_html) ? $before_html : ''; |
|
397 | 397 | ?> |
398 | 398 | <input |
399 | - name="<?php echo give_get_field_name( $field_options ); ?>[<?php echo esc_attr( $amount_range ); ?>]" |
|
399 | + name="<?php echo give_get_field_name($field_options); ?>[<?php echo esc_attr($amount_range); ?>]" |
|
400 | 400 | type="text" |
401 | 401 | id="<?php echo $field_options['id']; ?>_give_donation_limit_<?php echo $amount_range; ?>" |
402 | - data-range_type="<?php echo esc_attr( $amount_range ); ?>" |
|
403 | - value="<?php echo give_format_decimal( esc_attr( $field_options['value'][ $amount_range ] ) ); ?>" |
|
404 | - placeholder="<?php echo give_format_decimal( $field_options['options'][ $amount_range ] ); ?>" |
|
405 | - <?php echo give_get_custom_attributes( $field_options ); ?> |
|
402 | + data-range_type="<?php echo esc_attr($amount_range); ?>" |
|
403 | + value="<?php echo give_format_decimal(esc_attr($field_options['value'][$amount_range])); ?>" |
|
404 | + placeholder="<?php echo give_format_decimal($field_options['options'][$amount_range]); ?>" |
|
405 | + <?php echo give_get_custom_attributes($field_options); ?> |
|
406 | 406 | /> |
407 | 407 | <?php |
408 | - echo isset( $after_html ) ? $after_html : ''; |
|
408 | + echo isset($after_html) ? $after_html : ''; |
|
409 | 409 | echo '</span>'; |
410 | 410 | } |
411 | 411 | ?> |
412 | 412 | </span> |
413 | - <?php echo give_get_field_description( $field_options ); ?> |
|
413 | + <?php echo give_get_field_description($field_options); ?> |
|
414 | 414 | </p> |
415 | 415 | <?php |
416 | 416 | } |
@@ -433,29 +433,29 @@ discard block |
||
433 | 433 | * } |
434 | 434 | * @return void |
435 | 435 | */ |
436 | -function give_hidden_input( $field ) { |
|
436 | +function give_hidden_input($field) { |
|
437 | 437 | global $thepostid, $post; |
438 | 438 | |
439 | - $thepostid = empty( $thepostid ) ? $post->ID : $thepostid; |
|
440 | - $field['value'] = give_get_field_value( $field, $thepostid ); |
|
439 | + $thepostid = empty($thepostid) ? $post->ID : $thepostid; |
|
440 | + $field['value'] = give_get_field_value($field, $thepostid); |
|
441 | 441 | |
442 | 442 | // Custom attribute handling |
443 | 443 | $custom_attributes = array(); |
444 | 444 | |
445 | - if ( ! empty( $field['attributes'] ) && is_array( $field['attributes'] ) ) { |
|
445 | + if ( ! empty($field['attributes']) && is_array($field['attributes'])) { |
|
446 | 446 | |
447 | - foreach ( $field['attributes'] as $attribute => $value ) { |
|
448 | - $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $value ) . '"'; |
|
447 | + foreach ($field['attributes'] as $attribute => $value) { |
|
448 | + $custom_attributes[] = esc_attr($attribute).'="'.esc_attr($value).'"'; |
|
449 | 449 | } |
450 | 450 | } |
451 | 451 | ?> |
452 | 452 | |
453 | 453 | <input |
454 | 454 | type="hidden" |
455 | - name="<?php echo give_get_field_name( $field ); ?>" |
|
456 | - id="<?php echo esc_attr( $field['id'] ); ?>" |
|
457 | - value="<?php echo esc_attr( $field['value'] ); ?>" |
|
458 | - <?php echo give_get_custom_attributes( $field ); ?> |
|
455 | + name="<?php echo give_get_field_name($field); ?>" |
|
456 | + id="<?php echo esc_attr($field['id']); ?>" |
|
457 | + value="<?php echo esc_attr($field['value']); ?>" |
|
458 | + <?php echo give_get_custom_attributes($field); ?> |
|
459 | 459 | /> |
460 | 460 | <?php |
461 | 461 | } |
@@ -481,27 +481,27 @@ discard block |
||
481 | 481 | * } |
482 | 482 | * @return void |
483 | 483 | */ |
484 | -function give_textarea_input( $field ) { |
|
484 | +function give_textarea_input($field) { |
|
485 | 485 | global $thepostid, $post; |
486 | 486 | |
487 | - $thepostid = empty( $thepostid ) ? $post->ID : $thepostid; |
|
488 | - $field['style'] = isset( $field['style'] ) ? $field['style'] : ''; |
|
489 | - $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : ''; |
|
490 | - $field['value'] = give_get_field_value( $field, $thepostid ); |
|
487 | + $thepostid = empty($thepostid) ? $post->ID : $thepostid; |
|
488 | + $field['style'] = isset($field['style']) ? $field['style'] : ''; |
|
489 | + $field['wrapper_class'] = isset($field['wrapper_class']) ? $field['wrapper_class'] : ''; |
|
490 | + $field['value'] = give_get_field_value($field, $thepostid); |
|
491 | 491 | |
492 | 492 | ?> |
493 | - <p class="give-field-wrap <?php echo esc_attr( $field['id'] ); ?>_field <?php echo esc_attr( $field['wrapper_class'] ); ?>"> |
|
494 | - <label for="<?php echo give_get_field_name( $field ); ?>"><?php echo wp_kses_post( $field['name'] ); ?></label> |
|
493 | + <p class="give-field-wrap <?php echo esc_attr($field['id']); ?>_field <?php echo esc_attr($field['wrapper_class']); ?>"> |
|
494 | + <label for="<?php echo give_get_field_name($field); ?>"><?php echo wp_kses_post($field['name']); ?></label> |
|
495 | 495 | <textarea |
496 | - style="<?php echo esc_attr( $field['style'] ); ?>" |
|
497 | - name="<?php echo give_get_field_name( $field ); ?>" |
|
498 | - id="<?php echo esc_attr( $field['id'] ); ?>" |
|
496 | + style="<?php echo esc_attr($field['style']); ?>" |
|
497 | + name="<?php echo give_get_field_name($field); ?>" |
|
498 | + id="<?php echo esc_attr($field['id']); ?>" |
|
499 | 499 | rows="10" |
500 | 500 | cols="20" |
501 | - <?php echo give_get_custom_attributes( $field ); ?> |
|
502 | - ><?php echo esc_textarea( $field['value'] ); ?></textarea> |
|
501 | + <?php echo give_get_custom_attributes($field); ?> |
|
502 | + ><?php echo esc_textarea($field['value']); ?></textarea> |
|
503 | 503 | <?php |
504 | - echo give_get_field_description( $field ); |
|
504 | + echo give_get_field_description($field); |
|
505 | 505 | echo '</p>'; |
506 | 506 | } |
507 | 507 | |
@@ -525,29 +525,29 @@ discard block |
||
525 | 525 | * } |
526 | 526 | * @return void |
527 | 527 | */ |
528 | -function give_wysiwyg( $field ) { |
|
528 | +function give_wysiwyg($field) { |
|
529 | 529 | global $thepostid, $post; |
530 | 530 | |
531 | - $thepostid = empty( $thepostid ) ? $post->ID : $thepostid; |
|
532 | - $field['value'] = give_get_field_value( $field, $thepostid ); |
|
533 | - $field['style'] = isset( $field['style'] ) ? $field['style'] : ''; |
|
534 | - $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : ''; |
|
531 | + $thepostid = empty($thepostid) ? $post->ID : $thepostid; |
|
532 | + $field['value'] = give_get_field_value($field, $thepostid); |
|
533 | + $field['style'] = isset($field['style']) ? $field['style'] : ''; |
|
534 | + $field['wrapper_class'] = isset($field['wrapper_class']) ? $field['wrapper_class'] : ''; |
|
535 | 535 | |
536 | - $field['unique_field_id'] = give_get_field_name( $field ); |
|
536 | + $field['unique_field_id'] = give_get_field_name($field); |
|
537 | 537 | $editor_attributes = array( |
538 | - 'textarea_name' => isset( $field['repeatable_field_id'] ) ? $field['repeatable_field_id'] : $field['id'], |
|
538 | + 'textarea_name' => isset($field['repeatable_field_id']) ? $field['repeatable_field_id'] : $field['id'], |
|
539 | 539 | 'textarea_rows' => '10', |
540 | - 'editor_css' => esc_attr( $field['style'] ), |
|
540 | + 'editor_css' => esc_attr($field['style']), |
|
541 | 541 | 'editor_class' => $field['attributes']['class'], |
542 | 542 | ); |
543 | - $data_wp_editor = ' data-wp-editor="' . base64_encode( json_encode( array( |
|
543 | + $data_wp_editor = ' data-wp-editor="'.base64_encode(json_encode(array( |
|
544 | 544 | $field['value'], |
545 | 545 | $field['unique_field_id'], |
546 | 546 | $editor_attributes, |
547 | - ) ) ) . '"'; |
|
548 | - $data_wp_editor = isset( $field['repeatable_field_id'] ) ? $data_wp_editor : ''; |
|
547 | + ))).'"'; |
|
548 | + $data_wp_editor = isset($field['repeatable_field_id']) ? $data_wp_editor : ''; |
|
549 | 549 | |
550 | - echo '<div class="give-field-wrap ' . $field['unique_field_id'] . '_field ' . esc_attr( $field['wrapper_class'] ) . '"' . $data_wp_editor . '><label for="' . $field['unique_field_id'] . '">' . wp_kses_post( $field['name'] ) . '</label>'; |
|
550 | + echo '<div class="give-field-wrap '.$field['unique_field_id'].'_field '.esc_attr($field['wrapper_class']).'"'.$data_wp_editor.'><label for="'.$field['unique_field_id'].'">'.wp_kses_post($field['name']).'</label>'; |
|
551 | 551 | |
552 | 552 | wp_editor( |
553 | 553 | $field['value'], |
@@ -555,7 +555,7 @@ discard block |
||
555 | 555 | $editor_attributes |
556 | 556 | ); |
557 | 557 | |
558 | - echo give_get_field_description( $field ); |
|
558 | + echo give_get_field_description($field); |
|
559 | 559 | echo '</div>'; |
560 | 560 | } |
561 | 561 | |
@@ -580,29 +580,29 @@ discard block |
||
580 | 580 | * } |
581 | 581 | * @return void |
582 | 582 | */ |
583 | -function give_checkbox( $field ) { |
|
583 | +function give_checkbox($field) { |
|
584 | 584 | global $thepostid, $post; |
585 | 585 | |
586 | - $thepostid = empty( $thepostid ) ? $post->ID : $thepostid; |
|
587 | - $field['style'] = isset( $field['style'] ) ? $field['style'] : ''; |
|
588 | - $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : ''; |
|
589 | - $field['value'] = give_get_field_value( $field, $thepostid ); |
|
590 | - $field['cbvalue'] = isset( $field['cbvalue'] ) ? $field['cbvalue'] : 'on'; |
|
591 | - $field['name'] = isset( $field['name'] ) ? $field['name'] : $field['id']; |
|
586 | + $thepostid = empty($thepostid) ? $post->ID : $thepostid; |
|
587 | + $field['style'] = isset($field['style']) ? $field['style'] : ''; |
|
588 | + $field['wrapper_class'] = isset($field['wrapper_class']) ? $field['wrapper_class'] : ''; |
|
589 | + $field['value'] = give_get_field_value($field, $thepostid); |
|
590 | + $field['cbvalue'] = isset($field['cbvalue']) ? $field['cbvalue'] : 'on'; |
|
591 | + $field['name'] = isset($field['name']) ? $field['name'] : $field['id']; |
|
592 | 592 | ?> |
593 | - <p class="give-field-wrap <?php echo esc_attr( $field['id'] ); ?>_field <?php echo esc_attr( $field['wrapper_class'] ); ?>"> |
|
594 | - <label for="<?php echo give_get_field_name( $field ); ?>"><?php echo wp_kses_post( $field['name'] ); ?></label> |
|
593 | + <p class="give-field-wrap <?php echo esc_attr($field['id']); ?>_field <?php echo esc_attr($field['wrapper_class']); ?>"> |
|
594 | + <label for="<?php echo give_get_field_name($field); ?>"><?php echo wp_kses_post($field['name']); ?></label> |
|
595 | 595 | <input |
596 | 596 | type="checkbox" |
597 | - style="<?php echo esc_attr( $field['style'] ); ?>" |
|
598 | - name="<?php echo give_get_field_name( $field ); ?>" |
|
599 | - id="<?php echo esc_attr( $field['id'] ); ?>" |
|
600 | - value="<?php echo esc_attr( $field['cbvalue'] ); ?>" |
|
601 | - <?php echo checked( $field['value'], $field['cbvalue'], false ); ?> |
|
602 | - <?php echo give_get_custom_attributes( $field ); ?> |
|
597 | + style="<?php echo esc_attr($field['style']); ?>" |
|
598 | + name="<?php echo give_get_field_name($field); ?>" |
|
599 | + id="<?php echo esc_attr($field['id']); ?>" |
|
600 | + value="<?php echo esc_attr($field['cbvalue']); ?>" |
|
601 | + <?php echo checked($field['value'], $field['cbvalue'], false); ?> |
|
602 | + <?php echo give_get_custom_attributes($field); ?> |
|
603 | 603 | /> |
604 | 604 | <?php |
605 | - echo give_get_field_description( $field ); |
|
605 | + echo give_get_field_description($field); |
|
606 | 606 | echo '</p>'; |
607 | 607 | } |
608 | 608 | |
@@ -628,29 +628,29 @@ discard block |
||
628 | 628 | * } |
629 | 629 | * @return void |
630 | 630 | */ |
631 | -function give_select( $field ) { |
|
631 | +function give_select($field) { |
|
632 | 632 | global $thepostid, $post; |
633 | 633 | |
634 | - $thepostid = empty( $thepostid ) ? $post->ID : $thepostid; |
|
635 | - $field['style'] = isset( $field['style'] ) ? $field['style'] : ''; |
|
636 | - $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : ''; |
|
637 | - $field['value'] = give_get_field_value( $field, $thepostid ); |
|
638 | - $field['name'] = isset( $field['name'] ) ? $field['name'] : $field['id']; |
|
634 | + $thepostid = empty($thepostid) ? $post->ID : $thepostid; |
|
635 | + $field['style'] = isset($field['style']) ? $field['style'] : ''; |
|
636 | + $field['wrapper_class'] = isset($field['wrapper_class']) ? $field['wrapper_class'] : ''; |
|
637 | + $field['value'] = give_get_field_value($field, $thepostid); |
|
638 | + $field['name'] = isset($field['name']) ? $field['name'] : $field['id']; |
|
639 | 639 | ?> |
640 | - <p class="give-field-wrap <?php echo esc_attr( $field['id'] ); ?>_field <?php echo esc_attr( $field['wrapper_class'] ); ?>"> |
|
641 | - <label for="<?php echo give_get_field_name( $field ); ?>"><?php echo wp_kses_post( $field['name'] ); ?></label> |
|
640 | + <p class="give-field-wrap <?php echo esc_attr($field['id']); ?>_field <?php echo esc_attr($field['wrapper_class']); ?>"> |
|
641 | + <label for="<?php echo give_get_field_name($field); ?>"><?php echo wp_kses_post($field['name']); ?></label> |
|
642 | 642 | <select |
643 | - id="<?php echo esc_attr( $field['id'] ); ?>" |
|
644 | - name="<?php echo give_get_field_name( $field ); ?>" |
|
645 | - style="<?php echo esc_attr( $field['style'] ) ?>" |
|
646 | - <?php echo give_get_custom_attributes( $field ); ?> |
|
643 | + id="<?php echo esc_attr($field['id']); ?>" |
|
644 | + name="<?php echo give_get_field_name($field); ?>" |
|
645 | + style="<?php echo esc_attr($field['style']) ?>" |
|
646 | + <?php echo give_get_custom_attributes($field); ?> |
|
647 | 647 | > |
648 | 648 | <?php |
649 | - foreach ( $field['options'] as $key => $value ) { |
|
650 | - echo '<option value="' . esc_attr( $key ) . '" ' . selected( esc_attr( $field['value'] ), esc_attr( $key ), false ) . '>' . esc_html( $value ) . '</option>'; |
|
649 | + foreach ($field['options'] as $key => $value) { |
|
650 | + echo '<option value="'.esc_attr($key).'" '.selected(esc_attr($field['value']), esc_attr($key), false).'>'.esc_html($value).'</option>'; |
|
651 | 651 | } |
652 | 652 | echo '</select>'; |
653 | - echo give_get_field_description( $field ); |
|
653 | + echo give_get_field_description($field); |
|
654 | 654 | echo '</p>'; |
655 | 655 | } |
656 | 656 | |
@@ -677,32 +677,32 @@ discard block |
||
677 | 677 | * } |
678 | 678 | * @return void |
679 | 679 | */ |
680 | -function give_radio( $field ) { |
|
680 | +function give_radio($field) { |
|
681 | 681 | global $thepostid, $post; |
682 | 682 | |
683 | - $thepostid = empty( $thepostid ) ? $post->ID : $thepostid; |
|
684 | - $field['style'] = isset( $field['style'] ) ? $field['style'] : ''; |
|
685 | - $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : ''; |
|
686 | - $field['value'] = give_get_field_value( $field, $thepostid ); |
|
687 | - $field['name'] = isset( $field['name'] ) ? $field['name'] : $field['id']; |
|
683 | + $thepostid = empty($thepostid) ? $post->ID : $thepostid; |
|
684 | + $field['style'] = isset($field['style']) ? $field['style'] : ''; |
|
685 | + $field['wrapper_class'] = isset($field['wrapper_class']) ? $field['wrapper_class'] : ''; |
|
686 | + $field['value'] = give_get_field_value($field, $thepostid); |
|
687 | + $field['name'] = isset($field['name']) ? $field['name'] : $field['id']; |
|
688 | 688 | |
689 | - echo '<fieldset class="give-field-wrap ' . esc_attr( $field['id'] ) . '_field ' . esc_attr( $field['wrapper_class'] ) . '"><span class="give-field-label">' . wp_kses_post( $field['name'] ) . '</span><legend class="screen-reader-text">' . wp_kses_post( $field['name'] ) . '</legend><ul class="give-radios">'; |
|
689 | + echo '<fieldset class="give-field-wrap '.esc_attr($field['id']).'_field '.esc_attr($field['wrapper_class']).'"><span class="give-field-label">'.wp_kses_post($field['name']).'</span><legend class="screen-reader-text">'.wp_kses_post($field['name']).'</legend><ul class="give-radios">'; |
|
690 | 690 | |
691 | - foreach ( $field['options'] as $key => $value ) { |
|
691 | + foreach ($field['options'] as $key => $value) { |
|
692 | 692 | |
693 | 693 | echo '<li><label><input |
694 | - name="' . give_get_field_name( $field ) . '" |
|
695 | - value="' . esc_attr( $key ) . '" |
|
694 | + name="' . give_get_field_name($field).'" |
|
695 | + value="' . esc_attr($key).'" |
|
696 | 696 | type="radio" |
697 | - style="' . esc_attr( $field['style'] ) . '" |
|
698 | - ' . checked( esc_attr( $field['value'] ), esc_attr( $key ), false ) . ' ' |
|
699 | - . give_get_custom_attributes( $field ) . ' |
|
700 | - /> ' . esc_html( $value ) . '</label> |
|
697 | + style="' . esc_attr($field['style']).'" |
|
698 | + ' . checked(esc_attr($field['value']), esc_attr($key), false).' ' |
|
699 | + . give_get_custom_attributes($field).' |
|
700 | + /> ' . esc_html($value).'</label> |
|
701 | 701 | </li>'; |
702 | 702 | } |
703 | 703 | echo '</ul>'; |
704 | 704 | |
705 | - echo give_get_field_description( $field ); |
|
705 | + echo give_get_field_description($field); |
|
706 | 706 | echo '</fieldset>'; |
707 | 707 | } |
708 | 708 | |
@@ -726,27 +726,27 @@ discard block |
||
726 | 726 | * } |
727 | 727 | * @return void |
728 | 728 | */ |
729 | -function give_colorpicker( $field ) { |
|
729 | +function give_colorpicker($field) { |
|
730 | 730 | global $thepostid, $post; |
731 | 731 | |
732 | - $thepostid = empty( $thepostid ) ? $post->ID : $thepostid; |
|
733 | - $field['style'] = isset( $field['style'] ) ? $field['style'] : ''; |
|
734 | - $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : ''; |
|
735 | - $field['value'] = give_get_field_value( $field, $thepostid ); |
|
736 | - $field['name'] = isset( $field['name'] ) ? $field['name'] : $field['id']; |
|
732 | + $thepostid = empty($thepostid) ? $post->ID : $thepostid; |
|
733 | + $field['style'] = isset($field['style']) ? $field['style'] : ''; |
|
734 | + $field['wrapper_class'] = isset($field['wrapper_class']) ? $field['wrapper_class'] : ''; |
|
735 | + $field['value'] = give_get_field_value($field, $thepostid); |
|
736 | + $field['name'] = isset($field['name']) ? $field['name'] : $field['id']; |
|
737 | 737 | $field['type'] = 'text'; |
738 | 738 | ?> |
739 | - <p class="give-field-wrap <?php echo esc_attr( $field['id'] ); ?>_field <?php echo esc_attr( $field['wrapper_class'] ); ?>"> |
|
740 | - <label for="<?php echo give_get_field_name( $field ); ?>"><?php echo wp_kses_post( $field['name'] ); ?></label> |
|
739 | + <p class="give-field-wrap <?php echo esc_attr($field['id']); ?>_field <?php echo esc_attr($field['wrapper_class']); ?>"> |
|
740 | + <label for="<?php echo give_get_field_name($field); ?>"><?php echo wp_kses_post($field['name']); ?></label> |
|
741 | 741 | <input |
742 | - type="<?php echo esc_attr( $field['type'] ); ?>" |
|
743 | - style="<?php echo esc_attr( $field['style'] ); ?>" |
|
744 | - name="<?php echo give_get_field_name( $field ); ?>" |
|
745 | - id="' . esc_attr( $field['id'] ) . '" value="<?php echo esc_attr( $field['value'] ); ?>" |
|
746 | - <?php echo give_get_custom_attributes( $field ); ?> |
|
742 | + type="<?php echo esc_attr($field['type']); ?>" |
|
743 | + style="<?php echo esc_attr($field['style']); ?>" |
|
744 | + name="<?php echo give_get_field_name($field); ?>" |
|
745 | + id="' . esc_attr( $field['id'] ) . '" value="<?php echo esc_attr($field['value']); ?>" |
|
746 | + <?php echo give_get_custom_attributes($field); ?> |
|
747 | 747 | /> |
748 | 748 | <?php |
749 | - echo give_get_field_description( $field ); |
|
749 | + echo give_get_field_description($field); |
|
750 | 750 | echo '</p>'; |
751 | 751 | } |
752 | 752 | |
@@ -757,8 +757,8 @@ discard block |
||
757 | 757 | * |
758 | 758 | * @param array $field |
759 | 759 | */ |
760 | -function give_file( $field ) { |
|
761 | - give_media( $field ); |
|
760 | +function give_file($field) { |
|
761 | + give_media($field); |
|
762 | 762 | } |
763 | 763 | |
764 | 764 | |
@@ -769,37 +769,37 @@ discard block |
||
769 | 769 | * |
770 | 770 | * @param array $field |
771 | 771 | */ |
772 | -function give_media( $field ) { |
|
772 | +function give_media($field) { |
|
773 | 773 | global $thepostid, $post; |
774 | 774 | |
775 | - $thepostid = empty( $thepostid ) ? $post->ID : $thepostid; |
|
776 | - $button_label = sprintf( __( 'Add or Upload %s', 'give' ), ( 'file' === $field['type'] ? __( 'File', 'give' ) : __( 'Image', 'give' ) ) ); |
|
775 | + $thepostid = empty($thepostid) ? $post->ID : $thepostid; |
|
776 | + $button_label = sprintf(__('Add or Upload %s', 'give'), ('file' === $field['type'] ? __('File', 'give') : __('Image', 'give'))); |
|
777 | 777 | |
778 | - $field['style'] = isset( $field['style'] ) ? $field['style'] : ''; |
|
779 | - $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : ''; |
|
780 | - $field['value'] = give_get_field_value( $field, $thepostid ); |
|
781 | - $field['name'] = isset( $field['name'] ) ? $field['name'] : $field['id']; |
|
778 | + $field['style'] = isset($field['style']) ? $field['style'] : ''; |
|
779 | + $field['wrapper_class'] = isset($field['wrapper_class']) ? $field['wrapper_class'] : ''; |
|
780 | + $field['value'] = give_get_field_value($field, $thepostid); |
|
781 | + $field['name'] = isset($field['name']) ? $field['name'] : $field['id']; |
|
782 | 782 | $field['attributes']['class'] = "{$field['attributes']['class']} give-text-medium"; |
783 | 783 | |
784 | 784 | // Allow developer to save attachment ID or attachment url as metadata. |
785 | - $field['fvalue'] = isset( $field['fvalue'] ) ? $field['fvalue'] : 'url'; |
|
785 | + $field['fvalue'] = isset($field['fvalue']) ? $field['fvalue'] : 'url'; |
|
786 | 786 | |
787 | - $allow_media_preview_tags = array( 'jpg', 'jpeg', 'png', 'gif', 'ico' ); |
|
788 | - $preview_image_src = $field['value'] ? ( 'id' === $field['fvalue'] ? wp_get_attachment_url( $field['value'] ) : $field['value'] ) : '#'; |
|
789 | - $preview_image_extension = $preview_image_src ? pathinfo( $preview_image_src, PATHINFO_EXTENSION ) : ''; |
|
790 | - $is_show_preview = in_array( $preview_image_extension, $allow_media_preview_tags ); |
|
787 | + $allow_media_preview_tags = array('jpg', 'jpeg', 'png', 'gif', 'ico'); |
|
788 | + $preview_image_src = $field['value'] ? ('id' === $field['fvalue'] ? wp_get_attachment_url($field['value']) : $field['value']) : '#'; |
|
789 | + $preview_image_extension = $preview_image_src ? pathinfo($preview_image_src, PATHINFO_EXTENSION) : ''; |
|
790 | + $is_show_preview = in_array($preview_image_extension, $allow_media_preview_tags); |
|
791 | 791 | ?> |
792 | - <fieldset class="give-field-wrap <?php echo esc_attr( $field['id'] ); ?>_field <?php echo esc_attr( $field['wrapper_class'] ); ?>"> |
|
793 | - <label for="<?php echo give_get_field_name( $field ) ?>"><?php echo wp_kses_post( $field['name'] ); ?></label> |
|
792 | + <fieldset class="give-field-wrap <?php echo esc_attr($field['id']); ?>_field <?php echo esc_attr($field['wrapper_class']); ?>"> |
|
793 | + <label for="<?php echo give_get_field_name($field) ?>"><?php echo wp_kses_post($field['name']); ?></label> |
|
794 | 794 | <input |
795 | - name="<?php echo give_get_field_name( $field ); ?>" |
|
796 | - id="<?php echo esc_attr( $field['id'] ); ?>" |
|
795 | + name="<?php echo give_get_field_name($field); ?>" |
|
796 | + id="<?php echo esc_attr($field['id']); ?>" |
|
797 | 797 | type="text" |
798 | 798 | value="<?php echo $field['value']; ?>" |
799 | - style="<?php echo esc_attr( $field['style'] ); ?>" |
|
800 | - <?php echo give_get_custom_attributes( $field ); ?> |
|
799 | + style="<?php echo esc_attr($field['style']); ?>" |
|
800 | + <?php echo give_get_custom_attributes($field); ?> |
|
801 | 801 | /> <input class="give-upload-button button" type="button" value="<?php echo $button_label; ?>" data-fvalue="<?php echo $field['fvalue']; ?>" data-field-type="<?php echo $field['type']; ?>"> |
802 | - <?php echo give_get_field_description( $field ); ?> |
|
802 | + <?php echo give_get_field_description($field); ?> |
|
803 | 803 | <div class="give-image-thumb<?php echo ! $field['value'] || ! $is_show_preview ? ' give-hidden' : ''; ?>"> |
804 | 804 | <span class="give-delete-image-thumb dashicons dashicons-no-alt"></span> |
805 | 805 | <img src="<?php echo $preview_image_src; ?>" alt=""> |
@@ -817,27 +817,27 @@ discard block |
||
817 | 817 | * |
818 | 818 | * @return void |
819 | 819 | */ |
820 | -function give_default_gateway( $field ) { |
|
820 | +function give_default_gateway($field) { |
|
821 | 821 | global $thepostid, $post; |
822 | 822 | |
823 | 823 | // get all active payment gateways. |
824 | - $gateways = give_get_enabled_payment_gateways( $thepostid ); |
|
824 | + $gateways = give_get_enabled_payment_gateways($thepostid); |
|
825 | 825 | $field['options'] = array(); |
826 | 826 | |
827 | 827 | // Set field option value. |
828 | - if ( ! empty( $gateways ) ) { |
|
829 | - foreach ( $gateways as $key => $option ) { |
|
830 | - $field['options'][ $key ] = $option['admin_label']; |
|
828 | + if ( ! empty($gateways)) { |
|
829 | + foreach ($gateways as $key => $option) { |
|
830 | + $field['options'][$key] = $option['admin_label']; |
|
831 | 831 | } |
832 | 832 | } |
833 | 833 | |
834 | 834 | // Add a field to the Give Form admin single post view of this field |
835 | - if ( is_object( $post ) && 'give_forms' === $post->post_type ) { |
|
836 | - $field['options'] = array_merge( array( 'global' => esc_html__( 'Global Default', 'give' ) ), $field['options'] ); |
|
835 | + if (is_object($post) && 'give_forms' === $post->post_type) { |
|
836 | + $field['options'] = array_merge(array('global' => esc_html__('Global Default', 'give')), $field['options']); |
|
837 | 837 | } |
838 | 838 | |
839 | 839 | // Render select field. |
840 | - give_select( $field ); |
|
840 | + give_select($field); |
|
841 | 841 | } |
842 | 842 | |
843 | 843 | /** |
@@ -859,13 +859,13 @@ discard block |
||
859 | 859 | * @return void |
860 | 860 | */ |
861 | 861 | |
862 | -function give_docs_link( $field ) { |
|
863 | - $field['url'] = isset( $field['url'] ) ? $field['url'] : 'https://givewp.com/documentation'; |
|
864 | - $field['title'] = isset( $field['title'] ) ? $field['title'] : 'Documentation'; |
|
862 | +function give_docs_link($field) { |
|
863 | + $field['url'] = isset($field['url']) ? $field['url'] : 'https://givewp.com/documentation'; |
|
864 | + $field['title'] = isset($field['title']) ? $field['title'] : 'Documentation'; |
|
865 | 865 | |
866 | - echo '<p class="give-docs-link"><a href="' . esc_url( $field['url'] ) |
|
866 | + echo '<p class="give-docs-link"><a href="'.esc_url($field['url']) |
|
867 | 867 | . '" target="_blank">' |
868 | - . sprintf( esc_html__( 'Need Help? See docs on "%s"', 'give' ), $field['title'] ) |
|
868 | + . sprintf(esc_html__('Need Help? See docs on "%s"', 'give'), $field['title']) |
|
869 | 869 | . '<span class="dashicons dashicons-editor-help"></span></a></p>'; |
870 | 870 | } |
871 | 871 | |
@@ -877,15 +877,15 @@ discard block |
||
877 | 877 | * |
878 | 878 | * @param $field |
879 | 879 | */ |
880 | -function give_email_preview_buttons( $field ) { |
|
880 | +function give_email_preview_buttons($field) { |
|
881 | 881 | /* @var WP_Post $post */ |
882 | 882 | global $post; |
883 | 883 | |
884 | - $field_id = str_replace( array( '_give_', '_preview_buttons' ), '', $field['id'] ); |
|
884 | + $field_id = str_replace(array('_give_', '_preview_buttons'), '', $field['id']); |
|
885 | 885 | |
886 | 886 | ob_start(); |
887 | 887 | |
888 | - echo '<p class="give-field-wrap ' . esc_attr( $field['id'] ) . '_field"><label for="' . give_get_field_name( $field ) . '">' . wp_kses_post( $field['name'] ) . '</label>'; |
|
888 | + echo '<p class="give-field-wrap '.esc_attr($field['id']).'_field"><label for="'.give_get_field_name($field).'">'.wp_kses_post($field['name']).'</label>'; |
|
889 | 889 | |
890 | 890 | echo sprintf( |
891 | 891 | '<a href="%1$s" class="button-secondary" target="_blank">%2$s</a>', |
@@ -913,12 +913,12 @@ discard block |
||
913 | 913 | 'form_id' => $post->ID, |
914 | 914 | ) |
915 | 915 | ), 'give-send-preview-email' ), |
916 | - esc_attr__( 'Send Test Email.', 'give' ), |
|
917 | - esc_html__( 'Send Test Email', 'give' ) |
|
916 | + esc_attr__('Send Test Email.', 'give'), |
|
917 | + esc_html__('Send Test Email', 'give') |
|
918 | 918 | ); |
919 | 919 | |
920 | - if ( ! empty( $field['description'] ) ) { |
|
921 | - echo '<span class="give-field-description">' . wp_kses_post( $field['desc'] ) . '</span>'; |
|
920 | + if ( ! empty($field['description'])) { |
|
921 | + echo '<span class="give-field-description">'.wp_kses_post($field['desc']).'</span>'; |
|
922 | 922 | } |
923 | 923 | |
924 | 924 | echo '</p>'; |
@@ -939,29 +939,29 @@ discard block |
||
939 | 939 | * |
940 | 940 | * @return mixed |
941 | 941 | */ |
942 | -function give_get_field_value( $field, $postid ) { |
|
943 | - if ( isset( $field['attributes']['value'] ) ) { |
|
942 | +function give_get_field_value($field, $postid) { |
|
943 | + if (isset($field['attributes']['value'])) { |
|
944 | 944 | return $field['attributes']['value']; |
945 | 945 | } |
946 | 946 | |
947 | 947 | // If field is range slider. |
948 | - if ( 'donation_limit' === $field['type'] ) { |
|
948 | + if ('donation_limit' === $field['type']) { |
|
949 | 949 | |
950 | 950 | // Get minimum value. |
951 | - $minimum = give_get_meta( $postid, $field['id'] . '_minimum', true ); |
|
951 | + $minimum = give_get_meta($postid, $field['id'].'_minimum', true); |
|
952 | 952 | |
953 | 953 | // Give < 2.1 |
954 | - if ( '_give_custom_amount_range' === $field['id'] && empty( $minimum ) ) { |
|
955 | - $minimum = give_get_meta( $postid, '_give_custom_amount_minimum', true ); |
|
954 | + if ('_give_custom_amount_range' === $field['id'] && empty($minimum)) { |
|
955 | + $minimum = give_get_meta($postid, '_give_custom_amount_minimum', true); |
|
956 | 956 | } |
957 | 957 | |
958 | 958 | $field_value = array( |
959 | 959 | 'minimum' => $minimum, |
960 | - 'maximum' => give_get_meta( $postid, $field['id'] . '_maximum', true ), |
|
960 | + 'maximum' => give_get_meta($postid, $field['id'].'_maximum', true), |
|
961 | 961 | ); |
962 | 962 | } else { |
963 | 963 | // Get value from db. |
964 | - $field_value = give_get_meta( $postid, $field['id'], true ); |
|
964 | + $field_value = give_get_meta($postid, $field['id'], true); |
|
965 | 965 | } |
966 | 966 | |
967 | 967 | /** |
@@ -971,10 +971,10 @@ discard block |
||
971 | 971 | * |
972 | 972 | * @param mixed $field_value Field value. |
973 | 973 | */ |
974 | - $field_value = apply_filters( "{$field['id']}_field_value", $field_value, $field, $postid ); |
|
974 | + $field_value = apply_filters("{$field['id']}_field_value", $field_value, $field, $postid); |
|
975 | 975 | |
976 | 976 | // Set default value if no any data saved to db. |
977 | - if ( ! $field_value && isset( $field['default'] ) ) { |
|
977 | + if ( ! $field_value && isset($field['default'])) { |
|
978 | 978 | $field_value = $field['default']; |
979 | 979 | } |
980 | 980 | |
@@ -991,20 +991,20 @@ discard block |
||
991 | 991 | * |
992 | 992 | * @return string |
993 | 993 | */ |
994 | -function give_get_field_description( $field ) { |
|
994 | +function give_get_field_description($field) { |
|
995 | 995 | $field_desc_html = ''; |
996 | 996 | $description = ''; |
997 | 997 | |
998 | 998 | // Check for both `description` and `desc`. |
999 | - if ( isset( $field['description'] ) ) { |
|
999 | + if (isset($field['description'])) { |
|
1000 | 1000 | $description = $field['description']; |
1001 | - } elseif ( isset( $field['desc'] ) ) { |
|
1001 | + } elseif (isset($field['desc'])) { |
|
1002 | 1002 | $description = $field['desc']; |
1003 | 1003 | } |
1004 | 1004 | |
1005 | 1005 | // Set if there is a description. |
1006 | - if ( ! empty( $description ) ) { |
|
1007 | - $field_desc_html = '<span class="give-field-description">' . wp_kses_post( $description ) . '</span>'; |
|
1006 | + if ( ! empty($description)) { |
|
1007 | + $field_desc_html = '<span class="give-field-description">'.wp_kses_post($description).'</span>'; |
|
1008 | 1008 | } |
1009 | 1009 | |
1010 | 1010 | return $field_desc_html; |
@@ -1024,8 +1024,8 @@ discard block |
||
1024 | 1024 | * |
1025 | 1025 | * @return string |
1026 | 1026 | */ |
1027 | -function give_get_repeater_field_value( $field, $field_group, $fields ) { |
|
1028 | - $field_value = ( isset( $field_group[ $field['id'] ] ) ? $field_group[ $field['id'] ] : '' ); |
|
1027 | +function give_get_repeater_field_value($field, $field_group, $fields) { |
|
1028 | + $field_value = (isset($field_group[$field['id']]) ? $field_group[$field['id']] : ''); |
|
1029 | 1029 | |
1030 | 1030 | /** |
1031 | 1031 | * Filter the specific repeater field value |
@@ -1034,7 +1034,7 @@ discard block |
||
1034 | 1034 | * |
1035 | 1035 | * @param string $field_id |
1036 | 1036 | */ |
1037 | - $field_value = apply_filters( "give_get_repeater_field_{$field['id']}_value", $field_value, $field, $field_group, $fields ); |
|
1037 | + $field_value = apply_filters("give_get_repeater_field_{$field['id']}_value", $field_value, $field, $field_group, $fields); |
|
1038 | 1038 | |
1039 | 1039 | /** |
1040 | 1040 | * Filter the repeater field value |
@@ -1043,7 +1043,7 @@ discard block |
||
1043 | 1043 | * |
1044 | 1044 | * @param string $field_id |
1045 | 1045 | */ |
1046 | - $field_value = apply_filters( 'give_get_repeater_field_value', $field_value, $field, $field_group, $fields ); |
|
1046 | + $field_value = apply_filters('give_get_repeater_field_value', $field_value, $field, $field_group, $fields); |
|
1047 | 1047 | |
1048 | 1048 | return $field_value; |
1049 | 1049 | } |
@@ -1061,7 +1061,7 @@ discard block |
||
1061 | 1061 | * |
1062 | 1062 | * @return string |
1063 | 1063 | */ |
1064 | -function give_get_repeater_field_id( $field, $fields, $default = false ) { |
|
1064 | +function give_get_repeater_field_id($field, $fields, $default = false) { |
|
1065 | 1065 | $row_placeholder = false !== $default ? $default : '{{row-count-placeholder}}'; |
1066 | 1066 | |
1067 | 1067 | // Get field id. |
@@ -1074,7 +1074,7 @@ discard block |
||
1074 | 1074 | * |
1075 | 1075 | * @param string $field_id |
1076 | 1076 | */ |
1077 | - $field_id = apply_filters( "give_get_repeater_field_{$field['id']}_id", $field_id, $field, $fields, $default ); |
|
1077 | + $field_id = apply_filters("give_get_repeater_field_{$field['id']}_id", $field_id, $field, $fields, $default); |
|
1078 | 1078 | |
1079 | 1079 | /** |
1080 | 1080 | * Filter the repeater field id |
@@ -1083,7 +1083,7 @@ discard block |
||
1083 | 1083 | * |
1084 | 1084 | * @param string $field_id |
1085 | 1085 | */ |
1086 | - $field_id = apply_filters( 'give_get_repeater_field_id', $field_id, $field, $fields, $default ); |
|
1086 | + $field_id = apply_filters('give_get_repeater_field_id', $field_id, $field, $fields, $default); |
|
1087 | 1087 | |
1088 | 1088 | return $field_id; |
1089 | 1089 | } |
@@ -1098,8 +1098,8 @@ discard block |
||
1098 | 1098 | * |
1099 | 1099 | * @return string |
1100 | 1100 | */ |
1101 | -function give_get_field_name( $field ) { |
|
1102 | - $field_name = esc_attr( empty( $field['repeat'] ) ? $field['id'] : $field['repeatable_field_id'] ); |
|
1101 | +function give_get_field_name($field) { |
|
1102 | + $field_name = esc_attr(empty($field['repeat']) ? $field['id'] : $field['repeatable_field_id']); |
|
1103 | 1103 | |
1104 | 1104 | /** |
1105 | 1105 | * Filter the field name. |
@@ -1108,7 +1108,7 @@ discard block |
||
1108 | 1108 | * |
1109 | 1109 | * @param string $field_name |
1110 | 1110 | */ |
1111 | - $field_name = apply_filters( 'give_get_field_name', $field_name, $field ); |
|
1111 | + $field_name = apply_filters('give_get_field_name', $field_name, $field); |
|
1112 | 1112 | |
1113 | 1113 | return $field_name; |
1114 | 1114 | } |
@@ -1125,40 +1125,40 @@ discard block |
||
1125 | 1125 | * |
1126 | 1126 | * @return void |
1127 | 1127 | */ |
1128 | -function _give_metabox_form_data_repeater_fields( $fields ) { |
|
1128 | +function _give_metabox_form_data_repeater_fields($fields) { |
|
1129 | 1129 | global $thepostid, $post; |
1130 | 1130 | |
1131 | 1131 | // Bailout. |
1132 | - if ( ! isset( $fields['fields'] ) || empty( $fields['fields'] ) ) { |
|
1132 | + if ( ! isset($fields['fields']) || empty($fields['fields'])) { |
|
1133 | 1133 | return; |
1134 | 1134 | } |
1135 | 1135 | |
1136 | - $group_numbering = isset( $fields['options']['group_numbering'] ) ? (int) $fields['options']['group_numbering'] : 0; |
|
1137 | - $close_tabs = isset( $fields['options']['close_tabs'] ) ? (int) $fields['options']['close_tabs'] : 0; |
|
1138 | - $wrapper_class = isset( $fields['wrapper_class'] ) ? $fields['wrapper_class'] : ''; |
|
1136 | + $group_numbering = isset($fields['options']['group_numbering']) ? (int) $fields['options']['group_numbering'] : 0; |
|
1137 | + $close_tabs = isset($fields['options']['close_tabs']) ? (int) $fields['options']['close_tabs'] : 0; |
|
1138 | + $wrapper_class = isset($fields['wrapper_class']) ? $fields['wrapper_class'] : ''; |
|
1139 | 1139 | ?> |
1140 | - <div class="give-repeatable-field-section <?php echo esc_attr( $wrapper_class ); ?>" id="<?php echo "{$fields['id']}_field"; ?>" |
|
1140 | + <div class="give-repeatable-field-section <?php echo esc_attr($wrapper_class); ?>" id="<?php echo "{$fields['id']}_field"; ?>" |
|
1141 | 1141 | data-group-numbering="<?php echo $group_numbering; ?>" data-close-tabs="<?php echo $close_tabs; ?>"> |
1142 | - <?php if ( ! empty( $fields['name'] ) ) : ?> |
|
1142 | + <?php if ( ! empty($fields['name'])) : ?> |
|
1143 | 1143 | <p class="give-repeater-field-name"><?php echo $fields['name']; ?></p> |
1144 | 1144 | <?php endif; ?> |
1145 | 1145 | |
1146 | - <?php if ( ! empty( $fields['description'] ) ) : ?> |
|
1146 | + <?php if ( ! empty($fields['description'])) : ?> |
|
1147 | 1147 | <p class="give-repeater-field-description"><?php echo $fields['description']; ?></p> |
1148 | 1148 | <?php endif; ?> |
1149 | 1149 | |
1150 | 1150 | <table class="give-repeatable-fields-section-wrapper" cellspacing="0"> |
1151 | 1151 | <?php |
1152 | - $repeater_field_values = give_get_meta( $thepostid, $fields['id'], true ); |
|
1153 | - $header_title = isset( $fields['options']['header_title'] ) |
|
1152 | + $repeater_field_values = give_get_meta($thepostid, $fields['id'], true); |
|
1153 | + $header_title = isset($fields['options']['header_title']) |
|
1154 | 1154 | ? $fields['options']['header_title'] |
1155 | - : esc_attr__( 'Group', 'give' ); |
|
1155 | + : esc_attr__('Group', 'give'); |
|
1156 | 1156 | |
1157 | 1157 | $add_default_donation_field = false; |
1158 | 1158 | |
1159 | 1159 | // Check if level is not created or we have to add default level. |
1160 | - if ( is_array( $repeater_field_values ) && ( $fields_count = count( $repeater_field_values ) ) ) { |
|
1161 | - $repeater_field_values = array_values( $repeater_field_values ); |
|
1160 | + if (is_array($repeater_field_values) && ($fields_count = count($repeater_field_values))) { |
|
1161 | + $repeater_field_values = array_values($repeater_field_values); |
|
1162 | 1162 | } else { |
1163 | 1163 | $fields_count = 1; |
1164 | 1164 | $add_default_donation_field = true; |
@@ -1171,77 +1171,77 @@ discard block |
||
1171 | 1171 | <div class="give-row-head give-move"> |
1172 | 1172 | <button type="button" class="handlediv button-link"><span class="toggle-indicator"></span> |
1173 | 1173 | </button> |
1174 | - <span class="give-remove" title="<?php esc_html_e( 'Remove Group', 'give' ); ?>">-</span> |
|
1174 | + <span class="give-remove" title="<?php esc_html_e('Remove Group', 'give'); ?>">-</span> |
|
1175 | 1175 | <h2> |
1176 | 1176 | <span data-header-title="<?php echo $header_title; ?>"><?php echo $header_title; ?></span> |
1177 | 1177 | </h2> |
1178 | 1178 | </div> |
1179 | 1179 | <div class="give-row-body"> |
1180 | - <?php foreach ( $fields['fields'] as $field ) : ?> |
|
1180 | + <?php foreach ($fields['fields'] as $field) : ?> |
|
1181 | 1181 | <?php |
1182 | - if ( ! give_is_field_callback_exist( $field ) ) { |
|
1182 | + if ( ! give_is_field_callback_exist($field)) { |
|
1183 | 1183 | continue; |
1184 | 1184 | } |
1185 | 1185 | ?> |
1186 | 1186 | <?php |
1187 | 1187 | $field['repeat'] = true; |
1188 | - $field['repeatable_field_id'] = give_get_repeater_field_id( $field, $fields ); |
|
1188 | + $field['repeatable_field_id'] = give_get_repeater_field_id($field, $fields); |
|
1189 | 1189 | $field['id'] = str_replace( |
1190 | - array( '[', ']' ), |
|
1191 | - array( '_', '', ), |
|
1190 | + array('[', ']'), |
|
1191 | + array('_', '',), |
|
1192 | 1192 | $field['repeatable_field_id'] |
1193 | 1193 | ); |
1194 | 1194 | ?> |
1195 | - <?php give_render_field( $field ); ?> |
|
1195 | + <?php give_render_field($field); ?> |
|
1196 | 1196 | <?php endforeach; ?> |
1197 | 1197 | </div> |
1198 | 1198 | </td> |
1199 | 1199 | </tr> |
1200 | 1200 | |
1201 | - <?php if ( ! empty( $repeater_field_values ) ) : ?> |
|
1201 | + <?php if ( ! empty($repeater_field_values)) : ?> |
|
1202 | 1202 | <!--Stored repeater field group--> |
1203 | - <?php foreach ( $repeater_field_values as $index => $field_group ) : ?> |
|
1203 | + <?php foreach ($repeater_field_values as $index => $field_group) : ?> |
|
1204 | 1204 | <tr class="give-row"> |
1205 | 1205 | <td class="give-repeater-field-wrap give-column" colspan="2"> |
1206 | 1206 | <div class="give-row-head give-move"> |
1207 | 1207 | <button type="button" class="handlediv button-link"> |
1208 | 1208 | <span class="toggle-indicator"></span></button> |
1209 | - <span class="give-remove" title="<?php esc_html_e( 'Remove Group', 'give' ); ?>">- |
|
1209 | + <span class="give-remove" title="<?php esc_html_e('Remove Group', 'give'); ?>">- |
|
1210 | 1210 | </span> |
1211 | 1211 | <h2> |
1212 | 1212 | <span data-header-title="<?php echo $header_title; ?>"><?php echo $header_title; ?></span> |
1213 | 1213 | </h2> |
1214 | 1214 | </div> |
1215 | 1215 | <div class="give-row-body"> |
1216 | - <?php foreach ( $fields['fields'] as $field ) : ?> |
|
1217 | - <?php if ( ! give_is_field_callback_exist( $field ) ) { |
|
1216 | + <?php foreach ($fields['fields'] as $field) : ?> |
|
1217 | + <?php if ( ! give_is_field_callback_exist($field)) { |
|
1218 | 1218 | continue; |
1219 | 1219 | } ?> |
1220 | 1220 | <?php |
1221 | 1221 | $field['repeat'] = true; |
1222 | - $field['repeatable_field_id'] = give_get_repeater_field_id( $field, $fields, $index ); |
|
1223 | - $field['attributes']['value'] = give_get_repeater_field_value( $field, $field_group, $fields ); |
|
1222 | + $field['repeatable_field_id'] = give_get_repeater_field_id($field, $fields, $index); |
|
1223 | + $field['attributes']['value'] = give_get_repeater_field_value($field, $field_group, $fields); |
|
1224 | 1224 | $field['id'] = str_replace( |
1225 | - array( '[', ']' ), |
|
1226 | - array( '_', '', ), |
|
1225 | + array('[', ']'), |
|
1226 | + array('_', '',), |
|
1227 | 1227 | $field['repeatable_field_id'] |
1228 | 1228 | ); |
1229 | 1229 | ?> |
1230 | - <?php give_render_field( $field ); ?> |
|
1230 | + <?php give_render_field($field); ?> |
|
1231 | 1231 | <?php endforeach; ?> |
1232 | 1232 | </div> |
1233 | 1233 | </td> |
1234 | 1234 | </tr> |
1235 | - <?php endforeach;; ?> |
|
1235 | + <?php endforeach; ; ?> |
|
1236 | 1236 | |
1237 | - <?php elseif ( $add_default_donation_field ) : ?> |
|
1237 | + <?php elseif ($add_default_donation_field) : ?> |
|
1238 | 1238 | <!--Default repeater field group--> |
1239 | 1239 | <tr class="give-row"> |
1240 | 1240 | <td class="give-repeater-field-wrap give-column" colspan="2"> |
1241 | 1241 | <div class="give-row-head give-move"> |
1242 | 1242 | <button type="button" class="handlediv button-link"> |
1243 | 1243 | <span class="toggle-indicator"></span></button> |
1244 | - <span class="give-remove" title="<?php esc_html_e( 'Remove Group', 'give' ); ?>">- |
|
1244 | + <span class="give-remove" title="<?php esc_html_e('Remove Group', 'give'); ?>">- |
|
1245 | 1245 | </span> |
1246 | 1246 | <h2> |
1247 | 1247 | <span data-header-title="<?php echo $header_title; ?>"><?php echo $header_title; ?></span> |
@@ -1249,25 +1249,25 @@ discard block |
||
1249 | 1249 | </div> |
1250 | 1250 | <div class="give-row-body"> |
1251 | 1251 | <?php |
1252 | - foreach ( $fields['fields'] as $field ) : |
|
1253 | - if ( ! give_is_field_callback_exist( $field ) ) { |
|
1252 | + foreach ($fields['fields'] as $field) : |
|
1253 | + if ( ! give_is_field_callback_exist($field)) { |
|
1254 | 1254 | continue; |
1255 | 1255 | } |
1256 | 1256 | |
1257 | 1257 | $field['repeat'] = true; |
1258 | - $field['repeatable_field_id'] = give_get_repeater_field_id( $field, $fields, 0 ); |
|
1258 | + $field['repeatable_field_id'] = give_get_repeater_field_id($field, $fields, 0); |
|
1259 | 1259 | $field['attributes']['value'] = apply_filters( |
1260 | 1260 | "give_default_field_group_field_{$field['id']}_value", |
1261 | - ( ! empty( $field['default'] ) ? $field['default'] : '' ), |
|
1261 | + ( ! empty($field['default']) ? $field['default'] : ''), |
|
1262 | 1262 | $field, |
1263 | 1263 | $fields |
1264 | 1264 | ); |
1265 | - $field['id'] = str_replace( |
|
1266 | - array( '[', ']' ), |
|
1267 | - array( '_', '', ), |
|
1265 | + $field['id'] = str_replace( |
|
1266 | + array('[', ']'), |
|
1267 | + array('_', '',), |
|
1268 | 1268 | $field['repeatable_field_id'] |
1269 | 1269 | ); |
1270 | - give_render_field( $field ); |
|
1270 | + give_render_field($field); |
|
1271 | 1271 | |
1272 | 1272 | endforeach; |
1273 | 1273 | ?> |
@@ -1279,9 +1279,9 @@ discard block |
||
1279 | 1279 | <tfoot> |
1280 | 1280 | <tr> |
1281 | 1281 | <?php |
1282 | - $add_row_btn_title = isset( $fields['options']['add_button'] ) |
|
1282 | + $add_row_btn_title = isset($fields['options']['add_button']) |
|
1283 | 1283 | ? $add_row_btn_title = $fields['options']['add_button'] |
1284 | - : esc_html__( 'Add Row', 'give' ); |
|
1284 | + : esc_html__('Add Row', 'give'); |
|
1285 | 1285 | ?> |
1286 | 1286 | <td colspan="2" class="give-add-repeater-field-section-row-wrap"> |
1287 | 1287 | <span class="button button-primary give-add-repeater-field-section-row"><?php echo $add_row_btn_title; ?></span> |
@@ -1311,10 +1311,10 @@ discard block |
||
1311 | 1311 | * |
1312 | 1312 | * @param string |
1313 | 1313 | */ |
1314 | - $default_current_tab = apply_filters( "give_default_setting_tab_{$current_setting_page}", 'general' ); |
|
1314 | + $default_current_tab = apply_filters("give_default_setting_tab_{$current_setting_page}", 'general'); |
|
1315 | 1315 | |
1316 | 1316 | // Get current tab. |
1317 | - $current_tab = empty( $_GET['tab'] ) ? $default_current_tab : urldecode( $_GET['tab'] ); |
|
1317 | + $current_tab = empty($_GET['tab']) ? $default_current_tab : urldecode($_GET['tab']); |
|
1318 | 1318 | |
1319 | 1319 | // Output. |
1320 | 1320 | return $current_tab; |
@@ -1338,10 +1338,10 @@ discard block |
||
1338 | 1338 | * |
1339 | 1339 | * @param string |
1340 | 1340 | */ |
1341 | - $default_current_section = apply_filters( "give_default_setting_tab_section_{$current_tab}", '' ); |
|
1341 | + $default_current_section = apply_filters("give_default_setting_tab_section_{$current_tab}", ''); |
|
1342 | 1342 | |
1343 | 1343 | // Get current section. |
1344 | - $current_section = empty( $_REQUEST['section'] ) ? $default_current_section : urldecode( $_REQUEST['section'] ); |
|
1344 | + $current_section = empty($_REQUEST['section']) ? $default_current_section : urldecode($_REQUEST['section']); |
|
1345 | 1345 | |
1346 | 1346 | // Output. |
1347 | 1347 | return $current_section; |
@@ -1355,7 +1355,7 @@ discard block |
||
1355 | 1355 | */ |
1356 | 1356 | function give_get_current_setting_page() { |
1357 | 1357 | // Get current page. |
1358 | - $setting_page = ! empty( $_GET['page'] ) ? urldecode( $_GET['page'] ) : ''; |
|
1358 | + $setting_page = ! empty($_GET['page']) ? urldecode($_GET['page']) : ''; |
|
1359 | 1359 | |
1360 | 1360 | // Output. |
1361 | 1361 | return $setting_page; |
@@ -1375,13 +1375,13 @@ discard block |
||
1375 | 1375 | * |
1376 | 1376 | * @return string |
1377 | 1377 | */ |
1378 | -function _give_display_content_field_value( $field_value, $field, $postid ) { |
|
1379 | - $show_content = give_get_meta( $postid, '_give_content_option', true ); |
|
1378 | +function _give_display_content_field_value($field_value, $field, $postid) { |
|
1379 | + $show_content = give_get_meta($postid, '_give_content_option', true); |
|
1380 | 1380 | |
1381 | 1381 | if ( |
1382 | - ! give_get_meta( $postid, '_give_display_content', true ) |
|
1382 | + ! give_get_meta($postid, '_give_display_content', true) |
|
1383 | 1383 | && $show_content |
1384 | - && ( 'none' !== $show_content ) |
|
1384 | + && ('none' !== $show_content) |
|
1385 | 1385 | ) { |
1386 | 1386 | $field_value = 'enabled'; |
1387 | 1387 | } |
@@ -1389,7 +1389,7 @@ discard block |
||
1389 | 1389 | return $field_value; |
1390 | 1390 | } |
1391 | 1391 | |
1392 | -add_filter( '_give_display_content_field_value', '_give_display_content_field_value', 10, 3 ); |
|
1392 | +add_filter('_give_display_content_field_value', '_give_display_content_field_value', 10, 3); |
|
1393 | 1393 | |
1394 | 1394 | |
1395 | 1395 | /** |
@@ -1406,12 +1406,12 @@ discard block |
||
1406 | 1406 | * |
1407 | 1407 | * @return string |
1408 | 1408 | */ |
1409 | -function _give_content_placement_field_value( $field_value, $field, $postid ) { |
|
1410 | - $show_content = give_get_meta( $postid, '_give_content_option', true ); |
|
1409 | +function _give_content_placement_field_value($field_value, $field, $postid) { |
|
1410 | + $show_content = give_get_meta($postid, '_give_content_option', true); |
|
1411 | 1411 | |
1412 | 1412 | if ( |
1413 | - ! give_get_meta( $postid, '_give_content_placement', true ) |
|
1414 | - && ( 'none' !== $show_content ) |
|
1413 | + ! give_get_meta($postid, '_give_content_placement', true) |
|
1414 | + && ('none' !== $show_content) |
|
1415 | 1415 | ) { |
1416 | 1416 | $field_value = $show_content; |
1417 | 1417 | } |
@@ -1419,7 +1419,7 @@ discard block |
||
1419 | 1419 | return $field_value; |
1420 | 1420 | } |
1421 | 1421 | |
1422 | -add_filter( '_give_content_placement_field_value', '_give_content_placement_field_value', 10, 3 ); |
|
1422 | +add_filter('_give_content_placement_field_value', '_give_content_placement_field_value', 10, 3); |
|
1423 | 1423 | |
1424 | 1424 | |
1425 | 1425 | /** |
@@ -1435,17 +1435,17 @@ discard block |
||
1435 | 1435 | * |
1436 | 1436 | * @return string |
1437 | 1437 | */ |
1438 | -function _give_terms_option_field_value( $field_value, $field, $postid ) { |
|
1439 | - $term_option = give_get_meta( $postid, '_give_terms_option', true ); |
|
1438 | +function _give_terms_option_field_value($field_value, $field, $postid) { |
|
1439 | + $term_option = give_get_meta($postid, '_give_terms_option', true); |
|
1440 | 1440 | |
1441 | - if ( in_array( $term_option, array( 'none', 'yes' ) ) ) { |
|
1442 | - $field_value = ( 'yes' === $term_option ? 'enabled' : 'disabled' ); |
|
1441 | + if (in_array($term_option, array('none', 'yes'))) { |
|
1442 | + $field_value = ('yes' === $term_option ? 'enabled' : 'disabled'); |
|
1443 | 1443 | } |
1444 | 1444 | |
1445 | 1445 | return $field_value; |
1446 | 1446 | } |
1447 | 1447 | |
1448 | -add_filter( '_give_terms_option_field_value', '_give_terms_option_field_value', 10, 3 ); |
|
1448 | +add_filter('_give_terms_option_field_value', '_give_terms_option_field_value', 10, 3); |
|
1449 | 1449 | |
1450 | 1450 | |
1451 | 1451 | /** |
@@ -1462,17 +1462,17 @@ discard block |
||
1462 | 1462 | * |
1463 | 1463 | * @return string |
1464 | 1464 | */ |
1465 | -function _give_offline_donation_enable_billing_fields_single_field_value( $field_value, $field, $postid ) { |
|
1466 | - $offline_donation = give_get_meta( $postid, '_give_offline_donation_enable_billing_fields_single', true ); |
|
1465 | +function _give_offline_donation_enable_billing_fields_single_field_value($field_value, $field, $postid) { |
|
1466 | + $offline_donation = give_get_meta($postid, '_give_offline_donation_enable_billing_fields_single', true); |
|
1467 | 1467 | |
1468 | - if ( 'on' === $offline_donation ) { |
|
1468 | + if ('on' === $offline_donation) { |
|
1469 | 1469 | $field_value = 'enabled'; |
1470 | 1470 | } |
1471 | 1471 | |
1472 | 1472 | return $field_value; |
1473 | 1473 | } |
1474 | 1474 | |
1475 | -add_filter( '_give_offline_donation_enable_billing_fields_single_field_value', '_give_offline_donation_enable_billing_fields_single_field_value', 10, 3 ); |
|
1475 | +add_filter('_give_offline_donation_enable_billing_fields_single_field_value', '_give_offline_donation_enable_billing_fields_single_field_value', 10, 3); |
|
1476 | 1476 | |
1477 | 1477 | |
1478 | 1478 | /** |
@@ -1488,17 +1488,17 @@ discard block |
||
1488 | 1488 | * |
1489 | 1489 | * @return string |
1490 | 1490 | */ |
1491 | -function _give_custom_amount_field_value( $field_value, $field, $postid ) { |
|
1492 | - $custom_amount = give_get_meta( $postid, '_give_custom_amount', true ); |
|
1491 | +function _give_custom_amount_field_value($field_value, $field, $postid) { |
|
1492 | + $custom_amount = give_get_meta($postid, '_give_custom_amount', true); |
|
1493 | 1493 | |
1494 | - if ( in_array( $custom_amount, array( 'yes', 'no' ) ) ) { |
|
1495 | - $field_value = ( 'yes' === $custom_amount ? 'enabled' : 'disabled' ); |
|
1494 | + if (in_array($custom_amount, array('yes', 'no'))) { |
|
1495 | + $field_value = ('yes' === $custom_amount ? 'enabled' : 'disabled'); |
|
1496 | 1496 | } |
1497 | 1497 | |
1498 | 1498 | return $field_value; |
1499 | 1499 | } |
1500 | 1500 | |
1501 | -add_filter( '_give_custom_amount_field_value', '_give_custom_amount_field_value', 10, 3 ); |
|
1501 | +add_filter('_give_custom_amount_field_value', '_give_custom_amount_field_value', 10, 3); |
|
1502 | 1502 | |
1503 | 1503 | |
1504 | 1504 | /** |
@@ -1514,17 +1514,17 @@ discard block |
||
1514 | 1514 | * |
1515 | 1515 | * @return string |
1516 | 1516 | */ |
1517 | -function _give_goal_option_field_value( $field_value, $field, $postid ) { |
|
1518 | - $goal_option = give_get_meta( $postid, '_give_goal_option', true ); |
|
1517 | +function _give_goal_option_field_value($field_value, $field, $postid) { |
|
1518 | + $goal_option = give_get_meta($postid, '_give_goal_option', true); |
|
1519 | 1519 | |
1520 | - if ( in_array( $goal_option, array( 'yes', 'no' ) ) ) { |
|
1521 | - $field_value = ( 'yes' === $goal_option ? 'enabled' : 'disabled' ); |
|
1520 | + if (in_array($goal_option, array('yes', 'no'))) { |
|
1521 | + $field_value = ('yes' === $goal_option ? 'enabled' : 'disabled'); |
|
1522 | 1522 | } |
1523 | 1523 | |
1524 | 1524 | return $field_value; |
1525 | 1525 | } |
1526 | 1526 | |
1527 | -add_filter( '_give_goal_option_field_value', '_give_goal_option_field_value', 10, 3 ); |
|
1527 | +add_filter('_give_goal_option_field_value', '_give_goal_option_field_value', 10, 3); |
|
1528 | 1528 | |
1529 | 1529 | /** |
1530 | 1530 | * Set value for Donation Goal --> close Form. |
@@ -1540,17 +1540,17 @@ discard block |
||
1540 | 1540 | * |
1541 | 1541 | * @return string |
1542 | 1542 | */ |
1543 | -function _give_close_form_when_goal_achieved_value( $field_value, $field, $postid ) { |
|
1544 | - $close_form = give_get_meta( $postid, '_give_close_form_when_goal_achieved', true ); |
|
1543 | +function _give_close_form_when_goal_achieved_value($field_value, $field, $postid) { |
|
1544 | + $close_form = give_get_meta($postid, '_give_close_form_when_goal_achieved', true); |
|
1545 | 1545 | |
1546 | - if ( in_array( $close_form, array( 'yes', 'no' ) ) ) { |
|
1547 | - $field_value = ( 'yes' === $close_form ? 'enabled' : 'disabled' ); |
|
1546 | + if (in_array($close_form, array('yes', 'no'))) { |
|
1547 | + $field_value = ('yes' === $close_form ? 'enabled' : 'disabled'); |
|
1548 | 1548 | } |
1549 | 1549 | |
1550 | 1550 | return $field_value; |
1551 | 1551 | } |
1552 | 1552 | |
1553 | -add_filter( '_give_close_form_when_goal_achieved_field_value', '_give_close_form_when_goal_achieved_value', 10, 3 ); |
|
1553 | +add_filter('_give_close_form_when_goal_achieved_field_value', '_give_close_form_when_goal_achieved_value', 10, 3); |
|
1554 | 1554 | |
1555 | 1555 | |
1556 | 1556 | /** |
@@ -1566,17 +1566,17 @@ discard block |
||
1566 | 1566 | * |
1567 | 1567 | * @return string |
1568 | 1568 | */ |
1569 | -function _give_logged_in_only_value( $field_value, $field, $postid ) { |
|
1570 | - $guest_donation = give_get_meta( $postid, '_give_logged_in_only', true ); |
|
1569 | +function _give_logged_in_only_value($field_value, $field, $postid) { |
|
1570 | + $guest_donation = give_get_meta($postid, '_give_logged_in_only', true); |
|
1571 | 1571 | |
1572 | - if ( in_array( $guest_donation, array( 'yes', 'no' ) ) ) { |
|
1573 | - $field_value = ( 'yes' === $guest_donation ? 'enabled' : 'disabled' ); |
|
1572 | + if (in_array($guest_donation, array('yes', 'no'))) { |
|
1573 | + $field_value = ('yes' === $guest_donation ? 'enabled' : 'disabled'); |
|
1574 | 1574 | } |
1575 | 1575 | |
1576 | 1576 | return $field_value; |
1577 | 1577 | } |
1578 | 1578 | |
1579 | -add_filter( '_give_logged_in_only_field_value', '_give_logged_in_only_value', 10, 3 ); |
|
1579 | +add_filter('_give_logged_in_only_field_value', '_give_logged_in_only_value', 10, 3); |
|
1580 | 1580 | |
1581 | 1581 | /** |
1582 | 1582 | * Set value for Offline Donations --> Offline Donations. |
@@ -1592,17 +1592,17 @@ discard block |
||
1592 | 1592 | * |
1593 | 1593 | * @return string |
1594 | 1594 | */ |
1595 | -function _give_customize_offline_donations_value( $field_value, $field, $postid ) { |
|
1596 | - $customize_offline_text = give_get_meta( $postid, '_give_customize_offline_donations', true ); |
|
1595 | +function _give_customize_offline_donations_value($field_value, $field, $postid) { |
|
1596 | + $customize_offline_text = give_get_meta($postid, '_give_customize_offline_donations', true); |
|
1597 | 1597 | |
1598 | - if ( in_array( $customize_offline_text, array( 'yes', 'no' ) ) ) { |
|
1599 | - $field_value = ( 'yes' === $customize_offline_text ? 'enabled' : 'disabled' ); |
|
1598 | + if (in_array($customize_offline_text, array('yes', 'no'))) { |
|
1599 | + $field_value = ('yes' === $customize_offline_text ? 'enabled' : 'disabled'); |
|
1600 | 1600 | } |
1601 | 1601 | |
1602 | 1602 | return $field_value; |
1603 | 1603 | } |
1604 | 1604 | |
1605 | -add_filter( '_give_customize_offline_donations_field_value', '_give_customize_offline_donations_value', 10, 3 ); |
|
1605 | +add_filter('_give_customize_offline_donations_field_value', '_give_customize_offline_donations_value', 10, 3); |
|
1606 | 1606 | |
1607 | 1607 | |
1608 | 1608 | /** |
@@ -1617,14 +1617,14 @@ discard block |
||
1617 | 1617 | * |
1618 | 1618 | * @return mixed |
1619 | 1619 | */ |
1620 | -function _give_set_multi_level_repeater_field_id( $field_id, $field, $fields, $default ) { |
|
1620 | +function _give_set_multi_level_repeater_field_id($field_id, $field, $fields, $default) { |
|
1621 | 1621 | $row_placeholder = false !== $default ? $default : '{{row-count-placeholder}}'; |
1622 | 1622 | $field_id = "{$fields['id']}[{$row_placeholder}][{$field['id']}][level_id]"; |
1623 | 1623 | |
1624 | 1624 | return $field_id; |
1625 | 1625 | } |
1626 | 1626 | |
1627 | -add_filter( 'give_get_repeater_field__give_id_id', '_give_set_multi_level_repeater_field_id', 10, 4 ); |
|
1627 | +add_filter('give_get_repeater_field__give_id_id', '_give_set_multi_level_repeater_field_id', 10, 4); |
|
1628 | 1628 | |
1629 | 1629 | /** |
1630 | 1630 | * Set repeater field value for multi donation form. |
@@ -1638,13 +1638,13 @@ discard block |
||
1638 | 1638 | * |
1639 | 1639 | * @return mixed |
1640 | 1640 | */ |
1641 | -function _give_set_multi_level_repeater_field_value( $field_value, $field, $field_group, $fields ) { |
|
1642 | - $field_value = $field_group[ $field['id'] ]['level_id']; |
|
1641 | +function _give_set_multi_level_repeater_field_value($field_value, $field, $field_group, $fields) { |
|
1642 | + $field_value = $field_group[$field['id']]['level_id']; |
|
1643 | 1643 | |
1644 | 1644 | return $field_value; |
1645 | 1645 | } |
1646 | 1646 | |
1647 | -add_filter( 'give_get_repeater_field__give_id_value', '_give_set_multi_level_repeater_field_value', 10, 4 ); |
|
1647 | +add_filter('give_get_repeater_field__give_id_value', '_give_set_multi_level_repeater_field_value', 10, 4); |
|
1648 | 1648 | |
1649 | 1649 | /** |
1650 | 1650 | * Set default value for _give_id field. |
@@ -1655,11 +1655,11 @@ discard block |
||
1655 | 1655 | * |
1656 | 1656 | * @return string |
1657 | 1657 | */ |
1658 | -function _give_set_field_give_id_default_value( $field ) { |
|
1658 | +function _give_set_field_give_id_default_value($field) { |
|
1659 | 1659 | return 0; |
1660 | 1660 | } |
1661 | 1661 | |
1662 | -add_filter( 'give_default_field_group_field__give_id_value', '_give_set_field_give_id_default_value' ); |
|
1662 | +add_filter('give_default_field_group_field__give_id_value', '_give_set_field_give_id_default_value'); |
|
1663 | 1663 | |
1664 | 1664 | /** |
1665 | 1665 | * Set default value for _give_default field. |
@@ -1670,11 +1670,11 @@ discard block |
||
1670 | 1670 | * |
1671 | 1671 | * @return string |
1672 | 1672 | */ |
1673 | -function _give_set_field_give_default_default_value( $field ) { |
|
1673 | +function _give_set_field_give_default_default_value($field) { |
|
1674 | 1674 | return 'default'; |
1675 | 1675 | } |
1676 | 1676 | |
1677 | -add_filter( 'give_default_field_group_field__give_default_value', '_give_set_field_give_default_default_value' ); |
|
1677 | +add_filter('give_default_field_group_field__give_default_value', '_give_set_field_give_default_default_value'); |
|
1678 | 1678 | |
1679 | 1679 | /** |
1680 | 1680 | * Set repeater field editor id for field type wysiwyg. |
@@ -1686,15 +1686,15 @@ discard block |
||
1686 | 1686 | * |
1687 | 1687 | * @return string |
1688 | 1688 | */ |
1689 | -function give_repeater_field_set_editor_id( $field_name, $field ) { |
|
1690 | - if ( isset( $field['repeatable_field_id'] ) && 'wysiwyg' == $field['type'] ) { |
|
1691 | - $field_name = '_give_repeater_' . uniqid() . '_wysiwyg'; |
|
1689 | +function give_repeater_field_set_editor_id($field_name, $field) { |
|
1690 | + if (isset($field['repeatable_field_id']) && 'wysiwyg' == $field['type']) { |
|
1691 | + $field_name = '_give_repeater_'.uniqid().'_wysiwyg'; |
|
1692 | 1692 | } |
1693 | 1693 | |
1694 | 1694 | return $field_name; |
1695 | 1695 | } |
1696 | 1696 | |
1697 | -add_filter( 'give_get_field_name', 'give_repeater_field_set_editor_id', 10, 2 ); |
|
1697 | +add_filter('give_get_field_name', 'give_repeater_field_set_editor_id', 10, 2); |
|
1698 | 1698 | |
1699 | 1699 | /** |
1700 | 1700 | * Output Donation form radio input box. |
@@ -1719,45 +1719,45 @@ discard block |
||
1719 | 1719 | * } |
1720 | 1720 | * @return void |
1721 | 1721 | */ |
1722 | -function give_donation_form_goal( $field ) { |
|
1722 | +function give_donation_form_goal($field) { |
|
1723 | 1723 | global $thepostid, $post; |
1724 | 1724 | |
1725 | - $thepostid = empty( $thepostid ) ? $post->ID : $thepostid; |
|
1726 | - $field['style'] = isset( $field['style'] ) ? $field['style'] : ''; |
|
1727 | - $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : ''; |
|
1728 | - $field['value'] = give_get_field_value( $field, $thepostid ); |
|
1729 | - $field['name'] = isset( $field['name'] ) ? $field['name'] : $field['id']; |
|
1725 | + $thepostid = empty($thepostid) ? $post->ID : $thepostid; |
|
1726 | + $field['style'] = isset($field['style']) ? $field['style'] : ''; |
|
1727 | + $field['wrapper_class'] = isset($field['wrapper_class']) ? $field['wrapper_class'] : ''; |
|
1728 | + $field['value'] = give_get_field_value($field, $thepostid); |
|
1729 | + $field['name'] = isset($field['name']) ? $field['name'] : $field['id']; |
|
1730 | 1730 | |
1731 | 1731 | |
1732 | 1732 | printf( |
1733 | 1733 | '<fieldset class="give-field-wrap %s_field %s">', |
1734 | - esc_attr( $field['id'] ), |
|
1735 | - esc_attr( $field['wrapper_class'] ) |
|
1734 | + esc_attr($field['id']), |
|
1735 | + esc_attr($field['wrapper_class']) |
|
1736 | 1736 | ); |
1737 | 1737 | |
1738 | 1738 | printf( |
1739 | 1739 | '<span class="give-field-label">%s</span>', |
1740 | - esc_html( $field['name'] ) |
|
1740 | + esc_html($field['name']) |
|
1741 | 1741 | ); |
1742 | 1742 | |
1743 | 1743 | printf( |
1744 | 1744 | '<legend class="screen-reader-text">%s</legend>', |
1745 | - esc_html( $field['name'] ) |
|
1745 | + esc_html($field['name']) |
|
1746 | 1746 | ); |
1747 | 1747 | ?> |
1748 | 1748 | |
1749 | 1749 | <ul class="give-radios"> |
1750 | 1750 | <?php |
1751 | - foreach ( $field['options'] as $key => $value ) { |
|
1752 | - $attributes = empty( $field['attributes'] ) ? '' : give_get_attribute_str( $field['attributes'] ); |
|
1751 | + foreach ($field['options'] as $key => $value) { |
|
1752 | + $attributes = empty($field['attributes']) ? '' : give_get_attribute_str($field['attributes']); |
|
1753 | 1753 | printf( |
1754 | 1754 | '<li><label><input name="%s" value="%s" type="radio" style="%s" %s %s /> %s </label></li>', |
1755 | - give_get_field_name( $field ), |
|
1756 | - esc_attr( $key ), |
|
1757 | - esc_attr( $field['style'] ), |
|
1758 | - checked( esc_attr( $field['value'] ), esc_attr( $key ), false ), |
|
1755 | + give_get_field_name($field), |
|
1756 | + esc_attr($key), |
|
1757 | + esc_attr($field['style']), |
|
1758 | + checked(esc_attr($field['value']), esc_attr($key), false), |
|
1759 | 1759 | $attributes, |
1760 | - esc_html( $value ) |
|
1760 | + esc_html($value) |
|
1761 | 1761 | ); |
1762 | 1762 | } |
1763 | 1763 | ?> |
@@ -1771,9 +1771,9 @@ discard block |
||
1771 | 1771 | * |
1772 | 1772 | * @param array $field Array of radio field arguments. |
1773 | 1773 | */ |
1774 | - do_action( 'give_donation_form_goal_before_description', $field ); |
|
1774 | + do_action('give_donation_form_goal_before_description', $field); |
|
1775 | 1775 | |
1776 | - echo give_get_field_description( $field ); |
|
1776 | + echo give_get_field_description($field); |
|
1777 | 1777 | |
1778 | 1778 | echo '</fieldset>'; |
1779 | 1779 | } |
@@ -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,19 +23,19 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @return array An array of updated action links. |
25 | 25 | */ |
26 | -function give_plugin_action_links( $actions ) { |
|
26 | +function give_plugin_action_links($actions) { |
|
27 | 27 | $new_actions = array( |
28 | 28 | 'settings' => sprintf( |
29 | 29 | '<a href="%1$s">%2$s</a>', |
30 | - admin_url( 'edit.php?post_type=give_forms&page=give-settings' ), |
|
31 | - __( 'Settings', 'give' ) |
|
30 | + admin_url('edit.php?post_type=give_forms&page=give-settings'), |
|
31 | + __('Settings', 'give') |
|
32 | 32 | ), |
33 | 33 | ); |
34 | 34 | |
35 | - return array_merge( $new_actions, $actions ); |
|
35 | + return array_merge($new_actions, $actions); |
|
36 | 36 | } |
37 | 37 | |
38 | -add_filter( 'plugin_action_links_' . GIVE_PLUGIN_BASENAME, 'give_plugin_action_links' ); |
|
38 | +add_filter('plugin_action_links_'.GIVE_PLUGIN_BASENAME, 'give_plugin_action_links'); |
|
39 | 39 | |
40 | 40 | |
41 | 41 | /** |
@@ -48,8 +48,8 @@ discard block |
||
48 | 48 | * |
49 | 49 | * @return array |
50 | 50 | */ |
51 | -function give_plugin_row_meta( $plugin_meta, $plugin_file ) { |
|
52 | - if ( GIVE_PLUGIN_BASENAME !== $plugin_file ) { |
|
51 | +function give_plugin_row_meta($plugin_meta, $plugin_file) { |
|
52 | + if (GIVE_PLUGIN_BASENAME !== $plugin_file) { |
|
53 | 53 | return $plugin_meta; |
54 | 54 | } |
55 | 55 | |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | ), 'https://givewp.com/documentation/' |
66 | 66 | ) |
67 | 67 | ), |
68 | - __( 'Documentation', 'give' ) |
|
68 | + __('Documentation', 'give') |
|
69 | 69 | ), |
70 | 70 | sprintf( |
71 | 71 | '<a href="%1$s" target="_blank">%2$s</a>', |
@@ -78,14 +78,14 @@ discard block |
||
78 | 78 | ), 'https://givewp.com/addons/' |
79 | 79 | ) |
80 | 80 | ), |
81 | - __( 'Add-ons', 'give' ) |
|
81 | + __('Add-ons', 'give') |
|
82 | 82 | ), |
83 | 83 | ); |
84 | 84 | |
85 | - return array_merge( $plugin_meta, $new_meta_links ); |
|
85 | + return array_merge($plugin_meta, $new_meta_links); |
|
86 | 86 | } |
87 | 87 | |
88 | -add_filter( 'plugin_row_meta', 'give_plugin_row_meta', 10, 2 ); |
|
88 | +add_filter('plugin_row_meta', 'give_plugin_row_meta', 10, 2); |
|
89 | 89 | |
90 | 90 | |
91 | 91 | /** |
@@ -103,19 +103,18 @@ discard block |
||
103 | 103 | $title = ''; |
104 | 104 | global $submenu, $plugin_page; |
105 | 105 | |
106 | - foreach ( array_keys( $submenu ) as $parent ) { |
|
107 | - if ( 'edit.php?post_type=give_forms' !== $parent ) { |
|
106 | + foreach (array_keys($submenu) as $parent) { |
|
107 | + if ('edit.php?post_type=give_forms' !== $parent) { |
|
108 | 108 | continue; |
109 | 109 | } |
110 | 110 | |
111 | - foreach ( $submenu[ $parent ] as $submenu_array ) { |
|
112 | - if ( $plugin_page !== $submenu_array[2] ) { |
|
111 | + foreach ($submenu[$parent] as $submenu_array) { |
|
112 | + if ($plugin_page !== $submenu_array[2]) { |
|
113 | 113 | continue; |
114 | 114 | } |
115 | 115 | |
116 | - $title = isset( $submenu_array[0] ) ? |
|
117 | - $submenu_array[0] : |
|
118 | - $submenu_array[3]; |
|
116 | + $title = isset($submenu_array[0]) ? |
|
117 | + $submenu_array[0] : $submenu_array[3]; |
|
119 | 118 | } |
120 | 119 | } |
121 | 120 | |
@@ -129,11 +128,11 @@ discard block |
||
129 | 128 | */ |
130 | 129 | function give_recently_activated_addons() { |
131 | 130 | // Check if action is set. |
132 | - if ( isset( $_REQUEST['action'] ) ) { |
|
133 | - $plugin_action = ( '-1' !== $_REQUEST['action'] ) ? $_REQUEST['action'] : ( isset( $_REQUEST['action2'] ) ? $_REQUEST['action2'] : '' ); |
|
131 | + if (isset($_REQUEST['action'])) { |
|
132 | + $plugin_action = ('-1' !== $_REQUEST['action']) ? $_REQUEST['action'] : (isset($_REQUEST['action2']) ? $_REQUEST['action2'] : ''); |
|
134 | 133 | $plugins = array(); |
135 | 134 | |
136 | - switch ( $plugin_action ) { |
|
135 | + switch ($plugin_action) { |
|
137 | 136 | case 'activate': // Single add-on activation. |
138 | 137 | $plugins[] = $_REQUEST['plugin']; |
139 | 138 | break; |
@@ -143,27 +142,27 @@ discard block |
||
143 | 142 | } |
144 | 143 | |
145 | 144 | |
146 | - if ( ! empty( $plugins ) ) { |
|
145 | + if ( ! empty($plugins)) { |
|
147 | 146 | |
148 | 147 | $give_addons = give_get_recently_activated_addons(); |
149 | 148 | |
150 | - foreach ( $plugins as $plugin ) { |
|
149 | + foreach ($plugins as $plugin) { |
|
151 | 150 | // Get plugins which has 'Give-' as prefix. |
152 | - if ( stripos( $plugin, 'Give-' ) !== false ) { |
|
151 | + if (stripos($plugin, 'Give-') !== false) { |
|
153 | 152 | $give_addons[] = $plugin; |
154 | 153 | } |
155 | 154 | } |
156 | 155 | |
157 | - if ( ! empty( $give_addons ) ) { |
|
156 | + if ( ! empty($give_addons)) { |
|
158 | 157 | // Update the Give's activated add-ons. |
159 | - update_option( 'give_recently_activated_addons', $give_addons ); |
|
158 | + update_option('give_recently_activated_addons', $give_addons); |
|
160 | 159 | } |
161 | 160 | } |
162 | 161 | } |
163 | 162 | } |
164 | 163 | |
165 | 164 | // Add add-on plugins to wp option table. |
166 | -add_action( 'activated_plugin', 'give_recently_activated_addons', 10 ); |
|
165 | +add_action('activated_plugin', 'give_recently_activated_addons', 10); |
|
167 | 166 | |
168 | 167 | /** |
169 | 168 | * Create new menu in plugin section that include all the add-on |
@@ -174,19 +173,19 @@ discard block |
||
174 | 173 | * |
175 | 174 | * @return mixed |
176 | 175 | */ |
177 | -function give_filter_addons_do_filter_addons( $plugin_menu ) { |
|
176 | +function give_filter_addons_do_filter_addons($plugin_menu) { |
|
178 | 177 | global $plugins; |
179 | 178 | |
180 | - foreach ( $plugins['all'] as $plugin_slug => $plugin_data ) { |
|
179 | + foreach ($plugins['all'] as $plugin_slug => $plugin_data) { |
|
181 | 180 | |
182 | - if ( false !== strpos( $plugin_data['Name'], 'Give' ) && false !== strpos( $plugin_data['AuthorName'], 'WordImpress' ) ) { |
|
183 | - $plugins['give'][ $plugin_slug ] = $plugins['all'][ $plugin_slug ]; |
|
184 | - $plugins['give'][ $plugin_slug ]['plugin'] = $plugin_slug; |
|
181 | + if (false !== strpos($plugin_data['Name'], 'Give') && false !== strpos($plugin_data['AuthorName'], 'WordImpress')) { |
|
182 | + $plugins['give'][$plugin_slug] = $plugins['all'][$plugin_slug]; |
|
183 | + $plugins['give'][$plugin_slug]['plugin'] = $plugin_slug; |
|
185 | 184 | // replicate the next step. |
186 | - if ( current_user_can( 'update_plugins' ) ) { |
|
187 | - $current = get_site_transient( 'update_plugins' ); |
|
188 | - if ( isset( $current->response[ $plugin_slug ] ) ) { |
|
189 | - $plugins['give'][ $plugin_slug ]['update'] = true; |
|
185 | + if (current_user_can('update_plugins')) { |
|
186 | + $current = get_site_transient('update_plugins'); |
|
187 | + if (isset($current->response[$plugin_slug])) { |
|
188 | + $plugins['give'][$plugin_slug]['update'] = true; |
|
190 | 189 | } |
191 | 190 | } |
192 | 191 | } |
@@ -196,8 +195,8 @@ discard block |
||
196 | 195 | |
197 | 196 | } |
198 | 197 | |
199 | -add_filter( 'show_advanced_plugins', 'give_filter_addons_do_filter_addons' ); |
|
200 | -add_filter( 'show_network_active_plugins', 'give_filter_addons_do_filter_addons' ); |
|
198 | +add_filter('show_advanced_plugins', 'give_filter_addons_do_filter_addons'); |
|
199 | +add_filter('show_network_active_plugins', 'give_filter_addons_do_filter_addons'); |
|
201 | 200 | |
202 | 201 | /** |
203 | 202 | * Make the Give Menu as an default menu and update the Menu Name |
@@ -208,30 +207,30 @@ discard block |
||
208 | 207 | * |
209 | 208 | * @return mixed |
210 | 209 | */ |
211 | -function give_filter_addons_filter_addons( $views ) { |
|
210 | +function give_filter_addons_filter_addons($views) { |
|
212 | 211 | |
213 | 212 | global $status, $plugins; |
214 | 213 | |
215 | - if ( ! empty( $plugins['give'] ) ) { |
|
214 | + if ( ! empty($plugins['give'])) { |
|
216 | 215 | $class = ''; |
217 | 216 | |
218 | - if ( 'give' === $status ) { |
|
217 | + if ('give' === $status) { |
|
219 | 218 | $class = 'current'; |
220 | 219 | } |
221 | 220 | |
222 | 221 | $views['give'] = sprintf( |
223 | 222 | '<a class="%s" href="plugins.php?plugin_status=give"> %s <span class="count">(%s) </span></a>', |
224 | 223 | $class, |
225 | - __( 'Give', 'give' ), |
|
226 | - count( $plugins['give'] ) |
|
224 | + __('Give', 'give'), |
|
225 | + count($plugins['give']) |
|
227 | 226 | ); |
228 | 227 | } |
229 | 228 | |
230 | 229 | return $views; |
231 | 230 | } |
232 | 231 | |
233 | -add_filter( 'views_plugins', 'give_filter_addons_filter_addons' ); |
|
234 | -add_filter( 'views_plugins-network', 'give_filter_addons_filter_addons' ); |
|
232 | +add_filter('views_plugins', 'give_filter_addons_filter_addons'); |
|
233 | +add_filter('views_plugins-network', 'give_filter_addons_filter_addons'); |
|
235 | 234 | |
236 | 235 | /** |
237 | 236 | * Set the Give as the Main menu when admin click on the Give Menu in Plugin section. |
@@ -242,17 +241,17 @@ discard block |
||
242 | 241 | * |
243 | 242 | * @return mixed |
244 | 243 | */ |
245 | -function give_prepare_filter_addons( $plugins ) { |
|
244 | +function give_prepare_filter_addons($plugins) { |
|
246 | 245 | global $status; |
247 | 246 | |
248 | - if ( isset( $_REQUEST['plugin_status'] ) && 'give' === $_REQUEST['plugin_status'] ) { |
|
247 | + if (isset($_REQUEST['plugin_status']) && 'give' === $_REQUEST['plugin_status']) { |
|
249 | 248 | $status = 'give'; |
250 | 249 | } |
251 | 250 | |
252 | 251 | return $plugins; |
253 | 252 | } |
254 | 253 | |
255 | -add_filter( 'all_plugins', 'give_prepare_filter_addons' ); |
|
254 | +add_filter('all_plugins', 'give_prepare_filter_addons'); |
|
256 | 255 | |
257 | 256 | |
258 | 257 | /** |
@@ -263,26 +262,26 @@ discard block |
||
263 | 262 | * |
264 | 263 | * @since 2.1 |
265 | 264 | */ |
266 | -function give_in_plugin_update_message( $data, $response ) { |
|
265 | +function give_in_plugin_update_message($data, $response) { |
|
267 | 266 | $new_version = $data['new_version']; |
268 | - $current_version_parts = explode( '.', GIVE_VERSION ); |
|
269 | - $new_version_parts = explode( '.', $new_version ); |
|
267 | + $current_version_parts = explode('.', GIVE_VERSION); |
|
268 | + $new_version_parts = explode('.', $new_version); |
|
270 | 269 | |
271 | 270 | // If it is a minor upgrade then return. |
272 | - if ( version_compare( $current_version_parts[0] . '.' . $current_version_parts[1], $new_version_parts[0] . '.' . $new_version_parts[1], '=' ) ) { |
|
271 | + if (version_compare($current_version_parts[0].'.'.$current_version_parts[1], $new_version_parts[0].'.'.$new_version_parts[1], '=')) { |
|
273 | 272 | |
274 | 273 | return; |
275 | 274 | } |
276 | 275 | |
277 | 276 | // Get the upgrade notice from the trunk. |
278 | - $upgrade_notice = give_get_plugin_upgrade_notice( $new_version ); |
|
277 | + $upgrade_notice = give_get_plugin_upgrade_notice($new_version); |
|
279 | 278 | |
280 | 279 | // Display upgrade notice. |
281 | - echo apply_filters( 'give_in_plugin_update_message', $upgrade_notice ? '</p>' . wp_kses_post( $upgrade_notice ) . '<p class="dummy">' : '' ); |
|
280 | + echo apply_filters('give_in_plugin_update_message', $upgrade_notice ? '</p>'.wp_kses_post($upgrade_notice).'<p class="dummy">' : ''); |
|
282 | 281 | } |
283 | 282 | |
284 | 283 | // Display upgrade notice. |
285 | -add_action( 'in_plugin_update_message-' . GIVE_PLUGIN_BASENAME, 'give_in_plugin_update_message', 10, 2 ); |
|
284 | +add_action('in_plugin_update_message-'.GIVE_PLUGIN_BASENAME, 'give_in_plugin_update_message', 10, 2); |
|
286 | 285 | |
287 | 286 | |
288 | 287 | /** |
@@ -296,18 +295,18 @@ discard block |
||
296 | 295 | * |
297 | 296 | * @return string |
298 | 297 | */ |
299 | -function give_get_plugin_upgrade_notice( $new_version ) { |
|
298 | +function give_get_plugin_upgrade_notice($new_version) { |
|
300 | 299 | |
301 | 300 | // Cache the upgrade notice. |
302 | 301 | $transient_name = "give_upgrade_notice_{$new_version}"; |
303 | - $upgrade_notice = get_transient( $transient_name ); |
|
302 | + $upgrade_notice = get_transient($transient_name); |
|
304 | 303 | |
305 | - if ( false === $upgrade_notice ) { |
|
306 | - $response = wp_safe_remote_get( 'https://plugins.svn.wordpress.org/give/trunk/readme.txt' ); |
|
304 | + if (false === $upgrade_notice) { |
|
305 | + $response = wp_safe_remote_get('https://plugins.svn.wordpress.org/give/trunk/readme.txt'); |
|
307 | 306 | |
308 | - if ( ! is_wp_error( $response ) && ! empty( $response['body'] ) ) { |
|
309 | - $upgrade_notice = give_parse_plugin_update_notice( $response['body'], $new_version ); |
|
310 | - set_transient( $transient_name, $upgrade_notice, DAY_IN_SECONDS ); |
|
307 | + if ( ! is_wp_error($response) && ! empty($response['body'])) { |
|
308 | + $upgrade_notice = give_parse_plugin_update_notice($response['body'], $new_version); |
|
309 | + set_transient($transient_name, $upgrade_notice, DAY_IN_SECONDS); |
|
311 | 310 | } |
312 | 311 | } |
313 | 312 | |
@@ -327,46 +326,46 @@ discard block |
||
327 | 326 | * |
328 | 327 | * @return string |
329 | 328 | */ |
330 | -function give_parse_plugin_update_notice( $content, $new_version ) { |
|
331 | - $version_parts = explode( '.', $new_version ); |
|
329 | +function give_parse_plugin_update_notice($content, $new_version) { |
|
330 | + $version_parts = explode('.', $new_version); |
|
332 | 331 | $check_for_notices = array( |
333 | - $version_parts[0] . '.0', |
|
334 | - $version_parts[0] . '.0.0', |
|
335 | - $version_parts[0] . '.' . $version_parts[1] . '.' . '0', |
|
332 | + $version_parts[0].'.0', |
|
333 | + $version_parts[0].'.0.0', |
|
334 | + $version_parts[0].'.'.$version_parts[1].'.'.'0', |
|
336 | 335 | ); |
337 | 336 | |
338 | 337 | // Regex to extract Upgrade notice from the readme.txt file. |
339 | - $notice_regexp = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*' . preg_quote( $new_version ) . '\s*=|$)~Uis'; |
|
338 | + $notice_regexp = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*'.preg_quote($new_version).'\s*=|$)~Uis'; |
|
340 | 339 | |
341 | 340 | $upgrade_notice = ''; |
342 | 341 | |
343 | - foreach ( $check_for_notices as $check_version ) { |
|
344 | - if ( version_compare( GIVE_VERSION, $check_version, '>' ) ) { |
|
342 | + foreach ($check_for_notices as $check_version) { |
|
343 | + if (version_compare(GIVE_VERSION, $check_version, '>')) { |
|
345 | 344 | continue; |
346 | 345 | } |
347 | 346 | |
348 | 347 | $matches = null; |
349 | 348 | |
350 | - if ( preg_match( $notice_regexp, $content, $matches ) ) { |
|
351 | - $notices = (array) preg_split( '~[\r\n]+~', trim( $matches[2] ) ); |
|
349 | + if (preg_match($notice_regexp, $content, $matches)) { |
|
350 | + $notices = (array) preg_split('~[\r\n]+~', trim($matches[2])); |
|
352 | 351 | |
353 | - if ( version_compare( trim( $matches[1] ), $check_version, '=' ) ) { |
|
352 | + if (version_compare(trim($matches[1]), $check_version, '=')) { |
|
354 | 353 | $upgrade_notice .= '<p class="give-plugin-upgrade-notice">'; |
355 | 354 | |
356 | - foreach ( $notices as $index => $line ) { |
|
357 | - $upgrade_notice .= preg_replace( '~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line ); |
|
355 | + foreach ($notices as $index => $line) { |
|
356 | + $upgrade_notice .= preg_replace('~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line); |
|
358 | 357 | } |
359 | 358 | |
360 | 359 | $upgrade_notice .= '</p>'; |
361 | 360 | } |
362 | 361 | |
363 | - if ( ! empty( $upgrade_notice ) ) { |
|
362 | + if ( ! empty($upgrade_notice)) { |
|
364 | 363 | break; |
365 | 364 | } |
366 | 365 | } |
367 | 366 | } |
368 | 367 | |
369 | - return wp_kses_post( $upgrade_notice ); |
|
368 | + return wp_kses_post($upgrade_notice); |
|
370 | 369 | } |
371 | 370 | |
372 | 371 | |
@@ -403,7 +402,7 @@ discard block |
||
403 | 402 | <?php |
404 | 403 | } |
405 | 404 | |
406 | -add_action( 'admin_head', 'give_plugin_notice_css' ); |
|
405 | +add_action('admin_head', 'give_plugin_notice_css'); |
|
407 | 406 | |
408 | 407 | /** |
409 | 408 | * Get list of add-on last activated. |
@@ -413,5 +412,5 @@ discard block |
||
413 | 412 | * @return mixed|array list of recently activated add-on |
414 | 413 | */ |
415 | 414 | function give_get_recently_activated_addons() { |
416 | - return get_option( 'give_recently_activated_addons', array() ); |
|
415 | + return get_option('give_recently_activated_addons', array()); |
|
417 | 416 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -24,10 +24,10 @@ discard block |
||
24 | 24 | */ |
25 | 25 | public function __construct() { |
26 | 26 | |
27 | - $this->shortcode['title'] = esc_html__( 'Donation Receipt', 'give' ); |
|
28 | - $this->shortcode['label'] = esc_html__( 'Donation Receipt', 'give' ); |
|
27 | + $this->shortcode['title'] = esc_html__('Donation Receipt', 'give'); |
|
28 | + $this->shortcode['label'] = esc_html__('Donation Receipt', 'give'); |
|
29 | 29 | |
30 | - parent::__construct( 'give_receipt' ); |
|
30 | + parent::__construct('give_receipt'); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
@@ -40,71 +40,71 @@ discard block |
||
40 | 40 | return array( |
41 | 41 | array( |
42 | 42 | 'type' => 'container', |
43 | - 'html' => sprintf( '<p class="strong">%s</p>', esc_html__( 'Optional settings', 'give' ) ), |
|
43 | + 'html' => sprintf('<p class="strong">%s</p>', esc_html__('Optional settings', 'give')), |
|
44 | 44 | ), |
45 | 45 | array( |
46 | 46 | 'type' => 'listbox', |
47 | 47 | 'name' => 'price', |
48 | - 'label' => esc_html__( 'Show Donation Amount:', 'give' ), |
|
48 | + 'label' => esc_html__('Show Donation Amount:', 'give'), |
|
49 | 49 | 'options' => array( |
50 | - 'false' => esc_html__( 'Hide', 'give' ), |
|
50 | + 'false' => esc_html__('Hide', 'give'), |
|
51 | 51 | ), |
52 | - 'placeholder' => esc_html__( 'Show', 'give' ) |
|
52 | + 'placeholder' => esc_html__('Show', 'give') |
|
53 | 53 | ), |
54 | 54 | array( |
55 | 55 | 'type' => 'listbox', |
56 | 56 | 'name' => 'donor', |
57 | - 'label' => esc_html__( 'Show Donor Name:', 'give' ), |
|
57 | + 'label' => esc_html__('Show Donor Name:', 'give'), |
|
58 | 58 | 'options' => array( |
59 | - 'true' => esc_html__( 'Show', 'give' ), |
|
60 | - 'false' => esc_html__( 'Hide', 'give' ), |
|
59 | + 'true' => esc_html__('Show', 'give'), |
|
60 | + 'false' => esc_html__('Hide', 'give'), |
|
61 | 61 | ), |
62 | - 'placeholder' => esc_html__( 'Show', 'give' ) |
|
62 | + 'placeholder' => esc_html__('Show', 'give') |
|
63 | 63 | ), |
64 | 64 | array( |
65 | 65 | 'type' => 'listbox', |
66 | 66 | 'name' => 'date', |
67 | - 'label' => esc_html__( 'Show Date:', 'give' ), |
|
67 | + 'label' => esc_html__('Show Date:', 'give'), |
|
68 | 68 | 'options' => array( |
69 | - 'false' => esc_html__( 'Hide', 'give' ), |
|
69 | + 'false' => esc_html__('Hide', 'give'), |
|
70 | 70 | ), |
71 | - 'placeholder' => esc_html__( 'Show', 'give' ), |
|
71 | + 'placeholder' => esc_html__('Show', 'give'), |
|
72 | 72 | ), |
73 | 73 | array( |
74 | 74 | 'type' => 'listbox', |
75 | 75 | 'name' => 'payment_key', |
76 | - 'label' => esc_html__( 'Show Payment Key:', 'give' ), |
|
76 | + 'label' => esc_html__('Show Payment Key:', 'give'), |
|
77 | 77 | 'options' => array( |
78 | - 'true' => esc_html__( 'Show', 'give' ), |
|
78 | + 'true' => esc_html__('Show', 'give'), |
|
79 | 79 | ), |
80 | - 'placeholder' => esc_html__( 'Hide', 'give' ), |
|
80 | + 'placeholder' => esc_html__('Hide', 'give'), |
|
81 | 81 | ), |
82 | 82 | array( |
83 | 83 | 'type' => 'listbox', |
84 | 84 | 'name' => 'payment_method', |
85 | - 'label' => esc_html__( 'Show Payment Method:', 'give' ), |
|
85 | + 'label' => esc_html__('Show Payment Method:', 'give'), |
|
86 | 86 | 'options' => array( |
87 | - 'false' => esc_html__( 'Hide', 'give' ), |
|
87 | + 'false' => esc_html__('Hide', 'give'), |
|
88 | 88 | ), |
89 | - 'placeholder' => esc_html__( 'Show', 'give' ), |
|
89 | + 'placeholder' => esc_html__('Show', 'give'), |
|
90 | 90 | ), |
91 | 91 | array( |
92 | 92 | 'type' => 'listbox', |
93 | 93 | 'name' => 'payment_id', |
94 | - 'label' => esc_html__( 'Show Payment ID:', 'give' ), |
|
94 | + 'label' => esc_html__('Show Payment ID:', 'give'), |
|
95 | 95 | 'options' => array( |
96 | - 'false' => esc_html__( 'Hide', 'give' ), |
|
96 | + 'false' => esc_html__('Hide', 'give'), |
|
97 | 97 | ), |
98 | - 'placeholder' => esc_html__( 'Show', 'give' ), |
|
98 | + 'placeholder' => esc_html__('Show', 'give'), |
|
99 | 99 | ), |
100 | 100 | array( |
101 | 101 | 'type' => 'listbox', |
102 | 102 | 'name' => 'company_name', |
103 | - 'label' => esc_html__( 'Company Name:', 'give' ), |
|
103 | + 'label' => esc_html__('Company Name:', 'give'), |
|
104 | 104 | 'options' => array( |
105 | - 'true' => esc_html__( 'Show', 'give' ), |
|
105 | + 'true' => esc_html__('Show', 'give'), |
|
106 | 106 | ), |
107 | - 'placeholder' => esc_html__( 'Hide', 'give' ) |
|
107 | + 'placeholder' => esc_html__('Hide', 'give') |
|
108 | 108 | ), |
109 | 109 | ); |
110 | 110 | } |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if access directly. |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * @return static |
47 | 47 | */ |
48 | 48 | static function get_instance() { |
49 | - if ( null === static::$instance ) { |
|
49 | + if (null === static::$instance) { |
|
50 | 50 | self::$instance = new static(); |
51 | 51 | } |
52 | 52 | |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | * |
65 | 65 | * @return bool |
66 | 66 | */ |
67 | - public static function has_preview( Give_Email_Notification $email ) { |
|
67 | + public static function has_preview(Give_Email_Notification $email) { |
|
68 | 68 | return $email->config['has_preview']; |
69 | 69 | } |
70 | 70 | |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * |
79 | 79 | * @return bool |
80 | 80 | */ |
81 | - public static function has_recipient_field( Give_Email_Notification $email ) { |
|
81 | + public static function has_recipient_field(Give_Email_Notification $email) { |
|
82 | 82 | return $email->config['has_recipient_field']; |
83 | 83 | } |
84 | 84 | |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | * |
93 | 93 | * @return bool |
94 | 94 | */ |
95 | - public static function is_notification_status_editable( Give_Email_Notification $email ) { |
|
95 | + public static function is_notification_status_editable(Give_Email_Notification $email) { |
|
96 | 96 | $user_can_edit = $email->config['notification_status_editable']; |
97 | 97 | |
98 | 98 | return (bool) $user_can_edit; |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | * |
109 | 109 | * @return bool |
110 | 110 | */ |
111 | - public static function is_content_type_editable( Give_Email_Notification $email ) { |
|
111 | + public static function is_content_type_editable(Give_Email_Notification $email) { |
|
112 | 112 | return $email->config['content_type_editable']; |
113 | 113 | } |
114 | 114 | |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | * |
123 | 123 | * @return bool |
124 | 124 | */ |
125 | - public static function is_email_preview_has_header( Give_Email_Notification $email ) { |
|
125 | + public static function is_email_preview_has_header(Give_Email_Notification $email) { |
|
126 | 126 | return $email->config['has_preview_header']; |
127 | 127 | } |
128 | 128 | |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | * |
137 | 137 | * @return bool |
138 | 138 | */ |
139 | - public static function is_email_preview( Give_Email_Notification $email ) { |
|
139 | + public static function is_email_preview(Give_Email_Notification $email) { |
|
140 | 140 | return $email->config['has_preview']; |
141 | 141 | } |
142 | 142 | |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | * |
151 | 151 | * @return bool |
152 | 152 | */ |
153 | - public static function is_show_on_emails_setting_page( Give_Email_Notification $email ){ |
|
153 | + public static function is_show_on_emails_setting_page(Give_Email_Notification $email) { |
|
154 | 154 | return $email->config['show_on_emails_setting_page']; |
155 | 155 | } |
156 | 156 | |
@@ -165,8 +165,8 @@ discard block |
||
165 | 165 | * |
166 | 166 | * @return bool |
167 | 167 | */ |
168 | - public static function can_use_form_email_options( Give_Email_Notification $email, $form_id = null ){ |
|
169 | - return give_is_setting_enabled( give_get_meta( $form_id, '_give_email_options', true ) ); |
|
168 | + public static function can_use_form_email_options(Give_Email_Notification $email, $form_id = null) { |
|
169 | + return give_is_setting_enabled(give_get_meta($form_id, '_give_email_options', true)); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | /** |
@@ -180,13 +180,13 @@ discard block |
||
180 | 180 | * |
181 | 181 | * @return string |
182 | 182 | */ |
183 | - public static function is_email_notification_active( Give_Email_Notification $email, $form_id = null ) { |
|
184 | - $notification_status = $email->get_notification_status( $form_id ); |
|
183 | + public static function is_email_notification_active(Give_Email_Notification $email, $form_id = null) { |
|
184 | + $notification_status = $email->get_notification_status($form_id); |
|
185 | 185 | |
186 | 186 | |
187 | - $notification_status = empty( $form_id ) |
|
188 | - ? give_is_setting_enabled( $notification_status ) |
|
189 | - : give_is_setting_enabled( give_get_option( "{$email->config['id']}_notification", $email->config['notification_status'] ) ) && give_is_setting_enabled( $notification_status, array( 'enabled', 'global' ) ); |
|
187 | + $notification_status = empty($form_id) |
|
188 | + ? give_is_setting_enabled($notification_status) |
|
189 | + : give_is_setting_enabled(give_get_option("{$email->config['id']}_notification", $email->config['notification_status'])) && give_is_setting_enabled($notification_status, array('enabled', 'global')); |
|
190 | 190 | // To check if email notification is active or not on a per-form basis, email notification must be globally active—otherwise it will be considered disabled. |
191 | 191 | |
192 | 192 | /** |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | * |
201 | 201 | * @param bool $notification_status True if notification is enable and false when disable |
202 | 202 | */ |
203 | - return apply_filters( "give_{$email->config['id']}_is_email_notification_active", $notification_status, $email, $form_id ); |
|
203 | + return apply_filters("give_{$email->config['id']}_is_email_notification_active", $notification_status, $email, $form_id); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | /** |
@@ -214,8 +214,8 @@ discard block |
||
214 | 214 | $is_preview = false; |
215 | 215 | |
216 | 216 | if ( |
217 | - current_user_can( 'manage_give_settings' ) |
|
218 | - && ! empty( $_GET['give_action'] ) |
|
217 | + current_user_can('manage_give_settings') |
|
218 | + && ! empty($_GET['give_action']) |
|
219 | 219 | && 'preview_email' === $_GET['give_action'] |
220 | 220 | ) { |
221 | 221 | $is_preview = true; |
@@ -235,8 +235,8 @@ discard block |
||
235 | 235 | $is_preview = false; |
236 | 236 | |
237 | 237 | if ( |
238 | - current_user_can( 'manage_give_settings' ) |
|
239 | - && ! empty( $_GET['give_action'] ) |
|
238 | + current_user_can('manage_give_settings') |
|
239 | + && ! empty($_GET['give_action']) |
|
240 | 240 | && 'send_preview_email' === $_GET['give_action'] |
241 | 241 | ) { |
242 | 242 | $is_preview = true; |
@@ -256,13 +256,13 @@ discard block |
||
256 | 256 | * |
257 | 257 | * @return string |
258 | 258 | */ |
259 | - public static function get_formatted_email_type( $content_type ) { |
|
259 | + public static function get_formatted_email_type($content_type) { |
|
260 | 260 | $email_contents = array( |
261 | - 'text/html' => __( 'HTML', 'give' ), |
|
262 | - 'text/plain' => __( 'Plain', 'give' ), |
|
261 | + 'text/html' => __('HTML', 'give'), |
|
262 | + 'text/plain' => __('Plain', 'give'), |
|
263 | 263 | ); |
264 | 264 | |
265 | - return $email_contents[ $content_type ]; |
|
265 | + return $email_contents[$content_type]; |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | |
@@ -279,41 +279,41 @@ discard block |
||
279 | 279 | * |
280 | 280 | * @return mixed |
281 | 281 | */ |
282 | - public static function get_value( Give_Email_Notification $email, $option_name, $form_id = null, $default = false ) { |
|
282 | + public static function get_value(Give_Email_Notification $email, $option_name, $form_id = null, $default = false) { |
|
283 | 283 | // If form id set then option name can be contain _give_ prefix which is only used for meta key, |
284 | 284 | // So make sure you are using correct option name. |
285 | - $global_option_name = ( 0 === strpos( $option_name, '_give_' ) |
|
286 | - ? str_replace( '_give_', '', $option_name ) |
|
287 | - : $option_name ); |
|
288 | - $option_value = give_get_option( $global_option_name, $default ); |
|
285 | + $global_option_name = (0 === strpos($option_name, '_give_') |
|
286 | + ? str_replace('_give_', '', $option_name) |
|
287 | + : $option_name); |
|
288 | + $option_value = give_get_option($global_option_name, $default); |
|
289 | 289 | |
290 | 290 | if ( |
291 | - ! empty( $form_id ) |
|
291 | + ! empty($form_id) |
|
292 | 292 | && give_is_setting_enabled( |
293 | 293 | give_get_meta( |
294 | 294 | $form_id, |
295 | - Give_Email_Setting_Field::get_prefix( $email, $form_id ) . 'notification', |
|
295 | + Give_Email_Setting_Field::get_prefix($email, $form_id).'notification', |
|
296 | 296 | true, |
297 | 297 | 'global' |
298 | 298 | ) |
299 | 299 | ) |
300 | 300 | ) { |
301 | - $option_value = get_post_meta( $form_id, $option_name, true ); |
|
301 | + $option_value = get_post_meta($form_id, $option_name, true); |
|
302 | 302 | |
303 | 303 | // Get only email field value from recipients setting. |
304 | - if( Give_Email_Setting_Field::get_prefix( $email, $form_id ) . 'recipient' === $option_name ) { |
|
305 | - $option_value = wp_list_pluck( $option_value, 'email' ); |
|
304 | + if (Give_Email_Setting_Field::get_prefix($email, $form_id).'recipient' === $option_name) { |
|
305 | + $option_value = wp_list_pluck($option_value, 'email'); |
|
306 | 306 | } |
307 | 307 | } |
308 | 308 | |
309 | - $option_value = empty( $option_value ) ? $default : $option_value; |
|
309 | + $option_value = empty($option_value) ? $default : $option_value; |
|
310 | 310 | |
311 | 311 | /** |
312 | 312 | * Filter the setting value |
313 | 313 | * |
314 | 314 | * @since 2.0 |
315 | 315 | */ |
316 | - return apply_filters( 'give_email_setting_value', $option_value, $option_name, $email, $form_id, $default ); |
|
316 | + return apply_filters('give_email_setting_value', $option_value, $option_name, $email, $form_id, $default); |
|
317 | 317 | } |
318 | 318 | |
319 | 319 | |
@@ -328,12 +328,12 @@ discard block |
||
328 | 328 | * |
329 | 329 | * @return string |
330 | 330 | */ |
331 | - public static function get_email_logo( $form_id ) { |
|
331 | + public static function get_email_logo($form_id) { |
|
332 | 332 | |
333 | 333 | // Email logo tag. |
334 | - $header_img = $form_id && give_is_setting_enabled( give_get_meta( $form_id, '_give_email_options', true ) ) |
|
335 | - ? give_get_meta( $form_id, '_give_email_logo', true ) |
|
336 | - : give_get_option( 'email_logo', '' ); |
|
334 | + $header_img = $form_id && give_is_setting_enabled(give_get_meta($form_id, '_give_email_options', true)) |
|
335 | + ? give_get_meta($form_id, '_give_email_logo', true) |
|
336 | + : give_get_option('email_logo', ''); |
|
337 | 337 | |
338 | 338 | return $header_img; |
339 | 339 | } |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * @return static |
53 | 53 | */ |
54 | 54 | static function get_instance() { |
55 | - if ( null === static::$instance ) { |
|
55 | + if (null === static::$instance) { |
|
56 | 56 | self::$instance = new static(); |
57 | 57 | } |
58 | 58 | |
@@ -66,31 +66,31 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public function init() { |
68 | 68 | // Load files. |
69 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/emails/ajax-handler.php'; |
|
70 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/emails/class-email-setting-field.php'; |
|
71 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/emails/filters.php'; |
|
69 | + require_once GIVE_PLUGIN_DIR.'includes/admin/emails/ajax-handler.php'; |
|
70 | + require_once GIVE_PLUGIN_DIR.'includes/admin/emails/class-email-setting-field.php'; |
|
71 | + require_once GIVE_PLUGIN_DIR.'includes/admin/emails/filters.php'; |
|
72 | 72 | |
73 | 73 | // Load email notifications. |
74 | 74 | $this->add_emails_notifications(); |
75 | 75 | |
76 | - add_filter( 'give_metabox_form_data_settings', array( $this, 'add_metabox_setting_fields' ), 10, 2 ); |
|
77 | - add_action( 'init', array( $this, 'preview_email' ) ); |
|
78 | - add_action( 'init', array( $this, 'send_preview_email' ) ); |
|
79 | - add_action( 'init', array( $this, 'validate_settings' ) ); |
|
76 | + add_filter('give_metabox_form_data_settings', array($this, 'add_metabox_setting_fields'), 10, 2); |
|
77 | + add_action('init', array($this, 'preview_email')); |
|
78 | + add_action('init', array($this, 'send_preview_email')); |
|
79 | + add_action('init', array($this, 'validate_settings')); |
|
80 | 80 | |
81 | 81 | /* @var Give_Email_Notification $email */ |
82 | - foreach ( $this->get_email_notifications() as $email ) { |
|
82 | + foreach ($this->get_email_notifications() as $email) { |
|
83 | 83 | // Setup email section. |
84 | - if( Give_Email_Notification_Util::is_show_on_emails_setting_page( $email ) ) { |
|
85 | - add_filter( 'give_get_sections_emails', array( $email, 'add_section' ) ); |
|
86 | - add_filter( "give_hide_section_{$email->config['id']}_on_emails_page", array( $email, 'hide_section' ) ); |
|
84 | + if (Give_Email_Notification_Util::is_show_on_emails_setting_page($email)) { |
|
85 | + add_filter('give_get_sections_emails', array($email, 'add_section')); |
|
86 | + add_filter("give_hide_section_{$email->config['id']}_on_emails_page", array($email, 'hide_section')); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | // Setup email preview. |
90 | - if ( Give_Email_Notification_Util::is_email_preview_has_header( $email ) ) { |
|
91 | - add_action( "give_{$email->config['id']}_email_preview", array( $this, 'email_preview_header' ) ); |
|
92 | - add_filter( "give_{$email->config['id']}_email_preview_data", array( $this, 'email_preview_data' ) ); |
|
93 | - add_filter( "give_{$email->config['id']}_email_preview_message", array( $this, 'email_preview_message' ), 1, 2 ); |
|
90 | + if (Give_Email_Notification_Util::is_email_preview_has_header($email)) { |
|
91 | + add_action("give_{$email->config['id']}_email_preview", array($this, 'email_preview_header')); |
|
92 | + add_filter("give_{$email->config['id']}_email_preview_data", array($this, 'email_preview_data')); |
|
93 | + add_filter("give_{$email->config['id']}_email_preview_message", array($this, 'email_preview_message'), 1, 2); |
|
94 | 94 | } |
95 | 95 | } |
96 | 96 | } |
@@ -107,63 +107,63 @@ discard block |
||
107 | 107 | * |
108 | 108 | * @return array |
109 | 109 | */ |
110 | - public function add_metabox_setting_fields( $settings, $post_id ) { |
|
110 | + public function add_metabox_setting_fields($settings, $post_id) { |
|
111 | 111 | $emails = $this->get_email_notifications(); |
112 | 112 | |
113 | 113 | // Bailout. |
114 | - if ( empty( $emails ) ) { |
|
114 | + if (empty($emails)) { |
|
115 | 115 | return $settings; |
116 | 116 | } |
117 | 117 | |
118 | 118 | // Email notification setting. |
119 | 119 | $settings['email_notification_options'] = array( |
120 | 120 | 'id' => 'email_notification_options', |
121 | - 'title' => __( 'Email Notifications', 'give' ), |
|
121 | + 'title' => __('Email Notifications', 'give'), |
|
122 | 122 | 'icon-html' => '<span class="dashicons dashicons-email-alt"></span>', |
123 | 123 | 'fields' => array( |
124 | 124 | array( |
125 | - 'name' => __( 'Email Options', 'give' ), |
|
125 | + 'name' => __('Email Options', 'give'), |
|
126 | 126 | 'id' => '_give_email_options', |
127 | 127 | 'type' => 'radio_inline', |
128 | 128 | 'default' => 'global', |
129 | 129 | 'options' => array( |
130 | - 'global' => __( 'Global Options' ), |
|
131 | - 'enabled' => __( 'Customize', 'give' ), |
|
130 | + 'global' => __('Global Options'), |
|
131 | + 'enabled' => __('Customize', 'give'), |
|
132 | 132 | ), |
133 | 133 | ), |
134 | 134 | array( |
135 | 135 | 'id' => '_give_email_template', |
136 | - 'name' => esc_html__( 'Email Template', 'give' ), |
|
137 | - 'desc' => esc_html__( 'Choose your template from the available registered template types.', 'give' ), |
|
136 | + 'name' => esc_html__('Email Template', 'give'), |
|
137 | + 'desc' => esc_html__('Choose your template from the available registered template types.', 'give'), |
|
138 | 138 | 'type' => 'select', |
139 | 139 | 'default' => 'default', |
140 | 140 | 'options' => give_get_email_templates(), |
141 | 141 | ), |
142 | 142 | array( |
143 | 143 | 'id' => '_give_email_logo', |
144 | - 'name' => esc_html__( 'Logo', 'give' ), |
|
145 | - 'desc' => esc_html__( 'Upload or choose a logo to be displayed at the top of the donation receipt emails. Displayed on HTML emails only.', 'give' ), |
|
144 | + 'name' => esc_html__('Logo', 'give'), |
|
145 | + 'desc' => esc_html__('Upload or choose a logo to be displayed at the top of the donation receipt emails. Displayed on HTML emails only.', 'give'), |
|
146 | 146 | 'type' => 'file', |
147 | 147 | ), |
148 | 148 | array( |
149 | 149 | 'id' => '_give_from_name', |
150 | - 'name' => esc_html__( 'From Name', 'give' ), |
|
151 | - 'desc' => esc_html__( 'The name which appears in the "From" field in all Give donation emails.', 'give' ), |
|
152 | - 'default' => get_bloginfo( 'name' ), |
|
150 | + 'name' => esc_html__('From Name', 'give'), |
|
151 | + 'desc' => esc_html__('The name which appears in the "From" field in all Give donation emails.', 'give'), |
|
152 | + 'default' => get_bloginfo('name'), |
|
153 | 153 | 'type' => 'text', |
154 | 154 | ), |
155 | 155 | array( |
156 | 156 | 'id' => '_give_from_email', |
157 | - 'name' => esc_html__( 'From Email', 'give' ), |
|
158 | - 'desc' => esc_html__( 'Email address from which all Give emails are sent from. This will act as the "from" and "reply-to" email address.', 'give' ), |
|
159 | - 'default' => get_bloginfo( 'admin_email' ), |
|
157 | + 'name' => esc_html__('From Email', 'give'), |
|
158 | + 'desc' => esc_html__('Email address from which all Give emails are sent from. This will act as the "from" and "reply-to" email address.', 'give'), |
|
159 | + 'default' => get_bloginfo('admin_email'), |
|
160 | 160 | 'type' => 'text', |
161 | 161 | ), |
162 | 162 | array( |
163 | 163 | 'name' => 'email_notification_docs', |
164 | 164 | 'type' => 'docs_link', |
165 | 165 | 'url' => 'http://docs.givewp.com/email-notification', |
166 | - 'title' => __( 'Email Notification', 'give' ), |
|
166 | + 'title' => __('Email Notification', 'give'), |
|
167 | 167 | ), |
168 | 168 | ), |
169 | 169 | |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | * |
173 | 173 | * @since 2.0 |
174 | 174 | */ |
175 | - 'sub-fields' => apply_filters( 'give_email_notification_options_metabox_fields', array(), $post_id ), |
|
175 | + 'sub-fields' => apply_filters('give_email_notification_options_metabox_fields', array(), $post_id), |
|
176 | 176 | ); |
177 | 177 | |
178 | 178 | return $settings; |
@@ -186,13 +186,13 @@ discard block |
||
186 | 186 | */ |
187 | 187 | private function add_emails_notifications() { |
188 | 188 | $this->emails = array( |
189 | - include GIVE_PLUGIN_DIR . 'includes/admin/emails/class-new-donation-email.php', |
|
190 | - include GIVE_PLUGIN_DIR . 'includes/admin/emails/class-donation-receipt-email.php', |
|
191 | - include GIVE_PLUGIN_DIR . 'includes/admin/emails/class-new-offline-donation-email.php', |
|
192 | - include GIVE_PLUGIN_DIR . 'includes/admin/emails/class-offline-donation-instruction-email.php', |
|
193 | - include GIVE_PLUGIN_DIR . 'includes/admin/emails/class-new-donor-register-email.php', |
|
194 | - include GIVE_PLUGIN_DIR . 'includes/admin/emails/class-donor-register-email.php', |
|
195 | - include GIVE_PLUGIN_DIR . 'includes/admin/emails/class-email-access-email.php', |
|
189 | + include GIVE_PLUGIN_DIR.'includes/admin/emails/class-new-donation-email.php', |
|
190 | + include GIVE_PLUGIN_DIR.'includes/admin/emails/class-donation-receipt-email.php', |
|
191 | + include GIVE_PLUGIN_DIR.'includes/admin/emails/class-new-offline-donation-email.php', |
|
192 | + include GIVE_PLUGIN_DIR.'includes/admin/emails/class-offline-donation-instruction-email.php', |
|
193 | + include GIVE_PLUGIN_DIR.'includes/admin/emails/class-new-donor-register-email.php', |
|
194 | + include GIVE_PLUGIN_DIR.'includes/admin/emails/class-donor-register-email.php', |
|
195 | + include GIVE_PLUGIN_DIR.'includes/admin/emails/class-email-access-email.php', |
|
196 | 196 | ); |
197 | 197 | |
198 | 198 | /** |
@@ -200,15 +200,15 @@ discard block |
||
200 | 200 | * |
201 | 201 | * @since 2.0 |
202 | 202 | */ |
203 | - $this->emails = apply_filters( 'give_email_notifications', $this->emails, $this ); |
|
203 | + $this->emails = apply_filters('give_email_notifications', $this->emails, $this); |
|
204 | 204 | |
205 | 205 | // Bailout. |
206 | - if ( empty( $this->emails ) ) { |
|
206 | + if (empty($this->emails)) { |
|
207 | 207 | return; |
208 | 208 | } |
209 | 209 | |
210 | 210 | // Initiate email notifications. |
211 | - foreach ( $this->emails as $email ) { |
|
211 | + foreach ($this->emails as $email) { |
|
212 | 212 | $email->init(); |
213 | 213 | } |
214 | 214 | } |
@@ -235,42 +235,42 @@ discard block |
||
235 | 235 | */ |
236 | 236 | public function preview_email() { |
237 | 237 | // Bailout. |
238 | - if ( ! Give_Email_Notification_Util::can_preview_email() ) { |
|
238 | + if ( ! Give_Email_Notification_Util::can_preview_email()) { |
|
239 | 239 | return false; |
240 | 240 | } |
241 | 241 | |
242 | 242 | // Security check. |
243 | - give_validate_nonce( $_GET['_wpnonce'], 'give-preview-email' ); |
|
243 | + give_validate_nonce($_GET['_wpnonce'], 'give-preview-email'); |
|
244 | 244 | |
245 | 245 | // Get email type. |
246 | - $email_type = isset( $_GET['email_type'] ) ? esc_attr( $_GET['email_type'] ) : ''; |
|
246 | + $email_type = isset($_GET['email_type']) ? esc_attr($_GET['email_type']) : ''; |
|
247 | 247 | |
248 | 248 | /* @var Give_Email_Notification $email */ |
249 | - foreach ( $this->get_email_notifications() as $email ) { |
|
250 | - if ( $email_type !== $email->config['id'] ) { |
|
249 | + foreach ($this->get_email_notifications() as $email) { |
|
250 | + if ($email_type !== $email->config['id']) { |
|
251 | 251 | continue; |
252 | 252 | } |
253 | 253 | |
254 | 254 | // Set form id. |
255 | - $form_id = empty( $_GET['form_id'] ) ? null : absint( $_GET['form_id'] ); |
|
255 | + $form_id = empty($_GET['form_id']) ? null : absint($_GET['form_id']); |
|
256 | 256 | |
257 | 257 | // Call setup email data to apply filter and other thing to email. |
258 | 258 | $email->setup_email_data(); |
259 | 259 | |
260 | 260 | // Decode message. |
261 | - $email_message = $email->preview_email_template_tags( $email->get_email_message( $form_id ) ); |
|
261 | + $email_message = $email->preview_email_template_tags($email->get_email_message($form_id)); |
|
262 | 262 | |
263 | 263 | // Set email template. |
264 | 264 | Give()->emails->html = true; |
265 | - Give()->emails->__set( 'template', $email->get_email_template( $form_id ) ); |
|
265 | + Give()->emails->__set('template', $email->get_email_template($form_id)); |
|
266 | 266 | Give()->emails->form_id = $form_id; |
267 | 267 | |
268 | - if ( 'text/plain' === $email->config['content_type'] ) { |
|
268 | + if ('text/plain' === $email->config['content_type']) { |
|
269 | 269 | // Give()->emails->__set( 'html', false ); |
270 | - Give()->emails->__set( 'template', 'none' ); |
|
270 | + Give()->emails->__set('template', 'none'); |
|
271 | 271 | } |
272 | 272 | |
273 | - if ( $email_message = Give()->emails->build_email( $email_message ) ) { |
|
273 | + if ($email_message = Give()->emails->build_email($email_message)) { |
|
274 | 274 | |
275 | 275 | /** |
276 | 276 | * Filter the email preview data |
@@ -279,14 +279,14 @@ discard block |
||
279 | 279 | * |
280 | 280 | * @param array |
281 | 281 | */ |
282 | - $email_preview_data = apply_filters( "give_{$email_type}_email_preview_data", array() ); |
|
282 | + $email_preview_data = apply_filters("give_{$email_type}_email_preview_data", array()); |
|
283 | 283 | |
284 | 284 | /** |
285 | 285 | * Fire the give_{$email_type}_email_preview action |
286 | 286 | * |
287 | 287 | * @since 2.0 |
288 | 288 | */ |
289 | - do_action( "give_{$email_type}_email_preview", $email ); |
|
289 | + do_action("give_{$email_type}_email_preview", $email); |
|
290 | 290 | |
291 | 291 | /** |
292 | 292 | * Filter the email message |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | * @param array $email_preview_data |
298 | 298 | * @param Give_Email_Notification $email |
299 | 299 | */ |
300 | - echo apply_filters( "give_{$email_type}_email_preview_message", $email_message, $email_preview_data, $email ); |
|
300 | + echo apply_filters("give_{$email_type}_email_preview_message", $email_message, $email_preview_data, $email); |
|
301 | 301 | |
302 | 302 | exit(); |
303 | 303 | } |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | * |
314 | 314 | * @param Give_Email_Notification $email |
315 | 315 | */ |
316 | - public function email_preview_header( $email ) { |
|
316 | + public function email_preview_header($email) { |
|
317 | 317 | /** |
318 | 318 | * Filter the all email preview headers. |
319 | 319 | * |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | * |
322 | 322 | * @param Give_Email_Notification $email |
323 | 323 | */ |
324 | - $email_preview_header = apply_filters( 'give_email_preview_header', give_get_preview_email_header(), $email ); |
|
324 | + $email_preview_header = apply_filters('give_email_preview_header', give_get_preview_email_header(), $email); |
|
325 | 325 | |
326 | 326 | echo $email_preview_header; |
327 | 327 | } |
@@ -336,9 +336,9 @@ discard block |
||
336 | 336 | * |
337 | 337 | * @return array |
338 | 338 | */ |
339 | - public function email_preview_data( $email_preview_data ) { |
|
340 | - $email_preview_data['payment_id'] = absint( give_check_variable( give_clean( $_GET ), 'isset', 0, 'preview_id' ) ); |
|
341 | - $email_preview_data['user_id'] = absint( give_check_variable( give_clean( $_GET ), 'isset', 0, 'user_id' ) ); |
|
339 | + public function email_preview_data($email_preview_data) { |
|
340 | + $email_preview_data['payment_id'] = absint(give_check_variable(give_clean($_GET), 'isset', 0, 'preview_id')); |
|
341 | + $email_preview_data['user_id'] = absint(give_check_variable(give_clean($_GET), 'isset', 0, 'user_id')); |
|
342 | 342 | |
343 | 343 | return $email_preview_data; |
344 | 344 | } |
@@ -354,12 +354,12 @@ discard block |
||
354 | 354 | * |
355 | 355 | * @return string |
356 | 356 | */ |
357 | - public function email_preview_message( $email_message, $email_preview_data ) { |
|
357 | + public function email_preview_message($email_message, $email_preview_data) { |
|
358 | 358 | if ( |
359 | - ! empty( $email_preview_data['payment_id'] ) |
|
360 | - || ! empty( $email_preview_data['user_id'] ) |
|
359 | + ! empty($email_preview_data['payment_id']) |
|
360 | + || ! empty($email_preview_data['user_id']) |
|
361 | 361 | ) { |
362 | - $email_message = give_do_email_tags( $email_message, $email_preview_data ); |
|
362 | + $email_message = give_do_email_tags($email_message, $email_preview_data); |
|
363 | 363 | } |
364 | 364 | |
365 | 365 | return $email_message; |
@@ -374,26 +374,26 @@ discard block |
||
374 | 374 | */ |
375 | 375 | public function send_preview_email() { |
376 | 376 | // Bailout. |
377 | - if ( ! Give_Email_Notification_Util::can_send_preview_email() ) { |
|
377 | + if ( ! Give_Email_Notification_Util::can_send_preview_email()) { |
|
378 | 378 | return false; |
379 | 379 | } |
380 | 380 | |
381 | 381 | // Security check. |
382 | - give_validate_nonce( $_GET['_wpnonce'], 'give-send-preview-email' ); |
|
382 | + give_validate_nonce($_GET['_wpnonce'], 'give-send-preview-email'); |
|
383 | 383 | |
384 | 384 | // Get email type. |
385 | - $email_type = give_check_variable( give_clean( $_GET ), 'isset', '', 'email_type' ); |
|
385 | + $email_type = give_check_variable(give_clean($_GET), 'isset', '', 'email_type'); |
|
386 | 386 | |
387 | 387 | /* @var Give_Email_Notification $email */ |
388 | - foreach ( $this->get_email_notifications() as $email ) { |
|
389 | - if ( $email_type === $email->config['id'] && Give_Email_Notification_Util::is_email_preview( $email ) ) { |
|
388 | + foreach ($this->get_email_notifications() as $email) { |
|
389 | + if ($email_type === $email->config['id'] && Give_Email_Notification_Util::is_email_preview($email)) { |
|
390 | 390 | $email->send_preview_email(); |
391 | 391 | break; |
392 | 392 | } |
393 | 393 | } |
394 | 394 | |
395 | 395 | // Remove the test email query arg. |
396 | - wp_redirect( remove_query_arg( 'give_action' ) ); |
|
396 | + wp_redirect(remove_query_arg('give_action')); |
|
397 | 397 | exit; |
398 | 398 | } |
399 | 399 | |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | * @access public |
406 | 406 | */ |
407 | 407 | public function load() { |
408 | - add_action( 'init', array( $this, 'init' ), -1 ); |
|
408 | + add_action('init', array($this, 'init'), -1); |
|
409 | 409 | } |
410 | 410 | |
411 | 411 | |
@@ -420,7 +420,7 @@ discard block |
||
420 | 420 | if ( |
421 | 421 | ! Give_Admin_Settings::is_saving_settings() || |
422 | 422 | 'emails' !== give_get_current_setting_tab() || |
423 | - ! isset( $_GET['section'] ) |
|
423 | + ! isset($_GET['section']) |
|
424 | 424 | ) { |
425 | 425 | return; |
426 | 426 | } |
@@ -428,18 +428,18 @@ discard block |
||
428 | 428 | // Get email type. |
429 | 429 | $email_type = give_get_current_setting_section(); |
430 | 430 | |
431 | - if ( ! empty( $_POST["{$email_type}_recipient"] ) ) { |
|
432 | - $_POST["{$email_type}_recipient"] = array_unique( array_filter( $_POST["{$email_type}_recipient"] ) ); |
|
431 | + if ( ! empty($_POST["{$email_type}_recipient"])) { |
|
432 | + $_POST["{$email_type}_recipient"] = array_unique(array_filter($_POST["{$email_type}_recipient"])); |
|
433 | 433 | } |
434 | 434 | } |
435 | 435 | } |
436 | 436 | |
437 | 437 | // Helper class. |
438 | -require_once GIVE_PLUGIN_DIR . 'includes/admin/emails/abstract-email-notification.php'; |
|
439 | -require_once GIVE_PLUGIN_DIR . 'includes/admin/emails/class-email-notification-util.php'; |
|
438 | +require_once GIVE_PLUGIN_DIR.'includes/admin/emails/abstract-email-notification.php'; |
|
439 | +require_once GIVE_PLUGIN_DIR.'includes/admin/emails/class-email-notification-util.php'; |
|
440 | 440 | |
441 | 441 | // Add backward compatibility. |
442 | -require_once GIVE_PLUGIN_DIR . 'includes/admin/emails/backward-compatibility.php'; |
|
442 | +require_once GIVE_PLUGIN_DIR.'includes/admin/emails/backward-compatibility.php'; |
|
443 | 443 | |
444 | 444 | /** |
445 | 445 | * Initialize functionality. |
@@ -46,24 +46,24 @@ discard block |
||
46 | 46 | */ |
47 | 47 | function __construct() { |
48 | 48 | $this->metabox_id = 'give-metabox-form-data'; |
49 | - $this->metabox_label = __( 'Donation Form Options', 'give' ); |
|
49 | + $this->metabox_label = __('Donation Form Options', 'give'); |
|
50 | 50 | |
51 | 51 | // Setup. |
52 | - add_action( 'admin_init', array( $this, 'setup' ) ); |
|
52 | + add_action('admin_init', array($this, 'setup')); |
|
53 | 53 | |
54 | 54 | // Add metabox. |
55 | - add_action( 'add_meta_boxes', array( $this, 'add_meta_box' ), 10 ); |
|
55 | + add_action('add_meta_boxes', array($this, 'add_meta_box'), 10); |
|
56 | 56 | |
57 | 57 | // Save form meta. |
58 | - add_action( 'save_post_give_forms', array( $this, 'save' ), 10, 2 ); |
|
58 | + add_action('save_post_give_forms', array($this, 'save'), 10, 2); |
|
59 | 59 | |
60 | 60 | // cmb2 old setting loaders. |
61 | 61 | // add_filter( 'give_metabox_form_data_settings', array( $this, 'cmb2_metabox_settings' ) ); |
62 | 62 | // Add offline donations options. |
63 | - add_filter( 'give_metabox_form_data_settings', array( $this, 'add_offline_donations_setting_tab' ), 0, 1 ); |
|
63 | + add_filter('give_metabox_form_data_settings', array($this, 'add_offline_donations_setting_tab'), 0, 1); |
|
64 | 64 | |
65 | 65 | // Maintain active tab query parameter after save. |
66 | - add_filter( 'redirect_post_location', array( $this, 'maintain_active_tab' ), 10, 2 ); |
|
66 | + add_filter('redirect_post_location', array($this, 'maintain_active_tab'), 10, 2); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | */ |
88 | 88 | function get_settings() { |
89 | 89 | $post_id = give_get_admin_post_id(); |
90 | - $price_placeholder = give_format_decimal( '1.00', false, false ); |
|
90 | + $price_placeholder = give_format_decimal('1.00', false, false); |
|
91 | 91 | |
92 | 92 | // Start with an underscore to hide fields from custom fields list |
93 | 93 | $prefix = '_give_'; |
@@ -96,27 +96,27 @@ discard block |
||
96 | 96 | /** |
97 | 97 | * Repeatable Field Groups |
98 | 98 | */ |
99 | - 'form_field_options' => apply_filters( 'give_forms_field_options', array( |
|
99 | + 'form_field_options' => apply_filters('give_forms_field_options', array( |
|
100 | 100 | 'id' => 'form_field_options', |
101 | - 'title' => __( 'Donation Options', 'give' ), |
|
101 | + 'title' => __('Donation Options', 'give'), |
|
102 | 102 | 'icon-html' => '<span class="give-icon give-icon-heart"></span>', |
103 | - 'fields' => apply_filters( 'give_forms_donation_form_metabox_fields', array( |
|
103 | + 'fields' => apply_filters('give_forms_donation_form_metabox_fields', array( |
|
104 | 104 | // Donation Option. |
105 | 105 | array( |
106 | - 'name' => __( 'Donation Option', 'give' ), |
|
107 | - 'description' => __( 'Do you want this form to have one set donation price or multiple levels (for example, $10, $20, $50)?', 'give' ), |
|
108 | - 'id' => $prefix . 'price_option', |
|
106 | + 'name' => __('Donation Option', 'give'), |
|
107 | + 'description' => __('Do you want this form to have one set donation price or multiple levels (for example, $10, $20, $50)?', 'give'), |
|
108 | + 'id' => $prefix.'price_option', |
|
109 | 109 | 'type' => 'radio_inline', |
110 | 110 | 'default' => 'multi', |
111 | - 'options' => apply_filters( 'give_forms_price_options', array( |
|
112 | - 'multi' => __( 'Multi-level Donation', 'give' ), |
|
113 | - 'set' => __( 'Set Donation', 'give' ), |
|
114 | - ) ), |
|
111 | + 'options' => apply_filters('give_forms_price_options', array( |
|
112 | + 'multi' => __('Multi-level Donation', 'give'), |
|
113 | + 'set' => __('Set Donation', 'give'), |
|
114 | + )), |
|
115 | 115 | ), |
116 | 116 | array( |
117 | - 'name' => __( 'Set Donation', 'give' ), |
|
118 | - 'description' => __( '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' ), |
|
119 | - 'id' => $prefix . 'set_price', |
|
117 | + 'name' => __('Set Donation', 'give'), |
|
118 | + 'description' => __('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'), |
|
119 | + 'id' => $prefix.'set_price', |
|
120 | 120 | 'type' => 'text_small', |
121 | 121 | 'data_type' => 'price', |
122 | 122 | 'attributes' => array( |
@@ -126,34 +126,34 @@ discard block |
||
126 | 126 | ), |
127 | 127 | // Display Style. |
128 | 128 | array( |
129 | - 'name' => __( 'Display Style', 'give' ), |
|
130 | - 'description' => __( 'Set how the donations levels will display on the form.', 'give' ), |
|
131 | - 'id' => $prefix . 'display_style', |
|
129 | + 'name' => __('Display Style', 'give'), |
|
130 | + 'description' => __('Set how the donations levels will display on the form.', 'give'), |
|
131 | + 'id' => $prefix.'display_style', |
|
132 | 132 | 'type' => 'radio_inline', |
133 | 133 | 'default' => 'buttons', |
134 | 134 | 'options' => array( |
135 | - 'buttons' => __( 'Buttons', 'give' ), |
|
136 | - 'radios' => __( 'Radios', 'give' ), |
|
137 | - 'dropdown' => __( 'Dropdown', 'give' ), |
|
135 | + 'buttons' => __('Buttons', 'give'), |
|
136 | + 'radios' => __('Radios', 'give'), |
|
137 | + 'dropdown' => __('Dropdown', 'give'), |
|
138 | 138 | ), |
139 | 139 | 'wrapper_class' => 'give-hidden', |
140 | 140 | ), |
141 | 141 | // Custom Amount. |
142 | 142 | array( |
143 | - 'name' => __( 'Custom Amount', 'give' ), |
|
144 | - 'description' => __( 'Do you want the user to be able to input their own donation amount?', 'give' ), |
|
145 | - 'id' => $prefix . 'custom_amount', |
|
143 | + 'name' => __('Custom Amount', 'give'), |
|
144 | + 'description' => __('Do you want the user to be able to input their own donation amount?', 'give'), |
|
145 | + 'id' => $prefix.'custom_amount', |
|
146 | 146 | 'type' => 'radio_inline', |
147 | 147 | 'default' => 'disabled', |
148 | 148 | 'options' => array( |
149 | - 'enabled' => __( 'Enabled', 'give' ), |
|
150 | - 'disabled' => __( 'Disabled', 'give' ), |
|
149 | + 'enabled' => __('Enabled', 'give'), |
|
150 | + 'disabled' => __('Disabled', 'give'), |
|
151 | 151 | ), |
152 | 152 | ), |
153 | 153 | array( |
154 | - 'name' => __( 'Donation Limit', 'give' ), |
|
155 | - 'description' => __( 'Set the minimum and maximum amount for all gateways.', 'give' ), |
|
156 | - 'id' => $prefix . 'custom_amount_range', |
|
154 | + 'name' => __('Donation Limit', 'give'), |
|
155 | + 'description' => __('Set the minimum and maximum amount for all gateways.', 'give'), |
|
156 | + 'id' => $prefix.'custom_amount_range', |
|
157 | 157 | 'type' => 'donation_limit', |
158 | 158 | 'wrapper_class' => 'give-hidden', |
159 | 159 | 'data_type' => 'price', |
@@ -162,43 +162,43 @@ discard block |
||
162 | 162 | 'class' => 'give-money-field', |
163 | 163 | ), |
164 | 164 | 'options' => array( |
165 | - 'display_label' => __( 'Donation Limits: ', 'give' ), |
|
166 | - 'minimum' => give_format_decimal( '1.00', false, false ), |
|
167 | - 'maximum' => give_format_decimal( '999999.99', false, false ), |
|
165 | + 'display_label' => __('Donation Limits: ', 'give'), |
|
166 | + 'minimum' => give_format_decimal('1.00', false, false), |
|
167 | + 'maximum' => give_format_decimal('999999.99', false, false), |
|
168 | 168 | ), |
169 | 169 | ), |
170 | 170 | array( |
171 | - 'name' => __( 'Custom Amount Text', 'give' ), |
|
172 | - 'description' => __( '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' ), |
|
173 | - 'id' => $prefix . 'custom_amount_text', |
|
171 | + 'name' => __('Custom Amount Text', 'give'), |
|
172 | + 'description' => __('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'), |
|
173 | + 'id' => $prefix.'custom_amount_text', |
|
174 | 174 | 'type' => 'text_medium', |
175 | 175 | 'attributes' => array( |
176 | 176 | 'rows' => 3, |
177 | - 'placeholder' => __( 'Give a Custom Amount', 'give' ), |
|
177 | + 'placeholder' => __('Give a Custom Amount', 'give'), |
|
178 | 178 | ), |
179 | 179 | 'wrapper_class' => 'give-hidden', |
180 | 180 | ), |
181 | 181 | // Donation Levels. |
182 | 182 | array( |
183 | - 'id' => $prefix . 'donation_levels', |
|
183 | + 'id' => $prefix.'donation_levels', |
|
184 | 184 | 'type' => 'group', |
185 | 185 | 'options' => array( |
186 | - 'add_button' => __( 'Add Level', 'give' ), |
|
187 | - 'header_title' => __( 'Donation Level', 'give' ), |
|
186 | + 'add_button' => __('Add Level', 'give'), |
|
187 | + 'header_title' => __('Donation Level', 'give'), |
|
188 | 188 | 'remove_button' => '<span class="dashicons dashicons-no"></span>', |
189 | 189 | ), |
190 | 190 | 'wrapper_class' => 'give-hidden', |
191 | 191 | // Fields array works the same, except id's only need to be unique for this group. |
192 | 192 | // Prefix is not needed. |
193 | - 'fields' => apply_filters( 'give_donation_levels_table_row', array( |
|
193 | + 'fields' => apply_filters('give_donation_levels_table_row', array( |
|
194 | 194 | array( |
195 | - 'name' => __( 'ID', 'give' ), |
|
196 | - 'id' => $prefix . 'id', |
|
195 | + 'name' => __('ID', 'give'), |
|
196 | + 'id' => $prefix.'id', |
|
197 | 197 | 'type' => 'levels_id', |
198 | 198 | ), |
199 | 199 | array( |
200 | - 'name' => __( 'Amount', 'give' ), |
|
201 | - 'id' => $prefix . 'amount', |
|
200 | + 'name' => __('Amount', 'give'), |
|
201 | + 'id' => $prefix.'amount', |
|
202 | 202 | 'type' => 'text_small', |
203 | 203 | 'data_type' => 'price', |
204 | 204 | 'attributes' => array( |
@@ -207,126 +207,126 @@ discard block |
||
207 | 207 | ), |
208 | 208 | ), |
209 | 209 | array( |
210 | - 'name' => __( 'Text', 'give' ), |
|
211 | - 'id' => $prefix . 'text', |
|
210 | + 'name' => __('Text', 'give'), |
|
211 | + 'id' => $prefix.'text', |
|
212 | 212 | 'type' => 'text', |
213 | 213 | 'attributes' => array( |
214 | - 'placeholder' => __( 'Donation Level', 'give' ), |
|
214 | + 'placeholder' => __('Donation Level', 'give'), |
|
215 | 215 | 'class' => 'give-multilevel-text-field', |
216 | 216 | ), |
217 | 217 | ), |
218 | 218 | array( |
219 | - 'name' => __( 'Default', 'give' ), |
|
220 | - 'id' => $prefix . 'default', |
|
219 | + 'name' => __('Default', 'give'), |
|
220 | + 'id' => $prefix.'default', |
|
221 | 221 | 'type' => 'give_default_radio_inline', |
222 | 222 | ), |
223 | - ) ), |
|
223 | + )), |
|
224 | 224 | ), |
225 | 225 | array( |
226 | 226 | 'name' => 'donation_options_docs', |
227 | 227 | 'type' => 'docs_link', |
228 | 228 | 'url' => 'http://docs.givewp.com/form-donation-options', |
229 | - 'title' => __( 'Donation Options', 'give' ), |
|
229 | + 'title' => __('Donation Options', 'give'), |
|
230 | 230 | ), |
231 | 231 | ), |
232 | 232 | $post_id |
233 | 233 | ), |
234 | - ) ), |
|
234 | + )), |
|
235 | 235 | |
236 | 236 | /** |
237 | 237 | * Display Options |
238 | 238 | */ |
239 | - 'form_display_options' => apply_filters( 'give_form_display_options', array( |
|
239 | + 'form_display_options' => apply_filters('give_form_display_options', array( |
|
240 | 240 | 'id' => 'form_display_options', |
241 | - 'title' => __( 'Form Display', 'give' ), |
|
241 | + 'title' => __('Form Display', 'give'), |
|
242 | 242 | 'icon-html' => '<span class="give-icon give-icon-display"></span>', |
243 | - 'fields' => apply_filters( 'give_forms_display_options_metabox_fields', array( |
|
243 | + 'fields' => apply_filters('give_forms_display_options_metabox_fields', array( |
|
244 | 244 | array( |
245 | - 'name' => __( 'Display Options', 'give' ), |
|
246 | - 'desc' => sprintf( __( 'How would you like to display donation information for this form?', 'give' ), '#' ), |
|
247 | - 'id' => $prefix . 'payment_display', |
|
245 | + 'name' => __('Display Options', 'give'), |
|
246 | + 'desc' => sprintf(__('How would you like to display donation information for this form?', 'give'), '#'), |
|
247 | + 'id' => $prefix.'payment_display', |
|
248 | 248 | 'type' => 'radio_inline', |
249 | 249 | 'options' => array( |
250 | - 'onpage' => __( 'All Fields', 'give' ), |
|
251 | - 'modal' => __( 'Modal', 'give' ), |
|
252 | - 'reveal' => __( 'Reveal', 'give' ), |
|
253 | - 'button' => __( 'Button', 'give' ), |
|
250 | + 'onpage' => __('All Fields', 'give'), |
|
251 | + 'modal' => __('Modal', 'give'), |
|
252 | + 'reveal' => __('Reveal', 'give'), |
|
253 | + 'button' => __('Button', 'give'), |
|
254 | 254 | ), |
255 | 255 | 'default' => 'onpage', |
256 | 256 | ), |
257 | 257 | array( |
258 | - 'id' => $prefix . 'reveal_label', |
|
259 | - 'name' => __( 'Continue Button', 'give' ), |
|
260 | - 'desc' => __( 'The button label for displaying the additional payment fields.', 'give' ), |
|
258 | + 'id' => $prefix.'reveal_label', |
|
259 | + 'name' => __('Continue Button', 'give'), |
|
260 | + 'desc' => __('The button label for displaying the additional payment fields.', 'give'), |
|
261 | 261 | 'type' => 'text_small', |
262 | 262 | 'attributes' => array( |
263 | - 'placeholder' => __( 'Donate Now', 'give' ), |
|
263 | + 'placeholder' => __('Donate Now', 'give'), |
|
264 | 264 | ), |
265 | 265 | 'wrapper_class' => 'give-hidden', |
266 | 266 | ), |
267 | 267 | array( |
268 | - 'id' => $prefix . 'checkout_label', |
|
269 | - 'name' => __( 'Submit Button', 'give' ), |
|
270 | - 'desc' => __( 'The button label for completing a donation.', 'give' ), |
|
268 | + 'id' => $prefix.'checkout_label', |
|
269 | + 'name' => __('Submit Button', 'give'), |
|
270 | + 'desc' => __('The button label for completing a donation.', 'give'), |
|
271 | 271 | 'type' => 'text_small', |
272 | 272 | 'attributes' => array( |
273 | - 'placeholder' => __( 'Donate Now', 'give' ), |
|
273 | + 'placeholder' => __('Donate Now', 'give'), |
|
274 | 274 | ), |
275 | 275 | ), |
276 | 276 | array( |
277 | - 'name' => __( 'Default Gateway', 'give' ), |
|
278 | - 'desc' => __( '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' ), |
|
279 | - 'id' => $prefix . 'default_gateway', |
|
277 | + 'name' => __('Default Gateway', 'give'), |
|
278 | + 'desc' => __('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'), |
|
279 | + 'id' => $prefix.'default_gateway', |
|
280 | 280 | 'type' => 'default_gateway', |
281 | 281 | ), |
282 | 282 | array( |
283 | - 'name' => __( 'Company Donations', 'give' ), |
|
284 | - 'desc' => __( 'Do you want a Company field to appear after First Name and Last Name?', 'give' ), |
|
285 | - 'id' => $prefix . 'company_field', |
|
283 | + 'name' => __('Company Donations', 'give'), |
|
284 | + 'desc' => __('Do you want a Company field to appear after First Name and Last Name?', 'give'), |
|
285 | + 'id' => $prefix.'company_field', |
|
286 | 286 | 'type' => 'radio_inline', |
287 | 287 | 'default' => 'global', |
288 | 288 | 'options' => array( |
289 | - 'global' => __( 'Global Option', 'give' ), |
|
290 | - 'required' => __( 'Required', 'give' ), |
|
291 | - 'optional' => __( 'Optional', 'give' ), |
|
292 | - 'disabled' => __( 'Disabled', 'give' ), |
|
289 | + 'global' => __('Global Option', 'give'), |
|
290 | + 'required' => __('Required', 'give'), |
|
291 | + 'optional' => __('Optional', 'give'), |
|
292 | + 'disabled' => __('Disabled', 'give'), |
|
293 | 293 | |
294 | 294 | ), |
295 | 295 | ), |
296 | 296 | array( |
297 | - 'name' => __( 'Guest Donations', 'give' ), |
|
298 | - 'desc' => __( 'Do you want to allow non-logged-in users to make donations?', 'give' ), |
|
299 | - 'id' => $prefix . 'logged_in_only', |
|
297 | + 'name' => __('Guest Donations', 'give'), |
|
298 | + 'desc' => __('Do you want to allow non-logged-in users to make donations?', 'give'), |
|
299 | + 'id' => $prefix.'logged_in_only', |
|
300 | 300 | 'type' => 'radio_inline', |
301 | 301 | 'default' => 'enabled', |
302 | 302 | 'options' => array( |
303 | - 'enabled' => __( 'Enabled', 'give' ), |
|
304 | - 'disabled' => __( 'Disabled', 'give' ), |
|
303 | + 'enabled' => __('Enabled', 'give'), |
|
304 | + 'disabled' => __('Disabled', 'give'), |
|
305 | 305 | ), |
306 | 306 | ), |
307 | 307 | array( |
308 | - 'name' => __( 'Registration', 'give' ), |
|
309 | - 'desc' => __( 'Display the registration and login forms in the payment section for non-logged-in users.', 'give' ), |
|
310 | - 'id' => $prefix . 'show_register_form', |
|
308 | + 'name' => __('Registration', 'give'), |
|
309 | + 'desc' => __('Display the registration and login forms in the payment section for non-logged-in users.', 'give'), |
|
310 | + 'id' => $prefix.'show_register_form', |
|
311 | 311 | 'type' => 'radio', |
312 | 312 | 'options' => array( |
313 | - 'none' => __( 'None', 'give' ), |
|
314 | - 'registration' => __( 'Registration', 'give' ), |
|
315 | - 'login' => __( 'Login', 'give' ), |
|
316 | - 'both' => __( 'Registration + Login', 'give' ), |
|
313 | + 'none' => __('None', 'give'), |
|
314 | + 'registration' => __('Registration', 'give'), |
|
315 | + 'login' => __('Login', 'give'), |
|
316 | + 'both' => __('Registration + Login', 'give'), |
|
317 | 317 | ), |
318 | 318 | 'default' => 'none', |
319 | 319 | ), |
320 | 320 | array( |
321 | - 'name' => __( 'Floating Labels', 'give' ), |
|
321 | + 'name' => __('Floating Labels', 'give'), |
|
322 | 322 | /* translators: %s: forms http://docs.givewp.com/form-floating-labels */ |
323 | - 'desc' => sprintf( __( 'Select the <a href="%s" target="_blank">floating labels</a> setting for this Give form. Be aware that if you have the "Disable CSS" option enabled, you will need to style the floating labels yourself.', 'give' ), esc_url( 'http://docs.givewp.com/form-floating-labels' ) ), |
|
324 | - 'id' => $prefix . 'form_floating_labels', |
|
323 | + 'desc' => sprintf(__('Select the <a href="%s" target="_blank">floating labels</a> setting for this Give form. Be aware that if you have the "Disable CSS" option enabled, you will need to style the floating labels yourself.', 'give'), esc_url('http://docs.givewp.com/form-floating-labels')), |
|
324 | + 'id' => $prefix.'form_floating_labels', |
|
325 | 325 | 'type' => 'radio_inline', |
326 | 326 | 'options' => array( |
327 | - 'global' => __( 'Global Option', 'give' ), |
|
328 | - 'enabled' => __( 'Enabled', 'give' ), |
|
329 | - 'disabled' => __( 'Disabled', 'give' ), |
|
327 | + 'global' => __('Global Option', 'give'), |
|
328 | + 'enabled' => __('Enabled', 'give'), |
|
329 | + 'disabled' => __('Disabled', 'give'), |
|
330 | 330 | ), |
331 | 331 | 'default' => 'global', |
332 | 332 | ), |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | 'name' => 'form_display_docs', |
335 | 335 | 'type' => 'docs_link', |
336 | 336 | 'url' => 'http://docs.givewp.com/form-display-options', |
337 | - 'title' => __( 'Form Display', 'give' ), |
|
337 | + 'title' => __('Form Display', 'give'), |
|
338 | 338 | ), |
339 | 339 | ), |
340 | 340 | $post_id |
@@ -345,42 +345,42 @@ discard block |
||
345 | 345 | /** |
346 | 346 | * Donation Goals |
347 | 347 | */ |
348 | - 'donation_goal_options' => apply_filters( 'give_donation_goal_options', array( |
|
348 | + 'donation_goal_options' => apply_filters('give_donation_goal_options', array( |
|
349 | 349 | 'id' => 'donation_goal_options', |
350 | - 'title' => __( 'Donation Goal', 'give' ), |
|
350 | + 'title' => __('Donation Goal', 'give'), |
|
351 | 351 | 'icon-html' => '<span class="give-icon give-icon-target"></span>', |
352 | - 'fields' => apply_filters( 'give_forms_donation_goal_metabox_fields', array( |
|
352 | + 'fields' => apply_filters('give_forms_donation_goal_metabox_fields', array( |
|
353 | 353 | // Goals |
354 | 354 | array( |
355 | - 'name' => __( 'Donation Goal', 'give' ), |
|
356 | - 'description' => __( 'Do you want to set a donation goal for this form?', 'give' ), |
|
357 | - 'id' => $prefix . 'goal_option', |
|
355 | + 'name' => __('Donation Goal', 'give'), |
|
356 | + 'description' => __('Do you want to set a donation goal for this form?', 'give'), |
|
357 | + 'id' => $prefix.'goal_option', |
|
358 | 358 | 'type' => 'radio_inline', |
359 | 359 | 'default' => 'disabled', |
360 | 360 | 'options' => array( |
361 | - 'enabled' => __( 'Enabled', 'give' ), |
|
362 | - 'disabled' => __( 'Disabled', 'give' ), |
|
361 | + 'enabled' => __('Enabled', 'give'), |
|
362 | + 'disabled' => __('Disabled', 'give'), |
|
363 | 363 | ), |
364 | 364 | ), |
365 | 365 | |
366 | 366 | array( |
367 | - 'name' => __( 'Goal Format', 'give' ), |
|
368 | - 'description' => __( 'Do you want to display the total amount raised based on your monetary goal or a percentage? For instance, "$500 of $1,000 raised" or "50% funded" or "1 of 5 donations". You can also display a donor-based goal, such as "100 of 1,000 donors have given".', 'give' ), |
|
369 | - 'id' => $prefix . 'goal_format', |
|
367 | + 'name' => __('Goal Format', 'give'), |
|
368 | + 'description' => __('Do you want to display the total amount raised based on your monetary goal or a percentage? For instance, "$500 of $1,000 raised" or "50% funded" or "1 of 5 donations". You can also display a donor-based goal, such as "100 of 1,000 donors have given".', 'give'), |
|
369 | + 'id' => $prefix.'goal_format', |
|
370 | 370 | 'type' => 'donation_form_goal', |
371 | 371 | 'default' => 'amount', |
372 | 372 | 'options' => array( |
373 | - 'amount' => __( 'Amount Raised', 'give' ), |
|
374 | - 'percentage' => __( 'Percentage Raised', 'give' ), |
|
375 | - 'donation' => __( 'Number of Donations', 'give' ), |
|
376 | - 'donors' => __( 'Number of Donors', 'give' ), |
|
373 | + 'amount' => __('Amount Raised', 'give'), |
|
374 | + 'percentage' => __('Percentage Raised', 'give'), |
|
375 | + 'donation' => __('Number of Donations', 'give'), |
|
376 | + 'donors' => __('Number of Donors', 'give'), |
|
377 | 377 | ), |
378 | 378 | ), |
379 | 379 | |
380 | 380 | array( |
381 | - 'name' => __( 'Goal Amount', 'give' ), |
|
382 | - 'description' => __( 'This is the monetary goal amount you want to reach for this form.', 'give' ), |
|
383 | - 'id' => $prefix . 'set_goal', |
|
381 | + 'name' => __('Goal Amount', 'give'), |
|
382 | + 'description' => __('This is the monetary goal amount you want to reach for this form.', 'give'), |
|
383 | + 'id' => $prefix.'set_goal', |
|
384 | 384 | 'type' => 'text_small', |
385 | 385 | 'data_type' => 'price', |
386 | 386 | 'attributes' => array( |
@@ -390,9 +390,9 @@ discard block |
||
390 | 390 | 'wrapper_class' => 'give-hidden', |
391 | 391 | ), |
392 | 392 | array( |
393 | - 'id' => $prefix . 'number_of_donation_goal', |
|
394 | - 'name' => __( 'Donation Goal', 'give' ), |
|
395 | - 'desc' => __( 'Set the total number of donations as a goal.', 'give' ), |
|
393 | + 'id' => $prefix.'number_of_donation_goal', |
|
394 | + 'name' => __('Donation Goal', 'give'), |
|
395 | + 'desc' => __('Set the total number of donations as a goal.', 'give'), |
|
396 | 396 | 'type' => 'number', |
397 | 397 | 'default' => 1, |
398 | 398 | 'attributes' => array( |
@@ -400,9 +400,9 @@ discard block |
||
400 | 400 | ), |
401 | 401 | ), |
402 | 402 | array( |
403 | - 'id' => $prefix . 'number_of_donor_goal', |
|
404 | - 'name' => __( 'Donor Goal', 'give' ), |
|
405 | - 'desc' => __( 'Set the total number of donors as a goal.', 'give' ), |
|
403 | + 'id' => $prefix.'number_of_donor_goal', |
|
404 | + 'name' => __('Donor Goal', 'give'), |
|
405 | + 'desc' => __('Set the total number of donors as a goal.', 'give'), |
|
406 | 406 | 'type' => 'number', |
407 | 407 | 'default' => 1, |
408 | 408 | 'attributes' => array( |
@@ -410,85 +410,85 @@ discard block |
||
410 | 410 | ), |
411 | 411 | ), |
412 | 412 | array( |
413 | - 'name' => __( 'Progress Bar Color', 'give' ), |
|
414 | - 'desc' => __( 'Customize the color of the goal progress bar.', 'give' ), |
|
415 | - 'id' => $prefix . 'goal_color', |
|
413 | + 'name' => __('Progress Bar Color', 'give'), |
|
414 | + 'desc' => __('Customize the color of the goal progress bar.', 'give'), |
|
415 | + 'id' => $prefix.'goal_color', |
|
416 | 416 | 'type' => 'colorpicker', |
417 | 417 | 'default' => '#2bc253', |
418 | 418 | 'wrapper_class' => 'give-hidden', |
419 | 419 | ), |
420 | 420 | |
421 | 421 | array( |
422 | - 'name' => __( 'Close Form', 'give' ), |
|
423 | - 'desc' => __( 'Do you want to close the donation forms and stop accepting donations once this goal has been met?', 'give' ), |
|
424 | - 'id' => $prefix . 'close_form_when_goal_achieved', |
|
422 | + 'name' => __('Close Form', 'give'), |
|
423 | + 'desc' => __('Do you want to close the donation forms and stop accepting donations once this goal has been met?', 'give'), |
|
424 | + 'id' => $prefix.'close_form_when_goal_achieved', |
|
425 | 425 | 'type' => 'radio_inline', |
426 | 426 | 'default' => 'disabled', |
427 | 427 | 'options' => array( |
428 | - 'enabled' => __( 'Enabled', 'give' ), |
|
429 | - 'disabled' => __( 'Disabled', 'give' ), |
|
428 | + 'enabled' => __('Enabled', 'give'), |
|
429 | + 'disabled' => __('Disabled', 'give'), |
|
430 | 430 | ), |
431 | 431 | 'wrapper_class' => 'give-hidden', |
432 | 432 | ), |
433 | 433 | array( |
434 | - 'name' => __( 'Goal Achieved Message', 'give' ), |
|
435 | - 'desc' => __( 'Do you want to display a custom message when the goal is closed?', 'give' ), |
|
436 | - 'id' => $prefix . 'form_goal_achieved_message', |
|
434 | + 'name' => __('Goal Achieved Message', 'give'), |
|
435 | + 'desc' => __('Do you want to display a custom message when the goal is closed?', 'give'), |
|
436 | + 'id' => $prefix.'form_goal_achieved_message', |
|
437 | 437 | 'type' => 'wysiwyg', |
438 | - 'default' => __( 'Thank you to all our donors, we have met our fundraising goal.', 'give' ), |
|
438 | + 'default' => __('Thank you to all our donors, we have met our fundraising goal.', 'give'), |
|
439 | 439 | 'wrapper_class' => 'give-hidden', |
440 | 440 | ), |
441 | 441 | array( |
442 | 442 | 'name' => 'donation_goal_docs', |
443 | 443 | 'type' => 'docs_link', |
444 | 444 | 'url' => 'http://docs.givewp.com/form-donation-goal', |
445 | - 'title' => __( 'Donation Goal', 'give' ), |
|
445 | + 'title' => __('Donation Goal', 'give'), |
|
446 | 446 | ), |
447 | 447 | ), |
448 | 448 | $post_id |
449 | 449 | ), |
450 | - ) ), |
|
450 | + )), |
|
451 | 451 | |
452 | 452 | /** |
453 | 453 | * Content Field |
454 | 454 | */ |
455 | - 'form_content_options' => apply_filters( 'give_forms_content_options', array( |
|
455 | + 'form_content_options' => apply_filters('give_forms_content_options', array( |
|
456 | 456 | 'id' => 'form_content_options', |
457 | - 'title' => __( 'Form Content', 'give' ), |
|
457 | + 'title' => __('Form Content', 'give'), |
|
458 | 458 | 'icon-html' => '<span class="give-icon give-icon-edit"></span>', |
459 | - 'fields' => apply_filters( 'give_forms_content_options_metabox_fields', array( |
|
459 | + 'fields' => apply_filters('give_forms_content_options_metabox_fields', array( |
|
460 | 460 | |
461 | 461 | // Donation content. |
462 | 462 | array( |
463 | - 'name' => __( 'Display Content', 'give' ), |
|
464 | - 'description' => __( 'Do you want to add custom content to this form?', 'give' ), |
|
465 | - 'id' => $prefix . 'display_content', |
|
463 | + 'name' => __('Display Content', 'give'), |
|
464 | + 'description' => __('Do you want to add custom content to this form?', 'give'), |
|
465 | + 'id' => $prefix.'display_content', |
|
466 | 466 | 'type' => 'radio_inline', |
467 | 467 | 'options' => array( |
468 | - 'enabled' => __( 'Enabled', 'give' ), |
|
469 | - 'disabled' => __( 'Disabled', 'give' ), |
|
468 | + 'enabled' => __('Enabled', 'give'), |
|
469 | + 'disabled' => __('Disabled', 'give'), |
|
470 | 470 | ), |
471 | 471 | 'default' => 'disabled', |
472 | 472 | ), |
473 | 473 | |
474 | 474 | // Content placement. |
475 | 475 | array( |
476 | - 'name' => __( 'Content Placement', 'give' ), |
|
477 | - 'description' => __( 'This option controls where the content appears within the donation form.', 'give' ), |
|
478 | - 'id' => $prefix . 'content_placement', |
|
476 | + 'name' => __('Content Placement', 'give'), |
|
477 | + 'description' => __('This option controls where the content appears within the donation form.', 'give'), |
|
478 | + 'id' => $prefix.'content_placement', |
|
479 | 479 | 'type' => 'radio_inline', |
480 | - 'options' => apply_filters( 'give_forms_content_options_select', array( |
|
481 | - 'give_pre_form' => __( 'Above fields', 'give' ), |
|
482 | - 'give_post_form' => __( 'Below fields', 'give' ), |
|
480 | + 'options' => apply_filters('give_forms_content_options_select', array( |
|
481 | + 'give_pre_form' => __('Above fields', 'give'), |
|
482 | + 'give_post_form' => __('Below fields', 'give'), |
|
483 | 483 | ) |
484 | 484 | ), |
485 | 485 | 'default' => 'give_pre_form', |
486 | 486 | 'wrapper_class' => 'give-hidden', |
487 | 487 | ), |
488 | 488 | array( |
489 | - 'name' => __( 'Content', 'give' ), |
|
490 | - 'description' => __( 'This content will display on the single give form page.', 'give' ), |
|
491 | - 'id' => $prefix . 'form_content', |
|
489 | + 'name' => __('Content', 'give'), |
|
490 | + 'description' => __('This content will display on the single give form page.', 'give'), |
|
491 | + 'id' => $prefix.'form_content', |
|
492 | 492 | 'type' => 'wysiwyg', |
493 | 493 | 'wrapper_class' => 'give-hidden', |
494 | 494 | ), |
@@ -496,51 +496,51 @@ discard block |
||
496 | 496 | 'name' => 'form_content_docs', |
497 | 497 | 'type' => 'docs_link', |
498 | 498 | 'url' => 'http://docs.givewp.com/form-content', |
499 | - 'title' => __( 'Form Content', 'give' ), |
|
499 | + 'title' => __('Form Content', 'give'), |
|
500 | 500 | ), |
501 | 501 | ), |
502 | 502 | $post_id |
503 | 503 | ), |
504 | - ) ), |
|
504 | + )), |
|
505 | 505 | |
506 | 506 | /** |
507 | 507 | * Terms & Conditions |
508 | 508 | */ |
509 | - 'form_terms_options' => apply_filters( 'give_forms_terms_options', array( |
|
509 | + 'form_terms_options' => apply_filters('give_forms_terms_options', array( |
|
510 | 510 | 'id' => 'form_terms_options', |
511 | - 'title' => __( 'Terms & Conditions', 'give' ), |
|
511 | + 'title' => __('Terms & Conditions', 'give'), |
|
512 | 512 | 'icon-html' => '<span class="give-icon give-icon-checklist"></span>', |
513 | - 'fields' => apply_filters( 'give_forms_terms_options_metabox_fields', array( |
|
513 | + 'fields' => apply_filters('give_forms_terms_options_metabox_fields', array( |
|
514 | 514 | // Donation Option |
515 | 515 | array( |
516 | - 'name' => __( 'Terms and Conditions', 'give' ), |
|
517 | - 'description' => __( 'Do you want to require the donor to accept terms prior to being able to complete their donation?', 'give' ), |
|
518 | - 'id' => $prefix . 'terms_option', |
|
516 | + 'name' => __('Terms and Conditions', 'give'), |
|
517 | + 'description' => __('Do you want to require the donor to accept terms prior to being able to complete their donation?', 'give'), |
|
518 | + 'id' => $prefix.'terms_option', |
|
519 | 519 | 'type' => 'radio_inline', |
520 | - 'options' => apply_filters( 'give_forms_content_options_select', array( |
|
521 | - 'global' => __( 'Global Option', 'give' ), |
|
522 | - 'enabled' => __( 'Customize', 'give' ), |
|
523 | - 'disabled' => __( 'Disable', 'give' ), |
|
520 | + 'options' => apply_filters('give_forms_content_options_select', array( |
|
521 | + 'global' => __('Global Option', 'give'), |
|
522 | + 'enabled' => __('Customize', 'give'), |
|
523 | + 'disabled' => __('Disable', 'give'), |
|
524 | 524 | ) |
525 | 525 | ), |
526 | 526 | 'default' => 'global', |
527 | 527 | ), |
528 | 528 | array( |
529 | - 'id' => $prefix . 'agree_label', |
|
530 | - 'name' => __( 'Agreement Label', 'give' ), |
|
531 | - 'desc' => __( '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' ), |
|
529 | + 'id' => $prefix.'agree_label', |
|
530 | + 'name' => __('Agreement Label', 'give'), |
|
531 | + 'desc' => __('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'), |
|
532 | 532 | 'type' => 'text', |
533 | 533 | 'size' => 'regular', |
534 | 534 | 'attributes' => array( |
535 | - 'placeholder' => __( 'Agree to Terms?', 'give' ), |
|
535 | + 'placeholder' => __('Agree to Terms?', 'give'), |
|
536 | 536 | ), |
537 | 537 | 'wrapper_class' => 'give-hidden', |
538 | 538 | ), |
539 | 539 | array( |
540 | - 'id' => $prefix . 'agree_text', |
|
541 | - 'name' => __( 'Agreement Text', 'give' ), |
|
542 | - 'desc' => __( 'This is the actual text which the user will have to agree to in order to make a donation.', 'give' ), |
|
543 | - 'default' => give_get_option( 'agreement_text' ), |
|
540 | + 'id' => $prefix.'agree_text', |
|
541 | + 'name' => __('Agreement Text', 'give'), |
|
542 | + 'desc' => __('This is the actual text which the user will have to agree to in order to make a donation.', 'give'), |
|
543 | + 'default' => give_get_option('agreement_text'), |
|
544 | 544 | 'type' => 'wysiwyg', |
545 | 545 | 'wrapper_class' => 'give-hidden', |
546 | 546 | ), |
@@ -548,18 +548,18 @@ discard block |
||
548 | 548 | 'name' => 'terms_docs', |
549 | 549 | 'type' => 'docs_link', |
550 | 550 | 'url' => 'http://docs.givewp.com/form-terms', |
551 | - 'title' => __( 'Terms and Conditions', 'give' ), |
|
551 | + 'title' => __('Terms and Conditions', 'give'), |
|
552 | 552 | ), |
553 | 553 | ), |
554 | 554 | $post_id |
555 | 555 | ), |
556 | - ) ), |
|
556 | + )), |
|
557 | 557 | ); |
558 | 558 | |
559 | 559 | /** |
560 | 560 | * Filter the metabox tabbed panel settings. |
561 | 561 | */ |
562 | - $settings = apply_filters( 'give_metabox_form_data_settings', $settings, $post_id ); |
|
562 | + $settings = apply_filters('give_metabox_form_data_settings', $settings, $post_id); |
|
563 | 563 | |
564 | 564 | // Output. |
565 | 565 | return $settings; |
@@ -576,19 +576,19 @@ discard block |
||
576 | 576 | add_meta_box( |
577 | 577 | $this->get_metabox_ID(), |
578 | 578 | $this->get_metabox_label(), |
579 | - array( $this, 'output' ), |
|
580 | - array( 'give_forms' ), |
|
579 | + array($this, 'output'), |
|
580 | + array('give_forms'), |
|
581 | 581 | 'normal', |
582 | 582 | 'high' |
583 | 583 | ); |
584 | 584 | |
585 | 585 | // Show Goal Metabox only if goal is enabled. |
586 | - if ( give_is_setting_enabled( give_get_meta( give_get_admin_post_id(), '_give_goal_option', true ) ) ) { |
|
586 | + if (give_is_setting_enabled(give_get_meta(give_get_admin_post_id(), '_give_goal_option', true))) { |
|
587 | 587 | add_meta_box( |
588 | 588 | 'give-form-goal-stats', |
589 | - __( 'Goal Statistics', 'give' ), |
|
590 | - array( $this, 'output_goal' ), |
|
591 | - array( 'give_forms' ), |
|
589 | + __('Goal Statistics', 'give'), |
|
590 | + array($this, 'output_goal'), |
|
591 | + array('give_forms'), |
|
592 | 592 | 'side', |
593 | 593 | 'low' |
594 | 594 | ); |
@@ -607,7 +607,7 @@ discard block |
||
607 | 607 | function enqueue_script() { |
608 | 608 | global $post; |
609 | 609 | |
610 | - if ( is_object( $post ) && 'give_forms' === $post->post_type ) { |
|
610 | + if (is_object($post) && 'give_forms' === $post->post_type) { |
|
611 | 611 | |
612 | 612 | } |
613 | 613 | } |
@@ -645,32 +645,32 @@ discard block |
||
645 | 645 | public function get_tabs() { |
646 | 646 | $tabs = array(); |
647 | 647 | |
648 | - if ( ! empty( $this->settings ) ) { |
|
649 | - foreach ( $this->settings as $setting ) { |
|
650 | - if ( ! isset( $setting['id'] ) || ! isset( $setting['title'] ) ) { |
|
648 | + if ( ! empty($this->settings)) { |
|
649 | + foreach ($this->settings as $setting) { |
|
650 | + if ( ! isset($setting['id']) || ! isset($setting['title'])) { |
|
651 | 651 | continue; |
652 | 652 | } |
653 | 653 | $tab = array( |
654 | 654 | 'id' => $setting['id'], |
655 | 655 | 'label' => $setting['title'], |
656 | - 'icon-html' => ( ! empty( $setting['icon-html'] ) ? $setting['icon-html'] : '' ), |
|
656 | + 'icon-html' => ( ! empty($setting['icon-html']) ? $setting['icon-html'] : ''), |
|
657 | 657 | ); |
658 | 658 | |
659 | - if ( $this->has_sub_tab( $setting ) ) { |
|
660 | - if ( empty( $setting['sub-fields'] ) ) { |
|
659 | + if ($this->has_sub_tab($setting)) { |
|
660 | + if (empty($setting['sub-fields'])) { |
|
661 | 661 | $tab = array(); |
662 | 662 | } else { |
663 | - foreach ( $setting['sub-fields'] as $sub_fields ) { |
|
663 | + foreach ($setting['sub-fields'] as $sub_fields) { |
|
664 | 664 | $tab['sub-fields'][] = array( |
665 | 665 | 'id' => $sub_fields['id'], |
666 | 666 | 'label' => $sub_fields['title'], |
667 | - 'icon-html' => ( ! empty( $sub_fields['icon-html'] ) ? $sub_fields['icon-html'] : '' ), |
|
667 | + 'icon-html' => ( ! empty($sub_fields['icon-html']) ? $sub_fields['icon-html'] : ''), |
|
668 | 668 | ); |
669 | 669 | } |
670 | 670 | } |
671 | 671 | } |
672 | 672 | |
673 | - if ( ! empty( $tab ) ) { |
|
673 | + if ( ! empty($tab)) { |
|
674 | 674 | $tabs[] = $tab; |
675 | 675 | } |
676 | 676 | } |
@@ -688,33 +688,33 @@ discard block |
||
688 | 688 | */ |
689 | 689 | public function output() { |
690 | 690 | // Bailout. |
691 | - if ( $form_data_tabs = $this->get_tabs() ) : |
|
692 | - $active_tab = ! empty( $_GET['give_tab'] ) ? give_clean( $_GET['give_tab'] ) : 'form_field_options'; |
|
693 | - wp_nonce_field( 'give_save_form_meta', 'give_form_meta_nonce' ); |
|
691 | + if ($form_data_tabs = $this->get_tabs()) : |
|
692 | + $active_tab = ! empty($_GET['give_tab']) ? give_clean($_GET['give_tab']) : 'form_field_options'; |
|
693 | + wp_nonce_field('give_save_form_meta', 'give_form_meta_nonce'); |
|
694 | 694 | ?> |
695 | 695 | <input id="give_form_active_tab" type="hidden" name="give_form_active_tab"> |
696 | 696 | <div class="give-metabox-panel-wrap"> |
697 | 697 | <ul class="give-form-data-tabs give-metabox-tabs"> |
698 | - <?php foreach ( $form_data_tabs as $index => $form_data_tab ) : ?> |
|
698 | + <?php foreach ($form_data_tabs as $index => $form_data_tab) : ?> |
|
699 | 699 | <?php |
700 | 700 | // Determine if current tab is active. |
701 | 701 | $is_active = $active_tab === $form_data_tab['id'] ? true : false; |
702 | 702 | ?> |
703 | - <li class="<?php echo "{$form_data_tab['id']}_tab" . ( $is_active ? ' active' : '' ) . ( $this->has_sub_tab( $form_data_tab ) ? ' has-sub-fields' : '' ); ?>"> |
|
703 | + <li class="<?php echo "{$form_data_tab['id']}_tab".($is_active ? ' active' : '').($this->has_sub_tab($form_data_tab) ? ' has-sub-fields' : ''); ?>"> |
|
704 | 704 | <a href="#<?php echo $form_data_tab['id']; ?>" data-tab-id="<?php echo $form_data_tab['id']; ?>"> |
705 | - <?php if ( ! empty( $form_data_tab['icon-html'] ) ) : ?> |
|
705 | + <?php if ( ! empty($form_data_tab['icon-html'])) : ?> |
|
706 | 706 | <?php echo $form_data_tab['icon-html']; ?> |
707 | 707 | <?php else : ?> |
708 | 708 | <span class="give-icon give-icon-default"></span> |
709 | 709 | <?php endif; ?> |
710 | 710 | <span class="give-label"><?php echo $form_data_tab['label']; ?></span> |
711 | 711 | </a> |
712 | - <?php if ( $this->has_sub_tab( $form_data_tab ) ) : ?> |
|
712 | + <?php if ($this->has_sub_tab($form_data_tab)) : ?> |
|
713 | 713 | <ul class="give-metabox-sub-tabs give-hidden"> |
714 | - <?php foreach ( $form_data_tab['sub-fields'] as $sub_tab ) : ?> |
|
714 | + <?php foreach ($form_data_tab['sub-fields'] as $sub_tab) : ?> |
|
715 | 715 | <li class="<?php echo "{$sub_tab['id']}_tab"; ?>"> |
716 | 716 | <a href="#<?php echo $sub_tab['id']; ?>" data-tab-id="<?php echo $sub_tab['id']; ?>"> |
717 | - <?php if ( ! empty( $sub_tab['icon-html'] ) ) : ?> |
|
717 | + <?php if ( ! empty($sub_tab['icon-html'])) : ?> |
|
718 | 718 | <?php echo $sub_tab['icon-html']; ?> |
719 | 719 | <?php else : ?> |
720 | 720 | <span class="give-icon give-icon-default"></span> |
@@ -729,29 +729,29 @@ discard block |
||
729 | 729 | <?php endforeach; ?> |
730 | 730 | </ul> |
731 | 731 | |
732 | - <?php foreach ( $this->settings as $setting ) : ?> |
|
733 | - <?php do_action( "give_before_{$setting['id']}_settings" ); ?> |
|
732 | + <?php foreach ($this->settings as $setting) : ?> |
|
733 | + <?php do_action("give_before_{$setting['id']}_settings"); ?> |
|
734 | 734 | <?php |
735 | 735 | // Determine if current panel is active. |
736 | 736 | $is_active = $active_tab === $setting['id'] ? true : false; |
737 | 737 | ?> |
738 | - <div id="<?php echo $setting['id']; ?>" class="panel give_options_panel<?php echo( $is_active ? ' active' : '' ); ?>"> |
|
739 | - <?php if ( ! empty( $setting['fields'] ) ) : ?> |
|
740 | - <?php foreach ( $setting['fields'] as $field ) : ?> |
|
741 | - <?php give_render_field( $field ); ?> |
|
738 | + <div id="<?php echo $setting['id']; ?>" class="panel give_options_panel<?php echo($is_active ? ' active' : ''); ?>"> |
|
739 | + <?php if ( ! empty($setting['fields'])) : ?> |
|
740 | + <?php foreach ($setting['fields'] as $field) : ?> |
|
741 | + <?php give_render_field($field); ?> |
|
742 | 742 | <?php endforeach; ?> |
743 | 743 | <?php endif; ?> |
744 | 744 | </div> |
745 | - <?php do_action( "give_after_{$setting['id']}_settings" ); ?> |
|
745 | + <?php do_action("give_after_{$setting['id']}_settings"); ?> |
|
746 | 746 | |
747 | 747 | |
748 | - <?php if ( $this->has_sub_tab( $setting ) ) : ?> |
|
749 | - <?php if ( ! empty( $setting['sub-fields'] ) ) : ?> |
|
750 | - <?php foreach ( $setting['sub-fields'] as $index => $sub_fields ) : ?> |
|
748 | + <?php if ($this->has_sub_tab($setting)) : ?> |
|
749 | + <?php if ( ! empty($setting['sub-fields'])) : ?> |
|
750 | + <?php foreach ($setting['sub-fields'] as $index => $sub_fields) : ?> |
|
751 | 751 | <div id="<?php echo $sub_fields['id']; ?>" class="panel give_options_panel give-hidden"> |
752 | - <?php if ( ! empty( $sub_fields['fields'] ) ) : ?> |
|
753 | - <?php foreach ( $sub_fields['fields'] as $sub_field ) : ?> |
|
754 | - <?php give_render_field( $sub_field ); ?> |
|
752 | + <?php if ( ! empty($sub_fields['fields'])) : ?> |
|
753 | + <?php foreach ($sub_fields['fields'] as $sub_field) : ?> |
|
754 | + <?php give_render_field($sub_field); ?> |
|
755 | 755 | <?php endforeach; ?> |
756 | 756 | <?php endif; ?> |
757 | 757 | </div> |
@@ -774,9 +774,9 @@ discard block |
||
774 | 774 | * |
775 | 775 | * @return void |
776 | 776 | */ |
777 | - public function output_goal( $post ) { |
|
777 | + public function output_goal($post) { |
|
778 | 778 | |
779 | - echo give_admin_form_goal_stats( $post->ID ); |
|
779 | + echo give_admin_form_goal_stats($post->ID); |
|
780 | 780 | |
781 | 781 | } |
782 | 782 | |
@@ -789,9 +789,9 @@ discard block |
||
789 | 789 | * |
790 | 790 | * @return bool |
791 | 791 | */ |
792 | - private function has_sub_tab( $field_setting ) { |
|
792 | + private function has_sub_tab($field_setting) { |
|
793 | 793 | $has_sub_tab = false; |
794 | - if ( array_key_exists( 'sub-fields', $field_setting ) ) { |
|
794 | + if (array_key_exists('sub-fields', $field_setting)) { |
|
795 | 795 | $has_sub_tab = true; |
796 | 796 | } |
797 | 797 | |
@@ -806,13 +806,13 @@ discard block |
||
806 | 806 | * @return array |
807 | 807 | */ |
808 | 808 | function cmb2_metabox_settings() { |
809 | - $all_cmb2_settings = apply_filters( 'cmb2_meta_boxes', array() ); |
|
809 | + $all_cmb2_settings = apply_filters('cmb2_meta_boxes', array()); |
|
810 | 810 | $give_forms_settings = $all_cmb2_settings; |
811 | 811 | |
812 | 812 | // Filter settings: Use only give forms related settings. |
813 | - foreach ( $all_cmb2_settings as $index => $setting ) { |
|
814 | - if ( ! in_array( 'give_forms', $setting['object_types'] ) ) { |
|
815 | - unset( $give_forms_settings[ $index ] ); |
|
813 | + foreach ($all_cmb2_settings as $index => $setting) { |
|
814 | + if ( ! in_array('give_forms', $setting['object_types'])) { |
|
815 | + unset($give_forms_settings[$index]); |
|
816 | 816 | } |
817 | 817 | } |
818 | 818 | |
@@ -830,100 +830,100 @@ discard block |
||
830 | 830 | * |
831 | 831 | * @return void |
832 | 832 | */ |
833 | - public function save( $post_id, $post ) { |
|
833 | + public function save($post_id, $post) { |
|
834 | 834 | |
835 | 835 | // $post_id and $post are required. |
836 | - if ( empty( $post_id ) || empty( $post ) ) { |
|
836 | + if (empty($post_id) || empty($post)) { |
|
837 | 837 | return; |
838 | 838 | } |
839 | 839 | |
840 | 840 | // Don't save meta boxes for revisions or autosaves. |
841 | - if ( defined( 'DOING_AUTOSAVE' ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) { |
|
841 | + if (defined('DOING_AUTOSAVE') || is_int(wp_is_post_revision($post)) || is_int(wp_is_post_autosave($post))) { |
|
842 | 842 | return; |
843 | 843 | } |
844 | 844 | |
845 | 845 | // Check the nonce. |
846 | - if ( empty( $_POST['give_form_meta_nonce'] ) || ! wp_verify_nonce( $_POST['give_form_meta_nonce'], 'give_save_form_meta' ) ) { |
|
846 | + if (empty($_POST['give_form_meta_nonce']) || ! wp_verify_nonce($_POST['give_form_meta_nonce'], 'give_save_form_meta')) { |
|
847 | 847 | return; |
848 | 848 | } |
849 | 849 | |
850 | 850 | // Check the post being saved == the $post_id to prevent triggering this call for other save_post events. |
851 | - if ( empty( $_POST['post_ID'] ) || $_POST['post_ID'] != $post_id ) { |
|
851 | + if (empty($_POST['post_ID']) || $_POST['post_ID'] != $post_id) { |
|
852 | 852 | return; |
853 | 853 | } |
854 | 854 | |
855 | 855 | // Check user has permission to edit. |
856 | - if ( ! current_user_can( 'edit_post', $post_id ) ) { |
|
856 | + if ( ! current_user_can('edit_post', $post_id)) { |
|
857 | 857 | return; |
858 | 858 | } |
859 | 859 | |
860 | 860 | // Fire action before saving form meta. |
861 | - do_action( 'give_pre_process_give_forms_meta', $post_id, $post ); |
|
861 | + do_action('give_pre_process_give_forms_meta', $post_id, $post); |
|
862 | 862 | |
863 | 863 | /** |
864 | 864 | * Filter the meta key to save. |
865 | 865 | * Third party addon developer can remove there meta keys from this array to handle saving data on there own. |
866 | 866 | */ |
867 | - $form_meta_keys = apply_filters( 'give_process_form_meta_keys', $this->get_meta_keys_from_settings() ); |
|
867 | + $form_meta_keys = apply_filters('give_process_form_meta_keys', $this->get_meta_keys_from_settings()); |
|
868 | 868 | |
869 | 869 | // Save form meta data. |
870 | - if ( ! empty( $form_meta_keys ) ) { |
|
871 | - foreach ( $form_meta_keys as $form_meta_key ) { |
|
870 | + if ( ! empty($form_meta_keys)) { |
|
871 | + foreach ($form_meta_keys as $form_meta_key) { |
|
872 | 872 | |
873 | 873 | // Set default value for checkbox fields. |
874 | 874 | if ( |
875 | - ! isset( $_POST[ $form_meta_key ] ) |
|
876 | - && ( 'checkbox' === $this->get_field_type( $form_meta_key ) ) |
|
875 | + ! isset($_POST[$form_meta_key]) |
|
876 | + && ('checkbox' === $this->get_field_type($form_meta_key)) |
|
877 | 877 | ) { |
878 | - $_POST[ $form_meta_key ] = ''; |
|
878 | + $_POST[$form_meta_key] = ''; |
|
879 | 879 | } |
880 | 880 | |
881 | - if ( isset( $_POST[ $form_meta_key ] ) ) { |
|
882 | - $setting_field = $this->get_setting_field( $form_meta_key ); |
|
883 | - if ( ! empty( $setting_field['type'] ) ) { |
|
884 | - switch ( $setting_field['type'] ) { |
|
881 | + if (isset($_POST[$form_meta_key])) { |
|
882 | + $setting_field = $this->get_setting_field($form_meta_key); |
|
883 | + if ( ! empty($setting_field['type'])) { |
|
884 | + switch ($setting_field['type']) { |
|
885 | 885 | case 'textarea': |
886 | 886 | case 'wysiwyg': |
887 | - $form_meta_value = wp_kses_post( $_POST[ $form_meta_key ] ); |
|
887 | + $form_meta_value = wp_kses_post($_POST[$form_meta_key]); |
|
888 | 888 | break; |
889 | 889 | |
890 | 890 | case 'donation_limit' : |
891 | - $form_meta_value = $_POST[ $form_meta_key ]; |
|
891 | + $form_meta_value = $_POST[$form_meta_key]; |
|
892 | 892 | break; |
893 | 893 | |
894 | 894 | case 'group': |
895 | 895 | $form_meta_value = array(); |
896 | 896 | |
897 | - foreach ( $_POST[ $form_meta_key ] as $index => $group ) { |
|
897 | + foreach ($_POST[$form_meta_key] as $index => $group) { |
|
898 | 898 | |
899 | 899 | // Do not save template input field values. |
900 | - if ( '{{row-count-placeholder}}' === $index ) { |
|
900 | + if ('{{row-count-placeholder}}' === $index) { |
|
901 | 901 | continue; |
902 | 902 | } |
903 | 903 | |
904 | 904 | $group_meta_value = array(); |
905 | - foreach ( $group as $field_id => $field_value ) { |
|
906 | - switch ( $this->get_field_type( $field_id, $form_meta_key ) ) { |
|
905 | + foreach ($group as $field_id => $field_value) { |
|
906 | + switch ($this->get_field_type($field_id, $form_meta_key)) { |
|
907 | 907 | case 'wysiwyg': |
908 | - $group_meta_value[ $field_id ] = wp_kses_post( $field_value ); |
|
908 | + $group_meta_value[$field_id] = wp_kses_post($field_value); |
|
909 | 909 | break; |
910 | 910 | |
911 | 911 | default: |
912 | - $group_meta_value[ $field_id ] = give_clean( $field_value ); |
|
912 | + $group_meta_value[$field_id] = give_clean($field_value); |
|
913 | 913 | } |
914 | 914 | } |
915 | 915 | |
916 | - if ( ! empty( $group_meta_value ) ) { |
|
917 | - $form_meta_value[ $index ] = $group_meta_value; |
|
916 | + if ( ! empty($group_meta_value)) { |
|
917 | + $form_meta_value[$index] = $group_meta_value; |
|
918 | 918 | } |
919 | 919 | } |
920 | 920 | |
921 | 921 | // Arrange repeater field keys in order. |
922 | - $form_meta_value = array_values( $form_meta_value ); |
|
922 | + $form_meta_value = array_values($form_meta_value); |
|
923 | 923 | break; |
924 | 924 | |
925 | 925 | default: |
926 | - $form_meta_value = give_clean( $_POST[ $form_meta_key ] ); |
|
926 | + $form_meta_value = give_clean($_POST[$form_meta_key]); |
|
927 | 927 | }// End switch(). |
928 | 928 | |
929 | 929 | /** |
@@ -933,38 +933,38 @@ discard block |
||
933 | 933 | */ |
934 | 934 | $form_meta_value = apply_filters( |
935 | 935 | 'give_pre_save_form_meta_value', |
936 | - $this->sanitize_form_meta( $form_meta_value, $setting_field ), |
|
936 | + $this->sanitize_form_meta($form_meta_value, $setting_field), |
|
937 | 937 | $form_meta_key, |
938 | 938 | $this, |
939 | 939 | $post_id |
940 | 940 | ); |
941 | 941 | |
942 | 942 | // Range slider. |
943 | - if ( 'donation_limit' === $setting_field['type'] ) { |
|
943 | + if ('donation_limit' === $setting_field['type']) { |
|
944 | 944 | |
945 | 945 | // Sanitize amount for db. |
946 | - $form_meta_value = array_map( 'give_sanitize_amount_for_db', $form_meta_value ); |
|
946 | + $form_meta_value = array_map('give_sanitize_amount_for_db', $form_meta_value); |
|
947 | 947 | |
948 | 948 | // Store it to form meta. |
949 | - give_update_meta( $post_id, $form_meta_key . '_minimum', $form_meta_value['minimum'] ); |
|
950 | - give_update_meta( $post_id, $form_meta_key . '_maximum', $form_meta_value['maximum'] ); |
|
949 | + give_update_meta($post_id, $form_meta_key.'_minimum', $form_meta_value['minimum']); |
|
950 | + give_update_meta($post_id, $form_meta_key.'_maximum', $form_meta_value['maximum']); |
|
951 | 951 | } else { |
952 | 952 | // Save data. |
953 | - give_update_meta( $post_id, $form_meta_key, $form_meta_value ); |
|
953 | + give_update_meta($post_id, $form_meta_key, $form_meta_value); |
|
954 | 954 | } |
955 | 955 | |
956 | 956 | // Verify and delete form meta based on the form status. |
957 | - give_set_form_closed_status( $post_id ); |
|
957 | + give_set_form_closed_status($post_id); |
|
958 | 958 | |
959 | 959 | // Fire after saving form meta key. |
960 | - do_action( "give_save_{$form_meta_key}", $form_meta_key, $form_meta_value, $post_id, $post ); |
|
960 | + do_action("give_save_{$form_meta_key}", $form_meta_key, $form_meta_value, $post_id, $post); |
|
961 | 961 | }// End if(). |
962 | 962 | }// End if(). |
963 | 963 | }// End foreach(). |
964 | 964 | }// End if(). |
965 | 965 | |
966 | 966 | // Fire action after saving form meta. |
967 | - do_action( 'give_post_process_give_forms_meta', $post_id, $post ); |
|
967 | + do_action('give_post_process_give_forms_meta', $post_id, $post); |
|
968 | 968 | } |
969 | 969 | |
970 | 970 | |
@@ -977,10 +977,10 @@ discard block |
||
977 | 977 | * |
978 | 978 | * @return string |
979 | 979 | */ |
980 | - private function get_field_id( $field ) { |
|
980 | + private function get_field_id($field) { |
|
981 | 981 | $field_id = ''; |
982 | 982 | |
983 | - if ( array_key_exists( 'id', $field ) ) { |
|
983 | + if (array_key_exists('id', $field)) { |
|
984 | 984 | $field_id = $field['id']; |
985 | 985 | |
986 | 986 | } |
@@ -997,16 +997,16 @@ discard block |
||
997 | 997 | * |
998 | 998 | * @return array |
999 | 999 | */ |
1000 | - private function get_fields_id( $setting ) { |
|
1000 | + private function get_fields_id($setting) { |
|
1001 | 1001 | $meta_keys = array(); |
1002 | 1002 | |
1003 | 1003 | if ( |
1004 | - ! empty( $setting ) |
|
1005 | - && array_key_exists( 'fields', $setting ) |
|
1006 | - && ! empty( $setting['fields'] ) |
|
1004 | + ! empty($setting) |
|
1005 | + && array_key_exists('fields', $setting) |
|
1006 | + && ! empty($setting['fields']) |
|
1007 | 1007 | ) { |
1008 | - foreach ( $setting['fields'] as $field ) { |
|
1009 | - if ( $field_id = $this->get_field_id( $field ) ) { |
|
1008 | + foreach ($setting['fields'] as $field) { |
|
1009 | + if ($field_id = $this->get_field_id($field)) { |
|
1010 | 1010 | $meta_keys[] = $field_id; |
1011 | 1011 | } |
1012 | 1012 | } |
@@ -1024,14 +1024,14 @@ discard block |
||
1024 | 1024 | * |
1025 | 1025 | * @return array |
1026 | 1026 | */ |
1027 | - private function get_sub_fields_id( $setting ) { |
|
1027 | + private function get_sub_fields_id($setting) { |
|
1028 | 1028 | $meta_keys = array(); |
1029 | 1029 | |
1030 | - if ( $this->has_sub_tab( $setting ) && ! empty( $setting['sub-fields'] ) ) { |
|
1031 | - foreach ( $setting['sub-fields'] as $fields ) { |
|
1032 | - if ( ! empty( $fields['fields'] ) ) { |
|
1033 | - foreach ( $fields['fields'] as $field ) { |
|
1034 | - if ( $field_id = $this->get_field_id( $field ) ) { |
|
1030 | + if ($this->has_sub_tab($setting) && ! empty($setting['sub-fields'])) { |
|
1031 | + foreach ($setting['sub-fields'] as $fields) { |
|
1032 | + if ( ! empty($fields['fields'])) { |
|
1033 | + foreach ($fields['fields'] as $field) { |
|
1034 | + if ($field_id = $this->get_field_id($field)) { |
|
1035 | 1035 | $meta_keys[] = $field_id; |
1036 | 1036 | } |
1037 | 1037 | } |
@@ -1053,14 +1053,14 @@ discard block |
||
1053 | 1053 | private function get_meta_keys_from_settings() { |
1054 | 1054 | $meta_keys = array(); |
1055 | 1055 | |
1056 | - foreach ( $this->settings as $setting ) { |
|
1057 | - $meta_key = $this->get_fields_id( $setting ); |
|
1056 | + foreach ($this->settings as $setting) { |
|
1057 | + $meta_key = $this->get_fields_id($setting); |
|
1058 | 1058 | |
1059 | - if ( $this->has_sub_tab( $setting ) ) { |
|
1060 | - $meta_key = array_merge( $meta_key, $this->get_sub_fields_id( $setting ) ); |
|
1059 | + if ($this->has_sub_tab($setting)) { |
|
1060 | + $meta_key = array_merge($meta_key, $this->get_sub_fields_id($setting)); |
|
1061 | 1061 | } |
1062 | 1062 | |
1063 | - $meta_keys = array_merge( $meta_keys, $meta_key ); |
|
1063 | + $meta_keys = array_merge($meta_keys, $meta_key); |
|
1064 | 1064 | } |
1065 | 1065 | |
1066 | 1066 | return $meta_keys; |
@@ -1077,10 +1077,10 @@ discard block |
||
1077 | 1077 | * |
1078 | 1078 | * @return string |
1079 | 1079 | */ |
1080 | - function get_field_type( $field_id, $group_id = '' ) { |
|
1081 | - $field = $this->get_setting_field( $field_id, $group_id ); |
|
1080 | + function get_field_type($field_id, $group_id = '') { |
|
1081 | + $field = $this->get_setting_field($field_id, $group_id); |
|
1082 | 1082 | |
1083 | - $type = array_key_exists( 'type', $field ) |
|
1083 | + $type = array_key_exists('type', $field) |
|
1084 | 1084 | ? $field['type'] |
1085 | 1085 | : ''; |
1086 | 1086 | |
@@ -1098,12 +1098,12 @@ discard block |
||
1098 | 1098 | * |
1099 | 1099 | * @return array |
1100 | 1100 | */ |
1101 | - private function get_field( $setting, $field_id ) { |
|
1101 | + private function get_field($setting, $field_id) { |
|
1102 | 1102 | $setting_field = array(); |
1103 | 1103 | |
1104 | - if ( ! empty( $setting['fields'] ) ) { |
|
1105 | - foreach ( $setting['fields'] as $field ) { |
|
1106 | - if ( array_key_exists( 'id', $field ) && $field['id'] === $field_id ) { |
|
1104 | + if ( ! empty($setting['fields'])) { |
|
1105 | + foreach ($setting['fields'] as $field) { |
|
1106 | + if (array_key_exists('id', $field) && $field['id'] === $field_id) { |
|
1107 | 1107 | $setting_field = $field; |
1108 | 1108 | break; |
1109 | 1109 | } |
@@ -1123,12 +1123,12 @@ discard block |
||
1123 | 1123 | * |
1124 | 1124 | * @return array |
1125 | 1125 | */ |
1126 | - private function get_sub_field( $setting, $field_id ) { |
|
1126 | + private function get_sub_field($setting, $field_id) { |
|
1127 | 1127 | $setting_field = array(); |
1128 | 1128 | |
1129 | - if ( ! empty( $setting['sub-fields'] ) ) { |
|
1130 | - foreach ( $setting['sub-fields'] as $fields ) { |
|
1131 | - if ( $field = $this->get_field( $fields, $field_id ) ) { |
|
1129 | + if ( ! empty($setting['sub-fields'])) { |
|
1130 | + foreach ($setting['sub-fields'] as $fields) { |
|
1131 | + if ($field = $this->get_field($fields, $field_id)) { |
|
1132 | 1132 | $setting_field = $field; |
1133 | 1133 | break; |
1134 | 1134 | } |
@@ -1148,17 +1148,17 @@ discard block |
||
1148 | 1148 | * |
1149 | 1149 | * @return array |
1150 | 1150 | */ |
1151 | - function get_setting_field( $field_id, $group_id = '' ) { |
|
1151 | + function get_setting_field($field_id, $group_id = '') { |
|
1152 | 1152 | $setting_field = array(); |
1153 | 1153 | |
1154 | 1154 | $_field_id = $field_id; |
1155 | - $field_id = empty( $group_id ) ? $field_id : $group_id; |
|
1155 | + $field_id = empty($group_id) ? $field_id : $group_id; |
|
1156 | 1156 | |
1157 | - if ( ! empty( $this->settings ) ) { |
|
1158 | - foreach ( $this->settings as $setting ) { |
|
1157 | + if ( ! empty($this->settings)) { |
|
1158 | + foreach ($this->settings as $setting) { |
|
1159 | 1159 | if ( |
1160 | - ( $this->has_sub_tab( $setting ) && ( $setting_field = $this->get_sub_field( $setting, $field_id ) ) ) |
|
1161 | - || ( $setting_field = $this->get_field( $setting, $field_id ) ) |
|
1160 | + ($this->has_sub_tab($setting) && ($setting_field = $this->get_sub_field($setting, $field_id))) |
|
1161 | + || ($setting_field = $this->get_field($setting, $field_id)) |
|
1162 | 1162 | ) { |
1163 | 1163 | break; |
1164 | 1164 | } |
@@ -1166,9 +1166,9 @@ discard block |
||
1166 | 1166 | } |
1167 | 1167 | |
1168 | 1168 | // Get field from group. |
1169 | - if ( ! empty( $group_id ) ) { |
|
1170 | - foreach ( $setting_field['fields'] as $field ) { |
|
1171 | - if ( array_key_exists( 'id', $field ) && $field['id'] === $_field_id ) { |
|
1169 | + if ( ! empty($group_id)) { |
|
1170 | + foreach ($setting_field['fields'] as $field) { |
|
1171 | + if (array_key_exists('id', $field) && $field['id'] === $_field_id) { |
|
1172 | 1172 | $setting_field = $field; |
1173 | 1173 | } |
1174 | 1174 | } |
@@ -1187,14 +1187,14 @@ discard block |
||
1187 | 1187 | * |
1188 | 1188 | * @return mixed |
1189 | 1189 | */ |
1190 | - function add_offline_donations_setting_tab( $settings ) { |
|
1191 | - if ( give_is_gateway_active( 'offline' ) ) { |
|
1192 | - $settings['offline_donations_options'] = apply_filters( 'give_forms_offline_donations_options', array( |
|
1190 | + function add_offline_donations_setting_tab($settings) { |
|
1191 | + if (give_is_gateway_active('offline')) { |
|
1192 | + $settings['offline_donations_options'] = apply_filters('give_forms_offline_donations_options', array( |
|
1193 | 1193 | 'id' => 'offline_donations_options', |
1194 | - 'title' => __( 'Offline Donations', 'give' ), |
|
1194 | + 'title' => __('Offline Donations', 'give'), |
|
1195 | 1195 | 'icon-html' => '<span class="give-icon give-icon-purse"></span>', |
1196 | - 'fields' => apply_filters( 'give_forms_offline_donations_metabox_fields', array() ), |
|
1197 | - ) ); |
|
1196 | + 'fields' => apply_filters('give_forms_offline_donations_metabox_fields', array()), |
|
1197 | + )); |
|
1198 | 1198 | } |
1199 | 1199 | |
1200 | 1200 | return $settings; |
@@ -1212,37 +1212,33 @@ discard block |
||
1212 | 1212 | * |
1213 | 1213 | * @return mixed |
1214 | 1214 | */ |
1215 | - function sanitize_form_meta( $meta_value, $setting_field ) { |
|
1216 | - switch ( $setting_field['type'] ) { |
|
1215 | + function sanitize_form_meta($meta_value, $setting_field) { |
|
1216 | + switch ($setting_field['type']) { |
|
1217 | 1217 | case 'group': |
1218 | - if ( ! empty( $setting_field['fields'] ) ) { |
|
1219 | - foreach ( $setting_field['fields'] as $field ) { |
|
1220 | - if ( empty( $field['data_type'] ) || 'price' !== $field['data_type'] ) { |
|
1218 | + if ( ! empty($setting_field['fields'])) { |
|
1219 | + foreach ($setting_field['fields'] as $field) { |
|
1220 | + if (empty($field['data_type']) || 'price' !== $field['data_type']) { |
|
1221 | 1221 | continue; |
1222 | 1222 | } |
1223 | 1223 | |
1224 | - foreach ( $meta_value as $index => $meta_data ) { |
|
1225 | - if ( ! isset( $meta_value[ $index ][ $field['id'] ] ) ) { |
|
1224 | + foreach ($meta_value as $index => $meta_data) { |
|
1225 | + if ( ! isset($meta_value[$index][$field['id']])) { |
|
1226 | 1226 | continue; |
1227 | 1227 | } |
1228 | 1228 | |
1229 | - $meta_value[ $index ][ $field['id'] ] = ! empty( $meta_value[ $index ][ $field['id'] ] ) ? |
|
1230 | - give_sanitize_amount_for_db( $meta_value[ $index ][ $field['id'] ] ) : |
|
1231 | - ( ( '_give_amount' === $field['id'] && empty( $field_value ) ) ? |
|
1232 | - give_sanitize_amount_for_db( '1.00' ) : |
|
1233 | - 0 ); |
|
1229 | + $meta_value[$index][$field['id']] = ! empty($meta_value[$index][$field['id']]) ? |
|
1230 | + give_sanitize_amount_for_db($meta_value[$index][$field['id']]) : (('_give_amount' === $field['id'] && empty($field_value)) ? |
|
1231 | + give_sanitize_amount_for_db('1.00') : 0); |
|
1234 | 1232 | } |
1235 | 1233 | } |
1236 | 1234 | } |
1237 | 1235 | break; |
1238 | 1236 | |
1239 | 1237 | default: |
1240 | - if ( ! empty( $setting_field['data_type'] ) && 'price' === $setting_field['data_type'] ) { |
|
1238 | + if ( ! empty($setting_field['data_type']) && 'price' === $setting_field['data_type']) { |
|
1241 | 1239 | $meta_value = $meta_value ? |
1242 | - give_sanitize_amount_for_db( $meta_value ) : |
|
1243 | - ( in_array( $setting_field['id'], array( '_give_set_price', '_give_custom_amount_minimum', '_give_set_goal' ) ) ? |
|
1244 | - give_sanitize_amount_for_db( '1.00' ) : |
|
1245 | - 0 ); |
|
1240 | + give_sanitize_amount_for_db($meta_value) : (in_array($setting_field['id'], array('_give_set_price', '_give_custom_amount_minimum', '_give_set_goal')) ? |
|
1241 | + give_sanitize_amount_for_db('1.00') : 0); |
|
1246 | 1242 | } |
1247 | 1243 | } |
1248 | 1244 | |
@@ -1260,12 +1256,12 @@ discard block |
||
1260 | 1256 | * |
1261 | 1257 | * @return string The URL after redirect. |
1262 | 1258 | */ |
1263 | - public function maintain_active_tab( $location, $post_id ) { |
|
1259 | + public function maintain_active_tab($location, $post_id) { |
|
1264 | 1260 | if ( |
1265 | - 'give_forms' === get_post_type( $post_id ) && |
|
1266 | - ! empty( $_POST['give_form_active_tab'] ) |
|
1261 | + 'give_forms' === get_post_type($post_id) && |
|
1262 | + ! empty($_POST['give_form_active_tab']) |
|
1267 | 1263 | ) { |
1268 | - $location = add_query_arg( 'give_tab', give_clean( $_POST['give_form_active_tab'] ), $location ); |
|
1264 | + $location = add_query_arg('give_tab', give_clean($_POST['give_form_active_tab']), $location); |
|
1269 | 1265 | } |
1270 | 1266 | |
1271 | 1267 | return $location; |
@@ -9,11 +9,11 @@ discard block |
||
9 | 9 | * @since 1.8 |
10 | 10 | */ |
11 | 11 | |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; // Exit if accessed directly. |
14 | 14 | } |
15 | 15 | |
16 | -if ( ! class_exists( 'Give_Settings_License' ) ) : |
|
16 | +if ( ! class_exists('Give_Settings_License')) : |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Give_Settings_License. |
@@ -27,12 +27,12 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public function __construct() { |
29 | 29 | $this->id = 'licenses'; |
30 | - $this->label = esc_html__( 'Licenses', 'give' ); |
|
30 | + $this->label = esc_html__('Licenses', 'give'); |
|
31 | 31 | |
32 | 32 | parent::__construct(); |
33 | 33 | |
34 | 34 | // Filter to remove the license tab. |
35 | - add_filter( 'give-settings_tabs_array', array( $this, 'remove_license_tab' ), 9999999, 1 ); |
|
35 | + add_filter('give-settings_tabs_array', array($this, 'remove_license_tab'), 9999999, 1); |
|
36 | 36 | |
37 | 37 | } |
38 | 38 | |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * Filter the licenses settings. |
50 | 50 | * Backward compatibility: Please do not use this filter. This filter is deprecated in 1.8 |
51 | 51 | */ |
52 | - $settings = apply_filters( 'give_settings_licenses', $settings ); |
|
52 | + $settings = apply_filters('give_settings_licenses', $settings); |
|
53 | 53 | |
54 | 54 | /** |
55 | 55 | * Filter the settings. |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | * |
59 | 59 | * @param array $settings |
60 | 60 | */ |
61 | - $settings = apply_filters( 'give_get_settings_' . $this->id, $settings ); |
|
61 | + $settings = apply_filters('give_get_settings_'.$this->id, $settings); |
|
62 | 62 | |
63 | 63 | // Output. |
64 | 64 | return $settings; |
@@ -74,13 +74,13 @@ discard block |
||
74 | 74 | * |
75 | 75 | * @return array |
76 | 76 | */ |
77 | - public function remove_license_tab( $tabs ) { |
|
77 | + public function remove_license_tab($tabs) { |
|
78 | 78 | /** |
79 | 79 | * Remove the license tab if no Give licensed addon |
80 | 80 | * is activated. |
81 | 81 | */ |
82 | - if ( ! $this->is_show_setting_page() ) { |
|
83 | - unset( $tabs['licenses'] ); |
|
82 | + if ( ! $this->is_show_setting_page()) { |
|
83 | + unset($tabs['licenses']); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | return $tabs; |
@@ -97,17 +97,17 @@ discard block |
||
97 | 97 | */ |
98 | 98 | private function is_show_setting_page() { |
99 | 99 | $licensed_addons = Give_License::get_licensed_addons(); |
100 | - $activated_plugins = get_option( 'active_plugins', array() ); |
|
100 | + $activated_plugins = get_option('active_plugins', array()); |
|
101 | 101 | |
102 | 102 | // Get list of network enabled plugin. |
103 | - if ( is_multisite() ) { |
|
104 | - $sitewide_activated_plugins = array_keys( get_site_option( 'active_sitewide_plugins', array() ) ); |
|
105 | - $activated_plugins = ! empty( $activated_plugins ) |
|
106 | - ? array_merge( $sitewide_activated_plugins, $activated_plugins ) |
|
103 | + if (is_multisite()) { |
|
104 | + $sitewide_activated_plugins = array_keys(get_site_option('active_sitewide_plugins', array())); |
|
105 | + $activated_plugins = ! empty($activated_plugins) |
|
106 | + ? array_merge($sitewide_activated_plugins, $activated_plugins) |
|
107 | 107 | : $sitewide_activated_plugins; |
108 | 108 | } |
109 | 109 | |
110 | - return (bool) count( array_intersect( $activated_plugins, $licensed_addons ) ); |
|
110 | + return (bool) count(array_intersect($activated_plugins, $licensed_addons)); |
|
111 | 111 | } |
112 | 112 | } |
113 | 113 |