| 1 |
<?php |
| 2 |
|
| 3 |
namespace MasterAddons\Addons; |
| 4 |
|
| 5 |
// Elementor Classes |
| 6 |
use Elementor\Icons_Manager; |
| 7 |
use Elementor\Controls_Manager; |
| 8 |
use Elementor\Group_Control_Border; |
| 9 |
use Elementor\Group_Control_Typography; |
| 10 |
use Elementor\Core\Kits\Documents\Tabs\Global_Typography; |
| 11 |
|
| 12 |
use MasterAddons\Inc\Controls\JLTMA_Visual_Select; |
| 13 |
use MasterAddons\Inc\Classes\Helper; |
| 14 |
use MasterAddons\Inc\Admin\Config; |
| 15 |
use MasterAddons\Inc\Classes\Base\Master_Widget; |
| 16 |
|
| 17 |
/** |
| 18 |
* Author Name: Liton Arefin |
| 19 |
* Author URL : https://master-addons.com |
| 20 |
* Date : 3/15/2020 |
| 21 |
*/ |
| 22 |
|
| 23 |
// Exit if accessed directly. |
| 24 |
if (!defined('ABSPATH')) exit; |
| 25 |
|
| 26 |
/** |
| 27 |
* MA Header Search |
| 28 |
*/ |
| 29 |
class Search extends Master_Widget |
| 30 |
{ |
| 31 |
use \MasterAddons\Inc\Traits\Widget_Notice; |
| 32 |
use \MasterAddons\Inc\Traits\Widget_Assets_Trait; |
| 33 |
|
| 34 |
public function get_name() |
| 35 |
{ |
| 36 |
return 'ma-search'; |
| 37 |
} |
| 38 |
|
| 39 |
public function get_title() |
| 40 |
{ |
| 41 |
return __('Search', 'master-addons' ); |
| 42 |
} |
| 43 |
|
| 44 |
public function get_icon() |
| 45 |
{ |
| 46 |
return 'jltma-icon ' . Config::get_addon_icon($this->get_name()); |
| 47 |
} |
| 48 |
|
| 49 |
public function get_keywords() |
| 50 |
{ |
| 51 |
return ['search', 'search bar', 'header search', 'header', 'footer']; |
| 52 |
} |
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
private function jltma_get_post_types() |
| 57 |
{ |
| 58 |
$args = array('public' => true); |
| 59 |
|
| 60 |
$post_types = get_post_types($args, 'objects'); |
| 61 |
$posts = array(); |
| 62 |
|
| 63 |
foreach ($post_types as $post_type) { |
| 64 |
$labels = get_post_type_labels($post_type); |
| 65 |
$posts[$post_type->name] = $labels->name; |
| 66 |
} |
| 67 |
|
| 68 |
return $posts; |
| 69 |
} |
| 70 |
|
| 71 |
protected function register_controls() |
| 72 |
{ |
| 73 |
|
| 74 |
$this->start_controls_section( |
| 75 |
'jltma_search_general', |
| 76 |
array( |
| 77 |
'label' => __('Content', 'master-addons' ), |
| 78 |
) |
| 79 |
); |
| 80 |
|
| 81 |
$this->add_control( |
| 82 |
'jltma_search_type', |
| 83 |
array( |
| 84 |
'label' => __('Type', 'master-addons' ), |
| 85 |
'type' => Controls_Manager::SELECT, |
| 86 |
'default' => 'form', |
| 87 |
'options' => array( |
| 88 |
'form' => __('Form', 'master-addons' ), |
| 89 |
'icon' => __('Icon Popup', 'master-addons' ) |
| 90 |
) |
| 91 |
) |
| 92 |
); |
| 93 |
|
| 94 |
$this->add_control( |
| 95 |
'jltma_search_submit_type', |
| 96 |
array( |
| 97 |
'label' => __('Submit Button Type', 'master-addons' ), |
| 98 |
'type' => Controls_Manager::SELECT, |
| 99 |
'options' => array( |
| 100 |
'icon' => __('Icon', 'master-addons' ), |
| 101 |
'button' => __('Button', 'master-addons' ), |
| 102 |
), |
| 103 |
'default' => 'icon', |
| 104 |
'condition' => array( |
| 105 |
'jltma_search_type' => 'form' |
| 106 |
) |
| 107 |
) |
| 108 |
); |
| 109 |
|
| 110 |
$this->add_control( |
| 111 |
'jltma_search_submit_button', |
| 112 |
array( |
| 113 |
'label' => __('Button Text', 'master-addons' ), |
| 114 |
'type' => Controls_Manager::TEXT, |
| 115 |
'default' => 'Search', |
| 116 |
'condition' => array( |
| 117 |
'jltma_search_submit_type' => 'button' |
| 118 |
) |
| 119 |
) |
| 120 |
); |
| 121 |
|
| 122 |
$this->add_control( |
| 123 |
'jltma_search_icon', |
| 124 |
array( |
| 125 |
'label' => __('Icon', 'master-addons' ), |
| 126 |
'description' => __('Please choose an icon from the list.', 'master-addons' ), |
| 127 |
'type' => Controls_Manager::ICONS, |
| 128 |
'fa4compatibility' => 'icon', |
| 129 |
'default' => [ |
| 130 |
'value' => 'dashicons dashicons-search', |
| 131 |
'library' => 'dashicons', |
| 132 |
], |
| 133 |
'conditions' => array( |
| 134 |
'relation' => 'or', |
| 135 |
'terms' => array( |
| 136 |
array( |
| 137 |
'name' => 'jltma_search_type', |
| 138 |
'operator' => '==', |
| 139 |
'value' => 'icon' |
| 140 |
), |
| 141 |
array( |
| 142 |
'name' => 'jltma_search_submit_type', |
| 143 |
'operator' => '==', |
| 144 |
'value' => 'icon' |
| 145 |
) |
| 146 |
) |
| 147 |
) |
| 148 |
) |
| 149 |
); |
| 150 |
|
| 151 |
// $this->add_control( |
| 152 |
// 'jltma_search_has_category', |
| 153 |
// array( |
| 154 |
// 'label' => __('Searcy by Category', 'master-addons' ), |
| 155 |
// 'type' => Controls_Manager::SWITCHER, |
| 156 |
// 'label_on' => __( 'On', 'master-addons' ), |
| 157 |
// 'label_off' => __( 'Off', 'master-addons' ), |
| 158 |
// 'return_value' => true, |
| 159 |
// 'default' => false, |
| 160 |
// 'condition' => array( |
| 161 |
// 'jltma_search_type' => 'form' |
| 162 |
// ) |
| 163 |
// ) |
| 164 |
// ); |
| 165 |
|
| 166 |
// $this->add_control( |
| 167 |
// 'jltma_search_post_types', |
| 168 |
// array( |
| 169 |
// 'label' => __('Post Types', 'master-addons' ), |
| 170 |
// 'type' => Controls_Manager::SELECT2, |
| 171 |
// 'multiple' => true, |
| 172 |
// 'options' => $this->jltma_get_post_types() |
| 173 |
// ) |
| 174 |
// ); |
| 175 |
|
| 176 |
$this->end_controls_section(); |
| 177 |
|
| 178 |
$this->start_controls_section( |
| 179 |
'jltma_search_icon_popup_section', |
| 180 |
array( |
| 181 |
'label' => __('Popup Settings', 'master-addons' ), |
| 182 |
'conditions' => array( |
| 183 |
'relation' => 'or', |
| 184 |
'terms' => array( |
| 185 |
array( |
| 186 |
'name' => 'jltma_search_type', |
| 187 |
'operator' => '===', |
| 188 |
'value' => 'icon' |
| 189 |
), |
| 190 |
array( |
| 191 |
'name' => 'jltma_search_submit_type', |
| 192 |
'operator' => '===', |
| 193 |
'value' => 'icon' |
| 194 |
) |
| 195 |
) |
| 196 |
) |
| 197 |
) |
| 198 |
); |
| 199 |
|
| 200 |
$this->add_control( |
| 201 |
'jltma_search_icon_popup_search_text', |
| 202 |
[ |
| 203 |
'label' => __('Input Text', 'master-addons' ), |
| 204 |
'type' => Controls_Manager::TEXT, |
| 205 |
'placeholder' => __('Search ...', 'master-addons' ), |
| 206 |
'default' => __('Search ...', 'master-addons' ), |
| 207 |
] |
| 208 |
); |
| 209 |
|
| 210 |
$this->add_control( |
| 211 |
'jltma_search_icon_popup_search_details_desc', |
| 212 |
[ |
| 213 |
'label' => __('Description', 'master-addons' ), |
| 214 |
'type' => Controls_Manager::TEXTAREA, |
| 215 |
'placeholder' => __('Hit enter to search or click X to close', 'master-addons' ), |
| 216 |
'default' => __('Hit enter to search or click X to close', 'master-addons' ), |
| 217 |
] |
| 218 |
); |
| 219 |
|
| 220 |
$this->end_controls_section(); |
| 221 |
|
| 222 |
$this->start_controls_section( |
| 223 |
'jltma_search_icon_section', |
| 224 |
array( |
| 225 |
'label' => __('Icon', 'master-addons' ), |
| 226 |
'tab' => Controls_Manager::TAB_STYLE, |
| 227 |
'conditions' => array( |
| 228 |
'relation' => 'or', |
| 229 |
'terms' => array( |
| 230 |
array( |
| 231 |
'name' => 'jltma_search_type', |
| 232 |
'operator' => '===', |
| 233 |
'value' => 'icon' |
| 234 |
), |
| 235 |
array( |
| 236 |
'name' => 'jltma_search_submit_type', |
| 237 |
'operator' => '===', |
| 238 |
'value' => 'icon' |
| 239 |
) |
| 240 |
) |
| 241 |
) |
| 242 |
) |
| 243 |
); |
| 244 |
|
| 245 |
$this->add_responsive_control( |
| 246 |
'jltma_search_icon_size', |
| 247 |
array( |
| 248 |
'label' => __('Size', 'master-addons' ), |
| 249 |
'type' => Controls_Manager::SLIDER, |
| 250 |
'size_units' => array('px', 'em'), |
| 251 |
'range' => array( |
| 252 |
'px' => array( |
| 253 |
'max' => 100, |
| 254 |
'min' => 10 |
| 255 |
), |
| 256 |
'em' => array( |
| 257 |
'max' => 10, |
| 258 |
'min' => .5 |
| 259 |
) |
| 260 |
), |
| 261 |
'selectors' => array( |
| 262 |
'{{WRAPPER}} .jltma-btn--search' => 'font-size: {{SIZE}}{{UNIT}};', |
| 263 |
'{{WRAPPER}} .jltma-btn--search svg' => 'height: {{SIZE}}{{UNIT}}; width: {{SIZE}}{{UNIT}};', |
| 264 |
'{{WRAPPER}} .jltma-search-submit' => 'font-size: {{SIZE}}{{UNIT}};', |
| 265 |
'{{WRAPPER}} .jltma-search-submit svg' => 'height: {{SIZE}}{{UNIT}}; width: {{SIZE}}{{UNIT}};', |
| 266 |
) |
| 267 |
) |
| 268 |
); |
| 269 |
|
| 270 |
$this->add_control( |
| 271 |
'jltma_search_icon_color', |
| 272 |
array( |
| 273 |
'label' => __('Icon color', 'master-addons' ), |
| 274 |
'type' => Controls_Manager::COLOR, |
| 275 |
'default' => '#fff', |
| 276 |
'selectors' => array( |
| 277 |
'{{WRAPPER}} .jltma-btn--search i, {{WRAPPER}} .jltma-btn--search .dashicons, {{WRAPPER}} .jltma-search-form .jltma-search-submit i, {{WRAPPER}} .jltma-search-form .jltma-search-submit .dashicons' => 'color: {{VALUE}}', |
| 278 |
'{{WRAPPER}} .jltma-btn--search svg, {{WRAPPER}} .jltma-search-submit svg' => 'fill: {{VALUE}}', |
| 279 |
) |
| 280 |
) |
| 281 |
); |
| 282 |
|
| 283 |
$this->add_group_control( |
| 284 |
Group_Control_Border::get_type(), |
| 285 |
[ |
| 286 |
'name' => 'jltma_search_border', |
| 287 |
'label' => __('Border', 'master-addons' ), |
| 288 |
'placeholder' => '1px', |
| 289 |
'default' => '1px', |
| 290 |
'selector' => '{{WRAPPER}} .jltma-search-form .jltma-search-submit,{{WRAPPER}} .jltma-btn--search', |
| 291 |
'separator' => 'before', |
| 292 |
] |
| 293 |
); |
| 294 |
|
| 295 |
$this->add_responsive_control( |
| 296 |
'jltma_search_icon_padding', |
| 297 |
array( |
| 298 |
'label' => __('Icon Padding', 'master-addons' ), |
| 299 |
'type' => Controls_Manager::DIMENSIONS, |
| 300 |
'size_units' => array('px', '%'), |
| 301 |
'selectors' => array( |
| 302 |
'{{WRAPPER}} .jltma-btn--search i, {{WRAPPER}} .jltma-search-form .jltma-search-submit' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 303 |
) |
| 304 |
) |
| 305 |
); |
| 306 |
|
| 307 |
$this->add_responsive_control( |
| 308 |
'jltma_search_icon_margin', |
| 309 |
array( |
| 310 |
'label' => __('Icon Margin', 'master-addons' ), |
| 311 |
'type' => Controls_Manager::DIMENSIONS, |
| 312 |
'size_units' => array('px', '%'), |
| 313 |
'selectors' => array( |
| 314 |
'{{WRAPPER}} .jltma-btn--search i, {{WRAPPER}} .jltma-search-form .jltma-search-submit' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 315 |
) |
| 316 |
) |
| 317 |
); |
| 318 |
|
| 319 |
$this->end_controls_section(); |
| 320 |
|
| 321 |
/* Form Section |
| 322 |
/*-------------------------------------*/ |
| 323 |
$this->start_controls_section( |
| 324 |
'jltma_search_form_section', |
| 325 |
array( |
| 326 |
'label' => __('Form', 'master-addons' ), |
| 327 |
'tab' => Controls_Manager::TAB_STYLE, |
| 328 |
'conditions' => array( |
| 329 |
'relation' => 'or', |
| 330 |
'terms' => array( |
| 331 |
array( |
| 332 |
'name' => 'jltma_search_type', |
| 333 |
'operator' => '===', |
| 334 |
'value' => 'form' |
| 335 |
) |
| 336 |
) |
| 337 |
) |
| 338 |
) |
| 339 |
); |
| 340 |
|
| 341 |
$this->add_control( |
| 342 |
'jltma_search_form_bg_color', |
| 343 |
array( |
| 344 |
'label' => __('Background', 'master-addons' ), |
| 345 |
'type' => Controls_Manager::COLOR, |
| 346 |
'default' => '#FFF', |
| 347 |
'selectors' => array( |
| 348 |
'{{WRAPPER}} .jltma-search-wrapper' => 'background-color: {{VALUE}}', |
| 349 |
) |
| 350 |
) |
| 351 |
); |
| 352 |
|
| 353 |
$this->add_responsive_control( |
| 354 |
'jltma_search_form_width', |
| 355 |
array( |
| 356 |
'label' => __('Width', 'master-addons' ), |
| 357 |
'type' => Controls_Manager::SLIDER, |
| 358 |
'size_units' => array('px', 'em', '%'), |
| 359 |
'range' => array( |
| 360 |
'%' => array( |
| 361 |
'min' => 1, |
| 362 |
'max' => 120, |
| 363 |
'step' => 1 |
| 364 |
), |
| 365 |
'em' => array( |
| 366 |
'min' => 1, |
| 367 |
'max' => 120, |
| 368 |
'step' => 1 |
| 369 |
), |
| 370 |
'px' => array( |
| 371 |
'min' => 1, |
| 372 |
'max' => 1900, |
| 373 |
'step' => 1 |
| 374 |
) |
| 375 |
), |
| 376 |
'selectors' => array( |
| 377 |
'{{WRAPPER}} .jltma-search-wrapper' => 'max-width:{{SIZE}}{{UNIT}};' |
| 378 |
), |
| 379 |
) |
| 380 |
); |
| 381 |
|
| 382 |
$this->add_responsive_control( |
| 383 |
'jltma_search_form_margin', |
| 384 |
array( |
| 385 |
'label' => __('Form Margin', 'master-addons' ), |
| 386 |
'type' => Controls_Manager::DIMENSIONS, |
| 387 |
'size_units' => array('px', '%'), |
| 388 |
'selectors' => array( |
| 389 |
'{{WRAPPER}} .jltma-search-wrapper' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 390 |
) |
| 391 |
) |
| 392 |
); |
| 393 |
|
| 394 |
$this->add_responsive_control( |
| 395 |
'jltma_search_form_padding', |
| 396 |
array( |
| 397 |
'label' => __('Form Padding', 'master-addons' ), |
| 398 |
'type' => Controls_Manager::DIMENSIONS, |
| 399 |
'size_units' => array('px', '%'), |
| 400 |
'selectors' => array( |
| 401 |
'{{WRAPPER}} .jltma-search-wrapper' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 402 |
) |
| 403 |
) |
| 404 |
); |
| 405 |
|
| 406 |
$this->add_group_control( |
| 407 |
Group_Control_Border::get_type(), |
| 408 |
array( |
| 409 |
'name' => 'form_border', |
| 410 |
'selector' => '{{WRAPPER}} .jltma-search-wrapper', |
| 411 |
'separator' => 'none' |
| 412 |
) |
| 413 |
); |
| 414 |
|
| 415 |
$this->add_control( |
| 416 |
'jltma_search_form_border_radius', |
| 417 |
array( |
| 418 |
'label' => __('Border Radius', 'master-addons' ), |
| 419 |
'type' => Controls_Manager::DIMENSIONS, |
| 420 |
'size_units' => array('px', 'em', '%'), |
| 421 |
'selectors' => array( |
| 422 |
'{{WRAPPER}} .jltma-search-wrapper' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}}; overflow:hidden;' |
| 423 |
), |
| 424 |
'allowed_dimensions' => 'all', |
| 425 |
'separator' => 'after' |
| 426 |
) |
| 427 |
); |
| 428 |
|
| 429 |
// Form Control/Input Styles |
| 430 |
|
| 431 |
$this->add_group_control( |
| 432 |
Group_Control_Typography::get_type(), |
| 433 |
array( |
| 434 |
'name' => 'jltma_search_form_typgraphy', |
| 435 |
'global' => [ |
| 436 |
'default' => Global_Typography::TYPOGRAPHY_PRIMARY, |
| 437 |
], |
| 438 |
'selector' => '{{WRAPPER}} .jltma-search-form .jltma-form-control' |
| 439 |
) |
| 440 |
); |
| 441 |
|
| 442 |
$this->add_control( |
| 443 |
'jltma_search_form_control_color', |
| 444 |
array( |
| 445 |
'label' => __('Color', 'master-addons' ), |
| 446 |
'type' => Controls_Manager::COLOR, |
| 447 |
'default' => '#000', |
| 448 |
'selectors' => array( |
| 449 |
'{{WRAPPER}} .jltma-search-form .jltma-form-control' => 'color: {{VALUE}}', |
| 450 |
) |
| 451 |
) |
| 452 |
); |
| 453 |
|
| 454 |
$this->add_responsive_control( |
| 455 |
'jltma_search_form_control_width', |
| 456 |
array( |
| 457 |
'label' => __('Width', 'master-addons' ), |
| 458 |
'type' => Controls_Manager::SLIDER, |
| 459 |
'size_units' => array('px', 'em', '%'), |
| 460 |
'range' => array( |
| 461 |
'%' => array( |
| 462 |
'min' => 1, |
| 463 |
'max' => 120, |
| 464 |
'step' => 1 |
| 465 |
), |
| 466 |
'em' => array( |
| 467 |
'min' => 1, |
| 468 |
'max' => 120, |
| 469 |
'step' => 1 |
| 470 |
), |
| 471 |
'px' => array( |
| 472 |
'min' => 1, |
| 473 |
'max' => 1900, |
| 474 |
'step' => 1 |
| 475 |
) |
| 476 |
), |
| 477 |
'selectors' => array( |
| 478 |
'{{WRAPPER}} .jltma-form-control' => 'max-width:{{SIZE}}{{UNIT}};' |
| 479 |
), |
| 480 |
) |
| 481 |
); |
| 482 |
|
| 483 |
$this->add_responsive_control( |
| 484 |
'jltma_search_form_control_margin', |
| 485 |
array( |
| 486 |
'label' => __('Margin', 'master-addons' ), |
| 487 |
'type' => Controls_Manager::DIMENSIONS, |
| 488 |
'size_units' => array('px', '%'), |
| 489 |
'selectors' => array( |
| 490 |
'{{WRAPPER}} .jltma-form-control' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 491 |
) |
| 492 |
) |
| 493 |
); |
| 494 |
|
| 495 |
$this->add_responsive_control( |
| 496 |
'jltma_search_form_control_padding', |
| 497 |
array( |
| 498 |
'label' => __('Padding', 'master-addons' ), |
| 499 |
'type' => Controls_Manager::DIMENSIONS, |
| 500 |
'size_units' => array('px', '%'), |
| 501 |
'selectors' => array( |
| 502 |
'{{WRAPPER}} .jltma-form-control' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 503 |
) |
| 504 |
) |
| 505 |
); |
| 506 |
|
| 507 |
$this->add_control( |
| 508 |
'jltma_search_form_control_bg_color', |
| 509 |
array( |
| 510 |
'label' => __('Form Input Color', 'master-addons' ), |
| 511 |
'type' => Controls_Manager::COLOR, |
| 512 |
'default' => '#FFF', |
| 513 |
'selectors' => array( |
| 514 |
'{{WRAPPER}} .jltma-form-control' => 'background-color: {{VALUE}}', |
| 515 |
) |
| 516 |
) |
| 517 |
); |
| 518 |
|
| 519 |
$this->add_group_control( |
| 520 |
Group_Control_Border::get_type(), |
| 521 |
array( |
| 522 |
'name' => 'input_border', |
| 523 |
'selector' => '{{WRAPPER}} .jltma-form-control', |
| 524 |
'separator' => 'none' |
| 525 |
) |
| 526 |
); |
| 527 |
|
| 528 |
$this->add_control( |
| 529 |
'jltma_search_form_control_border_radius', |
| 530 |
array( |
| 531 |
'label' => __('Border Radius', 'master-addons' ), |
| 532 |
'type' => Controls_Manager::DIMENSIONS, |
| 533 |
'size_units' => array('px', 'em', '%'), |
| 534 |
'selectors' => array( |
| 535 |
'{{WRAPPER}} .jltma-form-control' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}}; overflow:hidden;' |
| 536 |
), |
| 537 |
'allowed_dimensions' => 'all', |
| 538 |
'separator' => 'after' |
| 539 |
) |
| 540 |
); |
| 541 |
|
| 542 |
$this->end_controls_section(); |
| 543 |
|
| 544 |
/* Icon Section |
| 545 |
/*-------------------------------------*/ |
| 546 |
$this->start_controls_section( |
| 547 |
'jltma_search_button_section', |
| 548 |
array( |
| 549 |
'label' => __('Button', 'master-addons' ), |
| 550 |
'tab' => Controls_Manager::TAB_STYLE, |
| 551 |
'conditions' => array( |
| 552 |
'relation' => 'and', |
| 553 |
'terms' => array( |
| 554 |
array( |
| 555 |
'name' => 'jltma_search_type', |
| 556 |
'operator' => '===', |
| 557 |
'value' => 'form' |
| 558 |
), |
| 559 |
array( |
| 560 |
'name' => 'jltma_search_submit_type', |
| 561 |
'operator' => '===', |
| 562 |
'value' => 'button' |
| 563 |
) |
| 564 |
) |
| 565 |
) |
| 566 |
) |
| 567 |
); |
| 568 |
|
| 569 |
$this->add_control( |
| 570 |
'jltma_search_button_background_color', |
| 571 |
array( |
| 572 |
'label' => __('Background Color', 'master-addons' ), |
| 573 |
'type' => Controls_Manager::COLOR, |
| 574 |
'default' => '#303030', |
| 575 |
'selectors' => array( |
| 576 |
'{{WRAPPER}} .jltma-search-form .jltma-search-submit, {{WRAPPER}} .jltma-btn--search' => 'background-color: {{VALUE}}', |
| 577 |
) |
| 578 |
) |
| 579 |
); |
| 580 |
|
| 581 |
$this->add_control( |
| 582 |
'jltma_search_button_color', |
| 583 |
array( |
| 584 |
'label' => __('Color', 'master-addons' ), |
| 585 |
'type' => Controls_Manager::COLOR, |
| 586 |
'default' => '#303030', |
| 587 |
'selectors' => array( |
| 588 |
'{{WRAPPER}} .jltma-search-form .jltma-search-submit' => 'color: {{VALUE}}', |
| 589 |
) |
| 590 |
) |
| 591 |
); |
| 592 |
|
| 593 |
$this->add_responsive_control( |
| 594 |
'jltma_search_button_padding', |
| 595 |
array( |
| 596 |
'label' => __('Padding', 'master-addons' ), |
| 597 |
'type' => Controls_Manager::DIMENSIONS, |
| 598 |
'size_units' => array('px', '%'), |
| 599 |
'selectors' => array( |
| 600 |
'{{WRAPPER}} .jltma-search-form .jltma-search-submit' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 601 |
) |
| 602 |
) |
| 603 |
); |
| 604 |
|
| 605 |
$this->add_responsive_control( |
| 606 |
'jltma_search_button_margin', |
| 607 |
array( |
| 608 |
'label' => __('Margin', 'master-addons' ), |
| 609 |
'type' => Controls_Manager::DIMENSIONS, |
| 610 |
'size_units' => array('px', '%'), |
| 611 |
'selectors' => array( |
| 612 |
'{{WRAPPER}} .jltma-search-form .jltma-search-submit' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 613 |
) |
| 614 |
) |
| 615 |
); |
| 616 |
|
| 617 |
$this->add_group_control( |
| 618 |
Group_Control_Typography::get_type(), |
| 619 |
array( |
| 620 |
'name' => 'jltma_search_button_typgraphy', |
| 621 |
'global' => [ |
| 622 |
'default' => Global_Typography::TYPOGRAPHY_PRIMARY, |
| 623 |
], |
| 624 |
'selector' => '{{WRAPPER}} .jltma-search-form .jltma-search-submit' |
| 625 |
) |
| 626 |
); |
| 627 |
|
| 628 |
$this->end_controls_section(); |
| 629 |
|
| 630 |
// Help Docs section (links from config.php) |
| 631 |
$this->jltma_help_docs(); |
| 632 |
|
| 633 |
$this->upgrade_to_pro_message(); |
| 634 |
|
| 635 |
} |
| 636 |
|
| 637 |
protected function render() |
| 638 |
{ |
| 639 |
$settings = $this->get_settings_for_display(); |
| 640 |
|
| 641 |
$jltma_search_type = $settings['jltma_search_type']; |
| 642 |
// $settings['jltma_search_has_category'] |
| 643 |
$jltma_search_submit_type = $settings['jltma_search_submit_type']; |
| 644 |
$jltma_search_submit_button = $settings['jltma_search_submit_button']; |
| 645 |
$jltma_search_icon = $settings['jltma_search_icon']; |
| 646 |
|
| 647 |
// $icon_migrated = isset($settings['__fa4_migrated']['jltma_search_icon']); |
| 648 |
// $icon_is_new = empty($settings['jltma_search_icon_new']); |
| 649 |
|
| 650 |
$this->add_render_attribute('ma_el_search_wrap', [ |
| 651 |
'class' => [ |
| 652 |
'jltma-search-wrapper', |
| 653 |
'jltma-search-wrapper-' . $jltma_search_type, |
| 654 |
|
| 655 |
], |
| 656 |
'id' => 'jltma-search-wrapper-' . $this->get_id(), |
| 657 |
'data-search-type' => $jltma_search_type |
| 658 |
]); |
| 659 |
?> |
| 660 |
|
| 661 |
<div <?php echo $this->get_render_attribute_string('ma_el_search_wrap'); ?>> |
| 662 |
|
| 663 |
<?php if ($jltma_search_type == "icon") { ?> |
| 664 |
|
| 665 |
<main class="jltma-search-main-wrap"> |
| 666 |
<div class="jltma-search-wrap"> |
| 667 |
<button id="jltma-btn-search" class="jltma-btn--search"> |
| 668 |
<?php |
| 669 |
if (!empty($jltma_search_icon['value'])) { |
| 670 |
Icons_Manager::render_icon($jltma_search_icon, ['aria-hidden' => 'true']); |
| 671 |
} else { |
| 672 |
echo '<span class="dashicons dashicons-search"></span>'; |
| 673 |
} |
| 674 |
?> |
| 675 |
</button> |
| 676 |
</div> |
| 677 |
</main><!-- /main-wrap --> |
| 678 |
|
| 679 |
<div class="jltma-search"> |
| 680 |
<div id="jltma-btn-search-close" class="jltma-btn--search-close" aria-label="Close search form"> |
| 681 |
<svg class="jltma-icon--search" id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 40 40"> |
| 682 |
<defs> |
| 683 |
<style> |
| 684 |
.cls-1 { |
| 685 |
fill: url(#linear-gradient); |
| 686 |
} |
| 687 |
|
| 688 |
.cls-2 { |
| 689 |
fill: url(#linear-gradient-2); |
| 690 |
} |
| 691 |
|
| 692 |
.cls-3 { |
| 693 |
fill: #fff; |
| 694 |
} |
| 695 |
</style> |
| 696 |
<linearGradient id="linear-gradient" y1="40" x2="40" gradientUnits="userSpaceOnUse"> |
| 697 |
<stop offset="0" stop-color="#c6027a" /> |
| 698 |
<stop offset="1" stop-color="#143df4" /> |
| 699 |
</linearGradient> |
| 700 |
<linearGradient id="linear-gradient-2" y1="40" x2="40" gradientUnits="userSpaceOnUse"> |
| 701 |
<stop offset="1" stop-color="#c6027a" /> |
| 702 |
<stop offset="1" stop-color="#143df4" /> |
| 703 |
</linearGradient> |
| 704 |
</defs> |
| 705 |
<title>close_03</title> |
| 706 |
<rect class="cls-1" width="40" height="40" /> |
| 707 |
<rect class="cls-2" width="40" height="40" /> |
| 708 |
<path class="cls-3" d="M22.12,20l6.72-6.72a1.5,1.5,0,1,0-2.12-2.12L20,17.88l-6.72-6.72a1.5,1.5,0,1,0-2.12,2.12L17.88,20l-6.72,6.72a1.5,1.5,0,1,0,2.12,2.12L20,22.12l6.72,6.72a1.5,1.5,0,1,0,2.12-2.12Z" /> |
| 709 |
</svg> |
| 710 |
</div> |
| 711 |
|
| 712 |
<form class="jltma-search__form" action="<?php echo esc_url(home_url('/')); ?>" method="get"> |
| 713 |
<input class="jltma-search__input" name="s" id="s" placeholder="<?php echo esc_attr($settings['jltma_search_icon_popup_search_text']); ?>" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" /> |
| 714 |
|
| 715 |
<?php if (!empty($settings['jltma_search_icon_popup_search_details_desc'])) { ?> |
| 716 |
<span class="jltma-search__info"> |
| 717 |
<?php echo esc_attr($settings['jltma_search_icon_popup_search_details_desc']); ?> |
| 718 |
</span> |
| 719 |
<?php } ?> |
| 720 |
</form> |
| 721 |
</div><!-- /search --> |
| 722 |
|
| 723 |
<?php } else if ($jltma_search_type == "form") { ?> |
| 724 |
|
| 725 |
<form method="get" class="jltma-search-form" action="<?php echo esc_url(home_url('/')); ?>"> |
| 726 |
|
| 727 |
<div class="jltma-input-group"> |
| 728 |
|
| 729 |
<input type="text" class="jltma-form-control jltma-search-field" name="s" title="Search for:" placeholder="<?php echo esc_html__('Search', 'master-addons' ); ?>" required=""> |
| 730 |
|
| 731 |
<div class="jltma-input-group-append"> |
| 732 |
<button type="submit" class="jltma-search-submit jltma-btn <?php if ($jltma_search_submit_type == "button") echo "jltma-text"; ?>"> |
| 733 |
<?php |
| 734 |
if (!empty($jltma_search_icon['value'])) { |
| 735 |
Icons_Manager::render_icon($jltma_search_icon, ['aria-hidden' => 'true']); |
| 736 |
} else { |
| 737 |
echo '<span class="dashicons dashicons-search"></span>'; |
| 738 |
} |
| 739 |
?> |
| 740 |
|
| 741 |
<?php |
| 742 |
if ($jltma_search_submit_button) { |
| 743 |
echo '<span>' . esc_html($this->parse_text_editor($jltma_search_submit_button)) . '</span>'; |
| 744 |
} ?> |
| 745 |
</button> |
| 746 |
</div> |
| 747 |
</div> |
| 748 |
|
| 749 |
</form> |
| 750 |
|
| 751 |
<?php } ?> |
| 752 |
|
| 753 |
</div> <!-- .search-wrapper --> |
| 754 |
|
| 755 |
<?php |
| 756 |
|
| 757 |
} |
| 758 |
} |
| 759 |
|