| 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('border_radius',$options)) |
| 349 |
$this->add_responsive_control( |
| 350 |
$type.'_border_radius'.$prefix, |
| 351 |
[ |
| 352 |
'label' => esc_html__( 'Border Radius', 'wpdirectorykit' ), |
| 353 |
'type' => Controls_Manager::DIMENSIONS, |
| 354 |
'size_units' => [ 'px', '%' ], |
| 355 |
'selectors' => [ |
| 356 |
$selector => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 357 |
], |
| 358 |
] |
| 359 |
); |
| 360 |
|
| 361 |
if(in_array('padding',$options)) |
| 362 |
$this->add_responsive_control( |
| 363 |
$type.'_padding'.$prefix, |
| 364 |
[ |
| 365 |
'label' => esc_html__( 'Padding', 'wpdirectorykit' ), |
| 366 |
'type' => Controls_Manager::DIMENSIONS, |
| 367 |
'size_units' => [ 'px', 'em', '%' ], |
| 368 |
'selectors' => [ |
| 369 |
$selector => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 370 |
], |
| 371 |
] |
| 372 |
); |
| 373 |
|
| 374 |
|
| 375 |
if(in_array('margin',$options)) |
| 376 |
$this->add_responsive_control( |
| 377 |
$type.'_margin'.$prefix, |
| 378 |
[ |
| 379 |
'label' => esc_html__( 'Margin', 'wpdirectorykit' ), |
| 380 |
'type' => Controls_Manager::DIMENSIONS, |
| 381 |
'size_units' => [ 'px', 'em', '%' ], |
| 382 |
'selectors' => [ |
| 383 |
$selector => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 384 |
], |
| 385 |
] |
| 386 |
); |
| 387 |
|
| 388 |
if(in_array('shadow',$options)) |
| 389 |
$this->add_group_control( |
| 390 |
Group_Control_Box_Shadow::get_type(), |
| 391 |
[ |
| 392 |
'name' => $type.'_box_shadow'.$prefix, |
| 393 |
'exclude' => [ |
| 394 |
'field_shadow_position', |
| 395 |
], |
| 396 |
'selector' => $selector, |
| 397 |
] |
| 398 |
); |
| 399 |
|
| 400 |
if(in_array('transition',$options)) |
| 401 |
$this->add_responsive_control( |
| 402 |
$type.'_transition'.$prefix, |
| 403 |
[ |
| 404 |
'label' => esc_html__( 'Transition Duration', 'wpdirectorykit' ), |
| 405 |
'type' => Controls_Manager::SLIDER, |
| 406 |
'range' => [ |
| 407 |
'px' => [ |
| 408 |
'min' => 0, |
| 409 |
'max' => 3000, |
| 410 |
], |
| 411 |
], |
| 412 |
'selectors' => [ |
| 413 |
$selector => 'transition-duration: {{SIZE}}ms', |
| 414 |
], |
| 415 |
] |
| 416 |
); |
| 417 |
if(in_array('width',$options)) |
| 418 |
$this->add_responsive_control( |
| 419 |
$type.'_width'.$prefix, |
| 420 |
[ |
| 421 |
'label' => esc_html__( 'Width', 'wpdirectorykit' ), |
| 422 |
'type' => Controls_Manager::SLIDER, |
| 423 |
'range' => [ |
| 424 |
'px' => [ |
| 425 |
'min' => 0, |
| 426 |
'max' => 3000, |
| 427 |
], |
| 428 |
], |
| 429 |
'size_units' => [ 'px', 'em', '%' ], |
| 430 |
'selectors' => [ |
| 431 |
$selector => 'width: {{SIZE}}{{UNIT}}', |
| 432 |
], |
| 433 |
] |
| 434 |
); |
| 435 |
if(in_array('height',$options)) |
| 436 |
$this->add_responsive_control( |
| 437 |
$type.'_height'.$prefix, |
| 438 |
[ |
| 439 |
'label' => esc_html__( 'height', 'wpdirectorykit' ), |
| 440 |
'type' => Controls_Manager::SLIDER, |
| 441 |
'range' => [ |
| 442 |
'px' => [ |
| 443 |
'min' => 0, |
| 444 |
'max' => 3000, |
| 445 |
], |
| 446 |
], |
| 447 |
'size_units' => [ 'px', 'em', '%' ], |
| 448 |
'selectors' => [ |
| 449 |
$selector => 'height: {{SIZE}}{{UNIT}}', |
| 450 |
], |
| 451 |
] |
| 452 |
); |
| 453 |
|
| 454 |
if(in_array('font-size',$options)) |
| 455 |
$this->add_responsive_control( |
| 456 |
$type.'_font_size'.$prefix, |
| 457 |
[ |
| 458 |
'label' => esc_html__( 'Font Size', 'wpdirectorykit' ), |
| 459 |
'type' => Controls_Manager::SLIDER, |
| 460 |
'size_units' => [ 'px', 'em', '%' ], |
| 461 |
'range' => [ |
| 462 |
'px' => [ |
| 463 |
'min' => 0, |
| 464 |
'max' => 150, |
| 465 |
], |
| 466 |
'vw' => [ |
| 467 |
'min' => 0, |
| 468 |
'max' => 100, |
| 469 |
], |
| 470 |
'%' => [ |
| 471 |
'min' => 0, |
| 472 |
'max' => 100, |
| 473 |
], |
| 474 |
], |
| 475 |
'selectors' => [ |
| 476 |
$selector => 'font-size: {{SIZE}}{{UNIT}};', |
| 477 |
], |
| 478 |
] |
| 479 |
); |
| 480 |
|
| 481 |
|
| 482 |
if (in_array('image_size_control', $options)) { |
| 483 |
$this->add_responsive_control( |
| 484 |
$type.'_image_size_control_max_heigth'.$prefix, |
| 485 |
[ |
| 486 |
'label' => esc_html__('Max Height', 'wpdirectorykit'), |
| 487 |
'type' => Controls_Manager::SLIDER, |
| 488 |
'range' => [ |
| 489 |
'px' => [ |
| 490 |
'min' => 10, |
| 491 |
'max' => 1500, |
| 492 |
], |
| 493 |
'vw' => [ |
| 494 |
'min' => 0, |
| 495 |
'max' => 100, |
| 496 |
], |
| 497 |
'%' => [ |
| 498 |
'min' => 0, |
| 499 |
'max' => 100, |
| 500 |
], |
| 501 |
], |
| 502 |
'size_units' => [ 'px', 'vw','%' ], |
| 503 |
'selectors' => [ |
| 504 |
$selector => 'max-height: {{SIZE}}{{UNIT}}', |
| 505 |
], |
| 506 |
|
| 507 |
] |
| 508 |
); |
| 509 |
|
| 510 |
$this->add_responsive_control( |
| 511 |
$type.'_image_size_control_max_width'.$prefix, |
| 512 |
[ |
| 513 |
'label' => esc_html__('Max Width', 'wpdirectorykit'), |
| 514 |
'type' => Controls_Manager::SLIDER, |
| 515 |
'range' => [ |
| 516 |
'px' => [ |
| 517 |
'min' => 10, |
| 518 |
'max' => 1500, |
| 519 |
], |
| 520 |
'vw' => [ |
| 521 |
'min' => 0, |
| 522 |
'max' => 100, |
| 523 |
], |
| 524 |
'%' => [ |
| 525 |
'min' => 0, |
| 526 |
'max' => 100, |
| 527 |
], |
| 528 |
], |
| 529 |
'size_units' => [ 'px', 'vw','%' ], |
| 530 |
'selectors' => [ |
| 531 |
$selector => 'max-width: {{SIZE}}{{UNIT}}', |
| 532 |
], |
| 533 |
|
| 534 |
] |
| 535 |
); |
| 536 |
|
| 537 |
$this->add_responsive_control( |
| 538 |
$type.'_image_size_control_heigth'.$prefix, |
| 539 |
[ |
| 540 |
'label' => esc_html__('Height', 'wpdirectorykit'), |
| 541 |
'type' => Controls_Manager::SLIDER, |
| 542 |
'range' => [ |
| 543 |
'px' => [ |
| 544 |
'min' => 10, |
| 545 |
'max' => 1500, |
| 546 |
], |
| 547 |
'vw' => [ |
| 548 |
'min' => 0, |
| 549 |
'max' => 100, |
| 550 |
], |
| 551 |
'%' => [ |
| 552 |
'min' => 0, |
| 553 |
'max' => 100, |
| 554 |
], |
| 555 |
], |
| 556 |
'size_units' => [ 'px', 'vw','%' ], |
| 557 |
'selectors' => [ |
| 558 |
$selector => 'height: {{SIZE}}{{UNIT}}', |
| 559 |
], |
| 560 |
|
| 561 |
] |
| 562 |
); |
| 563 |
|
| 564 |
$this->add_responsive_control( |
| 565 |
$type.'_image_size_control_width'.$prefix, |
| 566 |
[ |
| 567 |
'label' => esc_html__('Width', 'wpdirectorykit'), |
| 568 |
'type' => Controls_Manager::SLIDER, |
| 569 |
'range' => [ |
| 570 |
'px' => [ |
| 571 |
'min' => 10, |
| 572 |
'max' => 1500, |
| 573 |
], |
| 574 |
'vw' => [ |
| 575 |
'min' => 0, |
| 576 |
'max' => 100, |
| 577 |
], |
| 578 |
'%' => [ |
| 579 |
'min' => 0, |
| 580 |
'max' => 100, |
| 581 |
], |
| 582 |
], |
| 583 |
'size_units' => [ 'px', 'vw','%' ], |
| 584 |
'selectors' => [ |
| 585 |
$selector => 'width: {{SIZE}}{{UNIT}}', |
| 586 |
], |
| 587 |
|
| 588 |
] |
| 589 |
); |
| 590 |
} |
| 591 |
|
| 592 |
|
| 593 |
if (in_array('image_fit_control', $options)) { |
| 594 |
|
| 595 |
|
| 596 |
$this->add_control( |
| 597 |
$type.'_image_fit_control'.$prefix, |
| 598 |
[ |
| 599 |
'label' => esc_html__( 'Fit', 'textdomain' ), |
| 600 |
'type' => \Elementor\Controls_Manager::SELECT, |
| 601 |
'options' => [ |
| 602 |
'' => esc_html__( 'Default', 'textdomain' ), |
| 603 |
'fill' => esc_html__( 'Fill', 'textdomain' ), |
| 604 |
'contain' => esc_html__( 'Contain', 'textdomain' ), |
| 605 |
'cover' => esc_html__( 'Cover', 'textdomain' ), |
| 606 |
'none' => esc_html__( 'None', 'textdomain' ), |
| 607 |
'scale-down' => esc_html__( 'Scale down', 'textdomain' ), |
| 608 |
], |
| 609 |
'selectors' => [ |
| 610 |
$selector => 'object-fit: {{VALUE}};', |
| 611 |
], |
| 612 |
] |
| 613 |
); |
| 614 |
$this->add_control( |
| 615 |
$type.'_image_fit_control_position'.$prefix, |
| 616 |
[ |
| 617 |
'label' => esc_html__( 'Fit Position', 'textdomain' ), |
| 618 |
'type' => \Elementor\Controls_Manager::SELECT, |
| 619 |
'options' => [ |
| 620 |
'' => esc_html__( 'Default', 'textdomain' ), |
| 621 |
'top' => esc_html__( 'Top', 'textdomain' ), |
| 622 |
'bottom' => esc_html__( 'Bottom', 'textdomain' ), |
| 623 |
'left' => esc_html__( 'Left', 'textdomain' ), |
| 624 |
'right' => esc_html__( 'Right', 'textdomain' ), |
| 625 |
'center' => esc_html__( 'Center', 'textdomain' ), |
| 626 |
], |
| 627 |
'selectors' => [ |
| 628 |
$selector => 'object-position: {{VALUE}};', |
| 629 |
], |
| 630 |
] |
| 631 |
); |
| 632 |
|
| 633 |
} |
| 634 |
|
| 635 |
if (in_array('css_filters', $options)) { |
| 636 |
$this->add_group_control( |
| 637 |
\Elementor\Group_Control_Css_Filter::get_type(), |
| 638 |
[ |
| 639 |
'name' => $type.'_css_filters'.$prefix, |
| 640 |
'selector' => $selector, |
| 641 |
] |
| 642 |
); |
| 643 |
} |
| 644 |
|
| 645 |
if (in_array('background_group', $options)) { |
| 646 |
$this->add_group_control( |
| 647 |
\Elementor\Group_Control_Background::get_type(), |
| 648 |
[ |
| 649 |
'name' => $type.'_background_group'.$prefix, |
| 650 |
'label' => esc_html__( 'Background group', 'wpdirectorykit' ), |
| 651 |
'types' => [ 'classic', 'gradient', 'video' ], |
| 652 |
'selector' => $selector, |
| 653 |
] |
| 654 |
); |
| 655 |
$this->add_control( |
| 656 |
$type.'_background_group_hr'.$prefix, |
| 657 |
[ |
| 658 |
'type' => \Elementor\Controls_Manager::DIVIDER, |
| 659 |
] |
| 660 |
); |
| 661 |
} |
| 662 |
|
| 663 |
if (in_array('hover_animation', $options) && $prefix == 'hover') { |
| 664 |
$this->add_control( |
| 665 |
$type.'_hover_animation'.$prefix, |
| 666 |
[ |
| 667 |
'label' => esc_html__( 'Hover Animation', 'wpdirectorykit' ), |
| 668 |
'type' => \Elementor\Controls_Manager::SELECT2, |
| 669 |
'multiple' => false, |
| 670 |
'options' => [ |
| 671 |
'grow' => esc_html__( 'Grow', 'wpdirectorykit' ), |
| 672 |
'shrink' => esc_html__( 'Shrink', 'wpdirectorykit' ), |
| 673 |
'pulse' => esc_html__( 'Pulse', 'wpdirectorykit' ), |
| 674 |
'pulse-grow' => esc_html__( 'Pulse Grow', 'wpdirectorykit' ), |
| 675 |
'pulse-shrink' => esc_html__( 'Pulse Shrink', 'wpdirectorykit' ), |
| 676 |
'push' => esc_html__( 'Push', 'wpdirectorykit' ), |
| 677 |
'pop' => esc_html__( 'Pop', 'wpdirectorykit' ), |
| 678 |
'bounce-in' => esc_html__( 'Bounce In', 'wpdirectorykit' ), |
| 679 |
'bounce-out' => esc_html__( 'Bounce Out', 'wpdirectorykit' ), |
| 680 |
'rotate' => esc_html__( 'Rotate', 'wpdirectorykit' ), |
| 681 |
'grow-rotate' => esc_html__( 'Grow Rotate', 'wpdirectorykit' ), |
| 682 |
'float' => esc_html__( 'Float', 'wpdirectorykit' ), |
| 683 |
'sink' => esc_html__( 'Sink', 'wpdirectorykit' ), |
| 684 |
'bob' => esc_html__( 'Bob', 'wpdirectorykit' ), |
| 685 |
'hang' => esc_html__( 'Hang', 'wpdirectorykit' ), |
| 686 |
'skew' => esc_html__( 'Skew', 'wpdirectorykit' ), |
| 687 |
'skew-forward' => esc_html__( 'Skew Forward', 'wpdirectorykit' ), |
| 688 |
'skew-backward' => esc_html__( 'Skew Backward', 'wpdirectorykit' ), |
| 689 |
'wobble-vertical' => esc_html__( 'Wobble Vertical', 'wpdirectorykit' ), |
| 690 |
'wobble-horizontal' => esc_html__( 'wobble Horizontal', 'wpdirectorykit' ), |
| 691 |
'wobble-to-bottom-right' => esc_html__( 'Wobble To Bottom Right', 'wpdirectorykit' ), |
| 692 |
'wobble-to-top-right' => esc_html__( 'Wobble To Top Eight', 'wpdirectorykit' ), |
| 693 |
'wobble-top' => esc_html__( 'Wobble Top', 'wpdirectorykit' ), |
| 694 |
'wobble-bottom' => esc_html__( 'Wobble Bottom', 'wpdirectorykit' ), |
| 695 |
'wobble-skew' => esc_html__( 'Wobble Skew', 'wpdirectorykit' ), |
| 696 |
'buzz' => esc_html__( 'Buzz', 'wpdirectorykit' ), |
| 697 |
'buzz-out' => esc_html__( 'Buzz Out', 'wpdirectorykit' ), |
| 698 |
], |
| 699 |
'selectors_dictionary' => [ |
| 700 |
'grow' => 'animation-name: wdk-hover-animation-grow;animation-duration: 0.3s;animation-timing-function: linear;animation-iteration-count: 1;', |
| 701 |
'shrink' => 'animation-name: wdk-hover-animation-shrink;animation-duration: 0.3s;animation-timing-function: linear;animation-iteration-count: 1;', |
| 702 |
'pulse' => 'animation-name: wdk-hover-animation-pulse;animation-duration: 1s; animation-timing-function: linear;animation-iteration-count: infinite;', |
| 703 |
'pulse-grow' => 'animation-name: wdk-hover-animation-pulse-grow; animation-duration: 0.3s;animation-timing-function: linear;animation-iteration-count: infinite;animation-direction: alternate;', |
| 704 |
'pulse-shrink' => 'animation-name: wdk-hover-animation-pulse-shrink;animation-duration: 0.3s;animation-timing-function: linear;animation-iteration-count: infinite;animation-direction: alternate;', |
| 705 |
'push' => 'animation-name: wdk-hover-animation-push;animation-duration: 0.3s;animation-timing-function: linear;animation-iteration-count: 1;', |
| 706 |
'pop' => 'animation-name: wdk-hover-animation-pop;animation-duration: 0.3s;animation-timing-function: linear;animation-iteration-count: 1;', |
| 707 |
'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;', |
| 708 |
'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;', |
| 709 |
'rotate' => 'animation-name: wdk-hover-animation-rotate;animation-duration: 0.3s;animation-timing-function: linear;animation-iteration-count: 1;', |
| 710 |
'grow-rotate' => 'animation-name: wdk-hover-animation-grow;animation-duration: 0.3s;animation-timing-function: linear;animation-iteration-count: 1;', |
| 711 |
'float' => 'animation-name: wdk-hover-animation-float;animation-duration: 0.3s;animation-timing-function: ease-out;animation-iteration-count: 1;', |
| 712 |
'sink' => 'animation-name: wdk-hover-animation-sink;animation-duration: 0.3s;animation-timing-function: ease-out;animation-iteration-count: 1;', |
| 713 |
'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;', |
| 714 |
'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;', |
| 715 |
'skew' => 'animation-name: wdk-hover-animation-skew;animation-duration: 0.3s;animation-timing-function: ease-out;animation-iteration-count: 1;', |
| 716 |
'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%;', |
| 717 |
'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%;', |
| 718 |
'wobble-vertical' => 'animation-name: wdk-hover-animation-wobble-vertical;animation-duration: 1s;animation-timing-function: ease-in-out; animation-iteration-count: 1;', |
| 719 |
'wobble-horizontal' => 'animation-name: wdk-hover-animation-wobble-horizontal; animation-duration: 1s;animation-timing-function: ease-in-out;animation-iteration-count: 1;', |
| 720 |
'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;', |
| 721 |
'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;', |
| 722 |
'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;', |
| 723 |
'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;', |
| 724 |
'wobble-skew' => 'animation-name: wdk-hover-animation-wobble-skew;animation-duration: 1s;animation-timing-function: ease-in-out;animation-iteration-count: 1;', |
| 725 |
'buzz' => 'animation-name: wdk-hover-animation-buzz;animation-duration: 0.15s;animation-timing-function: linear;animation-iteration-count: infinite;', |
| 726 |
'buzz-out' => 'animation-name: wdk-hover-animation-buzz-out;animation-duration: 0.75s;animation-timing-function: linear;animation-iteration-count: 1;', |
| 727 |
], |
| 728 |
'default' => '', |
| 729 |
'selectors' => [ |
| 730 |
$selector => '{{VALUE}};', |
| 731 |
], |
| 732 |
'render_type' => 'template' |
| 733 |
] |
| 734 |
); |
| 735 |
} |
| 736 |
|
| 737 |
if($tabs_enable) |
| 738 |
$this->end_controls_tab(); |
| 739 |
} |
| 740 |
|
| 741 |
|
| 742 |
/** |
| 743 |
* @param $post_css Post |
| 744 |
*/ |
| 745 |
public function add_page_settings_css() { |
| 746 |
$settings = $this->get_settings(); |
| 747 |
$custom_css = $settings['custom_css']; |
| 748 |
$custom_css = trim( $custom_css ); |
| 749 |
|
| 750 |
if ( empty( $custom_css ) ) { |
| 751 |
return; |
| 752 |
} |
| 753 |
|
| 754 |
// Add a css comment |
| 755 |
$custom_css = '/* Start custom CSS for page-settings */' . $custom_css . '/* End custom CSS */'; |
| 756 |
|
| 757 |
|
| 758 |
$custom_css = str_replace( 'selector', '#wdk_el_' . $this->get_id(), $custom_css ); |
| 759 |
|
| 760 |
echo '<style>'.wmvc_xss_clean($custom_css).'</style>'; |
| 761 |
} |
| 762 |
|
| 763 |
private function break_css($css) |
| 764 |
{ |
| 765 |
|
| 766 |
$results = array(); |
| 767 |
preg_match_all('/(.+?)\s?\{\s?(.+?)\s?\}/', $css, $matches); |
| 768 |
foreach($matches[0] AS $i=>$original) |
| 769 |
foreach(explode(';', $matches[2][$i]) AS $attr) |
| 770 |
if (strlen(trim($attr)) > 0) // for missing semicolon on last element, which is legal |
| 771 |
{ |
| 772 |
list($name, $value) = explode(':', $attr); |
| 773 |
$results[$matches[1][$i]][trim($name)] = trim($value); |
| 774 |
} |
| 775 |
return $results; |
| 776 |
} |
| 777 |
|
| 778 |
public function generate_icon($icon, $attributes = [], $tag = 'i' ){ |
| 779 |
if ( empty( $icon['library'] ) ) { |
| 780 |
return false; |
| 781 |
} |
| 782 |
$output = ''; |
| 783 |
// handler SVG Icon |
| 784 |
if ( 'svg' === $icon['library'] ) { |
| 785 |
$output = \Elementor\Icons_Manager::render_svg_icon( $icon['value'] ); |
| 786 |
} else { |
| 787 |
$output = $this->render_icon_html( $icon, $attributes, $tag ); |
| 788 |
} |
| 789 |
|
| 790 |
return $output; |
| 791 |
} |
| 792 |
|
| 793 |
public function render_icon_html( $icon, $attributes = [], $tag = 'i' ) { |
| 794 |
$icon_types = \Elementor\Icons_Manager::get_icon_manager_tabs(); |
| 795 |
if ( isset( $icon_types[ $icon['library'] ]['render_callback'] ) && is_callable( $icon_types[ $icon['library'] ]['render_callback'] ) ) { |
| 796 |
return call_user_func_array( $icon_types[ $icon['library'] ]['render_callback'], [ $icon, $attributes, $tag ] ); |
| 797 |
} |
| 798 |
|
| 799 |
if ( empty( $attributes['class'] ) ) { |
| 800 |
$attributes['class'] = $icon['value']; |
| 801 |
} else { |
| 802 |
if ( is_array( $attributes['class'] ) ) { |
| 803 |
$attributes['class'][] = $icon['value']; |
| 804 |
} else { |
| 805 |
$attributes['class'] .= ' ' . $icon['value']; |
| 806 |
} |
| 807 |
} |
| 808 |
return '<' . $tag . ' ' . Utils::render_html_attributes( $attributes ) . '></' . $tag . '>'; |
| 809 |
} |
| 810 |
|
| 811 |
public static function render_svg_icon( $value ) { |
| 812 |
if ( ! isset( $value['id'] ) ) { |
| 813 |
return ''; |
| 814 |
} |
| 815 |
|
| 816 |
return Svg_Handler::get_inline_svg( $value['id'] ); |
| 817 |
} |
| 818 |
|
| 819 |
public function enqueue_styles_scripts() { |
| 820 |
|
| 821 |
} |
| 822 |
|
| 823 |
public function is_edit_mode_load() { |
| 824 |
|
| 825 |
if (isset($this->is_edit_mode) && null !== $this->is_edit_mode ) { |
| 826 |
return $this->is_edit_mode; |
| 827 |
} |
| 828 |
|
| 829 |
// Ajax request as Editor mode |
| 830 |
$actions = array( |
| 831 |
'elementor', |
| 832 |
// Templates |
| 833 |
'elementor_get_templates', |
| 834 |
'elementor_save_template', |
| 835 |
'elementor_get_template', |
| 836 |
'elementor_delete_template', |
| 837 |
'elementor_export_template', |
| 838 |
'elementor_import_template', |
| 839 |
); |
| 840 |
|
| 841 |
if (isset($_REQUEST['action']) && in_array($_REQUEST['action'], $actions)) { |
| 842 |
return true; |
| 843 |
} |
| 844 |
|
| 845 |
if (isset($_REQUEST['elementor-preview'])) { |
| 846 |
return true; |
| 847 |
} |
| 848 |
|
| 849 |
return false; |
| 850 |
} |
| 851 |
|
| 852 |
|
| 853 |
|
| 854 |
/** |
| 855 |
* Adding Go Premium message to all widgets |
| 856 |
* |
| 857 |
* @since 1.4.2 |
| 858 |
*/ |
| 859 |
public function insert_pro_message($section = 1) |
| 860 |
{ |
| 861 |
if(!function_exists('run_wdk_membership')){ |
| 862 |
$this->start_controls_section( |
| 863 |
'wdk_section_pro', |
| 864 |
[ |
| 865 |
'label' => __('Go Premium for More Features', 'wpdirectorykit'), |
| 866 |
'tab' => $section, |
| 867 |
] |
| 868 |
); |
| 869 |
|
| 870 |
$this->add_control( |
| 871 |
'wdk_control_get_pro', |
| 872 |
[ |
| 873 |
'label' => __('Unlock more possibilities', 'wpdirectorykit'), |
| 874 |
'type' => \Elementor\Controls_Manager::CHOOSE, |
| 875 |
'options' => [ |
| 876 |
'1' => [ |
| 877 |
'title' => '', |
| 878 |
'icon' => 'fa fa-unlock-alt', |
| 879 |
], |
| 880 |
], |
| 881 |
'default' => '1', |
| 882 |
'toggle' => false, |
| 883 |
'description' => '<span class="wdk_control_get_pro">'.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>' |
| 884 |
|
| 885 |
] |
| 886 |
); |
| 887 |
|
| 888 |
$this->end_controls_section(); |
| 889 |
} |
| 890 |
} |
| 891 |
|
| 892 |
} |