PluginProbe ʕ •ᴥ•ʔ
Kirki – Freeform Page Builder, Website Builder & Customizer / 6.2.4
Kirki – Freeform Page Builder, Website Builder & Customizer v6.2.4
6.2.5 6.2.4 6.2.3 6.2.2 6.2.1 6.2.0 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 / Page / PageRequest.php
kirki / app / Http / Requests / Page Last commit date
GlobalStyleRequest.php 1 month ago PageDataRequest.php 1 month ago PageRequest.php 1 month ago PageSettingsRequest.php 1 month ago PageUpdateRequest.php 1 month ago PopupRequest.php 1 month ago RenameStagingVersionRequest.php 1 month ago StagingVersionRequest.php 1 month ago TogglePageSymbolRequest.php 1 month ago
PageRequest.php
78 lines
1 <?php
2
3 namespace Kirki\App\Http\Requests\Page;
4
5 defined('ABSPATH') || exit;
6
7 use Kirki\App\Constants\PostTypes;
8 use Kirki\App\Constants\UtilityPageType;
9 use Kirki\App\Services\UtilityPageService;
10 use Kirki\Framework\Http\Request;
11 use Kirki\Framework\Sanitizer;
12
13 use function Kirki\App\ensure_array;
14
15 class PageRequest extends Request
16 {
17 protected function prepare_for_validation()
18 {
19 $this->merge([
20 'blocks' => ensure_array($this->blocks),
21 'conditions' => ensure_array($this->conditions),
22 'custom_template' => ensure_array($this->custom_template),
23 ]);
24 }
25
26 public function rules()
27 {
28 return [
29 'post_title' => 'required|string',
30 'post_type' => 'required|string',
31 'blocks' => 'nullable|array',
32 'conditions' => 'nullable|array',
33 'collection_type' => 'nullable|string',
34 'utility_page_type' => [
35 'nullable',
36 'string',
37 'in:' . UtilityPageType::join(),
38 function ($value) {
39 if ($this->post_type === PostTypes::UTILITY) {
40 if (empty($value)) {
41 return __("Utility page type is required.", 'kirki');
42 }
43
44 $exists = UtilityPageService::create()->exists($value);
45
46 if ($exists) {
47 /** translators: %s: Utility page type */
48 return sprintf(__("Utility page of type %s already exists."), $value);
49 }
50 }
51
52 return true;
53 }
54 ],
55 'custom_template' => 'nullable|array',
56 'custom_template.url' => 'nullable|url',
57 'content_manager_collection_id' => 'nullable|integer',
58 'content_manager_page_kind' => 'nullable|string|in:index,details',
59 ];
60 }
61
62 public function filters()
63 {
64 return [
65 'post_title' => Sanitizer::TEXT,
66 'post_type' => Sanitizer::TEXT,
67 'blocks' => Sanitizer::ARRAY,
68 'conditions' => Sanitizer::ARRAY,
69 'collection_type' => Sanitizer::TEXT,
70 'utility_page_type' => Sanitizer::TEXT,
71 'custom_template' => Sanitizer::ARRAY,
72 'custom_template.url' => Sanitizer::URL,
73 'content_manager_collection_id' => Sanitizer::INT,
74 'content_manager_page_kind' => Sanitizer::TEXT,
75 ];
76 }
77 }
78