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