| Server IP : 38.190.208.107 / Your IP : 216.73.217.46 Web Server : nginx/1.28.1 System : Linux ht2026040333114 6.1.0-10-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.37-1 (2023-07-03) x86_64 User : root ( 0) PHP Version : 8.2.28 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv,eval,assert,passthru,system,exec,shell_exec,popen,proc_open MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /www/wwwroot/wp.4/wp-content/themes/woodmart/inc/modules/header-builder/elements/ |
Upload File : |
<?php
/**
* Search element for header builder.
*
* @package woodmart
*/
namespace XTS\Modules\Header_Builder\Elements;
use XTS\Modules\Header_Builder\Element;
/**
* Search form. A few kinds of it.
*/
class Search extends Element {
/**
* Constructor.
*/
public function __construct() {
parent::__construct();
$this->template_name = 'search';
}
/**
* Map element options.
*/
public function map() {
$search_extra_content_options = array(
array(
'value' => '',
'label' => esc_html__( 'Inherit from Theme Settings', 'woodmart' ),
),
) + $this->get_html_block_options();
$search_extra_content_description = '';
if ( function_exists( 'woodmart_get_html_block_links' ) ) {
$search_extra_content_description .= woodmart_get_html_block_links();
}
$show_form_options = array(
'relation' => 'or',
'terms' => array(
array(
'field' => 'display',
'comparison' => 'equal',
'value' => array( 'form' ),
),
array(
'relation' => 'and',
'terms' => array(
array(
'field' => 'display',
'comparison' => 'equal',
'value' => array( 'full-screen' ),
),
array(
'field' => 'full_screen_opener',
'comparison' => 'equal',
'value' => array( 'form' ),
),
),
),
array(
'relation' => 'and',
'terms' => array(
array(
'field' => 'display',
'comparison' => 'equal',
'value' => array( 'full-screen-2' ),
),
array(
'field' => 'full_screen_opener',
'comparison' => 'equal',
'value' => array( '', 'form' ),
),
),
),
),
);
$show_button_options = array(
'relation' => 'or',
'terms' => array(
array(
'field' => 'display',
'comparison' => 'equal',
'value' => array( 'dropdown' ),
),
array(
'relation' => 'and',
'terms' => array(
array(
'field' => 'display',
'comparison' => 'equal',
'value' => array( 'full-screen' ),
),
array(
'field' => 'full_screen_opener',
'comparison' => 'equal',
'value' => array( '', 'button' ),
),
),
),
array(
'relation' => 'and',
'terms' => array(
array(
'field' => 'display',
'comparison' => 'equal',
'value' => array( 'full-screen-2' ),
),
array(
'field' => 'full_screen_opener',
'comparison' => 'equal',
'value' => array( 'button' ),
),
),
),
),
);
$this->args = array(
'type' => 'search',
'title' => esc_html__( 'Search', 'woodmart' ),
'text' => esc_html__( 'Search form', 'woodmart' ),
'icon' => 'xts-i-search',
'editable' => true,
'container' => false,
'edit_on_create' => true,
'drag_target_for' => array(),
'drag_source' => 'content_element',
'removable' => true,
'addable' => true,
'desktop' => true,
'params' => array(
// General.
'display' => array(
'id' => 'display',
'title' => esc_html__( 'Display', 'woodmart' ),
'type' => 'selector',
'tab' => esc_html__( 'General', 'woodmart' ),
'group' => esc_html__( 'General', 'woodmart' ),
'value' => 'full-screen',
'options' => array(
'full-screen' => array(
'value' => 'full-screen',
'label' => esc_html__( 'Full screen', 'woodmart' ),
'hint' => '<video src="' . WOODMART_TOOLTIP_URL . 'hb_search_display_full_screen.mp4" autoplay loop muted></video>',
),
'full-screen-2' => array(
'value' => 'full-screen',
'label' => esc_html__( 'Full screen 2', 'woodmart' ),
'hint' => '<video src="' . WOODMART_TOOLTIP_URL . 'hb_search_display_full_screen_2.mp4" autoplay loop muted></video>',
),
'dropdown' => array(
'value' => 'dropdown',
'label' => esc_html__( 'Dropdown', 'woodmart' ),
'hint' => '<video src="' . WOODMART_TOOLTIP_URL . 'hb_search_display_dropdown.mp4" autoplay loop muted></video>',
),
'form' => array(
'value' => 'form',
'label' => esc_html__( 'Form', 'woodmart' ),
'hint' => '<video src="' . WOODMART_TOOLTIP_URL . 'hb_search_display_form.mp4" autoplay loop muted></video>',
),
),
'description' => esc_html__( 'Display search icon/form in the header in different views.', 'woodmart' ),
),
'full_screen_opener' => array(
'id' => 'full_screen_opener',
'title' => esc_html__( 'Full screen opener', 'woodmart' ),
'type' => 'selector',
'tab' => esc_html__( 'General', 'woodmart' ),
'group' => esc_html__( 'General', 'woodmart' ),
'value' => '',
'options' => array(
'button' => array(
'value' => 'button',
'label' => esc_html__( 'Button', 'woodmart' ),
),
'form' => array(
'value' => 'form',
'label' => esc_html__( 'Form', 'woodmart' ),
),
),
'condition' => array(
'display' => array(
'comparison' => 'equal',
'value' => array( 'full-screen', 'full-screen-2' ),
),
),
),
'popular_requests' => array(
'id' => 'popular_requests',
'title' => esc_html__( 'Show popular requests', 'woodmart' ),
'hint' => '<video src="' . WOODMART_TOOLTIP_URL . 'hb_search_display_popular_requests.mp4" autoplay loop muted></video>',
'type' => 'switcher',
'description' => __( 'You can write a list of popular requests in Theme Settings -> General -> Search', 'woodmart' ),
'tab' => esc_html__( 'General', 'woodmart' ),
'group' => esc_html__( 'General', 'woodmart' ),
'value' => false,
),
'search_history_enabled' => array(
'id' => 'search_history_enabled',
'title' => esc_html__( 'Show search history', 'woodmart' ),
'hint' => '<video src="' . WOODMART_TOOLTIP_URL . 'search-history-enabled.mp4" autoplay loop muted></video>',
'description' => esc_html__( 'Allowing users to quickly access their previous searches.', 'woodmart' ),
'type' => 'switcher',
'tab' => esc_html__( 'General', 'woodmart' ),
'group' => esc_html__( 'General', 'woodmart' ),
'on-text' => esc_html__( 'Yes', 'woodmart' ),
'off-text' => esc_html__( 'No', 'woodmart' ),
'value' => false,
),
'search_extra_content_enabled' => array(
'id' => 'search_extra_content_enabled',
'title' => esc_html__( 'Search extra content', 'woodmart' ),
'hint' => '<video src="' . WOODMART_TOOLTIP_URL . 'full-screen-search-extra-content.mp4" autoplay loop muted></video>',
'tab' => esc_html__( 'General', 'woodmart' ),
'group' => esc_html__( 'General', 'woodmart' ),
'type' => 'switcher',
'value' => false,
),
'search_extra_content' => array(
'id' => 'search_extra_content',
'type' => 'select',
'tab' => esc_html__( 'General', 'woodmart' ),
'group' => esc_html__( 'General', 'woodmart' ),
'value' => '',
'options' => $search_extra_content_options,
'description' => $search_extra_content_description,
'condition' => array(
'search_extra_content_enabled' => array(
'comparison' => 'equal',
'value' => true,
),
),
),
'categories_dropdown' => array(
'id' => 'categories_dropdown',
'title' => esc_html__( 'Show product categories dropdown', 'woodmart' ),
'hint' => '<video src="' . WOODMART_TOOLTIP_URL . 'hb_search_display_categories_dropdown.mp4" autoplay loop muted></video>',
'type' => 'switcher',
'tab' => esc_html__( 'General', 'woodmart' ),
'group' => esc_html__( 'General', 'woodmart' ),
'value' => false,
'condition' => array(
'display' => array(
'comparison' => 'not_equal',
'value' => array( 'full-screen', 'dropdown' ),
),
),
'description' => esc_html__( 'Ability to search in a specific category.', 'woodmart' ),
),
'cat_selector_style' => array(
'id' => 'cat_selector_style',
'title' => esc_html__( 'Product categories selector style', 'woodmart' ),
'type' => 'selector',
'tab' => esc_html__( 'General', 'woodmart' ),
'group' => esc_html__( 'General', 'woodmart' ),
'value' => 'bordered',
'options' => array(
'default' => array(
'value' => 'default',
'label' => esc_html__( 'Default', 'woodmart' ),
'hint' => '<img src="' . WOODMART_TOOLTIP_URL . 'hb_categories_selector_style_default.jpg" alt="">',
),
'bordered' => array(
'value' => 'bordered',
'label' => esc_html__( 'Bordered', 'woodmart' ),
'hint' => '<img src="' . WOODMART_TOOLTIP_URL . 'hb_categories_selector_style_bordered.jpg" alt="">',
),
'separated' => array(
'value' => 'separated',
'label' => esc_html__( 'Separated', 'woodmart' ),
'hint' => '<img src="' . WOODMART_TOOLTIP_URL . 'hb_categories_selector_style_separated.jpg" alt="">',
),
),
'condition' => array(
'display' => array(
'comparison' => 'not_equal',
'value' => array( 'full-screen', 'dropdown' ),
),
'categories_dropdown' => array(
'comparison' => 'equal',
'value' => true,
),
),
),
'bg_overlay' => array(
'id' => 'bg_overlay',
'title' => esc_html__( 'Background overlay', 'woodmart' ),
'hint' => '<video src="' . WOODMART_TOOLTIP_URL . 'hb_search_bg_overlay.mp4" autoplay loop muted></video>',
'description' => esc_html__( 'Highlight dropdowns by darkening the background behind.', 'woodmart' ),
'type' => 'switcher',
'tab' => esc_html__( 'General', 'woodmart' ),
'group' => esc_html__( 'General', 'woodmart' ),
'value' => false,
'condition' => array(
'display' => array(
'comparison' => 'equal',
'value' => array( 'dropdown', 'form' ),
),
),
),
// Search result.
'ajax' => array(
'id' => 'ajax',
'title' => esc_html__( 'Search with AJAX', 'woodmart' ),
'hint' => '<video src="' . WOODMART_TOOLTIP_URL . 'hb_search_ajax.mp4" autoplay loop muted></video>',
'type' => 'switcher',
'tab' => esc_html__( 'General', 'woodmart' ),
'group' => esc_html__( 'Search result', 'woodmart' ),
'value' => true,
'description' => esc_html__( 'Enable instant AJAX search functionality for this form.', 'woodmart' ),
),
'ajax_result_count' => array(
'id' => 'ajax_result_count',
'title' => esc_html__( 'AJAX search results count', 'woodmart' ),
'description' => esc_html__( 'Number of products to display in AJAX search results.', 'woodmart' ),
'type' => 'slider',
'tab' => esc_html__( 'General', 'woodmart' ),
'group' => esc_html__( 'Search result', 'woodmart' ),
'from' => 3,
'to' => 50,
'value' => 20,
'units' => '',
'condition' => array(
'ajax' => array(
'comparison' => 'equal',
'value' => true,
),
),
),
'post_type' => array(
'id' => 'post_type',
'title' => esc_html__( 'Post type', 'woodmart' ),
'type' => 'selector',
'tab' => esc_html__( 'General', 'woodmart' ),
'group' => esc_html__( 'Search result', 'woodmart' ),
'value' => 'product',
'options' => array(
'product' => array(
'value' => 'product',
'label' => esc_html__( 'Product', 'woodmart' ),
),
'post' => array(
'value' => 'post',
'label' => esc_html__( 'Post', 'woodmart' ),
),
'portfolio' => array(
'value' => 'portfolio',
'label' => esc_html__( 'Portfolio', 'woodmart' ),
),
'page' => array(
'value' => 'page',
'label' => esc_html__( 'Page', 'woodmart' ),
),
'any' => array(
'value' => 'any',
'label' => esc_html__( 'All post types', 'woodmart' ),
),
),
),
'include_cat_search' => array(
'id' => 'include_cat_search',
'title' => esc_html__( 'Include categories in search', 'woodmart' ),
'hint' => '<video src="' . WOODMART_TOOLTIP_URL . 'include-cat-search.mp4" autoplay loop muted></video>',
'description' => esc_html__( 'When enabled, the search function will also look for and display categories that match the search query.', 'woodmart' ),
'type' => 'switcher',
'tab' => esc_html__( 'General', 'woodmart' ),
'group' => esc_html__( 'Search result', 'woodmart' ),
'value' => false,
'condition' => array(
'ajax' => array(
'comparison' => 'equal',
'value' => true,
),
'post_type' => array(
'comparison' => 'equal',
'value' => 'product',
),
),
),
// Form.
'search_style' => array(
'id' => 'search_style',
'title' => esc_html__( 'Search style', 'woodmart' ),
'type' => 'selector',
'tab' => esc_html__( 'Style', 'woodmart' ),
'group' => esc_html__( 'Form', 'woodmart' ),
'value' => 'default',
'options' => array(
'default' => array(
'value' => 'default',
'label' => esc_html__( 'Style 1', 'woodmart' ),
'image' => WOODMART_ASSETS_IMAGES . '/header-builder/search/default.jpg',
),
'with-bg' => array(
'value' => 'with-bg',
'label' => esc_html__( 'Style 2', 'woodmart' ),
'image' => WOODMART_ASSETS_IMAGES . '/header-builder/search/with-bg.jpg',
),
'with-bg-2' => array(
'value' => 'with-bg-2',
'label' => esc_html__( 'Style 3', 'woodmart' ),
'image' => WOODMART_ASSETS_IMAGES . '/header-builder/search/with-bg-2.jpg',
),
'4' => array(
'value' => '4',
'label' => esc_html__( 'Style 4', 'woodmart' ),
'image' => WOODMART_ASSETS_IMAGES . '/header-builder/search/fourth.jpg',
),
),
'conditions' => $show_form_options,
),
'form_shape' => array(
'id' => 'form_shape',
'title' => esc_html__( 'Form shape', 'woodmart' ),
'type' => 'select',
'tab' => esc_html__( 'Style', 'woodmart' ),
'group' => esc_html__( 'Form', 'woodmart' ),
'value' => '',
'generate_zero' => true,
'options' => array(
'' => array(
'label' => esc_html__( 'Inherit', 'woodmart' ),
'value' => '',
),
'0' => array(
'label' => esc_html__( 'Square', 'woodmart' ),
'value' => '0',
),
'5' => array(
'label' => esc_html__( 'Rounded', 'woodmart' ),
'value' => '5',
),
'35' => array(
'label' => esc_html__( 'Round', 'woodmart' ),
'value' => '35',
),
),
'selectors' => array(
'{{WRAPPER}}' => array(
'--wd-form-brd-radius: {{VALUE}}px;',
),
),
'conditions' => $show_form_options,
),
'form_width' => array(
'id' => 'form_width',
'title' => esc_html__( 'Form width', 'woodmart' ),
'type' => 'slider',
'tab' => esc_html__( 'Style', 'woodmart' ),
'group' => esc_html__( 'Form', 'woodmart' ),
'from' => 300,
'to' => 1000,
'value' => '',
'units' => 'px',
'selectors' => array(
'{{WRAPPER}}' => array(
'--wd-search-form-width: {{VALUE}}px;',
),
),
'conditions' => $show_form_options,
),
'form_height' => array(
'id' => 'form_height',
'title' => esc_html__( 'Form height', 'woodmart' ),
'type' => 'slider',
'tab' => esc_html__( 'Style', 'woodmart' ),
'group' => esc_html__( 'Form', 'woodmart' ),
'from' => 30,
'to' => 100,
'value' => 46,
'units' => 'px',
'selectors' => array(
'{{WRAPPER}} form.searchform' => array(
'--wd-form-height: {{VALUE}}px;',
),
),
'conditions' => $show_form_options,
),
'form_color' => array(
'id' => 'form_color',
'title' => esc_html__( 'Form text color', 'woodmart' ),
'type' => 'color',
'tab' => esc_html__( 'Style', 'woodmart' ),
'group' => esc_html__( 'Form', 'woodmart' ),
'value' => '',
'selectors' => array(
'{{WRAPPER}}.wd-search-form.wd-header-search-form .searchform' => array(
'--wd-form-color: {{VALUE}};',
),
),
'conditions' => $show_form_options,
'extra_class' => 'xts-col-6',
),
'form_placeholder_color' => array(
'id' => 'form_placeholder_color',
'title' => esc_html__( 'Form placeholder color', 'woodmart' ),
'type' => 'color',
'tab' => esc_html__( 'Style', 'woodmart' ),
'group' => esc_html__( 'Form', 'woodmart' ),
'value' => '',
'selectors' => array(
'{{WRAPPER}}.wd-search-form.wd-header-search-form .searchform' => array(
'--wd-form-placeholder-color: {{VALUE}};',
),
),
'conditions' => $show_form_options,
'extra_class' => 'xts-col-6',
),
'form_brd_color' => array(
'id' => 'form_brd_color',
'title' => esc_html__( 'Form border color', 'woodmart' ),
'type' => 'color',
'tab' => esc_html__( 'Style', 'woodmart' ),
'group' => esc_html__( 'Form', 'woodmart' ),
'value' => '',
'selectors' => array(
'{{WRAPPER}}.wd-search-form.wd-header-search-form .searchform' => array(
'--wd-form-brd-color: {{VALUE}};',
),
),
'conditions' => $show_form_options,
'extra_class' => 'xts-col-6',
),
'form_brd_color_focus' => array(
'id' => 'form_brd_color_focus',
'title' => esc_html__( 'Form border color focus', 'woodmart' ),
'type' => 'color',
'tab' => esc_html__( 'Style', 'woodmart' ),
'group' => esc_html__( 'Form', 'woodmart' ),
'value' => '',
'selectors' => array(
'{{WRAPPER}}.wd-search-form.wd-header-search-form .searchform' => array(
'--wd-form-brd-color-focus: {{VALUE}};',
),
),
'conditions' => $show_form_options,
'extra_class' => 'xts-col-6',
),
'form_bg' => array(
'id' => 'form_bg',
'title' => esc_html__( 'Form background color', 'woodmart' ),
'type' => 'color',
'tab' => esc_html__( 'Style', 'woodmart' ),
'group' => esc_html__( 'Form', 'woodmart' ),
'value' => '',
'selectors' => array(
'{{WRAPPER}}.wd-search-form.wd-header-search-form .searchform' => array(
'--wd-form-bg: {{VALUE}};',
),
),
'conditions' => $show_form_options,
'extra_class' => 'xts-col-6',
),
'form_icon_type' => array(
'id' => 'form_icon_type',
'title' => esc_html__( 'Form icon', 'woodmart' ),
'type' => 'selector',
'tab' => esc_html__( 'Style', 'woodmart' ),
'group' => esc_html__( 'Form', 'woodmart' ),
'value' => '',
'options' => array(
'default' => array(
'value' => 'default',
'label' => esc_html__( 'Default', 'woodmart' ),
'image' => WOODMART_ASSETS_IMAGES . '/header-builder/default-icons/search-default.jpg',
),
'custom' => array(
'value' => 'custom',
'label' => esc_html__( 'Custom', 'woodmart' ),
'image' => WOODMART_ASSETS_IMAGES . '/header-builder/upload.jpg',
),
),
'conditions' => array(
'relation' => 'or',
'terms' => array(
array(
'field' => 'display',
'comparison' => 'equal',
'value' => array( 'form', 'dropdown' ),
),
array(
'relation' => 'and',
'terms' => array(
array(
'field' => 'display',
'comparison' => 'equal',
'value' => array( 'full-screen' ),
),
array(
'field' => 'full_screen_opener',
'comparison' => 'equal',
'value' => array( 'form' ),
),
),
),
array(
'relation' => 'and',
'terms' => array(
array(
'field' => 'display',
'comparison' => 'equal',
'value' => array( 'full-screen-2' ),
),
array(
'field' => 'full_screen_opener',
'comparison' => 'equal',
'value' => array( '', 'form' ),
),
),
),
),
),
),
'form_custom_icon' => array(
'id' => 'form_custom_icon',
'title' => esc_html__( 'Upload an image', 'woodmart' ),
'type' => 'image',
'tab' => esc_html__( 'Style', 'woodmart' ),
'group' => esc_html__( 'Form', 'woodmart' ),
'value' => '',
'description' => '',
'conditions' => array(
'relation' => 'or',
'terms' => array(
array(
'field' => 'display',
'comparison' => 'equal',
'value' => array( 'form', 'dropdown' ),
),
array(
'relation' => 'and',
'terms' => array(
array(
'field' => 'display',
'comparison' => 'equal',
'value' => array( 'full-screen' ),
),
array(
'field' => 'full_screen_opener',
'comparison' => 'equal',
'value' => array( 'form' ),
),
),
),
array(
'relation' => 'and',
'terms' => array(
array(
'field' => 'display',
'comparison' => 'equal',
'value' => array( 'full-screen-2' ),
),
array(
'field' => 'full_screen_opener',
'comparison' => 'equal',
'value' => array( '', 'form' ),
),
),
),
),
),
'condition' => array(
'form_icon_type' => array(
'comparison' => 'equal',
'value' => array( 'custom' ),
),
),
'extra_class' => 'xts-col-6',
),
'form_custom_icon_width' => array(
'id' => 'form_custom_icon_width',
'title' => esc_html__( 'Icon width', 'woodmart' ),
'type' => 'slider',
'tab' => esc_html__( 'Style', 'woodmart' ),
'group' => esc_html__( 'Form', 'woodmart' ),
'from' => 0,
'to' => 60,
'value' => 0,
'units' => 'px',
'selectors' => array(
'{{WRAPPER}}' => array(
'--wd-tools-icon-width: {{VALUE}}px;',
),
),
'conditions' => array(
'relation' => 'or',
'terms' => array(
array(
'field' => 'display',
'comparison' => 'equal',
'value' => array( 'form', 'dropdown' ),
),
array(
'relation' => 'and',
'terms' => array(
array(
'field' => 'display',
'comparison' => 'equal',
'value' => array( 'full-screen' ),
),
array(
'field' => 'full_screen_opener',
'comparison' => 'equal',
'value' => array( 'form' ),
),
),
),
array(
'relation' => 'and',
'terms' => array(
array(
'field' => 'display',
'comparison' => 'equal',
'value' => array( 'full-screen-2' ),
),
array(
'field' => 'full_screen_opener',
'comparison' => 'equal',
'value' => array( '', 'form' ),
),
),
),
),
),
'condition' => array(
'form_icon_type' => array(
'comparison' => 'equal',
'value' => array( 'custom' ),
),
),
'extra_class' => 'xts-col-6',
),
// Button.
'style' => array(
'id' => 'style',
'title' => esc_html__( 'Button display', 'woodmart' ),
'type' => 'selector',
'tab' => esc_html__( 'Style', 'woodmart' ),
'group' => esc_html__( 'Button', 'woodmart' ),
'value' => 'icon',
'options' => array(
'text-only' => array(
'value' => 'text-only',
'label' => esc_html__( 'Text', 'woodmart' ),
),
'icon' => array(
'value' => 'icon',
'label' => esc_html__( 'Icon', 'woodmart' ),
),
'text' => array(
'value' => 'text',
'label' => esc_html__( 'Icon with text', 'woodmart' ),
),
),
'description' => esc_html__( 'Select whether to display only the icon, only the text, or both together.', 'woodmart' ),
'conditions' => $show_button_options,
),
'icon_design' => array(
'id' => 'icon_design',
'title' => esc_html__( 'Design', 'woodmart' ),
'type' => 'selector',
'tab' => esc_html__( 'Style', 'woodmart' ),
'group' => esc_html__( 'Button', 'woodmart' ),
'value' => '1',
'options' => array(
'1' => array(
'value' => '1',
'label' => esc_html__( 'First', 'woodmart' ),
'image' => WOODMART_ASSETS_IMAGES . '/header-builder/search-icons/first.jpg',
),
'6' => array(
'value' => '6',
'label' => esc_html__( 'Second', 'woodmart' ),
'image' => WOODMART_ASSETS_IMAGES . '/header-builder/search-icons/second.jpg',
),
'7' => array(
'value' => '7',
'label' => esc_html__( 'Third', 'woodmart' ),
'image' => WOODMART_ASSETS_IMAGES . '/header-builder/search-icons/third.jpg',
),
'8' => array(
'value' => '8',
'label' => esc_html__( 'Fourth', 'woodmart' ),
'image' => WOODMART_ASSETS_IMAGES . '/header-builder/search-icons/fourth.jpg',
),
),
'conditions' => $show_button_options,
'condition' => array(
'style' => array(
'comparison' => 'not_equal',
'value' => array( 'text-only' ),
),
),
),
'text_design' => array(
'id' => 'text_design',
'title' => esc_html__( 'Design', 'woodmart' ),
'type' => 'selector',
'tab' => esc_html__( 'Style', 'woodmart' ),
'group' => esc_html__( 'Button', 'woodmart' ),
'value' => '1',
'options' => array(
'1' => array(
'value' => '1',
'label' => esc_html__( 'First', 'woodmart' ),
'image' => WOODMART_ASSETS_IMAGES . '/header-builder/search-icons/text-first.jpg',
),
'6' => array(
'value' => '6',
'label' => esc_html__( 'Second', 'woodmart' ),
'image' => WOODMART_ASSETS_IMAGES . '/header-builder/search-icons/text-second.jpg',
),
'7' => array(
'value' => '7',
'label' => esc_html__( 'Third', 'woodmart' ),
'image' => WOODMART_ASSETS_IMAGES . '/header-builder/search-icons/text-third.jpg',
),
),
'conditions' => $show_button_options,
'condition' => array(
'style' => array(
'comparison' => 'equal',
'value' => array( 'text-only' ),
),
),
),
'text_color' => array(
'id' => 'text_color',
'title' => esc_html__( 'Color', 'woodmart' ),
'tab' => esc_html__( 'Style', 'woodmart' ),
'group' => esc_html__( 'Button', 'woodmart' ),
'type' => 'color',
'value' => '',
'selectors' => array(
'whb-row .{{WRAPPER}}.wd-tools-element .wd-tools-inner' => array(
'color: {{VALUE}};',
),
),
'conditions' => $show_button_options,
'condition' => array(
'style' => array(
'comparison' => 'equal',
'value' => array( 'text-only' ),
),
'text_design' => array(
'comparison' => 'equal',
'value' => array( '7' ),
),
),
'extra_class' => 'xts-col-6',
),
'text_hover_color' => array(
'id' => 'text_hover_color',
'title' => esc_html__( 'Hover color', 'woodmart' ),
'tab' => esc_html__( 'Style', 'woodmart' ),
'group' => esc_html__( 'Button', 'woodmart' ),
'type' => 'color',
'value' => '',
'selectors' => array(
'whb-row .{{WRAPPER}}.wd-tools-element:hover .wd-tools-inner' => array(
'color: {{VALUE}};',
),
),
'conditions' => $show_button_options,
'condition' => array(
'style' => array(
'comparison' => 'equal',
'value' => array( 'text-only' ),
),
'text_design' => array(
'comparison' => 'equal',
'value' => array( '7' ),
),
),
'extra_class' => 'xts-col-6',
),
'text_bg_color' => array(
'id' => 'text_bg_color',
'title' => esc_html__( 'Background color', 'woodmart' ),
'tab' => esc_html__( 'Style', 'woodmart' ),
'group' => esc_html__( 'Button', 'woodmart' ),
'type' => 'color',
'value' => '',
'selectors' => array(
'whb-row .{{WRAPPER}}.wd-tools-element .wd-tools-inner' => array(
'background-color: {{VALUE}};',
),
),
'conditions' => $show_button_options,
'condition' => array(
'style' => array(
'comparison' => 'equal',
'value' => array( 'text-only' ),
),
'text_design' => array(
'comparison' => 'equal',
'value' => array( '7' ),
),
),
'extra_class' => 'xts-col-6',
),
'text_bg_hover_color' => array(
'id' => 'text_bg_hover_color',
'title' => esc_html__( 'Hover background color', 'woodmart' ),
'tab' => esc_html__( 'Style', 'woodmart' ),
'group' => esc_html__( 'Button', 'woodmart' ),
'type' => 'color',
'value' => '',
'selectors' => array(
'whb-row .{{WRAPPER}}.wd-tools-element:hover .wd-tools-inner' => array(
'background-color: {{VALUE}};',
),
),
'conditions' => $show_button_options,
'condition' => array(
'style' => array(
'comparison' => 'equal',
'value' => array( 'text-only' ),
),
'text_design' => array(
'comparison' => 'equal',
'value' => array( '7' ),
),
),
'extra_class' => 'xts-col-6',
),
'wrap_type' => array(
'id' => 'wrap_type',
'title' => esc_html__( 'Background wrap type', 'woodmart' ),
'type' => 'selector',
'tab' => esc_html__( 'Style', 'woodmart' ),
'group' => esc_html__( 'Button', 'woodmart' ),
'value' => 'icon_only',
'options' => array(
'icon_only' => array(
'value' => 'icon_only',
'label' => esc_html__( 'Icon only', 'woodmart' ),
'image' => WOODMART_ASSETS_IMAGES . '/header-builder/bg-wrap-type/search-wrap-icon.jpg',
),
'icon_and_text' => array(
'value' => 'icon_and_text',
'label' => esc_html__( 'Icon and text', 'woodmart' ),
'image' => WOODMART_ASSETS_IMAGES . '/header-builder/bg-wrap-type/search-wrap-icon-and-text.jpg',
),
),
'conditions' => $show_button_options,
'condition' => array(
'style' => array(
'comparison' => 'equal',
'value' => array( 'text' ),
),
'icon_design' => array(
'comparison' => 'equal',
'value' => array( '6', '7' ),
),
),
),
'color' => array(
'id' => 'color',
'title' => esc_html__( 'Color', 'woodmart' ),
'tab' => esc_html__( 'Style', 'woodmart' ),
'group' => esc_html__( 'Button', 'woodmart' ),
'type' => 'color',
'value' => '',
'selectors' => array(
'whb-row .{{WRAPPER}}.wd-tools-element .wd-tools-inner, .whb-row .{{WRAPPER}}.wd-tools-element > a > .wd-tools-icon' => array(
'color: {{VALUE}};',
),
),
'conditions' => array(
'relation' => 'and',
'terms' => array(
$show_button_options,
array(
'relation' => 'or',
'terms' => array(
array(
'relation' => 'and',
'terms' => array(
array(
'field' => 'style',
'comparison' => 'not_equal',
'value' => array( 'text-only' ),
),
array(
'field' => 'icon_design',
'comparison' => 'equal',
'value' => array( '7' ),
),
),
),
array(
'relation' => 'and',
'terms' => array(
array(
'field' => 'style',
'comparison' => 'equal',
'value' => array( 'text' ),
),
array(
'field' => 'icon_design',
'comparison' => 'equal',
'value' => array( '8' ),
),
),
),
),
),
),
),
'extra_class' => 'xts-col-6',
),
'hover_color' => array(
'id' => 'hover_color',
'title' => esc_html__( 'Hover color', 'woodmart' ),
'tab' => esc_html__( 'Style', 'woodmart' ),
'group' => esc_html__( 'Button', 'woodmart' ),
'type' => 'color',
'value' => '',
'selectors' => array(
'whb-row .{{WRAPPER}}.wd-tools-element:hover .wd-tools-inner, .whb-row .{{WRAPPER}}.wd-tools-element:hover > a > .wd-tools-icon' => array(
'color: {{VALUE}};',
),
),
'conditions' => array(
'relation' => 'and',
'terms' => array(
$show_button_options,
array(
'relation' => 'or',
'terms' => array(
array(
'relation' => 'and',
'terms' => array(
array(
'field' => 'style',
'comparison' => 'not_equal',
'value' => array( 'text-only' ),
),
array(
'field' => 'icon_design',
'comparison' => 'equal',
'value' => array( '7' ),
),
),
),
array(
'relation' => 'and',
'terms' => array(
array(
'field' => 'style',
'comparison' => 'equal',
'value' => array( 'text' ),
),
array(
'field' => 'icon_design',
'comparison' => 'equal',
'value' => array( '8' ),
),
),
),
),
),
),
),
'extra_class' => 'xts-col-6',
),
'bg_color' => array(
'id' => 'bg_color',
'title' => esc_html__( 'Background color', 'woodmart' ),
'tab' => esc_html__( 'Style', 'woodmart' ),
'group' => esc_html__( 'Button', 'woodmart' ),
'type' => 'color',
'value' => '',
'selectors' => array(
'whb-row .{{WRAPPER}}.wd-tools-element .wd-tools-inner, .whb-row .{{WRAPPER}}.wd-tools-element > a > .wd-tools-icon' => array(
'background-color: {{VALUE}};',
),
),
'conditions' => $show_button_options,
'condition' => array(
'style' => array(
'comparison' => 'not_equal',
'value' => array( 'text-only' ),
),
'icon_design' => array(
'comparison' => 'equal',
'value' => array( '7', '8' ),
),
),
'extra_class' => 'xts-col-6',
),
'bg_hover_color' => array(
'id' => 'bg_hover_color',
'title' => esc_html__( 'Hover background color', 'woodmart' ),
'tab' => esc_html__( 'Style', 'woodmart' ),
'group' => esc_html__( 'Button', 'woodmart' ),
'type' => 'color',
'value' => '',
'selectors' => array(
'whb-row .{{WRAPPER}}.wd-tools-element:hover .wd-tools-inner, .whb-row .{{WRAPPER}}.wd-tools-element:hover > a > .wd-tools-icon' => array(
'background-color: {{VALUE}};',
),
),
'conditions' => $show_button_options,
'condition' => array(
'style' => array(
'comparison' => 'not_equal',
'value' => array( 'text-only' ),
),
'icon_design' => array(
'comparison' => 'equal',
'value' => array( '7', '8' ),
),
),
'extra_class' => 'xts-col-6',
),
'icon_color' => array(
'id' => 'icon_color',
'title' => esc_html__( 'Icon color', 'woodmart' ),
'tab' => esc_html__( 'Style', 'woodmart' ),
'group' => esc_html__( 'Button', 'woodmart' ),
'type' => 'color',
'value' => '',
'selectors' => array(
'{{WRAPPER}}.wd-tools-element.wd-design-8 .wd-tools-icon' => array(
'color: {{VALUE}};',
),
),
'conditions' => $show_button_options,
'condition' => array(
'style' => array(
'comparison' => 'not_equal',
'value' => array( 'text-only' ),
),
'icon_design' => array(
'comparison' => 'equal',
'value' => '8',
),
),
'extra_class' => 'xts-col-6',
),
'icon_hover_color' => array(
'id' => 'icon_hover_color',
'title' => esc_html__( 'Hover icon color', 'woodmart' ),
'tab' => esc_html__( 'Style', 'woodmart' ),
'group' => esc_html__( 'Button', 'woodmart' ),
'type' => 'color',
'value' => '',
'selectors' => array(
'{{WRAPPER}}.wd-tools-element.wd-design-8:hover .wd-tools-icon' => array(
'color: {{VALUE}};',
),
),
'conditions' => $show_button_options,
'condition' => array(
'style' => array(
'comparison' => 'not_equal',
'value' => array( 'text-only' ),
),
'icon_design' => array(
'comparison' => 'equal',
'value' => '8',
),
),
'extra_class' => 'xts-col-6',
),
'icon_bg_color' => array(
'id' => 'icon_bg_color',
'title' => esc_html__( 'Icon background color', 'woodmart' ),
'tab' => esc_html__( 'Style', 'woodmart' ),
'group' => esc_html__( 'Button', 'woodmart' ),
'type' => 'color',
'value' => '',
'selectors' => array(
'{{WRAPPER}}.wd-tools-element.wd-design-8 .wd-tools-icon' => array(
'background-color: {{VALUE}};',
),
),
'conditions' => $show_button_options,
'condition' => array(
'style' => array(
'comparison' => 'not_equal',
'value' => array( 'text-only' ),
),
'icon_design' => array(
'comparison' => 'equal',
'value' => '8',
),
),
'extra_class' => 'xts-col-6',
),
'icon_bg_hover_color' => array(
'id' => 'icon_bg_hover_color',
'title' => esc_html__( 'Hover icon background color', 'woodmart' ),
'tab' => esc_html__( 'Style', 'woodmart' ),
'group' => esc_html__( 'Button', 'woodmart' ),
'type' => 'color',
'value' => '',
'selectors' => array(
'{{WRAPPER}}.wd-tools-element.wd-design-8:hover .wd-tools-icon' => array(
'background-color: {{VALUE}};',
),
),
'conditions' => $show_button_options,
'condition' => array(
'style' => array(
'comparison' => 'not_equal',
'value' => array( 'text-only' ),
),
'icon_design' => array(
'comparison' => 'equal',
'value' => '8',
),
),
'extra_class' => 'xts-col-6',
),
'icon_type' => array(
'id' => 'icon_type',
'title' => esc_html__( 'Icon type', 'woodmart' ),
'type' => 'selector',
'tab' => esc_html__( 'Style', 'woodmart' ),
'group' => esc_html__( 'Button', 'woodmart' ),
'value' => 'default',
'options' => array(
'default' => array(
'value' => 'default',
'label' => esc_html__( 'Default', 'woodmart' ),
'image' => WOODMART_ASSETS_IMAGES . '/header-builder/default-icons/search-default.jpg',
),
'custom' => array(
'value' => 'custom',
'label' => esc_html__( 'Custom', 'woodmart' ),
'image' => WOODMART_ASSETS_IMAGES . '/header-builder/upload.jpg',
),
),
'conditions' => $show_button_options,
'condition' => array(
'style' => array(
'comparison' => 'not_equal',
'value' => array( 'text-only' ),
),
),
),
'custom_icon' => array(
'id' => 'custom_icon',
'title' => esc_html__( 'Upload an image', 'woodmart' ),
'type' => 'image',
'tab' => esc_html__( 'Style', 'woodmart' ),
'group' => esc_html__( 'Button', 'woodmart' ),
'value' => '',
'description' => '',
'conditions' => $show_button_options,
'condition' => array(
'style' => array(
'comparison' => 'not_equal',
'value' => array( 'text-only' ),
),
'icon_type' => array(
'comparison' => 'equal',
'value' => 'custom',
),
),
'extra_class' => 'xts-col-6',
),
'custom_icon_width' => array(
'id' => 'custom_icon_width',
'title' => esc_html__( 'Icon width', 'woodmart' ),
'type' => 'slider',
'tab' => esc_html__( 'Style', 'woodmart' ),
'group' => esc_html__( 'Button', 'woodmart' ),
'from' => 0,
'to' => 60,
'value' => 0,
'units' => 'px',
'selectors' => array(
'{{WRAPPER}}' => array(
'--wd-tools-icon-width: {{VALUE}}px;',
),
),
'conditions' => $show_button_options,
'condition' => array(
'style' => array(
'comparison' => 'not_equal',
'value' => array( 'text-only' ),
),
'icon_type' => array(
'comparison' => 'equal',
'value' => 'custom',
),
),
'extra_class' => 'xts-col-6',
),
),
);
}
/**
* Get extra class for the search element.
*
* @param array $args Arguments.
*
* @return string
*/
public function get_extra_class( $args ) {
$params = $args['params'];
$extra_class = '';
if (
in_array( $params['display'], array( 'icon', 'dropdown' ), true ) ||
(
'full-screen-2' === $params['display'] &&
! empty( $params['full_screen_opener'] ) &&
'button' === $params['full_screen_opener']
) ||
(
'full-screen' === $params['display'] &&
(
empty( $params['full_screen_opener'] ) ||
'button' === $params['full_screen_opener']
)
)
) {
$icon_type = $params['icon_type'];
if ( 'custom' === $icon_type ) {
$extra_class .= ' wd-tools-custom-icon';
}
if ( 'text-only' !== $params['style'] && ! empty( $params['icon_design'] ) ) {
$extra_class .= ' wd-design-' . $params['icon_design'];
}
if ( 'text-only' === $params['style'] && ! empty( $params['text_design'] ) ) {
$extra_class .= ' wd-design-' . $params['text_design'] . '-text';
}
if ( ! empty( $params['style'] ) ) {
$extra_class .= ' wd-style-' . $params['style'];
}
if ( isset( $params['wrap_type'], $params['style'], $params['icon_design'] ) && 'icon_and_text' === $params['wrap_type'] && 'text' === $params['style'] && in_array( $params['icon_design'], array( '6', '7' ), true ) ) {
$extra_class .= ' wd-with-wrap';
}
$extra_class .= ' wd-display-' . $params['display'];
if ( isset( $args['id'] ) ) {
$extra_class .= ' whb-' . $args['id'];
}
if ( 'dropdown' === $params['display'] ) {
$extra_class .= ' wd-event-hover';
if ( ! empty( $params['bg_overlay'] ) ) {
$extra_class .= ' wd-with-overlay';
}
}
}
return $extra_class;
}
/**
* Check if icon should be wrapped.
*
* @param array $args Arguments.
*
* @return bool
*/
public function should_wrap_icon( $args ) {
$params = $args['params'];
$icon_wrapper = false;
if ( ! in_array( $params['display'], array( 'dropdown', 'full-screen', 'full-screen-2', 'icon' ), true ) ) {
return false;
}
if (
(
'text-only' === $params['style'] &&
in_array( $params['text_design'], array( '6', '7' ), true )
) ||
(
'text-only' !== $params['style'] &&
(
'8' === $params['icon_design'] ||
(
isset( $params['wrap_type'], $params['style'], $params['icon_design'] ) &&
'icon_and_text' === $params['wrap_type'] &&
'text' === $params['style'] &&
in_array( $params['icon_design'], array( '6', '7' ), true )
)
)
)
) {
$icon_wrapper = true;
}
return $icon_wrapper;
}
/**
* Get wrapper classes for the search element.
*
* @param array $args Arguments.
*
* @return string
*/
public function get_wrapper_classes( $args ) {
$params = $args['params'];
$wrapper_classes = '';
if ( in_array( $params['display'], array( 'form', 'full-screen-2', 'full-screen' ), true ) ) {
$wrapper_classes .= 'wd-header-search-form';
$wrapper_classes .= ' wd-display-' . $params['display'];
if ( isset( $args['id'] ) ) {
$wrapper_classes .= ' whb-' . $args['id'];
}
if ( 'form' === $params['display'] && ! empty( $params['bg_overlay'] ) ) {
$wrapper_classes .= ' wd-with-overlay';
}
}
return $wrapper_classes;
}
/**
* Get dropdown search args.
*
* @param array $args Arguments.
*
* @return array
*/
public function get_dropdown_search_args( $args ) {
$params = $args['params'];
$search_args = array();
if (
(
'full-screen' === $params['display'] &&
(
empty( $params['full_screen_opener'] ) ||
'button' === $params['full_screen_opener']
)
) ||
(
'full-screen-2' === $params['display'] &&
! empty( $params['full_screen_opener'] ) &&
'button' === $params['full_screen_opener']
)
) {
return array();
}
$search_args = array(
'count' => isset( $params['ajax_result_count'] ) ? $params['ajax_result_count'] : 20,
'include_cat_search' => isset( $params['include_cat_search'] ) ? $params['include_cat_search'] : false,
'post_type' => isset( $params['post_type'] ) ? $params['post_type'] : 'product',
'search_style' => 'default',
'cat_selector_style' => isset( $params['cat_selector_style'] ) ? $params['cat_selector_style'] : 'bordered',
'wrapper_classes' => $this->get_wrapper_classes( $args ),
);
if ( 'full-screen-2' === $params['display'] ) {
$search_args['cat_selector_style'] = '';
}
if ( 'form' === $params['display'] ) {
$search_args['show_categories'] = isset( $params['categories_dropdown'] ) ? $params['categories_dropdown'] : false;
}
if ( 'dropdown' !== $params['display'] ) {
$search_args['search_style'] = isset( $params['search_style'] ) ? $params['search_style'] : 'default';
}
if ( 'dropdown' === $params['display'] ) {
$search_args['type'] = 'dropdown';
}
if ( 'form' === $params['display'] || 'dropdown' === $params['display'] ) {
$search_extra_content = 'disable';
if ( ! empty( $params['search_extra_content_enabled'] ) ) {
$search_extra_content = ! empty( $params['search_extra_content'] ) ? $params['search_extra_content'] : 'inherit';
}
$search_args['ajax'] = isset( $params['ajax'] ) ? $params['ajax'] : true;
$search_args['popular_requests'] = isset( $params['popular_requests'] ) ? $params['popular_requests'] : false;
$search_args['search_history_enabled'] = isset( $params['search_history_enabled'] ) ? $params['search_history_enabled'] : false;
$search_args['search_extra_content'] = $search_extra_content;
}
$display = $params['display'];
$opener = isset( $params['full_screen_opener'] ) ? $params['full_screen_opener'] : '';
$form_icon_type = isset( $params['form_icon_type'] ) ? $params['form_icon_type'] : '';
$style = isset( $params['style'] ) ? $params['style'] : '';
$use_default_icon = false;
$use_form_icon = false;
if ( 'full-screen' === $display ) {
$use_default_icon = empty( $opener ) || 'button' === $opener;
$use_form_icon = ! empty( $opener ) && 'form' === $opener;
} elseif ( 'full-screen-2' === $display ) {
$use_default_icon = ( ! empty( $opener ) && 'button' === $opener ) || ( empty( $opener ) && empty( $form_icon_type ) );
$use_form_icon = empty( $opener ) || 'form' === $opener;
} elseif ( 'form' === $display ) {
$use_default_icon = empty( $form_icon_type );
$use_form_icon = ! empty( $form_icon_type );
} elseif ( 'dropdown' === $display ) {
$use_default_icon = empty( $form_icon_type ) && 'text-only' !== $style;
$use_form_icon = ! empty( $form_icon_type );
}
if ( $use_default_icon ) {
$search_args['icon_type'] = isset( $params['icon_type'] ) ? $params['icon_type'] : '';
$search_args['custom_icon'] = isset( $params['custom_icon'] ) ? $params['custom_icon'] : '';
} elseif ( $use_form_icon ) {
$search_args['icon_type'] = ! empty( $form_icon_type ) ? $form_icon_type : 'default';
$search_args['custom_icon'] = isset( $params['form_custom_icon'] ) ? $params['form_custom_icon'] : '';
}
return $search_args;
}
/**
* Get full screen search args.
*
* @param array $args Arguments.
*
* @return array
*/
public function get_full_screen_search_args( $args ) {
$params = $args['params'];
$search_args = array();
if ( 'full-screen' !== $params['display'] && 'full-screen-2' !== $params['display'] ) {
return array();
}
$search_extra_content = 'disable';
if ( ! empty( $params['search_extra_content_enabled'] ) ) {
$search_extra_content = ! empty( $params['search_extra_content'] ) ? $params['search_extra_content'] : 'inherit';
}
$search_args['type'] = isset( $params['display'] ) ? $params['display'] : 'full-screen';
$search_args['popular_requests'] = isset( $params['popular_requests'] ) ? $params['popular_requests'] : '';
$search_args['search_history_enabled'] = isset( $params['search_history_enabled'] ) ? $params['search_history_enabled'] : false;
$search_args['search_extra_content'] = $search_extra_content;
$search_args['post_type'] = isset( $params['post_type'] ) ? $params['post_type'] : 'product';
$search_args['ajax'] = isset( $params['ajax'] ) ? $params['ajax'] : true;
$search_args['include_cat_search'] = isset( $params['include_cat_search'] ) ? $params['include_cat_search'] : false;
$search_args['count'] = ( isset( $params['ajax_result_count'] ) && $params['ajax_result_count'] ) ? $params['ajax_result_count'] : 20;
if ( 'full-screen-2' === $params['display'] ) {
$search_args['show_categories'] = isset( $params['categories_dropdown'] ) ? $params['categories_dropdown'] : '';
$search_args['cat_selector_style'] = isset( $params['cat_selector_style'] ) ? $params['cat_selector_style'] : '';
}
$search_args['device'] = 'desktop';
return $search_args;
}
/**
* Parse element args.
*
* @param WP_HB_Element $el Element.
*
* @return array
*/
protected function parse_args( $el ) {
$args = parent::parse_args( $el );
$params = $args['params'];
$args['params']['extra_class'] = $this->get_extra_class( $args );
$args['params']['icon_wrapper'] = $this->should_wrap_icon( $args );
$args['params']['dropdown_search_args'] = $this->get_dropdown_search_args( $args );
$args['params']['full_screen_search_args'] = $this->get_full_screen_search_args( $args );
return $args;
}
}