| 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 WdkListingFieldsSection 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 |
if ($this->is_edit_mode_load()) { |
| 48 |
$this->enqueue_styles_scripts(); |
| 49 |
} |
| 50 |
|
| 51 |
parent::__construct($data, $args); |
| 52 |
|
| 53 |
} |
| 54 |
|
| 55 |
/** |
| 56 |
* Retrieve the list of categories the widget belongs to. |
| 57 |
* |
| 58 |
* Used to determine where to display the widget in the editor. |
| 59 |
* |
| 60 |
* Note that currently Elementor supports only one category. |
| 61 |
* When multiple categories passed, Elementor uses the first one. |
| 62 |
* |
| 63 |
* @since 1.1.0 |
| 64 |
* |
| 65 |
* @access public |
| 66 |
* |
| 67 |
* @return array Widget categories. |
| 68 |
*/ |
| 69 |
public function get_categories() { |
| 70 |
return [ 'wdk-elementor-listing-preview' ]; |
| 71 |
} |
| 72 |
|
| 73 |
/** |
| 74 |
* Retrieve the widget name. |
| 75 |
* |
| 76 |
* @since 1.1.0 |
| 77 |
* |
| 78 |
* @access public |
| 79 |
* |
| 80 |
* @return string Widget name. |
| 81 |
*/ |
| 82 |
public function get_name() { |
| 83 |
return 'wdk-listing-fields-section'; |
| 84 |
} |
| 85 |
|
| 86 |
/** |
| 87 |
* Retrieve the widget title. |
| 88 |
* |
| 89 |
* @since 1.1.0 |
| 90 |
* |
| 91 |
* @access public |
| 92 |
* |
| 93 |
* @return string Widget title. |
| 94 |
*/ |
| 95 |
public function get_title() { |
| 96 |
return esc_html__('Wdk Fields Section', 'wpdirectorykit'); |
| 97 |
} |
| 98 |
|
| 99 |
/** |
| 100 |
* Retrieve the widget icon. |
| 101 |
* |
| 102 |
* @since 1.1.0 |
| 103 |
* |
| 104 |
* @access public |
| 105 |
* |
| 106 |
* @return string Widget icon. |
| 107 |
*/ |
| 108 |
public function get_icon() { |
| 109 |
return 'eicon-toggle'; |
| 110 |
} |
| 111 |
|
| 112 |
/** |
| 113 |
* Register the widget controls. |
| 114 |
* |
| 115 |
* Adds different input fields to allow the user to change and customize the widget settings. |
| 116 |
* |
| 117 |
* @since 1.1.0 |
| 118 |
* |
| 119 |
* @access protected |
| 120 |
*/ |
| 121 |
protected function register_controls() { |
| 122 |
$this->generate_controls_conf(); |
| 123 |
$this->generate_controls_layout(); |
| 124 |
$this->generate_controls_styles(); |
| 125 |
$this->generate_controls_content(); |
| 126 |
|
| 127 |
$this->insert_pro_message('1'); |
| 128 |
parent::register_controls(); |
| 129 |
} |
| 130 |
|
| 131 |
/** |
| 132 |
* Render the widget output on the frontend. |
| 133 |
* |
| 134 |
* Written in PHP and used to generate the final HTML. |
| 135 |
* |
| 136 |
* @since 1.1.0 |
| 137 |
* |
| 138 |
* @access protected |
| 139 |
*/ |
| 140 |
protected function render() { |
| 141 |
parent::render(); |
| 142 |
global $wdk_listing_id; |
| 143 |
|
| 144 |
$this->data['id_element'] = $this->get_id(); |
| 145 |
$this->data['settings'] = $this->get_settings(); |
| 146 |
$this->data['wdk_listing_id'] = $wdk_listing_id; |
| 147 |
|
| 148 |
|
| 149 |
$this->data['section_label'] = 'Example Section'; |
| 150 |
$this->data['sections_data'] = $this->WMVC->field_m->get_fields_section(); |
| 151 |
$this->data['section_data'] = array(); |
| 152 |
|
| 153 |
if(!empty($this->data['settings']['section_id'])){ |
| 154 |
$this->data['section_label'] = wdk_field_label($this->data['settings']['section_id']); |
| 155 |
if(isset($this->data['sections_data'][$this->data['settings']['section_id']])) |
| 156 |
$this->data['section_data'] = $this->data['sections_data'][$this->data['settings']['section_id']]; |
| 157 |
} |
| 158 |
|
| 159 |
if(!empty($this->data['settings']['field_id'])) |
| 160 |
$this->data['field_label'] = wdk_field_label($this->data['settings']['field_id']); |
| 161 |
|
| 162 |
$this->data['is_edit_mode']= false; |
| 163 |
if(Plugin::$instance->editor->is_edit_mode()){ |
| 164 |
$this->data['is_edit_mode']= true; |
| 165 |
if(empty($this->data['section_data'])){ |
| 166 |
echo '<p class="wdk_alert wdk_alert-danger">'.wdk_sprintf(esc_html__('Section #%1$s not found', 'wpdirectorykit'), $this->data['settings']['section_id']).'</p>'; |
| 167 |
return false; |
| 168 |
} |
| 169 |
} else { |
| 170 |
if(empty($this->data['section_data'])){ |
| 171 |
return false; |
| 172 |
} |
| 173 |
|
| 174 |
/* return false if no content */ |
| 175 |
if($this->data['settings']['hide_onempty_complete'] == 'yes') { |
| 176 |
$complete_empty = true; |
| 177 |
foreach($this->data['section_data']['fields'] as $field) { |
| 178 |
|
| 179 |
if(wdk_field_value('category_id', $wdk_listing_id) && wdk_depend_is_hidden_field(wmvc_show_data('idfield', $field), wdk_field_value('category_id', $wdk_listing_id))) { |
| 180 |
continue; |
| 181 |
} |
| 182 |
|
| 183 |
if(!empty(wdk_field_value (wmvc_show_data('idfield', $field), $wdk_listing_id))){ |
| 184 |
$complete_empty = false; |
| 185 |
break; |
| 186 |
} |
| 187 |
} |
| 188 |
|
| 189 |
if($complete_empty) |
| 190 |
return false; |
| 191 |
} |
| 192 |
} |
| 193 |
|
| 194 |
echo $this->view('wdk-listing-fields-section', $this->data); |
| 195 |
} |
| 196 |
|
| 197 |
|
| 198 |
private function generate_controls_conf() { |
| 199 |
$this->start_controls_section( |
| 200 |
'tab_conf_main_section', |
| 201 |
[ |
| 202 |
'label' => esc_html__('Main', 'wpdirectorykit'), |
| 203 |
'tab' => '1', |
| 204 |
] |
| 205 |
); |
| 206 |
|
| 207 |
$WMVC = &wdk_get_instance(); |
| 208 |
$WMVC->model('field_m'); |
| 209 |
|
| 210 |
$sections_list = array('0' => esc_html__('Not Selected', 'wpdirectorykit')); |
| 211 |
foreach($WMVC->field_m->get_sections() as $section_id => $section_label) |
| 212 |
{ |
| 213 |
$sections_list[$section_id] = '#'.$section_id.' '.$section_label; |
| 214 |
} |
| 215 |
|
| 216 |
$this->add_control( |
| 217 |
'section_id', |
| 218 |
[ |
| 219 |
'label' => __( 'Section id', 'wpdirectorykit' ), |
| 220 |
'type' => \Elementor\Controls_Manager::SELECT, |
| 221 |
'default' => '', |
| 222 |
'options' => $sections_list, |
| 223 |
'separator' => 'after', |
| 224 |
] |
| 225 |
); |
| 226 |
|
| 227 |
$this->add_control( |
| 228 |
'label_suffix', |
| 229 |
[ |
| 230 |
'label' => __( 'Label suffix', 'wpdirectorykit' ), |
| 231 |
'type' => \Elementor\Controls_Manager::TEXT, |
| 232 |
'default' => '', |
| 233 |
] |
| 234 |
); |
| 235 |
|
| 236 |
$this->add_control( |
| 237 |
'label_prefix', |
| 238 |
[ |
| 239 |
'label' => __( 'Label prefix', 'wpdirectorykit' ), |
| 240 |
'type' => \Elementor\Controls_Manager::TEXT, |
| 241 |
'default' => '', |
| 242 |
] |
| 243 |
); |
| 244 |
|
| 245 |
$this->add_control( |
| 246 |
'hide_onempty', |
| 247 |
[ |
| 248 |
'label' => __( 'Hide if empty field', 'wpdirectorykit' ), |
| 249 |
'type' => \Elementor\Controls_Manager::SWITCHER, |
| 250 |
'label_on' => __( 'True', 'wpdirectorykit' ), |
| 251 |
'label_off' => __( 'False', 'wpdirectorykit' ), |
| 252 |
'return_value' => 'yes', |
| 253 |
'default' => '', |
| 254 |
] |
| 255 |
); |
| 256 |
|
| 257 |
$this->add_control( |
| 258 |
'hide_onempty_checkbox', |
| 259 |
[ |
| 260 |
'label' => __( 'Hide unchecked Checkboxes', 'wpdirectorykit' ), |
| 261 |
'type' => \Elementor\Controls_Manager::SWITCHER, |
| 262 |
'label_on' => __( 'True', 'wpdirectorykit' ), |
| 263 |
'label_off' => __( 'False', 'wpdirectorykit' ), |
| 264 |
'return_value' => 'yes', |
| 265 |
'default' => 'yes', |
| 266 |
] |
| 267 |
); |
| 268 |
|
| 269 |
$this->add_control( |
| 270 |
'hide_onempty_complete', |
| 271 |
[ |
| 272 |
'label' => __( 'Hide section if empty all field', 'wpdirectorykit' ), |
| 273 |
'type' => \Elementor\Controls_Manager::SWITCHER, |
| 274 |
'label_on' => __( 'True', 'wpdirectorykit' ), |
| 275 |
'label_off' => __( 'False', 'wpdirectorykit' ), |
| 276 |
'return_value' => 'yes', |
| 277 |
'default' => 'yes', |
| 278 |
] |
| 279 |
); |
| 280 |
|
| 281 |
$this->add_control( |
| 282 |
'important_note', |
| 283 |
[ |
| 284 |
'label' => '', |
| 285 |
'type' => \Elementor\Controls_Manager::RAW_HTML, |
| 286 |
'raw' => wdk_sprintf(__( 'Manager Fields <a href="%1$s" target="_blank"> open </a>', 'wpdirectorykit' ), admin_url('admin.php?page=wdk_fields')), |
| 287 |
'content_classes' => 'wdk_elementor_hint', |
| 288 |
] |
| 289 |
); |
| 290 |
|
| 291 |
$this->end_controls_section(); |
| 292 |
|
| 293 |
} |
| 294 |
|
| 295 |
|
| 296 |
private function generate_controls_layout() { |
| 297 |
/* TAB_STYLE */ |
| 298 |
$this->start_controls_section( |
| 299 |
'section_form_style', |
| 300 |
[ |
| 301 |
'label' => __( 'Grid', 'wpdirectorykit' ), |
| 302 |
'tab' => Controls_Manager::TAB_STYLE, |
| 303 |
] |
| 304 |
); |
| 305 |
|
| 306 |
$this->add_responsive_control( |
| 307 |
'field_layout', |
| 308 |
[ |
| 309 |
'label' => __( 'Field Layout', 'wpdirectorykit' ), |
| 310 |
'type' => Controls_Manager::SELECT, |
| 311 |
'options' => [ |
| 312 |
'' => esc_html__('Default', 'wpdirectorykit'), |
| 313 |
'reverse' => esc_html__('Reverse', 'wpdirectorykit'), |
| 314 |
'column' => esc_html__('Column', 'wpdirectorykit'), |
| 315 |
'column-reverse' => esc_html__('Column Reverse', 'wpdirectorykit'), |
| 316 |
], |
| 317 |
'default' => '', |
| 318 |
'separator' => 'before', |
| 319 |
] |
| 320 |
); |
| 321 |
|
| 322 |
$this->add_responsive_control( |
| 323 |
'row_gap_col', |
| 324 |
[ |
| 325 |
'label' => __( 'Columns', 'wpdirectorykit' ), |
| 326 |
'type' => Controls_Manager::SELECT, |
| 327 |
'options' => [ |
| 328 |
'' => esc_html__('Default', 'wpdirectorykit'), |
| 329 |
'auto' => esc_html__('Auto', 'wpdirectorykit'), |
| 330 |
'100%' => '1', |
| 331 |
'50%' => '2', |
| 332 |
'calc(100% / 3)' => '3', |
| 333 |
'25%' => '4', |
| 334 |
'20%' => '5', |
| 335 |
'auto_flexible' => 'auto flexible', |
| 336 |
], |
| 337 |
'selectors_dictionary' => [ |
| 338 |
'auto' => 'width:auto;-webkit-flex:0 0 auto;flex:0 0 auto', |
| 339 |
'100%' => 'width:100%;-webkit-flex:0 0 100%;flex:0 0 100%', |
| 340 |
'50%' => 'width:50%;-webkit-flex:0 0 50%;flex:0 0 50%', |
| 341 |
'calc(100% / 3)' => 'width:calc(100% / 3);-webkit-flex:0 0 calc(100% / 3);flex:0 0 calc(100% / 3)', |
| 342 |
'25%' => 'width:25%;-webkit-flex:0 0 25%;flex:0 0 25%', |
| 343 |
'20%' => 'width:20%;-webkit-flex:0 0 20%;flex:0 0 20%', |
| 344 |
'auto' => 'width:auto;-webkit-flex:0 0 auto;flex:0 0 auto', |
| 345 |
'auto_flexible' => 'width:auto;-webkit-flex:1 2 auto;flex:1 2 auto', |
| 346 |
], |
| 347 |
'selectors' => [ |
| 348 |
'{{WRAPPER}} .wdk-row .wdk-col' => '{{UNIT}}', |
| 349 |
], |
| 350 |
'default' => 'calc(100% / 3)', |
| 351 |
'separator' => 'before', |
| 352 |
] |
| 353 |
); |
| 354 |
|
| 355 |
$this->add_responsive_control( |
| 356 |
'column_gap', |
| 357 |
[ |
| 358 |
'label' => esc_html__('Columns Gap', 'wpdirectorykit'), |
| 359 |
'type' => Controls_Manager::SLIDER, |
| 360 |
'default' => [ |
| 361 |
'size' => 0, |
| 362 |
], |
| 363 |
'range' => [ |
| 364 |
'px' => [ |
| 365 |
'min' => 0, |
| 366 |
'max' => 60, |
| 367 |
], |
| 368 |
], |
| 369 |
'selectors' => [ |
| 370 |
'{{WRAPPER}} .wdk-row .wdk-col' => 'padding-left: {{SIZE}}{{UNIT}};padding-right: {{SIZE}}{{UNIT}};;', |
| 371 |
], |
| 372 |
] |
| 373 |
); |
| 374 |
|
| 375 |
$this->add_responsive_control( |
| 376 |
'row_gap', |
| 377 |
[ |
| 378 |
'label' => esc_html__('Rows Gap', 'wpdirectorykit'), |
| 379 |
'type' => Controls_Manager::SLIDER, |
| 380 |
'default' => [ |
| 381 |
'size' => 10, |
| 382 |
], |
| 383 |
'range' => [ |
| 384 |
'px' => [ |
| 385 |
'min' => 0, |
| 386 |
'max' => 60, |
| 387 |
], |
| 388 |
], |
| 389 |
'selectors' => [ |
| 390 |
'{{WRAPPER}} .wdk-row .wdk-col' => 'padding-bottom: {{SIZE}}{{UNIT}}; padding-top: {{SIZE}}{{UNIT}};', |
| 391 |
'{{WRAPPER}} .wdk-row' => 'margin-bottom: -{{SIZE}}{{UNIT}}; margin-top: -{{SIZE}}{{UNIT}};', |
| 392 |
], |
| 393 |
] |
| 394 |
); |
| 395 |
|
| 396 |
$this->add_control( |
| 397 |
'item_border_header', |
| 398 |
[ |
| 399 |
'label' => __( 'Border', 'wpdirectorykit' ), |
| 400 |
'type' => Controls_Manager::HEADING, |
| 401 |
'separator' => 'before', |
| 402 |
] |
| 403 |
); |
| 404 |
|
| 405 |
$selectors = array( |
| 406 |
'normal' => '{{WRAPPER}} .wdk-row .wdk-col', |
| 407 |
); |
| 408 |
|
| 409 |
$this->generate_renders_tabs($selectors, 'item_border', ['border']); |
| 410 |
|
| 411 |
$this->add_control( |
| 412 |
'field_group_position', |
| 413 |
[ |
| 414 |
'label' => __( 'Positions', 'wpdirectorykit' ), |
| 415 |
'type' => Controls_Manager::HEADING, |
| 416 |
'separator' => 'before', |
| 417 |
] |
| 418 |
); |
| 419 |
|
| 420 |
$this->add_responsive_control( |
| 421 |
'field_group_align_h', |
| 422 |
[ |
| 423 |
'label' => __( 'Align Horizontal', 'wpdirectorykit' ), |
| 424 |
'type' => Controls_Manager::CHOOSE, |
| 425 |
'options' => [ |
| 426 |
'left' => [ |
| 427 |
'title' => esc_html__( 'Left', 'wpdirectorykit' ), |
| 428 |
'icon' => 'eicon-text-align-left', |
| 429 |
], |
| 430 |
'center' => [ |
| 431 |
'title' => esc_html__( 'Center', 'wpdirectorykit' ), |
| 432 |
'icon' => 'eicon-text-align-center', |
| 433 |
], |
| 434 |
'right' => [ |
| 435 |
'title' => esc_html__( 'Right', 'wpdirectorykit' ), |
| 436 |
'icon' => 'eicon-text-align-right', |
| 437 |
], |
| 438 |
'justify' => [ |
| 439 |
'title' => esc_html__( 'Justified', 'wpdirectorykit' ), |
| 440 |
'icon' => 'eicon-text-align-justify', |
| 441 |
], |
| 442 |
], |
| 443 |
'render_type' => 'template', |
| 444 |
'selectors_dictionary' => [ |
| 445 |
'left' => 'justify-content: flex-start;', |
| 446 |
'center' => 'justify-content: center;', |
| 447 |
'right' => 'justify-content: flex-end;', |
| 448 |
'justify' => 'justify-content: space-between;', |
| 449 |
], |
| 450 |
'selectors' => [ |
| 451 |
'{{WRAPPER}} .wdk-listing-fields-section .wdk-col' => '{{VALUE}};', |
| 452 |
], |
| 453 |
'conditions' => [ |
| 454 |
'terms' => [ |
| 455 |
[ |
| 456 |
'name' => 'field_layout', |
| 457 |
'operator' => '==', |
| 458 |
'value' => '', |
| 459 |
] |
| 460 |
], |
| 461 |
], |
| 462 |
] |
| 463 |
); |
| 464 |
|
| 465 |
$this->add_responsive_control( |
| 466 |
'field_group_align_h_reverse', |
| 467 |
[ |
| 468 |
'label' => __( 'Align Horizontal', 'wpdirectorykit' ), |
| 469 |
'type' => Controls_Manager::CHOOSE, |
| 470 |
'options' => [ |
| 471 |
'left' => [ |
| 472 |
'title' => esc_html__( 'Left', 'wpdirectorykit' ), |
| 473 |
'icon' => 'eicon-text-align-left', |
| 474 |
], |
| 475 |
'center' => [ |
| 476 |
'title' => esc_html__( 'Center', 'wpdirectorykit' ), |
| 477 |
'icon' => 'eicon-text-align-center', |
| 478 |
], |
| 479 |
'right' => [ |
| 480 |
'title' => esc_html__( 'Right', 'wpdirectorykit' ), |
| 481 |
'icon' => 'eicon-text-align-right', |
| 482 |
], |
| 483 |
'justify' => [ |
| 484 |
'title' => esc_html__( 'Justified', 'wpdirectorykit' ), |
| 485 |
'icon' => 'eicon-text-align-justify', |
| 486 |
], |
| 487 |
], |
| 488 |
'render_type' => 'template', |
| 489 |
'selectors_dictionary' => [ |
| 490 |
'left' => 'justify-content: flex-end;', |
| 491 |
'center' => 'justify-content: center;', |
| 492 |
'right' => 'justify-content: flex-start;', |
| 493 |
'justify' => 'justify-content: space-between;', |
| 494 |
], |
| 495 |
'selectors' => [ |
| 496 |
'{{WRAPPER}} .wdk-listing-fields-section .wdk-col' => '{{VALUE}};', |
| 497 |
], |
| 498 |
'conditions' => [ |
| 499 |
'terms' => [ |
| 500 |
[ |
| 501 |
'name' => 'field_layout', |
| 502 |
'operator' => '==', |
| 503 |
'value' => 'reverse', |
| 504 |
] |
| 505 |
], |
| 506 |
], |
| 507 |
] |
| 508 |
); |
| 509 |
|
| 510 |
$this->add_responsive_control( |
| 511 |
'field_group_align_v', |
| 512 |
[ |
| 513 |
'label' => __( 'Align Vertical', 'wpdirectorykit' ), |
| 514 |
'type' => Controls_Manager::CHOOSE, |
| 515 |
'options' => [ |
| 516 |
'left' => [ |
| 517 |
'title' => esc_html__( 'Top', 'wpdirectorykit' ), |
| 518 |
'icon' => 'eicon-v-align-top', |
| 519 |
], |
| 520 |
'center' => [ |
| 521 |
'title' => esc_html__( 'Center', 'wpdirectorykit' ), |
| 522 |
'icon' => 'eicon-v-align-middle', |
| 523 |
], |
| 524 |
'right' => [ |
| 525 |
'title' => esc_html__( 'Bottom', 'wpdirectorykit' ), |
| 526 |
'icon' => 'eicon-v-align-bottom', |
| 527 |
] |
| 528 |
], |
| 529 |
'default' => 'center', |
| 530 |
'render_type' => 'template', |
| 531 |
'selectors_dictionary' => [ |
| 532 |
'left' => 'align-items: flex-start;', |
| 533 |
'center' => 'align-items: center;', |
| 534 |
'right' => 'align-items: flex-end;', |
| 535 |
], |
| 536 |
'selectors' => [ |
| 537 |
'{{WRAPPER}} .wdk-listing-fields-section .wdk-col' => '{{VALUE}};', |
| 538 |
], |
| 539 |
'conditions' => [ |
| 540 |
'terms' => [ |
| 541 |
[ |
| 542 |
'name' => 'field_group_icon_enable', |
| 543 |
'operator' => '==', |
| 544 |
'value' => 'yes', |
| 545 |
] |
| 546 |
], |
| 547 |
], |
| 548 |
] |
| 549 |
); |
| 550 |
$this->end_controls_section(); |
| 551 |
|
| 552 |
} |
| 553 |
|
| 554 |
private function generate_controls_styles() { |
| 555 |
|
| 556 |
$this->start_controls_section( |
| 557 |
'field_group', |
| 558 |
[ |
| 559 |
'label' => esc_html__('Field Icon', 'wpdirectorykit'), |
| 560 |
'tab' => Controls_Manager::TAB_STYLE, |
| 561 |
] |
| 562 |
); |
| 563 |
|
| 564 |
$this->add_responsive_control( |
| 565 |
'field_group_icon_enable', |
| 566 |
[ |
| 567 |
'label' => esc_html__( 'Enable Icon', 'wpdirectorykit' ), |
| 568 |
'type' => \Elementor\Controls_Manager::SWITCHER, |
| 569 |
'label_on' => __( 'On', 'wpdirectorykit' ), |
| 570 |
'label_off' => __( 'Off', 'wpdirectorykit' ), |
| 571 |
'return_value' => 'yes', |
| 572 |
'default' => 'yes', |
| 573 |
] |
| 574 |
); |
| 575 |
|
| 576 |
$this->add_responsive_control ( |
| 577 |
'field_group_icon_max_heigth', |
| 578 |
[ |
| 579 |
'label' => esc_html__('Max Height', 'wpdirectorykit'), |
| 580 |
'type' => Controls_Manager::SLIDER, |
| 581 |
'range' => [ |
| 582 |
'px' => [ |
| 583 |
'min' => 10, |
| 584 |
'max' => 1500, |
| 585 |
], |
| 586 |
'vw' => [ |
| 587 |
'min' => 0, |
| 588 |
'max' => 100, |
| 589 |
], |
| 590 |
'%' => [ |
| 591 |
'min' => 0, |
| 592 |
'max' => 100, |
| 593 |
], |
| 594 |
], |
| 595 |
'size_units' => [ 'px', 'vw','%' ], |
| 596 |
'default' => [ |
| 597 |
'unit' => 'px', |
| 598 |
'size' => 18, |
| 599 |
], |
| 600 |
'selectors' => [ |
| 601 |
'{{WRAPPER}} .field_icon .wdk-icon' => 'max-height: {{SIZE}}{{UNIT}}', |
| 602 |
], |
| 603 |
'conditions' => [ |
| 604 |
'terms' => [ |
| 605 |
[ |
| 606 |
'name' => 'field_group_icon_enable', |
| 607 |
'operator' => '==', |
| 608 |
'value' => 'yes', |
| 609 |
] |
| 610 |
], |
| 611 |
], |
| 612 |
] |
| 613 |
); |
| 614 |
|
| 615 |
$this->add_responsive_control ( |
| 616 |
'field_group_icon_max_width', |
| 617 |
[ |
| 618 |
'label' => esc_html__('Max Width', 'wpdirectorykit'), |
| 619 |
'type' => Controls_Manager::SLIDER, |
| 620 |
'range' => [ |
| 621 |
'px' => [ |
| 622 |
'min' => 10, |
| 623 |
'max' => 1500, |
| 624 |
], |
| 625 |
'vw' => [ |
| 626 |
'min' => 0, |
| 627 |
'max' => 100, |
| 628 |
], |
| 629 |
'%' => [ |
| 630 |
'min' => 0, |
| 631 |
'max' => 100, |
| 632 |
], |
| 633 |
], |
| 634 |
'size_units' => [ 'px', 'vw','%' ], |
| 635 |
'default' => [ |
| 636 |
'unit' => 'px', |
| 637 |
'size' => 18, |
| 638 |
], |
| 639 |
'selectors' => [ |
| 640 |
'{{WRAPPER}} .field_icon .wdk-icon' => 'max-width: {{SIZE}}{{UNIT}}', |
| 641 |
], |
| 642 |
'conditions' => [ |
| 643 |
'terms' => [ |
| 644 |
[ |
| 645 |
'name' => 'field_group_icon_enable', |
| 646 |
'operator' => '==', |
| 647 |
'value' => 'yes', |
| 648 |
] |
| 649 |
], |
| 650 |
], |
| 651 |
] |
| 652 |
); |
| 653 |
|
| 654 |
$this->add_responsive_control( |
| 655 |
'field_group_icon', |
| 656 |
[ |
| 657 |
'label' => esc_html__( 'Margin Icon', 'wpdirectorykit' ), |
| 658 |
'type' => Controls_Manager::DIMENSIONS, |
| 659 |
'size_units' => [ 'px', 'em', '%' ], |
| 660 |
'selectors' => [ |
| 661 |
'{{WRAPPER}} .field_icon .wdk-icon' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 662 |
], |
| 663 |
'default' => [ |
| 664 |
'top' => 0, |
| 665 |
'right' => 4, |
| 666 |
'bottom' => 0, |
| 667 |
'left' => 0, |
| 668 |
], |
| 669 |
'conditions' => [ |
| 670 |
'terms' => [ |
| 671 |
[ |
| 672 |
'name' => 'field_group_icon_enable', |
| 673 |
'operator' => '==', |
| 674 |
'value' => 'yes', |
| 675 |
] |
| 676 |
], |
| 677 |
], |
| 678 |
] |
| 679 |
); |
| 680 |
|
| 681 |
$this->add_responsive_control( |
| 682 |
'field_group_icon_position', |
| 683 |
[ |
| 684 |
'label' => __( 'Icon Position', 'wpdirectorykit' ), |
| 685 |
'type' => Controls_Manager::CHOOSE, |
| 686 |
'options' => [ |
| 687 |
'left' => [ |
| 688 |
'title' => esc_html__( 'Left', 'wpdirectorykit' ), |
| 689 |
'icon' => 'eicon-text-align-left', |
| 690 |
], |
| 691 |
'top' => [ |
| 692 |
'title' => esc_html__( 'Top', 'wpdirectorykit' ), |
| 693 |
'icon' => 'eicon-v-align-top', |
| 694 |
], |
| 695 |
'right' => [ |
| 696 |
'title' => esc_html__( 'Right', 'wpdirectorykit' ), |
| 697 |
'icon' => 'eicon-text-align-right', |
| 698 |
], |
| 699 |
'bottom' => [ |
| 700 |
'title' => esc_html__( 'Bottom', 'wpdirectorykit' ), |
| 701 |
'icon' => 'eicon-v-align-bottom', |
| 702 |
], |
| 703 |
], |
| 704 |
'render_type' => 'template', |
| 705 |
'selectors_dictionary' => [ |
| 706 |
'left' => 'width: auto;', |
| 707 |
'top' => 'width: 100%;', |
| 708 |
'right' => 'width:auto;order: 4;', |
| 709 |
'bottom' => 'width:100%;order: 4;', |
| 710 |
], |
| 711 |
'selectors' => [ |
| 712 |
'{{WRAPPER}} .field_icon' => '{{VALUE}};', |
| 713 |
], |
| 714 |
'conditions' => [ |
| 715 |
'terms' => [ |
| 716 |
[ |
| 717 |
'name' => 'field_group_icon_enable', |
| 718 |
'operator' => '==', |
| 719 |
'value' => 'yes', |
| 720 |
], |
| 721 |
[ |
| 722 |
'name' => 'field_layout', |
| 723 |
'operator' => '==', |
| 724 |
'value' => '', |
| 725 |
] |
| 726 |
], |
| 727 |
], |
| 728 |
] |
| 729 |
); |
| 730 |
|
| 731 |
$this->add_responsive_control( |
| 732 |
'field_group_icon_position_reverse', |
| 733 |
[ |
| 734 |
'label' => __( 'Icon Position', 'wpdirectorykit' ), |
| 735 |
'type' => Controls_Manager::CHOOSE, |
| 736 |
'options' => [ |
| 737 |
'left' => [ |
| 738 |
'title' => esc_html__( 'Left', 'wpdirectorykit' ), |
| 739 |
'icon' => 'eicon-text-align-left', |
| 740 |
], |
| 741 |
'top' => [ |
| 742 |
'title' => esc_html__( 'Top', 'wpdirectorykit' ), |
| 743 |
'icon' => 'eicon-v-align-top', |
| 744 |
], |
| 745 |
'right' => [ |
| 746 |
'title' => esc_html__( 'Right', 'wpdirectorykit' ), |
| 747 |
'icon' => 'eicon-text-align-right', |
| 748 |
], |
| 749 |
'bottom' => [ |
| 750 |
'title' => esc_html__( 'Bottom', 'wpdirectorykit' ), |
| 751 |
'icon' => 'eicon-v-align-bottom', |
| 752 |
], |
| 753 |
], |
| 754 |
'render_type' => 'template', |
| 755 |
'selectors_dictionary' => [ |
| 756 |
'left' => 'width: auto;order: 4;', |
| 757 |
'top' => 'width: 100%;order: 1;', |
| 758 |
'right' => 'width:auto;order: 1;', |
| 759 |
'bottom' => 'width:100%;order: 4;', |
| 760 |
], |
| 761 |
'selectors' => [ |
| 762 |
'{{WRAPPER}} .field_icon' => '{{VALUE}};', |
| 763 |
], |
| 764 |
'conditions' => [ |
| 765 |
'terms' => [ |
| 766 |
[ |
| 767 |
'name' => 'field_group_icon_enable', |
| 768 |
'operator' => '==', |
| 769 |
'value' => 'yes', |
| 770 |
], |
| 771 |
[ |
| 772 |
'name' => 'field_layout', |
| 773 |
'operator' => '==', |
| 774 |
'value' => 'reverse', |
| 775 |
] |
| 776 |
], |
| 777 |
], |
| 778 |
] |
| 779 |
); |
| 780 |
|
| 781 |
$this->add_responsive_control( |
| 782 |
'field_group_icon_position_align', |
| 783 |
[ |
| 784 |
'label' => __( 'Icon Align', 'wpdirectorykit' ), |
| 785 |
'type' => Controls_Manager::CHOOSE, |
| 786 |
'options' => [ |
| 787 |
'left' => [ |
| 788 |
'title' => esc_html__( 'Left', 'wpdirectorykit' ), |
| 789 |
'icon' => 'eicon-text-align-left', |
| 790 |
], |
| 791 |
'center' => [ |
| 792 |
'title' => esc_html__( 'Center', 'wpdirectorykit' ), |
| 793 |
'icon' => 'eicon-text-align-center', |
| 794 |
], |
| 795 |
'right' => [ |
| 796 |
'title' => esc_html__( 'Right', 'wpdirectorykit' ), |
| 797 |
'icon' => 'eicon-text-align-right', |
| 798 |
], |
| 799 |
], |
| 800 |
'render_type' => 'template', |
| 801 |
'selectors_dictionary' => [ |
| 802 |
'left' => 'text-align:left', |
| 803 |
'center' => 'text-align:center', |
| 804 |
'right' => 'text-align:right', |
| 805 |
], |
| 806 |
'selectors' => [ |
| 807 |
'{{WRAPPER}} .field_icon' => '{{VALUE}};', |
| 808 |
], |
| 809 |
'conditions' => [ |
| 810 |
'terms' => [ |
| 811 |
[ |
| 812 |
'name' => 'field_group_icon_enable', |
| 813 |
'operator' => '==', |
| 814 |
'value' => 'yes', |
| 815 |
], |
| 816 |
], |
| 817 |
], |
| 818 |
] |
| 819 |
); |
| 820 |
|
| 821 |
$this->end_controls_section(); |
| 822 |
|
| 823 |
/* dynamic */ |
| 824 |
$items = [ |
| 825 |
[ |
| 826 |
'key'=>'section_title', |
| 827 |
'label'=> esc_html__('Section Title', 'wpdirectorykit'), |
| 828 |
'selector'=>'.section-title', |
| 829 |
'options'=>'full', |
| 830 |
], |
| 831 |
[ |
| 832 |
'key'=>'field_label', |
| 833 |
'label'=> esc_html__('Field Label', 'wpdirectorykit'), |
| 834 |
'selector'=>'.field_label', |
| 835 |
'options'=>['margin','typo','color','padding','transition'], |
| 836 |
], |
| 837 |
[ |
| 838 |
'key'=>'field_prefix', |
| 839 |
'label'=> esc_html__('Field Prefix', 'wpdirectorykit'), |
| 840 |
'selector'=>'.field_value .prefix', |
| 841 |
'options'=>['margin','typo','color','padding','transition'], |
| 842 |
], |
| 843 |
[ |
| 844 |
'key'=>'field_suffix', |
| 845 |
'label'=> esc_html__('Field Suffix', 'wpdirectorykit'), |
| 846 |
'selector'=>'.field_value .suffix', |
| 847 |
'options'=>['margin','typo','color','padding','transition'], |
| 848 |
], |
| 849 |
[ |
| 850 |
'key'=>'field_value', |
| 851 |
'label'=> esc_html__('Field Value', 'wpdirectorykit'), |
| 852 |
'selector'=>'.field_value .value', |
| 853 |
'options'=>['margin','typo','color','padding','transition'], |
| 854 |
] |
| 855 |
]; |
| 856 |
|
| 857 |
foreach ($items as $item) { |
| 858 |
$this->start_controls_section( |
| 859 |
$item['key'].'_section', |
| 860 |
[ |
| 861 |
'label' => $item['label'], |
| 862 |
'tab' => 'tab_layout' |
| 863 |
] |
| 864 |
); |
| 865 |
|
| 866 |
$this->add_responsive_control( |
| 867 |
$item['key'].'_hide', |
| 868 |
[ |
| 869 |
'label' => esc_html__( 'Hide Element', 'wpdirectorykit' ), |
| 870 |
'type' => Controls_Manager::SWITCHER, |
| 871 |
'none' => esc_html__( 'Hide', 'wpdirectorykit' ), |
| 872 |
'block' => esc_html__( 'Show', 'wpdirectorykit' ), |
| 873 |
'return_value' => 'none', |
| 874 |
'default' => '', |
| 875 |
'selectors' => [ |
| 876 |
'{{WRAPPER}} '.$item['selector'] => 'display: {{VALUE}};', |
| 877 |
], |
| 878 |
] |
| 879 |
); |
| 880 |
|
| 881 |
$selectors = array( |
| 882 |
'normal' => '{{WRAPPER}} '.$item['selector'], |
| 883 |
'hover'=>'{{WRAPPER}} '.$item['selector'].'%1$s' |
| 884 |
); |
| 885 |
$this->generate_renders_tabs($selectors, $item['key'].'_dynamic', $item['options']); |
| 886 |
|
| 887 |
$this->end_controls_section(); |
| 888 |
/* END special for some elements */ |
| 889 |
} |
| 890 |
|
| 891 |
$this->start_controls_section( |
| 892 |
'field_checkbox_icon', |
| 893 |
[ |
| 894 |
'label' => esc_html__('Checkbox', 'wpdirectorykit'), |
| 895 |
'tab' => Controls_Manager::TAB_STYLE, |
| 896 |
] |
| 897 |
); |
| 898 |
|
| 899 |
$this->add_responsive_control( |
| 900 |
'field_checkbox_icon_success_header', |
| 901 |
[ |
| 902 |
'label' => esc_html__('Success checkbox', 'wpdirectorykit'), |
| 903 |
'type' => Controls_Manager::HEADING, |
| 904 |
'separator' => 'before', |
| 905 |
] |
| 906 |
); |
| 907 |
|
| 908 |
$this->add_responsive_control( |
| 909 |
'field_checkbox_hide', |
| 910 |
[ |
| 911 |
'label' => esc_html__( 'Hide Element', 'wpdirectorykit' ), |
| 912 |
'type' => Controls_Manager::SWITCHER, |
| 913 |
'none' => esc_html__( 'Hide', 'wpdirectorykit' ), |
| 914 |
'block' => esc_html__( 'Show', 'wpdirectorykit' ), |
| 915 |
'return_value' => 'none', |
| 916 |
'default' => '', |
| 917 |
'selectors' => [ |
| 918 |
'{{WRAPPER}} .wdk-listing-fields-section .wdk-col.reverse.CHECKBOX .field_value' => 'display: {{VALUE}};', |
| 919 |
], |
| 920 |
] |
| 921 |
); |
| 922 |
|
| 923 |
$this->add_responsive_control( |
| 924 |
'field_checkbox_position', |
| 925 |
[ |
| 926 |
'label' => __( 'Columns', 'wpdirectorykit' ), |
| 927 |
'type' => Controls_Manager::SELECT, |
| 928 |
'options' => [ |
| 929 |
'left' => esc_html__('Left', 'wpdirectorykit'), |
| 930 |
'right' => esc_html__('Right', 'wpdirectorykit'), |
| 931 |
], |
| 932 |
'selectors_dictionary' => [ |
| 933 |
'left' => 'order:1', |
| 934 |
'right' => 'order: 3', |
| 935 |
], |
| 936 |
'selectors' => [ |
| 937 |
'{{WRAPPER}} .wdk-listing-fields-section .wdk-col.reverse.CHECKBOX .field_value' => '{{UNIT}}', |
| 938 |
], |
| 939 |
'default' => 'left', |
| 940 |
'separator' => 'before', |
| 941 |
'conditions' => [ |
| 942 |
'terms' => [ |
| 943 |
[ |
| 944 |
'name' => 'field_layout', |
| 945 |
'operator' => '==', |
| 946 |
'value' => '', |
| 947 |
] |
| 948 |
], |
| 949 |
], |
| 950 |
] |
| 951 |
); |
| 952 |
|
| 953 |
$this->add_responsive_control( |
| 954 |
'field_checkbox_position_reverse', |
| 955 |
[ |
| 956 |
'label' => __( 'Columns', 'wpdirectorykit' ), |
| 957 |
'type' => Controls_Manager::SELECT, |
| 958 |
'options' => [ |
| 959 |
'left' => esc_html__('Left', 'wpdirectorykit'), |
| 960 |
'right' => esc_html__('Right', 'wpdirectorykit'), |
| 961 |
], |
| 962 |
'selectors_dictionary' => [ |
| 963 |
'left' => 'order:3', |
| 964 |
'right' => 'order: 1', |
| 965 |
], |
| 966 |
'selectors' => [ |
| 967 |
'{{WRAPPER}} .wdk-listing-fields-section .wdk-col.reverse.CHECKBOX .field_value' => '{{UNIT}}', |
| 968 |
], |
| 969 |
'default' => 'left', |
| 970 |
'separator' => 'before', |
| 971 |
'conditions' => [ |
| 972 |
'terms' => [ |
| 973 |
[ |
| 974 |
'name' => 'field_layout', |
| 975 |
'operator' => '==', |
| 976 |
'value' => 'reverse', |
| 977 |
] |
| 978 |
], |
| 979 |
], |
| 980 |
] |
| 981 |
); |
| 982 |
|
| 983 |
$this->add_control ( |
| 984 |
'field_checkbox_icon_success', |
| 985 |
[ |
| 986 |
'label' => esc_html__('Icon', 'wpdirectorykit'), |
| 987 |
'type' => Controls_Manager::ICONS, |
| 988 |
'label_block' => true, |
| 989 |
'default' => [ |
| 990 |
'value' => 'fa fa-check', |
| 991 |
'library' => 'solid', |
| 992 |
], |
| 993 |
] |
| 994 |
); |
| 995 |
|
| 996 |
$selectors = array( |
| 997 |
'normal' => '{{WRAPPER}} .field_checkbox_success', |
| 998 |
); |
| 999 |
$this->generate_renders_tabs($selectors, 'field_checkbox_icon_success_dynamic', 'full'); |
| 1000 |
|
| 1001 |
|
| 1002 |
$this->add_responsive_control( |
| 1003 |
'field_checkbox_icon_unsuccess_header', |
| 1004 |
[ |
| 1005 |
'label' => esc_html__('Unsuccess checkbox', 'wpdirectorykit'), |
| 1006 |
'type' => Controls_Manager::HEADING, |
| 1007 |
'separator' => 'before', |
| 1008 |
] |
| 1009 |
); |
| 1010 |
|
| 1011 |
$this->add_control( |
| 1012 |
'field_checkbox_icon_unsuccess', |
| 1013 |
[ |
| 1014 |
'label' => esc_html__('Icon', 'wpdirectorykit'), |
| 1015 |
'type' => Controls_Manager::ICONS, |
| 1016 |
'label_block' => true, |
| 1017 |
'default' => [ |
| 1018 |
'value' => 'fa fa-close', |
| 1019 |
'library' => 'solid', |
| 1020 |
], |
| 1021 |
] |
| 1022 |
); |
| 1023 |
|
| 1024 |
$selectors = array( |
| 1025 |
'normal' => '{{WRAPPER}} .field_checkbox_unsuccess', |
| 1026 |
); |
| 1027 |
|
| 1028 |
$this->generate_renders_tabs($selectors, 'field_checkbox_icon_unsuccess_dynamic', 'full'); |
| 1029 |
|
| 1030 |
$this->end_controls_section(); |
| 1031 |
} |
| 1032 |
|
| 1033 |
|
| 1034 |
private function generate_controls_content() { |
| 1035 |
|
| 1036 |
} |
| 1037 |
|
| 1038 |
public function enqueue_styles_scripts() { |
| 1039 |
wp_enqueue_style('wdk-listing-fields-section'); |
| 1040 |
} |
| 1041 |
} |
| 1042 |
|