GlobalStyleRequest.php
1 week ago
PageDataRequest.php
1 week ago
PageRequest.php
1 week ago
PageSettingsRequest.php
1 week ago
PageUpdateRequest.php
1 week ago
PopupRequest.php
1 week ago
RenameStagingVersionRequest.php
1 week ago
StagingVersionRequest.php
1 week ago
TogglePageSymbolRequest.php
1 month ago
GlobalStyleRequest.php
40 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Kirki\App\Http\Requests\Page; |
| 4 | |
| 5 | use function Kirki\App\ensure_array; |
| 6 | |
| 7 | defined('ABSPATH') || exit; |
| 8 | |
| 9 | use Kirki\Framework\Http\Request; |
| 10 | use Kirki\Framework\Sanitizer; |
| 11 | |
| 12 | use function Kirki\App\is_falsy; |
| 13 | |
| 14 | class GlobalStyleRequest extends Request |
| 15 | { |
| 16 | protected function prepare_for_validation() |
| 17 | { |
| 18 | $this->merge([ |
| 19 | 'styles' => ensure_array($this->styles), |
| 20 | ]); |
| 21 | } |
| 22 | |
| 23 | public function rules() |
| 24 | { |
| 25 | return [ |
| 26 | 'session_id' => 'required|string', |
| 27 | 'styles' => 'nullable|array', |
| 28 | 'styles.*' => 'nullable|array', |
| 29 | 'styles.*.isGlobalStyle' => ['required', fn($value) => is_falsy($value) ? __('The isGlobalStyle field is required.', 'kirki') : true], |
| 30 | ]; |
| 31 | } |
| 32 | |
| 33 | public function filters() |
| 34 | { |
| 35 | return [ |
| 36 | 'session_id' => Sanitizer::TEXT, |
| 37 | 'styles' => Sanitizer::ARRAY , |
| 38 | ]; |
| 39 | } |
| 40 | } |