breadcrumbs.php
6 months ago
copyright.php
6 months ago
current-time.php
6 months ago
logo.php
6 months ago
menu.php
6 months ago
modern-search.php
6 months ago
search.php
6 months ago
select.php
6 months ago
shopping-cart.php
6 months ago
site-title.php
6 months ago
select.php
858 lines
| 1 | <?php |
| 2 | namespace Auxin\Plugin\CoreElements\Elementor\Elements\Theme_Elements; |
| 3 | /** |
| 4 | * Elementor Select Widget |
| 5 | * |
| 6 | * @since 1.2.2 |
| 7 | */ |
| 8 | if ( ! defined( 'ABSPATH' ) ) { |
| 9 | exit; // Exit if accessed directly. |
| 10 | } |
| 11 | |
| 12 | use Elementor\Widget_Base; |
| 13 | use Elementor\Controls_Manager; |
| 14 | use Elementor\Group_Control_Typography; |
| 15 | use Elementor\Core\Kits\Documents\Tabs\Global_Typography; |
| 16 | use Elementor\Group_Control_Border; |
| 17 | use Elementor\Group_Control_Background; |
| 18 | use Elementor\Group_Control_Box_Shadow; |
| 19 | |
| 20 | class Select extends Widget_Base { |
| 21 | |
| 22 | /** |
| 23 | * Get widget name. |
| 24 | * |
| 25 | * Retrieve Icon Box Left widget name. |
| 26 | * |
| 27 | * @since 1.0.0 |
| 28 | * @access public |
| 29 | * |
| 30 | * @return string Widget name. |
| 31 | */ |
| 32 | public function get_name() { |
| 33 | return 'aux_select_box'; |
| 34 | } |
| 35 | |
| 36 | /** |
| 37 | * Get widget title. |
| 38 | * |
| 39 | * Retrieve Icon Box Left widget title. |
| 40 | * |
| 41 | * @since 1.0.0 |
| 42 | * @access public |
| 43 | * |
| 44 | * @return string Widget title. |
| 45 | */ |
| 46 | public function get_title() { |
| 47 | return esc_html__( 'Select Box', 'auxin-elements' ); |
| 48 | } |
| 49 | |
| 50 | public function has_widget_inner_wrapper(): bool { |
| 51 | return ! \Elementor\Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' ); |
| 52 | } |
| 53 | |
| 54 | |
| 55 | /** |
| 56 | * Get widget icon. |
| 57 | * |
| 58 | * Retrieve Icon Box Left widget icon. |
| 59 | * |
| 60 | * @since 1.0.0 |
| 61 | * @access public |
| 62 | * |
| 63 | * @return string Widget icon. |
| 64 | */ |
| 65 | public function get_icon() { |
| 66 | return 'eicon-select auxin-badge'; |
| 67 | } |
| 68 | |
| 69 | /** |
| 70 | * Get widget categories. |
| 71 | * |
| 72 | * Retrieve the list of categories the Icon Box Left widget belongs to. |
| 73 | * |
| 74 | * @since 1.0.0 |
| 75 | * @access public |
| 76 | * |
| 77 | * @return array Widget categories. |
| 78 | */ |
| 79 | public function get_categories() { |
| 80 | return array( 'auxin-core', 'auxin-theme-elements' ); |
| 81 | } |
| 82 | |
| 83 | /** |
| 84 | * Register Icon Box Left widget controls. |
| 85 | * |
| 86 | * Adds different input fields to allow the user to change and customize the widget settings. |
| 87 | * |
| 88 | * @since 1.0.0 |
| 89 | * @access protected |
| 90 | */ |
| 91 | protected function register_controls() { |
| 92 | $this->start_controls_section( |
| 93 | 'content_section', |
| 94 | array( |
| 95 | 'label' => esc_html__( 'Select', 'auxin-elements' ), |
| 96 | 'tab' => Controls_Manager::TAB_CONTENT, |
| 97 | ) |
| 98 | ); |
| 99 | |
| 100 | $this->add_control( |
| 101 | 'dropdown_icon', |
| 102 | [ |
| 103 | 'label' => __( 'Dropdown icon', 'auxin-elements' ), |
| 104 | 'type' => Controls_Manager::ICONS, |
| 105 | 'default' => [ |
| 106 | 'value' => 'auxicon auxicon-chevron-down', |
| 107 | 'library' => 'auxicon', |
| 108 | ], |
| 109 | ] |
| 110 | ); |
| 111 | |
| 112 | $repeater = new \Elementor\Repeater(); |
| 113 | |
| 114 | $repeater->add_control( |
| 115 | 'item_title', |
| 116 | array( |
| 117 | 'label' => esc_html__( 'Title', 'auxin-elements' ), |
| 118 | 'type' => Controls_Manager::TEXT, |
| 119 | 'placeholder' => esc_html__( 'Link title', 'auxin-elements' ), |
| 120 | ) |
| 121 | ); |
| 122 | |
| 123 | $repeater->add_control( |
| 124 | 'item_link', |
| 125 | [ |
| 126 | 'label' => __( 'Link', 'auxin-elements' ), |
| 127 | 'type' => Controls_Manager::URL, |
| 128 | 'placeholder' => __( 'https://your-link.com', 'auxin-elements' ), |
| 129 | 'show_external' => true, |
| 130 | 'default' => [ |
| 131 | 'url' => '#', |
| 132 | 'is_external' => false, |
| 133 | 'nofollow' => true, |
| 134 | ], |
| 135 | 'dynamic' => array( |
| 136 | 'active' => true |
| 137 | ) |
| 138 | ] |
| 139 | ); |
| 140 | |
| 141 | $repeater->add_control( |
| 142 | 'item_icon', |
| 143 | [ |
| 144 | 'label' => __( 'Icon', 'auxin-elements' ), |
| 145 | 'type' => Controls_Manager::ICONS, |
| 146 | 'default' => [ |
| 147 | 'value' => 'fas fa-star', |
| 148 | 'library' => 'solid', |
| 149 | ], |
| 150 | ] |
| 151 | ); |
| 152 | |
| 153 | $repeater->add_control( |
| 154 | 'is_language_switcher', |
| 155 | array( |
| 156 | 'label' => __('Is lanugage swicher ?', 'auxin-elements'), |
| 157 | 'type' => Controls_Manager::SWITCHER, |
| 158 | 'label_on' => __( 'Yes', 'auxin-elements' ), |
| 159 | 'label_off' => __( 'No', 'auxin-elements' ), |
| 160 | 'return_value' => 'yes', |
| 161 | 'default' => 'yes', |
| 162 | ) |
| 163 | ); |
| 164 | |
| 165 | $repeater->add_control( |
| 166 | 'language', |
| 167 | array( |
| 168 | 'label' => __('Language', 'auxin-elements'), |
| 169 | 'type' => Controls_Manager::SELECT, |
| 170 | 'options' => $this->get_languages_list(), |
| 171 | 'condition' => [ |
| 172 | 'is_language_switcher' => 'yes' |
| 173 | ] |
| 174 | ) |
| 175 | ); |
| 176 | |
| 177 | $this->add_control( |
| 178 | 'select_items', |
| 179 | array( |
| 180 | 'label' => esc_html__( 'Items', 'auxin-elements' ), |
| 181 | 'type' => Controls_Manager::REPEATER, |
| 182 | 'fields' => $repeater->get_controls(), |
| 183 | 'default' => array( |
| 184 | array( |
| 185 | 'item_title' => esc_html__( 'First Item', 'auxin-elements' ), |
| 186 | ), |
| 187 | array( |
| 188 | 'item_title' => esc_html__( 'Second Item', 'auxin-elements' ), |
| 189 | ), |
| 190 | ), |
| 191 | 'title_field' => '{{{ item_title }}}', |
| 192 | ) |
| 193 | ); |
| 194 | |
| 195 | $this->add_control( |
| 196 | 'action', |
| 197 | array( |
| 198 | 'label' => esc_html__( 'Display Items On Hover', 'auxin-elements' ), |
| 199 | 'type' => Controls_Manager::SWITCHER, |
| 200 | 'label_on' => esc_html__( 'Hover', 'auxin-elements' ), |
| 201 | 'label_off' => esc_html__( 'Click', 'auxin-elements' ), |
| 202 | 'return_value' => 'hover', |
| 203 | 'default' => 'hover', |
| 204 | ) |
| 205 | ); |
| 206 | |
| 207 | $this->end_controls_section(); |
| 208 | |
| 209 | $this->start_controls_section( |
| 210 | 'select_style_section', |
| 211 | array( |
| 212 | 'label' => esc_html__( 'Select Style', 'auxin-elements' ), |
| 213 | 'tab' => Controls_Manager::TAB_STYLE, |
| 214 | ) |
| 215 | ); |
| 216 | |
| 217 | $this->add_responsive_control( |
| 218 | 'select_box_margin', |
| 219 | array( |
| 220 | 'label' => esc_html__( 'Select Margin', 'auxin-elements' ), |
| 221 | 'type' => Controls_Manager::DIMENSIONS, |
| 222 | 'size_units' => array( 'px', '%', 'em' ), |
| 223 | 'selectors' => array( |
| 224 | '{{WRAPPER}}' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 225 | ), |
| 226 | ) |
| 227 | ); |
| 228 | |
| 229 | $this->add_responsive_control( |
| 230 | 'select_align', |
| 231 | array( |
| 232 | 'label' => esc_html__( 'Alignment', 'auxin-elements' ), |
| 233 | 'type' => Controls_Manager::CHOOSE, |
| 234 | 'options' => array( |
| 235 | 'left' => array( |
| 236 | 'title' => __( 'Left', 'auxin-elements' ), |
| 237 | 'icon' => 'eicon-text-align-left', |
| 238 | ), |
| 239 | 'center' => array( |
| 240 | 'title' => __( 'Center', 'auxin-elements' ), |
| 241 | 'icon' => 'eicon-text-align-center', |
| 242 | ), |
| 243 | 'right' => array( |
| 244 | 'title' => __( 'Right', 'auxin-elements' ), |
| 245 | 'icon' => 'eicon-text-align-right', |
| 246 | ) |
| 247 | ), |
| 248 | 'default' => 'left', |
| 249 | 'selectors_dictionary' => [ |
| 250 | 'left' => 'text-align: left;justify-content: flex-start;', |
| 251 | 'center' => 'text-align: center;justify-content: center;', |
| 252 | 'right' => 'text-align: right;justify-content: flex-end;' |
| 253 | ], |
| 254 | 'selectors' => array( |
| 255 | '{{WRAPPER}} div.aux-select-element' => '{{VALUE}}', |
| 256 | '{{WRAPPER}} div.aux-select-element ul li' => '{{VALUE}}', |
| 257 | ), |
| 258 | ) |
| 259 | ); |
| 260 | |
| 261 | $this->add_responsive_control( |
| 262 | 'select_width', |
| 263 | array( |
| 264 | 'label' => __('Select Width', 'auxin-elements' ), |
| 265 | 'type' => Controls_Manager::SLIDER, |
| 266 | 'size_units' => array('px', '%'), |
| 267 | 'range' => array( |
| 268 | 'px' => array( |
| 269 | 'min' => 0, |
| 270 | 'max' => 2000, |
| 271 | 'step' => 5 |
| 272 | ), |
| 273 | '%' => array( |
| 274 | 'min' => 0, |
| 275 | 'max' => 100, |
| 276 | 'step' => 1 |
| 277 | ) |
| 278 | ), |
| 279 | 'selectors' => array( |
| 280 | '{{WRAPPER}} .aux-select-element' => 'width: {{SIZE}}{{UNIT}};' |
| 281 | ) |
| 282 | ) |
| 283 | ); |
| 284 | |
| 285 | $this->add_responsive_control( |
| 286 | 'select_height', |
| 287 | array( |
| 288 | 'label' => __('Select Height', 'auxin-elements' ), |
| 289 | 'type' => Controls_Manager::SLIDER, |
| 290 | 'size_units' => array('px', '%'), |
| 291 | 'range' => array( |
| 292 | 'px' => array( |
| 293 | 'min' => 0, |
| 294 | 'max' => 2000, |
| 295 | 'step' => 5 |
| 296 | ), |
| 297 | '%' => array( |
| 298 | 'min' => 0, |
| 299 | 'max' => 100, |
| 300 | 'step' => 1 |
| 301 | ) |
| 302 | ), |
| 303 | 'selectors' => array( |
| 304 | '{{WRAPPER}} .aux-select-element' => 'height: {{SIZE}}{{UNIT}};' |
| 305 | ) |
| 306 | ) |
| 307 | ); |
| 308 | |
| 309 | $this->start_controls_tabs( 'select_state_colors' ); |
| 310 | |
| 311 | $this->start_controls_tab( |
| 312 | 'select_normal', |
| 313 | array( |
| 314 | 'label' => __( 'Normal' , 'auxin-elements' ) |
| 315 | ) |
| 316 | ); |
| 317 | |
| 318 | $this->add_control( |
| 319 | 'current_color_normal', |
| 320 | array( |
| 321 | 'label' => esc_html__( 'Current Item Color ', 'auxin-elements' ), |
| 322 | 'type' => Controls_Manager::COLOR, |
| 323 | 'default' => '', |
| 324 | 'selectors' => [ |
| 325 | '{{WRAPPER}} .current, {{WRAPPER}} .current a' => 'color: {{VALUE}};' |
| 326 | ] |
| 327 | ) |
| 328 | ); |
| 329 | |
| 330 | $this->add_group_control( |
| 331 | Group_Control_Background::get_type(), |
| 332 | array( |
| 333 | 'name' => 'select_background_normal', |
| 334 | 'label' => __( 'Select Background', 'auxin-elements' ), |
| 335 | 'types' => array( 'classic', 'gradient' ), |
| 336 | 'selector' => '{{WRAPPER}} .aux-select-element', |
| 337 | ) |
| 338 | ); |
| 339 | |
| 340 | $this->end_controls_tab(); |
| 341 | |
| 342 | $this->start_controls_tab( |
| 343 | 'select_hover', |
| 344 | array( |
| 345 | 'label' => __( 'Hover' , 'auxin-elements' ) |
| 346 | ) |
| 347 | ); |
| 348 | |
| 349 | $this->add_control( |
| 350 | 'current_color_hover', |
| 351 | array( |
| 352 | 'label' => esc_html__( 'Current Item Color ', 'auxin-elements' ), |
| 353 | 'type' => Controls_Manager::COLOR, |
| 354 | 'default' => '', |
| 355 | 'selectors' => [ |
| 356 | '{{WRAPPER}} .current:hover, {{WRAPPER}} .current:hover a' => 'color: {{VALUE}};' |
| 357 | ] |
| 358 | ) |
| 359 | ); |
| 360 | |
| 361 | $this->add_group_control( |
| 362 | Group_Control_Background::get_type(), |
| 363 | array( |
| 364 | 'name' => 'select_background_hover', |
| 365 | 'label' => __( 'Select Background', 'auxin-elements' ), |
| 366 | 'types' => array( 'classic', 'gradient' ), |
| 367 | 'selector' => '{{WRAPPER}} .aux-select-element', |
| 368 | ) |
| 369 | ); |
| 370 | |
| 371 | $this->add_responsive_control( |
| 372 | 'select_transition', |
| 373 | array( |
| 374 | 'label' => __('Transition (ms)', 'auxin-elements' ), |
| 375 | 'type' => Controls_Manager::SLIDER, |
| 376 | 'size_units' => array('px'), |
| 377 | 'range' => array( |
| 378 | 'px' => array( |
| 379 | 'min' => 0, |
| 380 | 'max' => 5000, |
| 381 | 'step' => 100 |
| 382 | ) |
| 383 | ), |
| 384 | 'selectors' => array( |
| 385 | '{{WRAPPER}} .aux-select-element, {{WRAPPER}} .current' => 'transition: all {{SIZE}}ms ease;' |
| 386 | ) |
| 387 | ) |
| 388 | ); |
| 389 | |
| 390 | $this->end_controls_tab(); |
| 391 | |
| 392 | $this->end_controls_tabs(); |
| 393 | |
| 394 | $this->add_control( |
| 395 | 'select_border_options', |
| 396 | [ |
| 397 | 'label' => __( 'Select Border Options', 'auxin-elements' ), |
| 398 | 'type' => Controls_Manager::HEADING, |
| 399 | 'separator' => 'before', |
| 400 | ] |
| 401 | ); |
| 402 | |
| 403 | $this->add_group_control( |
| 404 | Group_Control_Border::get_type(), |
| 405 | array( |
| 406 | 'name' => 'select_border', |
| 407 | 'label' => esc_html__( 'Select Border', 'auxin-elements' ), |
| 408 | 'selector' => '{{WRAPPER}} div.aux-select-element', |
| 409 | 'separator' => 'none' |
| 410 | ) |
| 411 | ); |
| 412 | |
| 413 | $this->add_responsive_control( |
| 414 | 'select_border_radius', |
| 415 | array( |
| 416 | 'label' => esc_html__( 'Select Border Radius', 'auxin-elements' ), |
| 417 | 'type' => Controls_Manager::DIMENSIONS, |
| 418 | 'size_units' => array( 'px', '%', 'em' ), |
| 419 | 'selectors' => array( |
| 420 | '{{WRAPPER}} div.aux-select-element' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 421 | ), |
| 422 | ) |
| 423 | ); |
| 424 | |
| 425 | $this->end_controls_section(); |
| 426 | |
| 427 | $this->start_controls_section( |
| 428 | 'dropdown_style_section', |
| 429 | array( |
| 430 | 'label' => esc_html__( 'Dropdown Style', 'auxin-elements' ), |
| 431 | 'tab' => Controls_Manager::TAB_STYLE, |
| 432 | ) |
| 433 | ); |
| 434 | |
| 435 | $this->add_control( |
| 436 | 'select_list_border_options', |
| 437 | [ |
| 438 | 'label' => __( 'Dropdown Border Options', 'auxin-elements' ), |
| 439 | 'type' => Controls_Manager::HEADING, |
| 440 | 'separator' => 'before', |
| 441 | ] |
| 442 | ); |
| 443 | |
| 444 | $this->add_group_control( |
| 445 | Group_Control_Border::get_type(), |
| 446 | array( |
| 447 | 'name' => 'select_list_border', |
| 448 | 'label' => esc_html__( 'Select List Border', 'auxin-elements' ), |
| 449 | 'selector' => '{{WRAPPER}} div.aux-select-element ul', |
| 450 | 'separator' => 'none' |
| 451 | ) |
| 452 | ); |
| 453 | |
| 454 | $this->add_responsive_control( |
| 455 | 'select_list_border_radius', |
| 456 | array( |
| 457 | 'label' => esc_html__( 'Dropdown Border Radius', 'auxin-elements' ), |
| 458 | 'type' => Controls_Manager::DIMENSIONS, |
| 459 | 'size_units' => array( 'px', '%', 'em' ), |
| 460 | 'selectors' => array( |
| 461 | '{{WRAPPER}} div.aux-select-element ul' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 462 | ), |
| 463 | ) |
| 464 | ); |
| 465 | |
| 466 | $this->add_group_control( |
| 467 | Group_Control_Box_Shadow::get_type(), |
| 468 | array( |
| 469 | 'name' => 'dropdown_box_shadow', |
| 470 | 'selector' => '{{WRAPPER}} div.aux-select-element ul', |
| 471 | ) |
| 472 | ); |
| 473 | |
| 474 | $this->add_group_control( |
| 475 | Group_Control_Background::get_type(), |
| 476 | array( |
| 477 | 'name' => 'dropdown_background', |
| 478 | 'label' => __( 'Dropdown Background', 'auxin-elements' ), |
| 479 | 'types' => array( 'classic', 'gradient' ), |
| 480 | 'selector' => '{{WRAPPER}} ul', |
| 481 | ) |
| 482 | ); |
| 483 | |
| 484 | $this->end_controls_section(); |
| 485 | |
| 486 | $this->start_controls_section( |
| 487 | 'select_items_style_section', |
| 488 | array( |
| 489 | 'label' => esc_html__( 'Items Style', 'auxin-elements' ), |
| 490 | 'tab' => Controls_Manager::TAB_STYLE, |
| 491 | ) |
| 492 | ); |
| 493 | |
| 494 | $this->add_group_control( |
| 495 | Group_Control_Typography::get_type(), |
| 496 | array( |
| 497 | 'name' => 'item_typography', |
| 498 | 'label' => __( 'Item Typography', 'auxin-elements' ), |
| 499 | 'global' => [ |
| 500 | 'default' => Global_Typography::TYPOGRAPHY_PRIMARY, |
| 501 | ], |
| 502 | 'selector' => '{{WRAPPER}} .current .selected, {{WRAPPER}} ul li', |
| 503 | ) |
| 504 | ); |
| 505 | |
| 506 | $this->add_responsive_control( |
| 507 | 'item_padding', |
| 508 | array( |
| 509 | 'label' => esc_html__( 'Padding', 'auxin-elements' ), |
| 510 | 'type' => Controls_Manager::DIMENSIONS, |
| 511 | 'size_units' => array( 'px', '%', 'em' ), |
| 512 | 'selectors' => array( |
| 513 | '{{WRAPPER}} ul li' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 514 | ), |
| 515 | ) |
| 516 | ); |
| 517 | |
| 518 | $this->add_responsive_control( |
| 519 | 'item_margin', |
| 520 | array( |
| 521 | 'label' => esc_html__( 'Margin', 'auxin-elements' ), |
| 522 | 'type' => Controls_Manager::DIMENSIONS, |
| 523 | 'size_units' => array( 'px', '%', 'em' ), |
| 524 | 'selectors' => array( |
| 525 | '{{WRAPPER}} ul li' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 526 | ), |
| 527 | ) |
| 528 | ); |
| 529 | |
| 530 | $this->add_group_control( |
| 531 | Group_Control_Border::get_type(), |
| 532 | array( |
| 533 | 'name' => 'item_border', |
| 534 | 'label' => esc_html__( 'Border', 'auxin-elements' ), |
| 535 | 'selector' => '{{WRAPPER}} div.aux-select-element li:not(:last-child)', |
| 536 | 'separator' => 'none' |
| 537 | ) |
| 538 | ); |
| 539 | |
| 540 | $this->add_responsive_control( |
| 541 | 'icon_padding', |
| 542 | array( |
| 543 | 'label' => esc_html__( 'Icon/Image Padding', 'auxin-elements' ), |
| 544 | 'type' => Controls_Manager::DIMENSIONS, |
| 545 | 'size_units' => array( 'px', '%', 'em' ), |
| 546 | 'selectors' => array( |
| 547 | '{{WRAPPER}} .element-icon , {{WRAPPER}} img' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 548 | ), |
| 549 | ) |
| 550 | ); |
| 551 | |
| 552 | $this->add_responsive_control( |
| 553 | 'icon_size', |
| 554 | array( |
| 555 | 'label' => __( 'Size', 'auxin-elements' ), |
| 556 | 'type' => Controls_Manager::SLIDER, |
| 557 | 'size_units' => array( 'px', 'em' ), |
| 558 | 'range' => array( |
| 559 | 'px' => array( |
| 560 | 'max' => 100 |
| 561 | ), |
| 562 | 'em' => array( |
| 563 | 'max' => 10 |
| 564 | ) |
| 565 | ), |
| 566 | 'default' => [ |
| 567 | 'unit' => 'px', |
| 568 | 'size' => 16, |
| 569 | ], |
| 570 | 'selectors' => array( |
| 571 | '{{WRAPPER}} .element-icon' => 'font-size: {{SIZE}}{{UNIT}};height: {{SIZE}}{{UNIT}};', |
| 572 | ) |
| 573 | ) |
| 574 | ); |
| 575 | |
| 576 | $this->start_controls_tabs( 'item_state_colors' ); |
| 577 | |
| 578 | $this->start_controls_tab( |
| 579 | 'item_normal', |
| 580 | array( |
| 581 | 'label' => __( 'Normal' , 'auxin-elements' ) |
| 582 | ) |
| 583 | ); |
| 584 | |
| 585 | $this->add_control( |
| 586 | 'icon_color_normal', |
| 587 | array( |
| 588 | 'label' => esc_html__( 'Icon Color ', 'auxin-elements' ), |
| 589 | 'type' => Controls_Manager::COLOR, |
| 590 | 'default' => '', |
| 591 | 'selectors' => [ |
| 592 | '{{WRAPPER}} .element-icon' => 'color: {{VALUE}};fill: {{VALUE}};' |
| 593 | ] |
| 594 | ) |
| 595 | ); |
| 596 | |
| 597 | $this->add_control( |
| 598 | 'title_color_normal', |
| 599 | array( |
| 600 | 'label' => esc_html__( 'Text Color ', 'auxin-elements' ), |
| 601 | 'type' => Controls_Manager::COLOR, |
| 602 | 'default' => '', |
| 603 | 'selectors' => [ |
| 604 | '{{WRAPPER}} ul li a' => 'color: {{VALUE}};' |
| 605 | ] |
| 606 | ) |
| 607 | ); |
| 608 | |
| 609 | $this->add_group_control( |
| 610 | Group_Control_Background::get_type(), |
| 611 | array( |
| 612 | 'name' => 'item_background_normal', |
| 613 | 'label' => __( 'Item Background', 'auxin-elements' ), |
| 614 | 'types' => array( 'classic', 'gradient' ), |
| 615 | 'selector' => '{{WRAPPER}} ul li', |
| 616 | ) |
| 617 | ); |
| 618 | |
| 619 | $this->end_controls_tab(); |
| 620 | |
| 621 | $this->start_controls_tab( |
| 622 | 'item_hover', |
| 623 | array( |
| 624 | 'label' => __( 'Hover' , 'auxin-elements' ) |
| 625 | ) |
| 626 | ); |
| 627 | |
| 628 | $this->add_control( |
| 629 | 'icon_color_hover', |
| 630 | array( |
| 631 | 'label' => esc_html__( 'Icon Color ', 'auxin-elements' ), |
| 632 | 'type' => Controls_Manager::COLOR, |
| 633 | 'default' => '', |
| 634 | 'selectors' => [ |
| 635 | '{{WRAPPER}} ul li:hover .element-icon' => 'color: {{VALUE}};fill: {{VALUE}};' |
| 636 | ] |
| 637 | ) |
| 638 | ); |
| 639 | |
| 640 | $this->add_control( |
| 641 | 'title_color_hover', |
| 642 | array( |
| 643 | 'label' => esc_html__( 'Text Color ', 'auxin-elements' ), |
| 644 | 'type' => Controls_Manager::COLOR, |
| 645 | 'default' => '', |
| 646 | 'selectors' => [ |
| 647 | '{{WRAPPER}} ul li:hover a' => 'color: {{VALUE}};' |
| 648 | ] |
| 649 | ) |
| 650 | ); |
| 651 | |
| 652 | $this->add_group_control( |
| 653 | Group_Control_Background::get_type(), |
| 654 | array( |
| 655 | 'name' => 'item_background_hover', |
| 656 | 'label' => __( 'Item Background', 'auxin-elements' ), |
| 657 | 'types' => array( 'classic', 'gradient' ), |
| 658 | 'selector' => '{{WRAPPER}} ul li:hover', |
| 659 | ) |
| 660 | ); |
| 661 | |
| 662 | $this->add_responsive_control( |
| 663 | 'dropdown_transition', |
| 664 | array( |
| 665 | 'label' => __('Transition (ms)', 'auxin-elements' ), |
| 666 | 'type' => Controls_Manager::SLIDER, |
| 667 | 'size_units' => array('px'), |
| 668 | 'range' => array( |
| 669 | 'px' => array( |
| 670 | 'min' => 0, |
| 671 | 'max' => 5000, |
| 672 | 'step' => 100 |
| 673 | ) |
| 674 | ), |
| 675 | 'selectors' => array( |
| 676 | '{{WRAPPER}} ul li, {{WRAPPER}} ul li a, {{WRAPPER}} ul li .element-icon' => 'transition: all {{SIZE}}ms ease;' |
| 677 | ) |
| 678 | ) |
| 679 | ); |
| 680 | |
| 681 | $this->end_controls_tab(); |
| 682 | |
| 683 | $this->end_controls_tabs(); |
| 684 | |
| 685 | $this->end_controls_section(); |
| 686 | |
| 687 | } |
| 688 | |
| 689 | /** |
| 690 | * Render Icon Box Left widget output on the frontend. |
| 691 | * |
| 692 | * Written in PHP and used to generate the final HTML. |
| 693 | * |
| 694 | * @since 1.0.0 |
| 695 | * @access protected |
| 696 | */ |
| 697 | protected function render() { |
| 698 | $settings = $this->get_settings_for_display(); |
| 699 | |
| 700 | $action = $settings['action'] == 'hover' ? 'hover' : 'click'; |
| 701 | |
| 702 | $current_item = $this->get_current_item( $settings ); |
| 703 | |
| 704 | ?> |
| 705 | <div class="aux-select-element" data-action="<?php echo esc_attr( $action );?>"> |
| 706 | <span class="current"> |
| 707 | <span class="selected"> |
| 708 | <?php |
| 709 | if ( !empty( $settings['select_items'][ $current_item ]['item_icon']['library'] ) && $settings['select_items'][ $current_item ]['item_icon']['library'] == 'svg' ) { |
| 710 | $icon = '<img src="' . esc_url( $settings['select_items'][ $current_item ]['item_icon']['value']['url'] ) . '">'; |
| 711 | } elseif ( !empty( $settings['select_items'][ $current_item ]['item_icon']['value'] ) ) { |
| 712 | $icon = \Elementor\Icons_Manager::render_font_icon( $settings['select_items'][ $current_item ]['item_icon'], [ 'aria-hidden' => 'true', 'class' => 'element-icon' ] ); |
| 713 | } else { |
| 714 | $icon = ''; |
| 715 | } |
| 716 | echo auxin_kses( $icon ) . esc_html( $settings['select_items'][ $current_item ]['item_title'] ); |
| 717 | ?> |
| 718 | </span> |
| 719 | <?php |
| 720 | if ( !empty( $settings['dropdown_icon']['library'] ) && $settings['dropdown_icon']['library'] == 'svg' ) { |
| 721 | echo '<img class="dropdown-icon" src="' . esc_url( $settings['dropdown_icon']['value']['url'] ) . '">'; |
| 722 | } elseif ( !empty( $settings['dropdown_icon']['value'] ) ) { |
| 723 | echo \Elementor\Icons_Manager::render_font_icon( $settings['dropdown_icon'], [ 'aria-hidden' => 'true', 'class' => 'dropdown-icon' ] ); |
| 724 | } |
| 725 | ?> |
| 726 | </span> |
| 727 | <ul class="list"> |
| 728 | <?php |
| 729 | foreach( $settings['select_items'] as $key => $item ) { |
| 730 | $is_external = $item['item_link']['is_external'] ? '_blank' : '_self'; |
| 731 | if ( !empty( $item['item_icon']['library'] ) && $item['item_icon']['library'] == 'svg' ) { |
| 732 | $icon = '<img src="' . esc_url( $item['item_icon']['value']['url'] ) . '">'; |
| 733 | } elseif ( !empty( $item['item_icon']['value'] ) ) { |
| 734 | $icon = '<span class="element-icon ' . esc_attr( $item['item_icon']['value'] ) . '"></span>'; |
| 735 | } |
| 736 | |
| 737 | $item_link = $item['is_language_switcher'] ? $this->get_item_language_link( $item ) : rtrim( $item['item_link']['url'], '/' ); |
| 738 | ?> |
| 739 | <li class="option"><?php echo auxin_kses( $icon );?><a href="<?php echo esc_url( $item_link );?>" target="<?php echo esc_attr( $is_external );?>"><?php echo esc_html( $item['item_title'] );?></a></li> |
| 740 | <?php } ?> |
| 741 | </ul> |
| 742 | </div> |
| 743 | <?php |
| 744 | } |
| 745 | /** |
| 746 | * Whether the reload preview is required or not. |
| 747 | * |
| 748 | * Used to determine whether the reload preview is required. |
| 749 | * |
| 750 | * @since 1.0.0 |
| 751 | * @access public |
| 752 | * |
| 753 | * @return bool Whether the reload preview is required. |
| 754 | */ |
| 755 | public function is_reload_preview_required() { |
| 756 | return false; |
| 757 | } |
| 758 | |
| 759 | /** |
| 760 | * Render shortcode widget as plain content. |
| 761 | * |
| 762 | * Override the default behavior by printing the shortcode instead of rendering it. |
| 763 | * |
| 764 | * @since 1.0.0 |
| 765 | * @access public |
| 766 | */ |
| 767 | public function render_plain_content() { |
| 768 | |
| 769 | } |
| 770 | |
| 771 | protected function content_template() { |
| 772 | } |
| 773 | |
| 774 | /** |
| 775 | * Get current item for url visiting |
| 776 | * |
| 777 | * @param array $settings |
| 778 | * @return int |
| 779 | */ |
| 780 | public function get_current_item( $settings ) { |
| 781 | global $wp; |
| 782 | $current_link = rtrim( home_url( $wp->request ), '/' ); |
| 783 | |
| 784 | // if permalink structure is pretty |
| 785 | foreach( $settings['select_items'] as $key => $item ) { |
| 786 | $item_link = !empty( $item['is_language_switcher'] ) ? $this->get_item_language_link($item) : rtrim( $item['item_link']['url'], '/' ); |
| 787 | if ( !empty( $item_link ) && ( $item_link == $current_link || strpos( $current_link, $item_link ) != false ) ) { |
| 788 | return $key; |
| 789 | } |
| 790 | } |
| 791 | |
| 792 | // if permalink structure is not pretty and hast query variables inside |
| 793 | foreach( $settings['select_items'] as $key => $item ) { |
| 794 | $item_link = !empty( $item['is_language_switcher'] ) ? $this->get_item_language_link($item) : rtrim( $item['item_link']['url'], '/' ); |
| 795 | if ( !empty( $item_link ) ) { |
| 796 | $query = wp_parse_url($item_link, PHP_URL_QUERY); |
| 797 | parse_str($query, $params); |
| 798 | if ( !empty( $params ) ) { |
| 799 | $paramKeyFound = true; |
| 800 | foreach( $params as $paramKey => $paramValue ) { |
| 801 | if ( empty( $_GET[ $paramKey ] ) || $_GET[ $paramKey ] != $paramValue ) { |
| 802 | $paramKeyFound = false; |
| 803 | break; |
| 804 | } |
| 805 | } |
| 806 | |
| 807 | if ( $paramKeyFound ) { |
| 808 | return $key; |
| 809 | } |
| 810 | } |
| 811 | } |
| 812 | } |
| 813 | |
| 814 | return 0; |
| 815 | } |
| 816 | |
| 817 | /** |
| 818 | * List available languages |
| 819 | * |
| 820 | * @return array |
| 821 | */ |
| 822 | public function get_languages_list() { |
| 823 | if ( function_exists('pll_languages_list') ) { |
| 824 | $languages_list = pll_languages_list(); |
| 825 | return array_combine( $languages_list, $languages_list ); |
| 826 | } |
| 827 | |
| 828 | if ( function_exists('wpml_get_active_languages_filter') ) { |
| 829 | $languages_list = wpml_get_active_languages_filter(''); |
| 830 | return array_combine( array_keys( $languages_list ), array_keys( $languages_list ) ); |
| 831 | } |
| 832 | return []; |
| 833 | } |
| 834 | |
| 835 | /** |
| 836 | * Get relative language link for an item |
| 837 | * |
| 838 | * @param array $item |
| 839 | * @return string |
| 840 | */ |
| 841 | public function get_item_language_link( $item ) { |
| 842 | global $post; |
| 843 | if ( is_object( $post ) && !is_archive() ) { |
| 844 | if ( function_exists('pll_get_post') ) { |
| 845 | $translated_post = pll_get_post( $post->ID, $item['language'] ); |
| 846 | return !empty( $translated_post ) ? rtrim( get_permalink( $translated_post ), '/') : rtrim( $item['item_link']['url'], '/' ); |
| 847 | } |
| 848 | |
| 849 | if ( function_exists('wpml_object_id_filter') ) { |
| 850 | $translated_post = wpml_object_id_filter( $post->ID, $post->post_type, false, $item['language'] ); |
| 851 | return !empty( $translated_post ) ? rtrim( wpml_permalink_filter( get_permalink( $translated_post ), $item['language'] ), '/') : rtrim( $item['item_link']['url'], '/' ); |
| 852 | } |
| 853 | } |
| 854 | |
| 855 | return rtrim( $item['item_link']['url'], '/' ); |
| 856 | } |
| 857 | } |
| 858 |