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