| @@ -4,8 +4,9 @@ | ||
| 4 | 4 | |
| 5 | 5 | use FluentCart\Framework\Foundation\RequestGuard; |
| 6 | 6 | use FluentCart\Framework\Support\Arr; |
| 7 | 7 | use FluentCart\App\Services\Permission\PermissionManager; |
| 8 | +use FluentCart\App\Services\Theme\ColorPalette; | |
| 8 | 9 | |
| 9 | 10 | class FluentMetaRequest extends RequestGuard |
| 10 | 11 | { |
| 11 | 12 | |
| @@ -92,8 +93,11 @@ | ||
| 92 | 93 | 'show_cart_icon_in_body' => 'sanitize_text_field', |
| 93 | 94 | 'additional_address_field' => 'sanitize_text_field', |
| 94 | 95 | 'hide_coupon_field' => 'sanitize_text_field', |
| 95 | 96 | 'user_account_creation_mode' => 'sanitize_text_field', |
| 97 | + 'auto_login_after_account_creation' => function ($value) { | |
| 98 | + return $value === 'yes' ? 'yes' : 'no'; | |
| 99 | + }, | |
| 96 | 100 | 'force_ssl' => 'sanitize_text_field', |
| 97 | 101 | 'checkout_page_id' => 'intval', |
| 98 | 102 | 'custom_payment_page_id' => 'intval', |
| 99 | 103 | 'cart_page_id' => 'intval', |
| @@ -115,9 +119,26 @@ | ||
| 115 | 119 | 'template_settings_checkout_page_mode' => 'sanitize_text_field', |
| 116 | 120 | 'show_relevant_product_in_single_page' => 'sanitize_text_field', |
| 117 | 121 | 'show_relevant_product_in_modal' => 'sanitize_text_field', |
| 118 | 122 | 'enable_early_payment_for_installment' => 'sanitize_text_field', |
| 123 | + 'subscription_management_mode' => function ($value) { | |
| 124 | + $value = sanitize_text_field($value); | |
| 125 | + $allowed = ['gateway_managed', 'store_managed']; | |
| 126 | + return in_array($value, $allowed, true) ? $value : 'gateway_managed'; | |
| 127 | + }, | |
| 128 | + 'subscription_system_charge' => function ($value) { | |
| 129 | + $value = sanitize_text_field($value); | |
| 130 | + return in_array($value, ['yes', 'no'], true) ? $value : 'no'; | |
| 131 | + }, | |
| 132 | + 'subscription_manual_fallback' => function ($value) { | |
| 133 | + $value = sanitize_text_field($value); | |
| 134 | + return in_array($value, ['yes', 'no'], true) ? $value : 'no'; | |
| 135 | + }, | |
| 119 | 136 | 'order_mode' => 'sanitize_text_field', |
| 137 | + 'subscription_mode_guard' => function ($value) { | |
| 138 | + $value = sanitize_text_field($value); | |
| 139 | + return in_array($value, ['yes', 'no'], true) ? $value : 'yes'; | |
| 140 | + }, | |
| 120 | 141 | 'variation_view' => 'sanitize_text_field', |
| 121 | 142 | 'variation_columns' => 'sanitize_text_field', |
| 122 | 143 | 'modules_settings' => 'sanitize_text_field', |
| 123 | 144 | 'product_slug' => 'sanitize_text_field', |
| @@ -122,8 +143,16 @@ | ||
| 122 | 143 | 'modules_settings' => 'sanitize_text_field', |
| 123 | 144 | 'product_slug' => 'sanitize_text_field', |
| 124 | 145 | 'min_receipt_number' => 'sanitize_text_field', |
| 125 | 146 | 'inv_prefix' => 'sanitize_text_field', |
| 147 | + 'date_time_format_source' => function ($value) { | |
| 148 | + $value = sanitize_text_field($value); | |
| 149 | + return in_array($value, ['fluent_cart', 'wordpress'], true) ? $value : 'fluent_cart'; | |
| 150 | + }, | |
| 151 | + 'timezone_source' => function ($value) { | |
| 152 | + $value = sanitize_text_field($value); | |
| 153 | + return in_array($value, ['fluent_cart', 'wordpress'], true) ? $value : 'fluent_cart'; | |
| 154 | + }, | |
| 126 | 155 | 'weight_unit' => function ($value) { |
| 127 | 156 | if (!PermissionManager::hasPermission(['store/sensitive'])) { |
| 128 | 157 | $stored = get_option('fluent_cart_store_settings', []); |
| 129 | 158 | return $stored['weight_unit'] ?? 'kg'; |
| @@ -142,8 +171,37 @@ | ||
| 142 | 171 | return in_array($value, $allowed, true) ? $value : 'cm'; |
| 143 | 172 | }, |
| 144 | 173 | 'enable_image_zoom_in_single_product' => 'sanitize_text_field', |
| 145 | 174 | 'enable_image_zoom_in_modal' => 'sanitize_text_field', |
| 175 | + 'appearance_source' => function ($value) { | |
| 176 | + $value = sanitize_text_field($value); | |
| 177 | + | |
| 178 | + return in_array($value, ColorPalette::sources(), true) | |
| 179 | + ? $value | |
| 180 | + : ColorPalette::SOURCE_DEFAULT; | |
| 181 | + }, | |
| 182 | + 'appearance_colors' => function ($value) { | |
| 183 | + if (!is_array($value)) { | |
| 184 | + return []; | |
| 185 | + } | |
| 186 | + | |
| 187 | + // Driven off the registry rather than the submitted keys, so an | |
| 188 | + // unknown property can never reach the storefront stylesheet. | |
| 189 | + $colors = []; | |
| 190 | + | |
| 191 | + foreach (ColorPalette::globals() as $key => $definition) { | |
| 192 | + $hex = sanitize_hex_color((string)Arr::get($value, $key, '')); | |
| 193 | + | |
| 194 | + // sanitize_hex_color() returns null for anything malformed | |
| 195 | + // and '' for an empty picker; both mean "not set", which is | |
| 196 | + // how a colour falls back to FluentCart's own default. | |
| 197 | + if ($hex) { | |
| 198 | + $colors[$key] = $hex; | |
| 199 | + } | |
| 200 | + } | |
| 201 | + | |
| 202 | + return $colors; | |
| 203 | + }, | |
| 146 | 204 | 'theme_setup' => function ($value) { |
| 147 | 205 | if (!is_array($value)) { |
| 148 | 206 | return []; |
| 149 | 207 | } |