| 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 |
public $field_id = NULL; |
| 28 |
public $fields_list = array(); |
| 29 |
|
| 30 |
public function __construct($data = array(), $args = null) { |
| 31 |
|
| 32 |
\Elementor\Controls_Manager::add_tab( |
| 33 |
'tab_conf', |
| 34 |
esc_html__('Settings', 'wpdirectorykit') |
| 35 |
); |
| 36 |
|
| 37 |
\Elementor\Controls_Manager::add_tab( |
| 38 |
'tab_layout', |
| 39 |
esc_html__('Layout', 'wpdirectorykit') |
| 40 |
); |
| 41 |
|
| 42 |
\Elementor\Controls_Manager::add_tab( |
| 43 |
'tab_content', |
| 44 |
esc_html__('Main', 'wpdirectorykit') |
| 45 |
); |
| 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()) { |
| 53 |
$this->enqueue_styles_scripts(); |
| 54 |
} |
| 55 |
|
| 56 |
parent::__construct($data, $args); |
| 57 |
|
| 58 |
} |
| 59 |
|
| 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 |
/** |
| 79 |
* Retrieve the widget name. |
| 80 |
* |
| 81 |
* @since 1.1.0 |
| 82 |
* |
| 83 |
* @access public |
| 84 |
* |
| 85 |
* @return string Widget name. |
| 86 |
*/ |
| 87 |
public function get_name() { |
| 88 |
return 'wdk-field-value'; |
| 89 |
} |
| 90 |
|
| 91 |
/** |
| 92 |
* Retrieve the widget title. |
| 93 |
* |
| 94 |
* @since 1.1.0 |
| 95 |
* |
| 96 |
* @access public |
| 97 |
* |
| 98 |
* @return string Widget title. |
| 99 |
*/ |
| 100 |
public function get_title() { |
| 101 |
return esc_html__('Wdk Field Value', 'wpdirectorykit'); |
| 102 |
} |
| 103 |
|
| 104 |
/** |
| 105 |
* Retrieve the widget icon. |
| 106 |
* |
| 107 |
* @since 1.1.0 |
| 108 |
* |
| 109 |
* @access public |
| 110 |
* |
| 111 |
* @return string Widget icon. |
| 112 |
*/ |
| 113 |
public function get_icon() { |
| 114 |
return 'eicon-product-meta'; |
| 115 |
} |
| 116 |
|
| 117 |
/** |
| 118 |
* Register the widget controls. |
| 119 |
* |
| 120 |
* Adds different input fields to allow the user to change and customize the widget settings. |
| 121 |
* |
| 122 |
* @since 1.1.0 |
| 123 |
* |
| 124 |
* @access protected |
| 125 |
*/ |
| 126 |
protected function register_controls() { |
| 127 |
$this->generate_controls_conf(); |
| 128 |
$this->generate_controls_layout(); |
| 129 |
$this->generate_controls_styles(); |
| 130 |
$this->generate_controls_content(); |
| 131 |
|
| 132 |
$this->insert_pro_message('1'); |
| 133 |
parent::register_controls(); |
| 134 |
} |
| 135 |
|
| 136 |
/** |
| 137 |
* Render the widget output on the frontend. |
| 138 |
* |
| 139 |
* Written in PHP and used to generate the final HTML. |
| 140 |
* |
| 141 |
* @since 1.1.0 |
| 142 |
* |
| 143 |
* @access protected |
| 144 |
*/ |
| 145 |
protected function render() { |
| 146 |
parent::render(); |
| 147 |
global $wdk_listing_id; |
| 148 |
|
| 149 |
$this->data['id_element'] = $this->get_id(); |
| 150 |
$this->data['settings'] = $this->get_settings(); |
| 151 |
|
| 152 |
$this->data['field_value'] = 'Example Value'; |
| 153 |
$this->data['field_prefix'] = 'prefix'; |
| 154 |
$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); |
| 158 |
} |
| 159 |
|
| 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>'; |
| 164 |
} 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), 'wpdirectorykit'); |
| 169 |
|
| 170 |
if(strpos($this->data['field_value'], 'vimeo.com') !== FALSE) |
| 171 |
{ |
| 172 |
$this->data['field_value'] = wp_oembed_get($this->data['field_value'], array("width"=>"800", "height"=>"450")); |
| 173 |
} |
| 174 |
elseif(strpos($this->data['field_value'], 'watch?v=') !== FALSE) |
| 175 |
{ |
| 176 |
$embed_code = substr($this->data['field_value'], strpos($this->data['field_value'], 'watch?v=')+8); |
| 177 |
$this->data['field_value'] = wp_oembed_get('https://www.youtube.com/watch?v='.$embed_code, array("width"=>"800", "height"=>"455")); |
| 178 |
} |
| 179 |
elseif(strpos($this->data['field_value'], 'youtube.com/shorts/') !== FALSE) |
| 180 |
{ |
| 181 |
$embed_code = substr($this->data['field_value'], strpos($this->data['field_value'], 'shorts')+7); |
| 182 |
$this->data['field_value'] = wp_oembed_get('https://www.youtube.com/watch?v='.$embed_code,array("width"=>"800", "height"=>"455")); |
| 183 |
} |
| 184 |
elseif(strpos($this->data['field_value'], 'youtu.be/') !== FALSE) |
| 185 |
{ |
| 186 |
$embed_code = substr($this->data['field_value'], strpos($this->data['field_value'], 'youtu.be/')+9); |
| 187 |
$this->data['field_value'] = wp_oembed_get('https://www.youtube.com/watch?v='.$embed_code, array("width"=>"800", "height"=>"455")); |
| 188 |
} |
| 189 |
elseif(filter_var($this->data['field_value'], FILTER_VALIDATE_URL) !== FALSE && preg_match('/\.(mp4|flv|wmw|ogv|webm|ogg)$/i', $this->data['field_value'])) |
| 190 |
{ |
| 191 |
$this->data['field_value'] = '<video src="'.$this->data['field_value'].'" controls></video> '; |
| 192 |
} |
| 193 |
elseif(filter_var($this->data['field_value'] , FILTER_VALIDATE_EMAIL) !== FALSE) { |
| 194 |
if(wmvc_show_data('link_value',$this->data['settings']) == 'value') { |
| 195 |
$this->data['field_value'] = '<a href="mailto:'.$this->data['field_value'] .'">'.$this->data['field_value'] .'</a>'; |
| 196 |
} else if(wmvc_show_data('link_value',$this->data['settings']) == 'label') { |
| 197 |
$this->data['field_value'] = '<a href="mailto:'.$this->data['field_value'] .'">'.wdk_field_label($this->data['settings']['field_id']) .'</a>'; |
| 198 |
} else if(wmvc_show_data('link_value',$this->data['settings']) == 'icon' && wdk_field_option ($this->data['settings']['field_id'], 'icon_id')) { |
| 199 |
$this->data['field_value'] = '<a href="mailto:'.$this->data['field_value'] .'"><img src="'.esc_url(wdk_image_src(array('icon_id' =>wdk_field_option ($this->data['settings']['field_id'], 'icon_id')), 'full', NULL, 'icon_id')).'"></a>'; |
| 200 |
} else { |
| 201 |
$this->data['field_value'] = '<a href="mailto:'.$this->data['field_value'] .'">'.wdk_field_label($this->data['settings']['field_id']) .'</a>'; |
| 202 |
} |
| 203 |
} |
| 204 |
elseif(filter_var($this->data['field_value'] , FILTER_VALIDATE_URL) !== FALSE) { |
| 205 |
if(wmvc_show_data('link_value',$this->data['settings']) == 'value') { |
| 206 |
$this->data['field_value'] = '<a href="'.$this->data['field_value'] .'">'.$this->data['field_value'] .'</a>'; |
| 207 |
} else if(wmvc_show_data('link_value',$this->data['settings']) == 'label') { |
| 208 |
$this->data['field_value'] = '<a href="'.$this->data['field_value'] .'">'.wdk_field_label($this->data['settings']['field_id']) .'</a>'; |
| 209 |
} else if(wmvc_show_data('link_value',$this->data['settings']) == 'icon' && wdk_field_option ($this->data['settings']['field_id'], 'icon_id')) { |
| 210 |
$this->data['field_value'] = '<a href="'.$this->data['field_value'] .'"><img src="'.esc_url(wdk_image_src(array('icon_id' =>wdk_field_option ($this->data['settings']['field_id'], 'icon_id')), 'full', NULL, 'icon_id')).'"></a>'; |
| 211 |
} else { |
| 212 |
$this->data['field_value'] = '<a href="'.$this->data['field_value'] .'">'.wdk_field_label($this->data['settings']['field_id']) .'</a>'; |
| 213 |
} |
| 214 |
} |
| 215 |
} |
| 216 |
elseif($this->data['settings']['field_id'] == 'category_id') { |
| 217 |
if(wdk_field_value ($this->data['settings']['field_id'], $wdk_listing_id)){ |
| 218 |
$this->WMVC->model('category_m'); |
| 219 |
$tree_data = $this->WMVC->category_m->get(wdk_field_value ($this->data['settings']['field_id'], $wdk_listing_id), TRUE); |
| 220 |
$this->data['field_value'] = wmvc_show_data('category_title', $tree_data); |
| 221 |
|
| 222 |
if(get_option('wdk_multi_categories_other_enable', FALSE)) |
| 223 |
if(wdk_field_value ('categories_list', $wdk_listing_id)){ |
| 224 |
$other_categories = wdk_generate_other_categories_fast(wdk_field_value ('categories_list', $wdk_listing_id)); |
| 225 |
if(!empty($other_categories)) |
| 226 |
$this->data['field_value'] .=', '.join(', ',$other_categories); |
| 227 |
} |
| 228 |
|
| 229 |
$this->data['field_value'] =__($this->data['field_value'], 'wpdirectorykit'); |
| 230 |
} |
| 231 |
} |
| 232 |
elseif($this->data['settings']['field_id'] == 'location_id') { |
| 233 |
if(wdk_field_value ($this->data['settings']['field_id'], $wdk_listing_id)){ |
| 234 |
$this->WMVC->model('location_m'); |
| 235 |
$tree_data = $this->WMVC->location_m->get(wdk_field_value ($this->data['settings']['field_id'], $wdk_listing_id), TRUE); |
| 236 |
$this->data['field_value'] = wmvc_show_data('location_title', $tree_data); |
| 237 |
|
| 238 |
if(get_option('wdk_multi_locations_other_enable', FALSE)) |
| 239 |
if(wdk_field_value ('locations_list', $wdk_listing_id)){ |
| 240 |
$other_locations = wdk_generate_other_locations_fast(wdk_field_value ('locations_list', $wdk_listing_id)); |
| 241 |
if(!empty($other_locations)) |
| 242 |
$this->data['field_value'] .=', '.join(', ',$other_locations); |
| 243 |
} |
| 244 |
|
| 245 |
$this->data['field_value'] =__($this->data['field_value'], 'wpdirectorykit'); |
| 246 |
} |
| 247 |
|
| 248 |
} |
| 249 |
elseif(wdk_field_option($this->data['settings']['field_id'], 'field_type') == "DATE") { |
| 250 |
$this->data['field_value'] = __(wdk_get_date(wdk_field_value ($this->data['settings']['field_id'], $wdk_listing_id)), 'wpdirectorykit') ; |
| 251 |
} |
| 252 |
elseif(strpos($this->data['settings']['field_id'],'date') !== FALSE) { |
| 253 |
$this->data['field_value'] =__(wdk_get_date(wdk_field_value ($this->data['settings']['field_id'], $wdk_listing_id)), 'wpdirectorykit') ; |
| 254 |
} |
| 255 |
elseif( |
| 256 |
wdk_field_option($this->data['settings']['field_id'], 'field_type') == "TEXTAREA" || |
| 257 |
$this->data['settings']['field_id'] == 'post_content' |
| 258 |
) { |
| 259 |
global $wp_embed; |
| 260 |
$this->data['field_value'] = wpautop(__(wdk_field_value ($this->data['settings']['field_id'], $wdk_listing_id), 'wpdirectorykit' )); |
| 261 |
$this->data['field_value'] = html_entity_decode($wp_embed->autoembed($this->data['field_value'] )); |
| 262 |
} |
| 263 |
else { |
| 264 |
$this->data['field_value'] =__( wdk_field_value ($this->data['settings']['field_id'], $wdk_listing_id), 'wpdirectorykit'); |
| 265 |
} |
| 266 |
} else { |
| 267 |
if(wdk_field_option($this->data['settings']['field_id'],'field_type') == "CHECKBOX"){ |
| 268 |
$this->data['field_value'] = '<span class="field_checkbox_success">'.$this->generate_icon($this->data['settings']['field_checkbox_icon_success']).'</span>'; |
| 269 |
} elseif($this->data['settings']['field_id'] == 'post_title') { |
| 270 |
$this->data['field_value'] = esc_html__('Example', 'wpdirectorykit') .' '.esc_html__('Title', 'wpdirectorykit'); |
| 271 |
} elseif($this->data['settings']['field_id'] == 'address') { |
| 272 |
$this->data['field_value'] = esc_html__('Example', 'wpdirectorykit') .' '.esc_html__('Address', 'wpdirectorykit'); |
| 273 |
} elseif($this->data['settings']['field_id'] == 'post_content') { |
| 274 |
$this->data['field_value'] = esc_html__('Example', 'wpdirectorykit') .' '.esc_html__('Content', 'wpdirectorykit'); |
| 275 |
} elseif($this->data['settings']['field_id'] == 'post_title') { |
| 276 |
$this->data['field_value'] = esc_html__('Example', 'wpdirectorykit') .' '.esc_html__('Title', 'wpdirectorykit'); |
| 277 |
} elseif($this->data['settings']['field_id'] == 'counter_views') { |
| 278 |
$this->data['field_label'] = esc_html__('Example', 'wpdirectorykit') .' '.esc_html__('Views counter', 'wpdirectorykit'); |
| 279 |
} |
| 280 |
else{ |
| 281 |
$this->data['field_value'] = esc_html__('Example', 'wpdirectorykit') .' '. wdk_field_label($this->data['settings']['field_id']); |
| 282 |
} |
| 283 |
} |
| 284 |
$this->data['field_prefix'] = wdk_field_option ($this->data['settings']['field_id'], 'prefix'); |
| 285 |
$this->data['field_suffix'] = wdk_field_option ($this->data['settings']['field_id'], 'suffix'); |
| 286 |
} |
| 287 |
|
| 288 |
$this->data['is_edit_mode']= false; |
| 289 |
if(Plugin::$instance->editor->is_edit_mode() || empty($wdk_listing_id)) { |
| 290 |
$this->data['is_edit_mode']= true; |
| 291 |
if(is_intval($this->data['settings']['field_id']) && wdk_field_option($this->data['settings']['field_id'], 'is_visible_frontend') != 1) { |
| 292 |
$this->data['field_value'] .= ' <span class="dashicons dashicons-hidden" style="color:red"></span>'; |
| 293 |
} |
| 294 |
} else { |
| 295 |
if(is_intval($this->data['settings']['field_id']) && wdk_field_option($this->data['settings']['field_id'], 'is_visible_frontend') != 1) { |
| 296 |
return false; |
| 297 |
} |
| 298 |
|
| 299 |
if(wdk_field_value('category_id', $wdk_listing_id) && wdk_depend_is_hidden_field($this->data['settings']['field_id'], wdk_field_value('category_id', $wdk_listing_id))) { |
| 300 |
return false; |
| 301 |
} |
| 302 |
|
| 303 |
/* return false if no content */ |
| 304 |
if($this->data['settings']['hide_onempty'] == 'yes' && wdk_field_value($this->data['settings']['field_id'], $wdk_listing_id) == '') |
| 305 |
return false; |
| 306 |
|
| 307 |
$this->data['field_prefix'] = apply_filters( 'wpdirectorykit/listing/field/prefix', $this->data['field_prefix'], $this->data['settings']['field_id']); |
| 308 |
$this->data['field_suffix'] = apply_filters( 'wpdirectorykit/listing/field/suffix',$this->data['field_suffix'], $this->data['settings']['field_id']); |
| 309 |
|
| 310 |
/* price format implement */ |
| 311 |
if(function_exists('run_wdk_currency_conversion') && wdk_currencies_is_price_field($this->data['settings']['field_id'])) { |
| 312 |
/* if currency_conversion and field is price */ |
| 313 |
$value = strip_tags(apply_filters( 'wpdirectorykit/listing/field/value', wdk_filter_decimal($this->data['field_value']), $this->data['settings']['field_id'], FALSE)); |
| 314 |
$this->data['field_value'] = esc_html(wdk_number_format_i18n($value)); |
| 315 |
} elseif(wdk_field_option($this->data['settings']['field_id'], 'is_price_format') && wdk_field_option($this->data['settings']['field_id'], 'field_type') == 'NUMBER' && !empty($this->data['field_value'])) { |
| 316 |
/* if field enabled is_price_format and field type is number*/ |
| 317 |
$value = strip_tags(apply_filters( 'wpdirectorykit/listing/field/value', wdk_filter_decimal($this->data['field_value']), $this->data['settings']['field_id'], FALSE)); |
| 318 |
$this->data['field_value'] = esc_html(wdk_number_format_i18n($value)); |
| 319 |
} else { |
| 320 |
/* without number format */ |
| 321 |
$this->data['field_value'] = apply_filters( 'wpdirectorykit/listing/field/value', $this->data['field_value'], $this->data['settings']['field_id']); |
| 322 |
} |
| 323 |
} |
| 324 |
|
| 325 |
echo $this->view('wdk-field-value', $this->data); |
| 326 |
} |
| 327 |
|
| 328 |
|
| 329 |
private function generate_controls_conf() { |
| 330 |
$this->start_controls_section( |
| 331 |
'tab_conf_main_section', |
| 332 |
[ |
| 333 |
'label' => esc_html__('Main', 'wpdirectorykit'), |
| 334 |
'tab' => '1', |
| 335 |
] |
| 336 |
); |
| 337 |
|
| 338 |
|
| 339 |
$this->add_control( |
| 340 |
'html_tag', |
| 341 |
[ |
| 342 |
'label' => __( 'HTML Tag', 'wpdirectorykit' ), |
| 343 |
'type' => \Elementor\Controls_Manager::SELECT, |
| 344 |
'default' => 'span', |
| 345 |
'options' => array( |
| 346 |
''=>__( 'Default', 'wpdirectorykit' ), |
| 347 |
'h1'=>'H1', |
| 348 |
'h2'=>'H2', |
| 349 |
'h3'=>'H3', |
| 350 |
'h4'=>'H4', |
| 351 |
'h5'=>'H5', |
| 352 |
'h6'=>'H6', |
| 353 |
'span'=>'span', |
| 354 |
'address'=>'address', |
| 355 |
'strong'=>'strong', |
| 356 |
'div'=>'div', |
| 357 |
'p'=>'p', |
| 358 |
'q'=>'q', |
| 359 |
'time'=>'time', |
| 360 |
), |
| 361 |
'separator' => 'after', |
| 362 |
] |
| 363 |
); |
| 364 |
|
| 365 |
$fields_data = wdk_cached_field_get(); |
| 366 |
$fields_list = array('' => esc_html__('Not Selected', 'wpdirectorykit')); |
| 367 |
$order_i = 0; |
| 368 |
|
| 369 |
$fields_list [(++$order_i).'__section'] = esc_html__('-- Section Custom fields --', 'wpdirectorykit'); |
| 370 |
$fields_list [(++$order_i).'__idlisting'] = esc_html__('Id listing', 'wpdirectorykit'); |
| 371 |
$fields_list [(++$order_i).'__post_id'] = esc_html__('Post Id', 'wpdirectorykit'); |
| 372 |
$fields_list [(++$order_i).'__counter_views'] = esc_html__('Views counter', 'wpdirectorykit'); |
| 373 |
$fields_list [(++$order_i).'__lat'] = esc_html__('Gps Lat', 'wpdirectorykit'); |
| 374 |
$fields_list [(++$order_i).'__lng'] = esc_html__('Gps Lng', 'wpdirectorykit'); |
| 375 |
$fields_list [(++$order_i).'__date'] = esc_html__('Date', 'wpdirectorykit'); |
| 376 |
$fields_list [(++$order_i).'__date_modified'] = esc_html__('Date Modified', 'wpdirectorykit'); |
| 377 |
$fields_list [(++$order_i).'__post_title'] = esc_html__('WP Title', 'wpdirectorykit'); |
| 378 |
$fields_list [(++$order_i).'__post_content'] = esc_html__('WP Content', 'wpdirectorykit'); |
| 379 |
$fields_list [(++$order_i).'__address'] = esc_html__('Address', 'wpdirectorykit'); |
| 380 |
$fields_list [(++$order_i).'__category_id'] = esc_html__('Category', 'wpdirectorykit'); |
| 381 |
$fields_list [(++$order_i).'__location_id'] = esc_html__('Location', 'wpdirectorykit'); |
| 382 |
|
| 383 |
foreach($fields_data as $field) |
| 384 |
{ |
| 385 |
if(wmvc_show_data('field_type', $field) == 'SECTION') { |
| 386 |
$fields_list [(++$order_i).'section__'.wmvc_show_data('idfield', $field)] = '-- '.esc_html__('Section', 'wpdirectorykit').' '.wmvc_show_data('field_label', $field).' --'; |
| 387 |
} else { |
| 388 |
$fields_list[(++$order_i).'__'.wmvc_show_data('idfield', $field)] = '#'.wmvc_show_data('idfield', $field).' '.wmvc_show_data('field_label', $field).'['.wmvc_show_data('field_type', $field).']'; |
| 389 |
} |
| 390 |
} |
| 391 |
|
| 392 |
$this->add_control( |
| 393 |
'field_id', |
| 394 |
[ |
| 395 |
'label' => __( 'Field id', 'wpdirectorykit' ), |
| 396 |
'type' => \Elementor\Controls_Manager::SELECT2, |
| 397 |
'default' => '', |
| 398 |
'options' => $fields_list, |
| 399 |
'separator' => 'after', |
| 400 |
] |
| 401 |
); |
| 402 |
|
| 403 |
$this->add_control( |
| 404 |
'hide_onempty', |
| 405 |
[ |
| 406 |
'label' => __( 'Hide if empty', 'wpdirectorykit' ), |
| 407 |
'type' => \Elementor\Controls_Manager::SWITCHER, |
| 408 |
'label_on' => __( 'True', 'wpdirectorykit' ), |
| 409 |
'label_off' => __( 'False', 'wpdirectorykit' ), |
| 410 |
'return_value' => 'yes', |
| 411 |
'default' => '', |
| 412 |
] |
| 413 |
); |
| 414 |
|
| 415 |
$this->add_control( |
| 416 |
'link_value', |
| 417 |
[ |
| 418 |
'label' => esc_html__('in case of link detected', 'wpdirectorykit'), |
| 419 |
'type' => Controls_Manager::SELECT, |
| 420 |
'options' => [ |
| 421 |
'' => esc_html__('Default', 'wpdirectorykit'), |
| 422 |
'value' => esc_html__('show value', 'wpdirectorykit'), |
| 423 |
'label' => esc_html__('show field label', 'wpdirectorykit'), |
| 424 |
'icon' => esc_html__('show field icon', 'wpdirectorykit'), |
| 425 |
], |
| 426 |
] |
| 427 |
); |
| 428 |
|
| 429 |
$this->end_controls_section(); |
| 430 |
|
| 431 |
} |
| 432 |
|
| 433 |
private function generate_controls_layout() { |
| 434 |
} |
| 435 |
|
| 436 |
|
| 437 |
private function generate_controls_styles() { |
| 438 |
$items = [ |
| 439 |
[ |
| 440 |
'key'=>'field_value', |
| 441 |
'label'=> esc_html__('Field Value', 'wpdirectorykit'), |
| 442 |
'selector'=>'{{WRAPPER}} .wdk-field-value .value, {{WRAPPER}} .wdk-field-value .value p', |
| 443 |
'selector_hover'=>'{{WRAPPER}} .wdk-field-value .value%1$s, {{WRAPPER}} .wdk-field-value .value%1$s p', |
| 444 |
'options'=>'full', |
| 445 |
], |
| 446 |
[ |
| 447 |
'key'=>'field_prefix', |
| 448 |
'label'=> esc_html__('Field Prefix', 'wpdirectorykit'), |
| 449 |
'selector'=>'{{WRAPPER}} .wdk-field-value .prefix', |
| 450 |
'selector_hover'=>'{{WRAPPER}} .wdk-field-value .prefix%1$s', |
| 451 |
'options'=>'full', |
| 452 |
], |
| 453 |
[ |
| 454 |
'key'=>'field_suffix', |
| 455 |
'label'=> esc_html__('Field Suffix', 'wpdirectorykit'), |
| 456 |
'selector'=>'{{WRAPPER}} .wdk-field-value .suffix', |
| 457 |
'selector_hover'=>'{{WRAPPER}} .wdk-field-value .suffix%1$s', |
| 458 |
'options'=>'full', |
| 459 |
] |
| 460 |
]; |
| 461 |
|
| 462 |
foreach ($items as $item) { |
| 463 |
$this->start_controls_section( |
| 464 |
$item['key'].'_section', |
| 465 |
[ |
| 466 |
'label' => $item['label'], |
| 467 |
'tab' => 'tab_layout' |
| 468 |
] |
| 469 |
); |
| 470 |
|
| 471 |
if( $item ['key'] == 'field_value'){ |
| 472 |
$selectors = array( |
| 473 |
'normal' => '{{WRAPPER}} .wdk-field-value', |
| 474 |
); |
| 475 |
$this->generate_renders_tabs($selectors, $item['key'].'_dynamic_align', ['align']); |
| 476 |
} |
| 477 |
|
| 478 |
$selectors = array(); |
| 479 |
if(!empty($item['selector'])) |
| 480 |
$selectors['normal'] = $item['selector']; |
| 481 |
|
| 482 |
if(!empty($item['selector_hover'])) |
| 483 |
$selectors['hover'] = $item['selector_hover']; |
| 484 |
|
| 485 |
if(!empty($item['selector_focus'])) |
| 486 |
$selectors['focus'] = $item['selector_hover']; |
| 487 |
|
| 488 |
$this->generate_renders_tabs($selectors, $item['key'].'_dynamic', $item['options'], ['align']); |
| 489 |
|
| 490 |
$this->end_controls_section(); |
| 491 |
/* END special for some elements */ |
| 492 |
} |
| 493 |
|
| 494 |
|
| 495 |
$this->start_controls_section( |
| 496 |
'field_checkbox_icon', |
| 497 |
[ |
| 498 |
'label' => esc_html__('Checkbox', 'wpdirectorykit'), |
| 499 |
'tab' => Controls_Manager::TAB_STYLE, |
| 500 |
] |
| 501 |
); |
| 502 |
|
| 503 |
$this->add_responsive_control( |
| 504 |
'field_checkbox_icon_success_header', |
| 505 |
[ |
| 506 |
'label' => esc_html__('Success checkbox', 'wpdirectorykit'), |
| 507 |
'type' => Controls_Manager::HEADING, |
| 508 |
'separator' => 'before', |
| 509 |
] |
| 510 |
); |
| 511 |
|
| 512 |
$this->add_control( |
| 513 |
'field_checkbox_icon_success', |
| 514 |
[ |
| 515 |
'label' => esc_html__('Icon', 'wpdirectorykit'), |
| 516 |
'type' => Controls_Manager::ICONS, |
| 517 |
'label_block' => true, |
| 518 |
'default' => [ |
| 519 |
'value' => 'fa fa-check', |
| 520 |
'library' => 'solid', |
| 521 |
], |
| 522 |
] |
| 523 |
); |
| 524 |
|
| 525 |
$selectors = array( |
| 526 |
'normal' => '{{WRAPPER}} .field_checkbox_success', |
| 527 |
); |
| 528 |
$this->generate_renders_tabs($selectors, 'field_checkbox_icon_success_dynamic', 'full'); |
| 529 |
|
| 530 |
|
| 531 |
$this->add_responsive_control( |
| 532 |
'field_checkbox_icon_unsuccess_header', |
| 533 |
[ |
| 534 |
'label' => esc_html__('Unsuccess checkbox', 'wpdirectorykit'), |
| 535 |
'type' => Controls_Manager::HEADING, |
| 536 |
'separator' => 'before', |
| 537 |
] |
| 538 |
); |
| 539 |
|
| 540 |
$this->add_control( |
| 541 |
'field_checkbox_icon_unsuccess', |
| 542 |
[ |
| 543 |
'label' => esc_html__('Icon', 'wpdirectorykit'), |
| 544 |
'type' => Controls_Manager::ICONS, |
| 545 |
'label_block' => true, |
| 546 |
'default' => [ |
| 547 |
'value' => 'fa fa-close', |
| 548 |
'library' => 'solid', |
| 549 |
], |
| 550 |
] |
| 551 |
); |
| 552 |
|
| 553 |
$selectors = array( |
| 554 |
'normal' => '{{WRAPPER}} .field_checkbox_unsuccess', |
| 555 |
); |
| 556 |
$this->generate_renders_tabs($selectors, 'field_checkbox_icon_unsuccess_dynamic', 'full'); |
| 557 |
|
| 558 |
$this->end_controls_section(); |
| 559 |
} |
| 560 |
|
| 561 |
private function generate_controls_content() { |
| 562 |
|
| 563 |
} |
| 564 |
|
| 565 |
public function enqueue_styles_scripts() { |
| 566 |
|
| 567 |
} |
| 568 |
} |
| 569 |
|