PluginProbe
Smart Grid-Layout Design for Contact Form 7 / 4.10
Smart Grid-Layout Design for Contact Form 7 v4.10
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
cf7-grid-layout / admin / partials / cf7-dynamic-tag-display.php

cf7-dynamic-tag-display.php in Smart Grid-Layout Design for Contact Form 7 4.10, at admin/partials/cf7-dynamic-tag-display.php

248 lines 11.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Provide a admin area view for the plugin
5 *
6 * This file is used to markup the admin-facing aspects of the plugin.
7 *
8 * @link http://syllogic.in
9 * @since 1.5.0
10 *
11 * @package Cf7_2_Post
12 * @subpackage Cf7_2_Post/admin/partials
13 */
14 //TODO: add a check box to include or not address fields
15 ?>
16
17 <!-- This file should primarily consist of HTML with a little bit of PHP. -->
18
19 <div id="dynamic-select-tag-generator" class="control-box cf7-dynamic-select">
20 <fieldset>
21 <legend><?= __('Dynamic Select Dropdown field','cf7-grid-layout')?></legend>
22 <table class="form-table">
23 <tbody>
24 <tr>
25 <th scope="row"><label for="<?= esc_attr( $args['content'] . '-name' ); ?>"><?= esc_html( __cf7sg( 'Name' ) ); ?></label></th>
26 <td><input type="text" name="name" class="tg-name oneline" id="<?= esc_attr( $args['content'] . '-name' ); ?>" /></td>
27 </tr>
28 <tr>
29 <th scope="row"><?=__('Field type','cf7-grid-layout')?></th>
30 <td><input name="required" type="checkbox"><?=__('Required field','cf7-grid-layout')?><br /></td>
31 </tr>
32 <tr>
33 <th scope="row"><?=__('Id attribute','cf7-grid-layout')?></th>
34 <td>
35 <input name="id" class="idvalue oneline option" id="tag-generator-panel-dynamic-select-id" type="text">
36 </td>
37 </tr>
38 <tr>
39 <th scope="row"><?=__('Class attribute','cf7-grid-layout')?></th>
40 <td>
41 <input name="class" class="classvalue oneline option" id="tag-generator-panel-dynamic-select-class" type="text">
42 </td>
43 </tr>
44 <tr>
45 <th scope="row"><?=__('Dropdown style','cf7-grid-layout')?></th>
46 <td>
47 <div>
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')?>
51 </label>
52 </div>
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>
69 </td>
70 </tr>
71 <tr>
72 <th scope="row"><?=__('Mutliple attribute','cf7-grid-layout')?></th>
73 <td>
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>
76 </td>
77 </tr>
78 </tbody>
79 </table>
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>
84 <article>
85 <h4><?=__('Taxonomy source','cf7-grid-layout')?></h4>
86 <select class="taxonomy-list">
87 <option value="" data-name="" ><?=__('Choose a Taxonomy','cf7-grid-layout')?></option>
88 <option class="cf7sg-new-taxonomy" value="new_taxonomy" data-name="New Category"><?=__('New Categories','cf7-grid-layout')?></option>
89 <?php
90 //get options.
91 $dropdowns = get_option('_cf7sg_dynamic_dropdown_taxonomy',array());
92 $slugs = array();
93
94 foreach($dropdowns as $all_lists){
95 foreach($all_lists as $slug => $taxonomy){
96 if(isset($slugs[$slug]) ){
97 continue;
98 }else{
99 $slugs[$slug] = $slug;
100 }
101 echo '<option selected data-name="' . $taxonomy['singular'] . '" value="'. $taxonomy['slug'] . '" class="cf7sg-taxonomy">' . $taxonomy['plural'] . '</option>';
102 }
103 }
104 //inset the default post tags and category
105 ?>
106 <option value="post_tag" data-name="Post Tag" class="system-taxonomy"><?=__('Post Tags','cf7-grid-layout')?></option>
107 <option value="category" data-name="Post Category" class="system-taxonomy"><?=__('Post Categories','cf7-grid-layout')?></option>
108 <?php
109 $system_taxonomies = get_taxonomies( array('public'=>true, '_builtin' => false), 'objects' );
110 foreach($system_taxonomies as $taxonomy){
111 if( !empty($taxonomy_slug) && $taxonomy_slug == $taxonomy->name ) continue;
112 echo '<option value="' . $taxonomy->name . '" data-name="' . $taxonomy->labels->singular_name . '" class="system-taxonomy">' . $taxonomy->labels->name . '</option>';
113 }
114 ?>
115 </select>
116 <div class="cf72post-new-taxonomy">
117 <div><strong><?=__('New Taxonomy','cf7-grid-layout')?></strong></div>
118 <label><?=__('Plural Name','cf7-grid-layout')?><br />
119 <input disabled="true" class="cf72post-new-taxonomy" type="text" name="plural_name" value=""></label>
120 <label ><?=__('Singular Name','cf7-grid-layout')?><br />
121 <input disabled="true" class="cf72post-new-taxonomy" type="text" name="singular_name" value=""></label>
122 <label><?=__('Slug','cf7-grid-layout')?><br />
123 <input disabled="true" class="cf72post-new-taxonomy" type="text" name="taxonomy_slug" value="" /></label>
124 <label class="hidden"><input class="cf72post-new-taxonomy" type="checkbox" name="is_hierarchical" /><?=__('hierarchical','cf7-grid-layout')?></label>
125 </div>
126 </article>
127 </section>
128 <section id="post-source">
129 <input type="radio" name="sections" id="post-tab">
130 <label for="post-tab"><?=__('Post','cf7-grid-layout')?></label>
131 <article class="">
132 <h4><?=__('Post source','cf7-grid-layout')?></h4>
133 <select class="post-list">
134 <option value=""><?=__('Select a post','cf7-grid-layout')?></option>
135 <?php
136 $args = array(
137 'show_ui' => true,
138 '_builtin' => false
139 );
140 $output = 'objects'; // names or objects, note names is the default
141 $operator = 'and'; // 'and' or 'or'
142
143 $post_types = get_post_types( $args, $output, $operator );
144 foreach($post_types as $type=>$post){
145 echo '<option value="'.$type.'">'.$post->labels->name.'</option>';
146 $taxonomies = get_object_taxonomies( $type, 'objects' );
147
148 $taxonomy_lists[$type] = '';
149 foreach($taxonomies as $taxonomy){
150 //skup cf7 dynamic list taxonomies.
151 if(WPCF7_ContactForm::post_type == $type && 'wpcf7_type' != $taxonomy->name) continue;
152 $taxonomy_lists[$type] .= '<optgroup label="'.$taxonomy->label.'">'.PHP_EOL;
153 $taxonomy_lists[$type] .= cf7sg_terms_to_options($taxonomy->name, $taxonomy->hierarchical,0);
154 $taxonomy_lists[$type] .= '</optgroup>'.PHP_EOL;
155 }
156 }
157 $taxonomies = get_object_taxonomies( 'post', 'objects' );
158 $taxonomy_lists['post'] = '';
159 foreach($taxonomies as $taxonomy){
160 $taxonomy_lists['post'] .= '<optgroup label="'.$taxonomy->label.'">'.PHP_EOL;
161 $taxonomy_lists['post'] .= cf7sg_terms_to_options($taxonomy->name, $taxonomy->hierarchical,0);
162 $taxonomy_lists['post'] .= '</optgroup>'.PHP_EOL;
163 }
164 $taxonomies = get_object_taxonomies( 'page', 'objects' );
165 $taxonomy_lists['page'] = '';
166 foreach($taxonomies as $taxonomy){
167 $taxonomy_lists['page'] .= '<optgroup label="'.$taxonomy->label.'">'.PHP_EOL;
168 $taxonomy_lists['page'] .= cf7sg_terms_to_options($taxonomy->name, $taxonomy->hierarchical,0);
169 $taxonomy_lists['page'] .= '</optgroup>'.PHP_EOL;
170 }
171 ?>
172 <option value="post"><?=__('Posts','cf7-grid-layout')?></option>
173 <option value="page"><?=__('Pages','cf7-grid-layout')?></option>
174 </select>
175 <label><input type="checkbox" id="include-post-links"/><?= __('Include post links','cf7-grid-layout')?></label>
176
177 <?php foreach($taxonomy_lists as $type=>$list ):
178 if(empty($list)) continue;
179 ?>
180 <div id="<?php echo $type ?>" class="post-taxonomies hidden">
181 <select multiple class="select2">
182 <?php echo $list?>
183 </select>
184 </div>
185 <?php endforeach; ?>
186 </article>
187 </section>
188 <section id="custom-source">
189 <input type="radio" name="sections" id="custom-tab">
190 <label for="custom-tab"><?=__('Custom','cf7-grid-layout')?></label>
191 <article>
192 <h4><?=__('Custom source','cf7-grid-layout')?></h4>
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');?>
195 </p>
196 </article>
197 </section>
198 </div> <!-- end-tabs-->
199
200 </fieldset>
201 </div>
202 <div class="insert-box">
203 <input type="hidden" name="values" value="" />
204 <input type="text" name="dynamic-select" class="tag code" readonly="readonly" onfocus="this.select()" />
205
206 <div class="submitbox">
207 <input type="button" class="button button-primary insert-tag" value="<?php echo esc_attr( __cf7sg( 'Insert Tag' ) ); ?>" />
208 </div>
209
210 <br class="clear" />
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 ?>
248