| @@ -7,8 +7,9 @@ | ||
| 7 | 7 | } |
| 8 | 8 | |
| 9 | 9 | use ABlocks\Classes\AbstractAjaxHandler; |
| 10 | 10 | use ABlocks\Classes\Sanitizer; |
| 11 | +use ABlocks\Classes\Breakpoints; | |
| 11 | 12 | use ABlocks\Helper; |
| 12 | 13 | use ABlocks\Admin\Settings\Base as BaseSettings; |
| 13 | 14 | use ABlocks\Permissions\SettingsGuard; |
| 14 | 15 | |
| @@ -88,8 +89,13 @@ | ||
| 88 | 89 | // Editor paste |
| 89 | 90 | 'paste_google_docs' => 'boolean', |
| 90 | 91 | 'paste_convert_webp' => 'boolean', |
| 91 | 92 | 'paste_webp_quality' => 'integer', |
| 93 | + // Responsive breakpoints | |
| 94 | + 'breakpoint_tablet' => 'integer', | |
| 95 | + 'breakpoint_mobile' => 'integer', | |
| 96 | + 'breakpoint_mode' => 'string', | |
| 97 | + 'breakpoint_custom' => 'json', | |
| 92 | 98 | // Performance Suite — full-page cache. |
| 93 | 99 | 'perf_page_cache' => 'boolean', |
| 94 | 100 | 'perf_page_cache_scope' => 'string', |
| 95 | 101 | 'perf_page_cache_ttl' => 'integer', |
| @@ -309,8 +315,9 @@ | ||
| 309 | 315 | 'global_h3_typography' => 'json', |
| 310 | 316 | 'global_h4_typography' => 'json', |
| 311 | 317 | 'global_h5_typography' => 'json', |
| 312 | 318 | 'global_h6_typography' => 'json', |
| 319 | + 'breakpoint_custom' => 'json', | |
| 313 | 320 | ], $_POST ); // phpcs:ignore WordPress.Security.NonceVerification.Missing |
| 314 | 321 | |
| 315 | 322 | // The JSON fields are read straight from $_POST rather than the sanitized |
| 316 | 323 | // payload, so they need the same guard — the global colour and typography |
| @@ -316,10 +323,25 @@ | ||
| 316 | 323 | // payload, so they need the same guard — the global colour and typography |
| 317 | 324 | // presets live in here, and they are the design system. |
| 318 | 325 | $json_payload = SettingsGuard::filter_payload( $json_payload ); |
| 319 | 326 | |
| 327 | + // Breakpoints are only written when the request carries them, so a save | |
| 328 | + // that omits them keeps the stored list rather than resetting it. | |
| 329 | + $breakpoints = []; | |
| 330 | + foreach ( [ 'breakpoint_tablet', 'breakpoint_mobile' ] as $key ) { | |
| 331 | + if ( isset( $payload[ $key ] ) && $payload[ $key ] > 0 ) { | |
| 332 | + $breakpoints[ $key ] = $payload[ $key ]; | |
| 333 | + } | |
| 334 | + } | |
| 335 | + if ( isset( $payload['breakpoint_mode'] ) ) { | |
| 336 | + $breakpoints['breakpoint_mode'] = 'strict' === $payload['breakpoint_mode'] ? 'strict' : 'cascade'; | |
| 337 | + } | |
| 338 | + if ( isset( $json_payload['breakpoint_custom'] ) && is_array( $json_payload['breakpoint_custom'] ) ) { | |
| 339 | + $breakpoints['breakpoint_custom'] = Breakpoints::sanitize( $json_payload['breakpoint_custom'] ); | |
| 340 | + } | |
| 341 | + | |
| 320 | 342 | $default = BaseSettings::get_default_data(); |
| 321 | - $is_update = BaseSettings::save_settings( [ | |
| 343 | + $is_update = BaseSettings::save_settings( $breakpoints + [ | |
| 322 | 344 | 'default_container_width' => $payload['default_container_width'] ?? $default['default_container_width'], |
| 323 | 345 | 'container_padding' => $payload['container_padding'] ?? $default['container_padding'], |
| 324 | 346 | 'container_element_gap' => $payload['container_element_gap'] ?? $default['container_element_gap'], |
| 325 | 347 | 'enabled_assets_file_generation' => $payload['enabled_assets_file_generation'] ?? $default['enabled_assets_file_generation'], |