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