| 1 |
<?php |
| 2 |
|
| 3 |
namespace Wdk\Elementor\Widgets; |
| 4 |
|
| 5 |
use Elementor\Widget_Base; |
| 6 |
use Elementor\Controls_Manager; |
| 7 |
use Elementor\Utils; |
| 8 |
use Elementor\Typography; |
| 9 |
use Elementor\Editor; |
| 10 |
use Elementor\Plugin; |
| 11 |
use Elementor\Repeater; |
| 12 |
use Elementor\Core\Schemes; |
| 13 |
use Elementor\Group_Control_Typography; |
| 14 |
use Elementor\Group_Control_Border; |
| 15 |
use Elementor\Group_Control_Box_Shadow; |
| 16 |
use Elementor\Group_Control_Css_Filter; |
| 17 |
|
| 18 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
| 19 |
|
| 20 |
/** |
| 21 |
* @since 1.1.0 |
| 22 |
*/ |
| 23 |
class WdkElementorBase extends Widget_Base { |
| 24 |
/** |
| 25 |
* data array |
| 26 |
* |
| 27 |
* @var array |
| 28 |
*/ |
| 29 |
protected $data = array(); |
| 30 |
protected $WMVC = NULL; |
| 31 |
|
| 32 |
public function __construct($data = array(), $args = null) { |
| 33 |
/* load icons for tabs in edit mode */ |
| 34 |
wp_enqueue_style( 'wdk-elementor-main', WPDIRECTORYKIT_URL. 'elementor-elements/assets/css/wdk-main.css' ); |
| 35 |
|
| 36 |
if ($this->is_edit_mode_load()) { |
| 37 |
$this->enqueue_styles_scripts(); |
| 38 |
} |
| 39 |
|
| 40 |
parent::__construct($data, $args); |
| 41 |
} |
| 42 |
|
| 43 |
/** |
| 44 |
* Retrieve the widget name. |
| 45 |
* |
| 46 |
* @since 1.1.0 |
| 47 |
* |
| 48 |
* @access public |
| 49 |
* |
| 50 |
* @return string Widget name. |
| 51 |
*/ |
| 52 |
public function get_name() { |
| 53 |
return 'wdk-base'; |
| 54 |
} |
| 55 |
|
| 56 |
/** |
| 57 |
* Retrieve the widget title. |
| 58 |
* |
| 59 |
* @since 1.1.0 |
| 60 |
* |
| 61 |
* @access public |
| 62 |
* |
| 63 |
* @return string Widget title. |
| 64 |
*/ |
| 65 |
public function get_title() { |
| 66 |
return esc_html__( 'Wdk Widget Name', 'wpdirectorykit' ); |
| 67 |
} |
| 68 |
|
| 69 |
/** |
| 70 |
* Retrieve the widget icon. |
| 71 |
* |
| 72 |
* @since 1.1.0 |
| 73 |
* |
| 74 |
* @access public |
| 75 |
* |
| 76 |
* @return string Widget icon. |
| 77 |
*/ |
| 78 |
public function get_icon() { |
| 79 |
return ''; |
| 80 |
} |
| 81 |
|
| 82 |
/** |
| 83 |
* Retrieve the list of categories the widget belongs to. |
| 84 |
* |
| 85 |
* Used to determine where to display the widget in the editor. |
| 86 |
* |
| 87 |
* Note that currently Elementor supports only one category. |
| 88 |
* When multiple categories passed, Elementor uses the first one. |
| 89 |
* |
| 90 |
* @since 1.1.0 |
| 91 |
* |
| 92 |
* @access public |
| 93 |
* |
| 94 |
* @return array Widget categories. |
| 95 |
*/ |
| 96 |
public function get_categories() { |
| 97 |
return [ 'wdk-elementor' ]; |
| 98 |
} |
| 99 |
|
| 100 |
/** |
| 101 |
* Register the widget controls. |
| 102 |
* |
| 103 |
* Adds different input fields to allow the user to change and customize the widget settings. |
| 104 |
* |
| 105 |
* @since 1.1.0 |
| 106 |
* |
| 107 |
* @access protected |
| 108 |
*/ |
| 109 |
protected function register_controls() { |
| 110 |
/* TAB_STYLE */ |
| 111 |
$this->start_controls_section( |
| 112 |
'section_form_css', |
| 113 |
[ |
| 114 |
'label' => esc_html__( 'Custom сss', 'wpdirectorykit' ), |
| 115 |
'tab' => Controls_Manager::TAB_STYLE, |
| 116 |
] |
| 117 |
); |
| 118 |
|
| 119 |
$this->add_control( |
| 120 |
'custom_css_title', |
| 121 |
[ |
| 122 |
'raw' => esc_html__( 'Add your own custom CSS here', 'wpdirectorykit' ), |
| 123 |
'type' => Controls_Manager::RAW_HTML, |
| 124 |
] |
| 125 |
); |
| 126 |
|
| 127 |
$this->add_control( |
| 128 |
'custom_css', |
| 129 |
[ |
| 130 |
'type' => Controls_Manager::CODE, |
| 131 |
'label' => esc_html__( 'Custom CSS', 'wpdirectorykit' ), |
| 132 |
'language' => 'css', |
| 133 |
'render_type' => 'ui', |
| 134 |
'show_label' => false, |
| 135 |
'separator' => 'none', |
| 136 |
] |
| 137 |
); |
| 138 |
|
| 139 |
$this->add_control( |
| 140 |
'custom_css_description', |
| 141 |
[ |
| 142 |
'raw' => esc_html__( 'Use "selector" to target wrapper element. Examples:<br>selector {color: red;} // For main element<br>selector .child-element {margin: 10px;} // For child element<br>.my-class {text-align: center;} // Or use any custom selector', 'wpdirectorykit' ), |
| 143 |
'type' => Controls_Manager::RAW_HTML, |
| 144 |
'content_classes' => 'elementor-descriptor', |
| 145 |
] |
| 146 |
); |
| 147 |
|
| 148 |
$this->end_controls_section(); |
| 149 |
|
| 150 |
|
| 151 |
} |
| 152 |
|
| 153 |
/** |
| 154 |
* Render the widget output on the frontend. |
| 155 |
* |
| 156 |
* Written in PHP and used to generate the final HTML. |
| 157 |
* |
| 158 |
* @since 1.1.0 |
| 159 |
* |
| 160 |
* @access protected |
| 161 |
*/ |
| 162 |
protected function render() { |
| 163 |
$this->enqueue_styles_scripts(); |
| 164 |
$this->add_page_settings_css(); |
| 165 |
|
| 166 |
$this->WMVC = &wdk_get_instance(); |
| 167 |
$this->WMVC->model('listingfield_m'); |
| 168 |
$this->WMVC->model('listing_m'); |
| 169 |
$this->WMVC->load_helper('listing'); |
| 170 |
} |
| 171 |
|
| 172 |
|
| 173 |
public function view($view_file = '', $element = NULL, $print = false) |
| 174 |
{ |
| 175 |
if(empty($view_file)) return false; |
| 176 |
$file = false; |
| 177 |
|
| 178 |
if(is_child_theme() && file_exists(get_stylesheet_directory().'/wpdirectorykit/elementor-elements/views/'.$view_file.'.php')) |
| 179 |
{ |
| 180 |
$file = get_stylesheet_directory().'/wpdirectorykit/elementor-elements/views/'.$view_file.'.php'; |
| 181 |
} |
| 182 |
elseif(file_exists(get_template_directory().'/wpdirectorykit/elementor-elements/views/'.$view_file.'.php')) |
| 183 |
{ |
| 184 |
$file = get_template_directory().'/wpdirectorykit/elementor-elements/views/'.$view_file.'.php'; |
| 185 |
} |
| 186 |
elseif(file_exists(WPDIRECTORYKIT_PATH.'elementor-elements/views/'.$view_file.'.php')) |
| 187 |
{ |
| 188 |
$file = WPDIRECTORYKIT_PATH.'elementor-elements/views/'.$view_file.'.php'; |
| 189 |
} |
| 190 |
|
| 191 |
if($file) |
| 192 |
{ |
| 193 |
extract($element); |
| 194 |
if($print) { |
| 195 |
include $file; |
| 196 |
} else { |
| 197 |
ob_start(); |
| 198 |
include $file; |
| 199 |
return ob_get_clean(); |
| 200 |
} |
| 201 |
} |
| 202 |
else |
| 203 |
{ |
| 204 |
if($print) { |
| 205 |
echo 'View file not found in: '.esc_html(WPDIRECTORYKIT_PATH.'elementor-elements/views/'.$view_file.'.php'); |
| 206 |
} else { |
| 207 |
return 'View file not found in: '.esc_html(WPDIRECTORYKIT_PATH.'elementor-elements/views/'.$view_file.'.php'); |
| 208 |
} |
| 209 |
} |
| 210 |
} |
| 211 |
|
| 212 |
public function generate_renders_tabs($selectors = array(), $tab_prefix='', $enable_options = array(), $disable_options = array()) { |
| 213 |
/* margin */ |
| 214 |
//$options = ['margin','align','typo','color','background','border','border_radius','padding','shadow','transition','image_size_control','image_fit_control', 'height', 'width','font-size','css_filters','background_group','hover_animation']; |
| 215 |
$options = ['typo','color','background','border','border_radius','padding','shadow']; // default |
| 216 |
|
| 217 |
/* defined */ |
| 218 |
if(is_string($enable_options)){ |
| 219 |
switch($enable_options) { |
| 220 |
case 'block': $enable_options = ['typo','color','background','border','border_radius','padding','shadow','transition']; |
| 221 |
break; |
| 222 |
case 'text-block': $enable_options = ['align','typo','color','background','border','border_radius','padding','shadow','transition']; |
| 223 |
break; |
| 224 |
case 'text': $enable_options = ['align','typo','color','background','border','border_radius','padding','shadow','transition']; |
| 225 |
break; |
| 226 |
case 'full': $enable_options = ['margin','align','typo','color','background','border','border_radius','padding','shadow','transition']; |
| 227 |
break; |
| 228 |
deafult: $enable_options = ['margin','align','typo','color','background','border','border_radius','padding','shadow','transition']; |
| 229 |
break; |
| 230 |
} |
| 231 |
} |
| 232 |
|
| 233 |
|
| 234 |
/* enable options */ |
| 235 |
if(!empty($enable_options)){ |
| 236 |
$options = $enable_options; |
| 237 |
} |
| 238 |
$options_flip = array_flip($options); |
| 239 |
/* disable options */ |
| 240 |
if(!empty($disable_options)){ |
| 241 |
foreach ($disable_options as $value) { |
| 242 |
if(isset($options_flip[$value])) |
| 243 |
unset($options[$options_flip[$value]]); |
| 244 |
} |
| 245 |
} |
| 246 |
$tabs_enable = true; |
| 247 |
if(wmvc_count($selectors) == 1){ |
| 248 |
$tabs_enable = false; |
| 249 |
} |
| 250 |
if($tabs_enable) |
| 251 |
$this->start_controls_tabs( $tab_prefix.'_style' ); |
| 252 |
foreach($selectors as $key => $selector) |
| 253 |
$this->_generate_tabs($selector, $key, $tab_prefix, $options, $tabs_enable); |
| 254 |
if($tabs_enable) |
| 255 |
$this->end_controls_tabs(); |
| 256 |
|
| 257 |
} |
| 258 |
|
| 259 |
public function _generate_tabs($selector='', $prefix = '', $type='', $options = array(), $tabs_enable = true) { |
| 260 |
if(empty($selector)) return false; |
| 261 |
|
| 262 |
if(empty($prefix) || $prefix == 'normal'){ |
| 263 |
$selector = $selector; |
| 264 |
$prefix = 'normal'; |
| 265 |
} |
| 266 |
else |
| 267 |
$selector = sprintf($selector,':'.$prefix); |
| 268 |
|
| 269 |
if($tabs_enable) |
| 270 |
$this->start_controls_tab( |
| 271 |
$type.'_'.$prefix.'_style', |
| 272 |
[ |
| 273 |
'label' => ucfirst($prefix), |
| 274 |
] |
| 275 |
); |
| 276 |
|
| 277 |
if(in_array('typo',$options)) |
| 278 |
$this->add_group_control( |
| 279 |
Group_Control_Typography::get_type(), |
| 280 |
[ |
| 281 |
'name' => $type.'_typo'.$prefix, |
| 282 |
'selector' => $selector, |
| 283 |
] |
| 284 |
); |
| 285 |
|
| 286 |
if(in_array('align',$options)) |
| 287 |
$this->add_responsive_control( |
| 288 |
$type.'_align'.$prefix, |
| 289 |
[ |
| 290 |
'label' => esc_html__( 'Alignment', 'wpdirectorykit' ), |
| 291 |
'type' => Controls_Manager::CHOOSE, |
| 292 |
'options' => [ |
| 293 |
'left' => [ |
| 294 |
'title' => esc_html__( 'Left', 'wpdirectorykit' ), |
| 295 |
'icon' => 'eicon-text-align-left', |
| 296 |
], |
| 297 |
'center' => [ |
| 298 |
'title' => esc_html__( 'Center', 'wpdirectorykit' ), |
| 299 |
'icon' => 'eicon-text-align-center', |
| 300 |
], |
| 301 |
'right' => [ |
| 302 |
'title' => esc_html__( 'Right', 'wpdirectorykit' ), |
| 303 |
'icon' => 'eicon-text-align-right', |
| 304 |
], |
| 305 |
'justify' => [ |
| 306 |
'title' => esc_html__( 'Justified', 'wpdirectorykit' ), |
| 307 |
'icon' => 'eicon-text-align-justify', |
| 308 |
], |
| 309 |
], |
| 310 |
'selectors' => [ |
| 311 |
$selector => 'text-align: {{VALUE}};', |
| 312 |
], |
| 313 |
] |
| 314 |
); |
| 315 |
|
| 316 |
if(in_array('color',$options)) |
| 317 |
$this->add_responsive_control( |
| 318 |
$type.'_color'.$prefix, |
| 319 |
[ |
| 320 |
'label' => esc_html__( 'Color', 'wpdirectorykit' ), |
| 321 |
'type' => Controls_Manager::COLOR, |
| 322 |
'selectors' => [ |
| 323 |
$selector => 'color: {{VALUE}};', |
| 324 |
], |
| 325 |
] |
| 326 |
); |
| 327 |
|
| 328 |
if(in_array('background',$options)) |
| 329 |
$this->add_responsive_control( |
| 330 |
$type.'_background'.$prefix, |
| 331 |
[ |
| 332 |
'label' => esc_html__( 'Background', 'wpdirectorykit' ), |
| 333 |
'type' => Controls_Manager::COLOR, |
| 334 |
'selectors' => [ |
| 335 |
$selector => 'background-color: {{VALUE}};', |
| 336 |
], |
| 337 |
] |
| 338 |
); |
| 339 |
|
| 340 |
if(in_array('border',$options)) |
| 341 |
$this->add_group_control( |
| 342 |
Group_Control_Border::get_type(), [ |
| 343 |
'name' => $type.'_border'.$prefix, |
| 344 |
'selector' => $selector, |
| 345 |
] |
| 346 |
); |
| 347 |
|
| 348 |
if(in_array('outline',$options)) { |
| 349 |
|
| 350 |
$this->add_responsive_control( |
| 351 |
$type.'_outline'.$prefix, |
| 352 |
[ |
| 353 |
'label' => esc_html_x( 'Outline Type', 'Outline Control', 'elementor' ), |
| 354 |
'type' => \Elementor\Controls_Manager::SELECT, |
| 355 |
'options' => [ |
| 356 |
'' => esc_html__( 'Default', 'elementor' ), |
| 357 |
'none' => esc_html__( 'None', 'elementor' ), |
| 358 |
'solid' => esc_html_x( 'Solid', 'Outline Control', 'elementor' ), |
| 359 |
'double' => esc_html_x( 'Double', 'Outline Control', 'elementor' ), |
| 360 |
'dotted' => esc_html_x( 'Dotted', 'Outline Control', 'elementor' ), |
| 361 |
'dashed' => esc_html_x( 'Dashed', 'Outline Control', 'elementor' ), |
| 362 |
'groove' => esc_html_x( 'Groove', 'Outline Control', 'elementor' ), |
| 363 |
], |
| 364 |
'selectors' => [ |
| 365 |
$selector => 'outline-style: {{VALUE}};', |
| 366 |
], |
| 367 |
] |
| 368 |
); |
| 369 |
|
| 370 |
$this->add_responsive_control( |
| 371 |
$type.'_outline_width'.$prefix, |
| 372 |
[ |
| 373 |
'label' => esc_html_x( 'Width', 'Outline Control', 'elementor' ), |
| 374 |
'type' => \Elementor\Controls_Manager::NUMBER, |
| 375 |
'default' => '', |
| 376 |
'selectors' => [ |
| 377 |
$selector => 'outline-width: {{VALUE}}px;', |
| 378 |
], |
| 379 |
'condition' => [ |
| 380 |
$type.'_outline'.$prefix.'!' => [ '', 'none' ], |
| 381 |
], |
| 382 |
] |
| 383 |
); |
| 384 |
|
| 385 |
$this->add_responsive_control( |
| 386 |
$type.'_outline_color'.$prefix, |
| 387 |
[ |
| 388 |
'label' => esc_html_x( 'Color', 'Outline Control', 'elementor' ), |
| 389 |
'type' => \Elementor\Controls_Manager::COLOR, |
| 390 |
'default' => '', |
| 391 |
'selectors' => [ |
| 392 |
$selector => 'outline-color: {{VALUE}};', |
| 393 |
], |
| 394 |
'condition' => [ |
| 395 |
$type.'_outline'.$prefix.'!' => [ '', 'none' ], |
| 396 |
], |
| 397 |
] |
| 398 |
); |
| 399 |
|
| 400 |
$this->add_responsive_control( |
| 401 |
$type.'_outline_offset'.$prefix, |
| 402 |
[ |
| 403 |
'label' => esc_html_x( 'Offset', 'Outline Control', 'elementor' ), |
| 404 |
'type' => \Elementor\Controls_Manager::NUMBER, |
| 405 |
'default' => '', |
| 406 |
'selectors' => [ |
| 407 |
$selector => 'outline-offset: {{VALUE}}px;', |
| 408 |
], |
| 409 |
'condition' => [ |
| 410 |
$type.'_outline'.$prefix.'!' => [ '', 'none' ], |
| 411 |
], |
| 412 |
] |
| 413 |
); |
| 414 |
|
| 415 |
} |
| 416 |
|
| 417 |
if(in_array('border_radius',$options)) |
| 418 |
$this->add_responsive_control( |
| 419 |
$type.'_border_radius'.$prefix, |
| 420 |
[ |
| 421 |
'label' => esc_html__( 'Border Radius', 'wpdirectorykit' ), |
| 422 |
'type' => Controls_Manager::DIMENSIONS, |
| 423 |
'size_units' => [ 'px', '%' ], |
| 424 |
'selectors' => [ |
| 425 |
$selector => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 426 |
], |
| 427 |
] |
| 428 |
); |
| 429 |
|
| 430 |
if(in_array('padding',$options)) |
| 431 |
$this->add_responsive_control( |
| 432 |
$type.'_padding'.$prefix, |
| 433 |
[ |
| 434 |
'label' => esc_html__( 'Padding', 'wpdirectorykit' ), |
| 435 |
'type' => Controls_Manager::DIMENSIONS, |
| 436 |
'size_units' => [ 'px', 'em', '%' ], |
| 437 |
'selectors' => [ |
| 438 |
$selector => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 439 |
], |
| 440 |
] |
| 441 |
); |
| 442 |
|
| 443 |
|
| 444 |
if(in_array('margin',$options)) |
| 445 |
$this->add_responsive_control( |
| 446 |
$type.'_margin'.$prefix, |
| 447 |
[ |
| 448 |
'label' => esc_html__( 'Margin', 'wpdirectorykit' ), |
| 449 |
'type' => Controls_Manager::DIMENSIONS, |
| 450 |
'size_units' => [ 'px', 'em', '%' ], |
| 451 |
'selectors' => [ |
| 452 |
$selector => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 453 |
], |
| 454 |
] |
| 455 |
); |
| 456 |
|
| 457 |
if(in_array('shadow',$options)) |
| 458 |
$this->add_group_control( |
| 459 |
Group_Control_Box_Shadow::get_type(), |
| 460 |
[ |
| 461 |
'name' => $type.'_box_shadow'.$prefix, |
| 462 |
'exclude' => [ |
| 463 |
'field_shadow_position', |
| 464 |
], |
| 465 |
'selector' => $selector, |
| 466 |
] |
| 467 |
); |
| 468 |
|
| 469 |
if(in_array('transition',$options)) |
| 470 |
$this->add_responsive_control( |
| 471 |
$type.'_transition'.$prefix, |
| 472 |
[ |
| 473 |
'label' => esc_html__( 'Transition Duration', 'wpdirectorykit' ), |
| 474 |
'type' => Controls_Manager::SLIDER, |
| 475 |
'range' => [ |
| 476 |
'px' => [ |
| 477 |
'min' => 0, |
| 478 |
'max' => 3000, |
| 479 |
], |
| 480 |
], |
| 481 |
'selectors' => [ |
| 482 |
$selector => 'transition-duration: {{SIZE}}ms', |
| 483 |
], |
| 484 |
] |
| 485 |
); |
| 486 |
if(in_array('width',$options)) |
| 487 |
$this->add_responsive_control( |
| 488 |
$type.'_width'.$prefix, |
| 489 |
[ |
| 490 |
'label' => esc_html__( 'Width', 'wpdirectorykit' ), |
| 491 |
'type' => Controls_Manager::SLIDER, |
| 492 |
'range' => [ |
| 493 |
'px' => [ |
| 494 |
'min' => 0, |
| 495 |
'max' => 3000, |
| 496 |
], |
| 497 |
], |
| 498 |
'size_units' => [ 'px', 'em', '%' ], |
| 499 |
'selectors' => [ |
| 500 |
$selector => 'width: {{SIZE}}{{UNIT}}', |
| 501 |
], |
| 502 |
] |
| 503 |
); |
| 504 |
if(in_array('height',$options)) |
| 505 |
$this->add_responsive_control( |
| 506 |
$type.'_height'.$prefix, |
| 507 |
[ |
| 508 |
'label' => esc_html__( 'height', 'wpdirectorykit' ), |
| 509 |
'type' => Controls_Manager::SLIDER, |
| 510 |
'range' => [ |
| 511 |
'px' => [ |
| 512 |
'min' => 0, |
| 513 |
'max' => 3000, |
| 514 |
], |
| 515 |
], |
| 516 |
'size_units' => [ 'px', 'em', '%' ], |
| 517 |
'selectors' => [ |
| 518 |
$selector => 'height: {{SIZE}}{{UNIT}}', |
| 519 |
], |
| 520 |
] |
| 521 |
); |
| 522 |
|
| 523 |
if(in_array('font-size',$options)) |
| 524 |
$this->add_responsive_control( |
| 525 |
$type.'_font_size'.$prefix, |
| 526 |
[ |
| 527 |
'label' => esc_html__( 'Font Size', 'wpdirectorykit' ), |
| 528 |
'type' => Controls_Manager::SLIDER, |
| 529 |
'size_units' => [ 'px', 'em', '%' ], |
| 530 |
'range' => [ |
| 531 |
'px' => [ |
| 532 |
'min' => 0, |
| 533 |
'max' => 150, |
| 534 |
], |
| 535 |
'vw' => [ |
| 536 |
'min' => 0, |
| 537 |
'max' => 100, |
| 538 |
], |
| 539 |
'%' => [ |
| 540 |
'min' => 0, |
| 541 |
'max' => 100, |
| 542 |
], |
| 543 |
], |
| 544 |
'selectors' => [ |
| 545 |
$selector => 'font-size: {{SIZE}}{{UNIT}};', |
| 546 |
], |
| 547 |
] |
| 548 |
); |
| 549 |
|
| 550 |
|
| 551 |
if (in_array('image_size_control', $options)) { |
| 552 |
$this->add_responsive_control( |
| 553 |
$type.'_image_size_control_max_heigth'.$prefix, |
| 554 |
[ |
| 555 |
'label' => esc_html__('Max Height', 'wpdirectorykit'), |
| 556 |
'type' => Controls_Manager::SLIDER, |
| 557 |
'range' => [ |
| 558 |
'px' => [ |
| 559 |
'min' => 10, |
| 560 |
'max' => 1500, |
| 561 |
], |
| 562 |
'vw' => [ |
| 563 |
'min' => 0, |
| 564 |
'max' => 100, |
| 565 |
], |
| 566 |
'%' => [ |
| 567 |
'min' => 0, |
| 568 |
'max' => 100, |
| 569 |
], |
| 570 |
], |
| 571 |
'size_units' => [ 'px', 'vw','%' ], |
| 572 |
'selectors' => [ |
| 573 |
$selector => 'max-height: {{SIZE}}{{UNIT}}', |
| 574 |
], |
| 575 |
|
| 576 |
] |
| 577 |
); |
| 578 |
|
| 579 |
$this->add_responsive_control( |
| 580 |
$type.'_image_size_control_max_width'.$prefix, |
| 581 |
[ |
| 582 |
'label' => esc_html__('Max Width', 'wpdirectorykit'), |
| 583 |
'type' => Controls_Manager::SLIDER, |
| 584 |
'range' => [ |
| 585 |
'px' => [ |
| 586 |
'min' => 10, |
| 587 |
'max' => 1500, |
| 588 |
], |
| 589 |
'vw' => [ |
| 590 |
'min' => 0, |
| 591 |
'max' => 100, |
| 592 |
], |
| 593 |
'%' => [ |
| 594 |
'min' => 0, |
| 595 |
'max' => 100, |
| 596 |
], |
| 597 |
], |
| 598 |
'size_units' => [ 'px', 'vw','%' ], |
| 599 |
'selectors' => [ |
| 600 |
$selector => 'max-width: {{SIZE}}{{UNIT}}', |
| 601 |
], |
| 602 |
|
| 603 |
] |
| 604 |
); |
| 605 |
|
| 606 |
$this->add_responsive_control( |
| 607 |
$type.'_image_size_control_heigth'.$prefix, |
| 608 |
[ |
| 609 |
'label' => esc_html__('Height', 'wpdirectorykit'), |
| 610 |
'type' => Controls_Manager::SLIDER, |
| 611 |
'range' => [ |
| 612 |
'px' => [ |
| 613 |
'min' => 10, |
| 614 |
'max' => 1500, |
| 615 |
], |
| 616 |
'vw' => [ |
| 617 |
'min' => 0, |
| 618 |
'max' => 100, |
| 619 |
], |
| 620 |
'%' => [ |
| 621 |
'min' => 0, |
| 622 |
'max' => 100, |
| 623 |
], |
| 624 |
], |
| 625 |
'size_units' => [ 'px', 'vw','%' ], |
| 626 |
'selectors' => [ |
| 627 |
$selector => 'height: {{SIZE}}{{UNIT}}', |
| 628 |
], |
| 629 |
|
| 630 |
] |
| 631 |
); |
| 632 |
|
| 633 |
$this->add_responsive_control( |
| 634 |
$type.'_image_size_control_width'.$prefix, |
| 635 |
[ |
| 636 |
'label' => esc_html__('Width', 'wpdirectorykit'), |
| 637 |
'type' => Controls_Manager::SLIDER, |
| 638 |
'range' => [ |
| 639 |
'px' => [ |
| 640 |
'min' => 10, |
| 641 |
'max' => 1500, |
| 642 |
], |
| 643 |
'vw' => [ |
| 644 |
'min' => 0, |
| 645 |
'max' => 100, |
| 646 |
], |
| 647 |
'%' => [ |
| 648 |
'min' => 0, |
| 649 |
'max' => 100, |
| 650 |
], |
| 651 |
], |
| 652 |
'size_units' => [ 'px', 'vw','%' ], |
| 653 |
'selectors' => [ |
| 654 |
$selector => 'width: {{SIZE}}{{UNIT}}', |
| 655 |
], |
| 656 |
|
| 657 |
] |
| 658 |
); |
| 659 |
} |
| 660 |
|
| 661 |
|
| 662 |
if (in_array('image_fit_control', $options)) { |
| 663 |
|
| 664 |
|
| 665 |
$this->add_control( |
| 666 |
$type.'_image_fit_control'.$prefix, |
| 667 |
[ |
| 668 |
'label' => esc_html__( 'Fit', 'textdomain' ), |
| 669 |
'type' => \Elementor\Controls_Manager::SELECT, |
| 670 |
'options' => [ |
| 671 |
'' => esc_html__( 'Default', 'textdomain' ), |
| 672 |
'fill' => esc_html__( 'Fill', 'textdomain' ), |
| 673 |
'contain' => esc_html__( 'Contain', 'textdomain' ), |
| 674 |
'cover' => esc_html__( 'Cover', 'textdomain' ), |
| 675 |
'none' => esc_html__( 'None', 'textdomain' ), |
| 676 |
'scale-down' => esc_html__( 'Scale down', 'textdomain' ), |
| 677 |
], |
| 678 |
'selectors' => [ |
| 679 |
$selector => 'object-fit: {{VALUE}};', |
| 680 |
], |
| 681 |
] |
| 682 |
); |
| 683 |
$this->add_control( |
| 684 |
$type.'_image_fit_control_position'.$prefix, |
| 685 |
[ |
| 686 |
'label' => esc_html__( 'Fit Position', 'textdomain' ), |
| 687 |
'type' => \Elementor\Controls_Manager::SELECT, |
| 688 |
'options' => [ |
| 689 |
'' => esc_html__( 'Default', 'textdomain' ), |
| 690 |
'top' => esc_html__( 'Top', 'textdomain' ), |
| 691 |
'bottom' => esc_html__( 'Bottom', 'textdomain' ), |
| 692 |
'left' => esc_html__( 'Left', 'textdomain' ), |
| 693 |
'right' => esc_html__( 'Right', 'textdomain' ), |
| 694 |
'center' => esc_html__( 'Center', 'textdomain' ), |
| 695 |
], |
| 696 |
'selectors' => [ |
| 697 |
$selector => 'object-position: {{VALUE}};', |
| 698 |
], |
| 699 |
] |
| 700 |
); |
| 701 |
|
| 702 |
} |
| 703 |
|
| 704 |
if (in_array('css_filters', $options)) { |
| 705 |
$this->add_group_control( |
| 706 |
\Elementor\Group_Control_Css_Filter::get_type(), |
| 707 |
[ |
| 708 |
'name' => $type.'_css_filters'.$prefix, |
| 709 |
'selector' => $selector, |
| 710 |
] |
| 711 |
); |
| 712 |
} |
| 713 |
|
| 714 |
if (in_array('background_group', $options)) { |
| 715 |
$this->add_group_control( |
| 716 |
\Elementor\Group_Control_Background::get_type(), |
| 717 |
[ |
| 718 |
'name' => $type.'_background_group'.$prefix, |
| 719 |
'label' => esc_html__( 'Background group', 'wpdirectorykit' ), |
| 720 |
'types' => [ 'classic', 'gradient', 'video' ], |
| 721 |
'selector' => $selector, |
| 722 |
] |
| 723 |
); |
| 724 |
$this->add_control( |
| 725 |
$type.'_background_group_hr'.$prefix, |
| 726 |
[ |
| 727 |
'type' => \Elementor\Controls_Manager::DIVIDER, |
| 728 |
] |
| 729 |
); |
| 730 |
} |
| 731 |
|
| 732 |
if (in_array('hover_animation', $options) && $prefix == 'hover') { |
| 733 |
$this->add_control( |
| 734 |
$type.'_hover_animation'.$prefix, |
| 735 |
[ |
| 736 |
'label' => esc_html__( 'Hover Animation', 'wpdirectorykit' ), |
| 737 |
'type' => \Elementor\Controls_Manager::SELECT2, |
| 738 |
'multiple' => false, |
| 739 |
'options' => [ |
| 740 |
'grow' => esc_html__( 'Grow', 'wpdirectorykit' ), |
| 741 |
'shrink' => esc_html__( 'Shrink', 'wpdirectorykit' ), |
| 742 |
'pulse' => esc_html__( 'Pulse', 'wpdirectorykit' ), |
| 743 |
'pulse-grow' => esc_html__( 'Pulse Grow', 'wpdirectorykit' ), |
| 744 |
'pulse-shrink' => esc_html__( 'Pulse Shrink', 'wpdirectorykit' ), |
| 745 |
'push' => esc_html__( 'Push', 'wpdirectorykit' ), |
| 746 |
'pop' => esc_html__( 'Pop', 'wpdirectorykit' ), |
| 747 |
'bounce-in' => esc_html__( 'Bounce In', 'wpdirectorykit' ), |
| 748 |
'bounce-out' => esc_html__( 'Bounce Out', 'wpdirectorykit' ), |
| 749 |
'rotate' => esc_html__( 'Rotate', 'wpdirectorykit' ), |
| 750 |
'grow-rotate' => esc_html__( 'Grow Rotate', 'wpdirectorykit' ), |
| 751 |
'float' => esc_html__( 'Float', 'wpdirectorykit' ), |
| 752 |
'sink' => esc_html__( 'Sink', 'wpdirectorykit' ), |
| 753 |
'bob' => esc_html__( 'Bob', 'wpdirectorykit' ), |
| 754 |
'hang' => esc_html__( 'Hang', 'wpdirectorykit' ), |
| 755 |
'skew' => esc_html__( 'Skew', 'wpdirectorykit' ), |
| 756 |
'skew-forward' => esc_html__( 'Skew Forward', 'wpdirectorykit' ), |
| 757 |
'skew-backward' => esc_html__( 'Skew Backward', 'wpdirectorykit' ), |
| 758 |
'wobble-vertical' => esc_html__( 'Wobble Vertical', 'wpdirectorykit' ), |
| 759 |
'wobble-horizontal' => esc_html__( 'wobble Horizontal', 'wpdirectorykit' ), |
| 760 |
'wobble-to-bottom-right' => esc_html__( 'Wobble To Bottom Right', 'wpdirectorykit' ), |
| 761 |
'wobble-to-top-right' => esc_html__( 'Wobble To Top Eight', 'wpdirectorykit' ), |
| 762 |
'wobble-top' => esc_html__( 'Wobble Top', 'wpdirectorykit' ), |
| 763 |
'wobble-bottom' => esc_html__( 'Wobble Bottom', 'wpdirectorykit' ), |
| 764 |
'wobble-skew' => esc_html__( 'Wobble Skew', 'wpdirectorykit' ), |
| 765 |
'buzz' => esc_html__( 'Buzz', 'wpdirectorykit' ), |
| 766 |
'buzz-out' => esc_html__( 'Buzz Out', 'wpdirectorykit' ), |
| 767 |
], |
| 768 |
'selectors_dictionary' => [ |
| 769 |
'grow' => 'animation-name: wdk-hover-animation-grow;animation-duration: 0.3s;animation-timing-function: linear;animation-iteration-count: 1;', |
| 770 |
'shrink' => 'animation-name: wdk-hover-animation-shrink;animation-duration: 0.3s;animation-timing-function: linear;animation-iteration-count: 1;', |
| 771 |
'pulse' => 'animation-name: wdk-hover-animation-pulse;animation-duration: 1s; animation-timing-function: linear;animation-iteration-count: infinite;', |
| 772 |
'pulse-grow' => 'animation-name: wdk-hover-animation-pulse-grow; animation-duration: 0.3s;animation-timing-function: linear;animation-iteration-count: infinite;animation-direction: alternate;', |
| 773 |
'pulse-shrink' => 'animation-name: wdk-hover-animation-pulse-shrink;animation-duration: 0.3s;animation-timing-function: linear;animation-iteration-count: infinite;animation-direction: alternate;', |
| 774 |
'push' => 'animation-name: wdk-hover-animation-push;animation-duration: 0.3s;animation-timing-function: linear;animation-iteration-count: 1;', |
| 775 |
'pop' => 'animation-name: wdk-hover-animation-pop;animation-duration: 0.3s;animation-timing-function: linear;animation-iteration-count: 1;', |
| 776 |
'bounce-in' => 'animation-name: wdk-hover-animation-bounce-in;animation-duration: 0.5s;animation-timing-function: cubic-bezier(0.47, 2.02, 0.31, -0.36);;animation-iteration-count: 1;', |
| 777 |
'bounce-out' => 'animation-name: wdk-hover-animation-bounce-out;animation-duration: 0.5s;animation-timing-function: cubic-bezier(0.47, 2.02, 0.31, -0.36);animation-iteration-count: 1;', |
| 778 |
'rotate' => 'animation-name: wdk-hover-animation-rotate;animation-duration: 0.3s;animation-timing-function: linear;animation-iteration-count: 1;', |
| 779 |
'grow-rotate' => 'animation-name: wdk-hover-animation-grow;animation-duration: 0.3s;animation-timing-function: linear;animation-iteration-count: 1;', |
| 780 |
'float' => 'animation-name: wdk-hover-animation-float;animation-duration: 0.3s;animation-timing-function: ease-out;animation-iteration-count: 1;', |
| 781 |
'sink' => 'animation-name: wdk-hover-animation-sink;animation-duration: 0.3s;animation-timing-function: ease-out;animation-iteration-count: 1;', |
| 782 |
'bob' => 'animation-name: wdk-hover-animation-bob-float, wdk-hover-animation-bob;animation-duration: .3s, 1.5s;animation-delay: 0s, .3s;animation-timing-function: ease-out, ease-in-out;animation-iteration-count: 1, infinite;animation-fill-mode: forwards;animation-direction: normal, alternate;', |
| 783 |
'hang' => 'animation-name: wdk-hover-animation-hang-sink, wdk-hover-animation-hang;animation-duration: .3s, 1.5s;animation-delay: 0s, .3s;animation-timing-function: ease-out, ease-in-out;animation-iteration-count: 1, infinite;animation-fill-mode: forwards;animation-direction: normal, alternate;', |
| 784 |
'skew' => 'animation-name: wdk-hover-animation-skew;animation-duration: 0.3s;animation-timing-function: ease-out;animation-iteration-count: 1;', |
| 785 |
'skew-forward' => 'animation-name: wdk-hover-animation-skew-forward;animation-duration: 0.3s;animation-timing-function: ease-out;animation-iteration-count: 1;transform-origin: 0 100%;', |
| 786 |
'skew-backward' => 'animation-name: wdk-hover-animation-skew-backward;animation-duration: 0.3s;animation-timing-function: ease-out;animation-iteration-count: 1;transform-origin: 0 100%;', |
| 787 |
'wobble-vertical' => 'animation-name: wdk-hover-animation-wobble-vertical;animation-duration: 1s;animation-timing-function: ease-in-out; animation-iteration-count: 1;', |
| 788 |
'wobble-horizontal' => 'animation-name: wdk-hover-animation-wobble-horizontal; animation-duration: 1s;animation-timing-function: ease-in-out;animation-iteration-count: 1;', |
| 789 |
'wobble-to-bottom-right' => 'animation-name: wdk-hover-animation-wobble-to-bottom-right;animation-duration: 1s;animation-timing-function: ease-in-out;animation-iteration-count: 1;', |
| 790 |
'wobble-to-top-right' => 'animation-name: wdk-hover-animation-wobble-to-top-right;animation-duration: 1s;animation-timing-function: ease-in-out;animation-iteration-count: 1;', |
| 791 |
'wobble-top' => 'transform-origin: 0 100%;animation-name: wdk-hover-animation-wobble-top;animation-duration: 1s;animation-timing-function: ease-in-out;animation-iteration-count: 1;', |
| 792 |
'wobble-bottom' => 'transform-origin: 100% 0;animation-name: wdk-hover-animation-wobble-bottom;animation-duration: 1s;animation-timing-function: ease-in-out;animation-iteration-count: 1;', |
| 793 |
'wobble-skew' => 'animation-name: wdk-hover-animation-wobble-skew;animation-duration: 1s;animation-timing-function: ease-in-out;animation-iteration-count: 1;', |
| 794 |
'buzz' => 'animation-name: wdk-hover-animation-buzz;animation-duration: 0.15s;animation-timing-function: linear;animation-iteration-count: infinite;', |
| 795 |
'buzz-out' => 'animation-name: wdk-hover-animation-buzz-out;animation-duration: 0.75s;animation-timing-function: linear;animation-iteration-count: 1;', |
| 796 |
], |
| 797 |
'default' => '', |
| 798 |
'selectors' => [ |
| 799 |
$selector => '{{VALUE}};', |
| 800 |
], |
| 801 |
'render_type' => 'template' |
| 802 |
] |
| 803 |
); |
| 804 |
} |
| 805 |
|
| 806 |
if($tabs_enable) |
| 807 |
$this->end_controls_tab(); |
| 808 |
} |
| 809 |
|
| 810 |
|
| 811 |
/** |
| 812 |
* @param $post_css Post |
| 813 |
*/ |
| 814 |
public function add_page_settings_css() { |
| 815 |
$settings = $this->get_settings(); |
| 816 |
|
| 817 |
if(!isset($settings['custom_css'])) |
| 818 |
return; |
| 819 |
|
| 820 |
$custom_css = $settings['custom_css']; |
| 821 |
$custom_css = trim( $custom_css ); |
| 822 |
|
| 823 |
if ( empty( $custom_css ) ) { |
| 824 |
return; |
| 825 |
} |
| 826 |
|
| 827 |
// Add a css comment |
| 828 |
$custom_css_file = '/* Start custom CSS for page-settings */' . |
| 829 |
str_replace( 'selector', '#wdk_el_' . $this->get_id_int(), $custom_css ). |
| 830 |
str_replace( 'selector', '.elementor-element.elementor-element-' . $this->get_id(), $custom_css ). |
| 831 |
'/* End custom CSS */'; |
| 832 |
|
| 833 |
|
| 834 |
echo '<style>'.wmvc_xss_clean($custom_css_file).'</style>'; |
| 835 |
} |
| 836 |
|
| 837 |
private function break_css($css) |
| 838 |
{ |
| 839 |
|
| 840 |
$results = array(); |
| 841 |
preg_match_all('/(.+?)\s?\{\s?(.+?)\s?\}/', $css, $matches); |
| 842 |
foreach($matches[0] AS $i=>$original) |
| 843 |
foreach(explode(';', $matches[2][$i]) AS $attr) |
| 844 |
if (strlen(trim($attr)) > 0) // for missing semicolon on last element, which is legal |
| 845 |
{ |
| 846 |
list($name, $value) = explode(':', $attr); |
| 847 |
$results[$matches[1][$i]][trim($name)] = trim($value); |
| 848 |
} |
| 849 |
return $results; |
| 850 |
} |
| 851 |
|
| 852 |
public function generate_icon($icon, $attributes = [], $tag = 'i' ){ |
| 853 |
if ( empty( $icon['library'] ) ) { |
| 854 |
return false; |
| 855 |
} |
| 856 |
$output = ''; |
| 857 |
// handler SVG Icon |
| 858 |
if ( 'svg' === $icon['library'] ) { |
| 859 |
$output = \Elementor\Icons_Manager::render_uploaded_svg_icon( $icon['value'] ); |
| 860 |
} else { |
| 861 |
$output = $this->render_icon_html( $icon, $attributes, $tag ); |
| 862 |
} |
| 863 |
|
| 864 |
return $output; |
| 865 |
} |
| 866 |
|
| 867 |
public function render_icon_html( $icon, $attributes = [], $tag = 'i' ) { |
| 868 |
$icon_types = \Elementor\Icons_Manager::get_icon_manager_tabs(); |
| 869 |
if ( isset( $icon_types[ $icon['library'] ]['render_callback'] ) && is_callable( $icon_types[ $icon['library'] ]['render_callback'] ) ) { |
| 870 |
return call_user_func_array( $icon_types[ $icon['library'] ]['render_callback'], [ $icon, $attributes, $tag ] ); |
| 871 |
} |
| 872 |
|
| 873 |
if ( empty( $attributes['class'] ) ) { |
| 874 |
$attributes['class'] = $icon['value']; |
| 875 |
} else { |
| 876 |
if ( is_array( $attributes['class'] ) ) { |
| 877 |
$attributes['class'][] = $icon['value']; |
| 878 |
} else { |
| 879 |
$attributes['class'] .= ' ' . $icon['value']; |
| 880 |
} |
| 881 |
} |
| 882 |
return '<' . $tag . ' ' . Utils::render_html_attributes( $attributes ) . '></' . $tag . '>'; |
| 883 |
} |
| 884 |
|
| 885 |
public static function render_svg_icon( $value ) { |
| 886 |
if ( ! isset( $value['id'] ) ) { |
| 887 |
return ''; |
| 888 |
} |
| 889 |
|
| 890 |
return Svg_Handler::get_inline_svg( $value['id'] ); |
| 891 |
} |
| 892 |
|
| 893 |
public function enqueue_styles_scripts() { |
| 894 |
|
| 895 |
} |
| 896 |
|
| 897 |
public function is_edit_mode_load() { |
| 898 |
|
| 899 |
if (isset($this->is_edit_mode) && null !== $this->is_edit_mode ) { |
| 900 |
return $this->is_edit_mode; |
| 901 |
} |
| 902 |
|
| 903 |
// Ajax request as Editor mode |
| 904 |
$actions = array( |
| 905 |
'elementor', |
| 906 |
// Templates |
| 907 |
'elementor_get_templates', |
| 908 |
'elementor_save_template', |
| 909 |
'elementor_get_template', |
| 910 |
'elementor_delete_template', |
| 911 |
'elementor_export_template', |
| 912 |
'elementor_import_template', |
| 913 |
); |
| 914 |
|
| 915 |
if (isset($_REQUEST['action']) && in_array($_REQUEST['action'], $actions)) { |
| 916 |
return true; |
| 917 |
} |
| 918 |
|
| 919 |
if (isset($_REQUEST['elementor-preview'])) { |
| 920 |
return true; |
| 921 |
} |
| 922 |
|
| 923 |
return false; |
| 924 |
} |
| 925 |
|
| 926 |
|
| 927 |
|
| 928 |
/** |
| 929 |
* Adding Go Premium message to all widgets |
| 930 |
* |
| 931 |
* @since 1.4.2 |
| 932 |
*/ |
| 933 |
public function insert_pro_message($section = 1) |
| 934 |
{ |
| 935 |
if(!function_exists('run_wdk_membership')){ |
| 936 |
$this->start_controls_section( |
| 937 |
'wdk_section_pro', |
| 938 |
[ |
| 939 |
'label' => __('Go Premium for More Features', 'wpdirectorykit'), |
| 940 |
'tab' => $section, |
| 941 |
] |
| 942 |
); |
| 943 |
|
| 944 |
$this->add_control( |
| 945 |
'wdk_control_get_pro', |
| 946 |
[ |
| 947 |
'label' => __('Unlock more possibilities', 'wpdirectorykit'), |
| 948 |
'type' => \Elementor\Controls_Manager::CHOOSE, |
| 949 |
'options' => [ |
| 950 |
'1' => [ |
| 951 |
'title' => '', |
| 952 |
'icon' => 'fa fa-unlock-alt', |
| 953 |
], |
| 954 |
], |
| 955 |
'default' => '1', |
| 956 |
'toggle' => false, |
| 957 |
'description' => '<span class="wdk_control_get_pro">'.wdk_sprintf(esc_html__(' %1$sGet our Addons%2$s for more awesome elements and powerful features!','wpdirectorykit'),'<a href="//wpdirectorykit.com/plugins.html" target="_blank">','</a>').'</span>' |
| 958 |
|
| 959 |
] |
| 960 |
); |
| 961 |
|
| 962 |
$this->end_controls_section(); |
| 963 |
} |
| 964 |
} |
| 965 |
|
| 966 |
public function editing_element($key, $toolbar = 'basic', $attr = array()) { |
| 967 |
$this->add_inline_editing_attributes( $key, $toolbar ); |
| 968 |
foreach ($attr as $key_attr => $value_attr) { |
| 969 |
$this->add_render_attribute( $key, $key_attr, $value_attr ); |
| 970 |
} |
| 971 |
echo $this->get_render_attribute_string( $key ); |
| 972 |
} |
| 973 |
|
| 974 |
} |