PluginProbe
WP Directory Kit / 1.5.9
WP Directory Kit v1.5.9
1.5.9 1.5.7 1.5.6 1.5.5 1.5.4 1.5.3 trunk 1.1.0 1.1.6 1.1.8 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.8 All 37 releases
wpdirectorykit / application / views / fields_edit / SEO_INPUTBOX.php

SEO_INPUTBOX.php in WP Directory Kit 1.5.9, at application/views/fields_edit/SEO_INPUTBOX.php

163 lines 5.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * The template for Edit field INPUTBOX.
4 *
5 * This is the template that field layout for edit form
6 *
7 */
8
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit; // Exit if accessed directly.
11 }
12 ?>
13 <?php
14
15 //wmvc_dump($field);
16
17 if(isset($field->field))
18 {
19 $field_id = $field->field;
20 }
21 else
22 {
23 $field_id = 'field_'.$field->idfield;
24 }
25
26 if(!isset($field->hint))$field->hint = '';
27 if(!isset($field->columns_number))$field->columns_number = '';
28 if(!isset($field->class))$field->class = '';
29 if(!isset($field->prefix))$field->prefix = '';
30 if(!isset($field->suffix))$field->suffix = '';
31 if(!isset($field->default))$field->default = '';
32 if(!isset($field->empty_default))$field->empty_default = '';
33
34
35 $field_label = $field->field_label;
36
37 $required = '';
38 if(isset($field->is_required) && $field->is_required == 1)
39 $required = '*';
40
41 if(isset($field->rules) && strpos($field->rules, 'required') !== FALSE)
42 $required = '*';
43 ?>
44
45 <div class="wdk-field-<?php echo esc_attr($field_id);?> wdk-field-edit <?php echo esc_attr($field->field_type); ?> wdk-col-<?php echo esc_attr($field->columns_number); ?> <?php echo esc_attr($field->class); ?> <?php if(!empty($form) && method_exists($form, 'hasError') && $form->hasError($field_id)):?> field-error <?php endif;?>">
46 <label for="<?php echo esc_attr($field_id); ?>"><?php echo esc_html($field_label).esc_html($required); ?></label>
47 <div class="wdk-field-container">
48 <input class="regular-text"
49 name="<?php echo esc_attr($field_id); ?>"
50 type="text" id="<?php echo esc_attr($field_id); ?>"
51 value="<?php echo esc_attr(!empty(wmvc_show_data($field_id, $db_data, $field->default)) ? wmvc_show_data($field_id, $db_data, $field->default) : $field->empty_default); ?>"
52 >
53 <span class="suffix"><?php
54 // Dynamic field values are registered in the translation catalog separately.
55 // phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText
56 echo esc_html__($field->prefix, 'wpdirectorykit');
57 if(!empty($field->prefix) && !empty($field->suffix)) echo ' / ';
58 // Dynamic field values are registered in the translation catalog separately.
59 // phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText
60 echo esc_html__($field->suffix, 'wpdirectorykit');
61 ?></span>
62 <?php if(!empty($field->hint)):?>
63 <p class="wdk-hint">
64 <?php echo wp_kses_post($field->hint); ?>
65 </p>
66 <?php endif;?>
67 <?php if(!empty($form) && method_exists($form, 'hasError') && $form->getError($field_id)):?>
68 <p class="wdk-hint wdk-error">
69 <?php echo wp_kses_post($form->getError($field_id)); ?>
70 </p>
71 <?php endif;?>
72 </div>
73 </div>
74 <?php
75 // Register and enqueue Tribute.js style
76 wp_enqueue_style( 'tribute-css');
77 // Register and enqueue Tribute.js script
78 wp_enqueue_script( 'tribute-js');
79 ?>
80
81 <?php
82
83 $fields_data = wdk_cached_field_get();
84
85 $fields_list = array();
86 $fields_list['field_post_id'] = esc_html__('Post Id', 'wpdirectorykit');
87 $fields_list['field_counter_views'] = esc_html__('Views counter', 'wpdirectorykit');
88 $fields_list['field_lat'] = esc_html__('Gps Lat', 'wpdirectorykit');
89 $fields_list['field_lng'] = esc_html__('Gps Lng', 'wpdirectorykit');
90 $fields_list['field_date'] = esc_html__('Date', 'wpdirectorykit');
91 $fields_list['field_date_modified'] = esc_html__('Date Modified', 'wpdirectorykit');
92 $fields_list['field_post_title'] = esc_html__('Title', 'wpdirectorykit');
93 $fields_list['field_post_content'] = esc_html__('Content', 'wpdirectorykit');
94 $fields_list['field_address'] = esc_html__('Address', 'wpdirectorykit');
95 $fields_list['field_category'] = esc_html__('Category', 'wpdirectorykit');
96 $fields_list['field_location'] = esc_html__('Location', 'wpdirectorykit');
97
98 foreach ($fields_data as $field) {
99 if (wmvc_show_data('field_type', $field) == 'NUMBER' || wmvc_show_data('field_type', $field) == 'INPUTBOX') {
100 $fields_list['field_'.wmvc_show_data('idfield', $field)] = wmvc_show_data('field_label', $field);
101 }
102 }
103 ?>
104
105 <script>
106 document.addEventListener('DOMContentLoaded', function() {
107 var input = document.getElementById('<?php echo esc_js($field_id); ?>');
108
109 if (!input) {
110 return;
111 }
112
113 var tribute = new Tribute({
114 trigger: '{',
115
116 values: [
117 <?php
118 $first = true;
119
120 foreach ($fields_list as $value => $key) {
121 if (!$first) {
122 echo ',';
123 }
124 ?>
125 {
126 key: <?php echo json_encode($key); ?>,
127 value: <?php echo json_encode($value); ?>
128 }
129 <?php
130
131 $first = false;
132 }
133 ?>
134 ],
135
136 // Insert with curly braces
137 selectTemplate: function(item) {
138 return '{' + item.original.value + '}';
139 },
140
141 // Show field name in dropdown
142 menuItemTemplate: function(item) {
143 return item.string;
144 }
145 });
146
147 tribute.attach(input);
148
149 function openTributeMenu() {
150 if (!tribute.isActive) {
151 tribute.showMenuForCollection(input, 0);
152 }
153 }
154
155 // Open on first focus
156 input.addEventListener('focus', openTributeMenu);
157
158 // Open again when user clicks inside already focused input
159 input.addEventListener('click', openTributeMenu);
160 });
161 </script>
162
163