| 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 |
$class = str_replace('_','-' ,$tag_id); |
| 16 |
?> |
| 17 |
|
| 18 |
<!-- This file should primarily consist of HTML with a little bit of PHP. --> |
| 19 |
|
| 20 |
<div id="<?=$class?>-tag-generator" data-tag="<?=$tag_id?>" class="control-box cf7-<?=$class?> cf7sg-dynamic-list-tag-manager"> |
| 21 |
<fieldset> |
| 22 |
<legend><?= sprintf(__('%s field','cf7-grid-layout'), $dlo->label)?></legend> |
| 23 |
<table class="form-table"> |
| 24 |
<tbody> |
| 25 |
<tr> |
| 26 |
<th scope="row"><label for="<?= esc_attr( $args['content'] . '-name' ); ?>"><?= esc_html( __cf7sg( 'Name' ) ); ?></label></th> |
| 27 |
<td><input type="text" name="name" class="tg-name oneline" id="<?= esc_attr( $args['content'] . '-name' ); ?>" /></td> |
| 28 |
</tr> |
| 29 |
<tr> |
| 30 |
<th scope="row"><?=__('Field type','cf7-grid-layout')?></th> |
| 31 |
<td><input name="required" type="checkbox"><?=__('Required field','cf7-grid-layout')?><br /></td> |
| 32 |
</tr> |
| 33 |
<tr> |
| 34 |
<th scope="row"><?=__('Id attribute','cf7-grid-layout')?></th> |
| 35 |
<td> |
| 36 |
<input name="id" class="idvalue oneline option" id="tag-generator-panel-dynamic-select-id" type="text"> |
| 37 |
</td> |
| 38 |
</tr> |
| 39 |
<tr> |
| 40 |
<th scope="row"><?=__('Class attribute','cf7-grid-layout')?></th> |
| 41 |
<td> |
| 42 |
<input name="class" class="classvalue oneline option" id="tag-generator-panel-dynamic-select-class" type="text"> |
| 43 |
</td> |
| 44 |
</tr> |
| 45 |
<tr> |
| 46 |
<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 |
?> |
| 55 |
<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;?> |
| 99 |
</label> |
| 100 |
</div> |
| 101 |
<?php |
| 102 |
$checked = ''; |
| 103 |
$display_none=' display-none'; |
| 104 |
endforeach;?> |
| 105 |
</td> |
| 106 |
</tr> |
| 107 |
<tr class="others"> |
| 108 |
<th scope="row"><?=__('Other attributes','cf7-grid-layout')?></th> |
| 109 |
<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 |
?> |
| 149 |
</td> |
| 150 |
</tr> |
| 151 |
</tbody> |
| 152 |
</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> |
| 157 |
<article> |
| 158 |
<h4><?=__('Taxonomy source','cf7-grid-layout')?></h4> |
| 159 |
<select class="taxonomy-list"> |
| 160 |
<option value="" data-name="" selected="true" ><?=__('Choose a Taxonomy','cf7-grid-layout')?></option> |
| 161 |
<option class="cf7sg-new-taxonomy" value="new_taxonomy" data-name="New Category"><?=__('New Categories','cf7-grid-layout')?></option> |
| 162 |
<?php |
| 163 |
//get options. |
| 164 |
$dropdowns = get_option('_cf7sg_dynamic_dropdown_taxonomy',array()); |
| 165 |
$slugs = array(); |
| 166 |
|
| 167 |
foreach($dropdowns as $all_lists){ |
| 168 |
foreach($all_lists as $slug => $taxonomy){ |
| 169 |
if(isset($slugs[$slug]) ){ |
| 170 |
continue; |
| 171 |
}else{ |
| 172 |
$slugs[$slug] = $slug; |
| 173 |
} |
| 174 |
echo '<option data-name="' . $taxonomy['singular'] . '" value="'. $taxonomy['slug'] . '" class="cf7sg-taxonomy'.$taxonomy['hierarchical']?' hierarchical':''.'">' . $taxonomy['plural'] . '</option>'; |
| 175 |
} |
| 176 |
} |
| 177 |
//inset the default post tags and category |
| 178 |
?> |
| 179 |
<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> |
| 181 |
<?php |
| 182 |
$system_taxonomies = get_taxonomies( array('public'=>true, '_builtin' => false), 'objects' ); |
| 183 |
foreach($system_taxonomies as $taxonomy){ |
| 184 |
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>'; |
| 186 |
} |
| 187 |
?> |
| 188 |
</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 |
<div class="cf72post-new-taxonomy"> |
| 196 |
<div><strong><?=__('New Taxonomy','cf7-grid-layout')?></strong></div> |
| 197 |
<label><?=__('Plural Name','cf7-grid-layout')?><br /> |
| 198 |
<input disabled="true" class="cf72post-new-taxonomy" type="text" name="plural_name" value=""></label> |
| 199 |
<label ><?=__('Singular Name','cf7-grid-layout')?><br /> |
| 200 |
<input disabled="true" class="cf72post-new-taxonomy" type="text" name="singular_name" value=""></label> |
| 201 |
<label><?=__('Slug','cf7-grid-layout')?><br /> |
| 202 |
<input disabled="true" class="cf72post-new-taxonomy" type="text" name="taxonomy_slug" value="" /></label> |
| 203 |
<label class="hidden"><input class="cf72post-new-taxonomy" type="checkbox" name="is_hierarchical" /><?=__('hierarchical','cf7-grid-layout')?></label> |
| 204 |
</div> |
| 205 |
<?php do_action('cf7sg_dynamic_tag_manager_taxonomy_source', $tag_id); ?> |
| 206 |
</article> |
| 207 |
</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> |
| 211 |
<article class=""> |
| 212 |
<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> |
| 215 |
<?php |
| 216 |
$args = array( |
| 217 |
'show_ui' => true, |
| 218 |
'_builtin' => false |
| 219 |
); |
| 220 |
$output = 'objects'; // names or objects, note names is the default |
| 221 |
$operator = 'and'; // 'and' or 'or' |
| 222 |
|
| 223 |
$post_types = get_post_types( $args, $output, $operator ); |
| 224 |
foreach($post_types as $type=>$post){ |
| 225 |
echo '<option value="'.$type.'">'.$post->labels->name.'</option>'; |
| 226 |
$taxonomies = get_object_taxonomies( $type, 'objects' ); |
| 227 |
|
| 228 |
$taxonomy_lists[$type] = ''; |
| 229 |
foreach($taxonomies as $taxonomy){ |
| 230 |
//skup cf7 dynamic list taxonomies. |
| 231 |
if(WPCF7_ContactForm::post_type == $type && 'wpcf7_type' != $taxonomy->name) continue; |
| 232 |
if(empty($taxonomy->label)) continue; |
| 233 |
$taxonomy_lists[$type] .= '<optgroup label="'.$taxonomy->label.'">'.PHP_EOL; |
| 234 |
$taxonomy_lists[$type] .= $dlo->cf7sg_terms_to_options($taxonomy->name, $taxonomy->hierarchical); |
| 235 |
$taxonomy_lists[$type] .= '</optgroup>'.PHP_EOL; |
| 236 |
} |
| 237 |
} |
| 238 |
$taxonomies = get_object_taxonomies( 'post', 'objects' ); |
| 239 |
$taxonomy_lists['post'] = ''; |
| 240 |
foreach($taxonomies as $taxonomy){ |
| 241 |
if(empty($taxonomy->label)) continue; |
| 242 |
$taxonomy_lists['post'] .= '<optgroup label="'.$taxonomy->label.'">'.PHP_EOL; |
| 243 |
$taxonomy_lists['post'] .= $dlo->cf7sg_terms_to_options($taxonomy->name, $taxonomy->hierarchical); |
| 244 |
$taxonomy_lists['post'] .= '</optgroup>'.PHP_EOL; |
| 245 |
} |
| 246 |
$taxonomies = get_object_taxonomies( 'page', 'objects' ); |
| 247 |
$taxonomy_lists['page'] = ''; |
| 248 |
foreach($taxonomies as $taxonomy){ |
| 249 |
if(empty($taxonomy->label)) continue; |
| 250 |
$taxonomy_lists['page'] .= '<optgroup label="'.$taxonomy->label.'">'.PHP_EOL; |
| 251 |
$taxonomy_lists['page'] .= $dlo->cf7sg_terms_to_options($taxonomy->name, $taxonomy->hierarchical); |
| 252 |
$taxonomy_lists['page'] .= '</optgroup>'.PHP_EOL; |
| 253 |
} |
| 254 |
?> |
| 255 |
<option value="post"><?=__('Posts','cf7-grid-layout')?></option> |
| 256 |
<option value="page"><?=__('Pages','cf7-grid-layout')?></option> |
| 257 |
</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> |
| 266 |
|
| 267 |
<?php foreach($taxonomy_lists as $type=>$list ): |
| 268 |
if(empty($list)) continue; |
| 269 |
?> |
| 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?> |
| 274 |
</select> |
| 275 |
</div> |
| 276 |
<?php endforeach; ?> |
| 277 |
<?php do_action('cf7sg_dynamic_tag_manager_post_source', $tag_id); ?> |
| 278 |
</article> |
| 279 |
</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> |
| 283 |
<article> |
| 284 |
<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');?> |
| 293 |
</p> |
| 294 |
<?php do_action('cf7sg_dynamic_tag_manager_custom_source', $tag_id); ?> |
| 295 |
</article> |
| 296 |
</section> |
| 297 |
</div> <!-- end-tabs--> |
| 298 |
<?php do_action('cf7sg_dynamic_tag_manager_end', $tag_id); ?> |
| 299 |
</fieldset> |
| 300 |
</div> |
| 301 |
<div class="insert-box cf7sg-dynamic-tag-submit"> |
| 302 |
<input type="hidden" name="values" value="" /> |
| 303 |
<input type="text" name="<?=$class?>" class="tag code" readonly="readonly" onfocus="this.select()" /> |
| 304 |
|
| 305 |
<div class="submitbox "> |
| 306 |
<input type="button" class="button button-primary insert-tag" value="<?= esc_attr( __cf7sg( 'Insert Tag' ) ); ?>" /> |
| 307 |
</div> |
| 308 |
|
| 309 |
<br class="clear" /> |
| 310 |
</div> |
| 311 |
|