PluginProbe
Comments Extra Fields For Post,Pages and CPT / 1.7
Comments Extra Fields For Post,Pages and CPT v1.7
trunk 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 2.2 2.3 4.0 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8 5.0 5.1 5.2
wp-comment-fields / templates / render.comment.meta.php

render.comment.meta.php in Comments Extra Fields For Post,Pages and CPT 1.7, at templates/render.comment.meta.php

128 lines 3.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Rendering comment extra fields
4 * generated with N-Media plugin
5 */
6
7 global $nmwpcomment;
8
9 $existing_meta = get_option('wpcomment_meta');
10
11 //$existing_meta = json_encode($existing_meta);
12
13 //wpcomment_pa($existing_meta);
14
15 if($existing_meta){
16
17 $columns = 0;
18 echo '<div class="nm-wrap-comments">';
19 echo '<div class="row">';
20 foreach($existing_meta as $key => $meta)
21 {
22 $columns+= $meta['width'];
23
24 echo '<div class="col-lg-'.$meta['width'].'">';
25 $type = $meta['type'];
26 $name = strtolower( preg_replace("![^a-z0-9]+!i", "_", $meta['data_name']) );
27 $field_class = (isset($meta['class']) ? $meta['class'] : '');
28 $title = (isset($meta['title']) ? $meta['title'] : '');
29 $p_class = 'comment-'.$name;
30
31 $title = stripslashes( $title );
32
33 if($meta['required'] == 'on'){
34 $required = 'true';
35 $label = sprintf(__('%s <span class="required">*</span>', 'wp-comments'), $title);
36 }else{
37 $required = 'false';
38 $label = sprintf(__('%s', 'wp-comments'), $title);
39 }
40
41
42
43 switch ($type) {
44
45 case 'text':
46
47 echo '<p class="'.$p_class.'">';
48 echo '<label for="'.$name.'">'.$label.'</label>';
49 echo '<input class="form-control" id="'.$name.'" name="'.$name.'" type="text" aria-required="'.$required.'" class="'.$field_class.'">';
50 echo '</p>';
51
52 break;
53
54 case 'select':
55
56 $options = (isset($meta['options']) ? $meta['options'] : '');
57 $options = explode("\n", $options);
58
59 $selected = (isset($meta['selected']) ? $meta['selected'] : '');
60
61 echo '<p class="'.$p_class.'">';
62 echo '<label for="'.$name.'">'.$label.'</label>';
63 echo '<select class="form-control" name="'.$name.'">';
64
65 foreach ($options as $key) {
66
67 $selected_option = ($selected == $key ? 'selected="selected"' : '');
68 echo '<option value="'.esc_attr($key).'" '.$selected_option.'>'.esc_attr($key).'</option>';
69 }
70
71 echo '</select>';
72 echo '</p>';
73
74 break;
75
76 case 'radio':
77
78 $options = (isset($meta['options']) ? $meta['options'] : '');
79 $options = explode("\n", $options);
80
81 $selected = (isset($meta['selected']) ? $meta['selected'] : '');
82
83 echo '<p class="'.$p_class.'">';
84 echo '<label for="'.$name.'">' .$label. ' </label> ';
85
86 foreach ($options as $key=>$value) {
87
88 $selected_option = ($selected == $value ? 'selected="selected"' : '');
89 echo ' <input name="'.$name.'" id="'.$name.$key.'" type="radio" value="'.esc_attr($value).'" '.$selected_option.' /><label style="display:inline;" for="'.$name.$key.'"> '.esc_attr($value).' &nbsp;</label>';
90 }
91
92 echo '</p>';
93
94 break;
95
96 case 'checkbox':
97
98 $options = (isset($meta['options']) ? $meta['options'] : '');
99 $options = explode("\n", $options);
100
101 $selected = (isset($meta['selected']) ? $meta['selected'] : '');
102
103 echo '<p class="'.$p_class.'">';
104 echo '<label for="'.$name.'"> ' .$label. ' </label>';
105
106 foreach ($options as $key=>$value) {
107 // var_dump($key);
108 $selected_option = ($selected == $value ? 'selected="selected"' : '');
109 echo ' <input name="'.$name.'[]" id="'.$name.$key.'" type="checkbox" value="'.esc_attr($value).'" '.$selected_option.' /><label style="display:inline;" for="'.$name.$key.'"> '.esc_attr($value).' &nbsp;</label>';
110 }
111
112 echo '</p>';
113
114 break;
115 }
116 echo '</div>';
117 if ($columns == 12) {
118 echo '</div><div class="row">';
119 }
120 }
121
122
123 echo '</div>';
124
125 echo '</div>';
126 }
127
128