PluginProbe ʕ •ᴥ•ʔ
Kirki – Freeform Page Builder, Website Builder & Customizer / 6.0.13
Kirki – Freeform Page Builder, Website Builder & Customizer v6.0.13
6.1.1 6.1.0 6.0.14 6.0.13 6.0.12 6.0.11 6.0.10 6.0.9 6.0.8 6.0.7 6.0.6 6.0.5 6.0.4 6.0.3 6.0.2 6.0.1 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 4.0.19 4.0.20 4.0.21 4.0.22 4.0.23 4.0.24 4.1 4.2.0 5.0.0 5.1.0 5.1.1 5.2.0 5.2.1 5.2.2 5.2.3 6.0.0 trunk 3.0.40 3.0.41 3.0.42 3.0.43 3.0.44 3.0.45 3.1.0 3.1.1 3.1.2
kirki / app / Http / Requests / Collection / CollectionStoreRequest.php
kirki / app / Http / Requests / Collection Last commit date
CollectionStoreRequest.php 3 weeks ago
CollectionStoreRequest.php
71 lines
1 <?php
2
3 namespace Kirki\App\Http\Requests\Collection;
4
5 use Kirki\App\Constants\Collection\CustomFieldTypes;
6 use Kirki\Framework\Http\Request;
7 use Kirki\Framework\Sanitizer;
8
9 class CollectionStoreRequest extends Request
10 {
11 /**
12 * Prepare data for validation.
13 */
14 protected function prepare_for_validation()
15 {
16 $data = $this->get('data');
17
18 if (is_string($data)) {
19 $data = json_decode($data, true);
20 }
21
22 if (is_array($data)) {
23 $this->merge($data);
24 }
25 }
26
27 /**
28 * Validation rules.
29 */
30 public function rules()
31 {
32 return [
33 'ID' => 'nullable',
34 'post_title' => 'required|string',
35 'post_name' => 'nullable|string',
36
37 'fields' => 'nullable|array',
38 'fields.*.id' => 'required|string',
39 'fields.*.kind' => 'required|string|in:custom',
40 'fields.*.type' => 'required|string|in:' . CustomFieldTypes::join(),
41 'fields.*.title' => 'required|string',
42 'fields.*.help_text' => 'nullable|string',
43 'fields.*.required' => 'required|boolean',
44
45 'basic_fields' => 'nullable|array',
46 ];
47 }
48
49 /**
50 * Sanitization filters.
51 */
52 public function filters()
53 {
54 return [
55 'ID' => Sanitizer::INT,
56 'post_title' => Sanitizer::TEXT,
57 'post_name' => Sanitizer::TEXT,
58
59 'fields' => Sanitizer::ARRAY ,
60 'fields.*.id' => Sanitizer::TEXT,
61 'fields.*.kind' => Sanitizer::TEXT,
62 'fields.*.type' => Sanitizer::TEXT,
63 'fields.*.title' => Sanitizer::TEXT,
64 'fields.*.help_text' => Sanitizer::TEXT,
65 'fields.*.required' => Sanitizer::BOOL,
66
67 'basic_fields' => Sanitizer::ARRAY ,
68 ];
69 }
70 }
71