PluginProbe
Smart Grid-Layout Design for Contact Form 7 / 4.5
Smart Grid-Layout Design for Contact Form 7 v4.5
4.18.0 4.17.0 3.2.0 3.2.1 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 4.0.0 4.0.1 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4 4.10 4.11 4.12 4.13 4.14 All 119 releases
← All changes | admin/partials/cf7-dynamic-tag-display.php +93 -156 4.134.5 View file →
@@ -11,16 +11,15 @@
11 11 * @package Cf7_2_Post
12 12 * @subpackage Cf7_2_Post/admin/partials
13 13 */
14 14 //TODO: add a check box to include or not address fields
15 - $class = str_replace('_','-' ,$tag_id);
16 15 ?>
17 16
18 17 <!-- This file should primarily consist of HTML with a little bit of PHP. -->
19 18
20 -<div id="<?=$class?>-tag-generator" data-tag="<?=$tag_id?>" class="control-box cf7-<?=$class?> cf7sg-dynamic-list-tag-manager">
19 +<div id="dynamic-select-tag-generator" class="control-box cf7-dynamic-select">
21 20 <fieldset>
22 - <legend><?= sprintf(__('%s field','cf7-grid-layout'), $dlo->label)?></legend>
21 + <legend><?= __('Dynamic Select Dropdown field','cf7-grid-layout')?></legend>
23 22 <table class="form-table">
24 23 <tbody>
25 24 <tr>
26 25 <th scope="row"><label for="<?= esc_attr( $args['content'] . '-name' ); ?>"><?= esc_html( __cf7sg( 'Name' ) ); ?></label></th>
@@ -43,122 +42,50 @@
43 42 </td>
44 43 </tr>
45 44 <tr>
46 45 <th scope="row"><?=__('Dropdown style','cf7-grid-layout')?></th>
47 - <td class="cf7sg-dl-styles">
48 - <?php
49 - $styles = $dlo->get_tag_generator_styles();
50 - $checked = 'checked="checked"';
51 - $display_none = '';
52 - foreach($styles as $s=>$label):
53 - $id = $tag_id.'-'.$s;
54 - ?>
46 + <td>
55 47 <div>
56 - <label for="<?=$id?>">
57 - <input class="list-style <?=$tag_id?>" name="<?=$tag_id?>-style[]" id="<?=$id?>" type="radio" value="<?=$s?>" <?=$checked?>/>
58 - <?=$label?>
59 - <?php
60 - $extras = $dlo->get_style_extras($s);
61 - // debug_msg($extras, "$tag_id ");
62 - foreach($extras as $val => $field):
63 - $type = 'checkbox';
64 - $label = '';
65 - $attributes = 'disabled';
66 - $html='';
67 - if(is_array($field)){
68 - if(isset($field['label'])) $label = $field['label'];
69 - if(isset($field['type'])) $type = $field['type'];
70 - if(isset($field['attrs'])) $attributes = $field['attrs'];
71 - if(isset($field['html'])) $html = $field['html'];
72 - }else{
73 - $val = $s;
74 - $html = $field;
75 - }
76 - $pre='';
77 - $pst='';
78 - switch($type){
79 - case 'checkbox':
80 - $pst=$label;
81 - break;
82 - case 'number':
83 - case 'text':
84 - $pre=$label;
85 - break;
86 - }
87 - ?>
88 - <span class="cf7sg-se-option cf7sg-se-<?=$val?><?=$display_none?>">
89 - <?php if(!empty($label)):?>
90 - <label for="<?=$s?>-<?=$val?>">
91 - <?=$pre?><input id="<?=$s?>-<?=$val?>" type="<?=$type?>" value="<?=$val?>" <?=$attributes?>/><?=$pst?>
92 - </label>
93 - <?php endif;
94 - if(!empty($html)):?>
95 - <?=$html?>
96 - <?php endif;?>
97 - </span>
98 - <?php endforeach;?>
48 + <label for="html-select">
49 + <input name="select-style[]" id="html-select" class=" select-type " type="radio" value="select" checked="checked"/>
50 + <?=__('HTML Select field','cf7-grid-layout')?>
99 51 </label>
100 52 </div>
101 - <?php
102 - $checked = '';
103 - $display_none=' display-none';
104 - endforeach;?>
53 + <div>
54 + <label for="nice-select">
55 + <input id="nice-select" name="select-style[]" class=" select-type " type="radio" value="nice" />
56 + <a target="_blank" href="http://hernansartorio.com/jquery-nice-select/"><?=__('jQuery Nice Select','cf7-grid-layout')?></a>
57 + </label>
58 + </div>
59 + <div>
60 + <label for="select2-select">
61 + <input id="select2-select" name="select-style[]" class=" select-type " type="radio" value="select2" />
62 + <a target="_blank" href="https://select2.org/getting-started/basic-usage"><?=__('jQuery Select2','cf7-grid-layout')?></a>
63 + </label>
64 + <label for="select2-tags" class="display-none">
65 + <input name="select2-tags" id="select2-tags" type="checkbox" disabled value="select2tags"/>
66 + <a target="_blank" href="https://select2.org/tagging"><?=__('Enable user options','cf7-grid-layout')?></a>
67 + </label>
68 + </div>
105 69 </td>
106 70 </tr>
107 - <tr class="others">
108 - <th scope="row"><?=__('Other attributes','cf7-grid-layout')?></th>
71 + <tr>
72 + <th scope="row"><?=__('Mutliple attribute','cf7-grid-layout')?></th>
109 73 <td>
110 - <?php
111 - $others = $dlo->get_other_extras();
112 - $type = $dlo->get_other_extras_type();
113 - $ckd = ' checked';
114 - foreach($others as $val=>$field):
115 - $label = '<em>unknown field</em>';
116 - $attributes = '';
117 - if(is_array($field)){
118 - if(isset($field['label'])) $label = $field['label'];
119 - if(isset($field['type'])) $type = $field['type'];
120 - if(isset($field['attrs'])) $attributes = $field['attrs'];
121 - }else $label = $field;
122 - $pre='';
123 - $pst='';
124 - $name ='';
125 - switch($type){
126 - case 'checkbox':
127 - $pst=$label;
128 - break;
129 - case 'number':
130 - case 'text':
131 - $pre=$label;
132 - break;
133 - case 'radio':
134 - $name = ' name="dl_extras[]"';
135 - if(empty($val)) $name .=' checked';
136 - break;
137 - }
138 - ?>
139 - <div class="<?=$val?>">
140 - <label for="<?=$tag_id?>-<?=$val?>">
141 - <input class="select-<?=$val?>" id="<?=$tag_id?>-<?=$val?>" type="<?=$type?>" value="<?=$val?>"<?=$name?><?=$ckd?>/>
142 - <?=$label?>
143 - </label>
144 - </div>
145 - <?php
146 - $ckd='';
147 - endforeach;
148 - ?>
74 + <input name="select-multiple" id="select-multiple" type="checkbox" value="multiple"/>
75 + <a target="_blank" href="https://www.w3schools.com/tags/att_select_multiple.asp"><?=__('Enable multiple selection','cf7-grid-layout')?></a>
149 76 </td>
150 77 </tr>
151 78 </tbody>
152 79 </table>
153 - <div class="tabordion cf7sg-dynamic-list-sources">
154 - <section class="taxonomy-source">
155 - <input type="radio" id="<?=$class?>-taxonomy-tab" name="sections" class="taxonomy-tab source-tab" checked>
156 - <label for="<?=$class?>-taxonomy-tab"><?=__('Taxonomy','cf7-grid-layout')?></label>
80 + <div id="dynamic-dropdown-sources" class="tabordion">
81 + <section id="taxonomy-source">
82 + <input type="radio" name="sections" id="taxonomy-tab" checked>
83 + <label for="taxonomy-tab"><?=__('Taxonomy','cf7-grid-layout')?></label>
157 84 <article>
158 85 <h4><?=__('Taxonomy source','cf7-grid-layout')?></h4>
159 86 <select class="taxonomy-list">
160 - <option value="" data-name="" selected="true" ><?=__('Choose a Taxonomy','cf7-grid-layout')?></option>
87 + <option value="" data-name="" ><?=__('Choose a Taxonomy','cf7-grid-layout')?></option>
161 88 <option class="cf7sg-new-taxonomy" value="new_taxonomy" data-name="New Category"><?=__('New Categories','cf7-grid-layout')?></option>
162 89 <?php
163 90 //get options.
164 91 $dropdowns = get_option('_cf7sg_dynamic_dropdown_taxonomy',array());
@@ -163,9 +90,9 @@
163 90 //get options.
164 91 $dropdowns = get_option('_cf7sg_dynamic_dropdown_taxonomy',array());
165 92 $slugs = array();
166 93
167 - foreach($dropdowns as $post_id=>$all_lists){
94 + foreach($dropdowns as $all_lists){
168 95 foreach($all_lists as $slug => $taxonomy){
169 96 if(isset($slugs[$slug]) ){
170 97 continue;
171 98 }else{
@@ -170,29 +97,23 @@
170 97 continue;
171 98 }else{
172 99 $slugs[$slug] = $slug;
173 100 }
174 - echo '<option data-name="' . $taxonomy['singular'] . '" value="'. $taxonomy['slug'] . '" class="cf7sg-taxonomy'.$taxonomy['hierarchical']?' hierarchical':''.'">' . $taxonomy['plural'] . '</option>';
101 + echo '<option selected data-name="' . $taxonomy['singular'] . '" value="'. $taxonomy['slug'] . '" class="cf7sg-taxonomy">' . $taxonomy['plural'] . '</option>';
175 102 }
176 103 }
177 104 //inset the default post tags and category
178 105 ?>
179 106 <option value="post_tag" data-name="Post Tag" class="system-taxonomy"><?=__('Post Tags','cf7-grid-layout')?></option>
180 - <option value="category" data-name="Post Category" class="system-taxonomy hierarchical"><?=__('Post Categories','cf7-grid-layout')?></option>
107 + <option value="category" data-name="Post Category" class="system-taxonomy"><?=__('Post Categories','cf7-grid-layout')?></option>
181 108 <?php
182 109 $system_taxonomies = get_taxonomies( array('public'=>true, '_builtin' => false), 'objects' );
183 110 foreach($system_taxonomies as $taxonomy){
184 111 if( !empty($taxonomy_slug) && $taxonomy_slug == $taxonomy->name ) continue;
185 - echo '<option value="' . $taxonomy->name . '" data-name="' . $taxonomy->labels->singular_name . '" class="system-taxonomy'.$taxonomy->hierarchical? ' hierarchical':''.'">' . $taxonomy->labels->name . '</option>';
112 + echo '<option value="' . $taxonomy->name . '" data-name="' . $taxonomy->labels->singular_name . '" class="system-taxonomy">' . $taxonomy->labels->name . '</option>';
186 113 }
187 114 ?>
188 115 </select>
189 - <?php if($dlo->has_nesting()):/*@since 4.11 enable nested lists*/?>
190 - <label id="enable-branches" class="display-none">
191 - <input type="checkbox" />
192 - <?= __('Include branches','cf7-grid-layout');?>
193 - </label>
194 - <?php endif;?>
195 116 <div class="cf72post-new-taxonomy">
196 117 <div><strong><?=__('New Taxonomy','cf7-grid-layout')?></strong></div>
197 118 <label><?=__('Plural Name','cf7-grid-layout')?><br />
198 119 <input disabled="true" class="cf72post-new-taxonomy" type="text" name="plural_name" value=""></label>
@@ -201,18 +122,17 @@
201 122 <label><?=__('Slug','cf7-grid-layout')?><br />
202 123 <input disabled="true" class="cf72post-new-taxonomy" type="text" name="taxonomy_slug" value="" /></label>
203 124 <label class="hidden"><input class="cf72post-new-taxonomy" type="checkbox" name="is_hierarchical" /><?=__('hierarchical','cf7-grid-layout')?></label>
204 125 </div>
205 - <?php do_action('cf7sg_dynamic_tag_manager_taxonomy_source', $tag_id); ?>
206 126 </article>
207 127 </section>
208 - <section class="post-source">
209 - <input type="radio" id="<?=$class?>-post-tab" name="sections" class="post-tab source-tab">
210 - <label for="<?=$class?>-post-tab"><?=__('Post','cf7-grid-layout')?></label>
128 + <section id="post-source">
129 + <input type="radio" name="sections" id="post-tab">
130 + <label for="post-tab"><?=__('Post','cf7-grid-layout')?></label>
211 131 <article class="">
212 132 <h4><?=__('Post source','cf7-grid-layout')?></h4>
213 - <select id="<?=$class?>-post-list" class="post-list" name="<?=$tag_id?>_post_list">
214 - <option value="" selected><?=__('Select a post','cf7-grid-layout')?></option>
133 + <select class="post-list">
134 + <option value=""><?=__('Select a post','cf7-grid-layout')?></option>
215 135 <?php
216 136 $args = array(
217 137 'show_ui' => true,
218 138 '_builtin' => false
@@ -228,11 +148,10 @@
228 148 $taxonomy_lists[$type] = '';
229 149 foreach($taxonomies as $taxonomy){
230 150 //skup cf7 dynamic list taxonomies.
231 151 if(WPCF7_ContactForm::post_type == $type && 'wpcf7_type' != $taxonomy->name) continue;
232 - if(empty($taxonomy->label)) continue;
233 152 $taxonomy_lists[$type] .= '<optgroup label="'.$taxonomy->label.'">'.PHP_EOL;
234 - $taxonomy_lists[$type] .= $dlo->cf7sg_terms_to_options($taxonomy->name, $taxonomy->hierarchical);
153 + $taxonomy_lists[$type] .= cf7sg_terms_to_options($taxonomy->name, $taxonomy->hierarchical,0);
235 154 $taxonomy_lists[$type] .= '</optgroup>'.PHP_EOL;
236 155 }
237 156 }
238 157 $taxonomies = get_object_taxonomies( 'post', 'objects' );
@@ -237,19 +156,17 @@
237 156 }
238 157 $taxonomies = get_object_taxonomies( 'post', 'objects' );
239 158 $taxonomy_lists['post'] = '';
240 159 foreach($taxonomies as $taxonomy){
241 - if(empty($taxonomy->label)) continue;
242 160 $taxonomy_lists['post'] .= '<optgroup label="'.$taxonomy->label.'">'.PHP_EOL;
243 - $taxonomy_lists['post'] .= $dlo->cf7sg_terms_to_options($taxonomy->name, $taxonomy->hierarchical);
161 + $taxonomy_lists['post'] .= cf7sg_terms_to_options($taxonomy->name, $taxonomy->hierarchical,0);
244 162 $taxonomy_lists['post'] .= '</optgroup>'.PHP_EOL;
245 163 }
246 164 $taxonomies = get_object_taxonomies( 'page', 'objects' );
247 165 $taxonomy_lists['page'] = '';
248 166 foreach($taxonomies as $taxonomy){
249 - if(empty($taxonomy->label)) continue;
250 167 $taxonomy_lists['page'] .= '<optgroup label="'.$taxonomy->label.'">'.PHP_EOL;
251 - $taxonomy_lists['page'] .= $dlo->cf7sg_terms_to_options($taxonomy->name, $taxonomy->hierarchical);
168 + $taxonomy_lists['page'] .= cf7sg_terms_to_options($taxonomy->name, $taxonomy->hierarchical,0);
252 169 $taxonomy_lists['page'] .= '</optgroup>'.PHP_EOL;
253 170 }
254 171 ?>
255 172 <option value="post"><?=__('Posts','cf7-grid-layout')?></option>
@@ -254,57 +171,77 @@
254 171 ?>
255 172 <option value="post"><?=__('Posts','cf7-grid-layout')?></option>
256 173 <option value="page"><?=__('Pages','cf7-grid-layout')?></option>
257 174 </select>
258 - <div class="<?=$class?>-post-options">
259 - <label for="<?=$class?>-post-links" class="<?=$class?> include-links">
260 - <input id="<?=$class?>-post-links" value="include_links" name="<?=$tag_id?>_post_links" type="checkbox" class="include-post-links"/><?= __('Include post links','cf7-grid-layout')?>
261 - </label>
262 - <label for="<?=$class?>-post-images" class="<?=$class?> include-images">
263 - <input id="<?=$class?>-post-images" value="include_imgs" name="<?=$tag_id?>_post_imgs" type="checkbox" class="include-post-images"/><?= __('Include post thumbnails','cf7-grid-layout')?>
264 - </label>
265 - </div>
175 + <label><input type="checkbox" id="include-post-links"/><?= __('Include post links','cf7-grid-layout')?></label>
266 176
267 177 <?php foreach($taxonomy_lists as $type=>$list ):
268 178 if(empty($list)) continue;
269 179 ?>
270 - <div id="" class="post-taxonomies cf7sg-dynamic-tag hidden <?= $type ?>">
271 - <select id="<?=$class?>-<?=$type?>" multiple class="select2" name="<?=$tag_id?>_<?=$type?>">
272 - <option value=""><?=__('Filter by terms', 'cf7-grid-layout')?></option>
273 - <?= $list?>
180 + <div id="<?php echo $type ?>" class="post-taxonomies hidden">
181 + <select multiple class="select2">
182 + <?php echo $list?>
274 183 </select>
275 184 </div>
276 185 <?php endforeach; ?>
277 - <?php do_action('cf7sg_dynamic_tag_manager_post_source', $tag_id); ?>
278 186 </article>
279 187 </section>
280 - <section class="custom-source">
281 - <input type="radio" id="<?=$class?>-custom-tab" name="sections" class="custom-tab source-tab">
282 - <label for="<?=$class?>-custom-tab"><?=__('Custom','cf7-grid-layout')?></label>
188 + <section id="custom-source">
189 + <input type="radio" name="sections" id="custom-tab">
190 + <label for="custom-tab"><?=__('Custom','cf7-grid-layout')?></label>
283 191 <article>
284 192 <h4><?=__('Custom source','cf7-grid-layout')?></h4>
285 - <p class="position-relative filter-hook">
286 - <?php
287 - /** @since 4.11.0 generalise hook jelper code initialisation.
288 - * use the provided template to display a message to copy the filter link.
289 - * Insert the filter class name into the template, that matches the filter added to the list in
290 - * the file admin/partials/helpers/cf7sg-form-fields.php.
291 - */
292 - echo sprintf(__('Copy the following <a class="%s" href="javascript:void(0);">filter</a> to your <em>functions.php</em> file.', 'cf7-grid-layout'), 'cf7sg_filter_source');?>
193 + <p class="position-relative">
194 + <?= __('Copy the following <a href="javascript:void(0);">filter</a> to your <em>functions.php</em> file.', 'cf7-grid-layout');?>
293 195 </p>
294 - <?php do_action('cf7sg_dynamic_tag_manager_custom_source', $tag_id); ?>
295 196 </article>
296 197 </section>
297 198 </div> <!-- end-tabs-->
298 - <?php do_action('cf7sg_dynamic_tag_manager_end', $tag_id); ?>
199 +
299 200 </fieldset>
300 201 </div>
301 -<div class="insert-box cf7sg-dynamic-tag-submit">
202 +<div class="insert-box">
302 203 <input type="hidden" name="values" value="" />
303 - <input type="text" name="<?=$tag_id?>" class="tag code" readonly="readonly" onfocus="this.select()" />
204 + <input type="text" name="dynamic-select" class="tag code" readonly="readonly" onfocus="this.select()" />
304 205
305 - <div class="submitbox ">
306 - <input type="button" class="button button-primary insert-tag" value="<?= esc_attr( __cf7sg( 'Insert Tag' ) ); ?>" />
206 + <div class="submitbox">
207 + <input type="button" class="button button-primary insert-tag" value="<?php echo esc_attr( __cf7sg( 'Insert Tag' ) ); ?>" />
307 208 </div>
308 209
309 210 <br class="clear" />
310 211 </div>
212 +<?php
213 +/*
214 +Added functionality
215 +*/
216 +function cf7sg_terms_to_options($taxonomy, $is_hierarchical, $parent=0){
217 + $args = array('hide_empty' => 0);
218 + if($is_hierarchical){
219 + $args['parent'] = $parent;
220 + }
221 + //check the WP version
222 + global $wp_version;
223 + if ( $wp_version >= 4.5 ) {
224 + $args['taxonomy'] = $taxonomy;
225 + $terms = get_terms($args); //WP>= 4.5 the get_terms does not take a taxonomy slug field
226 + }else{
227 + $terms = get_terms($taxonomy, $args);
228 + }
229 + if( is_wp_error( $terms ) ){
230 + debug_msg('Taxonomy '.$taxonomy.' does not exist');
231 + return '';
232 + }else if( empty($terms) ){
233 + return'';
234 + }
235 + if(0==$parent) $class = 'parent';
236 + else $class = 'child';
237 + $script = '';
238 + foreach($terms as $term){
239 + $script .='<option value="taxonomy:' . $taxonomy . ':' . $term->slug . '" >' . $term->name . '</option>' . PHP_EOL;
240 + if($is_hierarchical){
241 + $script .= cf7sg_terms_to_options($taxonomy, $is_hierarchical, $term->term_id);
242 + }
243 + }
244 + return $script;
245 +}
246 +
247 +?>