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
4 years ago
shopping-cart.php
4 years ago
site-title.php
3 years ago
modern-search.php
1117 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\Core\Schemes\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' => '', |
| 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' => [ 'post' ], |
| 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' => 'yes', |
| 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->add_control( |
| 208 | 'search_field_placeholder_text', |
| 209 | [ |
| 210 | 'label' => __( 'Custom Placeholder Text', 'auxin-elements' ), |
| 211 | 'type' => Controls_Manager::TEXT, |
| 212 | 'default' => '', |
| 213 | 'placeholder' => __( 'Search ...', 'auxin-elements' ), |
| 214 | ] |
| 215 | ); |
| 216 | |
| 217 | $this->add_control( |
| 218 | 'search_field_title', |
| 219 | [ |
| 220 | 'label' => __( 'Search Title', 'auxin-elements' ), |
| 221 | 'type' => Controls_Manager::TEXT, |
| 222 | 'default' => '', |
| 223 | 'placeholder' => __( 'Type to Search', 'auxin-elements' ), |
| 224 | ] |
| 225 | ); |
| 226 | |
| 227 | |
| 228 | $this->end_controls_section(); |
| 229 | |
| 230 | /* Icon Style Section |
| 231 | /*-------------------------------------*/ |
| 232 | |
| 233 | $this->start_controls_section( |
| 234 | 'icon_style_section', |
| 235 | [ |
| 236 | 'label' => __( 'Icon', 'auxin-elements' ), |
| 237 | 'tab' => Controls_Manager::TAB_STYLE |
| 238 | ] |
| 239 | ); |
| 240 | |
| 241 | $this->start_controls_tabs( 'icon_styles' ); |
| 242 | |
| 243 | $this->start_controls_tab( |
| 244 | 'icon_style_normal', |
| 245 | [ |
| 246 | 'label' => __( 'Normal' , 'auxin-elements' ) |
| 247 | ] |
| 248 | ); |
| 249 | |
| 250 | $this->add_control( |
| 251 | 'icon_color_normal', |
| 252 | [ |
| 253 | 'label' => __( 'Color', 'auxin-elements' ), |
| 254 | 'type' => Controls_Manager::COLOR, |
| 255 | 'selectors' => [ |
| 256 | '{{WRAPPER}} .aux-search-submit i' => 'color: {{VALUE}};' |
| 257 | ] |
| 258 | ] |
| 259 | ); |
| 260 | |
| 261 | $this->add_responsive_control( |
| 262 | 'icon_size_normal', |
| 263 | [ |
| 264 | 'label' => __( 'Size', 'auxin-elements' ), |
| 265 | 'type' => Controls_Manager::SLIDER, |
| 266 | 'size_units' => [ 'px', '%' ], |
| 267 | 'range' => [ |
| 268 | 'px' => [ |
| 269 | 'min' => 16, |
| 270 | 'max' => 512, |
| 271 | 'step' => 2, |
| 272 | ], |
| 273 | '%' => [ |
| 274 | 'min' => 0, |
| 275 | 'max' => 100, |
| 276 | ], |
| 277 | ], |
| 278 | 'default' => [ |
| 279 | 'size' => 22, |
| 280 | 'unit' => 'px' |
| 281 | ], |
| 282 | 'selectors' => [ |
| 283 | '{{WRAPPER}} .aux-search-submit i' => 'font-size: {{SIZE}}{{UNIT}};', |
| 284 | ], |
| 285 | ] |
| 286 | ); |
| 287 | |
| 288 | $this->end_controls_tab(); |
| 289 | |
| 290 | $this->start_controls_tab( |
| 291 | 'icon_style_hover', |
| 292 | [ |
| 293 | 'label' => __( 'Hover' , 'auxin-elements' ) |
| 294 | ] |
| 295 | ); |
| 296 | |
| 297 | $this->add_control( |
| 298 | 'icon_color_hover', |
| 299 | [ |
| 300 | 'label' => __( 'Color', 'auxin-elements' ), |
| 301 | 'type' => Controls_Manager::COLOR, |
| 302 | 'selectors' => [ |
| 303 | '{{WRAPPER}} .aux-search-submit:hover i' => 'color: {{VALUE}};' |
| 304 | ] |
| 305 | ] |
| 306 | ); |
| 307 | |
| 308 | $this->add_responsive_control( |
| 309 | 'icon_size_hover', |
| 310 | [ |
| 311 | 'label' => __( 'Size', 'auxin-elements' ), |
| 312 | 'type' => Controls_Manager::SLIDER, |
| 313 | 'size_units' => [ 'px', '%' ], |
| 314 | 'range' => [ |
| 315 | 'px' => [ |
| 316 | 'min' => 16, |
| 317 | 'max' => 512, |
| 318 | 'step' => 2, |
| 319 | ], |
| 320 | '%' => [ |
| 321 | 'min' => 0, |
| 322 | 'max' => 100, |
| 323 | ], |
| 324 | ], |
| 325 | 'selectors' => [ |
| 326 | '{{WRAPPER}} .aux-search-submit:hover i' => 'font-size: {{SIZE}}{{UNIT}};', |
| 327 | ], |
| 328 | ] |
| 329 | ); |
| 330 | |
| 331 | $this->end_controls_tab(); |
| 332 | |
| 333 | $this->end_controls_tabs(); |
| 334 | |
| 335 | $this->end_controls_section(); |
| 336 | |
| 337 | /* Text Style Section |
| 338 | /*-------------------------------------*/ |
| 339 | $this->start_controls_section( |
| 340 | 'text_style_section', |
| 341 | [ |
| 342 | 'label' => __( 'Text', 'auxin-elements' ), |
| 343 | 'tab' => Controls_Manager::TAB_STYLE, |
| 344 | 'condition' => ['text!' => ''] |
| 345 | ] |
| 346 | ); |
| 347 | |
| 348 | $this->start_controls_tabs( 'text_styles' ); |
| 349 | |
| 350 | $this->start_controls_tab( |
| 351 | 'text_style_normal', |
| 352 | [ |
| 353 | 'label' => __( 'Normal' , 'auxin-elements' ) |
| 354 | ] |
| 355 | ); |
| 356 | |
| 357 | $this->add_control( |
| 358 | 'text_color_normal', |
| 359 | [ |
| 360 | 'label' => __( 'Color', 'auxin-elements' ), |
| 361 | 'type' => Controls_Manager::COLOR, |
| 362 | 'selectors' => [ |
| 363 | '{{WRAPPER}} .aux-search-submit' => 'color: {{VALUE}};' |
| 364 | ] |
| 365 | ] |
| 366 | ); |
| 367 | |
| 368 | $this->add_group_control( |
| 369 | Group_Control_Typography::get_type(), |
| 370 | [ |
| 371 | 'name' => 'text_typo_normal', |
| 372 | 'scheme' => Typography::TYPOGRAPHY_1, |
| 373 | 'selector' => '{{WRAPPER}} .aux-search-submit' |
| 374 | ] |
| 375 | ); |
| 376 | |
| 377 | $this->add_group_control( |
| 378 | Group_Control_Text_Shadow::get_type(), |
| 379 | [ |
| 380 | 'name' => 'text_text_shadow_normal', |
| 381 | 'selector' => '{{WRAPPER}} .aux-search-submit' |
| 382 | ] |
| 383 | ); |
| 384 | |
| 385 | $this->end_controls_tab(); |
| 386 | |
| 387 | $this->start_controls_tab( |
| 388 | 'text_style_hover', |
| 389 | [ |
| 390 | 'label' => __( 'Hover' , 'auxin-elements' ) |
| 391 | ] |
| 392 | ); |
| 393 | |
| 394 | $this->add_control( |
| 395 | 'text_color_hover', |
| 396 | [ |
| 397 | 'label' => __( 'Color', 'auxin-elements' ), |
| 398 | 'type' => Controls_Manager::COLOR, |
| 399 | 'selectors' => [ |
| 400 | '{{WRAPPER}} .aux-search-submit:hover' => 'color: {{VALUE}};' |
| 401 | ] |
| 402 | ] |
| 403 | ); |
| 404 | |
| 405 | $this->add_group_control( |
| 406 | Group_Control_Typography::get_type(), |
| 407 | [ |
| 408 | 'name' => 'text_typo_hover', |
| 409 | 'scheme' => Typography::TYPOGRAPHY_1, |
| 410 | 'selector' => '{{WRAPPER}} .aux-search-submit:hover' |
| 411 | ] |
| 412 | ); |
| 413 | |
| 414 | $this->add_group_control( |
| 415 | Group_Control_Text_Shadow::get_type(), |
| 416 | [ |
| 417 | 'name' => 'text_text_shadow_hover', |
| 418 | 'selector' => '{{WRAPPER}} .aux-search-submit:hover' |
| 419 | ] |
| 420 | ); |
| 421 | |
| 422 | $this->end_controls_tab(); |
| 423 | |
| 424 | $this->end_controls_tabs(); |
| 425 | |
| 426 | $this->end_controls_section(); |
| 427 | |
| 428 | /* Button Style Section |
| 429 | /*-------------------------------------*/ |
| 430 | |
| 431 | $this->start_controls_section( |
| 432 | 'button_style_section', |
| 433 | [ |
| 434 | 'label' => __( 'Button', 'auxin-elements' ), |
| 435 | 'tab' => Controls_Manager::TAB_STYLE, |
| 436 | ] |
| 437 | ); |
| 438 | |
| 439 | $this->start_controls_tabs( 'button_styles' ); |
| 440 | |
| 441 | $this->start_controls_tab( |
| 442 | 'button_style_normal', |
| 443 | [ |
| 444 | 'label' => __( 'Normal' , 'auxin-elements' ) |
| 445 | ] |
| 446 | ); |
| 447 | |
| 448 | $this->add_group_control( |
| 449 | Group_Control_Background::get_type(), |
| 450 | [ |
| 451 | 'name' => 'button_bg_normal', |
| 452 | 'selector' => '{{WRAPPER}} .aux-search-submit', |
| 453 | 'types' => [ 'classic', 'gradient'], |
| 454 | 'separator' => 'after' |
| 455 | ] |
| 456 | ); |
| 457 | |
| 458 | $this->add_responsive_control( |
| 459 | 'button_padding_normal', |
| 460 | [ |
| 461 | 'label' => __( 'Padding', 'auxin-elements' ), |
| 462 | 'type' => Controls_Manager::DIMENSIONS, |
| 463 | 'size_units' => [ 'px', '%' ], |
| 464 | 'selectors' => [ |
| 465 | '{{WRAPPER}} .aux-search-submit' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 466 | ], |
| 467 | 'separator' => 'before' |
| 468 | ] |
| 469 | ); |
| 470 | |
| 471 | $this->add_group_control( |
| 472 | Group_Control_Border::get_type(), |
| 473 | [ |
| 474 | 'name' => 'button_border_normal', |
| 475 | 'selector' => '{{WRAPPER}} .aux-search-submit', |
| 476 | 'separator' => 'none', |
| 477 | 'separator' => 'before' |
| 478 | ] |
| 479 | ); |
| 480 | |
| 481 | $this->add_responsive_control( |
| 482 | 'button_border_radius_normal', |
| 483 | [ |
| 484 | 'label' => __( 'Border Radius', 'auxin-elements' ), |
| 485 | 'type' => Controls_Manager::DIMENSIONS, |
| 486 | 'size_units' => [ 'px', 'em', '%' ], |
| 487 | 'allowed_dimensions' => 'all', |
| 488 | 'separator' => 'before', |
| 489 | 'selectors' => [ |
| 490 | '{{WRAPPER}} .aux-search-submit' => 'border-radius:{{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' |
| 491 | ], |
| 492 | ] |
| 493 | ); |
| 494 | |
| 495 | $this->add_group_control( |
| 496 | Group_Control_Box_Shadow::get_type(), |
| 497 | [ |
| 498 | 'name' => 'button_box_shadow_normal', |
| 499 | 'selector' => '{{WRAPPER}} .aux-search-submit', |
| 500 | 'separator' => 'before' |
| 501 | ] |
| 502 | ); |
| 503 | |
| 504 | $this->end_controls_tab(); |
| 505 | |
| 506 | $this->start_controls_tab( |
| 507 | 'button_style_hover', |
| 508 | [ |
| 509 | 'label' => __( 'Hover' , 'auxin-elements' ) |
| 510 | ] |
| 511 | ); |
| 512 | |
| 513 | $this->add_group_control( |
| 514 | Group_Control_Background::get_type(), |
| 515 | [ |
| 516 | 'name' => 'button_bg_hover', |
| 517 | 'selector' => '{{WRAPPER}} .aux-search-submit:hover', |
| 518 | 'types' => [ 'classic', 'gradient'], |
| 519 | 'separator' => 'after' |
| 520 | ] |
| 521 | ); |
| 522 | |
| 523 | $this->add_responsive_control( |
| 524 | 'button_padding_hover', |
| 525 | [ |
| 526 | 'label' => __( 'Padding', 'auxin-elements' ), |
| 527 | 'type' => Controls_Manager::DIMENSIONS, |
| 528 | 'size_units' => [ 'px', '%' ], |
| 529 | 'selectors' => [ |
| 530 | '{{WRAPPER}} .aux-search-submit:hover' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 531 | ], |
| 532 | 'separator' => 'before' |
| 533 | ] |
| 534 | ); |
| 535 | |
| 536 | $this->add_group_control( |
| 537 | Group_Control_Border::get_type(), |
| 538 | [ |
| 539 | 'name' => 'button_border_hover', |
| 540 | 'selector' => '{{WRAPPER}} .aux-search-submit:hover', |
| 541 | 'separator' => 'before' |
| 542 | ] |
| 543 | ); |
| 544 | |
| 545 | $this->add_responsive_control( |
| 546 | 'button_border_radius_hover', |
| 547 | [ |
| 548 | 'label' => __( 'Border Radius', 'auxin-elements' ), |
| 549 | 'type' => Controls_Manager::DIMENSIONS, |
| 550 | 'size_units' => [ 'px', 'em', '%' ], |
| 551 | 'selectors' => [ |
| 552 | '{{WRAPPER}} .aux-search-submit:hover' => 'border-radius:{{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' |
| 553 | ], |
| 554 | 'allowed_dimensions' => 'all', |
| 555 | 'separator' => 'before' |
| 556 | ] |
| 557 | ); |
| 558 | $this->add_group_control( |
| 559 | Group_Control_Box_Shadow::get_type(), |
| 560 | [ |
| 561 | 'name' => 'button_box_shadow_hover', |
| 562 | 'selector' => '{{WRAPPER}} .aux-search-submit:hover', |
| 563 | 'separator' => 'before' |
| 564 | ] |
| 565 | ); |
| 566 | |
| 567 | $this->end_controls_tab(); |
| 568 | |
| 569 | $this->end_controls_tabs(); |
| 570 | |
| 571 | $this->add_control( |
| 572 | 'button_cursor', |
| 573 | [ |
| 574 | 'label' => __( 'Cursor', 'auxin-elements' ), |
| 575 | 'type' => Controls_Manager::SELECT, |
| 576 | 'options' => [ |
| 577 | 'default' => __( 'Default', 'auxin-elements' ), |
| 578 | 'pointer' => __( 'Pointer', 'auxin-elements' ), |
| 579 | 'zoom-in' => __( 'Zoom', 'auxin-elements' ), |
| 580 | 'help' => __( 'Help', 'auxin-elements' ) |
| 581 | ], |
| 582 | 'default' => 'pointer', |
| 583 | 'selectors' => [ |
| 584 | '{{WRAPPER}} .aux-search-submit' => 'cursor: {{VALUE}};' |
| 585 | ], |
| 586 | 'separator' => 'before' |
| 587 | ] |
| 588 | ); |
| 589 | |
| 590 | $this->end_controls_section(); |
| 591 | |
| 592 | /* Input Style Section |
| 593 | /*-------------------------------------*/ |
| 594 | |
| 595 | $this->start_controls_section( |
| 596 | 'input_style_section', |
| 597 | [ |
| 598 | 'label' => __( 'Fullscreen Search Input', 'auxin-elements' ), |
| 599 | 'tab' => Controls_Manager::TAB_STYLE |
| 600 | ] |
| 601 | ); |
| 602 | |
| 603 | |
| 604 | $this->add_control( |
| 605 | 'input_color', |
| 606 | [ |
| 607 | 'label' => __( 'Text Color', 'auxin-elements' ), |
| 608 | 'type' => Controls_Manager::COLOR, |
| 609 | 'selectors' => [ |
| 610 | '{{WRAPPER}} .aux-search-popup .aux-search-field' => 'color: {{VALUE}};' |
| 611 | ] |
| 612 | ] |
| 613 | ); |
| 614 | |
| 615 | $this->add_control( |
| 616 | 'input_placeholder_color', |
| 617 | [ |
| 618 | 'label' => __( 'Placeholder Text Color', 'auxin-elements' ), |
| 619 | 'type' => Controls_Manager::COLOR, |
| 620 | 'selectors' => [ |
| 621 | '{{WRAPPER}} .aux-search-popup .aux-search-field::placeholder' => 'color:{{VALUE}};' |
| 622 | ], |
| 623 | 'separator' => 'after' |
| 624 | ] |
| 625 | ); |
| 626 | |
| 627 | $this->add_group_control( |
| 628 | Group_Control_Typography::get_type(), |
| 629 | [ |
| 630 | 'name' => 'input_typo', |
| 631 | 'scheme' => Typography::TYPOGRAPHY_1, |
| 632 | 'selector' => '{{WRAPPER}} .aux-search-popup .aux-search-field', |
| 633 | 'separator' => 'before' |
| 634 | ] |
| 635 | ); |
| 636 | |
| 637 | $this->add_responsive_control( |
| 638 | 'input_padding', |
| 639 | [ |
| 640 | 'label' => __( 'Padding', 'auxin-elements' ), |
| 641 | 'type' => Controls_Manager::DIMENSIONS, |
| 642 | 'size_units' => [ 'px', '%' ], |
| 643 | 'selectors' => [ |
| 644 | '{{WRAPPER}} .aux-search-popup .aux-search-field' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 645 | ], |
| 646 | 'separator' => 'before' |
| 647 | ] |
| 648 | ); |
| 649 | |
| 650 | $this->add_responsive_control( |
| 651 | 'input_border_size', |
| 652 | [ |
| 653 | 'label' => __( 'Border Size', 'auxin-elements' ), |
| 654 | 'type' => Controls_Manager::SLIDER, |
| 655 | 'size_units' => [ 'px' ], |
| 656 | 'range' => [ |
| 657 | 'px' => [ |
| 658 | 'min' => 0, |
| 659 | 'max' => 20, |
| 660 | 'step' => 1, |
| 661 | ], |
| 662 | ], |
| 663 | 'default' => [ |
| 664 | 'size' => 2, |
| 665 | 'unit' => 'px' |
| 666 | ], |
| 667 | 'selectors' => [ |
| 668 | '{{WRAPPER}} .aux-search-popup .aux-search-input-form' => 'border-width: {{SIZE}}{{UNIT}};', |
| 669 | ], |
| 670 | 'separator' => 'before' |
| 671 | ] |
| 672 | ); |
| 673 | |
| 674 | $this->add_control( |
| 675 | 'input_border_color', |
| 676 | [ |
| 677 | 'label' => __( 'Border Color', 'auxin-elements' ), |
| 678 | 'type' => Controls_Manager::COLOR, |
| 679 | 'selectors' => [ |
| 680 | '{{WRAPPER}} .aux-search-popup .aux-search-input-form' => 'border-color: {{VALUE}};' |
| 681 | ], |
| 682 | 'separator' => 'before' |
| 683 | ] |
| 684 | ); |
| 685 | |
| 686 | $this->add_control( |
| 687 | 'input_icon_enabled', |
| 688 | array( |
| 689 | 'label' => __( 'Display Search Icon', 'auxin-elements' ), |
| 690 | 'type' => Controls_Manager::SWITCHER, |
| 691 | 'label_on' => __( 'Show', 'auxin-elements' ), |
| 692 | 'label_off' => __( 'Hide', 'auxin-elements' ), |
| 693 | 'default' => 'yes', |
| 694 | 'separator' => 'before' |
| 695 | ) |
| 696 | ); |
| 697 | |
| 698 | $this->add_responsive_control( |
| 699 | 'input_icon_size', |
| 700 | [ |
| 701 | 'label' => __( 'Search Icon Size', 'auxin-elements' ), |
| 702 | 'type' => Controls_Manager::SLIDER, |
| 703 | 'size_units' => [ 'px', '%' ], |
| 704 | 'range' => [ |
| 705 | 'px' => [ |
| 706 | 'min' => 16, |
| 707 | 'max' => 512, |
| 708 | 'step' => 2, |
| 709 | ], |
| 710 | '%' => [ |
| 711 | 'min' => 0, |
| 712 | 'max' => 100, |
| 713 | ], |
| 714 | ], |
| 715 | 'default' => [ |
| 716 | 'size' => 30, |
| 717 | 'unit' => 'px' |
| 718 | ], |
| 719 | 'selectors' => [ |
| 720 | '{{WRAPPER}} .aux-search-popup .aux-submit-icon-container:before' => 'font-size: {{SIZE}}{{UNIT}};', |
| 721 | ], |
| 722 | 'condition' => [ |
| 723 | 'input_icon_enabled' => 'yes' |
| 724 | ] |
| 725 | ] |
| 726 | ); |
| 727 | |
| 728 | $this->add_control( |
| 729 | 'input_icon_color', |
| 730 | [ |
| 731 | 'label' => __( 'Search Icon Color', 'auxin-elements' ), |
| 732 | 'type' => Controls_Manager::COLOR, |
| 733 | 'selectors' => [ |
| 734 | '{{WRAPPER}} .aux-search-popup .aux-submit-icon-container:before' => 'color: {{VALUE}} !important;' |
| 735 | ], |
| 736 | 'condition' => [ |
| 737 | 'input_icon_enabled' => 'yes' |
| 738 | ] |
| 739 | ] |
| 740 | ); |
| 741 | |
| 742 | $this->add_group_control( |
| 743 | Group_Control_Background::get_type(), |
| 744 | [ |
| 745 | 'name' => 'input_bg', |
| 746 | 'selector' => '{{WRAPPER}} .aux-search-popup', |
| 747 | 'types' => [ 'classic', 'gradient'], |
| 748 | 'separator' => 'before', |
| 749 | 'fields_options' => [ |
| 750 | 'background' => [ |
| 751 | 'label' => __( 'Overlay Background', 'auxin-elements' ), |
| 752 | ] |
| 753 | ] |
| 754 | ] |
| 755 | ); |
| 756 | |
| 757 | $this->end_controls_section(); |
| 758 | |
| 759 | /* Input Style Section |
| 760 | /*-------------------------------------*/ |
| 761 | |
| 762 | $this->start_controls_section( |
| 763 | 'close_style_section', |
| 764 | [ |
| 765 | 'label' => __( 'Fullscreen Close Button', 'auxin-elements' ), |
| 766 | 'tab' => Controls_Manager::TAB_STYLE |
| 767 | ] |
| 768 | ); |
| 769 | |
| 770 | $this->add_responsive_control( |
| 771 | 'close_position_top', |
| 772 | [ |
| 773 | 'label' => __('Top Position','auxin-elements' ), |
| 774 | 'type' => Controls_Manager::SLIDER, |
| 775 | 'size_units' => ['px', 'em', '%'], |
| 776 | 'range' => [ |
| 777 | 'px' => [ |
| 778 | 'min' => -2000, |
| 779 | 'max' => 2000, |
| 780 | 'step' => 1 |
| 781 | ], |
| 782 | '%' => [ |
| 783 | 'min' => -100, |
| 784 | 'max' => 100, |
| 785 | 'step' => 1 |
| 786 | ], |
| 787 | 'em' => [ |
| 788 | 'min' => -150, |
| 789 | 'max' => 150, |
| 790 | 'step' => 1 |
| 791 | ] |
| 792 | ], |
| 793 | 'selectors' => [ |
| 794 | '{{WRAPPER}} .aux-search-popup .aux-panel-close' => 'top:{{SIZE}}{{UNIT}};' |
| 795 | ], |
| 796 | ] |
| 797 | ); |
| 798 | |
| 799 | $this->add_responsive_control( |
| 800 | 'close_position_right', |
| 801 | [ |
| 802 | 'label' => __('Right Position','auxin-elements' ), |
| 803 | 'type' => Controls_Manager::SLIDER, |
| 804 | 'size_units' => ['px', 'em', '%'], |
| 805 | 'range' => [ |
| 806 | 'px' => [ |
| 807 | 'min' => -2000, |
| 808 | 'max' => 2000, |
| 809 | 'step' => 1 |
| 810 | ], |
| 811 | '%' => [ |
| 812 | 'min' => -100, |
| 813 | 'max' => 100, |
| 814 | 'step' => 1 |
| 815 | ], |
| 816 | 'em' => [ |
| 817 | 'min' => -150, |
| 818 | 'max' => 150, |
| 819 | 'step' => 1 |
| 820 | ] |
| 821 | ], |
| 822 | 'selectors' => [ |
| 823 | '{{WRAPPER}} .aux-search-popup .aux-panel-close' => 'right:{{SIZE}}{{UNIT}};' |
| 824 | ] |
| 825 | ] |
| 826 | ); |
| 827 | |
| 828 | $this->end_controls_section(); |
| 829 | |
| 830 | |
| 831 | /* Search Title Style |
| 832 | /*-------------------------------------*/ |
| 833 | |
| 834 | $this->start_controls_section( |
| 835 | 'title_style_section', |
| 836 | [ |
| 837 | 'label' => __( 'Search Title', 'auxin-elements' ), |
| 838 | 'tab' => Controls_Manager::TAB_STYLE, |
| 839 | 'condition' => [ |
| 840 | 'search_field_title!' => '' |
| 841 | ] |
| 842 | ] |
| 843 | ); |
| 844 | |
| 845 | |
| 846 | $this->add_control( |
| 847 | 'title_color', |
| 848 | [ |
| 849 | 'label' => __( 'Title Color', 'auxin-elements' ), |
| 850 | 'type' => Controls_Manager::COLOR, |
| 851 | 'selectors' => [ |
| 852 | '{{WRAPPER}} .aux-search-form-legend' => 'color:{{VALUE}};' |
| 853 | ] |
| 854 | ] |
| 855 | ); |
| 856 | |
| 857 | $this->add_group_control( |
| 858 | Group_Control_Typography::get_type(), |
| 859 | [ |
| 860 | 'name' => 'title_typo', |
| 861 | 'scheme' => Typography::TYPOGRAPHY_1, |
| 862 | 'selector' => '{{WRAPPER}} .aux-search-form-legend' |
| 863 | ] |
| 864 | ); |
| 865 | |
| 866 | $this->add_responsive_control( |
| 867 | 'title_margin', |
| 868 | [ |
| 869 | 'label' => __( 'Margin', 'auxin-elements' ), |
| 870 | 'type' => Controls_Manager::DIMENSIONS, |
| 871 | 'size_units' => [ 'px', '%' ], |
| 872 | 'selectors' => [ |
| 873 | '{{WRAPPER}} .aux-search-form-legend' => 'margin:{{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 874 | ] |
| 875 | ] |
| 876 | ); |
| 877 | |
| 878 | $this->add_group_control( |
| 879 | Group_Control_Background::get_type(), |
| 880 | [ |
| 881 | 'name' => 'title_bg', |
| 882 | 'selector' => '{{WRAPPER}} .aux-search-form-legend', |
| 883 | 'types' => [ 'classic', 'gradient'], |
| 884 | 'separator' => 'before' |
| 885 | ] |
| 886 | ); |
| 887 | |
| 888 | $this->end_controls_section(); |
| 889 | } |
| 890 | |
| 891 | /** |
| 892 | * Render Search Input. |
| 893 | * |
| 894 | * Render button widget text. |
| 895 | * |
| 896 | * @since 1.5.0 |
| 897 | * @access protected |
| 898 | */ |
| 899 | protected function render_search_button( $args = [] ) { ; |
| 900 | |
| 901 | $defaults = [ |
| 902 | 'submit_class' => 'aux-search-submit aux-search-fullscreen', |
| 903 | 'submit_text' => '', |
| 904 | 'wrapper_class' => 'aux-modern-search-wrapper', |
| 905 | 'icon' => 'auxicon-search-4', |
| 906 | 'target' => '.aux-search-popup-' . $this->get_id(), |
| 907 | 'use_ajax' => false |
| 908 | ]; |
| 909 | |
| 910 | $args = wp_parse_args( $args, $defaults ); |
| 911 | |
| 912 | $this->add_render_attribute( 'wrapper', 'class', $args['wrapper_class'] ); |
| 913 | $this->add_render_attribute( 'button', 'class', $args['submit_class'] ); |
| 914 | $this->add_render_attribute( 'button', 'data-target', $args['target'] ); |
| 915 | $this->add_render_attribute( 'submit_text', 'class', 'aux-submit-text' ); |
| 916 | if ( empty( $args['icon']['library'] ) || $args['icon']['library'] != 'svg' ) { |
| 917 | $this->add_render_attribute( 'icon', 'class', $args['icon'] ); |
| 918 | } |
| 919 | ?> |
| 920 | <div <?php echo $this->get_render_attribute_string( 'wrapper' );?> > |
| 921 | <button <?php echo $this->get_render_attribute_string( 'button' );?> > |
| 922 | <?php if ( empty( $args['icon']['library'] ) || $args['icon']['library'] != 'svg' ) { ?> |
| 923 | <i <?php echo $this->get_render_attribute_string( 'icon' );?>></i> |
| 924 | <?php } else { ?> |
| 925 | <img src="<?php echo esc_url( $args['icon']['value']['url'] ); ?>"> |
| 926 | <?php } ?> |
| 927 | <span <?php echo $this->get_render_attribute_string( 'submit_text' );?> ><?php echo esc_html( $args['submit_text'] ); ?></span> |
| 928 | </button> |
| 929 | </div> |
| 930 | <?php |
| 931 | |
| 932 | } |
| 933 | /** |
| 934 | * Render Search Overlay. |
| 935 | * |
| 936 | * Render button widget text. |
| 937 | * |
| 938 | * @since 1.5.0 |
| 939 | * @access protected |
| 940 | */ |
| 941 | protected function render_search_overlay( $args = [] ) { ; |
| 942 | |
| 943 | $defaults = [ |
| 944 | 'wrapper_class' => 'aux-search-popup aux-search-popup-' . $this->get_id(), |
| 945 | 'use_ajax' => false, |
| 946 | 'post_types' => [], |
| 947 | 'placeholder_text' => __('Search...', 'auxin-elements' ), |
| 948 | 'search_title' => '' |
| 949 | ]; |
| 950 | |
| 951 | $args = wp_parse_args( $args, $defaults ); |
| 952 | |
| 953 | $form_args = [ |
| 954 | 'use_ajax' => $args['use_ajax'], |
| 955 | 'display_submit' => $args['display_submit'], |
| 956 | 'display_fill' => $args['display_fill'], |
| 957 | 'display_cats' => $args['display_cats'], |
| 958 | 'post_types' => $args['post_types'], |
| 959 | 'placeholder_text' => $args['placeholder_text'], |
| 960 | 'search_title' => $args['search_title'] |
| 961 | ]; |
| 962 | |
| 963 | $this->add_render_attribute( 'overlay_wrapper', 'class', $args['wrapper_class'] ); |
| 964 | ?> |
| 965 | <div <?php echo $this->get_render_attribute_string( 'overlay_wrapper' );?>> |
| 966 | <div class="aux-panel-close"> |
| 967 | <div class="aux-close aux-cross-symbol aux-thick-medium"></div> |
| 968 | </div> |
| 969 | <div class="aux-search-popup-content"> |
| 970 | <?php $this->render_search_form( $form_args ) ;?> |
| 971 | <?php if ( $args['use_ajax'] ) { ;?> |
| 972 | <div class="aux-search-ajax-container"> |
| 973 | <div class="aux-search-ajax-output"></div> |
| 974 | <div class="aux-loading-spinner aux-spinner-hide"> |
| 975 | <div class="aux-loading-loop"> |
| 976 | <svg class="aux-circle" width="100%" height="100%" viewBox="0 0 42 42"> |
| 977 | <circle class="aux-stroke-bg" r="20" cx="21" cy="21" fill="none"></circle> |
| 978 | <circle class="aux-progress" r="20" cx="21" cy="21" fill="none" transform="rotate(-90 21 21)"></circle> |
| 979 | </svg> |
| 980 | </div> |
| 981 | </div> |
| 982 | </div> |
| 983 | <?php };?> |
| 984 | </div> |
| 985 | </div> |
| 986 | <?php |
| 987 | } |
| 988 | |
| 989 | /** |
| 990 | * Render Search Overlay. |
| 991 | * |
| 992 | * Render button widget text. |
| 993 | * |
| 994 | * @since 1.5.0 |
| 995 | * @access protected |
| 996 | */ |
| 997 | protected function render_search_form( $args = [] ) { ; |
| 998 | |
| 999 | $defaults = [ |
| 1000 | 'wrapper_class' => 'aux-search-form', |
| 1001 | 'use_ajax' => false, |
| 1002 | 'display_submit' => true, |
| 1003 | 'display_fill' => false, |
| 1004 | 'display_cats' => false, |
| 1005 | 'post_types' => [], |
| 1006 | 'placeholder_text' => __('Search...', 'auxin-elements' ), |
| 1007 | 'search_title' => '' |
| 1008 | ]; |
| 1009 | |
| 1010 | $args = wp_parse_args( $args, $defaults ); |
| 1011 | |
| 1012 | $this->add_render_attribute( 'form_wrapper', 'class', $args['wrapper_class'] ); |
| 1013 | |
| 1014 | if ( $args['use_ajax'] ) { |
| 1015 | $this->add_render_attribute( 'form_wrapper', 'class', 'aux-search-ajax' ); |
| 1016 | } |
| 1017 | ?> |
| 1018 | <div <?php echo $this->get_render_attribute_string( 'form_wrapper' );?>> |
| 1019 | <?php if( ! empty( $args['search_title'] ) ){ |
| 1020 | echo '<h5 class="aux-search-form-legend">'. esc_html( $args['search_title'] ) .'</h5>'; |
| 1021 | } ?> |
| 1022 | <form action="<?php echo esc_url( home_url( '/' ) ); ?>" method="get" > |
| 1023 | <div class="aux-search-input-form"> |
| 1024 | <input type="text" class="aux-search-field" placeholder="<?php echo esc_attr( $args['placeholder_text'] ); ?>" name="s" autocomplete="off" data-post-types="<?php echo esc_attr ( wp_json_encode( $args['post_types'] ) ) ;?>" /> |
| 1025 | <input type="hidden" name='post_type' value="<?php echo esc_attr( implode( ',', $args['post_types'] ) );?>"> |
| 1026 | <?php if ( $args['display_cats'] ) { ;?> |
| 1027 | <?php $this->render_category( ['post_types' => $args['post_types'] ] );?> |
| 1028 | <?php };?> |
| 1029 | <?php if ( $args['display_submit'] ) { ;?> |
| 1030 | <?php if ( $args['display_fill'] ) { ;?> |
| 1031 | <input type="submit" class="aux-fill-search-submit" value="<?php esc_attr_e( 'Search', THEME_DOMAIN ); ?> " > |
| 1032 | <?php } else { ;?> |
| 1033 | <div class="aux-submit-icon-container auxicon-search-4"> |
| 1034 | <input type="submit" class="aux-iconic-search-submit" value="<?php esc_attr_e( 'Search', 'auxin-elements' ); ?>" > |
| 1035 | </div> |
| 1036 | <?php };?> |
| 1037 | <?php };?> |
| 1038 | </div> |
| 1039 | </form> |
| 1040 | </div> |
| 1041 | <?php |
| 1042 | } |
| 1043 | |
| 1044 | /** |
| 1045 | * Render Search Overlay. |
| 1046 | * |
| 1047 | * Render button widget text. |
| 1048 | * |
| 1049 | * @since 1.5.0 |
| 1050 | * @access protected |
| 1051 | */ |
| 1052 | protected function render_category( $args ) { |
| 1053 | $taxonomies = $args['post_types']; |
| 1054 | $post_types = []; |
| 1055 | $options_output = ''; |
| 1056 | |
| 1057 | foreach( $taxonomies as $taxonomy ) { |
| 1058 | |
| 1059 | $terms = get_terms( $taxonomy ); |
| 1060 | $post_type = get_taxonomy( $taxonomy )->object_type; |
| 1061 | $post_types = array_merge( $post_types, $post_type ); |
| 1062 | |
| 1063 | foreach ($terms as $term => $term_args) { |
| 1064 | $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>'; |
| 1065 | } |
| 1066 | |
| 1067 | } |
| 1068 | |
| 1069 | $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 ; |
| 1070 | |
| 1071 | echo '<div class="aux-search-cats">'; |
| 1072 | echo '<select class="aux-modern-search-cats" name="cat">' . wp_kses_post( $options_output ) . '</select>'; |
| 1073 | echo '</div>'; |
| 1074 | } |
| 1075 | |
| 1076 | /** |
| 1077 | * Get All Active Post Types. |
| 1078 | * |
| 1079 | * @since 1.5.0 |
| 1080 | * @access protected |
| 1081 | */ |
| 1082 | protected function get_post_types() { |
| 1083 | return auxin_get_available_post_types_for_search(); |
| 1084 | } |
| 1085 | |
| 1086 | /** |
| 1087 | * Render Modern Search widget output on the frontend. |
| 1088 | * |
| 1089 | * Written in PHP and used to generate the final HTML. |
| 1090 | * |
| 1091 | * @since 1.0.0 |
| 1092 | * @access protected |
| 1093 | */ |
| 1094 | protected function render() { |
| 1095 | $settings = $this->get_settings_for_display(); |
| 1096 | |
| 1097 | echo '<div class="aux-modern-search">'; |
| 1098 | |
| 1099 | $this->render_search_button([ |
| 1100 | 'submit_text' => $settings['text'], |
| 1101 | 'icon' => $settings['icon'] |
| 1102 | ]); |
| 1103 | |
| 1104 | $this->render_search_overlay([ |
| 1105 | 'use_ajax' => auxin_is_true( $settings['use_ajax'] ), |
| 1106 | 'display_submit' => auxin_is_true( $settings['fullscreen_display_submit'] ), |
| 1107 | 'display_cats' => auxin_is_true( $settings['fullscreen_display_cats']), |
| 1108 | 'display_fill' => auxin_is_true( $settings['fullscreen_display_fill_submit'] ), |
| 1109 | 'post_types' => $settings['post_types'], |
| 1110 | 'placeholder_text' => $settings['search_field_placeholder_text'], |
| 1111 | 'search_title' => $settings['search_field_title'] |
| 1112 | ]); |
| 1113 | |
| 1114 | echo '</div>'; |
| 1115 | } |
| 1116 | |
| 1117 | } |