akismet
3 years ago
constant-contact
3 years ago
recaptcha
3 years ago
sendinblue
3 years ago
stripe
3 years ago
acceptance.php
3 years ago
checkbox.php
3 years ago
count.php
3 years ago
date.php
3 years ago
disallowed-list.php
4 years ago
doi-helper.php
4 years ago
file.php
3 years ago
flamingo.php
3 years ago
hidden.php
7 years ago
listo.php
9 years ago
number.php
3 years ago
quiz.php
4 years ago
really-simple-captcha.php
3 years ago
reflection.php
3 years ago
response.php
6 years ago
select.php
3 years ago
submit.php
4 years ago
text.php
3 years ago
textarea.php
3 years ago
reflection.php
54 lines
| 1 | <?php |
| 2 | |
| 3 | add_action( 'wpcf7_init', 'wpcf7_add_form_tag_reflection', 10, 0 ); |
| 4 | |
| 5 | function wpcf7_add_form_tag_reflection() { |
| 6 | wpcf7_add_form_tag( 'reflection', |
| 7 | 'wpcf7_reflection_form_tag_handler', |
| 8 | array( |
| 9 | 'name-attr' => true, |
| 10 | 'display-block' => true, |
| 11 | 'not-for-mail' => true, |
| 12 | ) |
| 13 | ); |
| 14 | } |
| 15 | |
| 16 | function wpcf7_reflection_form_tag_handler( $tag ) { |
| 17 | if ( empty( $tag->name ) ) { |
| 18 | return ''; |
| 19 | } |
| 20 | |
| 21 | $content = ''; |
| 22 | |
| 23 | $values = (array) wpcf7_get_hangover( $tag->name ); |
| 24 | |
| 25 | if ( $values and ! wpcf7_get_validation_error( $tag->name ) ) { |
| 26 | $values = array_map( |
| 27 | function ( $val ) use ( $tag ) { |
| 28 | return sprintf( |
| 29 | '<output name="%1$s">%2$s</output>', |
| 30 | esc_attr( $tag->name ), |
| 31 | esc_html( $val ) |
| 32 | ); |
| 33 | }, |
| 34 | $values |
| 35 | ); |
| 36 | |
| 37 | $content = implode( '', $values ); |
| 38 | } |
| 39 | |
| 40 | $html = sprintf( |
| 41 | '<fieldset %1$s>%2$s</fieldset>', |
| 42 | wpcf7_format_atts( array( |
| 43 | 'data-reflection-of' => $tag->name, |
| 44 | 'class' => $tag->get_class_option( |
| 45 | wpcf7_form_controls_class( $tag->type ) |
| 46 | ), |
| 47 | 'id' => $tag->get_id_option(), |
| 48 | ) ), |
| 49 | $content |
| 50 | ); |
| 51 | |
| 52 | return $html; |
| 53 | } |
| 54 |