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