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 +913 -245 1.2.6 → 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,174 +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);
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'], 'youtu.be/') !== FALSE)
180 - {
181 - $embed_code = substr($this->data['field_value'], strpos($this->data['field_value'], 'youtu.be/')+9);
182 - $this->data['field_value'] = wp_oembed_get('https://www.youtube.com/watch?v='.$embed_code, array("width"=>"800", "height"=>"455"));
183 - }
184 - elseif(filter_var($this->data['field_value'], FILTER_VALIDATE_URL) !== FALSE && preg_match('/\.(mp4|flv|wmw|ogv|webm|ogg)$/i', $this->data['field_value']))
185 - {
186 - $this->data['field_value'] = '<video src="'.$this->data['field_value'].'" controls></video> ';
187 - }
188 - elseif(filter_var($this->data['field_value'] , FILTER_VALIDATE_EMAIL) !== FALSE) {
189 - if(wmvc_show_data('link_value',$this->data['settings']) == 'value') {
190 - $this->data['field_value'] = '<a href="mailto:'.$this->data['field_value'] .'">'.$this->data['field_value'] .'</a>';
191 - } else if(wmvc_show_data('link_value',$this->data['settings']) == 'label') {
192 - $this->data['field_value'] = '<a href="mailto:'.$this->data['field_value'] .'">'.wdk_field_label($this->data['settings']['field_id']) .'</a>';
193 - } else if(wmvc_show_data('link_value',$this->data['settings']) == 'icon' && wdk_field_option ($this->data['settings']['field_id'], 'icon_id')) {
194 - $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>';
195 202 } else {
196 - $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>';
197 204 }
198 - }
199 - elseif(filter_var($this->data['field_value'] , FILTER_VALIDATE_URL) !== FALSE) {
200 - if(wmvc_show_data('link_value',$this->data['settings']) == 'value') {
201 - $this->data['field_value'] = '<a href="'.$this->data['field_value'] .'">'.$this->data['field_value'] .'</a>';
202 - } else if(wmvc_show_data('link_value',$this->data['settings']) == 'label') {
203 - $this->data['field_value'] = '<a href="'.$this->data['field_value'] .'">'.wdk_field_label($this->data['settings']['field_id']) .'</a>';
204 - } else if(wmvc_show_data('link_value',$this->data['settings']) == 'icon' && wdk_field_option ($this->data['settings']['field_id'], 'icon_id')) {
205 - $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>';
206 212 } else {
207 - $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>';
208 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>';
209 221 }
210 - }
211 - elseif($this->data['settings']['field_id'] == 'category_id') {
212 - 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)) {
213 224 $this->WMVC->model('category_m');
214 - $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);
215 226 $this->data['field_value'] = wmvc_show_data('category_title', $tree_data);
216 227
217 - if(get_option('wdk_multi_categories_other_enable', FALSE))
218 - if(wdk_field_value ('categories_list', $wdk_listing_id)){
219 - $other_categories = wdk_generate_other_categories_fast(wdk_field_value ('categories_list', $wdk_listing_id));
220 - if(!empty($other_categories))
221 - $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);
222 233 }
234 +
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');
223 238 }
224 - }
225 - elseif($this->data['settings']['field_id'] == 'location_id') {
226 - 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)) {
227 241 $this->WMVC->model('location_m');
228 - $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);
229 243 $this->data['field_value'] = wmvc_show_data('location_title', $tree_data);
230 -
231 - if(get_option('wdk_multi_locations_other_enable', FALSE))
232 - if(wdk_field_value ('locations_list', $wdk_listing_id)){
233 - $other_locations = wdk_generate_other_locations_fast(wdk_field_value ('locations_list', $wdk_listing_id));
234 - if(!empty($other_locations))
235 - $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);
236 250 }
237 251
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');
238 255 }
239 - }
240 - elseif(wdk_field_option($this->data['settings']['field_id'], 'field_type') == "DATE") {
241 - $this->data['field_value'] = wdk_get_date(wdk_field_value ($this->data['settings']['field_id'], $wdk_listing_id));
242 - }
243 - elseif(strpos($this->data['settings']['field_id'],'date') !== FALSE) {
244 - $this->data['field_value'] = wdk_get_date(wdk_field_value ($this->data['settings']['field_id'], $wdk_listing_id));
245 - }
246 - 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 (
247 265 wdk_field_option($this->data['settings']['field_id'], 'field_type') == "TEXTAREA" ||
248 266 $this->data['settings']['field_id'] == 'post_content'
249 267 ) {
250 268 global $wp_embed;
251 - $this->data['field_value'] = wpautop(wdk_field_value ($this->data['settings']['field_id'], $wdk_listing_id));
252 - $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');
253 288 }
254 - else {
255 - $this->data['field_value'] = wdk_field_value ($this->data['settings']['field_id'], $wdk_listing_id);
256 - }
257 289 } else {
258 - if(wdk_field_option($this->data['settings']['field_id'],'field_type') == "CHECKBOX"){
259 - $this->data['field_value'] = '<span class="field_checkbox_success">'.$this->generate_icon($this->data['settings']['field_checkbox_icon_success']).'</span>';
260 - } elseif($this->data['settings']['field_id'] == 'post_title') {
261 - $this->data['field_value'] = esc_html__('Example', 'wpdirectorykit') .' '.esc_html__('Title', 'wpdirectorykit');
262 - } elseif($this->data['settings']['field_id'] == 'address') {
263 - $this->data['field_value'] = esc_html__('Example', 'wpdirectorykit') .' '.esc_html__('Address', 'wpdirectorykit');
264 - } elseif($this->data['settings']['field_id'] == 'post_content') {
265 - $this->data['field_value'] = esc_html__('Example', 'wpdirectorykit') .' '.esc_html__('Content', 'wpdirectorykit');
266 - } elseif($this->data['settings']['field_id'] == 'post_title') {
267 - $this->data['field_value'] = esc_html__('Example', 'wpdirectorykit') .' '.esc_html__('Title', 'wpdirectorykit');
268 - } elseif($this->data['settings']['field_id'] == 'counter_views') {
269 - $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']);
270 306 }
271 - else{
272 - $this->data['field_value'] = esc_html__('Example', 'wpdirectorykit') .' '. wdk_field_label($this->data['settings']['field_id']);
273 - }
274 - }
275 - $this->data['field_prefix'] = wdk_field_option ($this->data['settings']['field_id'], 'prefix');
276 - $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');
277 310 }
278 311
279 - $this->data['is_edit_mode']= false;
280 - if(Plugin::$instance->editor->is_edit_mode() || empty($wdk_listing_id)) {
281 - $this->data['is_edit_mode']= true;
282 - 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) {
283 316 $this->data['field_value'] .= ' <span class="dashicons dashicons-hidden" style="color:red"></span>';
284 317 }
285 318 } else {
286 - 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) {
287 320 return false;
288 321 }
289 322
290 - 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))) {
291 324 return false;
292 - }
325 + }
293 326
294 327 /* return false if no content */
295 - 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) == '')
296 329 return false;
297 -
298 - $this->data['field_prefix'] = apply_filters( 'wpdirectorykit/listing/field/prefix', $this->data['field_prefix'], $this->data['settings']['field_id']);
299 - $this->data['field_suffix'] = apply_filters( 'wpdirectorykit/listing/field/suffix',$this->data['field_suffix'], $this->data['settings']['field_id']);
300 -
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 +
301 334 /* price format implement */
302 - 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'])) {
303 336 /* if currency_conversion and field is price */
304 - $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));
305 338 $this->data['field_value'] = esc_html(wdk_number_format_i18n($value));
306 - } 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'])) {
307 340 /* if field enabled is_price_format and field type is number*/
308 - $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));
309 342 $this->data['field_value'] = esc_html(wdk_number_format_i18n($value));
310 343 } else {
311 344 /* without number format */
312 - $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']);
313 346 }
314 347 }
315 -
316 - echo $this->view('wdk-field-value', $this->data);
348 +
349 + $this->view('wdk-field-value', $this->data, true);
317 350 }
318 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 + }
319 364
320 - private function generate_controls_conf() {
365 +
366 + private function generate_controls_conf()
367 + {
321 368 $this->start_controls_section(
322 369 'tab_conf_main_section',
323 370 [
324 371 'label' => esc_html__('Main', 'wpdirectorykit'),
@@ -325,86 +372,100 @@
325 372 'tab' => '1',
326 373 ]
327 374 );
328 375
329 -
376 +
330 377 $this->add_control(
331 378 'html_tag',
332 379 [
333 - 'label' => __( 'HTML Tag', 'wpdirectorykit' ),
380 + 'label' => __('HTML Tag', 'wpdirectorykit'),
334 381 'type' => \Elementor\Controls_Manager::SELECT,
335 382 'default' => 'span',
336 383 'options' => array(
337 - ''=>__( 'Default', 'wpdirectorykit' ),
338 - 'h1'=>'H1',
339 - 'h2'=>'H2',
340 - 'h3'=>'H3',
341 - 'h4'=>'H4',
342 - 'h5'=>'H5',
343 - 'h6'=>'H6',
344 - 'span'=>'span',
345 - 'address'=>'address',
346 - 'strong'=>'strong',
347 - 'div'=>'div',
348 - 'p'=>'p',
349 - 'q'=>'q',
350 - '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',
351 398 ),
352 - 'separator' => 'after',
353 399 ]
354 400 );
355 401
356 - $WMVC = &wdk_get_instance();
357 - $WMVC->model('field_m');
358 - $fields_data = $WMVC->field_m->get();
402 + $fields_data = wdk_cached_field_get();
359 403 $fields_list = array('' => esc_html__('Not Selected', 'wpdirectorykit'));
360 - $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');
361 419
362 - $fields_list [(++$order_i).'__section'] = esc_html__('-- Section Custom fields --', 'wpdirectorykit');
363 - $fields_list [(++$order_i).'__idlisting'] = esc_html__('Id listing', 'wpdirectorykit');
364 - $fields_list [(++$order_i).'__post_id'] = esc_html__('Post Id', 'wpdirectorykit');
365 - $fields_list [(++$order_i).'__counter_views'] = esc_html__('Views counter', 'wpdirectorykit');
366 - $fields_list [(++$order_i).'__lat'] = esc_html__('Gps Lat', 'wpdirectorykit');
367 - $fields_list [(++$order_i).'__lng'] = esc_html__('Gps Lng', 'wpdirectorykit');
368 - $fields_list [(++$order_i).'__date'] = esc_html__('Date', 'wpdirectorykit');
369 - $fields_list [(++$order_i).'__date_modified'] = esc_html__('Date Modified', 'wpdirectorykit');
370 - $fields_list [(++$order_i).'__post_title'] = esc_html__('WP Title', 'wpdirectorykit');
371 - $fields_list [(++$order_i).'__post_content'] = esc_html__('WP Content', 'wpdirectorykit');
372 - $fields_list [(++$order_i).'__address'] = esc_html__('Address', 'wpdirectorykit');
373 - $fields_list [(++$order_i).'__category_id'] = esc_html__('Category', 'wpdirectorykit');
374 - $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) . ']';
375 425
376 - foreach($fields_data as $field)
377 - {
378 - if(wmvc_show_data('field_type', $field) == 'SECTION') {
379 - $fields_list [(++$order_i).'section__'.wmvc_show_data('idfield', $field)] = '-- '.esc_html__('Section', 'wpdirectorykit').' '.wmvc_show_data('field_label', $field).' --';
380 - } else {
381 - $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 + }
382 429 }
430 +
431 + if (wmvc_show_data('field_type', $field) == 'NUMBER') {
432 + $fields_number_types[] = wmvc_show_data('idfield', $field);
433 + }
383 434 }
384 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 +
385 445 $this->add_control(
386 446 'field_id',
387 447 [
388 - 'label' => __( 'Field id', 'wpdirectorykit' ),
389 - 'type' => \Elementor\Controls_Manager::SELECT,
448 + 'label' => __('Field id', 'wpdirectorykit'),
449 + 'type' => \Wdk\Includes\Controls\Wdk_Field_Selector::INIT,
390 450 'default' => '',
391 451 'options' => $fields_list,
452 + 'raw_options' => $raw,
392 453 'separator' => 'after',
393 454 ]
394 455 );
395 -
456 +
396 457 $this->add_control(
397 - 'hide_onempty',
398 - [
399 - 'label' => __( 'Hide if empty', 'wpdirectorykit' ),
400 - 'type' => \Elementor\Controls_Manager::SWITCHER,
401 - 'label_on' => __( 'True', 'wpdirectorykit' ),
402 - 'label_off' => __( 'False', 'wpdirectorykit' ),
403 - 'return_value' => 'yes',
404 - 'default' => '',
405 - ]
406 - );
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 + );
407 468
408 469 $this->add_control(
409 470 'link_value',
410 471 [
@@ -418,69 +479,114 @@
418 479 ],
419 480 ]
420 481 );
421 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 +
422 515 $this->end_controls_section();
423 -
424 516 }
425 517
426 - private function generate_controls_layout() {
427 - }
518 + private function generate_controls_layout() {}
428 519
429 520
430 - private function generate_controls_styles() {
521 + private function generate_controls_styles()
522 + {
431 523 $items = [
432 524 [
433 - 'key'=>'field_value',
434 - 'label'=> esc_html__('Field Value', 'wpdirectorykit'),
435 - 'selector'=>'{{WRAPPER}} .wdk-field-value .value, {{WRAPPER}} .wdk-field-value .value p',
436 - 'selector_hover'=>'{{WRAPPER}} .wdk-field-value .value%1$s, {{WRAPPER}} .wdk-field-value .value%1$s p',
437 - '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',
438 530 ],
439 531 [
440 - 'key'=>'field_prefix',
441 - 'label'=> esc_html__('Field Prefix', 'wpdirectorykit'),
442 - 'selector'=>'{{WRAPPER}} .wdk-field-value .prefix',
443 - 'selector_hover'=>'{{WRAPPER}} .wdk-field-value .prefix%1$s',
444 - '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',
445 537 ],
446 538 [
447 - 'key'=>'field_suffix',
448 - 'label'=> esc_html__('Field Suffix', 'wpdirectorykit'),
449 - 'selector'=>'{{WRAPPER}} .wdk-field-value .suffix',
450 - 'selector_hover'=>'{{WRAPPER}} .wdk-field-value .suffix%1$s',
451 - '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',
452 544 ]
453 545 ];
454 546
455 547 foreach ($items as $item) {
456 548 $this->start_controls_section(
457 - $item['key'].'_section',
549 + $item['key'] . '_section',
458 550 [
459 551 'label' => $item['label'],
460 - '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 + ],
461 567 ]
462 568 );
463 569
464 - if( $item ['key'] == 'field_value'){
570 + if ($item['key'] == 'field_value') {
465 571 $selectors = array(
466 572 'normal' => '{{WRAPPER}} .wdk-field-value',
467 573 );
468 - $this->generate_renders_tabs($selectors, $item['key'].'_dynamic_align', ['align']);
574 + $this->generate_renders_tabs($selectors, $item['key'] . '_dynamic_align', ['align']);
469 575 }
470 576
471 577 $selectors = array();
472 - if(!empty($item['selector']))
578 + if (!empty($item['selector']))
473 579 $selectors['normal'] = $item['selector'];
474 580
475 - if(!empty($item['selector_hover']))
581 + if (!empty($item['selector_hover']))
476 582 $selectors['hover'] = $item['selector_hover'];
477 583
478 - if(!empty($item['selector_focus']))
584 + if (!empty($item['selector_focus']))
479 585 $selectors['focus'] = $item['selector_hover'];
480 -
481 - $this->generate_renders_tabs($selectors, $item['key'].'_dynamic', $item['options'], ['align']);
482 586
587 + $this->generate_renders_tabs($selectors, $item['key'] . '_dynamic', $item['options'], ['align']);
588 +
483 589 $this->end_controls_section();
484 590 /* END special for some elements */
485 591 }
486 592
@@ -489,11 +595,25 @@
489 595 'field_checkbox_icon',
490 596 [
491 597 'label' => esc_html__('Checkbox', 'wpdirectorykit'),
492 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 + ],
493 613 ]
494 614 );
495 -
615 +
496 616 $this->add_responsive_control(
497 617 'field_checkbox_icon_success_header',
498 618 [
499 619 'label' => esc_html__('Success checkbox', 'wpdirectorykit'),
@@ -500,9 +620,9 @@
500 620 'type' => Controls_Manager::HEADING,
501 621 'separator' => 'before',
502 622 ]
503 623 );
504 -
624 +
505 625 $this->add_control(
506 626 'field_checkbox_icon_success',
507 627 [
508 628 'label' => esc_html__('Icon', 'wpdirectorykit'),
@@ -511,17 +631,17 @@
511 631 'default' => [
512 632 'value' => 'fa fa-check',
513 633 'library' => 'solid',
514 634 ],
515 - ]
635 + ]
516 636 );
517 -
637 +
518 638 $selectors = array(
519 639 'normal' => '{{WRAPPER}} .field_checkbox_success',
520 640 );
521 641 $this->generate_renders_tabs($selectors, 'field_checkbox_icon_success_dynamic', 'full');
522 -
523 -
642 +
643 +
524 644 $this->add_responsive_control(
525 645 'field_checkbox_icon_unsuccess_header',
526 646 [
527 647 'label' => esc_html__('Unsuccess checkbox', 'wpdirectorykit'),
@@ -528,9 +648,9 @@
528 648 'type' => Controls_Manager::HEADING,
529 649 'separator' => 'before',
530 650 ]
531 651 );
532 -
652 +
533 653 $this->add_control(
534 654 'field_checkbox_icon_unsuccess',
535 655 [
536 656 'label' => esc_html__('Icon', 'wpdirectorykit'),
@@ -539,23 +659,571 @@
539 659 'default' => [
540 660 'value' => 'fa fa-close',
541 661 'library' => 'solid',
542 662 ],
543 - ]
663 + ]
544 664 );
545 -
665 +
546 666 $selectors = array(
547 667 'normal' => '{{WRAPPER}} .field_checkbox_unsuccess',
548 668 );
549 669 $this->generate_renders_tabs($selectors, 'field_checkbox_icon_unsuccess_dynamic', 'full');
550 -
670 +
551 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();
552 838 }
553 839
554 - private function generate_controls_content() {
555 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 + }
556 1224 }
557 -
558 - public function enqueue_styles_scripts() {
559 -
560 - }
1225 +
1226 + private function generate_controls_content() {}
1227 +
1228 + public function enqueue_styles_scripts() {}
561 1229 }