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
← All changes | elementor-elements/classes/wdk-field-value.php +911 -250 1.3.4 → 1.5.9 View file →
@@ -21,14 +21,17 @@
21 21
22 22 /**
23 23 * @since 1.1.0
24 24 */
25 -class WdkFieldValue extends WdkElementorBase {
25 +class WdkFieldValue extends WdkElementorBase
26 +{
26 27
27 28 public $field_id = NULL;
28 29 public $fields_list = array();
30 + public $fields_list_files = array();
29 31
30 - public function __construct($data = array(), $args = null) {
32 + public function __construct($data = array(), $args = null)
33 + {
31 34
32 35 \Elementor\Controls_Manager::add_tab(
33 36 'tab_conf',
34 37 esc_html__('Settings', 'wpdirectorykit')
@@ -42,40 +45,39 @@
42 45 \Elementor\Controls_Manager::add_tab(
43 46 'tab_content',
44 47 esc_html__('Main', 'wpdirectorykit')
45 48 );
46 -
47 - add_action( 'elementor/editor/after_enqueue_styles', function()
48 - {
49 - wp_add_inline_style( 'elementor-editor', '.elementor-control-content select option[value*="section"]{color:#fff;background:#000}');
50 - } );
51 -
52 - if ($this->is_edit_mode_load()) {
49 +
50 + add_action('elementor/editor/after_enqueue_styles', function () {
51 + wp_add_inline_style('elementor-editor', '.elementor-control-content select option[value*="section"]{color:#fff;background:#000}');
52 + });
53 +
54 + if ($this->is_edit_mode_load()) {
53 55 $this->enqueue_styles_scripts();
54 56 }
55 57
56 58 parent::__construct($data, $args);
59 + }
57 60
61 + /**
62 + * Retrieve the list of categories the widget belongs to.
63 + *
64 + * Used to determine where to display the widget in the editor.
65 + *
66 + * Note that currently Elementor supports only one category.
67 + * When multiple categories passed, Elementor uses the first one.
68 + *
69 + * @since 1.1.0
70 + *
71 + * @access public
72 + *
73 + * @return array Widget categories.
74 + */
75 + public function get_categories()
76 + {
77 + return ['wdk-elementor-listing-preview'];
58 78 }
59 79
60 - /**
61 - * Retrieve the list of categories the widget belongs to.
62 - *
63 - * Used to determine where to display the widget in the editor.
64 - *
65 - * Note that currently Elementor supports only one category.
66 - * When multiple categories passed, Elementor uses the first one.
67 - *
68 - * @since 1.1.0
69 - *
70 - * @access public
71 - *
72 - * @return array Widget categories.
73 - */
74 - public function get_categories() {
75 - return [ 'wdk-elementor-listing-preview' ];
76 - }
77 -
78 80 /**
79 81 * Retrieve the widget name.
80 82 *
81 83 * @since 1.1.0
@@ -83,9 +85,10 @@
83 85 * @access public
84 86 *
85 87 * @return string Widget name.
86 88 */
87 - public function get_name() {
89 + public function get_name()
90 + {
88 91 return 'wdk-field-value';
89 92 }
90 93
91 94 /**
@@ -96,9 +99,10 @@
96 99 * @access public
97 100 *
98 101 * @return string Widget title.
99 102 */
100 - public function get_title() {
103 + public function get_title()
104 + {
101 105 return esc_html__('Wdk Field Value', 'wpdirectorykit');
102 106 }
103 107
104 108 /**
@@ -109,9 +113,10 @@
109 113 * @access public
110 114 *
111 115 * @return string Widget icon.
112 116 */
113 - public function get_icon() {
117 + public function get_icon()
118 + {
114 119 return 'eicon-product-meta';
115 120 }
116 121
117 122 /**
@@ -122,14 +127,17 @@
122 127 * @since 1.1.0
123 128 *
124 129 * @access protected
125 130 */
126 - protected function register_controls() {
131 + protected function register_controls()
132 + {
127 133 $this->generate_controls_conf();
128 134 $this->generate_controls_layout();
129 135 $this->generate_controls_styles();
130 136 $this->generate_controls_content();
131 -
137 +
138 + $this->generate_controls_styles_files();
139 +
132 140 $this->insert_pro_message('1');
133 141 parent::register_controls();
134 142 }
135 143
@@ -141,9 +149,10 @@
141 149 * @since 1.1.0
142 150 *
143 151 * @access protected
144 152 */
145 - protected function render() {
153 + protected function render()
154 + {
146 155 parent::render();
147 156 global $wdk_listing_id;
148 157
149 158 $this->data['id_element'] = $this->get_id();
@@ -151,183 +160,212 @@
151 160
152 161 $this->data['field_value'] = 'Example Value';
153 162 $this->data['field_prefix'] = 'prefix';
154 163 $this->data['field_suffix'] = 'suffix';
155 - if(!empty($this->data['settings']['field_id'])){
156 - if(strpos($this->data['settings']['field_id'],'__') !== FALSE){
157 - $this->data['settings']['field_id'] = substr($this->data['settings']['field_id'], strpos($this->data['settings']['field_id'],'__')+2);
164 + if (!empty($this->data['settings']['field_id'])) {
165 + if (strpos($this->data['settings']['field_id'], '__') !== FALSE) {
166 + $this->data['settings']['field_id'] = substr($this->data['settings']['field_id'], strpos($this->data['settings']['field_id'], '__') + 2);
158 167 }
159 168
160 - if(!Plugin::$instance->editor->is_edit_mode() && !empty($wdk_listing_id)) {
161 - if(wdk_field_option($this->data['settings']['field_id'], 'field_type') == "CHECKBOX") {
162 - if(wdk_field_value ($this->data['settings']['field_id'], $wdk_listing_id) == 1){
163 - $this->data['field_value'] = '<span class="field_checkbox_success">'.$this->generate_icon($this->data['settings']['field_checkbox_icon_success']).'</span>';
169 + if (!Plugin::$instance->editor->is_edit_mode() && !empty($wdk_listing_id)) {
170 + if (wdk_field_option($this->data['settings']['field_id'], 'field_type') == "CHECKBOX") {
171 + if (wdk_field_value($this->data['settings']['field_id'], $wdk_listing_id) == 1) {
172 + $this->data['field_value'] = '<span class="field_checkbox_success">' . $this->generate_icon($this->data['settings']['field_checkbox_icon_success']) . '</span>';
164 173 } else {
165 - $this->data['field_value'] = '<span class="field_checkbox_unsuccess">'.$this->generate_icon($this->data['settings']['field_checkbox_icon_unsuccess']).'</span>';
166 - }
167 - } else if(wdk_field_option($this->data['settings']['field_id'],'field_type') == "INPUTBOX") {
168 - $this->data['field_value'] =__(wdk_field_value ($this->data['settings']['field_id'], $wdk_listing_id, wdk_field_option($this->data['settings']['field_id'],'empty_value')), 'wpdirectorykit');
174 + $this->data['field_value'] = '<span class="field_checkbox_unsuccess">' . $this->generate_icon($this->data['settings']['field_checkbox_icon_unsuccess']) . '</span>';
175 + }
176 + } else if (wdk_field_option($this->data['settings']['field_id'], 'field_type') == "INPUTBOX") {
169 177
170 - if(strpos($this->data['field_value'], 'vimeo.com') !== FALSE)
171 - {
172 - $this->data['field_value'] = wp_oembed_get($this->data['field_value'], array("width"=>"800", "height"=>"450"));
173 - }
174 - elseif(strpos($this->data['field_value'], 'watch?v=') !== FALSE)
175 - {
176 - $embed_code = substr($this->data['field_value'], strpos($this->data['field_value'], 'watch?v=')+8);
177 - $this->data['field_value'] = wp_oembed_get('https://www.youtube.com/watch?v='.$embed_code, array("width"=>"800", "height"=>"455"));
178 - }
179 - elseif(strpos($this->data['field_value'], 'youtube.com/shorts/') !== FALSE)
180 - {
181 - $embed_code = substr($this->data['field_value'], strpos($this->data['field_value'], 'shorts')+7);
182 - $this->data['field_value'] = wp_oembed_get('https://www.youtube.com/watch?v='.$embed_code,array("width"=>"800", "height"=>"455"));
183 - }
184 - elseif(strpos($this->data['field_value'], 'youtu.be/') !== FALSE)
185 - {
186 - $embed_code = substr($this->data['field_value'], strpos($this->data['field_value'], 'youtu.be/')+9);
187 - $this->data['field_value'] = wp_oembed_get('https://www.youtube.com/watch?v='.$embed_code, array("width"=>"800", "height"=>"455"));
188 - }
189 - elseif(filter_var($this->data['field_value'], FILTER_VALIDATE_URL) !== FALSE && preg_match('/\.(mp4|flv|wmw|ogv|webm|ogg)$/i', $this->data['field_value']))
190 - {
191 - $this->data['field_value'] = '<video src="'.$this->data['field_value'].'" controls></video> ';
192 - }
193 - elseif(filter_var($this->data['field_value'] , FILTER_VALIDATE_EMAIL) !== FALSE) {
194 - if(wmvc_show_data('link_value',$this->data['settings']) == 'value') {
195 - $this->data['field_value'] = '<a href="mailto:'.$this->data['field_value'] .'">'.$this->data['field_value'] .'</a>';
196 - } else if(wmvc_show_data('link_value',$this->data['settings']) == 'label') {
197 - $this->data['field_value'] = '<a href="mailto:'.$this->data['field_value'] .'">'.wdk_field_label($this->data['settings']['field_id']) .'</a>';
198 - } else if(wmvc_show_data('link_value',$this->data['settings']) == 'icon' && wdk_field_option ($this->data['settings']['field_id'], 'icon_id')) {
199 - $this->data['field_value'] = '<a href="mailto:'.$this->data['field_value'] .'"><img src="'.esc_url(wdk_image_src(array('icon_id' =>wdk_field_option ($this->data['settings']['field_id'], 'icon_id')), 'full', NULL, 'icon_id')).'"></a>';
178 + // Dynamic field values are registered in the translation catalog separately.
179 + // phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText
180 + $this->data['field_value'] = __(wdk_field_value($this->data['settings']['field_id'], $wdk_listing_id, wdk_field_option($this->data['settings']['field_id'], 'empty_value')), 'wpdirectorykit');
181 +
182 + if (strpos($this->data['field_value'], 'vimeo.com') !== FALSE) {
183 + $this->data['field_value'] = wp_oembed_get($this->data['field_value'], array("width" => "800", "height" => "450"));
184 + } elseif (strpos($this->data['field_value'], 'watch?v=') !== FALSE) {
185 + $embed_code = substr($this->data['field_value'], strpos($this->data['field_value'], 'watch?v=') + 8);
186 + $this->data['field_value'] = wp_oembed_get('https://www.youtube.com/watch?v=' . $embed_code, array("width" => "800", "height" => "455"));
187 + } elseif (strpos($this->data['field_value'], 'youtube.com/shorts/') !== FALSE) {
188 + $embed_code = substr($this->data['field_value'], strpos($this->data['field_value'], 'shorts') + 7);
189 + $this->data['field_value'] = wp_oembed_get('https://www.youtube.com/watch?v=' . $embed_code, array("width" => "800", "height" => "455"));
190 + } elseif (strpos($this->data['field_value'], 'youtu.be/') !== FALSE) {
191 + $embed_code = substr($this->data['field_value'], strpos($this->data['field_value'], 'youtu.be/') + 9);
192 + $this->data['field_value'] = wp_oembed_get('https://www.youtube.com/watch?v=' . $embed_code, array("width" => "800", "height" => "455"));
193 + } elseif (filter_var($this->data['field_value'], FILTER_VALIDATE_URL) !== FALSE && preg_match('/\.(mp4|flv|wmw|ogv|webm|ogg)$/i', $this->data['field_value'])) {
194 + $this->data['field_value'] = '<video src="' . $this->data['field_value'] . '" controls></video> ';
195 + } elseif (filter_var($this->data['field_value'], FILTER_VALIDATE_EMAIL) !== FALSE) {
196 + if (wmvc_show_data('link_value', $this->data['settings']) == 'value') {
197 + $this->data['field_value'] = '<a class="value" href="mailto:' . $this->data['field_value'] . '">' . $this->data['field_value'] . '</a>';
198 + } else if (wmvc_show_data('link_value', $this->data['settings']) == 'label') {
199 + $this->data['field_value'] = '<a class="value" href="mailto:' . $this->data['field_value'] . '">' . wdk_field_label($this->data['settings']['field_id']) . '</a>';
200 + } else if (wmvc_show_data('link_value', $this->data['settings']) == 'icon' && wdk_field_option($this->data['settings']['field_id'], 'icon_id')) {
201 + $this->data['field_value'] = '<a class="value" href="mailto:' . $this->data['field_value'] . '"><img src="' . esc_url(wdk_image_src(array('icon_id' => wdk_field_option($this->data['settings']['field_id'], 'icon_id')), 'full', NULL, 'icon_id')) . '"></a>';
200 202 } else {
201 - $this->data['field_value'] = '<a href="mailto:'.$this->data['field_value'] .'">'.wdk_field_label($this->data['settings']['field_id']) .'</a>';
203 + $this->data['field_value'] = '<a class="value" href="mailto:' . $this->data['field_value'] . '">' . wdk_field_label($this->data['settings']['field_id']) . '</a>';
202 204 }
203 - }
204 - elseif(filter_var($this->data['field_value'] , FILTER_VALIDATE_URL) !== FALSE) {
205 - if(wmvc_show_data('link_value',$this->data['settings']) == 'value') {
206 - $this->data['field_value'] = '<a href="'.$this->data['field_value'] .'">'.$this->data['field_value'] .'</a>';
207 - } else if(wmvc_show_data('link_value',$this->data['settings']) == 'label') {
208 - $this->data['field_value'] = '<a href="'.$this->data['field_value'] .'">'.wdk_field_label($this->data['settings']['field_id']) .'</a>';
209 - } else if(wmvc_show_data('link_value',$this->data['settings']) == 'icon' && wdk_field_option ($this->data['settings']['field_id'], 'icon_id')) {
210 - $this->data['field_value'] = '<a href="'.$this->data['field_value'] .'"><img src="'.esc_url(wdk_image_src(array('icon_id' =>wdk_field_option ($this->data['settings']['field_id'], 'icon_id')), 'full', NULL, 'icon_id')).'"></a>';
205 + } elseif (filter_var($this->data['field_value'], FILTER_VALIDATE_URL) !== FALSE) {
206 + if (wmvc_show_data('link_value', $this->data['settings']) == 'value') {
207 + $this->data['field_value'] = '<a class="value" target="_blank" href="' . $this->data['field_value'] . '">' . $this->data['field_value'] . '</a>';
208 + } else if (wmvc_show_data('link_value', $this->data['settings']) == 'label') {
209 + $this->data['field_value'] = '<a class="value" target="_blank" href="' . $this->data['field_value'] . '">' . wdk_field_label($this->data['settings']['field_id']) . '</a>';
210 + } else if (wmvc_show_data('link_value', $this->data['settings']) == 'icon' && wdk_field_option($this->data['settings']['field_id'], 'icon_id')) {
211 + $this->data['field_value'] = '<a class="value" target="_blank" href="' . $this->data['field_value'] . '"><img src="' . esc_url(wdk_image_src(array('icon_id' => wdk_field_option($this->data['settings']['field_id'], 'icon_id')), 'full', NULL, 'icon_id')) . '"></a>';
211 212 } else {
212 - $this->data['field_value'] = '<a href="'.$this->data['field_value'] .'">'.wdk_field_label($this->data['settings']['field_id']) .'</a>';
213 + $this->data['field_value'] = '<a class="value" target="_blank" href="' . $this->data['field_value'] . '">' . wdk_field_label($this->data['settings']['field_id']) . '</a>';
213 214 }
215 + } elseif (wdk_field_option(wmvc_show_data('idfield', $this->data['settings']['field_id']), 'validation') == 'is_phone') {
216 + $this->data['field_value'] = '<a class="value" href="tel:' . wdk_filter_phone($this->data['field_value']) . '">' . $this->_generate_label() . '</a>';
217 + } elseif (wdk_field_option(wmvc_show_data('idfield', $this->data['settings']['field_id']), 'validation') == 'is_phone|wdk_viber') {
218 + $this->data['field_value'] = '<a class="value" href="viber://chat?number=' . wdk_filter_viber_phone($this->data['field_value']) . '">' . $this->_generate_label() . '</a>';
219 + } elseif (wdk_field_option(wmvc_show_data('idfield', $this->data['settings']['field_id']), 'validation') == 'is_phone|wdk_whatsapp') {
220 + $this->data['field_value'] = '<a class="value" target="_blank" href="//wa.me/' . wdk_filter_phone($this->data['field_value']) . '">' . $this->_generate_label() . '</a>';
214 221 }
215 - }
216 - elseif($this->data['settings']['field_id'] == 'category_id') {
217 - if(wdk_field_value ($this->data['settings']['field_id'], $wdk_listing_id)){
222 + } elseif ($this->data['settings']['field_id'] == 'category_id') {
223 + if (wdk_field_value($this->data['settings']['field_id'], $wdk_listing_id)) {
218 224 $this->WMVC->model('category_m');
219 - $tree_data = $this->WMVC->category_m->get(wdk_field_value ($this->data['settings']['field_id'], $wdk_listing_id), TRUE);
225 + $tree_data = $this->WMVC->category_m->get(wdk_field_value($this->data['settings']['field_id'], $wdk_listing_id), TRUE);
220 226 $this->data['field_value'] = wmvc_show_data('category_title', $tree_data);
221 227
222 - if(get_option('wdk_multi_categories_other_enable', FALSE))
223 - if(wdk_field_value ('categories_list', $wdk_listing_id)){
224 - $other_categories = wdk_generate_other_categories_fast(wdk_field_value ('categories_list', $wdk_listing_id));
225 - if(!empty($other_categories))
226 - $this->data['field_value'] .=', '.join(', ',$other_categories);
228 + if (get_option('wdk_multi_categories_other_enable', FALSE))
229 + if (wdk_field_value('categories_list', $wdk_listing_id)) {
230 + $other_categories = wdk_generate_other_categories_fast(wdk_field_value('categories_list', $wdk_listing_id));
231 + if (!empty($other_categories))
232 + $this->data['field_value'] .= ', ' . join(', ', $other_categories);
227 233 }
228 234
229 - $this->data['field_value'] =__($this->data['field_value'], 'wpdirectorykit');
235 + // Dynamic field values are registered in the translation catalog separately.
236 +// phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText
237 + $this->data['field_value'] = __($this->data['field_value'], 'wpdirectorykit');
230 238 }
231 - }
232 - elseif($this->data['settings']['field_id'] == 'location_id') {
233 - if(wdk_field_value ($this->data['settings']['field_id'], $wdk_listing_id)){
239 + } elseif ($this->data['settings']['field_id'] == 'location_id') {
240 + if (wdk_field_value($this->data['settings']['field_id'], $wdk_listing_id)) {
234 241 $this->WMVC->model('location_m');
235 - $tree_data = $this->WMVC->location_m->get(wdk_field_value ($this->data['settings']['field_id'], $wdk_listing_id), TRUE);
242 + $tree_data = $this->WMVC->location_m->get(wdk_field_value($this->data['settings']['field_id'], $wdk_listing_id), TRUE);
236 243 $this->data['field_value'] = wmvc_show_data('location_title', $tree_data);
237 -
238 - if(get_option('wdk_multi_locations_other_enable', FALSE))
239 - if(wdk_field_value ('locations_list', $wdk_listing_id)){
240 - $other_locations = wdk_generate_other_locations_fast(wdk_field_value ('locations_list', $wdk_listing_id));
241 - if(!empty($other_locations))
242 - $this->data['field_value'] .=', '.join(', ',$other_locations);
244 +
245 + if (get_option('wdk_multi_locations_other_enable', FALSE))
246 + if (wdk_field_value('locations_list', $wdk_listing_id)) {
247 + $other_locations = wdk_generate_other_locations_fast(wdk_field_value('locations_list', $wdk_listing_id));
248 + if (!empty($other_locations))
249 + $this->data['field_value'] .= ', ' . join(', ', $other_locations);
243 250 }
244 251
245 - $this->data['field_value'] =__($this->data['field_value'], 'wpdirectorykit');
252 + // Dynamic field values are registered in the translation catalog separately.
253 + // phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText
254 + $this->data['field_value'] = __($this->data['field_value'], 'wpdirectorykit');
246 255 }
247 -
248 - }
249 - elseif(wdk_field_option($this->data['settings']['field_id'], 'field_type') == "DATE") {
250 - $this->data['field_value'] = __(wdk_get_date(wdk_field_value ($this->data['settings']['field_id'], $wdk_listing_id)), 'wpdirectorykit') ;
251 - }
252 - elseif(strpos($this->data['settings']['field_id'],'date') !== FALSE) {
253 - $this->data['field_value'] =__(wdk_get_date(wdk_field_value ($this->data['settings']['field_id'], $wdk_listing_id)), 'wpdirectorykit') ;
254 - }
255 - elseif(
256 + } elseif (wdk_field_option($this->data['settings']['field_id'], 'field_type') == "DATE") {
257 + // Dynamic field values are registered in the translation catalog separately.
258 +// phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText
259 + $this->data['field_value'] = __(wdk_get_date(wdk_field_value($this->data['settings']['field_id'], $wdk_listing_id)), 'wpdirectorykit');
260 + } elseif (strpos($this->data['settings']['field_id'], 'date') !== FALSE) {
261 + // Dynamic field values are registered in the translation catalog separately.
262 +// phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText
263 + $this->data['field_value'] = __(wdk_get_date(wdk_field_value($this->data['settings']['field_id'], $wdk_listing_id)), 'wpdirectorykit');
264 + } elseif (
256 265 wdk_field_option($this->data['settings']['field_id'], 'field_type') == "TEXTAREA" ||
257 266 $this->data['settings']['field_id'] == 'post_content'
258 267 ) {
259 268 global $wp_embed;
260 - $this->data['field_value'] = wpautop(__(wdk_field_value ($this->data['settings']['field_id'], $wdk_listing_id), 'wpdirectorykit' ));
261 - $this->data['field_value'] = html_entity_decode($wp_embed->autoembed($this->data['field_value'] ));
269 + // Dynamic field values are registered in the translation catalog separately.
270 +// phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText
271 + $this->data['field_value'] = wpautop(__(wdk_field_value($this->data['settings']['field_id'], $wdk_listing_id), 'wpdirectorykit'));
272 + $this->data['field_value'] = html_entity_decode($wp_embed->autoembed($this->data['field_value']));
273 + } elseif (
274 + wdk_field_option($this->data['settings']['field_id'], 'field_type') == "FILEUPLOAD"
275 + ) {
276 + $this->data['field_value'] = wdk_field_value($this->data['settings']['field_id'], $wdk_listing_id);
277 + $this->data['field_value'] = wdk_files_data($this->data['field_value'], 'full');
278 +
279 +
280 + wp_enqueue_style('wdk-field-files');
281 + wp_enqueue_style('blueimp-gallery');
282 + wp_enqueue_script('blueimp-gallery');
283 + wp_enqueue_script('wdk-blueimp-gallery');
284 + } else {
285 + // Dynamic field values are registered in the translation catalog separately.
286 +// phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText
287 + $this->data['field_value'] = __(wdk_field_value($this->data['settings']['field_id'], $wdk_listing_id, wdk_field_option($this->data['settings']['field_id'], 'empty_value')), 'wpdirectorykit');
262 288 }
263 - else {
264 - $this->data['field_value'] =__( wdk_field_value ($this->data['settings']['field_id'], $wdk_listing_id, wdk_field_option($this->data['settings']['field_id'],'empty_value')), 'wpdirectorykit');
265 - }
266 289 } else {
267 - if(wdk_field_option($this->data['settings']['field_id'],'field_type') == "CHECKBOX"){
268 - $this->data['field_value'] = '<span class="field_checkbox_success">'.$this->generate_icon($this->data['settings']['field_checkbox_icon_success']).'</span>';
269 - } elseif($this->data['settings']['field_id'] == 'post_title') {
270 - $this->data['field_value'] = esc_html__('Example', 'wpdirectorykit') .' '.esc_html__('Title', 'wpdirectorykit');
271 - } elseif($this->data['settings']['field_id'] == 'address') {
272 - $this->data['field_value'] = esc_html__('Example', 'wpdirectorykit') .' '.esc_html__('Address', 'wpdirectorykit');
273 - } elseif($this->data['settings']['field_id'] == 'post_content') {
274 - $this->data['field_value'] = esc_html__('Example', 'wpdirectorykit') .' '.esc_html__('Content', 'wpdirectorykit');
275 - } elseif($this->data['settings']['field_id'] == 'post_title') {
276 - $this->data['field_value'] = esc_html__('Example', 'wpdirectorykit') .' '.esc_html__('Title', 'wpdirectorykit');
277 - } elseif($this->data['settings']['field_id'] == 'counter_views') {
278 - $this->data['field_label'] = esc_html__('Example', 'wpdirectorykit') .' '.esc_html__('Views counter', 'wpdirectorykit');
290 + if (wdk_field_option($this->data['settings']['field_id'], 'field_type') == "CHECKBOX") {
291 + $this->data['field_value'] = '<span class="field_checkbox_success">' . $this->generate_icon($this->data['settings']['field_checkbox_icon_success']) . '</span>';
292 + } elseif ($this->data['settings']['field_id'] == 'post_title') {
293 + $this->data['field_value'] = esc_html__('Example', 'wpdirectorykit') . ' ' . esc_html__('Title', 'wpdirectorykit');
294 + } elseif ($this->data['settings']['field_id'] == 'address') {
295 + $this->data['field_value'] = esc_html__('Example', 'wpdirectorykit') . ' ' . esc_html__('Address', 'wpdirectorykit');
296 + } elseif ($this->data['settings']['field_id'] == 'post_content') {
297 + $this->data['field_value'] = esc_html__('Example', 'wpdirectorykit') . ' ' . esc_html__('Content', 'wpdirectorykit');
298 + } elseif ($this->data['settings']['field_id'] == 'post_title') {
299 + $this->data['field_value'] = esc_html__('Example', 'wpdirectorykit') . ' ' . esc_html__('Title', 'wpdirectorykit');
300 + } elseif ($this->data['settings']['field_id'] == 'counter_views') {
301 + $this->data['field_label'] = esc_html__('Example', 'wpdirectorykit') . ' ' . esc_html__('Views counter', 'wpdirectorykit');
302 + } elseif (wdk_field_option($this->data['settings']['field_id'], 'field_type') == 'FILEUPLOAD') {
303 + $this->data['field_value'] = array_fill(0, 6, wdk_placeholder_image_src());
304 + } else {
305 + $this->data['field_value'] = esc_html__('Example', 'wpdirectorykit') . ' ' . wdk_field_label($this->data['settings']['field_id']);
279 306 }
280 - else{
281 - $this->data['field_value'] = esc_html__('Example', 'wpdirectorykit') .' '. wdk_field_label($this->data['settings']['field_id']);
282 - }
283 - }
284 - $this->data['field_prefix'] = wdk_field_option ($this->data['settings']['field_id'], 'prefix');
285 - $this->data['field_suffix'] = wdk_field_option ($this->data['settings']['field_id'], 'suffix');
307 + }
308 + $this->data['field_prefix'] = wdk_field_option($this->data['settings']['field_id'], 'prefix');
309 + $this->data['field_suffix'] = wdk_field_option($this->data['settings']['field_id'], 'suffix');
286 310 }
287 311
288 - $this->data['is_edit_mode']= false;
289 - if(Plugin::$instance->editor->is_edit_mode() || empty($wdk_listing_id)) {
290 - $this->data['is_edit_mode']= true;
291 - if(is_intval($this->data['settings']['field_id']) && wdk_field_option($this->data['settings']['field_id'], 'is_visible_frontend') != 1) {
312 + $this->data['is_edit_mode'] = false;
313 + if (Plugin::$instance->editor->is_edit_mode() || empty($wdk_listing_id)) {
314 + $this->data['is_edit_mode'] = true;
315 + if (is_intval($this->data['settings']['field_id']) && wdk_field_option($this->data['settings']['field_id'], 'is_visible_frontend') != 1) {
292 316 $this->data['field_value'] .= ' <span class="dashicons dashicons-hidden" style="color:red"></span>';
293 317 }
294 318 } else {
295 - if(is_intval($this->data['settings']['field_id']) && wdk_field_option($this->data['settings']['field_id'], 'is_visible_frontend') != 1) {
319 + if (is_intval($this->data['settings']['field_id']) && wdk_field_option($this->data['settings']['field_id'], 'is_visible_frontend') != 1) {
296 320 return false;
297 321 }
298 322
299 - if(wdk_field_value('category_id', $wdk_listing_id) && wdk_depend_is_hidden_field($this->data['settings']['field_id'], wdk_field_value('category_id', $wdk_listing_id))) {
323 + if (wdk_field_value('category_id', $wdk_listing_id) && wdk_depend_is_hidden_field($this->data['settings']['field_id'], wdk_field_value('category_id', $wdk_listing_id))) {
300 324 return false;
301 - }
325 + }
302 326
303 327 /* return false if no content */
304 - if($this->data['settings']['hide_onempty'] == 'yes' && wdk_field_value($this->data['settings']['field_id'], $wdk_listing_id) == '')
328 + if ($this->data['settings']['hide_onempty'] == 'yes' && wdk_field_value($this->data['settings']['field_id'], $wdk_listing_id) == '')
305 329 return false;
306 -
307 - $this->data['field_prefix'] = apply_filters( 'wpdirectorykit/listing/field/prefix', $this->data['field_prefix'], $this->data['settings']['field_id']);
308 - $this->data['field_suffix'] = apply_filters( 'wpdirectorykit/listing/field/suffix',$this->data['field_suffix'], $this->data['settings']['field_id']);
309 -
330 +
331 + $this->data['field_prefix'] = apply_filters('wpdirectorykit/listing/field/prefix', $this->data['field_prefix'], $this->data['settings']['field_id']);
332 + $this->data['field_suffix'] = apply_filters('wpdirectorykit/listing/field/suffix', $this->data['field_suffix'], $this->data['settings']['field_id']);
333 +
310 334 /* price format implement */
311 - if(function_exists('run_wdk_currency_conversion') && wdk_currencies_is_price_field($this->data['settings']['field_id'])) {
335 + if (function_exists('run_wdk_currency_conversion') && wdk_currencies_is_price_field($this->data['settings']['field_id'])) {
312 336 /* if currency_conversion and field is price */
313 - $value = strip_tags(apply_filters( 'wpdirectorykit/listing/field/value', wdk_filter_decimal($this->data['field_value']), $this->data['settings']['field_id'], FALSE));
337 + $value = wp_strip_all_tags(apply_filters('wpdirectorykit/listing/field/value', wdk_filter_decimal($this->data['field_value']), $this->data['settings']['field_id'], FALSE));
314 338 $this->data['field_value'] = esc_html(wdk_number_format_i18n($value));
315 - } elseif(wdk_field_option($this->data['settings']['field_id'], 'is_price_format') && wdk_field_option($this->data['settings']['field_id'], 'field_type') == 'NUMBER' && !empty($this->data['field_value'])) {
339 + } elseif (wdk_field_option($this->data['settings']['field_id'], 'is_price_format') && wdk_field_option($this->data['settings']['field_id'], 'field_type') == 'NUMBER' && !empty($this->data['field_value'])) {
316 340 /* if field enabled is_price_format and field type is number*/
317 - $value = strip_tags(apply_filters( 'wpdirectorykit/listing/field/value', wdk_filter_decimal($this->data['field_value']), $this->data['settings']['field_id'], FALSE));
341 + $value = wp_strip_all_tags(apply_filters('wpdirectorykit/listing/field/value', wdk_filter_decimal($this->data['field_value']), $this->data['settings']['field_id'], FALSE));
318 342 $this->data['field_value'] = esc_html(wdk_number_format_i18n($value));
319 343 } else {
320 344 /* without number format */
321 - $this->data['field_value'] = apply_filters( 'wpdirectorykit/listing/field/value', $this->data['field_value'], $this->data['settings']['field_id']);
345 + $this->data['field_value'] = apply_filters('wpdirectorykit/listing/field/value', $this->data['field_value'], $this->data['settings']['field_id']);
322 346 }
323 347 }
324 -
325 - echo $this->view('wdk-field-value', $this->data);
348 +
349 + $this->view('wdk-field-value', $this->data, true);
326 350 }
327 351
352 + private function _generate_label()
353 + {
354 + if (wmvc_show_data('link_value', $this->data['settings']) == 'value') {
355 + return $this->data['field_value'];
356 + } else if (wmvc_show_data('link_value', $this->data['settings']) == 'label') {
357 + return wdk_field_label($this->data['settings']['field_id']);
358 + } else if (wmvc_show_data('link_value', $this->data['settings']) == 'icon' && wdk_field_option($this->data['settings']['field_id'], 'icon_id')) {
359 + return '<img src="' . esc_url(wdk_image_src(array('icon_id' => wdk_field_option($this->data['settings']['field_id'], 'icon_id')), 'full', NULL, 'icon_id')) . '">';
360 + } else {
361 + return wdk_field_label($this->data['settings']['field_id']);
362 + }
363 + }
328 364
329 - private function generate_controls_conf() {
365 +
366 + private function generate_controls_conf()
367 + {
330 368 $this->start_controls_section(
331 369 'tab_conf_main_section',
332 370 [
333 371 'label' => esc_html__('Main', 'wpdirectorykit'),
@@ -334,84 +372,100 @@
334 372 'tab' => '1',
335 373 ]
336 374 );
337 375
338 -
376 +
339 377 $this->add_control(
340 378 'html_tag',
341 379 [
342 - 'label' => __( 'HTML Tag', 'wpdirectorykit' ),
380 + 'label' => __('HTML Tag', 'wpdirectorykit'),
343 381 'type' => \Elementor\Controls_Manager::SELECT,
344 382 'default' => 'span',
345 383 'options' => array(
346 - ''=>__( 'Default', 'wpdirectorykit' ),
347 - 'h1'=>'H1',
348 - 'h2'=>'H2',
349 - 'h3'=>'H3',
350 - 'h4'=>'H4',
351 - 'h5'=>'H5',
352 - 'h6'=>'H6',
353 - 'span'=>'span',
354 - 'address'=>'address',
355 - 'strong'=>'strong',
356 - 'div'=>'div',
357 - 'p'=>'p',
358 - 'q'=>'q',
359 - 'time'=>'time',
384 + '' => __('Default', 'wpdirectorykit'),
385 + 'h1' => 'H1',
386 + 'h2' => 'H2',
387 + 'h3' => 'H3',
388 + 'h4' => 'H4',
389 + 'h5' => 'H5',
390 + 'h6' => 'H6',
391 + 'span' => 'span',
392 + 'address' => 'address',
393 + 'strong' => 'strong',
394 + 'div' => 'div',
395 + 'p' => 'p',
396 + 'q' => 'q',
397 + 'time' => 'time',
360 398 ),
361 - 'separator' => 'after',
362 399 ]
363 400 );
364 401
365 402 $fields_data = wdk_cached_field_get();
366 403 $fields_list = array('' => esc_html__('Not Selected', 'wpdirectorykit'));
367 - $order_i = 0;
404 + $fields_number_types = array();
405 +
406 + $fields_list['section'] = esc_html__('-- Section Custom fields --', 'wpdirectorykit');
407 + $fields_list['idlisting'] = esc_html__('Id listing', 'wpdirectorykit');
408 + $fields_list['post_id'] = esc_html__('Post Id', 'wpdirectorykit');
409 + $fields_list['counter_views'] = esc_html__('Views counter', 'wpdirectorykit');
410 + $fields_list['lat'] = esc_html__('Gps Lat', 'wpdirectorykit');
411 + $fields_list['lng'] = esc_html__('Gps Lng', 'wpdirectorykit');
412 + $fields_list['date'] = esc_html__('Date', 'wpdirectorykit');
413 + $fields_list['date_modified'] = esc_html__('Date Modified', 'wpdirectorykit');
414 + $fields_list['post_title'] = esc_html__('WP Title', 'wpdirectorykit');
415 + $fields_list['post_content'] = esc_html__('WP Content', 'wpdirectorykit');
416 + $fields_list['address'] = esc_html__('Address', 'wpdirectorykit');
417 + $fields_list['category_id'] = esc_html__('Category', 'wpdirectorykit');
418 + $fields_list['location_id'] = esc_html__('Location', 'wpdirectorykit');
368 419
369 - $fields_list [(++$order_i).'__section'] = esc_html__('-- Section Custom fields --', 'wpdirectorykit');
370 - $fields_list [(++$order_i).'__idlisting'] = esc_html__('Id listing', 'wpdirectorykit');
371 - $fields_list [(++$order_i).'__post_id'] = esc_html__('Post Id', 'wpdirectorykit');
372 - $fields_list [(++$order_i).'__counter_views'] = esc_html__('Views counter', 'wpdirectorykit');
373 - $fields_list [(++$order_i).'__lat'] = esc_html__('Gps Lat', 'wpdirectorykit');
374 - $fields_list [(++$order_i).'__lng'] = esc_html__('Gps Lng', 'wpdirectorykit');
375 - $fields_list [(++$order_i).'__date'] = esc_html__('Date', 'wpdirectorykit');
376 - $fields_list [(++$order_i).'__date_modified'] = esc_html__('Date Modified', 'wpdirectorykit');
377 - $fields_list [(++$order_i).'__post_title'] = esc_html__('WP Title', 'wpdirectorykit');
378 - $fields_list [(++$order_i).'__post_content'] = esc_html__('WP Content', 'wpdirectorykit');
379 - $fields_list [(++$order_i).'__address'] = esc_html__('Address', 'wpdirectorykit');
380 - $fields_list [(++$order_i).'__category_id'] = esc_html__('Category', 'wpdirectorykit');
381 - $fields_list [(++$order_i).'__location_id'] = esc_html__('Location', 'wpdirectorykit');
420 + foreach ($fields_data as $field) {
421 + if (wmvc_show_data('field_type', $field) == 'SECTION') {
422 + $fields_list['section__' . wmvc_show_data('idfield', $field)] = '-- ' . esc_html__('Section', 'wpdirectorykit') . ' ' . wmvc_show_data('field_label', $field) . ' --';
423 + } else {
424 + $fields_list[wmvc_show_data('idfield', $field)] = '#' . wmvc_show_data('idfield', $field) . ' ' . wmvc_show_data('field_label', $field) . '[' . wmvc_show_data('field_type', $field) . ']';
382 425
383 - foreach($fields_data as $field)
384 - {
385 - if(wmvc_show_data('field_type', $field) == 'SECTION') {
386 - $fields_list [(++$order_i).'section__'.wmvc_show_data('idfield', $field)] = '-- '.esc_html__('Section', 'wpdirectorykit').' '.wmvc_show_data('field_label', $field).' --';
387 - } else {
388 - $fields_list[(++$order_i).'__'.wmvc_show_data('idfield', $field)] = '#'.wmvc_show_data('idfield', $field).' '.wmvc_show_data('field_label', $field).'['.wmvc_show_data('field_type', $field).']';
426 + if (wmvc_show_data('field_type', $field) == 'FILEUPLOAD') {
427 + $this->fields_list_files[] = wmvc_show_data('idfield', $field);
428 + }
389 429 }
430 +
431 + if (wmvc_show_data('field_type', $field) == 'NUMBER') {
432 + $fields_number_types[] = wmvc_show_data('idfield', $field);
433 + }
390 434 }
391 435
436 + // build raw_options preserving order
437 + $raw = [];
438 + foreach ( $fields_list as $k => $v ) {
439 + $raw[] = [
440 + 'value' => (string) $k,
441 + 'label' => $v,
442 + ];
443 + }
444 +
392 445 $this->add_control(
393 446 'field_id',
394 447 [
395 - 'label' => __( 'Field id', 'wpdirectorykit' ),
396 - 'type' => \Elementor\Controls_Manager::SELECT2,
448 + 'label' => __('Field id', 'wpdirectorykit'),
449 + 'type' => \Wdk\Includes\Controls\Wdk_Field_Selector::INIT,
397 450 'default' => '',
398 451 'options' => $fields_list,
452 + 'raw_options' => $raw,
399 453 'separator' => 'after',
400 454 ]
401 455 );
402 -
456 +
403 457 $this->add_control(
404 - 'hide_onempty',
405 - [
406 - 'label' => __( 'Hide if empty', 'wpdirectorykit' ),
407 - 'type' => \Elementor\Controls_Manager::SWITCHER,
408 - 'label_on' => __( 'True', 'wpdirectorykit' ),
409 - 'label_off' => __( 'False', 'wpdirectorykit' ),
410 - 'return_value' => 'yes',
411 - 'default' => '',
412 - ]
413 - );
458 + 'hide_onempty',
459 + [
460 + 'label' => __('Hide if empty', 'wpdirectorykit'),
461 + 'type' => \Elementor\Controls_Manager::SWITCHER,
462 + 'label_on' => __('True', 'wpdirectorykit'),
463 + 'label_off' => __('False', 'wpdirectorykit'),
464 + 'return_value' => 'yes',
465 + 'default' => '',
466 + ]
467 + );
414 468
415 469 $this->add_control(
416 470 'link_value',
417 471 [
@@ -425,69 +479,114 @@
425 479 ],
426 480 ]
427 481 );
428 482
483 + $this->add_control(
484 + 'show_like_stars',
485 + [
486 + 'label' => __('Show like stars', 'wpdirectorykit'),
487 + 'type' => \Elementor\Controls_Manager::SWITCHER,
488 + 'label_on' => __('On', 'wpdirectorykit'),
489 + 'label_off' => __('Off', 'wpdirectorykit'),
490 + 'return_value' => 'yes',
491 + 'default' => '',
492 + 'description' => esc_html__('Numeric values required', 'wpdirectorykit'),
493 + 'condition' => [
494 + 'field_id' => $fields_number_types,
495 + ],
496 + ]
497 + );
498 +
499 + $this->add_control(
500 + 'max_stars',
501 + [
502 + 'label' => __('Max Stars', 'wpdirectorykit'),
503 + 'type' => \Elementor\Controls_Manager::NUMBER,
504 + 'min' => 1,
505 + 'max' => 10,
506 + 'step' => 1,
507 + 'default' => 5,
508 + 'condition' => [
509 + 'show_like_stars' => 'yes',
510 + ],
511 + 'description' => esc_html__('Set the maximum number of stars to display.', 'wpdirectorykit'),
512 + ]
513 + );
514 +
429 515 $this->end_controls_section();
430 -
431 516 }
432 517
433 - private function generate_controls_layout() {
434 - }
518 + private function generate_controls_layout() {}
435 519
436 520
437 - private function generate_controls_styles() {
521 + private function generate_controls_styles()
522 + {
438 523 $items = [
439 524 [
440 - 'key'=>'field_value',
441 - 'label'=> esc_html__('Field Value', 'wpdirectorykit'),
442 - 'selector'=>'{{WRAPPER}} .wdk-field-value .value, {{WRAPPER}} .wdk-field-value .value p',
443 - 'selector_hover'=>'{{WRAPPER}} .wdk-field-value .value%1$s, {{WRAPPER}} .wdk-field-value .value%1$s p',
444 - 'options'=>'full',
525 + 'key' => 'field_value',
526 + 'label' => esc_html__('Field Value', 'wpdirectorykit'),
527 + 'selector' => '{{WRAPPER}} .wdk-field-value .value, {{WRAPPER}} .wdk-field-value .value p',
528 + 'selector_hover' => '{{WRAPPER}} .wdk-field-value .value%1$s, {{WRAPPER}} .wdk-field-value .value%1$s p, .wdk-listings-results .hover_link:hover {{WRAPPER}} .wdk-field-value .value, .wdk-listings-results .hover_link:hover {{WRAPPER}} .wdk-field-value .value p',
529 + 'options' => 'full',
445 530 ],
446 531 [
447 - 'key'=>'field_prefix',
448 - 'label'=> esc_html__('Field Prefix', 'wpdirectorykit'),
449 - 'selector'=>'{{WRAPPER}} .wdk-field-value .prefix',
450 - 'selector_hover'=>'{{WRAPPER}} .wdk-field-value .prefix%1$s',
451 - 'options'=>'full',
532 + 'key' => 'field_prefix',
533 + 'label' => esc_html__('Field Prefix', 'wpdirectorykit'),
534 + 'selector' => '{{WRAPPER}} .wdk-field-value .prefix',
535 + 'selector_hover' => '{{WRAPPER}} .wdk-field-value .prefix%1$s, .wdk-listings-results .hover_link:hover {{WRAPPER}} .wdk-field-value .prefix',
536 + 'options' => 'full',
452 537 ],
453 538 [
454 - 'key'=>'field_suffix',
455 - 'label'=> esc_html__('Field Suffix', 'wpdirectorykit'),
456 - 'selector'=>'{{WRAPPER}} .wdk-field-value .suffix',
457 - 'selector_hover'=>'{{WRAPPER}} .wdk-field-value .suffix%1$s',
458 - 'options'=>'full',
539 + 'key' => 'field_suffix',
540 + 'label' => esc_html__('Field Suffix', 'wpdirectorykit'),
541 + 'selector' => '{{WRAPPER}} .wdk-field-value .suffix',
542 + 'selector_hover' => '{{WRAPPER}} .wdk-field-value .suffix%1$s, .wdk-listings-results .hover_link:hover {{WRAPPER}} .wdk-field-value .suffix',
543 + 'options' => 'full',
459 544 ]
460 545 ];
461 546
462 547 foreach ($items as $item) {
463 548 $this->start_controls_section(
464 - $item['key'].'_section',
549 + $item['key'] . '_section',
465 550 [
466 551 'label' => $item['label'],
467 - 'tab' => 'tab_layout'
552 + 'tab' => 'tab_layout',
553 + 'conditions' => [
554 + 'terms' => [
555 + [
556 + 'name' => 'field_id',
557 + 'operator' => '!in',
558 + 'value' => $this->fields_list_files,
559 + ],
560 + [
561 + 'name' => 'show_like_stars',
562 + 'operator' => '!=',
563 + 'value' => 'yes',
564 + ],
565 + ],
566 + ],
468 567 ]
469 568 );
470 569
471 - if( $item ['key'] == 'field_value'){
570 + if ($item['key'] == 'field_value') {
472 571 $selectors = array(
473 572 'normal' => '{{WRAPPER}} .wdk-field-value',
474 573 );
475 - $this->generate_renders_tabs($selectors, $item['key'].'_dynamic_align', ['align']);
574 + $this->generate_renders_tabs($selectors, $item['key'] . '_dynamic_align', ['align']);
476 575 }
477 576
478 577 $selectors = array();
479 - if(!empty($item['selector']))
578 + if (!empty($item['selector']))
480 579 $selectors['normal'] = $item['selector'];
481 580
482 - if(!empty($item['selector_hover']))
581 + if (!empty($item['selector_hover']))
483 582 $selectors['hover'] = $item['selector_hover'];
484 583
485 - if(!empty($item['selector_focus']))
584 + if (!empty($item['selector_focus']))
486 585 $selectors['focus'] = $item['selector_hover'];
487 -
488 - $this->generate_renders_tabs($selectors, $item['key'].'_dynamic', $item['options'], ['align']);
489 586
587 + $this->generate_renders_tabs($selectors, $item['key'] . '_dynamic', $item['options'], ['align']);
588 +
490 589 $this->end_controls_section();
491 590 /* END special for some elements */
492 591 }
493 592
@@ -496,11 +595,25 @@
496 595 'field_checkbox_icon',
497 596 [
498 597 'label' => esc_html__('Checkbox', 'wpdirectorykit'),
499 598 'tab' => Controls_Manager::TAB_STYLE,
599 + 'conditions' => [
600 + 'terms' => [
601 + [
602 + 'name' => 'field_id',
603 + 'operator' => '!in',
604 + 'value' => $this->fields_list_files,
605 + ],
606 + [
607 + 'name' => 'show_like_stars',
608 + 'operator' => '!=',
609 + 'value' => 'yes',
610 + ],
611 + ],
612 + ],
500 613 ]
501 614 );
502 -
615 +
503 616 $this->add_responsive_control(
504 617 'field_checkbox_icon_success_header',
505 618 [
506 619 'label' => esc_html__('Success checkbox', 'wpdirectorykit'),
@@ -507,9 +620,9 @@
507 620 'type' => Controls_Manager::HEADING,
508 621 'separator' => 'before',
509 622 ]
510 623 );
511 -
624 +
512 625 $this->add_control(
513 626 'field_checkbox_icon_success',
514 627 [
515 628 'label' => esc_html__('Icon', 'wpdirectorykit'),
@@ -518,17 +631,17 @@
518 631 'default' => [
519 632 'value' => 'fa fa-check',
520 633 'library' => 'solid',
521 634 ],
522 - ]
635 + ]
523 636 );
524 -
637 +
525 638 $selectors = array(
526 639 'normal' => '{{WRAPPER}} .field_checkbox_success',
527 640 );
528 641 $this->generate_renders_tabs($selectors, 'field_checkbox_icon_success_dynamic', 'full');
529 -
530 -
642 +
643 +
531 644 $this->add_responsive_control(
532 645 'field_checkbox_icon_unsuccess_header',
533 646 [
534 647 'label' => esc_html__('Unsuccess checkbox', 'wpdirectorykit'),
@@ -535,9 +648,9 @@
535 648 'type' => Controls_Manager::HEADING,
536 649 'separator' => 'before',
537 650 ]
538 651 );
539 -
652 +
540 653 $this->add_control(
541 654 'field_checkbox_icon_unsuccess',
542 655 [
543 656 'label' => esc_html__('Icon', 'wpdirectorykit'),
@@ -546,23 +659,571 @@
546 659 'default' => [
547 660 'value' => 'fa fa-close',
548 661 'library' => 'solid',
549 662 ],
550 - ]
663 + ]
551 664 );
552 -
665 +
553 666 $selectors = array(
554 667 'normal' => '{{WRAPPER}} .field_checkbox_unsuccess',
555 668 );
556 669 $this->generate_renders_tabs($selectors, 'field_checkbox_icon_unsuccess_dynamic', 'full');
557 -
670 +
558 671 $this->end_controls_section();
672 +
673 +
674 +
675 + /* Stars */
676 + $this->start_controls_section(
677 + 'field_star_icon',
678 + [
679 + 'label' => esc_html__('Stars Options', 'wpdirectorykit'),
680 + 'tab' => Controls_Manager::TAB_STYLE,
681 + 'conditions' => [
682 + 'terms' => [
683 + [
684 + 'name' => 'show_like_stars',
685 + 'value' => 'yes',
686 + ],
687 + ],
688 + ],
689 + ]
690 + );
691 +
692 + $this->add_responsive_control(
693 + 'active_star_icon_header',
694 + [
695 + 'label' => esc_html__('Active Star Icon', 'wpdirectorykit'),
696 + 'type' => Controls_Manager::HEADING,
697 + 'separator' => 'before',
698 + ]
699 + );
700 +
701 + $this->add_control(
702 + 'active_star_icon',
703 + [
704 + 'label' => esc_html__('Icon', 'wpdirectorykit'),
705 + 'type' => Controls_Manager::ICONS,
706 + 'label_block' => true,
707 + 'default' => [
708 + 'value' => 'fas fa-star',
709 + 'library' => 'solid',
710 + ],
711 + ]
712 + );
713 +
714 + $selectors = array(
715 + 'normal' => '{{WRAPPER}} .wdk-field-value-stars-lst .star-active',
716 + );
717 + $this->generate_renders_tabs($selectors, 'active_star_icon_dynamic', ['color']);
718 +
719 + $this->add_responsive_control(
720 + 'inactive_star_icon_header',
721 + [
722 + 'label' => esc_html__('Inactive Star Icon', 'wpdirectorykit'),
723 + 'type' => Controls_Manager::HEADING,
724 + 'separator' => 'before',
725 + ]
726 + );
727 +
728 + $this->add_control(
729 + 'inactive_star_icon',
730 + [
731 + 'label' => esc_html__('Icon', 'wpdirectorykit'),
732 + 'type' => Controls_Manager::ICONS,
733 + 'label_block' => true,
734 + 'default' => [
735 + 'value' => 'far fa-star',
736 + 'library' => 'solid',
737 + ],
738 + ]
739 + );
740 +
741 + $selectors = array(
742 + 'normal' => '{{WRAPPER}} .wdk-field-value-stars-lst .innactive',
743 + );
744 + $this->generate_renders_tabs($selectors, 'inactive_star_icon_dynamic', ['color']);
745 +
746 + $this->add_responsive_control(
747 + 'star_icon_header',
748 + [
749 + 'label' => esc_html__('Global Options', 'wpdirectorykit'),
750 + 'type' => Controls_Manager::HEADING,
751 + 'separator' => 'before',
752 + ]
753 + );
754 +
755 + $this->add_responsive_control(
756 + 'star_icon_size',
757 + [
758 + 'label' => esc_html__('Star Icon Size', 'wpdirectorykit'),
759 + 'type' => \Elementor\Controls_Manager::SLIDER,
760 + 'size_units' => [ 'px', 'em', 'rem' ],
761 + 'range' => [
762 + 'px' => [
763 + 'min' => 8,
764 + 'max' => 64,
765 + ],
766 + 'em' => [
767 + 'min' => 0.5,
768 + 'max' => 4,
769 + ],
770 + 'rem' => [
771 + 'min' => 0.5,
772 + 'max' => 4,
773 + ],
774 + ],
775 + 'selectors' => [
776 + '{{WRAPPER}} .wdk-field-value-stars-lst i, {{WRAPPER}} .wdk-field-value-stars-lst svg' => 'font-size: {{SIZE}}{{UNIT}};',
777 + '{{WRAPPER}} .wdk-field-value-stars-lst img' => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}};',
778 + ],
779 + ]
780 + );
781 +
782 +
783 + // Add gap between stars
784 + $this->add_responsive_control(
785 + 'stars_gap',
786 + [
787 + 'label' => esc_html__('Stars Gap', 'wpdirectorykit'),
788 + 'type' => \Elementor\Controls_Manager::SLIDER,
789 + 'size_units' => [ 'px', 'em', '%' ],
790 + 'range' => [
791 + 'px' => [
792 + 'min' => 0,
793 + 'max' => 50,
794 + ],
795 + 'em' => [
796 + 'min' => 0,
797 + 'max' => 5,
798 + ],
799 + '%' => [
800 + 'min' => 0,
801 + 'max' => 20,
802 + ],
803 + ],
804 + 'selectors' => [
805 + '{{WRAPPER}} .wdk-field-value-stars-lst' => 'gap: {{SIZE}}{{UNIT}};',
806 + ],
807 + ]
808 + );
809 +
810 + // Add alignment control for stars using flexbox
811 + $this->add_responsive_control(
812 + 'stars_alignment',
813 + [
814 + 'label' => esc_html__('Stars Alignment', 'wpdirectorykit'),
815 + 'type' => \Elementor\Controls_Manager::CHOOSE,
816 + 'options' => [
817 + 'flex-start' => [
818 + 'title' => esc_html__('Left', 'wpdirectorykit'),
819 + 'icon' => 'eicon-text-align-left',
820 + ],
821 + 'center' => [
822 + 'title' => esc_html__('Center', 'wpdirectorykit'),
823 + 'icon' => 'eicon-text-align-center',
824 + ],
825 + 'flex-end' => [
826 + 'title' => esc_html__('Right', 'wpdirectorykit'),
827 + 'icon' => 'eicon-text-align-right',
828 + ],
829 + ],
830 + 'default' => 'flex-start',
831 + 'selectors' => [
832 + '{{WRAPPER}} .wdk-field-value-stars-lst' => 'justify-content: {{VALUE}};',
833 + ],
834 + ]
835 + );
836 +
837 + $this->end_controls_section();
559 838 }
560 839
561 - private function generate_controls_content() {
562 840
841 + private function generate_controls_styles_files()
842 + {
843 + $this->start_controls_section(
844 + 'files_styles_thmbn_section',
845 + [
846 + 'label' => esc_html__('Main', 'wpdirectorykit'),
847 + 'tab' => Controls_Manager::TAB_STYLE,
848 + 'conditions' => [
849 + 'terms' => [
850 + [
851 + 'name' => 'field_id',
852 + 'operator' => 'in',
853 + 'value' => $this->fields_list_files,
854 + ]
855 + ],
856 + ],
857 + ]
858 + );
859 +
860 + $this->add_responsive_control(
861 + 'files_row_gap_col',
862 + [
863 + 'label' => __('Columns', 'wpdirectorykit'),
864 + 'type' => Controls_Manager::SELECT,
865 + 'options' => [
866 + '' => esc_html__('Default', 'wpdirectorykit'),
867 + 'auto' => esc_html__('Auto', 'wpdirectorykit'),
868 + '100%' => '1',
869 + '50%' => '2',
870 + 'calc(100% / 3)' => '3',
871 + '25%' => '4',
872 + '20%' => '5',
873 + 'auto_flexible' => 'auto flexible',
874 + ],
875 + 'selectors_dictionary' => [
876 + 'auto' => 'width:auto;-webkit-flex:0 0 auto;flex:0 0 auto',
877 + '100%' => 'width:100%;-webkit-flex:0 0 100%;flex:0 0 100%',
878 + '50%' => 'width:50%;-webkit-flex:0 0 50%;flex:0 0 50%',
879 + 'calc(100% / 3)' => 'width:calc(100% / 3);-webkit-flex:0 0 calc(100% / 3);flex:0 0 calc(100% / 3)',
880 + '25%' => 'width:25%;-webkit-flex:0 0 25%;flex:0 0 25%',
881 + '20%' => 'width:20%;-webkit-flex:0 0 20%;flex:0 0 20%',
882 + 'auto' => 'width:auto;-webkit-flex:0 0 auto;flex:0 0 auto',
883 + 'auto_flexible' => 'width:auto;-webkit-flex:1 2 auto;flex:1 2 auto',
884 + ],
885 + 'selectors' => [
886 + '{{WRAPPER}} .wdk-row .wdk-col' => '{{UNIT}}',
887 + ],
888 + 'default' => 'calc(100% / 3)',
889 + 'separator' => 'before',
890 + ]
891 + );
892 +
893 + $this->add_responsive_control(
894 + 'files_column_gap',
895 + [
896 + 'label' => esc_html__('Columns Gap', 'wpdirectorykit'),
897 + 'type' => Controls_Manager::SLIDER,
898 + 'default' => [
899 + 'size' => 10,
900 + ],
901 + 'range' => [
902 + 'px' => [
903 + 'min' => 0,
904 + 'max' => 60,
905 + ],
906 + ],
907 + 'selectors' => [
908 + '{{WRAPPER}} .wdk-row .wdk-col' => 'padding-left: {{SIZE}}{{UNIT}};padding-right: {{SIZE}}{{UNIT}};;',
909 + '{{WRAPPER}} .wdk-row' => 'margin-left: -{{SIZE}}{{UNIT}};margin-right: -{{SIZE}}{{UNIT}};',
910 + ],
911 + ]
912 + );
913 +
914 + $this->add_responsive_control(
915 + 'files_row_gap',
916 + [
917 + 'label' => esc_html__('Rows Gap', 'wpdirectorykit'),
918 + 'type' => Controls_Manager::SLIDER,
919 + 'range' => [
920 + 'px' => [
921 + 'min' => 0,
922 + 'max' => 60,
923 + ],
924 + ],
925 + 'selectors' => [
926 + '{{WRAPPER}} .wdk-row .wdk-col' => 'margin-bottom: {{SIZE}}{{UNIT}};',
927 + '{{WRAPPER}} .wdk-row' => 'margin-bottom: -{{SIZE}}{{UNIT}};',
928 + ],
929 + ]
930 + );
931 +
932 + $this->end_controls_section();
933 +
934 + $this->start_controls_section(
935 + 'files_styles_thmbn_type',
936 + [
937 + 'label' => esc_html__('Thumbnail', 'wpdirectorykit'),
938 + 'tab' => Controls_Manager::TAB_STYLE,
939 + 'conditions' => [
940 + 'terms' => [
941 + [
942 + 'name' => 'field_id',
943 + 'operator' => 'in',
944 + 'value' => $this->fields_list_files,
945 + ]
946 + ],
947 + ],
948 + ]
949 + );
950 +
951 + $this->add_control(
952 + 'files_layout_image_design',
953 + [
954 + 'label' => __('Size style thumbnail', 'wpdirectorykit'),
955 + 'type' => \Elementor\Controls_Manager::SELECT,
956 + 'options' => [
957 + '' => __('None', 'wpdirectorykit'),
958 + 'contain' => __('Contain', 'wpdirectorykit'),
959 + 'cover' => __('Cover', 'wpdirectorykit'),
960 + ],
961 + 'selectors' => [
962 + '{{WRAPPER}} .wdk-field-files .wdk-listing-image' => 'object-fit: {{VALUE}}',
963 + ],
964 + ]
965 + );
966 +
967 + $selectors = array(
968 + 'normal' => '{{WRAPPER}} .wdk-field-files .wdk-listing-image',
969 + );
970 + $this->generate_renders_tabs($selectors, 'files_layout_image_dynamic', ['margin', 'padding', 'background', 'border', 'border_radius', 'css_filters', 'shadow', 'transition']);
971 +
972 + $this->add_control(
973 + 'files_enable_fixed_height',
974 + [
975 + 'label' => __('Fixed Height', 'wpdirectorykit'),
976 + 'type' => \Elementor\Controls_Manager::SWITCHER,
977 + 'label_on' => __('True', 'wpdirectorykit'),
978 + 'label_off' => __('False', 'wpdirectorykit'),
979 + 'return_value' => 'yes',
980 + 'default' => 'yes',
981 + ]
982 + );
983 +
984 + $this->add_responsive_control(
985 + 'files_styles_thmbn_des_height',
986 + [
987 + 'label' => esc_html__('Height', 'wpdirectorykit'),
988 + 'type' => Controls_Manager::SLIDER,
989 + 'range' => [
990 + 'px' => [
991 + 'min' => 100,
992 + 'max' => 1500,
993 + ],
994 + 'vw' => [
995 + 'min' => 0,
996 + 'max' => 100,
997 + ],
998 + ],
999 + 'size_units' => ['px', 'em', 'vw', '%', 'custom'],
1000 + 'selectors' => [
1001 + '{{WRAPPER}} .wdk-field-files .wdk-listing-image' => 'height: {{SIZE}}{{UNIT}}',
1002 + ],
1003 + 'separator' => 'after',
1004 + 'conditions' => [
1005 + 'terms' => [
1006 + [
1007 + 'name' => 'files_enable_fixed_height',
1008 + 'operator' => '==',
1009 + 'value' => 'yes',
1010 + ]
1011 + ],
1012 + ],
1013 + ]
1014 + );
1015 +
1016 + $this->end_controls_section();
1017 +
1018 + $items = [
1019 + [
1020 + 'key' => 'image',
1021 + 'label' => esc_html__('Image', 'wpdirectorykit'),
1022 + 'selector' => '{{WRAPPER}} .wdk-field-files .wdk-listing-image-card .wdk-listing-image',
1023 + 'selector_hover' => '{{WRAPPER}} .wdk-field-files .wdk-listing-image-card%1$s .wdk-listing-image',
1024 + 'options' => ['margin', 'background', 'border', 'border_radius', 'padding', 'shadow', 'transition', 'css_filters'],
1025 + ],
1026 + ];
1027 +
1028 + foreach ($items as $item) {
1029 + $this->start_controls_section(
1030 + 'files_' . $item['key'] . '_section',
1031 + [
1032 + 'label' => $item['label'],
1033 + 'tab' => Controls_Manager::TAB_STYLE,
1034 + 'conditions' => [
1035 + 'terms' => [
1036 + [
1037 + 'name' => 'field_id',
1038 + 'operator' => 'in',
1039 + 'value' => $this->fields_list_files,
1040 + ]
1041 + ],
1042 + ],
1043 + ]
1044 + );
1045 +
1046 + if ($item['key'] == 'caption')
1047 + $this->add_responsive_control(
1048 + 'files_' . $item['key'] . '_hide',
1049 + [
1050 + 'label' => esc_html__('Hide Element', 'wpdirectorykit'),
1051 + 'type' => Controls_Manager::SWITCHER,
1052 + 'none' => esc_html__('Hide', 'wpdirectorykit'),
1053 + 'block' => esc_html__('Show', 'wpdirectorykit'),
1054 + 'return_value' => 'none',
1055 + 'default' => '',
1056 + 'selectors' => [
1057 + $item['selector'] => 'display: {{VALUE}};',
1058 + ],
1059 + ]
1060 + );
1061 +
1062 + $selectors = array(
1063 + 'normal' => $item['selector'],
1064 + 'hover' => $item['selector_hover'],
1065 + );
1066 + $this->generate_renders_tabs($selectors, $item['key'] . '_dynamic', $item['options']);
1067 +
1068 + $this->end_controls_section();
1069 + }
1070 +
1071 +
1072 + /* files */
1073 + if (true) {
1074 +
1075 + $this->start_controls_section(
1076 + 'files_files_section',
1077 + [
1078 + 'label' => esc_html__('Files List', 'wpdirectorykit'),
1079 + 'tab' => Controls_Manager::TAB_STYLE,
1080 + 'conditions' => [
1081 + 'terms' => [
1082 + [
1083 + 'name' => 'field_id',
1084 + 'operator' => 'in',
1085 + 'value' => $this->fields_list_files,
1086 + ]
1087 + ],
1088 + ],
1089 + ]
1090 + );
1091 +
1092 + $this->add_responsive_control(
1093 + 'files_files_section_hide',
1094 + [
1095 + 'label' => esc_html__('Hide Element', 'wpdirectorykit'),
1096 + 'type' => Controls_Manager::SWITCHER,
1097 + 'none' => esc_html__('Hide', 'wpdirectorykit'),
1098 + 'block' => esc_html__('Show', 'wpdirectorykit'),
1099 + 'return_value' => 'yes',
1100 + 'default' => '',
1101 + ]
1102 + );
1103 +
1104 + $this->add_control(
1105 + 'files_files_section_box_header',
1106 + [
1107 + 'label' => __('Container', 'wpdirectorykit'),
1108 + 'type' => \Elementor\Controls_Manager::HEADING,
1109 + ]
1110 + );
1111 +
1112 + $selectors = array(
1113 + 'normal' => '{{WRAPPER}} .wdk-field-files .files-row ul.files',
1114 + );
1115 +
1116 + $this->generate_renders_tabs($selectors, 'files_section_bo_dynamic', ['background', 'border', 'border_radius', 'padding', 'margin', 'shadow', 'transition']);
1117 +
1118 + $this->add_control(
1119 + 'files_section_li',
1120 + [
1121 + 'label' => __('List Items', 'wpdirectorykit'),
1122 + 'type' => \Elementor\Controls_Manager::HEADING,
1123 + ]
1124 + );
1125 +
1126 + $this->add_control(
1127 + 'files_section_li_hr',
1128 + [
1129 + 'type' => \Elementor\Controls_Manager::DIVIDER,
1130 + ]
1131 + );
1132 +
1133 + $this->add_control(
1134 + 'files_section_space',
1135 + [
1136 + 'label' => __('Vertical Space', 'wpdirectorykit'),
1137 + 'type' => Controls_Manager::SLIDER,
1138 + 'size_units' => ['px'],
1139 + 'range' => [
1140 + 'px' => [
1141 + 'min' => 0,
1142 + 'max' => 250,
1143 + 'step' => 1,
1144 + ],
1145 + ],
1146 + 'selectors' => [
1147 + '{{WRAPPER}} .wdk-field-files .files-row ul.files li:not(:last-child)' => 'margin-bottom: {{SIZE}}{{UNIT}};',
1148 + ],
1149 + ]
1150 + );
1151 +
1152 + $selectors = array(
1153 + 'normal' => '{{WRAPPER}} .wdk-field-files .files-row ul.files li',
1154 + );
1155 +
1156 + $this->generate_renders_tabs($selectors, 'files_section_item_dynamic', ['align', 'background', 'border', 'border_radius', 'padding', 'shadow', 'transition']);
1157 +
1158 + $this->add_control(
1159 + 'files_section_hr',
1160 + [
1161 + 'type' => \Elementor\Controls_Manager::DIVIDER,
1162 + ]
1163 + );
1164 +
1165 + $this->add_control(
1166 + 'files_section_items',
1167 + [
1168 + 'label' => __('More Styles', 'wpdirectorykit'),
1169 + 'type' => \Elementor\Controls_Manager::HEADING,
1170 + ]
1171 + );
1172 +
1173 + $items = [
1174 + [
1175 + 'key' => 'files_icon',
1176 + 'label' => esc_html__('Icon', 'wpdirectorykit'),
1177 + 'selector' => '{{WRAPPER}} .wdk-field-files .files-row .list-item a .wdk-listing-file-icon',
1178 + 'selector_hover' => '{{WRAPPER}} .wdk-field-files .files-row .list-item%1$s a .wdk-listing-file-icon',
1179 + 'options' => ['margin', 'background', 'border', 'border_radius', 'padding', 'shadow', 'transition', 'image_size_control', 'css_filters', 'hover_animation'],
1180 + ],
1181 + [
1182 + 'key' => 'files_caption',
1183 + 'label' => esc_html__('Caption', 'wpdirectorykit'),
1184 + 'selector' => '{{WRAPPER}} .wdk-field-files .files-row .list-item a',
1185 + 'selector_hover' => '{{WRAPPER}} .wdk-field-files .files-row .list-item a%1$s',
1186 + 'options' => ['margin', 'align', 'typo', 'color', 'background', 'border', 'border_radius', 'padding', 'shadow', 'transition'],
1187 + ],
1188 + ];
1189 +
1190 + foreach ($items as $item) {
1191 + $this->add_control(
1192 + $item['key'] . '_header',
1193 + [
1194 + 'label' => $item['label'],
1195 + 'type' => \Elementor\Controls_Manager::HEADING,
1196 + ]
1197 + );
1198 +
1199 + if ($item['key'] == 'files_icon')
1200 + $this->add_responsive_control(
1201 + $item['key'] . '_hide',
1202 + [
1203 + 'label' => esc_html__('Hide Element', 'wpdirectorykit'),
1204 + 'type' => Controls_Manager::SWITCHER,
1205 + 'none' => esc_html__('Hide', 'wpdirectorykit'),
1206 + 'block' => esc_html__('Show', 'wpdirectorykit'),
1207 + 'return_value' => 'none',
1208 + 'default' => '',
1209 + 'selectors' => [
1210 + $item['selector'] => 'display: {{VALUE}};',
1211 + ],
1212 + ]
1213 + );
1214 +
1215 + $selectors = array(
1216 + 'normal' => $item['selector'],
1217 + 'hover' => $item['selector_hover'],
1218 + );
1219 + $this->generate_renders_tabs($selectors, $item['key'] . '_dynamic', $item['options']);
1220 + }
1221 +
1222 + $this->end_controls_section();
1223 + }
563 1224 }
564 -
565 - public function enqueue_styles_scripts() {
566 -
567 - }
1225 +
1226 + private function generate_controls_content() {}
1227 +
1228 + public function enqueue_styles_scripts() {}
568 1229 }