| 1 |
<?php |
| 2 |
if (!function_exists('search_style_control')) { |
| 3 |
function search_style_control($blockuniqueclass, $attributes) |
| 4 |
{ |
| 5 |
$inline_css = ''; |
| 6 |
$inline_css .= blockspare_visibility_css($attributes, $blockuniqueclass); |
| 7 |
|
| 8 |
//icon font size |
| 9 |
$inline_css .= ' .' . $blockuniqueclass . ' .bs-search-wrapper .bs-search-icon--toggle{ |
| 10 |
font-size:' . $attributes['iconSize'] . 'px; |
| 11 |
}'; |
| 12 |
|
| 13 |
//search form bordar radius |
| 14 |
$inline_css .= ' .' . $blockuniqueclass . ' .bs-search-wrapper .site-search-form{ |
| 15 |
border-radius:' . $attributes['borderRadius'] . 'px; |
| 16 |
}'; |
| 17 |
|
| 18 |
//search form height |
| 19 |
$inline_css .= ' .' . $blockuniqueclass . ' .bs-search-wrapper .bs-search-form-header .site-search-field{ |
| 20 |
height:' . $attributes['height'] . 'px; |
| 21 |
}'; |
| 22 |
|
| 23 |
//search form background color |
| 24 |
$inline_css .= ' .' . $blockuniqueclass . ' .bs-search-wrapper .bs--search-sidebar-wrapper .site-search-form{ |
| 25 |
background-color:' . $attributes['bgColor'] . '; |
| 26 |
}'; |
| 27 |
|
| 28 |
//search button background color |
| 29 |
if (isset($attributes['buttonBgColor'])) { |
| 30 |
$inline_css .= ' .' . $blockuniqueclass . ' .bs-search-wrapper .bs--search-sidebar-wrapper .btn-bs-search-form{ |
| 31 |
background-color:' . $attributes['buttonBgColor'] . '; |
| 32 |
}'; |
| 33 |
} |
| 34 |
|
| 35 |
//placeholder color |
| 36 |
if (isset($attributes['placeholderTextColor'])) { |
| 37 |
$inline_css .= ' .' . $blockuniqueclass . ' .bs-search-wrapper .site-search-field::placeholder{ |
| 38 |
color:' . $attributes['placeholderTextColor'] . '; |
| 39 |
}'; |
| 40 |
} |
| 41 |
|
| 42 |
//input color |
| 43 |
if (isset($attributes['inputTextColor'])) { |
| 44 |
$inline_css .= ' .' . $blockuniqueclass . ' .bs-search-wrapper .site-search-field{ |
| 45 |
color:' . $attributes['inputTextColor'] . '; |
| 46 |
}'; |
| 47 |
} |
| 48 |
|
| 49 |
//close icon color |
| 50 |
if (isset($attributes['closeIconColor'])) { |
| 51 |
$inline_css .= ' .' . $blockuniqueclass . ' .bs-search-wrapper .bs--site-search-close{ |
| 52 |
color:' . $attributes['closeIconColor'] . '; |
| 53 |
}'; |
| 54 |
} |
| 55 |
|
| 56 |
//icon color |
| 57 |
if ($attributes['searchStyle'] == "icon" || $attributes['buttonType'] == "icon") { |
| 58 |
if (isset($attributes['iconColor'])) { |
| 59 |
$inline_css .= ' .' . $blockuniqueclass . ' .bs-search-wrapper .bs-search-icon--toggle{ |
| 60 |
color:' . $attributes['iconColor'] . '; |
| 61 |
}'; |
| 62 |
} |
| 63 |
} |
| 64 |
if ($attributes['searchStyle'] == "icon" || $attributes['buttonType'] == "icon") { |
| 65 |
if (isset($attributes['formIconColor'])) { |
| 66 |
$inline_css .= ' .' . $blockuniqueclass . ' .bs-search-wrapper .btn-bs-search-form::before{ |
| 67 |
color:' . $attributes['formIconColor'] . '; |
| 68 |
}'; |
| 69 |
} |
| 70 |
} |
| 71 |
|
| 72 |
//button text color |
| 73 |
if ($attributes['buttonType'] == "text") { |
| 74 |
if (isset($attributes['buttonTextColor'])) { |
| 75 |
$inline_css .= ' .' . $blockuniqueclass . ' .bs-search-wrapper .bs--search-sidebar-wrapper .btn-bs-search-form{ |
| 76 |
color:' . $attributes['buttonTextColor'] . '; |
| 77 |
}'; |
| 78 |
} |
| 79 |
} |
| 80 |
|
| 81 |
//toogle icon Gaps |
| 82 |
$inline_css .= ' .' . $blockuniqueclass . ' .bs-search-wrapper .bs-search-icon--toggle{ |
| 83 |
padding-top:' . $attributes['toggleIconPaddingTop'] . 'px; |
| 84 |
padding-right:' . $attributes['toggleIconPaddingRight'] . 'px; |
| 85 |
padding-bottom:' . $attributes['toggleIconPaddingBottom'] . 'px; |
| 86 |
padding-left:' . $attributes['toggleIconPaddingLeft'] . 'px; |
| 87 |
}'; |
| 88 |
|
| 89 |
//search form Gaps |
| 90 |
$inline_css .= ' .' . $blockuniqueclass . ' .bs-search-wrapper .bs--search-sidebar-wrapper .site-search-form{ |
| 91 |
padding-top:' . $attributes['searchFormPaddingTop'] . 'px; |
| 92 |
padding-right:' . $attributes['searchFormPaddingRight'] . 'px; |
| 93 |
padding-bottom:' . $attributes['searchFormPaddingBottom'] . 'px; |
| 94 |
padding-left:' . $attributes['searchFormPaddingLeft'] . 'px; |
| 95 |
}'; |
| 96 |
|
| 97 |
//Block Gaps |
| 98 |
$inline_css .= ' .' . $blockuniqueclass . ' .bs-search-wrapper{ |
| 99 |
margin-top:' . $attributes['marginTop'] . 'px; |
| 100 |
margin-right:' . $attributes['marginRight'] . 'px; |
| 101 |
margin-bottom:' . $attributes['marginBottom'] . 'px; |
| 102 |
margin-left:' . $attributes['marginLeft'] . 'px; |
| 103 |
padding-top:' . $attributes['paddingTop'] . 'px; |
| 104 |
padding-right:' . $attributes['paddingRight'] . 'px; |
| 105 |
padding-bottom:' . $attributes['paddingBottom'] . 'px; |
| 106 |
padding-left:' . $attributes['paddingLeft'] . 'px; |
| 107 |
}'; |
| 108 |
|
| 109 |
//search input gaps |
| 110 |
$inline_css .= ' .' . $blockuniqueclass . ' .bs-search-wrapper .site-search-form .site-search-field{ |
| 111 |
padding-right:' . $attributes['searchInputPaddingRight'] . 'px; |
| 112 |
padding-left:' . $attributes['searchInputPaddingLeft'] . 'px; |
| 113 |
}'; |
| 114 |
|
| 115 |
//Font Settings |
| 116 |
|
| 117 |
$inline_css .= ' .' . $blockuniqueclass . ' .bs-search-wrapper .site-search-field::placeholder{ |
| 118 |
font-size: ' . $attributes['placeholderFontSize'] . $attributes['placeholderFontSizeType'] . '; |
| 119 |
' . bscheckFontfamily($attributes['placeholderFontFamily']) . '; |
| 120 |
' . bscheckFontfamilyWeight($attributes['placeholderFontWeight']) . '; |
| 121 |
}'; |
| 122 |
|
| 123 |
$inline_css .= ' .' . $blockuniqueclass . ' .bs-search-wrapper .site-search-field{ |
| 124 |
font-size: ' . $attributes['inputFontSize'] . $attributes['inputFontSizeType'] . '; |
| 125 |
' . bscheckFontfamily($attributes['inputFontFamily']) . '; |
| 126 |
' . bscheckFontfamilyWeight($attributes['inputFontWeight']) . '; |
| 127 |
}'; |
| 128 |
|
| 129 |
$inline_css .= ' .' . $blockuniqueclass . ' .bs-search-wrapper .bs--search-sidebar-wrapper .btn-bs-search-form:not(.fas){ |
| 130 |
font-size: ' . $attributes['searchFontSize'] . $attributes['searchFontSizeType'] . '; |
| 131 |
' . bscheckFontfamily($attributes['searchFontFamily']) . '; |
| 132 |
' . bscheckFontfamilyWeight($attributes['searchFontWeight']) . '; |
| 133 |
}'; |
| 134 |
|
| 135 |
$inline_css .= '@media (max-width: 1025px) { '; |
| 136 |
$inline_css .= ' .' . $blockuniqueclass . ' .bs-search-wrapper .site-search-field::placeholder{ |
| 137 |
font-size: ' . $attributes['placeholderFontSizeTablet'] . $attributes['placeholderFontSizeType'] . '; |
| 138 |
}'; |
| 139 |
|
| 140 |
$inline_css .= ' .' . $blockuniqueclass . ' .bs-search-wrapper .site-search-field{ |
| 141 |
font-size: ' . $attributes['inputFontSizeTablet'] . $attributes['inputFontSizeType'] . '; |
| 142 |
}'; |
| 143 |
|
| 144 |
$inline_css .= ' .' . $blockuniqueclass . ' .bs-search-wrapper .bs--search-sidebar-wrapper .btn-bs-search-form:not(.fas){ |
| 145 |
font-size: ' . $attributes['searchFontSizeTablet'] . $attributes['searchFontSizeType'] . '; |
| 146 |
}'; |
| 147 |
$inline_css .= '}'; |
| 148 |
|
| 149 |
$inline_css .= '@media (max-width: 767px) { '; |
| 150 |
$inline_css .= ' .' . $blockuniqueclass . ' .bs-search-wrapper .site-search-field::placeholder{ |
| 151 |
font-size: ' . $attributes['placeholderFontSizeMobile'] . $attributes['placeholderFontSizeType'] . '; |
| 152 |
}'; |
| 153 |
|
| 154 |
$inline_css .= ' .' . $blockuniqueclass . ' .bs-search-wrapper .site-search-field{ |
| 155 |
font-size: ' . $attributes['inputFontSizeMobile'] . $attributes['inputFontSizeType'] . '; |
| 156 |
}'; |
| 157 |
|
| 158 |
$inline_css .= ' .' . $blockuniqueclass . ' .bs-search-wrapper .bs--search-sidebar-wrapper .btn-bs-search-form:not(.fas){ |
| 159 |
font-size: ' . $attributes['searchFontSizeMobile'] . $attributes['searchFontSizeType'] . '; |
| 160 |
}'; |
| 161 |
$inline_css .= '}'; |
| 162 |
|
| 163 |
|
| 164 |
if (!empty($inline_css)) { |
| 165 |
wp_register_style('bs-search', false); |
| 166 |
wp_enqueue_style('bs-search'); |
| 167 |
wp_add_inline_style('bs-search', blockspare_minify_css($inline_css)); |
| 168 |
} |
| 169 |
} |
| 170 |
} |
| 171 |
function blockspare_search_html($attributes) |
| 172 |
{ |
| 173 |
ob_start(); |
| 174 |
$btnIconClass = 'btn-bs-search-form'; |
| 175 |
if ($attributes['buttonType'] == "icon") { |
| 176 |
$btnIconClass .= ' ' . $attributes['buttonIcon']; |
| 177 |
} |
| 178 |
?> |
| 179 |
<div |
| 180 |
class="bs--search-sidebar-wrapper" |
| 181 |
aria-expanded="false" |
| 182 |
role="form"> |
| 183 |
<form role="search" action="<?php echo home_url('/'); ?>" method="get" class="search-form site-search-form blockspare-hover-item"> |
| 184 |
<span class="screen-reader-text">Search for:</span> |
| 185 |
|
| 186 |
<input |
| 187 |
type="text" |
| 188 |
class="search-field site-search-field" |
| 189 |
placeholder="<?php echo esc_attr($attributes['placeholder']); ?>" |
| 190 |
name="s" |
| 191 |
aria-label="<?php echo esc_html__('search input', 'blockspare'); ?>" /> |
| 192 |
<button |
| 193 |
type="submit" |
| 194 |
class="<?php echo esc_attr($btnIconClass); ?>"> |
| 195 |
<?php if ($attributes['buttonType'] == "icon") { ?> |
| 196 |
<span class="screen-reader-text">Search</span> |
| 197 |
<?php } ?> |
| 198 |
<?php if ($attributes['buttonType'] == "text") { ?> |
| 199 |
<?php echo $attributes['buttonLabel'] != "" ? $attributes['buttonLabel'] : "Search"; ?> |
| 200 |
<?php } ?> |
| 201 |
</button> |
| 202 |
</form> |
| 203 |
</div> |
| 204 |
<?php return ob_get_clean(); |
| 205 |
} |
| 206 |
|