| 1 |
<?php |
| 2 |
/** |
| 3 |
* Booking form style presets. |
| 4 |
* |
| 5 |
* This file is the shared registry for the global form style model. |
| 6 |
* |
| 7 |
* @package Booking Calendar |
| 8 |
* @since 11.4.0 |
| 9 |
*/ |
| 10 |
|
| 11 |
if ( ! defined( 'ABSPATH' ) ) { |
| 12 |
exit; |
| 13 |
} |
| 14 |
|
| 15 |
/** |
| 16 |
* Get default global form style key. |
| 17 |
* |
| 18 |
* @return string |
| 19 |
*/ |
| 20 |
function wpbc_bfb_settings__get_default_form_style() { |
| 21 |
|
| 22 |
return 'light_bordered'; |
| 23 |
} |
| 24 |
|
| 25 |
/** |
| 26 |
* Get default values for the global custom form style. |
| 27 |
* |
| 28 |
* @return array |
| 29 |
*/ |
| 30 |
function wpbc_bfb_settings__get_default_custom_form_style_options() { |
| 31 |
|
| 32 |
return array( |
| 33 |
'booking_form_custom_background_color' => '#ffffff', |
| 34 |
'booking_form_custom_border_color' => '#cccccc', |
| 35 |
'booking_form_custom_border_width' => '1px', |
| 36 |
'booking_form_custom_border_radius' => '2px', |
| 37 |
'booking_form_custom_padding_vertical' => '10px', |
| 38 |
'booking_form_custom_padding_horizontal' => '30px', |
| 39 |
'booking_form_custom_text_color' => '#1d2327', |
| 40 |
'booking_form_custom_field_background_color' => '#ffffff', |
| 41 |
'booking_form_custom_field_text_color' => '#3c434a', |
| 42 |
'booking_form_custom_field_border_color' => '#cccccc', |
| 43 |
'booking_form_custom_button_background_color' => '#066aab', |
| 44 |
'booking_form_custom_button_text_color' => '#ffffff', |
| 45 |
'booking_form_custom_button_border_color' => '#066aab', |
| 46 |
'booking_form_custom_button_hover_background_color' => '#055589', |
| 47 |
'booking_form_custom_button_hover_text_color' => '#ffffff', |
| 48 |
'booking_form_custom_button_hover_border_color' => '#055589', |
| 49 |
'booking_form_custom_secondary_button_background_color' => '#fdfdfd', |
| 50 |
'booking_form_custom_secondary_button_text_color' => '#444444', |
| 51 |
'booking_form_custom_secondary_button_border_color' => '#eeeeee', |
| 52 |
'booking_form_custom_secondary_button_hover_background_color' => '#fdfdfd', |
| 53 |
'booking_form_custom_secondary_button_hover_text_color' => '#444444', |
| 54 |
'booking_form_custom_secondary_button_hover_border_color' => '#4d91cd', |
| 55 |
); |
| 56 |
} |
| 57 |
|
| 58 |
/** |
| 59 |
* Get CSS variable names owned by the global Form Style feature. |
| 60 |
* |
| 61 |
* Keep this list synchronized with the preset arrays and live preview cleanup. |
| 62 |
* |
| 63 |
* @return array |
| 64 |
*/ |
| 65 |
function wpbc_bfb_settings__get_form_style_css_var_names() { |
| 66 |
|
| 67 |
return array( |
| 68 |
'--wpbc-bfb-form-background', |
| 69 |
'--wpbc-bfb-form-border-color', |
| 70 |
'--wpbc-bfb-form-border-width', |
| 71 |
'--wpbc-bfb-form-border-radius', |
| 72 |
'--wpbc-bfb-form-padding', |
| 73 |
'--wpbc-bfb-form-box-shadow', |
| 74 |
'--wpbc_form-label-color', |
| 75 |
'--wpbc_form-label-sublabel-color', |
| 76 |
'--wpbc_form-label-error-color', |
| 77 |
'--wpbc_form-field-background-color', |
| 78 |
'--wpbc_form-field-menu-color', |
| 79 |
'--wpbc_form-field-text-color', |
| 80 |
'--wpbc_form-field-border-color', |
| 81 |
'--wpbc_form-field-border-color-spare', |
| 82 |
'--wpbc_form-field-focus-border-color', |
| 83 |
'--wpbc_form-field-focus-shadow-color', |
| 84 |
'--wpbc_form-field-disabled-color', |
| 85 |
'--wpbc_form-choice-checked-border-color', |
| 86 |
'--wpbc_form-choice-checked-color', |
| 87 |
'--wpbc_form-choice-focus-color', |
| 88 |
'--wpbc_form-button-background-color', |
| 89 |
'--wpbc_form-button-background-color-alt', |
| 90 |
'--wpbc_form-button-border-color', |
| 91 |
'--wpbc_form-button-text-color', |
| 92 |
'--wpbc_form-button-text-color-alt', |
| 93 |
'--wpbc_form-button-hover-background-color', |
| 94 |
'--wpbc_form-button-hover-border-color', |
| 95 |
'--wpbc_form-button-hover-text-color', |
| 96 |
'--wpbc_form-button-light-background-color', |
| 97 |
'--wpbc_form-button-light-border-color', |
| 98 |
'--wpbc_form-button-light-text-color', |
| 99 |
'--wpbc_form-button-light-box-shadow', |
| 100 |
'--wpbc_form-button-light-hover-background-color', |
| 101 |
'--wpbc_form-button-light-hover-border-color', |
| 102 |
'--wpbc_form-button-light-hover-text-color', |
| 103 |
'--wpbc_form-button-light-hover-box-shadow', |
| 104 |
'--wpbc_form-button-primary-hover-border-color', |
| 105 |
'--wpbc_form-page-break-color', |
| 106 |
); |
| 107 |
} |
| 108 |
|
| 109 |
/** |
| 110 |
* Get the global form style preset registry. |
| 111 |
* |
| 112 |
* Each preset owns its container, text, field, and button tokens so a new |
| 113 |
* Form Style can be added in one registry. |
| 114 |
* |
| 115 |
* @return array |
| 116 |
*/ |
| 117 |
function wpbc_bfb_settings__get_form_style_presets() { |
| 118 |
|
| 119 |
return array( |
| 120 |
'light_bordered' => array( |
| 121 |
'title' => __( 'Light bordered', 'booking' ), |
| 122 |
'theme_class' => '', |
| 123 |
'container_style' => 'bordered', |
| 124 |
'custom' => false, |
| 125 |
'css_vars' => array( |
| 126 |
'--wpbc-bfb-form-background' => '#ffffff', |
| 127 |
'--wpbc-bfb-form-border-color' => '#cccccc', |
| 128 |
'--wpbc-bfb-form-border-width' => '1px', |
| 129 |
'--wpbc-bfb-form-border-radius' => '2px', |
| 130 |
'--wpbc-bfb-form-padding' => '10px 30px', |
| 131 |
'--wpbc-bfb-form-box-shadow' => 'rgba(0, 0, 0, 0.05) 0px 2px 6px 0px', |
| 132 |
'--wpbc_form-label-color' => 'rgba(0, 0, 0, 0.85)', |
| 133 |
'--wpbc_form-label-sublabel-color' => 'rgba(0, 0, 0, 0.55)', |
| 134 |
'--wpbc_form-label-error-color' => '#d63637', |
| 135 |
'--wpbc_form-field-background-color' => '#ffffff', |
| 136 |
'--wpbc_form-field-border-color' => 'rgba(0, 0, 0, 0.25)', |
| 137 |
'--wpbc_form-field-border-color-spare' => 'rgba(0, 0, 0, 0.25)', |
| 138 |
'--wpbc_form-field-focus-border-color' => '#066aab', |
| 139 |
'--wpbc_form-field-focus-shadow-color' => '#066aab', |
| 140 |
'--wpbc_form-field-text-color' => 'rgba(0, 0, 0, 0.7)', |
| 141 |
'--wpbc_form-field-disabled-color' => 'rgba(0, 0, 0, 0.2)', |
| 142 |
'--wpbc_form-field-menu-color' => '#ffffff', |
| 143 |
'--wpbc_form-button-background-color' => '#066aab', |
| 144 |
'--wpbc_form-button-background-color-alt' => '#066aab', |
| 145 |
'--wpbc_form-button-border-color' => '#066aab', |
| 146 |
'--wpbc_form-button-text-color' => '#ffffff', |
| 147 |
'--wpbc_form-button-text-color-alt' => '#ffffff', |
| 148 |
'--wpbc_form-choice-checked-border-color' => '#066aab', |
| 149 |
'--wpbc_form-choice-checked-color' => '#066aab', |
| 150 |
'--wpbc_form-choice-focus-color' => '#066aab', |
| 151 |
'--wpbc_form-button-light-background-color' => '#fdfdfd', |
| 152 |
'--wpbc_form-button-light-border-color' => '#eeeeeeb5', |
| 153 |
'--wpbc_form-button-light-text-color' => '#444444e0', |
| 154 |
'--wpbc_form-button-light-box-shadow' => '0 2px 10px 2px #ffffff54', |
| 155 |
'--wpbc_form-button-light-hover-background-color' => '#fdfdfd', |
| 156 |
'--wpbc_form-button-light-hover-border-color' => 'rgb(77, 145, 205)', |
| 157 |
'--wpbc_form-button-light-hover-text-color' => '#444444e0', |
| 158 |
'--wpbc_form-button-light-hover-box-shadow' => '0 2px 10px 2px #ffffff54', |
| 159 |
'--wpbc_form-button-primary-hover-border-color' => '#ffffff', |
| 160 |
'--wpbc_form-page-break-color' => '#066aab', |
| 161 |
), |
| 162 |
), |
| 163 |
'light_none' => array( |
| 164 |
'title' => __( 'Light no border', 'booking' ), |
| 165 |
'theme_class' => '', |
| 166 |
'container_style' => 'none', |
| 167 |
'custom' => false, |
| 168 |
'css_vars' => array( |
| 169 |
'--wpbc-bfb-form-background' => 'transparent', |
| 170 |
'--wpbc-bfb-form-border-color' => 'transparent', |
| 171 |
'--wpbc-bfb-form-border-width' => '0px', |
| 172 |
'--wpbc-bfb-form-border-radius' => '0px', |
| 173 |
'--wpbc-bfb-form-padding' => '0px', |
| 174 |
'--wpbc-bfb-form-box-shadow' => 'none', |
| 175 |
'--wpbc_form-label-color' => 'rgba(0, 0, 0, 0.85)', |
| 176 |
'--wpbc_form-label-sublabel-color' => 'rgba(0, 0, 0, 0.55)', |
| 177 |
'--wpbc_form-label-error-color' => '#d63637', |
| 178 |
'--wpbc_form-field-background-color' => '#ffffff', |
| 179 |
'--wpbc_form-field-border-color' => 'rgba(0, 0, 0, 0.25)', |
| 180 |
'--wpbc_form-field-border-color-spare' => 'rgba(0, 0, 0, 0.25)', |
| 181 |
'--wpbc_form-field-focus-border-color' => '#066aab', |
| 182 |
'--wpbc_form-field-focus-shadow-color' => '#066aab', |
| 183 |
'--wpbc_form-field-text-color' => 'rgba(0, 0, 0, 0.7)', |
| 184 |
'--wpbc_form-field-disabled-color' => 'rgba(0, 0, 0, 0.2)', |
| 185 |
'--wpbc_form-field-menu-color' => '#ffffff', |
| 186 |
'--wpbc_form-button-background-color' => '#066aab', |
| 187 |
'--wpbc_form-button-background-color-alt' => '#066aab', |
| 188 |
'--wpbc_form-button-border-color' => '#066aab', |
| 189 |
'--wpbc_form-button-text-color' => '#ffffff', |
| 190 |
'--wpbc_form-button-text-color-alt' => '#ffffff', |
| 191 |
'--wpbc_form-choice-checked-border-color' => '#066aab', |
| 192 |
'--wpbc_form-choice-checked-color' => '#066aab', |
| 193 |
'--wpbc_form-choice-focus-color' => '#066aab', |
| 194 |
'--wpbc_form-button-light-background-color' => '#fdfdfd', |
| 195 |
'--wpbc_form-button-light-border-color' => '#eeeeeeb5', |
| 196 |
'--wpbc_form-button-light-text-color' => '#444444e0', |
| 197 |
'--wpbc_form-button-light-box-shadow' => '0 2px 10px 2px #ffffff54', |
| 198 |
'--wpbc_form-button-light-hover-background-color' => '#fdfdfd', |
| 199 |
'--wpbc_form-button-light-hover-border-color' => 'rgb(77, 145, 205)', |
| 200 |
'--wpbc_form-button-light-hover-text-color' => '#444444e0', |
| 201 |
'--wpbc_form-button-light-hover-box-shadow' => '0 2px 10px 2px #ffffff54', |
| 202 |
'--wpbc_form-button-primary-hover-border-color' => '#ffffff', |
| 203 |
'--wpbc_form-page-break-color' => '#066aab', |
| 204 |
), |
| 205 |
), |
| 206 |
'light_soft' => array( |
| 207 |
'title' => __( 'Light soft background', 'booking' ), |
| 208 |
'theme_class' => '', |
| 209 |
'container_style' => 'soft', |
| 210 |
'custom' => false, |
| 211 |
'css_vars' => array( |
| 212 |
'--wpbc-bfb-form-background' => '#f9f9fa', |
| 213 |
'--wpbc-bfb-form-border-color' => '#ffffff', |
| 214 |
'--wpbc-bfb-form-border-width' => '3px', |
| 215 |
'--wpbc-bfb-form-border-radius' => '8px', |
| 216 |
'--wpbc-bfb-form-padding' => '20px', |
| 217 |
'--wpbc-bfb-form-box-shadow' => 'rgba(15, 23, 42, 0.06) 0px 4px 16px 0px', |
| 218 |
'--wpbc_form-label-color' => 'rgba(0, 0, 0, 0.85)', |
| 219 |
'--wpbc_form-label-sublabel-color' => 'rgba(0, 0, 0, 0.55)', |
| 220 |
'--wpbc_form-label-error-color' => '#d63637', |
| 221 |
'--wpbc_form-field-background-color' => '#ffffff', |
| 222 |
'--wpbc_form-field-border-color' => 'rgba(0, 0, 0, 0.25)', |
| 223 |
'--wpbc_form-field-border-color-spare' => 'rgba(0, 0, 0, 0.25)', |
| 224 |
'--wpbc_form-field-focus-border-color' => '#066aab', |
| 225 |
'--wpbc_form-field-focus-shadow-color' => '#066aab', |
| 226 |
'--wpbc_form-field-text-color' => 'rgba(0, 0, 0, 0.7)', |
| 227 |
'--wpbc_form-field-disabled-color' => 'rgba(0, 0, 0, 0.2)', |
| 228 |
'--wpbc_form-field-menu-color' => '#ffffff', |
| 229 |
'--wpbc_form-button-background-color' => '#066aab', |
| 230 |
'--wpbc_form-button-background-color-alt' => '#066aab', |
| 231 |
'--wpbc_form-button-border-color' => '#066aab', |
| 232 |
'--wpbc_form-button-text-color' => '#ffffff', |
| 233 |
'--wpbc_form-button-text-color-alt' => '#ffffff', |
| 234 |
'--wpbc_form-choice-checked-border-color' => '#066aab', |
| 235 |
'--wpbc_form-choice-checked-color' => '#066aab', |
| 236 |
'--wpbc_form-choice-focus-color' => '#066aab', |
| 237 |
'--wpbc_form-button-light-background-color' => '#fdfdfd', |
| 238 |
'--wpbc_form-button-light-border-color' => '#eeeeeeb5', |
| 239 |
'--wpbc_form-button-light-text-color' => '#444444e0', |
| 240 |
'--wpbc_form-button-light-box-shadow' => '0 2px 10px 2px #ffffff54', |
| 241 |
'--wpbc_form-button-light-hover-background-color' => '#fdfdfd', |
| 242 |
'--wpbc_form-button-light-hover-border-color' => 'rgb(77, 145, 205)', |
| 243 |
'--wpbc_form-button-light-hover-text-color' => '#444444e0', |
| 244 |
'--wpbc_form-button-light-hover-box-shadow' => '0 2px 10px 2px #ffffff54', |
| 245 |
'--wpbc_form-button-primary-hover-border-color' => '#ffffff', |
| 246 |
'--wpbc_form-page-break-color' => '#066aab', |
| 247 |
), |
| 248 |
), |
| 249 |
'dark_bordered' => array( |
| 250 |
'title' => __( 'Dark bordered', 'booking' ), |
| 251 |
'theme_class' => 'wpbc_theme_dark_1', |
| 252 |
'container_style' => 'bordered', |
| 253 |
'custom' => false, |
| 254 |
'css_vars' => array( |
| 255 |
'--wpbc-bfb-form-background' => '#626262', |
| 256 |
'--wpbc-bfb-form-border-color' => '#000000', |
| 257 |
'--wpbc-bfb-form-border-width' => '1px', |
| 258 |
'--wpbc-bfb-form-border-radius' => '2px', |
| 259 |
'--wpbc-bfb-form-padding' => '10px 30px', |
| 260 |
'--wpbc-bfb-form-box-shadow' => '0 0px 3px #3b3b3b', |
| 261 |
'--wpbc_form-label-color' => '#f4f6f8', |
| 262 |
'--wpbc_form-label-sublabel-color' => 'rgba(255, 255, 255, 0.72)', |
| 263 |
'--wpbc_form-label-error-color' => '#ff8a8a', |
| 264 |
'--wpbc_form-field-background-color' => '#3f454f', |
| 265 |
'--wpbc_form-field-border-color' => 'rgba(255, 255, 255, 0.28)', |
| 266 |
'--wpbc_form-field-border-color-spare' => 'rgba(255, 255, 255, 0.28)', |
| 267 |
'--wpbc_form-field-focus-border-color' => '#5b8bff', |
| 268 |
'--wpbc_form-field-focus-shadow-color' => '#5b8bff', |
| 269 |
'--wpbc_form-field-text-color' => '#f4f6f8', |
| 270 |
'--wpbc_form-field-disabled-color' => 'rgba(255, 255, 255, 0.35)', |
| 271 |
'--wpbc_form-field-menu-color' => '#303640', |
| 272 |
'--wpbc_form-button-background-color' => '#4d4d4d', |
| 273 |
'--wpbc_form-button-background-color-alt' => '#4d4d4d', |
| 274 |
'--wpbc_form-button-border-color' => '#5f5f5f', |
| 275 |
'--wpbc_form-button-text-color' => '#ffffff', |
| 276 |
'--wpbc_form-button-text-color-alt' => '#ffffff', |
| 277 |
'--wpbc_form-choice-checked-border-color' => '#5b8bff', |
| 278 |
'--wpbc_form-choice-checked-color' => '#f4f6f8', |
| 279 |
'--wpbc_form-choice-focus-color' => '#5b8bff', |
| 280 |
'--wpbc_form-button-light-background-color' => '#2C2E2F', |
| 281 |
'--wpbc_form-button-light-border-color' => '#2C2E2F', |
| 282 |
'--wpbc_form-button-light-text-color' => '#ffffff', |
| 283 |
'--wpbc_form-button-light-box-shadow' => '0 0 0 #424242', |
| 284 |
'--wpbc_form-button-light-hover-background-color' => '#2C2E2F', |
| 285 |
'--wpbc_form-button-light-hover-border-color' => '#2C2E2F', |
| 286 |
'--wpbc_form-button-light-hover-text-color' => '#ffffff', |
| 287 |
'--wpbc_form-button-light-hover-box-shadow' => '0 0 0 #424242', |
| 288 |
'--wpbc_form-button-primary-hover-border-color' => '#ffffff', |
| 289 |
'--wpbc_form-page-break-color' => '#5f9ee7', |
| 290 |
), |
| 291 |
), |
| 292 |
'dark_none' => array( |
| 293 |
'title' => __( 'Dark no border', 'booking' ), |
| 294 |
'theme_class' => 'wpbc_theme_dark_1', |
| 295 |
'container_style' => 'none', |
| 296 |
'custom' => false, |
| 297 |
'css_vars' => array( |
| 298 |
'--wpbc-bfb-form-background' => 'transparent', |
| 299 |
'--wpbc-bfb-form-border-color' => 'transparent', |
| 300 |
'--wpbc-bfb-form-border-width' => '0px', |
| 301 |
'--wpbc-bfb-form-border-radius' => '0px', |
| 302 |
'--wpbc-bfb-form-padding' => '0px', |
| 303 |
'--wpbc-bfb-form-box-shadow' => 'none', |
| 304 |
'--wpbc_form-label-color' => '#1d2327', |
| 305 |
'--wpbc_form-label-sublabel-color' => 'rgba(29, 35, 39, 0.72)', |
| 306 |
'--wpbc_form-label-error-color' => '#d63637', |
| 307 |
'--wpbc_form-field-background-color' => '#3f454f', |
| 308 |
'--wpbc_form-field-border-color' => 'rgba(255, 255, 255, 0.28)', |
| 309 |
'--wpbc_form-field-border-color-spare' => 'rgba(255, 255, 255, 0.28)', |
| 310 |
'--wpbc_form-field-focus-border-color' => '#5b8bff', |
| 311 |
'--wpbc_form-field-focus-shadow-color' => '#5b8bff', |
| 312 |
'--wpbc_form-field-text-color' => '#f4f6f8', |
| 313 |
'--wpbc_form-field-disabled-color' => 'rgba(255, 255, 255, 0.35)', |
| 314 |
'--wpbc_form-field-menu-color' => '#303640', |
| 315 |
'--wpbc_form-button-background-color' => '#4d4d4d', |
| 316 |
'--wpbc_form-button-background-color-alt' => '#4d4d4d', |
| 317 |
'--wpbc_form-button-border-color' => '#5f5f5f', |
| 318 |
'--wpbc_form-button-text-color' => '#ffffff', |
| 319 |
'--wpbc_form-button-text-color-alt' => '#ffffff', |
| 320 |
'--wpbc_form-choice-checked-border-color' => '#5b8bff', |
| 321 |
'--wpbc_form-choice-checked-color' => '#f4f6f8', |
| 322 |
'--wpbc_form-choice-focus-color' => '#5b8bff', |
| 323 |
'--wpbc_form-button-light-background-color' => '#2C2E2F', |
| 324 |
'--wpbc_form-button-light-border-color' => '#2C2E2F', |
| 325 |
'--wpbc_form-button-light-text-color' => '#ffffff', |
| 326 |
'--wpbc_form-button-light-box-shadow' => '0 0 0 #424242', |
| 327 |
'--wpbc_form-button-light-hover-background-color' => '#2C2E2F', |
| 328 |
'--wpbc_form-button-light-hover-border-color' => '#2C2E2F', |
| 329 |
'--wpbc_form-button-light-hover-text-color' => '#ffffff', |
| 330 |
'--wpbc_form-button-light-hover-box-shadow' => '0 0 0 #424242', |
| 331 |
'--wpbc_form-button-primary-hover-border-color' => '#ffffff', |
| 332 |
'--wpbc_form-page-break-color' => '#5f9ee7', |
| 333 |
), |
| 334 |
), |
| 335 |
'dark_soft' => array( |
| 336 |
'title' => __( 'Dark soft background', 'booking' ), |
| 337 |
'theme_class' => 'wpbc_theme_dark_1', |
| 338 |
'container_style' => 'soft', |
| 339 |
'custom' => false, |
| 340 |
'css_vars' => array( |
| 341 |
'--wpbc-bfb-form-background' => '#1f2937', |
| 342 |
'--wpbc-bfb-form-border-color' => '#334155', |
| 343 |
'--wpbc-bfb-form-border-width' => '3px', |
| 344 |
'--wpbc-bfb-form-border-radius' => '8px', |
| 345 |
'--wpbc-bfb-form-padding' => '20px', |
| 346 |
'--wpbc-bfb-form-box-shadow' => 'rgba(0, 0, 0, 0.24) 0px 4px 16px 0px', |
| 347 |
'--wpbc_form-label-color' => '#f4f6f8', |
| 348 |
'--wpbc_form-label-sublabel-color' => 'rgba(255, 255, 255, 0.72)', |
| 349 |
'--wpbc_form-label-error-color' => '#ff8a8a', |
| 350 |
'--wpbc_form-field-background-color' => '#3f454f', |
| 351 |
'--wpbc_form-field-border-color' => 'rgba(255, 255, 255, 0.28)', |
| 352 |
'--wpbc_form-field-border-color-spare' => 'rgba(255, 255, 255, 0.28)', |
| 353 |
'--wpbc_form-field-focus-border-color' => '#5b8bff', |
| 354 |
'--wpbc_form-field-focus-shadow-color' => '#5b8bff', |
| 355 |
'--wpbc_form-field-text-color' => '#f4f6f8', |
| 356 |
'--wpbc_form-field-disabled-color' => 'rgba(255, 255, 255, 0.35)', |
| 357 |
'--wpbc_form-field-menu-color' => '#303640', |
| 358 |
'--wpbc_form-button-background-color' => '#4d4d4d', |
| 359 |
'--wpbc_form-button-background-color-alt' => '#4d4d4d', |
| 360 |
'--wpbc_form-button-border-color' => '#5f5f5f', |
| 361 |
'--wpbc_form-button-text-color' => '#ffffff', |
| 362 |
'--wpbc_form-button-text-color-alt' => '#ffffff', |
| 363 |
'--wpbc_form-choice-checked-border-color' => '#5b8bff', |
| 364 |
'--wpbc_form-choice-checked-color' => '#f4f6f8', |
| 365 |
'--wpbc_form-choice-focus-color' => '#5b8bff', |
| 366 |
'--wpbc_form-button-light-background-color' => '#2C2E2F', |
| 367 |
'--wpbc_form-button-light-border-color' => '#2C2E2F', |
| 368 |
'--wpbc_form-button-light-text-color' => '#ffffff', |
| 369 |
'--wpbc_form-button-light-box-shadow' => '0 0 0 #424242', |
| 370 |
'--wpbc_form-button-light-hover-background-color' => '#2C2E2F', |
| 371 |
'--wpbc_form-button-light-hover-border-color' => '#2C2E2F', |
| 372 |
'--wpbc_form-button-light-hover-text-color' => '#ffffff', |
| 373 |
'--wpbc_form-button-light-hover-box-shadow' => '0 0 0 #424242', |
| 374 |
'--wpbc_form-button-primary-hover-border-color' => '#ffffff', |
| 375 |
'--wpbc_form-page-break-color' => '#5f9ee7', |
| 376 |
), |
| 377 |
), |
| 378 |
'custom' => array( |
| 379 |
'title' => __( 'Custom', 'booking' ), |
| 380 |
'theme_class' => '', |
| 381 |
'container_style' => 'custom', |
| 382 |
'custom' => true, |
| 383 |
'css_vars' => array(), |
| 384 |
), |
| 385 |
); |
| 386 |
} |
| 387 |
|
| 388 |
/** |
| 389 |
* Get one form style preset. |
| 390 |
* |
| 391 |
* @param string $style Form style key. |
| 392 |
* @return array |
| 393 |
*/ |
| 394 |
function wpbc_bfb_settings__get_form_style_preset( $style ) { |
| 395 |
|
| 396 |
$presets = wpbc_bfb_settings__get_form_style_presets(); |
| 397 |
$style = sanitize_key( (string) $style ); |
| 398 |
|
| 399 |
if ( isset( $presets[ $style ] ) ) { |
| 400 |
return $presets[ $style ]; |
| 401 |
} |
| 402 |
|
| 403 |
return $presets[ wpbc_bfb_settings__get_default_form_style() ]; |
| 404 |
} |
| 405 |
|
| 406 |
/** |
| 407 |
* Sanitize a form style key. |
| 408 |
* |
| 409 |
* @param string $style Form style key. |
| 410 |
* @return string |
| 411 |
*/ |
| 412 |
function wpbc_bfb_settings__sanitize_form_style( $style ) { |
| 413 |
|
| 414 |
$presets = wpbc_bfb_settings__get_form_style_presets(); |
| 415 |
$style = sanitize_key( (string) $style ); |
| 416 |
|
| 417 |
return isset( $presets[ $style ] ) ? $style : wpbc_bfb_settings__get_default_form_style(); |
| 418 |
} |
| 419 |
|
| 420 |
/** |
| 421 |
* Get style titles for radio/select controls. |
| 422 |
* |
| 423 |
* @return array |
| 424 |
*/ |
| 425 |
function wpbc_bfb_settings__get_form_style_options() { |
| 426 |
|
| 427 |
$options = array(); |
| 428 |
|
| 429 |
foreach ( wpbc_bfb_settings__get_form_style_presets() as $style_key => $preset ) { |
| 430 |
$options[ $style_key ] = isset( $preset['title'] ) ? $preset['title'] : $style_key; |
| 431 |
} |
| 432 |
|
| 433 |
return $options; |
| 434 |
} |
| 435 |
|
| 436 |
/** |
| 437 |
* Get the currently selected global form style. |
| 438 |
* |
| 439 |
* @return string |
| 440 |
*/ |
| 441 |
function wpbc_bfb_settings__get_current_form_style() { |
| 442 |
|
| 443 |
$style = function_exists( 'get_bk_option' ) ? get_bk_option( 'booking_form_style' ) : ''; |
| 444 |
|
| 445 |
return wpbc_bfb_settings__sanitize_form_style( $style ); |
| 446 |
} |
| 447 |
|
| 448 |
/** |
| 449 |
* Check whether a style key is the Custom style. |
| 450 |
* |
| 451 |
* @param string $style Form style key. |
| 452 |
* @return bool |
| 453 |
*/ |
| 454 |
function wpbc_bfb_settings__is_custom_form_style( $style ) { |
| 455 |
|
| 456 |
return ( 'custom' === wpbc_bfb_settings__sanitize_form_style( $style ) ); |
| 457 |
} |
| 458 |
|
| 459 |
/** |
| 460 |
* Sanitize CSS color values used by global form style options. |
| 461 |
* |
| 462 |
* @param string $value Raw value. |
| 463 |
* @param string $fallback Fallback value. |
| 464 |
* @return string |
| 465 |
*/ |
| 466 |
function wpbc_bfb_settings__sanitize_form_style_color( $value, $fallback ) { |
| 467 |
|
| 468 |
$value = trim( (string) $value ); |
| 469 |
|
| 470 |
if ( preg_match( '/^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i', $value ) || 'transparent' === $value ) { |
| 471 |
return $value; |
| 472 |
} |
| 473 |
|
| 474 |
return $fallback; |
| 475 |
} |
| 476 |
|
| 477 |
/** |
| 478 |
* Sanitize CSS length values used by global form style options. |
| 479 |
* |
| 480 |
* @param string $value Raw value. |
| 481 |
* @param string $fallback Fallback value. |
| 482 |
* @return string |
| 483 |
*/ |
| 484 |
function wpbc_bfb_settings__sanitize_form_style_length( $value, $fallback ) { |
| 485 |
|
| 486 |
$value = trim( (string) $value ); |
| 487 |
|
| 488 |
if ( preg_match( '/^-?\d+(?:\.\d+)?(?:px|rem|em|%)$/i', $value ) ) { |
| 489 |
return $value; |
| 490 |
} |
| 491 |
|
| 492 |
return $fallback; |
| 493 |
} |
| 494 |
|
| 495 |
/** |
| 496 |
* Get sanitized global custom form style options. |
| 497 |
* |
| 498 |
* @param array $options Optional raw override values. |
| 499 |
* @return array |
| 500 |
*/ |
| 501 |
function wpbc_bfb_settings__get_custom_form_style_options( $options = array() ) { |
| 502 |
|
| 503 |
$defaults = wpbc_bfb_settings__get_default_custom_form_style_options(); |
| 504 |
$options = is_array( $options ) ? $options : array(); |
| 505 |
$values = array(); |
| 506 |
|
| 507 |
foreach ( $defaults as $key => $fallback ) { |
| 508 |
if ( array_key_exists( $key, $options ) ) { |
| 509 |
$values[ $key ] = $options[ $key ]; |
| 510 |
} elseif ( function_exists( 'get_bk_option' ) ) { |
| 511 |
$values[ $key ] = get_bk_option( $key ); |
| 512 |
} else { |
| 513 |
$values[ $key ] = $fallback; |
| 514 |
} |
| 515 |
} |
| 516 |
|
| 517 |
return array( |
| 518 |
'booking_form_custom_background_color' => wpbc_bfb_settings__sanitize_form_style_color( $values['booking_form_custom_background_color'], $defaults['booking_form_custom_background_color'] ), |
| 519 |
'booking_form_custom_border_color' => wpbc_bfb_settings__sanitize_form_style_color( $values['booking_form_custom_border_color'], $defaults['booking_form_custom_border_color'] ), |
| 520 |
'booking_form_custom_border_width' => wpbc_bfb_settings__sanitize_form_style_length( $values['booking_form_custom_border_width'], $defaults['booking_form_custom_border_width'] ), |
| 521 |
'booking_form_custom_border_radius' => wpbc_bfb_settings__sanitize_form_style_length( $values['booking_form_custom_border_radius'], $defaults['booking_form_custom_border_radius'] ), |
| 522 |
'booking_form_custom_padding_vertical' => wpbc_bfb_settings__sanitize_form_style_length( $values['booking_form_custom_padding_vertical'], $defaults['booking_form_custom_padding_vertical'] ), |
| 523 |
'booking_form_custom_padding_horizontal' => wpbc_bfb_settings__sanitize_form_style_length( $values['booking_form_custom_padding_horizontal'], $defaults['booking_form_custom_padding_horizontal'] ), |
| 524 |
'booking_form_custom_text_color' => wpbc_bfb_settings__sanitize_form_style_color( $values['booking_form_custom_text_color'], $defaults['booking_form_custom_text_color'] ), |
| 525 |
'booking_form_custom_field_background_color' => wpbc_bfb_settings__sanitize_form_style_color( $values['booking_form_custom_field_background_color'], $defaults['booking_form_custom_field_background_color'] ), |
| 526 |
'booking_form_custom_field_text_color' => wpbc_bfb_settings__sanitize_form_style_color( $values['booking_form_custom_field_text_color'], $defaults['booking_form_custom_field_text_color'] ), |
| 527 |
'booking_form_custom_field_border_color' => wpbc_bfb_settings__sanitize_form_style_color( $values['booking_form_custom_field_border_color'], $defaults['booking_form_custom_field_border_color'] ), |
| 528 |
'booking_form_custom_button_background_color' => wpbc_bfb_settings__sanitize_form_style_color( $values['booking_form_custom_button_background_color'], $defaults['booking_form_custom_button_background_color'] ), |
| 529 |
'booking_form_custom_button_text_color' => wpbc_bfb_settings__sanitize_form_style_color( $values['booking_form_custom_button_text_color'], $defaults['booking_form_custom_button_text_color'] ), |
| 530 |
'booking_form_custom_button_border_color' => wpbc_bfb_settings__sanitize_form_style_color( $values['booking_form_custom_button_border_color'], $defaults['booking_form_custom_button_border_color'] ), |
| 531 |
'booking_form_custom_button_hover_background_color' => wpbc_bfb_settings__sanitize_form_style_color( $values['booking_form_custom_button_hover_background_color'], $defaults['booking_form_custom_button_hover_background_color'] ), |
| 532 |
'booking_form_custom_button_hover_text_color' => wpbc_bfb_settings__sanitize_form_style_color( $values['booking_form_custom_button_hover_text_color'], $defaults['booking_form_custom_button_hover_text_color'] ), |
| 533 |
'booking_form_custom_button_hover_border_color' => wpbc_bfb_settings__sanitize_form_style_color( $values['booking_form_custom_button_hover_border_color'], $defaults['booking_form_custom_button_hover_border_color'] ), |
| 534 |
'booking_form_custom_secondary_button_background_color' => wpbc_bfb_settings__sanitize_form_style_color( $values['booking_form_custom_secondary_button_background_color'], $defaults['booking_form_custom_secondary_button_background_color'] ), |
| 535 |
'booking_form_custom_secondary_button_text_color' => wpbc_bfb_settings__sanitize_form_style_color( $values['booking_form_custom_secondary_button_text_color'], $defaults['booking_form_custom_secondary_button_text_color'] ), |
| 536 |
'booking_form_custom_secondary_button_border_color' => wpbc_bfb_settings__sanitize_form_style_color( $values['booking_form_custom_secondary_button_border_color'], $defaults['booking_form_custom_secondary_button_border_color'] ), |
| 537 |
'booking_form_custom_secondary_button_hover_background_color' => wpbc_bfb_settings__sanitize_form_style_color( $values['booking_form_custom_secondary_button_hover_background_color'], $defaults['booking_form_custom_secondary_button_hover_background_color'] ), |
| 538 |
'booking_form_custom_secondary_button_hover_text_color' => wpbc_bfb_settings__sanitize_form_style_color( $values['booking_form_custom_secondary_button_hover_text_color'], $defaults['booking_form_custom_secondary_button_hover_text_color'] ), |
| 539 |
'booking_form_custom_secondary_button_hover_border_color' => wpbc_bfb_settings__sanitize_form_style_color( $values['booking_form_custom_secondary_button_hover_border_color'], $defaults['booking_form_custom_secondary_button_hover_border_color'] ), |
| 540 |
); |
| 541 |
} |
| 542 |
|
| 543 |
/** |
| 544 |
* Resolve a global form style into CSS variables. |
| 545 |
* |
| 546 |
* @param string $style Form style key. |
| 547 |
* @param array $custom_options Optional custom style overrides. |
| 548 |
* @return array |
| 549 |
*/ |
| 550 |
function wpbc_bfb_settings__get_form_style_css_vars( $style = '', $custom_options = array() ) { |
| 551 |
|
| 552 |
$style = ( '' === (string) $style ) ? wpbc_bfb_settings__get_current_form_style() : wpbc_bfb_settings__sanitize_form_style( $style ); |
| 553 |
$preset = wpbc_bfb_settings__get_form_style_preset( $style ); |
| 554 |
|
| 555 |
if ( empty( $preset['custom'] ) ) { |
| 556 |
return isset( $preset['css_vars'] ) && is_array( $preset['css_vars'] ) ? $preset['css_vars'] : array(); |
| 557 |
} |
| 558 |
|
| 559 |
$custom = wpbc_bfb_settings__get_custom_form_style_options( $custom_options ); |
| 560 |
|
| 561 |
return array( |
| 562 |
'--wpbc-bfb-form-background' => $custom['booking_form_custom_background_color'], |
| 563 |
'--wpbc-bfb-form-border-color' => $custom['booking_form_custom_border_color'], |
| 564 |
'--wpbc-bfb-form-border-width' => $custom['booking_form_custom_border_width'], |
| 565 |
'--wpbc-bfb-form-border-radius' => $custom['booking_form_custom_border_radius'], |
| 566 |
'--wpbc-bfb-form-padding' => $custom['booking_form_custom_padding_vertical'] . ' ' . $custom['booking_form_custom_padding_horizontal'], |
| 567 |
'--wpbc-bfb-form-box-shadow' => 'rgba(0, 0, 0, 0.05) 0px 2px 6px 0px', |
| 568 |
'--wpbc_form-label-color' => $custom['booking_form_custom_text_color'], |
| 569 |
'--wpbc_form-label-sublabel-color' => $custom['booking_form_custom_text_color'], |
| 570 |
'--wpbc_form-label-error-color' => '#d63637', |
| 571 |
'--wpbc_form-field-background-color' => $custom['booking_form_custom_field_background_color'], |
| 572 |
'--wpbc_form-field-menu-color' => $custom['booking_form_custom_field_background_color'], |
| 573 |
'--wpbc_form-field-text-color' => $custom['booking_form_custom_field_text_color'], |
| 574 |
'--wpbc_form-field-border-color' => $custom['booking_form_custom_field_border_color'], |
| 575 |
'--wpbc_form-field-border-color-spare' => $custom['booking_form_custom_field_border_color'], |
| 576 |
'--wpbc_form-field-focus-border-color' => '#066aab', |
| 577 |
'--wpbc_form-field-focus-shadow-color' => '#066aab', |
| 578 |
'--wpbc_form-field-disabled-color' => 'rgba(0, 0, 0, 0.2)', |
| 579 |
'--wpbc_form-button-background-color' => $custom['booking_form_custom_button_background_color'], |
| 580 |
'--wpbc_form-button-background-color-alt' => $custom['booking_form_custom_button_background_color'], |
| 581 |
'--wpbc_form-button-border-color' => $custom['booking_form_custom_button_border_color'], |
| 582 |
'--wpbc_form-button-text-color' => $custom['booking_form_custom_button_text_color'], |
| 583 |
'--wpbc_form-button-text-color-alt' => $custom['booking_form_custom_button_text_color'], |
| 584 |
'--wpbc_form-button-hover-background-color' => $custom['booking_form_custom_button_hover_background_color'], |
| 585 |
'--wpbc_form-button-hover-border-color' => $custom['booking_form_custom_button_hover_border_color'], |
| 586 |
'--wpbc_form-button-hover-text-color' => $custom['booking_form_custom_button_hover_text_color'], |
| 587 |
'--wpbc_form-choice-checked-border-color' => '#066aab', |
| 588 |
'--wpbc_form-choice-checked-color' => '#066aab', |
| 589 |
'--wpbc_form-choice-focus-color' => '#066aab', |
| 590 |
'--wpbc_form-button-light-background-color' => $custom['booking_form_custom_secondary_button_background_color'], |
| 591 |
'--wpbc_form-button-light-border-color' => $custom['booking_form_custom_secondary_button_border_color'], |
| 592 |
'--wpbc_form-button-light-text-color' => $custom['booking_form_custom_secondary_button_text_color'], |
| 593 |
'--wpbc_form-button-light-box-shadow' => '0 2px 10px 2px #ffffff54', |
| 594 |
'--wpbc_form-button-light-hover-background-color' => $custom['booking_form_custom_secondary_button_hover_background_color'], |
| 595 |
'--wpbc_form-button-light-hover-border-color' => $custom['booking_form_custom_secondary_button_hover_border_color'], |
| 596 |
'--wpbc_form-button-light-hover-text-color' => $custom['booking_form_custom_secondary_button_hover_text_color'], |
| 597 |
'--wpbc_form-button-light-hover-box-shadow' => '0 2px 10px 2px #ffffff54', |
| 598 |
'--wpbc_form-button-primary-hover-border-color' => $custom['booking_form_custom_button_hover_border_color'], |
| 599 |
'--wpbc_form-page-break-color' => '#066aab', |
| 600 |
); |
| 601 |
} |
| 602 |
|
| 603 |
/** |
| 604 |
* Get form/settings JSON keys that belong to the global Form Style feature. |
| 605 |
* |
| 606 |
* These values are stored as global options. They must not be persisted inside |
| 607 |
* individual Builder form settings_json records. |
| 608 |
* |
| 609 |
* @return array |
| 610 |
*/ |
| 611 |
function wpbc_bfb_settings__get_form_json_style_option_keys() { |
| 612 |
|
| 613 |
return array( |
| 614 |
// New global Form Style model. |
| 615 |
'booking_form_style', |
| 616 |
'booking_form_custom_background_color', |
| 617 |
'booking_form_custom_border_color', |
| 618 |
'booking_form_custom_border_width', |
| 619 |
'booking_form_custom_border_radius', |
| 620 |
'booking_form_custom_padding_vertical', |
| 621 |
'booking_form_custom_padding_horizontal', |
| 622 |
'booking_form_custom_text_color', |
| 623 |
'booking_form_custom_field_background_color', |
| 624 |
'booking_form_custom_field_text_color', |
| 625 |
'booking_form_custom_field_border_color', |
| 626 |
'booking_form_custom_button_background_color', |
| 627 |
'booking_form_custom_button_text_color', |
| 628 |
'booking_form_custom_button_border_color', |
| 629 |
'booking_form_custom_button_hover_background_color', |
| 630 |
'booking_form_custom_button_hover_text_color', |
| 631 |
'booking_form_custom_button_hover_border_color', |
| 632 |
'booking_form_custom_secondary_button_background_color', |
| 633 |
'booking_form_custom_secondary_button_text_color', |
| 634 |
'booking_form_custom_secondary_button_border_color', |
| 635 |
'booking_form_custom_secondary_button_hover_background_color', |
| 636 |
'booking_form_custom_secondary_button_hover_text_color', |
| 637 |
'booking_form_custom_secondary_button_hover_border_color', |
| 638 |
|
| 639 |
// Retired per-form appearance model from the unreleased 11.4 work. |
| 640 |
'booking_form_theme', |
| 641 |
'booking_form_container_style', |
| 642 |
'booking_form_background_color', |
| 643 |
'booking_form_border_color', |
| 644 |
'booking_form_border_width', |
| 645 |
'booking_form_border_radius', |
| 646 |
'booking_form_padding', |
| 647 |
'booking_form_text_color', |
| 648 |
'booking_form_field_background_color', |
| 649 |
'booking_form_field_text_color', |
| 650 |
'booking_form_field_border_color', |
| 651 |
); |
| 652 |
} |
| 653 |
|
| 654 |
/** |
| 655 |
* Remove global/retired Form Style keys from a form settings pack. |
| 656 |
* |
| 657 |
* @param array $settings Settings pack. |
| 658 |
* @return array |
| 659 |
*/ |
| 660 |
function wpbc_bfb_settings__strip_form_style_options_from_form_settings( $settings ) { |
| 661 |
|
| 662 |
if ( ! is_array( $settings ) ) { |
| 663 |
return array(); |
| 664 |
} |
| 665 |
|
| 666 |
if ( empty( $settings['options'] ) || ! is_array( $settings['options'] ) ) { |
| 667 |
return $settings; |
| 668 |
} |
| 669 |
|
| 670 |
foreach ( wpbc_bfb_settings__get_form_json_style_option_keys() as $key ) { |
| 671 |
unset( $settings['options'][ $key ] ); |
| 672 |
} |
| 673 |
|
| 674 |
return $settings; |
| 675 |
} |
| 676 |
|