breadcrumbs.php
6 years ago
copyright.php
6 years ago
current-time.php
6 years ago
logo.php
6 years ago
menu.php
6 years ago
modern-search.php
6 years ago
search.php
6 years ago
shopping-cart.php
6 years ago
site-title.php
6 years ago
modern-search.php
995 lines
| 1 | <?php |
| 2 | namespace Auxin\Plugin\CoreElements\Elementor\Elements\Theme_Elements; |
| 3 | |
| 4 | use Elementor\Widget_Base; |
| 5 | use Elementor\Controls_Manager; |
| 6 | use Elementor\Group_Control_Typography; |
| 7 | use Elementor\Scheme_Typography; |
| 8 | use Elementor\Group_Control_Text_Shadow; |
| 9 | use Elementor\Group_Control_Background; |
| 10 | use Elementor\Group_Control_Box_Shadow; |
| 11 | use Elementor\Group_Control_Border; |
| 12 | |
| 13 | |
| 14 | if ( ! defined( 'ABSPATH' ) ) { |
| 15 | exit; // Exit if accessed directly. |
| 16 | } |
| 17 | |
| 18 | /** |
| 19 | * Elementor 'ModernSearch' widget. |
| 20 | * |
| 21 | * Elementor widget that displays an 'ModernSearch'. |
| 22 | * |
| 23 | * @since 1.0.0 |
| 24 | */ |
| 25 | class ModernSearch extends Widget_Base { |
| 26 | |
| 27 | /** |
| 28 | * Get widget name. |
| 29 | * |
| 30 | * Retrieve 'ModernSearch' widget name. |
| 31 | * |
| 32 | * @since 1.0.0 |
| 33 | * @access public |
| 34 | * |
| 35 | * @return string Widget name. |
| 36 | */ |
| 37 | public function get_name() { |
| 38 | return 'aux_modern_search'; |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * Get widget title. |
| 43 | * |
| 44 | * Retrieve 'ModernSearch' widget title. |
| 45 | * |
| 46 | * @since 1.0.0 |
| 47 | * @access public |
| 48 | * |
| 49 | * @return string Widget title. |
| 50 | */ |
| 51 | public function get_title() { |
| 52 | return __('Modern Search', 'auxin-elements' ); |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * Get widget icon. |
| 57 | * |
| 58 | * Retrieve 'ModernSearch' 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-search auxin-badge'; |
| 67 | } |
| 68 | |
| 69 | /** |
| 70 | * Get widget categories. |
| 71 | * |
| 72 | * Retrieve 'ModernSearch' widget icon. |
| 73 | * |
| 74 | * @since 1.0.0 |
| 75 | * @access public |
| 76 | * |
| 77 | * @return string Widget icon. |
| 78 | */ |
| 79 | public function get_categories() { |
| 80 | return [ 'auxin-core', 'auxin-theme-elements' ]; |
| 81 | } |
| 82 | |
| 83 | /** |
| 84 | * Register 'ModernSearch' 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 | |
| 93 | /* Search Section |
| 94 | /*-------------------------------------*/ |
| 95 | |
| 96 | $this->start_controls_section( |
| 97 | 'section_search', |
| 98 | [ |
| 99 | 'label' => __( 'Button', 'auxin-elements' ), |
| 100 | ] |
| 101 | ); |
| 102 | |
| 103 | $this->add_control( |
| 104 | 'icon', |
| 105 | [ |
| 106 | 'label' => __( 'Icon', 'auxin-elements' ), |
| 107 | 'type' => Controls_Manager::ICONS, |
| 108 | 'default' => [ |
| 109 | 'value' => 'auxicon-search-4', |
| 110 | 'library' => 'auxicon' |
| 111 | ] |
| 112 | ] |
| 113 | ); |
| 114 | |
| 115 | $this->add_control( |
| 116 | 'text', |
| 117 | [ |
| 118 | 'label' => __( 'Text', 'auxin-elements' ), |
| 119 | 'type' => Controls_Manager::TEXT, |
| 120 | 'dynamic' => [ |
| 121 | 'active' => true, |
| 122 | ], |
| 123 | 'default' => __( '', 'auxin-elements' ), |
| 124 | 'placeholder' => __( 'Submit', 'auxin-elements' ), |
| 125 | ] |
| 126 | ); |
| 127 | |
| 128 | $this->end_controls_section(); |
| 129 | |
| 130 | /* Search Section |
| 131 | /*-------------------------------------*/ |
| 132 | |
| 133 | $this->start_controls_section( |
| 134 | 'fullscreen', |
| 135 | [ |
| 136 | 'label' => __( 'Fullscreen Search Input', 'auxin-elements' ), |
| 137 | ] |
| 138 | ); |
| 139 | |
| 140 | $this->add_control( |
| 141 | 'post_types', |
| 142 | [ |
| 143 | 'label' => __('Post Types', 'auxin-elements'), |
| 144 | 'description' => __('Specifies a post type that you want to show posts from it.', 'auxin-elements' ), |
| 145 | 'type' => Controls_Manager::SELECT2, |
| 146 | 'multiple' => true, |
| 147 | 'options' => $this->get_post_types(), |
| 148 | 'default' => [ 'category' ], |
| 149 | ] |
| 150 | ); |
| 151 | |
| 152 | $this->add_control( |
| 153 | 'use_ajax', |
| 154 | [ |
| 155 | 'label' => __( 'Enable Ajax Search', 'auxin-elements' ), |
| 156 | 'type' => Controls_Manager::SWITCHER, |
| 157 | 'label_on' => __( 'On', 'auxin-elements' ), |
| 158 | 'label_off' => __( 'Off', 'auxin-elements' ), |
| 159 | 'return_value' => 'yes', |
| 160 | 'default' => 'no', |
| 161 | 'separator' => 'before' |
| 162 | ] |
| 163 | ); |
| 164 | |
| 165 | $this->add_control( |
| 166 | 'fullscreen_display_submit', |
| 167 | [ |
| 168 | 'label' => __( 'Display Submit Button', 'auxin-elements' ), |
| 169 | 'type' => Controls_Manager::SWITCHER, |
| 170 | 'label_on' => __( 'On', 'auxin-elements' ), |
| 171 | 'label_off' => __( 'Off', 'auxin-elements' ), |
| 172 | 'return_value' => 'yes', |
| 173 | 'default' => 'yes', |
| 174 | 'separator' => 'before' |
| 175 | ] |
| 176 | ); |
| 177 | |
| 178 | $this->add_control( |
| 179 | 'fullscreen_display_fill_submit', |
| 180 | [ |
| 181 | 'label' => __( 'Display Fill Submit Button', 'auxin-elements' ), |
| 182 | 'type' => Controls_Manager::SWITCHER, |
| 183 | 'label_on' => __( 'On', 'auxin-elements' ), |
| 184 | 'label_off' => __( 'Off', 'auxin-elements' ), |
| 185 | 'return_value' => 'yes', |
| 186 | 'default' => 'no', |
| 187 | 'separator' => 'before', |
| 188 | 'condition' => [ |
| 189 | 'fullscreen_display_submit' => 'yes' |
| 190 | ] |
| 191 | ] |
| 192 | ); |
| 193 | |
| 194 | $this->add_control( |
| 195 | 'fullscreen_display_cats', |
| 196 | [ |
| 197 | 'label' => __( 'Display Categories', 'auxin-elements' ), |
| 198 | 'type' => Controls_Manager::SWITCHER, |
| 199 | 'label_on' => __( 'On', 'auxin-elements' ), |
| 200 | 'label_off' => __( 'Off', 'auxin-elements' ), |
| 201 | 'return_value' => 'yes', |
| 202 | 'default' => 'no', |
| 203 | 'separator' => 'before' |
| 204 | ] |
| 205 | ); |
| 206 | |
| 207 | $this->end_controls_section(); |
| 208 | |
| 209 | /* Icon Style Section |
| 210 | /*-------------------------------------*/ |
| 211 | |
| 212 | $this->start_controls_section( |
| 213 | 'icon_style_section', |
| 214 | [ |
| 215 | 'label' => __( 'Icon', 'auxin-elements' ), |
| 216 | 'tab' => Controls_Manager::TAB_STYLE |
| 217 | ] |
| 218 | ); |
| 219 | |
| 220 | $this->start_controls_tabs( 'icon_styles' ); |
| 221 | |
| 222 | $this->start_controls_tab( |
| 223 | 'icon_style_normal', |
| 224 | [ |
| 225 | 'label' => __( 'Normal' , 'auxin-elements' ) |
| 226 | ] |
| 227 | ); |
| 228 | |
| 229 | $this->add_control( |
| 230 | 'icon_color_normal', |
| 231 | [ |
| 232 | 'label' => __( 'Color', 'auxin-elements' ), |
| 233 | 'type' => Controls_Manager::COLOR, |
| 234 | 'selectors' => [ |
| 235 | '{{WRAPPER}} .aux-search-submit i' => 'color: {{VALUE}};' |
| 236 | ] |
| 237 | ] |
| 238 | ); |
| 239 | |
| 240 | $this->add_responsive_control( |
| 241 | 'icon_size_normal', |
| 242 | [ |
| 243 | 'label' => __( 'Size', 'auxin-elements' ), |
| 244 | 'type' => Controls_Manager::SLIDER, |
| 245 | 'size_units' => [ 'px', '%' ], |
| 246 | 'range' => [ |
| 247 | 'px' => [ |
| 248 | 'min' => 16, |
| 249 | 'max' => 512, |
| 250 | 'step' => 2, |
| 251 | ], |
| 252 | '%' => [ |
| 253 | 'min' => 0, |
| 254 | 'max' => 100, |
| 255 | ], |
| 256 | ], |
| 257 | 'default' => [ |
| 258 | 'size' => 22, |
| 259 | 'unit' => 'px' |
| 260 | ], |
| 261 | 'selectors' => [ |
| 262 | '{{WRAPPER}} .aux-search-submit i' => 'font-size: {{SIZE}}{{UNIT}};', |
| 263 | ], |
| 264 | ] |
| 265 | ); |
| 266 | |
| 267 | $this->end_controls_tab(); |
| 268 | |
| 269 | $this->start_controls_tab( |
| 270 | 'icon_style_hover', |
| 271 | [ |
| 272 | 'label' => __( 'Hover' , 'auxin-elements' ) |
| 273 | ] |
| 274 | ); |
| 275 | |
| 276 | $this->add_control( |
| 277 | 'icon_color_hover', |
| 278 | [ |
| 279 | 'label' => __( 'Color', 'auxin-elements' ), |
| 280 | 'type' => Controls_Manager::COLOR, |
| 281 | 'selectors' => [ |
| 282 | '{{WRAPPER}} .aux-search-submit:hover i' => 'color: {{VALUE}};' |
| 283 | ] |
| 284 | ] |
| 285 | ); |
| 286 | |
| 287 | $this->add_responsive_control( |
| 288 | 'icon_size_hover', |
| 289 | [ |
| 290 | 'label' => __( 'Size', 'auxin-elements' ), |
| 291 | 'type' => Controls_Manager::SLIDER, |
| 292 | 'size_units' => [ 'px', '%' ], |
| 293 | 'range' => [ |
| 294 | 'px' => [ |
| 295 | 'min' => 16, |
| 296 | 'max' => 512, |
| 297 | 'step' => 2, |
| 298 | ], |
| 299 | '%' => [ |
| 300 | 'min' => 0, |
| 301 | 'max' => 100, |
| 302 | ], |
| 303 | ], |
| 304 | 'selectors' => [ |
| 305 | '{{WRAPPER}} .aux-search-submit:hover i' => 'font-size: {{SIZE}}{{UNIT}};', |
| 306 | ], |
| 307 | ] |
| 308 | ); |
| 309 | |
| 310 | $this->end_controls_tab(); |
| 311 | |
| 312 | $this->end_controls_tabs(); |
| 313 | |
| 314 | $this->end_controls_section(); |
| 315 | |
| 316 | /* Text Style Section |
| 317 | /*-------------------------------------*/ |
| 318 | $this->start_controls_section( |
| 319 | 'text_style_section', |
| 320 | [ |
| 321 | 'label' => __( 'Text', 'auxin-elements' ), |
| 322 | 'tab' => Controls_Manager::TAB_STYLE, |
| 323 | 'condition' => ['text!' => ''] |
| 324 | ] |
| 325 | ); |
| 326 | |
| 327 | $this->start_controls_tabs( 'text_styles' ); |
| 328 | |
| 329 | $this->start_controls_tab( |
| 330 | 'text_style_normal', |
| 331 | [ |
| 332 | 'label' => __( 'Normal' , 'auxin-elements' ) |
| 333 | ] |
| 334 | ); |
| 335 | |
| 336 | $this->add_control( |
| 337 | 'text_color_normal', |
| 338 | [ |
| 339 | 'label' => __( 'Color', 'auxin-elements' ), |
| 340 | 'type' => Controls_Manager::COLOR, |
| 341 | 'selectors' => [ |
| 342 | '{{WRAPPER}} .aux-search-submit' => 'color: {{VALUE}};' |
| 343 | ] |
| 344 | ] |
| 345 | ); |
| 346 | |
| 347 | $this->add_group_control( |
| 348 | Group_Control_Typography::get_type(), |
| 349 | [ |
| 350 | 'name' => 'text_typo_normal', |
| 351 | 'scheme' => Scheme_Typography::TYPOGRAPHY_1, |
| 352 | 'selector' => '{{WRAPPER}} .aux-search-submit' |
| 353 | ] |
| 354 | ); |
| 355 | |
| 356 | $this->add_group_control( |
| 357 | Group_Control_Text_Shadow::get_type(), |
| 358 | [ |
| 359 | 'name' => 'text_text_shadow_normal', |
| 360 | 'selector' => '{{WRAPPER}} .aux-search-submit' |
| 361 | ] |
| 362 | ); |
| 363 | |
| 364 | $this->end_controls_tab(); |
| 365 | |
| 366 | $this->start_controls_tab( |
| 367 | 'text_style_hover', |
| 368 | [ |
| 369 | 'label' => __( 'Hover' , 'auxin-elements' ) |
| 370 | ] |
| 371 | ); |
| 372 | |
| 373 | $this->add_control( |
| 374 | 'text_color_hover', |
| 375 | [ |
| 376 | 'label' => __( 'Color', 'auxin-elements' ), |
| 377 | 'type' => Controls_Manager::COLOR, |
| 378 | 'selectors' => [ |
| 379 | '{{WRAPPER}} .aux-search-submit:hover' => 'color: {{VALUE}};' |
| 380 | ] |
| 381 | ] |
| 382 | ); |
| 383 | |
| 384 | $this->add_group_control( |
| 385 | Group_Control_Typography::get_type(), |
| 386 | [ |
| 387 | 'name' => 'text_typo_hover', |
| 388 | 'scheme' => Scheme_Typography::TYPOGRAPHY_1, |
| 389 | 'selector' => '{{WRAPPER}} .aux-search-submit:hover' |
| 390 | ] |
| 391 | ); |
| 392 | |
| 393 | $this->add_group_control( |
| 394 | Group_Control_Text_Shadow::get_type(), |
| 395 | [ |
| 396 | 'name' => 'text_text_shadow_hover', |
| 397 | 'selector' => '{{WRAPPER}} .aux-search-submit:hover' |
| 398 | ] |
| 399 | ); |
| 400 | |
| 401 | $this->end_controls_tab(); |
| 402 | |
| 403 | $this->end_controls_tabs(); |
| 404 | |
| 405 | $this->end_controls_section(); |
| 406 | |
| 407 | /* Button Style Section |
| 408 | /*-------------------------------------*/ |
| 409 | |
| 410 | $this->start_controls_section( |
| 411 | 'button_style_section', |
| 412 | [ |
| 413 | 'label' => __( 'Button', 'auxin-elements' ), |
| 414 | 'tab' => Controls_Manager::TAB_STYLE, |
| 415 | ] |
| 416 | ); |
| 417 | |
| 418 | $this->start_controls_tabs( 'button_styles' ); |
| 419 | |
| 420 | $this->start_controls_tab( |
| 421 | 'button_style_normal', |
| 422 | [ |
| 423 | 'label' => __( 'Normal' , 'auxin-elements' ) |
| 424 | ] |
| 425 | ); |
| 426 | |
| 427 | $this->add_group_control( |
| 428 | Group_Control_Background::get_type(), |
| 429 | [ |
| 430 | 'name' => 'button_bg_normal', |
| 431 | 'selector' => '{{WRAPPER}} .aux-search-submit', |
| 432 | 'types' => [ 'classic', 'gradient'], |
| 433 | 'separator' => 'after' |
| 434 | ] |
| 435 | ); |
| 436 | |
| 437 | $this->add_responsive_control( |
| 438 | 'button_padding_normal', |
| 439 | [ |
| 440 | 'label' => __( 'Padding', 'auxin-elements' ), |
| 441 | 'type' => Controls_Manager::DIMENSIONS, |
| 442 | 'size_units' => [ 'px', '%' ], |
| 443 | 'selectors' => [ |
| 444 | '{{WRAPPER}} .aux-search-submit' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 445 | ], |
| 446 | 'separator' => 'before' |
| 447 | ] |
| 448 | ); |
| 449 | |
| 450 | $this->add_group_control( |
| 451 | Group_Control_Border::get_type(), |
| 452 | [ |
| 453 | 'name' => 'button_border_normal', |
| 454 | 'selector' => '{{WRAPPER}} .aux-search-submit', |
| 455 | 'separator' => 'none', |
| 456 | 'separator' => 'before' |
| 457 | ] |
| 458 | ); |
| 459 | |
| 460 | $this->add_responsive_control( |
| 461 | 'button_border_radius_normal', |
| 462 | [ |
| 463 | 'label' => __( 'Border Radius', 'auxin-elements' ), |
| 464 | 'type' => Controls_Manager::DIMENSIONS, |
| 465 | 'size_units' => [ 'px', 'em', '%' ], |
| 466 | 'allowed_dimensions' => 'all', |
| 467 | 'separator' => 'before', |
| 468 | 'selectors' => [ |
| 469 | '{{WRAPPER}} .aux-search-submit' => 'border-radius:{{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' |
| 470 | ], |
| 471 | ] |
| 472 | ); |
| 473 | |
| 474 | $this->add_group_control( |
| 475 | Group_Control_Box_Shadow::get_type(), |
| 476 | [ |
| 477 | 'name' => 'button_box_shadow_normal', |
| 478 | 'selector' => '{{WRAPPER}} .aux-search-submit', |
| 479 | 'separator' => 'before' |
| 480 | ] |
| 481 | ); |
| 482 | |
| 483 | $this->end_controls_tab(); |
| 484 | |
| 485 | $this->start_controls_tab( |
| 486 | 'button_style_hover', |
| 487 | [ |
| 488 | 'label' => __( 'Hover' , 'auxin-elements' ) |
| 489 | ] |
| 490 | ); |
| 491 | |
| 492 | $this->add_group_control( |
| 493 | Group_Control_Background::get_type(), |
| 494 | [ |
| 495 | 'name' => 'button_bg_hover', |
| 496 | 'selector' => '{{WRAPPER}} .aux-search-submit: hover', |
| 497 | 'types' => [ 'classic', 'gradient'], |
| 498 | 'separator' => 'after' |
| 499 | ] |
| 500 | ); |
| 501 | |
| 502 | $this->add_responsive_control( |
| 503 | 'button_padding_hover', |
| 504 | [ |
| 505 | 'label' => __( 'Padding', 'auxin-elements' ), |
| 506 | 'type' => Controls_Manager::DIMENSIONS, |
| 507 | 'size_units' => [ 'px', '%' ], |
| 508 | 'selectors' => [ |
| 509 | '{{WRAPPER}} .aux-search-submit:hover' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 510 | ], |
| 511 | 'separator' => 'before' |
| 512 | ] |
| 513 | ); |
| 514 | |
| 515 | $this->add_group_control( |
| 516 | Group_Control_Border::get_type(), |
| 517 | [ |
| 518 | 'name' => 'button_border_hover', |
| 519 | 'selector' => '{{WRAPPER}} .aux-search-submit:hover', |
| 520 | 'separator' => 'before' |
| 521 | ] |
| 522 | ); |
| 523 | |
| 524 | $this->add_responsive_control( |
| 525 | 'button_border_radius_hover', |
| 526 | [ |
| 527 | 'label' => __( 'Border Radius', 'auxin-elements' ), |
| 528 | 'type' => Controls_Manager::DIMENSIONS, |
| 529 | 'size_units' => [ 'px', 'em', '%' ], |
| 530 | 'selectors' => [ |
| 531 | '{{WRAPPER}} .aux-search-submit:hover' => 'border-radius:{{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' |
| 532 | ], |
| 533 | 'allowed_dimensions' => 'all', |
| 534 | 'separator' => 'before' |
| 535 | ] |
| 536 | ); |
| 537 | $this->add_group_control( |
| 538 | Group_Control_Box_Shadow::get_type(), |
| 539 | [ |
| 540 | 'name' => 'button_box_shadow_hover', |
| 541 | 'selector' => '{{WRAPPER}} .aux-search-submit:hover', |
| 542 | 'separator' => 'before' |
| 543 | ] |
| 544 | ); |
| 545 | |
| 546 | $this->end_controls_tab(); |
| 547 | |
| 548 | $this->end_controls_tabs(); |
| 549 | |
| 550 | $this->add_control( |
| 551 | 'button_cursor', |
| 552 | [ |
| 553 | 'label' => __( 'Cursor', 'auxin-elements' ), |
| 554 | 'type' => Controls_Manager::SELECT, |
| 555 | 'options' => [ |
| 556 | 'default' => __( 'Default', 'auxin-elements' ), |
| 557 | 'pointer' => __( 'Pointer', 'auxin-elements' ), |
| 558 | 'zoom-in' => __( 'Zoom', 'auxin-elements' ), |
| 559 | 'help' => __( 'Help', 'auxin-elements' ) |
| 560 | ], |
| 561 | 'default' => 'pointer', |
| 562 | 'selectors' => [ |
| 563 | '{{WRAPPER}} .aux-search-submit' => 'cursor: {{VALUE}};' |
| 564 | ], |
| 565 | 'separator' => 'before' |
| 566 | ] |
| 567 | ); |
| 568 | |
| 569 | $this->end_controls_section(); |
| 570 | |
| 571 | /* Input Style Section |
| 572 | /*-------------------------------------*/ |
| 573 | |
| 574 | $this->start_controls_section( |
| 575 | 'input_style_section', |
| 576 | [ |
| 577 | 'label' => __( 'Fullscreen Search Input', 'auxin-elements' ), |
| 578 | 'tab' => Controls_Manager::TAB_STYLE |
| 579 | ] |
| 580 | ); |
| 581 | |
| 582 | |
| 583 | $this->add_control( |
| 584 | 'input_color', |
| 585 | [ |
| 586 | 'label' => __( 'Text Color', 'auxin-elements' ), |
| 587 | 'type' => Controls_Manager::COLOR, |
| 588 | 'selectors' => [ |
| 589 | '{{WRAPPER}} .aux-search-popup .aux-search-field' => 'color: {{VALUE}};' |
| 590 | ], |
| 591 | 'separator' => 'after' |
| 592 | ] |
| 593 | ); |
| 594 | |
| 595 | $this->add_group_control( |
| 596 | Group_Control_Typography::get_type(), |
| 597 | [ |
| 598 | 'name' => 'input_typo', |
| 599 | 'scheme' => Scheme_Typography::TYPOGRAPHY_1, |
| 600 | 'selector' => '{{WRAPPER}} .aux-search-popup .aux-search-field', |
| 601 | 'separator' => 'before' |
| 602 | ] |
| 603 | ); |
| 604 | |
| 605 | $this->add_responsive_control( |
| 606 | 'input_padding', |
| 607 | [ |
| 608 | 'label' => __( 'Padding', 'auxin-elements' ), |
| 609 | 'type' => Controls_Manager::DIMENSIONS, |
| 610 | 'size_units' => [ 'px', '%' ], |
| 611 | 'selectors' => [ |
| 612 | '{{WRAPPER}} .aux-search-popup .aux-search-field' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 613 | ], |
| 614 | 'separator' => 'before' |
| 615 | ] |
| 616 | ); |
| 617 | |
| 618 | $this->add_responsive_control( |
| 619 | 'input_border_size', |
| 620 | [ |
| 621 | 'label' => __( 'Border Size', 'auxin-elements' ), |
| 622 | 'type' => Controls_Manager::SLIDER, |
| 623 | 'size_units' => [ 'px' ], |
| 624 | 'range' => [ |
| 625 | 'px' => [ |
| 626 | 'min' => 0, |
| 627 | 'max' => 20, |
| 628 | 'step' => 1, |
| 629 | ], |
| 630 | ], |
| 631 | 'default' => [ |
| 632 | 'size' => 2, |
| 633 | 'unit' => 'px' |
| 634 | ], |
| 635 | 'selectors' => [ |
| 636 | '{{WRAPPER}} .aux-search-popup .aux-search-input-form' => 'border-width: {{SIZE}}{{UNIT}};', |
| 637 | ], |
| 638 | 'separator' => 'before' |
| 639 | ] |
| 640 | ); |
| 641 | |
| 642 | $this->add_control( |
| 643 | 'input_border_color', |
| 644 | [ |
| 645 | 'label' => __( 'Border Color', 'auxin-elements' ), |
| 646 | 'type' => Controls_Manager::COLOR, |
| 647 | 'selectors' => [ |
| 648 | '{{WRAPPER}} .aux-search-popup .aux-search-input-form' => 'border-color: {{VALUE}};' |
| 649 | ], |
| 650 | 'separator' => 'before' |
| 651 | ] |
| 652 | ); |
| 653 | |
| 654 | $this->add_responsive_control( |
| 655 | 'input_icon_size', |
| 656 | [ |
| 657 | 'label' => __( 'Icon Size', 'auxin-elements' ), |
| 658 | 'type' => Controls_Manager::SLIDER, |
| 659 | 'size_units' => [ 'px', '%' ], |
| 660 | 'range' => [ |
| 661 | 'px' => [ |
| 662 | 'min' => 16, |
| 663 | 'max' => 512, |
| 664 | 'step' => 2, |
| 665 | ], |
| 666 | '%' => [ |
| 667 | 'min' => 0, |
| 668 | 'max' => 100, |
| 669 | ], |
| 670 | ], |
| 671 | 'default' => [ |
| 672 | 'size' => 30, |
| 673 | 'unit' => 'px' |
| 674 | ], |
| 675 | 'selectors' => [ |
| 676 | '{{WRAPPER}} .aux-search-popup .aux-submit-icon-container:before' => 'font-size: {{SIZE}}{{UNIT}};', |
| 677 | ], |
| 678 | 'separator' => 'before' |
| 679 | ] |
| 680 | ); |
| 681 | |
| 682 | $this->add_control( |
| 683 | 'input_icon_color', |
| 684 | [ |
| 685 | 'label' => __( 'Icon Color', 'auxin-elements' ), |
| 686 | 'type' => Controls_Manager::COLOR, |
| 687 | 'selectors' => [ |
| 688 | '{{WRAPPER}} .aux-search-popup .aux-submit-icon-container:before' => 'color: {{VALUE}} !important;' |
| 689 | ], |
| 690 | 'separator' => 'before' |
| 691 | ] |
| 692 | ); |
| 693 | |
| 694 | $this->add_group_control( |
| 695 | Group_Control_Background::get_type(), |
| 696 | [ |
| 697 | 'name' => 'input_bg', |
| 698 | 'selector' => '{{WRAPPER}} .aux-search-popup', |
| 699 | 'types' => [ 'classic', 'gradient'], |
| 700 | 'separator' => 'before', |
| 701 | 'fields_options' => [ |
| 702 | 'background' => [ |
| 703 | 'label' => __( 'Overlay Color', 'auxin-elements' ), |
| 704 | ], |
| 705 | ], |
| 706 | ] |
| 707 | ); |
| 708 | |
| 709 | $this->end_controls_section(); |
| 710 | |
| 711 | /* Input Style Section |
| 712 | /*-------------------------------------*/ |
| 713 | |
| 714 | $this->start_controls_section( |
| 715 | 'close_style_section', |
| 716 | [ |
| 717 | 'label' => __( 'Fullscreen Close Button', 'auxin-elements' ), |
| 718 | 'tab' => Controls_Manager::TAB_STYLE |
| 719 | ] |
| 720 | ); |
| 721 | |
| 722 | $this->add_responsive_control( |
| 723 | 'close_position_top', |
| 724 | [ |
| 725 | 'label' => __('Top Position','auxin-elements' ), |
| 726 | 'type' => Controls_Manager::SLIDER, |
| 727 | 'size_units' => ['px', 'em', '%'], |
| 728 | 'range' => [ |
| 729 | 'px' => [ |
| 730 | 'min' => -2000, |
| 731 | 'max' => 2000, |
| 732 | 'step' => 1 |
| 733 | ], |
| 734 | '%' => [ |
| 735 | 'min' => -100, |
| 736 | 'max' => 100, |
| 737 | 'step' => 1 |
| 738 | ], |
| 739 | 'em' => [ |
| 740 | 'min' => -150, |
| 741 | 'max' => 150, |
| 742 | 'step' => 1 |
| 743 | ] |
| 744 | ], |
| 745 | 'selectors' => [ |
| 746 | '{{WRAPPER}} .aux-search-popup .aux-panel-close' => 'top:{{SIZE}}{{UNIT}};' |
| 747 | ], |
| 748 | ] |
| 749 | ); |
| 750 | |
| 751 | $this->add_responsive_control( |
| 752 | 'close_position_right', |
| 753 | [ |
| 754 | 'label' => __('Right Position','auxin-elements' ), |
| 755 | 'type' => Controls_Manager::SLIDER, |
| 756 | 'size_units' => ['px', 'em', '%'], |
| 757 | 'range' => [ |
| 758 | 'px' => [ |
| 759 | 'min' => -2000, |
| 760 | 'max' => 2000, |
| 761 | 'step' => 1 |
| 762 | ], |
| 763 | '%' => [ |
| 764 | 'min' => -100, |
| 765 | 'max' => 100, |
| 766 | 'step' => 1 |
| 767 | ], |
| 768 | 'em' => [ |
| 769 | 'min' => -150, |
| 770 | 'max' => 150, |
| 771 | 'step' => 1 |
| 772 | ] |
| 773 | ], |
| 774 | 'selectors' => [ |
| 775 | '{{WRAPPER}} .aux-search-popup .aux-panel-close' => 'right:{{SIZE}}{{UNIT}};' |
| 776 | ], |
| 777 | ] |
| 778 | ); |
| 779 | |
| 780 | $this->end_controls_section(); |
| 781 | } |
| 782 | |
| 783 | /** |
| 784 | * Render Search Input. |
| 785 | * |
| 786 | * Render button widget text. |
| 787 | * |
| 788 | * @since 1.5.0 |
| 789 | * @access protected |
| 790 | */ |
| 791 | protected function render_search_button( $args = [] ) { ; |
| 792 | |
| 793 | $defaults = [ |
| 794 | 'submit_class' => 'aux-search-submit aux-search-fullscreen', |
| 795 | 'submit_text' => '', |
| 796 | 'wrapper_class' => 'aux-modern-search-wrapper', |
| 797 | 'icon' => 'auxicon-search-4', |
| 798 | 'target' => '.aux-search-popup-' . $this->get_id(), |
| 799 | 'use_ajax' => false |
| 800 | ]; |
| 801 | |
| 802 | $args = wp_parse_args( $args, $defaults ); |
| 803 | |
| 804 | $this->add_render_attribute( 'wrapper', 'class', $args['wrapper_class'] ); |
| 805 | $this->add_render_attribute( 'button', 'class', $args['submit_class'] ); |
| 806 | $this->add_render_attribute( 'button', 'data-target', $args['target'] ); |
| 807 | $this->add_render_attribute( 'submit_text', 'class', 'aux-submit-text' ); |
| 808 | $this->add_render_attribute( 'icon', 'class', $args['icon'] ); |
| 809 | ?> |
| 810 | <div <?php echo $this->get_render_attribute_string( 'wrapper' );?> > |
| 811 | <button <?php echo $this->get_render_attribute_string( 'button' );?> > |
| 812 | <i <?php echo $this->get_render_attribute_string( 'icon' );?>></i> |
| 813 | <span <?php echo $this->get_render_attribute_string( 'submit_text' );?> ><?php echo $args['submit_text']; ?></span> |
| 814 | </button> |
| 815 | </div> |
| 816 | <?php |
| 817 | |
| 818 | } |
| 819 | /** |
| 820 | * Render Search Overlay. |
| 821 | * |
| 822 | * Render button widget text. |
| 823 | * |
| 824 | * @since 1.5.0 |
| 825 | * @access protected |
| 826 | */ |
| 827 | protected function render_search_overlay( $args = [] ) { ; |
| 828 | |
| 829 | $defaults = [ |
| 830 | 'wrapper_class' => 'aux-search-popup aux-search-popup-' . $this->get_id(), |
| 831 | 'use_ajax' => false, |
| 832 | 'post_types' => [] |
| 833 | ]; |
| 834 | |
| 835 | $args = wp_parse_args( $args, $defaults ); |
| 836 | |
| 837 | $form_args = [ |
| 838 | 'use_ajax' => $args['use_ajax'], |
| 839 | 'display_submit' => $args['display_submit'], |
| 840 | 'display_fill' => $args['display_fill'], |
| 841 | 'display_cats' => $args['display_cats'], |
| 842 | 'post_types' => $args['post_types'] |
| 843 | ]; |
| 844 | |
| 845 | $this->add_render_attribute( 'overlay_wrapper', 'class', $args['wrapper_class'] ); |
| 846 | ?> |
| 847 | <div <?php echo $this->get_render_attribute_string( 'overlay_wrapper' );?>> |
| 848 | <div class="aux-panel-close"> |
| 849 | <div class="aux-close aux-cross-symbol aux-thick-medium"></div> |
| 850 | </div> |
| 851 | <div class="aux-search-popup-content"> |
| 852 | <?php $this->render_search_form( $form_args ) ;?> |
| 853 | <?php if ( $args['use_ajax'] ) { ;?> |
| 854 | <div class="aux-search-ajax-container"> |
| 855 | <div class="aux-search-ajax-output"></div> |
| 856 | <div class="aux-loading-spinner aux-spinner-hide"> |
| 857 | <div class="aux-loading-loop"> |
| 858 | <svg class="aux-circle" width="100%" height="100%" viewBox="0 0 42 42"> |
| 859 | <circle class="aux-stroke-bg" r="20" cx="21" cy="21" fill="none"></circle> |
| 860 | <circle class="aux-progress" r="20" cx="21" cy="21" fill="none" transform="rotate(-90 21 21)"></circle> |
| 861 | </svg> |
| 862 | </div> |
| 863 | </div> |
| 864 | </div> |
| 865 | <?php };?> |
| 866 | </div> |
| 867 | </div> |
| 868 | <?php |
| 869 | } |
| 870 | |
| 871 | /** |
| 872 | * Render Search Overlay. |
| 873 | * |
| 874 | * Render button widget text. |
| 875 | * |
| 876 | * @since 1.5.0 |
| 877 | * @access protected |
| 878 | */ |
| 879 | protected function render_search_form( $args = [] ) { ; |
| 880 | |
| 881 | $defaults = [ |
| 882 | 'wrapper_class' => 'aux-search-form', |
| 883 | 'use_ajax' => false, |
| 884 | 'display_submit' => true, |
| 885 | 'display_fill' => false, |
| 886 | 'display_cats' => false, |
| 887 | 'post_types' => [] |
| 888 | ]; |
| 889 | |
| 890 | $args = wp_parse_args( $args, $defaults ); |
| 891 | |
| 892 | $this->add_render_attribute( 'form_wrapper', 'class', $args['wrapper_class'] ); |
| 893 | |
| 894 | if ( $args['use_ajax'] ) { |
| 895 | $this->add_render_attribute( 'form_wrapper', 'class', 'aux-search-ajax' ); |
| 896 | } |
| 897 | |
| 898 | ?> |
| 899 | <div <?php echo $this->get_render_attribute_string( 'form_wrapper' );?>> |
| 900 | <form action="<?php echo esc_url( home_url( '/' ) ); ?>" method="get" > |
| 901 | <div class="aux-search-input-form"> |
| 902 | <input type="text" class="aux-search-field" placeholder="<?php esc_attr_e('Search...', 'auxin-elements' ); ?>" name="s" autocomplete="off" /> |
| 903 | <?php if ( $args['display_cats'] ) { ;?> |
| 904 | <?php $this->render_category( ['post_types' => $args['post_types'] ] );?> |
| 905 | <?php };?> |
| 906 | <?php if ( $args['display_submit'] ) { ;?> |
| 907 | <?php if ( $args['display_fill'] ) { ;?> |
| 908 | <input type="submit" class="aux-fill-search-submit" value="<?php esc_attr_e( 'Search', THEME_DOMAIN ); ?>" > |
| 909 | <?php } else { ;?> |
| 910 | <div class="aux-submit-icon-container auxicon-search-4"> |
| 911 | <input type="submit" class="aux-iconic-search-submit" value="<?php esc_attr_e( 'Search', 'auxin-elements' ); ?>" > |
| 912 | </div> |
| 913 | <?php };?> |
| 914 | <?php };?> |
| 915 | </div> |
| 916 | </form> |
| 917 | </div> |
| 918 | <?php |
| 919 | } |
| 920 | |
| 921 | /** |
| 922 | * Render Search Overlay. |
| 923 | * |
| 924 | * Render button widget text. |
| 925 | * |
| 926 | * @since 1.5.0 |
| 927 | * @access protected |
| 928 | */ |
| 929 | protected function render_category( $args ) { |
| 930 | $taxonomies = $args['post_types']; |
| 931 | $post_types = []; |
| 932 | $options_output = ''; |
| 933 | |
| 934 | foreach ( $taxonomies as $taxonomy ) { |
| 935 | |
| 936 | $terms = get_terms( $taxonomy ); |
| 937 | $post_type = get_taxonomy( $taxonomy )->object_type; |
| 938 | $post_types = array_merge( $post_types, $post_type ); |
| 939 | |
| 940 | foreach ($terms as $term => $term_args) { |
| 941 | $options_output .= '<option data-post-type="' . esc_attr( wp_json_encode( $post_type ) ) . '" data-taxonomy="' . esc_attr( wp_json_encode( [$term_args->taxonomy] ) ) . '" value="'. esc_attr( $term_args->term_id ) .'">'. esc_html( $term_args->name ) .'</option>'; |
| 942 | } |
| 943 | |
| 944 | } |
| 945 | |
| 946 | $options_output = '<option value="all" data-taxonomy="' . esc_attr ( wp_json_encode( $taxonomies ) ) . '" data-post-type="' . esc_attr ( wp_json_encode( $post_types ) ) . '">' . __('All Categories', THEME_DOMAIN) . '</option>' . $options_output ; |
| 947 | |
| 948 | $output = '<div class="aux-search-cats">'; |
| 949 | $output .= '<select class="aux-modern-search-cats" name="cat">' . $options_output . '</select>'; |
| 950 | $output .= '</div>'; |
| 951 | |
| 952 | echo $output; |
| 953 | } |
| 954 | |
| 955 | /** |
| 956 | * Get All Active Post Types. |
| 957 | * |
| 958 | * @since 1.5.0 |
| 959 | * @access protected |
| 960 | */ |
| 961 | protected function get_post_types() { |
| 962 | return auxin_general_post_types_category_slug(); |
| 963 | } |
| 964 | |
| 965 | /** |
| 966 | * Render Modern Search widget output on the frontend. |
| 967 | * |
| 968 | * Written in PHP and used to generate the final HTML. |
| 969 | * |
| 970 | * @since 1.0.0 |
| 971 | * @access protected |
| 972 | */ |
| 973 | protected function render() { |
| 974 | $settings = $this->get_settings_for_display(); |
| 975 | |
| 976 | echo '<div class="aux-modern-search">'; |
| 977 | |
| 978 | $this->render_search_button( [ |
| 979 | 'submit_text' => $settings['text'], |
| 980 | 'icon' => $settings['icon'] |
| 981 | ] ); |
| 982 | |
| 983 | $this->render_search_overlay( [ |
| 984 | 'use_ajax' => auxin_is_true( $settings['use_ajax'] ), |
| 985 | 'display_submit' => auxin_is_true( $settings['fullscreen_display_submit'] ), |
| 986 | 'display_cats' => auxin_is_true( $settings['fullscreen_display_cats']), |
| 987 | 'display_fill' => auxin_is_true( $settings['fullscreen_display_fill_submit'] ), |
| 988 | 'post_types' => $settings['post_types'] |
| 989 | ] |
| 990 | ); |
| 991 | |
| 992 | echo '</div>'; |
| 993 | } |
| 994 | |
| 995 | } |