cf7-conditional-fields
Last commit date
js
19 hours ago
jsdoc-out
19 hours ago
test-results
2 months ago
Wpcf7cfMailParser.php
3 days ago
admin-style.css
2 years ago
admin-style.css.map
2 years ago
admin-style.scss
4 years ago
admin.php
19 hours ago
cf7cf.php
2 weeks ago
conditional-fields.php
19 hours ago
contact-form-7-conditional-fields.php
1 year ago
init.php
19 hours ago
readme.txt
19 hours ago
style.css
2 months ago
tg_pane_group.php
2 months ago
wpcf7cf-options.php
2 months ago
tg_pane_group.php
153 lines
| 1 | <?php |
| 2 | /** |
| 3 | ** A base module for [group] |
| 4 | **/ |
| 5 | |
| 6 | /* form_tag handler */ |
| 7 | |
| 8 | add_action( 'wpcf7_init', 'wpcf7_add_form_tag_group', 10, 0 ); |
| 9 | |
| 10 | function wpcf7_add_form_tag_group() { |
| 11 | wpcf7_add_form_tag( 'group', |
| 12 | 'wpcf7_group_form_tag_handler', |
| 13 | array( |
| 14 | 'name-attr' => true, |
| 15 | 'selectable-values' => true, |
| 16 | ) |
| 17 | ); |
| 18 | } |
| 19 | |
| 20 | function wpcf7_group_form_tag_handler( $tag ) { |
| 21 | // Frontend output code comes here |
| 22 | } |
| 23 | |
| 24 | |
| 25 | /* Validation filter */ |
| 26 | |
| 27 | add_filter( 'wpcf7_validate_group', |
| 28 | 'wpcf7_group_validation_filter', 10, 2 ); |
| 29 | |
| 30 | function wpcf7_group_validation_filter( $result, $tag ) { |
| 31 | // Frontend validation code comes here |
| 32 | } |
| 33 | |
| 34 | |
| 35 | /* Tag generator */ |
| 36 | |
| 37 | add_action( 'wpcf7_admin_init', 'wpcf7_add_tag_generator_group', 600, 0 ); |
| 38 | |
| 39 | function wpcf7_add_tag_generator_group() { |
| 40 | $tag_generator = WPCF7_TagGenerator::get_instance(); |
| 41 | |
| 42 | do_action('wpcf7cf_tag_generator'); |
| 43 | |
| 44 | $tag_generator->add( 'group', __( 'Conditional group', 'cf7-conditional-fields' ), |
| 45 | 'wpcf7_tag_generator_group', |
| 46 | array( 'version' => '2' ) |
| 47 | ); |
| 48 | } |
| 49 | |
| 50 | function wpcf7_tag_generator_group( $contact_form, $options ) { |
| 51 | $field_types = array( |
| 52 | 'group' => array( |
| 53 | 'display_name' => __( 'Conditional group', 'cf7-conditional-fields' ), |
| 54 | 'heading' => __( 'Conditional group form-tag generator', 'cf7-conditional-fields' ), |
| 55 | 'description' => __( 'Generates the opening and closing form-tag for a Conditional group.', 'cf7-conditional-fields' ), |
| 56 | ), |
| 57 | ); |
| 58 | |
| 59 | $tgg = new WPCF7_TagGeneratorGenerator( $options['content'] ); |
| 60 | |
| 61 | ?> |
| 62 | <header class="description-box"> |
| 63 | <h3><?php |
| 64 | echo esc_html( $field_types['group']['heading'] ); |
| 65 | ?></h3> |
| 66 | |
| 67 | <p><?php |
| 68 | $description = wp_kses( |
| 69 | $field_types['group']['description'], |
| 70 | array( |
| 71 | 'a' => array( 'href' => true ), |
| 72 | 'strong' => array(), |
| 73 | ), |
| 74 | array( 'http', 'https' ) |
| 75 | ); |
| 76 | |
| 77 | echo $description; |
| 78 | ?></p> |
| 79 | </header> |
| 80 | |
| 81 | <div class="control-box"> |
| 82 | <fieldset style="display:none;"> |
| 83 | <legend id="<?php echo esc_attr( $tgg->ref( 'type-legend' ) ); ?>"><?php |
| 84 | echo esc_html( __( 'Field type', 'contact-form-7' ) ); |
| 85 | ?></legend> |
| 86 | |
| 87 | <select data-tag-part="basetype" aria-labelledby="<?php echo esc_attr( $tgg->ref( 'type-legend' ) ); ?>"><?php |
| 88 | echo sprintf( |
| 89 | '<option %1$s>%2$s</option>', |
| 90 | wpcf7_format_atts( array( |
| 91 | 'value' => 'group', |
| 92 | ) ), |
| 93 | esc_html( $field_types['group']['display_name'] ) |
| 94 | ); |
| 95 | ?></select> |
| 96 | |
| 97 | </fieldset> |
| 98 | |
| 99 | <fieldset> |
| 100 | <legend id="tag-generator-panel-group-name-legend">Group name</legend> |
| 101 | <input type="text" data-tag-part="name" pattern="[A-Za-z][A-Za-z0-9_\-]*" aria-labelledby="tag-generator-panel-group-name-legend"> |
| 102 | </fieldset> |
| 103 | |
| 104 | |
| 105 | <fieldset> |
| 106 | <legend id="<?php echo esc_attr( $tgg->ref( 'type-legend' ) ); ?>"><?php |
| 107 | echo esc_html( __( 'Options', 'cf7-conditional-fields' ) ); |
| 108 | ?></legend> |
| 109 | <label> |
| 110 | <input type="checkbox" data-tag-part="option" data-tag-option="clear_on_hide" /> |
| 111 | <strong>clear_on_hide</strong> (<?php echo esc_html( __( "clear inner fields when this group is hidden", 'cf7-conditional-fields' ) ); ?>) |
| 112 | </label> |
| 113 | <br> |
| 114 | <label> |
| 115 | <input type="checkbox" data-tag-part="option" data-tag-option="inline" /> |
| 116 | <strong>inline</strong> (<?php echo esc_html( __( "use <span> instead of <div>", 'cf7-conditional-fields' ) ); ?>) |
| 117 | </label> |
| 118 | <?php if (WPCF7CF_IS_PRO) { ?> |
| 119 | <br> |
| 120 | <label> |
| 121 | <input type="checkbox" data-tag-part="option" data-tag-option="disable_on_hide" /> |
| 122 | <strong>disable_on_hide</strong> (<?php echo esc_html( __( "disable inner fields when this group is hidden", 'cf7-conditional-fields' ) ); ?>) |
| 123 | </label> |
| 124 | <?php } ?> |
| 125 | </fieldset> |
| 126 | |
| 127 | <?php |
| 128 | |
| 129 | $tgg->print( 'class_attr' ); |
| 130 | ?> |
| 131 | |
| 132 | <?php |
| 133 | echo sprintf( |
| 134 | '<input %s />', |
| 135 | wpcf7_format_atts( array( |
| 136 | 'type' => 'hidden', |
| 137 | 'required' => false, |
| 138 | 'value' => '…', |
| 139 | 'data-tag-part' => 'content', |
| 140 | ) ) |
| 141 | ); |
| 142 | ?> |
| 143 | </div> |
| 144 | |
| 145 | <footer class="insert-box"> |
| 146 | <?php |
| 147 | $tgg->print( 'insert_box_content' ); |
| 148 | ?> |
| 149 | <p class="mail-tag-tip">To show conditional information in the email, put it between <strong data-tag-part="mail-tag">[group-455]</strong> and <strong data-tag-part="mail-tag-closed">[/group-455]</strong> in the email template.</p> |
| 150 | </footer> |
| 151 | <?php |
| 152 | } |
| 153 |